From 4661c49eda09d53ca2309343c1d9a9bfdb0bb5c0 Mon Sep 17 00:00:00 2001 From: asv Date: Fri, 10 Feb 2006 09:38:39 +0000 Subject: [PATCH] implementing save/restore visual parameters.. --- src/SVTK/SVTK_ViewWindow.cxx | 6 +- src/SalomeApp/SalomeApp_Module.cxx | 161 ++--------------------------- src/SalomeApp/SalomeApp_Study.cxx | 5 +- 3 files changed, 15 insertions(+), 157 deletions(-) diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 106c485b8..4175e3e82 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -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] ); } } diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index d32ea2210..b22992cf4 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -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" @@ -20,23 +20,23 @@ #include #include #include -#include +//#include -#include "SALOMEDS_IParameters.hxx" +//#include "SALOMEDS_IParameters.hxx" #include #include #include -#include -#include -#include +//#include +//#include +//#include #include #include -#include -#include +//#include +//#include /*!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( SUIT_Session::session()->activeApplication()->activeStudy() ); - if( !study ) - return; - _PTR(AttributeParameter) ap = study->studyDS()->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint); - SALOMEDS_IParameters ip(ap); - - QPtrList lst; - getApp()->viewManagers( lst ); - int vtkViewers( 0 ); - for ( QPtrListIterator 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 views = vman->getViews(); - for ( int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++ ) { - SVTK_ViewWindow* vtkView = dynamic_cast( 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( SUIT_Session::session()->activeApplication()->activeStudy() ); - if( !study ) - return; - _PTR(AttributeParameter) ap = study->studyDS()->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint); - SALOMEDS_IParameters ip(ap); - - QMap vtkActors; // actors are stored in a map after displaying of them for quicker access in future - - std::vector entries = ip.getEntries(); - for ( std::vector::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt ) { - std::vector paramNames = ip.getAllParameterNames( *entIt ); - std::vector paramValues = ip.getAllParameterValues( *entIt ); - std::vector::iterator namesIt = paramNames.begin(); - std::vector::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 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 } diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 6f7fd1298..a1965671a 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -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); -- 2.39.2