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_Object.h>
30 #include <LightApp_DataModel.h>
32 #include <SUIT_TreeModel.h>
35 class SUIT_DataObject;
36 class HYDROGUI_DataObject;
39 * \class HYDROGUI_DataModel
40 * \brief The class representing the HYDROGUI data model
42 class HYDROGUI_DataModel : public LightApp_DataModel, public SUIT_DataSearcher
47 * \param theModule module object
49 HYDROGUI_DataModel( CAM_Module* theModule );
50 virtual ~HYDROGUI_DataModel();
53 * Open the document into the data model. Reimplemented.
54 * \param theURL opened study path
55 * \param theStudy object study
56 * \param theFileList list of opened files for this model.
58 virtual bool open( const QString& theURL,
60 QStringList theFileList );
63 * Saves the document. Reimplemented.
64 * \param returned theFileList list of saved files of this model.
66 virtual bool save( QStringList& theFileList );
69 * Saves as the document. Reimplemented.
70 * \param theURL saved study path
71 * \param theStudy object study
72 * \param returned theFileList list of saved files of this model.
74 virtual bool saveAs( const QString& theURL,
76 QStringList& theFileList );
79 * Close the model and remove data. Reimplemented.
84 * Returns modification status. Reimplemented.
85 * \return boolean value of modification status
87 virtual bool isModified() const;
90 * Returns saving status. Reimplemented.
91 * \return true if document has saved files on disc.
93 virtual bool isSaved() const;
96 * Updates the internal structure of data object tree.
97 * \param theStudyId study identifier
99 virtual void update( const int theStudyId );
102 * Returns data object corresponding to the model object.
103 * \param the data model object
104 * \returns the only one object referenced to the given data model object, or null if not found
106 virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Object)& theModelObject );
109 * Returns a data object referenced to the given data object.
110 * \param the data object
111 * \returns the object referenced to the given object, or null if not found
113 virtual HYDROGUI_DataObject* getReferencedDataObject( HYDROGUI_DataObject* theObject );
116 * Finds the object by entry
117 * \param theEntry an object entry
119 virtual SUIT_DataObject* findObject( const QString& theEntry ) const;
122 * Updates the internal structure of data object tree starting from specified data object \a obj.
123 * \param theObject start data object
124 * \param theStudy study object
126 virtual void update( LightApp_DataObject* theObject = 0,
127 LightApp_Study* theStudy = 0 );
130 * Creates a module object and set is a root for the model
132 CAM_DataObject* createRootModuleObject( SUIT_DataObject* theParent );
135 * Correct an internal model object according to the current document mode
140 * Find a data object by the specified entry and kind
142 Handle(HYDROData_Object) objectByEntry( const QString& theEntry,
143 const ObjectKind theObjectKind );
146 * Check if it is possible to perform 'undo' operation
148 bool canUndo() const;
149 bool canRedo() const;
152 * Returns the list of names of available 'undo' actions
154 QStringList undoNames() const;
155 QStringList redoNames() const;
166 * Returns the document for the current study
168 Handle(HYDROData_Document) getDocument() const;
171 * Creates the GUI data object according to the model object.
172 * \param theParent a created object will be appended as a child of this object
173 * \param theObject model object
175 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
176 Handle(HYDROData_Object) theModelObject );
179 * Creates the GUI data object without corresponding model object: just by name
180 * \param theParent a created object will be appended as a child of this object
181 * \param theName name of this object
183 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
184 const QString& theName );
187 * Removes data object from the tree.
188 * \param theParent an object will be removed from this parent.
189 * \param theChild the removed object.
191 void removeChild( SUIT_DataObject* theParent,
192 SUIT_DataObject* theChild );
195 * Returns the first child of the object with the specified name
196 * \param theFather object that contain the searched object in children
197 * \param theName name f the searched data object
198 * \returns NULL if not found
200 static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
201 const QString& theName );
204 QString myStudyURL; ///< the saved/opened document URL