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