#include "CurveCreator_Displayer.h"
#include "CurveCreator_Utils.h"
-#include <AIS_Point.hxx>
-#include <AIS_Line.hxx>
#include <AIS_Shape.hxx>
+#include <AIS_InteractiveObject.hxx>
#include <Geom_CartesianPoint.hxx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
#include <stdio.h>
-//#define AIS_CURVE_DISPLAY
-
//=======================================================================
// function: Constructor
// purpose:
: 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
}
//=======================================================================
void CurveCreator_Curve::setDisplayer( CurveCreator_Displayer* theDisplayer )
{
myDisplayer = theDisplayer;
-
-#ifdef AIS_CURVE_DISPLAY
- myDisplayer->displayAIS( myAISCurve, false );
-#endif
}
//=======================================================================
return theIPnt * myDimension;
}
-std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructSection( int theISection ) const
-{
- std::vector<Handle_AIS_InteractiveObject> aSectionRepresentation;
-
- TopoDS_Shape aShape;
- CurveCreator_Utils::constructShape( this, theISection, aShape, aSectionRepresentation );
-
- AIS_Shape* anAISShape = new AIS_Shape( aShape );
- //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) );
- aSectionRepresentation.push_back( anAISShape );
-
- return aSectionRepresentation;
-}
-
//=======================================================================
// function: setUndoDepth
// purpose:
return myUndoDepth;
}
-Handle_AIS_Point CurveCreator_Curve::getAISPoint( int theISection, int theIPoint ) const
-{
- double anX, anY, aZ;
- getCoordinates( theISection, theIPoint, anX, anY, aZ );
- gp_Pnt aPoint( anX, anY, aZ);
-
- AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));
- return aPnt;
-}
-
-Handle_AIS_Line CurveCreator_Curve::getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const
-{
- double anX, anY, aZ;
- getCoordinates( theISection, theIPoint1, anX, anY, aZ );
- gp_Pnt aPoint1( anX, anY, aZ);
-
- double anX2, anY2, aZ2;
- getCoordinates( theISection, theIPoint2, anX2, anY2, aZ2 );
-//MTN to avoid crash during line construction
- if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){
- aZ2 += 1e-7;
- }
-
- gp_Pnt aPoint2( anX2, anY2, aZ2 );
-
- AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );
- return aLine;
-}
-
void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const
{
CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint );
}
}
-//#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 );
}
}
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();
return aCoords;
}
-
-/***********************************************/
-/*** Presentation methods ***/
-/***********************************************/
-std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructWire() const
+void CurveCreator_Curve::constructAISObject()
{
- std::vector<Handle_AIS_InteractiveObject> aCurveRepresentation;
- std::vector<Handle_AIS_InteractiveObject> aSectionObjects;
- for( int iSection = 0 ; iSection < getNbSections() ; iSection++ ){
- aSectionObjects = constructSection( iSection );
- for( int iObject = 0 ; iObject < aSectionObjects.size() ; iObject++ ){
- aCurveRepresentation.push_back( aSectionObjects.at(iObject) );
- }
- }
- return aCurveRepresentation;
+ TopoDS_Shape aShape;
+ CurveCreator_Utils::constructShape( this, aShape );
+
+ myAISShape = new AIS_Shape( aShape );
}
-void CurveCreator_Curve::getPoint( const int theISection, const int theIPoint,
- gp_Pnt& thePoint ) const
+Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
{
- double anX, anY, aZ;
- getCoordinates( theISection, theIPoint, anX, anY, aZ );
- thePoint = gp_Pnt( anX, anY, aZ);
-}
+ if ( !myAISShape && theNeedToBuild ) {
+ CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
+ aCurve->constructAISObject();
+ }
+ return myAISShape;
+}
\ No newline at end of file