]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #1330: correct update after preferences changes
authorasl <asl@opencascade.com>
Thu, 21 Sep 2017 12:29:53 +0000 (15:29 +0300)
committerasl <asl@opencascade.com>
Thu, 21 Sep 2017 12:29:53 +0000 (15:29 +0300)
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.h
src/HYDROGUI/HYDROGUI_Polyline.cxx
src/HYDROGUI/HYDROGUI_Shape.cxx

index aca7491c21c4ddfd4ddc716aa3d334ac9566d566..1c6b7ebaeecabfd97e103fc85f20069cd9360ada 100644 (file)
@@ -836,33 +836,51 @@ void HYDROGUI_Module::createPreferences()
   int polylineArrow = addPreference( tr( "PREF_POLYLINE_ARROW" ), polylinesGroup,
     LightApp_Preferences::Selector, "polyline", "arrow_type" );
 
-  QList<QVariant> indices;
-  indices.append( 0 );
-  indices.append( 1 );
-  indices.append( 2 );
-  setPreferenceProperty( polylineArrow, "indexes", indices );
   QList<QVariant> arrow_types;
   arrow_types.append( tr( "No" ) );
   arrow_types.append( tr( "Triangle" ) );
   arrow_types.append( tr( "Cone" ) );
   setPreferenceProperty( polylineArrow, "strings", arrow_types );
 
+  QList<QVariant> 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<OCCViewer_ViewManager*>( it.value().first );
+        if( aMgr )
+          getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize );
+      }
     }
     else
         LightApp_Module::preferencesChanged( theSection, thePref );
index d447abbe844546803c0a3fcaf3f0223c898cd524..feed7992d67883154a4baa224d5ff72824a839de 100644 (file)
@@ -27,6 +27,7 @@
 #include "HYDROGUI_Operation.h"
 #include "HYDROGUI_DataObject.h"
 #include "HYDROGUI_ZLayers.h"
+#include "HYDROGUI_Polyline.h"
 
 #include <HYDROData_Bathymetry.h>
 #include <HYDROData_Image.h>
@@ -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();
+}
index 92e20c815854ade1c62d9322833cf1fb7dc27df6..f20132977cae43dd50560a853b6478c4148559c5 100644 (file)
@@ -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:
   /**
index b7d58e0160632db4d1bead0c1b631aa1f3ca0b7a..2fd6719723fdacb152f84016a797cdca735e922f 100644 (file)
@@ -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;
index 8f271e54ff1bd599e0c826530571bf91984d86b2..964df94c41e6e121859167af5477eef6ef255e0d 100644 (file)
@@ -42,6 +42,9 @@
 #include <TopoDS_Wire.hxx>
 #include <TopExp_Explorer.hxx>
 
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
 HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext,
                                 const Handle(HYDROData_Entity)&       theObject,
                                 const int                             theZLayer )
@@ -499,7 +502,20 @@ QList<Handle(AIS_InteractiveObject)> 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
   {