]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
The type of section for profile added (Bug #172).
authoradv <adv@opencascade.com>
Mon, 9 Dec 2013 08:03:14 +0000 (08:03 +0000)
committeradv <adv@opencascade.com>
Mon, 9 Dec 2013 08:03:14 +0000 (08:03 +0000)
src/HYDROCurveCreator/CurveCreator_Profile.cxx
src/HYDROCurveCreator/CurveCreator_Profile.hxx
src/HYDROData/HYDROData_ProfileUZ.cxx
src/HYDROGUI/HYDROGUI_ProfileOp.cxx

index 4164ca68390eb48d4db918ff3a67050ff2b3d3f6..c857fd207a3e279a77f08de5fbea74f686c97c1e 100644 (file)
@@ -133,18 +133,6 @@ bool CurveCreator_Profile::setClosed( const int theISection,
   return false;
 }
 
-bool CurveCreator_Profile::setSectionTypeInternal( const int theISection, 
-                                                   const CurveCreator::SectionType theType )
-{
-  return CurveCreator_Curve::setSectionTypeInternal( theISection, theType );
-}
-
-bool CurveCreator_Profile::setSectionType( const int theISection, 
-                                           const CurveCreator::SectionType theType )
-{
-  return CurveCreator_Curve::setSectionType( theISection, theType );
-}
-
 bool CurveCreator_Profile::addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap )
 {
   bool res = false;
index 3d08001131926873bda910faedcf9658b66f7613..d544c87c304541f3f30a786550ee64b2455725bc 100644 (file)
@@ -97,18 +97,6 @@ public:
   virtual bool setClosed( const int theISection, 
                           const bool theIsClosed );
 
-  
-  //! For internal use only! Undo/Redo are not used here.
-  virtual bool setSectionTypeInternal( const int theISection, 
-                                       const CurveCreator::SectionType theType );
-  /**
-   *  Set type of the specified section (or all sections
-   *  if \a theISection is -1).
-   */
-  virtual bool setSectionType( const int theISection, 
-                               const CurveCreator::SectionType theType );
-
-
   /***********************************************/
   /***           Point methods                 ***/
   /***********************************************/
index 80fe9987309b306ecf9dc7ac997a2718e8577ec7..dc82a136233f8f6593c8f468de092ba42c0a3a8f 100755 (executable)
@@ -8,6 +8,9 @@
 
 #include <TColStd_ListIteratorOfListOfReal.hxx>
 
+#include <TDataStd_BooleanList.hxx>
+#include <TDataStd_ExtStringList.hxx>
+#include <TDataStd_IntegerList.hxx>
 #include <TDataStd_RealList.hxx>
 
 #include <TopoDS_Shape.hxx>
@@ -90,12 +93,29 @@ void HYDROData_ProfileUZ::SetSectionName( const int                      /*theSe
 
 HYDROData_ProfileUZ::SectionType HYDROData_ProfileUZ::GetSectionType( const int /*theSectionIndex*/ ) const
 {
-  return SECTION_POLYLINE;
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
+  if ( aTypesList.IsNull() || aTypesList->IsEmpty() )
+    return SECTION_POLYLINE;
+
+  return (SectionType)aTypesList->First();
 }
 
 void HYDROData_ProfileUZ::SetSectionType( const int         /*theSectionIndex*/, 
-                                          const SectionType /*theSectionType*/ )
+                                          const SectionType theSectionType )
 {
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList );
+  if ( aTypesList.IsNull()  )
+    return;
+
+  // Refill the existing list
+  aTypesList->Clear();
+  aTypesList->Append( theSectionType );
 }
 
 bool HYDROData_ProfileUZ::IsClosedSection( const int /*theSectionIndex*/ ) const
index a9a9cf2cdeb0a2280f2744e85ed1fe1c3ad9af33..90f382c7e8ff931ea7db40a97c978ece8b5204ba 100644 (file)
@@ -91,23 +91,36 @@ void HYDROGUI_ProfileOp::startOperation()
   QString aProfileName;
   if( !myEditedObject.IsNull() )
   {
-    CurveCreator::Coordinates aCurveCoords;
-    CurveCreator::SectionsMap aSectionsMap;
-
-    HYDROData_ProfileUZ::PointsList aSectPointsList = myEditedObject->GetParametricPoints();
-    CurveCreator::PosPointsList aPoints;
-    for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
+    Handle(HYDROData_ProfileUZ) aProfileUZ = myEditedObject->GetProfileUZ( false );
+    if ( !aProfileUZ.IsNull() )
     {
-      const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList.Value( k );
-      aCurveCoords.clear();
-      aCurveCoords.push_back( aSectPoint.X() );
-      aCurveCoords.push_back( aSectPoint.Y() );
+      CurveCreator::Coordinates aCurveCoords;
+      CurveCreator::SectionsMap aSectionsMap;
+
+      HYDROData_ProfileUZ::PointsList aSectPointsList = aProfileUZ->GetPoints();
+      CurveCreator::PosPointsList aPoints;
+      for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
+      {
+        const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList.Value( k );
+        aCurveCoords.clear();
+        aCurveCoords.push_back( aSectPoint.X() );
+        aCurveCoords.push_back( aSectPoint.Y() );
+
+        CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( k, aCurveCoords );
+        aPoints.push_back( aPosPoint );
+      }
+
+      aSectionsMap[0] = aPoints;
+      myProfile->addPointsInternal( aSectionsMap );
+
+      HYDROData_ProfileUZ::SectionType aSectType = aProfileUZ->GetSectionType( 0 );
 
-      CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( k, aCurveCoords );
-      aPoints.push_back( aPosPoint );
+      CurveCreator::SectionType aCurveType = CurveCreator::Polyline;
+      if( aSectType == HYDROData_ProfileUZ::SECTION_SPLINE )
+        aCurveType = CurveCreator::Spline;
+
+      myProfile->setSectionType( 0, aCurveType );
     }
-    aSectionsMap[0] = aPoints;
-    myProfile->addPointsInternal( aSectionsMap );
 
     aProfileName = myEditedObject->GetName();
   }
@@ -177,6 +190,10 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags,
   if( aProfileObj.IsNull() )
     return false;
 
+  Handle(HYDROData_ProfileUZ) aProfileUZ = aProfileObj->GetProfileUZ();
+  if ( aProfileUZ.IsNull() )
+    return false;
+
   aProfileObj->SetName(aProfileName);
 
   HYDROData_ProfileUZ::PointsList aProfileParamPoints;
@@ -200,6 +217,12 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags,
   }
   aProfileObj->SetParametricPoints( aProfileParamPoints );
 
+  HYDROData_ProfileUZ::SectionType aSectType = HYDROData_ProfileUZ::SECTION_POLYLINE;
+  if ( myProfile->getSectionType( 0 ) == CurveCreator::Spline )
+    aSectType = HYDROData_ProfileUZ::SECTION_SPLINE;
+
+  aProfileUZ->SetSectionType( 0, aSectType );
+
   aProfileObj->Update();
 
   theUpdateFlags = UF_Model;