HYDRO / refs #1334

This commit is contained in:
isn 2017-10-18 20:24:10 +03:00
parent 19d83677d4
commit ed9a2d484b
4 changed files with 52 additions and 24 deletions

View File

@ -56,7 +56,10 @@ CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimensi
myNbRedos (0), myNbRedos (0),
myUndoDepth (-1), myUndoDepth (-1),
myOpLevel(0), 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"); //DEBTRACE("redisplayCurve");
if( myDisplayer ) { if( myDisplayer )
myDisplayer->eraseAll( false ); {
if (preEraseAllObjects)
myDisplayer->eraseAll( false );
else
myDisplayer->erase( myAISShape, false);
myAISShape = NULL; myAISShape = NULL;
myDisplayer->display( getAISObject( true ), true ); myDisplayer->display( getAISObject( true ), true );
} }
} }
@ -422,7 +428,7 @@ bool CurveCreator_Curve::joinInternal( const std::list<int>& theSections )
break; break;
} }
redisplayCurve(); redisplayCurve(false);
return res; return res;
} }
@ -465,7 +471,7 @@ int CurveCreator_Curve::addSectionInternal
aSection->myIsClosed = theIsClosed; aSection->myIsClosed = theIsClosed;
aSection->myPoints = thePoints; aSection->myPoints = thePoints;
mySections.push_back(aSection); mySections.push_back(aSection);
redisplayCurve(); redisplayCurve(false);
return mySections.size()-1; return mySections.size()-1;
} }
@ -525,7 +531,7 @@ bool CurveCreator_Curve::removeSectionInternal( const int theISection )
delete *anIterRm; delete *anIterRm;
mySections.erase(anIterRm); mySections.erase(anIterRm);
} }
redisplayCurve(); redisplayCurve(false);
return true; return true;
} }
@ -616,14 +622,14 @@ bool CurveCreator_Curve::setClosedInternal( const int theISection,
aSection = (CurveCreator_Section*)getSection( i ); aSection = (CurveCreator_Section*)getSection( i );
if( aSection ) { if( aSection ) {
aSection->myIsClosed = theIsClosed; aSection->myIsClosed = theIsClosed;
redisplayCurve(); redisplayCurve(false);
} }
} }
} else { } else {
aSection = (CurveCreator_Section*)getSection( theISection ); aSection = (CurveCreator_Section*)getSection( theISection );
if ( aSection ) { if ( aSection ) {
aSection->myIsClosed = theIsClosed; aSection->myIsClosed = theIsClosed;
redisplayCurve(); redisplayCurve(false);
} }
} }
return true; return true;
@ -706,12 +712,12 @@ bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
if ( aSection ) if ( aSection )
aSection->myType = theType; aSection->myType = theType;
} }
redisplayCurve(); redisplayCurve(false);
} else { } else {
aSection = (CurveCreator_Section*)getSection( theISection ); aSection = (CurveCreator_Section*)getSection( theISection );
if ( aSection && aSection->myType != theType ){ if ( aSection && aSection->myType != theType ){
aSection->myType = theType; aSection->myType = theType;
redisplayCurve(); redisplayCurve(false);
} }
} }
return true; return true;
@ -772,7 +778,7 @@ bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &the
} }
} }
if(res) if(res)
redisplayCurve(); redisplayCurve(false);
return res; return res;
} }
@ -830,7 +836,7 @@ bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theS
} }
} }
if(res) if(res)
redisplayCurve(); redisplayCurve(false);
return res; return res;
} }
@ -914,7 +920,7 @@ bool CurveCreator_Curve::removePointsInternal( const SectionToPointList &thePoin
aRes = removeSectionPoints(aSectionId, anIt->second); aRes = removeSectionPoints(aSectionId, anIt->second);
} }
if( aRes) if( aRes)
redisplayCurve(); redisplayCurve(false);
return aRes; return aRes;
} }
@ -989,20 +995,21 @@ void CurveCreator_Curve::constructAISObject()
//DEBTRACE("constructAISObject"); //DEBTRACE("constructAISObject");
TopoDS_Shape aShape; TopoDS_Shape aShape;
CurveCreator_Utils::constructShape( this, 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(); Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect();
anAspect->SetScale( 3.0 ); anAspect->SetScale( 3.0 );
anAspect->SetTypeOfMarker(Aspect_TOM_O_POINT); anAspect->SetTypeOfMarker(Aspect_TOM_O_POINT);
anAspect->SetColor(Quantity_NOC_ROYALBLUE4); anAspect->SetColor(myPointAspectColor);
myAISShape->Attributes()->SetPointAspect( anAspect ); myAISShape->Attributes()->SetPointAspect( anAspect );
} }
Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
{ {
//DEBTRACE("getAISObject"); //DEBTRACE("getAISObject");
if ( !myAISShape && theNeedToBuild ) { if ( !myAISShape && theNeedToBuild )
{
CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this; CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
aCurve->constructAISObject(); aCurve->constructAISObject();
} }

View File

@ -36,6 +36,7 @@ struct CurveCreator_Section;
class CurveCreator_Displayer; class CurveCreator_Displayer;
class AIS_Shape; class AIS_Shape;
class AIS_InteractiveObject; class AIS_InteractiveObject;
class Quantity_Color;
/** /**
* The CurveCreator_Curve object is represented as one or more sets of * The CurveCreator_Curve object is represented as one or more sets of
@ -108,7 +109,7 @@ protected:
public: // TODO: remove public public: // TODO: remove public
void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const; void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
protected: // TODO: remove public protected: // TODO: remove public
void redisplayCurve(); void redisplayCurve(bool preEraseAllObjects = true);
public: public:
/************ Implementation of INTERFACE methods ************/ /************ Implementation of INTERFACE methods ************/
@ -294,7 +295,7 @@ public:
/** /**
* Get the curve AIS object * 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: protected:
/** /**
@ -324,6 +325,9 @@ public:
CurveCreator::Sections mySections; //!< curve data CurveCreator::Sections mySections; //!< curve data
CurveCreator::Dimension myDimension; //!< curve dimension CurveCreator::Dimension myDimension; //!< curve dimension
CurveCreator_Displayer* myDisplayer; //!< curve displayer CurveCreator_Displayer* myDisplayer; //!< curve displayer
Quantity_Color myPointAspectColor;
Quantity_Color myCurveColor;
double myLineWidth;
private: private:

View File

@ -54,14 +54,22 @@ void CurveCreator_Displayer::eraseAll( bool isUpdate )
{ {
if(myObjects.empty()) if(myObjects.empty())
return; return;
for( int i = 0 ; i < myObjects.size() ; i++ ){ for( int i = 0 ; i < myObjects.size() ; i++ )
myContext->Erase(myObjects[i], Standard_False); myContext->Erase(myObjects[i], Standard_False);
}
myObjects.clear(); myObjects.clear();
if( isUpdate ) if( isUpdate )
myContext->UpdateCurrentViewer(); 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 ) Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL )
{ {
if( isHL ){ if( isHL ){
@ -70,6 +78,13 @@ Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL )
return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB ); 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 ) /*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL )
{ {
return; return;

View File

@ -38,6 +38,8 @@ public:
void display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate ); void display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate );
void eraseAll( bool isUpdate ); void eraseAll( bool isUpdate );
void erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate );
void Update();
//void highlight( const AISObjectsList& theObjects, bool isHL ); //void highlight( const AISObjectsList& theObjects, bool isHL );
protected: protected: