7fd59977 |
1 | // OCC_3dView.cpp: implementation of the OCC_3dView class. |
2 | // |
3 | |
4 | #include "stdafx.h" |
5 | |
6 | #include "OCC_3dView.h" |
7 | |
8 | #include "OCC_3dApp.h" |
9 | #include "OCC_3dBaseDoc.h" |
10 | #include <res\OCC_Resource.h> |
11 | |
12 | #include <Visual3d_View.hxx> |
13 | #include <Graphic3d_ExportFormat.hxx> |
14 | |
15 | #define ValZWMin 1 |
16 | |
17 | IMPLEMENT_DYNCREATE(OCC_3dView, CView) |
18 | |
19 | BEGIN_MESSAGE_MAP(OCC_3dView, CView) |
20 | //{{AFX_MSG_MAP(OCC_3dView) |
21 | ON_COMMAND(ID_BUTTONAxo, OnBUTTONAxo) |
22 | ON_COMMAND(ID_BUTTONBack, OnBUTTONBack) |
23 | ON_COMMAND(ID_BUTTONBottom, OnBUTTONBottom) |
24 | ON_COMMAND(ID_BUTTONFront, OnBUTTONFront) |
25 | ON_COMMAND(ID_BUTTONHlrOff, OnBUTTONHlrOff) |
26 | ON_COMMAND(ID_BUTTONHlrOn, OnBUTTONHlrOn) |
27 | ON_COMMAND(ID_BUTTONLeft, OnBUTTONLeft) |
28 | ON_COMMAND(ID_BUTTONPan, OnBUTTONPan) |
29 | ON_COMMAND(ID_BUTTONPanGlo, OnBUTTONPanGlo) |
30 | ON_COMMAND(ID_BUTTONReset, OnBUTTONReset) |
31 | ON_COMMAND(ID_BUTTONRight, OnBUTTONRight) |
32 | ON_COMMAND(ID_BUTTONRot, OnBUTTONRot) |
33 | ON_COMMAND(ID_BUTTONTop, OnBUTTONTop) |
34 | ON_COMMAND(ID_BUTTONZoomAll, OnBUTTONZoomAll) |
35 | ON_WM_SIZE() |
36 | ON_COMMAND(ID_FILE_EXPORT_IMAGE, OnFileExportImage) |
37 | ON_COMMAND(ID_BUTTONZoomProg, OnBUTTONZoomProg) |
38 | ON_COMMAND(ID_BUTTONZoomWin, OnBUTTONZoomWin) |
39 | ON_WM_LBUTTONDOWN() |
40 | ON_WM_LBUTTONUP() |
41 | ON_WM_MBUTTONDOWN() |
42 | ON_WM_MBUTTONUP() |
43 | ON_WM_MOUSEMOVE() |
44 | ON_WM_RBUTTONDOWN() |
45 | ON_WM_RBUTTONUP() |
46 | ON_UPDATE_COMMAND_UI(ID_BUTTONHlrOff, OnUpdateBUTTONHlrOff) |
47 | ON_UPDATE_COMMAND_UI(ID_BUTTONHlrOn, OnUpdateBUTTONHlrOn) |
48 | ON_UPDATE_COMMAND_UI(ID_BUTTONPanGlo, OnUpdateBUTTONPanGlo) |
49 | ON_UPDATE_COMMAND_UI(ID_BUTTONPan, OnUpdateBUTTONPan) |
50 | ON_UPDATE_COMMAND_UI(ID_BUTTONZoomProg, OnUpdateBUTTONZoomProg) |
51 | ON_UPDATE_COMMAND_UI(ID_BUTTONZoomWin, OnUpdateBUTTONZoomWin) |
52 | ON_UPDATE_COMMAND_UI(ID_BUTTONRot, OnUpdateBUTTONRot) |
53 | ON_COMMAND(ID_Modify_ChangeBackground , OnModifyChangeBackground) |
54 | //}}AFX_MSG_MAP |
55 | END_MESSAGE_MAP() |
56 | |
57 | ///////////////////////////////////////////////////////////////////////////// |
58 | // OCC_3dView construction/destruction |
59 | |
60 | OCC_3dView::OCC_3dView() |
61 | { |
62 | // TODO: add construction code here |
63 | myXmin=0; |
64 | myYmin=0; |
65 | myXmax=0; |
66 | myYmax=0; |
67 | myCurZoom=0; |
68 | myWidth=0; |
69 | myHeight=0; |
70 | // will be set in OnInitial update, but, for more security : |
71 | myCurrentMode = CurAction3d_Nothing; |
72 | myDegenerateModeIsOn=Standard_True; |
73 | m_Pen = NULL; |
74 | |
75 | } |
76 | |
77 | OCC_3dView::~OCC_3dView() |
78 | { |
79 | if ( myView ) |
80 | myView->Remove(); |
81 | if (m_Pen) delete m_Pen; |
82 | } |
83 | |
84 | BOOL OCC_3dView::PreCreateWindow(CREATESTRUCT& cs) |
85 | { |
86 | // TODO: Modify the Window class or styles here by modifying |
87 | // the CREATESTRUCT cs |
88 | |
89 | return CView::PreCreateWindow(cs); |
90 | } |
91 | |
92 | ///////////////////////////////////////////////////////////////////////////// |
93 | // OCC_3dView drawing |
94 | void OCC_3dView::OnInitialUpdate() |
95 | { |
96 | CView::OnInitialUpdate(); |
97 | |
98 | myView = GetDocument()->GetViewer()->CreateView(); |
99 | |
100 | // set the default mode in wireframe ( not hidden line ! ) |
101 | myView->SetDegenerateModeOn(); |
102 | // store for restore state after rotation (witch is in Degenerated mode) |
103 | myDegenerateModeIsOn = Standard_True; |
104 | |
105 | |
106 | Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice = |
107 | ((OCC_3dApp*)AfxGetApp())->GetGraphicDevice(); |
108 | |
109 | Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ()); |
110 | myView->SetWindow(aWNTWindow); |
111 | if (!aWNTWindow->IsMapped()) aWNTWindow->Map(); |
112 | |
113 | // store the mode ( nothing , dynamic zooming, dynamic ... ) |
114 | myCurrentMode = CurAction3d_Nothing; |
115 | |
116 | } |
117 | |
118 | void OCC_3dView::OnDraw(CDC* pDC) |
119 | { |
120 | CRect aRect; |
121 | GetWindowRect(aRect); |
122 | if(myWidth != aRect.Width() || myHeight != aRect.Height()) { |
123 | myWidth = aRect.Width(); |
124 | myHeight = aRect.Height(); |
125 | ::PostMessage ( GetSafeHwnd () , WM_SIZE , SW_SHOW , myWidth + myHeight*65536 ); |
126 | } |
127 | myView->Redraw(); |
128 | |
129 | } |
130 | |
131 | ///////////////////////////////////////////////////////////////////////////// |
132 | // OCC_3dView diagnostics |
133 | |
134 | #ifdef _DEBUG |
135 | void OCC_3dView::AssertValid() const |
136 | { |
137 | CView::AssertValid(); |
138 | } |
139 | |
140 | void OCC_3dView::Dump(CDumpContext& dc) const |
141 | { |
142 | CView::Dump(dc); |
143 | } |
144 | |
145 | OCC_3dBaseDoc* OCC_3dView::GetDocument() // non-debug version is inline |
146 | { |
147 | // ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(OCC_3dBaseDoc))); |
148 | return (OCC_3dBaseDoc*)m_pDocument; |
149 | } |
150 | |
151 | #endif //_DEBUG |
152 | |
153 | ///////////////////////////////////////////////////////////////////////////// |
154 | // OCC_3dView message handlers |
155 | void OCC_3dView::OnFileExportImage() |
156 | { |
157 | LPCTSTR filter; |
158 | filter = _T("BMP Files (*.BMP)|*.bmp|GIF Files (*.GIF)|*.gif|XWD Files (*.XWD)|*.xwd|PS Files (*.PS)|*.ps|EPS Files (*.EPS)|*.eps|TEX Files (*.TEX)|*.tex|PDF Files (*.PDF)|*.pdf|SVG Files (*.SVG)|*.svg|PGF Files (*.PGF)|*.pgf||"); |
159 | CFileDialog dlg(FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, |
160 | filter, |
161 | NULL ); |
162 | |
163 | if (dlg.DoModal() == IDOK) |
164 | { |
165 | SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); |
166 | CString filename = dlg.GetPathName(); |
167 | char* theFile = new char[filename.GetLength()+1]; |
168 | //_tcscpy(theFile,filename); |
169 | strcpy_s(theFile,filename.GetLength()+1,filename); |
170 | CString ext = dlg.GetFileExt(); |
171 | if (ext == "ps" || ext == "emf") |
172 | { |
173 | Graphic3d_ExportFormat exFormat; |
174 | if (ext == "ps") exFormat = Graphic3d_EF_PostScript; |
175 | else exFormat = Graphic3d_EF_EnhPostScript; |
176 | myView->View()->Export( theFile, exFormat ); |
177 | return; |
178 | } |
179 | Handle(Aspect_Window) anAspectWindow = myView->Window(); |
180 | Handle(WNT_Window) aWNTWindow = Handle(WNT_Window)::DownCast(anAspectWindow); |
181 | if (ext == "bmp") aWNTWindow->SetOutputFormat ( WNT_TOI_BMP ); |
182 | if (ext == "gif") aWNTWindow->SetOutputFormat ( WNT_TOI_GIF ); |
183 | if (ext == "xwd") aWNTWindow->SetOutputFormat ( WNT_TOI_XWD ); |
184 | aWNTWindow->Dump ((Standard_CString)(LPCTSTR)filename); |
185 | SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); |
186 | } |
187 | } |
188 | |
189 | void OCC_3dView::OnSize(UINT nType, int cx, int cy) |
190 | { |
191 | if (!myView.IsNull()) |
192 | myView->MustBeResized(); |
193 | } |
194 | |
195 | void OCC_3dView::OnBUTTONBack() |
196 | { myView->SetProj(V3d_Xneg); } // See the back View |
197 | void OCC_3dView::OnBUTTONFront() |
198 | { myView->SetProj(V3d_Xpos); } // See the front View |
199 | |
200 | void OCC_3dView::OnBUTTONBottom() |
201 | { myView->SetProj(V3d_Zneg); } // See the bottom View |
202 | void OCC_3dView::OnBUTTONTop() |
203 | { myView->SetProj(V3d_Zpos); } // See the top View |
204 | |
205 | void OCC_3dView::OnBUTTONLeft() |
206 | { myView->SetProj(V3d_Ypos); } // See the left View |
207 | void OCC_3dView::OnBUTTONRight() |
208 | { myView->SetProj(V3d_Yneg); } // See the right View |
209 | |
210 | void OCC_3dView::OnBUTTONAxo() |
211 | { myView->SetProj(V3d_XposYnegZpos); } // See the axonometric View |
212 | |
213 | void OCC_3dView::OnBUTTONHlrOff() |
214 | { |
215 | myView->SetDegenerateModeOn(); |
216 | myDegenerateModeIsOn = Standard_True; |
217 | } |
218 | |
219 | void OCC_3dView::OnBUTTONHlrOn() |
220 | { |
221 | SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); |
222 | myView->SetDegenerateModeOff(); |
223 | myDegenerateModeIsOn = Standard_False; |
224 | SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); |
225 | } |
226 | |
227 | void OCC_3dView::OnBUTTONPan() |
228 | { myCurrentMode = CurAction3d_DynamicPanning; } |
229 | |
230 | void OCC_3dView::OnBUTTONPanGlo() |
231 | { |
232 | // save the current zoom value |
233 | myCurZoom = myView->Scale(); |
234 | // Do a Global Zoom |
235 | //myView->FitAll(); |
236 | // Set the mode |
237 | myCurrentMode = CurAction3d_GlobalPanning; |
238 | } |
239 | |
240 | void OCC_3dView::OnBUTTONReset() |
241 | { myView->Reset(); } |
242 | |
243 | void OCC_3dView::OnBUTTONRot() |
244 | { myCurrentMode = CurAction3d_DynamicRotation; } |
245 | |
246 | |
247 | void OCC_3dView::OnBUTTONZoomAll() |
248 | { |
249 | myView->FitAll(); |
250 | myView->ZFitAll(); |
251 | } |
252 | |
253 | void OCC_3dView::OnBUTTONZoomProg() |
254 | { myCurrentMode = CurAction3d_DynamicZooming; } |
255 | |
256 | void OCC_3dView::OnBUTTONZoomWin() |
257 | { myCurrentMode = CurAction3d_WindowZooming; } |
258 | |
259 | void OCC_3dView::OnLButtonDown(UINT nFlags, CPoint point) |
260 | { |
261 | // save the current mouse coordinate in min |
262 | myXmin=point.x; myYmin=point.y; |
263 | myXmax=point.x; myYmax=point.y; |
264 | |
265 | if ( nFlags & MK_CONTROL ) |
266 | { |
267 | // Button MB1 down Control :start zomming |
268 | // SetCursor(AfxGetApp()->LoadStandardCursor()); |
269 | } |
270 | else // if ( Ctrl ) |
271 | { |
272 | switch (myCurrentMode) |
273 | { |
274 | case CurAction3d_Nothing : // start a drag |
275 | if (nFlags & MK_SHIFT) |
276 | GetDocument()->ShiftDragEvent(myXmax,myYmax,-1,myView); |
277 | else |
278 | GetDocument()->DragEvent(myXmax,myYmax,-1,myView); |
279 | break; |
280 | break; |
281 | case CurAction3d_DynamicZooming : // noting |
282 | break; |
283 | case CurAction3d_WindowZooming : // noting |
284 | break; |
285 | case CurAction3d_DynamicPanning :// noting |
286 | break; |
287 | case CurAction3d_GlobalPanning :// noting |
288 | break; |
289 | case CurAction3d_DynamicRotation : |
290 | if (!myDegenerateModeIsOn) |
291 | myView->SetDegenerateModeOn(); |
292 | myView->StartRotation(point.x,point.y); |
293 | break; |
294 | default : |
295 | Standard_Failure::Raise(" incompatible Current Mode "); |
296 | break; |
297 | } |
298 | } |
299 | } |
300 | |
301 | void OCC_3dView::OnLButtonUp(UINT nFlags, CPoint point) |
302 | { |
303 | if ( nFlags & MK_CONTROL ) |
304 | { |
305 | return; |
306 | } |
307 | else // if ( Ctrl ) |
308 | { |
309 | switch (myCurrentMode) |
310 | { |
311 | case CurAction3d_Nothing : |
312 | if (point.x == myXmin && point.y == myYmin) |
313 | { // no offset between down and up --> selectEvent |
314 | myXmax=point.x; |
315 | myYmax=point.y; |
316 | if (nFlags & MK_SHIFT ) |
317 | GetDocument()->ShiftInputEvent(point.x,point.y,myView); |
318 | else |
319 | GetDocument()->InputEvent (point.x,point.y,myView); |
320 | } else |
321 | { |
322 | myXmax=point.x; myYmax=point.y; |
323 | DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False); |
324 | if (nFlags & MK_SHIFT) |
325 | GetDocument()->ShiftDragEvent(point.x,point.y,1,myView); |
326 | else |
327 | GetDocument()->DragEvent(point.x,point.y,1,myView); |
328 | } |
329 | break; |
330 | case CurAction3d_DynamicZooming : |
331 | // SetCursor(AfxGetApp()->LoadStandardCursor()); |
332 | myCurrentMode = CurAction3d_Nothing; |
333 | break; |
334 | case CurAction3d_WindowZooming : |
335 | myXmax=point.x; myYmax=point.y; |
336 | DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False); |
337 | if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin)) |
338 | // Test if the zoom window is greater than a minimale window. |
339 | { |
340 | // Do the zoom window between Pmin and Pmax |
341 | myView->WindowFitAll(myXmin,myYmin,myXmax,myYmax); |
342 | } |
343 | myCurrentMode = CurAction3d_Nothing; |
344 | break; |
345 | case CurAction3d_DynamicPanning : |
346 | myCurrentMode = CurAction3d_Nothing; |
347 | break; |
348 | case CurAction3d_GlobalPanning : |
349 | myView->Place(point.x,point.y,myCurZoom); |
350 | myCurrentMode = CurAction3d_Nothing; |
351 | break; |
352 | case CurAction3d_DynamicRotation : |
353 | myCurrentMode = CurAction3d_Nothing; |
354 | if (!myDegenerateModeIsOn) |
355 | { |
356 | CWaitCursor aWaitCursor; |
357 | myView->SetDegenerateModeOff(); |
358 | myDegenerateModeIsOn = Standard_False; |
359 | } |
360 | else |
361 | { |
362 | myView->SetDegenerateModeOn(); |
363 | myDegenerateModeIsOn = Standard_True; |
364 | } |
365 | break; |
366 | default : |
367 | Standard_Failure::Raise(" incompatible Current Mode "); |
368 | break; |
369 | } //switch (myCurrentMode) |
370 | } // else // if ( Ctrl ) |
371 | } |
372 | |
373 | void OCC_3dView::OnMButtonDown(UINT nFlags, CPoint point) |
374 | { |
375 | if ( nFlags & MK_CONTROL ) |
376 | { |
377 | // Button MB2 down Control : panning init |
378 | // SetCursor(AfxGetApp()->LoadStandardCursor()); |
379 | } |
380 | } |
381 | |
382 | void OCC_3dView::OnMButtonUp(UINT nFlags, CPoint point) |
383 | { |
384 | if ( nFlags & MK_CONTROL ) |
385 | { |
386 | // Button MB2 down Control : panning init |
387 | // SetCursor(AfxGetApp()->LoadStandardCursor()); |
388 | } |
389 | } |
390 | |
391 | void OCC_3dView::OnRButtonDown(UINT nFlags, CPoint point) |
392 | { |
393 | if ( nFlags & MK_CONTROL ) |
394 | { |
395 | // SetCursor(AfxGetApp()->LoadStandardCursor()); |
396 | if (!myDegenerateModeIsOn) |
397 | myView->SetDegenerateModeOn(); |
398 | myView->StartRotation(point.x,point.y); |
399 | } |
400 | else // if ( Ctrl ) |
401 | { |
402 | GetDocument()->Popup(point.x,point.y,myView); |
403 | } |
404 | } |
405 | |
406 | void OCC_3dView::OnRButtonUp(UINT nFlags, CPoint point) |
407 | { |
408 | SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); |
409 | if (!myDegenerateModeIsOn) |
410 | { |
411 | myView->SetDegenerateModeOff(); |
412 | myDegenerateModeIsOn = Standard_False; |
413 | } else |
414 | { |
415 | myView->SetDegenerateModeOn(); |
416 | myDegenerateModeIsOn = Standard_True; |
417 | } |
418 | SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); |
419 | } |
420 | |
421 | void OCC_3dView::OnMouseMove(UINT nFlags, CPoint point) |
422 | { |
423 | // ============================ LEFT BUTTON ======================= |
424 | if ( nFlags & MK_LBUTTON) |
425 | { |
426 | if ( nFlags & MK_CONTROL ) |
427 | { |
428 | // move with MB1 and Control : on the dynamic zooming |
429 | // Do the zoom in function of mouse's coordinates |
430 | myView->Zoom(myXmax,myYmax,point.x,point.y); |
431 | // save the current mouse coordinate in min |
432 | myXmax = point.x; |
433 | myYmax = point.y; |
434 | } |
435 | else // if ( Ctrl ) |
436 | { |
437 | switch (myCurrentMode) |
438 | { |
439 | case CurAction3d_Nothing : |
440 | myXmax = point.x; myYmax = point.y; |
441 | DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False); |
442 | if (nFlags & MK_SHIFT) |
443 | GetDocument()->ShiftDragEvent(myXmax,myYmax,0,myView); |
444 | else |
445 | GetDocument()->DragEvent(myXmax,myYmax,0,myView); |
446 | DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True); |
447 | |
448 | break; |
449 | case CurAction3d_DynamicZooming : |
450 | myView->Zoom(myXmax,myYmax,point.x,point.y); |
451 | // save the current mouse coordinate in min \n"; |
452 | myXmax=point.x; myYmax=point.y; |
453 | break; |
454 | case CurAction3d_WindowZooming : |
455 | myXmax = point.x; myYmax = point.y; |
456 | DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash); |
457 | DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash); |
458 | break; |
459 | case CurAction3d_DynamicPanning : |
460 | myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning |
461 | myXmax = point.x; myYmax = point.y; |
462 | break; |
463 | case CurAction3d_GlobalPanning : // nothing |
464 | break; |
465 | case CurAction3d_DynamicRotation : |
466 | myView->Rotation(point.x,point.y); |
467 | myView->Redraw(); |
468 | break; |
469 | default : |
470 | Standard_Failure::Raise(" incompatible Current Mode "); |
471 | break; |
472 | }// switch (myCurrentMode) |
473 | }// if ( nFlags & MK_CONTROL ) else |
474 | } else // if ( nFlags & MK_LBUTTON) |
475 | // ============================ MIDDLE BUTTON ======================= |
476 | if ( nFlags & MK_MBUTTON) |
477 | { |
478 | if ( nFlags & MK_CONTROL ) |
479 | { |
480 | myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning |
481 | myXmax = point.x; myYmax = point.y; |
482 | |
483 | } |
484 | } else // if ( nFlags & MK_MBUTTON) |
485 | // ============================ RIGHT BUTTON ======================= |
486 | if ( nFlags & MK_RBUTTON) |
487 | { |
488 | if ( nFlags & MK_CONTROL ) |
489 | { |
490 | myView->Rotation(point.x,point.y); |
491 | } |
492 | }else //if ( nFlags & MK_RBUTTON) |
493 | // ============================ NO BUTTON ======================= |
494 | { // No buttons |
495 | myXmax = point.x; myYmax = point.y; |
496 | if (nFlags & MK_SHIFT) |
497 | GetDocument()->ShiftMoveEvent(point.x,point.y,myView); |
498 | else |
499 | GetDocument()->MoveEvent(point.x,point.y,myView); |
500 | } |
501 | } |
502 | |
503 | void OCC_3dView::DrawRectangle(const Standard_Integer MinX , |
504 | const Standard_Integer MinY , |
505 | const Standard_Integer MaxX , |
506 | const Standard_Integer MaxY , |
507 | const Standard_Boolean Draw , |
508 | const LineStyle aLineStyle) |
509 | { |
510 | static int m_DrawMode; |
511 | if (!m_Pen && aLineStyle ==Solid ) |
512 | {m_Pen = new CPen(PS_SOLID, 1, RGB(0,0,0)); m_DrawMode = R2_MERGEPENNOT;} |
513 | else if (!m_Pen && aLineStyle ==Dot ) |
514 | {m_Pen = new CPen(PS_DOT, 1, RGB(0,0,0)); m_DrawMode = R2_XORPEN;} |
515 | else if (!m_Pen && aLineStyle == ShortDash) |
516 | {m_Pen = new CPen(PS_DASH, 1, RGB(255,0,0)); m_DrawMode = R2_XORPEN;} |
517 | else if (!m_Pen && aLineStyle == LongDash) |
518 | {m_Pen = new CPen(PS_DASH, 1, RGB(0,0,0)); m_DrawMode = R2_NOTXORPEN;} |
519 | else if (aLineStyle == Default) |
520 | { m_Pen = NULL; m_DrawMode = R2_MERGEPENNOT;} |
521 | |
522 | CPen* aOldPen; |
523 | CClientDC clientDC(this); |
524 | if (m_Pen) aOldPen = clientDC.SelectObject(m_Pen); |
525 | clientDC.SetROP2(m_DrawMode); |
526 | |
527 | static Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY; |
528 | static Standard_Boolean m_IsVisible; |
529 | |
530 | if ( m_IsVisible && !Draw) // move or up : erase at the old position |
531 | { |
532 | clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY); |
533 | clientDC.LineTo(StoredMaxX,StoredMaxY); |
534 | clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY); |
535 | m_IsVisible = false; |
536 | } |
537 | |
538 | StoredMinX = min ( MinX, MaxX ); |
539 | StoredMinY = min ( MinY, MaxY ); |
540 | StoredMaxX = max ( MinX, MaxX ); |
541 | StoredMaxY = max ( MinY, MaxY); |
542 | |
543 | if (Draw) // move : draw |
544 | { |
545 | clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY); |
546 | clientDC.LineTo(StoredMaxX,StoredMaxY); |
547 | clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY); |
548 | m_IsVisible = true; |
549 | } |
550 | |
551 | if (m_Pen) clientDC.SelectObject(aOldPen); |
552 | } |
553 | |
554 | |
555 | |
556 | void OCC_3dView::OnUpdateBUTTONHlrOff(CCmdUI* pCmdUI) |
557 | { |
558 | pCmdUI->SetCheck (myDegenerateModeIsOn); |
559 | pCmdUI->Enable (!myDegenerateModeIsOn); |
560 | } |
561 | |
562 | void OCC_3dView::OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI) |
563 | { |
564 | pCmdUI->SetCheck (!myDegenerateModeIsOn); |
565 | pCmdUI->Enable (myDegenerateModeIsOn); |
566 | } |
567 | |
568 | void OCC_3dView::OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI) |
569 | { |
570 | pCmdUI->SetCheck (myCurrentMode == CurAction3d_GlobalPanning); |
571 | pCmdUI->Enable (myCurrentMode != CurAction3d_GlobalPanning); |
572 | |
573 | } |
574 | |
575 | void OCC_3dView::OnUpdateBUTTONPan(CCmdUI* pCmdUI) |
576 | { |
577 | pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicPanning); |
578 | pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicPanning ); |
579 | } |
580 | |
581 | void OCC_3dView::OnUpdateBUTTONZoomProg(CCmdUI* pCmdUI) |
582 | { |
583 | pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicZooming ); |
584 | pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicZooming); |
585 | } |
586 | |
587 | void OCC_3dView::OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI) |
588 | { |
589 | pCmdUI->SetCheck (myCurrentMode == CurAction3d_WindowZooming); |
590 | pCmdUI->Enable (myCurrentMode != CurAction3d_WindowZooming); |
591 | } |
592 | |
593 | void OCC_3dView::OnUpdateBUTTONRot(CCmdUI* pCmdUI) |
594 | { |
595 | pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicRotation); |
596 | pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicRotation); |
597 | } |
598 | |
599 | void OCC_3dView::OnModifyChangeBackground() |
600 | { |
601 | Standard_Real R1; |
602 | Standard_Real G1; |
603 | Standard_Real B1; |
604 | myView->BackgroundColor(Quantity_TOC_RGB,R1,G1,B1); |
605 | COLORREF m_clr ; |
606 | m_clr = RGB(R1*255,G1*255,B1*255); |
607 | |
608 | CColorDialog dlgColor(m_clr); |
609 | if (dlgColor.DoModal() == IDOK) |
610 | { |
611 | m_clr = dlgColor.GetColor(); |
612 | R1 = GetRValue(m_clr)/255.; |
613 | G1 = GetGValue(m_clr)/255.; |
614 | B1 = GetBValue(m_clr)/255.; |
615 | myView->SetBackgroundColor(Quantity_TOC_RGB,R1,G1,B1); |
616 | } |
617 | myView->Redraw(); |
618 | } |