1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef HYDROGUI_DATAMODEL_H
24 #define HYDROGUI_DATAMODEL_H
26 #include <HYDROData_Document.h>
27 #include <HYDROData_Entity.h>
28 #include <HYDROData_Zone.h>
29 #include <HYDROData_Region.h>
30 #include <HYDROData_CalculationCase.h>
34 #include <LightApp_DataModel.h>
36 #include <SUIT_TreeModel.h>
39 class SUIT_DataObject;
40 class HYDROGUI_DataObject;
44 * \class HYDROGUI_DataModel
45 * \brief The class representing the HYDROGUI data model
47 class HYDROGUI_DataModel : public LightApp_DataModel, public SUIT_DataSearcher
52 * \param theModule module object
54 HYDROGUI_DataModel( CAM_Module* theModule );
55 virtual ~HYDROGUI_DataModel();
58 * Open the document into the data model. Reimplemented.
59 * \param theURL opened study path
60 * \param theStudy object study
61 * \param theFileList list of opened files for this model.
63 virtual bool open( const QString& theURL,
65 QStringList theFileList );
68 * Saves the document. Reimplemented.
69 * \param returned theFileList list of saved files of this model.
71 virtual bool save( QStringList& theFileList );
74 * Saves as the document. Reimplemented.
75 * \param theURL saved study path
76 * \param theStudy object study
77 * \param returned theFileList list of saved files of this model.
79 virtual bool saveAs( const QString& theURL,
81 QStringList& theFileList );
84 * Close the model and remove data. Reimplemented.
89 * Dump study data to Python script. Reimplemented.
91 virtual bool dumpPython( const QString& theURL,
94 QStringList& theListOfFiles );
97 * Returns modification status. Reimplemented.
98 * \return boolean value of modification status
100 virtual bool isModified() const;
103 * Returns saving status. Reimplemented.
104 * \return true if document has saved files on disc.
106 virtual bool isSaved() const;
109 * Updates the internal structure of data object tree.
110 * \param theStudyId study identifier
112 virtual void update( const int theStudyId );
115 * Returns data object corresponding to the model object.
116 * \param the data model object
117 * \return the only one object referenced to the given data model object, or null if not found
119 virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Entity)& theModelObject );
122 * Returns a data object referenced to the given data object.
123 * \param the data object
124 * \return the object referenced to the given object, or null if not found
126 virtual HYDROGUI_DataObject* getReferencedDataObject( HYDROGUI_DataObject* theObject );
129 * Finds the object by entry
130 * \param theEntry an object entry
132 virtual SUIT_DataObject* findObject( const QString& theEntry ) const;
135 * Updates the internal structure of data object tree starting from specified data object \a obj.
136 * \param theObject start data object
137 * \param theStudy study object
139 virtual void update( LightApp_DataObject* theObject = 0,
140 LightApp_Study* theStudy = 0 );
143 * Creates a module object and set is a root for the model
145 CAM_DataObject* createRootModuleObject( SUIT_DataObject* theParent );
148 * Create a new region in the given calculation case containing given zones.
150 bool createNewRegion( Handle(HYDROData_CalculationCase) theCase, const QList<HYDROGUI_Zone*>& theZonesList );
153 * Correct an internal model object according to the current document mode
158 * Find a data object by the specified entry and kind
160 Handle(HYDROData_Entity) objectByEntry( const QString& theEntry,
161 const ObjectKind theObjectKind = KIND_UNKNOWN );
164 * Check if it is possible to perform 'undo' operation
166 bool canUndo() const;
169 * Check if it is possible to perform 'redo' operation
171 bool canRedo() const;
174 * Returns the list of names of available 'undo' actions
176 QStringList undoNames() const;
179 * Returns the list of names of available 'redo' actions
181 QStringList redoNames() const;
184 * Clear the list of stored 'undo' actions
189 * Clear the list of stored 'redo' actions
194 * Perform the 'undo' operation
199 * Perform the 'redo' operation
204 * Check if it is possible to perform 'copy' operation
209 * Check if it is possible to perform 'paste' operation
214 * Perform the 'copy' operation
219 * Perform the 'paste' operation
224 * Creates the GUI data object according to the model object.
225 * \param theParent a created object will be appended as a child of this object
226 * \param theModelObject model object
227 * \param theParentEntry entry of parent object
229 void buildCaseTree( SUIT_DataObject* theParent,
230 Handle(HYDROData_CalculationCase) theCase );
233 * Update the sequence of the objects to be copied
235 static void changeCopyingObjects( const HYDROData_SequenceOfObjects& );
238 * Returns name of the partition containing the objects of the specified kind
239 * \param theObjectKind kind of objects
240 * \return partition name
242 static QString partitionName( const ObjectKind theObjectKind );
246 * Returns the document for the current study
248 Handle(HYDROData_Document) getDocument() const;
251 * Creates the GUI data object according to the model object.
252 * \param theParent a created object will be appended as a child of this object
253 * \param theModelObject model object
254 * \param theParentEntry entry of parent object
256 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
257 Handle(HYDROData_Entity) theModelObject,
258 const QString& theParentEntry = QString(),
259 const bool theIsBuildTree = true );
262 * Creates the GUI data object without corresponding model object: just by name
263 * \param theParent a created object will be appended as a child of this object
264 * \param theName name of this object
265 * \param theParentEntry entry of parent object
267 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
268 const QString& theName,
269 const QString& theParentEntry = QString() );
272 * Build object tree if the flag theIsBuildTree is true.
273 * This is a conditional wrapper for buildObjectTree method.
274 * \param theParent a created object will be appended as a child of this object
275 * \param theObject the GUI object
276 * \param theParentEntry the entry of parent object
277 * \param theIsBuildTree if true then build the subtree of the GUI object
279 LightApp_DataObject* buildObject( SUIT_DataObject* theParent,
280 HYDROGUI_DataObject* theObject,
281 const QString& theParentEntry,
282 const bool theIsBuildTree );
284 LightApp_DataObject* createZone( SUIT_DataObject* theParent,
285 Handle(HYDROData_Zone) theModelObject,
286 const QString& theParentEntry,
287 const bool theIsBuildTree );
289 LightApp_DataObject* createRegion( SUIT_DataObject* theParent,
290 Handle(HYDROData_Region) theModelObject,
291 const QString& theParentEntry,
292 const bool theIsBuildTree );
294 * Build tree of model object.
295 * \param theParent a created object will be appended as a child of this object
296 * \param theObject gui object for which the tree will be build
297 * \param theParentEntry entry of parent object
299 void buildObjectTree( SUIT_DataObject* theParent,
300 SUIT_DataObject* theObject,
301 const QString& theParentEntry = QString() );
304 * Removes data object from the tree.
305 * \param theParent an object will be removed from this parent.
306 * \param theChild the removed object.
308 void removeChild( SUIT_DataObject* theParent,
309 SUIT_DataObject* theChild );
312 * Returns the first child of the object with the specified name
313 * \param theFather object that contain the searched object in children
314 * \param theName name f the searched data object
315 * \returns NULL if not found
317 static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
318 const QString& theName );
321 QString myStudyURL; ///< the saved/opened document URL