From: adv Date: Wed, 11 Dec 2013 08:52:35 +0000 (+0000) Subject: Fictive 3D object for objects with 2 types of presentation (Bug #216). X-Git-Tag: BR_hydro_v_0_5~26 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=89c9794998495fcd82e49e22a75502367de46bd5;p=modules%2Fhydro.git Fictive 3D object for objects with 2 types of presentation (Bug #216). --- diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index f5b04d56..aa8b6132 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -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 index 00000000..d8af281c --- /dev/null +++ b/src/HYDROData/HYDROData_DummyObject3D.cxx @@ -0,0 +1,84 @@ + +#include "HYDROData_DummyObject3D.h" + +#include "HYDROData_Object.h" + +#include + +#include +#include + +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 index 00000000..e1222fa6 --- /dev/null +++ b/src/HYDROData/HYDROData_DummyObject3D.h @@ -0,0 +1,91 @@ + +#ifndef HYDROData_DummyObject3D_HeaderFile +#define HYDROData_DummyObject3D_HeaderFile + +#include + +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 diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index b1211e45..de2fa87d 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -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) diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index 73435626..4d61c150 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -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; } diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 3efd5c7b..5349d354 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -2,6 +2,8 @@ #include "HYDROData_Object.h" #include "HYDROData_Bathymetry.h" +#include "HYDROData_DummyObject3D.h" +#include "HYDROData_Iterator.h" #include #include @@ -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() diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index 053a39e4..3eb38248 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -4,11 +4,12 @@ #include -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. */ diff --git a/src/HYDROData/HYDROData_Polyline3D.h b/src/HYDROData/HYDROData_Polyline3D.h index 67e93e20..16c6f6e6 100644 --- a/src/HYDROData/HYDROData_Polyline3D.h +++ b/src/HYDROData/HYDROData_Polyline3D.h @@ -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; diff --git a/src/HYDROData/HYDROData_Profile.h b/src/HYDROData/HYDROData_Profile.h index eabbb395..9f8aa531 100644 --- a/src/HYDROData/HYDROData_Profile.h +++ b/src/HYDROData/HYDROData_Profile.h @@ -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; diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 2369f1f5..a436ec17 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -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 ) diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx index a201b3e6..a3227a7d 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -22,10 +22,15 @@ #include "HYDROGUI_DataObject.h" -#include +#include +#include + #include + +#include #include #include + #include 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 ); diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 7244bab7..5534edf5 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -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 ) ); diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index 973210e2..39810702 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -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 ); diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index c53f1d0a..9967bc00 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -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 ); diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index 14b8836b..ccea02da 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -57,6 +57,8 @@ #include +#include + #include #include #include @@ -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 ); } } } diff --git a/src/HYDROGUI/HYDROGUI_Tool.h b/src/HYDROGUI/HYDROGUI_Tool.h index 48c8e246..c3d971da 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.h +++ b/src/HYDROGUI/HYDROGUI_Tool.h @@ -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