From: rnv Date: Tue, 1 Feb 2011 06:33:42 +0000 (+0000) Subject: Implementation of the 20937: EDF 1399 GEOM: extend the properties of GEOM object. X-Git-Tag: V6_3_0a1~73 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a1d512208fab217c86dd4825be8ab1a6ffb010e0;p=modules%2Fgui.git Implementation of the 20937: EDF 1399 GEOM: extend the properties of GEOM object. --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 7da67202c..2ba5cf62d 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -3127,6 +3127,10 @@ void LightApp_Application::removeViewManager( SUIT_ViewManager* vm ) { disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), this, SLOT( onCloseView( SUIT_ViewManager* ) ) ); + LightApp_Study* aStudy = dynamic_cast(activeStudy()); + if (aStudy ) + aStudy->removeViewMgr(vm->getGlobalId()); + STD_Application::removeViewManager( vm ); delete vm; } diff --git a/src/LightApp/LightApp_Study.cxx b/src/LightApp/LightApp_Study.cxx index aa1d15e84..fd344206c 100644 --- a/src/LightApp/LightApp_Study.cxx +++ b/src/LightApp/LightApp_Study.cxx @@ -33,7 +33,6 @@ #include "SUIT_DataObjectIterator.h" #include -#include /*! Constructor. @@ -492,3 +491,154 @@ QString LightApp_Study::getVisualComponentName() const return "Interface Applicative"; } + + + + +/*! + Set a visual property of the object + \param theViewId - Id of the viewer namager + \param theEntry - Entry of the object + \param thePropName - the name of the visual property + \param theValue - the value of the visual property +*/ +void LightApp_Study::setObjectProperty(int theViewId, QString theEntry, QString thePropName, QVariant theValue) { + + //Try to find viewer manager in the map + ViewMgrMap::Iterator v_it = myViewMgrMap.find(theViewId); + if(v_it == myViewMgrMap.end()) { + + //1) Create property map + PropMap aPropMap; + aPropMap.insert(thePropName, theValue); + + //2) Create object map + ObjMap anObjMap; + anObjMap.insert(theEntry,aPropMap); + + //3) Insert in the view manager map + myViewMgrMap.insert(theViewId, anObjMap); + + } else { + ObjMap& anObjMap = v_it.value(); + ObjMap::Iterator o_it = anObjMap.find(theEntry); + if(o_it == anObjMap.end()) { + //1) Create property map + PropMap aPropMap; + aPropMap.insert(thePropName, theValue); + + //2) Insert in the object map + anObjMap.insert(theEntry, aPropMap); + } else { + PropMap& aPropMap = o_it.value(); + aPropMap.insert(thePropName, theValue); + } + } +} + +/*! + Get a visual property of the object identified by theViewMgrId, theEntry and thePropName. + \param theViewMgrId - Id of the viewer manager. + \param theEntry - Entry of the object. + \param thePropName - the name of the visual property. + \param theDefValue - the default value of the visual property. + \return value of the visual propetry. If value is't found then return theDefValue. +*/ +QVariant LightApp_Study::getObjectProperty(int theViewMgrId, QString theEntry, QString thePropName, QVariant theDefValue) const { + QVariant& aResult = theDefValue; + ViewMgrMap::ConstIterator v_it = myViewMgrMap.find(theViewMgrId); + if(v_it != myViewMgrMap.end()){ + const ObjMap& anOnjectMap = v_it.value(); + ObjMap::ConstIterator o_it = anOnjectMap.find(theEntry); + if(o_it != anOnjectMap.end()) { + const PropMap& aPropMap = o_it.value(); + PropMap::ConstIterator p_it = aPropMap.find(thePropName); + if(p_it != aPropMap.end()) { + aResult = p_it.value(); + } + } + } + return aResult; +} + +/*! + Remove view manager with all objects. + \param theViewMgrId - Id of the viewer manager. +*/ +void LightApp_Study::removeViewMgr( int theViewMgrId ) { + myViewMgrMap.remove(theViewMgrId); +} + + +/*! + Get a map of the properties of the object identified by theViewMgrId and theEntry. + \param theViewMgrId - Id of the viewer manager. + \param theEntry - Entry of the object. + \return a map of the properties of the object. +*/ +const PropMap& LightApp_Study::getObjectPropMap(int theViewMgrId, QString theEntry) { + ViewMgrMap::Iterator v_it = myViewMgrMap.find(theViewMgrId); + if(v_it != myViewMgrMap.end()){ + ObjMap& anOnjectMap = v_it.value(); + ObjMap::Iterator o_it = anOnjectMap.find(theEntry); + if(o_it != anOnjectMap.end()) { + return o_it.value(); + } else { + PropMap aPropMap; + anOnjectMap.insert(theEntry, aPropMap); + return anOnjectMap.find(theEntry).value(); + } + } else { + PropMap aPropMap; + ObjMap anObjMap; + anObjMap.insert(theEntry,aPropMap); + myViewMgrMap.insert(theViewMgrId, anObjMap); + return anObjMap.find(theEntry).value(); + } +} + +/*! + Set a map of the properties of the object identified by theViewMgrId and theEntry. + \param theViewMgrId - Id of the viewer manager. + \param theEntry - Entry of the object. +*/ +void LightApp_Study::setObjectPropMap(int theViewMgrId, QString theEntry, PropMap thePropMap) { + //Try to find viewer manager in the map + ViewMgrMap::Iterator v_it = myViewMgrMap.find(theViewMgrId); + if(v_it == myViewMgrMap.end()) { + + //1) Create object map + ObjMap anObjMap; + anObjMap.insert(theEntry,thePropMap); + + //3) Insert in the view manager map + myViewMgrMap.insert(theViewMgrId, anObjMap); + } else { + ObjMap& anObjMap = v_it.value(); + anObjMap.insert(theEntry,thePropMap); + } +} + +/*! + Remove object's properties from all view managers. + \param theEntry - Entry of the object. +*/ +void LightApp_Study::removeObjectFromAll( QString theEntry ) { + ViewMgrMap::Iterator v_it = myViewMgrMap.begin(); + for( ;v_it != myViewMgrMap.end(); v_it++ ) { + v_it.value().remove(theEntry); + } +} +/*! + Get all objects and it's properties from view manager identified by theViewMgrId. + \param theEntry - Entry of the object. +*/ +const ObjMap& LightApp_Study::getObjectMap ( int theViewMgrId ) { + ViewMgrMap::Iterator v_it = myViewMgrMap.find(theViewMgrId); + if( v_it == myViewMgrMap.end() ) { + ObjMap anObjMap; + myViewMgrMap.insert(theViewMgrId , anObjMap); + return myViewMgrMap.find(theViewMgrId).value(); + } + return v_it.value(); +} diff --git a/src/LightApp/LightApp_Study.h b/src/LightApp/LightApp_Study.h index dae0c721a..32a5cddbd 100644 --- a/src/LightApp/LightApp_Study.h +++ b/src/LightApp/LightApp_Study.h @@ -31,10 +31,29 @@ #include "string" #include "vector" +#include +#include + class SUIT_Study; class SUIT_Application; class CAM_DataModel; +//Map to store visual property of the object. +//Key: Name of the visual property of the object. +//Value: value of the visual property. +typedef QMap PropMap; + +//Map to store objects with it's visual properties. +//Key: Entry of the object. +//Value: Map of the visual properties of the object. +typedef QMap ObjMap; + +//Map to store view managers and all objects which displayed in views of the view managers. +//Key: Id of the viewer. +//Value: Map of the objects with it's visual properties. +typedef QMap ViewMgrMap; + + /*! Custom study, using for open/close of documents HDF format. Data of each module can be saved to different files, those @@ -73,6 +92,17 @@ public: virtual QString getVisualComponentName() const; + virtual void setObjectProperty ( int theViewMgrId, QString theEntry, QString thePropName, QVariant theValue ); + virtual QVariant getObjectProperty ( int theViewMgrId, QString theEntry, QString thePropName, QVariant theDefValue ) const; + virtual void removeViewMgr ( int theViewMgrId ); + virtual void setObjectPropMap ( int theViewMgrId, QString theEntry, PropMap thePropMap ); + virtual const PropMap& getObjectPropMap ( int theViewMgrId, QString theEntry ) ; + virtual void removeObjectFromAll( QString theEntry ); + virtual const ObjMap& getObjectMap ( int theViewMgrId ); + virtual const ViewMgrMap& getViewMgrMap ( int theViewMgrId ) { return myViewMgrMap; }; + + + protected: virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles ); @@ -97,6 +127,7 @@ signals: private: LightApp_Driver* myDriver; + ViewMgrMap myViewMgrMap; friend class LightApp_Application; }; diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 9006a49ff..47d0fde74 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -983,3 +983,12 @@ void STD_Application::studySaved( SUIT_Study* ) updateDesktopTitle(); updateCommandsStatus(); } + +/*! + Return index of the view ma +*/ +int STD_Application::viewManagerId( const SUIT_ViewManager* theManager) const +{ + return myViewMgrs.indexOf(const_cast(theManager)); +} + diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index a8e5dea33..286246ca7 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -86,6 +86,7 @@ public: ViewManagerList viewManagers() const; void viewManagers( ViewManagerList& ) const; void viewManagers( const QString&, ViewManagerList& ) const; + virtual int viewManagerId (const SUIT_ViewManager* ) const; virtual QString getFileFilter() const { return QString(); } virtual QString getFileName( bool open, const QString& initial, const QString& filters, diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index 3773977fc..86c1d5a80 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -35,7 +35,7 @@ class QAction; class QWidget; class SUIT_Desktop; -class SUIT_ViewModel; +class SUIT_ViewManager; class SUIT_ResourceMgr; class SUIT_ShortcutMgr; class SUIT_Study; @@ -110,6 +110,9 @@ public: //! Invokes application-specific "Select Directory" dialog and returns the selected directory name. virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0; + + virtual int viewManagerId ( const SUIT_ViewManager* ) const = 0; + signals: void applicationClosed( SUIT_Application* ); void activated( SUIT_Application* ); diff --git a/src/SUIT/SUIT_ViewManager.cxx b/src/SUIT/SUIT_ViewManager.cxx index 1e55aecef..0ab6a11af 100755 --- a/src/SUIT/SUIT_ViewManager.cxx +++ b/src/SUIT/SUIT_ViewManager.cxx @@ -26,6 +26,7 @@ #include "SUIT_ViewModel.h" #include "SUIT_ViewWindow.h" #include "SUIT_Study.h" +#include "SUIT_Session.h" #include #include @@ -84,6 +85,16 @@ int SUIT_ViewManager::useNewId( const QString& type ) return id; } + +int SUIT_ViewManager::getGlobalId() const { + int id = -1; + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if(app) { + id = app->viewManagerId(this); + } + return id; +} + void SUIT_ViewManager::setTitle( const QString& theTitle ) { if ( myTitle == theTitle ) diff --git a/src/SUIT/SUIT_ViewManager.h b/src/SUIT/SUIT_ViewManager.h index 07c8ca8bf..7846fcdcf 100755 --- a/src/SUIT/SUIT_ViewManager.h +++ b/src/SUIT/SUIT_ViewManager.h @@ -83,6 +83,8 @@ public: int getId() const; + int getGlobalId() const; + public slots: void createView(); void closeAllViews();