From: srn Date: Fri, 27 Jan 2006 09:29:53 +0000 (+0000) Subject: Changes the signatures of visual parameter methods X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fa5af2062ce7d7c0c0a9c1c131b6fbe506a35e8d;p=modules%2Fgui.git Changes the signatures of visual parameter methods --- diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 2d5532af8..693e52a4e 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -137,7 +137,8 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) emit opened( this ); study->IsSaved(true); - restoreState(1);//############### VISUAL PARAMETERS + vector savePoints = getSavePoints(); + if(savePoints.size() > 0) restoreState(savePoints[savePoints.size()-1]);//############### VISUAL PARAMETERS return res; } @@ -187,7 +188,7 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) //======================================================================= bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) { - storeState(1);//############### VISUAL PARAMETERS + storeState();//############### VISUAL PARAMETERS ModelList list; dataModels( list ); @@ -224,7 +225,7 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) //======================================================================= bool SalomeApp_Study::saveDocument() { - storeState(1); //############### VISUAL PARAMETERS + storeState(); //############### VISUAL PARAMETERS ModelList list; dataModels( list ); @@ -642,16 +643,16 @@ void SalomeApp_Study::components( QStringList& comps ) const } //================================================================ -// Function : getNbSavePoints -/*! Purpose : returns a number of saved points +// Function : getSavePoints +/*! Purpose : returns a list of saved points' IDs */ //================================================================ -int SalomeApp_Study::getNbSavePoints() +vector SalomeApp_Study::getSavePoints() { - int nbSavePoints = 0; + vector v; _PTR(SObject) so = studyDS()->FindComponent("Interface Applicative"); - if(!so) return 0; + if(!so) return v; _PTR(StudyBuilder) builder = studyDS()->NewBuilder(); _PTR(ChildIterator) anIter ( studyDS()->NewChildIterator( so ) ); @@ -659,10 +660,10 @@ int SalomeApp_Study::getNbSavePoints() { _PTR(SObject) val( anIter->Value() ); _PTR(GenericAttribute) genAttr; - if(builder->FindAttribute(val, genAttr, "AttributeParameter")) nbSavePoints++; + if(builder->FindAttribute(val, genAttr, "AttributeParameter")) v.push_back(val->Tag()); } - return nbSavePoints; + return v; } //================================================================ @@ -692,9 +693,15 @@ void SalomeApp_Study::setNameOfSavePoint(int savePoint, const QString& nameOfSav /*! Purpose : store the visual parameters of the viewers */ //================================================================ -void SalomeApp_Study::storeState(int savePoint) +int SalomeApp_Study::storeState() { - SUIT_ViewWindow* activeWindow = application()->desktop()->activeWindow(); + SUIT_ViewWindow* activeWindow = 0; + if(application()->desktop()) activeWindow = application()->desktop()->activeWindow(); + + int savePoint = 1; + vector savePoints = getSavePoints(); + //Calculate a new savePoint number = the last save point number + 1 + if(savePoints.size() > 0) savePoint = savePoints[savePoints.size()-1] + 1; //Remove the previous content of the attribute ViewerContainer container(savePoint); @@ -738,6 +745,8 @@ void SalomeApp_Study::storeState(int savePoint) container.addModule(module->moduleName()); module->storeVisualParameters(savePoint); } + + return savePoint; } //================================================================ @@ -814,12 +823,11 @@ void SalomeApp_Study::restoreState(int savePoint) } //================================================================ -// Function : getViewerParameters -/*! Purpose : Return an attribute that stores the viewers' - * parameters +// Function : getStateParameters +/*! Purpose : Return an attribute that stores the saved state parameters */ //================================================================ -_PTR(AttributeParameter) SalomeApp_Study::getViewerParameters(int savePoint) +_PTR(AttributeParameter) SalomeApp_Study::getStateParameters(int savePoint) { _PTR(StudyBuilder) builder = studyDS()->NewBuilder(); _PTR(SObject) so = studyDS()->FindComponent("Interface Applicative"); diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index 474e5fec0..70bd86cf3 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -66,12 +66,12 @@ public: virtual void children( const QString&, QStringList& ) const; virtual void components( QStringList& ) const; - int getNbSavePoints(); + std::vector getSavePoints(); QString getNameOfSavePoint(int savePoint); void setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint); - void storeState(int savePoint); + int storeState(); void restoreState(int savePoint); - _PTR(AttributeParameter) getViewerParameters(int savePoint); + _PTR(AttributeParameter) getStateParameters(int savePoint); protected: virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); diff --git a/src/SalomeApp/SalomeApp_VisualParameters.cxx b/src/SalomeApp/SalomeApp_VisualParameters.cxx index 94d72e7f1..2a4ec902a 100644 --- a/src/SalomeApp/SalomeApp_VisualParameters.cxx +++ b/src/SalomeApp/SalomeApp_VisualParameters.cxx @@ -41,13 +41,15 @@ using namespace std; /*! Constructor */ -SalomeApp_VisualParameters::SalomeApp_VisualParameters(const _PTR(SComponent)& sco, const int savePoint) +SalomeApp_VisualParameters::SalomeApp_VisualParameters(const string& moduleName, const int savePoint) { + /* if(!sco) return; _PTR(Study) study = sco->GetStudy(); _PTR(StudyBuilder) builder = study->NewBuilder(); _PTR(SObject) so = builder->NewObjectToTag(sco, savePoint); _ap = builder->FindOrCreateAttribute(so, "AttributeParameter"); + */ } /*! @@ -181,7 +183,7 @@ ViewerContainer::ViewerContainer(int savePoint) { SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); if( !study ) return; - _ap = study->getViewerParameters(savePoint); + _ap = study->getStateParameters(savePoint); } int ViewerContainer::getNbViewers() diff --git a/src/SalomeApp/SalomeApp_VisualParameters.h b/src/SalomeApp/SalomeApp_VisualParameters.h index ba1b79342..4b0b0c2bf 100644 --- a/src/SalomeApp/SalomeApp_VisualParameters.h +++ b/src/SalomeApp/SalomeApp_VisualParameters.h @@ -36,8 +36,8 @@ class SALOMEAPP_EXPORT SalomeApp_VisualParameters { public: - SalomeApp_VisualParameters(const _PTR(SComponent)& sco, const int savePoint); - + SalomeApp_VisualParameters(const std::string& moduleName, const int savePoint); + void setColor(const std::string& entry, std::vector color); std::vector getColor(const std::string& entry); @@ -74,6 +74,7 @@ class SALOMEAPP_EXPORT ViewerContainer { public: ViewerContainer(int savePoint); + /*! returns a number of viewers*/ int getNbViewers(); /*! sets an active view ID*/