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