-#include "HYDROGUI_AISCurve.h"\r
-#include "CurveCreator_Curve.hxx"\r
-\r
-#include <AIS_Point.hxx>\r
-#include <AIS_Line.hxx>\r
-#include <gp_Pnt.hxx>\r
-#include <gp_Lin.hxx>\r
-#include <Geom_CartesianPoint.hxx>\r
-\r
-HYDROGUI_AISCurveSection::HYDROGUI_AISCurveSection( Handle_AIS_InteractiveContext theContext, \r
- CurveCreator_Curve* theCurve, int theSection) :\r
- myCurve(theCurve), mySection(theSection), myContext(theContext), myIsHL(false)\r
-{\r
- buildSection();\r
-}\r
-\r
-HYDROGUI_AISCurveSection::~HYDROGUI_AISCurveSection()\r
-{\r
- Erase();\r
- for( int i = 0 ; i < myObjects.size() ; i++ ){\r
- myObjects[i].Nullify();\r
- }\r
- myObjects.clear();\r
-}\r
-\r
-Quantity_Color HYDROGUI_AISCurveSection::getActiveColor()\r
-{\r
- if( myIsHL ){\r
- return Quantity_Color( 1., 0., 0., Quantity_TOC_RGB );\r
- }\r
- return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );\r
-}\r
-\r
-void HYDROGUI_AISCurveSection::highlight( bool isHL )\r
-{\r
- myIsHL = isHL;\r
- Quantity_Color aColor = getActiveColor();\r
- for( int i = 0 ; i < myObjects.size() ; i++ ){\r
- myObjects[i]->SetColor(aColor);\r
- myContext->Display(myObjects[i]);\r
- }\r
-}\r
-\r
-void HYDROGUI_AISCurveSection::Display()\r
-{\r
- for( int i = 0 ; i < myObjects.size() ; i++ ){\r
- myContext->Display(myObjects[i]);\r
- }\r
-}\r
-\r
-void HYDROGUI_AISCurveSection::Erase()\r
-{\r
- for( int i = 0 ; i < myObjects.size() ; i++ ){\r
- myContext->Erase(myObjects[i]);\r
- }\r
-}\r
-\r
-void HYDROGUI_AISCurveSection::buildSection()\r
-{\r
- int aSectSize = myCurve->getNbPoints( mySection );\r
- double anX;\r
- double anY;\r
- double aZ;\r
- int i = 0; \r
- for( ; i < ( aSectSize - 1 ) ; i++ ){\r
- Handle_AIS_Point anAISPnt = getAISPoint(i);\r
- myObjects.push_back( anAISPnt );\r
- Handle_AIS_Line aLine = getAISLine( i, i+1 );\r
- myObjects.push_back( aLine );\r
- }\r
- if( aSectSize != 0 ){\r
- Handle_AIS_Point anAISPnt = getAISPoint(i); \r
- myObjects.push_back( anAISPnt );\r
- if( myCurve->isClosed(mySection) && ( aSectSize > 1 ) ){\r
- Handle_AIS_Line aLine = getAISLine( i, 0 );\r
- myObjects.push_back( aLine );\r
- }\r
- }\r
-}\r
-\r
-Handle_AIS_Point HYDROGUI_AISCurveSection::getAISPoint( int theIndx )\r
-{\r
- double anX;\r
- double anY;\r
- double aZ;\r
- getPoint( theIndx, anX, anY, aZ );\r
- gp_Pnt aPoint( anX, anY, aZ);\r
- AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));\r
- return aPnt;\r
-}\r
-\r
-Handle_AIS_Line HYDROGUI_AISCurveSection::getAISLine( int theIndx1, int theIndx2 )\r
-{\r
- double anX;\r
- double anY;\r
- double aZ;\r
- getPoint( theIndx1, anX, anY, aZ );\r
- gp_Pnt aPoint1( anX, anY, aZ);\r
- double anX2;\r
- double anY2;\r
- double aZ2;\r
- getPoint( theIndx2, anX2, anY2, aZ2 );\r
-//MTN to avoid crash during line construction\r
- if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){\r
- aZ2 += 1e-7;\r
- }\r
- gp_Pnt aPoint2( anX2, anY2, aZ2 );\r
- AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );\r
- return aLine;\r
-}\r
-\r
-void HYDROGUI_AISCurveSection::getPoint( int theIndx, double& theX, double& theY, double& theZ )\r
-{\r
- CurveCreator::Dimension aDim = myCurve->getDimension();\r
- CurveCreator::Coordinates aCoords = myCurve->getCoordinates( mySection, theIndx );\r
- theX = aCoords[0];\r
- theY = aCoords[1];\r
- theZ = 0.;\r
- if( aDim == CurveCreator::Dim3d ){\r
- theZ = aCoords[2];\r
- }\r
-}\r
-\r
-/******************************* HYDROGUI_AISCurve ********************************************/\r
-HYDROGUI_AISCurve::HYDROGUI_AISCurve( CurveCreator_Curve* theCurve, Handle_AIS_InteractiveContext theContext ) :\r
- CurveCreator_Listener(), myCurve(theCurve), myContext( theContext )\r
-{\r
- myCurve->setListener(this);\r
- buildCurve();\r
-}\r
-\r
-HYDROGUI_AISCurve::~HYDROGUI_AISCurve(void)\r
-{\r
-}\r
-\r
-void HYDROGUI_AISCurve::setCurve( CurveCreator_Curve* theCurve )\r
-{\r
- myCurve = theCurve;\r
- buildCurve();\r
-}\r
-\r
-void HYDROGUI_AISCurve::Display()\r
-{\r
- for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){\r
- myCurveRepresentation[i]->Display();\r
- }\r
-}\r
-\r
-void HYDROGUI_AISCurve::buildCurve()\r
-{\r
- for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){\r
- myCurveRepresentation[i]->Erase();\r
- delete myCurveRepresentation[i];\r
- }\r
- myCurveRepresentation.clear();\r
- for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){\r
- HYDROGUI_AISCurveSection* aSection = new HYDROGUI_AISCurveSection( myContext, myCurve, i);\r
- myCurveRepresentation.push_back( aSection );\r
- myCurveRepresentation[i]->Display();\r
- }\r
-}\r
-\r
-void HYDROGUI_AISCurve::pointInserted( int theSection, int theIndx )\r
-{\r
- buildCurve();\r
-}\r
-\r
-void HYDROGUI_AISCurve::highlightSection( int theSection, bool isHL )\r
-{\r
- if( theSection >= myCurveRepresentation.size() )\r
- return;\r
- myCurveRepresentation[theSection]->highlight(isHL);\r
-}\r
+#include "HYDROGUI_AISCurve.h"
+
+#include "CurveCreator_Curve.hxx"
+
+
+
+#include <AIS_Point.hxx>
+
+#include <AIS_Line.hxx>
+
+#include <gp_Pnt.hxx>
+
+#include <gp_Lin.hxx>
+
+#include <Geom_CartesianPoint.hxx>
+
+
+
+HYDROGUI_AISCurveSection::HYDROGUI_AISCurveSection( Handle_AIS_InteractiveContext theContext,
+
+ CurveCreator_Curve* theCurve, int theSection) :
+
+ myCurve(theCurve), mySection(theSection), myContext(theContext), myIsHL(false)
+
+{
+
+ buildSection();
+
+}
+
+
+
+HYDROGUI_AISCurveSection::~HYDROGUI_AISCurveSection()
+
+{
+
+ Erase();
+
+ for( int i = 0 ; i < myObjects.size() ; i++ ){
+
+ myObjects[i].Nullify();
+
+ }
+
+ myObjects.clear();
+
+}
+
+
+
+Quantity_Color HYDROGUI_AISCurveSection::getActiveColor()
+
+{
+
+ if( myIsHL ){
+
+ return Quantity_Color( 1., 0., 0., Quantity_TOC_RGB );
+
+ }
+
+ return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
+
+}
+
+
+
+void HYDROGUI_AISCurveSection::highlight( bool isHL )
+
+{
+
+ myIsHL = isHL;
+
+ Quantity_Color aColor = getActiveColor();
+
+ for( int i = 0 ; i < myObjects.size() ; i++ ){
+
+ myObjects[i]->SetColor(aColor);
+
+ myContext->Display(myObjects[i]);
+
+ }
+
+}
+
+
+
+void HYDROGUI_AISCurveSection::Display()
+
+{
+
+ for( int i = 0 ; i < myObjects.size() ; i++ ){
+
+ myContext->Display(myObjects[i]);
+
+ }
+
+}
+
+
+
+void HYDROGUI_AISCurveSection::Erase()
+
+{
+
+ for( int i = 0 ; i < myObjects.size() ; i++ ){
+
+ myContext->Erase(myObjects[i]);
+
+ }
+
+}
+
+
+
+void HYDROGUI_AISCurveSection::buildSection()
+
+{
+
+ int aSectSize = myCurve->getNbPoints( mySection );
+
+ double anX;
+
+ double anY;
+
+ double aZ;
+
+ int i = 0;
+
+ for( ; i < ( aSectSize - 1 ) ; i++ ){
+
+ Handle_AIS_Point anAISPnt = getAISPoint(i);
+
+ myObjects.push_back( anAISPnt );
+
+ Handle_AIS_Line aLine = getAISLine( i, i+1 );
+
+ myObjects.push_back( aLine );
+
+ }
+
+ if( aSectSize != 0 ){
+
+ Handle_AIS_Point anAISPnt = getAISPoint(i);
+
+ myObjects.push_back( anAISPnt );
+
+ if( myCurve->isClosed(mySection) && ( aSectSize > 1 ) ){
+
+ Handle_AIS_Line aLine = getAISLine( i, 0 );
+
+ myObjects.push_back( aLine );
+
+ }
+
+ }
+
+}
+
+
+
+Handle_AIS_Point HYDROGUI_AISCurveSection::getAISPoint( int theIndx )
+
+{
+
+ double anX;
+
+ double anY;
+
+ double aZ;
+
+ getPoint( theIndx, anX, anY, aZ );
+
+ gp_Pnt aPoint( anX, anY, aZ);
+
+ AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));
+
+ return aPnt;
+
+}
+
+
+
+Handle_AIS_Line HYDROGUI_AISCurveSection::getAISLine( int theIndx1, int theIndx2 )
+
+{
+
+ double anX;
+
+ double anY;
+
+ double aZ;
+
+ getPoint( theIndx1, anX, anY, aZ );
+
+ gp_Pnt aPoint1( anX, anY, aZ);
+
+ double anX2;
+
+ double anY2;
+
+ double aZ2;
+
+ getPoint( theIndx2, 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 HYDROGUI_AISCurveSection::getPoint( int theIndx, double& theX, double& theY, double& theZ )
+
+{
+
+ CurveCreator::Dimension aDim = myCurve->getDimension();
+
+ CurveCreator::Coordinates aCoords = myCurve->getCoordinates( mySection, theIndx );
+
+ theX = aCoords[0];
+
+ theY = aCoords[1];
+
+ theZ = 0.;
+
+ if( aDim == CurveCreator::Dim3d ){
+
+ theZ = aCoords[2];
+
+ }
+
+}
+
+
+
+/******************************* HYDROGUI_AISCurve ********************************************/
+
+HYDROGUI_AISCurve::HYDROGUI_AISCurve( CurveCreator_Curve* theCurve, Handle_AIS_InteractiveContext theContext ) :
+
+ CurveCreator_Listener(), myCurve(theCurve), myContext( theContext )
+
+{
+
+ myCurve->setListener(this);
+
+ buildCurve();
+
+}
+
+
+
+HYDROGUI_AISCurve::~HYDROGUI_AISCurve(void)
+
+{
+
+}
+
+
+
+void HYDROGUI_AISCurve::setCurve( CurveCreator_Curve* theCurve )
+
+{
+
+ myCurve = theCurve;
+
+ buildCurve();
+
+}
+
+
+
+void HYDROGUI_AISCurve::Display()
+
+{
+
+ for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){
+
+ myCurveRepresentation[i]->Display();
+
+ }
+
+}
+
+
+
+void HYDROGUI_AISCurve::buildCurve()
+
+{
+
+ for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){
+
+ myCurveRepresentation[i]->Erase();
+
+ delete myCurveRepresentation[i];
+
+ }
+
+ myCurveRepresentation.clear();
+
+ for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){
+
+ HYDROGUI_AISCurveSection* aSection = new HYDROGUI_AISCurveSection( myContext, myCurve, i);
+
+ myCurveRepresentation.push_back( aSection );
+
+ myCurveRepresentation[i]->Display();
+
+ }
+
+}
+
+
+
+void HYDROGUI_AISCurve::pointInserted( int theSection, int theIndx )
+
+{
+
+ buildCurve();
+
+}
+
+
+
+void HYDROGUI_AISCurve::highlightSection( int theSection, bool isHL )
+
+{
+
+ if( theSection >= myCurveRepresentation.size() )
+
+ return;
+
+ myCurveRepresentation[theSection]->highlight(isHL);
+
+}
+
-#ifndef HYDROGUI_AIS_CURVE_H\r
-#define HYDROGUI_AIS_CURVE_H\r
-\r
-#include <vector>\r
-#include <list>\r
-\r
-#include <AIS_InteractiveContext.hxx>\r
-#include <AIS_Point.hxx>\r
-#include <AIS_Line.hxx>\r
-#include <CurveCreator_Listener.hxx>\r
-\r
-class CurveCreator_Curve;\r
-class AIS_InteractiveObject;\r
-class AIS_Point;\r
-class AIS_Line;\r
-\r
-class HYDROGUI_AISCurveSection\r
-{\r
-public:\r
- HYDROGUI_AISCurveSection( Handle_AIS_InteractiveContext theContext, \r
- CurveCreator_Curve* theCurve, int theSection );\r
- virtual ~HYDROGUI_AISCurveSection();\r
-\r
- void Display();\r
- void Erase();\r
-\r
- void highlight( bool isHL );\r
-protected:\r
- virtual void buildSection();\r
- void getPoint( int theIndx, double& theX, double& theY, double& theZ );\r
- Handle_AIS_Point getAISPoint( int theIndx );\r
- Handle_AIS_Line getAISLine( int theIndx1, int theIndx2 );\r
- Quantity_Color getActiveColor();\r
-\r
-private:\r
- CurveCreator_Curve* myCurve;\r
- int mySection;\r
- std::vector< Handle_AIS_InteractiveObject > myObjects;\r
- Handle_AIS_InteractiveContext myContext;\r
- bool myIsHighlight;\r
- bool myIsHL;\r
-};\r
-\r
-class HYDROGUI_AISCurve : public CurveCreator_Listener\r
-{\r
-public:\r
- HYDROGUI_AISCurve(CurveCreator_Curve* theCurve, Handle_AIS_InteractiveContext theContext );\r
- ~HYDROGUI_AISCurve(void);\r
-\r
- void setCurve( CurveCreator_Curve* theCurve );\r
-\r
- void Display();\r
-\r
- virtual void pointInserted( int theSection, int theIndx );\r
-\r
- void highlightSection( int theSection, bool isHL );\r
- void clearSelection();\r
-\r
-protected:\r
- virtual void buildCurve();\r
- Quantity_Color getActiveColor();\r
-\r
-private:\r
- CurveCreator_Curve* myCurve;\r
- Handle_AIS_InteractiveContext myContext;\r
- std::vector< HYDROGUI_AISCurveSection* > myCurveRepresentation; \r
-};\r
-\r
+#ifndef HYDROGUI_AIS_CURVE_H
+
+#define HYDROGUI_AIS_CURVE_H
+
+
+
+#include <vector>
+
+#include <list>
+
+
+
+#include <AIS_InteractiveContext.hxx>
+
+#include <AIS_Point.hxx>
+
+#include <AIS_Line.hxx>
+
+#include <CurveCreator_Listener.hxx>
+
+
+
+class CurveCreator_Curve;
+
+class AIS_InteractiveObject;
+
+class AIS_Point;
+
+class AIS_Line;
+
+
+
+class HYDROGUI_AISCurveSection
+
+{
+
+public:
+
+ HYDROGUI_AISCurveSection( Handle_AIS_InteractiveContext theContext,
+
+ CurveCreator_Curve* theCurve, int theSection );
+
+ virtual ~HYDROGUI_AISCurveSection();
+
+
+
+ void Display();
+
+ void Erase();
+
+
+
+ void highlight( bool isHL );
+
+protected:
+
+ virtual void buildSection();
+
+ void getPoint( int theIndx, double& theX, double& theY, double& theZ );
+
+ Handle_AIS_Point getAISPoint( int theIndx );
+
+ Handle_AIS_Line getAISLine( int theIndx1, int theIndx2 );
+
+ Quantity_Color getActiveColor();
+
+
+
+private:
+
+ CurveCreator_Curve* myCurve;
+
+ int mySection;
+
+ std::vector< Handle_AIS_InteractiveObject > myObjects;
+
+ Handle_AIS_InteractiveContext myContext;
+
+ bool myIsHighlight;
+
+ bool myIsHL;
+
+};
+
+
+
+class HYDROGUI_AISCurve : public CurveCreator_Listener
+
+{
+
+public:
+
+ HYDROGUI_AISCurve(CurveCreator_Curve* theCurve, Handle_AIS_InteractiveContext theContext );
+
+ ~HYDROGUI_AISCurve(void);
+
+
+
+ void setCurve( CurveCreator_Curve* theCurve );
+
+
+
+ void Display();
+
+
+
+ virtual void pointInserted( int theSection, int theIndx );
+
+
+
+ void highlightSection( int theSection, bool isHL );
+
+ void clearSelection();
+
+
+
+protected:
+
+ virtual void buildCurve();
+
+ Quantity_Color getActiveColor();
+
+
+
+private:
+
+ CurveCreator_Curve* myCurve;
+
+ Handle_AIS_InteractiveContext myContext;
+
+ std::vector< HYDROGUI_AISCurveSection* > myCurveRepresentation;
+
+};
+
+
+
#endif
\ No newline at end of file