#include "CurveCreator_Utils.h"
#include <AIS_Shape.hxx>
+#include <AIS_InteractiveObject.hxx>
#include <Geom_CartesianPoint.hxx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
void CurveCreator_Curve::redisplayCurve()
{
if( myDisplayer ) {
- myDisplayer->erase( false );
+ myDisplayer->eraseAll( false );
myAISShape = NULL;
- myDisplayer->display( constructWire(), true );
+
+ myDisplayer->display( getAISObject( true ), true );
}
}
{
// erase curve from the viewer
if( myDisplayer ) {
- myDisplayer->erase( true );
+ myDisplayer->eraseAll( true );
myAISShape = NULL;
}
// Delete all allocated data.
return aCoords;
}
-
-/***********************************************/
-/*** Presentation methods ***/
-/***********************************************/
-std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructWire()
+void CurveCreator_Curve::constructAISObject()
{
- std::vector<Handle_AIS_InteractiveObject> aCurveRepresentation;
-
TopoDS_Shape aShape;
CurveCreator_Utils::constructShape( this, aShape );
myAISShape = new AIS_Shape( aShape );
- aCurveRepresentation.push_back( myAISShape );
- return aCurveRepresentation;
}
-//=======================================================================
-// function: getAISObject
-// purpose:
-//=======================================================================
-Handle_AIS_InteractiveObject CurveCreator_Curve::getAISObject() const
+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
#include "CurveCreator.hxx"
#include "CurveCreator_Diff.hxx"
-#include <AIS_InteractiveObject.hxx>
-
#include <list>
#include <map>
struct CurveCreator_Section;
class CurveCreator_Displayer;
class AIS_Shape;
+class Handle_AIS_InteractiveObject;
/**
* The CurveCreator_Curve object is represented as one or more sets of
/***********************************************/
/*** Presentation methods ***/
/***********************************************/
- virtual ListAISObjects constructWire();
-
/**
* Get the curve AIS object
*/
- virtual Handle_AIS_InteractiveObject getAISObject() const;
+ virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const;
+
+protected:
+ virtual void constructAISObject();
public:
bool myIsLocked;
CurveCreator::Sections mySections; //!< curve data
CurveCreator::Dimension myDimension; //!< curve dimension
CurveCreator_Displayer* myDisplayer; //!< curve displayer
- AIS_Shape* myAISShape; //!< AIS shape
private:
ListDiff myListDiffs;
int myUndoDepth;
int myOpLevel;
+ AIS_Shape* myAISShape; //!< AIS shape
};
#endif
CurveCreator_Displayer::~CurveCreator_Displayer(void)
{
- erase( true );
+ eraseAll( true );
for( int i = 0 ; i < myObjects.size() ; i++ ){
myObjects[i].Nullify();
}
myObjects.clear();
}
-void CurveCreator_Displayer::display( AISObjectsList theCurveObjects, bool isUpdate )
+void CurveCreator_Displayer::display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate )
{
- myObjects = theCurveObjects;
- if(myObjects.empty())
+ if ( theObject.IsNull() )
return;
- for( int i = 0 ; i < myObjects.size() ; i++ ){
- myContext->Display(myObjects[i], Standard_False);
- }
+
+ myObjects.push_back( theObject );
+ myContext->Display( theObject, Standard_False );
+
if( isUpdate )
myContext->UpdateCurrentViewer();
}
-void CurveCreator_Displayer::erase( bool isUpdate )
+void CurveCreator_Displayer::eraseAll( bool isUpdate )
{
if(myObjects.empty())
return;
for( int i = 0 ; i < myObjects.size() ; i++ ){
myContext->Erase(myObjects[i], Standard_False);
}
- if( isUpdate )
- myContext->UpdateCurrentViewer();
-}
-
-void CurveCreator_Displayer::displayAIS( Handle(AIS_InteractiveObject) theObject, bool isUpdate )
-{
- myContext->Display( theObject, Standard_False );
-
- if( isUpdate )
- myContext->UpdateCurrentViewer();
-}
-
-void CurveCreator_Displayer::redisplayAIS( Handle(AIS_InteractiveObject) theObject, bool isUpdate )
-{
- myContext->Redisplay( theObject, Standard_False );
-
+ myObjects.clear();
if( isUpdate )
myContext->UpdateCurrentViewer();
}
return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
}
-void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL )
+/*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL )
{
return;
//TODO:
myContext->Display(theObjects[i], Standard_False);
}
myContext->UpdateCurrentViewer();
-}
+}*/
CurveCreator_Displayer(Handle_AIS_InteractiveContext theContext );
~CurveCreator_Displayer(void);
- //TODO: remove
- Handle_AIS_InteractiveContext getAISContext() { return myContext; }
-
- void display( AISObjectsList theCurveObjects, bool isUpdate );
- void erase( bool isUpdate );
- void highlight( const AISObjectsList& theObjects, bool isHL );
-
- void displayAIS( Handle_AIS_InteractiveObject theObject, bool isUpdate );
- void redisplayAIS( Handle_AIS_InteractiveObject theObject, bool isUpdate );
+ void display( const Handle_AIS_InteractiveObject& theObject, bool isUpdate );
+ void eraseAll( bool isUpdate );
+ //void highlight( const AISObjectsList& theObjects, bool isHL );
protected:
Quantity_Color getActiveColor( bool isHL );
#include <deque>
#include <vector>
-#include <AIS_InteractiveObject.hxx>
+class Handle_AIS_InteractiveObject;
namespace CurveCreator
{
class CURVECREATOR_EXPORT CurveCreator_ICurve
{
public:
- typedef std::vector<Handle_AIS_InteractiveObject> ListAISObjects;
-
typedef std::pair<int,int> SectionToPoint;
typedef std::deque<SectionToPoint> SectionToPointList;
/***********************************************/
/*** Presentation methods ***/
/***********************************************/
- virtual ListAISObjects constructWire() = 0;
- virtual Handle_AIS_InteractiveObject getAISObject() const = 0;
+ virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const = 0;
+
+protected:
+ virtual void constructAISObject() = 0;
+
};
#endif
{
// erase curve from the viewer
if( myDisplayer )
- myDisplayer->erase( true );
+ myDisplayer->eraseAll( true );
// Delete all allocated data.
mySections[ 0 ]->myPoints.clear();
#include "CurveCreator_ICurve.hxx"
+#include <gp_Pnt.hxx>
+
#include <QMap>
#include <QList>
return;
gp_Pnt aPoint;
gp_Pnt aPoint1, aPoint2;
- //bool isFoundPoint = CurveCreator_Utils::getNeighbourPoints( aContext, aView, theX, theY,
- // aPoint, aPoint1, aPoint2 );
Handle(AIS_InteractiveObject) anAISObject = myCurve->getAISObject();
bool isFoundPoint = CurveCreator_Utils::pointOnObject( aView, anAISObject, theX, theY,
aPoint, aPoint1, aPoint2 );
//QList<int> aSelSections = aPanel->getSelectedSections();
bool aIsHl = false;
//if( aSelSections.contains(i) ){
- aDisplayer->highlight( myCurve->constructWire(), aIsHl );
+ // TODO
+ //aDisplayer->highlight( myCurve->getAISObject(), aIsHl );
//}
}
{
CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx );
myCurve->setDisplayer( aDisplayer );
- aDisplayer->display( myCurve->constructWire(), true );
+ aDisplayer->display( myCurve->getAISObject( true ), true );
}
}
}
Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
if( !aCtx.IsNull() )
{
- aDisplayer->erase( true );
+ aDisplayer->eraseAll( true );
}
}
}
{
CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx );
myProfile->setDisplayer( aDisplayer );
- aDisplayer->display( myProfile->constructWire(), true );
+ aDisplayer->display( myProfile->getAISObject( true ), true );
}
}
}
Handle(AIS_InteractiveContext) aCtx = aPanel->getAISContext();
if( !aCtx.IsNull() )
{
- aDisplayer->erase( true );
+ aDisplayer->eraseAll( true );
}
}
}