]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
implementing save/restore visual parameters..
authorasv <asv@opencascade.com>
Fri, 10 Feb 2006 09:38:39 +0000 (09:38 +0000)
committerasv <asv@opencascade.com>
Fri, 10 Feb 2006 09:38:39 +0000 (09:38 +0000)
src/SVTK/SVTK_ViewWindow.cxx
src/SalomeApp/SalomeApp_Module.cxx
src/SalomeApp/SalomeApp_Study.cxx

index 106c485b88b69f0ff0fb8536a47dfa6ec7d32b1c..4175e3e8244fcfe1677b48e8dd5f4bf1ae2d7dc1 100755 (executable)
@@ -669,8 +669,10 @@ SVTK_ViewWindow
     camera->SetParallelScale( parScale );
     SetScale( scale );
 
-    getRenderer()->ResetCameraClippingRange();
-    Repaint();
+    //    resize( size() );
+
+    //    getRenderer()->ResetCameraClippingRange();
+    //    Repaint();
     //    getMainWindow()->GetRenderer()->GetTransform()->SetMatrixScale( scale[0], scale[1], scale[2] );
   }
 }
index d32ea2210f3639551dc1492bdc3ea665eb576af8..b22992cf4daadf35ef64e9f05c12719cf3875d05 100644 (file)
@@ -11,7 +11,7 @@
 #include "LightApp_Selection.h"
 #include "LightApp_Operation.h"
 #include "LightApp_Preferences.h"
-#include "LightApp_Displayer.h"
+//#include "LightApp_Displayer.h"
 
 #include "CAM_DataModel.h"
 
 #include <SALOME_ListIO.hxx>
 #include <SALOME_ListIteratorOfListIO.hxx>
 #include <SALOME_InteractiveObject.hxx>
-#include <SALOME_Actor.h>
+//#include <SALOME_Actor.h>
 
-#include "SALOMEDS_IParameters.hxx"
+//#include "SALOMEDS_IParameters.hxx"
 
 #include <SUIT_Session.h>
 #include <SUIT_ViewModel.h>
 
 #include <SVTK_ViewWindow.h>
-#include <SVTK_ViewModel.h>
-#include <SVTK_MainWindow.h>
-#include <SVTK_RenderWindowInteractor.h>
+//#include <SVTK_ViewModel.h>
+//#include <SVTK_MainWindow.h>
+//#include <SVTK_RenderWindowInteractor.h>
 
 #include <qstring.h>
 #include <qmap.h>
 
-#include <vtkActorCollection.h>
-#include <vtkRenderer.h>
+//#include <vtkActorCollection.h>
+//#include <vtkRenderer.h>
 
 /*!Constructor.*/
 SalomeApp_Module::SalomeApp_Module( const QString& name )
@@ -111,23 +111,6 @@ void SalomeApp_Module::extractContainers( const SALOME_ListIO& source, SALOME_Li
   }
 }
 
-const char gSeparator = '_'; // character used to separate parameter names
-const int ViewerType = 0;
-const int ViewIndex = 1;
-const int ParamName = 2;
-// visual parameters are stored in strings as follows:
-// ViewerType_ViewNumber_ParamName.  '_' is used as separator and should not be used in
-// viewer type or parameter names
-
-// return viewer type substring from parameter name
-std::string getParam( const std::string& paramName, const int index )
-{
-  QStringList lst = QStringList::split( gSeparator, QString( paramName.c_str() ) );
-  if ( !lst.isEmpty() && index < lst.size() )
-    return lst[index];
-  return "";
-}
-
 /*!
  * \brief Virtual public
  *
@@ -136,96 +119,6 @@ std::string getParam( const std::string& paramName, const int index )
  */
 void SalomeApp_Module::storeVisualParameters(int savePoint)
 {
-  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
-  if( !study )
-    return;
-  _PTR(AttributeParameter) ap = study->studyDS()->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint);
-  SALOMEDS_IParameters ip(ap);
-
-  QPtrList<SUIT_ViewManager> lst;
-  getApp()->viewManagers( lst );
-  int vtkViewers( 0 );
-  for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it ) {
-    SUIT_ViewManager* vman = it.current();
-    SUIT_ViewModel* vmodel = vman->getViewModel();
-
-    // saving VTK actors' properties
-    if ( vmodel && vmodel->inherits( "SVTK_Viewer" ) ) {
-      QPtrVector<SUIT_ViewWindow> views = vman->getViews();
-      for ( int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++ ) {
-       SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>( views[i] );
-       if ( vtkView ) {
-         vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
-         allActors->InitTraversal();
-         while ( vtkActor* actor = allActors->GetNextActor() ) {
-           if ( actor->GetVisibility() ) { // store only visible actors
-             if ( SALOME_Actor* salomeActor = SALOME_Actor::SafeDownCast( actor ) ) {
-               if ( salomeActor->hasIO() ) { // actor corresponds to existing obj
-                 
-                 Handle(SALOME_InteractiveObject) io = salomeActor->getIO();
-                 const char* entry = io->getEntry();
-                 const char* aName = salomeActor->getName();
-                 float opacity = salomeActor->GetOpacity();
-                 float r, g, b;
-                 salomeActor->GetColor(r, g, b);
-                 int repMode = salomeActor->GetRepresentation();
-                 int disMode = salomeActor->getDisplayMode();
-                 bool isInf = salomeActor->IsInfinitive();
-                 bool isShrunk = ( salomeActor->IsShrunkable() && salomeActor->IsShrunk() );
-                 
-                 //  printf (" -- actor: entry=%s, name=%s, opacity=%f, color=%d,%d,%d, repMode=%d, disMode=%d... -- \n",
-                 //      entry, aName, opacity, r, g, b, repMode, disMode );
-                 
-                 QString param, vtkParam = vmodel->getType(); vtkParam += gSeparator; 
-                 vtkParam += QString::number( vtkViewers );   vtkParam += gSeparator; 
-                 param = vtkParam + "Visibility";     
-                 ip.setParameter( entry, param.latin1(), "true" );
-                 param = vtkParam + "Name";     
-                 ip.setParameter( entry, param.latin1(), aName );
-                 param = vtkParam + "Opacity";  
-                 ip.setParameter( entry, param.latin1(), QString::number( opacity ).latin1() );
-                 param = vtkParam + "ColorRed"; 
-                 ip.setParameter( entry, param.latin1(), QString::number( r ).latin1() );
-                 param = vtkParam + "ColorGreen";
-                 ip.setParameter( entry, param.latin1(), QString::number( g ).latin1() );
-                 param = vtkParam + "ColorBlue";
-                 ip.setParameter( entry, param.latin1(), QString::number( b ).latin1() );
-                 param = vtkParam + "RepresentationMode";
-                 ip.setParameter( entry, param.latin1(), QString::number( repMode ).latin1() );
-                 param = vtkParam + "DisplayMode";
-                 ip.setParameter( entry, param.latin1(), QString::number( disMode ).latin1() );
-                 param = vtkParam + "IsInfitine";
-                 ip.setParameter( entry, param.latin1(), QString::number( isInf ).latin1() );
-                 param = vtkParam + "IsShrunk";
-                 ip.setParameter( entry, param.latin1(), QString::number( isShrunk ).latin1() );
-               } // hasIO
-             } // salome_actor successfull downcast
-           } // isVisible
-         } // end of ..while.. actors traversal
-       } // if ( vtkView )
-      } // for ( views ) 
-      vtkViewers++;   
-    } // if ( SVTK view model )
-  }
-}
-
-// returns SALOME_Actor with IO with given entry
-SALOME_Actor* getActor( std::string entry, SVTK_ViewWindow* vtkView )
-{
-  if ( vtkView && !entry.empty() ) {
-    vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
-    allActors->InitTraversal();
-    while ( vtkActor* actor = allActors->GetNextActor() ) {
-      if ( SALOME_Actor* salomeActor = SALOME_Actor::SafeDownCast( actor ) ) {
-       if ( salomeActor->hasIO() ) { // actor corresponds to existing obj
-         Handle(SALOME_InteractiveObject) io = salomeActor->getIO();
-         if ( entry == io->getEntry() )
-           return salomeActor;
-       }
-      }
-    }
-  }
-  return 0;
 }
 
 /*!
@@ -236,43 +129,5 @@ SALOME_Actor* getActor( std::string entry, SVTK_ViewWindow* vtkView )
  */
 void SalomeApp_Module::restoreVisualParameters(int savePoint)
 {
-  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
-  if( !study )
-    return;
-  _PTR(AttributeParameter) ap = study->studyDS()->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint);
-  SALOMEDS_IParameters ip(ap);
-
-  QMap<QString, SALOME_Actor*> vtkActors; // actors are stored in a map after displaying of them for quicker access in future
-  
-  std::vector<std::string> entries = ip.getEntries();
-  for ( std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt ) {
-    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();
-    for ( ; namesIt != paramNames.end(); ++namesIt, ++valuesIt ) {
-      std::string viewerType = ::getParam( *namesIt, ViewerType );
-      std::string viewIndexStr = ::getParam( *namesIt, ViewIndex );
-      std::string paramName = ::getParam( *namesIt, ParamName );
-      if ( viewerType == SVTK_Viewer::Type().latin1() ) {
-       cout << "--SVTK parameter: entry = " << *entIt << ", viewIndex = " << viewIndexStr << ", paramName = " << paramName << endl;
-       int viewIndex = QString( viewIndexStr.c_str() ).toUInt();
-       QPtrList<SUIT_ViewManager> lst;
-       getApp()->viewManagers( SVTK_Viewer::Type(), lst );
-       if ( viewIndex < lst.count() ) {
-         // for VTK ViewManager always has 1 ViewWindow, so view index is number of view manager.
-         if ( paramName == "Visibility" && displayer() ) {
-           displayer()->Display( (*entIt).c_str() );
-
-           SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) lst.at( viewIndex )->getActiveView();
-           vtkView->getRenderer()->ResetCameraClippingRange();
-           vtkView->Repaint();
-
-           vtkActors[(*entIt).c_str()] = getActor( *entIt, vtkView ); // store displayed actor
-         }
-       } // if view index less then VTK view managers size
-      } // if SVTK
-    } // for names/parameters iterator
-  } // for entries iterator
 }
 
index 6f7fd1298ab3cf2fb969a94a7401526998c82b20..a1965671addafc346801652b9571b866ac2e8d9a 100644 (file)
@@ -838,8 +838,9 @@ void SalomeApp_Study::restoreState(int savePoint)
       while ( !viewWin->isVisible() )
        qApp->processEvents();
 
-      if (application()->desktop()) 
-       viewWin->resize( (int)( application()->desktop()->width() * 0.6 ), (int)( application()->desktop()->height() * 0.6 ) );
+      //      if (application()->desktop()) 
+      //       viewWin->resize( (int)( application()->desktop()->width() * 0.6 ), (int)( application()->desktop()->height() * 0.6 ) );
+      
       viewWin->setCaption(ip.getValue(viewerEntry, j).c_str());
       viewWin->setVisualParameters(ip.getValue(viewerEntry, j+1).c_str());
       sprintf(buffer, "%s_%d", viewerID.c_str(), j);