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