From: asl Date: Thu, 21 Sep 2017 12:29:53 +0000 (+0300) Subject: refs #1330: correct update after preferences changes X-Git-Tag: v2.1~66^2~13^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=36b9511e8424534853e45af2d61054bd7608822e;p=modules%2Fhydro.git refs #1330: correct update after preferences changes --- diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index aca7491c..1c6b7eba 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -836,33 +836,51 @@ void HYDROGUI_Module::createPreferences() int polylineArrow = addPreference( tr( "PREF_POLYLINE_ARROW" ), polylinesGroup, LightApp_Preferences::Selector, "polyline", "arrow_type" ); - QList indices; - indices.append( 0 ); - indices.append( 1 ); - indices.append( 2 ); - setPreferenceProperty( polylineArrow, "indexes", indices ); QList arrow_types; arrow_types.append( tr( "No" ) ); arrow_types.append( tr( "Triangle" ) ); arrow_types.append( tr( "Cone" ) ); setPreferenceProperty( polylineArrow, "strings", arrow_types ); + QList indices; + indices.append( 0 ); + indices.append( 1 ); + indices.append( 2 ); + setPreferenceProperty( polylineArrow, "indexes", indices ); + setPreferenceProperty( polylineArrow, "ids", indices ); + int polylineSize = addPreference( tr( "PREF_POLYLINE_ARROW_SIZE" ), polylinesGroup, LightApp_Preferences::IntSpin, "polyline", "arrow_size" ); } void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref ) { + SUIT_ResourceMgr* resMgr = application()->resourceMgr(); if ( theSection == "preferences" && thePref == "default_strickler_coefficient" ) { - SUIT_ResourceMgr* resMgr = application()->resourceMgr(); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() ); if ( resMgr && !aDoc.IsNull() ) aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) ); } else if( theSection == "polyline" ) { - //TODO: update polylines + int aType = -1; + int aSize = -1; + if( resMgr ) + { + resMgr->value( "polyline", "arrow_type", aType ); + resMgr->value( "polyline", "arrow_size", aSize ); + } + //Update polylines + ViewManagerMap::const_iterator it = myViewManagerMap.begin(), last = myViewManagerMap.end(); + for( ; it!=last; it++ ) + { + int aViewerId = it.key(); + OCCViewer_ViewManager* aMgr = dynamic_cast( it.value().first ); + if( aMgr ) + getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize ); + } } else LightApp_Module::preferencesChanged( theSection, thePref ); diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index d447abbe..feed7992 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -27,6 +27,7 @@ #include "HYDROGUI_Operation.h" #include "HYDROGUI_DataObject.h" #include "HYDROGUI_ZLayers.h" +#include "HYDROGUI_Polyline.h" #include #include @@ -560,3 +561,32 @@ Handle(AIS_ColorScale) HYDROGUI_OCCDisplayer::GetColorScale( const int theViewer return aColorScale; } + +void HYDROGUI_OCCDisplayer::UpdatePolylines( int theViewerId, int theType, int theSize ) +{ + OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId ); + if( !aViewer ) + return; + + // Get interactive context + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if( aCtx.IsNull() ) + return; + + AIS_ListOfInteractive objs; + aCtx->DisplayedObjects( objs ); + AIS_ListOfInteractive::const_iterator it = objs.begin(), last = objs.end(); + for( ; it!=last; it++ ) + { + Handle(HYDROGUI_Arrow) arr = Handle(HYDROGUI_Arrow)::DownCast( *it ); + if( !arr.IsNull() ) + { + if( theType>=0 ) + arr->SetType( (HYDROGUI_Arrow::Type)theType ); + if( theSize>=0 ) + arr->SetSize( theSize ); + aCtx->Redisplay( arr, Standard_False ); + } + } + aCtx->UpdateCurrentViewer(); +} diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.h b/src/HYDROGUI/HYDROGUI_OCCDisplayer.h index 92e20c81..f2013297 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.h +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.h @@ -80,7 +80,10 @@ public: * \param theViewerId viewer identifier * \return the color scale */ - Handle(AIS_ColorScale) GetColorScale( const int theViewerId ); + Handle(AIS_ColorScale) GetColorScale( const int theViewerId ); + + + void UpdatePolylines( int theViewerId, int theType, int theSize ); protected: /** diff --git a/src/HYDROGUI/HYDROGUI_Polyline.cxx b/src/HYDROGUI/HYDROGUI_Polyline.cxx index b7d58e01..2fd67197 100644 --- a/src/HYDROGUI/HYDROGUI_Polyline.cxx +++ b/src/HYDROGUI/HYDROGUI_Polyline.cxx @@ -197,7 +197,10 @@ void HYDROGUI_Arrow::Compute( const Handle(PrsMgr_PresentationManager3d)& aPrese // if size==0, then the arrow length is proportional to curve length arrowLen = curveLen/10; else - arrowLen = qMin( curveLen/10, (double)mySize ); + { + //arrowLen = qMin( curveLen/10, (double)mySize ); + arrowLen = (double)mySize; + } double t = ( anAdaptor.FirstParameter() + anAdaptor.LastParameter() ) / 2; gp_Pnt P, P1; diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 8f271e54..964df94c 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -42,6 +42,9 @@ #include #include +#include +#include + HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext, const Handle(HYDROData_Entity)& theObject, const int theZLayer ) @@ -499,7 +502,20 @@ QList HYDROGUI_Shape::createShape() const if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE || IsWireEdgeCompound) { - shapes.append( HYDROGUI_Polyline::createPresentations( myTopoShape ) ); + SUIT_ResourceMgr* aResMgr = 0; + SUIT_Session* aSession = SUIT_Session::session(); + if ( aSession ) + aResMgr = SUIT_Session::session()->resourceMgr(); + + int aType = -1; + int aSize = -1; + if( aResMgr ) + { + aResMgr->value( "polyline", "arrow_type", aType ); + aResMgr->value( "polyline", "arrow_size", aSize ); + } + + shapes.append( HYDROGUI_Polyline::createPresentations( myTopoShape, aType, aSize ) ); } else {