From: nds Date: Wed, 4 Dec 2013 18:12:30 +0000 (+0000) Subject: Bug #167 - Crash in polyline dialog X-Git-Tag: BR_hydro_v_0_4~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=26e583f66a1d492ebe7d2cab874273697e455f8c;p=modules%2Fhydro.git Bug #167 - Crash in polyline dialog --- diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.cxx b/src/HYDROCurveCreator/CurveCreator_Curve.cxx index 1ce68e6c..3f88a8b2 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.cxx @@ -29,6 +29,7 @@ #include "CurveCreator_Utils.h" #include +#include #include #include #include @@ -244,9 +245,10 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& void CurveCreator_Curve::redisplayCurve() { if( myDisplayer ) { - myDisplayer->erase( false ); + myDisplayer->eraseAll( false ); myAISShape = NULL; - myDisplayer->display( constructWire(), true ); + + myDisplayer->display( getAISObject( true ), true ); } } @@ -365,7 +367,7 @@ bool CurveCreator_Curve::clearInternal() { // erase curve from the viewer if( myDisplayer ) { - myDisplayer->erase( true ); + myDisplayer->eraseAll( true ); myAISShape = NULL; } // Delete all allocated data. @@ -939,27 +941,19 @@ CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) return aCoords; } - -/***********************************************/ -/*** Presentation methods ***/ -/***********************************************/ -std::vector CurveCreator_Curve::constructWire() +void CurveCreator_Curve::constructAISObject() { - std::vector aCurveRepresentation; - TopoDS_Shape aShape; CurveCreator_Utils::constructShape( this, aShape ); myAISShape = new AIS_Shape( aShape ); - aCurveRepresentation.push_back( myAISShape ); - return aCurveRepresentation; } -//======================================================================= -// function: getAISObject -// purpose: -//======================================================================= -Handle_AIS_InteractiveObject CurveCreator_Curve::getAISObject() const +Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const { + if ( !myAISShape && theNeedToBuild ) { + CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this; + aCurve->constructAISObject(); + } return myAISShape; } \ No newline at end of file diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.hxx b/src/HYDROCurveCreator/CurveCreator_Curve.hxx index ffa89c9c..24a216cf 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.hxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.hxx @@ -29,14 +29,13 @@ #include "CurveCreator.hxx" #include "CurveCreator_Diff.hxx" -#include - #include #include struct CurveCreator_Section; class CurveCreator_Displayer; class AIS_Shape; +class Handle_AIS_InteractiveObject; /** * The CurveCreator_Curve object is represented as one or more sets of @@ -262,19 +261,19 @@ public: /***********************************************/ /*** Presentation methods ***/ /***********************************************/ - virtual ListAISObjects constructWire(); - /** * Get the curve AIS object */ - virtual Handle_AIS_InteractiveObject getAISObject() const; + virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const; + +protected: + virtual void constructAISObject(); public: bool myIsLocked; CurveCreator::Sections mySections; //!< curve data CurveCreator::Dimension myDimension; //!< curve dimension CurveCreator_Displayer* myDisplayer; //!< curve displayer - AIS_Shape* myAISShape; //!< AIS shape private: @@ -284,6 +283,7 @@ private: ListDiff myListDiffs; int myUndoDepth; int myOpLevel; + AIS_Shape* myAISShape; //!< AIS shape }; #endif diff --git a/src/HYDROCurveCreator/CurveCreator_Displayer.cxx b/src/HYDROCurveCreator/CurveCreator_Displayer.cxx index f0c5463d..5872e3f8 100644 --- a/src/HYDROCurveCreator/CurveCreator_Displayer.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Displayer.cxx @@ -8,48 +8,33 @@ CurveCreator_Displayer::CurveCreator_Displayer( Handle_AIS_InteractiveContext th CurveCreator_Displayer::~CurveCreator_Displayer(void) { - erase( true ); + eraseAll( true ); for( int i = 0 ; i < myObjects.size() ; i++ ){ myObjects[i].Nullify(); } myObjects.clear(); } -void CurveCreator_Displayer::display( AISObjectsList theCurveObjects, bool isUpdate ) +void CurveCreator_Displayer::display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate ) { - myObjects = theCurveObjects; - if(myObjects.empty()) + if ( theObject.IsNull() ) return; - for( int i = 0 ; i < myObjects.size() ; i++ ){ - myContext->Display(myObjects[i], Standard_False); - } + + myObjects.push_back( theObject ); + myContext->Display( theObject, Standard_False ); + if( isUpdate ) myContext->UpdateCurrentViewer(); } -void CurveCreator_Displayer::erase( bool isUpdate ) +void CurveCreator_Displayer::eraseAll( bool isUpdate ) { if(myObjects.empty()) return; for( int i = 0 ; i < myObjects.size() ; i++ ){ myContext->Erase(myObjects[i], Standard_False); } - if( 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 ); - + myObjects.clear(); if( isUpdate ) myContext->UpdateCurrentViewer(); } @@ -62,7 +47,7 @@ Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL ) return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB ); } -void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL ) +/*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL ) { return; //TODO: @@ -72,4 +57,4 @@ void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool i myContext->Display(theObjects[i], Standard_False); } myContext->UpdateCurrentViewer(); -} +}*/ diff --git a/src/HYDROCurveCreator/CurveCreator_Displayer.h b/src/HYDROCurveCreator/CurveCreator_Displayer.h index fba268bc..ad762b7f 100644 --- a/src/HYDROCurveCreator/CurveCreator_Displayer.h +++ b/src/HYDROCurveCreator/CurveCreator_Displayer.h @@ -16,15 +16,9 @@ public: CurveCreator_Displayer(Handle_AIS_InteractiveContext theContext ); ~CurveCreator_Displayer(void); - //TODO: remove - Handle_AIS_InteractiveContext getAISContext() { return myContext; } - - void display( AISObjectsList theCurveObjects, bool isUpdate ); - 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 ); + void display( const Handle_AIS_InteractiveObject& theObject, bool isUpdate ); + void eraseAll( bool isUpdate ); + //void highlight( const AISObjectsList& theObjects, bool isHL ); protected: Quantity_Color getActiveColor( bool isHL ); diff --git a/src/HYDROCurveCreator/CurveCreator_ICurve.hxx b/src/HYDROCurveCreator/CurveCreator_ICurve.hxx index ed6b3c2e..fa031746 100644 --- a/src/HYDROCurveCreator/CurveCreator_ICurve.hxx +++ b/src/HYDROCurveCreator/CurveCreator_ICurve.hxx @@ -27,7 +27,7 @@ #include #include -#include +class Handle_AIS_InteractiveObject; namespace CurveCreator { @@ -57,8 +57,6 @@ namespace CurveCreator class CURVECREATOR_EXPORT CurveCreator_ICurve { public: - typedef std::vector ListAISObjects; - typedef std::pair SectionToPoint; typedef std::deque SectionToPointList; @@ -179,9 +177,12 @@ public: /***********************************************/ /*** Presentation methods ***/ /***********************************************/ - virtual ListAISObjects constructWire() = 0; - virtual Handle_AIS_InteractiveObject getAISObject() const = 0; + virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const = 0; + +protected: + virtual void constructAISObject() = 0; + }; #endif diff --git a/src/HYDROCurveCreator/CurveCreator_Profile.cxx b/src/HYDROCurveCreator/CurveCreator_Profile.cxx index 0a13021c..d34695d9 100644 --- a/src/HYDROCurveCreator/CurveCreator_Profile.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Profile.cxx @@ -68,7 +68,7 @@ bool CurveCreator_Profile::clearInternal() { // erase curve from the viewer if( myDisplayer ) - myDisplayer->erase( true ); + myDisplayer->eraseAll( true ); // Delete all allocated data. mySections[ 0 ]->myPoints.clear(); diff --git a/src/HYDROCurveCreator/CurveCreator_UtilsICurve.hxx b/src/HYDROCurveCreator/CurveCreator_UtilsICurve.hxx index 60e78683..96b4e454 100644 --- a/src/HYDROCurveCreator/CurveCreator_UtilsICurve.hxx +++ b/src/HYDROCurveCreator/CurveCreator_UtilsICurve.hxx @@ -24,6 +24,8 @@ #include "CurveCreator_ICurve.hxx" +#include + #include #include diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index 60a024d2..0e7936e5 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -1075,8 +1075,6 @@ void CurveCreator_Widget::insertPointToSelectedSegment( const int theX, return; gp_Pnt aPoint; gp_Pnt aPoint1, aPoint2; - //bool isFoundPoint = CurveCreator_Utils::getNeighbourPoints( aContext, aView, theX, theY, - // aPoint, aPoint1, aPoint2 ); Handle(AIS_InteractiveObject) anAISObject = myCurve->getAISObject(); bool isFoundPoint = CurveCreator_Utils::pointOnObject( aView, anAISObject, theX, theY, aPoint, aPoint1, aPoint2 ); diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index 7ad2b2f6..889a1336 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -291,7 +291,8 @@ void HYDROGUI_PolylineOp::onEditorSelectionChanged() //QList aSelSections = aPanel->getSelectedSections(); bool aIsHl = false; //if( aSelSections.contains(i) ){ - aDisplayer->highlight( myCurve->constructWire(), aIsHl ); + // TODO + //aDisplayer->highlight( myCurve->getAISObject(), aIsHl ); //} } @@ -306,7 +307,7 @@ void HYDROGUI_PolylineOp::displayPreview() { CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx ); myCurve->setDisplayer( aDisplayer ); - aDisplayer->display( myCurve->constructWire(), true ); + aDisplayer->display( myCurve->getAISObject( true ), true ); } } } @@ -322,7 +323,7 @@ void HYDROGUI_PolylineOp::erasePreview() Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); if( !aCtx.IsNull() ) { - aDisplayer->erase( true ); + aDisplayer->eraseAll( true ); } } } diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index db4cd7ba..6ed7bd15 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -217,7 +217,7 @@ void HYDROGUI_ProfileOp::displayPreview() { CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx ); myProfile->setDisplayer( aDisplayer ); - aDisplayer->display( myProfile->constructWire(), true ); + aDisplayer->display( myProfile->getAISObject( true ), true ); } } } @@ -231,7 +231,7 @@ void HYDROGUI_ProfileOp::erasePreview() Handle(AIS_InteractiveContext) aCtx = aPanel->getAISContext(); if( !aCtx.IsNull() ) { - aDisplayer->erase( true ); + aDisplayer->eraseAll( true ); } } }