From: nds Date: Thu, 21 Nov 2013 09:25:39 +0000 (+0000) Subject: Curve displayer is moved to the curve creator. X-Git-Tag: BR_hydro_v_0_3_1~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d13b5e8e4b3544e500dfa500fe39e40904309801;p=modules%2Fhydro.git Curve displayer is moved to the curve creator. This is an attempt to fix the bug refs #94 - Fatal error after second Edit polyline A fix for the bug #refs 111 - curve becomes invisible after edit in modification mode --- diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index ae3d5b21..a73efdb3 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -46,7 +46,7 @@ HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit ) : HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), myCurve(NULL), - myViewManager(NULL), myCurveDisplayer(NULL) + myViewManager(NULL) { setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) ); } @@ -205,6 +205,11 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, } aPolylineObj->SetPolylineData(aPolylineData); + // the viewer should be release from the widget before the module update it + // because it has an opened local context and updated presentation should not be displayed in it + if ( aPanel ) + aPanel->setOCCViewer( 0 ); + if( !myIsEdit ) module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aPolylineObj, true ); @@ -220,13 +225,14 @@ void HYDROGUI_PolylineOp::onEditorSelectionChanged() return; if( !myCurve ) return; - if( !myCurveDisplayer ) + CurveCreator_Displayer* aDisplayer = myCurve->getDisplayer(); + if( !aDisplayer ) return; QList aSelSections = aPanel->getSelectedSections(); for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){ bool aIsHl = false; if( aSelSections.contains(i) ){ - myCurveDisplayer->highlight( myCurve->constructSection(i), aIsHl ); + aDisplayer->highlight( myCurve->constructSection(i), aIsHl ); } } } @@ -240,9 +246,9 @@ void HYDROGUI_PolylineOp::displayPreview() Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); if( !aCtx.IsNull() ) { - myCurveDisplayer = new CurveCreator_Displayer( aCtx ); - myCurve->setDisplayer( myCurveDisplayer ); - myCurveDisplayer->display( myCurve->constructWire() ); + CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx ); + myCurve->setDisplayer( aDisplayer ); + aDisplayer->display( myCurve->constructWire() ); } } } @@ -250,16 +256,15 @@ void HYDROGUI_PolylineOp::displayPreview() void HYDROGUI_PolylineOp::erasePreview() { - if( myViewManager ) + CurveCreator_Displayer* aDisplayer = myCurve ? myCurve->getDisplayer() : 0; + if( myViewManager && aDisplayer ) { if( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() ) { Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); - if( !aCtx.IsNull() && myCurveDisplayer ) + if( !aCtx.IsNull() ) { - myCurveDisplayer->erase(); - delete myCurveDisplayer; - myCurveDisplayer = 0; + aDisplayer->erase(); } } } diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.h b/src/HYDROGUI/HYDROGUI_PolylineOp.h index c7fbe658..aebd8be0 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.h +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.h @@ -29,7 +29,6 @@ class OCCViewer_ViewManager; class CurveCreator_Curve; -class CurveCreator_Displayer; class HYDROGUI_PolylineOp : public HYDROGUI_Operation { @@ -64,7 +63,6 @@ private: bool myIsEdit; Handle(HYDROData_Polyline) myEditedObject; CurveCreator_Curve* myCurve; - CurveCreator_Displayer* myCurveDisplayer; }; #endif