]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Issue 0021319: EDF 1616 ALL: synchronization of 3D viewers
authorvsr <vsr@opencascade.com>
Sat, 24 Sep 2011 11:56:04 +0000 (11:56 +0000)
committervsr <vsr@opencascade.com>
Sat, 24 Sep 2011 11:56:04 +0000 (11:56 +0000)
13 files changed:
src/OCCViewer/Makefile.am
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h
src/OCCViewer/resources/OCCViewer_images.ts
src/OCCViewer/resources/OCCViewer_msg_en.ts
src/OCCViewer/resources/occ_view_sync.png [new file with mode: 0755]
src/SUIT/SUIT_Application.h
src/SVTK/Makefile.am
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h
src/SVTK/resources/SVTK_images.ts
src/SVTK/resources/SVTK_msg_en.ts
src/SVTK/resources/vtk_view_sync.png [new file with mode: 0755]

index fb30817446bd610cfe9e71bb88611ff5a5488cfa..f30b953f7a2a06867e0ec7cac34b29aa53e9ad97 100755 (executable)
@@ -116,7 +116,8 @@ dist_salomeres_DATA =                               \
        resources/occ_view_style_switch.png     \
        resources/occ_view_zooming_style_switch.png \
        resources/occ_view_maximized.png        \
-       resources/occ_view_minimized.png
+       resources/occ_view_minimized.png        \
+       resources/occ_view_sync.png
 
 nodist_salomeres_DATA =                \
        OCCViewer_images.qm     \
index 2388b95dedd91d2ed67adef337b0de9f555313a8..bc78de4010165279ad19626538777cf7645b0eeb 100755 (executable)
@@ -41,6 +41,7 @@
 #include <SUIT_Tools.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_MessageBox.h>
+#include <SUIT_Application.h>
 
 #include <QtxActionToolMgr.h>
 #include <QtxMultiAction.h>
@@ -54,6 +55,7 @@
 #include <QKeyEvent>
 #include <QMouseEvent>
 #include <QApplication>
+#include <QMenu>
 
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
@@ -277,6 +279,11 @@ void OCCViewer_ViewWindow::initLayout()
   myCubeAxesDlg->initialize();
 }
 
+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.
@@ -1219,6 +1226,15 @@ void OCCViewer_ViewWindow::createActions()
   aAction->setStatusTip(tr("DSC_MINIMIZE_VIEW"));
   connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView()));
   toolMgr()->registerAction( aAction, MaximizedId );
+
+  // Synchronize view
+  aAction = new QtxAction(tr("MNU_SYNCHRONIZE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SYNC" ) ),
+                          tr( "MNU_SYNCHRONIZE_VIEW" ), 0, this );
+  aAction->setStatusTip(tr("DSC_SYNCHRONIZE_VIEW"));
+  aAction->setMenu( new QMenu( this ) );
+  connect(aAction->menu(), SIGNAL(aboutToShow()), this, SLOT(updateSyncViews()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onSynchronizeView()));
+  toolMgr()->registerAction( aAction, SynchronizeId );
 }
 
 /*!
@@ -1297,7 +1313,8 @@ void OCCViewer_ViewWindow::createToolBar()
 #endif
   toolMgr()->append( AmbientId, tid );
 
-  toolMgr()->append( MaximizedId, tid);
+  toolMgr()->append( MaximizedId, tid );
+  toolMgr()->append( SynchronizeId, tid );
 }
 
 /*!
@@ -1571,7 +1588,7 @@ void OCCViewer_ViewWindow::onRestoreView()
   \brief Restore view parameters.
   \param anItem view parameters
 */
-void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem )
+void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool baseParamsOnly )
 {
   Handle(V3d_View) aView3d = myViewPort->getView();
 
@@ -1584,57 +1601,62 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem )
   aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );
   aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );
   aView3d->SetAxialScale( anItem.scaleX, anItem.scaleY, anItem.scaleZ );
-  myModel->setTrihedronShown( anItem.isVisible );
-  myModel->setTrihedronSize( anItem.size );
+
+  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 );
+    // 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;
 }
 
@@ -2434,3 +2456,69 @@ void OCCViewer_ViewWindow::updateViewAspects( const viewAspectList& aViewList )
 {
   myViewAspects = aViewList;
 }
+
+/*!
+  "Synchronize View" action slot.
+*/
+void OCCViewer_ViewWindow::onSynchronizeView()
+{
+  QAction* a = qobject_cast<QAction*>( sender() );
+  if ( a ) {
+    int id = a->data().toInt();
+    if ( id != 0 ) {
+      SUIT_Application* app = SUIT_Session::session()->activeApplication();
+      if ( !app ) return;
+      QList<SUIT_ViewManager*> wmlist;
+      app->viewManagers( getViewManager()->getType(), wmlist );
+      foreach( SUIT_ViewManager* wm, wmlist ) {
+       QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
+       foreach ( SUIT_ViewWindow* vw, vwlist ) {
+         OCCViewer_ViewWindow* occVW = dynamic_cast<OCCViewer_ViewWindow*>( vw );
+         if ( !occVW ) continue;
+         // list only compatible types
+         OCCViewer_ViewWindow* subWindow = occVW->getView( get2dMode() );
+         if ( subWindow && subWindow->getId() == id && subWindow != this ) {
+           // perform synchronization
+           performRestoring( subWindow->getViewParams(), true );
+         }
+       }
+      }
+      
+      if ( a != toolMgr()->action( SynchronizeId ) )
+       toolMgr()->action( SynchronizeId )->setData( id );
+    }
+  }
+}
+
+/*!
+  Update list of available view for the "Synchronize View" action
+*/
+void OCCViewer_ViewWindow::updateSyncViews()
+{
+  QAction* anAction = toolMgr()->action( SynchronizeId );
+  if ( anAction && anAction->menu() ) {
+    anAction->menu()->clear();
+    SUIT_Application* app = SUIT_Session::session()->activeApplication();
+    if ( app ) { 
+      QList<SUIT_ViewManager*> wmlist;
+      app->viewManagers( getViewManager()->getType(), wmlist );
+      foreach( SUIT_ViewManager* wm, wmlist ) {
+       QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
+       foreach ( SUIT_ViewWindow* vw, vwlist ) {
+         OCCViewer_ViewWindow* occVW = dynamic_cast<OCCViewer_ViewWindow*>( vw );
+         if ( !occVW || occVW == this ) continue;
+         // list only compatible types
+         OCCViewer_ViewWindow* subWindow = occVW->getView( get2dMode() );
+         if ( subWindow && subWindow != this ) {
+           QAction* a = anAction->menu()->addAction( occVW->windowTitle() );
+           a->setData( subWindow->getId() );
+           connect( a, SIGNAL( triggered() ), this, SLOT( onSynchronizeView() ) );
+         }
+       }
+      }
+    }
+    if ( anAction->menu()->actions().isEmpty() ) {
+      anAction->menu()->addAction( tr( "MNU_SYNC_NO_VIEW" ) );
+    }
+  }
+}
index 7eb3f87f88784d99da4cbc28a58ac8ed98995622..01a393e6b71e12af23264f1a30fa5f03304970d8 100755 (executable)
@@ -120,7 +120,7 @@ public:
          FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
         ResetId, CloneId, ClippingId, MemId, RestoreId,
          TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
-        SwitchInteractionStyleId, SwitchZoomingStyleId, MaximizedId, UserId };
+        SwitchInteractionStyleId, SwitchZoomingStyleId, MaximizedId, SynchronizeId, UserId };
 
   enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, 
                       PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
@@ -137,11 +137,13 @@ public:
   OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
   virtual ~OCCViewer_ViewWindow();
 
+  virtual OCCViewer_ViewWindow* getView( const int ) const;
+
   virtual OCCViewer_ViewPort3d* getViewPort();
 
   virtual bool eventFilter(QObject* watched, QEvent* e);
 
-  virtual void performRestoring( const viewAspect& );
+  virtual void performRestoring( const viewAspect&, bool = false );
   
   virtual void initLayout();
 
@@ -229,6 +231,9 @@ public slots:
 
   virtual void onMaximizedView();
 
+  virtual void onSynchronizeView();
+  virtual void updateSyncViews();
+
 signals:
   void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
   void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
index 40bb075112c5cb4bdc789dc2005573086f1c920c..21c1ae70581fb893b2a1d34b5e5bdfdcf7428467 100644 (file)
         <source>ICON_OCCVIEWER_MINIMIZE</source>
         <translation>occ_view_minimized.png</translation>
     </message>
+    <message>
+        <source>ICON_OCCVIEWER_SYNC</source>
+        <translation>occ_view_sync.png</translation>
+    </message>
 </context>
 </TS>
index 6b065ead4b9f6b1dd063a34b23bf7dec89aa3a64..6ad0d76d3487094173753f70cde9230c4c5b58d1 100644 (file)
         <source>DSC_MINIMIZE_VIEW</source>
         <translation>Minimize view</translation>
     </message>
+    <message>
+        <source>DSC_SYNCHRONIZE_VIEW</source>
+        <translation>Synchronize view</translation>
+    </message>
     <message>
         <source>MNU_MAXIMIZE_VIEW</source>
         <translation>Maximize</translation>
         <source>MNU_MINIMIZE_VIEW</source>
         <translation>Minimize</translation>
     </message>
+    <message>
+        <source>MNU_SYNCHRONIZE_VIEW</source>
+        <translation>Synchronize</translation>
+    </message>
+    <message>
+        <source>MNU_SYNC_NO_VIEW</source>
+        <translation>[ No appropriate view ]</translation>
+    </message>
 </context>
 <context>
     <name>OCCViewer_CreateRestoreViewDlg</name>
diff --git a/src/OCCViewer/resources/occ_view_sync.png b/src/OCCViewer/resources/occ_view_sync.png
new file mode 100755 (executable)
index 0000000..32b9522
Binary files /dev/null and b/src/OCCViewer/resources/occ_view_sync.png differ
index 9b156f90b8c7412644da58e5bf5a7901df7b3cd7..03f86727b078ca5b4294f1ad59ebaf75d94b9491 100755 (executable)
@@ -101,17 +101,18 @@ public:
   SUIT_ShortcutMgr*     shortcutMgr() const;
 
   //! Puts the message to the status bar  
-  void putInfo ( const QString&, const int = 0 );
+  void                  putInfo ( const QString&, const int = 0 );
 
   //! Invokes application-specific "Open/Save File" dialog and returns the selected file name.
-  virtual QString getFileName( bool open, const QString& initial, const QString& filters, 
-                               const QString& caption, QWidget* parent ) = 0;
+  virtual QString       getFileName( bool open, const QString& initial, const QString& filters, 
+                                     const QString& caption, QWidget* parent ) = 0;
 
   //! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
-  virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
+  virtual QString       getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
 
 
-  virtual int     viewManagerId ( const SUIT_ViewManager* ) const = 0;
+  virtual int           viewManagerId ( const SUIT_ViewManager* ) const = 0;
+  virtual void          viewManagers( const QString&, QList<SUIT_ViewManager*>& ) const = 0;
 
 signals:
   void                  applicationClosed( SUIT_Application* );
index 6a3f71fcf63c8135ccaaa3d97fd8303e898980f8..f7f57dccd342392bef85b8d959ac1002a8068f0d 100755 (executable)
@@ -132,7 +132,8 @@ dist_salomeres_DATA=\
        resources/vtk_view_recording_start.png \
        resources/vtk_view_recording_play.png \
        resources/vtk_view_recording_pause.png \
-       resources/vtk_view_recording_stop.png
+       resources/vtk_view_recording_stop.png \
+       resources/vtk_view_sync.png
 
 nodist_salomeres_DATA =        \
        SVTK_msg_en.qm  \
index dab457576783627c5d08324602b304646c3742d8..1a853416bc7a685206e72fbbaa7602adfa3ccdb7 100755 (executable)
@@ -28,6 +28,7 @@
 
 #include "SALOME_Actor.h"
 
+#include <QMenu>
 #include <QToolBar>
 #include <QEvent>
 #include <QXmlStreamWriter>
@@ -55,6 +56,7 @@
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_Accel.h"
 #include "SUIT_OverrideCursor.h"
+#include "SUIT_ViewManager.h"
 #include "QtxActionToolMgr.h"
 #include "QtxMultiAction.h"
 
@@ -1422,7 +1424,7 @@ void SVTK_ViewWindow::setVisualParameters( const QString& parameters )
 /*!
   The method restores visual parameters of this view from a formated string
 */
-void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters )
+void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly )
 {
   double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
 
@@ -1455,24 +1457,33 @@ void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters )
         scale[1] = aAttr.value("Y").toString().toDouble();
         scale[2] = aAttr.value("Z").toString().toDouble();
         //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
-      } else if (aReader.name() == "DisplayCubeAxis") {
-        if (aAttr.value("Show") == "0")
-          gradAxesActor->VisibilityOff();
-        else
-          gradAxesActor->VisibilityOn();
-      } else if (aReader.name() == "GraduatedAxis") {
-        if(aAttr.value("Axis") == "X") 
-          setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
-        else if(aAttr.value("Axis") == "Y")
-          setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
-        else if(aAttr.value("Axis") == "Z")
-          setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
-      } else if (aReader.name() == "Trihedron") {
-        if (aAttr.value("isShown") == "0")
-          GetTrihedron()->VisibilityOff();
-        else
-          GetTrihedron()->VisibilityOn();
-        SetTrihedronSize(aAttr.value("Size").toString().toDouble());
+      } 
+      else if (aReader.name() == "DisplayCubeAxis") {
+       if ( !baseParamsOnly ) {
+         if (aAttr.value("Show") == "0")
+           gradAxesActor->VisibilityOff();
+         else
+           gradAxesActor->VisibilityOn();
+       }
+      }
+      else if (aReader.name() == "GraduatedAxis") {
+       if ( !baseParamsOnly ) {
+         if(aAttr.value("Axis") == "X") 
+           setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
+         else if(aAttr.value("Axis") == "Y")
+           setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
+         else if(aAttr.value("Axis") == "Z")
+           setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
+       }
+      } 
+      else if (aReader.name() == "Trihedron") {
+       if ( !baseParamsOnly ) {
+         if (aAttr.value("isShown") == "0")
+           GetTrihedron()->VisibilityOff();
+         else
+           GetTrihedron()->VisibilityOn();
+         SetTrihedronSize(aAttr.value("Size").toString().toDouble());
+       }
       }
     } 
   }
@@ -1483,7 +1494,8 @@ void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters )
     camera->SetViewUp( viewUp );
     camera->SetParallelScale( parScale );
     SetScale( scale );
-  } else {
+  }
+  else {
     QStringList paramsLst = parameters.split( '*' );
     if ( paramsLst.size() >= nNormalParams ) {
       // 'reading' list of parameters
@@ -1510,26 +1522,29 @@ void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters )
       SetScale( scale );
       
       // apply graduated axes parameters
-      SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
-      if ( gradAxesActor && paramsLst.size() == nAllParams ) {
-        int i = nNormalParams+1, j = i + nGradAxisParams - 1;
-        ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) ); 
-        i = j + 1; j += nGradAxisParams;
-        ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) ); 
-        i = j + 1; j += nGradAxisParams;
-        ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) ); 
+      if ( !baseParamsOnly ) {
+       SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
+       if ( gradAxesActor && paramsLst.size() == nAllParams ) {
+         int i = nNormalParams+1, j = i + nGradAxisParams - 1;
+         ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) ); 
+         i = j + 1; j += nGradAxisParams;
+         ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) ); 
+         i = j + 1; j += nGradAxisParams;
+         ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) ); 
         
-        if ( paramsLst[13].toUShort() )
-          gradAxesActor->VisibilityOn();
-        else
-          gradAxesActor->VisibilityOff();
-      } else if ( paramsLst.size() == nAllParams ) {
-        if ( paramsLst[90].toUShort() )
-          GetTrihedron()->VisibilityOn();
-        else
-          GetTrihedron()->VisibilityOff();
+         if ( paramsLst[13].toUShort() )
+           gradAxesActor->VisibilityOn();
+         else
+           gradAxesActor->VisibilityOff();
+       }
+       else if ( paramsLst.size() == nAllParams ) {
+         if ( paramsLst[90].toUShort() )
+           GetTrihedron()->VisibilityOn();
+         else
+           GetTrihedron()->VisibilityOff();
         
-        SetTrihedronSize(paramsLst[91].toDouble());
+         SetTrihedronSize(paramsLst[91].toDouble());
+       }
       }
     }
   }
@@ -1825,6 +1840,16 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
   connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
   mgr->registerAction( anAction, ViewParametersId );
 
+  // Synchronize View 
+  anAction = new QtxAction(tr("MNU_SYNCHRONIZE_VIEW"), 
+                           theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SYNCHRONIZE" ) ),
+                           tr( "MNU_SYNCHRONIZE_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_SYNCHRONIZE_VIEW"));
+  anAction->setMenu( new QMenu( this ) );
+  connect(anAction->menu(), SIGNAL(aboutToShow()), this, SLOT(updateSyncViews()));
+  connect(anAction, SIGNAL(triggered()), this, SLOT(onSynchronizeView()));
+  mgr->registerAction( anAction, SynchronizeId );
+
   // Switch between interaction styles
   anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"), 
                            theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
@@ -1925,7 +1950,10 @@ void SVTK_ViewWindow::createToolBar()
   mgr->append( GraduatedAxes, myToolBar );
 
   mgr->append( ViewParametersId, myToolBar );
+  mgr->append( SynchronizeId, myToolBar );
+
   mgr->append( toolMgr()->separator(), myToolBar );
+
   mgr->append( ParallelModeId, myToolBar );
   mgr->append( ProjectionModeId, myToolBar );
 
@@ -2098,3 +2126,61 @@ void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent )
   emit Hide( theEvent );
 }
 
+/*!
+  "Synchronize View" action slot.
+*/
+void SVTK_ViewWindow::onSynchronizeView()
+{
+  QAction* a = qobject_cast<QAction*>( sender() );
+  if ( a ) {
+    int id = a->data().toInt();
+    if ( id != 0 ) {
+      SUIT_Application* app = SUIT_Session::session()->activeApplication();
+      if ( !app ) return;
+      QList<SUIT_ViewManager*> wmlist;
+      app->viewManagers( getViewManager()->getType(), wmlist );
+      foreach( SUIT_ViewManager* wm, wmlist ) {
+       QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
+       foreach ( SUIT_ViewWindow* vw, vwlist ) {
+         SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( vw );
+         if ( vtkVW && vtkVW->getId() == id && vtkVW != this ) {
+           // perform synchronization
+           doSetVisualParameters( vtkVW->getVisualParameters(), true );
+         }
+       }
+      }
+      
+      if ( a != toolMgr()->action( SynchronizeId ) )
+       toolMgr()->action( SynchronizeId )->setData( id );
+    }
+  }
+}
+
+/*!
+  Update list of available view for the "Synchronize View" action
+*/
+void SVTK_ViewWindow::updateSyncViews()
+{
+  QAction* anAction = toolMgr()->action( SynchronizeId );
+  if ( anAction && anAction->menu() ) {
+    anAction->menu()->clear();
+    SUIT_Application* app = SUIT_Session::session()->activeApplication();
+    if ( app ) { 
+      QList<SUIT_ViewManager*> wmlist;
+      app->viewManagers( getViewManager()->getType(), wmlist );
+      foreach( SUIT_ViewManager* wm, wmlist ) {
+       QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
+       foreach ( SUIT_ViewWindow* vw, vwlist ) {
+         SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( vw );
+         if ( !vtkVW || vtkVW == this ) continue;
+         QAction* a = anAction->menu()->addAction( vtkVW->windowTitle() );
+         a->setData( vtkVW->getId() );
+         connect( a, SIGNAL( triggered() ), this, SLOT( onSynchronizeView() ) );
+       }
+      }
+    }
+    if ( anAction->menu()->actions().isEmpty() ) {
+      anAction->menu()->addAction( tr( "MNU_SYNC_NO_VIEW" ) );
+    }
+  }
+}
index fddddef2ec82a1779f5e9bc7a4e16a8ff13ec050..24f29d9aa61fb29eb4a515c2dd31bde1348b70e3 100755 (executable)
@@ -307,6 +307,9 @@ public slots:
   void onPauseRecording();
   void onStopRecording();
 
+  void onSynchronizeView();
+  void updateSyncViews();
+
 signals:
  void selectionChanged();
  void actorAdded(VTKViewer_Actor*);
@@ -367,7 +370,7 @@ protected:
   virtual void Initialize(SVTK_View* theView,
                           SVTK_ViewModelBase* theModel);
 
-  void doSetVisualParameters( const QString& );
+  void doSetVisualParameters( const QString&, bool = false );
   void SetEventDispatcher(vtkObject* theDispatcher);
 
   QImage dumpViewContent();
@@ -385,7 +388,7 @@ protected:
          ChangeRotationPointId, RotationId,
          FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId,
         ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate,
-         ParallelModeId, ProjectionModeId, ViewParametersId, SwitchInteractionStyleId,
+         ParallelModeId, ProjectionModeId, ViewParametersId, SynchronizeId, SwitchInteractionStyleId,
          SwitchZoomingStyleId,
          StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId };
 
index 8ac1e43a1895b7480d40c908d7fc4f98278e1d47..c2afa1b8e0c135cce56aae37e0507e6a161aa727 100644 (file)
@@ -55,5 +55,9 @@
         <source>ICON_SVTK_RECORDING_STOP</source>
         <translation>vtk_view_recording_stop.png</translation>
     </message>
+    <message>
+        <source>ICON_SVTK_SYNCHRONIZE</source>
+        <translation>vtk_view_sync.png</translation>
+    </message>
 </context>
 </TS>
index d76686531cdd3674fbd33b964c3743930a8690cf..d5ef2af33ae97225bef817278d2ff0ea0608b92e 100644 (file)
         <source>DSC_VIEWPARAMETERS_VIEW</source>
         <translation>Change the parameters of the view</translation>
     </message>
+    <message>
+        <source>MNU_SYNCHRONIZE_VIEW</source>
+        <translation>Synchronize</translation>
+    </message>
+    <message>
+        <source>DSC_SYNCHRONIZE_VIEW</source>
+        <translation>Synchronize view</translation>
+    </message>
+    <message>
+        <source>MNU_SYNC_NO_VIEW</source>
+        <translation>[ No appropriate view ]</translation>
+    </message>
     <message>
         <source>MNU_SVTK_PARALLEL_MODE</source>
         <translation>Orthogonal Mode</translation>
diff --git a/src/SVTK/resources/vtk_view_sync.png b/src/SVTK/resources/vtk_view_sync.png
new file mode 100755 (executable)
index 0000000..32b9522
Binary files /dev/null and b/src/SVTK/resources/vtk_view_sync.png differ