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_Object.h>
29 #include <LightApp_DataModel.h>
31 #include <SUIT_TreeModel.h>
34 class SUIT_DataObject;
35 class HYDROGUI_DataObject;
38 * \class HYDROGUI_DataModel
39 * \brief The class representing the HYDROGUI data model
41 class HYDROGUI_DataModel : public LightApp_DataModel, public SUIT_DataSearcher
46 * \param theModule module object
48 HYDROGUI_DataModel( CAM_Module* theModule );
49 virtual ~HYDROGUI_DataModel();
52 * Open the document into the data model. Reimplemented.
53 * \param theURL opened study path
54 * \param theStudy object study
55 * \param theFileList list of opened files for this model.
57 virtual bool open( const QString& theURL,
59 QStringList theFileList );
62 * Saves the document. Reimplemented.
63 * \param returned theFileList list of saved files of this model.
65 virtual bool save( QStringList& theFileList );
68 * Saves as the document. Reimplemented.
69 * \param theURL saved study path
70 * \param theStudy object study
71 * \param returned theFileList list of saved files of this model.
73 virtual bool saveAs( const QString& theURL,
75 QStringList& theFileList );
78 * Close the model and remove data. Reimplemented.
83 * Returns modification status. Reimplemented.
84 * \return boolean value of modification status
86 virtual bool isModified() const;
89 * Returns saving status. Reimplemented.
90 * \return true if document has saved files on disc.
92 virtual bool isSaved() const;
95 * Updates the internal structure of data object tree.
96 * \param theStudyId study identifier
98 virtual void update( const int theStudyId );
101 * Returns data object corresponding to the model object.
102 * \param the data model object
103 * \returns the only one object referenced to the given data model object, or null if not found
105 virtual HYDROGUI_DataObject* getDataObject( const Handle(HYDROData_Object)& theModelObject );
108 * Returns a data object referenced to the given data object.
109 * \param the data object
110 * \returns the object referenced to the given object, or null if not found
112 virtual HYDROGUI_DataObject* getReferencedDataObject( HYDROGUI_DataObject* theObject );
115 * Finds the object by entry
116 * \param theEntry an object entry
118 virtual SUIT_DataObject* findObject( const QString& theEntry ) const;
121 * Updates the internal structure of data object tree starting from specified data object \a obj.
122 * \param theObject start data object
123 * \param theStudy study object
125 virtual void update( LightApp_DataObject* theObject = 0,
126 LightApp_Study* theStudy = 0 );
129 * Creates a module object and set is a root for the model
131 CAM_DataObject* createRootModuleObject( SUIT_DataObject* theParent );
134 * Correct an internal model object according to the current document mode
139 * Find a data object by the specified entry and kind
141 Handle(HYDROData_Object) objectByEntry( const QString& theEntry,
142 const ObjectKind theObjectKind );
146 * Creates the GUI data object according to the model object.
147 * \param theParent a created object will be appended as a child of this object
148 * \param theObject model object
150 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
151 Handle(HYDROData_Object) theModelObject );
154 * Creates the GUI data object without corresponding model object: just by name
155 * \param theParent a created object will be appended as a child of this object
156 * \param theName name of this object
158 LightApp_DataObject* createObject( SUIT_DataObject* theParent,
159 const QString& theName );
162 * Removes data object from the tree.
163 * \param theParent an object will be removed from this parent.
164 * \param theChild the removed object.
166 void removeChild( SUIT_DataObject* theParent,
167 SUIT_DataObject* theChild );
170 * Returns the first child of the object with the specified name
171 * \param theFather object that contain the searched object in children
172 * \param theName name f the searched data object
173 * \returns NULL if not found
175 static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
176 const QString& theName );
179 QString myStudyURL; ///< the saved/opened document URL