Salome HOME
Properly process show/hide static trihedron in OCC view
authorvsr <vsr@opencascade.com>
Thu, 10 Apr 2014 16:28:19 +0000 (20:28 +0400)
committervsr <vsr@opencascade.com>
Thu, 10 Apr 2014 16:28:19 +0000 (20:28 +0400)
src/OCCViewer/OCCViewer_ViewFrame.cxx
src/OCCViewer/OCCViewer_ViewFrame.h
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewPort3d.cxx
src/OCCViewer/OCCViewer_ViewPort3d.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h

index cf6d3dd8d39cfc50765c374265ea82a984a6e0eb..cc20fd47394a9f9160a871aae4e57df86719a88a 100644 (file)
@@ -423,6 +423,17 @@ Qtx::BackgroundData OCCViewer_ViewFrame::background() const
   return getView(MAIN_VIEW)->background(); 
 }
 
+void OCCViewer_ViewFrame::showStaticTrihedron( bool on )
+{
+  if ( myPopupRequestedView )
+    myPopupRequestedView->showStaticTrihedron( on ); 
+  else {
+    foreach ( OCCViewer_ViewWindow* aView, myViews ) {
+      aView->showStaticTrihedron( on ); 
+    }
+  }
+}
+
 QImage OCCViewer_ViewFrame::dumpView()
 {
   foreach (OCCViewer_ViewWindow* aView, myViews) {
index 5c1b952973c1b4b3623c49f7b850117ac364472b..0f10e19f0f8090743d61846b05d2c32b2072bf18 100644 (file)
@@ -89,7 +89,9 @@ public:
   virtual Qtx::BackgroundData background() const;
   virtual void                setBackground( const Qtx::BackgroundData& );
 
-  virtual void   setDropDownButtons( bool );
+  virtual void showStaticTrihedron( bool );
+
+  virtual void setDropDownButtons( bool );
 
   virtual SUIT_CameraProperties cameraProperties();
 
index f34b888e5e520ba294f279e9708e30d97cc7eedc..366d3bb0cc53954d530318213857a9872fda4120 100755 (executable)
@@ -153,11 +153,6 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
   // selection
   mySelectionEnabled = true;
   myMultiSelectionEnabled = true;
-  
-  
-  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  if(resMgr)
-    myShowStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
 }
 
 /*!
@@ -225,6 +220,9 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view )
     if ( vp3d )
     {
       vp3d->getView()->SetSurfaceDetail(V3d_TEX_ALL);
+      // connect signal from viewport
+      connect(vp3d, SIGNAL(vpClosed(OCCViewer_ViewPort3d*)), this, SLOT(onViewClosed(OCCViewer_ViewPort3d*)));
+      connect(vp3d, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewMapped(OCCViewer_ViewPort3d*)));
     }
   }
 }
@@ -243,9 +241,7 @@ SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop )
   initView( vw );
   // set default background for view window
   vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here)
-  // connect signal from viewport
-  connect(view->getViewPort(), SIGNAL(vpClosed()), this, SLOT(onViewClosed()));
-  connect(view->getViewPort(), SIGNAL(vpMapped()), this, SLOT(onViewMapped()));
+
   return view;
 }
 
@@ -393,7 +389,7 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven
   emit selectionChanged();
 }
 
-void OCCViewer_Viewer::onViewClosed()
+void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*)
 {
   Standard_Integer aViewsNb = 0;
   for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews())
@@ -404,9 +400,13 @@ void OCCViewer_Viewer::onViewClosed()
   }
 }
 
-void OCCViewer_Viewer::onViewMapped()
+void OCCViewer_Viewer::onViewMapped(OCCViewer_ViewPort3d* viewPort)
 {
   setTrihedronShown( true );
+  bool showStaticTrihedron = true;
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  if ( resMgr ) showStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
+  viewPort->showStaticTrihedron( showStaticTrihedron );
 }
 
 int OCCViewer_Viewer::getTopLayerId()
@@ -899,7 +899,7 @@ void OCCViewer_Viewer::isos( int& u, int& v ) const
  */
 OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow()
 {
-  return new OCCViewer_ViewWindow( 0,  this);
+  return new OCCViewer_ViewWindow(0,  this);
 }
 
 // obsolete  
@@ -933,18 +933,10 @@ void OCCViewer_Viewer::setBackground( int theViewId, const Qtx::BackgroundData&
 /*!
   Set the show static trihedron flag
 */
-void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on) {
-  if(myShowStaticTrihedron != on) {
-    OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
-    if(!aView)
-      return;
-
-    OCCViewer_ViewPort3d* vp3d = aView->getViewPort();
-    if(vp3d) {
-      myShowStaticTrihedron = on;
-      vp3d->updateStaticTriedronVisibility();
-    }
-  }
+void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on)
+{
+  OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
+  if ( aView ) aView->showStaticTrihedron( on );
 }
 
 /*!
index c4f88dbd9c8fec3df10c72e83c230f0cfb36b512..5e2e955b38192864e1c8435dddc3266ddb8b44d4 100755 (executable)
@@ -46,6 +46,7 @@ class SUIT_ViewWindow;
 class SUIT_Desktop;
 class OCCViewer_ClippingDlg;
 class OCCViewer_ViewWindow;
+class OCCViewer_ViewPort3d;
 
 class AIS_ListOfInteractive;
 
@@ -152,7 +153,6 @@ public:
 
   int                             getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
 
-  bool                            isStaticTrihedronDisplayed() { return myShowStaticTrihedron; }
   void                            setStaticTrihedronDisplayed(const bool on);
 
   /* Clip planes management */
@@ -187,8 +187,8 @@ protected slots:
   virtual void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
   virtual void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
   virtual void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
-  virtual void onViewClosed();
-  virtual void onViewMapped();
+  virtual void onViewClosed(OCCViewer_ViewPort3d*);
+  virtual void onViewMapped(OCCViewer_ViewPort3d*);
 
   void onDumpView();
   void onChangeBackground();
@@ -217,8 +217,6 @@ protected:
   //QColor                          myBgColor;
   QPoint                          myStartPnt, myEndPnt, myCurPnt;
 
-  bool                            myShowStaticTrihedron;
-
   double                          myTrihedronSize;
 
   QVector<Qtx::BackgroundData>    myBackgrounds;
index 3f546a855b9a2eef241d2355c185b85273e522e9..110076d130317b883b1b8da214efd33904cf9065 100755 (executable)
@@ -96,7 +96,7 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V
 */
 OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d()
 {
-  emit vpClosed();
+  emit vpClosed(this);
   Handle(V3d_View) aView = activeView();
   if (!aView.IsNull())
     aView->Remove();
@@ -134,17 +134,7 @@ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view )
       view->View()->Deactivate();
   }
 
-  /* create static trihedron (16551: EDF PAL 501) */
-  OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
-  if ( aVW ) {
-    OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
-    if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){
-      view->ZBufferTriedronSetup();
-      view->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
-    }
-  }
-
-  emit( vpMapped() );
+  emit( vpMapped(this) );
 
   return true;
 }
@@ -812,18 +802,16 @@ bool OCCViewer_ViewPort3d::synchronize( OCCViewer_ViewPort* view )
 /*
  * Show/Hide static triedron
  */
-void OCCViewer_ViewPort3d::updateStaticTriedronVisibility() {
-  OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
-  if ( aVW ) {
-    OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
-    Handle(V3d_View) aView = activeView();
-    if ( aViewModel ){
-      if(aViewModel->isStaticTrihedronDisplayed()) {
-       aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
-      } else {
-       aView->TriedronErase();
-      }
-      aView->Update();
-    }
+void OCCViewer_ViewPort3d::showStaticTrihedron( bool on )
+{
+  Handle(V3d_View) aView = activeView();
+  if ( !aView ) return;
+  
+  if ( on ) {
+    aView->ZBufferTriedronSetup();
+    aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
+  } else {
+    aView->TriedronErase();
   }
+  aView->Update();
 }
index cd8b1c9e1c945603967a4f1af48ef0fb92d294d9..9cc4b3de68139b49fc471730a40f937c4134ef9d 100755 (executable)
@@ -63,8 +63,6 @@ public:
   virtual int           getBgImgHeight(){return myBgImgHeight; };
   virtual int           getBgImgWidth() {return myBgImgWidth;  };
 
-  virtual void          updateStaticTriedronVisibility();
-
 //   void         setActive( V3d_TypeOfView );
   virtual bool          syncronize( const OCCViewer_ViewPort3d* );
 
@@ -94,10 +92,12 @@ public:
   void                  setAdvancedZoomingEnabled( const bool theState ) { myIsAdvancedZoomingEnabled = theState; }
   bool                  isAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; }
 
+  void                  showStaticTrihedron( bool );
+
 signals:
   void                  vpChangeBackground( const Qtx::BackgroundData& );
-  void                  vpClosed();
-  void                  vpMapped();
+  void                  vpClosed(OCCViewer_ViewPort3d*);
+  void                  vpMapped(OCCViewer_ViewPort3d*);
 
 public slots:
   virtual bool          synchronize( OCCViewer_ViewPort* );
index 8b965a462cdeb38bb275197a9b64eb656737bda9..ec18d289247a59fd923a3820620247ec4bc607a8 100755 (executable)
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE\r
-//\r
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
-//\r
-// This library is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU Lesser General Public\r
-// License as published by the Free Software Foundation; either\r
-// version 2.1 of the License, or (at your option) any later version.\r
-//\r
-// This library is distributed in the hope that it will be useful,\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
-// Lesser General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU Lesser General Public\r
-// License along with this library; if not, write to the Free Software\r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA\r
-//\r
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
-//\r
-\r
-// File   : OCCViewer_ViewWindow.cxx\r
-// Author :\r
-\r
-#include "OCCViewer_ViewWindow.h"\r
-#include "OCCViewer_ViewModel.h"\r
-#include "OCCViewer_ViewPort3d.h"\r
-#include "OCCViewer_ViewManager.h"\r
-#include "OCCViewer_ViewSketcher.h"\r
-#include "OCCViewer_CreateRestoreViewDlg.h"\r
-#include "OCCViewer_ClipPlane.h"\r
-#include "OCCViewer_SetRotationPointDlg.h"\r
-#include "OCCViewer_AxialScaleDlg.h"\r
-#include "OCCViewer_CubeAxesDlg.h"\r
-#include "OCCViewer_ClippingDlg.h"\r
-\r
-#include <Basics_OCCTVersion.hxx>\r
-\r
-#include <SUIT_Desktop.h>\r
-#include <SUIT_Session.h>\r
-#include <SUIT_ViewManager.h>\r
-#include <SUIT_Tools.h>\r
-#include <SUIT_ResourceMgr.h>\r
-#include <SUIT_MessageBox.h>\r
-#include <SUIT_Application.h>\r
-\r
-#include <QtxActionToolMgr.h>\r
-#include <QtxMultiAction.h>\r
-#include <QtxRubberBand.h>\r
-\r
-#include <OpenGLUtils_FrameBuffer.h>\r
-\r
-#include <QPainter>\r
-#include <QTime>\r
-#include <QImage>\r
-#include <QKeyEvent>\r
-#include <QMouseEvent>\r
-#include <QApplication>\r
-#include <QMenu>\r
-\r
-#include <AIS_ListOfInteractive.hxx>\r
-#include <AIS_ListIteratorOfListOfInteractive.hxx>\r
-#include <AIS_Shape.hxx>\r
-\r
-#include <BRep_Tool.hxx>\r
-#include <BRepBndLib.hxx>\r
-#include <BRepGProp.hxx>\r
-#include <GProp_GProps.hxx>\r
-#include <TopoDS.hxx>\r
-\r
-#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>\r
-#include <Graphic3d_MapOfStructure.hxx>\r
-#include <Graphic3d_Structure.hxx>\r
-#include <Graphic3d_ExportFormat.hxx>\r
-\r
-#include <Visual3d_View.hxx>\r
-#include <V3d_Plane.hxx>\r
-#include <V3d_Light.hxx>\r
-\r
-#include <gp_Dir.hxx>\r
-#include <gp_Pln.hxx>\r
-#include <gp_GTrsf.hxx>\r
-#include <TColgp_Array1OfPnt2d.hxx>\r
-\r
-#if OCC_VERSION_LARGE > 0x06060000 \r
-#include <Graphic3d_SequenceOfHClipPlane.hxx>\r
-#include <Graphic3d_ClipPlane.hxx>\r
-\r
-#endif\r
-\r
-#include <Standard_Version.hxx>\r
-\r
-#include "utilities.h"\r
-\r
-// // OpenCV includes\r
-// #include <cv.h>\r
-// #include <highgui.h>\r
-\r
-static QEvent* l_mbPressEvent = 0;\r
-\r
-#ifdef WIN32\r
-# include <QWindowsStyle>\r
-#endif\r
-\r
-#include <GL/gl.h>\r
-\r
-const char* imageZoomCursor[] = {\r
-"32 32 3 1",\r
-". c None",\r
-"a c #000000",\r
-"# c #ffffff",\r
-"................................",\r
-"................................",\r
-".#######........................",\r
-"..aaaaaaa.......................",\r
-"................................",\r
-".............#####..............",\r
-"...........##.aaaa##............",\r
-"..........#.aa.....a#...........",\r
-".........#.a.........#..........",\r
-".........#a..........#a.........",\r
-"........#.a...........#.........",\r
-"........#a............#a........",\r
-"........#a............#a........",\r
-"........#a............#a........",\r
-"........#a............#a........",\r
-".........#...........#.a........",\r
-".........#a..........#a.........",\r
-".........##.........#.a.........",\r
-"........#####.....##.a..........",\r
-".......###aaa#####.aa...........",\r
-"......###aa...aaaaa.......#.....",\r
-".....###aa................#a....",\r
-"....###aa.................#a....",\r
-"...###aa...............#######..",\r
-"....#aa.................aa#aaaa.",\r
-".....a....................#a....",\r
-"..........................#a....",\r
-"...........................a....",\r
-"................................",\r
-"................................",\r
-"................................",\r
-"................................"};\r
-\r
-const char* imageRotateCursor[] = {\r
-"32 32 3 1",\r
-". c None",\r
-"a c #000000",\r
-"# c #ffffff",\r
-"................................",\r
-"................................",\r
-"................................",\r
-"................................",\r
-"........#.......................",\r
-".......#.a......................",\r
-"......#######...................",\r
-".......#aaaaa#####..............",\r
-"........#..##.a#aa##........##..",\r
-".........a#.aa..#..a#.....##.aa.",\r
-".........#.a.....#...#..##.aa...",\r
-".........#a.......#..###.aa.....",\r
-"........#.a.......#a..#aa.......",\r
-"........#a.........#..#a........",\r
-"........#a.........#a.#a........",\r
-"........#a.........#a.#a........",\r
-"........#a.........#a.#a........",\r
-".........#.........#a#.a........",\r
-"........##a........#a#a.........",\r
-"......##.a#.......#.#.a.........",\r
-"....##.aa..##.....##.a..........",\r
-"..##.aa.....a#####.aa...........",\r
-"...aa.........aaa#a.............",\r
-"................#.a.............",\r
-"...............#.a..............",\r
-"..............#.a...............",\r
-"...............a................",\r
-"................................",\r
-"................................",\r
-"................................",\r
-"................................",\r
-"................................"};\r
-\r
-const char* imageCrossCursor[] = {\r
-  "32 32 3 1",\r
-  ". c None",\r
-  "a c #000000",\r
-  "# c #ffffff",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "...............#................",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  ".......#################........",\r
-  "........aaaaaaa#aaaaaaaaa.......",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "...............#a...............",\r
-  "................a...............",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................",\r
-  "................................"};\r
-\r
-\r
-/*!\r
-  \brief Constructor\r
-  \param theDesktop main window of application\r
-  \param theModel OCC 3D viewer\r
-*/\r
-OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,\r
-                                            OCCViewer_Viewer* theModel )\r
-: SUIT_ViewWindow( theDesktop )\r
-{\r
-  myModel = theModel;\r
-  myRestoreFlag = 0;\r
-  myEnableDrawMode = false;\r
-  myDrawRect=false;\r
-  updateEnabledDrawMode();\r
-  myScalingDlg = 0;\r
-  mySetRotationPointDlg = 0;\r
-  myRectBand = 0;\r
-  \r
-  IsSketcherStyle = false;\r
-  myIsKeyFree = false;\r
-\r
-  mypSketcher = 0;\r
-  myCurSketch = -1;\r
-  my2dMode = No2dMode;\r
-\r
-  myInteractionStyle = SUIT_ViewModel::STANDARD;\r
-  myPreselectionEnabled = true;\r
-  mySelectionEnabled = true;\r
-\r
-\r
-  clearViewAspects();\r
-  \r
-}\r
-\r
-/*!\r
-  \brief Destructor.\r
-*/\r
-OCCViewer_ViewWindow::~OCCViewer_ViewWindow()\r
-{\r
-  endDrawRect();\r
-  qDeleteAll( mySketchers );\r
-}\r
-\r
-/*!\r
-  \brief Internal initialization.\r
-*/\r
-void OCCViewer_ViewWindow::initLayout()\r
-{\r
-  myViewPort = new OCCViewer_ViewPort3d( this, myModel->getViewer3d(), V3d_ORTHOGRAPHIC );\r
-  myViewPort->installEventFilter(this);\r
-  setCentralWidget(myViewPort);\r
-  myOperation = NOTHING;\r
-\r
-  myCurrPointType = GRAVITY;\r
-  myPrevPointType = GRAVITY;\r
-  mySelectedPoint = gp_Pnt(0.,0.,0.);\r
-  myRotationPointSelection = false;\r
-\r
-  setTransformRequested ( NOTHING );\r
-  setTransformInProcess ( false );\r
-\r
-  createActions();\r
-  createToolBar();\r
-\r
-  switch (my2dMode) {\r
-  case XYPlane:\r
-    onTopView();\r
-    break;\r
-  case XZPlane:\r
-    onLeftView();\r
-    break;\r
-  case YZPlane:\r
-    onFrontView();\r
-    break;\r
-  }\r
-\r
-  // Graduated axes dialog\r
-  QtxAction* anAction = dynamic_cast<QtxAction*>( toolMgr()->action( GraduatedAxesId ) );\r
-  myCubeAxesDlg = new OCCViewer_CubeAxesDlg( anAction, this, "OCCViewer_CubeAxesDlg" );\r
-  myCubeAxesDlg->initialize();\r
-  \r
-  connect( myViewPort, SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), this, SLOT( emitViewModified() ) );\r
-}\r
-\r
-OCCViewer_ViewWindow* OCCViewer_ViewWindow::getView( const int mode ) const\r
-{\r
-  return mode == get2dMode() ? const_cast<OCCViewer_ViewWindow*>( this ) : 0;\r
-}\r
-\r
-/*!\r
-  \brief Detect viewer operation according the the mouse button pressed\r
-  and key modifiers used.\r
-  \param theEvent mouse event\r
-  \return type of the operation\r
-*/\r
-OCCViewer_ViewWindow::OperationType\r
-OCCViewer_ViewWindow::getButtonState( QMouseEvent* theEvent, int theInteractionStyle )\r
-{\r
-  OperationType aOp = NOTHING;\r
-  SUIT_ViewModel::InteractionStyle aStyle = (SUIT_ViewModel::InteractionStyle)theInteractionStyle;\r
-  if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ZOOM]) &&\r
-      (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ZOOM]) )\r
-    aOp = ZOOMVIEW;\r
-  else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::PAN]) &&\r
-           (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::PAN]) )\r
-    aOp = PANVIEW;\r
-  else if( (theEvent->modifiers()  == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ROTATE]) &&\r
-           (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ROTATE]) &&\r
-           (my2dMode == No2dMode))\r
-    aOp = ROTATE;\r
-\r
-  return aOp;\r
-}\r
-\r
-/*!\r
-  \brief Customize event handling\r
-  \param watched event receiver object\r
-  \param e event\r
-  \return \c true if the event processing should be stopped\r
-*/\r
-bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )\r
-{\r
-  if ( watched == myViewPort ) {\r
-    int aType = e->type();\r
-    switch(aType) {\r
-    case QEvent::MouseButtonPress:\r
-      vpMousePressEvent((QMouseEvent*) e);\r
-      return true;\r
-\r
-    case QEvent::MouseButtonRelease:\r
-      vpMouseReleaseEvent((QMouseEvent*) e);\r
-      return true;\r
-\r
-    case QEvent::MouseMove:\r
-      vpMouseMoveEvent((QMouseEvent*) e);\r
-      return true;\r
-\r
-    case QEvent::MouseButtonDblClick:\r
-      emit mouseDoubleClicked(this, (QMouseEvent*)e);\r
-      return true;\r
-\r
-    case QEvent::Wheel:\r
-      {\r
-        QWheelEvent* aEvent = (QWheelEvent*) e;\r
-  myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() );\r
-  double delta = (double)( aEvent->delta() ) / ( 15 * 8 );\r
-  int x  = aEvent->x();\r
-  int y  = aEvent->y();\r
-  int x1 = (int)( aEvent->x() + width()*delta/100 );\r
-  int y1 = (int)( aEvent->y() + height()*delta/100 );\r
-  myViewPort->zoom( x, y, x1, y1 );\r
-      }\r
-      return true;\r
-\r
-    case QEvent::ContextMenu:\r
-      {\r
-        QContextMenuEvent * aEvent = (QContextMenuEvent*)e;\r
-        if ( aEvent->reason() != QContextMenuEvent::Mouse )\r
-          emit contextMenuRequested( aEvent );\r
-      }\r
-      return true;\r
-\r
-    case QEvent::KeyPress:\r
-      emit keyPressed(this, (QKeyEvent*) e);\r
-      return true;\r
-\r
-    default:\r
-      break;\r
-    }\r
-  }\r
-  return SUIT_ViewWindow::eventFilter(watched, e);\r
-}\r
-\r
-/*!\r
-  \brief Update state of enable draw mode state.\r
-*/\r
-void OCCViewer_ViewWindow::updateEnabledDrawMode()\r
-{\r
-  if ( myModel )\r
-    myEnableDrawMode = myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled();\r
-}\r
-\r
-/*!\r
-  \brief Handle mouse press event\r
-  \param theEvent mouse event\r
-*/\r
-void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )\r
-{\r
-  myStartX = theEvent->x();\r
-  myStartY = theEvent->y();\r
-  int anInteractionStyle = interactionStyle();\r
-\r
-  // in "key free" interaction style zoom operation is activated by two buttons (simultaneously pressed),\r
-  // which are assigned for pan and rotate - these operations are activated immediately after pressing \r
-  // of the first button, so it is necessary to switch to zoom when the second button is pressed\r
-  bool aSwitchToZoom = false;\r
-  if ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && \r
-       ( myOperation == PANVIEW || myOperation == ROTATE ) ) {\r
-    aSwitchToZoom = getButtonState( theEvent, anInteractionStyle ) == ZOOMVIEW;\r
-  }\r
-\r
-  switch ( myOperation ) {\r
-  case WINDOWFIT:\r
-    if ( theEvent->button() == Qt::LeftButton )\r
-      emit vpTransformationStarted ( WINDOWFIT );\r
-    break;\r
-\r
-  case PANGLOBAL:\r
-    if ( theEvent->button() == Qt::LeftButton )\r
-      emit vpTransformationStarted ( PANGLOBAL );\r
-    break;\r
-\r
-  case ZOOMVIEW:\r
-    if ( theEvent->button() == Qt::LeftButton ) {\r
-      myViewPort->startZoomAtPoint( myStartX, myStartY );\r
-      emit vpTransformationStarted ( ZOOMVIEW );\r
-    }\r
-    break;\r
-\r
-  case PANVIEW:\r
-    if ( aSwitchToZoom ) {\r
-      myViewPort->startZoomAtPoint( myStartX, myStartY );\r
-      activateZoom();\r
-    }\r
-    else if ( theEvent->button() == Qt::LeftButton )\r
-      emit vpTransformationStarted ( PANVIEW );\r
-    break;\r
-\r
-  case ROTATE:\r
-    if ( aSwitchToZoom ) {\r
-      myViewPort->startZoomAtPoint( myStartX, myStartY );\r
-      activateZoom();\r
-    }\r
-    else if ( theEvent->button() == Qt::LeftButton ) {\r
-      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);\r
-      emit vpTransformationStarted ( ROTATE );\r
-    }\r
-    break;\r
-\r
-  default:\r
-  /*  Try to activate a transformation */\r
-    OperationType aState;\r
-    if ( interactionStyle() == SUIT_ViewModel::STANDARD )\r
-      aState = getButtonState(theEvent, anInteractionStyle);\r
-    else {\r
-      aState = OCCViewer_ViewWindow::NOTHING;\r
-      myIsKeyFree = true;\r
-    }\r
-    switch ( aState ) {\r
-    case ZOOMVIEW:\r
-      myViewPort->startZoomAtPoint( myStartX, myStartY );\r
-      activateZoom();\r
-      break;\r
-    case PANVIEW:\r
-      activatePanning();\r
-      break;\r
-    case ROTATE:\r
-      activateRotation();\r
-      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);\r
-      break;\r
-    default:\r
-      if ( myRotationPointSelection )\r
-      {\r
-        if ( theEvent->button() == Qt::LeftButton )\r
-        {\r
-          Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-          ic->Select();\r
-          for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() )\r
-          {\r
-            TopoDS_Shape aShape = ic->SelectedShape();\r
-            GProp_GProps aSystem;\r
-            gp_Pnt aPnt;\r
-            if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )\r
-            {\r
-              aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );\r
-            }\r
-            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE )\r
-            {\r
-              BRepGProp::LinearProperties( aShape, aSystem );\r
-              aPnt = aSystem.CentreOfMass();\r
-            }\r
-            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_FACE )\r
-            {\r
-              BRepGProp::SurfaceProperties( aShape, aSystem );\r
-              aPnt = aSystem.CentreOfMass();\r
-            }\r
-            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_SOLID )\r
-            {\r
-              BRepGProp::VolumeProperties( aShape, aSystem );\r
-              aPnt = aSystem.CentreOfMass();\r
-            }\r
-            else\r
-            {\r
-              myCurrPointType = myPrevPointType;\r
-              break;\r
-            }\r
-\r
-            if ( mySetRotationPointDlg )\r
-            {\r
-              myRotationPointSelection = false;\r
-              mySetRotationPointDlg->setCoords(aPnt.X(), aPnt.Y(), aPnt.Z());\r
-            }\r
-          }\r
-          if ( ic->NbSelected() == 0 ) myCurrPointType = myPrevPointType;\r
-          if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();\r
-          ic->CloseAllContexts();\r
-          myOperation = NOTHING;\r
-          myViewPort->setCursor( myCursor );\r
-          myCursorIsHand = false;\r
-          myRotationPointSelection = false;\r
-        }\r
-      }\r
-      else\r
-        emit mousePressed(this, theEvent);\r
-      break;\r
-    }\r
-    /* notify that we start a transformation */\r
-    if ( transformRequested() )\r
-            emit vpTransformationStarted ( myOperation );\r
-  }\r
-  if ( transformRequested() )\r
-    setTransformInProcess( true );\r
-\r
-  /* we may need it for sketching... */\r
-  if ( l_mbPressEvent )\r
-    delete l_mbPressEvent;\r
-  l_mbPressEvent = new QMouseEvent( *theEvent );\r
-}\r
-\r
-\r
-/*!\r
-  \brief Start zooming operation.\r
-\r
-  Sets the corresponding cursor for the widget.\r
-*/\r
-void OCCViewer_ViewWindow::activateZoom()\r
-{\r
-  if ( !transformRequested() && !myCursorIsHand )\r
-    myCursor = cursor();                /* save old cursor */\r
-\r
-  if ( myOperation != ZOOMVIEW ) {\r
-    QPixmap zoomPixmap (imageZoomCursor);\r
-    QCursor zoomCursor (zoomPixmap);\r
-    if( setTransformRequested ( ZOOMVIEW ) )\r
-      myViewPort->setCursor( zoomCursor );\r
-  }\r
-}\r
-\r
-\r
-/*!\r
-  \brief Start panning operation.\r
-\r
-  Sets the corresponding cursor for the widget.\r
-*/\r
-void OCCViewer_ViewWindow::activatePanning()\r
-{\r
-  if ( !transformRequested() && !myCursorIsHand )\r
-    myCursor = cursor();                // save old cursor\r
-\r
-  if ( myOperation != PANVIEW ) {\r
-    QCursor panCursor (Qt::SizeAllCursor);\r
-    if( setTransformRequested ( PANVIEW ) )\r
-      myViewPort->setCursor( panCursor );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Start rotation operation\r
-\r
-  Sets the corresponding cursor for the widget.\r
-*/\r
-void OCCViewer_ViewWindow::activateRotation()\r
-{\r
-  if ( !transformRequested() && !myCursorIsHand )\r
-    myCursor = cursor();                // save old cursor\r
-\r
-  if ( myOperation != ROTATE ) {\r
-    QPixmap rotatePixmap (imageRotateCursor);\r
-    QCursor rotCursor (rotatePixmap);\r
-    if( setTransformRequested ( ROTATE ) )\r
-      myViewPort->setCursor( rotCursor );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Compute the gravity center.\r
-  \param theX used to return X coordinate of the gravity center\r
-  \param theY used to return Y coordinate of the gravity center\r
-  \param theZ used to return Z coordinate of the gravity center\r
-  \return \c true if the gravity center is computed\r
-*/\r
-bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, double& theZ )\r
-{\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-\r
-  // Project boundaries points and add to avergae gravity\r
-  // the ones which lie within the screen limits\r
-  Standard_Real aScreenLimits[4] = { 0.0, 0.0, 0.0, 0.0 };\r
-\r
-#if OCC_VERSION_LARGE > 0x06070100\r
-  // NDC space screen limits\r
-  aScreenLimits[0] = -1.0;\r
-  aScreenLimits[1] =  1.0;\r
-  aScreenLimits[2] = -1.0;\r
-  aScreenLimits[3] =  1.0;\r
-#else\r
-  aView3d->View()->ViewMapping().WindowLimit( aScreenLimits[0],\r
-                                              aScreenLimits[1],\r
-                                              aScreenLimits[2],\r
-                                              aScreenLimits[3] );\r
-#endif\r
-\r
-  Standard_Integer aPointsNb = 0;\r
-\r
-  Standard_Real aXmin = 0.0;\r
-  Standard_Real aYmin = 0.0;\r
-  Standard_Real aZmin = 0.0;\r
-  Standard_Real aXmax = 0.0;\r
-  Standard_Real aYmax = 0.0;\r
-  Standard_Real aZmax = 0.0;\r
-\r
-  Graphic3d_MapOfStructure aSetOfStructures;\r
-  aView3d->View()->DisplayedStructures( aSetOfStructures );\r
-  Graphic3d_MapIteratorOfMapOfStructure aStructureIt( aSetOfStructures );\r
-\r
-  for( ; aStructureIt.More(); aStructureIt.Next() ) {\r
-    const Handle(Graphic3d_Structure)& aStructure = aStructureIt.Key();\r
-    if ( aStructure->IsEmpty() ) {\r
-      continue;\r
-    }\r
-\r
-    aStructure->MinMaxValues( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );\r
-\r
-    // Infinite structures are skipped\r
-    Standard_Real aLIM = ShortRealLast() - 1.0;\r
-    if ( Abs( aXmin ) > aLIM || Abs( aYmin ) > aLIM || Abs( aZmin ) > aLIM\r
-      || Abs( aXmax ) > aLIM || Abs( aYmax ) > aLIM || Abs( aZmax ) > aLIM ) {\r
-      continue;\r
-    }\r
-\r
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : OCCViewer_ViewWindow.cxx
+// Author :
+
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewModel.h"
+#include "OCCViewer_ViewPort3d.h"
+#include "OCCViewer_ViewManager.h"
+#include "OCCViewer_ViewSketcher.h"
+#include "OCCViewer_CreateRestoreViewDlg.h"
+#include "OCCViewer_ClipPlane.h"
+#include "OCCViewer_SetRotationPointDlg.h"
+#include "OCCViewer_AxialScaleDlg.h"
+#include "OCCViewer_CubeAxesDlg.h"
+#include "OCCViewer_ClippingDlg.h"
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_Tools.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Application.h>
+
+#include <QtxActionToolMgr.h>
+#include <QtxMultiAction.h>
+#include <QtxRubberBand.h>
+
+#include <OpenGLUtils_FrameBuffer.h>
+
+#include <QPainter>
+#include <QTime>
+#include <QImage>
+#include <QKeyEvent>
+#include <QMouseEvent>
+#include <QApplication>
+#include <QMenu>
+
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Shape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
+#include <TopoDS.hxx>
+
+#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
+#include <Graphic3d_MapOfStructure.hxx>
+#include <Graphic3d_Structure.hxx>
+#include <Graphic3d_ExportFormat.hxx>
+
+#include <Visual3d_View.hxx>
+#include <V3d_Plane.hxx>
+#include <V3d_Light.hxx>
+
+#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
+#include <gp_GTrsf.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
+
+#if OCC_VERSION_LARGE > 0x06060000 
+#include <Graphic3d_SequenceOfHClipPlane.hxx>
+#include <Graphic3d_ClipPlane.hxx>
+
+#endif
+
+#include <Standard_Version.hxx>
+
+#include "utilities.h"
+
+// // OpenCV includes
+// #include <cv.h>
+// #include <highgui.h>
+
+static QEvent* l_mbPressEvent = 0;
+
+#ifdef WIN32
+# include <QWindowsStyle>
+#endif
+
+#include <GL/gl.h>
+
+const char* imageZoomCursor[] = {
+"32 32 3 1",
+". c None",
+"a c #000000",
+"# c #ffffff",
+"................................",
+"................................",
+".#######........................",
+"..aaaaaaa.......................",
+"................................",
+".............#####..............",
+"...........##.aaaa##............",
+"..........#.aa.....a#...........",
+".........#.a.........#..........",
+".........#a..........#a.........",
+"........#.a...........#.........",
+"........#a............#a........",
+"........#a............#a........",
+"........#a............#a........",
+"........#a............#a........",
+".........#...........#.a........",
+".........#a..........#a.........",
+".........##.........#.a.........",
+"........#####.....##.a..........",
+".......###aaa#####.aa...........",
+"......###aa...aaaaa.......#.....",
+".....###aa................#a....",
+"....###aa.................#a....",
+"...###aa...............#######..",
+"....#aa.................aa#aaaa.",
+".....a....................#a....",
+"..........................#a....",
+"...........................a....",
+"................................",
+"................................",
+"................................",
+"................................"};
+
+const char* imageRotateCursor[] = {
+"32 32 3 1",
+". c None",
+"a c #000000",
+"# c #ffffff",
+"................................",
+"................................",
+"................................",
+"................................",
+"........#.......................",
+".......#.a......................",
+"......#######...................",
+".......#aaaaa#####..............",
+"........#..##.a#aa##........##..",
+".........a#.aa..#..a#.....##.aa.",
+".........#.a.....#...#..##.aa...",
+".........#a.......#..###.aa.....",
+"........#.a.......#a..#aa.......",
+"........#a.........#..#a........",
+"........#a.........#a.#a........",
+"........#a.........#a.#a........",
+"........#a.........#a.#a........",
+".........#.........#a#.a........",
+"........##a........#a#a.........",
+"......##.a#.......#.#.a.........",
+"....##.aa..##.....##.a..........",
+"..##.aa.....a#####.aa...........",
+"...aa.........aaa#a.............",
+"................#.a.............",
+"...............#.a..............",
+"..............#.a...............",
+"...............a................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................"};
+
+const char* imageCrossCursor[] = {
+  "32 32 3 1",
+  ". c None",
+  "a c #000000",
+  "# c #ffffff",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "...............#................",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  ".......#################........",
+  "........aaaaaaa#aaaaaaaaa.......",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "................a...............",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................"};
+
+
+/*!
+  \brief Constructor
+  \param theDesktop main window of application
+  \param theModel OCC 3D viewer
+*/
+OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,
+                                            OCCViewer_Viewer* theModel )
+: SUIT_ViewWindow( theDesktop )
+{
+  myModel = theModel;
+  myRestoreFlag = 0;
+  myEnableDrawMode = false;
+  myDrawRect=false;
+  updateEnabledDrawMode();
+  myScalingDlg = 0;
+  mySetRotationPointDlg = 0;
+  myRectBand = 0;
+  
+  IsSketcherStyle = false;
+  myIsKeyFree = false;
+
+  mypSketcher = 0;
+  myCurSketch = -1;
+  my2dMode = No2dMode;
+
+  myInteractionStyle = SUIT_ViewModel::STANDARD;
+  myPreselectionEnabled = true;
+  mySelectionEnabled = true;
+
+
+  clearViewAspects();
+  
+}
+
+/*!
+  \brief Destructor.
+*/
+OCCViewer_ViewWindow::~OCCViewer_ViewWindow()
+{
+  endDrawRect();
+  qDeleteAll( mySketchers );
+}
+
+/*!
+  \brief Internal initialization.
+*/
+void OCCViewer_ViewWindow::initLayout()
+{
+  myViewPort = new OCCViewer_ViewPort3d( this, myModel->getViewer3d(), V3d_ORTHOGRAPHIC );
+  myViewPort->installEventFilter(this);
+  setCentralWidget(myViewPort);
+  myOperation = NOTHING;
+
+  myCurrPointType = GRAVITY;
+  myPrevPointType = GRAVITY;
+  mySelectedPoint = gp_Pnt(0.,0.,0.);
+  myRotationPointSelection = false;
+
+  setTransformRequested ( NOTHING );
+  setTransformInProcess ( false );
+
+  createActions();
+  createToolBar();
+
+  switch (my2dMode) {
+  case XYPlane:
+    onTopView();
+    break;
+  case XZPlane:
+    onLeftView();
+    break;
+  case YZPlane:
+    onFrontView();
+    break;
+  }
+
+  // Graduated axes dialog
+  QtxAction* anAction = dynamic_cast<QtxAction*>( toolMgr()->action( GraduatedAxesId ) );
+  myCubeAxesDlg = new OCCViewer_CubeAxesDlg( anAction, this, "OCCViewer_CubeAxesDlg" );
+  myCubeAxesDlg->initialize();
+  
+  connect( myViewPort, SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), this, SLOT( emitViewModified() ) );
+}
+
+OCCViewer_ViewWindow* OCCViewer_ViewWindow::getView( const int mode ) const
+{
+  return mode == get2dMode() ? const_cast<OCCViewer_ViewWindow*>( this ) : 0;
+}
+
+/*!
+  \brief Detect viewer operation according the the mouse button pressed
+  and key modifiers used.
+  \param theEvent mouse event
+  \return type of the operation
+*/
+OCCViewer_ViewWindow::OperationType
+OCCViewer_ViewWindow::getButtonState( QMouseEvent* theEvent, int theInteractionStyle )
+{
+  OperationType aOp = NOTHING;
+  SUIT_ViewModel::InteractionStyle aStyle = (SUIT_ViewModel::InteractionStyle)theInteractionStyle;
+  if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ZOOM]) &&
+      (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ZOOM]) )
+    aOp = ZOOMVIEW;
+  else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::PAN]) &&
+           (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::PAN]) )
+    aOp = PANVIEW;
+  else if( (theEvent->modifiers()  == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ROTATE]) &&
+           (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ROTATE]) &&
+           (my2dMode == No2dMode))
+    aOp = ROTATE;
+
+  return aOp;
+}
+
+/*!
+  \brief Customize event handling
+  \param watched event receiver object
+  \param e event
+  \return \c true if the event processing should be stopped
+*/
+bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
+{
+  if ( watched == myViewPort ) {
+    int aType = e->type();
+    switch(aType) {
+    case QEvent::MouseButtonPress:
+      vpMousePressEvent((QMouseEvent*) e);
+      return true;
+
+    case QEvent::MouseButtonRelease:
+      vpMouseReleaseEvent((QMouseEvent*) e);
+      return true;
+
+    case QEvent::MouseMove:
+      vpMouseMoveEvent((QMouseEvent*) e);
+      return true;
+
+    case QEvent::MouseButtonDblClick:
+      emit mouseDoubleClicked(this, (QMouseEvent*)e);
+      return true;
+
+    case QEvent::Wheel:
+      {
+        QWheelEvent* aEvent = (QWheelEvent*) e;
+  myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() );
+  double delta = (double)( aEvent->delta() ) / ( 15 * 8 );
+  int x  = aEvent->x();
+  int y  = aEvent->y();
+  int x1 = (int)( aEvent->x() + width()*delta/100 );
+  int y1 = (int)( aEvent->y() + height()*delta/100 );
+  myViewPort->zoom( x, y, x1, y1 );
+      }
+      return true;
+
+    case QEvent::ContextMenu:
+      {
+        QContextMenuEvent * aEvent = (QContextMenuEvent*)e;
+        if ( aEvent->reason() != QContextMenuEvent::Mouse )
+          emit contextMenuRequested( aEvent );
+      }
+      return true;
+
+    case QEvent::KeyPress:
+      emit keyPressed(this, (QKeyEvent*) e);
+      return true;
+
+    default:
+      break;
+    }
+  }
+  return SUIT_ViewWindow::eventFilter(watched, e);
+}
+
+/*!
+  \brief Update state of enable draw mode state.
+*/
+void OCCViewer_ViewWindow::updateEnabledDrawMode()
+{
+  if ( myModel )
+    myEnableDrawMode = myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled();
+}
+
+/*!
+  \brief Handle mouse press event
+  \param theEvent mouse event
+*/
+void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )
+{
+  myStartX = theEvent->x();
+  myStartY = theEvent->y();
+  int anInteractionStyle = interactionStyle();
+
+  // in "key free" interaction style zoom operation is activated by two buttons (simultaneously pressed),
+  // which are assigned for pan and rotate - these operations are activated immediately after pressing 
+  // of the first button, so it is necessary to switch to zoom when the second button is pressed
+  bool aSwitchToZoom = false;
+  if ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && 
+       ( myOperation == PANVIEW || myOperation == ROTATE ) ) {
+    aSwitchToZoom = getButtonState( theEvent, anInteractionStyle ) == ZOOMVIEW;
+  }
+
+  switch ( myOperation ) {
+  case WINDOWFIT:
+    if ( theEvent->button() == Qt::LeftButton )
+      emit vpTransformationStarted ( WINDOWFIT );
+    break;
+
+  case PANGLOBAL:
+    if ( theEvent->button() == Qt::LeftButton )
+      emit vpTransformationStarted ( PANGLOBAL );
+    break;
+
+  case ZOOMVIEW:
+    if ( theEvent->button() == Qt::LeftButton ) {
+      myViewPort->startZoomAtPoint( myStartX, myStartY );
+      emit vpTransformationStarted ( ZOOMVIEW );
+    }
+    break;
+
+  case PANVIEW:
+    if ( aSwitchToZoom ) {
+      myViewPort->startZoomAtPoint( myStartX, myStartY );
+      activateZoom();
+    }
+    else if ( theEvent->button() == Qt::LeftButton )
+      emit vpTransformationStarted ( PANVIEW );
+    break;
+
+  case ROTATE:
+    if ( aSwitchToZoom ) {
+      myViewPort->startZoomAtPoint( myStartX, myStartY );
+      activateZoom();
+    }
+    else if ( theEvent->button() == Qt::LeftButton ) {
+      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
+      emit vpTransformationStarted ( ROTATE );
+    }
+    break;
+
+  default:
+  /*  Try to activate a transformation */
+    OperationType aState;
+    if ( interactionStyle() == SUIT_ViewModel::STANDARD )
+      aState = getButtonState(theEvent, anInteractionStyle);
+    else {
+      aState = OCCViewer_ViewWindow::NOTHING;
+      myIsKeyFree = true;
+    }
+    switch ( aState ) {
+    case ZOOMVIEW:
+      myViewPort->startZoomAtPoint( myStartX, myStartY );
+      activateZoom();
+      break;
+    case PANVIEW:
+      activatePanning();
+      break;
+    case ROTATE:
+      activateRotation();
+      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
+      break;
+    default:
+      if ( myRotationPointSelection )
+      {
+        if ( theEvent->button() == Qt::LeftButton )
+        {
+          Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+          ic->Select();
+          for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() )
+          {
+            TopoDS_Shape aShape = ic->SelectedShape();
+            GProp_GProps aSystem;
+            gp_Pnt aPnt;
+            if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
+            {
+              aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
+            }
+            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE )
+            {
+              BRepGProp::LinearProperties( aShape, aSystem );
+              aPnt = aSystem.CentreOfMass();
+            }
+            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_FACE )
+            {
+              BRepGProp::SurfaceProperties( aShape, aSystem );
+              aPnt = aSystem.CentreOfMass();
+            }
+            else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_SOLID )
+            {
+              BRepGProp::VolumeProperties( aShape, aSystem );
+              aPnt = aSystem.CentreOfMass();
+            }
+            else
+            {
+              myCurrPointType = myPrevPointType;
+              break;
+            }
+
+            if ( mySetRotationPointDlg )
+            {
+              myRotationPointSelection = false;
+              mySetRotationPointDlg->setCoords(aPnt.X(), aPnt.Y(), aPnt.Z());
+            }
+          }
+          if ( ic->NbSelected() == 0 ) myCurrPointType = myPrevPointType;
+          if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();
+          ic->CloseAllContexts();
+          myOperation = NOTHING;
+          myViewPort->setCursor( myCursor );
+          myCursorIsHand = false;
+          myRotationPointSelection = false;
+        }
+      }
+      else
+        emit mousePressed(this, theEvent);
+      break;
+    }
+    /* notify that we start a transformation */
+    if ( transformRequested() )
+            emit vpTransformationStarted ( myOperation );
+  }
+  if ( transformRequested() )
+    setTransformInProcess( true );
+
+  /* we may need it for sketching... */
+  if ( l_mbPressEvent )
+    delete l_mbPressEvent;
+  l_mbPressEvent = new QMouseEvent( *theEvent );
+}
+
+
+/*!
+  \brief Start zooming operation.
+
+  Sets the corresponding cursor for the widget.
+*/
+void OCCViewer_ViewWindow::activateZoom()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();                /* save old cursor */
+
+  if ( myOperation != ZOOMVIEW ) {
+    QPixmap zoomPixmap (imageZoomCursor);
+    QCursor zoomCursor (zoomPixmap);
+    if( setTransformRequested ( ZOOMVIEW ) )
+      myViewPort->setCursor( zoomCursor );
+  }
+}
+
+
+/*!
+  \brief Start panning operation.
+
+  Sets the corresponding cursor for the widget.
+*/
+void OCCViewer_ViewWindow::activatePanning()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();                // save old cursor
+
+  if ( myOperation != PANVIEW ) {
+    QCursor panCursor (Qt::SizeAllCursor);
+    if( setTransformRequested ( PANVIEW ) )
+      myViewPort->setCursor( panCursor );
+  }
+}
+
+/*!
+  \brief Start rotation operation
+
+  Sets the corresponding cursor for the widget.
+*/
+void OCCViewer_ViewWindow::activateRotation()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();                // save old cursor
+
+  if ( myOperation != ROTATE ) {
+    QPixmap rotatePixmap (imageRotateCursor);
+    QCursor rotCursor (rotatePixmap);
+    if( setTransformRequested ( ROTATE ) )
+      myViewPort->setCursor( rotCursor );
+  }
+}
+
+/*!
+  \brief Compute the gravity center.
+  \param theX used to return X coordinate of the gravity center
+  \param theY used to return Y coordinate of the gravity center
+  \param theZ used to return Z coordinate of the gravity center
+  \return \c true if the gravity center is computed
+*/
+bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, double& theZ )
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+
+  // Project boundaries points and add to avergae gravity
+  // the ones which lie within the screen limits
+  Standard_Real aScreenLimits[4] = { 0.0, 0.0, 0.0, 0.0 };
+
+#if OCC_VERSION_LARGE > 0x06070100
+  // NDC space screen limits
+  aScreenLimits[0] = -1.0;
+  aScreenLimits[1] =  1.0;
+  aScreenLimits[2] = -1.0;
+  aScreenLimits[3] =  1.0;
+#else
+  aView3d->View()->ViewMapping().WindowLimit( aScreenLimits[0],
+                                              aScreenLimits[1],
+                                              aScreenLimits[2],
+                                              aScreenLimits[3] );
+#endif
+
+  Standard_Integer aPointsNb = 0;
+
+  Standard_Real aXmin = 0.0;
+  Standard_Real aYmin = 0.0;
+  Standard_Real aZmin = 0.0;
+  Standard_Real aXmax = 0.0;
+  Standard_Real aYmax = 0.0;
+  Standard_Real aZmax = 0.0;
+
+  Graphic3d_MapOfStructure aSetOfStructures;
+  aView3d->View()->DisplayedStructures( aSetOfStructures );
+  Graphic3d_MapIteratorOfMapOfStructure aStructureIt( aSetOfStructures );
+
+  for( ; aStructureIt.More(); aStructureIt.Next() ) {
+    const Handle(Graphic3d_Structure)& aStructure = aStructureIt.Key();
+    if ( aStructure->IsEmpty() ) {
+      continue;
+    }
+
+    aStructure->MinMaxValues( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+
+    // Infinite structures are skipped
+    Standard_Real aLIM = ShortRealLast() - 1.0;
+    if ( Abs( aXmin ) > aLIM || Abs( aYmin ) > aLIM || Abs( aZmin ) > aLIM
+      || Abs( aXmax ) > aLIM || Abs( aYmax ) > aLIM || Abs( aZmax ) > aLIM ) {
+      continue;
+    }
+
     gp_Pnt aPoints[8] = {
       gp_Pnt( aXmin, aYmin, aZmin ), gp_Pnt( aXmin, aYmin, aZmax ),
       gp_Pnt( aXmin, aYmax, aZmin ), gp_Pnt( aXmin, aYmax, aZmax ),
       gp_Pnt( aXmax, aYmin, aZmin ), gp_Pnt( aXmax, aYmin, aZmax ),
       gp_Pnt( aXmax, aYmax, aZmin ), gp_Pnt( aXmax, aYmax, aZmax )
     };
-\r
-    for ( Standard_Integer aPointIt = 0; aPointIt < 8; ++aPointIt ) {\r
+
+    for ( Standard_Integer aPointIt = 0; aPointIt < 8; ++aPointIt ) {
       const gp_Pnt& aBBPoint = aPoints[aPointIt];
 
 #if OCC_VERSION_LARGE > 0x06070100
@@ -690,2352 +690,2357 @@ bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, dou
         theX += aBBPoint.X();
         theY += aBBPoint.Y();
         theZ += aBBPoint.Z();
-      }\r
-    }\r
-  }\r
-\r
-  if ( aPointsNb > 0 )\r
-  {\r
-    theX /= aPointsNb;\r
-    theY /= aPointsNb;\r
-    theZ /= aPointsNb;\r
-  }\r
-  return true;\r
-}\r
-\r
-/*!\r
-  \brief Set the gravity center as a rotation point.\r
-*/\r
-void OCCViewer_ViewWindow::activateSetRotationGravity()\r
-{\r
-  if ( myRotationPointSelection )\r
-  {\r
-    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-    ic->CloseAllContexts();\r
-    myOperation = NOTHING;\r
-    myViewPort->setCursor( myCursor );\r
-    myCursorIsHand = false;\r
-    myRotationPointSelection = false;\r
-  }\r
-\r
-  myPrevPointType = myCurrPointType;\r
-  myCurrPointType = GRAVITY;\r
-\r
-  Standard_Real Xcenter, Ycenter, Zcenter;\r
-  if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )\r
-    mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );\r
-}\r
-\r
-/*!\r
-  \brief Update gravity center in the "Set Rotation Point" dialog box.\r
-  \sa OCCViewer_SetRotationPointDlg class\r
-*/\r
-void OCCViewer_ViewWindow::updateGravityCoords()\r
-{\r
-  if ( mySetRotationPointDlg && mySetRotationPointDlg->isVisible() && myCurrPointType == GRAVITY )\r
-  {\r
-    Standard_Real Xcenter, Ycenter, Zcenter;\r
-    if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )\r
-      mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Set the point selected by the user as a rotation point.\r
-  \param theX X coordinate of the rotation point\r
-  \param theY Y coordinate of the rotation point\r
-  \param theZ Z coordinate of the rotation point\r
-*/\r
-void OCCViewer_ViewWindow::activateSetRotationSelected( double theX, double theY, double theZ )\r
-{\r
-  if ( myRotationPointSelection )\r
-  {\r
-    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-    ic->CloseAllContexts();\r
-    myOperation = NOTHING;\r
-    myViewPort->setCursor( myCursor );\r
-    myCursorIsHand = false;\r
-    myRotationPointSelection = false;\r
-  }\r
-\r
-  myPrevPointType = myCurrPointType;\r
-  myCurrPointType = SELECTED;\r
-  mySelectedPoint.SetCoord(theX,theY,theZ);\r
-}\r
-\r
-/*!\r
-  \brief Start the shape selection process.\r
-*/\r
-void OCCViewer_ViewWindow::activateStartPointSelection( TopAbs_ShapeEnum theShapeType )\r
-{\r
-  myPrevPointType = myCurrPointType;\r
-  myCurrPointType = SELECTED;\r
-\r
-  // activate selection ------>\r
-  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-\r
-  ic->OpenLocalContext();\r
-\r
-  AIS_ListOfInteractive aList;\r
-  ic->DisplayedObjects( aList );\r
-  for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() )\r
-  {\r
-    Handle(AIS_InteractiveObject) anObj = it.Value();\r
-    if ( !anObj.IsNull() && anObj->HasPresentation() &&\r
-         anObj->IsKind( STANDARD_TYPE(AIS_Shape) ) )\r
-    {\r
-      ic->Load(anObj,-1);\r
-      ic->Activate(anObj,AIS_Shape::SelectionMode(theShapeType));\r
-     }\r
-  }\r
-  // activate selection <------\r
-\r
-  if ( !myCursorIsHand )\r
-  {\r
-    QCursor handCursor (Qt::PointingHandCursor);\r
-    myCursorIsHand = true;\r
-    myCursor = cursor();\r
-    myViewPort->setCursor( handCursor );\r
-  }\r
-  myRotationPointSelection = true;\r
-}\r
-\r
-/*!\r
-  \brief Start global panning operation\r
-\r
-  Sets the corresponding cursor for the widget.\r
-*/\r
-void OCCViewer_ViewWindow::activateGlobalPanning()\r
-{\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) {\r
-    QPixmap globalPanPixmap (imageCrossCursor);\r
-    QCursor glPanCursor (globalPanPixmap);\r
-    myCurScale = aView3d->Scale();\r
-    aView3d->FitAll(0.01, false);\r
-    myCursor = cursor();                // save old cursor\r
-    myViewPort->fitAll(); // fits view before selecting a new scene center\r
-    if( setTransformRequested( PANGLOBAL ) )\r
-      myViewPort->setCursor( glPanCursor );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Starts fit operation.\r
-\r
-  Sets the corresponding cursor for the widget.\r
-*/\r
-void OCCViewer_ViewWindow::activateWindowFit()\r
-{\r
-  if ( !transformRequested() && !myCursorIsHand )\r
-    myCursor = cursor();                /* save old cursor */\r
-\r
-  if ( myOperation != WINDOWFIT ) {\r
-    QCursor handCursor (Qt::PointingHandCursor);\r
-    if( setTransformRequested ( WINDOWFIT ) )\r
-    {\r
-      myViewPort->setCursor ( handCursor );\r
-      myCursorIsHand = true;\r
-    }\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Start delayed viewer operation.\r
-*/\r
-bool OCCViewer_ViewWindow::setTransformRequested( OperationType op )\r
-{\r
-  bool ok = transformEnabled( op );\r
-  myOperation = ok ? op : NOTHING;\r
-  myViewPort->setMouseTracking( myOperation == NOTHING );  \r
-  return ok;\r
-}\r
-\r
-/*!\r
-  \brief Handle mouse move event.\r
-  \param theEvent mouse event\r
-*/\r
-void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent )\r
-{\r
-  if ( myIsKeyFree && interactionStyle() == SUIT_ViewModel::KEY_FREE ) {\r
-    myIsKeyFree = false;\r
-    switch ( getButtonState( theEvent, interactionStyle() ) ) {\r
-    case ZOOMVIEW:\r
-      myViewPort->startZoomAtPoint( myStartX, myStartY );\r
-      activateZoom();\r
-      break;\r
-    case PANVIEW:\r
-      activatePanning();\r
-      break;\r
-    case ROTATE:\r
-      activateRotation();\r
-      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);\r
-      break;\r
-    default:\r
-      break;\r
-    }\r
-  }\r
-\r
-  myCurrX = theEvent->x();\r
-  myCurrY = theEvent->y();\r
-  switch (myOperation) {\r
-  case ROTATE:\r
-    myViewPort->rotate(myCurrX, myCurrY, myCurrPointType, mySelectedPoint);\r
-    break;\r
-\r
-  case ZOOMVIEW:\r
-    myViewPort->zoom(myStartX, myStartY, myCurrX, myCurrY);\r
-    myStartX = myCurrX;\r
-    myStartY = myCurrY;\r
-    break;\r
-\r
-  case PANVIEW:\r
-    myViewPort->pan(myCurrX - myStartX, myStartY - myCurrY);\r
-    myStartX = myCurrX;\r
-    myStartY = myCurrY;\r
-    break;\r
-\r
-/*    case WINDOWFIT:\r
-    myDrawRect = true;\r
-    repaint();\r
-    break;\r
-*/\r
-  case PANGLOBAL:\r
-    break;\r
-\r
-  default:\r
-    if ( myRotationPointSelection || isSketcherStyle() )\r
-    {\r
-      emit mouseMoving( this, theEvent );\r
-    }\r
-    else\r
-    {\r
-      int aState = theEvent->modifiers();\r
-      int aButton = theEvent->buttons();\r
-      int anInteractionStyle = interactionStyle();\r
-      if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD &&\r
-           aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||\r
-         ( anInteractionStyle == SUIT_ViewModel::KEY_FREE &&\r
-         aButton == Qt::LeftButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {\r
-        myDrawRect = myEnableDrawMode;\r
-        if ( myDrawRect ) {\r
-          drawRect();\r
-          if ( !myCursorIsHand )        {   // we are going to sketch a rectangle\r
-            QCursor handCursor (Qt::PointingHandCursor);\r
-            myCursorIsHand = true;\r
-            myCursor = cursor();\r
-            myViewPort->setCursor( handCursor );\r
-          }\r
-        }\r
-        emit mouseMoving( this, theEvent );\r
-      }\r
-      else if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD &&\r
-                aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||\r
-                ( anInteractionStyle == SUIT_ViewModel::KEY_FREE &&\r
-                aButton == Qt::RightButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {\r
-        OCCViewer_ViewSketcher* sketcher = 0;\r
-        QList<OCCViewer_ViewSketcher*>::Iterator it;\r
-        for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )\r
-        {\r
-          OCCViewer_ViewSketcher* sk = (*it);\r
-          if( sk->isDefault() && sk->sketchButton() == aButton )\r
-            sketcher = sk;\r
-        }\r
-        if ( sketcher && myCurSketch == -1 )\r
-        {\r
-          activateSketching( sketcher->type() );\r
-          if ( mypSketcher )\r
-          {\r
-            myCurSketch = mypSketcher->sketchButton();\r
-\r
-            if ( l_mbPressEvent )\r
-            {\r
-              QApplication::sendEvent( getViewPort(), l_mbPressEvent );\r
-              delete l_mbPressEvent;\r
-              l_mbPressEvent = 0;\r
-            }\r
-            QApplication::sendEvent( getViewPort(), theEvent );\r
-          }\r
-        }\r
-      }\r
-      else\r
-        emit mouseMoving( this, theEvent );\r
-    }\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Handle mouse release event.\r
-  \param theEvent mouse event\r
-*/\r
-void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)\r
-{\r
-  switch ( myOperation ) {\r
-  case NOTHING:\r
-    {\r
-      int prevState = myCurSketch;\r
-      if(theEvent->button() == Qt::RightButton)\r
-      {\r
-        QList<OCCViewer_ViewSketcher*>::Iterator it;\r
-        for ( it = mySketchers.begin(); it != mySketchers.end() && myCurSketch != -1; ++it )\r
-        {\r
-          OCCViewer_ViewSketcher* sk = (*it);\r
-          if( ( sk->sketchButton() & theEvent->button() ) && sk->sketchButton() == myCurSketch )\r
-            myCurSketch = -1;\r
-        }\r
-      }\r
-\r
-      emit mouseReleased(this, theEvent);\r
-      if(theEvent->button() == Qt::RightButton && prevState == -1)\r
-      {\r
-        QContextMenuEvent aEvent( QContextMenuEvent::Mouse,\r
-                                  theEvent->pos(), theEvent->globalPos() );\r
-        emit contextMenuRequested( &aEvent );\r
-      }\r
-    }\r
-    break;\r
-  case ROTATE:\r
-    myViewPort->endRotation();\r
-    resetState();\r
-    break;\r
-\r
-  case PANVIEW:\r
-  case ZOOMVIEW:\r
-    resetState();\r
-    break;\r
-\r
-  case PANGLOBAL:\r
-    if ( theEvent->button() == Qt::LeftButton ) {\r
-      myViewPort->setCenter( theEvent->x(), theEvent->y() );\r
-      myViewPort->getView()->SetScale(myCurScale);\r
-      resetState();\r
-    }\r
-    break;\r
-\r
-  case WINDOWFIT:\r
-    if ( theEvent->button() == Qt::LeftButton ) {\r
-      myCurrX = theEvent->x();\r
-      myCurrY = theEvent->y();\r
-      drawRect();\r
-      QRect rect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);\r
-      if ( !rect.isEmpty() ) myViewPort->fitRect(rect);\r
-      endDrawRect();\r
-      resetState();\r
-    }\r
-    break;\r
-  }\r
-\r
-  // NOTE: viewer 3D detects a rectangle of selection using this event\r
-  // so we must emit it BEFORE resetting the selection rectangle\r
-\r
-  if ( theEvent->button() == Qt::LeftButton && myDrawRect ) {\r
-    drawRect();\r
-    endDrawRect();\r
-    resetState();\r
-    myViewPort->update();\r
-  }\r
-\r
-  if ( l_mbPressEvent )\r
-  {\r
-    delete l_mbPressEvent;\r
-    l_mbPressEvent = 0;\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Reset the viewport to its initial state\r
-  ( no transformations in process etc. )\r
-*/\r
-void OCCViewer_ViewWindow::resetState()\r
-{\r
-  myDrawRect = false;\r
-\r
-  if ( myRotationPointSelection )\r
-  {\r
-    QCursor handCursor (Qt::PointingHandCursor);\r
-    myViewPort->setCursor( handCursor );\r
-  }\r
-  else\r
-  {\r
-    if ( transformRequested() || myCursorIsHand )\r
-      myViewPort->setCursor( myCursor );\r
-    myCursorIsHand = false;\r
-  }\r
-\r
-  if ( transformRequested() )\r
-    emit vpTransformationFinished (myOperation);\r
-\r
-  setTransformInProcess( false );\r
-  setTransformRequested( NOTHING );\r
-}\r
-\r
-\r
-/*!\r
-  \brief Draw rubber band rectangle.\r
-*/\r
-void OCCViewer_ViewWindow::drawRect()\r
-{\r
-  if ( !myRectBand ) {\r
-    myRectBand = new QtxRectRubberBand( myViewPort );\r
-    //QPalette palette;\r
-    //palette.setColor(myRectBand->foregroundRole(), Qt::white);\r
-    //myRectBand->setPalette(palette);\r
-  }\r
-  //myRectBand->hide();\r
-  \r
-  myRectBand->setUpdatesEnabled ( false );\r
-  QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);\r
-  myRectBand->initGeometry( aRect );\r
-\r
-  if ( !myRectBand->isVisible() )\r
-    myRectBand->show();\r
-\r
-  myRectBand->setUpdatesEnabled ( true );\r
-  //myRectBand->repaint();\r
-\r
-  //myRectBand->setVisible( aRect.isValid() );\r
-  //if ( myRectBand->isVisible() )\r
-  //  myRectBand->repaint();\r
-  //else\r
-  //  myRectBand->show();\r
-  //myRectBand->repaint();\r
-}\r
-\r
-/*!\r
-  \brief Clear rubber band rectangle on the end on the dragging operation.\r
-*/\r
-void OCCViewer_ViewWindow::endDrawRect()\r
-{\r
-  //delete myRectBand;\r
-  //myRectBand = 0;\r
-  if ( myRectBand )\r
-    {\r
-      myRectBand->clearGeometry();\r
-      myRectBand->hide();\r
-    }\r
-}\r
-\r
-/*!\r
-  \brief Create actions.\r
-*/\r
-void OCCViewer_ViewWindow::createActions()\r
-{\r
-  if( !toolMgr()->isEmpty() )\r
-    return;\r
-  \r
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();\r
-\r
-  QtxAction* aAction;\r
-\r
-  // Dump view\r
-  aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_DUMP" ) ),\r
-                           tr( "MNU_DUMP_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_DUMP_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onDumpView()));\r
-  toolMgr()->registerAction( aAction, DumpId );\r
-\r
-  // FitAll\r
-  aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITALL" ) ),\r
-                           tr( "MNU_FITALL" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_FITALL"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onFitAll()));\r
-  toolMgr()->registerAction( aAction, FitAllId );\r
-\r
-  // FitRect\r
-  aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITAREA" ) ),\r
-                           tr( "MNU_FITRECT" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_FITRECT"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));\r
-  toolMgr()->registerAction( aAction, FitRectId );\r
-  \r
-  // Zoom\r
-  aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ZOOM" ) ),\r
-                           tr( "MNU_ZOOM_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activateZoom()));\r
-  toolMgr()->registerAction( aAction, ZoomId );\r
-\r
-  // Panning\r
-  aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ),\r
-                           tr( "MNU_PAN_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_PAN_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning()));\r
-  toolMgr()->registerAction( aAction, PanId );\r
-\r
-  // Global Panning\r
-  aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_GLOBALPAN" ) ),\r
-                           tr( "MNU_GLOBALPAN_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));\r
-  toolMgr()->registerAction( aAction, GlobalPanId );\r
-\r
-  // Rotation Point\r
-  mySetRotationPointAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATION_POINT" ) ),\r
-                           tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);\r
-  mySetRotationPointAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));\r
-  mySetRotationPointAction->setCheckable( true );\r
-  connect(mySetRotationPointAction, SIGNAL(toggled( bool )), this, SLOT(onSetRotationPoint( bool )));\r
-  toolMgr()->registerAction( mySetRotationPointAction, ChangeRotationPointId );\r
-\r
-  // Rotation\r
-  aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATE" ) ),\r
-                           tr( "MNU_ROTATE_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activateRotation()));\r
-  toolMgr()->registerAction( aAction, RotationId );\r
-\r
-  // Projections\r
-  aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FRONT" ) ),\r
-                           tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");\r
-  aAction->setStatusTip(tr("DSC_FRONT_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onFrontView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, FrontId );\r
-\r
-  aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BACK" ) ),\r
-                           tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");\r
-  aAction->setStatusTip(tr("DSC_BACK_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onBackView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, BackId );\r
-\r
-  aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TOP" ) ),\r
-                           tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");\r
-  aAction->setStatusTip(tr("DSC_TOP_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onTopView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, TopId );\r
-\r
-  aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BOTTOM" ) ),\r
-                           tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");\r
-  aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onBottomView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, BottomId );\r
-  \r
-  aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_LEFT" ) ),\r
-                           tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");\r
-  aAction->setStatusTip(tr("DSC_LEFT_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onLeftView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, LeftId );\r
-\r
-  aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RIGHT" ) ),\r
-                           tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");\r
-  aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onRightView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, RightId );\r
-\r
-  // rotate anticlockwise\r
-  aAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ANTICLOCKWISE" ) ),\r
-                           tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");\r
-  aAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, AntiClockWiseId );\r
-\r
-  // rotate clockwise\r
-  aAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_CLOCKWISE" ) ),\r
-                           tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");\r
-  aAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, ClockWiseId );\r
-\r
-  // Reset\r
-  aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RESET" ) ),\r
-                           tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");\r
-  aAction->setStatusTip(tr("DSC_RESET_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onResetView()));\r
-  this->addAction(aAction);\r
-  toolMgr()->registerAction( aAction, ResetId );\r
-\r
-  // Clone\r
-  aAction = new QtxAction(tr("MNU_CLONE_VIEW"),\r
-                          aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_CLONE_VIEW")),\r
-                          tr("MNU_CLONE_VIEW"), 0, this);\r
-  aAction->setStatusTip(tr("DSC_CLONE_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onCloneView()));\r
-  toolMgr()->registerAction( aAction, CloneId );\r
-\r
-  aAction = new QtxAction (tr ("MNU_CLIPPING"), aResMgr->loadPixmap ("OCCViewer", tr ("ICON_OCCVIEWER_CLIPPING")),\r
-                                      tr ("MNU_CLIPPING"), 0, this);\r
-  aAction->setStatusTip (tr ("DSC_CLIPPING"));\r
-  aAction->setCheckable (true);\r
-  connect (aAction, SIGNAL (toggled (bool)), this, SLOT (onClipping (bool)));\r
-  toolMgr()->registerAction (aAction, ClippingId);\r
-\r
-  aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ),\r
-                           tr( "MNU_SHOOT_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_SHOOT_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onMemorizeView()));\r
-  toolMgr()->registerAction( aAction, MemId );\r
-\r
-  aAction = new QtxAction(tr("MNU_PRESETS_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESETS_VIEW" ) ),\r
-                           tr( "MNU_PRESETS_VIEW" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_PRESETS_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onRestoreView()));\r
-  toolMgr()->registerAction( aAction, RestoreId );\r
-\r
-  if (myModel->trihedronActivated()) {\r
-    aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TRIHEDRON" ) ),\r
-                             tr( "MNU_SHOW_TRIHEDRE" ), 0, this);\r
-    aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRE"));\r
-    connect(aAction, SIGNAL(triggered()), this, SLOT(onTrihedronShow()));\r
-    toolMgr()->registerAction( aAction, TrihedronShowId );\r
-  }\r
-\r
-  // Scale\r
-  aAction = new QtxAction(tr("MNU_SCALING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SCALING" ) ),\r
-                           tr( "MNU_SCALING" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_SCALING"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale()));\r
-  toolMgr()->registerAction( aAction, AxialScaleId );\r
-\r
-  // Enable/disable preselection\r
-  aAction = new QtxAction(tr("MNU_ENABLE_PRESELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESELECTION" ) ),\r
-                          tr( "MNU_ENABLE_PRESELECTION" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_ENABLE_PRESELECTION"));\r
-  aAction->setCheckable(true);\r
-  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchPreselection(bool)));\r
-  toolMgr()->registerAction( aAction, SwitchPreselectionId );\r
-\r
-  // Enable/disable selection\r
-  aAction = new QtxAction(tr("MNU_ENABLE_SELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SELECTION" ) ),\r
-                          tr( "MNU_ENABLE_SELECTION" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_ENABLE_SELECTION"));\r
-  aAction->setCheckable(true);\r
-  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchSelection(bool)));\r
-  toolMgr()->registerAction( aAction, SwitchSelectionId );\r
-\r
-  // Graduated axes \r
-  aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ),\r
-                           tr( "MNU_GRADUATED_AXES" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_GRADUATED_AXES"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onGraduatedAxes()));\r
-  toolMgr()->registerAction( aAction, GraduatedAxesId );\r
-\r
-  // Active only ambient light or not\r
-  aAction = new QtxAction(tr("MNU_AMBIENT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_AMBIENT" ) ),\r
-                           tr( "MNU_AMBIENT" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_AMBIENT"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onAmbientToogle()));\r
-  toolMgr()->registerAction( aAction, AmbientId );\r
-\r
-  // Switch between interaction styles\r
-  aAction = new QtxAction(tr("MNU_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_STYLE_SWITCH" ) ),\r
-                          tr( "MNU_STYLE_SWITCH" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_STYLE_SWITCH"));\r
-  aAction->setCheckable(true);\r
-  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));\r
-  toolMgr()->registerAction( aAction, SwitchInteractionStyleId );\r
-\r
-  // Switch between zooming styles\r
-  aAction = new QtxAction(tr("MNU_ZOOMING_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_ZOOMING_STYLE_SWITCH" ) ),\r
-                          tr( "MNU_ZOOMING_STYLE_SWITCH" ), 0, this);\r
-  aAction->setStatusTip(tr("DSC_ZOOMING_STYLE_SWITCH"));\r
-  aAction->setCheckable(true);\r
-  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));\r
-  toolMgr()->registerAction( aAction, SwitchZoomingStyleId );\r
-\r
-  // Maximized view\r
-  aAction = new QtxAction(tr("MNU_MINIMIZE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ),\r
-                          tr( "MNU_MINIMIZE_VIEW" ), 0, this );\r
-  aAction->setStatusTip(tr("DSC_MINIMIZE_VIEW"));\r
-  connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView()));\r
-  toolMgr()->registerAction( aAction, MaximizedId );\r
-\r
-  // Return to 3d view\r
-  if (my2dMode!=No2dMode){\r
-    aAction = new QtxAction(tr("MNU_RETURN_3D_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_RETURN_3D_VIEW" ) ),\r
-                            tr( "MNU_RETURN_3D_VIEW" ), 0, this );\r
-    aAction->setStatusTip(tr("DSC_RETURN_3D_VIEW"));\r
-    connect(aAction, SIGNAL(triggered()), this, SLOT(returnTo3dView()));\r
-    toolMgr()->registerAction( aAction, ReturnTo3dViewId );\r
-  }\r
-\r
-  // Synchronize View \r
-  toolMgr()->registerAction( synchronizeAction(), SynchronizeId );\r
-}\r
-\r
-/*!\r
-  \brief Create toolbar.\r
-*/\r
-void OCCViewer_ViewWindow::createToolBar()\r
-{\r
-  QString aToolbarName;\r
-  switch (my2dMode) {\r
-  case XYPlane:\r
-    aToolbarName = tr( "LBL_XYTOOLBAR_LABEL" );\r
-    break;\r
-  case XZPlane:\r
-    aToolbarName = tr( "LBL_XZTOOLBAR_LABEL" );\r
-    break;\r
-  case YZPlane:\r
-    aToolbarName = tr( "LBL_YZTOOLBAR_LABEL" );\r
-    break;\r
-  default:\r
-    aToolbarName = tr( "LBL_3DTOOLBAR_LABEL" );\r
-  }\r
-  \r
-  int tid = toolMgr()->createToolBar( aToolbarName, false );\r
-  if ( my2dMode != No2dMode ){\r
-    toolMgr()->append( ReturnTo3dViewId, tid );\r
-    toolMgr()->append( toolMgr()->separator(), tid );\r
-  }\r
-  toolMgr()->append( DumpId, tid );\r
-  toolMgr()->append( SwitchInteractionStyleId, tid );\r
-#if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version\r
-  toolMgr()->append( SwitchZoomingStyleId, tid );\r
-#endif\r
-  toolMgr()->append( SwitchPreselectionId, tid );\r
-  toolMgr()->append( SwitchSelectionId, tid );\r
-  if( myModel->trihedronActivated() )\r
-    toolMgr()->append( TrihedronShowId, tid );\r
-\r
-  QtxMultiAction* aScaleAction = new QtxMultiAction( this );\r
-  aScaleAction->insertAction( toolMgr()->action( FitAllId ) );\r
-  aScaleAction->insertAction( toolMgr()->action( FitRectId ) );\r
-  aScaleAction->insertAction( toolMgr()->action( ZoomId ) );\r
-  toolMgr()->append( aScaleAction, tid );\r
-\r
-  QtxMultiAction* aPanningAction = new QtxMultiAction( this );\r
-  aPanningAction->insertAction( toolMgr()->action( PanId ) );\r
-  aPanningAction->insertAction( toolMgr()->action( GlobalPanId ) );\r
-  toolMgr()->append( aPanningAction, tid );\r
-\r
-  if (my2dMode == No2dMode) {\r
-    toolMgr()->append( ChangeRotationPointId, tid );\r
-    toolMgr()->append( RotationId, tid );\r
-\r
-    QtxMultiAction* aViewsAction = new QtxMultiAction( this );\r
-    aViewsAction->insertAction( toolMgr()->action( FrontId ) );\r
-    aViewsAction->insertAction( toolMgr()->action( BackId ) );\r
-    aViewsAction->insertAction( toolMgr()->action( TopId ) );\r
-    aViewsAction->insertAction( toolMgr()->action( BottomId ) );\r
-    aViewsAction->insertAction( toolMgr()->action( LeftId ) );\r
-    aViewsAction->insertAction( toolMgr()->action( RightId ) );\r
-    toolMgr()->append( aViewsAction, tid );\r
-\r
-    toolMgr()->append( AntiClockWiseId, tid );\r
-    toolMgr()->append( ClockWiseId, tid );\r
-\r
-    toolMgr()->append( ResetId, tid );\r
-  }\r
-\r
-  QtxMultiAction* aMemAction = new QtxMultiAction( this );\r
-  aMemAction->insertAction( toolMgr()->action( MemId ) );\r
-  aMemAction->insertAction( toolMgr()->action( RestoreId ) );\r
-  toolMgr()->append( aMemAction, tid );\r
-\r
-  toolMgr()->append( toolMgr()->separator(), tid );\r
-  toolMgr()->append( CloneId, tid );\r
-  \r
-  toolMgr()->append( toolMgr()->separator(), tid );\r
-  toolMgr()->append( ClippingId, tid );\r
-  toolMgr()->append( AxialScaleId, tid );\r
-#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version\r
-  toolMgr()->append( GraduatedAxesId, tid );\r
-#endif\r
-  toolMgr()->append( AmbientId, tid );\r
-\r
-  toolMgr()->append( MaximizedId, tid );\r
-  toolMgr()->append( SynchronizeId, tid );\r
-}\r
-\r
-/*!\r
-  \brief Perform 'fit all' operation.\r
-*/\r
-void OCCViewer_ViewWindow::onViewFitAll()\r
-{\r
-  myViewPort->fitAll();\r
-}\r
-\r
-/*!\r
-  \brief Perform "front view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onFrontView()\r
-{\r
-  emit vpTransformationStarted ( FRONTVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xpos);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( FRONTVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "back view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onBackView()\r
-{\r
-  emit vpTransformationStarted ( BACKVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xneg);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( BACKVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "top view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onTopView()\r
-{\r
-  emit vpTransformationStarted ( TOPVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zpos);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( TOPVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "bottom view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onBottomView()\r
-{\r
-  emit vpTransformationStarted ( BOTTOMVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zneg);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( BOTTOMVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "left view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onLeftView()\r
-{\r
-  emit vpTransformationStarted ( LEFTVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Yneg);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( LEFTVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "right view" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onRightView()\r
-{\r
-  emit vpTransformationStarted ( RIGHTVIEW );\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Ypos);\r
-  onViewFitAll();\r
-  emit vpTransformationFinished ( RIGHTVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Rotate view 90 degrees clockwise\r
-*/\r
-void OCCViewer_ViewWindow::onClockWiseView()\r
-{\r
-  emit vpTransformationStarted ( CLOCKWISEVIEW );\r
-  myViewPort->rotateXY( 90. );\r
-  emit vpTransformationFinished ( CLOCKWISEVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Rotate view 90 degrees conterclockwise\r
-*/\r
-void OCCViewer_ViewWindow::onAntiClockWiseView()\r
-{\r
-  emit vpTransformationStarted ( ANTICLOCKWISEVIEW );\r
-  myViewPort->rotateXY( -90. );\r
-  emit vpTransformationFinished ( ANTICLOCKWISEVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "reset view" transformation.\r
-\r
-  Sets default orientation of the viewport camera.\r
-*/\r
-void OCCViewer_ViewWindow::onResetView()\r
-{\r
-  emit vpTransformationStarted( RESETVIEW );\r
-  bool upd = myViewPort->getView()->SetImmediateUpdate( false );\r
-  myViewPort->getView()->Reset( false );\r
-  myViewPort->fitAll( false, true, false );\r
-  myViewPort->getView()->SetImmediateUpdate( upd );\r
-  myViewPort->getView()->Update();\r
-  emit vpTransformationFinished( RESETVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Perform "fit all" transformation.\r
-*/\r
-void OCCViewer_ViewWindow::onFitAll()\r
-{\r
-  emit vpTransformationStarted( FITALLVIEW );\r
-  myViewPort->fitAll();\r
-  emit vpTransformationFinished( FITALLVIEW );\r
-}\r
-\r
-/*!\r
-  \brief Called if 'change rotation point' operation is activated.\r
-  \param on action state\r
-*/\r
-void OCCViewer_ViewWindow::onSetRotationPoint( bool on )\r
-{\r
-  if (on)\r
-  {\r
-    if (!mySetRotationPointDlg)\r
-    {\r
-      mySetRotationPointDlg = new OCCViewer_SetRotationPointDlg (this);\r
-      mySetRotationPointDlg->SetAction(mySetRotationPointAction);\r
-    }\r
-\r
-    if (!mySetRotationPointDlg->isVisible())\r
-    {\r
-      //if (mySetRotationPointDlg->IsFirstShown())\r
-      if (myCurrPointType == GRAVITY)\r
-      {\r
-        Standard_Real Xcenter, Ycenter, Zcenter;\r
-        if (computeGravityCenter(Xcenter, Ycenter, Zcenter))\r
-          mySetRotationPointDlg->setCoords(Xcenter, Ycenter, Zcenter);\r
-      }\r
-      mySetRotationPointDlg->show();\r
-    }\r
-  }\r
-  else\r
-  {\r
-    if (mySetRotationPointDlg->isVisible())\r
-      mySetRotationPointDlg->hide();\r
-  }\r
-}\r
-\r
-/*!\r
-   \brief Create one more window with same content.\r
-*/\r
-void OCCViewer_ViewWindow::onCloneView()\r
-{\r
-  SUIT_ViewWindow* vw = myManager->createViewWindow();\r
-  //vw->show();\r
-  emit viewCloned( vw );\r
-}\r
-\r
-/*!\r
-  Creates one more window with same content\r
-*/\r
-void OCCViewer_ViewWindow::onAxialScale()\r
-{\r
-  if ( !myScalingDlg )\r
-    myScalingDlg = new OCCViewer_AxialScaleDlg( this );\r
-  \r
-  if ( !myScalingDlg->isVisible() )\r
-  {\r
-    myScalingDlg->Update();\r
-    myScalingDlg->show();\r
-  }\r
-}\r
-\r
-/*!\r
-  Shows Graduated Axes dialog\r
-*/\r
-void OCCViewer_ViewWindow::onGraduatedAxes()\r
-{\r
-  myCubeAxesDlg->Update();\r
-  myCubeAxesDlg->show();\r
-}\r
-\r
-void OCCViewer_ViewWindow::onAmbientToogle()\r
-{\r
-  Handle(V3d_Viewer) viewer = myViewPort->getViewer();\r
-  viewer->InitDefinedLights();\r
-  while(viewer->MoreDefinedLights())\r
-    {\r
-      Handle(V3d_Light) light = viewer->DefinedLight();\r
-      if(light->Type() != V3d_AMBIENT)\r
-        {\r
-          Handle(V3d_View) aView3d = myViewPort->getView();\r
-          if( aView3d->IsActiveLight(light) ) viewer->SetLightOff(light);\r
-          else viewer->SetLightOn(light);\r
-        }\r
-      viewer->NextDefinedLights();\r
-    }\r
-  viewer->Update();\r
-}\r
-\r
-/*!\r
-  \brief Store view parameters.\r
-*/\r
-void OCCViewer_ViewWindow::onMemorizeView()\r
-{\r
-  appendViewAspect( getViewParams() );\r
-}\r
-\r
-/*!\r
-  \brief Restore view parameters.\r
-*/\r
-void OCCViewer_ViewWindow::onRestoreView()\r
-{\r
-  OCCViewer_CreateRestoreViewDlg* aDlg = new OCCViewer_CreateRestoreViewDlg( centralWidget(), this );\r
-  connect( aDlg, SIGNAL( dlgOk() ), this, SLOT( setRestoreFlag() ) );\r
-  aDlg->exec();\r
-  updateViewAspects( aDlg->parameters() );\r
-  if( myRestoreFlag && aDlg->parameters().count() )\r
-    performRestoring( aDlg->currentItem() );\r
-}\r
-\r
-/*!\r
-  \brief Restore view parameters.\r
-  \param anItem view parameters\r
-*/\r
-void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool baseParamsOnly )\r
-{\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-\r
-  Standard_Boolean prev = aView3d->SetImmediateUpdate( Standard_False );\r
-  aView3d->SetScale( anItem.scale );\r
-  aView3d->SetTwist( anItem.twist );\r
-  aView3d->SetAt( anItem.atX, anItem.atY, anItem.atZ );\r
-  aView3d->SetImmediateUpdate( prev );\r
-  aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );\r
-  aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );\r
-  aView3d->SetAxialScale( anItem.scaleX, anItem.scaleY, anItem.scaleZ );\r
-\r
-#if OCC_VERSION_LARGE > 0x06070100\r
-  if ( anItem.centerX != 0.0 || anItem.centerY != 0.0 )\r
-  {\r
-    double anUpX = 0.0, anUpY = 0.0, anUpZ = 0.0;\r
-\r
-    // "eye" and "at" require conversion to represent center panning\r
-    // up direction is only available after setting angle of twist and\r
-    // other view parameters\r
-    aView3d->Up( anUpX, anUpY, anUpZ );\r
-\r
-    gp_Dir aProj( -anItem.projX, -anItem.projY, -anItem.projZ );\r
-    gp_Dir anUp( anUpX, anUpY, anUpZ );\r
-    gp_Pnt anAt( anItem.atX, anItem.atY, anItem.atZ );\r
-    gp_Pnt anEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );\r
-    gp_Dir aSide = aProj ^ anUp;\r
-\r
-    anAt.Translate( gp_Vec( aSide ) * anItem.centerX );\r
-    anAt.Translate( gp_Vec( anUp  ) * anItem.centerY );\r
-\r
-    aView3d->SetAt( anAt.X(), anAt.Y(), anAt.Z() );\r
-    aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );\r
-  }\r
-#else\r
-  aView3d->SetCenter( anItem.centerX, anItem.centerY );\r
-#endif\r
-\r
-  if ( !baseParamsOnly ) {\r
-\r
-    myModel->setTrihedronShown( anItem.isVisible );\r
-    myModel->setTrihedronSize( anItem.size );\r
-        \r
-#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version\r
-    // graduated trihedron\r
-    bool anIsVisible = anItem.gtIsVisible;\r
-    OCCViewer_AxisWidget::AxisData anAxisData[3];\r
-    anAxisData[0].DrawName = anItem.gtDrawNameX;\r
-    anAxisData[1].DrawName = anItem.gtDrawNameZ;\r
-    anAxisData[2].DrawName = anItem.gtDrawNameZ;\r
-    anAxisData[0].Name = anItem.gtNameX;\r
-    anAxisData[1].Name = anItem.gtNameZ;\r
-    anAxisData[2].Name = anItem.gtNameZ;\r
-    anAxisData[0].NameColor = QColor( anItem.gtNameColorRX,\r
-              anItem.gtNameColorGX,\r
-              anItem.gtNameColorBX );\r
-    anAxisData[1].NameColor = QColor( anItem.gtNameColorRY,\r
-              anItem.gtNameColorGY,\r
-              anItem.gtNameColorBY );\r
-    anAxisData[2].NameColor = QColor( anItem.gtNameColorRZ,\r
-              anItem.gtNameColorGZ,\r
-              anItem.gtNameColorBZ );\r
-    anAxisData[0].DrawValues = anItem.gtDrawValuesX;\r
-    anAxisData[1].DrawValues = anItem.gtDrawValuesY;\r
-    anAxisData[2].DrawValues = anItem.gtDrawValuesZ;\r
-    anAxisData[0].NbValues = anItem.gtNbValuesX;\r
-    anAxisData[1].NbValues = anItem.gtNbValuesY;\r
-    anAxisData[2].NbValues = anItem.gtNbValuesZ;\r
-    anAxisData[0].Offset = anItem.gtOffsetX;\r
-    anAxisData[1].Offset = anItem.gtOffsetY;\r
-    anAxisData[2].Offset = anItem.gtOffsetZ;\r
-    anAxisData[0].Color = QColor( anItem.gtColorRX,\r
-          anItem.gtColorGX,\r
-          anItem.gtColorBX );\r
-    anAxisData[1].Color = QColor( anItem.gtColorRY,\r
-          anItem.gtColorGY,\r
-          anItem.gtColorBY );\r
-    anAxisData[2].Color = QColor( anItem.gtColorRZ,\r
-          anItem.gtColorGZ,\r
-          anItem.gtColorBZ );\r
-    anAxisData[0].DrawTickmarks = anItem.gtDrawTickmarksX;\r
-    anAxisData[1].DrawTickmarks = anItem.gtDrawTickmarksY;\r
-    anAxisData[2].DrawTickmarks = anItem.gtDrawTickmarksZ;\r
-    anAxisData[0].TickmarkLength = anItem.gtTickmarkLengthX;\r
-    anAxisData[1].TickmarkLength = anItem.gtTickmarkLengthY;\r
-    anAxisData[2].TickmarkLength = anItem.gtTickmarkLengthZ;\r
-\r
-    myCubeAxesDlg->SetData( anIsVisible, anAxisData );\r
-    myCubeAxesDlg->ApplyData( aView3d );\r
-#endif\r
-\r
-  } // if ( !baseParamsOnly )\r
-\r
-  myRestoreFlag = 0;\r
-}\r
-\r
-/*!\r
-  \brief Set restore flag.\r
-*/\r
-void OCCViewer_ViewWindow::setRestoreFlag()\r
-{\r
-  myRestoreFlag = 1;\r
-}\r
-\r
-/*!\r
-  \brief Called when action "show/hide trihedron" is activated.\r
-*/\r
-void OCCViewer_ViewWindow::onTrihedronShow()\r
-{\r
-  myModel->toggleTrihedron();\r
-}\r
-\r
-/*!\r
-  \brief Toggles preselection (highlighting) on/off\r
-*/\r
-void OCCViewer_ViewWindow::onSwitchPreselection( bool on )\r
-{\r
-  myPreselectionEnabled = on;\r
-  myModel->setSelectionOptions( isPreselectionEnabled(), myModel->isSelectionEnabled() );\r
-\r
-  // unhighlight all highlighted objects\r
-  /*if ( !on ) {\r
-    myModel->unHighlightAll( true, false );\r
-  }*/\r
-\r
-  // update action state if method is called outside\r
-  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );\r
-  if ( a && a->isChecked() != on ) {\r
-    a->setChecked( on );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Toggles selection on/off\r
-*/\r
-void OCCViewer_ViewWindow::onSwitchSelection( bool on )\r
-{\r
-  mySelectionEnabled = on;\r
-  myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() );\r
-  \r
-  // update action state if method is called outside\r
-\r
-  // preselection\r
-  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );\r
-  if ( a ) {\r
-    a->setEnabled( on );\r
-  }\r
-\r
-  // selection\r
-  a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchSelectionId ) );\r
-  if ( a && a->isChecked() != on ) {\r
-    a->setChecked( on );\r
-  }\r
-}\r
-\r
-/*!\r
-  \brief Switches "keyboard free" interaction style on/off\r
-*/\r
-void OCCViewer_ViewWindow::onSwitchInteractionStyle( bool on )\r
-{\r
-  myInteractionStyle = on ? (int)SUIT_ViewModel::KEY_FREE : (int)SUIT_ViewModel::STANDARD;\r
-\r
-  // update action state if method is called outside\r
-  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchInteractionStyleId ) );\r
-  if ( a->isChecked() != on )\r
-    a->setChecked( on );\r
-}\r
-\r
-/*!\r
-  \brief Toogles advanced zooming style (relatively to the cursor position) on/off\r
-*/\r
-void OCCViewer_ViewWindow::onSwitchZoomingStyle( bool on )\r
-{\r
-  myViewPort->setAdvancedZoomingEnabled( on );\r
-\r
-  // update action state if method is called outside\r
-  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );\r
-  if ( a->isChecked() != on )\r
-    a->setChecked( on );\r
-}\r
-\r
-/*!\r
-  \brief Get current interaction style\r
-  \return interaction style\r
-*/\r
-int OCCViewer_ViewWindow::interactionStyle() const\r
-{\r
-  return myInteractionStyle;\r
-}\r
-\r
-/*!\r
-  \brief Set current interaction style\r
-  \param theStyle interaction style\r
-*/\r
-void OCCViewer_ViewWindow::setInteractionStyle( const int theStyle )\r
-{\r
-  onSwitchInteractionStyle( theStyle == (int)SUIT_ViewModel::KEY_FREE );\r
-}\r
-\r
-/*!\r
-  \brief Get current zooming style\r
-  \return zooming style\r
-*/\r
-int OCCViewer_ViewWindow::zoomingStyle() const\r
-{\r
-  return myViewPort->isAdvancedZoomingEnabled() ? 1 : 0;\r
-}\r
-\r
-/*!\r
-  \brief Set current zooming style\r
-  \param theStyle zooming style\r
-*/\r
-void OCCViewer_ViewWindow::setZoomingStyle( const int theStyle )\r
-{\r
-  onSwitchZoomingStyle( theStyle == 1 );\r
-}\r
-\r
-/*!\r
-  \brief Dump view window contents to the pixmap.\r
-  \return pixmap containing all scene rendered in the window\r
-*/\r
-QImage OCCViewer_ViewWindow::dumpView()\r
-{\r
-  Handle(V3d_View) view = myViewPort->getView();\r
-  if ( view.IsNull() )\r
-    return QImage();\r
-  \r
-  int aWidth = myViewPort->width();\r
-  int aHeight = myViewPort->height();\r
-  QApplication::syncX();\r
-  view->Redraw(); // In order to reactivate GL context\r
-  //view->Update();\r
-\r
-  OpenGLUtils_FrameBuffer aFrameBuffer;\r
-  if( aFrameBuffer.init( aWidth, aHeight ) )\r
-  {\r
-    QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );\r
-   \r
-    glPushAttrib( GL_VIEWPORT_BIT );\r
-    glViewport( 0, 0, aWidth, aHeight );\r
-    aFrameBuffer.bind();\r
-\r
-    // draw scene\r
-    view->Redraw();\r
-\r
-    aFrameBuffer.unbind();\r
-    glPopAttrib();\r
-\r
-    aFrameBuffer.bind();\r
-    glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );\r
-    aFrameBuffer.unbind();\r
-\r
-    anImage = anImage.rgbSwapped();\r
-    anImage = anImage.mirrored();\r
-    return anImage;\r
-  }\r
-  // if frame buffers are unsupported, use old functionality\r
-  //view->Redraw();\r
-\r
-  unsigned char* data = new unsigned char[ aWidth*aHeight*4 ];\r
-\r
-  QPoint p = myViewPort->mapFromParent(myViewPort->geometry().topLeft());\r
-\r
-  glReadPixels( p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE,\r
-                data);\r
-\r
-  QImage anImage( data, aWidth, aHeight, QImage::Format_ARGB32 );\r
-  anImage = anImage.mirrored();\r
-  anImage = anImage.rgbSwapped();\r
-  return anImage;\r
-}\r
-\r
-bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, \r
-                                             const QString& fileName, \r
-                                             const QString& format )\r
-{\r
-  if ( format != "PS" && format != "EPS")\r
-    return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );\r
-\r
-  Handle(Visual3d_View) a3dView = myViewPort->getView()->View();\r
-\r
-  if (format == "PS")\r
-    a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_PostScript);\r
-  else if (format == "EPS")\r
-    a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_EnhPostScript);\r
-\r
-  return true;\r
-}\r
-\r
-\r
-QString OCCViewer_ViewWindow::filter() const\r
-{\r
-  return tr( "OCC_IMAGE_FILES" );\r
-}\r
-\r
-\r
-/*!\r
-  \brief Set parameters of the cutting plane\r
-  \param on if \c true, cutting plane is enabled\r
-  \param x X position of plane point\r
-  \param y Y position of plane point\r
-  \param z Z position of plane point\r
-  \param dx X coordinate of plane normal\r
-  \param dy Y coordinate of plane normal\r
-  \param dz Z coordinate of plane normal\r
-*/\r
-void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x,  const double y,  const double z,\r
-                                            const double dx, const double dy, const double dz )\r
-{\r
-  Handle(V3d_View) view = myViewPort->getView();\r
-  if ( view.IsNull() )\r
-    return;\r
-\r
-  if ( on ) {\r
-    Handle(V3d_Viewer) viewer = myViewPort->getViewer();\r
-\r
-    // try to use already existing plane or create a new one\r
-    Handle(V3d_Plane) clipPlane;\r
-\r
-    // calculate new a,b,c,d values for the plane\r
-    gp_Pln pln (gp_Pnt(x, y, z), gp_Dir(dx, dy, dz));\r
-    double a, b, c, d;\r
-    pln.Coefficients(a, b, c, d);\r
-    \r
-    Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();\r
-    Handle(Graphic3d_ClipPlane) aClipPlane;\r
-    if(aPlanes.Size() > 0 ) {\r
-      Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);\r
-      aClipPlane = anIter.Value();\r
-      aClipPlane->SetEquation(pln);\r
-      aClipPlane->SetOn(Standard_True);\r
-    } else {\r
-      aClipPlane = new Graphic3d_ClipPlane(pln);\r
-      view->AddClipPlane(aClipPlane);\r
-      aClipPlane->SetOn(Standard_True);\r
-    }\r
-  }\r
-  else {\r
-    Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();\r
-    Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);\r
-    for( ;anIter.More();anIter.Next() ){\r
-      Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();\r
-      aClipPlane->SetOn(Standard_False);\r
-    }\r
-  }\r
-\r
-  view->Update();\r
-  view->Redraw();\r
-}\r
-\r
-void OCCViewer_ViewWindow::setCuttingPlane( bool on, const gp_Pln pln )\r
-{\r
-  gp_Dir aDir = pln.Axis().Direction();\r
-  gp_Pnt aPnt = pln.Location();\r
-  setCuttingPlane(on, aPnt.X(), aPnt.Y(), aPnt.Z(), aDir.X(), aDir.Y(), aDir.Z());\r
-}\r
-\r
-\r
-/*!\r
-  \brief Check if any cutting plane is enabled\r
-  \return \c true if at least one cutting plane is enabled\r
-*/\r
-bool OCCViewer_ViewWindow::isCuttingPlane()\r
-{\r
-  Handle(V3d_View) view = myViewPort->getView();\r
-  bool res = false;\r
-  Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();\r
-  Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);\r
-  for( ;anIter.More();anIter.Next() ) {\r
-    Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();\r
-    if(aClipPlane->IsOn()) {\r
-      res = true;\r
-      break;\r
-    }\r
-  }\r
-  return res;\r
-}\r
-\r
-/*!\r
-  \brief Get the visual parameters of the view window.\r
-  \return visual parameters of view window\r
-*/\r
-viewAspect OCCViewer_ViewWindow::getViewParams() const\r
-{\r
-  double projX, projY, projZ, twist;\r
-  double atX, atY, atZ, eyeX, eyeY, eyeZ;\r
-  double aScaleX, aScaleY, aScaleZ;\r
-\r
-  Handle(V3d_View) aView3d = myViewPort->getView();\r
-\r
-  aView3d->Proj( projX, projY, projZ );\r
-  aView3d->At( atX, atY, atZ );\r
-  aView3d->Eye( eyeX, eyeY, eyeZ );\r
-  twist = aView3d->Twist();\r
-\r
-  aView3d->AxialScale(aScaleX,aScaleY,aScaleZ);\r
-\r
-  bool isShown = myModel->isTrihedronVisible();\r
-  double size = myModel->trihedronSize();\r
-\r
-  QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" );\r
-\r
-  viewAspect params;\r
-  params.scale    = aView3d->Scale();\r
-  params.projX    = projX;\r
-  params.projY    = projY;\r
-  params.projZ    = projZ;\r
-  params.twist    = twist;\r
-  params.atX      = atX;\r
-  params.atY      = atY;\r
-  params.atZ      = atZ;\r
-  params.eyeX     = eyeX;\r
-  params.eyeY     = eyeY;\r
-  params.eyeZ     = eyeZ;\r
-  params.scaleX   = aScaleX;\r
-  params.scaleY   = aScaleY;\r
-  params.scaleZ   = aScaleZ;\r
-  params.name     = aName;\r
-  params.isVisible= isShown;\r
-  params.size     = size;\r
-\r
-#if OCC_VERSION_LARGE <= 0x06070100 // the property is deprecated after OCCT 6.7.1\r
-  aView3d->Center( params.centerX, params.centerY );\r
-#endif\r
-\r
-#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version\r
-  // graduated trihedron\r
-  bool anIsVisible = false;\r
-  OCCViewer_AxisWidget::AxisData anAxisData[3];\r
-  myCubeAxesDlg->GetData( anIsVisible, anAxisData );\r
-\r
-  params.gtIsVisible = anIsVisible;\r
-  params.gtDrawNameX = anAxisData[0].DrawName;\r
-  params.gtDrawNameY = anAxisData[1].DrawName;\r
-  params.gtDrawNameZ = anAxisData[2].DrawName;\r
-  params.gtNameX = anAxisData[0].Name;\r
-  params.gtNameY = anAxisData[1].Name;\r
-  params.gtNameZ = anAxisData[2].Name;\r
-  params.gtNameColorRX = anAxisData[0].NameColor.red();\r
-  params.gtNameColorGX = anAxisData[0].NameColor.green();\r
-  params.gtNameColorBX = anAxisData[0].NameColor.blue();\r
-  params.gtNameColorRY = anAxisData[1].NameColor.red();\r
-  params.gtNameColorGY = anAxisData[1].NameColor.green();\r
-  params.gtNameColorBY = anAxisData[1].NameColor.blue();\r
-  params.gtNameColorRZ = anAxisData[2].NameColor.red();\r
-  params.gtNameColorGZ = anAxisData[2].NameColor.green();\r
-  params.gtNameColorBZ = anAxisData[2].NameColor.blue();\r
-  params.gtDrawValuesX = anAxisData[0].DrawValues;\r
-  params.gtDrawValuesY = anAxisData[1].DrawValues;\r
-  params.gtDrawValuesZ = anAxisData[2].DrawValues;\r
-  params.gtNbValuesX = anAxisData[0].NbValues;\r
-  params.gtNbValuesY = anAxisData[1].NbValues;\r
-  params.gtNbValuesZ = anAxisData[2].NbValues;\r
-  params.gtOffsetX = anAxisData[0].Offset;\r
-  params.gtOffsetY = anAxisData[1].Offset;\r
-  params.gtOffsetZ = anAxisData[2].Offset;\r
-  params.gtColorRX = anAxisData[0].Color.red();\r
-  params.gtColorGX = anAxisData[0].Color.green();\r
-  params.gtColorBX = anAxisData[0].Color.blue();\r
-  params.gtColorRY = anAxisData[1].Color.red();\r
-  params.gtColorGY = anAxisData[1].Color.green();\r
-  params.gtColorBY = anAxisData[1].Color.blue();\r
-  params.gtColorRZ = anAxisData[2].Color.red();\r
-  params.gtColorGZ = anAxisData[2].Color.green();\r
-  params.gtColorBZ = anAxisData[2].Color.blue();\r
-  params.gtDrawTickmarksX = anAxisData[0].DrawTickmarks;\r
-  params.gtDrawTickmarksY = anAxisData[1].DrawTickmarks;\r
-  params.gtDrawTickmarksZ = anAxisData[2].DrawTickmarks;\r
-  params.gtTickmarkLengthX = anAxisData[0].TickmarkLength;\r
-  params.gtTickmarkLengthY = anAxisData[1].TickmarkLength;\r
-  params.gtTickmarkLengthZ = anAxisData[2].TickmarkLength;\r
-#endif\r
-\r
-  return params;\r
-}\r
-\r
-/*!\r
-  \brief Get visual parameters of this view window.\r
-  \return visual parameters of view window\r
-*/\r
-QString OCCViewer_ViewWindow::getVisualParameters()\r
-{\r
-  viewAspect params = getViewParams();\r
-\r
-  QStringList data;\r
-\r
-  data << QString( "scale=%1" )    .arg( params.scale,   0, 'e', 12 );\r
-#if OCC_VERSION_LARGE <= 0x06070100 // the property is deprecated after OCCT 6.7.1\r
-  data << QString( "centerX=%1" )  .arg( params.centerX, 0, 'e', 12 );\r
-  data << QString( "centerY=%1" )  .arg( params.centerY, 0, 'e', 12 );\r
-#endif\r
-  data << QString( "projX=%1" )    .arg( params.projX,   0, 'e', 12 );\r
-  data << QString( "projY=%1" )    .arg( params.projY,   0, 'e', 12 );\r
-  data << QString( "projZ=%1" )    .arg( params.projZ,   0, 'e', 12 );\r
-  data << QString( "twist=%1" )    .arg( params.twist,   0, 'e', 12 );\r
-  data << QString( "atX=%1" )      .arg( params.atX,     0, 'e', 12 );\r
-  data << QString( "atY=%1" )      .arg( params.atY,     0, 'e', 12 );\r
-  data << QString( "atZ=%1" )      .arg( params.atZ,     0, 'e', 12 );\r
-  data << QString( "eyeX=%1" )     .arg( params.eyeX,    0, 'e', 12 );\r
-  data << QString( "eyeY=%1" )     .arg( params.eyeY,    0, 'e', 12 );\r
-  data << QString( "eyeZ=%1" )     .arg( params.eyeZ,    0, 'e', 12 );\r
-  data << QString( "scaleX=%1" )   .arg( params.scaleX,  0, 'e', 12 );\r
-  data << QString( "scaleY=%1" )   .arg( params.scaleY,  0, 'e', 12 );\r
-  data << QString( "scaleZ=%1" )   .arg( params.scaleZ,  0, 'e', 12 );\r
-  data << QString( "isVisible=%1" ).arg( params.isVisible );\r
-  data << QString( "size=%1" )     .arg( params.size,    0, 'f',  2 );\r
-\r
-  ClipPlanesList aPlanes =  myModel->getClipPlanes();\r
-  for ( int i=0; i < aPlanes.size(); i++ )\r
-  {\r
-    OCCViewer_ClipPlane& aPlane = aPlanes[i];\r
-    QString ClippingPlane = QString( "ClippingPlane%1=").arg( i+1 );\r
-    ClippingPlane +=  QString( "Mode~%1;").arg( (int)aPlane.Mode );\r
-    ClippingPlane +=  QString( "IsActive~%1;").arg( aPlane.IsOn );\r
-    switch ( aPlane.Mode )\r
-    {\r
-      case OCCViewer_ClipPlane::Absolute :\r
-      {\r
-        ClippingPlane += QString( "AbsoluteOrientation~%1;" ).arg( aPlane.OrientationType );\r
-\r
-        if ( aPlane.OrientationType == OCCViewer_ClipPlane::AbsoluteCustom )\r
-        {\r
-          ClippingPlane += QString( "Dx~%1;" ).arg( aPlane.AbsoluteOrientation.Dx );\r
-          ClippingPlane += QString( "Dy~%1;" ).arg( aPlane.AbsoluteOrientation.Dy );\r
-          ClippingPlane += QString( "Dz~%1;" ).arg( aPlane.AbsoluteOrientation.Dz );\r
-        }\r
-        else\r
-        {\r
-          ClippingPlane += QString( "IsInvert~%1;" ).arg( aPlane.AbsoluteOrientation.IsInvert );\r
-        }\r
-      }\r
-      break;\r
-\r
-      case OCCViewer_ClipPlane::Relative :\r
-      {\r
-        ClippingPlane += QString( "RelativeOrientation~%1;" ).arg( aPlane.OrientationType );\r
-        ClippingPlane += QString( "Rotation1~%1;" ).arg( aPlane.RelativeOrientation.Rotation1 );\r
-        ClippingPlane += QString( "Rotation2~%1" ).arg( aPlane.RelativeOrientation.Rotation2 );\r
-      }\r
-      break;\r
-    }\r
-\r
-    ClippingPlane +=  QString( "X~%1;" ).arg( aPlane.X );\r
-    ClippingPlane +=  QString( "Y~%1;" ).arg( aPlane.Y );\r
-    ClippingPlane +=  QString( "Z~%1;" ).arg( aPlane.Z );\r
-    data << ClippingPlane;\r
-  }\r
-\r
-\r
-#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 or newer version\r
-  // graduated trihedron\r
-  data << QString( "gtIsVisible=%1" )      .arg( params.gtIsVisible );\r
-  data << QString( "gtDrawNameX=%1" )      .arg( params.gtDrawNameX );\r
-  data << QString( "gtDrawNameY=%1" )      .arg( params.gtDrawNameY );\r
-  data << QString( "gtDrawNameZ=%1" )      .arg( params.gtDrawNameZ );\r
-  data << QString( "gtNameX=%1" )          .arg( params.gtNameX );\r
-  data << QString( "gtNameY=%1" )          .arg( params.gtNameY );\r
-  data << QString( "gtNameZ=%1" )          .arg( params.gtNameZ );\r
-  data << QString( "gtNameColorRX=%1" )    .arg( params.gtNameColorRX );\r
-  data << QString( "gtNameColorGX=%1" )    .arg( params.gtNameColorGX );\r
-  data << QString( "gtNameColorBX=%1" )    .arg( params.gtNameColorBX );\r
-  data << QString( "gtNameColorRY=%1" )    .arg( params.gtNameColorRY );\r
-  data << QString( "gtNameColorGY=%1" )    .arg( params.gtNameColorGY );\r
-  data << QString( "gtNameColorBY=%1" )    .arg( params.gtNameColorBY );\r
-  data << QString( "gtNameColorRZ=%1" )    .arg( params.gtNameColorRZ );\r
-  data << QString( "gtNameColorGZ=%1" )    .arg( params.gtNameColorGZ );\r
-  data << QString( "gtNameColorBZ=%1" )    .arg( params.gtNameColorBZ );\r
-  data << QString( "gtDrawValuesX=%1" )    .arg( params.gtDrawValuesX );\r
-  data << QString( "gtDrawValuesY=%1" )    .arg( params.gtDrawValuesY );\r
-  data << QString( "gtDrawValuesZ=%1" )    .arg( params.gtDrawValuesZ );\r
-  data << QString( "gtNbValuesX=%1" )      .arg( params.gtNbValuesX );\r
-  data << QString( "gtNbValuesY=%1" )      .arg( params.gtNbValuesY );\r
-  data << QString( "gtNbValuesZ=%1" )      .arg( params.gtNbValuesZ );\r
-  data << QString( "gtOffsetX=%1" )        .arg( params.gtOffsetX );\r
-  data << QString( "gtOffsetY=%1" )        .arg( params.gtOffsetY );\r
-  data << QString( "gtOffsetZ=%1" )        .arg( params.gtOffsetZ );\r
-  data << QString( "gtColorRX=%1" )        .arg( params.gtColorRX );\r
-  data << QString( "gtColorGX=%1" )        .arg( params.gtColorGX );\r
-  data << QString( "gtColorBX=%1" )        .arg( params.gtColorBX );\r
-  data << QString( "gtColorRY=%1" )        .arg( params.gtColorRY );\r
-  data << QString( "gtColorGY=%1" )        .arg( params.gtColorGY );\r
-  data << QString( "gtColorBY=%1" )        .arg( params.gtColorBY );\r
-  data << QString( "gtColorRZ=%1" )        .arg( params.gtColorRZ );\r
-  data << QString( "gtColorGZ=%1" )        .arg( params.gtColorGZ );\r
-  data << QString( "gtColorBZ=%1" )        .arg( params.gtColorBZ );\r
-  data << QString( "gtDrawTickmarksX=%1" ) .arg( params.gtDrawTickmarksX );\r
-  data << QString( "gtDrawTickmarksY=%1" ) .arg( params.gtDrawTickmarksY );\r
-  data << QString( "gtDrawTickmarksZ=%1" ) .arg( params.gtDrawTickmarksZ );\r
-  data << QString( "gtTickmarkLengthX=%1" ).arg( params.gtTickmarkLengthX );\r
-  data << QString( "gtTickmarkLengthY=%1" ).arg( params.gtTickmarkLengthY );\r
-  data << QString( "gtTickmarkLengthZ=%1" ).arg( params.gtTickmarkLengthZ );\r
-#endif\r
-  QString bg = Qtx::backgroundToString( background() ).replace( "=", "$" );\r
-  data << QString( "background=%1" ).arg( bg );\r
-\r
-  return data.join("*");\r
-}\r
-\r
-/*!\r
-  \brief Restore visual parameters of the view window.\r
-  \param parameters visual parameters of view window\r
-*/\r
-void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters )\r
-{\r
-  viewAspect params;\r
-  ClipPlanesList aClipPlanes;\r
-  QStringList data = parameters.split( '*' );\r
-  Qtx::BackgroundData bgData;\r
-  if ( parameters.contains( '=' )  ) // new format - "scale=1.000e+00*centerX=0.000e+00..."\r
-  {\r
-    foreach( QString param, data ) {\r
-      QString paramName  = param.section( '=', 0, 0 ).trimmed();\r
-      QString paramValue = param.section( '=', 1, 1 ).trimmed();\r
-      if      ( paramName == "scale" )             params.scale             = paramValue.toDouble();\r
-      else if ( paramName == "centerX" )           params.centerX           = paramValue.toDouble();\r
-      else if ( paramName == "centerY" )           params.centerY           = paramValue.toDouble();\r
-      else if ( paramName == "projX" )             params.projX             = paramValue.toDouble();\r
-      else if ( paramName == "projY" )             params.projY             = paramValue.toDouble();\r
-      else if ( paramName == "projZ" )             params.projZ             = paramValue.toDouble();\r
-      else if ( paramName == "twist" )             params.twist             = paramValue.toDouble();\r
-      else if ( paramName == "atX" )               params.atX               = paramValue.toDouble();\r
-      else if ( paramName == "atY" )               params.atY               = paramValue.toDouble();\r
-      else if ( paramName == "atZ" )               params.atZ               = paramValue.toDouble();\r
-      else if ( paramName == "eyeX" )              params.eyeX              = paramValue.toDouble();\r
-      else if ( paramName == "eyeY" )              params.eyeY              = paramValue.toDouble();\r
-      else if ( paramName == "eyeZ" )              params.eyeZ              = paramValue.toDouble();\r
-      else if ( paramName == "scaleX" )            params.scaleX            = paramValue.toDouble();\r
-      else if ( paramName == "scaleY" )            params.scaleY            = paramValue.toDouble();\r
-      else if ( paramName == "scaleZ" )            params.scaleZ            = paramValue.toDouble();\r
-      else if ( paramName == "isVisible" )         params.isVisible         = paramValue.toInt();\r
-      else if ( paramName == "size" )              params.size              = paramValue.toDouble();\r
-      else if ( paramName.contains( "ClippingPlane" ) )\r
-      {\r
-        QStringList ClipPlaneData = paramValue.split( ';' );\r
-        OCCViewer_ClipPlane aPlane;\r
-        foreach( QString ClipPlaneParam, ClipPlaneData )\r
-        {\r
-          QString ClipPlane_paramName  = ClipPlaneParam.section( '~', 0, 0 ).trimmed();\r
-          QString ClipPlane_paramValue = ClipPlaneParam.section( '~', 1, 1 ).trimmed();\r
-          if ( ClipPlane_paramName == "Mode" )\r
-          {\r
-            aPlane.Mode = ( OCCViewer_ClipPlane::PlaneMode ) ClipPlane_paramValue.toInt();\r
-          }\r
-          else if ( ClipPlane_paramName == "IsActive" ) aPlane.IsOn = ClipPlane_paramValue.toInt();\r
-          else if ( ClipPlane_paramName == "X" )        aPlane.X    = ClipPlane_paramValue.toDouble();\r
-          else if ( ClipPlane_paramName == "Y" )        aPlane.Y    = ClipPlane_paramValue.toDouble();\r
-          else if ( ClipPlane_paramName == "Z" )        aPlane.Z    = ClipPlane_paramValue.toDouble();\r
-          else\r
-          {\r
-            switch ( aPlane.Mode )\r
-            {\r
-              case OCCViewer_ClipPlane::Absolute :\r
-                if      ( ClipPlane_paramName == "Dx" ) aPlane.AbsoluteOrientation.Dx = ClipPlane_paramValue.toDouble();\r
-                else if ( ClipPlane_paramName == "Dy" ) aPlane.AbsoluteOrientation.Dy = ClipPlane_paramValue.toDouble();\r
-                else if ( ClipPlane_paramName == "Dz" ) aPlane.AbsoluteOrientation.Dz = ClipPlane_paramValue.toDouble();\r
-                else if ( ClipPlane_paramName == "IsInvert" ) aPlane.AbsoluteOrientation.IsInvert = ClipPlane_paramValue.toInt();\r
-                else if ( ClipPlane_paramName == "AbsoluteOrientation" ) aPlane.OrientationType = ClipPlane_paramValue.toInt();\r
-                break;\r
-\r
-              case OCCViewer_ClipPlane::Relative :\r
-                if      ( ClipPlane_paramName == "RelativeOrientation" ) aPlane.OrientationType = ClipPlane_paramValue.toInt();\r
-                else if ( ClipPlane_paramName == "Rotation1" )           aPlane.RelativeOrientation.Rotation1 = ClipPlane_paramValue.toDouble();\r
-                else if ( ClipPlane_paramName == "Rotation2" )           aPlane.RelativeOrientation.Rotation2 = ClipPlane_paramValue.toDouble();\r
-                break;\r
-            }\r
-          }\r
-        }\r
-        aClipPlanes.push_back(aPlane);\r
-      }\r
-      // graduated trihedron\r
-      else if ( paramName == "gtIsVisible" )       params.gtIsVisible       = paramValue.toInt();\r
-      else if ( paramName == "gtDrawNameX" )       params.gtDrawNameX       = paramValue.toInt();\r
-      else if ( paramName == "gtDrawNameY" )       params.gtDrawNameY       = paramValue.toInt();\r
-      else if ( paramName == "gtDrawNameZ" )       params.gtDrawNameZ       = paramValue.toInt();\r
-      else if ( paramName == "gtNameX" )           params.gtNameX           = paramValue;\r
-      else if ( paramName == "gtNameY" )           params.gtNameY           = paramValue;\r
-      else if ( paramName == "gtNameZ" )           params.gtNameZ           = paramValue;\r
-      else if ( paramName == "gtNameColorRX" )     params.gtNameColorRX     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorGX" )     params.gtNameColorGX     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorBX" )     params.gtNameColorBX     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorRY" )     params.gtNameColorRY     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorGY" )     params.gtNameColorGY     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorBY" )     params.gtNameColorBY     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorRZ" )     params.gtNameColorRZ     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorGZ" )     params.gtNameColorGZ     = paramValue.toInt();\r
-      else if ( paramName == "gtNameColorBZ" )     params.gtNameColorBZ     = paramValue.toInt();\r
-      else if ( paramName == "gtDrawValuesX" )     params.gtDrawValuesX     = paramValue.toInt();\r
-      else if ( paramName == "gtDrawValuesY" )     params.gtDrawValuesY     = paramValue.toInt();\r
-      else if ( paramName == "gtDrawValuesZ" )     params.gtDrawValuesZ     = paramValue.toInt();\r
-      else if ( paramName == "gtNbValuesX" )       params.gtNbValuesX       = paramValue.toInt();\r
-      else if ( paramName == "gtNbValuesY" )       params.gtNbValuesY       = paramValue.toInt();\r
-      else if ( paramName == "gtNbValuesZ" )       params.gtNbValuesZ       = paramValue.toInt();\r
-      else if ( paramName == "gtOffsetX" )         params.gtOffsetX         = paramValue.toInt();\r
-      else if ( paramName == "gtOffsetY" )         params.gtOffsetY         = paramValue.toInt();\r
-      else if ( paramName == "gtOffsetZ" )         params.gtOffsetZ         = paramValue.toInt();\r
-      else if ( paramName == "gtColorRX" )         params.gtColorRX         = paramValue.toInt();\r
-      else if ( paramName == "gtColorGX" )         params.gtColorGX         = paramValue.toInt();\r
-      else if ( paramName == "gtColorBX" )         params.gtColorBX         = paramValue.toInt();\r
-      else if ( paramName == "gtColorRY" )         params.gtColorRY         = paramValue.toInt();\r
-      else if ( paramName == "gtColorGY" )         params.gtColorGY         = paramValue.toInt();\r
-      else if ( paramName == "gtColorBY" )         params.gtColorBY         = paramValue.toInt();\r
-      else if ( paramName == "gtColorRZ" )         params.gtColorRZ         = paramValue.toInt();\r
-      else if ( paramName == "gtColorGZ" )         params.gtColorGZ         = paramValue.toInt();\r
-      else if ( paramName == "gtColorBZ" )         params.gtColorBZ         = paramValue.toInt();\r
-      else if ( paramName == "gtDrawTickmarksX" )  params.gtDrawTickmarksX  = paramValue.toInt();\r
-      else if ( paramName == "gtDrawTickmarksY" )  params.gtDrawTickmarksY  = paramValue.toInt();\r
-      else if ( paramName == "gtDrawTickmarksZ" )  params.gtDrawTickmarksZ  = paramValue.toInt();\r
-      else if ( paramName == "gtTickmarkLengthX" ) params.gtTickmarkLengthX = paramValue.toInt();\r
-      else if ( paramName == "gtTickmarkLengthY" ) params.gtTickmarkLengthY = paramValue.toInt();\r
-      else if ( paramName == "gtTickmarkLengthZ" ) params.gtTickmarkLengthZ = paramValue.toInt();\r
-      else if ( paramName == "background" )        {\r
-  QString bg = paramValue.replace( "$", "=" );\r
-  bgData = Qtx::stringToBackground( bg );\r
-      }\r
-    }\r
-  }\r
-  else // old format - "1.000e+00*0.000e+00..."\r
-  {\r
-    int idx = 0;\r
-    params.scale     = data.count() > idx ? data[idx++].toDouble() : 1.0;\r
-    params.centerX   = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.centerY   = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.projX     = data.count() > idx ? data[idx++].toDouble() : sqrt(1./3);\r
-    params.projY     = data.count() > idx ? data[idx++].toDouble() : -sqrt(1./3);\r
-    params.projZ     = data.count() > idx ? data[idx++].toDouble() : sqrt(1./3);\r
-    params.twist     = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.atX       = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.atY       = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.atZ       = data.count() > idx ? data[idx++].toDouble() : 0.0;\r
-    params.eyeX      = data.count() > idx ? data[idx++].toDouble() : sqrt(250000./3);\r
-    params.eyeY      = data.count() > idx ? data[idx++].toDouble() : -sqrt(250000./3);\r
-    params.eyeZ      = data.count() > idx ? data[idx++].toDouble() : sqrt(250000./3);\r
-    params.scaleX    = data.count() > idx ? data[idx++].toDouble() : 1.0;\r
-    params.scaleY    = data.count() > idx ? data[idx++].toDouble() : 1.0;\r
-    params.scaleZ    = data.count() > idx ? data[idx++].toDouble() : 1.0;\r
-    params.isVisible = data.count() > idx ? data[idx++].toInt()    : 1;\r
-    params.size      = data.count() > idx ? data[idx++].toDouble() : 100.0;\r
-  }\r
-  performRestoring( params );  \r
-  setBackground( bgData );\r
-  myModel->setClipPlanes(aClipPlanes);\r
-}\r
-\r
-/*!\r
-  \brief Handle show event.\r
-\r
-  Emits Show() signal.\r
-\r
-  \param theEvent show event\r
-*/\r
-void OCCViewer_ViewWindow::showEvent( QShowEvent* theEvent )\r
-{\r
-  emit Show( theEvent );\r
-}\r
-\r
-/*!\r
-  \brief Handle hide event.\r
-\r
-  Emits Hide() signal.\r
-\r
-  \param theEvent hide event\r
-*/\r
-void OCCViewer_ViewWindow::hideEvent( QHideEvent* theEvent )\r
-{\r
-  emit Hide( theEvent );\r
-}\r
-\r
-\r
-/*!\r
-    Creates default sketcher. [ virtual protected ]\r
-*/\r
-OCCViewer_ViewSketcher* OCCViewer_ViewWindow::createSketcher( int type )\r
-{\r
-  if ( type == Rect )\r
-    return new OCCViewer_RectSketcher( this, type );\r
-  if ( type == Polygon )\r
-    return new OCCViewer_PolygonSketcher( this, type );\r
-  return 0;\r
-}\r
-\r
-void OCCViewer_ViewWindow::initSketchers()\r
-{\r
-  if ( mySketchers.isEmpty() )\r
-  {\r
-    mySketchers.append( createSketcher( Rect ) );\r
-    mySketchers.append( createSketcher( Polygon ) );\r
-  }\r
-}\r
-\r
-OCCViewer_ViewSketcher* OCCViewer_ViewWindow::getSketcher( const int typ )\r
-{\r
-  OCCViewer_ViewSketcher* sketcher = 0;\r
-  QList<OCCViewer_ViewSketcher*>::Iterator it;\r
-  for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )\r
-  {\r
-    OCCViewer_ViewSketcher* sk = (*it);\r
-    if ( sk->type() == typ )\r
-      sketcher = sk;\r
-  }\r
-  return sketcher;\r
-}\r
-\r
-/*!\r
-    Handles requests for sketching in the active view. [ virtual public ]\r
-*/\r
-void OCCViewer_ViewWindow::activateSketching( int type )\r
-{\r
-  OCCViewer_ViewPort3d* vp = getViewPort();\r
-  if ( !vp )\r
-    return;\r
-\r
-  if ( !vp->isSketchingEnabled() )\r
-    return;\r
-\r
-  /* Finish current sketching */\r
-  if ( type == NoSketching )\r
-  {\r
-    if ( mypSketcher )\r
-    {\r
-      onSketchingFinished();\r
-      mypSketcher->deactivate();\r
-      mypSketcher = 0;\r
-    }\r
-  }\r
-  /* Activate new sketching */\r
-  else\r
-  {\r
-    activateSketching( NoSketching );  /* concurrency not suported */\r
-    mypSketcher = getSketcher( type );\r
-    if ( mypSketcher )\r
-    {\r
-      mypSketcher->activate();\r
-      onSketchingStarted();\r
-    }\r
-  }\r
-}\r
-\r
-/*!\r
-    Unhilights detected entities. [ virtual protected ]\r
-*/\r
-void OCCViewer_ViewWindow::onSketchingStarted()\r
-{\r
-}\r
-\r
-/*!\r
-    Selection by rectangle or polygon. [ virtual protected ]\r
-*/\r
-void OCCViewer_ViewWindow::onSketchingFinished()\r
-{\r
-  MESSAGE("OCCViewer_ViewWindow::onSketchingFinished()")\r
-  if ( mypSketcher && mypSketcher->result() == OCCViewer_ViewSketcher::Accept )\r
-  {\r
-    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();\r
-    bool append = bool( mypSketcher->buttonState() && mypSketcher->isHasShift() );\r
-    switch( mypSketcher->type() )\r
-    {\r
-    case Rect:\r
-      {\r
-        QRect* aRect = (QRect*)mypSketcher->data();\r
-        if( aRect )\r
-        {\r
-          int aLeft = aRect->left();\r
-          int aRight = aRect->right();\r
-          int aTop = aRect->top();\r
-          int aBottom = aRect->bottom();\r
-//           myRect = aRect;\r
-\r
-          if( append )\r
-            ic->ShiftSelect( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );\r
-          else\r
-            ic->Select( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );\r
-        }\r
-      }\r
-      break;\r
-    case Polygon:\r
-      {\r
-        QPolygon* aPolygon = (QPolygon*)mypSketcher->data();\r
-        if( aPolygon )\r
-        {\r
-          int size = aPolygon->size();\r
-          TColgp_Array1OfPnt2d anArray( 1, size );\r
-\r
-          QPolygon::Iterator it = aPolygon->begin();\r
-          QPolygon::Iterator itEnd = aPolygon->end();\r
-          for( int index = 1; it != itEnd; ++it, index++ )\r
-          {\r
-            QPoint aPoint = *it;\r
-            anArray.SetValue( index, gp_Pnt2d( aPoint.x(), aPoint.y() ) );\r
-          }\r
-\r
-          if( append )\r
-            ic->ShiftSelect( anArray, getViewPort()->getView(), Standard_False );\r
-          else\r
-            ic->Select( anArray, getViewPort()->getView(), Standard_False );\r
-        }\r
-      }\r
-      break;\r
-    default:\r
-      break;\r
-    }\r
-\r
-    OCCViewer_ViewManager* aViewMgr = ( OCCViewer_ViewManager* )getViewManager();\r
-    aViewMgr->getOCCViewer()->performSelectionChanged();\r
-  }\r
-}\r
-\r
-OCCViewer_ViewPort3d* OCCViewer_ViewWindow::getViewPort()\r
-{\r
-  return myViewPort;\r
-}\r
-\r
-bool OCCViewer_ViewWindow::transformRequested() const\r
-{\r
-  return ( myOperation != NOTHING );\r
-}\r
-\r
-bool OCCViewer_ViewWindow::transformInProcess() const\r
-{\r
-  return myEventStarted;\r
-}\r
-\r
-void OCCViewer_ViewWindow::setTransformInProcess( bool bOn )\r
-{\r
-  myEventStarted = bOn;\r
-}\r
-\r
-/*!\r
-  Set enabled state of transformation (rotate, zoom, etc)\r
-*/\r
-void OCCViewer_ViewWindow::setTransformEnabled( const OperationType id, const bool on )\r
-{\r
-  if ( id != NOTHING ) myStatus.insert( id, on );\r
-}\r
-\r
-/*!\r
-  \return enabled state of transformation (rotate, zoom, etc)\r
-*/\r
-bool OCCViewer_ViewWindow::transformEnabled( const OperationType id ) const\r
-{\r
-  return myStatus.contains( id ) ? myStatus[ id ] : true;\r
-}\r
-\r
-void OCCViewer_ViewWindow::onMaximizedView()\r
-{\r
-  setMaximized(!isMaximized());\r
-}\r
-\r
-void OCCViewer_ViewWindow::returnTo3dView()\r
-{\r
-  setReturnedTo3dView( true );\r
-}\r
-\r
-void OCCViewer_ViewWindow::setReturnedTo3dView(bool isVisible3dView)\r
-{\r
-  if ( !toolMgr()->action( ReturnTo3dViewId ) ||\r
-    toolMgr()->isShown(ReturnTo3dViewId) != isVisible3dView ) return;\r
-  if ( !isVisible3dView )\r
-    toolMgr()->show( ReturnTo3dViewId );\r
-  else\r
-    toolMgr()->hide( ReturnTo3dViewId );\r
-  if ( isVisible3dView ) emit returnedTo3d( );\r
-}\r
-\r
-\r
-void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal)\r
-{\r
-  QAction* anAction =  toolMgr()->action( MaximizedId );\r
-  QAction* anAction2 =  toolMgr()->action( ReturnTo3dViewId );\r
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();\r
-  if ( toMaximize ) {\r
-    anAction->setText( tr( "MNU_MINIMIZE_VIEW" ) );  \r
-    anAction->setToolTip( tr( "MNU_MINIMIZE_VIEW" ) );  \r
-    anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ) );\r
-    anAction->setStatusTip( tr( "DSC_MINIMIZE_VIEW" ) );\r
-    if ( anAction2 && my2dMode != No2dMode ) toolMgr()->show( ReturnTo3dViewId );\r
-    if (toSendSignal) {\r
-      emit maximized( this, true );\r
-    }\r
-  }\r
-  else {\r
-    anAction->setText( tr( "MNU_MAXIMIZE_VIEW" ) );  \r
-    anAction->setToolTip( tr( "MNU_MAXIMIZE_VIEW" ) );  \r
-    anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MAXIMIZE" ) ) );\r
-    anAction->setStatusTip( tr( "DSC_MAXIMIZE_VIEW" ) );\r
-    if ( anAction2 && my2dMode != No2dMode ) toolMgr()->hide( ReturnTo3dViewId );\r
-    if (toSendSignal) {\r
-      emit maximized( this, false );\r
-    }\r
-  }\r
-}\r
-\r
-bool OCCViewer_ViewWindow::isMaximized() const\r
-{\r
-  return !(toolMgr()->action( MaximizedId )->text() == tr( "MNU_MAXIMIZE_VIEW" ));\r
-}\r
-\r
-void OCCViewer_ViewWindow::setSketcherStyle( bool enable )\r
-{ \r
-  IsSketcherStyle = enable; \r
-}\r
-\r
-bool OCCViewer_ViewWindow::isSketcherStyle() const \r
-{ \r
-  return IsSketcherStyle; \r
-}\r
-\r
-\r
-void OCCViewer_ViewWindow::set2dMode(Mode2dType theType)\r
-{\r
-  my2dMode = theType;\r
-}\r
-\r
-// obsolete   \r
-QColor OCCViewer_ViewWindow::backgroundColor() const\r
-{\r
-  return myViewPort ? myViewPort->backgroundColor() : Qt::black;\r
-}\r
-   \r
-// obsolete\r
-void OCCViewer_ViewWindow::setBackgroundColor( const QColor& theColor )\r
-{\r
-  if ( myViewPort ) myViewPort->setBackgroundColor( theColor );\r
-}\r
-\r
-Qtx::BackgroundData OCCViewer_ViewWindow::background() const\r
-{\r
-  return myViewPort ? myViewPort->background() : Qtx::BackgroundData();\r
-}\r
-   \r
-void OCCViewer_ViewWindow::setBackground( const Qtx::BackgroundData& theBackground )\r
-{\r
-  if ( myViewPort ) myViewPort->setBackground( theBackground );\r
-}\r
-\r
-/*!\r
-  Clears view aspects\r
-*/\r
-void OCCViewer_ViewWindow::clearViewAspects()\r
-{\r
-  myViewAspects.clear();\r
-}\r
-\r
-/*!\r
-  \return const reference to list of view aspects\r
-*/\r
-const viewAspectList& OCCViewer_ViewWindow::getViewAspects()\r
-{\r
-  return myViewAspects;\r
-}\r
-\r
-/*!\r
-  Appends new view aspect\r
-  \param aParams - new view aspects\r
-*/\r
-void OCCViewer_ViewWindow::appendViewAspect( const viewAspect& aParams )\r
-{\r
-  myViewAspects.append( aParams );\r
-}\r
-\r
-/*!\r
-  Replaces old view aspects by new ones\r
-  \param aViewList - list of new view aspects\r
-*/\r
-void OCCViewer_ViewWindow::updateViewAspects( const viewAspectList& aViewList )\r
-{\r
-  myViewAspects = aViewList;\r
-}\r
-\r
-/*!\r
-  Get camera properties for the OCC view window.\r
-  \return shared pointer on camera properties.\r
-*/\r
-SUIT_CameraProperties OCCViewer_ViewWindow::cameraProperties()\r
-{\r
-  SUIT_CameraProperties aProps;\r
-\r
-  Handle(V3d_View) aSourceView = getViewPort()->getView();\r
-  if ( aSourceView.IsNull() )\r
-    return aProps;\r
-\r
-  if ( get2dMode() == No2dMode ) {\r
-    aProps.setDimension( SUIT_CameraProperties::Dim3D );\r
-  }\r
-  else {\r
-    aProps.setDimension( SUIT_CameraProperties::Dim2D );\r
-    aProps.setViewSide( (SUIT_CameraProperties::ViewSide)(int)get2dMode() );\r
-  }\r
-\r
-  // read common properites of the view\r
-  Standard_Real anUp[3];\r
-  Standard_Real anAt[3];\r
-  Standard_Real anEye[3];\r
-  Standard_Real aProj[3];\r
-  Standard_Real anAxialScale[3];\r
-\r
-  aSourceView->Up( anUp[0], anUp[1], anUp[2] );\r
-  aSourceView->At( anAt[0], anAt[1], anAt[2] );\r
-  aSourceView->Proj( aProj[0], aProj[1], aProj[2] );\r
-  getViewPort()->getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );\r
-\r
-  aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );\r
-  aProps.setViewUp( anUp[0], anUp[1], anUp[2] );\r
-\r
-#if OCC_VERSION_LARGE > 0x06070100\r
-  aSourceView->Eye( anEye[0], anEye[1], anEye[2] );\r
-\r
-  // store camera properties "as is": it is up to synchronized\r
-  // view classes to provide necessary property conversion.\r
-  aProps.setPosition( anEye[0], anEye[1], anEye[2] );\r
-  aProps.setFocalPoint( anAt[0], anAt[1], anAt[2] );\r
-\r
-  if ( aSourceView->Camera()->IsOrthographic() )\r
-  {\r
-    aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );\r
-    aProps.setViewAngle( 0.0 );\r
-  }\r
-  else\r
-  {\r
-    aProps.setProjection( SUIT_CameraProperties::PrjPerspective );\r
-    aProps.setViewAngle( aSourceView->Camera()->FOVy() );\r
-  }\r
-  aProps.setMappingScale( aSourceView->Camera()->Scale() );\r
-#else\r
-  Standard_Real aCameraDepth = aSourceView->Depth() + aSourceView->ZSize() * 0.5;\r
-\r
-  // generate view orientation matrix for transforming OCC projection reference point\r
-  // into a camera (eye) position.\r
-  gp_Dir aLeftDir = gp_Dir( anUp[0], anUp[1], anUp[2] ) ^ gp_Dir( aProj[0], aProj[1], aProj[2] );\r
-\r
-  gp_GTrsf aTrsf;\r
-  aTrsf.SetValue( 1, 1, aLeftDir.X() );\r
-  aTrsf.SetValue( 2, 1, aLeftDir.Y() );\r
-  aTrsf.SetValue( 3, 1, aLeftDir.Z() );\r
-\r
-  aTrsf.SetValue( 1, 2, anUp[0] );\r
-  aTrsf.SetValue( 2, 2, anUp[1] );\r
-  aTrsf.SetValue( 3, 2, anUp[2] );\r
-\r
-  aTrsf.SetValue( 1, 3, aProj[0] );\r
-  aTrsf.SetValue( 2, 3, aProj[1] );\r
-  aTrsf.SetValue( 3, 3, aProj[2] );\r
-\r
-  aTrsf.SetValue( 1, 4, anAt[0] );\r
-  aTrsf.SetValue( 2, 4, anAt[1] );\r
-  aTrsf.SetValue( 3, 4, anAt[2] );\r
-\r
-  Graphic3d_Vertex aProjRef = aSourceView->ViewMapping().ProjectionReferencePoint();\r
-\r
-  // transform to world-space coordinate system\r
-  gp_XYZ aPosition( aProjRef.X(), aProjRef.Y(), aCameraDepth );\r
-  aTrsf.Transforms( aPosition );\r
-\r
-  // compute focal point\r
-  double aFocalPoint[3];\r
-\r
-  aFocalPoint[0] = aPosition.X() - aProj[0] * aCameraDepth;\r
-  aFocalPoint[1] = aPosition.Y() - aProj[1] * aCameraDepth;\r
-  aFocalPoint[2] = aPosition.Z() - aProj[2] * aCameraDepth;\r
-\r
-  aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );\r
-  aProps.setPosition( aPosition.X(), aPosition.Y(), aPosition.Z() );\r
-\r
-  Standard_Real aViewScale[2];\r
-  aSourceView->Size( aViewScale[0], aViewScale[1] );\r
-  aProps.setMappingScale( aViewScale[1] );\r
-#endif\r
-\r
-  return aProps;\r
-}\r
-\r
-/*!\r
-  Synchronize views.\r
-  This implementation synchronizes OCC view's camera propreties.\r
-*/\r
-void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView )\r
-{\r
-  bool blocked = blockSignals( true );\r
-\r
-  SUIT_CameraProperties aProps = theView->cameraProperties();\r
-  if ( !cameraProperties().isCompatible( aProps ) ) {\r
-    // other view, this one is being currently synchronized to, seems has become incompatible\r
-    // we have to break synchronization\r
-    updateSyncViews();\r
-    return;\r
-  }\r
-\r
-  Handle(V3d_View) aDestView = getViewPort()->getView();\r
-\r
-  aDestView->SetImmediateUpdate( Standard_False );\r
-\r
-  double anUpDir[3];\r
-  double aPosition[3];\r
-  double aFocalPoint[3];\r
-  double anAxialScale[3];\r
-\r
-  // get common properties\r
-  aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );\r
-  aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );\r
-  aProps.getViewUp( anUpDir[0], anUpDir[1], anUpDir[2] );\r
-  aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );\r
-\r
-#if OCC_VERSION_LARGE > 0x06070100\r
-  aDestView->SetAt( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );\r
-  aDestView->SetEye( aPosition[0], aPosition[1], aPosition[2] );\r
-  aDestView->SetUp( anUpDir[0], anUpDir[1], anUpDir[2] );\r
-  aDestView->Camera()->SetScale( aProps.getMappingScale() );\r
-#else\r
-  gp_Dir aProjDir( aPosition[0] - aFocalPoint[0],\r
-                   aPosition[1] - aFocalPoint[1],\r
-                   aPosition[2] - aFocalPoint[2] );\r
-\r
-  // get custom view translation\r
-  Standard_Real aTranslation[3];\r
-  aDestView->At( aTranslation[0], aTranslation[1], aTranslation[2] );\r
-\r
-  gp_Dir aLeftDir = gp_Dir( anUpDir[0], anUpDir[1], anUpDir[2] )\r
-                  ^ gp_Dir( aProjDir.X(), aProjDir.Y(), aProjDir.Z() );\r
-\r
-  gp_GTrsf aTrsf;\r
-  aTrsf.SetValue( 1, 1, aLeftDir.X() );\r
-  aTrsf.SetValue( 2, 1, aLeftDir.Y() );\r
-  aTrsf.SetValue( 3, 1, aLeftDir.Z() );\r
-\r
-  aTrsf.SetValue( 1, 2, anUpDir[0] );\r
-  aTrsf.SetValue( 2, 2, anUpDir[1] );\r
-  aTrsf.SetValue( 3, 2, anUpDir[2] );\r
-\r
-  aTrsf.SetValue( 1, 3, aProjDir.X() );\r
-  aTrsf.SetValue( 2, 3, aProjDir.Y() );\r
-  aTrsf.SetValue( 3, 3, aProjDir.Z() );\r
-\r
-  aTrsf.SetValue( 1, 4, aTranslation[0] );\r
-  aTrsf.SetValue( 2, 4, aTranslation[1] );\r
-  aTrsf.SetValue( 3, 4, aTranslation[2] );\r
-  aTrsf.Invert();\r
-\r
-  // transform to view-space coordinate system\r
-  gp_XYZ aProjRef( aPosition[0], aPosition[1], aPosition[2] );\r
-  aTrsf.Transforms( aProjRef );\r
-\r
-  // set view camera properties using low-level approach. this is done\r
-  // in order to avoid interference with static variables in v3d view used\r
-  // when rotation is in process in another view.\r
-  Visual3d_ViewMapping aMapping = aDestView->View()->ViewMapping();\r
-  Visual3d_ViewOrientation anOrientation = aDestView->View()->ViewOrientation();\r
-\r
-  Graphic3d_Vector aMappingProj( aProjDir.X(), aProjDir.Y(), aProjDir.Z() );\r
-  Graphic3d_Vector aMappingUp( anUpDir[0], anUpDir[1], anUpDir[2] );\r
-\r
-  aMappingProj.Normalize();\r
-  aMappingUp.Normalize();\r
-\r
-  anOrientation.SetViewReferencePlane( aMappingProj );\r
-  anOrientation.SetViewReferenceUp( aMappingUp );\r
-\r
-  aDestView->SetViewMapping( aMapping );\r
-  aDestView->SetViewOrientation( anOrientation );\r
-\r
-  // set panning\r
-  aDestView->SetCenter( aProjRef.X(), aProjRef.Y() );\r
-\r
-  // set mapping scale\r
-  double aMapScaling = aProps.getMappingScale();\r
-  Standard_Real aWidth, aHeight;\r
-  aDestView->Size( aWidth, aHeight );\r
-  aDestView->SetSize ( aWidth > aHeight ? aMapScaling * (aWidth / aHeight) : aMapScaling );\r
-#endif\r
-\r
-  getViewPort()->setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );\r
-\r
-  aDestView->ZFitAll();\r
-  aDestView->SetImmediateUpdate( Standard_True );\r
-  aDestView->Redraw();\r
-\r
-  blockSignals( blocked );\r
-}\r
-\r
-/*!\r
-  \brief Indicates whether preselection is enabled\r
-  \return true if preselection is enabled\r
-*/\r
-bool OCCViewer_ViewWindow::isPreselectionEnabled() const\r
-{\r
-  return myPreselectionEnabled;\r
-}\r
-\r
-/*!\r
-  \brief Enables/disables preselection\r
-  \param theIsToEnable if true - preselection will be enabled\r
-*/\r
-void OCCViewer_ViewWindow::enablePreselection( bool theIsToEnable )\r
-{\r
-  onSwitchPreselection( theIsToEnable );\r
-}\r
-\r
-/*!\r
-  \brief Indicates whether selection is enabled\r
-  \return true if selection is enabled\r
-*/\r
-bool OCCViewer_ViewWindow::isSelectionEnabled() const\r
-{\r
-  return mySelectionEnabled;\r
-}\r
-\r
-/*!\r
-  \brief Enables/disables selection\r
-  \param theIsToEnable if true - selection will be enabled\r
-*/\r
-void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable )\r
-{\r
-  onSwitchSelection( theIsToEnable );\r
-}\r
-\r
-\r
-/*!\r
-  \brief called if clipping operation is activated / deactivated.\r
-\r
-  Enables/disables clipping plane displaying.\r
-\r
-  \parma on action state\r
-*/\r
-void OCCViewer_ViewWindow::onClipping (bool theIsOn)\r
-{\r
-  if(!myModel) return;\r
-  OCCViewer_ClippingDlg* aClippingDlg = myModel->getClippingDlg();\r
-  \r
-  if (theIsOn) {\r
-    if (!aClippingDlg) {\r
-      aClippingDlg = new OCCViewer_ClippingDlg (this, myModel);\r
-      myModel->setClippingDlg(aClippingDlg);\r
-    }\r
-    if (!aClippingDlg->isVisible())\r
-      aClippingDlg->show();\r
-  } else {\r
-    if ( aClippingDlg ) {\r
-      aClippingDlg->close();\r
-      myModel->setClippingDlg(0);\r
-    }\r
-  }\r
-\r
-  SUIT_ViewManager* mgr = getViewManager();\r
-  if( mgr ) {\r
-    QVector<SUIT_ViewWindow*> aViews = mgr->getViews();\r
-    for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) {\r
-      if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) {\r
-       QtxActionToolMgr* mgr = aViewWindow->toolMgr();\r
-       if(!mgr) continue;\r
-       QAction* a = toolMgr()->action( ClippingId );\r
-       if(!a) continue;\r
-       if(theIsOn != a->isChecked()){\r
-         disconnect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool)));\r
-         a->setChecked(theIsOn);\r
-         connect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool)));\r
-       }\r
-      }\r
-    }\r
-  }\r
-}\r
+      }
+    }
+  }
+
+  if ( aPointsNb > 0 )
+  {
+    theX /= aPointsNb;
+    theY /= aPointsNb;
+    theZ /= aPointsNb;
+  }
+  return true;
+}
+
+/*!
+  \brief Set the gravity center as a rotation point.
+*/
+void OCCViewer_ViewWindow::activateSetRotationGravity()
+{
+  if ( myRotationPointSelection )
+  {
+    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+    ic->CloseAllContexts();
+    myOperation = NOTHING;
+    myViewPort->setCursor( myCursor );
+    myCursorIsHand = false;
+    myRotationPointSelection = false;
+  }
+
+  myPrevPointType = myCurrPointType;
+  myCurrPointType = GRAVITY;
+
+  Standard_Real Xcenter, Ycenter, Zcenter;
+  if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
+    mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
+}
+
+/*!
+  \brief Update gravity center in the "Set Rotation Point" dialog box.
+  \sa OCCViewer_SetRotationPointDlg class
+*/
+void OCCViewer_ViewWindow::updateGravityCoords()
+{
+  if ( mySetRotationPointDlg && mySetRotationPointDlg->isVisible() && myCurrPointType == GRAVITY )
+  {
+    Standard_Real Xcenter, Ycenter, Zcenter;
+    if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
+      mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
+  }
+}
+
+/*!
+  \brief Set the point selected by the user as a rotation point.
+  \param theX X coordinate of the rotation point
+  \param theY Y coordinate of the rotation point
+  \param theZ Z coordinate of the rotation point
+*/
+void OCCViewer_ViewWindow::activateSetRotationSelected( double theX, double theY, double theZ )
+{
+  if ( myRotationPointSelection )
+  {
+    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+    ic->CloseAllContexts();
+    myOperation = NOTHING;
+    myViewPort->setCursor( myCursor );
+    myCursorIsHand = false;
+    myRotationPointSelection = false;
+  }
+
+  myPrevPointType = myCurrPointType;
+  myCurrPointType = SELECTED;
+  mySelectedPoint.SetCoord(theX,theY,theZ);
+}
+
+/*!
+  \brief Start the shape selection process.
+*/
+void OCCViewer_ViewWindow::activateStartPointSelection( TopAbs_ShapeEnum theShapeType )
+{
+  myPrevPointType = myCurrPointType;
+  myCurrPointType = SELECTED;
+
+  // activate selection ------>
+  Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+
+  ic->OpenLocalContext();
+
+  AIS_ListOfInteractive aList;
+  ic->DisplayedObjects( aList );
+  for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() )
+  {
+    Handle(AIS_InteractiveObject) anObj = it.Value();
+    if ( !anObj.IsNull() && anObj->HasPresentation() &&
+         anObj->IsKind( STANDARD_TYPE(AIS_Shape) ) )
+    {
+      ic->Load(anObj,-1);
+      ic->Activate(anObj,AIS_Shape::SelectionMode(theShapeType));
+     }
+  }
+  // activate selection <------
+
+  if ( !myCursorIsHand )
+  {
+    QCursor handCursor (Qt::PointingHandCursor);
+    myCursorIsHand = true;
+    myCursor = cursor();
+    myViewPort->setCursor( handCursor );
+  }
+  myRotationPointSelection = true;
+}
+
+/*!
+  \brief Start global panning operation
+
+  Sets the corresponding cursor for the widget.
+*/
+void OCCViewer_ViewWindow::activateGlobalPanning()
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+    QPixmap globalPanPixmap (imageCrossCursor);
+    QCursor glPanCursor (globalPanPixmap);
+    myCurScale = aView3d->Scale();
+    aView3d->FitAll(0.01, false);
+    myCursor = cursor();                // save old cursor
+    myViewPort->fitAll(); // fits view before selecting a new scene center
+    if( setTransformRequested( PANGLOBAL ) )
+      myViewPort->setCursor( glPanCursor );
+  }
+}
+
+/*!
+  \brief Starts fit operation.
+
+  Sets the corresponding cursor for the widget.
+*/
+void OCCViewer_ViewWindow::activateWindowFit()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();                /* save old cursor */
+
+  if ( myOperation != WINDOWFIT ) {
+    QCursor handCursor (Qt::PointingHandCursor);
+    if( setTransformRequested ( WINDOWFIT ) )
+    {
+      myViewPort->setCursor ( handCursor );
+      myCursorIsHand = true;
+    }
+  }
+}
+
+/*!
+  \brief Start delayed viewer operation.
+*/
+bool OCCViewer_ViewWindow::setTransformRequested( OperationType op )
+{
+  bool ok = transformEnabled( op );
+  myOperation = ok ? op : NOTHING;
+  myViewPort->setMouseTracking( myOperation == NOTHING );  
+  return ok;
+}
+
+/*!
+  \brief Handle mouse move event.
+  \param theEvent mouse event
+*/
+void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent )
+{
+  if ( myIsKeyFree && interactionStyle() == SUIT_ViewModel::KEY_FREE ) {
+    myIsKeyFree = false;
+    switch ( getButtonState( theEvent, interactionStyle() ) ) {
+    case ZOOMVIEW:
+      myViewPort->startZoomAtPoint( myStartX, myStartY );
+      activateZoom();
+      break;
+    case PANVIEW:
+      activatePanning();
+      break;
+    case ROTATE:
+      activateRotation();
+      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
+      break;
+    default:
+      break;
+    }
+  }
+
+  myCurrX = theEvent->x();
+  myCurrY = theEvent->y();
+  switch (myOperation) {
+  case ROTATE:
+    myViewPort->rotate(myCurrX, myCurrY, myCurrPointType, mySelectedPoint);
+    break;
+
+  case ZOOMVIEW:
+    myViewPort->zoom(myStartX, myStartY, myCurrX, myCurrY);
+    myStartX = myCurrX;
+    myStartY = myCurrY;
+    break;
+
+  case PANVIEW:
+    myViewPort->pan(myCurrX - myStartX, myStartY - myCurrY);
+    myStartX = myCurrX;
+    myStartY = myCurrY;
+    break;
+
+/*    case WINDOWFIT:
+    myDrawRect = true;
+    repaint();
+    break;
+*/
+  case PANGLOBAL:
+    break;
+
+  default:
+    if ( myRotationPointSelection || isSketcherStyle() )
+    {
+      emit mouseMoving( this, theEvent );
+    }
+    else
+    {
+      int aState = theEvent->modifiers();
+      int aButton = theEvent->buttons();
+      int anInteractionStyle = interactionStyle();
+      if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD &&
+           aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||
+         ( anInteractionStyle == SUIT_ViewModel::KEY_FREE &&
+         aButton == Qt::LeftButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {
+        myDrawRect = myEnableDrawMode;
+        if ( myDrawRect ) {
+          drawRect();
+          if ( !myCursorIsHand )        {   // we are going to sketch a rectangle
+            QCursor handCursor (Qt::PointingHandCursor);
+            myCursorIsHand = true;
+            myCursor = cursor();
+            myViewPort->setCursor( handCursor );
+          }
+        }
+        emit mouseMoving( this, theEvent );
+      }
+      else if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD &&
+                aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||
+                ( anInteractionStyle == SUIT_ViewModel::KEY_FREE &&
+                aButton == Qt::RightButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {
+        OCCViewer_ViewSketcher* sketcher = 0;
+        QList<OCCViewer_ViewSketcher*>::Iterator it;
+        for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )
+        {
+          OCCViewer_ViewSketcher* sk = (*it);
+          if( sk->isDefault() && sk->sketchButton() == aButton )
+            sketcher = sk;
+        }
+        if ( sketcher && myCurSketch == -1 )
+        {
+          activateSketching( sketcher->type() );
+          if ( mypSketcher )
+          {
+            myCurSketch = mypSketcher->sketchButton();
+
+            if ( l_mbPressEvent )
+            {
+              QApplication::sendEvent( getViewPort(), l_mbPressEvent );
+              delete l_mbPressEvent;
+              l_mbPressEvent = 0;
+            }
+            QApplication::sendEvent( getViewPort(), theEvent );
+          }
+        }
+      }
+      else
+        emit mouseMoving( this, theEvent );
+    }
+  }
+}
+
+/*!
+  \brief Handle mouse release event.
+  \param theEvent mouse event
+*/
+void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)
+{
+  switch ( myOperation ) {
+  case NOTHING:
+    {
+      int prevState = myCurSketch;
+      if(theEvent->button() == Qt::RightButton)
+      {
+        QList<OCCViewer_ViewSketcher*>::Iterator it;
+        for ( it = mySketchers.begin(); it != mySketchers.end() && myCurSketch != -1; ++it )
+        {
+          OCCViewer_ViewSketcher* sk = (*it);
+          if( ( sk->sketchButton() & theEvent->button() ) && sk->sketchButton() == myCurSketch )
+            myCurSketch = -1;
+        }
+      }
+
+      emit mouseReleased(this, theEvent);
+      if(theEvent->button() == Qt::RightButton && prevState == -1)
+      {
+        QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
+                                  theEvent->pos(), theEvent->globalPos() );
+        emit contextMenuRequested( &aEvent );
+      }
+    }
+    break;
+  case ROTATE:
+    myViewPort->endRotation();
+    resetState();
+    break;
+
+  case PANVIEW:
+  case ZOOMVIEW:
+    resetState();
+    break;
+
+  case PANGLOBAL:
+    if ( theEvent->button() == Qt::LeftButton ) {
+      myViewPort->setCenter( theEvent->x(), theEvent->y() );
+      myViewPort->getView()->SetScale(myCurScale);
+      resetState();
+    }
+    break;
+
+  case WINDOWFIT:
+    if ( theEvent->button() == Qt::LeftButton ) {
+      myCurrX = theEvent->x();
+      myCurrY = theEvent->y();
+      drawRect();
+      QRect rect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
+      if ( !rect.isEmpty() ) myViewPort->fitRect(rect);
+      endDrawRect();
+      resetState();
+    }
+    break;
+  }
+
+  // NOTE: viewer 3D detects a rectangle of selection using this event
+  // so we must emit it BEFORE resetting the selection rectangle
+
+  if ( theEvent->button() == Qt::LeftButton && myDrawRect ) {
+    drawRect();
+    endDrawRect();
+    resetState();
+    myViewPort->update();
+  }
+
+  if ( l_mbPressEvent )
+  {
+    delete l_mbPressEvent;
+    l_mbPressEvent = 0;
+  }
+}
+
+/*!
+  \brief Reset the viewport to its initial state
+  ( no transformations in process etc. )
+*/
+void OCCViewer_ViewWindow::resetState()
+{
+  myDrawRect = false;
+
+  if ( myRotationPointSelection )
+  {
+    QCursor handCursor (Qt::PointingHandCursor);
+    myViewPort->setCursor( handCursor );
+  }
+  else
+  {
+    if ( transformRequested() || myCursorIsHand )
+      myViewPort->setCursor( myCursor );
+    myCursorIsHand = false;
+  }
+
+  if ( transformRequested() )
+    emit vpTransformationFinished (myOperation);
+
+  setTransformInProcess( false );
+  setTransformRequested( NOTHING );
+}
+
+
+/*!
+  \brief Draw rubber band rectangle.
+*/
+void OCCViewer_ViewWindow::drawRect()
+{
+  if ( !myRectBand ) {
+    myRectBand = new QtxRectRubberBand( myViewPort );
+    //QPalette palette;
+    //palette.setColor(myRectBand->foregroundRole(), Qt::white);
+    //myRectBand->setPalette(palette);
+  }
+  //myRectBand->hide();
+  
+  myRectBand->setUpdatesEnabled ( false );
+  QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
+  myRectBand->initGeometry( aRect );
+
+  if ( !myRectBand->isVisible() )
+    myRectBand->show();
+
+  myRectBand->setUpdatesEnabled ( true );
+  //myRectBand->repaint();
+
+  //myRectBand->setVisible( aRect.isValid() );
+  //if ( myRectBand->isVisible() )
+  //  myRectBand->repaint();
+  //else
+  //  myRectBand->show();
+  //myRectBand->repaint();
+}
+
+/*!
+  \brief Clear rubber band rectangle on the end on the dragging operation.
+*/
+void OCCViewer_ViewWindow::endDrawRect()
+{
+  //delete myRectBand;
+  //myRectBand = 0;
+  if ( myRectBand )
+    {
+      myRectBand->clearGeometry();
+      myRectBand->hide();
+    }
+}
+
+/*!
+  \brief Create actions.
+*/
+void OCCViewer_ViewWindow::createActions()
+{
+  if( !toolMgr()->isEmpty() )
+    return;
+  
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+
+  QtxAction* aAction;
+
+  // Dump view
+  aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_DUMP" ) ),
+                           tr( "MNU_DUMP_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
+  toolMgr()->registerAction( aAction, DumpId );
+
+  // FitAll
+  aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITALL" ) ),
+                           tr( "MNU_FITALL" ), 0, this);
+  aAction->setStatusTip(tr("DSC_FITALL"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
+  toolMgr()->registerAction( aAction, FitAllId );
+
+  // FitRect
+  aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITAREA" ) ),
+                           tr( "MNU_FITRECT" ), 0, this);
+  aAction->setStatusTip(tr("DSC_FITRECT"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
+  toolMgr()->registerAction( aAction, FitRectId );
+  
+  // Zoom
+  aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ZOOM" ) ),
+                           tr( "MNU_ZOOM_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
+  toolMgr()->registerAction( aAction, ZoomId );
+
+  // Panning
+  aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ),
+                           tr( "MNU_PAN_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_PAN_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
+  toolMgr()->registerAction( aAction, PanId );
+
+  // Global Panning
+  aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_GLOBALPAN" ) ),
+                           tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
+  toolMgr()->registerAction( aAction, GlobalPanId );
+
+  // Rotation Point
+  mySetRotationPointAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATION_POINT" ) ),
+                           tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
+  mySetRotationPointAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
+  mySetRotationPointAction->setCheckable( true );
+  connect(mySetRotationPointAction, SIGNAL(toggled( bool )), this, SLOT(onSetRotationPoint( bool )));
+  toolMgr()->registerAction( mySetRotationPointAction, ChangeRotationPointId );
+
+  // Rotation
+  aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATE" ) ),
+                           tr( "MNU_ROTATE_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
+  toolMgr()->registerAction( aAction, RotationId );
+
+  // Projections
+  aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FRONT" ) ),
+                           tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
+  aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, FrontId );
+
+  aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BACK" ) ),
+                           tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
+  aAction->setStatusTip(tr("DSC_BACK_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onBackView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, BackId );
+
+  aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TOP" ) ),
+                           tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
+  aAction->setStatusTip(tr("DSC_TOP_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onTopView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, TopId );
+
+  aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BOTTOM" ) ),
+                           tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
+  aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, BottomId );
+  
+  aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_LEFT" ) ),
+                           tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
+  aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, LeftId );
+
+  aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RIGHT" ) ),
+                           tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
+  aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onRightView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, RightId );
+
+  // rotate anticlockwise
+  aAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ANTICLOCKWISE" ) ),
+                           tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
+  aAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, AntiClockWiseId );
+
+  // rotate clockwise
+  aAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_CLOCKWISE" ) ),
+                           tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
+  aAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, ClockWiseId );
+
+  // Reset
+  aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RESET" ) ),
+                           tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
+  aAction->setStatusTip(tr("DSC_RESET_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onResetView()));
+  this->addAction(aAction);
+  toolMgr()->registerAction( aAction, ResetId );
+
+  // Clone
+  aAction = new QtxAction(tr("MNU_CLONE_VIEW"),
+                          aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_CLONE_VIEW")),
+                          tr("MNU_CLONE_VIEW"), 0, this);
+  aAction->setStatusTip(tr("DSC_CLONE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onCloneView()));
+  toolMgr()->registerAction( aAction, CloneId );
+
+  aAction = new QtxAction (tr ("MNU_CLIPPING"), aResMgr->loadPixmap ("OCCViewer", tr ("ICON_OCCVIEWER_CLIPPING")),
+                                      tr ("MNU_CLIPPING"), 0, this);
+  aAction->setStatusTip (tr ("DSC_CLIPPING"));
+  aAction->setCheckable (true);
+  connect (aAction, SIGNAL (toggled (bool)), this, SLOT (onClipping (bool)));
+  toolMgr()->registerAction (aAction, ClippingId);
+
+  aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ),
+                           tr( "MNU_SHOOT_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_SHOOT_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onMemorizeView()));
+  toolMgr()->registerAction( aAction, MemId );
+
+  aAction = new QtxAction(tr("MNU_PRESETS_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESETS_VIEW" ) ),
+                           tr( "MNU_PRESETS_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_PRESETS_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onRestoreView()));
+  toolMgr()->registerAction( aAction, RestoreId );
+
+  if (myModel->trihedronActivated()) {
+    aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TRIHEDRON" ) ),
+                             tr( "MNU_SHOW_TRIHEDRE" ), 0, this);
+    aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRE"));
+    connect(aAction, SIGNAL(triggered()), this, SLOT(onTrihedronShow()));
+    toolMgr()->registerAction( aAction, TrihedronShowId );
+  }
+
+  // Scale
+  aAction = new QtxAction(tr("MNU_SCALING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SCALING" ) ),
+                           tr( "MNU_SCALING" ), 0, this);
+  aAction->setStatusTip(tr("DSC_SCALING"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale()));
+  toolMgr()->registerAction( aAction, AxialScaleId );
+
+  // Enable/disable preselection
+  aAction = new QtxAction(tr("MNU_ENABLE_PRESELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESELECTION" ) ),
+                          tr( "MNU_ENABLE_PRESELECTION" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ENABLE_PRESELECTION"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchPreselection(bool)));
+  toolMgr()->registerAction( aAction, SwitchPreselectionId );
+
+  // Enable/disable selection
+  aAction = new QtxAction(tr("MNU_ENABLE_SELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SELECTION" ) ),
+                          tr( "MNU_ENABLE_SELECTION" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ENABLE_SELECTION"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchSelection(bool)));
+  toolMgr()->registerAction( aAction, SwitchSelectionId );
+
+  // Graduated axes 
+  aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ),
+                           tr( "MNU_GRADUATED_AXES" ), 0, this);
+  aAction->setStatusTip(tr("DSC_GRADUATED_AXES"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onGraduatedAxes()));
+  toolMgr()->registerAction( aAction, GraduatedAxesId );
+
+  // Active only ambient light or not
+  aAction = new QtxAction(tr("MNU_AMBIENT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_AMBIENT" ) ),
+                           tr( "MNU_AMBIENT" ), 0, this);
+  aAction->setStatusTip(tr("DSC_AMBIENT"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onAmbientToogle()));
+  toolMgr()->registerAction( aAction, AmbientId );
+
+  // Switch between interaction styles
+  aAction = new QtxAction(tr("MNU_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_STYLE_SWITCH" ) ),
+                          tr( "MNU_STYLE_SWITCH" ), 0, this);
+  aAction->setStatusTip(tr("DSC_STYLE_SWITCH"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
+  toolMgr()->registerAction( aAction, SwitchInteractionStyleId );
+
+  // Switch between zooming styles
+  aAction = new QtxAction(tr("MNU_ZOOMING_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_ZOOMING_STYLE_SWITCH" ) ),
+                          tr( "MNU_ZOOMING_STYLE_SWITCH" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ZOOMING_STYLE_SWITCH"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
+  toolMgr()->registerAction( aAction, SwitchZoomingStyleId );
+
+  // Maximized view
+  aAction = new QtxAction(tr("MNU_MINIMIZE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ),
+                          tr( "MNU_MINIMIZE_VIEW" ), 0, this );
+  aAction->setStatusTip(tr("DSC_MINIMIZE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView()));
+  toolMgr()->registerAction( aAction, MaximizedId );
+
+  // Return to 3d view
+  if (my2dMode!=No2dMode){
+    aAction = new QtxAction(tr("MNU_RETURN_3D_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_RETURN_3D_VIEW" ) ),
+                            tr( "MNU_RETURN_3D_VIEW" ), 0, this );
+    aAction->setStatusTip(tr("DSC_RETURN_3D_VIEW"));
+    connect(aAction, SIGNAL(triggered()), this, SLOT(returnTo3dView()));
+    toolMgr()->registerAction( aAction, ReturnTo3dViewId );
+  }
+
+  // Synchronize View 
+  toolMgr()->registerAction( synchronizeAction(), SynchronizeId );
+}
+
+/*!
+  \brief Create toolbar.
+*/
+void OCCViewer_ViewWindow::createToolBar()
+{
+  QString aToolbarName;
+  switch (my2dMode) {
+  case XYPlane:
+    aToolbarName = tr( "LBL_XYTOOLBAR_LABEL" );
+    break;
+  case XZPlane:
+    aToolbarName = tr( "LBL_XZTOOLBAR_LABEL" );
+    break;
+  case YZPlane:
+    aToolbarName = tr( "LBL_YZTOOLBAR_LABEL" );
+    break;
+  default:
+    aToolbarName = tr( "LBL_3DTOOLBAR_LABEL" );
+  }
+  
+  int tid = toolMgr()->createToolBar( aToolbarName, false );
+  if ( my2dMode != No2dMode ){
+    toolMgr()->append( ReturnTo3dViewId, tid );
+    toolMgr()->append( toolMgr()->separator(), tid );
+  }
+  toolMgr()->append( DumpId, tid );
+  toolMgr()->append( SwitchInteractionStyleId, tid );
+#if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
+  toolMgr()->append( SwitchZoomingStyleId, tid );
+#endif
+  toolMgr()->append( SwitchPreselectionId, tid );
+  toolMgr()->append( SwitchSelectionId, tid );
+  if( myModel->trihedronActivated() )
+    toolMgr()->append( TrihedronShowId, tid );
+
+  QtxMultiAction* aScaleAction = new QtxMultiAction( this );
+  aScaleAction->insertAction( toolMgr()->action( FitAllId ) );
+  aScaleAction->insertAction( toolMgr()->action( FitRectId ) );
+  aScaleAction->insertAction( toolMgr()->action( ZoomId ) );
+  toolMgr()->append( aScaleAction, tid );
+
+  QtxMultiAction* aPanningAction = new QtxMultiAction( this );
+  aPanningAction->insertAction( toolMgr()->action( PanId ) );
+  aPanningAction->insertAction( toolMgr()->action( GlobalPanId ) );
+  toolMgr()->append( aPanningAction, tid );
+
+  if (my2dMode == No2dMode) {
+    toolMgr()->append( ChangeRotationPointId, tid );
+    toolMgr()->append( RotationId, tid );
+
+    QtxMultiAction* aViewsAction = new QtxMultiAction( this );
+    aViewsAction->insertAction( toolMgr()->action( FrontId ) );
+    aViewsAction->insertAction( toolMgr()->action( BackId ) );
+    aViewsAction->insertAction( toolMgr()->action( TopId ) );
+    aViewsAction->insertAction( toolMgr()->action( BottomId ) );
+    aViewsAction->insertAction( toolMgr()->action( LeftId ) );
+    aViewsAction->insertAction( toolMgr()->action( RightId ) );
+    toolMgr()->append( aViewsAction, tid );
+
+    toolMgr()->append( AntiClockWiseId, tid );
+    toolMgr()->append( ClockWiseId, tid );
+
+    toolMgr()->append( ResetId, tid );
+  }
+
+  QtxMultiAction* aMemAction = new QtxMultiAction( this );
+  aMemAction->insertAction( toolMgr()->action( MemId ) );
+  aMemAction->insertAction( toolMgr()->action( RestoreId ) );
+  toolMgr()->append( aMemAction, tid );
+
+  toolMgr()->append( toolMgr()->separator(), tid );
+  toolMgr()->append( CloneId, tid );
+  
+  toolMgr()->append( toolMgr()->separator(), tid );
+  toolMgr()->append( ClippingId, tid );
+  toolMgr()->append( AxialScaleId, tid );
+#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version
+  toolMgr()->append( GraduatedAxesId, tid );
+#endif
+  toolMgr()->append( AmbientId, tid );
+
+  toolMgr()->append( MaximizedId, tid );
+  toolMgr()->append( SynchronizeId, tid );
+}
+
+/*!
+  \brief Perform 'fit all' operation.
+*/
+void OCCViewer_ViewWindow::onViewFitAll()
+{
+  myViewPort->fitAll();
+}
+
+/*!
+  \brief Perform "front view" transformation.
+*/
+void OCCViewer_ViewWindow::onFrontView()
+{
+  emit vpTransformationStarted ( FRONTVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xpos);
+  onViewFitAll();
+  emit vpTransformationFinished ( FRONTVIEW );
+}
+
+/*!
+  \brief Perform "back view" transformation.
+*/
+void OCCViewer_ViewWindow::onBackView()
+{
+  emit vpTransformationStarted ( BACKVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xneg);
+  onViewFitAll();
+  emit vpTransformationFinished ( BACKVIEW );
+}
+
+/*!
+  \brief Perform "top view" transformation.
+*/
+void OCCViewer_ViewWindow::onTopView()
+{
+  emit vpTransformationStarted ( TOPVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zpos);
+  onViewFitAll();
+  emit vpTransformationFinished ( TOPVIEW );
+}
+
+/*!
+  \brief Perform "bottom view" transformation.
+*/
+void OCCViewer_ViewWindow::onBottomView()
+{
+  emit vpTransformationStarted ( BOTTOMVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zneg);
+  onViewFitAll();
+  emit vpTransformationFinished ( BOTTOMVIEW );
+}
+
+/*!
+  \brief Perform "left view" transformation.
+*/
+void OCCViewer_ViewWindow::onLeftView()
+{
+  emit vpTransformationStarted ( LEFTVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Yneg);
+  onViewFitAll();
+  emit vpTransformationFinished ( LEFTVIEW );
+}
+
+/*!
+  \brief Perform "right view" transformation.
+*/
+void OCCViewer_ViewWindow::onRightView()
+{
+  emit vpTransformationStarted ( RIGHTVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Ypos);
+  onViewFitAll();
+  emit vpTransformationFinished ( RIGHTVIEW );
+}
+
+/*!
+  \brief Rotate view 90 degrees clockwise
+*/
+void OCCViewer_ViewWindow::onClockWiseView()
+{
+  emit vpTransformationStarted ( CLOCKWISEVIEW );
+  myViewPort->rotateXY( 90. );
+  emit vpTransformationFinished ( CLOCKWISEVIEW );
+}
+
+/*!
+  \brief Rotate view 90 degrees conterclockwise
+*/
+void OCCViewer_ViewWindow::onAntiClockWiseView()
+{
+  emit vpTransformationStarted ( ANTICLOCKWISEVIEW );
+  myViewPort->rotateXY( -90. );
+  emit vpTransformationFinished ( ANTICLOCKWISEVIEW );
+}
+
+/*!
+  \brief Perform "reset view" transformation.
+
+  Sets default orientation of the viewport camera.
+*/
+void OCCViewer_ViewWindow::onResetView()
+{
+  emit vpTransformationStarted( RESETVIEW );
+  bool upd = myViewPort->getView()->SetImmediateUpdate( false );
+  myViewPort->getView()->Reset( false );
+  myViewPort->fitAll( false, true, false );
+  myViewPort->getView()->SetImmediateUpdate( upd );
+  myViewPort->getView()->Update();
+  emit vpTransformationFinished( RESETVIEW );
+}
+
+/*!
+  \brief Perform "fit all" transformation.
+*/
+void OCCViewer_ViewWindow::onFitAll()
+{
+  emit vpTransformationStarted( FITALLVIEW );
+  myViewPort->fitAll();
+  emit vpTransformationFinished( FITALLVIEW );
+}
+
+/*!
+  \brief Called if 'change rotation point' operation is activated.
+  \param on action state
+*/
+void OCCViewer_ViewWindow::onSetRotationPoint( bool on )
+{
+  if (on)
+  {
+    if (!mySetRotationPointDlg)
+    {
+      mySetRotationPointDlg = new OCCViewer_SetRotationPointDlg (this);
+      mySetRotationPointDlg->SetAction(mySetRotationPointAction);
+    }
+
+    if (!mySetRotationPointDlg->isVisible())
+    {
+      //if (mySetRotationPointDlg->IsFirstShown())
+      if (myCurrPointType == GRAVITY)
+      {
+        Standard_Real Xcenter, Ycenter, Zcenter;
+        if (computeGravityCenter(Xcenter, Ycenter, Zcenter))
+          mySetRotationPointDlg->setCoords(Xcenter, Ycenter, Zcenter);
+      }
+      mySetRotationPointDlg->show();
+    }
+  }
+  else
+  {
+    if (mySetRotationPointDlg->isVisible())
+      mySetRotationPointDlg->hide();
+  }
+}
+
+/*!
+   \brief Create one more window with same content.
+*/
+void OCCViewer_ViewWindow::onCloneView()
+{
+  SUIT_ViewWindow* vw = myManager->createViewWindow();
+  //vw->show();
+  emit viewCloned( vw );
+}
+
+/*!
+  Creates one more window with same content
+*/
+void OCCViewer_ViewWindow::onAxialScale()
+{
+  if ( !myScalingDlg )
+    myScalingDlg = new OCCViewer_AxialScaleDlg( this );
+  
+  if ( !myScalingDlg->isVisible() )
+  {
+    myScalingDlg->Update();
+    myScalingDlg->show();
+  }
+}
+
+/*!
+  Shows Graduated Axes dialog
+*/
+void OCCViewer_ViewWindow::onGraduatedAxes()
+{
+  myCubeAxesDlg->Update();
+  myCubeAxesDlg->show();
+}
+
+void OCCViewer_ViewWindow::onAmbientToogle()
+{
+  Handle(V3d_Viewer) viewer = myViewPort->getViewer();
+  viewer->InitDefinedLights();
+  while(viewer->MoreDefinedLights())
+    {
+      Handle(V3d_Light) light = viewer->DefinedLight();
+      if(light->Type() != V3d_AMBIENT)
+        {
+          Handle(V3d_View) aView3d = myViewPort->getView();
+          if( aView3d->IsActiveLight(light) ) viewer->SetLightOff(light);
+          else viewer->SetLightOn(light);
+        }
+      viewer->NextDefinedLights();
+    }
+  viewer->Update();
+}
+
+/*!
+  \brief Store view parameters.
+*/
+void OCCViewer_ViewWindow::onMemorizeView()
+{
+  appendViewAspect( getViewParams() );
+}
+
+/*!
+  \brief Restore view parameters.
+*/
+void OCCViewer_ViewWindow::onRestoreView()
+{
+  OCCViewer_CreateRestoreViewDlg* aDlg = new OCCViewer_CreateRestoreViewDlg( centralWidget(), this );
+  connect( aDlg, SIGNAL( dlgOk() ), this, SLOT( setRestoreFlag() ) );
+  aDlg->exec();
+  updateViewAspects( aDlg->parameters() );
+  if( myRestoreFlag && aDlg->parameters().count() )
+    performRestoring( aDlg->currentItem() );
+}
+
+/*!
+  \brief Restore view parameters.
+  \param anItem view parameters
+*/
+void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool baseParamsOnly )
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+
+  Standard_Boolean prev = aView3d->SetImmediateUpdate( Standard_False );
+  aView3d->SetScale( anItem.scale );
+  aView3d->SetTwist( anItem.twist );
+  aView3d->SetAt( anItem.atX, anItem.atY, anItem.atZ );
+  aView3d->SetImmediateUpdate( prev );
+  aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );
+  aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );
+  aView3d->SetAxialScale( anItem.scaleX, anItem.scaleY, anItem.scaleZ );
+
+#if OCC_VERSION_LARGE > 0x06070100
+  if ( anItem.centerX != 0.0 || anItem.centerY != 0.0 )
+  {
+    double anUpX = 0.0, anUpY = 0.0, anUpZ = 0.0;
+
+    // "eye" and "at" require conversion to represent center panning
+    // up direction is only available after setting angle of twist and
+    // other view parameters
+    aView3d->Up( anUpX, anUpY, anUpZ );
+
+    gp_Dir aProj( -anItem.projX, -anItem.projY, -anItem.projZ );
+    gp_Dir anUp( anUpX, anUpY, anUpZ );
+    gp_Pnt anAt( anItem.atX, anItem.atY, anItem.atZ );
+    gp_Pnt anEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );
+    gp_Dir aSide = aProj ^ anUp;
+
+    anAt.Translate( gp_Vec( aSide ) * anItem.centerX );
+    anAt.Translate( gp_Vec( anUp  ) * anItem.centerY );
+
+    aView3d->SetAt( anAt.X(), anAt.Y(), anAt.Z() );
+    aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );
+  }
+#else
+  aView3d->SetCenter( anItem.centerX, anItem.centerY );
+#endif
+
+  if ( !baseParamsOnly ) {
+
+    myModel->setTrihedronShown( anItem.isVisible );
+    myModel->setTrihedronSize( anItem.size );
+        
+#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version
+    // graduated trihedron
+    bool anIsVisible = anItem.gtIsVisible;
+    OCCViewer_AxisWidget::AxisData anAxisData[3];
+    anAxisData[0].DrawName = anItem.gtDrawNameX;
+    anAxisData[1].DrawName = anItem.gtDrawNameZ;
+    anAxisData[2].DrawName = anItem.gtDrawNameZ;
+    anAxisData[0].Name = anItem.gtNameX;
+    anAxisData[1].Name = anItem.gtNameZ;
+    anAxisData[2].Name = anItem.gtNameZ;
+    anAxisData[0].NameColor = QColor( anItem.gtNameColorRX,
+              anItem.gtNameColorGX,
+              anItem.gtNameColorBX );
+    anAxisData[1].NameColor = QColor( anItem.gtNameColorRY,
+              anItem.gtNameColorGY,
+              anItem.gtNameColorBY );
+    anAxisData[2].NameColor = QColor( anItem.gtNameColorRZ,
+              anItem.gtNameColorGZ,
+              anItem.gtNameColorBZ );
+    anAxisData[0].DrawValues = anItem.gtDrawValuesX;
+    anAxisData[1].DrawValues = anItem.gtDrawValuesY;
+    anAxisData[2].DrawValues = anItem.gtDrawValuesZ;
+    anAxisData[0].NbValues = anItem.gtNbValuesX;
+    anAxisData[1].NbValues = anItem.gtNbValuesY;
+    anAxisData[2].NbValues = anItem.gtNbValuesZ;
+    anAxisData[0].Offset = anItem.gtOffsetX;
+    anAxisData[1].Offset = anItem.gtOffsetY;
+    anAxisData[2].Offset = anItem.gtOffsetZ;
+    anAxisData[0].Color = QColor( anItem.gtColorRX,
+          anItem.gtColorGX,
+          anItem.gtColorBX );
+    anAxisData[1].Color = QColor( anItem.gtColorRY,
+          anItem.gtColorGY,
+          anItem.gtColorBY );
+    anAxisData[2].Color = QColor( anItem.gtColorRZ,
+          anItem.gtColorGZ,
+          anItem.gtColorBZ );
+    anAxisData[0].DrawTickmarks = anItem.gtDrawTickmarksX;
+    anAxisData[1].DrawTickmarks = anItem.gtDrawTickmarksY;
+    anAxisData[2].DrawTickmarks = anItem.gtDrawTickmarksZ;
+    anAxisData[0].TickmarkLength = anItem.gtTickmarkLengthX;
+    anAxisData[1].TickmarkLength = anItem.gtTickmarkLengthY;
+    anAxisData[2].TickmarkLength = anItem.gtTickmarkLengthZ;
+
+    myCubeAxesDlg->SetData( anIsVisible, anAxisData );
+    myCubeAxesDlg->ApplyData( aView3d );
+#endif
+
+  } // if ( !baseParamsOnly )
+
+  myRestoreFlag = 0;
+}
+
+/*!
+  \brief Set restore flag.
+*/
+void OCCViewer_ViewWindow::setRestoreFlag()
+{
+  myRestoreFlag = 1;
+}
+
+/*!
+  \brief Called when action "show/hide trihedron" is activated.
+*/
+void OCCViewer_ViewWindow::onTrihedronShow()
+{
+  myModel->toggleTrihedron();
+}
+
+/*!
+  \brief Toggles preselection (highlighting) on/off
+*/
+void OCCViewer_ViewWindow::onSwitchPreselection( bool on )
+{
+  myPreselectionEnabled = on;
+  myModel->setSelectionOptions( isPreselectionEnabled(), myModel->isSelectionEnabled() );
+
+  // unhighlight all highlighted objects
+  /*if ( !on ) {
+    myModel->unHighlightAll( true, false );
+  }*/
+
+  // update action state if method is called outside
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );
+  if ( a && a->isChecked() != on ) {
+    a->setChecked( on );
+  }
+}
+
+/*!
+  \brief Toggles selection on/off
+*/
+void OCCViewer_ViewWindow::onSwitchSelection( bool on )
+{
+  mySelectionEnabled = on;
+  myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() );
+  
+  // update action state if method is called outside
+
+  // preselection
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchPreselectionId ) );
+  if ( a ) {
+    a->setEnabled( on );
+  }
+
+  // selection
+  a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchSelectionId ) );
+  if ( a && a->isChecked() != on ) {
+    a->setChecked( on );
+  }
+}
+
+/*!
+  \brief Switches "keyboard free" interaction style on/off
+*/
+void OCCViewer_ViewWindow::onSwitchInteractionStyle( bool on )
+{
+  myInteractionStyle = on ? (int)SUIT_ViewModel::KEY_FREE : (int)SUIT_ViewModel::STANDARD;
+
+  // update action state if method is called outside
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchInteractionStyleId ) );
+  if ( a->isChecked() != on )
+    a->setChecked( on );
+}
+
+/*!
+  \brief Toogles advanced zooming style (relatively to the cursor position) on/off
+*/
+void OCCViewer_ViewWindow::onSwitchZoomingStyle( bool on )
+{
+  myViewPort->setAdvancedZoomingEnabled( on );
+
+  // update action state if method is called outside
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
+  if ( a->isChecked() != on )
+    a->setChecked( on );
+}
+
+/*!
+  \brief Get current interaction style
+  \return interaction style
+*/
+int OCCViewer_ViewWindow::interactionStyle() const
+{
+  return myInteractionStyle;
+}
+
+/*!
+  \brief Set current interaction style
+  \param theStyle interaction style
+*/
+void OCCViewer_ViewWindow::setInteractionStyle( const int theStyle )
+{
+  onSwitchInteractionStyle( theStyle == (int)SUIT_ViewModel::KEY_FREE );
+}
+
+/*!
+  \brief Get current zooming style
+  \return zooming style
+*/
+int OCCViewer_ViewWindow::zoomingStyle() const
+{
+  return myViewPort->isAdvancedZoomingEnabled() ? 1 : 0;
+}
+
+/*!
+  \brief Set current zooming style
+  \param theStyle zooming style
+*/
+void OCCViewer_ViewWindow::setZoomingStyle( const int theStyle )
+{
+  onSwitchZoomingStyle( theStyle == 1 );
+}
+
+/*!
+  \brief Dump view window contents to the pixmap.
+  \return pixmap containing all scene rendered in the window
+*/
+QImage OCCViewer_ViewWindow::dumpView()
+{
+  Handle(V3d_View) view = myViewPort->getView();
+  if ( view.IsNull() )
+    return QImage();
+  
+  int aWidth = myViewPort->width();
+  int aHeight = myViewPort->height();
+  QApplication::syncX();
+  view->Redraw(); // In order to reactivate GL context
+  //view->Update();
+
+  OpenGLUtils_FrameBuffer aFrameBuffer;
+  if( aFrameBuffer.init( aWidth, aHeight ) )
+  {
+    QImage anImage( aWidth, aHeight, QImage::Format_RGB32 );
+   
+    glPushAttrib( GL_VIEWPORT_BIT );
+    glViewport( 0, 0, aWidth, aHeight );
+    aFrameBuffer.bind();
+
+    // draw scene
+    view->Redraw();
+
+    aFrameBuffer.unbind();
+    glPopAttrib();
+
+    aFrameBuffer.bind();
+    glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() );
+    aFrameBuffer.unbind();
+
+    anImage = anImage.rgbSwapped();
+    anImage = anImage.mirrored();
+    return anImage;
+  }
+  // if frame buffers are unsupported, use old functionality
+  //view->Redraw();
+
+  unsigned char* data = new unsigned char[ aWidth*aHeight*4 ];
+
+  QPoint p = myViewPort->mapFromParent(myViewPort->geometry().topLeft());
+
+  glReadPixels( p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE,
+                data);
+
+  QImage anImage( data, aWidth, aHeight, QImage::Format_ARGB32 );
+  anImage = anImage.mirrored();
+  anImage = anImage.rgbSwapped();
+  return anImage;
+}
+
+bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, 
+                                             const QString& fileName, 
+                                             const QString& format )
+{
+  if ( format != "PS" && format != "EPS")
+    return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
+
+  Handle(Visual3d_View) a3dView = myViewPort->getView()->View();
+
+  if (format == "PS")
+    a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_PostScript);
+  else if (format == "EPS")
+    a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_EnhPostScript);
+
+  return true;
+}
+
+
+QString OCCViewer_ViewWindow::filter() const
+{
+  return tr( "OCC_IMAGE_FILES" );
+}
+
+
+/*!
+  \brief Set parameters of the cutting plane
+  \param on if \c true, cutting plane is enabled
+  \param x X position of plane point
+  \param y Y position of plane point
+  \param z Z position of plane point
+  \param dx X coordinate of plane normal
+  \param dy Y coordinate of plane normal
+  \param dz Z coordinate of plane normal
+*/
+void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x,  const double y,  const double z,
+                                            const double dx, const double dy, const double dz )
+{
+  Handle(V3d_View) view = myViewPort->getView();
+  if ( view.IsNull() )
+    return;
+
+  if ( on ) {
+    Handle(V3d_Viewer) viewer = myViewPort->getViewer();
+
+    // try to use already existing plane or create a new one
+    Handle(V3d_Plane) clipPlane;
+
+    // calculate new a,b,c,d values for the plane
+    gp_Pln pln (gp_Pnt(x, y, z), gp_Dir(dx, dy, dz));
+    double a, b, c, d;
+    pln.Coefficients(a, b, c, d);
+    
+    Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
+    Handle(Graphic3d_ClipPlane) aClipPlane;
+    if(aPlanes.Size() > 0 ) {
+      Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+      aClipPlane = anIter.Value();
+      aClipPlane->SetEquation(pln);
+      aClipPlane->SetOn(Standard_True);
+    } else {
+      aClipPlane = new Graphic3d_ClipPlane(pln);
+      view->AddClipPlane(aClipPlane);
+      aClipPlane->SetOn(Standard_True);
+    }
+  }
+  else {
+    Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
+    Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+    for( ;anIter.More();anIter.Next() ){
+      Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
+      aClipPlane->SetOn(Standard_False);
+    }
+  }
+
+  view->Update();
+  view->Redraw();
+}
+
+void OCCViewer_ViewWindow::setCuttingPlane( bool on, const gp_Pln pln )
+{
+  gp_Dir aDir = pln.Axis().Direction();
+  gp_Pnt aPnt = pln.Location();
+  setCuttingPlane(on, aPnt.X(), aPnt.Y(), aPnt.Z(), aDir.X(), aDir.Y(), aDir.Z());
+}
+
+
+/*!
+  \brief Check if any cutting plane is enabled
+  \return \c true if at least one cutting plane is enabled
+*/
+bool OCCViewer_ViewWindow::isCuttingPlane()
+{
+  Handle(V3d_View) view = myViewPort->getView();
+  bool res = false;
+  Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
+  Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+  for( ;anIter.More();anIter.Next() ) {
+    Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
+    if(aClipPlane->IsOn()) {
+      res = true;
+      break;
+    }
+  }
+  return res;
+}
+
+/*!
+  \brief Get the visual parameters of the view window.
+  \return visual parameters of view window
+*/
+viewAspect OCCViewer_ViewWindow::getViewParams() const
+{
+  double projX, projY, projZ, twist;
+  double atX, atY, atZ, eyeX, eyeY, eyeZ;
+  double aScaleX, aScaleY, aScaleZ;
+
+  Handle(V3d_View) aView3d = myViewPort->getView();
+
+  aView3d->Proj( projX, projY, projZ );
+  aView3d->At( atX, atY, atZ );
+  aView3d->Eye( eyeX, eyeY, eyeZ );
+  twist = aView3d->Twist();
+
+  aView3d->AxialScale(aScaleX,aScaleY,aScaleZ);
+
+  bool isShown = myModel->isTrihedronVisible();
+  double size = myModel->trihedronSize();
+
+  QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" );
+
+  viewAspect params;
+  params.scale    = aView3d->Scale();
+  params.projX    = projX;
+  params.projY    = projY;
+  params.projZ    = projZ;
+  params.twist    = twist;
+  params.atX      = atX;
+  params.atY      = atY;
+  params.atZ      = atZ;
+  params.eyeX     = eyeX;
+  params.eyeY     = eyeY;
+  params.eyeZ     = eyeZ;
+  params.scaleX   = aScaleX;
+  params.scaleY   = aScaleY;
+  params.scaleZ   = aScaleZ;
+  params.name     = aName;
+  params.isVisible= isShown;
+  params.size     = size;
+
+#if OCC_VERSION_LARGE <= 0x06070100 // the property is deprecated after OCCT 6.7.1
+  aView3d->Center( params.centerX, params.centerY );
+#endif
+
+#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version
+  // graduated trihedron
+  bool anIsVisible = false;
+  OCCViewer_AxisWidget::AxisData anAxisData[3];
+  myCubeAxesDlg->GetData( anIsVisible, anAxisData );
+
+  params.gtIsVisible = anIsVisible;
+  params.gtDrawNameX = anAxisData[0].DrawName;
+  params.gtDrawNameY = anAxisData[1].DrawName;
+  params.gtDrawNameZ = anAxisData[2].DrawName;
+  params.gtNameX = anAxisData[0].Name;
+  params.gtNameY = anAxisData[1].Name;
+  params.gtNameZ = anAxisData[2].Name;
+  params.gtNameColorRX = anAxisData[0].NameColor.red();
+  params.gtNameColorGX = anAxisData[0].NameColor.green();
+  params.gtNameColorBX = anAxisData[0].NameColor.blue();
+  params.gtNameColorRY = anAxisData[1].NameColor.red();
+  params.gtNameColorGY = anAxisData[1].NameColor.green();
+  params.gtNameColorBY = anAxisData[1].NameColor.blue();
+  params.gtNameColorRZ = anAxisData[2].NameColor.red();
+  params.gtNameColorGZ = anAxisData[2].NameColor.green();
+  params.gtNameColorBZ = anAxisData[2].NameColor.blue();
+  params.gtDrawValuesX = anAxisData[0].DrawValues;
+  params.gtDrawValuesY = anAxisData[1].DrawValues;
+  params.gtDrawValuesZ = anAxisData[2].DrawValues;
+  params.gtNbValuesX = anAxisData[0].NbValues;
+  params.gtNbValuesY = anAxisData[1].NbValues;
+  params.gtNbValuesZ = anAxisData[2].NbValues;
+  params.gtOffsetX = anAxisData[0].Offset;
+  params.gtOffsetY = anAxisData[1].Offset;
+  params.gtOffsetZ = anAxisData[2].Offset;
+  params.gtColorRX = anAxisData[0].Color.red();
+  params.gtColorGX = anAxisData[0].Color.green();
+  params.gtColorBX = anAxisData[0].Color.blue();
+  params.gtColorRY = anAxisData[1].Color.red();
+  params.gtColorGY = anAxisData[1].Color.green();
+  params.gtColorBY = anAxisData[1].Color.blue();
+  params.gtColorRZ = anAxisData[2].Color.red();
+  params.gtColorGZ = anAxisData[2].Color.green();
+  params.gtColorBZ = anAxisData[2].Color.blue();
+  params.gtDrawTickmarksX = anAxisData[0].DrawTickmarks;
+  params.gtDrawTickmarksY = anAxisData[1].DrawTickmarks;
+  params.gtDrawTickmarksZ = anAxisData[2].DrawTickmarks;
+  params.gtTickmarkLengthX = anAxisData[0].TickmarkLength;
+  params.gtTickmarkLengthY = anAxisData[1].TickmarkLength;
+  params.gtTickmarkLengthZ = anAxisData[2].TickmarkLength;
+#endif
+
+  return params;
+}
+
+/*!
+  \brief Get visual parameters of this view window.
+  \return visual parameters of view window
+*/
+QString OCCViewer_ViewWindow::getVisualParameters()
+{
+  viewAspect params = getViewParams();
+
+  QStringList data;
+
+  data << QString( "scale=%1" )    .arg( params.scale,   0, 'e', 12 );
+#if OCC_VERSION_LARGE <= 0x06070100 // the property is deprecated after OCCT 6.7.1
+  data << QString( "centerX=%1" )  .arg( params.centerX, 0, 'e', 12 );
+  data << QString( "centerY=%1" )  .arg( params.centerY, 0, 'e', 12 );
+#endif
+  data << QString( "projX=%1" )    .arg( params.projX,   0, 'e', 12 );
+  data << QString( "projY=%1" )    .arg( params.projY,   0, 'e', 12 );
+  data << QString( "projZ=%1" )    .arg( params.projZ,   0, 'e', 12 );
+  data << QString( "twist=%1" )    .arg( params.twist,   0, 'e', 12 );
+  data << QString( "atX=%1" )      .arg( params.atX,     0, 'e', 12 );
+  data << QString( "atY=%1" )      .arg( params.atY,     0, 'e', 12 );
+  data << QString( "atZ=%1" )      .arg( params.atZ,     0, 'e', 12 );
+  data << QString( "eyeX=%1" )     .arg( params.eyeX,    0, 'e', 12 );
+  data << QString( "eyeY=%1" )     .arg( params.eyeY,    0, 'e', 12 );
+  data << QString( "eyeZ=%1" )     .arg( params.eyeZ,    0, 'e', 12 );
+  data << QString( "scaleX=%1" )   .arg( params.scaleX,  0, 'e', 12 );
+  data << QString( "scaleY=%1" )   .arg( params.scaleY,  0, 'e', 12 );
+  data << QString( "scaleZ=%1" )   .arg( params.scaleZ,  0, 'e', 12 );
+  data << QString( "isVisible=%1" ).arg( params.isVisible );
+  data << QString( "size=%1" )     .arg( params.size,    0, 'f',  2 );
+
+  ClipPlanesList aPlanes =  myModel->getClipPlanes();
+  for ( int i=0; i < aPlanes.size(); i++ )
+  {
+    OCCViewer_ClipPlane& aPlane = aPlanes[i];
+    QString ClippingPlane = QString( "ClippingPlane%1=").arg( i+1 );
+    ClippingPlane +=  QString( "Mode~%1;").arg( (int)aPlane.Mode );
+    ClippingPlane +=  QString( "IsActive~%1;").arg( aPlane.IsOn );
+    switch ( aPlane.Mode )
+    {
+      case OCCViewer_ClipPlane::Absolute :
+      {
+        ClippingPlane += QString( "AbsoluteOrientation~%1;" ).arg( aPlane.OrientationType );
+
+        if ( aPlane.OrientationType == OCCViewer_ClipPlane::AbsoluteCustom )
+        {
+          ClippingPlane += QString( "Dx~%1;" ).arg( aPlane.AbsoluteOrientation.Dx );
+          ClippingPlane += QString( "Dy~%1;" ).arg( aPlane.AbsoluteOrientation.Dy );
+          ClippingPlane += QString( "Dz~%1;" ).arg( aPlane.AbsoluteOrientation.Dz );
+        }
+        else
+        {
+          ClippingPlane += QString( "IsInvert~%1;" ).arg( aPlane.AbsoluteOrientation.IsInvert );
+        }
+      }
+      break;
+
+      case OCCViewer_ClipPlane::Relative :
+      {
+        ClippingPlane += QString( "RelativeOrientation~%1;" ).arg( aPlane.OrientationType );
+        ClippingPlane += QString( "Rotation1~%1;" ).arg( aPlane.RelativeOrientation.Rotation1 );
+        ClippingPlane += QString( "Rotation2~%1" ).arg( aPlane.RelativeOrientation.Rotation2 );
+      }
+      break;
+    }
+
+    ClippingPlane +=  QString( "X~%1;" ).arg( aPlane.X );
+    ClippingPlane +=  QString( "Y~%1;" ).arg( aPlane.Y );
+    ClippingPlane +=  QString( "Z~%1;" ).arg( aPlane.Z );
+    data << ClippingPlane;
+  }
+
+
+#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 or newer version
+  // graduated trihedron
+  data << QString( "gtIsVisible=%1" )      .arg( params.gtIsVisible );
+  data << QString( "gtDrawNameX=%1" )      .arg( params.gtDrawNameX );
+  data << QString( "gtDrawNameY=%1" )      .arg( params.gtDrawNameY );
+  data << QString( "gtDrawNameZ=%1" )      .arg( params.gtDrawNameZ );
+  data << QString( "gtNameX=%1" )          .arg( params.gtNameX );
+  data << QString( "gtNameY=%1" )          .arg( params.gtNameY );
+  data << QString( "gtNameZ=%1" )          .arg( params.gtNameZ );
+  data << QString( "gtNameColorRX=%1" )    .arg( params.gtNameColorRX );
+  data << QString( "gtNameColorGX=%1" )    .arg( params.gtNameColorGX );
+  data << QString( "gtNameColorBX=%1" )    .arg( params.gtNameColorBX );
+  data << QString( "gtNameColorRY=%1" )    .arg( params.gtNameColorRY );
+  data << QString( "gtNameColorGY=%1" )    .arg( params.gtNameColorGY );
+  data << QString( "gtNameColorBY=%1" )    .arg( params.gtNameColorBY );
+  data << QString( "gtNameColorRZ=%1" )    .arg( params.gtNameColorRZ );
+  data << QString( "gtNameColorGZ=%1" )    .arg( params.gtNameColorGZ );
+  data << QString( "gtNameColorBZ=%1" )    .arg( params.gtNameColorBZ );
+  data << QString( "gtDrawValuesX=%1" )    .arg( params.gtDrawValuesX );
+  data << QString( "gtDrawValuesY=%1" )    .arg( params.gtDrawValuesY );
+  data << QString( "gtDrawValuesZ=%1" )    .arg( params.gtDrawValuesZ );
+  data << QString( "gtNbValuesX=%1" )      .arg( params.gtNbValuesX );
+  data << QString( "gtNbValuesY=%1" )      .arg( params.gtNbValuesY );
+  data << QString( "gtNbValuesZ=%1" )      .arg( params.gtNbValuesZ );
+  data << QString( "gtOffsetX=%1" )        .arg( params.gtOffsetX );
+  data << QString( "gtOffsetY=%1" )        .arg( params.gtOffsetY );
+  data << QString( "gtOffsetZ=%1" )        .arg( params.gtOffsetZ );
+  data << QString( "gtColorRX=%1" )        .arg( params.gtColorRX );
+  data << QString( "gtColorGX=%1" )        .arg( params.gtColorGX );
+  data << QString( "gtColorBX=%1" )        .arg( params.gtColorBX );
+  data << QString( "gtColorRY=%1" )        .arg( params.gtColorRY );
+  data << QString( "gtColorGY=%1" )        .arg( params.gtColorGY );
+  data << QString( "gtColorBY=%1" )        .arg( params.gtColorBY );
+  data << QString( "gtColorRZ=%1" )        .arg( params.gtColorRZ );
+  data << QString( "gtColorGZ=%1" )        .arg( params.gtColorGZ );
+  data << QString( "gtColorBZ=%1" )        .arg( params.gtColorBZ );
+  data << QString( "gtDrawTickmarksX=%1" ) .arg( params.gtDrawTickmarksX );
+  data << QString( "gtDrawTickmarksY=%1" ) .arg( params.gtDrawTickmarksY );
+  data << QString( "gtDrawTickmarksZ=%1" ) .arg( params.gtDrawTickmarksZ );
+  data << QString( "gtTickmarkLengthX=%1" ).arg( params.gtTickmarkLengthX );
+  data << QString( "gtTickmarkLengthY=%1" ).arg( params.gtTickmarkLengthY );
+  data << QString( "gtTickmarkLengthZ=%1" ).arg( params.gtTickmarkLengthZ );
+#endif
+  QString bg = Qtx::backgroundToString( background() ).replace( "=", "$" );
+  data << QString( "background=%1" ).arg( bg );
+
+  return data.join("*");
+}
+
+/*!
+  \brief Restore visual parameters of the view window.
+  \param parameters visual parameters of view window
+*/
+void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters )
+{
+  viewAspect params;
+  ClipPlanesList aClipPlanes;
+  QStringList data = parameters.split( '*' );
+  Qtx::BackgroundData bgData;
+  if ( parameters.contains( '=' )  ) // new format - "scale=1.000e+00*centerX=0.000e+00..."
+  {
+    foreach( QString param, data ) {
+      QString paramName  = param.section( '=', 0, 0 ).trimmed();
+      QString paramValue = param.section( '=', 1, 1 ).trimmed();
+      if      ( paramName == "scale" )             params.scale             = paramValue.toDouble();
+      else if ( paramName == "centerX" )           params.centerX           = paramValue.toDouble();
+      else if ( paramName == "centerY" )           params.centerY           = paramValue.toDouble();
+      else if ( paramName == "projX" )             params.projX             = paramValue.toDouble();
+      else if ( paramName == "projY" )             params.projY             = paramValue.toDouble();
+      else if ( paramName == "projZ" )             params.projZ             = paramValue.toDouble();
+      else if ( paramName == "twist" )             params.twist             = paramValue.toDouble();
+      else if ( paramName == "atX" )               params.atX               = paramValue.toDouble();
+      else if ( paramName == "atY" )               params.atY               = paramValue.toDouble();
+      else if ( paramName == "atZ" )               params.atZ               = paramValue.toDouble();
+      else if ( paramName == "eyeX" )              params.eyeX              = paramValue.toDouble();
+      else if ( paramName == "eyeY" )              params.eyeY              = paramValue.toDouble();
+      else if ( paramName == "eyeZ" )              params.eyeZ              = paramValue.toDouble();
+      else if ( paramName == "scaleX" )            params.scaleX            = paramValue.toDouble();
+      else if ( paramName == "scaleY" )            params.scaleY            = paramValue.toDouble();
+      else if ( paramName == "scaleZ" )            params.scaleZ            = paramValue.toDouble();
+      else if ( paramName == "isVisible" )         params.isVisible         = paramValue.toInt();
+      else if ( paramName == "size" )              params.size              = paramValue.toDouble();
+      else if ( paramName.contains( "ClippingPlane" ) )
+      {
+        QStringList ClipPlaneData = paramValue.split( ';' );
+        OCCViewer_ClipPlane aPlane;
+        foreach( QString ClipPlaneParam, ClipPlaneData )
+        {
+          QString ClipPlane_paramName  = ClipPlaneParam.section( '~', 0, 0 ).trimmed();
+          QString ClipPlane_paramValue = ClipPlaneParam.section( '~', 1, 1 ).trimmed();
+          if ( ClipPlane_paramName == "Mode" )
+          {
+            aPlane.Mode = ( OCCViewer_ClipPlane::PlaneMode ) ClipPlane_paramValue.toInt();
+          }
+          else if ( ClipPlane_paramName == "IsActive" ) aPlane.IsOn = ClipPlane_paramValue.toInt();
+          else if ( ClipPlane_paramName == "X" )        aPlane.X    = ClipPlane_paramValue.toDouble();
+          else if ( ClipPlane_paramName == "Y" )        aPlane.Y    = ClipPlane_paramValue.toDouble();
+          else if ( ClipPlane_paramName == "Z" )        aPlane.Z    = ClipPlane_paramValue.toDouble();
+          else
+          {
+            switch ( aPlane.Mode )
+            {
+              case OCCViewer_ClipPlane::Absolute :
+                if      ( ClipPlane_paramName == "Dx" ) aPlane.AbsoluteOrientation.Dx = ClipPlane_paramValue.toDouble();
+                else if ( ClipPlane_paramName == "Dy" ) aPlane.AbsoluteOrientation.Dy = ClipPlane_paramValue.toDouble();
+                else if ( ClipPlane_paramName == "Dz" ) aPlane.AbsoluteOrientation.Dz = ClipPlane_paramValue.toDouble();
+                else if ( ClipPlane_paramName == "IsInvert" ) aPlane.AbsoluteOrientation.IsInvert = ClipPlane_paramValue.toInt();
+                else if ( ClipPlane_paramName == "AbsoluteOrientation" ) aPlane.OrientationType = ClipPlane_paramValue.toInt();
+                break;
+
+              case OCCViewer_ClipPlane::Relative :
+                if      ( ClipPlane_paramName == "RelativeOrientation" ) aPlane.OrientationType = ClipPlane_paramValue.toInt();
+                else if ( ClipPlane_paramName == "Rotation1" )           aPlane.RelativeOrientation.Rotation1 = ClipPlane_paramValue.toDouble();
+                else if ( ClipPlane_paramName == "Rotation2" )           aPlane.RelativeOrientation.Rotation2 = ClipPlane_paramValue.toDouble();
+                break;
+            }
+          }
+        }
+        aClipPlanes.push_back(aPlane);
+      }
+      // graduated trihedron
+      else if ( paramName == "gtIsVisible" )       params.gtIsVisible       = paramValue.toInt();
+      else if ( paramName == "gtDrawNameX" )       params.gtDrawNameX       = paramValue.toInt();
+      else if ( paramName == "gtDrawNameY" )       params.gtDrawNameY       = paramValue.toInt();
+      else if ( paramName == "gtDrawNameZ" )       params.gtDrawNameZ       = paramValue.toInt();
+      else if ( paramName == "gtNameX" )           params.gtNameX           = paramValue;
+      else if ( paramName == "gtNameY" )           params.gtNameY           = paramValue;
+      else if ( paramName == "gtNameZ" )           params.gtNameZ           = paramValue;
+      else if ( paramName == "gtNameColorRX" )     params.gtNameColorRX     = paramValue.toInt();
+      else if ( paramName == "gtNameColorGX" )     params.gtNameColorGX     = paramValue.toInt();
+      else if ( paramName == "gtNameColorBX" )     params.gtNameColorBX     = paramValue.toInt();
+      else if ( paramName == "gtNameColorRY" )     params.gtNameColorRY     = paramValue.toInt();
+      else if ( paramName == "gtNameColorGY" )     params.gtNameColorGY     = paramValue.toInt();
+      else if ( paramName == "gtNameColorBY" )     params.gtNameColorBY     = paramValue.toInt();
+      else if ( paramName == "gtNameColorRZ" )     params.gtNameColorRZ     = paramValue.toInt();
+      else if ( paramName == "gtNameColorGZ" )     params.gtNameColorGZ     = paramValue.toInt();
+      else if ( paramName == "gtNameColorBZ" )     params.gtNameColorBZ     = paramValue.toInt();
+      else if ( paramName == "gtDrawValuesX" )     params.gtDrawValuesX     = paramValue.toInt();
+      else if ( paramName == "gtDrawValuesY" )     params.gtDrawValuesY     = paramValue.toInt();
+      else if ( paramName == "gtDrawValuesZ" )     params.gtDrawValuesZ     = paramValue.toInt();
+      else if ( paramName == "gtNbValuesX" )       params.gtNbValuesX       = paramValue.toInt();
+      else if ( paramName == "gtNbValuesY" )       params.gtNbValuesY       = paramValue.toInt();
+      else if ( paramName == "gtNbValuesZ" )       params.gtNbValuesZ       = paramValue.toInt();
+      else if ( paramName == "gtOffsetX" )         params.gtOffsetX         = paramValue.toInt();
+      else if ( paramName == "gtOffsetY" )         params.gtOffsetY         = paramValue.toInt();
+      else if ( paramName == "gtOffsetZ" )         params.gtOffsetZ         = paramValue.toInt();
+      else if ( paramName == "gtColorRX" )         params.gtColorRX         = paramValue.toInt();
+      else if ( paramName == "gtColorGX" )         params.gtColorGX         = paramValue.toInt();
+      else if ( paramName == "gtColorBX" )         params.gtColorBX         = paramValue.toInt();
+      else if ( paramName == "gtColorRY" )         params.gtColorRY         = paramValue.toInt();
+      else if ( paramName == "gtColorGY" )         params.gtColorGY         = paramValue.toInt();
+      else if ( paramName == "gtColorBY" )         params.gtColorBY         = paramValue.toInt();
+      else if ( paramName == "gtColorRZ" )         params.gtColorRZ         = paramValue.toInt();
+      else if ( paramName == "gtColorGZ" )         params.gtColorGZ         = paramValue.toInt();
+      else if ( paramName == "gtColorBZ" )         params.gtColorBZ         = paramValue.toInt();
+      else if ( paramName == "gtDrawTickmarksX" )  params.gtDrawTickmarksX  = paramValue.toInt();
+      else if ( paramName == "gtDrawTickmarksY" )  params.gtDrawTickmarksY  = paramValue.toInt();
+      else if ( paramName == "gtDrawTickmarksZ" )  params.gtDrawTickmarksZ  = paramValue.toInt();
+      else if ( paramName == "gtTickmarkLengthX" ) params.gtTickmarkLengthX = paramValue.toInt();
+      else if ( paramName == "gtTickmarkLengthY" ) params.gtTickmarkLengthY = paramValue.toInt();
+      else if ( paramName == "gtTickmarkLengthZ" ) params.gtTickmarkLengthZ = paramValue.toInt();
+      else if ( paramName == "background" )        {
+  QString bg = paramValue.replace( "$", "=" );
+  bgData = Qtx::stringToBackground( bg );
+      }
+    }
+  }
+  else // old format - "1.000e+00*0.000e+00..."
+  {
+    int idx = 0;
+    params.scale     = data.count() > idx ? data[idx++].toDouble() : 1.0;
+    params.centerX   = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.centerY   = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.projX     = data.count() > idx ? data[idx++].toDouble() : sqrt(1./3);
+    params.projY     = data.count() > idx ? data[idx++].toDouble() : -sqrt(1./3);
+    params.projZ     = data.count() > idx ? data[idx++].toDouble() : sqrt(1./3);
+    params.twist     = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.atX       = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.atY       = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.atZ       = data.count() > idx ? data[idx++].toDouble() : 0.0;
+    params.eyeX      = data.count() > idx ? data[idx++].toDouble() : sqrt(250000./3);
+    params.eyeY      = data.count() > idx ? data[idx++].toDouble() : -sqrt(250000./3);
+    params.eyeZ      = data.count() > idx ? data[idx++].toDouble() : sqrt(250000./3);
+    params.scaleX    = data.count() > idx ? data[idx++].toDouble() : 1.0;
+    params.scaleY    = data.count() > idx ? data[idx++].toDouble() : 1.0;
+    params.scaleZ    = data.count() > idx ? data[idx++].toDouble() : 1.0;
+    params.isVisible = data.count() > idx ? data[idx++].toInt()    : 1;
+    params.size      = data.count() > idx ? data[idx++].toDouble() : 100.0;
+  }
+  performRestoring( params );  
+  setBackground( bgData );
+  myModel->setClipPlanes(aClipPlanes);
+}
+
+/*!
+  \brief Handle show event.
+
+  Emits Show() signal.
+
+  \param theEvent show event
+*/
+void OCCViewer_ViewWindow::showEvent( QShowEvent* theEvent )
+{
+  emit Show( theEvent );
+}
+
+/*!
+  \brief Handle hide event.
+
+  Emits Hide() signal.
+
+  \param theEvent hide event
+*/
+void OCCViewer_ViewWindow::hideEvent( QHideEvent* theEvent )
+{
+  emit Hide( theEvent );
+}
+
+
+/*!
+    Creates default sketcher. [ virtual protected ]
+*/
+OCCViewer_ViewSketcher* OCCViewer_ViewWindow::createSketcher( int type )
+{
+  if ( type == Rect )
+    return new OCCViewer_RectSketcher( this, type );
+  if ( type == Polygon )
+    return new OCCViewer_PolygonSketcher( this, type );
+  return 0;
+}
+
+void OCCViewer_ViewWindow::initSketchers()
+{
+  if ( mySketchers.isEmpty() )
+  {
+    mySketchers.append( createSketcher( Rect ) );
+    mySketchers.append( createSketcher( Polygon ) );
+  }
+}
+
+OCCViewer_ViewSketcher* OCCViewer_ViewWindow::getSketcher( const int typ )
+{
+  OCCViewer_ViewSketcher* sketcher = 0;
+  QList<OCCViewer_ViewSketcher*>::Iterator it;
+  for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )
+  {
+    OCCViewer_ViewSketcher* sk = (*it);
+    if ( sk->type() == typ )
+      sketcher = sk;
+  }
+  return sketcher;
+}
+
+/*!
+    Handles requests for sketching in the active view. [ virtual public ]
+*/
+void OCCViewer_ViewWindow::activateSketching( int type )
+{
+  OCCViewer_ViewPort3d* vp = getViewPort();
+  if ( !vp )
+    return;
+
+  if ( !vp->isSketchingEnabled() )
+    return;
+
+  /* Finish current sketching */
+  if ( type == NoSketching )
+  {
+    if ( mypSketcher )
+    {
+      onSketchingFinished();
+      mypSketcher->deactivate();
+      mypSketcher = 0;
+    }
+  }
+  /* Activate new sketching */
+  else
+  {
+    activateSketching( NoSketching );  /* concurrency not suported */
+    mypSketcher = getSketcher( type );
+    if ( mypSketcher )
+    {
+      mypSketcher->activate();
+      onSketchingStarted();
+    }
+  }
+}
+
+/*!
+    Unhilights detected entities. [ virtual protected ]
+*/
+void OCCViewer_ViewWindow::onSketchingStarted()
+{
+}
+
+/*!
+    Selection by rectangle or polygon. [ virtual protected ]
+*/
+void OCCViewer_ViewWindow::onSketchingFinished()
+{
+  MESSAGE("OCCViewer_ViewWindow::onSketchingFinished()")
+  if ( mypSketcher && mypSketcher->result() == OCCViewer_ViewSketcher::Accept )
+  {
+    Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+    bool append = bool( mypSketcher->buttonState() && mypSketcher->isHasShift() );
+    switch( mypSketcher->type() )
+    {
+    case Rect:
+      {
+        QRect* aRect = (QRect*)mypSketcher->data();
+        if( aRect )
+        {
+          int aLeft = aRect->left();
+          int aRight = aRect->right();
+          int aTop = aRect->top();
+          int aBottom = aRect->bottom();
+//           myRect = aRect;
+
+          if( append )
+            ic->ShiftSelect( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );
+          else
+            ic->Select( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );
+        }
+      }
+      break;
+    case Polygon:
+      {
+        QPolygon* aPolygon = (QPolygon*)mypSketcher->data();
+        if( aPolygon )
+        {
+          int size = aPolygon->size();
+          TColgp_Array1OfPnt2d anArray( 1, size );
+
+          QPolygon::Iterator it = aPolygon->begin();
+          QPolygon::Iterator itEnd = aPolygon->end();
+          for( int index = 1; it != itEnd; ++it, index++ )
+          {
+            QPoint aPoint = *it;
+            anArray.SetValue( index, gp_Pnt2d( aPoint.x(), aPoint.y() ) );
+          }
+
+          if( append )
+            ic->ShiftSelect( anArray, getViewPort()->getView(), Standard_False );
+          else
+            ic->Select( anArray, getViewPort()->getView(), Standard_False );
+        }
+      }
+      break;
+    default:
+      break;
+    }
+
+    OCCViewer_ViewManager* aViewMgr = ( OCCViewer_ViewManager* )getViewManager();
+    aViewMgr->getOCCViewer()->performSelectionChanged();
+  }
+}
+
+OCCViewer_ViewPort3d* OCCViewer_ViewWindow::getViewPort()
+{
+  return myViewPort;
+}
+
+bool OCCViewer_ViewWindow::transformRequested() const
+{
+  return ( myOperation != NOTHING );
+}
+
+bool OCCViewer_ViewWindow::transformInProcess() const
+{
+  return myEventStarted;
+}
+
+void OCCViewer_ViewWindow::setTransformInProcess( bool bOn )
+{
+  myEventStarted = bOn;
+}
+
+/*!
+  Set enabled state of transformation (rotate, zoom, etc)
+*/
+void OCCViewer_ViewWindow::setTransformEnabled( const OperationType id, const bool on )
+{
+  if ( id != NOTHING ) myStatus.insert( id, on );
+}
+
+/*!
+  \return enabled state of transformation (rotate, zoom, etc)
+*/
+bool OCCViewer_ViewWindow::transformEnabled( const OperationType id ) const
+{
+  return myStatus.contains( id ) ? myStatus[ id ] : true;
+}
+
+void OCCViewer_ViewWindow::onMaximizedView()
+{
+  setMaximized(!isMaximized());
+}
+
+void OCCViewer_ViewWindow::returnTo3dView()
+{
+  setReturnedTo3dView( true );
+}
+
+void OCCViewer_ViewWindow::setReturnedTo3dView(bool isVisible3dView)
+{
+  if ( !toolMgr()->action( ReturnTo3dViewId ) ||
+    toolMgr()->isShown(ReturnTo3dViewId) != isVisible3dView ) return;
+  if ( !isVisible3dView )
+    toolMgr()->show( ReturnTo3dViewId );
+  else
+    toolMgr()->hide( ReturnTo3dViewId );
+  if ( isVisible3dView ) emit returnedTo3d( );
+}
+
+
+void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal)
+{
+  QAction* anAction =  toolMgr()->action( MaximizedId );
+  QAction* anAction2 =  toolMgr()->action( ReturnTo3dViewId );
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  if ( toMaximize ) {
+    anAction->setText( tr( "MNU_MINIMIZE_VIEW" ) );  
+    anAction->setToolTip( tr( "MNU_MINIMIZE_VIEW" ) );  
+    anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ) );
+    anAction->setStatusTip( tr( "DSC_MINIMIZE_VIEW" ) );
+    if ( anAction2 && my2dMode != No2dMode ) toolMgr()->show( ReturnTo3dViewId );
+    if (toSendSignal) {
+      emit maximized( this, true );
+    }
+  }
+  else {
+    anAction->setText( tr( "MNU_MAXIMIZE_VIEW" ) );  
+    anAction->setToolTip( tr( "MNU_MAXIMIZE_VIEW" ) );  
+    anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MAXIMIZE" ) ) );
+    anAction->setStatusTip( tr( "DSC_MAXIMIZE_VIEW" ) );
+    if ( anAction2 && my2dMode != No2dMode ) toolMgr()->hide( ReturnTo3dViewId );
+    if (toSendSignal) {
+      emit maximized( this, false );
+    }
+  }
+}
+
+bool OCCViewer_ViewWindow::isMaximized() const
+{
+  return !(toolMgr()->action( MaximizedId )->text() == tr( "MNU_MAXIMIZE_VIEW" ));
+}
+
+void OCCViewer_ViewWindow::setSketcherStyle( bool enable )
+{ 
+  IsSketcherStyle = enable; 
+}
+
+bool OCCViewer_ViewWindow::isSketcherStyle() const 
+{ 
+  return IsSketcherStyle; 
+}
+
+
+void OCCViewer_ViewWindow::set2dMode(Mode2dType theType)
+{
+  my2dMode = theType;
+}
+
+// obsolete   
+QColor OCCViewer_ViewWindow::backgroundColor() const
+{
+  return myViewPort ? myViewPort->backgroundColor() : Qt::black;
+}
+   
+// obsolete
+void OCCViewer_ViewWindow::setBackgroundColor( const QColor& theColor )
+{
+  if ( myViewPort ) myViewPort->setBackgroundColor( theColor );
+}
+
+Qtx::BackgroundData OCCViewer_ViewWindow::background() const
+{
+  return myViewPort ? myViewPort->background() : Qtx::BackgroundData();
+}
+   
+void OCCViewer_ViewWindow::setBackground( const Qtx::BackgroundData& theBackground )
+{
+  if ( myViewPort ) myViewPort->setBackground( theBackground );
+}
+
+void OCCViewer_ViewWindow::showStaticTrihedron( bool on )
+{
+  if ( myViewPort ) myViewPort->showStaticTrihedron( on );
+}
+
+/*!
+  Clears view aspects
+*/
+void OCCViewer_ViewWindow::clearViewAspects()
+{
+  myViewAspects.clear();
+}
+
+/*!
+  \return const reference to list of view aspects
+*/
+const viewAspectList& OCCViewer_ViewWindow::getViewAspects()
+{
+  return myViewAspects;
+}
+
+/*!
+  Appends new view aspect
+  \param aParams - new view aspects
+*/
+void OCCViewer_ViewWindow::appendViewAspect( const viewAspect& aParams )
+{
+  myViewAspects.append( aParams );
+}
+
+/*!
+  Replaces old view aspects by new ones
+  \param aViewList - list of new view aspects
+*/
+void OCCViewer_ViewWindow::updateViewAspects( const viewAspectList& aViewList )
+{
+  myViewAspects = aViewList;
+}
+
+/*!
+  Get camera properties for the OCC view window.
+  \return shared pointer on camera properties.
+*/
+SUIT_CameraProperties OCCViewer_ViewWindow::cameraProperties()
+{
+  SUIT_CameraProperties aProps;
+
+  Handle(V3d_View) aSourceView = getViewPort()->getView();
+  if ( aSourceView.IsNull() )
+    return aProps;
+
+  if ( get2dMode() == No2dMode ) {
+    aProps.setDimension( SUIT_CameraProperties::Dim3D );
+  }
+  else {
+    aProps.setDimension( SUIT_CameraProperties::Dim2D );
+    aProps.setViewSide( (SUIT_CameraProperties::ViewSide)(int)get2dMode() );
+  }
+
+  // read common properites of the view
+  Standard_Real anUp[3];
+  Standard_Real anAt[3];
+  Standard_Real anEye[3];
+  Standard_Real aProj[3];
+  Standard_Real anAxialScale[3];
+
+  aSourceView->Up( anUp[0], anUp[1], anUp[2] );
+  aSourceView->At( anAt[0], anAt[1], anAt[2] );
+  aSourceView->Proj( aProj[0], aProj[1], aProj[2] );
+  getViewPort()->getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
+
+  aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
+  aProps.setViewUp( anUp[0], anUp[1], anUp[2] );
+
+#if OCC_VERSION_LARGE > 0x06070100
+  aSourceView->Eye( anEye[0], anEye[1], anEye[2] );
+
+  // store camera properties "as is": it is up to synchronized
+  // view classes to provide necessary property conversion.
+  aProps.setPosition( anEye[0], anEye[1], anEye[2] );
+  aProps.setFocalPoint( anAt[0], anAt[1], anAt[2] );
+
+  if ( aSourceView->Camera()->IsOrthographic() )
+  {
+    aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );
+    aProps.setViewAngle( 0.0 );
+  }
+  else
+  {
+    aProps.setProjection( SUIT_CameraProperties::PrjPerspective );
+    aProps.setViewAngle( aSourceView->Camera()->FOVy() );
+  }
+  aProps.setMappingScale( aSourceView->Camera()->Scale() );
+#else
+  Standard_Real aCameraDepth = aSourceView->Depth() + aSourceView->ZSize() * 0.5;
+
+  // generate view orientation matrix for transforming OCC projection reference point
+  // into a camera (eye) position.
+  gp_Dir aLeftDir = gp_Dir( anUp[0], anUp[1], anUp[2] ) ^ gp_Dir( aProj[0], aProj[1], aProj[2] );
+
+  gp_GTrsf aTrsf;
+  aTrsf.SetValue( 1, 1, aLeftDir.X() );
+  aTrsf.SetValue( 2, 1, aLeftDir.Y() );
+  aTrsf.SetValue( 3, 1, aLeftDir.Z() );
+
+  aTrsf.SetValue( 1, 2, anUp[0] );
+  aTrsf.SetValue( 2, 2, anUp[1] );
+  aTrsf.SetValue( 3, 2, anUp[2] );
+
+  aTrsf.SetValue( 1, 3, aProj[0] );
+  aTrsf.SetValue( 2, 3, aProj[1] );
+  aTrsf.SetValue( 3, 3, aProj[2] );
+
+  aTrsf.SetValue( 1, 4, anAt[0] );
+  aTrsf.SetValue( 2, 4, anAt[1] );
+  aTrsf.SetValue( 3, 4, anAt[2] );
+
+  Graphic3d_Vertex aProjRef = aSourceView->ViewMapping().ProjectionReferencePoint();
+
+  // transform to world-space coordinate system
+  gp_XYZ aPosition( aProjRef.X(), aProjRef.Y(), aCameraDepth );
+  aTrsf.Transforms( aPosition );
+
+  // compute focal point
+  double aFocalPoint[3];
+
+  aFocalPoint[0] = aPosition.X() - aProj[0] * aCameraDepth;
+  aFocalPoint[1] = aPosition.Y() - aProj[1] * aCameraDepth;
+  aFocalPoint[2] = aPosition.Z() - aProj[2] * aCameraDepth;
+
+  aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
+  aProps.setPosition( aPosition.X(), aPosition.Y(), aPosition.Z() );
+
+  Standard_Real aViewScale[2];
+  aSourceView->Size( aViewScale[0], aViewScale[1] );
+  aProps.setMappingScale( aViewScale[1] );
+#endif
+
+  return aProps;
+}
+
+/*!
+  Synchronize views.
+  This implementation synchronizes OCC view's camera propreties.
+*/
+void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView )
+{
+  bool blocked = blockSignals( true );
+
+  SUIT_CameraProperties aProps = theView->cameraProperties();
+  if ( !cameraProperties().isCompatible( aProps ) ) {
+    // other view, this one is being currently synchronized to, seems has become incompatible
+    // we have to break synchronization
+    updateSyncViews();
+    return;
+  }
+
+  Handle(V3d_View) aDestView = getViewPort()->getView();
+
+  aDestView->SetImmediateUpdate( Standard_False );
+
+  double anUpDir[3];
+  double aPosition[3];
+  double aFocalPoint[3];
+  double anAxialScale[3];
+
+  // get common properties
+  aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
+  aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] );
+  aProps.getViewUp( anUpDir[0], anUpDir[1], anUpDir[2] );
+  aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
+
+#if OCC_VERSION_LARGE > 0x06070100
+  aDestView->SetAt( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] );
+  aDestView->SetEye( aPosition[0], aPosition[1], aPosition[2] );
+  aDestView->SetUp( anUpDir[0], anUpDir[1], anUpDir[2] );
+  aDestView->Camera()->SetScale( aProps.getMappingScale() );
+#else
+  gp_Dir aProjDir( aPosition[0] - aFocalPoint[0],
+                   aPosition[1] - aFocalPoint[1],
+                   aPosition[2] - aFocalPoint[2] );
+
+  // get custom view translation
+  Standard_Real aTranslation[3];
+  aDestView->At( aTranslation[0], aTranslation[1], aTranslation[2] );
+
+  gp_Dir aLeftDir = gp_Dir( anUpDir[0], anUpDir[1], anUpDir[2] )
+                  ^ gp_Dir( aProjDir.X(), aProjDir.Y(), aProjDir.Z() );
+
+  gp_GTrsf aTrsf;
+  aTrsf.SetValue( 1, 1, aLeftDir.X() );
+  aTrsf.SetValue( 2, 1, aLeftDir.Y() );
+  aTrsf.SetValue( 3, 1, aLeftDir.Z() );
+
+  aTrsf.SetValue( 1, 2, anUpDir[0] );
+  aTrsf.SetValue( 2, 2, anUpDir[1] );
+  aTrsf.SetValue( 3, 2, anUpDir[2] );
+
+  aTrsf.SetValue( 1, 3, aProjDir.X() );
+  aTrsf.SetValue( 2, 3, aProjDir.Y() );
+  aTrsf.SetValue( 3, 3, aProjDir.Z() );
+
+  aTrsf.SetValue( 1, 4, aTranslation[0] );
+  aTrsf.SetValue( 2, 4, aTranslation[1] );
+  aTrsf.SetValue( 3, 4, aTranslation[2] );
+  aTrsf.Invert();
+
+  // transform to view-space coordinate system
+  gp_XYZ aProjRef( aPosition[0], aPosition[1], aPosition[2] );
+  aTrsf.Transforms( aProjRef );
+
+  // set view camera properties using low-level approach. this is done
+  // in order to avoid interference with static variables in v3d view used
+  // when rotation is in process in another view.
+  Visual3d_ViewMapping aMapping = aDestView->View()->ViewMapping();
+  Visual3d_ViewOrientation anOrientation = aDestView->View()->ViewOrientation();
+
+  Graphic3d_Vector aMappingProj( aProjDir.X(), aProjDir.Y(), aProjDir.Z() );
+  Graphic3d_Vector aMappingUp( anUpDir[0], anUpDir[1], anUpDir[2] );
+
+  aMappingProj.Normalize();
+  aMappingUp.Normalize();
+
+  anOrientation.SetViewReferencePlane( aMappingProj );
+  anOrientation.SetViewReferenceUp( aMappingUp );
+
+  aDestView->SetViewMapping( aMapping );
+  aDestView->SetViewOrientation( anOrientation );
+
+  // set panning
+  aDestView->SetCenter( aProjRef.X(), aProjRef.Y() );
+
+  // set mapping scale
+  double aMapScaling = aProps.getMappingScale();
+  Standard_Real aWidth, aHeight;
+  aDestView->Size( aWidth, aHeight );
+  aDestView->SetSize ( aWidth > aHeight ? aMapScaling * (aWidth / aHeight) : aMapScaling );
+#endif
+
+  getViewPort()->setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
+
+  aDestView->ZFitAll();
+  aDestView->SetImmediateUpdate( Standard_True );
+  aDestView->Redraw();
+
+  blockSignals( blocked );
+}
+
+/*!
+  \brief Indicates whether preselection is enabled
+  \return true if preselection is enabled
+*/
+bool OCCViewer_ViewWindow::isPreselectionEnabled() const
+{
+  return myPreselectionEnabled;
+}
+
+/*!
+  \brief Enables/disables preselection
+  \param theIsToEnable if true - preselection will be enabled
+*/
+void OCCViewer_ViewWindow::enablePreselection( bool theIsToEnable )
+{
+  onSwitchPreselection( theIsToEnable );
+}
+
+/*!
+  \brief Indicates whether selection is enabled
+  \return true if selection is enabled
+*/
+bool OCCViewer_ViewWindow::isSelectionEnabled() const
+{
+  return mySelectionEnabled;
+}
+
+/*!
+  \brief Enables/disables selection
+  \param theIsToEnable if true - selection will be enabled
+*/
+void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable )
+{
+  onSwitchSelection( theIsToEnable );
+}
+
+
+/*!
+  \brief called if clipping operation is activated / deactivated.
+
+  Enables/disables clipping plane displaying.
+
+  \parma on action state
+*/
+void OCCViewer_ViewWindow::onClipping (bool theIsOn)
+{
+  if(!myModel) return;
+  OCCViewer_ClippingDlg* aClippingDlg = myModel->getClippingDlg();
+  
+  if (theIsOn) {
+    if (!aClippingDlg) {
+      aClippingDlg = new OCCViewer_ClippingDlg (this, myModel);
+      myModel->setClippingDlg(aClippingDlg);
+    }
+    if (!aClippingDlg->isVisible())
+      aClippingDlg->show();
+  } else {
+    if ( aClippingDlg ) {
+      aClippingDlg->close();
+      myModel->setClippingDlg(0);
+    }
+  }
+
+  SUIT_ViewManager* mgr = getViewManager();
+  if( mgr ) {
+    QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
+    for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+      if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+       QtxActionToolMgr* mgr = aViewWindow->toolMgr();
+       if(!mgr) continue;
+       QAction* a = toolMgr()->action( ClippingId );
+       if(!a) continue;
+       if(theIsOn != a->isChecked()){
+         disconnect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool)));
+         a->setChecked(theIsOn);
+         connect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool)));
+       }
+      }
+    }
+  }
+}
index 57b819862524d722f416c17f81756b822e7676f4..135d81c0d430086cbb9e5dbcf80dfb32b7bc7d69 100755 (executable)
@@ -223,6 +223,8 @@ public:
   virtual QColor  backgroundColor() const;                      // obsolete
   virtual void    setBackgroundColor( const QColor& );          // obsolete
 
+  virtual void    showStaticTrihedron( bool );
+
   virtual Qtx::BackgroundData  background() const;
   virtual void                 setBackground( const Qtx::BackgroundData& );