1 #include "HYDROGUI_AISCurve.h"
\r
2 #include "CurveCreator_Curve.hxx"
\r
4 #include <AIS_Point.hxx>
\r
5 #include <AIS_Line.hxx>
\r
6 #include <gp_Pnt.hxx>
\r
7 #include <gp_Lin.hxx>
\r
8 #include <Geom_CartesianPoint.hxx>
\r
10 HYDROGUI_AISCurveSection::HYDROGUI_AISCurveSection( Handle_AIS_InteractiveContext theContext,
\r
11 CurveCreator_Curve* theCurve, int theSection) :
\r
12 myCurve(theCurve), mySection(theSection), myContext(theContext), myIsHL(false)
\r
17 HYDROGUI_AISCurveSection::~HYDROGUI_AISCurveSection()
\r
20 for( int i = 0 ; i < myObjects.size() ; i++ ){
\r
21 myObjects[i].Nullify();
\r
26 Quantity_Color HYDROGUI_AISCurveSection::getActiveColor()
\r
29 return Quantity_Color( 1., 0., 0., Quantity_TOC_RGB );
\r
31 return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
\r
34 void HYDROGUI_AISCurveSection::highlight( bool isHL )
\r
37 Quantity_Color aColor = getActiveColor();
\r
38 for( int i = 0 ; i < myObjects.size() ; i++ ){
\r
39 myObjects[i]->SetColor(aColor);
\r
40 myContext->Display(myObjects[i]);
\r
44 void HYDROGUI_AISCurveSection::Display()
\r
46 for( int i = 0 ; i < myObjects.size() ; i++ ){
\r
47 myContext->Display(myObjects[i]);
\r
51 void HYDROGUI_AISCurveSection::Erase()
\r
53 for( int i = 0 ; i < myObjects.size() ; i++ ){
\r
54 myContext->Erase(myObjects[i]);
\r
58 void HYDROGUI_AISCurveSection::buildSection()
\r
60 int aSectSize = myCurve->getNbPoints( mySection );
\r
65 for( ; i < ( aSectSize - 1 ) ; i++ ){
\r
66 Handle_AIS_Point anAISPnt = getAISPoint(i);
\r
67 myObjects.push_back( anAISPnt );
\r
68 Handle_AIS_Line aLine = getAISLine( i, i+1 );
\r
69 myObjects.push_back( aLine );
\r
71 if( aSectSize != 0 ){
\r
72 Handle_AIS_Point anAISPnt = getAISPoint(i);
\r
73 myObjects.push_back( anAISPnt );
\r
74 if( myCurve->isClosed(mySection) && ( aSectSize > 1 ) ){
\r
75 Handle_AIS_Line aLine = getAISLine( i, 0 );
\r
76 myObjects.push_back( aLine );
\r
81 Handle_AIS_Point HYDROGUI_AISCurveSection::getAISPoint( int theIndx )
\r
86 getPoint( theIndx, anX, anY, aZ );
\r
87 gp_Pnt aPoint( anX, anY, aZ);
\r
88 AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));
\r
92 Handle_AIS_Line HYDROGUI_AISCurveSection::getAISLine( int theIndx1, int theIndx2 )
\r
97 getPoint( theIndx1, anX, anY, aZ );
\r
98 gp_Pnt aPoint1( anX, anY, aZ);
\r
102 getPoint( theIndx2, anX2, anY2, aZ2 );
\r
103 //MTN to avoid crash during line construction
\r
104 if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){
\r
107 gp_Pnt aPoint2( anX2, anY2, aZ2 );
\r
108 AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );
\r
112 void HYDROGUI_AISCurveSection::getPoint( int theIndx, double& theX, double& theY, double& theZ )
\r
114 CurveCreator::Dimension aDim = myCurve->getDimension();
\r
115 CurveCreator::Coordinates aCoords = myCurve->getCoordinates( mySection, theIndx );
\r
119 if( aDim == CurveCreator::Dim3d ){
\r
124 /******************************* HYDROGUI_AISCurve ********************************************/
\r
125 HYDROGUI_AISCurve::HYDROGUI_AISCurve( CurveCreator_Curve* theCurve, Handle_AIS_InteractiveContext theContext ) :
\r
126 CurveCreator_Listener(), myCurve(theCurve), myContext( theContext )
\r
128 myCurve->setListener(this);
\r
132 HYDROGUI_AISCurve::~HYDROGUI_AISCurve(void)
\r
136 void HYDROGUI_AISCurve::setCurve( CurveCreator_Curve* theCurve )
\r
138 myCurve = theCurve;
\r
142 void HYDROGUI_AISCurve::Display()
\r
144 for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){
\r
145 myCurveRepresentation[i]->Display();
\r
149 void HYDROGUI_AISCurve::buildCurve()
\r
151 for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){
\r
152 myCurveRepresentation[i]->Erase();
\r
153 delete myCurveRepresentation[i];
\r
155 myCurveRepresentation.clear();
\r
156 for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){
\r
157 HYDROGUI_AISCurveSection* aSection = new HYDROGUI_AISCurveSection( myContext, myCurve, i);
\r
158 myCurveRepresentation.push_back( aSection );
\r
159 myCurveRepresentation[i]->Display();
\r
163 void HYDROGUI_AISCurve::pointInserted( int theSection, int theIndx )
\r
168 void HYDROGUI_AISCurve::highlightSection( int theSection, bool isHL )
\r
170 if( theSection >= myCurveRepresentation.size() )
\r
172 myCurveRepresentation[theSection]->highlight(isHL);
\r