1 #include "HYDROGUI_AISCurve.h"
3 #include "CurveCreator_Curve.hxx"
7 #include <AIS_Point.hxx>
9 #include <AIS_Line.hxx>
15 #include <Geom_CartesianPoint.hxx>
19 HYDROGUI_AISCurveSection::HYDROGUI_AISCurveSection( Handle_AIS_InteractiveContext theContext,
21 CurveCreator_Curve* theCurve, int theSection) :
23 myCurve(theCurve), mySection(theSection), myContext(theContext), myIsHL(false)
33 HYDROGUI_AISCurveSection::~HYDROGUI_AISCurveSection()
39 for( int i = 0 ; i < myObjects.size() ; i++ ){
41 myObjects[i].Nullify();
51 Quantity_Color HYDROGUI_AISCurveSection::getActiveColor()
57 return Quantity_Color( 1., 0., 0., Quantity_TOC_RGB );
61 return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
67 void HYDROGUI_AISCurveSection::highlight( bool isHL )
73 Quantity_Color aColor = getActiveColor();
75 for( int i = 0 ; i < myObjects.size() ; i++ ){
77 myObjects[i]->SetColor(aColor);
79 myContext->Display(myObjects[i]);
87 void HYDROGUI_AISCurveSection::Display()
91 for( int i = 0 ; i < myObjects.size() ; i++ ){
93 myContext->Display(myObjects[i]);
101 void HYDROGUI_AISCurveSection::Erase()
105 for( int i = 0 ; i < myObjects.size() ; i++ ){
107 myContext->Erase(myObjects[i]);
115 void HYDROGUI_AISCurveSection::buildSection()
119 int aSectSize = myCurve->getNbPoints( mySection );
129 for( ; i < ( aSectSize - 1 ) ; i++ ){
131 Handle_AIS_Point anAISPnt = getAISPoint(i);
133 myObjects.push_back( anAISPnt );
135 Handle_AIS_Line aLine = getAISLine( i, i+1 );
137 myObjects.push_back( aLine );
141 if( aSectSize != 0 ){
143 Handle_AIS_Point anAISPnt = getAISPoint(i);
145 myObjects.push_back( anAISPnt );
147 if( myCurve->isClosed(mySection) && ( aSectSize > 1 ) ){
149 Handle_AIS_Line aLine = getAISLine( i, 0 );
151 myObjects.push_back( aLine );
161 Handle_AIS_Point HYDROGUI_AISCurveSection::getAISPoint( int theIndx )
171 getPoint( theIndx, anX, anY, aZ );
173 gp_Pnt aPoint( anX, anY, aZ);
175 AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));
183 Handle_AIS_Line HYDROGUI_AISCurveSection::getAISLine( int theIndx1, int theIndx2 )
193 getPoint( theIndx1, anX, anY, aZ );
195 gp_Pnt aPoint1( anX, anY, aZ);
203 getPoint( theIndx2, anX2, anY2, aZ2 );
205 //MTN to avoid crash during line construction
207 if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){
213 gp_Pnt aPoint2( anX2, anY2, aZ2 );
215 AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );
223 void HYDROGUI_AISCurveSection::getPoint( int theIndx, double& theX, double& theY, double& theZ )
227 CurveCreator::Dimension aDim = myCurve->getDimension();
229 CurveCreator::Coordinates aCoords = myCurve->getCoordinates( mySection, theIndx );
237 if( aDim == CurveCreator::Dim3d ){
247 /******************************* HYDROGUI_AISCurve ********************************************/
249 HYDROGUI_AISCurve::HYDROGUI_AISCurve( CurveCreator_Curve* theCurve, Handle_AIS_InteractiveContext theContext ) :
251 CurveCreator_Listener(), myCurve(theCurve), myContext( theContext )
255 myCurve->setListener(this);
263 HYDROGUI_AISCurve::~HYDROGUI_AISCurve(void)
271 void HYDROGUI_AISCurve::setCurve( CurveCreator_Curve* theCurve )
283 void HYDROGUI_AISCurve::Display()
287 for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){
289 myCurveRepresentation[i]->Display();
297 void HYDROGUI_AISCurve::buildCurve()
301 for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){
303 myCurveRepresentation[i]->Erase();
305 delete myCurveRepresentation[i];
309 myCurveRepresentation.clear();
311 for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){
313 HYDROGUI_AISCurveSection* aSection = new HYDROGUI_AISCurveSection( myContext, myCurve, i);
315 myCurveRepresentation.push_back( aSection );
317 myCurveRepresentation[i]->Display();
325 void HYDROGUI_AISCurve::pointInserted( int theSection, int theIndx )
335 void HYDROGUI_AISCurve::highlightSection( int theSection, bool isHL )
339 if( theSection >= myCurveRepresentation.size() )
343 myCurveRepresentation[theSection]->highlight(isHL);