0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / samples / mfc / standard / Common / LengthParamsVerticesPage.cpp
CommitLineData
a6eb515f 1// LengthParamsVerticesPage.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "LengthParamsVerticesPage.h"
6#include "DimensionDlg.h"
7#include <Standard_Macro.hxx>
8#include <AIS_InteractiveContext.hxx>
787ff240 9#include <PrsDim_LengthDimension.hxx>
a6eb515f 10#include <GC_MakePlane.hxx>
11
12
13// CLengthParamsVerticesPage dialog
14
15IMPLEMENT_DYNAMIC(CLengthParamsVerticesPage, CDialog)
16
17//=======================================================================
18//function : CLengthParamsVerticesPage
19//purpose :
20//=======================================================================
21
22CLengthParamsVerticesPage::CLengthParamsVerticesPage (Handle(AIS_InteractiveContext) theAISContext, CWnd* pParent /*=NULL*/)
23: CDialog (CLengthParamsVerticesPage::IDD, pParent)
24{
25 myAISContext = theAISContext;
26}
27
28//=======================================================================
29//function : ~CLengthParamsVerticesPage
30//purpose :
31//=======================================================================
32
33CLengthParamsVerticesPage::~CLengthParamsVerticesPage()
34{
35}
36
37//=======================================================================
38//function : DoDataExchange
39//purpose :
40//=======================================================================
41
42void CLengthParamsVerticesPage::DoDataExchange (CDataExchange* pDX)
43{
44 CDialog::DoDataExchange (pDX);
45}
46
47
48BEGIN_MESSAGE_MAP(CLengthParamsVerticesPage, CDialog)
49 ON_BN_CLICKED(IDC_BUTTON1, &CLengthParamsVerticesPage::OnBnClickedVertex1Btn)
50 ON_BN_CLICKED(IDC_BUTTON2, &CLengthParamsVerticesPage::OnBnClickedVertex2Btn)
51END_MESSAGE_MAP()
52
53
54//=======================================================================
55//function : OnBnClickedVertex1Btn
56//purpose :
57//=======================================================================
58
59void CLengthParamsVerticesPage::OnBnClickedVertex1Btn()
60{
404c8936 61 myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX));
a6eb515f 62
404c8936 63 // Now it's ok, edge selection mode is activated
a6eb515f 64 // Check if some edge is selected
404c8936 65 myAISContext->InitSelected();
66 if (!myAISContext->MoreSelected() ||
71c089e9 67 myAISContext->SelectedShape().ShapeType() != TopAbs_VERTEX)
a6eb515f 68 {
69 AfxMessageBox (_T ("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK);
70 return;
71 }
72
404c8936 73 myFirstVertex = TopoDS::Vertex (myAISContext->SelectedShape());
a6eb515f 74
0577ae8c 75 myAISContext->ClearSelected (Standard_True);
a6eb515f 76}
77
78//=======================================================================
79//function : OnBnClickedVertex2Btn
80//purpose :
81//=======================================================================
82
83void CLengthParamsVerticesPage::OnBnClickedVertex2Btn()
84{
404c8936 85 myAISContext->InitSelected();
86 if (!myAISContext->MoreSelected() ||
71c089e9 87 myAISContext->SelectedShape().ShapeType() != TopAbs_VERTEX)
a6eb515f 88 {
89 AfxMessageBox (_T ("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK);
90 return;
91 }
92
404c8936 93 mySecondVertex = TopoDS::Vertex (myAISContext->SelectedShape());
0577ae8c 94 myAISContext->ClearSelected (Standard_False);
a6eb515f 95
96 //Build dimension here
97 gp_Pnt aP1=BRep_Tool::Pnt (myFirstVertex);
98 gp_Pnt aP2=BRep_Tool::Pnt (mySecondVertex);
99 gp_Pnt aP3 (aP2.X() + 10, aP2.Y() + 10, aP2.Z() + 10);
100
101 GC_MakePlane aMkPlane (aP1,aP2,aP3);
102 Handle(Geom_Plane) aPlane = aMkPlane.Value();
103
104 CDimensionDlg *aDimDlg = (CDimensionDlg*)(this->GetParentOwner());
105
787ff240 106 Handle(PrsDim_LengthDimension) aLenDim = new PrsDim_LengthDimension (aP1, aP2, aPlane->Pln());
a6eb515f 107
108 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
109 anAspect->MakeArrows3d (Standard_False);
110 anAspect->MakeText3d (aDimDlg->GetTextType());
111 anAspect->TextAspect()->SetHeight (aDimDlg->GetFontHeight());
112 anAspect->MakeTextShaded (aDimDlg->IsText3dShaded());
47162471 113 anAspect->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed());
60bf98ae 114 if (aDimDlg->IsUnitsDisplayed())
a6eb515f 115 {
116 aLenDim->SetDisplayUnits (aDimDlg->GetUnits ());
117 }
118
119 aLenDim->SetDimensionAspect (anAspect);
120 aLenDim->SetFlyout (aDimDlg->GetFlyout());
121
0577ae8c 122 myAISContext->Display (aLenDim, Standard_True);
404c8936 123 myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX));
a6eb515f 124}
125
126//=======================================================================
127//function : getFirstVertex
128//purpose :
129//=======================================================================
130
131const TopoDS_Vertex& CLengthParamsVerticesPage::getFirstVertex() const
132{
133 return myFirstVertex;
134}
135
136//=======================================================================
137//function : getSecondVertex
138//purpose :
139//=======================================================================
140
141const TopoDS_Vertex& CLengthParamsVerticesPage::getSecondVertex() const
142{
143 return mySecondVertex;
144}