From f2cd9ebfca8f8f58c6e98e30d2ebb387488016cc Mon Sep 17 00:00:00 2001 From: adv Date: Thu, 20 Mar 2014 11:46:51 +0000 Subject: [PATCH] Ordering of model objects implementation. --- src/HYDROData/HYDROData_Channel.cxx | 5 + src/HYDROData/HYDROData_Channel.h | 5 + src/HYDROData/HYDROData_Document.cxx | 166 ++++++++++++++++++++- src/HYDROData/HYDROData_Document.h | 3 + src/HYDROData/HYDROData_Entity.cxx | 162 +++++++++++++------- src/HYDROData/HYDROData_Entity.h | 58 ++++--- src/HYDROData/HYDROData_Image.cxx | 5 + src/HYDROData/HYDROData_Image.h | 5 + src/HYDROData/HYDROData_ImmersibleZone.cxx | 5 + src/HYDROData/HYDROData_ImmersibleZone.h | 5 + src/HYDROData/HYDROData_Obstacle.cxx | 5 + src/HYDROData/HYDROData_Obstacle.h | 5 + src/HYDROData/HYDROData_PolylineXY.cxx | 5 + src/HYDROData/HYDROData_PolylineXY.h | 17 ++- src/HYDROData/HYDROData_River.cxx | 11 ++ src/HYDROData/HYDROData_River.h | 11 ++ src/HYDROData/HYDROData_Stream.cxx | 5 + src/HYDROData/HYDROData_Stream.h | 5 + src/HYDROData/HYDROData_Zone.cxx | 5 + src/HYDROData/HYDROData_Zone.h | 6 + src/HYDROGUI/CMakeLists.txt | 2 + src/HYDROPy/HYDROData_Entity.sip | 22 +++ 22 files changed, 435 insertions(+), 83 deletions(-) diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index bd757fbd..1f2b6355 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -174,6 +174,11 @@ void HYDROData_Channel::Update() anOutGroup->SetShapes( anOutletEdges ); } +bool HYDROData_Channel::IsHas2dPrs() const +{ + return true; +} + QColor HYDROData_Channel::DefaultFillingColor() { return QColor( Qt::blue ); diff --git a/src/HYDROData/HYDROData_Channel.h b/src/HYDROData/HYDROData_Channel.h index 72a4621e..b3b4483c 100644 --- a/src/HYDROData/HYDROData_Channel.h +++ b/src/HYDROData/HYDROData_Channel.h @@ -62,6 +62,11 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + /** + * Checks that object has 2D presentation. Reimlemented to retun true. + */ + HYDRODATA_EXPORT virtual bool IsHas2dPrs() const; + /** * Returns default filling color for new channel. */ diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index 1d51206c..eea22c6d 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -26,6 +26,9 @@ static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for Histo using namespace std; +typedef QMap MapOfOrdered; +typedef QMap MapOfUnordered; + Handle(HYDROData_Document) HYDROData_Document::Document(const int theStudyID) { Handle(HYDROData_Document) aResult = @@ -306,29 +309,184 @@ bool HYDROData_Document::dumpPartitionToPython( QFile& theFile, return aRes; } +bool takeLastDigits( QString& theStr, int& aRes ) +{ + aRes = -1; + + QString anStrNum; + for ( int i = theStr.length() - 1; i >= 0; --i ) + { + const QChar& aChar = theStr.at( i ); + if ( !aChar.isDigit() ) + break; + + anStrNum.prepend( aChar ); + } + + if ( anStrNum.isEmpty() ) + return false; + + theStr.remove( theStr.length() - anStrNum.length(), anStrNum.length() ); + aRes = anStrNum.toInt(); + + return true; +} + +bool isObjectNameLessThan( const QString& theStr1, const QString& theStr2 ) +{ + QString aStr1 = theStr1, aStr2 = theStr2; + + int aNum1 = -1, aNum2 = -1; + if ( takeLastDigits( aStr1, aNum1 ) && takeLastDigits( aStr2, aNum2 ) ) + { + if ( aStr1 == aStr2 ) + return aNum1 < aNum2; + } + + return theStr1 < theStr2; +} + HYDROData_SequenceOfObjects HYDROData_Document::GetObjectsLayerOrder( const Standard_Boolean theIsAll ) const { HYDROData_SequenceOfObjects anOrder; - // TODO + MapOfOrdered aMapOfOrdered; + MapOfUnordered aMapOfUnordered; + + HYDROData_Iterator anIter( this ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Entity) anObject = anIter.Current(); + if ( anObject.IsNull() || !anObject->IsHas2dPrs() ) + continue; + + Standard_Integer anObjZLevel = -1; + if ( anObject->GetZLevel( anObjZLevel ) ) + { + aMapOfOrdered.insert( anObjZLevel, anObject ); + } + else + { + QString anObjName = anObject->GetName(); + if ( anObjName.isEmpty() ) + continue; + + aMapOfUnordered.insert( anObjName, anObject ); + } + } + + MapOfOrdered::const_iterator anOrderedMapIt = aMapOfOrdered.constBegin(); + for ( ; anOrderedMapIt != aMapOfOrdered.constEnd(); anOrderedMapIt++ ) + { + const Handle(HYDROData_Entity)& anObject = anOrderedMapIt.value(); + anOrder.Prepend( anObject ); + } + + if ( theIsAll ) + { + QStringList aSortedNames = aMapOfUnordered.keys(); + qSort( aSortedNames.begin(), aSortedNames.end(), isObjectNameLessThan ); + + for ( int i = 0; i < aSortedNames.length(); ++i ) + { + QString anObjName = aSortedNames.value( i ); + + const Handle(HYDROData_Entity)& anObject = aMapOfUnordered.value( anObjName ); + anOrder.Append( anObject ); + } + } return anOrder; } void HYDROData_Document::SetObjectsLayerOrder( const HYDROData_SequenceOfObjects& theOrder ) { - // TODO + // At first we remove previous model order + RemoveObjectsLayerOrder(); + + // Make new objects order + Standard_Integer aLevel = 0; + for ( int i = theOrder.Length(), n = 1; i >= n; --i ) + { + const Handle(HYDROData_Entity)& anObject = theOrder.Value( i ); + if ( anObject.IsNull() || !anObject->IsHas2dPrs() ) + continue; + + anObject->SetZLevel( aLevel++ ); + } } void HYDROData_Document::Show( const Handle_HYDROData_Entity& theObject ) { - // TODO + HYDROData_SequenceOfObjects anOrder; + anOrder.Append( theObject ); + Show( anOrder ); } void HYDROData_Document::Show( const HYDROData_SequenceOfObjects& theObjects ) { - // TODO + MapOfUnordered aMapOfUnordered; + + for ( int i = 1, n = theObjects.Length(); i <= n; ++i ) + { + const Handle(HYDROData_Entity)& anObject = theObjects.Value( i ); + if ( anObject.IsNull() || !anObject->IsHas2dPrs() ) + continue; + + Standard_Integer anObjZLevel = -1; + if ( anObject->GetZLevel( anObjZLevel ) ) + { + continue; // Skip objects that already have the z-level + } + else + { + QString anObjName = anObject->GetName(); + if ( anObjName.isEmpty() ) + continue; + + aMapOfUnordered.insert( anObjName, anObject ); + } + } + + if ( aMapOfUnordered.isEmpty() ) + return; // Nothing to show + + Standard_Integer aTopId = 0; + + HYDROData_SequenceOfObjects aModelOrder = GetObjectsLayerOrder( Standard_False ); + if ( !aModelOrder.IsEmpty() ) + { + const Handle(HYDROData_Entity)& anObject = aModelOrder.First(); + anObject->GetZLevel( aTopId ); + aTopId++; + } + + aTopId += aMapOfUnordered.size() - 1; + + QStringList aSortedNames = aMapOfUnordered.keys(); + qSort( aSortedNames.begin(), aSortedNames.end(), isObjectNameLessThan ); + + for ( int i = 0; i < aSortedNames.length(); ++i ) + { + QString anObjName = aSortedNames.value( i ); + + const Handle(HYDROData_Entity)& anObject = aMapOfUnordered.value( anObjName ); + anObject->SetZLevel( aTopId-- ); + } +} + +void HYDROData_Document::RemoveObjectsLayerOrder() +{ + HYDROData_Iterator anIter( this ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Entity) anObject = anIter.Current(); + if ( anObject.IsNull() || !anObject->IsHas2dPrs() ) + continue; + + anObject->RemoveZLevel(); + } } void HYDROData_Document::StartOperation() diff --git a/src/HYDROData/HYDROData_Document.h b/src/HYDROData/HYDROData_Document.h index 2709b5b5..ffdaf981 100644 --- a/src/HYDROData/HYDROData_Document.h +++ b/src/HYDROData/HYDROData_Document.h @@ -120,6 +120,9 @@ public: //! The objects from the sequence will be sorted alphabetically at first. HYDRODATA_EXPORT void Show( const HYDROData_SequenceOfObjects& theObjects ); + //! Removes the order of objects presentation. + HYDRODATA_EXPORT void RemoveObjectsLayerOrder(); + public: diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index bacca511..4c1ed735 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -59,33 +60,21 @@ QStringList HYDROData_Entity::DumpToPython( MapOfTreatedObjects& theTreatedObjec return anEmptyList; } -QStringList HYDROData_Entity::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const +void HYDROData_Entity::Update() { - QStringList aResList; - - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); - if ( aDocument.IsNull() ) - return aResList; - - QString aDocName = aDocument->GetDocPyName(); - QString aName = GetObjPyName(); - - aResList << QString( "%1 = %2.CreateObject( %3 );" ) - .arg( aName ).arg( aDocName ).arg( getPyTypeID() ); - aResList << QString( "%1.SetName( \"%2\" );" ) - .arg( aName ).arg( GetName() ); - aResList << QString( "" ); - - return aResList; + SetToUpdate( false ); } -void HYDROData_Entity::Update() +bool HYDROData_Entity::IsHas2dPrs() const { - SetToUpdate( false ); + return false; } void HYDROData_Entity::Show() { + if ( !IsHas2dPrs() ) + return; + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); if ( aDocument.IsNull() ) return; @@ -93,39 +82,6 @@ void HYDROData_Entity::Show() aDocument->Show( this ); } -QString HYDROData_Entity::getPyTypeID() const -{ - switch( GetKind() ) - { - case KIND_IMAGE: return "KIND_IMAGE"; - case KIND_POLYLINE: return "KIND_POLYLINE"; - case KIND_BATHYMETRY: return "KIND_BATHYMETRY"; - case KIND_ALTITUDE: return "KIND_ALTITUDE"; - case KIND_IMMERSIBLE_ZONE: return "KIND_IMMERSIBLE_ZONE"; - case KIND_RIVER: return "KIND_RIVER"; - case KIND_STREAM: return "KIND_STREAM"; - case KIND_CONFLUENCE: return "KIND_CONFLUENCE"; - case KIND_CHANNEL: return "KIND_CHANNEL"; - case KIND_OBSTACLE: return "KIND_OBSTACLE"; - case KIND_DIGUE: return "KIND_DIGUE"; - case KIND_PROFILE: return "KIND_PROFILE"; - case KIND_PROFILEUZ: return "KIND_PROFILEUZ"; - case KIND_POLYLINEXY: return "KIND_POLYLINEXY"; - case KIND_CALCULATION: return "KIND_CALCULATION"; - case KIND_ZONE: return "KIND_ZONE"; - case KIND_REGION: return "KIND_REGION"; - case KIND_VISUAL_STATE: return "KIND_VISUAL_STATE"; - case KIND_ARTIFICIAL_OBJECT: return "KIND_ARTIFICIAL_OBJECT"; - case KIND_NATURAL_OBJECT: return "KIND_NATURAL_OBJECT"; - case KIND_DUMMY_3D: return "KIND_DUMMY_3D"; - case KIND_SHAPES_GROUP: return "KIND_SHAPES_GROUP"; - case KIND_SPLITTED_GROUP: return "KIND_SPLITTED_GROUP"; - case KIND_STREAM_ALTITUDE: return "KIND_STREAM_ALTITUDE"; - case KIND_OBSTACLE_ALTITUDE: return "KIND_OBSTACLE_ALTITUDE"; - default: return "KIND_UNKNOWN"; ///! Unrecognized object - } -} - QVariant HYDROData_Entity::GetDataVariant() { return QVariant(); @@ -215,13 +171,44 @@ HYDROData_SequenceOfObjects HYDROData_Entity::GetAllReferenceObjects() const return HYDROData_SequenceOfObjects(); } -void HYDROData_Entity::SetLabel(TDF_Label theLabel) +Standard_Boolean HYDROData_Entity::GetZLevel( Standard_Integer& theLevel ) const +{ + theLevel = -1; + + TDF_Label aLabel = myLab.FindChild( DataTag_ZLevel, false ); + if ( !aLabel.IsNull() ) + { + Handle(TDataStd_Integer) anIntVal; + if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anIntVal ) ) + { + theLevel = anIntVal->Get(); + return Standard_True; + } + } + + return Standard_False; +} + +void HYDROData_Entity::SetZLevel( const Standard_Integer& theLevel ) +{ + TDataStd_Integer::Set( myLab.FindChild( DataTag_ZLevel ), theLevel ); +} + +void HYDROData_Entity::RemoveZLevel() +{ + TDF_Label aLabel = myLab.FindChild( DataTag_ZLevel, false ); + if ( !aLabel.IsNull() ) + aLabel.ForgetAllAttributes(); +} + +void HYDROData_Entity::SetLabel( const TDF_Label& theLabel ) { myLab = theLabel; } -void HYDROData_Entity::SaveByteArray(const int theTag, - const char* theData, const int theLen) +void HYDROData_Entity::SaveByteArray( const int theTag, + const char* theData, + const int theLen ) { TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag); // array is empty, remove the attribute @@ -503,6 +490,71 @@ QColor HYDROData_Entity::GetColor( const QColor& theDefColor, return aResColor; } +QStringList HYDROData_Entity::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const +{ + QStringList aResList; + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + if ( aDocument.IsNull() ) + return aResList; + + QString aDocName = aDocument->GetDocPyName(); + QString aName = GetObjPyName(); + + aResList << QString( "%1 = %2.CreateObject( %3 );" ) + .arg( aName ).arg( aDocName ).arg( getPyTypeID() ); + aResList << QString( "%1.SetName( \"%2\" );" ) + .arg( aName ).arg( GetName() ); + aResList << QString( "" ); + + if ( IsHas2dPrs() ) + { + // Dump object z-level in viewer + Standard_Integer anObjZLevel = -1; + if ( GetZLevel( anObjZLevel ) ) + { + aResList << QString( "%1.SetZLevel( %2 );" ) + .arg( aName ).arg( anObjZLevel ); + aResList << QString( "" ); + } + } + + return aResList; +} + +QString HYDROData_Entity::getPyTypeID() const +{ + switch( GetKind() ) + { + case KIND_IMAGE: return "KIND_IMAGE"; + case KIND_POLYLINE: return "KIND_POLYLINE"; + case KIND_BATHYMETRY: return "KIND_BATHYMETRY"; + case KIND_ALTITUDE: return "KIND_ALTITUDE"; + case KIND_IMMERSIBLE_ZONE: return "KIND_IMMERSIBLE_ZONE"; + case KIND_RIVER: return "KIND_RIVER"; + case KIND_STREAM: return "KIND_STREAM"; + case KIND_CONFLUENCE: return "KIND_CONFLUENCE"; + case KIND_CHANNEL: return "KIND_CHANNEL"; + case KIND_OBSTACLE: return "KIND_OBSTACLE"; + case KIND_DIGUE: return "KIND_DIGUE"; + case KIND_PROFILE: return "KIND_PROFILE"; + case KIND_PROFILEUZ: return "KIND_PROFILEUZ"; + case KIND_POLYLINEXY: return "KIND_POLYLINEXY"; + case KIND_CALCULATION: return "KIND_CALCULATION"; + case KIND_ZONE: return "KIND_ZONE"; + case KIND_REGION: return "KIND_REGION"; + case KIND_VISUAL_STATE: return "KIND_VISUAL_STATE"; + case KIND_ARTIFICIAL_OBJECT: return "KIND_ARTIFICIAL_OBJECT"; + case KIND_NATURAL_OBJECT: return "KIND_NATURAL_OBJECT"; + case KIND_DUMMY_3D: return "KIND_DUMMY_3D"; + case KIND_SHAPES_GROUP: return "KIND_SHAPES_GROUP"; + case KIND_SPLITTED_GROUP: return "KIND_SPLITTED_GROUP"; + case KIND_STREAM_ALTITUDE: return "KIND_STREAM_ALTITUDE"; + case KIND_OBSTACLE_ALTITUDE: return "KIND_OBSTACLE_ALTITUDE"; + default: return "KIND_UNKNOWN"; ///! Unrecognized object + } +} + void HYDROData_Entity::setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects, QStringList& theScript, const Handle(HYDROData_Entity)& theRefObject, diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index aef06bf9..b46a6e43 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -54,6 +54,8 @@ typedef QMap MapOfTreatedObjects; typedef NCollection_Sequence HYDROData_SequenceOfObjects; +///! Is Equal for HYDROData_Entity mapping +HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2); /**\class HYDROData_Entity * \brief Generic class of any object in the data model. @@ -72,8 +74,8 @@ protected: */ enum DataTag { - DataTag_First = 0 ///< first tag, to reserve - // ... + DataTag_First = 0, ///< first tag, to reserve + DataTag_ZLevel, ///< z-level of object presentation }; public: @@ -112,11 +114,18 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + + /** + * Checks that object has 2D presentation. Base implementation returns false. + */ + HYDRODATA_EXPORT virtual bool IsHas2dPrs() const; + /** * Show object at the top of other model objects. */ HYDRODATA_EXPORT virtual void Show(); + /** * Returns data of object wrapped to QVariant. * Base implementation returns null value. @@ -188,6 +197,22 @@ public: HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const; + /** + * Returns the z-level for object presentation, -1 if no z-level. + */ + HYDRODATA_EXPORT virtual Standard_Boolean GetZLevel( Standard_Integer& theLevel ) const; + + /** + * Set the z-level for object presentation. + */ + HYDRODATA_EXPORT virtual void SetZLevel( const Standard_Integer& theLevel ); + + /** + * Remove the z-level of object presentation. + */ + HYDRODATA_EXPORT virtual void RemoveZLevel(); + + protected: friend class HYDROData_Iterator; @@ -207,7 +232,7 @@ protected: * Put the object to the label of the document. * \param theLabel new label of the object */ - HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel); + HYDRODATA_EXPORT virtual void SetLabel( const TDF_Label& theLabel ); /** * Internal method that used to store the byte array attribute @@ -333,6 +358,18 @@ protected: protected: + /** + * Dump the initial object creation to a Python script. + * You should call it from DumpToPython implementation before + * dumping fields of the object. + */ + HYDRODATA_EXPORT virtual QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const; + + /** + * Returns an object type name as a string for dumping to Python. + */ + QString getPyTypeID() const; + void setPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects, QStringList& theScript, const Handle(HYDROData_Entity)& theRefObject, @@ -347,18 +384,6 @@ protected: const QColor& theDefaultColor, const QString& theMethod ) const; - /** - * Dump the initial object creation to a Python script. - * You should call it from DumpToPython implementation before - * dumping fields of the object. - */ - HYDRODATA_EXPORT virtual QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const; - - /** - * Returns an object type name as a string for dumping to Python. - */ - QString getPyTypeID() const; - protected: Handle(TDataStd_ReferenceList) getReferenceList( const int theTag, @@ -370,7 +395,4 @@ protected: TDF_Label myLab; ///< label of this object }; -///! Is Equal for HYDROData_Entity mapping -HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2); - #endif diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index 09ce073a..ea1fed9c 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -212,6 +212,11 @@ void HYDROData_Image::Update() SetToUpdate( false ); } +bool HYDROData_Image::IsHas2dPrs() const +{ + return true; +} + QVariant HYDROData_Image::GetDataVariant() { QTransform aTransform = Trsf(); diff --git a/src/HYDROData/HYDROData_Image.h b/src/HYDROData/HYDROData_Image.h index d7eccacc..7860f41b 100644 --- a/src/HYDROData/HYDROData_Image.h +++ b/src/HYDROData/HYDROData_Image.h @@ -63,6 +63,11 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + /** + * Checks that object has 2D presentation. Reimlemented to retun true. + */ + HYDRODATA_EXPORT virtual bool IsHas2dPrs() const; + /** * Returns data of object wrapped to QVariant. * Reimplemented to wrap and return saved image. diff --git a/src/HYDROData/HYDROData_ImmersibleZone.cxx b/src/HYDROData/HYDROData_ImmersibleZone.cxx index 8c40d467..800d2753 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.cxx +++ b/src/HYDROData/HYDROData_ImmersibleZone.cxx @@ -86,6 +86,11 @@ void HYDROData_ImmersibleZone::Update() createGroupObjects(); } +bool HYDROData_ImmersibleZone::IsHas2dPrs() const +{ + return true; +} + TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape() const { return generateTopShape( GetPolyline() ); diff --git a/src/HYDROData/HYDROData_ImmersibleZone.h b/src/HYDROData/HYDROData_ImmersibleZone.h index 7a97a11d..9e0b929d 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.h +++ b/src/HYDROData/HYDROData_ImmersibleZone.h @@ -48,6 +48,11 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + /** + * Checks that object has 2D presentation. Reimlemented to retun true. + */ + HYDRODATA_EXPORT virtual bool IsHas2dPrs() const; + /** * Returns the top shape of the object. */ diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index 5a108d6e..4dfae867 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -107,6 +107,11 @@ void HYDROData_Obstacle::Update() HYDROData_Entity::Update(); } +bool HYDROData_Obstacle::IsHas2dPrs() const +{ + return true; +} + TopoDS_Shape HYDROData_Obstacle::GetTopShape() const { return getTopShape(); diff --git a/src/HYDROData/HYDROData_Obstacle.h b/src/HYDROData/HYDROData_Obstacle.h index ccf1599d..a0ba13ad 100644 --- a/src/HYDROData/HYDROData_Obstacle.h +++ b/src/HYDROData/HYDROData_Obstacle.h @@ -43,6 +43,11 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + /** + * Checks that object has 2D presentation. Reimlemented to retun true. + */ + HYDRODATA_EXPORT virtual bool IsHas2dPrs() const; + /** * Returns the top shape of the object. */ diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index e6643808..be2495cd 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -538,6 +538,11 @@ void HYDROData_PolylineXY::Update() setPolylineShape( aResult ); } +bool HYDROData_PolylineXY::IsHas2dPrs() const +{ + return true; +} + bool HYDROData_PolylineXY::IsEditable() const { return !myLab.IsAttribute( GUID_IS_UNEDITABLE ); diff --git a/src/HYDROData/HYDROData_PolylineXY.h b/src/HYDROData/HYDROData_PolylineXY.h index ccbdaba6..86ae8e54 100644 --- a/src/HYDROData/HYDROData_PolylineXY.h +++ b/src/HYDROData/HYDROData_PolylineXY.h @@ -40,6 +40,17 @@ public: */ HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + /** + * Update the wire contour on the basis of the polyline data. + * Call this method whenever you made changes for polyline data. + */ + HYDRODATA_EXPORT virtual void Update(); + + /** + * Checks that object has 2D presentation. Reimlemented to retun true. + */ + HYDRODATA_EXPORT virtual bool IsHas2dPrs() const; + /** * Returns data of object wrapped to QVariant. * Reimplemented to wrap and return saved path. @@ -100,12 +111,6 @@ public: */ HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape ); - /** - * Update the wire contour on the basis of the polyline data. - * Call this method whenever you made changes for polyline data. - */ - HYDRODATA_EXPORT virtual void Update(); - /** * Returns flag indicating that polyline can be edited or not. diff --git a/src/HYDROData/HYDROData_River.cxx b/src/HYDROData/HYDROData_River.cxx index bd22befb..012167d2 100644 --- a/src/HYDROData/HYDROData_River.cxx +++ b/src/HYDROData/HYDROData_River.cxx @@ -34,6 +34,17 @@ QStringList HYDROData_River::DumpToPython( MapOfTreatedObjects& theTreatedObject return aResList; } +void HYDROData_River::Update() +{ + // TODO + HYDROData_NaturalObject::Update(); +} + +bool HYDROData_River::IsHas2dPrs() const +{ + return true; +} + TopoDS_Shape HYDROData_River::GetTopShape() const { // TODO diff --git a/src/HYDROData/HYDROData_River.h b/src/HYDROData/HYDROData_River.h index 8d5df364..9503d5b0 100644 --- a/src/HYDROData/HYDROData_River.h +++ b/src/HYDROData/HYDROData_River.h @@ -34,6 +34,17 @@ public: */ HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + /** + * Update the immersible zone object. + * Call this method whenever you made changes for object data. + */ + HYDRODATA_EXPORT virtual void Update(); + + /** + * Checks that object has 2D presentation. Reimlemented to retun true. + */ + HYDRODATA_EXPORT virtual bool IsHas2dPrs() const; + /** * Returns the top shape of the object. */ diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index df6ad67b..3b67a6b5 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -146,6 +146,11 @@ void HYDROData_Stream::Update() UpdatePrs(); } +bool HYDROData_Stream::IsHas2dPrs() const +{ + return true; +} + void HYDROData_Stream::UpdatePrs() { HYDROData_NaturalObject::Update(); diff --git a/src/HYDROData/HYDROData_Stream.h b/src/HYDROData/HYDROData_Stream.h index b1ee6f48..2b47bd78 100644 --- a/src/HYDROData/HYDROData_Stream.h +++ b/src/HYDROData/HYDROData_Stream.h @@ -63,6 +63,11 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + /** + * Checks that object has 2D presentation. Reimlemented to retun true. + */ + HYDRODATA_EXPORT virtual bool IsHas2dPrs() const; + /** * Update the shape presentations of stream. */ diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index adde27bf..2df7c740 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -34,6 +34,11 @@ bool HYDROData_Zone::CanBeUpdated() const return false; } +bool HYDROData_Zone::IsHas2dPrs() const +{ + return true; +} + bool HYDROData_Zone::CanRemove() { return false; diff --git a/src/HYDROData/HYDROData_Zone.h b/src/HYDROData/HYDROData_Zone.h index 30e86cc0..f1e3ba96 100644 --- a/src/HYDROData/HYDROData_Zone.h +++ b/src/HYDROData/HYDROData_Zone.h @@ -57,6 +57,12 @@ public: HYDRODATA_EXPORT virtual bool CanBeUpdated() const; + /** + * Checks that object has 2D presentation. Reimlemented to retun true. + */ + HYDRODATA_EXPORT virtual bool IsHas2dPrs() const; + + /** * Returns flag indicating that object can be removed or not. */ diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 5a0472cd..95a1d878 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -88,6 +88,7 @@ set(PROJECT_HEADERS HYDROGUI_TranslateObstacleOp.h HYDROGUI_ZLevelsModel.h HYDROGUI_ZLevelsDlg.h + HYDROGUI_ZLevelsOp.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -177,6 +178,7 @@ set(PROJECT_SOURCES HYDROGUI_TranslateObstacleOp.cxx HYDROGUI_ZLevelsModel.cxx HYDROGUI_ZLevelsDlg.cxx + HYDROGUI_ZLevelsOp.cxx ) add_definitions( diff --git a/src/HYDROPy/HYDROData_Entity.sip b/src/HYDROPy/HYDROData_Entity.sip index 6208ab9f..6492535a 100644 --- a/src/HYDROPy/HYDROData_Entity.sip +++ b/src/HYDROPy/HYDROData_Entity.sip @@ -174,6 +174,11 @@ public: */ virtual void Update(); + /** + * Checks that object has 2D presentation. Base implementation returns false. + */ + virtual bool IsHas2dPrs() const; + /** * Returns data of object wrapped to QVariant. * Base implementation returns null value. @@ -250,6 +255,23 @@ public: */ virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const; + + /** + * Returns the z-level for object presentation, -1 if no z-level. + */ + virtual bool GetZLevel( int& theLevel ) const [Standard_Boolean ( Standard_Integer& )]; + + /** + * Set the z-level for object presentation. + */ + virtual void SetZLevel( const int& theLevel ) [void ( const Standard_Integer& )]; + + /** + * Remove the z-level of object presentation. + */ + virtual void RemoveZLevel(); + + protected: /** -- 2.39.2