diff --git a/src/CurveCreator/CurveCreator_Curve.cxx b/src/CurveCreator/CurveCreator_Curve.cxx index fb85db9d8..a2add5ddb 100644 --- a/src/CurveCreator/CurveCreator_Curve.cxx +++ b/src/CurveCreator/CurveCreator_Curve.cxx @@ -56,7 +56,10 @@ CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimensi myNbRedos (0), myUndoDepth (-1), myOpLevel(0), - mySkipSorting(false) + mySkipSorting(false), + myPointAspectColor (Quantity_NOC_ROYALBLUE4), + myCurveColor (Quantity_NOC_RED), + myLineWidth(1) { } @@ -249,13 +252,16 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& } } -void CurveCreator_Curve::redisplayCurve() +void CurveCreator_Curve::redisplayCurve(bool preEraseAllObjects) { //DEBTRACE("redisplayCurve"); - if( myDisplayer ) { - myDisplayer->eraseAll( false ); + if( myDisplayer ) + { + if (preEraseAllObjects) + myDisplayer->eraseAll( false ); + else + myDisplayer->erase( myAISShape, false); myAISShape = NULL; - myDisplayer->display( getAISObject( true ), true ); } } @@ -422,7 +428,7 @@ bool CurveCreator_Curve::joinInternal( const std::list& theSections ) break; } - redisplayCurve(); + redisplayCurve(false); return res; } @@ -465,7 +471,7 @@ int CurveCreator_Curve::addSectionInternal aSection->myIsClosed = theIsClosed; aSection->myPoints = thePoints; mySections.push_back(aSection); - redisplayCurve(); + redisplayCurve(false); return mySections.size()-1; } @@ -525,7 +531,7 @@ bool CurveCreator_Curve::removeSectionInternal( const int theISection ) delete *anIterRm; mySections.erase(anIterRm); } - redisplayCurve(); + redisplayCurve(false); return true; } @@ -616,14 +622,14 @@ bool CurveCreator_Curve::setClosedInternal( const int theISection, aSection = (CurveCreator_Section*)getSection( i ); if( aSection ) { aSection->myIsClosed = theIsClosed; - redisplayCurve(); + redisplayCurve(false); } } } else { aSection = (CurveCreator_Section*)getSection( theISection ); if ( aSection ) { aSection->myIsClosed = theIsClosed; - redisplayCurve(); + redisplayCurve(false); } } return true; @@ -706,12 +712,12 @@ bool CurveCreator_Curve::setSectionTypeInternal( const int theISection, if ( aSection ) aSection->myType = theType; } - redisplayCurve(); + redisplayCurve(false); } else { aSection = (CurveCreator_Section*)getSection( theISection ); if ( aSection && aSection->myType != theType ){ aSection->myType = theType; - redisplayCurve(); + redisplayCurve(false); } } return true; @@ -772,7 +778,7 @@ bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &the } } if(res) - redisplayCurve(); + redisplayCurve(false); return res; } @@ -830,7 +836,7 @@ bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theS } } if(res) - redisplayCurve(); + redisplayCurve(false); return res; } @@ -914,7 +920,7 @@ bool CurveCreator_Curve::removePointsInternal( const SectionToPointList &thePoin aRes = removeSectionPoints(aSectionId, anIt->second); } if( aRes) - redisplayCurve(); + redisplayCurve(false); return aRes; } @@ -989,20 +995,21 @@ void CurveCreator_Curve::constructAISObject() //DEBTRACE("constructAISObject"); TopoDS_Shape aShape; CurveCreator_Utils::constructShape( this, aShape ); - - myAISShape = new AIS_Shape( aShape ); + myAISShape = new AIS_Shape( aShape ); + myAISShape->SetColor( myCurveColor ); + myAISShape->SetWidth( myLineWidth ); Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect(); anAspect->SetScale( 3.0 ); anAspect->SetTypeOfMarker(Aspect_TOM_O_POINT); - anAspect->SetColor(Quantity_NOC_ROYALBLUE4); + anAspect->SetColor(myPointAspectColor); myAISShape->Attributes()->SetPointAspect( anAspect ); - } Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const { //DEBTRACE("getAISObject"); - if ( !myAISShape && theNeedToBuild ) { + if ( !myAISShape && theNeedToBuild ) + { CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this; aCurve->constructAISObject(); } diff --git a/src/CurveCreator/CurveCreator_Curve.hxx b/src/CurveCreator/CurveCreator_Curve.hxx index 5763d1fff..7a4cbb9ec 100644 --- a/src/CurveCreator/CurveCreator_Curve.hxx +++ b/src/CurveCreator/CurveCreator_Curve.hxx @@ -36,6 +36,7 @@ struct CurveCreator_Section; class CurveCreator_Displayer; class AIS_Shape; class AIS_InteractiveObject; +class Quantity_Color; /** * The CurveCreator_Curve object is represented as one or more sets of @@ -108,7 +109,7 @@ protected: public: // TODO: remove public void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const; protected: // TODO: remove public - void redisplayCurve(); + void redisplayCurve(bool preEraseAllObjects = true); public: /************ Implementation of INTERFACE methods ************/ @@ -294,7 +295,7 @@ public: /** * Get the curve AIS object */ - virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false ) const; + virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false) const; protected: /** @@ -324,6 +325,9 @@ public: CurveCreator::Sections mySections; //!< curve data CurveCreator::Dimension myDimension; //!< curve dimension CurveCreator_Displayer* myDisplayer; //!< curve displayer + Quantity_Color myPointAspectColor; + Quantity_Color myCurveColor; + double myLineWidth; private: diff --git a/src/CurveCreator/CurveCreator_Displayer.cxx b/src/CurveCreator/CurveCreator_Displayer.cxx index 61285c962..4ac2e0450 100644 --- a/src/CurveCreator/CurveCreator_Displayer.cxx +++ b/src/CurveCreator/CurveCreator_Displayer.cxx @@ -54,14 +54,22 @@ void CurveCreator_Displayer::eraseAll( bool isUpdate ) { if(myObjects.empty()) return; - for( int i = 0 ; i < myObjects.size() ; i++ ){ + for( int i = 0 ; i < myObjects.size() ; i++ ) myContext->Erase(myObjects[i], Standard_False); - } myObjects.clear(); if( isUpdate ) myContext->UpdateCurrentViewer(); } +void CurveCreator_Displayer::erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate ) +{ + if(theObject.IsNull()) + return; + myContext->Erase(theObject, Standard_False); + if( isUpdate ) + myContext->UpdateCurrentViewer(); +} + Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL ) { if( isHL ){ @@ -70,6 +78,13 @@ Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL ) return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB ); } +void CurveCreator_Displayer::Update() +{ + for( int i = 0 ; i < myObjects.size() ; i++ ) + myContext->Update(myObjects[i], Standard_True); + myContext->UpdateCurrentViewer(); +} + /*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL ) { return; diff --git a/src/CurveCreator/CurveCreator_Displayer.hxx b/src/CurveCreator/CurveCreator_Displayer.hxx index d78b2a2f2..9528c8616 100644 --- a/src/CurveCreator/CurveCreator_Displayer.hxx +++ b/src/CurveCreator/CurveCreator_Displayer.hxx @@ -38,6 +38,8 @@ public: void display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate ); void eraseAll( bool isUpdate ); + void erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate ); + void Update(); //void highlight( const AISObjectsList& theObjects, bool isHL ); protected: