From 0a662d3ac2ab067cc2a48cb521d77a1ff7c93a46 Mon Sep 17 00:00:00 2001 From: stv Date: Tue, 30 Jun 2015 14:31:27 +0300 Subject: [PATCH] #612 - The order of extracted polylines in object browser is unexpected --- .../HYDROGUI_PolylineExtractionOp.cxx | 43 ++++++++++--------- src/HYDROGUI/HYDROGUI_PolylineExtractionOp.h | 20 +++++++-- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_PolylineExtractionOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineExtractionOp.cxx index 4a758cf0..ac0a39ad 100644 --- a/src/HYDROGUI/HYDROGUI_PolylineExtractionOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineExtractionOp.cxx @@ -65,28 +65,29 @@ void HYDROGUI_PolylineExtractionOp::startOperation() if ( anObject.IsNull() ) continue; - ShapeMap aMap; + ShapeInfoList aList; switch ( anObject->GetKind() ) { case KIND_STREAM: - aMap = extract( Handle(HYDROData_Stream)::DownCast( anObject ) ); + aList = extract( Handle(HYDROData_Stream)::DownCast( anObject ) ); break; case KIND_DIGUE: case KIND_CHANNEL: - aMap = extract( Handle(HYDROData_Channel)::DownCast( anObject ) ); + aList = extract( Handle(HYDROData_Channel)::DownCast( anObject ) ); break; case KIND_OBSTACLE: - aMap = extract( Handle(HYDROData_Obstacle)::DownCast( anObject ) ); + aList = extract( Handle(HYDROData_Obstacle)::DownCast( anObject ) ); break; } startDocOperation(); - for ( ShapeMap::Iterator it( aMap ); it.More(); it.Next() ) + for ( ShapeInfoList::const_iterator it = aList.begin(); it != aList.end(); ++it ) { - TopoDS_Shape aLine = it.Key(); - QString aName = QString( "%1_%2" ).arg( anObject->GetName() ).arg( it.Value() ); + const ShapeInfo& inf = *it; + TopoDS_Shape aLine = inf.shape(); + QString aName = QString( "%1_%2" ).arg( anObject->GetName() ).arg( inf.name() ); if ( !HYDROGUI_Tool::FindObjectByName( aModule, aName ).IsNull() ) { int num = 1; @@ -113,27 +114,27 @@ void HYDROGUI_PolylineExtractionOp::startOperation() commit(); } -HYDROGUI_PolylineExtractionOp::ShapeMap HYDROGUI_PolylineExtractionOp::extract( const Handle(HYDROData_Stream)& theStream ) +HYDROGUI_PolylineExtractionOp::ShapeInfoList HYDROGUI_PolylineExtractionOp::extract( const Handle(HYDROData_Stream)& theStream ) const { - ShapeMap aMap; + ShapeInfoList aList; if ( !theStream.IsNull() ) { - aMap.Bind( theStream->GetLeftShape(), "Left bank" ); - aMap.Bind( theStream->GetRightShape(), "Right bank" ); + aList.append( ShapeInfo( theStream->GetLeftShape(), QString( "Left bank" ) ) ); + aList.append( ShapeInfo( theStream->GetRightShape(), QString( "Right bank" ) ) ); HYDROData_SequenceOfObjects aProfiles = theStream->GetProfiles(); for ( int i = 1; i <= aProfiles.Length(); i++ ) { Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aProfiles.Value( i ) ); - aMap.Bind( aProfile->GetTopShape(), aProfile->GetName() ); + aList.append( ShapeInfo( aProfile->GetTopShape(), QString( "Profile_%1" ).arg( i ) ) ); } } - return aMap; + return aList; } -HYDROGUI_PolylineExtractionOp::ShapeMap HYDROGUI_PolylineExtractionOp::extract( const Handle(HYDROData_Channel)& aChannel ) +HYDROGUI_PolylineExtractionOp::ShapeInfoList HYDROGUI_PolylineExtractionOp::extract( const Handle(HYDROData_Channel)& aChannel ) const { - ShapeMap aMap; + ShapeInfoList aList; if ( !aChannel.IsNull() ) { HYDROData_SequenceOfObjects aGroups = aChannel->GetGroups(); @@ -151,16 +152,16 @@ HYDROGUI_PolylineExtractionOp::ShapeMap HYDROGUI_PolylineExtractionOp::extract( for ( int s = 1; s <= aShapes.Length(); s++ ) aBuilder.Add( aWire, aShapes.Value( s ) ); - aMap.Bind( aWire, i > 1 ? "Right bank" : "Left bank" ); + aList.append( ShapeInfo( aWire, i > 1 ? "Right bank" : "Left bank" ) ); } } } - return aMap; + return aList; } -HYDROGUI_PolylineExtractionOp::ShapeMap HYDROGUI_PolylineExtractionOp::extract( const Handle(HYDROData_Obstacle)& theObstacle ) +HYDROGUI_PolylineExtractionOp::ShapeInfoList HYDROGUI_PolylineExtractionOp::extract( const Handle(HYDROData_Obstacle)& theObstacle ) const { - ShapeMap aMap; + ShapeInfoList aList; if ( !theObstacle.IsNull() ) { TopoDS_Wire aWire; @@ -175,7 +176,7 @@ HYDROGUI_PolylineExtractionOp::ShapeMap HYDROGUI_PolylineExtractionOp::extract( for ( int s = 1; s <= aShapes.Length(); s++ ) aBuilder.Add( aWire, aShapes.Value( s ) ); } - aMap.Bind( aWire, "Contour" ); + aList.append( ShapeInfo( aWire, QString( "Contour" ) ) ); } - return aMap; + return aList; } diff --git a/src/HYDROGUI/HYDROGUI_PolylineExtractionOp.h b/src/HYDROGUI/HYDROGUI_PolylineExtractionOp.h index 72fbc6fc..414799e5 100644 --- a/src/HYDROGUI/HYDROGUI_PolylineExtractionOp.h +++ b/src/HYDROGUI/HYDROGUI_PolylineExtractionOp.h @@ -40,12 +40,24 @@ protected: virtual void startOperation(); private: - typedef NCollection_DataMap ShapeMap; + class ShapeInfo + { + public: + ShapeInfo( const TopoDS_Shape s, const QString& n ) : myShape( s ), myName( n ) {} + TopoDS_Shape shape() const { return myShape; } + QString name() const { return myName; } + + private: + TopoDS_Shape myShape; + QString myName; + }; + + typedef QList ShapeInfoList; private: - ShapeMap extract( const Handle(HYDROData_Stream)& ); - ShapeMap extract( const Handle(HYDROData_Channel)& ); - ShapeMap extract( const Handle(HYDROData_Obstacle)& ); + ShapeInfoList extract( const Handle(HYDROData_Stream)& ) const; + ShapeInfoList extract( const Handle(HYDROData_Channel)& ) const; + ShapeInfoList extract( const Handle(HYDROData_Obstacle)& ) const; }; #endif -- 2.39.2