1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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
24 #ifndef HYDROGUI_DATAMODEL_H
25 #define HYDROGUI_DATAMODEL_H
27 #include <HYDROData_Document.h>
28 #include <HYDROData_Entity.h>
29 #include <HYDROData_Zone.h>
30 #include <HYDROData_Region.h>
31 #include <HYDROData_CalculationCase.h>
35 #include <LightApp_DataModel.h>
37 #include <SUIT_TreeModel.h>
40 class SUIT_DataObject;
41 class HYDROGUI_DataObject;
45 * \class HYDROGUI_DataModel
46 * \brief The class representing the HYDROGUI data model
48 class HYDROGUI_DataModel : public LightApp_DataModel, public SUIT_DataSearcher
53 * \param theModule module object
55 HYDROGUI_DataModel( CAM_Module* theModule );
56 virtual ~HYDROGUI_DataModel();
59 * Open the document into the data model. Reimplemented.
60 * \param theURL opened study path
61 * \param theStudy object study
62 * \param theFileList list of opened files for this model.
64 virtual bool open( const QString& theURL,
66 QStringList theFileList );
69 * Saves the document. Reimplemented.
70 * \param returned theFileList list of saved files of this model.
72 virtual bool save( QStringList& theFileList );
75 * Saves as the document. Reimplemented.
76 * \param theURL saved study path
77 * \param theStudy object study
78 * \param returned theFileList list of saved files of this model.
80 virtual bool saveAs( const QString& theURL,
82 QStringList& theFileList );
85 * Close the model and remove data. Reimplemented.
90 * Dump study data to Python script. Reimplemented.
92 virtual bool dumpPython( const QString& theURL,
95 QStringList& theListOfFiles );
98 * Returns modification status. Reimplemented.
99 * \return boolean value of modification status
101 virtual bool isModified() const;
104 * Returns saving status. Reimplemented.
105 * \return true if document has saved files on disc.
107 virtual bool isSaved() const;
110 * Updates the internal structure of data object tree.
111 * \param theStudyId study identifier
113 virtual void update( const int theStudyId );
116 * Returns data object corresponding to the model object.
117 * \param the data model object
118 * \return the only one object referenced to the given data model object, or null if not found
120 virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Entity)& theModelObject );
123 * Returns a data object referenced to the given data object.
124 * \param the data object
125 * \return the object referenced to the given object, or null if not found
127 virtual HYDROGUI_DataObject* getReferencedDataObject( HYDROGUI_DataObject* theObject );
130 * Finds the object by entry
131 * \param theEntry an object entry
133 virtual SUIT_DataObject* findObject( const QString& theEntry ) const;
136 * Updates the internal structure of data object tree starting from specified data object \a obj.
137 * \param theObject start data object
138 * \param theStudy study object
140 virtual void update( LightApp_DataObject* theObject = 0,
141 LightApp_Study* theStudy = 0 );
144 * Creates a module object and set is a root for the model
146 CAM_DataObject* createRootModuleObject( SUIT_DataObject* theParent );
149 * Create a new region in the given calculation case containing given zones.
151 bool createNewRegion( Handle(HYDROData_CalculationCase) theCase, const QList<HYDROGUI_Zone*>& theZonesList );
154 * Correct an internal model object according to the current document mode
159 * Find a data object by the specified entry and kind
161 Handle(HYDROData_Entity) objectByEntry( const QString& theEntry,
162 const ObjectKind theObjectKind = KIND_UNKNOWN );
165 * Check if it is possible to perform 'undo' operation
167 bool canUndo() const;
170 * Check if it is possible to perform 'redo' operation
172 bool canRedo() const;
175 * Returns the list of names of available 'undo' actions
177 QStringList undoNames() const;
180 * Returns the list of names of available 'redo' actions
182 QStringList redoNames() const;
185 * Clear the list of stored 'undo' actions
190 * Clear the list of stored 'redo' actions
195 * Perform the 'undo' operation
200 * Perform the 'redo' operation
205 * Check if it is possible to perform 'copy' operation
210 * Check if it is possible to perform 'paste' operation
215 * Perform the 'copy' operation
220 * Perform the 'paste' operation
227 bool rename( Handle(HYDROData_Entity) theEntity, const QString& theName );
230 * Creates the Calculation Case subtree for usage within an operation dialog.
231 * \param theParent a created object will be appended as a child of this GUI object
232 * \param theCase the calculation case model object
234 void buildCaseTree( SUIT_DataObject* theParent,
235 Handle(HYDROData_CalculationCase) theCase );
238 * Updates the object subtree.
239 * \param theObj the data model entity
241 void updateObjectTree( Handle(HYDROData_Entity)& theObj );
244 * Update the sequence of the objects to be copied
246 static void changeCopyingObjects( const HYDROData_SequenceOfObjects& );
249 * Returns name of the partition containing the objects of the specified kind
250 * \param theObjectKind kind of objects
251 * \return partition name
253 static QString partitionName( const ObjectKind theObjectKind );
257 * Returns the document for the current study
259 Handle(HYDROData_Document) getDocument() const;
262 * Creates the GUI data object according to the model object.
263 * \param theParent a created object will be appended as a child of this object
264 * \param theModelObject model object
265 * \param theParentEntry entry of parent object
267 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
268 Handle(HYDROData_Entity) theModelObject,
269 const QString& theParentEntry = QString(),
270 const bool theIsBuildTree = true );
273 * Creates the GUI data object without corresponding model object: just by name
274 * \param theParent a created object will be appended as a child of this object
275 * \param theName name of this object
276 * \param theParentEntry entry of parent object
278 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
279 const QString& theName,
280 const QString& theParentEntry = QString() );
283 * Build object tree if the flag theIsBuildTree is true.
284 * This is a conditional wrapper for buildObjectTree method.
285 * \param theParent a created object will be appended as a child of this object
286 * \param theObject the GUI object
287 * \param theParentEntry the entry of parent object
288 * \param theIsBuildTree if true then build the subtree of the GUI object
289 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
291 LightApp_DataObject* buildObject( SUIT_DataObject* theParent,
292 HYDROGUI_DataObject* theObject,
293 const QString& theParentEntry,
294 const bool theIsBuildTree,
295 const bool theIsInOperation = false );
298 * Build object tree if the flag theIsBuildTree is true.
299 * \param theParent a created object will be appended as a child of this GUI object
300 * \param theModelObject the data model zone object
301 * \param theParentEntry the entry of parent object
302 * \param theIsBuildTree if true then build the subtree of the GUI object
303 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
305 LightApp_DataObject* createZone( SUIT_DataObject* theParent,
306 Handle(HYDROData_Zone) theModelObject,
307 const QString& theParentEntry,
308 const bool theIsBuildTree ,
309 const bool theIsInOperation = false );
312 * Build object tree if the flag theIsBuildTree is true.
313 * \param theParent a created object will be appended as a child of this GUI object
314 * \param theModelObject the data model region object
315 * \param theParentEntry the entry of parent object
316 * \param theIsBuildTree if true then build the subtree of the GUI object
317 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
319 LightApp_DataObject* createRegion( SUIT_DataObject* theParent,
320 Handle(HYDROData_Region) theModelObject,
321 const QString& theParentEntry,
322 const bool theIsBuildTree ,
323 const bool theIsInOperation = false );
325 * Build partition for object.
326 * \param theObject gui object for which the partition will be build
327 * \param theObjects sequence of builded objects
328 * \param thePartName name of created partition
329 * \param theIsCreateEmpty if true then partition will be created in any case
331 void buildObjectPartition( SUIT_DataObject* theObject,
332 const HYDROData_SequenceOfObjects& theObjects,
333 const QString& thePartName,
334 const bool theIsCreateEmpty );
337 * Build tree of a model object.
338 * \param theParent a created object will be appended as a child of this object
339 * \param theObject gui object for which the tree will be build
340 * \param theParentEntry entry of parent object
341 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
343 void buildObjectTree( SUIT_DataObject* theParent,
344 SUIT_DataObject* theObject,
345 const QString& theParentEntry = QString(),
346 const bool theIsInOperation = false );
349 * Removes data object from the tree.
350 * \param theParent an object will be removed from this parent.
351 * \param theChild the removed object.
353 void removeChild( SUIT_DataObject* theParent,
354 SUIT_DataObject* theChild );
357 * Returns the first child of the object with the specified name
358 * \param theFather object that contain the searched object in children
359 * \param theName name f the searched data object
360 * \returns NULL if not found
362 static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
363 const QString& theName );
366 QString myStudyURL; ///< the saved/opened document URL