]>
Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // ModelClippingDlg.cpp : implementation file |
2 | // | |
3 | ||
4 | #include "stdafx.h" | |
5 | #include "Viewer3dApp.h" | |
6 | #include "ModelClippingDlg.h" | |
7 | #include "Viewer3dDoc.h" | |
8 | #include "offsetdlg.h" // Added by ClassView | |
9 | ||
10 | #ifdef _DEBUG | |
11 | #define new DEBUG_NEW | |
12 | #undef THIS_FILE | |
13 | static char THIS_FILE[] = __FILE__; | |
14 | #endif | |
15 | ||
16 | ||
17 | ///////////////////////////////////////////////////////////////////////////// | |
18 | // CModelClippingDlg dialog | |
19 | ||
20 | ||
21 | CModelClippingDlg::CModelClippingDlg(Handle(V3d_View) aView, Handle(V3d_Plane) aPlane, | |
22 | Handle(AIS_Shape) aShape, CViewer3dDoc* pDoc, CWnd* pParent /*=NULL*/) | |
23 | : CDialog(CModelClippingDlg::IDD, pParent) | |
24 | { | |
25 | //{{AFX_DATA_INIT(CModelClippingDlg) | |
26 | m_ModelClipping_Z = 0.0; | |
27 | myView=aView; | |
28 | myPlane=aPlane; | |
29 | myShape=aShape; | |
30 | myDoc=pDoc; | |
31 | m_ModelClippingONOFF = FALSE; | |
32 | //}}AFX_DATA_INIT | |
33 | } | |
34 | ||
35 | ||
36 | void CModelClippingDlg::DoDataExchange(CDataExchange* pDX) | |
37 | { | |
38 | CDialog::DoDataExchange(pDX); | |
39 | //{{AFX_DATA_MAP(CModelClippingDlg) | |
40 | DDX_Control(pDX, IDC_SLIDER_MODELCLIPPING_Z, m_ModelClippingZSlidCtrl); | |
41 | DDX_Text(pDX, IDC_EDIT_MODELCLIPPING_Z, m_ModelClipping_Z); | |
42 | DDX_Check(pDX, IDC_CHECK_MODELCLIPPINGONOFF, m_ModelClippingONOFF); | |
43 | //}}AFX_DATA_MAP | |
44 | } | |
45 | ||
46 | ||
47 | BEGIN_MESSAGE_MAP(CModelClippingDlg, CDialog) | |
48 | //{{AFX_MSG_MAP(CModelClippingDlg) | |
49 | ON_WM_HSCROLL() | |
50 | ON_EN_CHANGE(IDC_EDIT_MODELCLIPPING_Z, OnChangeEditModelclippingZ) | |
51 | ON_BN_CLICKED(IDC_CHECK_MODELCLIPPINGONOFF, OnCheckModelclippingonoff) | |
52 | //}}AFX_MSG_MAP | |
53 | END_MESSAGE_MAP() | |
54 | ||
55 | ///////////////////////////////////////////////////////////////////////////// | |
56 | // CModelClippingDlg message handlers | |
57 | ||
58 | void CModelClippingDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) | |
59 | { | |
60 | UpdateData(TRUE); | |
61 | ||
62 | m_ModelClipping_Z = m_ModelClippingZSlidCtrl.GetPos(); | |
63 | ||
64 | UpdateData(FALSE); | |
65 | ||
66 | // Setting the ZClipping depth at m_ZClippingDepth value | |
67 | gp_Pln clipPln(gp_Pnt(-m_ModelClipping_Z,0,0),gp_Dir(1,0,0)); | |
68 | Standard_Real A,B,C,D; | |
69 | clipPln.Coefficients(A,B,C,D); | |
70 | myPlane->SetPlane(A,B,C,D); | |
71 | if(m_ModelClippingONOFF) | |
72 | myView->SetPlaneOn(myPlane); | |
73 | gp_Trsf myTrsf; | |
74 | myTrsf.SetTranslation(gp_Pnt(m_ModelClipping_Z,0,0), gp_Pnt(myModelClipping_Z,0,0)); | |
75 | myDoc->GetAISContext()->SetLocation(myShape,TopLoc_Location(myTrsf)) ; | |
76 | myDoc->GetAISContext()->Redisplay(myShape); | |
77 | myView->Update(); | |
78 | ||
79 | TCollection_AsciiString Message("\ | |
80 | gp_Pln clipPln(gp_Pnt(-m_ModelClippingZSlidCtrl.GetPos(),0,0),gp_Dir(1,0,0));\n\ | |
81 | Standard_Real A,B,C,D;\n\ | |
82 | clipPln.Coefficients(A,B,C,D);\n\ | |
83 | myPlane->SetPlane(A,B,C,D);\n\ | |
84 | myView->SetPlaneOn(myPlane); \n\ | |
85 | "); | |
86 | ||
87 | // Update The Result Message Dialog | |
88 | myDoc->UpdateResultMessageDlg("SetPlaneOn",Message); | |
89 | ||
90 | CDialog::OnHScroll(nSBCode, nPos, pScrollBar); | |
91 | } | |
92 | ||
93 | BOOL CModelClippingDlg::OnInitDialog() | |
94 | { | |
95 | CDialog::OnInitDialog(); | |
96 | ||
97 | Standard_Real A,B,C,D; | |
98 | myPlane->Plane(A,B,C,D); | |
99 | m_ModelClipping_Z = D; | |
100 | m_ModelClippingZSlidCtrl.SetRange(-750, 750, TRUE); | |
101 | m_ModelClippingZSlidCtrl.SetPos( (int) floor(m_ModelClipping_Z)); | |
102 | ||
103 | Handle(V3d_Plane) thePlane; | |
104 | for( myView->InitActivePlanes() ; | |
105 | myView->MoreActivePlanes() ; myView->NextActivePlanes() ) { | |
106 | thePlane = myView->ActivePlane() ; | |
107 | if( thePlane == myPlane ) m_ModelClippingONOFF = TRUE; | |
108 | } | |
109 | if(m_ModelClippingONOFF) | |
110 | if(!myShape.IsNull()) | |
111 | myDoc->GetAISContext()->Display(myShape); | |
112 | ||
113 | UpdateData(FALSE); | |
114 | ||
115 | return TRUE; // return TRUE unless you set the focus to a control | |
116 | // EXCEPTION: OCX Property Pages should return FALSE | |
117 | } //V3d_Plane.hxx | |
118 | ||
119 | void CModelClippingDlg::OnChangeEditModelclippingZ() | |
120 | { | |
121 | UpdateData(TRUE); | |
122 | ||
123 | // Setting the m_ZClippingDepthSlidCtrl position at floor(m_ZClippingDepth) value (because slider position is an integer) | |
124 | m_ModelClippingZSlidCtrl.SetPos( (int) floor(m_ModelClipping_Z)); | |
125 | // Setting the ZClipping depth at m_ZClippingDepth value | |
126 | gp_Pln clipPln(gp_Pnt(-m_ModelClipping_Z,0,0),gp_Dir(1,0,0)); | |
127 | Standard_Real A,B,C,D; | |
128 | clipPln.Coefficients(A,B,C,D); | |
129 | myPlane->SetPlane(A,B,C,D); | |
130 | if(m_ModelClippingONOFF) | |
131 | myView->SetPlaneOn(myPlane); | |
132 | gp_Trsf myTrsf; | |
133 | myTrsf.SetTranslation(gp_Pnt(m_ModelClipping_Z,0,0), gp_Pnt(myModelClipping_Z,0,0)); | |
134 | myDoc->GetAISContext()->SetLocation(myShape,TopLoc_Location(myTrsf)) ; | |
135 | myDoc->GetAISContext()->Redisplay(myShape); | |
136 | myView->Update(); | |
137 | ||
138 | myModelClipping_Z = m_ModelClipping_Z; | |
139 | ||
140 | TCollection_AsciiString Message("\ | |
141 | gp_Pln clipPln(gp_Pnt(-m_ModelClipping_Z,0,0),gp_Dir(1,0,0));\n\ | |
142 | Standard_Real A,B,C,D;\n\ | |
143 | clipPln.Coefficients(A,B,C,D);\n\ | |
144 | myPlane->SetPlane(A,B,C,D);\n\ | |
145 | myView->SetPlaneOn(myPlane); \n\ | |
146 | "); | |
147 | ||
148 | // Update The Result Message Dialog | |
149 | myDoc->UpdateResultMessageDlg("SetPlaneOn",Message); | |
150 | } | |
151 | ||
152 | void CModelClippingDlg::OnCheckModelclippingonoff() | |
153 | { | |
154 | UpdateData(TRUE); | |
155 | ||
156 | //activate the plane | |
157 | if(m_ModelClippingONOFF) | |
158 | { | |
159 | //activate the plane | |
160 | myView->SetPlaneOn(myPlane); | |
161 | myDoc->GetAISContext()->Display(myShape); | |
162 | } | |
163 | else | |
164 | //deactivate the plane | |
165 | { | |
166 | myView->SetPlaneOff(myPlane); | |
167 | myDoc->GetAISContext()->Erase(myShape); | |
168 | } | |
169 | ||
170 | myView->Update(); | |
171 | ||
172 | TCollection_AsciiString Message("\ | |
173 | gp_Pln clipPln(gp_Pnt(-m_ModelClippingZSlidCtrl.GetPos(),0,0),gp_Dir(1,0,0));\n\ | |
174 | Standard_Real A,B,C,D;\n\ | |
175 | clipPln.Coefficients(A,B,C,D);\n\ | |
176 | myPlane->SetPlane(A,B,C,D);\n\ | |
177 | if(m_ModelClippingONOFF) \n\ | |
178 | myView->SetPlaneOn(myPlane); \n\ | |
179 | else \n\ | |
180 | myView->SetPlaneOff(myPlane); \n\ | |
181 | "); | |
182 | ||
183 | // Update The Result Message Dialog | |
184 | myDoc->UpdateResultMessageDlg("SetPlaneOn",Message); | |
185 | } | |
186 | ||
187 | void CModelClippingDlg::OnCancel() | |
188 | { | |
189 | UpdateData(TRUE); | |
190 | if(m_ModelClippingONOFF) | |
191 | //deactivate the plane | |
192 | myView->SetPlaneOff(myPlane); | |
193 | ||
194 | m_ModelClippingONOFF=FALSE; | |
195 | ||
196 | if(!myShape.IsNull()) | |
197 | myDoc->GetAISContext()->Erase(myShape); | |
198 | ||
199 | myView->Update(); | |
200 | ||
201 | CDialog::OnCancel(); | |
202 | } | |
203 | ||
204 | void CModelClippingDlg::OnOK() | |
205 | { | |
206 | if(!myShape.IsNull()) | |
207 | myDoc->GetAISContext()->Erase(myShape); | |
208 | ||
209 | CDialog::OnOK(); | |
210 | } |