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
28 #include <HYDROData_Object.h>
31 #include <LightApp_DataModel.h>
33 #include <SUIT_TreeModel.h>
36 class SUIT_DataObject;
37 class HYDROGUI_DataObject;
40 * \class HYDROGUI_DataModel
41 * \brief The class representing the HYDROGUI data model
43 class HYDROGUI_DataModel : public LightApp_DataModel, public SUIT_DataSearcher
48 * \param theModule module object
50 HYDROGUI_DataModel( CAM_Module* theModule );
51 virtual ~HYDROGUI_DataModel();
54 * Open the document into the data model. Reimplemented.
55 * /param theURL opened study path
56 * /param theStudy object study
57 * /param theFileList list of opened files for this model.
59 virtual bool open( const QString& theURL,
61 QStringList theFileList );
64 * Saves the document. Reimplemented.
65 * /param returned theFileList list of saved files of this model.
67 virtual bool save( QStringList& theFileList );
70 * Saves as the document. Reimplemented.
71 * /param theURL saved study path
72 * /param theStudy object study
73 * /param returned theFileList list of saved files of this model.
75 virtual bool saveAs( const QString& theURL,
77 QStringList& theFileList );
80 * Close the model and remove data. Reimplemented.
85 * Returns modification status. Reimplemented.
86 * /return boolean value of modification status
88 virtual bool isModified() const;
91 * Returns saving status. Reimplemented.
92 * \return true if document has saved files on disc.
94 virtual bool isSaved() const;
97 * Updates the internal structure of data object tree.
98 * \param theStudyId study identifier
100 virtual void update( const int theStudyId );
103 * Returns data object corresponding to the model object.
104 * \param the data model object
105 * \returns the only one object referenced to the given data model object, or null if not found
107 virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Object)& theModelObject );
110 * Returns a data object referenced to the given data object.
111 * \param the data object
112 * \returns the object referenced to the given object, or null if not found
114 virtual HYDROGUI_DataObject* getReferencedDataObject( HYDROGUI_DataObject* theObject );
117 * Finds the object by entry
118 * \param theEntry an object entry
120 virtual SUIT_DataObject* findObject( const QString& theEntry ) const;
123 * Updates the internal structure of data object tree starting from specified data object \a obj.
124 * /param theObject start data object
125 * /param theStudy study object
127 virtual void update( LightApp_DataObject* theObject = 0,
128 LightApp_Study* theStudy = 0 );
131 * Creates a module object and set is a root for the model
133 CAM_DataObject* createRootModuleObject( SUIT_DataObject* theParent );
136 * Correct an internal model object according to the current document mode
142 * Creates the GUI data object according to the model object.
143 * \param theParent a created object will be appended as a child of this object
144 * \param theObject model object
146 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
147 Handle(HYDROData_Object) theModelObject );
150 * Creates the GUI data object without corresponding model object: just by name
151 * \param theParent a created object will be appended as a child of this object
152 * \param theName name of this object
154 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
155 const QString& theName );
158 * Removes data object from the tree.
159 * \param theParent an object will be removed from this parent.
160 * \param theChild the removed object.
162 void removeChild( SUIT_DataObject* theParent,
163 SUIT_DataObject* theChild );
166 * Returns the first child of the object with the specified name
167 * \param theFather object that contain the searched object in children
168 * \param theName name f the searched data object
169 * \returns NULL if not found
171 static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
172 const QString& theName );
175 QString myStudyURL; ///< the saved/opened document URL