mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0024425: Improve usage ergonomics of new dimension presentations
- Added format for value string. - Construction and validness. - Revise modification of properties and update of presentations. - Units moved to Drawer; code revisions. - Length and angle initialization was changed. Type of geometry filed was added to AIS_Dimension. - Method for test case bugs/vis/buc60915 was corrected. Description of the dimension classes was corrected. - Fixed initialization of angle and length.
This commit is contained in:
120
samples/mfc/standard/Common/ParamsFacesPage.cpp
Normal file
120
samples/mfc/standard/Common/ParamsFacesPage.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
// ParamsFacesPage.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ParamsFacesPage.h"
|
||||
#include "DimensionDlg.h"
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <AIS_LengthDimension.hxx>
|
||||
#include <AIS_AngleDimension.hxx>
|
||||
|
||||
// CParamsFacesPage dialog
|
||||
|
||||
IMPLEMENT_DYNAMIC(CParamsFacesPage, CDialog)
|
||||
|
||||
CParamsFacesPage::CParamsFacesPage (Handle(AIS_InteractiveContext) theAISContext,
|
||||
bool isAngleDimension /*= false*/,
|
||||
CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CParamsFacesPage::IDD, pParent),
|
||||
myAISContext (theAISContext),
|
||||
myIsAngleDimension (isAngleDimension)
|
||||
{
|
||||
}
|
||||
|
||||
CParamsFacesPage::~CParamsFacesPage()
|
||||
{
|
||||
}
|
||||
|
||||
void CParamsFacesPage::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CParamsFacesPage, CDialog)
|
||||
ON_BN_CLICKED(IDC_FacesBtn1, &CParamsFacesPage::OnBnClickedFacesbtn1)
|
||||
ON_BN_CLICKED(IDC_FacesBtn2, &CParamsFacesPage::OnBnClickedFacesbtn2)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CParamsFacesPage message handlers
|
||||
|
||||
void CParamsFacesPage::OnBnClickedFacesbtn1()
|
||||
{
|
||||
// Check if face is selected
|
||||
myAISContext->LocalContext()->InitSelected();
|
||||
if (!myAISContext->LocalContext()->MoreSelected())
|
||||
{
|
||||
AfxMessageBox(_T("Choose the face and press the button again"),
|
||||
MB_ICONINFORMATION | MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
myFirstFace = TopoDS::Face (myAISContext->LocalContext()->SelectedShape());
|
||||
myAISContext->LocalContext()->ClearSelected();
|
||||
}
|
||||
|
||||
void CParamsFacesPage::OnBnClickedFacesbtn2()
|
||||
{
|
||||
// Check if face is selected
|
||||
myAISContext->LocalContext()->InitSelected();
|
||||
if (!myAISContext->LocalContext()->MoreSelected())
|
||||
{
|
||||
AfxMessageBox(_T("Choose the face and press the button again"),
|
||||
MB_ICONINFORMATION | MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
mySecondFace = TopoDS::Face (myAISContext->LocalContext()->SelectedShape());
|
||||
myAISContext->LocalContext()->ClearSelected();
|
||||
|
||||
CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner());
|
||||
|
||||
myAISContext->CloseAllContexts();
|
||||
|
||||
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());
|
||||
if (myIsAngleDimension)
|
||||
{
|
||||
// Build an angle dimension between two non-parallel edges
|
||||
Handle(AIS_AngleDimension) anAngleDim = new AIS_AngleDimension (myFirstFace, mySecondFace);
|
||||
anAngleDim->SetDimensionAspect (anAspect);
|
||||
anAngleDim->DimensionAspect()->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed());
|
||||
if (aDimDlg->IsUnitsDisplayed())
|
||||
{
|
||||
anAngleDim->SetDisplayUnits (aDimDlg->GetUnits ());
|
||||
if ((anAngleDim->GetDisplayUnits().IsEqual (TCollection_AsciiString ("deg"))))
|
||||
{
|
||||
anAngleDim->DimensionAspect()->MakeUnitsDisplayed (Standard_False);
|
||||
}
|
||||
else
|
||||
{
|
||||
anAngleDim->SetDisplaySpecialSymbol (AIS_DSS_No);
|
||||
}
|
||||
}
|
||||
|
||||
anAngleDim->SetFlyout (aDimDlg->GetFlyout());
|
||||
myAISContext->Display (anAngleDim);
|
||||
}
|
||||
else
|
||||
{
|
||||
Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (myFirstFace, mySecondFace);
|
||||
aLenDim->SetDimensionAspect (anAspect);
|
||||
aLenDim->DimensionAspect()->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed());
|
||||
if (aLenDim->DimensionAspect()->IsUnitsDisplayed())
|
||||
{
|
||||
aLenDim->SetFlyout (aDimDlg->GetFlyout());
|
||||
aLenDim->SetDisplayUnits (aDimDlg->GetUnits());
|
||||
}
|
||||
|
||||
myAISContext->Display (aLenDim);
|
||||
}
|
||||
|
||||
myAISContext->OpenLocalContext();
|
||||
myAISContext->ActivateStandardMode (TopAbs_FACE);
|
||||
}
|
Reference in New Issue
Block a user