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
226 bool rename( Handle(HYDROData_Entity) theEntity, const QString& theName );
229 * Creates the Calculation Case subtree for usage within an operation dialog.
230 * \param theParent a created object will be appended as a child of this GUI object
231 * \param theCase the calculation case model object
233 void buildCaseTree( SUIT_DataObject* theParent,
234 Handle(HYDROData_CalculationCase) theCase );
237 * Updates the object subtree.
238 * \param theObj the data model entity
240 void updateObjectTree( Handle(HYDROData_Entity)& theObj );
243 * Update the sequence of the objects to be copied
245 static void changeCopyingObjects( const HYDROData_SequenceOfObjects& );
248 * Returns name of the partition containing the objects of the specified kind
249 * \param theObjectKind kind of objects
250 * \return partition name
252 static QString partitionName( const ObjectKind theObjectKind );
256 * Returns the document for the current study
258 Handle(HYDROData_Document) getDocument() const;
261 * Creates the GUI data object according to the model object.
262 * \param theParent a created object will be appended as a child of this object
263 * \param theModelObject model object
264 * \param theParentEntry entry of parent object
266 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
267 Handle(HYDROData_Entity) theModelObject,
268 const QString& theParentEntry = QString(),
269 const bool theIsBuildTree = true );
272 * Creates the GUI data object without corresponding model object: just by name
273 * \param theParent a created object will be appended as a child of this object
274 * \param theName name of this object
275 * \param theParentEntry entry of parent object
277 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
278 const QString& theName,
279 const QString& theParentEntry = QString() );
282 * Build object tree if the flag theIsBuildTree is true.
283 * This is a conditional wrapper for buildObjectTree method.
284 * \param theParent a created object will be appended as a child of this object
285 * \param theObject the GUI object
286 * \param theParentEntry the entry of parent object
287 * \param theIsBuildTree if true then build the subtree of the GUI object
288 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
290 LightApp_DataObject* buildObject( SUIT_DataObject* theParent,
291 HYDROGUI_DataObject* theObject,
292 const QString& theParentEntry,
293 const bool theIsBuildTree,
294 const bool theIsInOperation = false );
297 * Build object tree if the flag theIsBuildTree is true.
298 * \param theParent a created object will be appended as a child of this GUI object
299 * \param theModelObject the data model zone object
300 * \param theParentEntry the entry of parent object
301 * \param theIsBuildTree if true then build the subtree of the GUI object
302 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
304 LightApp_DataObject* createZone( SUIT_DataObject* theParent,
305 Handle(HYDROData_Zone) theModelObject,
306 const QString& theParentEntry,
307 const bool theIsBuildTree ,
308 const bool theIsInOperation = false );
311 * Build object tree if the flag theIsBuildTree is true.
312 * \param theParent a created object will be appended as a child of this GUI object
313 * \param theModelObject the data model region object
314 * \param theParentEntry the entry of parent object
315 * \param theIsBuildTree if true then build the subtree of the GUI object
316 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
318 LightApp_DataObject* createRegion( SUIT_DataObject* theParent,
319 Handle(HYDROData_Region) theModelObject,
320 const QString& theParentEntry,
321 const bool theIsBuildTree ,
322 const bool theIsInOperation = false );
324 * Build tree of a model object.
325 * \param theParent a created object will be appended as a child of this object
326 * \param theObject gui object for which the tree will be build
327 * \param theParentEntry entry of parent object
328 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
330 void buildObjectTree( SUIT_DataObject* theParent,
331 SUIT_DataObject* theObject,
332 const QString& theParentEntry = QString(),
333 const bool theIsInOperation = false );
336 * Removes data object from the tree.
337 * \param theParent an object will be removed from this parent.
338 * \param theChild the removed object.
340 void removeChild( SUIT_DataObject* theParent,
341 SUIT_DataObject* theChild );
344 * Returns the first child of the object with the specified name
345 * \param theFather object that contain the searched object in children
346 * \param theName name f the searched data object
347 * \returns NULL if not found
349 static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
350 const QString& theName );
353 QString myStudyURL; ///< the saved/opened document URL