]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve SVTK Viewer architecture
authorapo <apo@opencascade.com>
Mon, 5 Sep 2005 07:26:18 +0000 (07:26 +0000)
committerapo <apo@opencascade.com>
Mon, 5 Sep 2005 07:26:18 +0000 (07:26 +0000)
src/VISUGUI/VisuGUI_Module.cxx
src/VVTK/VVTK_ViewModel.cxx
src/VVTK/VVTK_ViewWindow.cxx
src/VVTK/VVTK_ViewWindow.h

index 41390058368e74656246a7775b579af52e12f071..47984e5c61cbbbeed297387eb5a9a170014d9bb2 100644 (file)
@@ -177,18 +177,18 @@ VisuGUI_Module
   //createMenu( GAUSS_CREATE_PRS, aMenuId, 10 );
 
   SUIT_Accel* accel = getApp()->accel();
-  accel->setActionKey( SUIT_Accel::PanLeft,     Key_Left,          VVTK_Viewer::Type() );
-  accel->setActionKey( SUIT_Accel::PanRight,    Key_Right,         VVTK_Viewer::Type() );
-  accel->setActionKey( SUIT_Accel::PanUp,       Key_Up,            VVTK_Viewer::Type() );
-  accel->setActionKey( SUIT_Accel::PanDown,     Key_Down,          VVTK_Viewer::Type() );
-  accel->setActionKey( SUIT_Accel::ZoomIn,      Key_PageUp,        VVTK_Viewer::Type() );
-  accel->setActionKey( SUIT_Accel::ZoomOut,     Key_PageDown,      VVTK_Viewer::Type() );
-  accel->setActionKey( SUIT_Accel::RotateLeft,  CTRL+Key_Left,     VVTK_Viewer::Type() );
-  accel->setActionKey( SUIT_Accel::RotateRight, CTRL+Key_Right,    VVTK_Viewer::Type() );
-  accel->setActionKey( SUIT_Accel::RotateUp,    CTRL+Key_Up,       VVTK_Viewer::Type() );
-  accel->setActionKey( SUIT_Accel::RotateDown,  CTRL+Key_Down,     VVTK_Viewer::Type() );
-  accel->setActionKey( PlusSpeedIncrementEvent, Key_Plus,          VVTK_Viewer::Type() );
-  accel->setActionKey( MinusSpeedIncrementEvent,Key_Minus,         VVTK_Viewer::Type() );
+  accel->setActionKey( SUIT_Accel::PanLeft,Key_Left,VVTK_Viewer::Type() );
+  accel->setActionKey( SUIT_Accel::PanRight,Key_Right,VVTK_Viewer::Type() );
+  accel->setActionKey( SUIT_Accel::PanUp,Key_Up,VVTK_Viewer::Type() );
+  accel->setActionKey( SUIT_Accel::PanDown,Key_Down,VVTK_Viewer::Type() );
+  accel->setActionKey( SUIT_Accel::ZoomIn,Key_PageUp,VVTK_Viewer::Type() );
+  accel->setActionKey( SUIT_Accel::ZoomOut,Key_PageDown,VVTK_Viewer::Type() );
+  accel->setActionKey( SUIT_Accel::RotateLeft,CTRL+Key_Left,VVTK_Viewer::Type() );
+  accel->setActionKey( SUIT_Accel::RotateRight,CTRL+Key_Right,VVTK_Viewer::Type() );
+  accel->setActionKey( SUIT_Accel::RotateUp,CTRL+Key_Up,VVTK_Viewer::Type() );
+  accel->setActionKey( SUIT_Accel::RotateDown,CTRL+Key_Down,VVTK_Viewer::Type() );
+  accel->setActionKey( SVTK::PlusSpeedIncrementEvent,Key_Plus,VVTK_Viewer::Type() );
+  accel->setActionKey( SVTK::MinusSpeedIncrementEvent,Key_Minus,VVTK_Viewer::Type() );
 
   connect( getApp(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ), this, SLOT( OnViewManagerAdded (SUIT_ViewManager*) ) );
 
@@ -354,7 +354,7 @@ void
 VisuGUI_Module
 ::OnCreateGaussPoints()
 {
-  CreatePrs3d<VISU::GaussPoints_i,SVTK_Viewer,VisuGUI_GaussPointsDlg,1>(this);
+  CreatePrs3d<VISU::GaussPoints_i,VVTK_Viewer,VisuGUI_GaussPointsDlg,1>(this);
 }
 
 void
@@ -393,27 +393,27 @@ VisuGUI_Module
   int val;
   if ( pref == "speed_increment" ) {
     val = resMgr->integerValue( "VISU", pref, 10 );
-    view->FireEvent( SetSpeedIncrementEvent, &val );
+    view->InvokeEvent( SVTK::SetSpeedIncrementEvent, &val );
   }
   else if ( pref == "spacemouse_func1_btn" ) {
     val = resMgr->integerValue( "VISU", pref, 1 );
-    view->FireEvent( SetSpaceMouseF1Event, &val );
+    view->InvokeEvent( SVTK::SetSpaceMouseF1Event, &val );
   }
   else if ( pref == "spacemouse_func2_btn" ) {
     val = resMgr->integerValue( "VISU", pref, 2 );
-    view->FireEvent( SetSpaceMouseF2Event, &val );
+    view->InvokeEvent( SVTK::SetSpaceMouseF2Event, &val );
   }
   else if ( pref == "spacemouse_func3_btn" ) {
     val = resMgr->integerValue( "VISU", pref, 10 );
-    view->FireEvent( SetSpaceMouseF3Event, &val );
+    view->InvokeEvent( SVTK::SetSpaceMouseF3Event, &val );
   }
   else if ( pref == "spacemouse_func4_btn" ) {
     val = resMgr->integerValue( "VISU", pref, 11 );
-    view->FireEvent( SetSpaceMouseF4Event, &val );
+    view->InvokeEvent( SVTK::SetSpaceMouseF4Event, &val );
   }
   else if ( pref == "spacemouse_func5_btn" ) {
     val = resMgr->integerValue( "VISU", pref, 9 );
-    view->FireEvent( SetSpaceMouseF5Event, &val );
+    view->InvokeEvent( SVTK::SetSpaceMouseF5Event, &val );
   }
 }
 
index 749a0f3695264ed318029fd9b712fe261c25d2e3..aac6ca38b83601ed4ed0d7755ac93ba0b29fc34c 100644 (file)
@@ -19,8 +19,7 @@ VVTK_Viewer
 
 VVTK_Viewer
 ::~VVTK_Viewer() 
-{
-}
+{}
 
 
 //==========================================================
@@ -49,9 +48,12 @@ SUIT_ViewWindow*
 VVTK_Viewer
 ::createView( SUIT_Desktop* theDesktop )
 {
-  TViewWindow* aViewWindow = new TViewWindow( theDesktop, this );
+  TViewWindow* aViewWindow = new TViewWindow(theDesktop);
+  aViewWindow->Initialize(this);
+    
   aViewWindow->setBackgroundColor( backgroundColor() );
   aViewWindow->SetTrihedronSize( trihedronSize() );
+
   return aViewWindow;
 }
 
index dce4e48e0347a89a49841c0f4c1f3939f9344b6d..81bdb7078bba410151b85c4ea125aa727f5db190 100755 (executable)
 #include "QtxAction.h"
 
 #include <qtoolbar.h>
+#include <qsplitter.h>
+#include <qlayout.h>
 
+//----------------------------------------------------------------------------
+VVTK_ViewWindow
+::VVTK_ViewWindow(SUIT_Desktop* theDesktop):
+  SVTK_ViewWindow(theDesktop)
+{
+}
 
 //----------------------------------------------------------------------------
+void
 VVTK_ViewWindow
-::VVTK_ViewWindow( SUIT_Desktop* theDesktop, 
-                  VVTK_Viewer* theModel )
-  : SVTK_ViewWindow( theDesktop, theModel )
+::Initialize(SVTK_ViewModelBase* theModel)
 {
-  // important! : the default interactor style which is pushed is VVTK
-  // see onSwitchIS() for details
-  getView()->pushInteractorStyle( VVTK_InteractorStyle::New() );
-
-  connect(this,SIGNAL(selectionChanged()),theModel,SLOT(onSelectionChanged()));
-
-  // create another toolbar
-  myToolBar = new QToolBar(this);
-  myToolBar->setCloseMode(QDockWindow::Undocked);
-  myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
-
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
-  // SVTK / VVTK switcher action
-  QtxAction* aAction = new QtxAction(tr("MNU_VVTK_SWITCH"), aResMgr->loadPixmap( "VISU", tr( "ICON_VVTK_SWITCH" ) ),
-                                    tr( "MNU_VVTK_SWITCH" ), 0, this, "vvtk/svtk", true);
-  aAction->setToggleAction(true); // pressed by default
-  aAction->toggle();
-  aAction->setStatusTip(tr("DSC_VVTK_SWITCH"));
-  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchIS(bool)));
-  aAction->addTo( myToolBar );
+  if(SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr()){
+    QWidget* aWidget = new QWidget(this);
+    setCentralWidget(aWidget);
+    
+    QBoxLayout* aLayout = new QVBoxLayout(aWidget);
+    aLayout->setAutoAdd(true);
+    QSplitter* aSplitter = new QSplitter(Qt::Vertical,aWidget);
+
+    // Create SVTK_View (successor of RenderWindowInteractor).
+    myView = new SVTK_View(aSplitter,"SVTK_View",aResourceMgr);
+
+    // important! : the default interactor style which is pushed is VVTK
+    // see onSwitchIS() for details
+    myView->PushInteractorStyle(VVTK_InteractorStyle::New());
+
+    // create another toolbar
+    myToolBar = new QToolBar(myView);
+    myToolBar->setCloseMode(QDockWindow::Undocked);
+    myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
+    
+    // SVTK / VVTK switcher action
+    QtxAction* aAction = new QtxAction(tr("MNU_VVTK_SWITCH"), 
+                                      aResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_SWITCH" ) ),
+                                      tr( "MNU_VVTK_SWITCH" ), 0, this, "vvtk/svtk", true);
+    aAction->setToggleAction(true); // pressed by default
+    aAction->toggle();
+    aAction->setStatusTip(tr("DSC_VVTK_SWITCH"));
+    connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchIS(bool)));
+    aAction->addTo( myToolBar );
+
+    SVTK_ViewWindow::Initialize(myView,theModel);
+  }
 }
 
 //----------------------------------------------------------------------------
@@ -56,7 +75,7 @@ VVTK_ViewWindow
   // if SVTK is a current one - pop it (remove from stack), below it there MUST BE
   // (logically) a VVTK interactor style.
   if ( isVVTK )
-    getView()->popInteractorStyle();
+    getView()->PopInteractorStyle();
   else
-    getView()->pushInteractorStyle( SVTK_InteractorStyle::New() );
+    getView()->PushInteractorStyle( SVTK_InteractorStyle::New() );
 }
index a946bf055689a1a399dd1c5238ed37458925c785..a89c5a8339a2c12e42d424ee2c265d761117bb78 100755 (executable)
@@ -16,15 +16,20 @@ class VVTK_EXPORT VVTK_ViewWindow : public SVTK_ViewWindow
   Q_OBJECT;
 
 public:
-  VVTK_ViewWindow( SUIT_Desktop*, VVTK_Viewer* );
-  virtual ~VVTK_ViewWindow();
+  VVTK_ViewWindow(SUIT_Desktop* theDesktop);
+
+  virtual
+  ~VVTK_ViewWindow();
+
+  virtual
+  void
+  Initialize(SVTK_ViewModelBase* theModel);
 
 protected slots:
   void onSwitchIS(bool isVVTK); 
 
 private:
   QToolBar* myToolBar;
 };
 
 #ifdef WIN32