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>
32 #include <LightApp_DataModel.h>
34 #include <SUIT_TreeModel.h>
37 class SUIT_DataObject;
38 class HYDROGUI_DataObject;
41 * \class HYDROGUI_DataModel
42 * \brief The class representing the HYDROGUI data model
44 class HYDROGUI_DataModel : public LightApp_DataModel, public SUIT_DataSearcher
49 * \param theModule module object
51 HYDROGUI_DataModel( CAM_Module* theModule );
52 virtual ~HYDROGUI_DataModel();
55 * Open the document into the data model. Reimplemented.
56 * \param theURL opened study path
57 * \param theStudy object study
58 * \param theFileList list of opened files for this model.
60 virtual bool open( const QString& theURL,
62 QStringList theFileList );
65 * Saves the document. Reimplemented.
66 * \param returned theFileList list of saved files of this model.
68 virtual bool save( QStringList& theFileList );
71 * Saves as the document. Reimplemented.
72 * \param theURL saved study path
73 * \param theStudy object study
74 * \param returned theFileList list of saved files of this model.
76 virtual bool saveAs( const QString& theURL,
78 QStringList& theFileList );
81 * Close the model and remove data. Reimplemented.
86 * Dump study data to Python script. Reimplemented.
88 virtual bool dumpPython( const QString& theURL,
91 QStringList& theListOfFiles );
94 * Returns modification status. Reimplemented.
95 * \return boolean value of modification status
97 virtual bool isModified() const;
100 * Returns saving status. Reimplemented.
101 * \return true if document has saved files on disc.
103 virtual bool isSaved() const;
106 * Updates the internal structure of data object tree.
107 * \param theStudyId study identifier
109 virtual void update( const int theStudyId );
112 * Returns data object corresponding to the model object.
113 * \param the data model object
114 * \return the only one object referenced to the given data model object, or null if not found
116 virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Entity)& theModelObject );
119 * Returns a data object referenced to the given data object.
120 * \param the data object
121 * \return the object referenced to the given object, or null if not found
123 virtual HYDROGUI_DataObject* getReferencedDataObject( HYDROGUI_DataObject* theObject );
126 * Finds the object by entry
127 * \param theEntry an object entry
129 virtual SUIT_DataObject* findObject( const QString& theEntry ) const;
132 * Updates the internal structure of data object tree starting from specified data object \a obj.
133 * \param theObject start data object
134 * \param theStudy study object
136 virtual void update( LightApp_DataObject* theObject = 0,
137 LightApp_Study* theStudy = 0 );
140 * Creates a module object and set is a root for the model
142 CAM_DataObject* createRootModuleObject( SUIT_DataObject* theParent );
145 * Correct an internal model object according to the current document mode
150 * Find a data object by the specified entry and kind
152 Handle(HYDROData_Entity) objectByEntry( const QString& theEntry,
153 const ObjectKind theObjectKind = KIND_UNKNOWN );
156 * Check if it is possible to perform 'undo' operation
158 bool canUndo() const;
161 * Check if it is possible to perform 'redo' operation
163 bool canRedo() const;
166 * Returns the list of names of available 'undo' actions
168 QStringList undoNames() const;
171 * Returns the list of names of available 'redo' actions
173 QStringList redoNames() const;
176 * Clear the list of stored 'undo' actions
181 * Clear the list of stored 'redo' actions
186 * Perform the 'undo' operation
191 * Perform the 'redo' operation
196 * Check if it is possible to perform 'copy' operation
201 * Check if it is possible to perform 'paste' operation
206 * Perform the 'copy' operation
211 * Perform the 'paste' operation
216 * Update the sequence of the objects to be copied
218 static void changeCopyingObjects( const HYDROData_SequenceOfObjects& );
221 * Returns name of the partition containing the objects of the specified kind
222 * \param theObjectKind kind of objects
223 * \return partition name
225 static QString partitionName( const ObjectKind theObjectKind );
228 * Returns the document for the current study
230 Handle(HYDROData_Document) getDocument() const;
233 * Creates the GUI data object according to the model object.
234 * \param theParent a created object will be appended as a child of this object
235 * \param theModelObject model object
236 * \param theParentEntry entry of parent object
238 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
239 Handle(HYDROData_Entity) theModelObject,
240 const QString& theParentEntry = QString(),
241 const bool theIsBuildTree = true );
245 * Creates the GUI data object without corresponding model object: just by name
246 * \param theParent a created object will be appended as a child of this object
247 * \param theName name of this object
248 * \param theParentEntry entry of parent object
250 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
251 const QString& theName,
252 const QString& theParentEntry = QString() );
255 * Build object tree if the flag theIsBuildTree is true.
256 * This is a conditional wrapper for buildObjectTree method.
257 * \param theParent a created object will be appended as a child of this object
258 * \param theObject the GUI object
259 * \param theParentEntry the entry of parent object
260 * \param theIsBuildTree if true then build the subtree of the GUI object
262 LightApp_DataObject* buildObject( SUIT_DataObject* theParent,
263 HYDROGUI_DataObject* theObject,
264 const QString& theParentEntry,
265 const bool theIsBuildTree );
267 LightApp_DataObject* createZone( SUIT_DataObject* theParent,
268 Handle(HYDROData_Zone) theModelObject,
269 const QString& theParentEntry,
270 const bool theIsBuildTree );
272 LightApp_DataObject* createRegion( SUIT_DataObject* theParent,
273 Handle(HYDROData_Region) theModelObject,
274 const QString& theParentEntry,
275 const bool theIsBuildTree );
277 * Build tree of model object.
278 * \param theParent a created object will be appended as a child of this object
279 * \param theObject gui object for which the tree will be build
280 * \param theParentEntry entry of parent object
282 void buildObjectTree( SUIT_DataObject* theParent,
283 SUIT_DataObject* theObject,
284 const QString& theParentEntry = QString() );
287 * Removes data object from the tree.
288 * \param theParent an object will be removed from this parent.
289 * \param theChild the removed object.
291 void removeChild( SUIT_DataObject* theParent,
292 SUIT_DataObject* theChild );
295 * Returns the first child of the object with the specified name
296 * \param theFather object that contain the searched object in children
297 * \param theName name f the searched data object
298 * \returns NULL if not found
300 static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
301 const QString& theName );
304 QString myStudyURL; ///< the saved/opened document URL