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