From: apo Date: Tue, 16 Aug 2005 13:27:14 +0000 (+0000) Subject: To customize SVTK package for VISU X-Git-Tag: BR-D5-38-2003_D2005-12-09~114 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ccde74caf865e9f9c7f53ef7e96d67bed8e9e97f;p=modules%2Fvisu.git To customize SVTK package for VISU --- diff --git a/src/Makefile.in b/src/Makefile.in index b8b86f6e..c9211e43 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,6 +32,6 @@ VPATH=.:@srcdir@ @COMMENCE@ -SUBDIRS = CONVERTOR PIPELINE OBJECT ENGINE GUITOOLS VISU_I VISUGUI VISU_SWIG +SUBDIRS = CONVERTOR PIPELINE OBJECT ENGINE VVTK GUITOOLS VISU_I VISUGUI VISU_SWIG @MODULE@ diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index ed3d2792..746ff260 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -119,7 +119,7 @@ CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) \ -I${GUI_ROOT_DIR}/include/salome LDFLAGS += $(QWT_LIBS) -lSalomeNS \ - -lSVTK -lSPlot2d -lVisuObject -lVISUEngineImpl -lVISUGUITOOLS \ + -lSVTK -lVVTK -lSPlot2d -lVisuObject -lVISUEngineImpl -lVISUGUITOOLS \ -L${KERNEL_ROOT_DIR}/lib/salome \ -L${GUI_ROOT_DIR}/lib/salome diff --git a/src/VISUGUI/VISUM_msg_en.po b/src/VISUGUI/VISUM_msg_en.po index a4c4a6c4..68302532 100644 --- a/src/VISUGUI/VISUM_msg_en.po +++ b/src/VISUGUI/VISUM_msg_en.po @@ -11,3 +11,6 @@ msgstr "Gauss" msgid "VisuGUI_Module::MEN_NEW_VIEWER" msgstr "New Viewer" + +msgid "VVTK_ViewManager::VTK_VIEW_TITLE" +msgstr "VISU scene:%1 - viewer:%2" \ No newline at end of file diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index a581b04d..97372f56 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -37,8 +37,8 @@ #include "SalomeApp_SelectionMgr.h" #include "SalomeApp_VTKSelector.h" -#include "SVTK_ViewManager.h" -#include "SVTK_ViewModel.h" +#include "VVTK_ViewManager.h" +#include "VVTK_ViewModel.h" #ifdef _DEBUG_ static int MYDEBUG = 1; @@ -55,15 +55,15 @@ namespace VISU //--------------------------------------------------------------- class Viewer { - SVTK_ViewManager* myViewManager; + VVTK_ViewManager* myViewManager; SalomeApp_VTKSelector* mySelector; public: Viewer(VisuGUI_Module* theModule, TViewerMap& theViewerMap) { SalomeApp_Application* anApp = theModule->getApp(); - myViewManager = new SVTK_ViewManager( anApp->activeStudy(), anApp->desktop() ); - SVTK_Viewer* aViewer = (SVTK_Viewer*)myViewManager->getViewModel(); + myViewManager = new VVTK_ViewManager( anApp->activeStudy(), anApp->desktop() ); + VVTK_Viewer* aViewer = (VVTK_Viewer*)myViewManager->getViewModel(); mySelector = new SalomeApp_VTKSelector( aViewer, anApp->selectionMgr() ); anApp->addViewManager( myViewManager ); @@ -126,8 +126,6 @@ VisuGUI_Module { VisuGUI::initialize( theApp ); - onCreateViewManager(); - // Add menus int aMenuId; aMenuId = createMenu( tr( "MEN_GAUSS" ), -1, -1, 30 ); diff --git a/src/VVTK/Makefile.in b/src/VVTK/Makefile.in new file mode 100755 index 00000000..fb1023d2 --- /dev/null +++ b/src/VVTK/Makefile.in @@ -0,0 +1,41 @@ +# File : Makefile.in +# Author : Alexander Solovyov(OCN) +# Module : VVTK +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= VVTK.h \ + VVTK_ViewManager.h \ + VVTK_ViewModel.h \ + VVTK_ViewWindow.h + +# Libraries targets +LIB = libVVTK.la + +LIB_SRC= VVTK_ViewManager.cxx \ + VVTK_ViewModel.cxx \ + VVTK_ViewWindow.cxx + +LIB_MOC = VVTK_ViewWindow.h \ + VVTK_ViewModel.h \ + VVTK_ViewManager.h + +CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) \ + -I$(KERNEL_ROOT_DIR)/include/salome \ + -I$(GUI_ROOT_DIR)/include/salome + +LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) \ + -L$(KERNEL_ROOT_DIR)/lib/salome \ + -L$(GUI_ROOT_DIR)/lib/salome + +LIBS+= -lsuit -lCAM -lSalomeObject -lSVTK -lOpUtil + +@CONCLUDE@ diff --git a/src/VVTK/VVTK.h b/src/VVTK/VVTK.h new file mode 100755 index 00000000..d6dd0648 --- /dev/null +++ b/src/VVTK/VVTK.h @@ -0,0 +1,13 @@ +#ifdef WNT +#ifdef SVTK_EXPORTS +#define VVTK_EXPORT __declspec(dllexport) +#else +#define VVTK_EXPORT __declspec(dllimport) +#endif +#else +#define VVTK_EXPORT +#endif + +#if defined WNT +#pragma warning ( disable: 4251 ) +#endif diff --git a/src/VVTK/VVTK_ViewManager.cxx b/src/VVTK/VVTK_ViewManager.cxx new file mode 100644 index 00000000..8c3cb03b --- /dev/null +++ b/src/VVTK/VVTK_ViewManager.cxx @@ -0,0 +1,26 @@ +#include "VVTK_ViewManager.h" +#include "VVTK_ViewModel.h" + +int VVTK_ViewManager::_VVTKViewMgr_Id = 0; + +//*************************************************************** +VVTK_ViewManager +::VVTK_ViewManager( SUIT_Study* study, + SUIT_Desktop* theDesktop ) +: SUIT_ViewManager( study, theDesktop ) +{ + myId = ++_VVTKViewMgr_Id; + setViewModel( new VVTK_Viewer() ); +} + +//*************************************************************** +VVTK_ViewManager::~VVTK_ViewManager() +{ +} + +//*************************************************************** +void VVTK_ViewManager::setViewName(SUIT_ViewWindow* theView) +{ + int aPos = myViews.find(theView); + theView->setCaption( tr( "VTK_VIEW_TITLE" ).arg( myId ).arg( aPos + 1 ) ); +} diff --git a/src/VVTK/VVTK_ViewManager.h b/src/VVTK/VVTK_ViewManager.h new file mode 100644 index 00000000..9e70cbc4 --- /dev/null +++ b/src/VVTK/VVTK_ViewManager.h @@ -0,0 +1,25 @@ +#ifndef VVTK_VIEWMANAGER_H +#define VVTK_VIEWMANAGER_H + +#include "SUIT_ViewManager.h" +#include "VVTK.h" + +class SUIT_Desktop; + +class VVTK_EXPORT VVTK_ViewManager : public SUIT_ViewManager +{ + Q_OBJECT; +public: + + VVTK_ViewManager( SUIT_Study* study, SUIT_Desktop* ); + virtual ~VVTK_ViewManager(); + +protected: + void setViewName( SUIT_ViewWindow* theView ); + +private: + int myId; + static int _VVTKViewMgr_Id; +}; + +#endif diff --git a/src/VVTK/VVTK_ViewModel.cxx b/src/VVTK/VVTK_ViewModel.cxx new file mode 100644 index 00000000..749a0f36 --- /dev/null +++ b/src/VVTK/VVTK_ViewModel.cxx @@ -0,0 +1,190 @@ +#include +#include + +#include "VVTK_ViewModel.h" +#include "VVTK_ViewWindow.h" + +#include "SVTK_RenderWindowInteractor.h" +#include "SVTK_RenderWindow.h" +#include "SVTK_View.h" + +#include "VTKViewer_ViewModel.h" + +//========================================================== +VVTK_Viewer +::VVTK_Viewer() +{ + myTrihedronSize = 100; +} + +VVTK_Viewer +::~VVTK_Viewer() +{ +} + + +//========================================================== +void +VVTK_Viewer +::setViewManager(SUIT_ViewManager* theViewManager) +{ + SUIT_ViewModel::setViewManager(theViewManager); + + if ( !theViewManager ) + return; + + connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + + connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*))); + + connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); +} + + +//========================================================== +SUIT_ViewWindow* +VVTK_Viewer +::createView( SUIT_Desktop* theDesktop ) +{ + TViewWindow* aViewWindow = new TViewWindow( theDesktop, this ); + aViewWindow->setBackgroundColor( backgroundColor() ); + aViewWindow->SetTrihedronSize( trihedronSize() ); + return aViewWindow; +} + + +//========================================================== +void +VVTK_Viewer +::contextMenuPopup( QPopupMenu* thePopup ) +{ + thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); + thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) ); + + thePopup->insertSeparator(); + + if(TViewWindow* aView = dynamic_cast(myViewManager->getActiveView())){ + if ( !aView->getView()->getToolBar()->isVisible() ){ + thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); + } + } +} + + +//========================================================== +void +VVTK_Viewer +::Repaint() +{ + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + if(TViewWindow* aView = dynamic_cast(aViews.at(i))){ + aView->getView()->update(); + } + } +} + + +//========================================================== +void +VVTK_Viewer +::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event) +{} + +void +VVTK_Viewer +::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event) +{} + +void +VVTK_Viewer +::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event) +{} + + +//========================================================== +QColor +VVTK_Viewer +::backgroundColor() const +{ + return myBgColor; +} + +void +VVTK_Viewer +::setBackgroundColor( const QColor& theColor ) +{ + if ( !theColor.isValid() ) + return; + + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ + if(TViewWindow* aView = dynamic_cast(aViewWindow)){ + aView->setBackgroundColor(theColor); + } + } + } + + myBgColor = theColor; +} + +//========================================================== +int +VVTK_Viewer +::trihedronSize() const +{ + return myTrihedronSize; +} + +void +VVTK_Viewer +::setTrihedronSize( const int theSize ) +{ + myTrihedronSize = theSize; + if(SUIT_ViewManager* aViewManager = getViewManager()){ + QPtrVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ){ + if(TViewWindow* aView = dynamic_cast(aViews.at( i ))){ + aView->SetTrihedronSize( theSize ); + } + } + } +} + +//========================================================== +void +VVTK_Viewer +::onDumpView() +{ + if(SUIT_ViewWindow* aView = myViewManager->getActiveView()) + aView->onDumpView(); +} + +//========================================================== +void +VVTK_Viewer +::onChangeBgColor() +{ + if(SUIT_ViewWindow* aView = myViewManager->getActiveView()){ + QColor aColor = QColorDialog::getColor( backgroundColor(), aView); + setBackgroundColor(aColor); + } +} + +//========================================================== +void +VVTK_Viewer +::onShowToolbar() +{ + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + if(TViewWindow* aView = dynamic_cast(aViews.at(i))){ + aView->getView()->getToolBar()->show(); + } + } +} + diff --git a/src/VVTK/VVTK_ViewModel.h b/src/VVTK/VVTK_ViewModel.h new file mode 100644 index 00000000..3c8bd709 --- /dev/null +++ b/src/VVTK/VVTK_ViewModel.h @@ -0,0 +1,52 @@ +#ifndef VVTK_VIEWMODEL_H +#define VVTK_VIEWMODEL_H + +#include + +#include "VVTK.h" +#include "SVTK_ViewModelBase.h" + +class VVTK_ViewWindow; + +class VVTK_EXPORT VVTK_Viewer : public SVTK_ViewModelBase +{ + Q_OBJECT; + +public: + typedef VVTK_ViewWindow TViewWindow; + static QString Type() { return "VVTK"; } + + VVTK_Viewer(); + virtual ~VVTK_Viewer(); + + virtual SUIT_ViewWindow* createView(SUIT_Desktop*); + + virtual void setViewManager(SUIT_ViewManager* theViewManager); + virtual void contextMenuPopup( QPopupMenu* ); + virtual QString getType() const { return Type(); } + + virtual void Repaint(); + + QColor backgroundColor() const; + void setBackgroundColor( const QColor& ); + + int trihedronSize() const; + void setTrihedronSize( const int ); + +protected slots: + void onMousePress(SUIT_ViewWindow*, QMouseEvent*); + void onMouseMove(SUIT_ViewWindow*, QMouseEvent*); + void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); + + void onDumpView(); + void onShowToolbar(); + void onChangeBgColor(); + +private: + QColor myBgColor; + int myTrihedronSize; + bool mySelectionEnabled; + bool myMultiSelectionEnabled; +}; + +#endif diff --git a/src/VVTK/VVTK_ViewWindow.cxx b/src/VVTK/VVTK_ViewWindow.cxx new file mode 100755 index 00000000..806eacdb --- /dev/null +++ b/src/VVTK/VVTK_ViewWindow.cxx @@ -0,0 +1,17 @@ +#include "VVTK_ViewWindow.h" +#include "VVTK_ViewModel.h" + +//---------------------------------------------------------------------------- +VVTK_ViewWindow +::VVTK_ViewWindow( SUIT_Desktop* theDesktop, + VVTK_Viewer* theModel ) + : SVTK_ViewWindow( theDesktop, theModel ) +{ + connect(this,SIGNAL(selectionChanged()), + theModel,SLOT(onSelectionChanged())); +} + +//---------------------------------------------------------------------------- +VVTK_ViewWindow +::~VVTK_ViewWindow() +{} diff --git a/src/VVTK/VVTK_ViewWindow.h b/src/VVTK/VVTK_ViewWindow.h new file mode 100755 index 00000000..3507f7f0 --- /dev/null +++ b/src/VVTK/VVTK_ViewWindow.h @@ -0,0 +1,26 @@ +#ifndef VVTK_VIEWWINDOW_H +#define VVTK_VIEWWINDOW_H + +#ifdef WIN32 +#pragma warning( disable:4251 ) +#endif + +#include "VVTK.h" +#include "SVTK_ViewWindow.h" + +class VVTK_Viewer; + +class VVTK_EXPORT VVTK_ViewWindow : public SVTK_ViewWindow +{ + Q_OBJECT; + +public: + VVTK_ViewWindow( SUIT_Desktop*, VVTK_Viewer* ); + virtual ~VVTK_ViewWindow(); +}; + +#ifdef WIN32 +#pragma warning( default:4251 ) +#endif + +#endif