HYDROData_Confluence.h
HYDROData_Digue.h
HYDROData_Document.h
+ HYDROData_DummyObject3D.h
HYDROData_Entity.h
HYDROData_IAltitudeObject.h
HYDROData_Image.h
HYDROData_Object.h
HYDROData_Obstacle.h
HYDROData_OperationsFactory.h
-# HYDROData_Polyline.h
HYDROData_PolylineXY.h
HYDROData_Polyline3D.h
HYDROData_Profile.h
HYDROData_Confluence.cxx
HYDROData_Digue.cxx
HYDROData_Document.cxx
+ HYDROData_DummyObject3D.cxx
HYDROData_Entity.cxx
HYDROData_IAltitudeObject.cxx
HYDROData_Image.cxx
HYDROData_Object.cxx
HYDROData_Obstacle.cxx
HYDROData_OperationsFactory.cxx
-# HYDROData_Polyline.cxx
HYDROData_PolylineXY.cxx
HYDROData_Polyline3D.cxx
HYDROData_Profile.cxx
--- /dev/null
+
+#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;
+}
+
+
--- /dev/null
+
+#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
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)
#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"
case KIND_VISUAL_STATE:
aResult = new HYDROData_VisualState();
break;
+ case KIND_DUMMY_3D:
+ aResult = new HYDROData_DummyObject3D();
+ break;
default:
break;
}
#include "HYDROData_Object.h"
#include "HYDROData_Bathymetry.h"
+#include "HYDROData_DummyObject3D.h"
+#include "HYDROData_Iterator.h"
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
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 ) );
{
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()
#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.
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:
*/
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.
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.
*/
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.
*/
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;
*/
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;
#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>
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 )
#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,
}
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 );
bool anIsChannel = false;
bool anIsDigue = false;
bool anIsGeomObject = false;
+ bool anIsDummyObject3D = false;
// check the selected GEOM objects
if ( anIsObjectBrowser && !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) {
anIsChannel = true;
else if( anObjectKind == KIND_DIGUE )
anIsDigue = true;
+ else if( anObjectKind == KIND_DUMMY_3D )
+ anIsDummyObject3D = true;
}
anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject );
if( anIsImage || anIsPolyline || anIsPolyline3D ||
anIsImmersibleZone || anIsZone || anIsRegion ||
anIsBathymetry || anIsObstacle || anIsStream ||
- anIsChannel || anIsDigue || anIsValidProfile )
+ anIsChannel || anIsDigue || anIsDummyObject3D ||
+ anIsValidProfile )
{
if( anIsHiddenInSelection )
theMenu->addAction( action( ShowId ) );
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 );
#include <HYDROData_Channel.h>
#include <HYDROData_Document.h>
+#include <HYDROData_DummyObject3D.h>
#include <HYDROData_Image.h>
#include <HYDROData_ImmersibleZone.h>
#include <HYDROData_Obstacle.h>
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 =
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 );
#include <SALOMEDSClient.hxx>
+#include <SVTK_ViewModel.h>
+
#include <QDir>
#include <QFileInfo>
#include <QDockWidget>
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 )
{
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 );
}
}
}
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