]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_DataModel.h
Salome HOME
84a07b79de8a1f3f01be76e789cd1bd864b3ac66
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataModel.h
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, 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.
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 HYDROGUI_DATAMODEL_H
24 #define HYDROGUI_DATAMODEL_H
25
26 #include <HYDROData_Object.h>
27
28 #include <QMap>
29 #include <LightApp_DataModel.h>
30
31 #include <SUIT_TreeModel.h>
32
33 class CAM_DataObject;
34 class SUIT_DataObject;
35 class HYDROGUI_DataObject;
36
37 /**
38  * \class HYDROGUI_DataModel
39  * \brief The class representing the HYDROGUI data model
40  */
41 class HYDROGUI_DataModel : public LightApp_DataModel, public SUIT_DataSearcher
42 {
43 public:
44   /**
45    * Constructor.
46    * \param theModule module object
47    */
48   HYDROGUI_DataModel( CAM_Module* theModule );
49   virtual ~HYDROGUI_DataModel();
50
51   /**
52    * Open the document into the data model. Reimplemented.
53    * \param theURL opened study path
54    * \param theStudy object study
55    * \param theFileList list of opened files for this model.
56    */
57   virtual bool open( const QString& theURL,
58                      CAM_Study* theStudy,
59                      QStringList theFileList );
60
61   /**
62    * Saves the document. Reimplemented.
63    * \param returned theFileList list of saved files of this model.
64    */
65   virtual bool save( QStringList& theFileList );
66
67   /**
68    * Saves as the document. Reimplemented.
69    * \param theURL saved study path
70    * \param theStudy object study
71    * \param returned theFileList list of saved files of this model.
72    */
73   virtual bool saveAs( const QString& theURL,
74                        CAM_Study* theStudy,
75                        QStringList& theFileList );
76
77   /**
78    * Close the model and remove data. Reimplemented.
79    */
80   virtual bool close();
81
82   /**
83    * Returns modification status. Reimplemented.
84    * \return boolean value of modification status
85    */
86   virtual bool isModified() const;
87
88   /**
89    * Returns saving status. Reimplemented.
90    * \return true if document has saved files on disc.
91    */
92   virtual bool isSaved() const;
93
94   /**
95    * Updates the internal structure of data object tree.
96    * \param theStudyId study identifier
97    */
98   virtual void update( const int theStudyId );
99
100   /**
101    * Returns data object corresponding to the model object.
102    * \param the data model object
103    * \returns the only one object referenced to the given data model object, or null if not found
104    */
105   virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Object)& theModelObject );
106
107   /**
108    * Returns a data object referenced to the given data object.
109    * \param the data object
110    * \returns the object referenced to the given object, or null if not found
111    */
112   virtual HYDROGUI_DataObject* getReferencedDataObject( HYDROGUI_DataObject* theObject );
113
114   /**
115    * Finds the object by entry
116    * \param theEntry an object entry
117    */
118   virtual SUIT_DataObject* findObject( const QString& theEntry ) const;
119
120   /**
121    * Updates the internal structure of data object tree starting from specified data object \a obj.
122    * \param theObject start data object
123    * \param theStudy study object
124    */
125   virtual void update( LightApp_DataObject* theObject = 0,
126                        LightApp_Study* theStudy = 0 );
127
128   /**
129    * Creates a module object and set is a root for the model
130    */
131   CAM_DataObject* createRootModuleObject( SUIT_DataObject* theParent );
132
133   /**
134    * Correct an internal model object according to the current document mode
135    */
136   void updateModel();
137
138   /**
139    * Find a data object by the specified entry and kind
140    */
141   Handle(HYDROData_Object) objectByEntry( const QString& theEntry,
142                                           const ObjectKind theObjectKind );
143
144 protected:
145   /**
146    * Creates the GUI data object according to the model object.
147    * \param theParent a created object will be appended as a child of this object
148    * \param theObject model object
149    */
150   LightApp_DataObject* createObject( SUIT_DataObject* theParent,
151                                      Handle(HYDROData_Object) theModelObject );
152
153   /**
154    * Creates the GUI data object without corresponding model object: just by name
155    * \param theParent a created object will be appended as a child of this object
156    * \param theName name of this object
157    */
158   LightApp_DataObject* createObject( SUIT_DataObject* theParent,
159                                      const QString& theName );
160
161   /**
162    * Removes data object from the tree.
163    * \param theParent an object will be removed from this parent.
164    * \param theChild the removed object.
165    */
166   void removeChild( SUIT_DataObject* theParent,
167                     SUIT_DataObject* theChild );
168
169   /**
170    * Returns the first child of the object with the specified name
171    * \param theFather object that contain the searched object in children
172    * \param theName name f the searched data object
173    * \returns NULL if not found
174    */
175   static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
176                                            const QString& theName );
177
178 protected:
179   QString myStudyURL; ///< the saved/opened document URL
180 };
181
182 #endif