Salome HOME
17.12.2013. Added Partition algorithm (draft version).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Tool.cxx
index da585626e88ea249033e48cd03d9a717521a974d..ccea02da1c095767d823957baa15b069e0dd71d3 100644 (file)
@@ -57,6 +57,8 @@
 
 #include <SALOMEDSClient.hxx>
 
+#include <SVTK_ViewModel.h>
+
 #include <QDir>
 #include <QFileInfo>
 #include <QDockWidget>
@@ -204,6 +206,49 @@ void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule,
           aWorkstack->setActiveWindow( aViewWindow );
 }
 
+bool HYDROGUI_Tool::IsObjectHasPresentation( const Handle(HYDROData_Entity)& theObject,
+                                             const QString&                  theViewerType )
+{
+  
+  if ( theObject.IsNull() )
+    return false;
+
+  ObjectKind anObjectKind = theObject->GetKind();
+  if ( theViewerType.isEmpty() || theViewerType == OCCViewer_Viewer::Type() )
+  {
+    if ( anObjectKind == KIND_IMAGE ||
+         anObjectKind == KIND_POLYLINEXY ||
+         anObjectKind == KIND_POLYLINE ||
+         anObjectKind == KIND_IMMERSIBLE_ZONE ||
+         anObjectKind == KIND_REGION ||
+         anObjectKind == KIND_ZONE ||
+         anObjectKind == KIND_OBSTACLE ||
+         anObjectKind == KIND_PROFILE ||
+         anObjectKind == KIND_STREAM ||
+         anObjectKind == KIND_CHANNEL ||
+         anObjectKind == KIND_DIGUE ||
+         anObjectKind == KIND_DUMMY_3D )
+    {
+      return true;
+    }
+  }
+  
+  if ( theViewerType.isEmpty() || theViewerType == SVTK_Viewer::Type() )
+  {
+    if ( anObjectKind == KIND_BATHYMETRY )
+      return true;
+  }
+
+  if ( theViewerType.isEmpty() || theViewerType == GraphicsView_Viewer::Type() )
+  {
+    if ( anObjectKind == KIND_IMAGE ||
+         anObjectKind == KIND_POLYLINEXY )
+      return true;
+  }
+
+  return false;
+}
+
 void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
                                       HYDROData_SequenceOfObjects& theSeq )
 {
@@ -214,21 +259,10 @@ void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
     for( ; anIterator.More(); anIterator.Next() )
     {
       Handle(HYDROData_Entity) anObject = anIterator.Current();
-      if( !anObject.IsNull() && ( 
-        ( anObject->GetKind() == KIND_IMAGE ) ||
-        ( anObject->GetKind() == KIND_POLYLINEXY ) ||
-        ( 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 ) ||
-        ( anObject->GetKind() == KIND_PROFILE ) ||
-        ( anObject->GetKind() == KIND_STREAM ) ||
-        ( anObject->GetKind() == KIND_CHANNEL ) ) )
-      {
-        theSeq.Append( anObject );
-      }
+      if ( !IsObjectHasPresentation( anObject ) )
+        continue;
+
+      theSeq.Append( anObject );
     }
   }
 }