Salome HOME
IMP 0016175: EDF455: Save GUIState don't redisplay the objects.
authorjfa <jfa@opencascade.com>
Tue, 9 Sep 2008 14:38:40 +0000 (14:38 +0000)
committerjfa <jfa@opencascade.com>
Tue, 9 Sep 2008 14:38:40 +0000 (14:38 +0000)
src/GEOM/GEOM_Engine.cxx
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI.h
src/GEOM_I/GEOM_DumpPython.cc

index 2db3accd07f3ee9a98557e563d56f6a57d538019..a55f32fd4852c41406cc9dc6939863ae074f0f12 100644 (file)
@@ -419,34 +419,34 @@ void GEOM_Engine::Close(int theDocID)
  *  DumpPython
  */
 //=============================================================================
-TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, 
+TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
                                                Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
-                                               bool isPublished, 
+                                               bool isPublished,
                                                bool& aValidScript)
 {
   TCollection_AsciiString aScript;
   Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
-  
-  if(aDoc.IsNull()) return TCollection_AsciiString("def RebuildData(theStudy): pass\n");
+
+  if (aDoc.IsNull()) return TCollection_AsciiString("def RebuildData(theStudy): pass\n");
+
   aScript = "import geompy\n";
   aScript += "import math\n";
   aScript += "import SALOMEDS\n\n";
   aScript += "def RebuildData(theStudy):";
   aScript += "\n\tgeompy.init_geom(theStudy)";
-  
+
   Standard_Integer posToInertGlobalVars = aScript.Length() + 1;
 
   Handle(TDataStd_TreeNode) aNode, aRoot;
   Handle(GEOM_Function) aFunction;
   TColStd_MapOfTransient aMap;
 
-  if(aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) {
+  if (aDoc->Main().FindAttribute(GEOM_Function::GetFunctionTreeID(), aRoot)) {
     TDataStd_ChildNodeIterator Itr(aRoot);
-    for(; Itr.More(); Itr.Next()) {
+    for (; Itr.More(); Itr.Next()) {
       aNode = Itr.Value();
       aFunction = GEOM_Function::GetFunction(aNode->Label());
-      if(aFunction.IsNull()) {
+      if (aFunction.IsNull()) {
        MESSAGE ( "Null function !!!!" );
        continue;
       }
@@ -482,12 +482,12 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
   //Replace entries by the names
   TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("geomObj_"),
     allowedChars ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_");
-  if(aLen == 0) anUpdatedScript = aScript;
+  if (aLen == 0) anUpdatedScript = aScript;
 
-  for(Standard_Integer i = 1; i <= aLen; i+=2) {
+  for (Standard_Integer i = 1; i <= aLen; i+=2) {
     anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i)-1);
     anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i+1));
-    if(theObjectNames.IsBound(anEntry)) {
+    if (theObjectNames.IsBound(anEntry)) {
       aName = theObjectNames.Find(anEntry);
       // check validity of aName
       bool isValidName = true;
@@ -530,8 +530,9 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
   }
 
   //Add final part of the script
-  if(aLen && aSeq->Value(aLen) < aScriptLength)  anUpdatedScript += aScript.SubString(aSeq->Value(aLen)+1, aScriptLength); // mkr : IPAL11865
+  if (aLen && aSeq->Value(aLen) < aScriptLength)
+    anUpdatedScript += aScript.SubString(aSeq->Value(aLen)+1, aScriptLength); // mkr : IPAL11865
+
   // ouv : NPAL12872
   for (anEntryToNameIt.Initialize( theObjectNames );
        anEntryToNameIt.More();
@@ -612,7 +613,8 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
     }
   }
 
-  anUpdatedScript += "\n\tpass\n";
+  //anUpdatedScript += "\n\tpass\n";
+  anUpdatedScript += "\n";
   aValidScript = true;
 
   // fill _studyEntry2NameMap and build globalVars
@@ -633,7 +635,7 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
     globalVars.Insert( 1, "\n\tglobal " );
     anUpdatedScript.Insert( posToInertGlobalVars, globalVars );
   }
-  
+
   return anUpdatedScript;
 }
 
index 3cc82bb0f4e3b775b1a2048d6cc47ee821fbf798..3fdf39984e943c75f0c03d766eb7df365ad70293 100644 (file)
@@ -27,6 +27,9 @@
 #include "GEOMGUI_OCCSelector.h"
 #include "GEOMGUI_Selection.h"
 #include "GEOM_Displayer.h"
+#include "GEOM_AISShape.hxx"
+
+#include "GEOM_Actor.h"
 
 #include <SUIT_Desktop.h>
 #include <SUIT_MessageBox.h>
 #include <OCCViewer_ViewModel.h>
 #include <OCCViewer_ViewManager.h>
 
+#include <SOCC_ViewModel.h>
+#include <SOCC_ViewWindow.h>
+
 #include <SVTK_ViewWindow.h>
 #include <SVTK_RenderWindowInteractor.h>
 #include <SVTK_InteractorStyle.h>
 #include <SVTK_ViewModel.h>
 
 #include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_VTKSelector.h>
 #include <LightApp_DataObject.h>
-#include <SalomeApp_Study.h>
 #include <LightApp_Preferences.h>
+
 #include <SALOME_LifeCycleCORBA.hxx>
 #include <SALOME_ListIO.hxx>
 #include <SALOME_ListIteratorOfListIO.hxx>
 
+#include <SALOMEDSClient_ClientFactory.hxx>
+#include <SALOMEDSClient_IParameters.hxx>
+
 // External includes
 #include <QAction>
 #include <QFileInfo>
 #include <QString>
 #include <QPainter>
 
+#include <AIS_Drawer.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_IsoAspect.hxx>
 #include <Aspect_TypeOfMarker.hxx>
 #include <OSD_SharedLibrary.hxx>
+#include <NCollection_DataMap.hxx>
 
 #include <utilities.h>
 
@@ -1305,7 +1320,7 @@ void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
     return;
 
   const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
-  const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
+  //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
 
   // disable non-OCC viewframe menu commands
 //  action( 404 )->setEnabled( ViewOCC ); // SKETCHER
@@ -1551,3 +1566,440 @@ int GeometryGUI::getLocalSelectionMode() const
 {
   return myLocalSelectionMode;
 }
+
+const char gSeparator = '_'; // character used to separate parameter names
+const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
+
+/*!
+ * \brief Store visual parameters
+ *
+ * This method is called just before the study document is saved.
+ * Store visual parameters in AttributeParameter attribue(s)
+ */
+void GeometryGUI::storeVisualParameters (int savePoint)
+{
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
+  if (!appStudy || !appStudy->studyDS())
+    return;
+  _PTR(Study) studyDS = appStudy->studyDS();
+
+  // componentName is used for encoding of entries when storing them in IParameters
+  std::string componentName = myComponentGeom->ComponentDataType();
+  //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
+  //if (!aSComponent) return;
+
+  // IParameters
+  _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
+                                                             componentName.c_str(),
+                                                             savePoint);
+  _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+
+  // viewers counters are used for storing view_numbers in IParameters
+  int vtkViewers(0), occViewers(0);
+
+  QList<SUIT_ViewManager*> lst;
+  QList<SUIT_ViewManager*>::Iterator it;
+
+  // main cycle to store parameters of displayed objects
+  lst.clear();
+  vtkViewers = occViewers = 0;
+  getApp()->viewManagers(lst);
+  for (it = lst.begin(); it != lst.end(); it++)
+  {
+    SUIT_ViewManager* vman = *it;
+    QString vType = vman->getType();
+
+    // saving VTK actors properties
+    if (vType == SVTK_Viewer::Type())
+    {
+      QVector<SUIT_ViewWindow*> views = vman->getViews();
+      for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
+      {
+       if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
+        {
+         vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
+         allActors->InitTraversal();
+         while (vtkActor* actor = allActors->GetNextActor())
+          {
+           if (actor->GetVisibility()) // store only visible actors
+            {
+              GEOM_Actor* aGeomActor = 0;
+              if (actor->IsA("GEOM_Actor"))
+                aGeomActor = GEOM_Actor::SafeDownCast(actor);
+             if (aGeomActor && aGeomActor->hasIO())
+              {
+                Handle(SALOME_InteractiveObject) io = aGeomActor->getIO();
+                if (io->hasEntry())
+                {
+                  // entry is "encoded" = it does NOT contain component adress, since it is a
+                  // subject to change on next component loading
+                  std::string entry = ip->encodeEntry(io->getEntry(), componentName);
+
+                  std::string param, occParam = vType.toLatin1().data();
+                  occParam += gSeparator;
+                  occParam += QString::number(vtkViewers).toLatin1().data();
+                  occParam += gSeparator;
+
+                  param = occParam + "Visibility";
+                  ip->setParameter(entry, param, "On");
+
+                  param = occParam + "DisplayMode";
+                  ip->setParameter(entry, param, QString::number
+                                   (aGeomActor->getDisplayMode()).toLatin1().data());
+
+                  vtkFloatingPointType r, g, b;
+                  aGeomActor->GetColor(r, g, b);
+                  QString colorStr = QString::number(r);
+                  colorStr += gDigitsSep; colorStr += QString::number(g);
+                  colorStr += gDigitsSep; colorStr += QString::number(b);
+                  param = occParam + "Color";
+                  ip->setParameter(entry, param, colorStr.toLatin1().data());
+
+                  param = occParam + "Opacity";
+                  ip->setParameter(entry, param, QString::number(aGeomActor->GetOpacity()).toLatin1().data());
+
+                  int nbUIso(0), nbVIso(0);
+                  aGeomActor->GetNbIsos(nbUIso,nbVIso);
+                  QString isosStr = QString::number(nbUIso);
+                  isosStr += gDigitsSep;
+                  isosStr += QString::number(nbVIso);
+                  param = occParam + "Isos";
+                  ip->setParameter(entry, param, isosStr.toLatin1().data());
+                } // if (io->hasEntry())
+             } // GEOM_Actor && hasIO
+           } // isVisible
+         } // while.. actors traversal
+       } // if (vtkView)
+      } // for (views)
+      vtkViewers++;
+    } // if (SVTK view model)
+    else if (vType == SOCC_Viewer::Type()) // processing OCC viewers
+    {
+      QVector<SUIT_ViewWindow*> views = vman->getViews();
+      for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
+      {
+       SOCC_ViewWindow* occView = dynamic_cast<SOCC_ViewWindow*>(views[i]);
+       if (occView)
+        {
+          //Handle(AIS_InteractiveContext) ic =
+          //  ((OCCViewer_Viewer*)(occView->getViewManager()->getViewModel()))->getAISContext();
+          OCCViewer_Viewer* viewModel = (OCCViewer_Viewer*)(vman->getViewModel());
+          //OCCViewer_Viewer* viewModel = ((OCCViewer_ViewManager*)vman)->getOCCViewer();
+          Handle(AIS_InteractiveContext) ic = viewModel->getAISContext();
+
+          AIS_ListOfInteractive aList;
+          ic->DisplayedObjects(aList);
+
+          AIS_ListIteratorOfListOfInteractive ite (aList);
+          for (; ite.More(); ite.Next())
+          {
+            if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
+            {
+              Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+              if (aSh->hasIO())
+              {
+                Handle(SALOME_InteractiveObject) io =
+                  Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
+                if (io->hasEntry())
+                {
+                  // entry is "encoded": it does NOT contain component adress,
+                  // since it is a subject to change on next component loading
+                  std::string entry = ip->encodeEntry(io->getEntry(), componentName);
+
+                  std::string param, occParam = vType.toLatin1().data();
+                  occParam += gSeparator;
+                  occParam += QString::number(occViewers).toLatin1().data();
+                  occParam += gSeparator;
+
+                  // Visibility
+                  param = occParam + "Visibility";
+                  ip->setParameter(entry, param, "On");
+
+                  // DisplayMode
+                  param = occParam + "DisplayMode";
+                  int dm = aSh->DisplayMode();
+                  ip->setParameter(entry, param, QString::number(dm).toLatin1().data());
+
+                  // Color
+                  // is a property of GEOM_Object, it is stored by GEOM engine
+
+                  // Transparency
+                  param = occParam + "Transparency";
+                  ip->setParameter(entry, param, QString::number(aSh->Transparency()).toLatin1().data());
+
+                  // Isos
+                  Handle(AIS_Drawer) aDrawer = aSh->Attributes();
+                  int nbUIso = aDrawer->UIsoAspect()->Number();
+                  int nbVIso = aDrawer->VIsoAspect()->Number();
+                  QString isosStr = QString::number(nbUIso);
+                  isosStr += gDigitsSep;
+                  isosStr += QString::number(nbVIso);
+                  param = occParam + "Isos";
+                  ip->setParameter(entry, param, isosStr.toLatin1().data());
+                } // if (io->hasEntry())
+              } // if (io)
+           } // if (GEOM_AISShape)
+         } // for (AIS_ListOfInteractive)
+       } // if ( occView )
+      } // for ( views )
+      occViewers++;
+    } // if (SOCC view model)
+    else
+    {
+      // unknown viewer type
+    }
+  } // for (viewManagers)
+}
+
+/*!
+ * \brief Restore visual parameters
+ *
+ * This method is called after the study document is opened.
+ * Restore visual parameters from AttributeParameter attribue(s)
+ */
+void GeometryGUI::restoreVisualParameters (int savePoint)
+{
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
+  if (!appStudy || !appStudy->studyDS())
+    return;
+  _PTR(Study) studyDS = appStudy->studyDS();
+
+  // componentName is used for encoding of entries when storing them in IParameters
+  std::string componentName = myComponentGeom->ComponentDataType();
+  //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
+  //if (!aSComponent) return;
+
+  // IParameters
+  _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
+                                                             componentName.c_str(),
+                                                             savePoint);
+  _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+
+  std::vector<std::string> entries = ip->getEntries();
+
+  for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
+  {
+    // entry is a normal entry - it should be "decoded" (setting base adress of component)
+    QString entry (ip->decodeEntry(*entIt).c_str());
+
+    // Check that the entry corresponds to a real object in the Study
+    // as the object may be deleted or modified after the visual state is saved.
+    _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
+    if (!so) continue; //Skip the not existent entry
+
+    std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
+    std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
+
+    std::vector<std::string>::iterator namesIt = paramNames.begin();
+    std::vector<std::string>::iterator valuesIt = paramValues.begin();
+
+    // actors are stored in a map after displaying of them for
+    // quicker access in the future: map < viewID to actor >
+    NCollection_DataMap<int, GEOM_Actor*          > vtkActors;
+    NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
+
+    for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
+    {
+      // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
+      // '_' is used as separator and should not be used in viewer type or parameter names.
+      QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
+      if (lst.size() != 3)
+        continue;
+
+      QString viewerTypStr = lst[0];
+      QString viewIndexStr = lst[1];
+      QString paramNameStr = lst[2];
+
+      bool ok;
+      int viewIndex = viewIndexStr.toUInt(&ok);
+      if (!ok) // bad conversion of view index to integer
+       continue;
+
+      // viewers
+      if (viewerTypStr == SVTK_Viewer::Type())
+      {
+        GEOM_Actor* vActor = 0;
+        if (vtkActors.IsBound(viewIndex))
+          vActor = vtkActors.Find(viewIndex);
+
+        if (paramNameStr == "Visibility")
+        {
+          if (!vActor && displayer())
+          {
+            QList<SUIT_ViewManager*> lst;
+            getApp()->viewManagers(viewerTypStr, lst);
+
+            // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
+            if (viewIndex >= 0 && viewIndex < lst.count()) {
+              SUIT_ViewManager* vman = lst.at(viewIndex);
+              SUIT_ViewModel* vmodel = vman->getViewModel();
+              // SVTK view model can be casted to SALOME_View
+              displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
+
+              // store displayed actor in a temporary map for quicker
+              // access later when restoring other parameters
+              SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
+              vtkRenderer* Renderer = vtkView->getRenderer();
+              vtkActorCollection* theActors = Renderer->GetActors();
+              theActors->InitTraversal();
+              bool isFound = false;
+              vtkActor *ac = theActors->GetNextActor();
+              for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
+                if (ac->IsA("GEOM_Actor")) {
+                  GEOM_Actor* aGeomAc = GEOM_Actor::SafeDownCast(ac);
+                  if (aGeomAc->hasIO()) {
+                    Handle(SALOME_InteractiveObject) io =
+                      Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
+                    if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
+                      isFound = true;
+                      vtkActors.Bind(viewIndex, aGeomAc);
+                    }
+                  }
+                }
+              }
+            }
+          }
+        } // if (paramNameStr == "Visibility")
+       else
+        {
+          // the rest properties "work" with GEOM_Actor
+         if (vActor)
+          {
+            QString val ((*valuesIt).c_str());
+
+            if (paramNameStr == "DisplayMode") {
+              vActor->setDisplayMode(val.toInt());
+            }
+            else if (paramNameStr == "Color") {
+              QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
+              if (colors.count() == 3)
+                vActor->SetColor(colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat());
+            }
+            else if (paramNameStr == "Opacity") {
+              vActor->SetOpacity(val.toFloat());
+            }
+            else if (paramNameStr == "Isos") {
+              QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
+              if (isos.count() == 2) {
+                int aIsos[2] = {isos[0].toInt(), isos[1].toInt()};
+                vActor->SetNbIsos(aIsos);
+              }
+            }
+          }
+       } // other parameters than Visibility
+      }
+      else if (viewerTypStr == SOCC_Viewer::Type())
+      {
+        //Handle(AIS_InteractiveObject) occActor;
+        Handle(GEOM_AISShape) occActor;
+        if (occActors.IsBound(viewIndex))
+          occActor = occActors.Find(viewIndex);
+
+        // ViewModel and InteractiveContext
+        SOCC_Viewer* occVModel = 0;
+        Handle(AIS_InteractiveContext) ic;
+
+        QList<SUIT_ViewManager*> lst;
+        getApp()->viewManagers(viewerTypStr, lst);
+
+        // SOCC ViewManager always has 1 ViewWindow, so view index is index of view manager
+        if (viewIndex >= 0 && viewIndex < lst.count()) {
+          SUIT_ViewManager* vman = lst.at(viewIndex);
+          SUIT_ViewModel* vmodel = vman->getViewModel();
+          occVModel = dynamic_cast<SOCC_Viewer*>(vmodel);
+          if (occVModel)
+            ic = occVModel->getAISContext();
+        }
+
+        if (ic.IsNull())
+          continue;
+
+        if (paramNameStr == "Visibility")
+        {
+         if (occActor.IsNull() && displayer())
+          {
+            displayer()->Display(entry, true, occVModel);
+
+            // store displayed actor in a temporary map for quicker
+            // access later when restoring other parameters
+            AIS_ListOfInteractive aList;
+            ic->DisplayedObjects(aList);
+            bool isFound = false;
+            AIS_ListIteratorOfListOfInteractive ite (aList);
+            for (; ite.More() && !isFound; ite.Next()) {
+              if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+                Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+                if (aSh->hasIO()) {
+                  Handle(SALOME_InteractiveObject) io =
+                    Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
+                  if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
+                    isFound = true;
+                    occActors.Bind(viewIndex, aSh);
+                  }
+                }
+              }
+            }
+          }
+        } // if (paramNameStr == "Visibility")
+       else
+        {
+          // the rest properties "work" with GEOM_AISShape
+         if (!occActor.IsNull())
+          {
+            QString val ((*valuesIt).c_str());
+
+            if (paramNameStr == "DisplayMode") {
+              ic->SetDisplayMode(occActor, AIS_DisplayMode(val.toInt()), false);
+              //ic->Redisplay(occActor, Standard_False, Standard_True);
+            }
+            // Color is restored by the GEOM engine
+            else if (paramNameStr == "Transparency") {
+              ic->SetTransparency(occActor, val.toFloat(), false);
+              ic->Redisplay(occActor, Standard_False, Standard_True);
+            }
+            else if (paramNameStr == "Isos") {
+              QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
+              if (isos.count() == 2) {
+                Handle(AIS_Drawer) aDrawer = occActor->Attributes();
+                int nbUIso = isos[0].toInt();
+                int nbVIso = isos[1].toInt();
+                Handle(Prs3d_IsoAspect) uIsoAspect = aDrawer->UIsoAspect();
+                Handle(Prs3d_IsoAspect) vIsoAspect = aDrawer->VIsoAspect();
+                uIsoAspect->SetNumber(nbUIso);
+                vIsoAspect->SetNumber(nbVIso);
+                aDrawer->SetUIsoAspect(uIsoAspect);
+                aDrawer->SetVIsoAspect(vIsoAspect);
+                ic->SetLocalAttributes(occActor, aDrawer);
+                ic->Redisplay(occActor);
+              }
+            }
+          }
+       } // other parameters than Visibility
+      }
+      else
+      {
+        // unknown viewer type
+      }
+    } // for names/parameters iterator
+  } // for entries iterator
+
+  // update all VTK and OCC views
+  QList<SUIT_ViewManager*> lst;
+  getApp()->viewManagers(lst);
+  for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
+    SUIT_ViewModel* vmodel = (*it)->getViewModel();
+    if (!vmodel)
+      continue;
+    if (vmodel->getType() == SVTK_Viewer::Type()) {
+      SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
+      vtkView->getRenderer()->ResetCameraClippingRange();
+      vtkView->Repaint();
+    }
+    else if (vmodel->getType() == SOCC_Viewer::Type()) {
+      //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
+      SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
+      if (occVMod)
+        occVMod->Repaint();
+    }
+  }
+}
index 7477ac6007cc12ea0ff54b4c70ff6ea2588cd2cd..cf9d7079d360d9212cbb011144cf8ea4c780ff14 100644 (file)
@@ -120,6 +120,9 @@ public:
   int                         getLocalSelectionMode() const;
   void                        setLocalSelectionMode(const int mode);
 
+  virtual void storeVisualParameters  (int savePoint);
+  virtual void restoreVisualParameters(int savePoint);
+
 public slots:
   virtual bool                deactivateModule( SUIT_Study* );
   virtual bool                activateModule( SUIT_Study* );
index 3fb087871c8b0cb48f78c150285fa6bf0e8bccef..8f545f63ec88fa9c80e8b74a76c4080e25c9316c 100644 (file)
@@ -68,6 +68,19 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
       "### of GEOM component\n\n";
   aScript += _impl->DumpPython(aStudy->StudyId(), aMap, isPublished, isValidScript);
 
+  if (isPublished)
+  {
+    //Output the script that sets up the visual parameters.
+    char* script = aStudy->GetDefaultScript(ComponentDataType(), "\t");
+    if (script && strlen(script) > 0) {
+      aScript += "\n\t### Store presentation parameters of displayed objects\n";
+      aScript += script;
+      CORBA::string_free(script);
+    }
+  }
+
+  aScript += "\n\tpass\n";
+
   int aLen = aScript.Length(); 
   unsigned char* aBuffer = new unsigned char[aLen+1];
   strcpy((char*)aBuffer, aScript.ToCString());