]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To customize SVTK package for VISU
authorapo <apo@opencascade.com>
Tue, 16 Aug 2005 13:27:14 +0000 (13:27 +0000)
committerapo <apo@opencascade.com>
Tue, 16 Aug 2005 13:27:14 +0000 (13:27 +0000)
12 files changed:
src/Makefile.in
src/VISUGUI/Makefile.in
src/VISUGUI/VISUM_msg_en.po
src/VISUGUI/VisuGUI_Module.cxx
src/VVTK/Makefile.in [new file with mode: 0755]
src/VVTK/VVTK.h [new file with mode: 0755]
src/VVTK/VVTK_ViewManager.cxx [new file with mode: 0644]
src/VVTK/VVTK_ViewManager.h [new file with mode: 0644]
src/VVTK/VVTK_ViewModel.cxx [new file with mode: 0644]
src/VVTK/VVTK_ViewModel.h [new file with mode: 0644]
src/VVTK/VVTK_ViewWindow.cxx [new file with mode: 0755]
src/VVTK/VVTK_ViewWindow.h [new file with mode: 0755]

index b8b86f6e6d07e1a5b72515e8df411d4e235db269..c9211e433daddb6fef81cf578523ca9d04340960 100644 (file)
@@ -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@
index ed3d27921a32ffa3a474e48beba2eb4b0cf17033..746ff2602679ce7ea47e549db7e8a02d5a710585 100644 (file)
@@ -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
 
index a4c4a6c466cbaa00a97d5aef540f4e034eb46f5f..683025322d0bb9a7399b425ad9f3e756ba73321a 100644 (file)
@@ -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
index a581b04d028eeadcd4b79e4dc84bf46331cbc72c..97372f56bea68b6992b99da50ba7a2d09c40c220 100644 (file)
@@ -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 (executable)
index 0000000..fb1023d
--- /dev/null
@@ -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 (executable)
index 0000000..d6dd064
--- /dev/null
@@ -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 (file)
index 0000000..8c3cb03
--- /dev/null
@@ -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 (file)
index 0000000..9e70cbc
--- /dev/null
@@ -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 (file)
index 0000000..749a0f3
--- /dev/null
@@ -0,0 +1,190 @@
+#include <qpopupmenu.h>
+#include <qcolordialog.h>
+
+#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<TViewWindow*>(myViewManager->getActiveView())){
+    if ( !aView->getView()->getToolBar()->isVisible() ){
+      thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) );
+    }
+  }
+}
+
+
+//==========================================================
+void 
+VVTK_Viewer
+::Repaint()
+{
+  QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+  for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+    if(TViewWindow* aView = dynamic_cast<TViewWindow*>(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<SUIT_ViewWindow> 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<TViewWindow*>(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<SUIT_ViewWindow> aViews = aViewManager->getViews();
+    for ( int i = 0; i < aViews.count(); i++ ){
+      if(TViewWindow* aView = dynamic_cast<TViewWindow*>(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<SUIT_ViewWindow> aViews = myViewManager->getViews();
+  for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+    if(TViewWindow* aView = dynamic_cast<TViewWindow*>(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 (file)
index 0000000..3c8bd70
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef VVTK_VIEWMODEL_H
+#define VVTK_VIEWMODEL_H
+
+#include <qcolor.h>
+
+#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 (executable)
index 0000000..806eacd
--- /dev/null
@@ -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 (executable)
index 0000000..3507f7f
--- /dev/null
@@ -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