]> SALOME platform Git repositories - modules/gui.git/blob - src/OCCViewer/OCCViewer_ViewWindow.cxx
Salome HOME
0021883 [CEA 674] Deactivate pre-selection in OCC and VTK viewer
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewWindow.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File   : OCCViewer_ViewWindow.cxx
24 // Author :
25
26 #include "OCCViewer_ViewWindow.h"
27 #include "OCCViewer_ViewModel.h"
28 #include "OCCViewer_ViewPort3d.h"
29 #include "OCCViewer_ViewManager.h"
30 #include "OCCViewer_ViewSketcher.h"
31 #include "OCCViewer_CreateRestoreViewDlg.h"
32 #include "OCCViewer_ClippingDlg.h"
33 #include "OCCViewer_SetRotationPointDlg.h"
34 #include "OCCViewer_AxialScaleDlg.h"
35 #include "OCCViewer_CubeAxesDlg.h"
36
37 #include <Basics_OCCTVersion.hxx>
38
39 #include <SUIT_Desktop.h>
40 #include <SUIT_Session.h>
41 #include <SUIT_ViewManager.h>
42 #include <SUIT_Tools.h>
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_MessageBox.h>
45 #include <SUIT_Application.h>
46
47 #include <QtxActionToolMgr.h>
48 #include <QtxMultiAction.h>
49 #include <QtxRubberBand.h>
50
51 #include <OpenGLUtils_FrameBuffer.h>
52
53 #include <QPainter>
54 #include <QTime>
55 #include <QImage>
56 #include <QKeyEvent>
57 #include <QMouseEvent>
58 #include <QApplication>
59 #include <QMenu>
60
61 #include <AIS_ListOfInteractive.hxx>
62 #include <AIS_ListIteratorOfListOfInteractive.hxx>
63 #include <AIS_Shape.hxx>
64
65 #include <BRep_Tool.hxx>
66 #include <BRepBndLib.hxx>
67 #include <TopoDS.hxx>
68
69 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
70 #include <Graphic3d_MapOfStructure.hxx>
71 #include <Graphic3d_Structure.hxx>
72 #include <Graphic3d_ExportFormat.hxx>
73
74 #include <Visual3d_View.hxx>
75 #include <V3d_Plane.hxx>
76 #include <V3d_Light.hxx>
77
78 #include <gp_Dir.hxx>
79 #include <gp_Pln.hxx>
80 #include <TColgp_Array1OfPnt2d.hxx>
81
82 #include <Standard_Version.hxx>
83
84 #include "utilities.h"
85
86 // // OpenCV includes
87 // #include <cv.h>
88 // #include <highgui.h>
89
90 static QEvent* l_mbPressEvent = 0;
91
92 #ifdef WIN32
93 # include <QWindowsStyle>
94 #endif
95
96 #include <GL/gl.h>
97
98 const char* imageZoomCursor[] = {
99 "32 32 3 1",
100 ". c None",
101 "a c #000000",
102 "# c #ffffff",
103 "................................",
104 "................................",
105 ".#######........................",
106 "..aaaaaaa.......................",
107 "................................",
108 ".............#####..............",
109 "...........##.aaaa##............",
110 "..........#.aa.....a#...........",
111 ".........#.a.........#..........",
112 ".........#a..........#a.........",
113 "........#.a...........#.........",
114 "........#a............#a........",
115 "........#a............#a........",
116 "........#a............#a........",
117 "........#a............#a........",
118 ".........#...........#.a........",
119 ".........#a..........#a.........",
120 ".........##.........#.a.........",
121 "........#####.....##.a..........",
122 ".......###aaa#####.aa...........",
123 "......###aa...aaaaa.......#.....",
124 ".....###aa................#a....",
125 "....###aa.................#a....",
126 "...###aa...............#######..",
127 "....#aa.................aa#aaaa.",
128 ".....a....................#a....",
129 "..........................#a....",
130 "...........................a....",
131 "................................",
132 "................................",
133 "................................",
134 "................................"};
135
136 const char* imageRotateCursor[] = {
137 "32 32 3 1",
138 ". c None",
139 "a c #000000",
140 "# c #ffffff",
141 "................................",
142 "................................",
143 "................................",
144 "................................",
145 "........#.......................",
146 ".......#.a......................",
147 "......#######...................",
148 ".......#aaaaa#####..............",
149 "........#..##.a#aa##........##..",
150 ".........a#.aa..#..a#.....##.aa.",
151 ".........#.a.....#...#..##.aa...",
152 ".........#a.......#..###.aa.....",
153 "........#.a.......#a..#aa.......",
154 "........#a.........#..#a........",
155 "........#a.........#a.#a........",
156 "........#a.........#a.#a........",
157 "........#a.........#a.#a........",
158 ".........#.........#a#.a........",
159 "........##a........#a#a.........",
160 "......##.a#.......#.#.a.........",
161 "....##.aa..##.....##.a..........",
162 "..##.aa.....a#####.aa...........",
163 "...aa.........aaa#a.............",
164 "................#.a.............",
165 "...............#.a..............",
166 "..............#.a...............",
167 "...............a................",
168 "................................",
169 "................................",
170 "................................",
171 "................................",
172 "................................"};
173
174 const char* imageCrossCursor[] = {
175   "32 32 3 1",
176   ". c None",
177   "a c #000000",
178   "# c #ffffff",
179   "................................",
180   "................................",
181   "................................",
182   "................................",
183   "................................",
184   "................................",
185   "................................",
186   "...............#................",
187   "...............#a...............",
188   "...............#a...............",
189   "...............#a...............",
190   "...............#a...............",
191   "...............#a...............",
192   "...............#a...............",
193   "...............#a...............",
194   ".......#################........",
195   "........aaaaaaa#aaaaaaaaa.......",
196   "...............#a...............",
197   "...............#a...............",
198   "...............#a...............",
199   "...............#a...............",
200   "...............#a...............",
201   "...............#a...............",
202   "...............#a...............",
203   "................a...............",
204   "................................",
205   "................................",
206   "................................",
207   "................................",
208   "................................",
209   "................................",
210   "................................"};
211
212
213 /*!
214   \brief Constructor
215   \param theDesktop main window of application
216   \param theModel OCC 3D viewer
217 */
218 OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,
219                                             OCCViewer_Viewer* theModel )
220 : SUIT_ViewWindow( theDesktop )
221 {
222   myModel = theModel;
223   myRestoreFlag = 0;
224   myEnableDrawMode = false;
225   myDrawRect=false;
226   updateEnabledDrawMode();
227   myClippingDlg = 0;
228   myScalingDlg = 0;
229   mySetRotationPointDlg = 0;
230   myRectBand = 0;
231   
232   IsSketcherStyle = false;
233   myIsKeyFree = false;
234
235   mypSketcher = 0;
236   myCurSketch = -1;
237   my2dMode = No2dMode;
238
239   myInteractionStyle = SUIT_ViewModel::STANDARD;
240   myPreselectionEnabled = true;
241   mySelectionEnabled = true;
242
243
244   clearViewAspects();
245   
246 }
247
248 /*!
249   \brief Destructor.
250 */
251 OCCViewer_ViewWindow::~OCCViewer_ViewWindow()
252 {
253   endDrawRect();
254   qDeleteAll( mySketchers );
255 }
256
257 /*!
258   \brief Internal initialization.
259 */
260 void OCCViewer_ViewWindow::initLayout()
261 {
262   myViewPort = new OCCViewer_ViewPort3d( this, myModel->getViewer3d(), V3d_ORTHOGRAPHIC );
263   myViewPort->installEventFilter(this);
264   setCentralWidget(myViewPort);
265   myOperation = NOTHING;
266
267   myCurrPointType = GRAVITY;
268   myPrevPointType = GRAVITY;
269   mySelectedPoint = gp_Pnt(0.,0.,0.);
270   myRotationPointSelection = false;
271
272   setTransformRequested ( NOTHING );
273   setTransformInProcess ( false );
274
275   createActions();
276   createToolBar();
277
278   switch (my2dMode) {
279   case XYPlane:
280     onTopView();
281     break;
282   case XZPlane:
283     onLeftView();
284     break;
285   case YZPlane:
286     onFrontView();
287     break;
288   }
289
290   // Graduated axes dialog
291   QtxAction* anAction = dynamic_cast<QtxAction*>( toolMgr()->action( GraduatedAxesId ) );
292   myCubeAxesDlg = new OCCViewer_CubeAxesDlg( anAction, this, "OCCViewer_CubeAxesDlg" );
293   myCubeAxesDlg->initialize();
294   
295   connect( myViewPort, SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), this, SLOT( emitViewModified() ) );
296 }
297
298 OCCViewer_ViewWindow* OCCViewer_ViewWindow::getView( const int mode ) const
299 {
300   return mode == get2dMode() ? const_cast<OCCViewer_ViewWindow*>( this ) : 0;
301 }
302
303 /*!
304   \brief Detect viewer operation according the the mouse button pressed
305   and key modifiers used.
306   \param theEvent mouse event
307   \return type of the operation
308 */
309 OCCViewer_ViewWindow::OperationType
310 OCCViewer_ViewWindow::getButtonState( QMouseEvent* theEvent, int theInteractionStyle )
311 {
312   OperationType aOp = NOTHING;
313   SUIT_ViewModel::InteractionStyle aStyle = (SUIT_ViewModel::InteractionStyle)theInteractionStyle;
314   if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ZOOM]) &&
315       (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ZOOM]) )
316     aOp = ZOOMVIEW;
317   else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::PAN]) &&
318            (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::PAN]) )
319     aOp = PANVIEW;
320   else if( (theEvent->modifiers()  == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ROTATE]) &&
321            (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ROTATE]) &&
322            (my2dMode == No2dMode))
323     aOp = ROTATE;
324
325   return aOp;
326 }
327
328 /*!
329   \brief Customize event handling
330   \param watched event receiver object
331   \param e event
332   \return \c true if the event processing should be stopped
333 */
334 bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
335 {
336   if ( watched == myViewPort ) {
337     int aType = e->type();
338     switch(aType) {
339     case QEvent::MouseButtonPress:
340       vpMousePressEvent((QMouseEvent*) e);
341       return true;
342
343     case QEvent::MouseButtonRelease:
344       vpMouseReleaseEvent((QMouseEvent*) e);
345       return true;
346
347     case QEvent::MouseMove:
348       vpMouseMoveEvent((QMouseEvent*) e);
349       return true;
350
351     case QEvent::MouseButtonDblClick:
352       emit mouseDoubleClicked(this, (QMouseEvent*)e);
353       return true;
354
355     case QEvent::Wheel:
356       {
357         QWheelEvent* aEvent = (QWheelEvent*) e;
358         myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() );
359         double delta = (double)( aEvent->delta() ) / ( 15 * 8 );
360         int x  = aEvent->x();
361         int y  = aEvent->y();
362         int x1 = (int)( aEvent->x() + width()*delta/100 );
363         int y1 = (int)( aEvent->y() + height()*delta/100 );
364         myViewPort->zoom( x, y, x1, y1 );
365       }
366       return true;
367
368     case QEvent::ContextMenu:
369       {
370         QContextMenuEvent * aEvent = (QContextMenuEvent*)e;
371         if ( aEvent->reason() != QContextMenuEvent::Mouse )
372           emit contextMenuRequested( aEvent );
373       }
374       return true;
375
376     case QEvent::KeyPress:
377       emit keyPressed(this, (QKeyEvent*) e);
378       return true;
379
380     default:
381       break;
382     }
383   }
384   return SUIT_ViewWindow::eventFilter(watched, e);
385 }
386
387 /*!
388   \brief Update state of enable draw mode state.
389 */
390 void OCCViewer_ViewWindow::updateEnabledDrawMode()
391 {
392   if ( myModel )
393     myEnableDrawMode = myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled();
394 }
395
396 /*!
397   \brief Handle mouse press event
398   \param theEvent mouse event
399 */
400 void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )
401 {
402   myStartX = theEvent->x();
403   myStartY = theEvent->y();
404   int anInteractionStyle = interactionStyle();
405
406   // in "key free" interaction style zoom operation is activated by two buttons (simultaneously pressed),
407   // which are assigned for pan and rotate - these operations are activated immediately after pressing 
408   // of the first button, so it is necessary to switch to zoom when the second button is pressed
409   bool aSwitchToZoom = false;
410   if ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && 
411        ( myOperation == PANVIEW || myOperation == ROTATE ) ) {
412     aSwitchToZoom = getButtonState( theEvent, anInteractionStyle ) == ZOOMVIEW;
413   }
414
415   switch ( myOperation ) {
416   case WINDOWFIT:
417     if ( theEvent->button() == Qt::LeftButton )
418       emit vpTransformationStarted ( WINDOWFIT );
419     break;
420
421   case PANGLOBAL:
422     if ( theEvent->button() == Qt::LeftButton )
423       emit vpTransformationStarted ( PANGLOBAL );
424     break;
425
426   case ZOOMVIEW:
427     if ( theEvent->button() == Qt::LeftButton ) {
428       myViewPort->startZoomAtPoint( myStartX, myStartY );
429       emit vpTransformationStarted ( ZOOMVIEW );
430     }
431     break;
432
433   case PANVIEW:
434     if ( aSwitchToZoom ) {
435       myViewPort->startZoomAtPoint( myStartX, myStartY );
436       activateZoom();
437     }
438     else if ( theEvent->button() == Qt::LeftButton )
439       emit vpTransformationStarted ( PANVIEW );
440     break;
441
442   case ROTATE:
443     if ( aSwitchToZoom ) {
444       myViewPort->startZoomAtPoint( myStartX, myStartY );
445       activateZoom();
446     }
447     else if ( theEvent->button() == Qt::LeftButton ) {
448       myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
449       emit vpTransformationStarted ( ROTATE );
450     }
451     break;
452
453   default:
454   /*  Try to activate a transformation */
455     OperationType aState;
456     if ( interactionStyle() == SUIT_ViewModel::STANDARD )
457       aState = getButtonState(theEvent, anInteractionStyle);
458     else {
459       aState = OCCViewer_ViewWindow::NOTHING;
460       myIsKeyFree = true;
461     }
462     switch ( aState ) {
463     case ZOOMVIEW:
464       myViewPort->startZoomAtPoint( myStartX, myStartY );
465       activateZoom();
466       break;
467     case PANVIEW:
468       activatePanning();
469       break;
470     case ROTATE:
471       activateRotation();
472       myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
473       break;
474     default:
475       if ( myRotationPointSelection )
476       {
477         if ( theEvent->button() == Qt::LeftButton )
478         {
479           Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
480           ic->Select();
481           for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() )
482           {
483             TopoDS_Shape aShape = ic->SelectedShape();
484             if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
485             {
486               gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
487               if ( mySetRotationPointDlg )
488               {
489                 myRotationPointSelection = false;
490                 mySetRotationPointDlg->setCoords(aPnt.X(), aPnt.Y(), aPnt.Z());
491               }
492             }
493             else
494             {
495               myCurrPointType = myPrevPointType;
496               break;
497             }
498           }
499           if ( ic->NbSelected() == 0 ) myCurrPointType = myPrevPointType;
500           if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();
501           ic->CloseAllContexts();
502           myOperation = NOTHING;
503           myViewPort->setCursor( myCursor );
504           myCursorIsHand = false;
505           myRotationPointSelection = false;
506         }
507       }
508       else
509         emit mousePressed(this, theEvent);
510       break;
511     }
512     /* notify that we start a transformation */
513     if ( transformRequested() )
514             emit vpTransformationStarted ( myOperation );
515   }
516   if ( transformRequested() )
517     setTransformInProcess( true );
518
519   /* we may need it for sketching... */
520   if ( l_mbPressEvent )
521     delete l_mbPressEvent;
522   l_mbPressEvent = new QMouseEvent( *theEvent );
523 }
524
525
526 /*!
527   \brief Start zooming operation.
528
529   Sets the corresponding cursor for the widget.
530 */
531 void OCCViewer_ViewWindow::activateZoom()
532 {
533   if ( !transformRequested() && !myCursorIsHand )
534     myCursor = cursor();                /* save old cursor */
535
536   if ( myOperation != ZOOMVIEW ) {
537     QPixmap zoomPixmap (imageZoomCursor);
538     QCursor zoomCursor (zoomPixmap);
539     if( setTransformRequested ( ZOOMVIEW ) )
540       myViewPort->setCursor( zoomCursor );
541   }
542 }
543
544
545 /*!
546   \brief Start panning operation.
547
548   Sets the corresponding cursor for the widget.
549 */
550 void OCCViewer_ViewWindow::activatePanning()
551 {
552   if ( !transformRequested() && !myCursorIsHand )
553     myCursor = cursor();                // save old cursor
554
555   if ( myOperation != PANVIEW ) {
556     QCursor panCursor (Qt::SizeAllCursor);
557     if( setTransformRequested ( PANVIEW ) )
558       myViewPort->setCursor( panCursor );
559   }
560 }
561
562 /*!
563   \brief Start rotation operation
564
565   Sets the corresponding cursor for the widget.
566 */
567 void OCCViewer_ViewWindow::activateRotation()
568 {
569   if ( !transformRequested() && !myCursorIsHand )
570     myCursor = cursor();                // save old cursor
571
572   if ( myOperation != ROTATE ) {
573     QPixmap rotatePixmap (imageRotateCursor);
574     QCursor rotCursor (rotatePixmap);
575     if( setTransformRequested ( ROTATE ) )
576       myViewPort->setCursor( rotCursor );
577   }
578 }
579
580 /*!
581   \brief Compute the gravity center.
582   \param theX used to return X coordinate of the gravity center
583   \param theY used to return Y coordinate of the gravity center
584   \param theZ used to return Z coordinate of the gravity center
585   \return \c true if the gravity center is computed
586 */
587 bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, double& theZ )
588 {
589   Handle(Visual3d_View) aView = myViewPort->getView()->View();
590
591   Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ;
592   Standard_Real Umin,Vmin,Umax,Vmax ;
593   Standard_Integer Nstruct,Npoint ;
594   Graphic3d_MapOfStructure MySetOfStructures;
595
596   aView->DisplayedStructures (MySetOfStructures);
597   Nstruct = MySetOfStructures.Extent() ;
598
599   Graphic3d_MapIteratorOfMapOfStructure MyIterator(MySetOfStructures) ;
600   aView->ViewMapping().WindowLimit(Umin,Vmin,Umax,Vmax) ;
601   Npoint = 0 ; theX = theY = theZ = 0. ;
602   for( ; MyIterator.More(); MyIterator.Next()) {
603     if (!(MyIterator.Key())->IsEmpty()) {
604       (MyIterator.Key())->MinMaxValues(Xmin,Ymin,Zmin,
605                                          Xmax,Ymax,Zmax) ;
606
607       Standard_Real LIM = ShortRealLast() -1.;
608       if (!    (fabs(Xmin) > LIM || fabs(Ymin) > LIM || fabs(Zmin) > LIM
609                 ||  fabs(Xmax) > LIM || fabs(Ymax) > LIM || fabs(Zmax) > LIM )) {
610
611         aView->Projects(Xmin,Ymin,Zmin,U,V,W) ;
612         if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
613           Npoint++ ; theX += Xmin ; theY += Ymin ; theZ += Zmin ;
614         }
615         aView->Projects(Xmax,Ymin,Zmin,U,V,W) ;
616         if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
617           Npoint++ ; theX += Xmax ; theY += Ymin ; theZ += Zmin ;
618         }
619         aView->Projects(Xmin,Ymax,Zmin,U,V,W) ;
620         if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
621           Npoint++ ; theX += Xmin ; theY += Ymax ; theZ += Zmin ;
622         }
623         aView->Projects(Xmax,Ymax,Zmin,U,V,W) ;
624         if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
625           Npoint++ ; theX += Xmax ; theY += Ymax ; theZ += Zmin ;
626         }
627         aView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
628         if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
629           Npoint++ ; theX += Xmin ; theY += Ymin ; theZ += Zmax ;
630         }
631         aView->Projects(Xmax,Ymin,Zmax,U,V,W) ;
632         if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
633           Npoint++ ; theX += Xmax ; theY += Ymin ; theZ += Zmax ;
634         }
635         aView->Projects(Xmin,Ymax,Zmax,U,V,W) ;
636         if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
637           Npoint++ ; theX += Xmin ; theY += Ymax ; theZ += Zmax ;
638         }
639         aView->Projects(Xmax,Ymax,Zmax,U,V,W) ;
640         if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
641           Npoint++ ; theX += Xmax ; theY += Ymax ; theZ += Zmax ;
642         }
643       }
644     }
645   }
646   if( Npoint > 0 ) {
647     theX /= Npoint ; theY /= Npoint ; theZ /= Npoint ;
648   }
649   return true;
650 }
651
652 /*!
653   \brief Set the gravity center as a rotation point.
654 */
655 void OCCViewer_ViewWindow::activateSetRotationGravity()
656 {
657   if ( myRotationPointSelection )
658   {
659     Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
660     ic->CloseAllContexts();
661     myOperation = NOTHING;
662     myViewPort->setCursor( myCursor );
663     myCursorIsHand = false;
664     myRotationPointSelection = false;
665   }
666
667   myPrevPointType = myCurrPointType;
668   myCurrPointType = GRAVITY;
669
670   Standard_Real Xcenter, Ycenter, Zcenter;
671   if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
672     mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
673 }
674
675 /*!
676   \brief Update gravity center in the "Set Rotation Point" dialog box.
677   \sa OCCViewer_SetRotationPointDlg class
678 */
679 void OCCViewer_ViewWindow::updateGravityCoords()
680 {
681   if ( mySetRotationPointDlg && mySetRotationPointDlg->isVisible() && myCurrPointType == GRAVITY )
682   {
683     Standard_Real Xcenter, Ycenter, Zcenter;
684     if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
685       mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
686   }
687 }
688
689 /*!
690   \brief Set the point selected by the user as a rotation point.
691   \param theX X coordinate of the rotation point
692   \param theY Y coordinate of the rotation point
693   \param theZ Z coordinate of the rotation point
694 */
695 void OCCViewer_ViewWindow::activateSetRotationSelected( double theX, double theY, double theZ )
696 {
697   if ( myRotationPointSelection )
698   {
699     Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
700     ic->CloseAllContexts();
701     myOperation = NOTHING;
702     myViewPort->setCursor( myCursor );
703     myCursorIsHand = false;
704     myRotationPointSelection = false;
705   }
706
707   myPrevPointType = myCurrPointType;
708   myCurrPointType = SELECTED;
709   mySelectedPoint.SetCoord(theX,theY,theZ);
710 }
711
712 /*!
713   \brief Start the point selection process.
714 */
715 void OCCViewer_ViewWindow::activateStartPointSelection()
716 {
717   myPrevPointType = myCurrPointType;
718   myCurrPointType = SELECTED;
719
720   // activate selection ------>
721   Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
722
723   ic->OpenLocalContext();
724
725   AIS_ListOfInteractive aList;
726   ic->DisplayedObjects( aList );
727   for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() )
728   {
729     Handle(AIS_InteractiveObject) anObj = it.Value();
730     if ( !anObj.IsNull() && anObj->HasPresentation() &&
731          anObj->IsKind( STANDARD_TYPE(AIS_Shape) ) )
732     {
733       ic->Load(anObj,-1);
734       ic->Activate(anObj,AIS_Shape::SelectionMode(TopAbs_VERTEX));
735      }
736   }
737   // activate selection <------
738
739   if ( !myCursorIsHand )
740   {
741     QCursor handCursor (Qt::PointingHandCursor);
742     myCursorIsHand = true;
743     myCursor = cursor();
744     myViewPort->setCursor( handCursor );
745   }
746   myRotationPointSelection = true;
747 }
748
749 /*!
750   \brief Start global panning operation
751
752   Sets the corresponding cursor for the widget.
753 */
754 void OCCViewer_ViewWindow::activateGlobalPanning()
755 {
756   Handle(V3d_View) aView3d = myViewPort->getView();
757   if ( !aView3d.IsNull() ) {
758     QPixmap globalPanPixmap (imageCrossCursor);
759     QCursor glPanCursor (globalPanPixmap);
760     myCurScale = aView3d->Scale();
761     aView3d->FitAll(0.01, false);
762     myCursor = cursor();                // save old cursor
763     myViewPort->fitAll(); // fits view before selecting a new scene center
764     if( setTransformRequested( PANGLOBAL ) )
765       myViewPort->setCursor( glPanCursor );
766   }
767 }
768
769 /*!
770   \brief Starts fit operation.
771
772   Sets the corresponding cursor for the widget.
773 */
774 void OCCViewer_ViewWindow::activateWindowFit()
775 {
776   if ( !transformRequested() && !myCursorIsHand )
777     myCursor = cursor();                /* save old cursor */
778
779   if ( myOperation != WINDOWFIT ) {
780     QCursor handCursor (Qt::PointingHandCursor);
781     if( setTransformRequested ( WINDOWFIT ) )
782     {
783       myViewPort->setCursor ( handCursor );
784       myCursorIsHand = true;
785     }
786   }
787 }
788
789 /*!
790   \brief Start delayed viewer operation.
791 */
792 bool OCCViewer_ViewWindow::setTransformRequested( OperationType op )
793 {
794   bool ok = transformEnabled( op );
795   myOperation = ok ? op : NOTHING;
796   myViewPort->setMouseTracking( myOperation == NOTHING );  
797   return ok;
798 }
799
800 /*!
801   \brief Handle mouse move event.
802   \param theEvent mouse event
803 */
804 void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent )
805 {
806   if ( myIsKeyFree && interactionStyle() == SUIT_ViewModel::KEY_FREE ) {
807     myIsKeyFree = false;
808     switch ( getButtonState( theEvent, interactionStyle() ) ) {
809     case ZOOMVIEW:
810       myViewPort->startZoomAtPoint( myStartX, myStartY );
811       activateZoom();
812       break;
813     case PANVIEW:
814       activatePanning();
815       break;
816     case ROTATE:
817       activateRotation();
818       myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
819       break;
820     default:
821       break;
822     }
823   }
824
825   myCurrX = theEvent->x();
826   myCurrY = theEvent->y();
827   switch (myOperation) {
828   case ROTATE:
829     myViewPort->rotate(myCurrX, myCurrY, myCurrPointType, mySelectedPoint);
830     break;
831
832   case ZOOMVIEW:
833     myViewPort->zoom(myStartX, myStartY, myCurrX, myCurrY);
834     myStartX = myCurrX;
835     myStartY = myCurrY;
836     break;
837
838   case PANVIEW:
839     myViewPort->pan(myCurrX - myStartX, myStartY - myCurrY);
840     myStartX = myCurrX;
841     myStartY = myCurrY;
842     break;
843
844 /*    case WINDOWFIT:
845     myDrawRect = true;
846     repaint();
847     break;
848 */
849   case PANGLOBAL:
850     break;
851
852   default:
853     if ( myRotationPointSelection || isSketcherStyle() )
854     {
855       emit mouseMoving( this, theEvent );
856     }
857     else
858     {
859       int aState = theEvent->modifiers();
860       int aButton = theEvent->buttons();
861       int anInteractionStyle = interactionStyle();
862       if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD &&
863            aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||
864            ( anInteractionStyle == SUIT_ViewModel::KEY_FREE &&
865            aButton == Qt::LeftButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {
866         myDrawRect = myEnableDrawMode;
867         if ( myDrawRect ) {
868           drawRect();
869           if ( !myCursorIsHand )        {   // we are going to sketch a rectangle
870             QCursor handCursor (Qt::PointingHandCursor);
871             myCursorIsHand = true;
872             myCursor = cursor();
873             myViewPort->setCursor( handCursor );
874           }
875         }
876         emit mouseMoving( this, theEvent );
877       }
878       else if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD &&
879                 aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||
880                 ( anInteractionStyle == SUIT_ViewModel::KEY_FREE &&
881                 aButton == Qt::RightButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {
882         OCCViewer_ViewSketcher* sketcher = 0;
883         QList<OCCViewer_ViewSketcher*>::Iterator it;
884         for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )
885         {
886           OCCViewer_ViewSketcher* sk = (*it);
887           if( sk->isDefault() && sk->sketchButton() == aButton )
888             sketcher = sk;
889         }
890         if ( sketcher && myCurSketch == -1 )
891         {
892           activateSketching( sketcher->type() );
893           if ( mypSketcher )
894           {
895             myCurSketch = mypSketcher->sketchButton();
896
897             if ( l_mbPressEvent )
898             {
899               QApplication::sendEvent( getViewPort(), l_mbPressEvent );
900               delete l_mbPressEvent;
901               l_mbPressEvent = 0;
902             }
903             QApplication::sendEvent( getViewPort(), theEvent );
904           }
905         }
906       }
907       else
908         emit mouseMoving( this, theEvent );
909     }
910   }
911 }
912
913 /*!
914   \brief Handle mouse release event.
915   \param theEvent mouse event
916 */
917 void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)
918 {
919   switch ( myOperation ) {
920   case NOTHING:
921     {
922       int prevState = myCurSketch;
923       if(theEvent->button() == Qt::RightButton)
924       {
925         QList<OCCViewer_ViewSketcher*>::Iterator it;
926         for ( it = mySketchers.begin(); it != mySketchers.end() && myCurSketch != -1; ++it )
927         {
928           OCCViewer_ViewSketcher* sk = (*it);
929           if( ( sk->sketchButton() & theEvent->button() ) && sk->sketchButton() == myCurSketch )
930             myCurSketch = -1;
931         }
932       }
933
934       emit mouseReleased(this, theEvent);
935       if(theEvent->button() == Qt::RightButton && prevState == -1)
936       {
937         QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
938                                   theEvent->pos(), theEvent->globalPos() );
939         emit contextMenuRequested( &aEvent );
940       }
941     }
942     break;
943   case ROTATE:
944     myViewPort->endRotation();
945     resetState();
946     break;
947
948   case PANVIEW:
949   case ZOOMVIEW:
950     resetState();
951     break;
952
953   case PANGLOBAL:
954     if ( theEvent->button() == Qt::LeftButton ) {
955       myViewPort->setCenter( theEvent->x(), theEvent->y() );
956       myViewPort->getView()->SetScale(myCurScale);
957       resetState();
958     }
959     break;
960
961   case WINDOWFIT:
962     if ( theEvent->button() == Qt::LeftButton ) {
963       myCurrX = theEvent->x();
964       myCurrY = theEvent->y();
965       drawRect();
966       QRect rect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
967       if ( !rect.isEmpty() ) myViewPort->fitRect(rect);
968       endDrawRect();
969       resetState();
970     }
971     break;
972   }
973
974   // NOTE: viewer 3D detects a rectangle of selection using this event
975   // so we must emit it BEFORE resetting the selection rectangle
976
977   if ( theEvent->button() == Qt::LeftButton && myDrawRect ) {
978     drawRect();
979     endDrawRect();
980     resetState();
981     myViewPort->update();
982   }
983
984   if ( l_mbPressEvent )
985   {
986     delete l_mbPressEvent;
987     l_mbPressEvent = 0;
988   }
989 }
990
991 /*!
992   \brief Reset the viewport to its initial state
993   ( no transformations in process etc. )
994 */
995 void OCCViewer_ViewWindow::resetState()
996 {
997   myDrawRect = false;
998
999   if ( myRotationPointSelection )
1000   {
1001     QCursor handCursor (Qt::PointingHandCursor);
1002     myViewPort->setCursor( handCursor );
1003   }
1004   else
1005   {
1006     if ( transformRequested() || myCursorIsHand )
1007       myViewPort->setCursor( myCursor );
1008     myCursorIsHand = false;
1009   }
1010
1011   if ( transformRequested() )
1012     emit vpTransformationFinished (myOperation);
1013
1014   setTransformInProcess( false );
1015   setTransformRequested( NOTHING );
1016 }
1017
1018
1019 /*!
1020   \brief Draw rubber band rectangle.
1021 */
1022 void OCCViewer_ViewWindow::drawRect()
1023 {
1024   if ( !myRectBand ) {
1025     myRectBand = new QtxRectRubberBand( myViewPort );
1026     //QPalette palette;
1027     //palette.setColor(myRectBand->foregroundRole(), Qt::white);
1028     //myRectBand->setPalette(palette);
1029   }
1030   //myRectBand->hide();
1031   
1032   myRectBand->setUpdatesEnabled ( false );
1033   QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
1034   myRectBand->initGeometry( aRect );
1035
1036   if ( !myRectBand->isVisible() )
1037     myRectBand->show();
1038
1039   myRectBand->setUpdatesEnabled ( true );
1040   //myRectBand->repaint();
1041
1042   //myRectBand->setVisible( aRect.isValid() );
1043   //if ( myRectBand->isVisible() )
1044   //  myRectBand->repaint();
1045   //else
1046   //  myRectBand->show();
1047   //myRectBand->repaint();
1048 }
1049
1050 /*!
1051   \brief Clear rubber band rectangle on the end on the dragging operation.
1052 */
1053 void OCCViewer_ViewWindow::endDrawRect()
1054 {
1055   //delete myRectBand;
1056   //myRectBand = 0;
1057   if ( myRectBand )
1058     {
1059       myRectBand->clearGeometry();
1060       myRectBand->hide();
1061     }
1062 }
1063
1064 /*!
1065   \brief Create actions.
1066 */
1067 void OCCViewer_ViewWindow::createActions()
1068 {
1069   if( !toolMgr()->isEmpty() )
1070     return;
1071   
1072   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1073
1074   QtxAction* aAction;
1075
1076   // Dump view
1077   aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_DUMP" ) ),
1078                            tr( "MNU_DUMP_VIEW" ), 0, this);
1079   aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
1080   connect(aAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
1081   toolMgr()->registerAction( aAction, DumpId );
1082
1083   // FitAll
1084   aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITALL" ) ),
1085                            tr( "MNU_FITALL" ), 0, this);
1086   aAction->setStatusTip(tr("DSC_FITALL"));
1087   connect(aAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
1088   toolMgr()->registerAction( aAction, FitAllId );
1089
1090   // FitRect
1091   aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITAREA" ) ),
1092                            tr( "MNU_FITRECT" ), 0, this);
1093   aAction->setStatusTip(tr("DSC_FITRECT"));
1094   connect(aAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
1095   toolMgr()->registerAction( aAction, FitRectId );
1096   
1097   // Zoom
1098   aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ZOOM" ) ),
1099                            tr( "MNU_ZOOM_VIEW" ), 0, this);
1100   aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
1101   connect(aAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
1102   toolMgr()->registerAction( aAction, ZoomId );
1103
1104   // Panning
1105   aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ),
1106                            tr( "MNU_PAN_VIEW" ), 0, this);
1107   aAction->setStatusTip(tr("DSC_PAN_VIEW"));
1108   connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
1109   toolMgr()->registerAction( aAction, PanId );
1110
1111   // Global Panning
1112   aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_GLOBALPAN" ) ),
1113                            tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
1114   aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
1115   connect(aAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
1116   toolMgr()->registerAction( aAction, GlobalPanId );
1117
1118   // Rotation Point
1119   mySetRotationPointAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATION_POINT" ) ),
1120                            tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
1121   mySetRotationPointAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
1122   mySetRotationPointAction->setCheckable( true );
1123   connect(mySetRotationPointAction, SIGNAL(toggled( bool )), this, SLOT(onSetRotationPoint( bool )));
1124   toolMgr()->registerAction( mySetRotationPointAction, ChangeRotationPointId );
1125
1126   // Rotation
1127   aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATE" ) ),
1128                            tr( "MNU_ROTATE_VIEW" ), 0, this);
1129   aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
1130   connect(aAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
1131   toolMgr()->registerAction( aAction, RotationId );
1132
1133   // Projections
1134   aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FRONT" ) ),
1135                            tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
1136   aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
1137   connect(aAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
1138   this->addAction(aAction);
1139   toolMgr()->registerAction( aAction, FrontId );
1140
1141   aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BACK" ) ),
1142                            tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
1143   aAction->setStatusTip(tr("DSC_BACK_VIEW"));
1144   connect(aAction, SIGNAL(triggered()), this, SLOT(onBackView()));
1145   this->addAction(aAction);
1146   toolMgr()->registerAction( aAction, BackId );
1147
1148   aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TOP" ) ),
1149                            tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
1150   aAction->setStatusTip(tr("DSC_TOP_VIEW"));
1151   connect(aAction, SIGNAL(triggered()), this, SLOT(onTopView()));
1152   this->addAction(aAction);
1153   toolMgr()->registerAction( aAction, TopId );
1154
1155   aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BOTTOM" ) ),
1156                            tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
1157   aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
1158   connect(aAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
1159   this->addAction(aAction);
1160   toolMgr()->registerAction( aAction, BottomId );
1161   
1162   aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_LEFT" ) ),
1163                            tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
1164   aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
1165   connect(aAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
1166   this->addAction(aAction);
1167   toolMgr()->registerAction( aAction, LeftId );
1168
1169   aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RIGHT" ) ),
1170                            tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
1171   aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
1172   connect(aAction, SIGNAL(triggered()), this, SLOT(onRightView()));
1173   this->addAction(aAction);
1174   toolMgr()->registerAction( aAction, RightId );
1175
1176   // rotate anticlockwise
1177   aAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ANTICLOCKWISE" ) ),
1178                            tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
1179   aAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
1180   connect(aAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
1181   this->addAction(aAction);
1182   toolMgr()->registerAction( aAction, AntiClockWiseId );
1183
1184   // rotate clockwise
1185   aAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_CLOCKWISE" ) ),
1186                            tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
1187   aAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
1188   connect(aAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
1189   this->addAction(aAction);
1190   toolMgr()->registerAction( aAction, ClockWiseId );
1191
1192   // Reset
1193   aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RESET" ) ),
1194                            tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
1195   aAction->setStatusTip(tr("DSC_RESET_VIEW"));
1196   connect(aAction, SIGNAL(triggered()), this, SLOT(onResetView()));
1197   this->addAction(aAction);
1198   toolMgr()->registerAction( aAction, ResetId );
1199
1200   // Clone
1201   aAction = new QtxAction(tr("MNU_CLONE_VIEW"),
1202                           aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_CLONE_VIEW")),
1203                           tr("MNU_CLONE_VIEW"), 0, this);
1204   aAction->setStatusTip(tr("DSC_CLONE_VIEW"));
1205   connect(aAction, SIGNAL(triggered()), this, SLOT(onCloneView()));
1206   toolMgr()->registerAction( aAction, CloneId );
1207
1208   myClippingAction = new QtxAction(tr("MNU_CLIPPING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ) ),
1209                            tr( "MNU_CLIPPING" ), 0, this);
1210   myClippingAction->setStatusTip(tr("DSC_CLIPPING"));
1211   myClippingAction->setCheckable( true );
1212   connect(myClippingAction, SIGNAL(toggled( bool )), this, SLOT(onClipping( bool )));
1213   toolMgr()->registerAction( myClippingAction, ClippingId );
1214
1215   aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ),
1216                            tr( "MNU_SHOOT_VIEW" ), 0, this);
1217   aAction->setStatusTip(tr("DSC_SHOOT_VIEW"));
1218   connect(aAction, SIGNAL(triggered()), this, SLOT(onMemorizeView()));
1219   toolMgr()->registerAction( aAction, MemId );
1220
1221   aAction = new QtxAction(tr("MNU_PRESETS_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESETS_VIEW" ) ),
1222                            tr( "MNU_PRESETS_VIEW" ), 0, this);
1223   aAction->setStatusTip(tr("DSC_PRESETS_VIEW"));
1224   connect(aAction, SIGNAL(triggered()), this, SLOT(onRestoreView()));
1225   toolMgr()->registerAction( aAction, RestoreId );
1226
1227   if (myModel->trihedronActivated()) {
1228     aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TRIHEDRON" ) ),
1229                              tr( "MNU_SHOW_TRIHEDRE" ), 0, this);
1230     aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRE"));
1231     connect(aAction, SIGNAL(triggered()), this, SLOT(onTrihedronShow()));
1232     toolMgr()->registerAction( aAction, TrihedronShowId );
1233   }
1234
1235   // Scale
1236   aAction = new QtxAction(tr("MNU_SCALING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SCALING" ) ),
1237                            tr( "MNU_SCALING" ), 0, this);
1238   aAction->setStatusTip(tr("DSC_SCALING"));
1239   connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale()));
1240   toolMgr()->registerAction( aAction, AxialScaleId );
1241
1242   // Enable/disable preselection
1243   aAction = new QtxAction(tr("MNU_ENABLE_PRESELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESELECTION" ) ),
1244                           tr( "MNU_ENABLE_PRESELECTION" ), 0, this);
1245   aAction->setStatusTip(tr("DSC_ENABLE_PRESELECTION"));
1246   aAction->setCheckable(true);
1247   connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchPreselection(bool)));
1248   toolMgr()->registerAction( aAction, SwitchPreselectionId );
1249
1250   // Enable/disable selection
1251   aAction = new QtxAction(tr("MNU_ENABLE_SELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SELECTION" ) ),
1252                           tr( "MNU_ENABLE_SELECTION" ), 0, this);
1253   aAction->setStatusTip(tr("DSC_ENABLE_SELECTION"));
1254   aAction->setCheckable(true);
1255   connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchSelection(bool)));
1256   toolMgr()->registerAction( aAction, SwitchSelectionId );
1257
1258   // Graduated axes 
1259   aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ),
1260                            tr( "MNU_GRADUATED_AXES" ), 0, this);
1261   aAction->setStatusTip(tr("DSC_GRADUATED_AXES"));
1262   connect(aAction, SIGNAL(triggered()), this, SLOT(onGraduatedAxes()));
1263   toolMgr()->registerAction( aAction, GraduatedAxesId );
1264
1265   // Active only ambient light or not
1266   aAction = new QtxAction(tr("MNU_AMBIENT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_AMBIENT" ) ),
1267                            tr( "MNU_AMBIENT" ), 0, this);
1268   aAction->setStatusTip(tr("DSC_AMBIENT"));
1269   connect(aAction, SIGNAL(triggered()), this, SLOT(onAmbientToogle()));
1270   toolMgr()->registerAction( aAction, AmbientId );
1271
1272   // Switch between interaction styles
1273   aAction = new QtxAction(tr("MNU_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_STYLE_SWITCH" ) ),
1274                           tr( "MNU_STYLE_SWITCH" ), 0, this);
1275   aAction->setStatusTip(tr("DSC_STYLE_SWITCH"));
1276   aAction->setCheckable(true);
1277   connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
1278   toolMgr()->registerAction( aAction, SwitchInteractionStyleId );
1279
1280   // Switch between zooming styles
1281   aAction = new QtxAction(tr("MNU_ZOOMING_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_ZOOMING_STYLE_SWITCH" ) ),
1282                           tr( "MNU_ZOOMING_STYLE_SWITCH" ), 0, this);
1283   aAction->setStatusTip(tr("DSC_ZOOMING_STYLE_SWITCH"));
1284   aAction->setCheckable(true);
1285   connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
1286   toolMgr()->registerAction( aAction, SwitchZoomingStyleId );
1287
1288   // Maximized view
1289   aAction = new QtxAction(tr("MNU_MINIMIZE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ),
1290                           tr( "MNU_MINIMIZE_VIEW" ), 0, this );
1291   aAction->setStatusTip(tr("DSC_MINIMIZE_VIEW"));
1292   connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView()));
1293   toolMgr()->registerAction( aAction, MaximizedId );
1294
1295   // Synchronize View 
1296   toolMgr()->registerAction( synchronizeAction(), SynchronizeId );
1297 }
1298
1299 /*!
1300   \brief Create toolbar.
1301 */
1302 void OCCViewer_ViewWindow::createToolBar()
1303 {
1304   QString aToolbarName;
1305   switch (my2dMode) {
1306   case XYPlane:
1307     aToolbarName = tr( "LBL_XYTOOLBAR_LABEL" );
1308     break;
1309   case XZPlane:
1310     aToolbarName = tr( "LBL_XZTOOLBAR_LABEL" );
1311     break;
1312   case YZPlane:
1313     aToolbarName = tr( "LBL_YZTOOLBAR_LABEL" );
1314     break;
1315   default:
1316     aToolbarName = tr( "LBL_3DTOOLBAR_LABEL" );
1317   }
1318   
1319   int tid = toolMgr()->createToolBar( aToolbarName, false );
1320
1321   toolMgr()->append( DumpId, tid );
1322   toolMgr()->append( SwitchInteractionStyleId, tid );
1323 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
1324   toolMgr()->append( SwitchZoomingStyleId, tid );
1325 #endif
1326   toolMgr()->append( SwitchPreselectionId, tid );
1327   toolMgr()->append( SwitchSelectionId, tid );
1328   if( myModel->trihedronActivated() )
1329     toolMgr()->append( TrihedronShowId, tid );
1330
1331   QtxMultiAction* aScaleAction = new QtxMultiAction( this );
1332   aScaleAction->insertAction( toolMgr()->action( FitAllId ) );
1333   aScaleAction->insertAction( toolMgr()->action( FitRectId ) );
1334   aScaleAction->insertAction( toolMgr()->action( ZoomId ) );
1335   toolMgr()->append( aScaleAction, tid );
1336
1337   QtxMultiAction* aPanningAction = new QtxMultiAction( this );
1338   aPanningAction->insertAction( toolMgr()->action( PanId ) );
1339   aPanningAction->insertAction( toolMgr()->action( GlobalPanId ) );
1340   toolMgr()->append( aPanningAction, tid );
1341
1342   if (my2dMode == No2dMode) {
1343     toolMgr()->append( ChangeRotationPointId, tid );
1344     toolMgr()->append( RotationId, tid );
1345
1346     QtxMultiAction* aViewsAction = new QtxMultiAction( this );
1347     aViewsAction->insertAction( toolMgr()->action( FrontId ) );
1348     aViewsAction->insertAction( toolMgr()->action( BackId ) );
1349     aViewsAction->insertAction( toolMgr()->action( TopId ) );
1350     aViewsAction->insertAction( toolMgr()->action( BottomId ) );
1351     aViewsAction->insertAction( toolMgr()->action( LeftId ) );
1352     aViewsAction->insertAction( toolMgr()->action( RightId ) );
1353     toolMgr()->append( aViewsAction, tid );
1354
1355     toolMgr()->append( AntiClockWiseId, tid );
1356     toolMgr()->append( ClockWiseId, tid );
1357
1358     toolMgr()->append( ResetId, tid );
1359   }
1360
1361   QtxMultiAction* aMemAction = new QtxMultiAction( this );
1362   aMemAction->insertAction( toolMgr()->action( MemId ) );
1363   aMemAction->insertAction( toolMgr()->action( RestoreId ) );
1364   toolMgr()->append( aMemAction, tid );
1365
1366   toolMgr()->append( toolMgr()->separator(), tid );
1367   toolMgr()->append( CloneId, tid );
1368   
1369   toolMgr()->append( toolMgr()->separator(), tid );
1370   toolMgr()->append( ClippingId, tid );
1371   toolMgr()->append( AxialScaleId, tid );
1372 #if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version
1373   toolMgr()->append( GraduatedAxesId, tid );
1374 #endif
1375   toolMgr()->append( AmbientId, tid );
1376
1377   toolMgr()->append( MaximizedId, tid );
1378   toolMgr()->append( SynchronizeId, tid );
1379 }
1380
1381 /*!
1382   \brief Perform 'fit all' operation.
1383 */
1384 void OCCViewer_ViewWindow::onViewFitAll()
1385 {
1386   myViewPort->fitAll();
1387 }
1388
1389 /*!
1390   \brief Perform "front view" transformation.
1391 */
1392 void OCCViewer_ViewWindow::onFrontView()
1393 {
1394   emit vpTransformationStarted ( FRONTVIEW );
1395   Handle(V3d_View) aView3d = myViewPort->getView();
1396   if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xpos);
1397   onViewFitAll();
1398   emit vpTransformationFinished ( FRONTVIEW );
1399 }
1400
1401 /*!
1402   \brief Perform "back view" transformation.
1403 */
1404 void OCCViewer_ViewWindow::onBackView()
1405 {
1406   emit vpTransformationStarted ( BACKVIEW );
1407   Handle(V3d_View) aView3d = myViewPort->getView();
1408   if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xneg);
1409   onViewFitAll();
1410   emit vpTransformationFinished ( BACKVIEW );
1411 }
1412
1413 /*!
1414   \brief Perform "top view" transformation.
1415 */
1416 void OCCViewer_ViewWindow::onTopView()
1417 {
1418   emit vpTransformationStarted ( TOPVIEW );
1419   Handle(V3d_View) aView3d = myViewPort->getView();
1420   if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zpos);
1421   onViewFitAll();
1422   emit vpTransformationFinished ( TOPVIEW );
1423 }
1424
1425 /*!
1426   \brief Perform "bottom view" transformation.
1427 */
1428 void OCCViewer_ViewWindow::onBottomView()
1429 {
1430   emit vpTransformationStarted ( BOTTOMVIEW );
1431   Handle(V3d_View) aView3d = myViewPort->getView();
1432   if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zneg);
1433   onViewFitAll();
1434   emit vpTransformationFinished ( BOTTOMVIEW );
1435 }
1436
1437 /*!
1438   \brief Perform "left view" transformation.
1439 */
1440 void OCCViewer_ViewWindow::onLeftView()
1441 {
1442   emit vpTransformationStarted ( LEFTVIEW );
1443   Handle(V3d_View) aView3d = myViewPort->getView();
1444   if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Yneg);
1445   onViewFitAll();
1446   emit vpTransformationFinished ( LEFTVIEW );
1447 }
1448
1449 /*!
1450   \brief Perform "right view" transformation.
1451 */
1452 void OCCViewer_ViewWindow::onRightView()
1453 {
1454   emit vpTransformationStarted ( RIGHTVIEW );
1455   Handle(V3d_View) aView3d = myViewPort->getView();
1456   if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Ypos);
1457   onViewFitAll();
1458   emit vpTransformationFinished ( RIGHTVIEW );
1459 }
1460
1461 /*!
1462   \brief Rotate view 90 degrees clockwise
1463 */
1464 void OCCViewer_ViewWindow::onClockWiseView()
1465 {
1466   emit vpTransformationStarted ( CLOCKWISEVIEW );
1467   myViewPort->rotateXY( 90. );
1468   emit vpTransformationFinished ( CLOCKWISEVIEW );
1469 }
1470
1471 /*!
1472   \brief Rotate view 90 degrees conterclockwise
1473 */
1474 void OCCViewer_ViewWindow::onAntiClockWiseView()
1475 {
1476   emit vpTransformationStarted ( ANTICLOCKWISEVIEW );
1477   myViewPort->rotateXY( -90. );
1478   emit vpTransformationFinished ( ANTICLOCKWISEVIEW );
1479 }
1480
1481 /*!
1482   \brief Perform "reset view" transformation.
1483
1484   Sets default orientation of the viewport camera.
1485 */
1486 void OCCViewer_ViewWindow::onResetView()
1487 {
1488   emit vpTransformationStarted( RESETVIEW );
1489   bool upd = myViewPort->getView()->SetImmediateUpdate( false );
1490   myViewPort->getView()->Reset( false );
1491   myViewPort->fitAll( false, true, false );
1492   myViewPort->getView()->SetImmediateUpdate( upd );
1493   myViewPort->getView()->Update();
1494   emit vpTransformationFinished( RESETVIEW );
1495 }
1496
1497 /*!
1498   \brief Perform "fit all" transformation.
1499 */
1500 void OCCViewer_ViewWindow::onFitAll()
1501 {
1502   emit vpTransformationStarted( FITALLVIEW );
1503   myViewPort->fitAll();
1504   emit vpTransformationFinished( FITALLVIEW );
1505 }
1506
1507 /*!
1508   \brief Called if 'change rotation point' operation is activated.
1509   \param on action state
1510 */
1511 void OCCViewer_ViewWindow::onSetRotationPoint( bool on )
1512 {
1513   if (on)
1514   {
1515     if (!mySetRotationPointDlg)
1516     {
1517       mySetRotationPointDlg = new OCCViewer_SetRotationPointDlg (this);
1518       mySetRotationPointDlg->SetAction(mySetRotationPointAction);
1519     }
1520
1521     if (!mySetRotationPointDlg->isVisible())
1522     {
1523       //if (mySetRotationPointDlg->IsFirstShown())
1524       if (myCurrPointType == GRAVITY)
1525       {
1526         Standard_Real Xcenter, Ycenter, Zcenter;
1527         if (computeGravityCenter(Xcenter, Ycenter, Zcenter))
1528           mySetRotationPointDlg->setCoords(Xcenter, Ycenter, Zcenter);
1529       }
1530       mySetRotationPointDlg->show();
1531     }
1532   }
1533   else
1534   {
1535     if (mySetRotationPointDlg->isVisible())
1536       mySetRotationPointDlg->hide();
1537   }
1538 }
1539
1540 /*!
1541    \brief Create one more window with same content.
1542 */
1543 void OCCViewer_ViewWindow::onCloneView()
1544 {
1545   SUIT_ViewWindow* vw = myManager->createViewWindow();
1546   //vw->show();
1547   emit viewCloned( vw );
1548 }
1549
1550 /*!
1551   \brief called if clipping operation is activated.
1552
1553   Enables/disables clipping plane displaying.
1554
1555   \parma on action state
1556 */
1557 void OCCViewer_ViewWindow::onClipping( bool on )
1558 {
1559   /*
1560   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1561   if ( on )
1562     myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING_PRESSED" )));
1563   else
1564     myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" )));
1565   */
1566   OCCViewer_ViewWindow* aParent = dynamic_cast<OCCViewer_ViewWindow*>(parent()->parent());
1567   if (!aParent)
1568     aParent = this;
1569   if ( on )
1570     {
1571       if ( !myClippingDlg )
1572         {
1573           myClippingDlg = new OCCViewer_ClippingDlg( aParent );
1574           myClippingDlg->SetAction( myClippingAction );
1575         }
1576     
1577       if ( !myClippingDlg->isVisible() )
1578         myClippingDlg->show();
1579     }
1580   else
1581     {
1582       if ( myClippingDlg->isVisible() )
1583         myClippingDlg->hide();
1584       aParent->setCuttingPlane(false);
1585     }
1586 }
1587
1588 /*!
1589   Creates one more window with same content
1590 */
1591 void OCCViewer_ViewWindow::onAxialScale()
1592 {
1593   if ( !myScalingDlg )
1594     myScalingDlg = new OCCViewer_AxialScaleDlg( this );
1595   
1596   if ( !myScalingDlg->isVisible() )
1597   {
1598     myScalingDlg->Update();
1599     myScalingDlg->show();
1600   }
1601 }
1602
1603 /*!
1604   Shows Graduated Axes dialog
1605 */
1606 void OCCViewer_ViewWindow::onGraduatedAxes()
1607 {
1608   myCubeAxesDlg->Update();
1609   myCubeAxesDlg->show();
1610 }
1611
1612 void OCCViewer_ViewWindow::onAmbientToogle()
1613 {
1614   Handle(V3d_Viewer) viewer = myViewPort->getViewer();
1615   viewer->InitDefinedLights();
1616   while(viewer->MoreDefinedLights())
1617     {
1618       Handle(V3d_Light) light = viewer->DefinedLight();
1619       if(light->Type() != V3d_AMBIENT)
1620         {
1621           Handle(V3d_View) aView3d = myViewPort->getView();
1622           if( aView3d->IsActiveLight(light) ) viewer->SetLightOff(light);
1623           else viewer->SetLightOn(light);
1624         }
1625       viewer->NextDefinedLights();
1626     }
1627   viewer->Update();
1628 }
1629
1630 /*!
1631   \brief Store view parameters.
1632 */
1633 void OCCViewer_ViewWindow::onMemorizeView()
1634 {
1635   appendViewAspect( getViewParams() );
1636 }
1637
1638 /*!
1639   \brief Restore view parameters.
1640 */
1641 void OCCViewer_ViewWindow::onRestoreView()
1642 {
1643   OCCViewer_CreateRestoreViewDlg* aDlg = new OCCViewer_CreateRestoreViewDlg( centralWidget(), this );
1644   connect( aDlg, SIGNAL( dlgOk() ), this, SLOT( setRestoreFlag() ) );
1645   aDlg->exec();
1646   updateViewAspects( aDlg->parameters() );
1647   if( myRestoreFlag && aDlg->parameters().count() )
1648     performRestoring( aDlg->currentItem() );
1649 }
1650
1651 /*!
1652   \brief Restore view parameters.
1653   \param anItem view parameters
1654 */
1655 void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool baseParamsOnly )
1656 {
1657   Handle(V3d_View) aView3d = myViewPort->getView();
1658
1659   Standard_Boolean prev = aView3d->SetImmediateUpdate( Standard_False );
1660   aView3d->SetScale( anItem.scale );
1661   aView3d->SetCenter( anItem.centerX, anItem.centerY );
1662   aView3d->SetTwist( anItem.twist );
1663   aView3d->SetAt( anItem.atX, anItem.atY, anItem.atZ );
1664   aView3d->SetImmediateUpdate( prev );
1665   aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );
1666   aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );
1667   aView3d->SetAxialScale( anItem.scaleX, anItem.scaleY, anItem.scaleZ );
1668
1669   if ( !baseParamsOnly ) {
1670
1671     myModel->setTrihedronShown( anItem.isVisible );
1672     myModel->setTrihedronSize( anItem.size );
1673         
1674 #if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version
1675     // graduated trihedron
1676     bool anIsVisible = anItem.gtIsVisible;
1677     OCCViewer_AxisWidget::AxisData anAxisData[3];
1678     anAxisData[0].DrawName = anItem.gtDrawNameX;
1679     anAxisData[1].DrawName = anItem.gtDrawNameZ;
1680     anAxisData[2].DrawName = anItem.gtDrawNameZ;
1681     anAxisData[0].Name = anItem.gtNameX;
1682     anAxisData[1].Name = anItem.gtNameZ;
1683     anAxisData[2].Name = anItem.gtNameZ;
1684     anAxisData[0].NameColor = QColor( anItem.gtNameColorRX,
1685                                       anItem.gtNameColorGX,
1686                                       anItem.gtNameColorBX );
1687     anAxisData[1].NameColor = QColor( anItem.gtNameColorRY,
1688                                       anItem.gtNameColorGY,
1689                                       anItem.gtNameColorBY );
1690     anAxisData[2].NameColor = QColor( anItem.gtNameColorRZ,
1691                                       anItem.gtNameColorGZ,
1692                                       anItem.gtNameColorBZ );
1693     anAxisData[0].DrawValues = anItem.gtDrawValuesX;
1694     anAxisData[1].DrawValues = anItem.gtDrawValuesY;
1695     anAxisData[2].DrawValues = anItem.gtDrawValuesZ;
1696     anAxisData[0].NbValues = anItem.gtNbValuesX;
1697     anAxisData[1].NbValues = anItem.gtNbValuesY;
1698     anAxisData[2].NbValues = anItem.gtNbValuesZ;
1699     anAxisData[0].Offset = anItem.gtOffsetX;
1700     anAxisData[1].Offset = anItem.gtOffsetY;
1701     anAxisData[2].Offset = anItem.gtOffsetZ;
1702     anAxisData[0].Color = QColor( anItem.gtColorRX,
1703                                   anItem.gtColorGX,
1704                                   anItem.gtColorBX );
1705     anAxisData[1].Color = QColor( anItem.gtColorRY,
1706                                   anItem.gtColorGY,
1707                                   anItem.gtColorBY );
1708     anAxisData[2].Color = QColor( anItem.gtColorRZ,
1709                                   anItem.gtColorGZ,
1710                                   anItem.gtColorBZ );
1711     anAxisData[0].DrawTickmarks = anItem.gtDrawTickmarksX;
1712     anAxisData[1].DrawTickmarks = anItem.gtDrawTickmarksY;
1713     anAxisData[2].DrawTickmarks = anItem.gtDrawTickmarksZ;
1714     anAxisData[0].TickmarkLength = anItem.gtTickmarkLengthX;
1715     anAxisData[1].TickmarkLength = anItem.gtTickmarkLengthY;
1716     anAxisData[2].TickmarkLength = anItem.gtTickmarkLengthZ;
1717
1718     myCubeAxesDlg->SetData( anIsVisible, anAxisData );
1719     myCubeAxesDlg->ApplyData( aView3d );
1720 #endif
1721
1722   } // if ( !baseParamsOnly )
1723
1724   myRestoreFlag = 0;
1725 }
1726
1727 /*!
1728   \brief Set restore flag.
1729 */
1730 void OCCViewer_ViewWindow::setRestoreFlag()
1731 {
1732   myRestoreFlag = 1;
1733 }
1734
1735 /*!
1736   \brief Called when action "show/hide trihedron" is activated.
1737 */
1738 void OCCViewer_ViewWindow::onTrihedronShow()
1739 {
1740   myModel->toggleTrihedron();
1741 }
1742
1743 /*!
1744   \brief Toggles preselection (highlighting) on/off
1745 */
1746 void OCCViewer_ViewWindow::onSwitchPreselection( bool on )
1747 {
1748   myPreselectionEnabled = on;
1749   myModel->setSelectionOptions( isPreselectionEnabled(), myModel->isSelectionEnabled() );
1750
1751   // unhighlight all highlighted objects
1752   /*if ( !on ) {
1753     myModel->unHighlightAll( true, false );
1754   }*/
1755
1756   // update action state if method is called outside
1757   QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );
1758   if ( a && a->isChecked() != on ) {
1759     a->setChecked( on );
1760   }
1761 }
1762
1763 /*!
1764   \brief Toggles selection on/off
1765 */
1766 void OCCViewer_ViewWindow::onSwitchSelection( bool on )
1767 {
1768   mySelectionEnabled = on;
1769   myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() );
1770   
1771   // update action state if method is called outside
1772
1773   // preselection
1774   QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );
1775   if ( a ) {
1776     a->setEnabled( on );
1777   }
1778
1779   // selection
1780   a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchSelectionId ) );
1781   if ( a && a->isChecked() != on ) {
1782     a->setChecked( on );
1783   }
1784 }
1785
1786 /*!
1787   \brief Switches "keyboard free" interaction style on/off
1788 */
1789 void OCCViewer_ViewWindow::onSwitchInteractionStyle( bool on )
1790 {
1791   myInteractionStyle = on ? (int)SUIT_ViewModel::KEY_FREE : (int)SUIT_ViewModel::STANDARD;
1792
1793   // update action state if method is called outside
1794   QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchInteractionStyleId ) );
1795   if ( a->isChecked() != on )
1796     a->setChecked( on );
1797 }
1798
1799 /*!
1800   \brief Toogles advanced zooming style (relatively to the cursor position) on/off
1801 */
1802 void OCCViewer_ViewWindow::onSwitchZoomingStyle( bool on )
1803 {
1804   myViewPort->setAdvancedZoomingEnabled( on );
1805
1806   // update action state if method is called outside
1807   QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
1808   if ( a->isChecked() != on )
1809     a->setChecked( on );
1810 }
1811
1812 /*!
1813   \brief Get current interaction style
1814   \return interaction style
1815 */
1816 int OCCViewer_ViewWindow::interactionStyle() const
1817 {
1818   return myInteractionStyle;
1819 }
1820
1821 /*!
1822   \brief Set current interaction style
1823   \param theStyle interaction style
1824 */
1825 void OCCViewer_ViewWindow::setInteractionStyle( const int theStyle )
1826 {
1827   onSwitchInteractionStyle( theStyle == (int)SUIT_ViewModel::KEY_FREE );
1828 }
1829
1830 /*!
1831   \brief Get current zooming style
1832   \return zooming style
1833 */
1834 int OCCViewer_ViewWindow::zoomingStyle() const
1835 {
1836   return myViewPort->isAdvancedZoomingEnabled() ? 1 : 0;
1837 }
1838
1839 /*!
1840   \brief Set current zooming style
1841   \param theStyle zooming style
1842 */
1843 void OCCViewer_ViewWindow::setZoomingStyle( const int theStyle )
1844 {
1845   onSwitchZoomingStyle( theStyle == 1 );
1846 }
1847
1848 /*!
1849   \brief Dump view window contents to the pixmap.
1850   \return pixmap containing all scene rendered in the window
1851 */
1852 QImage OCCViewer_ViewWindow::dumpView()
1853 {
1854   Handle(V3d_View) view = myViewPort->getView();
1855   if ( view.IsNull() )
1856     return QImage();
1857   
1858   int aWidth = myViewPort->width();
1859   int aHeight = myViewPort->height();
1860   QApplication::syncX();
1861   view->Redraw(); // In order to reactivate GL context
1862   //view->Update();
1863
1864   OpenGLUtils_FrameBuffer aFrameBuffer;
1865   if( aFrameBuffer.init( aWidth, aHeight ) )
1866   {
1867     QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );
1868    
1869     glPushAttrib( GL_VIEWPORT_BIT );
1870     glViewport( 0, 0, aWidth, aHeight );
1871     aFrameBuffer.bind();
1872
1873     // draw scene
1874     view->Redraw();
1875
1876     aFrameBuffer.unbind();
1877     glPopAttrib();
1878
1879     aFrameBuffer.bind();
1880     glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );
1881     aFrameBuffer.unbind();
1882
1883     anImage = anImage.rgbSwapped();
1884     anImage = anImage.mirrored();
1885     return anImage;
1886   }
1887   // if frame buffers are unsupported, use old functionality
1888   //view->Redraw();
1889
1890   unsigned char* data = new unsigned char[ aWidth*aHeight*4 ];
1891
1892   QPoint p = myViewPort->mapFromParent(myViewPort->geometry().topLeft());
1893
1894   glReadPixels( p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE,
1895                 data);
1896
1897   QImage anImage( data, aWidth, aHeight, QImage::Format_ARGB32 );
1898   anImage = anImage.mirrored();
1899   anImage = anImage.rgbSwapped();
1900   return anImage;
1901 }
1902
1903 bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, 
1904                                              const QString& fileName, 
1905                                              const QString& format )
1906 {
1907   if ( format != "PS" && format != "EPS")
1908     return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
1909
1910   Handle(Visual3d_View) a3dView = myViewPort->getView()->View();
1911
1912   if (format == "PS")
1913     a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_PostScript);
1914   else if (format == "EPS")
1915     a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_EnhPostScript);
1916
1917   return true;
1918 }
1919
1920
1921 QString OCCViewer_ViewWindow::filter() const
1922 {
1923   return tr( "OCC_IMAGE_FILES" );
1924 }
1925
1926
1927 /*!
1928   \brief Set parameters of the cutting plane
1929   \param on if \c true, cutting plane is enabled
1930   \param x X position of plane point
1931   \param y Y position of plane point
1932   \param z Z position of plane point
1933   \param dx X coordinate of plane normal
1934   \param dy Y coordinate of plane normal
1935   \param dz Z coordinate of plane normal
1936 */
1937 void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x,  const double y,  const double z,
1938                                             const double dx, const double dy, const double dz )
1939 {
1940   Handle(V3d_View) view = myViewPort->getView();
1941   if ( view.IsNull() )
1942     return;
1943
1944   if ( on ) {
1945     Handle(V3d_Viewer) viewer = myViewPort->getViewer();
1946
1947     // try to use already existing plane or create a new one
1948     Handle(V3d_Plane) clipPlane;
1949     view->InitActivePlanes();
1950
1951     // calculate new a,b,c,d values for the plane
1952     gp_Pln pln (gp_Pnt(x, y, z), gp_Dir(dx, dy, dz));
1953     double a, b, c, d;
1954     pln.Coefficients(a, b, c, d);
1955
1956 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1957     if (view->MoreActivePlanes()) {
1958       clipPlane = view->ActivePlane();
1959       clipPlane->SetPlane(a, b, c, d);
1960     }
1961     else
1962       clipPlane = new V3d_Plane (a, b, c, d);
1963 #else
1964     if (view->MoreActivePlanes())
1965       clipPlane = view->ActivePlane();
1966     else
1967       clipPlane = new V3d_Plane (viewer);
1968
1969     clipPlane->SetPlane(a, b, c, d);
1970 #endif
1971
1972     view->SetPlaneOn(clipPlane);
1973   }
1974   else
1975     view->SetPlaneOff();
1976
1977   view->Update();
1978   view->Redraw();
1979 }
1980
1981 void OCCViewer_ViewWindow::setCuttingPlane( bool on, const gp_Pln pln )
1982 {
1983   gp_Dir aDir = pln.Axis().Direction();
1984   gp_Pnt aPnt = pln.Location();
1985   setCuttingPlane(on, aPnt.X(), aPnt.Y(), aPnt.Z(), aDir.X(), aDir.Y(), aDir.Z());
1986 }
1987
1988
1989 /*!
1990   \brief Check if any cutting plane is enabled
1991   \return \c true if at least one cutting plane is enabled
1992 */
1993 bool OCCViewer_ViewWindow::isCuttingPlane()
1994 {
1995   Handle(V3d_View) view = myViewPort->getView();
1996   view->InitActivePlanes();
1997   return (view->MoreActivePlanes());
1998 }
1999
2000 /*!
2001   \brief Get the visual parameters of the view window.
2002   \return visual parameters of view window
2003 */
2004 viewAspect OCCViewer_ViewWindow::getViewParams() const
2005 {
2006   double centerX, centerY, projX, projY, projZ, twist;
2007   double atX, atY, atZ, eyeX, eyeY, eyeZ;
2008   double aScaleX, aScaleY, aScaleZ;
2009
2010   Handle(V3d_View) aView3d = myViewPort->getView();
2011
2012   aView3d->Center( centerX, centerY );
2013   aView3d->Proj( projX, projY, projZ );
2014   aView3d->At( atX, atY, atZ );
2015   aView3d->Eye( eyeX, eyeY, eyeZ );
2016   twist = aView3d->Twist();
2017
2018   aView3d->AxialScale(aScaleX,aScaleY,aScaleZ);
2019
2020   bool isShown = myModel->isTrihedronVisible();
2021   double size = myModel->trihedronSize();
2022
2023   QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" );
2024
2025   viewAspect params;
2026   params.scale    = aView3d->Scale();
2027   params.centerX  = centerX;
2028   params.centerY  = centerY;
2029   params.projX    = projX;
2030   params.projY    = projY;
2031   params.projZ    = projZ;
2032   params.twist    = twist;
2033   params.atX      = atX;
2034   params.atY      = atY;
2035   params.atZ      = atZ;
2036   params.eyeX     = eyeX;
2037   params.eyeY     = eyeY;
2038   params.eyeZ     = eyeZ;
2039   params.scaleX   = aScaleX;
2040   params.scaleY   = aScaleY;
2041   params.scaleZ   = aScaleZ;
2042   params.name     = aName;
2043   params.isVisible= isShown;
2044   params.size     = size;
2045
2046 #if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version
2047   // graduated trihedron
2048   bool anIsVisible = false;
2049   OCCViewer_AxisWidget::AxisData anAxisData[3];
2050   myCubeAxesDlg->GetData( anIsVisible, anAxisData );
2051
2052   params.gtIsVisible = anIsVisible;
2053   params.gtDrawNameX = anAxisData[0].DrawName;
2054   params.gtDrawNameY = anAxisData[1].DrawName;
2055   params.gtDrawNameZ = anAxisData[2].DrawName;
2056   params.gtNameX = anAxisData[0].Name;
2057   params.gtNameY = anAxisData[1].Name;
2058   params.gtNameZ = anAxisData[2].Name;
2059   params.gtNameColorRX = anAxisData[0].NameColor.red();
2060   params.gtNameColorGX = anAxisData[0].NameColor.green();
2061   params.gtNameColorBX = anAxisData[0].NameColor.blue();
2062   params.gtNameColorRY = anAxisData[1].NameColor.red();
2063   params.gtNameColorGY = anAxisData[1].NameColor.green();
2064   params.gtNameColorBY = anAxisData[1].NameColor.blue();
2065   params.gtNameColorRZ = anAxisData[2].NameColor.red();
2066   params.gtNameColorGZ = anAxisData[2].NameColor.green();
2067   params.gtNameColorBZ = anAxisData[2].NameColor.blue();
2068   params.gtDrawValuesX = anAxisData[0].DrawValues;
2069   params.gtDrawValuesY = anAxisData[1].DrawValues;
2070   params.gtDrawValuesZ = anAxisData[2].DrawValues;
2071   params.gtNbValuesX = anAxisData[0].NbValues;
2072   params.gtNbValuesY = anAxisData[1].NbValues;
2073   params.gtNbValuesZ = anAxisData[2].NbValues;
2074   params.gtOffsetX = anAxisData[0].Offset;
2075   params.gtOffsetY = anAxisData[1].Offset;
2076   params.gtOffsetZ = anAxisData[2].Offset;
2077   params.gtColorRX = anAxisData[0].Color.red();
2078   params.gtColorGX = anAxisData[0].Color.green();
2079   params.gtColorBX = anAxisData[0].Color.blue();
2080   params.gtColorRY = anAxisData[1].Color.red();
2081   params.gtColorGY = anAxisData[1].Color.green();
2082   params.gtColorBY = anAxisData[1].Color.blue();
2083   params.gtColorRZ = anAxisData[2].Color.red();
2084   params.gtColorGZ = anAxisData[2].Color.green();
2085   params.gtColorBZ = anAxisData[2].Color.blue();
2086   params.gtDrawTickmarksX = anAxisData[0].DrawTickmarks;
2087   params.gtDrawTickmarksY = anAxisData[1].DrawTickmarks;
2088   params.gtDrawTickmarksZ = anAxisData[2].DrawTickmarks;
2089   params.gtTickmarkLengthX = anAxisData[0].TickmarkLength;
2090   params.gtTickmarkLengthY = anAxisData[1].TickmarkLength;
2091   params.gtTickmarkLengthZ = anAxisData[2].TickmarkLength;
2092 #endif
2093
2094   return params;
2095 }
2096
2097
2098 /*!
2099   \brief Get visual parameters of this view window.
2100   \return visual parameters of view window
2101 */
2102 QString OCCViewer_ViewWindow::getVisualParameters()
2103 {
2104   viewAspect params = getViewParams();
2105
2106   QStringList data;
2107
2108   data << QString( "scale=%1" )    .arg( params.scale,   0, 'e', 12 );
2109   data << QString( "centerX=%1" )  .arg( params.centerX, 0, 'e', 12 );
2110   data << QString( "centerY=%1" )  .arg( params.centerY, 0, 'e', 12 );
2111   data << QString( "projX=%1" )    .arg( params.projX,   0, 'e', 12 );
2112   data << QString( "projY=%1" )    .arg( params.projY,   0, 'e', 12 );
2113   data << QString( "projZ=%1" )    .arg( params.projZ,   0, 'e', 12 );
2114   data << QString( "twist=%1" )    .arg( params.twist,   0, 'e', 12 );
2115   data << QString( "atX=%1" )      .arg( params.atX,     0, 'e', 12 );
2116   data << QString( "atY=%1" )      .arg( params.atY,     0, 'e', 12 );
2117   data << QString( "atZ=%1" )      .arg( params.atZ,     0, 'e', 12 );
2118   data << QString( "eyeX=%1" )     .arg( params.eyeX,    0, 'e', 12 );
2119   data << QString( "eyeY=%1" )     .arg( params.eyeY,    0, 'e', 12 );
2120   data << QString( "eyeZ=%1" )     .arg( params.eyeZ,    0, 'e', 12 );
2121   data << QString( "scaleX=%1" )   .arg( params.scaleX,  0, 'e', 12 );
2122   data << QString( "scaleY=%1" )   .arg( params.scaleY,  0, 'e', 12 );
2123   data << QString( "scaleZ=%1" )   .arg( params.scaleZ,  0, 'e', 12 );
2124   data << QString( "isVisible=%1" ).arg( params.isVisible );
2125   data << QString( "size=%1" )     .arg( params.size,    0, 'f',  2 );
2126
2127 #if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 or newer version
2128   // graduated trihedron
2129   data << QString( "gtIsVisible=%1" )      .arg( params.gtIsVisible );
2130   data << QString( "gtDrawNameX=%1" )      .arg( params.gtDrawNameX );
2131   data << QString( "gtDrawNameY=%1" )      .arg( params.gtDrawNameY );
2132   data << QString( "gtDrawNameZ=%1" )      .arg( params.gtDrawNameZ );
2133   data << QString( "gtNameX=%1" )          .arg( params.gtNameX );
2134   data << QString( "gtNameY=%1" )          .arg( params.gtNameY );
2135   data << QString( "gtNameZ=%1" )          .arg( params.gtNameZ );
2136   data << QString( "gtNameColorRX=%1" )    .arg( params.gtNameColorRX );
2137   data << QString( "gtNameColorGX=%1" )    .arg( params.gtNameColorGX );
2138   data << QString( "gtNameColorBX=%1" )    .arg( params.gtNameColorBX );
2139   data << QString( "gtNameColorRY=%1" )    .arg( params.gtNameColorRY );
2140   data << QString( "gtNameColorGY=%1" )    .arg( params.gtNameColorGY );
2141   data << QString( "gtNameColorBY=%1" )    .arg( params.gtNameColorBY );
2142   data << QString( "gtNameColorRZ=%1" )    .arg( params.gtNameColorRZ );
2143   data << QString( "gtNameColorGZ=%1" )    .arg( params.gtNameColorGZ );
2144   data << QString( "gtNameColorBZ=%1" )    .arg( params.gtNameColorBZ );
2145   data << QString( "gtDrawValuesX=%1" )    .arg( params.gtDrawValuesX );
2146   data << QString( "gtDrawValuesY=%1" )    .arg( params.gtDrawValuesY );
2147   data << QString( "gtDrawValuesZ=%1" )    .arg( params.gtDrawValuesZ );
2148   data << QString( "gtNbValuesX=%1" )      .arg( params.gtNbValuesX );
2149   data << QString( "gtNbValuesY=%1" )      .arg( params.gtNbValuesY );
2150   data << QString( "gtNbValuesZ=%1" )      .arg( params.gtNbValuesZ );
2151   data << QString( "gtOffsetX=%1" )        .arg( params.gtOffsetX );
2152   data << QString( "gtOffsetY=%1" )        .arg( params.gtOffsetY );
2153   data << QString( "gtOffsetZ=%1" )        .arg( params.gtOffsetZ );
2154   data << QString( "gtColorRX=%1" )        .arg( params.gtColorRX );
2155   data << QString( "gtColorGX=%1" )        .arg( params.gtColorGX );
2156   data << QString( "gtColorBX=%1" )        .arg( params.gtColorBX );
2157   data << QString( "gtColorRY=%1" )        .arg( params.gtColorRY );
2158   data << QString( "gtColorGY=%1" )        .arg( params.gtColorGY );
2159   data << QString( "gtColorBY=%1" )        .arg( params.gtColorBY );
2160   data << QString( "gtColorRZ=%1" )        .arg( params.gtColorRZ );
2161   data << QString( "gtColorGZ=%1" )        .arg( params.gtColorGZ );
2162   data << QString( "gtColorBZ=%1" )        .arg( params.gtColorBZ );
2163   data << QString( "gtDrawTickmarksX=%1" ) .arg( params.gtDrawTickmarksX );
2164   data << QString( "gtDrawTickmarksY=%1" ) .arg( params.gtDrawTickmarksY );
2165   data << QString( "gtDrawTickmarksZ=%1" ) .arg( params.gtDrawTickmarksZ );
2166   data << QString( "gtTickmarkLengthX=%1" ).arg( params.gtTickmarkLengthX );
2167   data << QString( "gtTickmarkLengthY=%1" ).arg( params.gtTickmarkLengthY );
2168   data << QString( "gtTickmarkLengthZ=%1" ).arg( params.gtTickmarkLengthZ );
2169 #endif
2170   QString bg = Qtx::backgroundToString( background() ).replace( "=", "$" );
2171   data << QString( "background=%1" ).arg( bg );
2172
2173   return data.join("*");
2174 }
2175
2176 /*!
2177   \brief Restore visual parameters of the view window.
2178   \param parameters visual parameters of view window
2179 */
2180 void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters )
2181 {
2182   viewAspect params;
2183
2184   QStringList data = parameters.split( '*' );
2185   Qtx::BackgroundData bgData;
2186   if ( parameters.contains( '=' )  ) // new format - "scale=1.000e+00*centerX=0.000e+00..."
2187   {
2188     foreach( QString param, data ) {
2189       QString paramName  = param.section( '=', 0, 0 ).trimmed();
2190       QString paramValue = param.section( '=', 1, 1 ).trimmed();
2191       if      ( paramName == "scale" )             params.scale             = paramValue.toDouble();
2192       else if ( paramName == "centerX" )           params.centerX           = paramValue.toDouble();
2193       else if ( paramName == "centerY" )           params.centerY           = paramValue.toDouble();
2194       else if ( paramName == "projX" )             params.projX             = paramValue.toDouble();
2195       else if ( paramName == "projY" )             params.projY             = paramValue.toDouble();
2196       else if ( paramName == "projZ" )             params.projZ             = paramValue.toDouble();
2197       else if ( paramName == "twist" )             params.twist             = paramValue.toDouble();
2198       else if ( paramName == "atX" )               params.atX               = paramValue.toDouble();
2199       else if ( paramName == "atY" )               params.atY               = paramValue.toDouble();
2200       else if ( paramName == "atZ" )               params.atZ               = paramValue.toDouble();
2201       else if ( paramName == "eyeX" )              params.eyeX              = paramValue.toDouble();
2202       else if ( paramName == "eyeY" )              params.eyeY              = paramValue.toDouble();
2203       else if ( paramName == "eyeZ" )              params.eyeZ              = paramValue.toDouble();
2204       else if ( paramName == "scaleX" )            params.scaleX            = paramValue.toDouble();
2205       else if ( paramName == "scaleY" )            params.scaleY            = paramValue.toDouble();
2206       else if ( paramName == "scaleZ" )            params.scaleZ            = paramValue.toDouble();
2207       else if ( paramName == "isVisible" )         params.isVisible         = paramValue.toInt();
2208       else if ( paramName == "size" )              params.size              = paramValue.toDouble();
2209       // graduated trihedron
2210       else if ( paramName == "gtIsVisible" )       params.gtIsVisible       = paramValue.toInt();
2211       else if ( paramName == "gtDrawNameX" )       params.gtDrawNameX       = paramValue.toInt();
2212       else if ( paramName == "gtDrawNameY" )       params.gtDrawNameY       = paramValue.toInt();
2213       else if ( paramName == "gtDrawNameZ" )       params.gtDrawNameZ       = paramValue.toInt();
2214       else if ( paramName == "gtNameX" )           params.gtNameX           = paramValue;
2215       else if ( paramName == "gtNameY" )           params.gtNameY           = paramValue;
2216       else if ( paramName == "gtNameZ" )           params.gtNameZ           = paramValue;
2217       else if ( paramName == "gtNameColorRX" )     params.gtNameColorRX     = paramValue.toInt();
2218       else if ( paramName == "gtNameColorGX" )     params.gtNameColorGX     = paramValue.toInt();
2219       else if ( paramName == "gtNameColorBX" )     params.gtNameColorBX     = paramValue.toInt();
2220       else if ( paramName == "gtNameColorRY" )     params.gtNameColorRY     = paramValue.toInt();
2221       else if ( paramName == "gtNameColorGY" )     params.gtNameColorGY     = paramValue.toInt();
2222       else if ( paramName == "gtNameColorBY" )     params.gtNameColorBY     = paramValue.toInt();
2223       else if ( paramName == "gtNameColorRZ" )     params.gtNameColorRZ     = paramValue.toInt();
2224       else if ( paramName == "gtNameColorGZ" )     params.gtNameColorGZ     = paramValue.toInt();
2225       else if ( paramName == "gtNameColorBZ" )     params.gtNameColorBZ     = paramValue.toInt();
2226       else if ( paramName == "gtDrawValuesX" )     params.gtDrawValuesX     = paramValue.toInt();
2227       else if ( paramName == "gtDrawValuesY" )     params.gtDrawValuesY     = paramValue.toInt();
2228       else if ( paramName == "gtDrawValuesZ" )     params.gtDrawValuesZ     = paramValue.toInt();
2229       else if ( paramName == "gtNbValuesX" )       params.gtNbValuesX       = paramValue.toInt();
2230       else if ( paramName == "gtNbValuesY" )       params.gtNbValuesY       = paramValue.toInt();
2231       else if ( paramName == "gtNbValuesZ" )       params.gtNbValuesZ       = paramValue.toInt();
2232       else if ( paramName == "gtOffsetX" )         params.gtOffsetX         = paramValue.toInt();
2233       else if ( paramName == "gtOffsetY" )         params.gtOffsetY         = paramValue.toInt();
2234       else if ( paramName == "gtOffsetZ" )         params.gtOffsetZ         = paramValue.toInt();
2235       else if ( paramName == "gtColorRX" )         params.gtColorRX         = paramValue.toInt();
2236       else if ( paramName == "gtColorGX" )         params.gtColorGX         = paramValue.toInt();
2237       else if ( paramName == "gtColorBX" )         params.gtColorBX         = paramValue.toInt();
2238       else if ( paramName == "gtColorRY" )         params.gtColorRY         = paramValue.toInt();
2239       else if ( paramName == "gtColorGY" )         params.gtColorGY         = paramValue.toInt();
2240       else if ( paramName == "gtColorBY" )         params.gtColorBY         = paramValue.toInt();
2241       else if ( paramName == "gtColorRZ" )         params.gtColorRZ         = paramValue.toInt();
2242       else if ( paramName == "gtColorGZ" )         params.gtColorGZ         = paramValue.toInt();
2243       else if ( paramName == "gtColorBZ" )         params.gtColorBZ         = paramValue.toInt();
2244       else if ( paramName == "gtDrawTickmarksX" )  params.gtDrawTickmarksX  = paramValue.toInt();
2245       else if ( paramName == "gtDrawTickmarksY" )  params.gtDrawTickmarksY  = paramValue.toInt();
2246       else if ( paramName == "gtDrawTickmarksZ" )  params.gtDrawTickmarksZ  = paramValue.toInt();
2247       else if ( paramName == "gtTickmarkLengthX" ) params.gtTickmarkLengthX = paramValue.toInt();
2248       else if ( paramName == "gtTickmarkLengthY" ) params.gtTickmarkLengthY = paramValue.toInt();
2249       else if ( paramName == "gtTickmarkLengthZ" ) params.gtTickmarkLengthZ = paramValue.toInt();
2250       else if ( paramName == "background" )        {
2251         QString bg = paramValue.replace( "$", "=" );
2252         bgData = Qtx::stringToBackground( bg );
2253       }
2254     }
2255   }
2256   else // old format - "1.000e+00*0.000e+00..."
2257   {
2258     int idx = 0;
2259     params.scale     = data.count() > idx ? data[idx++].toDouble() : 1.0;
2260     params.centerX   = data.count() > idx ? data[idx++].toDouble() : 0.0;
2261     params.centerY   = data.count() > idx ? data[idx++].toDouble() : 0.0;
2262     params.projX     = data.count() > idx ? data[idx++].toDouble() : sqrt(1./3);
2263     params.projY     = data.count() > idx ? data[idx++].toDouble() : -sqrt(1./3);
2264     params.projZ     = data.count() > idx ? data[idx++].toDouble() : sqrt(1./3);
2265     params.twist     = data.count() > idx ? data[idx++].toDouble() : 0.0;
2266     params.atX       = data.count() > idx ? data[idx++].toDouble() : 0.0;
2267     params.atY       = data.count() > idx ? data[idx++].toDouble() : 0.0;
2268     params.atZ       = data.count() > idx ? data[idx++].toDouble() : 0.0;
2269     params.eyeX      = data.count() > idx ? data[idx++].toDouble() : sqrt(250000./3);
2270     params.eyeY      = data.count() > idx ? data[idx++].toDouble() : -sqrt(250000./3);
2271     params.eyeZ      = data.count() > idx ? data[idx++].toDouble() : sqrt(250000./3);
2272     params.scaleX    = data.count() > idx ? data[idx++].toDouble() : 1.0;
2273     params.scaleY    = data.count() > idx ? data[idx++].toDouble() : 1.0;
2274     params.scaleZ    = data.count() > idx ? data[idx++].toDouble() : 1.0;
2275     params.isVisible = data.count() > idx ? data[idx++].toInt()    : 1;
2276     params.size      = data.count() > idx ? data[idx++].toDouble() : 100.0;
2277   }
2278   performRestoring( params );
2279   setBackground( bgData );
2280 }
2281
2282 /*!
2283   \brief Handle show event.
2284
2285   Emits Show() signal.
2286
2287   \param theEvent show event
2288 */
2289 void OCCViewer_ViewWindow::showEvent( QShowEvent* theEvent )
2290 {
2291   emit Show( theEvent );
2292 }
2293
2294 /*!
2295   \brief Handle hide event.
2296
2297   Emits Hide() signal.
2298
2299   \param theEvent hide event
2300 */
2301 void OCCViewer_ViewWindow::hideEvent( QHideEvent* theEvent )
2302 {
2303   emit Hide( theEvent );
2304 }
2305
2306
2307 /*!
2308     Creates default sketcher. [ virtual protected ]
2309 */
2310 OCCViewer_ViewSketcher* OCCViewer_ViewWindow::createSketcher( int type )
2311 {
2312   if ( type == Rect )
2313     return new OCCViewer_RectSketcher( this, type );
2314   if ( type == Polygon )
2315     return new OCCViewer_PolygonSketcher( this, type );
2316   return 0;
2317 }
2318
2319 void OCCViewer_ViewWindow::initSketchers()
2320 {
2321   if ( mySketchers.isEmpty() )
2322   {
2323     mySketchers.append( createSketcher( Rect ) );
2324     mySketchers.append( createSketcher( Polygon ) );
2325   }
2326 }
2327
2328 OCCViewer_ViewSketcher* OCCViewer_ViewWindow::getSketcher( const int typ )
2329 {
2330   OCCViewer_ViewSketcher* sketcher = 0;
2331   QList<OCCViewer_ViewSketcher*>::Iterator it;
2332   for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )
2333   {
2334     OCCViewer_ViewSketcher* sk = (*it);
2335     if ( sk->type() == typ )
2336       sketcher = sk;
2337   }
2338   return sketcher;
2339 }
2340
2341 /*!
2342     Handles requests for sketching in the active view. [ virtual public ]
2343 */
2344 void OCCViewer_ViewWindow::activateSketching( int type )
2345 {
2346   OCCViewer_ViewPort3d* vp = getViewPort();
2347   if ( !vp )
2348     return;
2349
2350   if ( !vp->isSketchingEnabled() )
2351     return;
2352
2353   /* Finish current sketching */
2354   if ( type == NoSketching )
2355   {
2356     if ( mypSketcher )
2357     {
2358       onSketchingFinished();
2359       mypSketcher->deactivate();
2360       mypSketcher = 0;
2361     }
2362   }
2363   /* Activate new sketching */
2364   else
2365   {
2366     activateSketching( NoSketching );  /* concurrency not suported */
2367     mypSketcher = getSketcher( type );
2368     if ( mypSketcher )
2369     {
2370       mypSketcher->activate();
2371       onSketchingStarted();
2372     }
2373   }
2374 }
2375
2376 /*!
2377     Unhilights detected entities. [ virtual protected ]
2378 */
2379 void OCCViewer_ViewWindow::onSketchingStarted()
2380 {
2381 }
2382
2383 /*!
2384     Selection by rectangle or polygon. [ virtual protected ]
2385 */
2386 void OCCViewer_ViewWindow::onSketchingFinished()
2387 {
2388   MESSAGE("OCCViewer_ViewWindow::onSketchingFinished()")
2389   if ( mypSketcher && mypSketcher->result() == OCCViewer_ViewSketcher::Accept )
2390   {
2391     Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
2392     bool append = bool( mypSketcher->buttonState() && mypSketcher->isHasShift() );
2393     switch( mypSketcher->type() )
2394     {
2395     case Rect:
2396       {
2397         QRect* aRect = (QRect*)mypSketcher->data();
2398         if( aRect )
2399         {
2400           int aLeft = aRect->left();
2401           int aRight = aRect->right();
2402           int aTop = aRect->top();
2403           int aBottom = aRect->bottom();
2404 //           myRect = aRect;
2405
2406           if( append )
2407             ic->ShiftSelect( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );
2408           else
2409             ic->Select( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );
2410         }
2411       }
2412       break;
2413     case Polygon:
2414       {
2415         QPolygon* aPolygon = (QPolygon*)mypSketcher->data();
2416         if( aPolygon )
2417         {
2418           int size = aPolygon->size();
2419           TColgp_Array1OfPnt2d anArray( 1, size );
2420
2421           QPolygon::Iterator it = aPolygon->begin();
2422           QPolygon::Iterator itEnd = aPolygon->end();
2423           for( int index = 1; it != itEnd; ++it, index++ )
2424           {
2425             QPoint aPoint = *it;
2426             anArray.SetValue( index, gp_Pnt2d( aPoint.x(), aPoint.y() ) );
2427           }
2428
2429           if( append )
2430             ic->ShiftSelect( anArray, getViewPort()->getView(), Standard_False );
2431           else
2432             ic->Select( anArray, getViewPort()->getView(), Standard_False );
2433         }
2434       }
2435       break;
2436     default:
2437       break;
2438     }
2439
2440     OCCViewer_ViewManager* aViewMgr = ( OCCViewer_ViewManager* )getViewManager();
2441     aViewMgr->getOCCViewer()->performSelectionChanged();
2442   }
2443 }
2444
2445 OCCViewer_ViewPort3d* OCCViewer_ViewWindow::getViewPort()
2446 {
2447   return myViewPort;
2448 }
2449
2450 bool OCCViewer_ViewWindow::transformRequested() const
2451 {
2452   return ( myOperation != NOTHING );
2453 }
2454
2455 bool OCCViewer_ViewWindow::transformInProcess() const
2456 {
2457   return myEventStarted;
2458 }
2459
2460 void OCCViewer_ViewWindow::setTransformInProcess( bool bOn )
2461 {
2462   myEventStarted = bOn;
2463 }
2464
2465 /*!
2466   Set enabled state of transformation (rotate, zoom, etc)
2467 */
2468 void OCCViewer_ViewWindow::setTransformEnabled( const OperationType id, const bool on )
2469 {
2470   if ( id != NOTHING ) myStatus.insert( id, on );
2471 }
2472
2473 /*!
2474   \return enabled state of transformation (rotate, zoom, etc)
2475 */
2476 bool OCCViewer_ViewWindow::transformEnabled( const OperationType id ) const
2477 {
2478   return myStatus.contains( id ) ? myStatus[ id ] : true;
2479 }
2480
2481 void OCCViewer_ViewWindow::onMaximizedView()
2482 {
2483   setMaximized(!isMaximized());
2484 }
2485
2486
2487 void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal)
2488 {
2489   QAction* anAction =  toolMgr()->action( MaximizedId );
2490   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
2491   if ( toMaximize ) {
2492     anAction->setText( tr( "MNU_MINIMIZE_VIEW" ) );  
2493     anAction->setToolTip( tr( "MNU_MINIMIZE_VIEW" ) );  
2494     anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ) );
2495     anAction->setStatusTip( tr( "DSC_MINIMIZE_VIEW" ) );
2496     if (toSendSignal) {
2497       emit maximized( this, true );
2498     }
2499   }
2500   else {
2501     anAction->setText( tr( "MNU_MAXIMIZE_VIEW" ) );  
2502     anAction->setToolTip( tr( "MNU_MAXIMIZE_VIEW" ) );  
2503     anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MAXIMIZE" ) ) );
2504     anAction->setStatusTip( tr( "DSC_MAXIMIZE_VIEW" ) );
2505     if (toSendSignal) {
2506       emit maximized( this, false );
2507     }
2508   }
2509 }
2510
2511
2512 bool OCCViewer_ViewWindow::isMaximized() const
2513 {
2514   return !(toolMgr()->action( MaximizedId )->text() == tr( "MNU_MAXIMIZE_VIEW" ));
2515 }
2516
2517 void OCCViewer_ViewWindow::setSketcherStyle( bool enable )
2518
2519   IsSketcherStyle = enable; 
2520 }
2521
2522 bool OCCViewer_ViewWindow::isSketcherStyle() const 
2523
2524   return IsSketcherStyle; 
2525 }
2526
2527
2528 void OCCViewer_ViewWindow::set2dMode(Mode2dType theType)
2529 {
2530   my2dMode = theType;
2531 }
2532
2533 // obsolete   
2534 QColor OCCViewer_ViewWindow::backgroundColor() const
2535 {
2536   return myViewPort ? myViewPort->backgroundColor() : Qt::black;
2537 }
2538    
2539 // obsolete
2540 void OCCViewer_ViewWindow::setBackgroundColor( const QColor& theColor )
2541 {
2542   if ( myViewPort ) myViewPort->setBackgroundColor( theColor );
2543 }
2544
2545 Qtx::BackgroundData OCCViewer_ViewWindow::background() const
2546 {
2547   return myViewPort ? myViewPort->background() : Qtx::BackgroundData();
2548 }
2549    
2550 void OCCViewer_ViewWindow::setBackground( const Qtx::BackgroundData& theBackground )
2551 {
2552   if ( myViewPort ) myViewPort->setBackground( theBackground );
2553 }
2554
2555 /*!
2556   Clears view aspects
2557 */
2558 void OCCViewer_ViewWindow::clearViewAspects()
2559 {
2560   myViewAspects.clear();
2561 }
2562
2563 /*!
2564   \return const reference to list of view aspects
2565 */
2566 const viewAspectList& OCCViewer_ViewWindow::getViewAspects()
2567 {
2568   return myViewAspects;
2569 }
2570
2571 /*!
2572   Appends new view aspect
2573   \param aParams - new view aspects
2574 */
2575 void OCCViewer_ViewWindow::appendViewAspect( const viewAspect& aParams )
2576 {
2577   myViewAspects.append( aParams );
2578 }
2579
2580 /*!
2581   Replaces old view aspects by new ones
2582   \param aViewList - list of new view aspects
2583 */
2584 void OCCViewer_ViewWindow::updateViewAspects( const viewAspectList& aViewList )
2585 {
2586   myViewAspects = aViewList;
2587 }
2588
2589 /*!
2590   Get camera properties for the OCC view window.
2591   \return shared pointer on camera properties.
2592 */
2593 SUIT_CameraProperties OCCViewer_ViewWindow::cameraProperties()
2594 {
2595   SUIT_CameraProperties aProps;
2596
2597   Handle(V3d_View) aSourceView = getViewPort()->getView();
2598   if ( aSourceView.IsNull() )
2599     return aProps;
2600
2601   if ( get2dMode() == No2dMode ) {
2602     aProps.setDimension( SUIT_CameraProperties::Dim3D );
2603   }
2604   else {
2605     aProps.setDimension( SUIT_CameraProperties::Dim2D );
2606     aProps.setViewSide( (SUIT_CameraProperties::ViewSide)(int)get2dMode() );
2607   }
2608   
2609   // read common properites of the view
2610   Standard_Real anUpDir[3];
2611   Standard_Real aPrjDir[3];
2612   Standard_Real aMapScale[2];
2613   Standard_Real aTranslation[3];
2614   Standard_Real anAxialScale[3];
2615   
2616   aSourceView->Up(anUpDir[0], anUpDir[1], anUpDir[2]);
2617   aSourceView->Proj(aPrjDir[0], aPrjDir[1], aPrjDir[2]);
2618   aSourceView->At(aTranslation[0], aTranslation[1], aTranslation[2]);
2619   aSourceView->Size(aMapScale[0], aMapScale[1]);
2620
2621   getViewPort()->getAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
2622
2623   // we use similar depth to the one used in perspective projection 
2624   // to proivde a convinience synchronization with other camera views that
2625   // can switch between orthogonal & perspective projection. otherwise,
2626   // the camera will get to close when switching from orthogonal to perspective.
2627   Standard_Real aCameraDepth = aSourceView->Depth() + aSourceView->ZSize() * 0.5;
2628
2629   // store common props
2630   aProps.setViewUp(anUpDir[0], anUpDir[1], anUpDir[2]);
2631   aProps.setMappingScale(aMapScale[1] / 2.0);
2632   aProps.setAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
2633   
2634   // generate view orientation matrix for transforming OCC projection reference point
2635   // into a camera (eye) position.
2636   gp_Dir aLeftDir = gp_Dir(anUpDir[0], anUpDir[1], anUpDir[2]).Crossed(
2637     gp_Dir(aPrjDir[0], aPrjDir[1], aPrjDir[2]));
2638
2639   gp_Trsf aTrsf;
2640   aTrsf.SetValues( aLeftDir.X(), anUpDir[0], aPrjDir[0], aTranslation[0],
2641                    aLeftDir.Y(), anUpDir[1], aPrjDir[1], aTranslation[1],
2642                    aLeftDir.Z(), anUpDir[2], aPrjDir[2], aTranslation[2],
2643                    Precision::Confusion(),
2644                    Precision::Confusion() );
2645
2646   // get projection reference point in view coordinates
2647   Graphic3d_Vertex aProjRef = aSourceView->ViewMapping().ProjectionReferencePoint();
2648   
2649   // transform to world-space coordinate system
2650   gp_Pnt aPosition = gp_Pnt(aProjRef.X(), aProjRef.Y(), aCameraDepth).Transformed(aTrsf);
2651   
2652   // compute focal point
2653   double aFocalPoint[3];
2654
2655   aFocalPoint[0] = aPosition.X() - aPrjDir[0] * aCameraDepth;
2656   aFocalPoint[1] = aPosition.Y() - aPrjDir[1] * aCameraDepth;
2657   aFocalPoint[2] = aPosition.Z() - aPrjDir[2] * aCameraDepth;
2658
2659   aProps.setFocalPoint(aFocalPoint[0], aFocalPoint[1], aFocalPoint[2]);
2660   aProps.setPosition(aPosition.X(), aPosition.Y(), aPosition.Z());
2661
2662   return aProps;
2663 }
2664
2665 /*!
2666   Synchronize views.
2667   This implementation synchronizes OCC view's camera propreties.
2668 */
2669 void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView )
2670 {
2671   bool blocked = blockSignals( true );
2672
2673   SUIT_CameraProperties aProps = theView->cameraProperties();
2674   if ( !cameraProperties().isCompatible( aProps ) ) {
2675     // other view, this one is being currently synchronized to, seems has become incompatible
2676     // we have to break synchronization
2677     updateSyncViews();
2678     return;
2679   }
2680
2681   Handle(V3d_View) aDestView = getViewPort()->getView();
2682
2683   aDestView->SetImmediateUpdate( Standard_False );
2684
2685   double anUpDir[3];
2686   double aPosition[3];
2687   double aFocalPoint[3];
2688   double aMapScaling;
2689   double anAxialScale[3];
2690
2691   // get common properties
2692   aProps.getFocalPoint(aFocalPoint[0], aFocalPoint[1], aFocalPoint[2]);
2693   aProps.getPosition(aPosition[0], aPosition[1], aPosition[2]);
2694   aProps.getViewUp(anUpDir[0], anUpDir[1], anUpDir[2]);
2695   aProps.getAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
2696   aMapScaling = aProps.getMappingScale() * 2.0;
2697
2698   gp_Dir aProjDir(aPosition[0] - aFocalPoint[0],
2699                   aPosition[1] - aFocalPoint[1],
2700                   aPosition[2] - aFocalPoint[2]);
2701   
2702   // get custom view translation
2703   Standard_Real aTranslation[3];
2704   aDestView->At(aTranslation[0], aTranslation[1], aTranslation[2]);
2705
2706   gp_Dir aLeftDir = gp_Dir(anUpDir[0], anUpDir[1], anUpDir[2]).Crossed(
2707     gp_Dir(aProjDir.X(), aProjDir.Y(), aProjDir.Z()));
2708
2709   // convert camera position into a view reference point
2710   gp_Trsf aTrsf;
2711   aTrsf.SetValues( aLeftDir.X(), anUpDir[0], aProjDir.X(), aTranslation[0],
2712                    aLeftDir.Y(), anUpDir[1], aProjDir.Y(), aTranslation[1],
2713                    aLeftDir.Z(), anUpDir[2], aProjDir.Z(), aTranslation[2], 
2714                    Precision::Confusion(),
2715                    Precision::Confusion() );
2716   aTrsf.Invert();
2717
2718   // transform to view-space coordinate system
2719   gp_Pnt aProjRef(aPosition[0], aPosition[1], aPosition[2]);
2720   aProjRef.Transform(aTrsf);
2721
2722   // set view camera properties using low-level approach. this is done
2723   // in order to avoid interference with static variables in v3d view used
2724   // when rotation is in process in another view.
2725   Visual3d_ViewMapping aMapping = aDestView->View()->ViewMapping();
2726   Visual3d_ViewOrientation anOrientation = aDestView->View()->ViewOrientation();
2727
2728   Graphic3d_Vector aMappingProj(aProjDir.X(), aProjDir.Y(), aProjDir.Z());
2729   Graphic3d_Vector aMappingUp(anUpDir[0], anUpDir[1], anUpDir[2]);
2730
2731   aMappingProj.Normalize();
2732   aMappingUp.Normalize();
2733
2734   anOrientation.SetViewReferencePlane(aMappingProj);
2735   anOrientation.SetViewReferenceUp(aMappingUp);
2736
2737   aDestView->SetViewMapping(aMapping);
2738   aDestView->SetViewOrientation(anOrientation);
2739
2740   // set panning
2741   aDestView->SetCenter(aProjRef.X(), aProjRef.Y());
2742
2743   // set mapping scale
2744   Standard_Real aWidth, aHeight;
2745   aDestView->Size(aWidth, aHeight);
2746   
2747   if ( aWidth > aHeight )
2748     aDestView->SetSize (aMapScaling * (aWidth / aHeight));
2749   else
2750     aDestView->SetSize (aMapScaling);
2751
2752   getViewPort()->setAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
2753
2754   aDestView->ZFitAll();
2755   aDestView->SetImmediateUpdate( Standard_True );
2756   aDestView->Redraw();
2757
2758   blockSignals( blocked );
2759 }
2760
2761 /*!
2762   \brief Indicates whether preselection is enabled
2763   \return true if preselection is enabled
2764 */
2765 bool OCCViewer_ViewWindow::isPreselectionEnabled() const
2766 {
2767   return myPreselectionEnabled;
2768 }
2769
2770 /*!
2771   \brief Enables/disables preselection
2772   \param theIsToEnable if true - preselection will be enabled
2773 */
2774 void OCCViewer_ViewWindow::enablePreselection( bool theIsToEnable )
2775 {
2776   onSwitchPreselection( theIsToEnable );
2777 }
2778
2779 /*!
2780   \brief Indicates whether selection is enabled
2781   \return true if selection is enabled
2782 */
2783 bool OCCViewer_ViewWindow::isSelectionEnabled() const
2784 {
2785   return mySelectionEnabled;
2786 }
2787
2788 /*!
2789   \brief Enables/disables selection
2790   \param theIsToEnable if true - selection will be enabled
2791 */
2792 void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable )
2793 {
2794   onSwitchSelection( theIsToEnable );
2795 }