From: apo Date: Fri, 9 Sep 2005 08:07:19 +0000 (+0000) Subject: First step to customize segmentation window X-Git-Tag: BR-D5-38-2003_D2005-12-09~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9652b403ff1c52b1c13d31b109ae0e5ad1e7e72b;p=modules%2Fvisu.git First step to customize segmentation window --- diff --git a/src/VVTK/VVTK_View.cxx b/src/VVTK/VVTK_View.cxx index effb4637..29c4bb2f 100644 --- a/src/VVTK/VVTK_View.cxx +++ b/src/VVTK/VVTK_View.cxx @@ -29,6 +29,9 @@ #include "VVTK_View.h" #include "VVTK_InteractorStyle.h" +#include "SVTK_RenderWindowInteractor.h" +#include "SVTK_Renderer.h" + #include "SUIT_ResourceMgr.h" #include "QtxAction.h" @@ -38,20 +41,18 @@ VVTK_MainWindow ::VVTK_MainWindow(QWidget* theParent, const char* theName, - SUIT_ResourceMgr* theResourceMgr, - bool theIsBase): + SUIT_ResourceMgr* theResourceMgr): SVTK_MainWindow(theParent,theName,theResourceMgr), - myInteractorStyle(VVTK_InteractorStyle::New()), - myIsBase(theIsBase) + myInteractorStyle(VVTK_InteractorStyle::New()) { myInteractorStyle->Delete(); this->moveDockWindow(myToolBar,Qt::DockLeft); - myToolBar2 = new QToolBar(this); - myToolBar2->setCloseMode(QDockWindow::Undocked); - myToolBar2->setLabel(tr("LBL_TOOLBAR_LABEL")); - this->moveDockWindow(myToolBar2,Qt::DockLeft); + myPtsToolBar = new QToolBar(this); + myPtsToolBar->setCloseMode(QDockWindow::Undocked); + myPtsToolBar->setLabel(tr("LBL_TOOLBAR_LABEL")); + this->moveDockWindow(myPtsToolBar,Qt::DockLeft); QPixmap aPixmap; QtxAction* anAction; @@ -67,7 +68,7 @@ VVTK_MainWindow anAction->setToggleAction(true); anAction->setStatusTip(tr("DSC_VVTK_INTERACTOR_STYLE_SWITCH")); connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onInteractorStyleSwitch(bool))); - anAction->addTo( myToolBar2 ); + anAction->addTo( myPtsToolBar ); aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_SELECTION_MODE_SWITCH")); anAction = new QtxAction(tr("MNU_VVTK_SELECTION_MODE_SWITCH"), @@ -80,7 +81,7 @@ VVTK_MainWindow anAction->setToggleAction(true); anAction->setStatusTip(tr("DSC_VVTK_SELECTION_MODE_SWITCH")); connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSelectionModeSwitch(bool))); - anAction->addTo( myToolBar2 ); + anAction->addTo( myPtsToolBar ); } void @@ -105,12 +106,10 @@ VVTK_MainWindow ::sizeHint() const { QWidget* aParent = parentWidget(); - float aCoeff = 2.0/3.0; - if(!myIsBase) - aCoeff = 1.0/3.0; - + static float aCoeff = 2.0/3.0; int aWidth = int(aCoeff*aParent->width()); int aHeight = int(aCoeff*aParent->height()); + return QSize(aWidth,aHeight); } @@ -137,3 +136,49 @@ VVTK_MainWindow { SetSelectionMode(theIsSelectionOn? NodeSelection: ActorSelection); } + + +//---------------------------------------------------------------------------- +VVTK_SMainWindow +::VVTK_SMainWindow(QWidget* theParent, + const char* theName, + SUIT_ResourceMgr* theResourceMgr): + VVTK_MainWindow(theParent,theName,theResourceMgr) +{} + +void +VVTK_SMainWindow +::Initialize() +{ + SetInteractor(new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor")); + + SVTK_Renderer* aRenderer = SVTK_Renderer::New(); + GetInteractor()->SetRenderer(aRenderer); + aRenderer->Delete(); + + SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New(); + GetInteractor()->PushInteractorStyle(aStyle); + aStyle->Delete(); + + // important! : the default interactor style which is pushed is VVTK + // see onInteractorStyleSwitch() for details + PushInteractorStyle(myInteractorStyle.GetPointer()); +} + +VVTK_SMainWindow +::~VVTK_SMainWindow() +{} + + +//---------------------------------------------------------------------------- +QSize +VVTK_SMainWindow +::sizeHint() const +{ + QWidget* aParent = parentWidget(); + static float aCoeff = 1.0/3.0; + int aWidth = int(aCoeff*aParent->width()); + int aHeight = int(aCoeff*aParent->height()); + + return QSize(aWidth,aHeight); +} diff --git a/src/VVTK/VVTK_View.h b/src/VVTK/VVTK_View.h index 88f5285f..66206770 100644 --- a/src/VVTK/VVTK_View.h +++ b/src/VVTK/VVTK_View.h @@ -17,9 +17,7 @@ class VVTK_EXPORT VVTK_MainWindow: public SVTK_MainWindow public: VVTK_MainWindow(QWidget* theParent, const char* theName, - SUIT_ResourceMgr* theResourceMgr, - bool theIsBase); - + SUIT_ResourceMgr* theResourceMgr); virtual void Initialize(); @@ -36,12 +34,34 @@ public: void onSelectionModeSwitch(bool theIsSelectionOn); protected: - bool myIsBase; - QToolBar* myToolBar2; + QToolBar* myPtsToolBar; vtkSmartPointer myInteractorStyle; }; +//---------------------------------------------------------------------------- +class VVTK_EXPORT VVTK_SMainWindow: public VVTK_MainWindow +{ + Q_OBJECT; + +public: + VVTK_SMainWindow(QWidget* theParent, + const char* theName, + SUIT_ResourceMgr* theResourceMgr); + + virtual + void + Initialize(); + + virtual + ~VVTK_SMainWindow(); + + virtual + QSize + sizeHint() const; +}; + + #ifdef WIN32 #pragma warning( default:4251 ) #endif diff --git a/src/VVTK/VVTK_ViewWindow.cxx b/src/VVTK/VVTK_ViewWindow.cxx index 78ae8310..c2f457bb 100755 --- a/src/VVTK/VVTK_ViewWindow.cxx +++ b/src/VVTK/VVTK_ViewWindow.cxx @@ -26,25 +26,20 @@ VVTK_ViewWindow aLayout->setAutoAdd(true); QSplitter* aSplitter = new QSplitter(Qt::Vertical,aWidget); - myVMainWindow[0] = new VVTK_MainWindow(aSplitter, - "SVTK_MainWindow", - aResourceMgr, - true); - myVMainWindow[0]->Initialize(); + myMainWindow = new VVTK_MainWindow(aSplitter, + "VVTK_MainWindow", + aResourceMgr); + myMainWindow->Initialize(); - myVView[0] = new SVTK_View(myVMainWindow[0]); - - myVMainWindow[1] = new VVTK_MainWindow(aSplitter, - "SVTK_MainWindow", - aResourceMgr, - false); - myVMainWindow[1]->Initialize(); + myView = new SVTK_View(myMainWindow); + SVTK_ViewWindow::Initialize(myView,theModel); - myVView[1] = new SVTK_View(myVMainWindow[0]); + mySMainWindow = new VVTK_SMainWindow(aSplitter, + "VVTK_SegmantationWindow", + aResourceMgr); + mySMainWindow->Initialize(); - myView = myVView[0]; - myMainWindow = myVMainWindow[0]; - SVTK_ViewWindow::Initialize(myView,theModel); + mySView = new SVTK_View(mySMainWindow); } } diff --git a/src/VVTK/VVTK_ViewWindow.h b/src/VVTK/VVTK_ViewWindow.h index e7892cc4..edb1fba6 100755 --- a/src/VVTK/VVTK_ViewWindow.h +++ b/src/VVTK/VVTK_ViewWindow.h @@ -8,6 +8,7 @@ #include "VVTK.h" #include "SVTK_ViewWindow.h" +class VVTK_SMainWindow; class VVTK_MainWindow; class SVTK_View; @@ -26,8 +27,8 @@ public: Initialize(SVTK_ViewModelBase* theModel); protected: - VVTK_MainWindow* myVMainWindow[2]; - SVTK_View* myVView[2]; + VVTK_SMainWindow* mySMainWindow; + SVTK_View* mySView; }; #ifdef WIN32