]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
#612 - The order of extracted polylines in object browser is unexpected
authorstv <stv@opencascade.com>
Tue, 30 Jun 2015 11:31:27 +0000 (14:31 +0300)
committerstv <stv@opencascade.com>
Tue, 30 Jun 2015 11:31:27 +0000 (14:31 +0300)
src/HYDROGUI/HYDROGUI_PolylineExtractionOp.cxx
src/HYDROGUI/HYDROGUI_PolylineExtractionOp.h

index 4a758cf0b46c3ce9bc1c3f7328bf3b5a0b6d9e16..ac0a39ade019ca88f4cd19139050e4739c110fe1 100644 (file)
@@ -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;
 }
index 72fbc6fcdee362445bf96ff48adf6a6bc347ff30..414799e5bcdfeda6d7c91399d5913d8692dbf00a 100644 (file)
@@ -40,12 +40,24 @@ protected:
   virtual void               startOperation();
 
 private:
-  typedef NCollection_DataMap<TopoDS_Shape, QString> 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<ShapeInfo> 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