Salome HOME
patch for correct compilation on Linux
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Curve.cxx
index ac43473ce7d33d1cdcd1ff670a13285470571b53..3f88a8b2bddda6622673f0070e50d193fa438794 100644 (file)
@@ -29,6 +29,7 @@
 #include "CurveCreator_Utils.h"
 
 #include <AIS_Shape.hxx>
+#include <AIS_InteractiveObject.hxx>
 #include <Geom_CartesianPoint.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_Lin.hxx>
@@ -38,8 +39,6 @@
 
 #include <stdio.h>
 
-//#define AIS_CURVE_DISPLAY
-
 //=======================================================================
 // function: Constructor
 // purpose:
@@ -48,14 +47,12 @@ CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimensi
 : myIsLocked  (false),
   myDimension (theDimension),
   myDisplayer (NULL),
+  myAISShape  (NULL),
   myNbUndos   (0),
   myNbRedos   (0),
   myUndoDepth (-1),
   myOpLevel(0)
 {
-#ifdef AIS_CURVE_DISPLAY
-  myAISCurve = new CurveCreator_AISCurve( this );
-#endif
 }
 
 //=======================================================================
@@ -105,10 +102,6 @@ std::string CurveCreator_Curve::getUniqSectionName() const
 void CurveCreator_Curve::setDisplayer( CurveCreator_Displayer* theDisplayer )
 {
   myDisplayer = theDisplayer;
-  
-#ifdef AIS_CURVE_DISPLAY
-  myDisplayer->displayAIS( myAISCurve, false );
-#endif
 }
 
 //=======================================================================
@@ -249,30 +242,13 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double&
   }
 }
 
-//#define USE_COMPOUND
 void CurveCreator_Curve::redisplayCurve()
 {
   if( myDisplayer ) {
-#ifdef AIS_CURVE_DISPLAY
-    myDisplayer->redisplayAIS(myAISCurve, false);
-#else
-    myDisplayer->erase( false );
-//#ifndef USE_COMPOUND
-    myDisplayer->display( constructWire(), true );
-//#else
-    /*std::vector<Handle_AIS_InteractiveObject> anAISObjects = constructWire();
-    int aSelMode = AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX );
-    Handle(AIS_InteractiveContext) aContext = myDisplayer->getAISContext();
-    for( int i = 0 ; i < anAISObjects.size() ; i++ ){
-      Handle_AIS_InteractiveObject anAISObject = anAISObjects[i];
-      //anAISObject->SetSelectionMode( aSelMode );
-      aContext->Display( anAISObject, Standard_False );
-      //aContext->Display( anAISObject, 0, aSelMode, Standard_False, Standard_True );
-    }
-      aContext->UpdateCurrentViewer();
-    */
-//#endif
-#endif
+    myDisplayer->eraseAll( false );
+    myAISShape = NULL;
+
+    myDisplayer->display( getAISObject( true ), true );
   }
 }
 
@@ -390,8 +366,10 @@ bool CurveCreator_Curve::redo()
 bool CurveCreator_Curve::clearInternal()
 {
   // erase curve from the viewer
-  if( myDisplayer )
-    myDisplayer->erase( true );
+  if( myDisplayer ) {
+    myDisplayer->eraseAll( true );
+    myAISShape = NULL;
+  }
   // Delete all allocated data.
   int i = 0;
   const int aNbSections = getNbSections();
@@ -963,18 +941,19 @@ CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection )
   return aCoords;
 }
 
-
-/***********************************************/
-/***       Presentation methods              ***/
-/***********************************************/
-std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructWire() const
+void CurveCreator_Curve::constructAISObject()
 {
-  std::vector<Handle_AIS_InteractiveObject> aCurveRepresentation;
-
   TopoDS_Shape aShape;
   CurveCreator_Utils::constructShape( this, aShape );
 
-  AIS_Shape* anAISShape = new AIS_Shape( aShape );
-  aCurveRepresentation.push_back( anAISShape );
-  return aCurveRepresentation;
+  myAISShape = new AIS_Shape( aShape );
 }
+
+Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
+{
+  if ( !myAISShape && theNeedToBuild ) {
+    CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
+    aCurve->constructAISObject();
+  }
+  return myAISShape;
+}
\ No newline at end of file