From: apo Date: Mon, 5 Sep 2005 07:26:18 +0000 (+0000) Subject: To improve SVTK Viewer architecture X-Git-Tag: BR-D5-38-2003_D2005-12-09~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ddf0c5b0252a72ef322047da857cdee3dccd36ab;p=modules%2Fvisu.git To improve SVTK Viewer architecture --- diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 41390058..47984e5c 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -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(this); + CreatePrs3d(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 ); } } diff --git a/src/VVTK/VVTK_ViewModel.cxx b/src/VVTK/VVTK_ViewModel.cxx index 749a0f36..aac6ca38 100644 --- a/src/VVTK/VVTK_ViewModel.cxx +++ b/src/VVTK/VVTK_ViewModel.cxx @@ -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; } diff --git a/src/VVTK/VVTK_ViewWindow.cxx b/src/VVTK/VVTK_ViewWindow.cxx index dce4e48e..81bdb707 100755 --- a/src/VVTK/VVTK_ViewWindow.cxx +++ b/src/VVTK/VVTK_ViewWindow.cxx @@ -10,34 +10,53 @@ #include "QtxAction.h" #include +#include +#include +//---------------------------------------------------------------------------- +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() ); } diff --git a/src/VVTK/VVTK_ViewWindow.h b/src/VVTK/VVTK_ViewWindow.h index a946bf05..a89c5a83 100755 --- a/src/VVTK/VVTK_ViewWindow.h +++ b/src/VVTK/VVTK_ViewWindow.h @@ -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