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