Salome HOME
[bos#35161][EDF](2023-T1) Automatic backup - initial commit
[modules/gui.git] / src / LightApp / LightApp_Study.h
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef LIGHTAPP_STUDY_H
24 #define LIGHTAPP_STUDY_H
25
26 #include "LightApp.h"
27 #include "LightApp_Driver.h"
28
29 #include <CAM_Study.h>
30
31 #include "string"
32 #include "vector"
33 #include <Qtx.h>
34
35 #include <QMap>
36 #include <QVariant>
37
38 class SUIT_Study;
39 class SUIT_Application;
40 class CAM_DataModel;
41 class CAM_ModuleObject;
42 class LightApp_DataObject;
43 class LightApp_DataModel;
44
45 //Map to store visual property of the object.
46 //Key:   Name of the visual property of the object.
47 //Value: value of the visual property.
48 typedef QMap<QString, QVariant> PropMap;
49
50 //Map to store objects with it's visual properties.
51 //Key:   Entry of the object.
52 //Value: Map of the visual properties of the object.
53 typedef QMap<QString, PropMap> ObjMap;
54
55 //Map to store view managers and all objects which displayed in views of the view managers.
56 //Key:   Id of the viewer.
57 //Value: Map of the objects with it's visual properties.
58 typedef QMap<int, ObjMap> ViewMgrMap;
59
60
61 /*!
62   Custom study, using for open/close of documents HDF format.
63   Data of each module can be saved to different files, those 
64   after that are combined into one HDF file
65 */
66 class LIGHTAPP_EXPORT LightApp_Study : public CAM_Study
67 {
68   Q_OBJECT
69
70 public:
71   LightApp_Study( SUIT_Application* );
72   virtual ~LightApp_Study();
73
74   virtual bool        createDocument( const QString& );
75   virtual bool        openDocument( const QString& );
76   virtual bool        loadDocument( const QString& ); 
77
78   virtual bool        saveDocument();
79   virtual bool        saveDocumentAs( const QString& , bool isBackup=false );
80
81   virtual void        closeDocument(bool permanently = true);
82
83   virtual bool        dump( const QString&, bool, bool, bool ) { return false; }
84
85   virtual bool        isSaved()  const;
86   virtual bool        isModified() const;
87
88   virtual void        addComponent   ( const CAM_DataModel* dm);
89
90   virtual std::string GetTmpDir      ( const char* theURL, const bool  isMultiFile );
91
92   virtual QString     componentDataType( const QString& ) const;
93   virtual QString     referencedToEntry( const QString& ) const;
94   virtual bool        isComponent( const QString& ) const;
95   virtual void        children( const QString&, QStringList& ) const;
96   virtual void        components( QStringList& ) const;
97   virtual QString     centry( const QString& ) const;
98
99   virtual QString     getVisualComponentName() const;
100
101   virtual void              setObjectProperty( int, const QString&, const QString&, const QVariant& );
102   virtual void              setObjectProperty( const QString&, const QString&, const QVariant& );
103   virtual void              setObjectProperty( int, const QString&, const QVariant& );
104   virtual void              setObjectProperties( int, const QString&, const PropMap& );
105   virtual QVariant          getObjectProperty( int, const QString&, const QString&, const QVariant& ) const;
106   virtual const PropMap&    getObjectProperties( int, const QString& );
107   virtual const ObjMap&     getObjectProperties( int );
108   virtual const ViewMgrMap& getObjectProperties() const;
109   virtual void              removeObjectProperties( int );
110   virtual void              removeObjectProperties( const QString& );
111
112   virtual void                  setVisibilityState(const QString& theEntry, Qtx::VisibilityState theState);
113   virtual Qtx::VisibilityState  visibilityState(const QString& theEntry) const;
114   virtual void                  setVisibilityStateForAll(Qtx::VisibilityState theState);
115
116   virtual LightApp_DataObject* findObjectByEntry( const QString& theEntry );
117
118 protected:
119   virtual void        saveModuleData ( QString theModuleName, int type, QStringList theListOfFiles );
120   virtual void        openModuleData ( QString theModuleName, int type, QStringList& theListOfFiles );
121   virtual bool        saveStudyData  ( const QString& theFileName, int type );
122   virtual bool        openStudyData  ( const QString& theFileName, int type );
123
124   virtual std::vector<std::string> GetListOfFiles ( const char* theModuleName, int type ) const;
125   virtual void        SetListOfFiles ( const char* theModuleName, int type,
126                                        const std::vector<std::string> theListOfFiles );
127
128   virtual void        RemoveTemporaryFiles ( const char*, bool, bool = false );
129
130 protected:
131   virtual bool        openDataModel  ( const QString&, CAM_DataModel* );
132   virtual CAM_ModuleObject* createModuleObject( LightApp_DataModel* theDataModel, 
133                                                 SUIT_DataObject* theParent ) const;
134
135 signals:
136   void                saved  ( SUIT_Study* );
137   void                opened ( SUIT_Study* );
138   void                closed ( SUIT_Study* );
139   void                created( SUIT_Study* );
140
141   void                objVisibilityChanged( QString, Qtx::VisibilityState );
142
143
144 private:
145   LightApp_Driver*    myDriver;
146   ViewMgrMap          myViewMgrMap;
147
148   friend class LightApp_Application;
149   friend class LightApp_DataModel;
150 };
151
152 #endif