From: adv Date: Wed, 27 Nov 2013 06:32:36 +0000 (+0000) Subject: The polyline object has deen moved to new realisation. X-Git-Tag: issue_132_11_28~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d84fadb6fba0d9ef3926995eab878175cc24e291;p=modules%2Fhydro.git The polyline object has deen moved to new realisation. --- diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index 63ee232d..bd03c1f1 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -23,7 +23,7 @@ set(PROJECT_HEADERS HYDROData_Object.h HYDROData_Obstacle.h HYDROData_OperationsFactory.h - HYDROData_Polyline.h +# HYDROData_Polyline.h HYDROData_PolylineXY.h HYDROData_Profile.h HYDROData_ProfileUZ.h @@ -58,7 +58,7 @@ set(PROJECT_SOURCES HYDROData_Object.cxx HYDROData_Obstacle.cxx HYDROData_OperationsFactory.cxx - HYDROData_Polyline.cxx +# HYDROData_Polyline.cxx HYDROData_PolylineXY.cxx HYDROData_Profile.cxx HYDROData_ProfileUZ.cxx @@ -105,7 +105,7 @@ if(SALOME_BUILD_TESTS) test_HYDROData_Image.h test_HYDROData_Iterator.h test_HYDROData_OperationsFactory.h - test_HYDROData_Polyline.h + test_HYDROData_PolylineXY.h ) set(TEST_SOURCES @@ -118,7 +118,7 @@ if(SALOME_BUILD_TESTS) test_HYDROData_Image.cxx test_HYDROData_Iterator.cxx test_HYDROData_OperationsFactory.cxx - test_HYDROData_Polyline.cxx + test_HYDROData_PolylineXY.cxx ) set(TEST_EXE test_HYDROData) diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index e6976786..3441d309 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -5,7 +5,7 @@ #include "HYDROData_Document.h" #include "HYDROData_Iterator.h" #include "HYDROData_NaturalObject.h" -#include "HYDROData_Polyline.h" +#include "HYDROData_PolylineXY.h" #include "HYDROData_SplitToZonesTool.h" #include "HYDROData_Region.h" #include "HYDROData_Tool.h" @@ -138,7 +138,7 @@ void HYDROData_CalculationCase::SplitGeometryObjects() if ( aDocument.IsNull() ) return; - Handle(HYDROData_Polyline) aBoundaryPolyline = GetBoundaryPolyline(); + Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline(); HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); if ( aGeomObjects.IsEmpty() ) return; @@ -229,9 +229,9 @@ void HYDROData_CalculationCase::RemoveGeometryObjects() SetToUpdate( true ); } -void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline ) +void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline ) { - Handle(HYDROData_Polyline) aPrevPolyline = GetBoundaryPolyline(); + Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline(); SetReferenceObject( thePolyline, DataTag_Polyline ); @@ -239,15 +239,15 @@ void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_Poly SetToUpdate( !IsEqual( aPrevPolyline, thePolyline ) || IsMustBeUpdated() ); } -Handle(HYDROData_Polyline) HYDROData_CalculationCase::GetBoundaryPolyline() const +Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const { - return Handle(HYDROData_Polyline)::DownCast( + return Handle(HYDROData_PolylineXY)::DownCast( GetReferenceObject( DataTag_Polyline ) ); } void HYDROData_CalculationCase::RemoveBoundaryPolyline() { - Handle(HYDROData_Polyline) aPrevPolyline = GetBoundaryPolyline(); + Handle(HYDROData_PolylineXY) aPrevPolyline = GetBoundaryPolyline(); ClearReferenceObjects( DataTag_Polyline ); diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index 1b6d4bfb..12e0704a 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -10,7 +10,7 @@ class TopoDS_Shell; class Handle(HYDROData_Object); class Handle(HYDROData_Region); class Handle(HYDROData_Zone); -class Handle(HYDROData_Polyline); +class Handle(HYDROData_PolylineXY); DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity) @@ -89,12 +89,12 @@ public: /** * Sets reference boundary polyline object for calculation case. */ - HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline ); + HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline ); /** * Returns reference boundary polyline object of calculation case. */ - HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline) GetBoundaryPolyline() const; + HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const; /** * Remove reference boundary polyline object from calculation case. diff --git a/src/HYDROData/HYDROData_IPolyline.cxx b/src/HYDROData/HYDROData_IPolyline.cxx index 20fe2099..687318cc 100755 --- a/src/HYDROData/HYDROData_IPolyline.cxx +++ b/src/HYDROData/HYDROData_IPolyline.cxx @@ -3,8 +3,16 @@ #include +#include +#include +#include #include +#include + +#include +#include + IMPLEMENT_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity) @@ -22,6 +30,61 @@ int HYDROData_IPolyline::NbPoints( const int theSectionIndex ) const return GetPoints( theSectionIndex ).Length(); } +TopoDS_Shape HYDROData_IPolyline::getPolylineShape() const +{ + TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false ); + if ( !aShapeLabel.IsNull() ) + { + Handle(TNaming_NamedShape) aNamedShape; + if ( aShapeLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) ) + return aNamedShape->Get(); + } + return TopoDS_Shape(); +} + +void HYDROData_IPolyline::setPolylineShape( const TopoDS_Shape& theShape ) +{ + TNaming_Builder aBuilder( myLab.FindChild( DataTag_PolylineShape ) ); + aBuilder.Generated( theShape ); +} + +void HYDROData_IPolyline::removePolylineShape() +{ + TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false ); + if ( !aShapeLabel.IsNull() ) + aShapeLabel.ForgetAllAttributes(); +} + +void HYDROData_IPolyline::getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList, + Handle(TDataStd_IntegerList)& theTypesList, + Handle(TDataStd_BooleanList)& theClosuresList, + const bool theIsCreate ) const +{ + theNamesList.Nullify(); + theTypesList.Nullify(); + theClosuresList.Nullify(); + + TDF_Label aSectLabel = myLab.FindChild( DataTag_Sections, theIsCreate ); + if ( aSectLabel.IsNull() ) + return; + + if ( !aSectLabel.FindAttribute( TDataStd_ExtStringList::GetID(), theNamesList ) && theIsCreate ) + theNamesList = TDataStd_ExtStringList::Set( aSectLabel ); + + if ( !aSectLabel.FindAttribute( TDataStd_IntegerList::GetID(), theTypesList ) && theIsCreate ) + theTypesList = TDataStd_IntegerList::Set( aSectLabel ); + + if ( !aSectLabel.FindAttribute( TDataStd_BooleanList::GetID(), theClosuresList ) && theIsCreate ) + theClosuresList = TDataStd_BooleanList::Set( aSectLabel ); +} + +void HYDROData_IPolyline::removeSectionsLists() +{ + TDF_Label aSectsLabel = myLab.FindChild( DataTag_Sections, false ); + if ( !aSectsLabel.IsNull() ) + aSectsLabel.ForgetAllAttributes(); +} + void HYDROData_IPolyline::getPointsLists( const int theSectionIndex, Handle(TDataStd_RealList)& theListX, Handle(TDataStd_RealList)& theListY, @@ -59,7 +122,14 @@ void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const if ( aLabel.IsNull() ) return; - TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false ); - if ( !aSectLabel.IsNull() ) - aSectLabel.ForgetAllAttributes(); + if ( theSectionIndex < 0 ) + { + aLabel.ForgetAllAttributes(); + } + else + { + TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false ); + if ( !aSectLabel.IsNull() ) + aSectLabel.ForgetAllAttributes(); + } } diff --git a/src/HYDROData/HYDROData_IPolyline.h b/src/HYDROData/HYDROData_IPolyline.h index 9155f693..0d3d7442 100644 --- a/src/HYDROData/HYDROData_IPolyline.h +++ b/src/HYDROData/HYDROData_IPolyline.h @@ -8,8 +8,12 @@ DEFINE_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity) class gp_XY; -class TopoDS_Wire; +class TopoDS_Shape; class Handle(TDataStd_RealList); +class Handle(TDataStd_ExtStringList); +class Handle(TDataStd_BooleanList); +class Handle(TDataStd_IntegerList); + /**\class HYDROData_IPolyline * \brief Base class that stores/retreives information about the 2D points. @@ -18,6 +22,8 @@ class HYDROData_IPolyline : public HYDROData_Entity { public: + enum SectionType{ SECTION_POLYLINE = 0, SECTION_SPLINE = 1 }; + typedef gp_XY Point; typedef NCollection_Sequence PointsList; @@ -29,6 +35,8 @@ protected: { DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve DataTag_Points, + DataTag_Sections, + DataTag_PolylineShape, }; public: @@ -37,7 +45,7 @@ public: /** * Returns the 3D presentation of all points. */ - HYDRODATA_EXPORT virtual TopoDS_Wire GetWire() const = 0; + HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() = 0; /** @@ -47,9 +55,41 @@ public: /** * Adds new one section. - * \param theIsClosed flag indicates type of polyline + * \param theSectName name of the section + * \param theSectionType type of section + * \param theIsClosed flag indicates closures of section + */ + HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName, + const SectionType theSectionType, + const bool theIsClosed ) = 0; + + /** + * Returns name of section with given index. + * \param theSectionIndex index of section + */ + HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const = 0; + + /** + * Set name for section with given index. + * \param theSectionIndex index of section + * \param theSectionName new section name + */ + HYDRODATA_EXPORT virtual void SetSectionName( const int theSectionIndex, + const TCollection_AsciiString& theSectionName ) = 0; + + /** + * Returns type of section with given index. + * \param theSectionIndex index of section */ - HYDRODATA_EXPORT virtual void AddSection( const bool theIsClosed ) = 0; + HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const = 0; + + /** + * Set type for section with given index. + * \param theSectionIndex index of section + * \param theSectionType new section type + */ + HYDRODATA_EXPORT virtual void SetSectionType( const int theSectionIndex, + const SectionType theSectionType ) = 0; /** * Returns true if section with given index is closed. @@ -57,6 +97,14 @@ public: */ HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const = 0; + /** + * Set closed flag for section with given index. + * \param theSectionIndex index of section + * \param theIsClosed new closures state + */ + HYDRODATA_EXPORT virtual void SetSectionClosed( const int theSectionIndex, + const bool theIsClosed ) = 0; + /** * Removes section with given index. * \param theSectionIndex index of section @@ -88,12 +136,12 @@ public: /** * Replaces point for section with index "theSectionIndex". * \param theSectionIndex index of section - * \param thePointIndex index of point to replace * \param thePoint new point + * \param thePointIndex index of point to replace */ HYDRODATA_EXPORT virtual void SetPoint( const int theSectionIndex, - const int thePointIndex, - const Point& thePoint ) = 0; + const Point& thePoint, + const int thePointIndex ) = 0; /** * Removes point from section with index "theSectionIndex". @@ -114,12 +162,26 @@ public: protected: + TopoDS_Shape getPolylineShape() const; + + void setPolylineShape( const TopoDS_Shape& theShape ); + + void removePolylineShape(); + + + void getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList, + Handle(TDataStd_IntegerList)& theTypesList, + Handle(TDataStd_BooleanList)& theClosuresList, + const bool theIsCreate = true ) const; + + void removeSectionsLists(); + void getPointsLists( const int theSectionIndex, Handle(TDataStd_RealList)& theListX, Handle(TDataStd_RealList)& theListY, const bool theIsCreate = true ) const; - void removePointsLists( const int theSectionIndex ) const; + void removePointsLists( const int theSectionIndex = -1 ) const; protected: @@ -127,12 +189,12 @@ protected: * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ - HYDROData_IPolyline(); + HYDRODATA_EXPORT HYDROData_IPolyline(); /** * Destructs properties of the object and object itself, removes it from the document. */ - ~HYDROData_IPolyline(); + HYDRODATA_EXPORT ~HYDROData_IPolyline(); }; #endif diff --git a/src/HYDROData/HYDROData_ImmersibleZone.cxx b/src/HYDROData/HYDROData_ImmersibleZone.cxx index c31dac11..e35a1f17 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.cxx +++ b/src/HYDROData/HYDROData_ImmersibleZone.cxx @@ -3,7 +3,7 @@ #include "HYDROData_Bathymetry.h" #include "HYDROData_Document.h" -#include "HYDROData_Polyline.h" +#include "HYDROData_PolylineXY.h" #include @@ -67,7 +67,7 @@ QStringList HYDROData_ImmersibleZone::DumpToPython( MapOfTreatedObjects& theTrea Handle(HYDROData_Bathymetry) aRefBathymetry = GetBathymetry(); setPythonReferenceObject( theTreatedObjects, aResList, aRefBathymetry, "SetBathymetry" ); - Handle(HYDROData_Polyline) aRefPolyline = GetPolyline(); + Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline(); setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" ); return aResList; @@ -77,10 +77,10 @@ TopoDS_Shape HYDROData_ImmersibleZone::GetTopShape() const { TopoDS_Shape aResShape = TopoDS_Face(); - Handle(HYDROData_Polyline) aPolyline = GetPolyline(); + Handle(HYDROData_PolylineXY) aPolyline = GetPolyline(); if( !aPolyline.IsNull() ) { - TopoDS_Shape aPolylineShape = aPolyline->GetTopShape(); + TopoDS_Shape aPolylineShape = aPolyline->GetShape(); TopTools_ListOfShape aWiresList; if ( !aPolylineShape.IsNull() && @@ -141,14 +141,14 @@ QColor HYDROData_ImmersibleZone::DefaultBorderColor() return QColor( Qt::transparent ); } -void HYDROData_ImmersibleZone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline ) +void HYDROData_ImmersibleZone::SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline ) { SetReferenceObject( thePolyline, DataTag_Polyline ); } -Handle(HYDROData_Polyline) HYDROData_ImmersibleZone::GetPolyline() const +Handle(HYDROData_PolylineXY) HYDROData_ImmersibleZone::GetPolyline() const { - return Handle(HYDROData_Polyline)::DownCast( + return Handle(HYDROData_PolylineXY)::DownCast( GetReferenceObject( DataTag_Polyline ) ); } diff --git a/src/HYDROData/HYDROData_ImmersibleZone.h b/src/HYDROData/HYDROData_ImmersibleZone.h index c540574c..04616f48 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.h +++ b/src/HYDROData/HYDROData_ImmersibleZone.h @@ -6,7 +6,7 @@ DEFINE_STANDARD_HANDLE(HYDROData_ImmersibleZone, HYDROData_NaturalObject) -class Handle(HYDROData_Polyline); +class Handle(HYDROData_PolylineXY); /**\class HYDROData_ImmersibleZone * \brief @@ -60,12 +60,12 @@ public: /** * Sets reference polyline object for zone. */ - HYDRODATA_EXPORT virtual void SetPolyline( const Handle(HYDROData_Polyline)& thePolyline ); + HYDRODATA_EXPORT virtual void SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline ); /** * Returns reference polyline object of zone. */ - HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline) GetPolyline() const; + HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetPolyline() const; /** * Remove reference polyline object of zone. diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index f33065fa..b29eec52 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -10,7 +10,6 @@ #include "HYDROData_Image.h" #include "HYDROData_ImmersibleZone.h" #include "HYDROData_Obstacle.h" -#include "HYDROData_Polyline.h" #include "HYDROData_PolylineXY.h" #include "HYDROData_Profile.h" #include "HYDROData_ProfileUZ.h" @@ -107,9 +106,9 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel ) case KIND_IMAGE: aResult = new HYDROData_Image(); break; - case KIND_POLYLINE: - aResult = new HYDROData_Polyline(); - break; + //case KIND_POLYLINE: + //aResult = new HYDROData_Polyline(); + //break; case KIND_BATHYMETRY: aResult = new HYDROData_Bathymetry(); break; diff --git a/src/HYDROData/HYDROData_Polyline.cxx b/src/HYDROData/HYDROData_Polyline.cxx index c8850001..3f561c5d 100755 --- a/src/HYDROData/HYDROData_Polyline.cxx +++ b/src/HYDROData/HYDROData_Polyline.cxx @@ -28,9 +28,6 @@ #include -// tage of the child of my label that contains information about the operator -static const Standard_GUID GUID_MUST_BE_UPDATED("6647e1f7-1971-4c5a-86c7-11ff0291452d"); - #define PYTHON_POLYLINE_ID "KIND_POLYLINE" IMPLEMENT_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object) diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index f651ac2a..04039c96 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -1,16 +1,39 @@ #include "HYDROData_PolylineXY.h" +#include "HYDROData_BSplineOperation.h" +#include "HYDROData_Document.h" #include "HYDROData_Tool.h" +#include +#include +#include + +#include + +#include #include +#include + +#include + +#include +#include #include +#include +#include +#include +#include #include -#include +#include + +#include +#include +#define PYTHON_POLYLINEXY_ID "KIND_POLYLINEXY" IMPLEMENT_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline) @@ -24,155 +47,621 @@ HYDROData_PolylineXY::~HYDROData_PolylineXY() { } -TopoDS_Wire HYDROData_PolylineXY::GetWire() const +QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { - // TODO - return TopoDS_Wire(); + QStringList aResList; + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + if ( aDocument.IsNull() ) + return aResList; + + QString aDocName = aDocument->GetDocPyName(); + QString aPolylineName = GetName(); + + aResList << QString( "%1 = %2.CreateObject( %3 );" ) + .arg( aPolylineName ).arg( aDocName ).arg( PYTHON_POLYLINEXY_ID ); + aResList << QString( "%1.SetName( \"%1\" );" ).arg( aPolylineName ); + + // Set polilyne data + NCollection_Sequence aSectNames; + NCollection_Sequence aSectTypes; + NCollection_Sequence aSectClosures; + GetSections( aSectNames, aSectTypes, aSectClosures ); + + for ( int i = 1, n = aSectNames.Size(); i <= n; ++i ) + { + const TCollection_AsciiString& aSectName = aSectNames.Value( i ); + const SectionType& aSectType = aSectTypes.Value( i ); + bool aSectClosure = aSectClosures.Value( i ); + + aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aPolylineName ) + .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure ); + + HYDROData_PolylineXY::PointsList aSectPointsList = GetPoints( i ); + for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k ) + { + const HYDROData_PolylineXY::Point& aSectPoint = aSectPointsList.Value( k ); + + aResList << QString( "%1.AddPoint( %2, QPointF( %3, %4 ) );" ).arg( aPolylineName ) + .arg( i - 1 ).arg( aSectPoint.X() ).arg( aSectPoint.Y() ); + } + } + + return aResList; } -int HYDROData_PolylineXY::NbSections() const +QVariant HYDROData_PolylineXY::GetDataVariant() { - return 1; + QPainterPath aPath = GetPainterPath(); + + QVariant aVarData; + aVarData.setValue( aPath ); + + return aVarData; } -void HYDROData_PolylineXY::AddSection( const bool /*theIsClosed*/ ) +TopoDS_Shape HYDROData_PolylineXY::GetShape() { + return getPolylineShape(); } -bool HYDROData_PolylineXY::IsClosedSection( const int /*theSectionIndex*/ ) const +void HYDROData_PolylineXY::Update() { - return false; + NCollection_Sequence aSectNames; + NCollection_Sequence aSectTypes; + NCollection_Sequence aSectClosures; + GetSections( aSectNames, aSectTypes, aSectClosures ); + + BRepBuilderAPI_MakeWire aMakeWire; + + TopTools_ListOfShape aSectionWiresList; + + for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ ) + { + TCollection_AsciiString aSectName = aSectNames.Value( aSectionId ); + SectionType aSectionType = aSectTypes.Value( aSectionId ); + bool anIsSectionClosed = aSectClosures.Value( aSectionId ); + + PointsList aSectPointsList = GetPoints( aSectionId - 1 ); + if ( aSectPointsList.IsEmpty() ) + continue; + + BRepBuilderAPI_MakeWire aMakeSectionWire; + if( aSectionType == SECTION_POLYLINE ) + { + for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i ) + { + const Point& aFirstPoint = aSectPointsList.Value( i ); + + Point aLastPoint; + if ( i == n ) + { + if( anIsSectionClosed ) + aLastPoint = aSectPointsList.Value( 1 ); + else + break; + } + else + { + aLastPoint = aSectPointsList.Value( i + 1 ); + } + + gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0.0 ); + gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), 0.0 ); + + TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge(); + aMakeSectionWire.Add( anEdge ); + } + } + else //if( aSectionType == PolylineSection::SECTION_SPLINE ) + { + QList aPoints; + for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i ) + { + const Point& aSectPoint = aSectPointsList.Value( i ); + aPoints << aSectPoint.X() << aSectPoint.Y(); + } + + HYDROData_BSplineOperation aBSpline( aPoints, 0.0, anIsSectionClosed ); + + TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge(); + aMakeSectionWire.Add( anEdge ); + } + + TopoDS_Wire aSectionWire = aMakeSectionWire.Wire(); + aSectionWiresList.Append( aSectionWire ); + aMakeWire.Add( aSectionWire ); + } + + TopoDS_Shape aShape; + + if ( aMakeWire.IsDone() ) + { + aShape = aMakeWire.Shape(); + } + else if ( !aSectionWiresList.IsEmpty() ) + { + // build compound + TopoDS_Compound aCompound; + + BRep_Builder aBuilder; + aBuilder.MakeCompound( aCompound ); + + TopTools_ListIteratorOfListOfShape anIter( aSectionWiresList ); + for ( ; anIter.More(); anIter.Next() ) + { + aBuilder.Add( aCompound, anIter.Value() ); + } + + aShape = aCompound; + } + + setPolylineShape( aShape ); } -void HYDROData_PolylineXY::RemoveSection( const int /*theSectionIndex*/ ) +/** + * Returns true if polyline is closed + */ +bool HYDROData_PolylineXY::IsClosed() const { - RemoveSections(); + NCollection_Sequence aSectNames; + NCollection_Sequence aSectTypes; + NCollection_Sequence aSectClosures; + GetSections( aSectNames, aSectTypes, aSectClosures ); + if( aSectNames.IsEmpty() ) + return false; + + bool anIsClosed = true; + for( int i = 1, n = aSectClosures.Size(); i <= n && anIsClosed; ++i ) + anIsClosed = anIsClosed && aSectClosures.Value( i ); + + return anIsClosed; } -void HYDROData_PolylineXY::RemoveSections() +int HYDROData_PolylineXY::NbSections() const { - removePointsLists( 0 ); + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + + return !aClosuresList.IsNull() ? aClosuresList->Extent() : 0; } -void HYDROData_PolylineXY::AddPoint( const int /*theSectionIndex*/, - const Point& thePoint, - const int thePointIndex ) +TCollection_ExtendedString getUniqueSectionName( const Handle(TDataStd_ExtStringList)& theNamesList ) { - double aNewCoordU = thePoint.X(); - double aNewCoordZ = thePoint.Y(); + NCollection_Map aNamesMap; + + TDataStd_ListIteratorOfListOfExtendedString aNamesIter( theNamesList->List() ); + for ( ; aNamesIter.More(); aNamesIter.Next() ) + aNamesMap.Add( aNamesIter.Value() ); - Handle(TDataStd_RealList) aListU, aListZ; - getPointsLists( 0, aListU, aListZ ); + TCollection_ExtendedString aResName; - if ( aListU->IsEmpty() || aNewCoordU > aListU->Last() ) + int aPrefIdx = 1; + do { - aListU->Append( aNewCoordU ); - aListZ->Append( aNewCoordZ ); - return; + aResName = "Section_" + aPrefIdx; + ++aPrefIdx; } - else if ( aNewCoordU < aListU->First() ) + while ( aNamesMap.Contains( aResName ) ); + + return aResName; +} + +void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectName, + const SectionType theSectionType, + const bool theIsClosed ) +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList ); + + TCollection_ExtendedString aSectName( theSectName ); + if ( aSectName.Length() <= 0 ) + aSectName = getUniqueSectionName( aNamesList ); + + aNamesList->Append( aSectName ); + aTypesList->Append( theSectionType ); + aClosuresList->Append( theIsClosed ); +} + +TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const +{ + TCollection_AsciiString aResName; + + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() ) + return aResName; + + TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() ); + for ( int i = 0; aNamesIter.More() && i != theSectionIndex; aNamesIter.Next(), ++i ); + + if ( aNamesIter.More() ) + aResName = aNamesIter.Value(); + + return aResName; +} + +void HYDROData_PolylineXY::SetSectionName( const int theSectionIndex, + const TCollection_AsciiString& theSectionName ) +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() ) + return; + + TDataStd_ListOfExtendedString anOldNamesList; + anOldNamesList = aNamesList->List(); + + // Refill the existing list + aNamesList->Clear(); + + TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() ); + for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i ) + aNamesList->Append( i == theSectionIndex ? theSectionName : aNamesIter.Value() ); +} + +HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() ) + return SECTION_POLYLINE; + + TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() ); + for ( int i = 0; aTypesIter.More() && i != theSectionIndex; aTypesIter.Next(), ++i ); + + return aTypesIter.More() ? (SectionType)aTypesIter.Value() : SECTION_POLYLINE; +} + +void HYDROData_PolylineXY::SetSectionType( const int theSectionIndex, + const SectionType theSectionType ) +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() ) + return; + + TColStd_ListOfInteger anOldTypesList; + anOldTypesList = aTypesList->List(); + + // Refill the existing list + aTypesList->Clear(); + + TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList ); + for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i ) + aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() ); +} + +bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() ) + return false; + + TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() ); + for ( int i = 0; aClosuresIter.More() && i != theSectionIndex; aClosuresIter.Next(), ++i ); + + return aClosuresIter.More() ? (bool)aClosuresIter.Value() : false; +} + +void HYDROData_PolylineXY::SetSectionClosed( const int theSectionIndex, + const bool theIsClosed ) +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() ) + return; + + TDataStd_ListOfByte anOldClosuresList; + anOldClosuresList = aClosuresList->List(); + + // Refill the existing list + aClosuresList->Clear(); + + TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList ); + for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i ) + aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() ); +} + +void HYDROData_PolylineXY::GetSections( NCollection_Sequence& theSectNames, + NCollection_Sequence& theSectTypes, + NCollection_Sequence& theSectClosures ) const +{ + theSectNames.Clear(); + theSectTypes.Clear(); + theSectClosures.Clear(); + + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aNamesList.IsNull() || aTypesList.IsNull() || aClosuresList.IsNull() ) + return; + + TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() ); + TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() ); + TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() ); + for ( ; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More(); + aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next() ) { - aListU->Prepend( aNewCoordU ); - aListZ->Prepend( aNewCoordZ ); + const TCollection_ExtendedString& aSectName = aNamesIter.Value(); + SectionType aSectType = (SectionType)aTypesIter.Value(); + bool aSectClosures = aClosuresIter.Value(); + + theSectNames.Append( aSectName ); + theSectTypes.Append( aSectType ); + theSectClosures.Append( aSectClosures ); + } +} + +void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex ) +{ + Handle(TDataStd_ExtStringList) aNamesList; + Handle(TDataStd_IntegerList) aTypesList; + Handle(TDataStd_BooleanList) aClosuresList; + getSectionsLists( aNamesList, aTypesList, aClosuresList, false ); + if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() ) return; + + if ( aNamesList->Extent() == 1 ) + { + removeSectionsLists(); + removePointsLists(); } + else + { + TDataStd_ListOfExtendedString anOldNamesList; + anOldNamesList = aNamesList->List(); - TColStd_ListOfReal anOldListU; - anOldListU = aListU->List(); + TColStd_ListOfInteger anOldTypesList; + anOldTypesList = aTypesList->List(); - TColStd_ListOfReal anOldListZ; - anOldListZ = aListZ->List(); + TDataStd_ListOfByte anOldClosuresList; + anOldClosuresList = aClosuresList->List(); - // Crsat new lists - removePointsLists( 0 ); - getPointsLists( 0, aListU, aListZ ); + // Refill the existing lists + aNamesList->Clear(); + aTypesList->Clear(); + aClosuresList->Clear(); - bool anIsInserted = false; - TColStd_ListIteratorOfListOfReal anIterU( anOldListU ); - TColStd_ListIteratorOfListOfReal anIterZ( anOldListZ ); - for ( ; anIterU.More() && anIterZ.More(); anIterU.Next(), anIterZ.Next() ) + TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList ); + TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList ); + TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList ); + for ( int i = 0; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More(); + aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next(), ++i ) + { + if ( i == theSectionIndex ) + continue; // skip index to remove + + aNamesList->Append( aNamesIter.Value() ); + aTypesList->Append( aTypesIter.Value() ); + aClosuresList->Append( (bool)aClosuresIter.Value() ); + } + + // Remove points that belongs to removed section + removePointsLists( theSectionIndex ); + } +} + +void HYDROData_PolylineXY::RemoveSections() +{ + removeSectionsLists(); + removePointsLists(); +} + +void HYDROData_PolylineXY::AddPoint( const int theSectionIndex, + const Point& thePoint, + const int thePointIndex ) +{ + Handle(TDataStd_RealList) aListX, aListY; + getPointsLists( theSectionIndex, aListX, aListY ); + + if ( thePointIndex < 0 || thePointIndex >= aListX->Extent() ) + { + aListX->Append( thePoint.X() ); + aListY->Append( thePoint.Y() ); + } + else { - double aCoordU = anIterU.Value(); - double aCoordZ = anIterZ.Value(); + TColStd_ListOfReal anOldListX; + anOldListX = aListX->List(); + + TColStd_ListOfReal anOldListY; + anOldListY = aListY->List(); + + // Refill the existing lists + aListX->Clear(); + aListY->Clear(); - if ( !anIsInserted ) + TColStd_ListIteratorOfListOfReal anIterX( anOldListX ); + TColStd_ListIteratorOfListOfReal anIterY( anOldListY ); + for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i ) { - if ( ValuesEquals( aNewCoordU, aCoordU ) ) - { - // Just update Z value - aCoordZ = aNewCoordZ; - anIsInserted = true; - } - else if ( aNewCoordU < aCoordU ) + double aCoordX = anIterX.Value(); + double aCoordY = anIterY.Value(); + + if ( i == thePointIndex ) { - // Insert new point - aListU->Append( aNewCoordU ); - aListZ->Append( aNewCoordZ ); - anIsInserted = true; + // Insert our new point + aListX->Append( thePoint.X() ); + aListY->Append( thePoint.Y() ); } - } - aListU->Append( aCoordU ); - aListZ->Append( aCoordZ ); + aListX->Append( aCoordX ); + aListY->Append( aCoordY ); + } } } void HYDROData_PolylineXY::SetPoint( const int theSectionIndex, - const int /*thePointIndex*/, - const Point& thePoint ) + const Point& thePoint, + const int thePointIndex ) { - AddPoint( theSectionIndex, thePoint ); + Handle(TDataStd_RealList) aListX, aListY; + getPointsLists( theSectionIndex, aListX, aListY ); + + if ( thePointIndex < 0 ) + { + aListX->Prepend( thePoint.X() ); + aListY->Prepend( thePoint.Y() ); + } + else if ( thePointIndex >= aListX->Extent() ) + { + aListX->Append( thePoint.X() ); + aListY->Append( thePoint.Y() ); + } + else + { + TColStd_ListOfReal anOldListX; + anOldListX = aListX->List(); + + TColStd_ListOfReal anOldListY; + anOldListY = aListY->List(); + + // Refill the existing lists + aListX->Clear(); + aListY->Clear(); + + TColStd_ListIteratorOfListOfReal anIterX( anOldListX ); + TColStd_ListIteratorOfListOfReal anIterY( anOldListY ); + for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i ) + { + double aCoordX = anIterX.Value(); + double aCoordY = anIterY.Value(); + + if ( i == thePointIndex ) + { + // Insert our new point instead of old one + aCoordX = thePoint.X(); + aCoordY = thePoint.Y(); + } + + aListX->Append( aCoordX ); + aListY->Append( aCoordY ); + } + } } -void HYDROData_PolylineXY::RemovePoint( const int /*theSectionIndex*/, - const int thePointIndex ) +void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex, + const int thePointIndex ) { - Handle(TDataStd_RealList) aListU, aListZ; - getPointsLists( 0, aListU, aListZ, false ); - if ( aListU.IsNull() || aListZ.IsNull() || aListU->IsEmpty() ) + Handle(TDataStd_RealList) aListX, aListY; + getPointsLists( theSectionIndex, aListX, aListY, false ); + if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() ) return; - TColStd_ListOfReal anOldListU; - anOldListU = aListU->List(); + if ( aListX->Extent() == 1 ) + { + removePointsLists( theSectionIndex ); + } + else + { + TColStd_ListOfReal anOldListX; + anOldListX = aListX->List(); - TColStd_ListOfReal anOldListZ; - anOldListZ = aListZ->List(); + TColStd_ListOfReal anOldListY; + anOldListY = aListY->List(); - // Creat new lists - removePointsLists( 0 ); - getPointsLists( 0, aListU, aListZ ); + // Refill the existing lists + aListX->Clear(); + aListY->Clear(); - bool anIsInserted = false; - TColStd_ListIteratorOfListOfReal anIterU( anOldListU ); - TColStd_ListIteratorOfListOfReal anIterZ( anOldListZ ); - for ( int i = 0; anIterU.More() && anIterZ.More(); anIterU.Next(), anIterZ.Next(), ++i ) - { - if ( i == thePointIndex ) - continue; // skip index to remove + TColStd_ListIteratorOfListOfReal anIterX( anOldListX ); + TColStd_ListIteratorOfListOfReal anIterY( anOldListY ); + for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i ) + { + if ( i == thePointIndex ) + continue; // skip index to remove - aListU->Append( anIterU.Value() ); - aListZ->Append( anIterZ.Value() ); + aListX->Append( anIterX.Value() ); + aListY->Append( anIterY.Value() ); + } } } -HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int /*theSectionIndex*/ ) const +HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex ) const { PointsList aResList; - Handle(TDataStd_RealList) aListU, aListZ; - getPointsLists( 0, aListU, aListZ, false ); - if ( aListU.IsNull() || aListZ.IsNull() ) + Handle(TDataStd_RealList) aListX, aListY; + getPointsLists( theSectionIndex, aListX, aListY, false ); + if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() ) return aResList; - TColStd_ListIteratorOfListOfReal anIterU( aListU->List() ); - TColStd_ListIteratorOfListOfReal anIterZ( aListZ->List() ); - for ( ; anIterU.More() && anIterZ.More(); anIterU.Next(), anIterZ.Next() ) + TColStd_ListIteratorOfListOfReal anIterX( aListX->List() ); + TColStd_ListIteratorOfListOfReal anIterY( aListY->List() ); + for ( ; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next() ) { - Point aPoint( anIterU.Value(), anIterZ.Value() ); + Point aPoint( anIterX.Value(), anIterY.Value() ); aResList.Append( aPoint ); } return aResList; } +QPainterPath HYDROData_PolylineXY::GetPainterPath() const +{ + QPainterPath aPath; + + NCollection_Sequence aSectNames; + NCollection_Sequence aSectTypes; + NCollection_Sequence aSectClosures; + GetSections( aSectNames, aSectTypes, aSectClosures ); + if( aSectNames.IsEmpty() ) + return aPath; + + PointsList aSectPointsList = GetPoints( 0 ); + if( aSectPointsList.IsEmpty() ) + return aPath; + + SectionType aSectionType = aSectTypes.Value( 1 ); + bool anIsSectionClosed = aSectClosures.Value( 1 ); + + if ( aSectionType == SECTION_POLYLINE ) + { + aPath.moveTo( aSectPointsList.Value( 1 ).X(), aSectPointsList.Value( 1 ).Y() ); + + for( int i = 2, n = aSectPointsList.Size(); i <= n; ++i ) + { + const Point& aSectPoint = aSectPointsList.Value( i ); + + aPath.lineTo( aSectPoint.X(), aSectPoint.Y() ); + } + + if( anIsSectionClosed ) + aPath.closeSubpath(); + } + else + { + QList aPoints; + for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i ) + { + const Point& aSectPoint = aSectPointsList.Value( i ); + aPoints << aSectPoint.X() << aSectPoint.Y(); + } + + HYDROData_BSplineOperation aBSpline( aPoints, 0, anIsSectionClosed ); + aPath = aBSpline.ComputePath(); + } + + return aPath; +} + diff --git a/src/HYDROData/HYDROData_PolylineXY.h b/src/HYDROData/HYDROData_PolylineXY.h index ae8c848f..315fe7f1 100644 --- a/src/HYDROData/HYDROData_PolylineXY.h +++ b/src/HYDROData/HYDROData_PolylineXY.h @@ -6,6 +6,8 @@ DEFINE_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline) +class QPainterPath; + /**\class HYDROData_PolylineXY * \brief Class that stores/retreives information about the * parametric profile points. @@ -30,15 +32,37 @@ public: */ HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINEXY;} + /** + * Dump object to Python script representation. + */ + HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + + /** + * Returns data of object wrapped to QVariant. + * Reimplemented to wrap and return saved path. + */ + HYDRODATA_EXPORT virtual QVariant GetDataVariant(); public: /** * Returns the 3D presentation of all points. */ - HYDRODATA_EXPORT virtual TopoDS_Wire GetWire() const; + HYDRODATA_EXPORT virtual TopoDS_Shape GetShape(); + /** + * 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 true if polyline is closed + */ + HYDRODATA_EXPORT bool IsClosed() const; + /** * Returns number of sections. */ @@ -46,9 +70,41 @@ public: /** * Adds new one section. - * \param theIsClosed flag indicates type of polyline + * \param theSectName name of the section + * \param theSectionType type of section + * \param theIsClosed flag indicates closures of section */ - HYDRODATA_EXPORT virtual void AddSection( const bool theIsClosed ); + HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName, + const SectionType theSectionType, + const bool theIsClosed ); + + /** + * Returns name of section with given index. + * \param theSectionIndex index of section + */ + HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const; + + /** + * Set name for section with given index. + * \param theSectionIndex index of section + * \param theSectionName new section name + */ + HYDRODATA_EXPORT virtual void SetSectionName( const int theSectionIndex, + const TCollection_AsciiString& theSectionName ); + + /** + * Returns type of section with given index. + * \param theSectionIndex index of section + */ + HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const; + + /** + * Set type for section with given index. + * \param theSectionIndex index of section + * \param theSectionType new section type + */ + HYDRODATA_EXPORT virtual void SetSectionType( const int theSectionIndex, + const SectionType theSectionType ); /** * Returns true if section with given index is closed. @@ -56,6 +112,24 @@ public: */ HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const; + /** + * Set closed flag for section with given index. + * \param theSectionIndex index of section + * \param theIsClosed new closures state + */ + HYDRODATA_EXPORT virtual void SetSectionClosed( const int theSectionIndex, + const bool theIsClosed ); + + /** + * Adds new one section. + * \param theSectName name of the section + * \param theSectionType type of section + * \param theIsClosed flag indicates closures of section + */ + HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence& theSectNames, + NCollection_Sequence& theSectTypes, + NCollection_Sequence& theSectClosures ) const; + /** * Removes section with given index. * \param theSectionIndex index of section @@ -81,12 +155,12 @@ public: /** * Replaces point for section with index "theSectionIndex". * \param theSectionIndex index of section - * \param thePointIndex index of point to replace * \param thePoint new point + * \param thePointIndex index of point to replace */ HYDRODATA_EXPORT virtual void SetPoint( const int theSectionIndex, - const int thePointIndex, - const Point& thePoint ); + const Point& thePoint, + const int thePointIndex ); /** * Removes point from section with index "theSectionIndex". @@ -105,6 +179,15 @@ public: */ HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const; + + /** + * Returns the painter path. + * Note: currently only the first section of the polyline data is taken into account. + * \return polyline painter path. + */ + HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const; + + protected: friend class HYDROData_Profile; diff --git a/src/HYDROData/HYDROData_ProfileUZ.cxx b/src/HYDROData/HYDROData_ProfileUZ.cxx index 36ce31c6..d8ccba4e 100755 --- a/src/HYDROData/HYDROData_ProfileUZ.cxx +++ b/src/HYDROData/HYDROData_ProfileUZ.cxx @@ -9,7 +9,7 @@ #include -#include +#include IMPLEMENT_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline) @@ -24,10 +24,10 @@ HYDROData_ProfileUZ::~HYDROData_ProfileUZ() { } -TopoDS_Wire HYDROData_ProfileUZ::GetWire() const +TopoDS_Shape HYDROData_ProfileUZ::GetShape() { // TODO - return TopoDS_Wire(); + return TopoDS_Shape(); } int HYDROData_ProfileUZ::NbSections() const @@ -35,7 +35,29 @@ int HYDROData_ProfileUZ::NbSections() const return 1; } -void HYDROData_ProfileUZ::AddSection( const bool /*theIsClosed*/ ) +void HYDROData_ProfileUZ::AddSection( const TCollection_AsciiString& /*theSectName*/, + const SectionType /*theSectionType*/, + const bool /*theIsClosed*/ ) +{ +} + +TCollection_AsciiString HYDROData_ProfileUZ::GetSectionName( const int /*theSectionIndex*/ ) const +{ + return "Section_1"; +} + +void HYDROData_ProfileUZ::SetSectionName( const int /*theSectionIndex*/, + const TCollection_AsciiString& /*theSectionName*/ ) +{ +} + +HYDROData_ProfileUZ::SectionType HYDROData_ProfileUZ::GetSectionType( const int /*theSectionIndex*/ ) const +{ + return SECTION_POLYLINE; +} + +void HYDROData_ProfileUZ::SetSectionType( const int /*theSectionIndex*/, + const SectionType /*theSectionType*/ ) { } @@ -44,6 +66,11 @@ bool HYDROData_ProfileUZ::IsClosedSection( const int /*theSectionIndex*/ ) const return false; } +void HYDROData_ProfileUZ::SetSectionClosed( const int /*theSectionIndex*/, + const bool /*theIsClosed*/ ) +{ +} + void HYDROData_ProfileUZ::RemoveSection( const int /*theSectionIndex*/ ) { RemoveSections(); @@ -118,8 +145,8 @@ void HYDROData_ProfileUZ::AddPoint( const int /*theSectionIndex*/, } void HYDROData_ProfileUZ::SetPoint( const int theSectionIndex, - const int /*thePointIndex*/, - const Point& thePoint ) + const Point& thePoint, + const int /*thePointIndex*/ ) { AddPoint( theSectionIndex, thePoint ); } diff --git a/src/HYDROData/HYDROData_ProfileUZ.h b/src/HYDROData/HYDROData_ProfileUZ.h index 22441a56..3ec8fabc 100644 --- a/src/HYDROData/HYDROData_ProfileUZ.h +++ b/src/HYDROData/HYDROData_ProfileUZ.h @@ -35,7 +35,7 @@ public: /** * Returns the 3D presentation of all points. */ - HYDRODATA_EXPORT virtual TopoDS_Wire GetWire() const; + HYDRODATA_EXPORT virtual TopoDS_Shape GetShape(); /** @@ -45,9 +45,41 @@ public: /** * Adds new one section. - * \param theIsClosed flag indicates type of polyline + * \param theSectName name of the section + * \param theSectionType type of section + * \param theIsClosed flag indicates closures of section */ - HYDRODATA_EXPORT virtual void AddSection( const bool theIsClosed ); + HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName, + const SectionType theSectionType, + const bool theIsClosed ); + + /** + * Returns name of section with given index. + * \param theSectionIndex index of section + */ + HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const; + + /** + * Set name for section with given index. + * \param theSectionIndex index of section + * \param theSectionName new section name + */ + HYDRODATA_EXPORT virtual void SetSectionName( const int theSectionIndex, + const TCollection_AsciiString& theSectionName ); + + /** + * Returns type of section with given index. + * \param theSectionIndex index of section + */ + HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const; + + /** + * Set type for section with given index. + * \param theSectionIndex index of section + * \param theSectionType new section type + */ + HYDRODATA_EXPORT virtual void SetSectionType( const int theSectionIndex, + const SectionType theSectionType ); /** * Returns true if section with given index is closed. @@ -55,6 +87,14 @@ public: */ HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const; + /** + * Set closed flag for section with given index. + * \param theSectionIndex index of section + * \param theIsClosed new closures state + */ + HYDRODATA_EXPORT virtual void SetSectionClosed( const int theSectionIndex, + const bool theIsClosed ); + /** * Removes section with given index. * \param theSectionIndex index of section @@ -80,12 +120,12 @@ public: /** * Replaces point for section with index "theSectionIndex". * \param theSectionIndex index of section - * \param thePointIndex index of point to replace * \param thePoint new point + * \param thePointIndex index of point to replace */ HYDRODATA_EXPORT virtual void SetPoint( const int theSectionIndex, - const int thePointIndex, - const Point& thePoint ); + const Point& thePoint, + const int thePointIndex ); /** * Removes point from section with index "theSectionIndex". diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.cxx b/src/HYDROData/HYDROData_SplitToZonesTool.cxx index 24e53396..0990ef4c 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.cxx +++ b/src/HYDROData/HYDROData_SplitToZonesTool.cxx @@ -1,7 +1,7 @@ #include "HYDROData_SplitToZonesTool.h" -#include "HYDROData_Polyline.h" +#include "HYDROData_PolylineXY.h" #include #include @@ -36,7 +36,7 @@ TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const HYDROData_SplitToZonesTool::SplitDataList HYDROData_SplitToZonesTool::SplitToZones( const HYDROData_SequenceOfObjects& theObjectList, - const Handle(HYDROData_Polyline)& thePolyline ) + const Handle(HYDROData_PolylineXY)& thePolyline ) { SplitDataList anOutputSplitDataList; @@ -106,7 +106,7 @@ HYDROData_SplitToZonesTool::SplitToZones( const HYDROData_SequenceOfObjects& the // Step 2. Take into account the boundary polyline. if( !thePolyline.IsNull() ) { - TopoDS_Wire aWire = TopoDS::Wire( thePolyline->GetTopShape() ); + TopoDS_Wire aWire = TopoDS::Wire( thePolyline->GetShape() ); if( !aWire.IsNull() ) { BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True ); diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.h b/src/HYDROData/HYDROData_SplitToZonesTool.h index 4552dd8c..4d7780f3 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.h +++ b/src/HYDROData/HYDROData_SplitToZonesTool.h @@ -8,7 +8,7 @@ #include -class Handle(HYDROData_Polyline); +class Handle(HYDROData_PolylineXY); /** * \class HYDROData_SplitToZonesTool @@ -42,7 +42,7 @@ public: public: static SplitDataList SplitToZones( const HYDROData_SequenceOfObjects& theObjectList, - const Handle(HYDROData_Polyline)& thePolyline ); + const Handle(HYDROData_PolylineXY)& thePolyline ); private: diff --git a/src/HYDROData/test_HYDROData_OperationsFactory.cxx b/src/HYDROData/test_HYDROData_OperationsFactory.cxx index b5d068fe..b54ce7ee 100644 --- a/src/HYDROData/test_HYDROData_OperationsFactory.cxx +++ b/src/HYDROData/test_HYDROData_OperationsFactory.cxx @@ -2,11 +2,13 @@ #include #include -#include +#include #include #include +#include + #include void test_HYDROData_OperationsFactory::testCreate() @@ -46,21 +48,15 @@ void test_HYDROData_OperationsFactory::testCrop() QImage aTestImage = TestImage(); anOriImage->SetImage( aTestImage ); - Handle(HYDROData_Polyline) aCropPolyline = - Handle(HYDROData_Polyline)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) ); - - HYDROData_Polyline::PolylineData aPolylineData; - - PolylineSection aPolylineSect; - - aPolylineSect.myCoords << 25 << 0 << 0; - aPolylineSect.myCoords << 0 << 20 << 0; - aPolylineSect.myCoords << 25 << 40 << 0; - aPolylineSect.myCoords << 50 << 20 << 0; + Handle(HYDROData_PolylineXY) aCropPolyline = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); - aPolylineData << aPolylineSect; + aCropPolyline->AddSection( "", HYDROData_PolylineXY::SECTION_POLYLINE, true ); - aCropPolyline->SetPolylineData( aPolylineData ); + aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 25, 0 ) ); + aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 0, 20 ) ); + aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 25, 40 ) ); + aCropPolyline->AddPoint( 0, HYDROData_PolylineXY::Point( 50, 20 ) ); // prepare Composer Operation ImageComposer_Operator* aCropOp = diff --git a/src/HYDROData/test_HYDROData_Polyline.cxx b/src/HYDROData/test_HYDROData_Polyline.cxx deleted file mode 100755 index 8899ee29..00000000 --- a/src/HYDROData/test_HYDROData_Polyline.cxx +++ /dev/null @@ -1,80 +0,0 @@ -#include - -#include -#include - -#include -#include - -void test_HYDROData_Polyline::testPolyline() -{ - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); - - Handle(HYDROData_Polyline) aPolyline = - Handle(HYDROData_Polyline)::DownCast(aDoc->CreateObject(KIND_POLYLINE)); - // empty image - - int aDim = aPolyline->GetDimension(); - CPPUNIT_ASSERT(aDim == 0 ); - - aPolyline->SetDimension(2); - aDim = aPolyline->GetDimension(); - CPPUNIT_ASSERT( aDim == 2 ); - - aPolyline->SetDimension(3); - aDim = aPolyline->GetDimension(); - CPPUNIT_ASSERT( aDim == 3 ); - - PolylineSection aSect1; - aSect1.mySectionName = "Section_1"; - aSect1.myType = PolylineSection::SECTION_POLYLINE; - aSect1.myIsClosed = false; - - QList aSections; - aSections << aSect1; - - PolylineSection aSect2; - aSect1.mySectionName = "Section_2"; - aSect1.myType = PolylineSection::SECTION_SPLINE; - aSect1.myIsClosed = true; - aSections << aSect2; - - aPolyline->SetPolylineData( aSections ); - QList aRestoredSect = aPolyline->GetPolylineData(); - int aRestSize = aRestoredSect.size(); - CPPUNIT_ASSERT( aRestSize == 2 ); - -// printf("Sect1.Name=%s RestName=%s\n", aSect1.mySectionName, aRestoredSect[0].mySectionName ); - CPPUNIT_ASSERT( aRestoredSect[0].myType == PolylineSection::SECTION_POLYLINE ); - CPPUNIT_ASSERT( aRestoredSect[0].myIsClosed == false ); - CPPUNIT_ASSERT( aRestoredSect[0].mySectionName.IsLess( aSect1.mySectionName ) == false ); - CPPUNIT_ASSERT( aRestoredSect[0].mySectionName.IsGreater( aSect1.mySectionName ) == false ); - CPPUNIT_ASSERT( aRestoredSect[0].myCoords.size() == 0 ); - - CPPUNIT_ASSERT( aRestoredSect[1].myType == PolylineSection::SECTION_SPLINE ); - CPPUNIT_ASSERT( aRestoredSect[1].myIsClosed == true ); - CPPUNIT_ASSERT( aRestoredSect[1].mySectionName.IsLess( aSect2.mySectionName ) == false ); - CPPUNIT_ASSERT( aRestoredSect[1].mySectionName.IsGreater( aSect2.mySectionName ) == false ); - CPPUNIT_ASSERT( aRestoredSect[1].myCoords.size() == 0 ); - - aDoc->Close(); -} - - -void test_HYDROData_Polyline::testCopy() -{ - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); - Handle(HYDROData_Polyline) aPolyline1 = - Handle(HYDROData_Polyline)::DownCast(aDoc->CreateObject(KIND_POLYLINE)); - - -// aPolyline1->setPoints(aPoints); - - Handle(HYDROData_Polyline) aPolyline2 = - Handle(HYDROData_Polyline)::DownCast(aDoc->CreateObject(KIND_POLYLINE)); - - aPolyline1->CopyTo(aPolyline2); - - - aDoc->Close(); -} diff --git a/src/HYDROData/test_HYDROData_Polyline.h b/src/HYDROData/test_HYDROData_Polyline.h deleted file mode 100755 index 30c8e893..00000000 --- a/src/HYDROData/test_HYDROData_Polyline.h +++ /dev/null @@ -1,25 +0,0 @@ -#include - -class test_HYDROData_Polyline : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(test_HYDROData_Polyline); - CPPUNIT_TEST(testPolyline); - CPPUNIT_TEST(testCopy); - CPPUNIT_TEST_SUITE_END(); - -private: - -public: - - void setUp() {} - - void tearDown() {} - - // checks save/restore QImages information - void testPolyline(); - - // checks the image properties copy/paste - void testCopy(); -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Polyline); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Polyline, "HYDROData_Polyline"); diff --git a/src/HYDROData/test_HYDROData_PolylineXY.cxx b/src/HYDROData/test_HYDROData_PolylineXY.cxx new file mode 100644 index 00000000..72187033 --- /dev/null +++ b/src/HYDROData/test_HYDROData_PolylineXY.cxx @@ -0,0 +1,55 @@ +#include + +#include +#include + +#include +#include + +void test_HYDROData_PolylineXY::testPolyline() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); + + Handle(HYDROData_PolylineXY) aPolyline = + Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY)); + + aPolyline->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, false ); + aPolyline->AddSection( "Section_2", HYDROData_PolylineXY::SECTION_SPLINE, true ); + + int aNbSections = aPolyline->NbSections(); + CPPUNIT_ASSERT( aNbSections == 2 ); + + NCollection_Sequence aSectNames; + NCollection_Sequence aSectTypes; + NCollection_Sequence aSectClosures; + aPolyline->GetSections( aSectNames, aSectTypes, aSectClosures ); + + CPPUNIT_ASSERT( aSectNames.Value( 0 ) == "Section_1" ); + CPPUNIT_ASSERT( aSectTypes.Value( 0 ) == HYDROData_PolylineXY::SECTION_POLYLINE ); + CPPUNIT_ASSERT( aSectClosures.Value( 0 ) == false ); + + CPPUNIT_ASSERT( aSectNames.Value( 1 ) == "Section_2" ); + CPPUNIT_ASSERT( aSectTypes.Value( 1 ) == HYDROData_PolylineXY::SECTION_SPLINE ); + CPPUNIT_ASSERT( aSectClosures.Value( 1 ) == true ); + + aDoc->Close(); +} + + +void test_HYDROData_PolylineXY::testCopy() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_PolylineXY) aPolyline1 = + Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY)); + + +// aPolyline1->setPoints(aPoints); + + Handle(HYDROData_PolylineXY) aPolyline2 = + Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY)); + + aPolyline1->CopyTo(aPolyline2); + + + aDoc->Close(); +} diff --git a/src/HYDROData/test_HYDROData_PolylineXY.h b/src/HYDROData/test_HYDROData_PolylineXY.h new file mode 100755 index 00000000..425b4da6 --- /dev/null +++ b/src/HYDROData/test_HYDROData_PolylineXY.h @@ -0,0 +1,25 @@ +#include + +class test_HYDROData_PolylineXY : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(test_HYDROData_PolylineXY); + CPPUNIT_TEST(testPolyline); + CPPUNIT_TEST(testCopy); + CPPUNIT_TEST_SUITE_END(); + +private: + +public: + + void setUp() {} + + void tearDown() {} + + // checks save/restore QImages information + void testPolyline(); + + // checks the image properties copy/paste + void testCopy(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_PolylineXY, "HYDROData_PolylineXY"); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 707a3086..0ded3730 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -30,7 +30,7 @@ #include "HYDROGUI_Zone.h" #include "HYDROGUI_Region.h" -#include +#include #include #include #include @@ -85,17 +85,17 @@ void HYDROGUI_CalculationOp::startOperation() // Get all polylines aList.clear(); anEntryList.clear(); - HYDROData_Iterator anIter( doc(), KIND_POLYLINE ); - Handle(HYDROData_Polyline) aPolylineObj; + HYDROData_Iterator anIter( doc(), KIND_POLYLINEXY ); + Handle(HYDROData_PolylineXY) aPolylineObj; QString aPolylineName; for ( ; anIter.More(); anIter.Next() ) { - aPolylineObj = Handle(HYDROData_Polyline)::DownCast( anIter.Current() ); + aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() ); if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed() ) { // Check the polyline shape - TopoDS_Shape aPolylineShape = aPolylineObj->GetTopShape(); + TopoDS_Shape aPolylineShape = aPolylineObj->GetShape(); if ( !aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE ) { aPolylineName = aPolylineObj->GetName(); if ( !aPolylineName.isEmpty() ) @@ -214,7 +214,7 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName ) { // Set the selected boundary polyline to the calculation case - Handle(HYDROData_Polyline) anObject; + Handle(HYDROData_PolylineXY) anObject; Handle(AIS_InteractiveContext) aCtx; if ( myPreviewViewManager ) { @@ -238,10 +238,10 @@ void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName ) else { Handle(HYDROData_Entity) anEntity = - HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_POLYLINE ); + HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_POLYLINEXY ); if ( !anEntity.IsNull() ) { - anObject = Handle(HYDROData_Polyline)::DownCast( anEntity ); + anObject = Handle(HYDROData_PolylineXY)::DownCast( anEntity ); if ( !anObject.IsNull() ) { myEditedObject->SetBoundaryPolyline( anObject ); diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 9432c01c..f3440a44 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -250,7 +250,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) LightApp_DataObject* aCalculRootObj = createObject( aRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) ); // POLYLINES - LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) ); + LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINEXY ).toAscii() ) ); // PROFILES LightApp_DataObject* aProfileRootObj = createObject( aRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) ); @@ -343,10 +343,10 @@ void HYDROGUI_DataModel::update( const int theStudyId ) break; } - case KIND_POLYLINE: + case KIND_POLYLINEXY: { - Handle(HYDROData_Polyline) aPolylineObj = - Handle(HYDROData_Polyline)::DownCast( anObj ); + Handle(HYDROData_PolylineXY) aPolylineObj = + Handle(HYDROData_PolylineXY)::DownCast( anObj ); if( !aPolylineObj.IsNull() ) { createObject( aPolylineRootObj, aPolylineObj ); } @@ -595,7 +595,7 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind ) switch( theObjectKind ) { case KIND_IMAGE: return "IMAGES"; - case KIND_POLYLINE: return "POLYLINES"; + case KIND_POLYLINEXY: return "POLYLINES"; case KIND_PROFILE: return "PROFILES"; case KIND_VISUAL_STATE: return "VISUAL_STATES"; case KIND_BATHYMETRY: return "BATHYMETRIES"; @@ -697,7 +697,7 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent, LightApp_DataObject* aPolylineSect = createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() ); - Handle(HYDROData_Polyline) aPolyline = aZoneObj->GetPolyline(); + Handle(HYDROData_PolylineXY) aPolyline = aZoneObj->GetPolyline(); if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() ) createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false ); diff --git a/src/HYDROGUI/HYDROGUI_DeleteOp.cxx b/src/HYDROGUI/HYDROGUI_DeleteOp.cxx index 704fa4e3..deb1542d 100644 --- a/src/HYDROGUI/HYDROGUI_DeleteOp.cxx +++ b/src/HYDROGUI/HYDROGUI_DeleteOp.cxx @@ -63,7 +63,7 @@ void HYDROGUI_DeleteOp::startOperation() // collect the back-references ObjectKind aKind = anObject->GetKind(); - if( aKind == KIND_IMAGE || aKind == KIND_POLYLINE ) + if( aKind == KIND_IMAGE || aKind == KIND_POLYLINEXY ) { HYDROData_SequenceOfObjects anObjects; QStringList aNames; diff --git a/src/HYDROGUI/HYDROGUI_Displayer.cxx b/src/HYDROGUI/HYDROGUI_Displayer.cxx index 045b7db3..548f5e47 100644 --- a/src/HYDROGUI/HYDROGUI_Displayer.cxx +++ b/src/HYDROGUI/HYDROGUI_Displayer.cxx @@ -201,7 +201,7 @@ HYDROGUI_PrsDriver* HYDROGUI_Displayer::getDriver( const Handle(HYDROData_Entity case KIND_IMAGE: aDriver = new HYDROGUI_PrsImageDriver(); break; - case KIND_POLYLINE: + case KIND_POLYLINEXY: aDriver = new HYDROGUI_PrsPolylineDriver(); break; case KIND_ZONE: diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx index ecf6b283..92bcc38c 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include @@ -86,7 +86,7 @@ void HYDROGUI_ImmersibleZoneOp::startOperation() aFillingColor = myEditedObject->GetFillingColor(); aBorderColor = myEditedObject->GetBorderColor(); - Handle(HYDROData_Polyline) aRefPolyline = myEditedObject->GetPolyline(); + Handle(HYDROData_PolylineXY) aRefPolyline = myEditedObject->GetPolyline(); if ( !aRefPolyline.IsNull() ) aSelectedPolyline = aRefPolyline->GetName(); @@ -99,11 +99,11 @@ void HYDROGUI_ImmersibleZoneOp::startOperation() // collect information about existing closed polylines QStringList aPolylines; - HYDROData_Iterator anIter( doc(), KIND_POLYLINE ); + HYDROData_Iterator anIter( doc(), KIND_POLYLINEXY ); for ( ; anIter.More(); anIter.Next() ) { - Handle(HYDROData_Polyline) aPolylineObj = - Handle(HYDROData_Polyline)::DownCast( anIter.Current() ); + Handle(HYDROData_PolylineXY) aPolylineObj = + Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() ); if ( aPolylineObj.IsNull() || !aPolylineObj->IsClosed() ) continue; @@ -195,14 +195,14 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags, if ( aZoneObj.IsNull() ) return false; - Handle(HYDROData_Polyline) aZonePolyline; + Handle(HYDROData_PolylineXY) aZonePolyline; Handle(HYDROData_Bathymetry) aZoneBathymetry; QString aPolylineName = aPanel->getPolylineName(); if ( !aPolylineName.isEmpty() ) { - aZonePolyline = Handle(HYDROData_Polyline)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINE ) ); + aZonePolyline = Handle(HYDROData_PolylineXY)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) ); } QString aBathymetryName = aPanel->getBathymetryName(); @@ -241,11 +241,11 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName TopoDS_Wire aWire; TopoDS_Shape aShape; - Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), thePolylineName, KIND_POLYLINE ) ); + Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), thePolylineName, KIND_POLYLINEXY ) ); if ( !aPolyline.IsNull() ) { - aShape = aPolyline->GetTopShape(); + aShape = aPolyline->GetShape(); if ( aShape.ShapeType() == TopAbs_WIRE ) { aWire = TopoDS::Wire( aShape ); } diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 4a3ad4ca..c7f9eff5 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -279,7 +279,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, } } } - else if( anObject->GetKind() == KIND_POLYLINE ) + else if( anObject->GetKind() == KIND_POLYLINEXY ) anIsPolyline = true; else if( anObject->GetKind() == KIND_PROFILE ) anIsProfile = true; @@ -313,7 +313,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, case KIND_IMAGE: theMenu->addAction( action( ImportImageId ) ); break; - case KIND_POLYLINE: + case KIND_POLYLINEXY: theMenu->addAction( action( CreatePolylineId ) ); break; case KIND_PROFILE: diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index 602cb5cb..faf46892 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -101,7 +101,7 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int ObjectKind anObjectKind = theObject->GetKind(); if ( anObjectKind != KIND_IMAGE && - anObjectKind != KIND_POLYLINE && + anObjectKind != KIND_POLYLINEXY && anObjectKind != KIND_IMMERSIBLE_ZONE && anObjectKind != KIND_REGION && anObjectKind != KIND_ZONE && diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index 5932efc5..ce078a5f 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -19,16 +19,18 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "HYDROGUI_Module.h" + #include "HYDROGUI_PolylineOp.h" + +#include "HYDROGUI_Module.h" #include "HYDROGUI_PolylineDlg.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" -#include "HYDROData_Document.h" -#include "HYDROData_Polyline.h" -#include "CurveCreator_Curve.hxx" -#include "CurveCreator_Displayer.h" +#include + +#include +#include #include #include @@ -45,8 +47,10 @@ //static int ZValueIncrement = 0; HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit ) -: HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), myCurve(NULL), - myViewManager(NULL) +: HYDROGUI_Operation( theModule ), + myIsEdit( theIsEdit ), + myCurve( NULL ), + myViewManager( NULL ) { setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) ); } @@ -77,10 +81,9 @@ bool HYDROGUI_PolylineOp::deleteEnabled() void HYDROGUI_PolylineOp::startOperation() { if( myCurve ) - { delete myCurve; - myCurve = 0; - } + + myCurve = new CurveCreator_Curve( CurveCreator::Dim2d ); HYDROGUI_Operation::startOperation(); @@ -93,39 +96,48 @@ void HYDROGUI_PolylineOp::startOperation() aPanel->setOCCViewer( myViewManager ? myViewManager->getOCCViewer() : 0 ); if( myIsEdit ) - myEditedObject = Handle(HYDROData_Polyline)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + myEditedObject = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + + QString aPolylineName; if( !myEditedObject.IsNull() ) { - int anIntDim = myEditedObject->GetDimension(); - CurveCreator::Dimension aDim = CurveCreator::Dim3d; - if( anIntDim == 2 ) - aDim = CurveCreator::Dim2d; - myCurve = new CurveCreator_Curve(aDim); - QList aPolylineData = myEditedObject->GetPolylineData(); - - for( int i = 0 ; i < aPolylineData.size() ; i++ ){ - std::string aName = HYDROGUI_Tool::ToQString(aPolylineData[i].mySectionName).toStdString(); - bool isClosed = aPolylineData[i].myIsClosed; - CurveCreator::SectionType aType = CurveCreator::Polyline; - if( aPolylineData[i].myType == PolylineSection::SECTION_SPLINE ){ - aType = CurveCreator::Spline; - } - CurveCreator::Coordinates aCoords; - for( int j = 0 ; j < aPolylineData[i].myCoords.size() ; j++ ){ - aCoords.push_back(aPolylineData[i].myCoords[j]); + NCollection_Sequence aSectNames; + NCollection_Sequence aSectTypes; + NCollection_Sequence aSectClosures; + myEditedObject->GetSections( aSectNames, aSectTypes, aSectClosures ); + + for ( int i = 1, n = aSectNames.Size(); i <= n; ++i ) + { + QString aSectName = HYDROGUI_Tool::ToQString( aSectNames.Value( i ) ); + HYDROData_PolylineXY::SectionType aSectType = aSectTypes.Value( i ); + bool aSectClosure = aSectClosures.Value( i ); + + CurveCreator::SectionType aCurveType = CurveCreator::Polyline; + if( aSectType == HYDROData_PolylineXY::SECTION_SPLINE ) + aCurveType = CurveCreator::Spline; + + CurveCreator::Coordinates aCurveCoords; + + HYDROData_PolylineXY::PointsList aSectPointsList = myEditedObject->GetPoints( i - 1 ); + for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k ) + { + const HYDROData_PolylineXY::Point& aSectPoint = aSectPointsList.Value( k ); + aCurveCoords.push_back( aSectPoint.X() ); + aCurveCoords.push_back( aSectPoint.Y() ); } - myCurve->addSectionInternal( aName, aType, isClosed, aCoords ); + + myCurve->addSectionInternal( aSectName.toStdString(), aCurveType, aSectClosure, aCurveCoords ); } - aPanel->setPolylineName( myEditedObject->GetName() ); + aPolylineName = myEditedObject->GetName(); } - else{ - myCurve = new CurveCreator_Curve(CurveCreator::Dim2d); - //aPanel->setCurve(myCurve); - QString aNewName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_POLYLINE_NAME" ) ); - aPanel->setPolylineName(aNewName); + else + { + aPolylineName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_POLYLINE_NAME" ) ); } - aPanel->setCurve(myCurve); + + aPanel->setPolylineName( aPolylineName ); + aPanel->setCurve( myCurve ); displayPreview(); } @@ -168,12 +180,14 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, if( aDocument.IsNull() ) return false; - Handle(HYDROData_Polyline) aPolylineObj; - if( myIsEdit ){ + Handle(HYDROData_PolylineXY) aPolylineObj; + if( myIsEdit ) + { aPolylineObj = myEditedObject; + aPolylineObj->RemoveSections(); } else{ - aPolylineObj = Handle(HYDROData_Polyline)::DownCast( aDocument->CreateObject( KIND_POLYLINE ) ); + aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( aDocument->CreateObject( KIND_POLYLINEXY ) ); //double aZValue = double( ++ZValueIncrement ) * 1e-2; // empiric value, to be revised //aPolylineObj->SetZValue( aZValue ); @@ -184,36 +198,59 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, QString aPolylineName = aPanel->getPolylineName(); aPolylineObj->SetName(aPolylineName); - int aDimInt = 3; - if( myCurve->getDimension() == CurveCreator::Dim2d ) - aDimInt = 2; - aPolylineObj->SetDimension(aDimInt); - QList aPolylineData; - for( int i=0 ; i < myCurve->getNbSections() ; i++ ){ - PolylineSection aSect; - aSect.mySectionName = HYDROGUI_Tool::ToExtString( QString::fromLocal8Bit(myCurve->getSectionName(i).c_str())); - aSect.myIsClosed = myCurve->isClosed(i); - aSect.myType = PolylineSection::SECTION_POLYLINE; - if( myCurve->getSectionType(i) == CurveCreator::Spline ){ - aSect.myType = PolylineSection::SECTION_SPLINE; - } - CurveCreator::Coordinates aCoords = myCurve->getPoints(i); - for( int j = 0 ; j < aCoords.size() ; j++ ){ - aSect.myCoords << aCoords.at(j); + + for ( int i = 0 ; i < myCurve->getNbSections() ; i++ ) + { + TCollection_AsciiString aSectName = HYDROGUI_Tool::ToAsciiString( myCurve->getSectionName( i ).c_str() ); + CurveCreator::SectionType aCurveType = myCurve->getSectionType( i ); + bool aSectClosure = myCurve->isClosed( i ); + + HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE; + + if ( aCurveType == CurveCreator::Spline ) + aSectType = HYDROData_PolylineXY::SECTION_SPLINE; + + aPolylineObj->AddSection( aSectName, aSectType, aSectClosure ); + + // Add the points fro section + CurveCreator::Coordinates aCurveCoords = myCurve->getPoints( i ); + for ( int k = 0 ; k + 1 < aCurveCoords.size() ; k++ ) + { + HYDROData_PolylineXY::Point aSectPoint; + + aSectPoint.SetX( aCurveCoords.at( k ) ); + k++; + aSectPoint.SetY( aCurveCoords.at( k ) ); + + aPolylineObj->AddPoint( i, aSectPoint ); } - aPolylineData << aSect; } - aPolylineObj->SetPolylineData(aPolylineData); + + // Update the wire of polyline + aPolylineObj->Update(); // the viewer should be release from the widget before the module update it // because it has an opened local context and updated presentation should not be displayed in it if ( aPanel ) aPanel->setOCCViewer( 0 ); - if( !myIsEdit ) - module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aPolylineObj, true ); + theUpdateFlags = UF_Model; + + size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() ); + if ( anActiveViewId != 0 ) + { + theUpdateFlags |= UF_Viewer | UF_GV_Forced; + } + else + { + anActiveViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() ); + theUpdateFlags |= UF_OCCViewer | UF_OCC_Forced; + } - theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced; + if( !myIsEdit ) + { + module()->setObjectVisible( anActiveViewId, aPolylineObj, true ); + } return true; } diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.h b/src/HYDROGUI/HYDROGUI_PolylineOp.h index aebd8be0..2192aa5f 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.h +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.h @@ -25,7 +25,7 @@ #include "HYDROGUI_Operation.h" -#include +#include class OCCViewer_ViewManager; class CurveCreator_Curve; @@ -58,11 +58,11 @@ private: void erasePreview(); private: - OCCViewer_ViewManager* myViewManager; + OCCViewer_ViewManager* myViewManager; - bool myIsEdit; - Handle(HYDROData_Polyline) myEditedObject; - CurveCreator_Curve* myCurve; + bool myIsEdit; + Handle(HYDROData_PolylineXY) myEditedObject; + CurveCreator_Curve* myCurve; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_PrsPolylineDriver.cxx b/src/HYDROGUI/HYDROGUI_PrsPolylineDriver.cxx index 5bb2ba29..d7304e9e 100644 --- a/src/HYDROGUI/HYDROGUI_PrsPolylineDriver.cxx +++ b/src/HYDROGUI/HYDROGUI_PrsPolylineDriver.cxx @@ -24,7 +24,7 @@ #include "HYDROGUI_PrsPolyline.h" -#include +#include HYDROGUI_PrsPolylineDriver::HYDROGUI_PrsPolylineDriver() :HYDROGUI_PrsDriver() @@ -43,7 +43,7 @@ bool HYDROGUI_PrsPolylineDriver::Update( const Handle(HYDROData_Entity)& theObj, if( theObj.IsNull() ) return false; - Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast( theObj ); + Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( theObj ); if( aPolyline.IsNull() ) return false; diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 534a57ce..d1de7c3c 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include @@ -139,12 +139,12 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) setFillingColor( aFillingColor, false, false ); setBorderColor( aBorderColor, false, false ); } - else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline) ) ) + else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_PolylineXY) ) ) { - Handle(HYDROData_Polyline) aPolyline = - Handle(HYDROData_Polyline)::DownCast( myObject ); + Handle(HYDROData_PolylineXY) aPolyline = + Handle(HYDROData_PolylineXY)::DownCast( myObject ); - TopoDS_Shape aPolylineShape = aPolyline->GetTopShape(); + TopoDS_Shape aPolylineShape = aPolyline->GetShape(); if ( !aPolylineShape.IsNull() ) { if ( aPolylineShape.ShapeType() == TopAbs_WIRE ) { diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index 45214704..51126a3c 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -214,7 +214,7 @@ void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule, Handle(HYDROData_Entity) anObject = anIterator.Current(); if( !anObject.IsNull() && ( ( anObject->GetKind() == KIND_IMAGE ) || - ( anObject->GetKind() == KIND_POLYLINE ) || + ( anObject->GetKind() == KIND_POLYLINEXY ) || ( anObject->GetKind() == KIND_IMMERSIBLE_ZONE ) || ( anObject->GetKind() == KIND_REGION ) || ( anObject->GetKind() == KIND_BATHYMETRY ) || diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx index 4ed15020..1ba4a668 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx @@ -62,7 +62,7 @@ HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const myImage2 = new HYDROGUI_ObjSelector( theModule, KIND_IMAGE, aParamGroup ); myPolylineLabel = new QLabel( tr( "POLYLINE" ), aParamGroup ); - myPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINE, aParamGroup ); + myPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINEXY, aParamGroup ); QFrame* aBackgroundFrame = new QFrame( aParamGroup ); QLabel* aBackgroundLabel = new QLabel( tr( "BACKGROUND" ), aBackgroundFrame ); diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx index 38375491..def6f125 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx @@ -29,7 +29,6 @@ #include #include -#include #include diff --git a/src/HYDROPy/CMakeLists.txt b/src/HYDROPy/CMakeLists.txt index 151f7ad0..73dc1425 100644 --- a/src/HYDROPy/CMakeLists.txt +++ b/src/HYDROPy/CMakeLists.txt @@ -55,10 +55,12 @@ SET(_sip_files SET(_sip_files2 HYDROData_Entity.sip HYDROData_Object.sip + HYDROData_IPolyline.sip + HYDROData_ProfileUZ.sip + HYDROData_PolylineXY.sip HYDROData_ArtificialObject.sip HYDROData_NaturalObject.sip HYDROData_Image.sip - HYDROData_Polyline.sip HYDROData_Bathymetry.sip HYDROData_ImmersibleZone.sip HYDROData_Zone.sip diff --git a/src/HYDROPy/HYDROData.sip b/src/HYDROPy/HYDROData.sip index 3166f050..ccd6aa89 100644 --- a/src/HYDROPy/HYDROData.sip +++ b/src/HYDROPy/HYDROData.sip @@ -53,10 +53,13 @@ See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com %Include HYDROData_Entity.sip %Include HYDROData_Object.sip +%Include HYDROData_IPolyline.sip +%Include HYDROData_ProfileUZ.sip +%Include HYDROData_PolylineXY.sip %Include HYDROData_ArtificialObject.sip %Include HYDROData_NaturalObject.sip %Include HYDROData_Image.sip -%Include HYDROData_Polyline.sip +%Include HYDROData_PolylineXY.sip %Include HYDROData_Bathymetry.sip %Include HYDROData_ImmersibleZone.sip %Include HYDROData_Zone.sip diff --git a/src/HYDROPy/HYDROData_Document.sip b/src/HYDROPy/HYDROData_Document.sip index 2cbfbbc7..37bd970f 100644 --- a/src/HYDROPy/HYDROData_Document.sip +++ b/src/HYDROPy/HYDROData_Document.sip @@ -67,11 +67,6 @@ class HYDROData_Document aRes = new HYDROData_Image( *dynamic_cast( theObject ) ); break; } - case KIND_POLYLINE: - { - aRes = new HYDROData_Polyline( *dynamic_cast( theObject ) ); - break; - } case KIND_BATHYMETRY: { aRes = new HYDROData_Bathymetry( *dynamic_cast( theObject ) ); @@ -82,6 +77,16 @@ class HYDROData_Document aRes = new HYDROData_ImmersibleZone( *dynamic_cast( theObject ) ); break; } + case KIND_PROFILEUZ: + { + aRes = new HYDROData_ProfileUZ( *dynamic_cast( theObject ) ); + break; + } + case KIND_POLYLINEXY: + { + aRes = new HYDROData_PolylineXY( *dynamic_cast( theObject ) ); + break; + } case KIND_CALCULATION: { aRes = new HYDROData_CalculationCase( *dynamic_cast( theObject ) ); diff --git a/src/HYDROPy/HYDROData_Entity.sip b/src/HYDROPy/HYDROData_Entity.sip index e148402d..3bba4c53 100644 --- a/src/HYDROPy/HYDROData_Entity.sip +++ b/src/HYDROPy/HYDROData_Entity.sip @@ -30,7 +30,17 @@ const ObjectKind KIND_UNKNOWN; const ObjectKind KIND_IMAGE; const ObjectKind KIND_POLYLINE; const ObjectKind KIND_BATHYMETRY; +const ObjectKind KIND_ALTITUDE; const ObjectKind KIND_IMMERSIBLE_ZONE; +const ObjectKind KIND_RIVER; +const ObjectKind KIND_STREAM; +const ObjectKind KIND_CONFLUENCE; +const ObjectKind KIND_CHANNEL; +const ObjectKind KIND_OBSTACLE; +const ObjectKind KIND_DIGUE; +const ObjectKind KIND_PROFILE; +const ObjectKind KIND_PROFILEUZ; +const ObjectKind KIND_POLYLINEXY; const ObjectKind KIND_CALCULATION; const ObjectKind KIND_ZONE; const ObjectKind KIND_REGION; @@ -49,8 +59,8 @@ class HYDROData_Entity sipClass = sipClass_HYDROData_Image; break; - case KIND_POLYLINE: - sipClass = sipClass_HYDROData_Polyline; + case KIND_POLYLINEXY: + sipClass = sipClass_HYDROData_PolylineXY; break; case KIND_BATHYMETRY: diff --git a/src/HYDROPy/HYDROData_IPolyline.sip b/src/HYDROPy/HYDROData_IPolyline.sip new file mode 100644 index 00000000..1e0e9c7d --- /dev/null +++ b/src/HYDROPy/HYDROData_IPolyline.sip @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +%ExportedHeaderCode +#include +%End + +class HYDROData_IPolyline : HYDROData_Entity /Abstract/ +{ + +%TypeHeaderCode +#include +%End + +%ConvertToSubClassCode + switch ( sipCpp->GetKind() ) + { + case KIND_POLYLINEXY: + sipClass = sipClass_HYDROData_PolylineXY; + break; + + case KIND_PROFILEUZ: + sipClass = sipClass_HYDROData_ProfileUZ; + break; + + default: + // We don't recognise the type. + sipClass = NULL; + } +%End + +public: + + enum SectionType{ SECTION_POLYLINE = 0, SECTION_SPLINE = 1 }; + +public: + + +protected: + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_IPolyline(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_IPolyline(); +}; + + diff --git a/src/HYDROPy/HYDROData_ImmersibleZone.sip b/src/HYDROPy/HYDROData_ImmersibleZone.sip index 5346eb3b..326dd5cb 100644 --- a/src/HYDROPy/HYDROData_ImmersibleZone.sip +++ b/src/HYDROPy/HYDROData_ImmersibleZone.sip @@ -69,11 +69,11 @@ public: /** * Sets reference polyline object for zone. */ - void SetPolyline( HYDROData_Polyline thePolyline ) [void (const Handle_HYDROData_Polyline&)]; + void SetPolyline( HYDROData_PolylineXY thePolyline ) [void (const Handle_HYDROData_PolylineXY&)]; %MethodCode - Handle(HYDROData_Polyline) aRefPolyline = - Handle(HYDROData_Polyline)::DownCast( createHandle( a0 ) ); + Handle(HYDROData_PolylineXY) aRefPolyline = + Handle(HYDROData_PolylineXY)::DownCast( createHandle( a0 ) ); if ( !aRefPolyline.IsNull() ) { Py_BEGIN_ALLOW_THREADS @@ -87,17 +87,17 @@ public: /** * Returns reference polyline object of zone. */ - HYDROData_Polyline GetPolyline() const [Handle_HYDROData_Polyline ()]; + HYDROData_PolylineXY GetPolyline() const [Handle_HYDROData_PolylineXY ()]; %MethodCode - Handle(HYDROData_Polyline) aRefPolyline; + Handle(HYDROData_PolylineXY) aRefPolyline; Py_BEGIN_ALLOW_THREADS aRefPolyline = sipSelfWasArg ? sipCpp->HYDROData_ImmersibleZone::GetPolyline() : sipCpp->GetPolyline(); Py_END_ALLOW_THREADS - sipRes = (HYDROData_Polyline*)createPointer( aRefPolyline ); + sipRes = (HYDROData_PolylineXY*)createPointer( aRefPolyline ); %End diff --git a/src/HYDROPy/HYDROData_Object.sip b/src/HYDROPy/HYDROData_Object.sip index c93dd51d..6a9e89b4 100644 --- a/src/HYDROPy/HYDROData_Object.sip +++ b/src/HYDROPy/HYDROData_Object.sip @@ -40,10 +40,6 @@ class HYDROData_Object : HYDROData_Entity /Abstract/ // HYDROData_Object sub-classes provide a unique kind ID. switch ( sipCpp->GetKind() ) { - case KIND_POLYLINE: - sipClass = sipClass_HYDROData_Polyline; - break; - case KIND_UNKNOWN: sipClass = sipClass_HYDROData_Object; break; diff --git a/src/HYDROPy/HYDROData_Polyline.sip b/src/HYDROPy/HYDROData_Polyline.sip deleted file mode 100644 index 6ab03787..00000000 --- a/src/HYDROPy/HYDROData_Polyline.sip +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -%ExportedHeaderCode -#include -%End - -class HYDROData_Polyline : HYDROData_Object -{ - -%TypeHeaderCode -#include -%End - -%ConvertToSubClassCode - switch ( sipCpp->GetKind() ) - { - case KIND_POLYLINE: - sipClass = sipClass_HYDROData_Polyline; - break; - - default: - // We don't recognise the type. - sipClass = NULL; - } -%End - -public: - - /** - * Return polyline dimension - * \return polyline dimension (2 or 3) - */ - int GetDimension() const; - - /** - * Set polyline dimension (2 or 3) - * \param theDimension the polyline dimension - */ - void SetDimension( int theDimension ); - - /** - * Remove all sections from polyline - */ - void RemoveAll(); - - - /** - * Returns the painter path. The painter path is construct by lines - */ - QPainterPath GetPainterPath(); - - - /** - * Sets the z value for polyline. - */ - void SetZValue( const double theZValue ); - - /** - * Returns the z value for polyline. - */ - double ZValue() const; - -protected: - - /** - * Creates new object in the internal data structure. Use higher level objects - * to create objects with real content. - */ - HYDROData_Polyline(); - - /** - * Destructs properties of the object and object itself, removes it from the document. - */ - ~HYDROData_Polyline(); -}; - - diff --git a/src/HYDROPy/HYDROData_PolylineXY.sip b/src/HYDROPy/HYDROData_PolylineXY.sip new file mode 100644 index 00000000..37dadf7c --- /dev/null +++ b/src/HYDROPy/HYDROData_PolylineXY.sip @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +%ExportedHeaderCode +#include +%End + +class HYDROData_PolylineXY : HYDROData_IPolyline +{ + +%TypeHeaderCode +#include +%End + +%ConvertToSubClassCode + switch ( sipCpp->GetKind() ) + { + case KIND_POLYLINEXY: + sipClass = sipClass_HYDROData_PolylineXY; + break; + + default: + // We don't recognise the type. + sipClass = NULL; + } +%End + +public: + +protected: + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_PolylineXY(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_PolylineXY(); +}; + + diff --git a/src/HYDROPy/HYDROData_ProfileUZ.sip b/src/HYDROPy/HYDROData_ProfileUZ.sip new file mode 100644 index 00000000..bb31535a --- /dev/null +++ b/src/HYDROPy/HYDROData_ProfileUZ.sip @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +%ExportedHeaderCode +#include +%End + +class HYDROData_ProfileUZ : HYDROData_IPolyline +{ + +%TypeHeaderCode +#include +%End + +%ConvertToSubClassCode + switch ( sipCpp->GetKind() ) + { + case KIND_PROFILEUZ: + sipClass = sipClass_HYDROData_ProfileUZ; + break; + + default: + // We don't recognise the type. + sipClass = NULL; + } +%End + +public: + +protected: + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_ProfileUZ(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_ProfileUZ(); +}; + +