From a1dadedaaaf0f5beb63642da4e861d6f1b6af534 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 9 Sep 2005 05:44:06 +0000 Subject: [PATCH] To sepaterate base and segmentation windows --- src/VVTK/Makefile.in | 9 ++- src/VVTK/VVTK_View.cxx | 139 +++++++++++++++++++++++++++++++++++ src/VVTK/VVTK_View.h | 49 ++++++++++++ src/VVTK/VVTK_ViewWindow.cxx | 86 ++++------------------ src/VVTK/VVTK_ViewWindow.h | 13 ++-- 5 files changed, 215 insertions(+), 81 deletions(-) create mode 100644 src/VVTK/VVTK_View.cxx create mode 100644 src/VVTK/VVTK_View.h diff --git a/src/VVTK/Makefile.in b/src/VVTK/Makefile.in index d0c151ea..0f36b64c 100755 --- a/src/VVTK/Makefile.in +++ b/src/VVTK/Makefile.in @@ -16,7 +16,8 @@ EXPORT_HEADERS= VVTK.h \ VVTK_ViewManager.h \ VVTK_ViewModel.h \ VVTK_InteractorStyle.h \ - VVTK_ViewWindow.h + VVTK_ViewWindow.h \ + VVTK_View.h # Libraries targets LIB = libVVTK.la @@ -24,11 +25,13 @@ LIB = libVVTK.la LIB_SRC= VVTK_ViewManager.cxx \ VVTK_ViewModel.cxx \ VVTK_InteractorStyle.cxx \ - VVTK_ViewWindow.cxx + VVTK_ViewWindow.cxx \ + VVTK_View.cxx LIB_MOC = VVTK_ViewWindow.h \ VVTK_ViewModel.h \ - VVTK_ViewManager.h + VVTK_ViewManager.h \ + VVTK_View.h CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) \ -I$(KERNEL_ROOT_DIR)/include/salome \ diff --git a/src/VVTK/VVTK_View.cxx b/src/VVTK/VVTK_View.cxx new file mode 100644 index 00000000..a28940c4 --- /dev/null +++ b/src/VVTK/VVTK_View.cxx @@ -0,0 +1,139 @@ +// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers +// +// Copyright (C) 2003 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. +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : +// Author : +// Module : +// $Header$ + +#include "VVTK_View.h" +#include "VVTK_InteractorStyle.h" + +#include "SUIT_ResourceMgr.h" +#include "QtxAction.h" + +#include + +//---------------------------------------------------------------------------- +VVTK_MainWindow +::VVTK_MainWindow(QWidget* theParent, + const char* theName, + SUIT_ResourceMgr* theResourceMgr, + bool theIsBase): + SVTK_MainWindow(theParent,theName,theResourceMgr), + myInteractorStyle(VVTK_InteractorStyle::New()), + myIsBase(theIsBase) +{ + 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); + + QPixmap aPixmap; + QtxAction* anAction; + aPixmap = theResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_INTERACTOR_STYLE_SWITCH" ) ); + anAction = new QtxAction(tr("MNU_VVTK_INTERACTOR_STYLE_SWITCH"), + aPixmap, + tr( "MNU_VVTK_INTERACTOR_STYLE_SWITCH" ), + 0, + this, + "VVTK/SVTK StyleSwitch", + true); + anAction->toggle(); + anAction->setToggleAction(true); + anAction->setStatusTip(tr("DSC_VVTK_INTERACTOR_STYLE_SWITCH")); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onInteractorStyleSwitch(bool))); + anAction->addTo( myToolBar2 ); + + aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_SELECTION_MODE_SWITCH")); + anAction = new QtxAction(tr("MNU_VVTK_SELECTION_MODE_SWITCH"), + aPixmap, + tr( "MNU_VVTK_SELECTION_MODE_SWITCH" ), + 0, + this, + "VVTK/SVTK SelectionSwitch", + true); + anAction->setToggleAction(true); + anAction->setStatusTip(tr("DSC_VVTK_SELECTION_MODE_SWITCH")); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSelectionModeSwitch(bool))); + anAction->addTo( myToolBar2 ); +} + +void +VVTK_MainWindow +::Initialize() +{ + SVTK_MainWindow::Initialize(); + + // important! : the default interactor style which is pushed is VVTK + // see onInteractorStyleSwitch() for details + PushInteractorStyle(myInteractorStyle.GetPointer()); +} + +VVTK_MainWindow +::~VVTK_MainWindow() +{} + + +//---------------------------------------------------------------------------- +QSize +VVTK_MainWindow +::sizeHint() const +{ + QWidget* aParent = parentWidget(); + if(myIsBase){ + static float aCoeff = 2.0/3.0; + return QSize(aCoeff*aParent->width(),aCoeff*aParent->height()); + }else{ + static float aCoeff = 1.0/3.0; + return QSize(aCoeff*aParent->width(),aCoeff*aParent->height()); + } +} + + +//---------------------------------------------------------------------------- +void +VVTK_MainWindow +::onInteractorStyleSwitch(bool theIsVVTKStyle) +{ + // default interactor style which is pushed in this view window constructor + // is VVTK. If it is a current interactor style -- push SVTK "above" it. + // if SVTK is a current one - pop it (remove from stack), below it there MUST BE + // (logically) a VVTK interactor style. + if ( theIsVVTKStyle ) + this->PopInteractorStyle(); + else + this->PushInteractorStyle(myInteractorStyle.GetPointer()); +} + +//---------------------------------------------------------------------------- +void +VVTK_MainWindow +::onSelectionModeSwitch(bool theIsSelectionOn) +{ + SetSelectionMode(theIsSelectionOn? NodeSelection: ActorSelection); +} diff --git a/src/VVTK/VVTK_View.h b/src/VVTK/VVTK_View.h new file mode 100644 index 00000000..88f5285f --- /dev/null +++ b/src/VVTK/VVTK_View.h @@ -0,0 +1,49 @@ +#ifndef VVTK_VIEW_H +#define VVTK_VIEW_H + +#ifdef WIN32 +#pragma warning( disable:4251 ) +#endif + +#include "VVTK.h" +#include "SVTK_View.h" + + +//---------------------------------------------------------------------------- +class VVTK_EXPORT VVTK_MainWindow: public SVTK_MainWindow +{ + Q_OBJECT; + +public: + VVTK_MainWindow(QWidget* theParent, + const char* theName, + SUIT_ResourceMgr* theResourceMgr, + bool theIsBase); + + virtual + void + Initialize(); + + virtual + ~VVTK_MainWindow(); + + virtual + QSize + sizeHint() const; + + public slots: + void onInteractorStyleSwitch(bool theIsVVTKStyle); + void onSelectionModeSwitch(bool theIsSelectionOn); + + protected: + bool myIsBase; + QToolBar* myToolBar2; + vtkSmartPointer myInteractorStyle; +}; + + +#ifdef WIN32 +#pragma warning( default:4251 ) +#endif + +#endif diff --git a/src/VVTK/VVTK_ViewWindow.cxx b/src/VVTK/VVTK_ViewWindow.cxx index f20d526d..78ae8310 100755 --- a/src/VVTK/VVTK_ViewWindow.cxx +++ b/src/VVTK/VVTK_ViewWindow.cxx @@ -1,15 +1,9 @@ #include "VVTK_ViewWindow.h" #include "VVTK_ViewModel.h" -#include "VVTK_InteractorStyle.h" +#include "VVTK_View.h" -#include "SVTK_View.h" - -#include "SUIT_ResourceMgr.h" #include "SUIT_Session.h" -#include "QtxAction.h" - -#include #include #include @@ -17,8 +11,7 @@ VVTK_ViewWindow ::VVTK_ViewWindow(SUIT_Desktop* theDesktop): SVTK_ViewWindow(theDesktop) -{ -} +{} //---------------------------------------------------------------------------- void @@ -33,48 +26,24 @@ VVTK_ViewWindow aLayout->setAutoAdd(true); QSplitter* aSplitter = new QSplitter(Qt::Vertical,aWidget); - // Create SVTK_View (successor of RenderWindowInteractor). - myMainWindow = new SVTK_MainWindow(aSplitter,"SVTK_MainWindow",aResourceMgr); - myView = new SVTK_View(myMainWindow); + myVMainWindow[0] = new VVTK_MainWindow(aSplitter, + "SVTK_MainWindow", + aResourceMgr, + true); + myVMainWindow[0]->Initialize(); - // important! : the default interactor style which is pushed is VVTK - // see onSwitchIS() for details - myMainWindow->PushInteractorStyle(VVTK_InteractorStyle::New()); + myVView[0] = new SVTK_View(myVMainWindow[0]); - // create another toolbar - myToolBar = new QToolBar(myMainWindow); - myToolBar->setCloseMode(QDockWindow::Undocked); - myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL")); - - QPixmap aPixmap; - QtxAction* anAction; - aPixmap = aResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_INTERACTOR_STYLE_SWITCH" ) ); - anAction = new QtxAction(tr("MNU_VVTK_INTERACTOR_STYLE_SWITCH"), - aPixmap, - tr( "MNU_VVTK_INTERACTOR_STYLE_SWITCH" ), - 0, - this, - "VVTK/SVTK StyleSwitch", - true); - anAction->toggle(); - anAction->setToggleAction(true); - anAction->setStatusTip(tr("DSC_VVTK_INTERACTOR_STYLE_SWITCH")); - connect(anAction, SIGNAL(toggled(bool)), this, SLOT(OnInteractorStyleSwitch(bool))); - anAction->addTo( myToolBar ); + myVMainWindow[1] = new VVTK_MainWindow(aSplitter, + "SVTK_MainWindow", + aResourceMgr, + false); + myVMainWindow[1]->Initialize(); - aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_SELECTION_MODE_SWITCH")); - anAction = new QtxAction(tr("MNU_VVTK_SELECTION_MODE_SWITCH"), - aPixmap, - tr( "MNU_VVTK_SELECTION_MODE_SWITCH" ), - 0, - this, - "VVTK/SVTK SelectionSwitch", - true); - anAction->setToggleAction(true); - anAction->setStatusTip(tr("DSC_VVTK_SELECTION_MODE_SWITCH")); - connect(anAction, SIGNAL(toggled(bool)), this, SLOT(OnSelectionModeSwitch(bool))); - anAction->addTo( myToolBar ); + myVView[1] = new SVTK_View(myVMainWindow[0]); + myView = myVView[0]; + myMainWindow = myVMainWindow[0]; SVTK_ViewWindow::Initialize(myView,theModel); } } @@ -83,26 +52,3 @@ VVTK_ViewWindow VVTK_ViewWindow ::~VVTK_ViewWindow() {} - -//---------------------------------------------------------------------------- -void -VVTK_ViewWindow -::OnInteractorStyleSwitch(bool theIsVVTKStyle) -{ - // default interactor style which is pushed in this view window constructor - // is VVTK. If it is a current interactor style -- push SVTK "above" it. - // if SVTK is a current one - pop it (remove from stack), below it there MUST BE - // (logically) a VVTK interactor style. - if ( theIsVVTKStyle ) - getMainWindow()->PopInteractorStyle(); - else - getMainWindow()->PushInteractorStyle( SVTK_InteractorStyle::New() ); -} - -void -VVTK_ViewWindow -::OnSelectionModeSwitch(bool theIsSelectionOn) -{ - Selection_Mode aMode = theIsSelectionOn? NodeSelection: ActorSelection; - getMainWindow()->SetSelectionMode(aMode); -} diff --git a/src/VVTK/VVTK_ViewWindow.h b/src/VVTK/VVTK_ViewWindow.h index a9880860..e7892cc4 100755 --- a/src/VVTK/VVTK_ViewWindow.h +++ b/src/VVTK/VVTK_ViewWindow.h @@ -8,8 +8,8 @@ #include "VVTK.h" #include "SVTK_ViewWindow.h" -class VVTK_Viewer; -class QToolBar; +class VVTK_MainWindow; +class SVTK_View; class VVTK_EXPORT VVTK_ViewWindow : public SVTK_ViewWindow { @@ -25,12 +25,9 @@ public: void Initialize(SVTK_ViewModelBase* theModel); -protected slots: - void OnInteractorStyleSwitch(bool theIsVVTKStyle); - void OnSelectionModeSwitch(bool theIsSelectionOn); - -private: - QToolBar* myToolBar; +protected: + VVTK_MainWindow* myVMainWindow[2]; + SVTK_View* myVView[2]; }; #ifdef WIN32 -- 2.39.2