mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0024133: Development of improvement of dimensions implementation; new length, radius,diameter and angle dimensions.
Some corrections; test cases were added; coding standards in MFC samples & presentations Request stencil buffer for Linux. correct test cases; correct compilation errors compilation warnings (gcc/Linux)
This commit is contained in:
133
samples/mfc/standard/Common/RadiusParamsPage.cpp
Normal file
133
samples/mfc/standard/Common/RadiusParamsPage.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "RadiusParamsPage.h"
|
||||
#include "DimensionDlg.h"
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <AIS_RadiusDimension.hxx>
|
||||
#include <AIS_DiameterDimension.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
IMPLEMENT_DYNAMIC(CRadiusParamsPage, CDialog)
|
||||
|
||||
//=======================================================================
|
||||
//function : CRadiusParamsPage
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CRadiusParamsPage::CRadiusParamsPage (const Handle(AIS_InteractiveContext)& theAISContext,
|
||||
const Standard_Boolean isDiameterDimension /* =Standard_False*/,
|
||||
CWnd* pParent /*=NULL*/)
|
||||
: CDialog (CRadiusParamsPage::IDD, pParent)
|
||||
{
|
||||
myAISContext = theAISContext;
|
||||
myIsDiameterDimension = isDiameterDimension;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ~CRadiusParamsPage
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CRadiusParamsPage::~CRadiusParamsPage()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DoDataExchange
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CRadiusParamsPage::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CRadiusParamsPage, CDialog)
|
||||
ON_BN_CLICKED(IDC_BUTTON1, &CRadiusParamsPage::OnBnClickedObjectBtn)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
//=======================================================================
|
||||
//function : OnBnClickedObjectBtn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CRadiusParamsPage::OnBnClickedObjectBtn()
|
||||
{
|
||||
//Build dimension here
|
||||
myAISContext->LocalContext()->InitSelected();
|
||||
if (!myAISContext->LocalContext()->MoreSelected())
|
||||
{
|
||||
AfxMessageBox (_T ("Choose the edge and press the button again"), MB_ICONINFORMATION | MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
gp_Circ aCircle;
|
||||
Standard_Boolean isAttachPoint = Standard_False;
|
||||
Standard_Real aFirstPar = 0, aLastPar = 0;
|
||||
|
||||
TopoDS_Shape aSelShape = myAISContext->LocalContext()->SelectedShape();
|
||||
if (aSelShape.ShapeType() != TopAbs_EDGE &&
|
||||
aSelShape.ShapeType() != TopAbs_FACE &&
|
||||
aSelShape.ShapeType() != TopAbs_WIRE)
|
||||
return;
|
||||
|
||||
if (aSelShape.ShapeType() == TopAbs_EDGE)
|
||||
{
|
||||
BRepAdaptor_Curve aCurve (TopoDS::Edge (aSelShape));
|
||||
if (aCurve.GetType() != GeomAbs_Circle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
aCircle = aCurve.Circle();
|
||||
if (aCurve.FirstParameter() != 0 && aCurve.LastParameter() != M_PI * 2)
|
||||
{
|
||||
isAttachPoint = Standard_True;
|
||||
aFirstPar = aCurve.FirstParameter();
|
||||
aLastPar = aCurve.LastParameter();
|
||||
}
|
||||
}
|
||||
|
||||
myAISContext->LocalContext()->ClearSelected();
|
||||
CDimensionDlg *aDimDlg = (CDimensionDlg*)(this->GetParentOwner());
|
||||
// Try to create dimension if it is possible
|
||||
Handle(AIS_Dimension) aDim;
|
||||
if (myIsDiameterDimension)
|
||||
{
|
||||
aDim = isAttachPoint ? new AIS_DiameterDimension (aCircle, ElCLib::Value ((aFirstPar + aLastPar) / 2.0, aCircle))
|
||||
: new AIS_DiameterDimension (aCircle);
|
||||
Handle(AIS_DiameterDimension)::DownCast(aDim)->SetFlyout (aDimDlg->GetFlyout());
|
||||
}
|
||||
else
|
||||
{
|
||||
aDim = isAttachPoint ? new AIS_RadiusDimension (aCircle, ElCLib::Value ((aFirstPar + aLastPar) / 2.0, aCircle))
|
||||
: new AIS_RadiusDimension (aCircle);
|
||||
Handle(AIS_RadiusDimension)::DownCast(aDim)->SetFlyout (aDimDlg->GetFlyout());
|
||||
}
|
||||
|
||||
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
|
||||
anAspect->MakeArrows3d (Standard_False);
|
||||
anAspect->MakeText3d (aDimDlg->GetTextType());
|
||||
anAspect->TextAspect()->SetHeight (aDimDlg->GetFontHeight());
|
||||
anAspect->MakeTextShaded (aDimDlg->IsText3dShaded());
|
||||
anAspect->SetCommonColor (aDimDlg->GetDimensionColor());
|
||||
aDim->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed());
|
||||
if (aDim->IsUnitsDisplayed())
|
||||
{
|
||||
aDim->SetDisplayUnits (aDimDlg->GetUnits());
|
||||
}
|
||||
|
||||
aDim->SetDimensionAspect (anAspect);
|
||||
|
||||
// Display dimension in the neutral point
|
||||
myAISContext->CloseAllContexts();
|
||||
|
||||
myAISContext->Display (aDim);
|
||||
|
||||
myAISContext->OpenLocalContext();
|
||||
myAISContext->ActivateStandardMode (TopAbs_EDGE);
|
||||
}
|
Reference in New Issue
Block a user