]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Fictive 3D object for objects with 2 types of presentation (Bug #216).
authoradv <adv@opencascade.com>
Wed, 11 Dec 2013 08:52:35 +0000 (08:52 +0000)
committeradv <adv@opencascade.com>
Wed, 11 Dec 2013 08:52:35 +0000 (08:52 +0000)
16 files changed:
src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData_DummyObject3D.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_DummyObject3D.h [new file with mode: 0644]
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_Iterator.cxx
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROData/HYDROData_Polyline3D.h
src/HYDROData/HYDROData_Profile.h
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_DataObject.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_Tool.h

index f5b04d56f8ab9a1b260368d1fe8d8472aee5fc39..aa8b61327f1e345e71f95a0268992f30988a88e0 100644 (file)
@@ -12,6 +12,7 @@ set(PROJECT_HEADERS
     HYDROData_Confluence.h
     HYDROData_Digue.h
     HYDROData_Document.h
+    HYDROData_DummyObject3D.h
     HYDROData_Entity.h
     HYDROData_IAltitudeObject.h
     HYDROData_Image.h
@@ -23,7 +24,6 @@ set(PROJECT_HEADERS
     HYDROData_Object.h
     HYDROData_Obstacle.h
     HYDROData_OperationsFactory.h
-#    HYDROData_Polyline.h
     HYDROData_PolylineXY.h
     HYDROData_Polyline3D.h
     HYDROData_Profile.h
@@ -48,6 +48,7 @@ set(PROJECT_SOURCES
     HYDROData_Confluence.cxx
     HYDROData_Digue.cxx
     HYDROData_Document.cxx
+    HYDROData_DummyObject3D.cxx
     HYDROData_Entity.cxx
     HYDROData_IAltitudeObject.cxx
     HYDROData_Image.cxx
@@ -59,7 +60,6 @@ set(PROJECT_SOURCES
     HYDROData_Object.cxx
     HYDROData_Obstacle.cxx
     HYDROData_OperationsFactory.cxx
-#    HYDROData_Polyline.cxx
     HYDROData_PolylineXY.cxx
     HYDROData_Polyline3D.cxx
     HYDROData_Profile.cxx
diff --git a/src/HYDROData/HYDROData_DummyObject3D.cxx b/src/HYDROData/HYDROData_DummyObject3D.cxx
new file mode 100644 (file)
index 0000000..d8af281
--- /dev/null
@@ -0,0 +1,84 @@
+
+#include "HYDROData_DummyObject3D.h"
+
+#include "HYDROData_Object.h"
+
+#include <TopoDS_Shape.hxx>
+
+#include <QString>
+#include <QColor>
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_DummyObject3D,HYDROData_Entity)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_DummyObject3D,HYDROData_Entity)
+
+HYDROData_DummyObject3D::HYDROData_DummyObject3D()
+: HYDROData_Entity()
+{
+}
+
+HYDROData_DummyObject3D::~HYDROData_DummyObject3D()
+{
+}
+
+QString HYDROData_DummyObject3D::GetName() const
+{
+  QString aName;
+
+  Handle(HYDROData_Object) aFatherObj = GetObject();
+  if ( !aFatherObj.IsNull() )
+    aName = aFatherObj->GetName();
+
+  aName += "_3D";
+
+  return aName;
+}
+
+bool HYDROData_DummyObject3D::CanBeUpdated() const
+{
+  return false;
+}
+
+bool HYDROData_DummyObject3D::CanRemove()
+{
+  return false;
+}
+
+Handle(HYDROData_Object) HYDROData_DummyObject3D::GetObject() const
+{
+  return Handle(HYDROData_Object)::DownCast( GetFatherObject() );
+}
+
+TopoDS_Shape HYDROData_DummyObject3D::GetShape() const
+{
+  TopoDS_Shape aResShape;
+
+  Handle(HYDROData_Object) aFatherObj = GetObject();
+  if ( !aFatherObj.IsNull() )
+    aResShape = aFatherObj->GetShape3D();
+
+  return aResShape;
+}
+
+QColor HYDROData_DummyObject3D::GetFillingColor() const
+{
+  QColor aResColor( HYDROData_Object::DefaultFillingColor() );
+
+  Handle(HYDROData_Object) aFatherObj = GetObject();
+  if ( !aFatherObj.IsNull() )
+    aResColor = aFatherObj->GetFillingColor();
+
+  return aResColor;
+}
+
+QColor HYDROData_DummyObject3D::GetBorderColor() const
+{
+  QColor aResColor( HYDROData_Object::DefaultBorderColor() );
+
+  Handle(HYDROData_Object) aFatherObj = GetObject();
+  if ( !aFatherObj.IsNull() )
+    aResColor = aFatherObj->GetBorderColor();
+
+  return aResColor;
+}
+
+
diff --git a/src/HYDROData/HYDROData_DummyObject3D.h b/src/HYDROData/HYDROData_DummyObject3D.h
new file mode 100644 (file)
index 0000000..e1222fa
--- /dev/null
@@ -0,0 +1,91 @@
+
+#ifndef HYDROData_DummyObject3D_HeaderFile
+#define HYDROData_DummyObject3D_HeaderFile
+
+#include <HYDROData_Entity.h>
+
+DEFINE_STANDARD_HANDLE(HYDROData_DummyObject3D, HYDROData_Entity)
+
+class Handle(HYDROData_Object);
+class TopoDS_Shape;
+
+/**\class HYDROData_DummyObject3D
+ * \brief The artificial objects are objects created or planned for creation by human.
+ *
+ */
+class HYDROData_DummyObject3D : public HYDROData_Entity
+{
+protected:
+  /**
+   * Enumeration of tags corresponding to the persistent object parameters.
+   */
+  enum DataTag
+  {
+    DataTag_First = HYDROData_Entity::DataTag_First + 100 ///< first tag, to reserve
+  };
+
+public:
+  DEFINE_STANDARD_RTTI(HYDROData_DummyObject3D);
+
+public:
+
+  /**
+   * Returns the kind of this object. Must be redefined in all objects of known type.
+   */
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_DUMMY_3D; }
+
+  /**
+   * Returns the name of this object.
+   */
+  HYDRODATA_EXPORT virtual QString GetName() const;
+
+  /**
+   * Returns flag indicating that object is updateble or not.
+   */
+  HYDRODATA_EXPORT virtual bool CanBeUpdated() const;
+
+  /**
+   * Returns flag indicating that object can be removed or not.
+   */
+  HYDRODATA_EXPORT virtual bool CanRemove();
+
+
+  /**
+   * Returns the parent object.
+   */
+  HYDRODATA_EXPORT Handle(HYDROData_Object) GetObject() const;
+
+  /**
+   * Returns the 3d shape of the parent object.
+   */
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() const;
+
+
+  /**
+   * Returns filling color of object.
+   */
+  HYDRODATA_EXPORT virtual QColor GetFillingColor() const;
+
+  /**
+   * Returns border color of object.
+   */
+  HYDRODATA_EXPORT virtual QColor GetBorderColor() const;
+
+
+protected:
+
+  friend class HYDROData_Iterator;
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDRODATA_EXPORT HYDROData_DummyObject3D();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  virtual HYDRODATA_EXPORT ~HYDROData_DummyObject3D();
+};
+
+#endif
index b1211e45336ef4b3a3340cc57e1eea2c92ea1d27..de2fa87dc38f3406e66a91c3b6c9ff5c40351e2a 100644 (file)
@@ -41,7 +41,8 @@ const ObjectKind KIND_REGION            = 17;
 const ObjectKind KIND_VISUAL_STATE      = 18;
 const ObjectKind KIND_ARTIFICIAL_OBJECT = 19;
 const ObjectKind KIND_NATURAL_OBJECT    = 20;
-const ObjectKind KIND_LAST              = KIND_NATURAL_OBJECT;
+const ObjectKind KIND_DUMMY_3D          = 21;
+const ObjectKind KIND_LAST              = KIND_DUMMY_3D;
 
 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
 
index 734356260d90a69f7bb04f0daae004ea1bf2dbbc..4d61c1508263c44df27d31b156bc3c198548cee5 100644 (file)
@@ -6,6 +6,7 @@
 #include "HYDROData_CalculationCase.h"
 #include "HYDROData_Channel.h"
 #include "HYDROData_Confluence.h"
+#include "HYDROData_DummyObject3D.h"
 #include "HYDROData_Digue.h"
 #include "HYDROData_Image.h"
 #include "HYDROData_ImmersibleZone.h"
@@ -158,6 +159,9 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel )
     case KIND_VISUAL_STATE:
       aResult = new HYDROData_VisualState();
       break;
+    case KIND_DUMMY_3D:
+      aResult = new HYDROData_DummyObject3D();
+      break;
     default:
       break;
   }
index 3efd5c7bfad7bfc46a5248376ba31af5d0ff340d..5349d354169574155e9a35e97f47d6984f779571 100644 (file)
@@ -2,6 +2,8 @@
 #include "HYDROData_Object.h"
 
 #include "HYDROData_Bathymetry.h"
+#include "HYDROData_DummyObject3D.h"
+#include "HYDROData_Iterator.h"
 
 #include <TNaming_Builder.hxx>
 #include <TNaming_NamedShape.hxx>
@@ -33,6 +35,15 @@ HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const
   return aResSeq;
 }
 
+void HYDROData_Object::SetToUpdate( bool theFlag )
+{
+  HYDROData_Entity::SetToUpdate( theFlag );
+
+  Handle(HYDROData_DummyObject3D) anObject3D = GetObject3D();
+  if ( !anObject3D.IsNull() )
+    anObject3D->SetToUpdate( theFlag );
+}
+
 void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape )
 {
   TNaming_Builder aBuilder( myLab.FindChild( DataTag_TopShape ) );
@@ -43,6 +54,37 @@ void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape )
 {
   TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape3D ) );
   aBuilder.Generated( theShape );
+  
+  // Check the object 3D existance
+  checkAndSetObject3D();
+}
+
+Handle(HYDROData_DummyObject3D) HYDROData_Object::GetObject3D() const
+{
+  Handle(HYDROData_DummyObject3D) anObject;
+  
+  TDF_Label aLabel = myLab.FindChild( DataTag_Object3D, false );
+  if ( !aLabel.IsNull() )
+  {
+    TDF_Label aChildLabel = aLabel.FindChild( 0, false );
+    if ( !aChildLabel.IsNull() )
+    {
+      anObject = Handle(HYDROData_DummyObject3D)::DownCast(
+        HYDROData_Iterator::Object( aChildLabel ) );
+    }
+  }
+
+  return anObject;
+}
+
+void HYDROData_Object::checkAndSetObject3D()
+{
+  TDF_Label aLabel = myLab.FindChild( DataTag_Object3D, false );
+  if ( !aLabel.IsNull() )
+    return;
+
+  TDF_Label aChildLabel = myLab.FindChild( DataTag_Object3D ).FindChild( 0 );
+  HYDROData_Iterator::CreateObject( aChildLabel, KIND_DUMMY_3D );
 }
 
 void HYDROData_Object::Update()
index 053a39e4a808f65c234cc946e45fa929def83499..3eb3824872f878ee68bc4229628d275f72e50733 100644 (file)
@@ -4,11 +4,12 @@
 
 #include <HYDROData_Entity.h>
 
-class TopoDS_Shape;
 
 DEFINE_STANDARD_HANDLE(HYDROData_Object, HYDROData_Entity)
 
+class TopoDS_Shape;
 class Handle(HYDROData_Bathymetry);
+class Handle(HYDROData_DummyObject3D);
 
 /**\class HYDROData_Object
  * \brief The base class for all geometrical objects in the HYDRO module.
@@ -27,7 +28,8 @@ protected:
     DataTag_Shape3D,
     DataTag_Bathymetry,   ///< reference bathymetry
     DataTag_FillingColor, ///< filling color of geometrical object
-    DataTag_BorderColor   ///< border color of geometrical object
+    DataTag_BorderColor,  ///< border color of geometrical object
+    DataTag_Object3D      ///< child 3D object
   };
 
 public:
@@ -44,6 +46,12 @@ public:
    */
   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
 
+  /**
+   * Sets the "MustBeUpdated" flag: if object is depended on updated features.
+   * Reimplemented to update the state of child 3D object.
+   */
+  HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag );
+
 
   /**
    * Sets the top(2d projection) shape of the object.
@@ -66,6 +74,13 @@ public:
   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const = 0;
 
   
+  /**
+   * Returns reference object which represent the 3D shape of object.
+   * Base implementation returns NULL pointer.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_DummyObject3D) GetObject3D() const;
+
+
   /**
    * Set reference bathymetry object for geometry object.
    */
@@ -126,6 +141,13 @@ protected:
 
 protected:
 
+  /**
+   * Checks and if necessary create child 3D object.
+   * Reimplement this function in your subclass if you 
+   * do not want to create child 3D object.
+   */
+  HYDRODATA_EXPORT virtual void checkAndSetObject3D();
+
   /**
    * Retrieve the top shape of the object from data label.
    */
index 67e93e20f9e147e76d6898174466f722fdbc8dfc..16c6f6e6e751e0de8dd90bb3c43544315a1efb87 100644 (file)
@@ -102,6 +102,15 @@ public:
   HYDRODATA_EXPORT virtual void RemoveProfileUZ();
 
 
+protected:
+
+  /**
+   * Checks and if necessary create child 3D object.
+   * Reimplemented to prevent creation of 3D child object.
+   */
+  HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
+
+
 protected:
 
   friend class HYDROData_Iterator;
index eabbb395fe94ddba2d2ae851952b9d0c2bdf5833..9f8aa531c06efb031ddc7048d6149cedc80ddd48 100644 (file)
@@ -196,6 +196,15 @@ public:
    */
   HYDRODATA_EXPORT virtual bool ImportFromFile( OSD_File& theFile );
 
+protected:
+
+  /**
+   * Checks and if necessary create child 3D object.
+   * Reimplemented to prevent creation of 3D child object.
+   */
+  HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
+
+
 protected:
 
   friend class HYDROData_Iterator;
index 2369f1f52e58533dd3f44eff1453c7b70e8056a2..a436ec17b755f946242195c239438158956f5e79 100644 (file)
@@ -31,6 +31,7 @@
 #include <HYDROData_Bathymetry.h>
 #include <HYDROData_CalculationCase.h>
 #include <HYDROData_Document.h>
+#include <HYDROData_DummyObject3D.h>
 #include <HYDROData_Image.h>
 #include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Iterator.h>
@@ -706,6 +707,16 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
   if ( aDataObj.IsNull() )
     return;
 
+  if ( aDataObj->IsKind( STANDARD_TYPE(HYDROData_Object) ) )
+  {
+    Handle(HYDROData_Object) aGeomObj =
+      Handle(HYDROData_Object)::DownCast( aDataObj );
+
+    Handle(HYDROData_DummyObject3D) anObject3D = aGeomObj->GetObject3D();
+    if ( !anObject3D.IsNull() )
+      createObject( aGuiObj, anObject3D, aGuiObj->entry(), false );
+  }
+
   ObjectKind anObjectKind = aDataObj->GetKind();
 
   if ( anObjectKind == KIND_IMAGE )
index a201b3e6320de970b369cc2cc1e73644199a524c..a3227a7d63c61c37264e45ff992f7155fdb1215d 100644 (file)
 
 #include "HYDROGUI_DataObject.h"
 
-#include <SUIT_DataObject.h>
+#include <HYDROData_DummyObject3D.h>
+#include <HYDROData_Object.h>
+
 #include <TDF_Tool.hxx>
+
+#include <SUIT_DataObject.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
+
 #include <QPixmap>
 
 HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent, 
@@ -141,12 +146,20 @@ QPixmap HYDROGUI_DataObject::icon( const int theId ) const
     }
     else
     {
-      QString aNeedUpdate = "";
-      if ( aDataObject->IsMustBeUpdated() )
+      QString aNeedUpdate( aDataObject->IsMustBeUpdated() ? "M_" : "" );
+
+      int anObjectKind = (int)aDataObject->GetKind();
+      if ( anObjectKind == KIND_DUMMY_3D )
       {
-        aNeedUpdate = "M_";
+        Handle(HYDROData_DummyObject3D) anObject3D = 
+          Handle(HYDROData_DummyObject3D)::DownCast( aDataObject );
+        
+        Handle(HYDROData_Object) aFatherObj = anObject3D->GetObject();
+        if ( !aFatherObj.IsNull() )
+          anObjectKind = aFatherObj->GetKind();
       }
-      anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( (int)aDataObject->GetKind() ).toAscii() );
+
+      anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toAscii() );
     }
 
     return aResMgr->loadPixmap( "HYDRO", anIcon );
index 7244bab70c5448c06576aef30aa561bff201f1ef..5534edf5584b7b38061db6369f8078ddd1d21af2 100644 (file)
@@ -306,6 +306,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsChannel = false;
   bool anIsDigue = false;
   bool anIsGeomObject = false;
+  bool anIsDummyObject3D = false;
 
   // check the selected GEOM objects
   if ( anIsObjectBrowser && !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) {
@@ -391,6 +392,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsChannel = true;
       else if( anObjectKind == KIND_DIGUE )
         anIsDigue = true;
+      else if( anObjectKind == KIND_DUMMY_3D )
+        anIsDummyObject3D = true;
     }
 
     anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject );
@@ -559,7 +562,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     if( anIsImage || anIsPolyline || anIsPolyline3D || 
         anIsImmersibleZone || anIsZone || anIsRegion ||
         anIsBathymetry || anIsObstacle || anIsStream ||
-        anIsChannel || anIsDigue || anIsValidProfile )
+        anIsChannel || anIsDigue || anIsDummyObject3D ||
+        anIsValidProfile )
     {
       if( anIsHiddenInSelection )
         theMenu->addAction( action( ShowId ) );
index 973210e24e775fd5f94043de0d8c56244e36e31c..39810702fbeaccabbfdbc72d8898469c6b6a041b 100644 (file)
@@ -100,18 +100,7 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int
   if ( theContext.IsNull() || theObject.IsNull() )
     return aResShape;
 
-  ObjectKind anObjectKind = theObject->GetKind();
-  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 )
+  if ( !HYDROGUI_Tool::IsObjectHasPresentation( theObject, OCCViewer_Viewer::Type() ) )
     return aResShape;
 
   aResShape = new HYDROGUI_Shape( theContext, theObject );
index c53f1d0aea34c8769bbcb1ab5c644a5f15be0198..9967bc006c2fdf2952ea63b4b5a1e5a3031919d2 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <HYDROData_Channel.h>
 #include <HYDROData_Document.h>
+#include <HYDROData_DummyObject3D.h>
 #include <HYDROData_Image.h>
 #include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Obstacle.h>
@@ -289,26 +290,6 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
       setTextureFileName( aTextureFileName, false, false );
       setFace( aWire, false, false );
     }
-    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Obstacle) ) )
-    {
-      Handle(HYDROData_Obstacle) anObstacle =
-        Handle(HYDROData_Obstacle)::DownCast( myObject );
-
-      //TODO BEGIN of the block of code to be reimplemented
-      //TODO GetTopShape() to be used in future
-      myTopoShape = anObstacle->GetShape3D();
-      myDisplayMode = AIS_Shaded;
-
-      QColor aFillingColor = anObstacle->GetFillingColor();
-      QColor aBorderColor = anObstacle->GetBorderColor();
-
-      setFillingColor( aFillingColor, false, false );
-      setBorderColor( aBorderColor, false, false );
-
-      buildShape();
-      updateShape( false, false );
-      //TODO END of the block of code to be reimplemented
-    }
     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Profile) ) )
     {
       Handle(HYDROData_Profile) aProfile =
@@ -327,33 +308,34 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
 
       setWire( aProfileWire, false, false );  
     }
-    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Stream) ) )
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Stream) ) ||
+              myObject->IsKind( STANDARD_TYPE(HYDROData_Channel) ) ||
+              myObject->IsKind( STANDARD_TYPE(HYDROData_Obstacle) ) )
     {
-      Handle(HYDROData_Stream) aStream =
-        Handle(HYDROData_Stream)::DownCast( myObject );
+      Handle(HYDROData_Object) aGeomObject =
+        Handle(HYDROData_Object)::DownCast( myObject );
 
-      TopoDS_Shape aStreamShape = aStream->GetTopShape();
+      TopoDS_Shape anObjShape = aGeomObject->GetTopShape();
 
-      setShape( aStreamShape, false, false );
+      setShape( anObjShape, false, false );
 
-      QColor aFillingColor = aStream->GetFillingColor();
-      QColor aBorderColor = aStream->GetBorderColor();
+      QColor aFillingColor = aGeomObject->GetFillingColor();
+      QColor aBorderColor = aGeomObject->GetBorderColor();
 
       setFillingColor( aFillingColor, false, false );
       setBorderColor( aBorderColor, false, false );
     }
-    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Channel) ) )
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_DummyObject3D) ) )
     {
-      Handle(HYDROData_Channel) aChannel =
-        Handle(HYDROData_Channel)::DownCast( myObject );
+      Handle(HYDROData_DummyObject3D) anObject3D =
+        Handle(HYDROData_DummyObject3D)::DownCast( myObject );
 
-      TopoDS_Face aChannelShape2d = TopoDS::Face( aChannel->GetTopShape() );
-      TopoDS_Shape aChannelShape = aChannel->GetShape3D();
+      TopoDS_Shape aShape3D = anObject3D->GetShape();
 
-      setShape( aChannelShape, false, false );
+      setShape( aShape3D, false, false );
 
-      QColor aFillingColor = aChannel->GetFillingColor();
-      QColor aBorderColor = aChannel->GetBorderColor();
+      QColor aFillingColor = anObject3D->GetFillingColor();
+      QColor aBorderColor = anObject3D->GetBorderColor();
 
       setFillingColor( aFillingColor, false, false );
       setBorderColor( aBorderColor, false, false );
index 14b8836bc9c51054ee1c9f1ec13f4686e68d7acc..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,22 +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 ) ||
-        ( anObject->GetKind() == KIND_DIGUE ) ) )
-      {
-        theSeq.Append( anObject );
-      }
+      if ( !IsObjectHasPresentation( anObject ) )
+        continue;
+
+      theSeq.Append( anObject );
     }
   }
 }
index 48c8e246dcc0903ae4a20fc2613475074777760b..c3d971dad45b74813666fb485354cab02ae026ae 100644 (file)
@@ -112,6 +112,14 @@ public:
                                                         SUIT_ViewManager* theViewManager );
 
   /**
+   * \brief Returns TRUE if object can be shown on the viewer.
+   * \param theObject data model object to check
+   * \param theViewerType viewer type
+   */
+  static bool                     IsObjectHasPresentation( const Handle(HYDROData_Entity)& theObject,
+                                                           const QString&                  theViewerType = "" );
+
+/**
    * \brief Get sub-objects to build presentations.
    * \param theModule module
    * \param theSeq sequence of sub-objects