]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
- VTKPrsDisplayer is introduced for Bathymetry visualization.
authorrkv <rkv@opencascade.com>
Wed, 20 Nov 2013 09:38:21 +0000 (09:38 +0000)
committerrkv <rkv@opencascade.com>
Wed, 20 Nov 2013 09:38:21 +0000 (09:38 +0000)
- All displayers are inherited from the abstract displayer.

23 files changed:
CMakeLists.txt
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_AbstractDisplayer.cxx
src/HYDROGUI/HYDROGUI_AbstractDisplayer.h
src/HYDROGUI/HYDROGUI_Displayer.cxx
src/HYDROGUI/HYDROGUI_Displayer.h
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.h
src/HYDROGUI/HYDROGUI_ShowHideOp.cxx
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_UpdateFlags.h
src/HYDROGUI/HYDROGUI_VTKPrs.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_VTKPrs.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_VTKPrsBathymetryDriver.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_VTKPrsBathymetryDriver.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_VTKPrsDriver.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_VTKPrsDriver.h [new file with mode: 0644]

index 68865e5db4fcfd91e70da5ed52118b7a661a048c..3c6f8487db1565b1ed3b248883c114ff72fac965 100644 (file)
@@ -123,6 +123,8 @@ ENDIF(SALOME_BUILD_GUI)
 
 FIND_PACKAGE(SalomeCAS REQUIRED)
 
+FIND_PACKAGE(SalomeVTK REQUIRED)
+
 FIND_PACKAGE(SalomeSIP REQUIRED)  # should come after Python and before PyQt4
 
 FIND_PACKAGE(SalomePyQt4 REQUIRED)
index a3666627623ac97fd50532734072c84e19c8495d..52ad4000e54f163de93a598ed9088f90c92f043c 100644 (file)
@@ -51,6 +51,11 @@ set(PROJECT_HEADERS
     HYDROGUI_UpdateFlags.h
     HYDROGUI_UpdateImageOp.h
     HYDROGUI_VisualStateOp.h
+    HYDROGUI_VTKPrs.h
+    HYDROGUI_VTKPrsBathymetry.h
+    HYDROGUI_VTKPrsBathymetryDriver.h
+    HYDROGUI_VTKPrsDisplayer.h
+    HYDROGUI_VTKPrsDriver.h
     HYDROGUI_Wizard.h
     HYDROGUI_Zone.h
     HYDROGUI_ImportGeomObjectOp.h
@@ -111,6 +116,11 @@ set(PROJECT_SOURCES
     HYDROGUI_TwoImagesOp.cxx
     HYDROGUI_UpdateImageOp.cxx
     HYDROGUI_VisualStateOp.cxx
+    HYDROGUI_VTKPrs.cxx
+    HYDROGUI_VTKPrsBathymetry.cxx
+    HYDROGUI_VTKPrsBathymetryDriver.cxx
+    HYDROGUI_VTKPrsDisplayer.cxx
+    HYDROGUI_VTKPrsDriver.cxx
     HYDROGUI_Wizard.cxx
     HYDROGUI_Zone.cxx
     HYDROGUI_ImportGeomObjectOp.cxx
@@ -142,13 +152,16 @@ include_directories(
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROData
   ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROCurveCreator
+  ${VTK_INCLUDE_DIRS}
 )
 
+
 add_library(HYDROGUI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${PROJECT_HEADERS_MOC})
 target_link_libraries(HYDROGUI HYDROData HYDROCurveCreator
     ${CAS_TKV3d} ${CAS_TKTopAlgo} ${CAS_TKBrep} ${CAS_TKBO}
-    ${GUI_LightApp} ${GUI_CAM} ${GUI_suit} ${GUI_qtx} ${GUI_ObjBrowser} ${GUI_GraphicsView} ${GUI_std} ${GUI_Event} ${GUI_OCCViewer}
-    ${GEOM_GEOM} ${GEOM_GEOMBase}
+    ${GUI_LightApp} ${GUI_CAM} ${GUI_suit} ${GUI_qtx} ${GUI_ObjBrowser} ${GUI_GraphicsView} ${GUI_std} 
+    ${GUI_Event} ${GUI_OCCViewer} ${GEOM_GEOM} ${GEOM_GEOMBase}
+    ${VTK_LIBRARIES} ${SVTK} ${SalomeObject} ${SalomePrs}
     )
 INSTALL(TARGETS HYDROGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 
index 7817f3ccd693e78e24ac61f44d15d2f07ec4d17a..8a1262bd1f49f902413af6d735a57636f6d9c859 100644 (file)
@@ -26,6 +26,8 @@
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_Tool.h"
 
+#include <SUIT_ViewManager.h>
+
 HYDROGUI_AbstractDisplayer::HYDROGUI_AbstractDisplayer( HYDROGUI_Module* theModule )
 : myModule( theModule )
 {
@@ -35,6 +37,16 @@ HYDROGUI_AbstractDisplayer::~HYDROGUI_AbstractDisplayer()
 {
 }
 
+bool HYDROGUI_AbstractDisplayer::IsApplicable( const int theViewerId ) const
+{
+  return IsApplicable( myModule->getViewManager( theViewerId ) );
+}
+
+bool HYDROGUI_AbstractDisplayer::IsApplicable( const SUIT_ViewManager* theViewMgr ) const
+{
+  return ( theViewMgr && ( theViewMgr->getType() == GetType() ) );
+}
+
 void HYDROGUI_AbstractDisplayer::UpdateAll( const int  theViewerId,
                                        const bool theIsInit,
                                        const bool theIsForced,
index ec3f9ed4039579538c929f75fc5a1d050089df80..6438d3dd5288a2dd08f9def1be73d836cb8e0038 100644 (file)
@@ -26,6 +26,7 @@
 #include <HYDROData_Entity.h>
 
 class HYDROGUI_Module;
+class SUIT_ViewManager;
 
 /**
  * \class HYDROGUI_DataModel
@@ -46,6 +47,20 @@ public:
   virtual ~HYDROGUI_AbstractDisplayer();
 
 public:
+  /**
+   * \brief Check if this displayer is applicable to the given view manager.
+   * The view manager method getType is used.
+   * \param theViewerId viewer identifier
+   */
+  virtual bool     IsApplicable( const int theViewerId ) const;
+
+  /**
+   * \brief Check if this displayer is applicable to the given view manager.
+   * The view manager method getType is used.
+   * \param theViewMgr the view manager to check
+   */
+  virtual bool     IsApplicable( const SUIT_ViewManager* theViewMgr ) const;
+
   /**
    * \brief Update all objects in the viewer.
    * \param theViewerId viewer identifier
@@ -65,6 +80,11 @@ public:
   virtual void     SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
                                 const int theViewerId ) = 0;
 
+  /**
+   * \brief Get the applicable viewer type.
+   */
+  virtual QString  GetType() const = 0;
+
 protected:
   /**
    * \brief Update and display all objects in the viewer.
@@ -113,6 +133,7 @@ protected:
                             const bool theIsForced,
                             const bool theDoFitAll ) = 0;
 
+protected:
   /**
    * \brief Purge all invalid objects in the viewer.
    * \param theViewerId viewer identifier
index 006c64c4318718f60d3f652e5309016628ee92ed..570ba30cf0fc184869308102cb7fd33951ebbdd0 100644 (file)
@@ -216,3 +216,8 @@ HYDROGUI_PrsDriver* HYDROGUI_Displayer::getDriver( const Handle(HYDROData_Entity
 
   return aDriver;
 }
+
+QString HYDROGUI_Displayer::GetType() const
+{
+  return GraphicsView_Viewer::Type();
+}
index 4d80827278c9bb17e7418691da3b06da2863a0e9..f7948dcab39993540c2e8d25c0970bf673316f1b 100644 (file)
 
 class HYDROGUI_PrsDriver;
 
-class GraphicsView_Viewer;
-
 /**
- * \class HYDROGUI_DataModel
- * \brief Class intended to create, display and update the presentations.
+ * \class HYDROGUI_Displayer
+ * \brief Class intended to create, display and update the presentations in 2D graphics viewer.
  */
 class HYDROGUI_Displayer : public HYDROGUI_AbstractDisplayer
 {
@@ -55,23 +53,28 @@ public:
    * \param theObjs sequence of objects to update
    * \param theViewerId viewer identifier
    */
-  void                            SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
-                                               const int theViewerId );
+  void             SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
+                                const int theViewerId );
+
+  /**
+   * \brief Get the applicable viewer type.
+   */
+  virtual QString  GetType() const;
 
 protected:
   /**
    * \brief Erase all viewer objects.
    * \param theViewerId viewer identifier
    */
-  void                            EraseAll( const int theViewerId );
+  void             EraseAll( const int theViewerId );
 
   /**
    * \brief Erase the specified viewer objects.
    * \param theObjs sequence of objects to erase
    * \param theViewerId viewer identifier
    */
-  void                            Erase( const HYDROData_SequenceOfObjects& theObjs,
-                                         const int theViewerId );
+  void             Erase( const HYDROData_SequenceOfObjects& theObjs,
+                          const int theViewerId );
 
   /**
    * \brief Display the specified viewer objects.
@@ -80,16 +83,17 @@ protected:
    * \param theIsForced flag used to update all objects, including the unchanged ones
    * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default
    */
-  void                            Display( const HYDROData_SequenceOfObjects& theObjs,
-                                           const int theViewerId,
-                                           const bool theIsForced,
-                                           const bool theDoFitAll );
+  void             Display( const HYDROData_SequenceOfObjects& theObjs,
+                            const int theViewerId,
+                            const bool theIsForced,
+                            const bool theDoFitAll );
 
+protected:
   /**
    * \brief Purge all invalid objects in the viewer.
    * \param theViewerId viewer identifier
    */
-  void                            purgeObjects( const int theViewerId );
+  void             purgeObjects( const int theViewerId );
 
 private:
   /**
index 5af8b51b14ea634b8efbad12096e3883dbdd2a21..28fc93e7d9a08b2826a2f949a1c78283e94242a6 100644 (file)
@@ -35,6 +35,9 @@
 #include "HYDROGUI_Tool.h"
 #include "HYDROGUI_UpdateFlags.h"
 #include "HYDROGUI_Shape.h"
+#include "HYDROGUI_VTKPrs.h"
+#include "HYDROGUI_VTKPrsDisplayer.h"
+#include "HYDROGUI_AbstractDisplayer.h"
 
 #include <HYDROData_Image.h>
 #include <HYDROData_Lambert93.h>
 #include <SUIT_Study.h>
 #include <SUIT_ViewManager.h>
 
+#include <SVTK_ViewManager.h>
+#include <SVTK_ViewModel.h>
+#include <SVTK_Selector.h>
+
 #include <QAction>
 #include <QApplication>
 #include <QGraphicsSceneMouseEvent>
@@ -118,6 +125,7 @@ void HYDROGUI_Module::initialize( CAM_Application* theApp )
 
   myDisplayer = new HYDROGUI_Displayer( this );
   myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
+  myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
 }
 
 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
@@ -196,7 +204,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
   bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
   bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
-  if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView )
+  bool anIsVTKView = theClient == SVTK_Viewer::Type();
+  if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
     return;
 
   size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
@@ -213,6 +222,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsSplittedImage = false;
   bool anIsMustBeUpdatedImage = false;
   bool anIsPolyline = false;
+  bool anIsBathymetry = false;
   bool anIsCalculation = false;
   bool anIsImmersibleZone = false;
   bool anIsVisualState = false;
@@ -279,6 +289,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsRegion = true;
       else if( anObject->GetKind() == KIND_ZONE )
         anIsZone = true;
+      else if( anObject->GetKind() == KIND_BATHYMETRY )
+        anIsBathymetry = true;
       else if( anObject->GetKind() == KIND_OBSTACLE )
         anIsObstacle = true;
     }
@@ -395,7 +407,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addAction( action( DeleteId ) );
     theMenu->addSeparator();
 
-    if( anIsImage || anIsPolyline || anIsImmersibleZone || anIsZone || anIsRegion || anIsObstacle )
+    if( anIsImage || anIsPolyline || anIsImmersibleZone || anIsZone || anIsRegion || anIsBathymetry || anIsObstacle )
     {
       if( anIsHiddenInSelection )
         theMenu->addAction( action( ShowId ) );
@@ -406,7 +418,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     }
   }
 
-  if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView )
+  if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
   {
     theMenu->addAction( action( ShowAllId ) );
     theMenu->addAction( action( HideAllId ) );
@@ -428,15 +440,15 @@ void HYDROGUI_Module::update( const int flags )
   // store selected objects
   QStringList aSelectedEntries = storeSelection();
 
+  bool aDoFitAll = flags & UF_FitAll;
   if( ( flags & UF_Viewer ) )
-    updateGV( flags & UF_GV_Init,
-              flags & UF_GV_Forced,
-              flags & UF_FitAll );
+    updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll ); 
 
   if( ( flags & UF_OCCViewer ) )
-    updateOCCViewer( flags & UF_OCC_Init,
-                     flags & UF_OCC_Forced,
-                     flags & UF_FitAll );
+    updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll ); 
+
+  if( ( flags & UF_VTKViewer ) )
+    updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll ); 
 
   if( ( flags & UF_Model ) && getDataModel() && getApp() )
   {
@@ -496,6 +508,20 @@ HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
   return myOCCDisplayer;
 }
 
+HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
+{
+  return myVTKDisplayer;
+}
+
+SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
+{
+  if( myViewManagerMap.contains( theId ) )
+  {
+    return myViewManagerMap[ theId ].first;
+  }
+  return NULL;
+}
+
 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
 {
   if( myViewManagerMap.contains( theId ) )
@@ -522,6 +548,19 @@ OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
   return NULL;
 }
 
+SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
+{
+  if( myViewManagerMap.contains( theId ) )
+  {
+    ViewManagerInfo anInfo = myViewManagerMap[ theId ];
+    SVTK_ViewManager* aViewManager =
+      ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
+    if( aViewManager )
+      return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
+  }
+  return NULL;
+}
+
 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
 {
   ViewManagerMapIterator anIter( myViewManagerMap );
@@ -589,6 +628,7 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId,
   }
 }
 
+/////////////////// OCC SHAPES PROCESSING
 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int                       theViewId,
                                                  const Handle(HYDROData_Entity)& theObject ) const
 {
@@ -661,6 +701,82 @@ void HYDROGUI_Module::removeViewShapes( const int theViewId )
 
   myShapesMap.remove( theViewId );
 }
+/////////////////// END OF OCC SHAPES PROCESSING
+
+/////////////////// VTKPrs PROCESSING
+HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int                       theViewId,
+                                                 const Handle(HYDROData_Entity)& theObject ) const
+{
+  HYDROGUI_VTKPrs* aResShape = NULL;
+  if( theObject.IsNull() )
+    return aResShape;
+
+  if ( myVTKPrsMap.contains( theViewId ) )
+  {
+    const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
+    foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
+    {
+      if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
+        continue;
+
+      aResShape = aShape;
+      break;
+    }
+  }
+
+  return aResShape;
+}
+
+void HYDROGUI_Module::setObjectVTKPrs( const int                       theViewId,
+                                       const Handle(HYDROData_Entity)& theObject,
+                                       HYDROGUI_VTKPrs*                 theShape )
+{
+  if( theObject.IsNull() )
+    return;
+
+  ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
+  aViewShapes.append( theShape );
+}
+
+void HYDROGUI_Module::removeObjectVTKPrs( const int                       theViewId,
+                                          const Handle(HYDROData_Entity)& theObject )
+{
+  if ( !myVTKPrsMap.contains( theViewId ) )
+    return;
+
+  ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
+  Handle(HYDROData_Entity) anObject;
+  for ( int i = 0; i < aViewShapes.length(); )
+  {
+    HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
+    anObject = aShape->getObject();
+    if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
+    {
+      delete aShape;
+      aViewShapes.removeAt( i );
+      continue;
+    }
+
+    ++i;
+  }
+}
+
+void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
+{
+  if ( !myVTKPrsMap.contains( theViewId ) )
+    return;
+
+  const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
+  for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
+  {
+    HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
+    if ( aShape )
+      delete aShape;
+  }
+
+  myVTKPrsMap.remove( theViewId );
+}
+/////////////////// END OF VTKPrs PROCESSING
 
 CAM_DataModel* HYDROGUI_Module::createDataModel()
 {
@@ -831,59 +947,31 @@ void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
   */
 }
 
-void HYDROGUI_Module::updateGV( const bool theIsInit,
-                                const bool theIsForced,
-                                const bool theDoFitAll )
+void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer, 
+                                    const bool theIsInit, 
+                                    const bool theIsForced, 
+                                    const bool theDoFitAll )
 {
-  if( !getDisplayer() )
-    return;
-
   QList<int> aViewManagerIdList;
 
   // currently, all views are updated
   ViewManagerMapIterator anIter( myViewManagerMap );
   while( anIter.hasNext() )
   { 
-    GraphicsView_ViewManager* aViewManager =
-      dynamic_cast<GraphicsView_ViewManager*>( anIter.next().value().first );
-    if ( !aViewManager )
-      continue;
+    SUIT_ViewManager* aViewManager = anIter.next().value().first;
 
-    int anId = anIter.key();
-    aViewManagerIdList.append( anId );
+    if ( theDisplayer->IsApplicable( aViewManager ) )
+    {
+      int anId = anIter.key();
+      aViewManagerIdList.append( anId );
+    }
   }
 
   QListIterator<int> anIdIter( aViewManagerIdList );
   while( anIdIter.hasNext() )
-    getDisplayer()->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
-}
-
-void HYDROGUI_Module::updateOCCViewer( const bool theIsInit,
-                                       const bool theIsForced,
-                                       const bool theDoFitAll )
-{
-  HYDROGUI_OCCDisplayer* anOCCDisplayer = getOCCDisplayer();
-  if( !anOCCDisplayer )
-    return;
-
-  QList<int> aViewManagerIdList;
-
-  // currently, all views are updated
-  ViewManagerMapIterator anIter( myViewManagerMap );
-  while( anIter.hasNext() )
-  { 
-    OCCViewer_ViewManager* aViewManager =
-      ::qobject_cast<OCCViewer_ViewManager*>( anIter.next().value().first );
-    if ( !aViewManager )
-      continue;
-
-    int anId = anIter.key();
-    aViewManagerIdList.append( anId );
+  {
+    theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
   }
-
-  QListIterator<int> anIdIter( aViewManagerIdList );
-  while( anIdIter.hasNext() )
-    anOCCDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
 }
 
 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
@@ -909,6 +997,7 @@ void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
   {
     SUIT_Selector* aSelector = *anIter;
     if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
+                       !dynamic_cast<SVTK_Selector*>( aSelector ) &&
                        !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
       aSelector->setEnabled( false );
   }
index d2825208639d1e205a76060269f2fa6489a5767f..0aaf8f0b7091d17811b72d8a19693f0641441afd 100644 (file)
 class QGraphicsSceneMouseEvent;
 
 class GraphicsView_Viewer;
+class OCCViewer_Viewer;
+class SVTK_Viewer;
 
 class SUIT_ViewWindow;
+class SUIT_ViewManager;
 
 class HYDROGUI_DataModel;
 class HYDROGUI_Displayer;
 class HYDROGUI_OCCDisplayer;
+class HYDROGUI_VTKPrsDisplayer;
+class HYDROGUI_AbstractDisplayer;
 class HYDROGUI_Shape;
-
-class OCCViewer_Viewer;
+class HYDROGUI_VTKPrs;
 
 /**\class HYDROGUI_Module
  *\brief The class representing the HYDROGUI module
@@ -81,6 +85,9 @@ public:
   typedef QList<HYDROGUI_Shape*> ListOfShapes;
   typedef QMap<int,ListOfShapes> ViewId2ListOfShapes;
 
+  typedef QList<HYDROGUI_VTKPrs*> ListOfVTKPrs;
+  typedef QMap<int,ListOfVTKPrs> ViewId2ListOfVTKPrs;
+
 public:
   HYDROGUI_Module();
   virtual ~HYDROGUI_Module();
@@ -98,12 +105,15 @@ public:
 
   virtual void                    selectionChanged();
 
+  SUIT_ViewManager*               getViewManager( const int theId ) const;
   HYDROGUI_DataModel*             getDataModel() const;
   HYDROGUI_Displayer*             getDisplayer() const;
   HYDROGUI_OCCDisplayer*          getOCCDisplayer() const;
+  HYDROGUI_VTKPrsDisplayer*       getVTKDisplayer() const;
 
   GraphicsView_Viewer*            getViewer( const int theId ) const;
   OCCViewer_Viewer*               getOCCViewer( const int theId ) const;
+  SVTK_Viewer*                    getVTKViewer( const int theId ) const;
 
   int                             getViewManagerId( SUIT_ViewManager* theViewManager );
   ViewManagerRole                 getViewManagerRole( SUIT_ViewManager* theViewManager );
@@ -121,10 +131,19 @@ public:
   void                            setObjectShape( const int                       theViewId,
                                                   const Handle(HYDROData_Entity)& theObject,
                                                   HYDROGUI_Shape*                 theShape );
-  void                            removeViewShapes( const int                       theViewId );
+  void                            removeViewShapes( const int                     theViewId );
   void                            removeObjectShape( const int                       theViewId,
                                                      const Handle(HYDROData_Entity)& theObject );
 
+  HYDROGUI_VTKPrs*                getObjectVTKPrs( const int                       theViewId,
+                                                   const Handle(HYDROData_Entity)& theObject ) const;
+  void                            setObjectVTKPrs( const int                       theViewId,
+                                                   const Handle(HYDROData_Entity)& theObject,
+                                                   HYDROGUI_VTKPrs*                theShape );
+  void                            removeViewVTKPrs( const int                      theViewId );
+  void                            removeObjectVTKPrs( const int                      theViewId,
+                                                     const Handle(HYDROData_Entity)& theObject );
+
   QStringList                     GetGeomObjectsToImport();
 
 protected:
@@ -157,13 +176,10 @@ protected slots:
                                                                const QStringList& );
 
 private:
-  void                            updateGV( const bool theIsInit = false, 
-                                            const bool theIsForced = false,
-                                            const bool theDoFitAll = false );
-
-  void                            updateOCCViewer( const bool theIsInit = false, 
-                                                   const bool theIsForced = false,
-                                                   const bool theDoFitAll = false );
+  void                            updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer, 
+                                                const bool theIsInit = false, 
+                                                const bool theIsForced = false, 
+                                                const bool theDoFitAll = false );
 
   void                            createSelector( SUIT_ViewManager* viewMgr );
 
@@ -191,11 +207,13 @@ private:
 private:
   HYDROGUI_Displayer*             myDisplayer;
   HYDROGUI_OCCDisplayer*          myOCCDisplayer;
+  HYDROGUI_VTKPrsDisplayer*       myVTKDisplayer;
 
   ViewManagerMap                  myViewManagerMap;
   ViewId2Name2ObjectStateMap      myObjectStateMap;
 
   ViewId2ListOfShapes             myShapesMap;
+  ViewId2ListOfVTKPrs             myVTKPrsMap;
 
   bool                            myIsUpdateEnabled;
 
index 9d3e2cf440986c5aa72e19768981dc736f377f0a..602cb5cb5cd00ab7a2a967c84f0de611fde56c30 100644 (file)
@@ -194,4 +194,7 @@ void HYDROGUI_OCCDisplayer::purgeObjects( const int theViewerId )
   }
 }
 
-
+QString HYDROGUI_OCCDisplayer::GetType() const
+{
+  return OCCViewer_Viewer::Type();
+}
index 69b976ee0adecc353f58a747073e39d01a6aab63..681e137abcdc629e70073b385194cd52eb4582e4 100644 (file)
@@ -55,6 +55,11 @@ public:
   void                            SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
                                                const int theViewerId );
 
+  /**
+   * \brief Get the applicable viewer type.
+   */
+  virtual QString  GetType() const;
+
 protected:
   /**
    * \brief Erase all viewer objects.
@@ -82,6 +87,7 @@ protected:
                                            const bool theIsForced,
                                            const bool theDoFitAll );
 
+protected:
   /**
    * \brief Purge all invalid objects in the viewer.
    * \param theViewerId viewer identifier
index b1ddd661d2bc8c6f2a36dff2c22675f9439fdd56..755e933a3cde31fb1e543d00fb7dfd76f864a876 100644 (file)
@@ -36,6 +36,7 @@
 #include <LightApp_Application.h>
 
 #include <OCCViewer_ViewModel.h>
+#include <SVTK_ViewModel.h>
 
 #include <SUIT_ViewManager.h>
 
@@ -130,6 +131,10 @@ void HYDROGUI_ShowHideOp::startOperation()
     {
       anUpdateFlags |= UF_OCCViewer;
     }
+    else if ( aViewMgr->getType() == SVTK_Viewer::Type() )
+    {
+      anUpdateFlags |= UF_VTKViewer;
+    }
   }
 
   module()->update( anUpdateFlags );
index 5e026dd4b61866821e7c5633b616bdf4789092c4..45214704940a3249db75562b91414809bc3839be 100644 (file)
@@ -217,6 +217,7 @@ void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
         ( anObject->GetKind() == KIND_POLYLINE ) ||
         ( anObject->GetKind() == KIND_IMMERSIBLE_ZONE ) ||
         ( anObject->GetKind() == KIND_REGION ) ||
+        ( anObject->GetKind() == KIND_BATHYMETRY ) ||
         ( anObject->GetKind() == KIND_ZONE ) ||
         ( anObject->GetKind() == KIND_OBSTACLE ) ) )
       {
index 14ef92ef13124e83280acaa4e388f9de8e5c4805..c7831fbe981157c7b2c35bd06e456618483f4a21 100644 (file)
@@ -42,6 +42,10 @@ typedef enum
   UF_OCC_Init      = 0x00000100, //!< initial update (used with UF_OCCViewer)
   UF_OCC_Forced    = 0x00000200, //!< to force recomputing all presentations (used with UF_OCCViewer)
   
+  UF_VTKViewer     = 0x00000800, //!< OCC viewer
+  UF_VTK_Init      = 0x00001000, //!< initial update (used with UF_OCCViewer)
+  UF_VTK_Forced    = 0x00002000, //!< to force recomputing all presentations (used with UF_OCCViewer)
+  
   UF_FitAll        = 0x00000400, //!< to do fit all (used with UF_Viewer or UF_OCCViewer)
 
   UF_All           = UF_Base | UF_GV_Init | UF_GV_Forced | UF_OCCViewer | UF_OCC_Init | UF_OCC_Forced//!< all update flags
diff --git a/src/HYDROGUI/HYDROGUI_VTKPrs.cxx b/src/HYDROGUI/HYDROGUI_VTKPrs.cxx
new file mode 100644 (file)
index 0000000..ad2fd39
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_VTKPrs.h"
+
+#include "HYDROGUI_DataObject.h"
+
+//=======================================================================
+// name    : HYDROGUI_VTKPrs
+// Purpose : Constructor
+//=======================================================================
+HYDROGUI_VTKPrs::HYDROGUI_VTKPrs( const Handle(HYDROData_Entity)& theObject ) 
+: myObject( theObject ), 
+  myIsToUpdate( false )
+{
+  // Define IO for actors to be added:
+  QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
+  myIO = new SALOME_InteractiveObject(
+    anEntry.toAscii(), QString::number( theObject->GetKind() ).toAscii(), theObject->GetName().toAscii() );
+}
+
+//=======================================================================
+// name    : HYDROGUI_VTKPrs
+// Purpose : Destructor
+//=======================================================================
+HYDROGUI_VTKPrs::~HYDROGUI_VTKPrs()
+{
+}
+
+//=======================================================================
+// name    : compute
+// Purpose : Compute the presentation
+//=======================================================================
+void HYDROGUI_VTKPrs::compute()
+{
+}
diff --git a/src/HYDROGUI/HYDROGUI_VTKPrs.h b/src/HYDROGUI/HYDROGUI_VTKPrs.h
new file mode 100644 (file)
index 0000000..d679856
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_VTKPrs_H
+#define HYDROGUI_VTKPrs_H
+
+#include <HYDROData_Entity.h>
+
+#include <SALOME_InteractiveObject.hxx>
+#include <SVTK_Prs.h>
+
+/*
+  Class       : HYDROGUI_VTKPrs
+  Description : Base class for all HYDRO presentation in VTK viewer
+*/
+class HYDROGUI_VTKPrs : public SVTK_Prs
+{
+public:
+  HYDROGUI_VTKPrs( const Handle(HYDROData_Entity)& theObject );
+  virtual ~HYDROGUI_VTKPrs();
+
+  virtual void                     compute();
+
+public:
+  Handle(HYDROData_Entity)         getObject() const { return myObject; }
+  Handle(SALOME_InteractiveObject) getIO() const { return myIO; }
+
+  bool                             getIsToUpdate() const { return myIsToUpdate; }
+  void                             setIsToUpdate( bool theState ) { myIsToUpdate = theState; }
+
+private:
+  Handle(HYDROData_Entity)         myObject;
+  Handle(SALOME_InteractiveObject) myIO;
+  bool                             myIsToUpdate;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.cxx b/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.cxx
new file mode 100644 (file)
index 0000000..16983bf
--- /dev/null
@@ -0,0 +1,98 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_VTKPrsBathymetry.h"
+
+#include <HYDROData_Entity.h>
+
+#include <SALOME_Actor.h>
+#include <gp_XYZ.hxx>
+#include <vtkPoints.h>
+#include <vtkPolyData.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkVertex.h>
+
+#include <QString>
+
+//=======================================================================
+// name    : HYDROGUI_VTKPrsBathymetry
+// Purpose : Constructor
+//=======================================================================
+HYDROGUI_VTKPrsBathymetry::HYDROGUI_VTKPrsBathymetry( const Handle(HYDROData_Bathymetry)& theObject )
+: HYDROGUI_VTKPrs( theObject )
+{
+}
+
+//=======================================================================
+// name    : HYDROGUI_VTKPrsBathymetry
+// Purpose : Destructor
+//=======================================================================
+HYDROGUI_VTKPrsBathymetry::~HYDROGUI_VTKPrsBathymetry()
+{
+}
+
+//================================================================
+// Function : compute
+// Purpose  : 
+//================================================================
+void HYDROGUI_VTKPrsBathymetry::compute()
+{
+  if ( !getObject().IsNull() )
+  {
+    Handle(HYDROData_Bathymetry) aBathymetry = Handle(HYDROData_Bathymetry)::DownCast( getObject() );
+    if ( !aBathymetry.IsNull() )
+    {
+      HYDROData_Bathymetry::AltitudePoints anAltPoints = aBathymetry->GetAltitudePoints();
+      int aNbPoints = anAltPoints.length();
+
+      HYDROData_Bathymetry::AltitudePoint anAltPnt;
+      vtkPoints* aPoints = vtkPoints::New();
+      aPoints->SetNumberOfPoints( aNbPoints );
+
+      vtkPolyData* aVertexGrid = vtkPolyData::New();
+      aVertexGrid->Allocate( aNbPoints );
+
+      vtkVertex* aVertex = vtkVertex::New();
+
+      for (int i = 0; i < aNbPoints; i++ )
+      {
+        anAltPnt = anAltPoints.at( i );
+        aPoints->InsertPoint( i, anAltPnt.X(), anAltPnt.Y(), anAltPnt.Z() );
+        aVertex->GetPointIds()->SetId( 0, i );
+        aVertexGrid->InsertNextCell( aVertex->GetCellType(), aVertex->GetPointIds());
+      }
+
+      aVertex->Delete();
+
+      aVertexGrid->SetPoints( aPoints );
+      vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
+      aMapper->SetInputData( aVertexGrid );
+      SALOME_Actor* anActor = SALOME_Actor::New();
+      anActor->SetMapper( aMapper );
+      anActor->setIO( getIO() );
+      //anActor->setName( aBathymetry->GetName().toLatin1() );
+      AddObject( anActor );
+      //anActor.AddPosition(0, 0, 6);
+      //anActor.GetProperty().SetDiffuseColor(1, 1, 1);
+    }
+  }
+}
diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.h b/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.h
new file mode 100644 (file)
index 0000000..3a4098c
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_VTKPrsBathymetry_H
+#define HYDROGUI_VTKPrsBathymetry_H
+
+#include "HYDROGUI_VTKPrs.h"
+
+#include <HYDROData_Bathymetry.h>
+
+/*
+  Class       : HYDROGUI_VTKPrsBathymetry
+  Description : Presentation for Bathymetry object
+*/
+class HYDROGUI_VTKPrsBathymetry : public HYDROGUI_VTKPrs
+{
+public:
+  HYDROGUI_VTKPrsBathymetry( const Handle(HYDROData_Bathymetry)& theObject );
+  virtual ~HYDROGUI_VTKPrsBathymetry();
+
+  virtual void compute();
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsBathymetryDriver.cxx b/src/HYDROGUI/HYDROGUI_VTKPrsBathymetryDriver.cxx
new file mode 100644 (file)
index 0000000..a00cc17
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_VTKPrsBathymetryDriver.h"
+
+#include "HYDROGUI_VTKPrsBathymetry.h"
+
+#include <HYDROData_Bathymetry.h>
+
+HYDROGUI_VTKPrsBathymetryDriver::HYDROGUI_VTKPrsBathymetryDriver()
+{
+}
+
+HYDROGUI_VTKPrsBathymetryDriver::~HYDROGUI_VTKPrsBathymetryDriver()
+{
+}
+
+bool HYDROGUI_VTKPrsBathymetryDriver::Update( const Handle(HYDROData_Entity)& theObj,
+                                         HYDROGUI_VTKPrs*& thePrs )
+{
+  HYDROGUI_VTKPrsDriver::Update( theObj, thePrs );
+
+  if( theObj.IsNull() )
+    return false;
+
+  Handle(HYDROData_Bathymetry) aBathymetry = Handle(HYDROData_Bathymetry)::DownCast( theObj );
+  if( aBathymetry.IsNull() )
+    return false;
+
+  if( !thePrs )
+    thePrs = new HYDROGUI_VTKPrsBathymetry( aBathymetry );
+
+  HYDROGUI_VTKPrsBathymetry* aPrsBathymetry = (HYDROGUI_VTKPrsBathymetry*)thePrs;
+
+  //aPrsBathymetry->setName( aBathymetry->GetName() );
+  //aPrsBathymetry->setPath( aBathymetry->GetPainterPath() );
+
+  aPrsBathymetry->compute();
+
+  return true;
+}
diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsBathymetryDriver.h b/src/HYDROGUI/HYDROGUI_VTKPrsBathymetryDriver.h
new file mode 100644 (file)
index 0000000..37bee69
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_VTKPrsBathymetryDRIVER_H
+#define HYDROGUI_VTKPrsBathymetryDRIVER_H
+
+#include <HYDROGUI_VTKPrsDriver.h>
+
+/**
+ * \class HYDROGUI_VTKPrsBathymetryDriver
+ * \brief Presentation driver for Bathymetry objects.
+ */
+class HYDROGUI_VTKPrsBathymetryDriver : public HYDROGUI_VTKPrsDriver
+{
+public:
+  /**
+   * \brief Constructor.
+   */
+  HYDROGUI_VTKPrsBathymetryDriver();
+
+  /**
+   * \brief Destructor.
+   */
+  virtual ~HYDROGUI_VTKPrsBathymetryDriver();
+
+public:
+  /**
+   * \brief Update or create the Bathymetry presentation on a basis of data object.
+   * \param theObj data object
+   * \param thePrs presentation
+   * \return status of the operation
+   */
+  virtual bool Update( const Handle(HYDROData_Entity)& theObj,
+                       HYDROGUI_VTKPrs*& thePrs );
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx b/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.cxx
new file mode 100644 (file)
index 0000000..101176f
--- /dev/null
@@ -0,0 +1,207 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_VTKPrsDisplayer.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_VTKPrs.h"
+#include "HYDROGUI_VTKPrsBathymetryDriver.h"
+#include "HYDROGUI_Tool.h"
+
+#include <SVTK_ViewModel.h>
+#include <SVTK_ViewWindow.h>
+#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+#include <SALOME_InteractiveObject.hxx>
+#include <SUIT_ViewManager.h>
+#include <SUIT_Accel.h>
+
+#include <QVector>
+
+HYDROGUI_VTKPrsDisplayer::HYDROGUI_VTKPrsDisplayer( HYDROGUI_Module* theModule )
+: HYDROGUI_AbstractDisplayer( theModule ), myDriver( NULL )
+{
+}
+
+HYDROGUI_VTKPrsDisplayer::~HYDROGUI_VTKPrsDisplayer()
+{
+}
+
+void HYDROGUI_VTKPrsDisplayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
+                                      const int theViewerId )
+{
+  SVTK_Viewer* aViewer = module()->getVTKViewer( theViewerId );
+  if( !aViewer )
+  {
+    HYDROGUI_VTKPrs* anObjShape;
+    for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
+    {
+      Handle(HYDROData_Entity) anObj = theObjs.Value( i );
+      if( !anObj.IsNull() )
+      {
+        anObjShape = module()->getObjectVTKPrs( (size_t)aViewer, anObj );
+        if ( anObjShape )
+        {
+          anObjShape->setIsToUpdate( true );
+        }
+      }
+    }
+  }
+}
+
+void HYDROGUI_VTKPrsDisplayer::EraseAll( const int theViewerId )
+{
+  SVTK_Viewer* aViewer = module()->getVTKViewer( theViewerId );
+  if( aViewer )
+  {
+    aViewer->EraseAll( true );
+    module()->removeViewVTKPrs( (size_t)aViewer );
+  }
+}
+
+void HYDROGUI_VTKPrsDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
+                                const int theViewerId )
+{
+  SVTK_Viewer* aViewer = module()->getVTKViewer( theViewerId );
+  if( aViewer )
+  {
+    HYDROGUI_VTKPrs* aPrs;
+    for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
+    {
+      Handle(HYDROData_Entity) anObj = theObjs.Value( i );
+      if( anObj.IsNull() )
+        continue;
+
+      aPrs = module()->getObjectVTKPrs( (size_t)aViewer, anObj );
+      if ( aPrs )
+      {
+        aViewer->Erase( aPrs, true );
+      }
+      module()->removeObjectVTKPrs( (size_t)aViewer, anObj );
+    }
+  }
+}
+
+void HYDROGUI_VTKPrsDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs,
+                                        const int theViewerId,
+                                        const bool theIsForced,
+                                        const bool theDoFitAll)
+{
+  SVTK_Viewer* aViewer = module()->getVTKViewer( theViewerId );
+  if( aViewer )
+  {
+    bool isChanged = false;
+    HYDROGUI_VTKPrs* aPrs;
+    for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
+    {
+      Handle(HYDROData_Entity) anObj = theObjs.Value( i );
+      if( !anObj.IsNull() )
+      {
+        bool anIsVisible = module()->isObjectVisible( (size_t)(aViewer->getViewManager()->getViewModel()), anObj );
+        aPrs = module()->getObjectVTKPrs( (size_t)aViewer, anObj );
+
+        bool anIsInserted = ( aPrs != 0 );
+        if( anIsVisible && ( !aPrs || aPrs->getIsToUpdate() || theIsForced ) )
+        {
+          if( HYDROGUI_VTKPrsDriver* aDriver = getDriver( anObj ) )
+          {
+            if( aDriver->Update( anObj, aPrs ) && aPrs && !anIsInserted )
+            {
+              module()->setObjectVTKPrs( theViewerId, anObj, aPrs );
+              aViewer->Display( aPrs );
+              isChanged = true;
+            }
+          }
+        }
+
+        if( aPrs && !anIsVisible )
+        {
+          aViewer->Erase( aPrs );
+          isChanged = true;
+        }
+      }
+    }
+
+    if ( theDoFitAll )
+    {
+      // Repaint is done inside OnFitAll()
+      aViewer->getViewManager()->getActiveView()->onAccelAction( SUIT_Accel::ZoomFit );
+    } 
+    else if ( isChanged )
+    {
+      aViewer->Repaint();
+    }
+  }
+}
+
+void HYDROGUI_VTKPrsDisplayer::purgeObjects( const int theViewerId )
+{
+  SVTK_Viewer* aViewer = module()->getVTKViewer( theViewerId );
+  if( aViewer )
+  {
+    SALOME_ListIO aListIO;
+    aViewer->GetVisible( aListIO );
+
+    HYDROGUI_VTKPrs* aPrs;
+    SALOME_ListIteratorOfListIO anIter( aListIO );
+    for( ; anIter.More(); anIter.Next() )
+    {
+      Handle(SALOME_InteractiveObject) aPrsObj = anIter.Value();
+      if ( !aPrsObj.IsNull() )
+      {
+        Handle(HYDROData_Entity) anOwnerObj = 
+          module()->getDataModel()->objectByEntry( aPrsObj->getEntry() );
+        if ( !anOwnerObj.IsNull() && anOwnerObj->IsRemoved() )
+        {
+          aPrs = module()->getObjectVTKPrs( (size_t)aViewer, anOwnerObj );
+          if ( aPrs )
+          {
+            aViewer->Erase( aPrs );
+          }
+          module()->removeObjectVTKPrs( (size_t)aViewer, anOwnerObj );
+        }
+      }
+    }
+  }
+}
+
+HYDROGUI_VTKPrsDriver* HYDROGUI_VTKPrsDisplayer::getDriver( const Handle(HYDROData_Entity)& theObj )
+{
+  HYDROGUI_VTKPrsDriver* aDriver = NULL;
+  ObjectKind aKind = theObj->GetKind();
+  if( theObj->GetKind() == KIND_BATHYMETRY )
+  {
+    if ( !myDriver )
+    {
+      myDriver = new HYDROGUI_VTKPrsBathymetryDriver();
+    }
+    aDriver = myDriver;
+  }
+
+  return aDriver;
+}
+
+QString HYDROGUI_VTKPrsDisplayer::GetType() const
+{
+  return SVTK_Viewer::Type();
+}
diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.h b/src/HYDROGUI/HYDROGUI_VTKPrsDisplayer.h
new file mode 100644 (file)
index 0000000..6e53647
--- /dev/null
@@ -0,0 +1,106 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_VTKPRSDISPLAYER_H
+#define HYDROGUI_VTKPRSDISPLAYER_H
+
+#include "HYDROGUI_AbstractDisplayer.h"
+
+class HYDROGUI_VTKPrsDriver;
+
+/**
+ * \class HYDROGUI_VTKPrsDisplayer
+ * \brief Class intended to create, display and update the presentations in VTK viewer.
+ */
+class HYDROGUI_VTKPrsDisplayer : public HYDROGUI_AbstractDisplayer
+{
+public:
+  /**
+   * \brief Constructor.
+   * \param theModule module object
+   */
+  HYDROGUI_VTKPrsDisplayer( HYDROGUI_Module* theModule );
+
+  /**
+   * \brief Destructor.
+   */
+  virtual ~HYDROGUI_VTKPrsDisplayer();
+
+public:
+  /**
+   * \brief Force the specified objects to be updated.
+   * \param theObjs sequence of objects to update
+   * \param theViewerId viewer identifier
+   */
+  void             SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
+                                const int theViewerId );
+
+  /**
+   * \brief Get the applicable viewer type.
+   */
+  virtual QString  GetType() const;
+
+protected:
+  /**
+   * \brief Erase all viewer objects.
+   * \param theViewerId viewer identifier
+   */
+  void             EraseAll( const int theViewerId );
+
+  /**
+   * \brief Erase the specified viewer objects.
+   * \param theObjs sequence of objects to erase
+   * \param theViewerId viewer identifier
+   */
+  void             Erase( const HYDROData_SequenceOfObjects& theObjs,
+                          const int theViewerId );
+
+  /**
+   * \brief Display the specified viewer objects.
+   * \param theObjs sequence of objects to display
+   * \param theViewerId viewer identifier
+   * \param theIsForced flag used to update all objects, including the unchanged ones
+   * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default
+   */
+  void             Display( const HYDROData_SequenceOfObjects& theObjs,
+                            const int theViewerId,
+                            const bool theIsForced,
+                            const bool theDoFitAll );
+
+protected:
+  /**
+   * \brief Purge all invalid objects in the viewer.
+   * \param theViewerId viewer identifier
+   */
+  void             purgeObjects( const int theViewerId );
+
+private:
+  /**
+   * \brief Get the presentation driver for the specified data object.
+   * \param theObj data object
+   */
+  HYDROGUI_VTKPrsDriver* getDriver( const Handle(HYDROData_Entity)& theObj );
+
+  HYDROGUI_VTKPrsDriver* myDriver;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsDriver.cxx b/src/HYDROGUI/HYDROGUI_VTKPrsDriver.cxx
new file mode 100644 (file)
index 0000000..1dceef4
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_VTKPrsDriver.h"
+
+#include "HYDROGUI_VTKPrs.h"
+
+HYDROGUI_VTKPrsDriver::HYDROGUI_VTKPrsDriver()
+{
+}
+
+HYDROGUI_VTKPrsDriver::~HYDROGUI_VTKPrsDriver()
+{
+}
+
+bool HYDROGUI_VTKPrsDriver::Update( const Handle(HYDROData_Entity)& theObj,
+                                 HYDROGUI_VTKPrs*& thePrs )
+{
+  if ( thePrs )
+    thePrs->setIsToUpdate( false );
+  return true;
+}
diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsDriver.h b/src/HYDROGUI/HYDROGUI_VTKPrsDriver.h
new file mode 100644 (file)
index 0000000..a66a25d
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_VTKPrsDRIVER_H
+#define HYDROGUI_VTKPrsDRIVER_H
+
+#include <HYDROData_Entity.h>
+
+class HYDROGUI_VTKPrs;
+
+/**
+ * \class HYDROGUI_VTKPrsDriver
+ * \brief Base class of presentation driver, which allows to build a
+ *        VTK presentation on a basis of data object.
+ */
+class HYDROGUI_VTKPrsDriver
+{
+public:
+  /**
+   * \brief Constructor.
+   */
+  HYDROGUI_VTKPrsDriver();
+
+  /**
+   * \brief Destructor.
+   */
+  virtual ~HYDROGUI_VTKPrsDriver();
+
+public:
+  /**
+   * \brief Virtual method intended to update or create the presentation
+   *        on a basis of data object.
+   * \param theObj data object
+   * \param thePrs presentation
+   * \return status of the operation
+   */
+  virtual bool Update( const Handle(HYDROData_Entity)& theObj,
+                       HYDROGUI_VTKPrs*& thePrs );
+};
+
+#endif