#include "HYDROData_LandCover.h"
+#include "HYDROData_PolylineXY.h"
+
+#include <TDataStd_AsciiString.hxx>
+#include <TNaming_Builder.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <QStringList>
+
IMPLEMENT_STANDARD_HANDLE( HYDROData_LandCover, HYDROData_Entity )
IMPLEMENT_STANDARD_RTTIEXT( HYDROData_LandCover, HYDROData_Entity )
{
}
-
HYDROData_LandCover::~HYDROData_LandCover()
{
}
{
return KIND_LAND_COVER;
}
+
+QStringList HYDROData_LandCover::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+ QStringList aResList = dumpObjectCreation( theTreatedObjects );
+ QString aName = GetObjPyName();
+
+ // Set Strickler type
+ QString aType = GetStricklerType();
+ if ( !aType.isEmpty() ) {
+ aResList << QString( "" );
+ ///< \TODO to be implemented:
+ // aResList << QString( "%1.SetStricklerType( \"%2\" );" ).arg( aName ).arg( aType );
+ aResList << QString( "" );
+ }
+
+ // Set polylines
+ ///< \TODO to be implemented:
+
+ aResList << QString( "" );
+ aResList << QString( "%1.Update();" ).arg( aName );
+ aResList << QString( "" );
+
+ return aResList;
+}
+
+HYDROData_SequenceOfObjects HYDROData_LandCover::GetAllReferenceObjects() const
+{
+ HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
+
+ HYDROData_SequenceOfObjects aSeqOfPolylines = GetPolylines();
+ aResSeq.Append( aSeqOfPolylines );
+
+ return aResSeq;
+}
+
+bool HYDROData_LandCover::IsHas2dPrs() const
+{
+ return true;
+}
+
+void HYDROData_LandCover::SetStricklerType( const QString& theType )
+{
+ TCollection_AsciiString anAsciiStr( theType.toStdString().c_str() );
+ TDataStd_AsciiString::Set( myLab.FindChild( DataTag_StricklerType ), anAsciiStr );
+}
+
+QString HYDROData_LandCover::GetStricklerType() const
+{
+ QString aType;
+
+ TDF_Label aLabel = myLab.FindChild( DataTag_StricklerType, false );
+ if ( !aLabel.IsNull() ) {
+ Handle(TDataStd_AsciiString) anAsciiStr;
+ if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) ) {
+ aType = QString( anAsciiStr->Get().ToCString() );
+ }
+ }
+
+ return aType;
+}
+
+void HYDROData_LandCover::Update()
+{
+ HYDROData_Entity::Update();
+
+ removeShape();
+
+ TopoDS_Shape aResShape = buildShape();
+
+ setShape( aResShape );
+}
+
+void HYDROData_LandCover::SetPolylines( const HYDROData_SequenceOfObjects& thePolylines )
+{
+ SetReferenceObjects( thePolylines, DataTag_Polylines );
+ SetToUpdate( true );
+}
+
+HYDROData_SequenceOfObjects HYDROData_LandCover::GetPolylines() const
+{
+ return GetReferenceObjects( DataTag_Polylines );
+}
+
+void HYDROData_LandCover::setShape( const TopoDS_Shape& theShape )
+{
+ TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) );
+ aBuilder.Generated( theShape );
+}
+
+void HYDROData_LandCover::removeShape()
+{
+ TDF_Label aLabel = myLab.FindChild( DataTag_Shape, false );
+ if ( !aLabel.IsNull() ) {
+ aLabel.ForgetAllAttributes();
+ }
+}
+
+TopoDS_Shape HYDROData_LandCover::buildShape() const
+{
+ TopoDS_Shape aResShape;
+
+ ///< \TODO to be reimplemented
+ HYDROData_SequenceOfObjects aRefPolylines = GetPolylines();
+ for ( int i = 1, n = aRefPolylines.Length(); i <= n; ++i ) {
+ Handle(HYDROData_PolylineXY) aPolyline =
+ Handle(HYDROData_PolylineXY)::DownCast( aRefPolylines.Value( i ) );
+
+ if ( aPolyline.IsNull() ) {
+ continue;
+ }
+
+ if ( aPolyline->IsClosed() ) {
+ aResShape = aPolyline->GetShape();
+ break;
+ }
+ }
+ return aResShape;
+}
\ No newline at end of file
DEFINE_STANDARD_HANDLE( HYDROData_LandCover, HYDROData_Entity )
+class TopoDS_Shape;
+
class HYDROData_LandCover : public HYDROData_Entity
{
protected:
enum DataTag
{
- DataTag_Table = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
+ DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
+ DataTag_Shape, ///< the shape presentation of the land cover
+ DataTag_StricklerType, ///< the type corresponding to types in the Strickler tables
+ DataTag_Polylines ///< the set of reference polylines
};
HYDRODATA_EXPORT HYDROData_LandCover();
public:
DEFINE_STANDARD_RTTI( HYDROData_LandCover );
+ /**
+ */
HYDRODATA_EXPORT virtual const ObjectKind GetKind() const;
+
+ /**
+ * Dump object to Python script representation.
+ */
+ HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
+ /**
+ * Returns the list of all reference objects of this object.
+ */
+ HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
+ /**
+ * Update the shape presentation of the land cover.
+ * Call this method whenever you made changes for land cover polylines.
+ */
+ HYDRODATA_EXPORT virtual void Update();
+
+ /**
+ * Checks that object has 2D presentation. Reimlemented to return true.
+ */
+ HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
+
+ /**
+ * Set Strickler type for the land cover.
+ */
+ HYDRODATA_EXPORT virtual void SetStricklerType( const QString& theType );
+
+ /**
+ * Returns Strickler type for the land cover.
+ */
+ HYDRODATA_EXPORT virtual QString GetStricklerType() const;
+
+ /**
+ * Set reference polyline objects for the land cover.
+ */
+ HYDRODATA_EXPORT virtual void SetPolylines( const HYDROData_SequenceOfObjects& thePolylines );
+
+ /**
+ * Returns all reference polyline objects of the land cover.
+ */
+ HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetPolylines() const;
+
+protected:
+ /**
+ * Sets shape presentation of the land cover.
+ */
+ HYDRODATA_EXPORT virtual void setShape( const TopoDS_Shape& theShape );
+
+ /**
+ * Removes the shape from data label of the land cover object.
+ */
+ HYDRODATA_EXPORT virtual void removeShape();
+
+ /**
+ * Build the shape presentation of the land cover.
+ */
+ HYDRODATA_EXPORT virtual TopoDS_Shape buildShape() const;
};
#endif