]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
OCC functionality moving out from the widget
authornds <nds@opencascade.com>
Tue, 3 Dec 2013 15:32:50 +0000 (15:32 +0000)
committernds <nds@opencascade.com>
Tue, 3 Dec 2013 15:32:50 +0000 (15:32 +0000)
src/HYDROCurveCreator/CurveCreator_Curve.cxx
src/HYDROCurveCreator/CurveCreator_Curve.hxx
src/HYDROCurveCreator/CurveCreator_Utils.cxx
src/HYDROCurveCreator/CurveCreator_Utils.h

index cab312d69de6ff42e1f9ab33befe6897d88770ca..129520136437240ed6e21fce61cf9ae439a34aad 100644 (file)
@@ -182,58 +182,17 @@ int CurveCreator_Curve::toICoord(const int theIPnt) const
   return theIPnt * myDimension;
 }
 
-//#define USE_COMPOUND
 std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructSection( int theISection ) const
 {
   std::vector<Handle_AIS_InteractiveObject> aSectionRepresentation;
-  CurveCreator::SectionType aSectType = getSectionType( theISection );
 
-  bool isShapeConstruct = false;
-#ifdef USE_COMPOUND
-  isShapeConstruct = true;
-#else
-  isShapeConstruct = aSectType == CurveCreator::Spline;
-#endif
+  TopoDS_Shape aShape;
+  CurveCreator_Utils::constructShape( this, theISection, aShape, aSectionRepresentation );
 
-  if ( isShapeConstruct ) {
-    TopoDS_Shape aShape;
-    CurveCreator_Utils::constructShape( this, theISection, aShape );
-    AIS_Shape* anAISShape = new AIS_Shape( aShape );
-    //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) );
-    aSectionRepresentation.push_back( anAISShape );
-    if ( aSectType != CurveCreator::Spline )
-      return aSectionRepresentation;
-  }
+  AIS_Shape* anAISShape = new AIS_Shape( aShape );
+  //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) );
+  aSectionRepresentation.push_back( anAISShape );
 
-  int aPointSize = getNbPoints( theISection );
-  bool aSectIsClosed = isClosed( theISection );
-  if( aSectType == CurveCreator::Polyline )
-  {
-    int iPoint = 0; 
-    for( ; iPoint < ( aPointSize - 1 ) ; iPoint++ ){
-      Handle_AIS_Point anAISPnt = getAISPoint(theISection, iPoint);
-      aSectionRepresentation.push_back( anAISPnt );
-      Handle_AIS_Line aLine = getAISLine( theISection, iPoint, iPoint+1 );
-      aSectionRepresentation.push_back( aLine );
-    }
-    if( aPointSize != 0 ){
-      Handle_AIS_Point anAISPnt = getAISPoint(theISection, iPoint); 
-      aSectionRepresentation.push_back( anAISPnt );
-      if( isClosed(theISection) && ( aPointSize > 1 ) ){
-        Handle_AIS_Line aLine = getAISLine( theISection, iPoint, 0 );
-        aSectionRepresentation.push_back( aLine );
-      }
-    }
-  }
-  else if( aSectType == CurveCreator::Spline )
-  {
-    std::vector<double> aPoints;
-    for( int iPoint = 0; iPoint < aPointSize; iPoint++ )
-    {
-      Handle_AIS_Point anAISPnt = getAISPoint( theISection, iPoint );
-      aSectionRepresentation.push_back( anAISPnt );
-    }
-  }
   return aSectionRepresentation;
 }
 
@@ -335,6 +294,7 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double&
   }
 }
 
+//#define USE_COMPOUND
 void CurveCreator_Curve::redisplayCurve()
 {
   if( myDisplayer ) {
index 339a485f1f8417270249ba4b13d1e2c3d079d728..0981118855dd49a6dc4d328b599dba49ac38e137 100644 (file)
@@ -110,9 +110,9 @@ protected:
    */
   virtual bool addEmptyDiff();
 
+public: // TODO: remove public
   Handle_AIS_Point getAISPoint( int theISection, int theIPoint ) const;
   Handle_AIS_Line  getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const;
-public: // TODO: remove public
   void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
 protected:  // TODO: remove public
   void redisplayCurve();
index c05b926a650add9d61d07e0dede9cbdfad0244b1..39084ac6a42c06e6fb376bb1601fc7184c73cffd 100644 (file)
@@ -86,8 +86,10 @@ gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) a
 
 
 //#define USE_COMPOUND
+#include "CurveCreator_Curve.hxx" // TODO - remove
 void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
-                                         const int theISection, TopoDS_Shape& theShape )
+                                         const int theISection, TopoDS_Shape& theShape,
+                                         std::vector<Handle_AIS_InteractiveObject>& aSectionRepresentation )
 {
   CurveCreator::SectionType aSectType = theCurve->getSectionType( theISection );
 
@@ -96,7 +98,7 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
   bool aSectIsClosed = theCurve->isClosed( theISection );
   if( aSectType == CurveCreator::Polyline )
   {
-//#ifdef USE_COMPOUND
+#ifdef USE_COMPOUND
     BRep_Builder aBuilder;
     TopoDS_Compound aComp;
     aBuilder.MakeCompound(aComp);
@@ -123,7 +125,7 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
         aBuilder.Add( aComp, aPointEdge );
         aPrevPoint = aPoint;
       }
-      if( theCurve->isClosed( theISection ) && ( aPointSize > 2 ) ) {
+      if( aSectIsClosed && ( aPointSize > 2 ) ) {
         CurveCreator_UtilsICurve::getPoint( theCurve, theISection, 0, aPoint );
         aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
         aBuilder.Add( aComp, aVertex );
@@ -132,12 +134,11 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
       }
       theShape = aComp;
     }
-//#endif
+#endif
   }
   else if( aSectType == CurveCreator::Spline )
   {
 #ifdef USE_COMPOUND
-
 #else
     std::vector<double> aPoints;
     for( int iPoint = 0; iPoint < aPointSize; iPoint++ )
@@ -182,6 +183,40 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
     }
 #endif
   }
+
+#ifndef USE_COMPOUND
+  const CurveCreator_Curve* aCurve = dynamic_cast<const CurveCreator_Curve*>( theCurve );
+  if ( !aCurve )
+    return;
+
+  if( aSectType == CurveCreator::Polyline )
+  {
+    int iPoint = 0; 
+    for( ; iPoint < ( aPointSize - 1 ) ; iPoint++ ){
+      Handle_AIS_Point anAISPnt = aCurve->getAISPoint(theISection, iPoint);
+      aSectionRepresentation.push_back( anAISPnt );
+      Handle_AIS_Line aLine = aCurve->getAISLine( theISection, iPoint, iPoint+1 );
+      aSectionRepresentation.push_back( aLine );
+    }
+    if( aPointSize != 0 ){
+      Handle_AIS_Point anAISPnt = aCurve->getAISPoint(theISection, iPoint); 
+      aSectionRepresentation.push_back( anAISPnt );
+      if( aSectIsClosed && ( aPointSize > 1 ) ){
+        Handle_AIS_Line aLine = aCurve->getAISLine( theISection, iPoint, 0 );
+        aSectionRepresentation.push_back( aLine );
+      }
+    }
+  }
+  else if( aSectType == CurveCreator::Spline )
+  {
+    std::vector<double> aPoints;
+    for( int iPoint = 0; iPoint < aPointSize; iPoint++ )
+    {
+      Handle_AIS_Point anAISPnt = aCurve->getAISPoint( theISection, iPoint );
+      aSectionRepresentation.push_back( anAISPnt );
+    }
+  }
+#endif
 }
 
 std::list<float> CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext )
index 496946565e31c654885ea5a446941384e6aae635..cc0817fac079fd3dedb8a27672254e9b97ede8d5 100644 (file)
 #include "CurveCreator_Macro.hxx"
 
 #include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx> // TODO: remove
 #include <V3d_View.hxx>
 #include <gp_Pnt.hxx>
 #include <Geom_Curve.hxx>
 #include <TopoDS_Shape.hxx>
 
 #include <list>
+#include <vector> // TODO: remove
 
 class CurveCreator_ICurve;
 
@@ -67,7 +69,8 @@ public:
    */
   CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
                                                   const int theISection,
-                                                  TopoDS_Shape& theShape );
+                                                  TopoDS_Shape& theShape,
+                                                  std::vector<Handle_AIS_InteractiveObject>& theAdditional );
 
   /**
    * Find selected points in the context