From: nds Date: Mon, 2 Dec 2013 09:58:36 +0000 (+0000) Subject: AIS presentation for a curve creator X-Git-Tag: BR_hydro_v_0_4~111 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f421395e52587dca27a63b18170f2c7e6daa6b9f;p=modules%2Fhydro.git AIS presentation for a curve creator --- diff --git a/src/HYDROCurveCreator/CurveCreator_AISCurve.cxx b/src/HYDROCurveCreator/CurveCreator_AISCurve.cxx index 952364d0..668e8564 100644 --- a/src/HYDROCurveCreator/CurveCreator_AISCurve.cxx +++ b/src/HYDROCurveCreator/CurveCreator_AISCurve.cxx @@ -18,12 +18,24 @@ // #include "CurveCreator_AISCurve.hxx" +#include "CurveCreator_ICurve.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include IMPLEMENT_STANDARD_HANDLE(CurveCreator_AISCurve, AIS_Shape) IMPLEMENT_STANDARD_RTTIEXT(CurveCreator_AISCurve, AIS_Shape) -CurveCreator_AISCurve::CurveCreator_AISCurve() -: AIS_Shape( TopoDS_Shape() ) +CurveCreator_AISCurve::CurveCreator_AISCurve( CurveCreator_ICurve* theCurve ) +: AIS_Shape( TopoDS_Shape() ), myCurve( theCurve ) { } @@ -31,7 +43,83 @@ void CurveCreator_AISCurve::Compute( const Handle(PrsMgr_PresentationManager3d)& const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode ) { - AIS_Shape::Compute( thePM, thePrs, theMode ); + thePrs->Clear(); + //AIS_Shape::Compute( thePM, thePrs, theMode ); + + for( int iSection = 0 ; iSection < myCurve->getNbSections() ; iSection++ ) { + //TopoDS_Shape aShape; + + CurveCreator::SectionType aSectType = myCurve->getSectionType( iSection ); + int aSectSize = myCurve->getNbPoints( iSection ); + bool aSectIsClosed = myCurve->isClosed( iSection ); + /*if( aSectType == CurveCreator::Polyline ) + { + int iPoint = 0; + for( ; iPoint < ( aSectSize - 1 ) ; iPoint++ ){ + Handle_AIS_Point anAISPnt = getAISPoint(theISection, iPoint); + aSectionRepresentation.push_back( anAISPnt ); + Handle_AIS_Line aLine = getAISLine( theISection, iPoint, iPoint+1 ); + aSectionRepresentation.push_back( aLine ); + } + if( aSectSize != 0 ){ + Handle_AIS_Point anAISPnt = getAISPoint(theISection, iPoint); + aSectionRepresentation.push_back( anAISPnt ); + if( isClosed(theISection) && ( aSectSize > 1 ) ){ + Handle_AIS_Line aLine = getAISLine( theISection, iPoint, 0 ); + aSectionRepresentation.push_back( aLine ); + } + } + }*/ + //else if( aSectType == CurveCreator::Spline ) + { + std::vector aPoints; + for( int iPoint = 0; iPoint < aSectSize; iPoint++ ) + { + /*Handle_AIS_Point anAISPnt = getAISPoint( theISection, iPoint ); + aSectionRepresentation.push_back( anAISPnt ); + */ + CurveCreator::Coordinates aCoords = myCurve->getPoint( iSection, iPoint ); + double aX = aCoords[0]; + double aY = aCoords[1]; + double aZ = aCoords[2]; + aPoints.push_back( aX ); + aPoints.push_back( aY ); + } + if( aSectSize > 1 ) + { + Handle(Geom_BSplineCurve) aBSplineCurve; + // fill array for algorithm by the received coordinates + int aLen = aPoints.size() / 2; + Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aLen); + std::vector::const_iterator aListIter = aPoints.begin(); + for (int ind = 1; ind <= aLen; ind++) { + gp_Pnt aPnt(gp::Origin()); + aPnt.SetX(*aListIter); + aListIter++; + aPnt.SetY(*aListIter); + aListIter++; + aPnt.SetZ(0); + aHCurvePoints->SetValue(ind, aPnt); + } + // compute BSpline + GeomAPI_Interpolate aGBC(aHCurvePoints, aSectIsClosed, gp::Resolution()); + aGBC.Perform(); + if (aGBC.IsDone()) { + aBSplineCurve = aGBC.Curve(); + } + TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSplineCurve ).Edge(); + + TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire(); + + //Handle(AIS_Shape) aShape = new AIS_Shape( aWire ); + //aSectionRepresentation.push_back( aShape ); + StdPrs_WFDeflectionShape::Add( thePrs, aWire/*aShape*/, myDrawer ); + //Quantity_Color aColor( 200, 200, 100, Quantity_TOC_RGB ); + //SetColor(aColor); + } + } + //StdPrs_WFDeflectionShape::Add( thePrs, aShape, myDrawer ); + } } void CurveCreator_AISCurve::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection, diff --git a/src/HYDROCurveCreator/CurveCreator_AISCurve.hxx b/src/HYDROCurveCreator/CurveCreator_AISCurve.hxx index 3672e57b..292e77c0 100644 --- a/src/HYDROCurveCreator/CurveCreator_AISCurve.hxx +++ b/src/HYDROCurveCreator/CurveCreator_AISCurve.hxx @@ -27,6 +27,8 @@ #include +class CurveCreator_ICurve; + DEFINE_STANDARD_HANDLE(CurveCreator_AISCurve, AIS_Shape) /** @@ -36,7 +38,7 @@ DEFINE_STANDARD_HANDLE(CurveCreator_AISCurve, AIS_Shape) class CurveCreator_AISCurve : public AIS_Shape { public: - Standard_EXPORT CurveCreator_AISCurve(); + Standard_EXPORT CurveCreator_AISCurve( CurveCreator_ICurve* theCurve ); protected: /** @@ -59,6 +61,9 @@ protected: public: DEFINE_STANDARD_RTTI(CurveCreator_AISCurve) + +protected: + CurveCreator_ICurve* myCurve; }; #endif // CURVECREATOR_AIS_CURVE_H diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.cxx b/src/HYDROCurveCreator/CurveCreator_Curve.cxx index d0c18958..25939c14 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.cxx @@ -43,6 +43,8 @@ #include +//#define AIS_CURVE_DISPLAY + //======================================================================= // function: Constructor // purpose: @@ -56,6 +58,9 @@ CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimensi myUndoDepth (-1), myOpLevel(0) { +#ifdef AIS_CURVE_DISPLAY + myAISCurve = new CurveCreator_AISCurve( this ); +#endif } //======================================================================= @@ -105,6 +110,10 @@ std::string CurveCreator_Curve::getUniqSectionName() const void CurveCreator_Curve::setDisplayer( CurveCreator_Displayer* theDisplayer ) { myDisplayer = theDisplayer; + +#ifdef AIS_CURVE_DISPLAY + myDisplayer->displayAIS( myAISCurve, false ); +#endif } //======================================================================= @@ -352,8 +361,12 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& void CurveCreator_Curve::redisplayCurve() { if( myDisplayer ) { +#ifdef AIS_CURVE_DISPLAY + myDisplayer->redisplayAIS(myAISCurve, false); +#else myDisplayer->erase( false ); myDisplayer->display( constructWire(), true ); +#endif } } diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.hxx b/src/HYDROCurveCreator/CurveCreator_Curve.hxx index 5747dd8b..e359e66c 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.hxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.hxx @@ -28,6 +28,7 @@ #include "CurveCreator_Macro.hxx" #include "CurveCreator.hxx" #include "CurveCreator_Diff.hxx" +#include "CurveCreator_AISCurve.hxx" #include #include @@ -269,7 +270,7 @@ public: virtual ListAISObjects constructWire() const; public: - + Handle(CurveCreator_AISCurve) myAISCurve; bool myIsLocked; CurveCreator::Sections mySections; //!< curve data CurveCreator::Dimension myDimension; //!< curve dimension diff --git a/src/HYDROCurveCreator/CurveCreator_Displayer.cxx b/src/HYDROCurveCreator/CurveCreator_Displayer.cxx index 92df3234..f0c5463d 100644 --- a/src/HYDROCurveCreator/CurveCreator_Displayer.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Displayer.cxx @@ -38,6 +38,22 @@ void CurveCreator_Displayer::erase( bool 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 ); + + if( isUpdate ) + myContext->UpdateCurrentViewer(); +} + Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL ) { if( isHL ){ diff --git a/src/HYDROCurveCreator/CurveCreator_Displayer.h b/src/HYDROCurveCreator/CurveCreator_Displayer.h index 6bfc8d08..92ed520b 100644 --- a/src/HYDROCurveCreator/CurveCreator_Displayer.h +++ b/src/HYDROCurveCreator/CurveCreator_Displayer.h @@ -1,5 +1,5 @@ -#ifndef CURVECREATOR_AIS_CURVE_H -#define CURVECREATOR_AIS_CURVE_H +#ifndef CURVECREATOR_DISPLAYER_H +#define CURVECREATOR_DISPLAYER_H #include "CurveCreator_Macro.hxx" @@ -20,6 +20,9 @@ public: 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 ); + protected: Quantity_Color getActiveColor( bool isHL );