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_DATAOBJECT_H
25 #define HYDROGUI_DATAOBJECT_H
27 #include <HYDROData_Entity.h>
30 #pragma warning( disable: 4250 )
31 #pragma warning( disable: 4251 )
34 #include <LightApp_DataObject.h>
41 #pragma warning( disable: 4250 )
42 #pragma warning( disable: 4251 )
46 * \class HYDROGUI_DataObject
47 * \brief Module data object, used for object browser tree creation.
49 * This is an Object Browser object that contains reference to data structure
51 * This class inherits CAM_DataObject virtually, so it is necessary to call in the class
52 * constructor the CAM object constructor manually for the correct initialization
54 class HYDROGUI_DataObject : public LightApp_DataObject
59 RefObjectId = RefEntryId + 1, //!< Ref.Object column
60 AltitudeObjId //!< Altitude column
65 IsInOperationRole = Qtx::AppropriateRole + 100 //!< Filter value role
70 * \param theParent parent data object
71 * \param theData reference to the corresponding object from data structure
72 * \param theParentEntry entry of the parent data object (for reference objects)
73 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
75 HYDROGUI_DataObject( SUIT_DataObject* theParent,
76 Handle(HYDROData_Entity) theData,
77 const QString& theParentEntry,
78 const bool theIsInOperation = false );
81 * Returns the unique object identifier string.
83 virtual QString entry() const;
86 * Returns the entry of the referenced object.
88 virtual QString refEntry() const;
91 * Returns the name of object.
93 virtual QString name() const;
96 * Returns the font of displayed object name.
98 virtual QFont font( const int = SUIT_DataObject::NameId ) const;
101 * Returns the object color.
103 virtual QColor color( const ColorRole, const int = NameId ) const;
106 * Returns the object icon.
108 virtual QPixmap icon( const int = NameId ) const;
111 * Returns true if renaming is allowed for the object.
113 virtual bool renameAllowed( const int = NameId ) const;
116 * Returns the model data object.
118 const Handle(HYDROData_Entity)& modelObject() const { return myData; }
121 * Redefines the object.
123 void setObject( const Handle(HYDROData_Entity)& theObject ) { myData = theObject; }
126 * Returns the entry prefix for all HYDRO data objects.
128 static QString entryPrefix() { return QString( "HYDRO:" ); }
131 * Returns the full entry for the specified data object.
133 static QString dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
134 const bool theWithPrefix = true );
136 * Sets the validity flag: if object is valid or not.
137 * \param theIsValid is true for valid objects, false for invalid
139 void setIsValid( const bool theIsValid );
142 * Returns the validity flag: is object valid or not
143 * \return false if object is not valid
145 bool isValid() const;
148 * Returns the usage within active operation flag:
149 * is the object is used in the local tree of an active operation dialog or not.
150 * \return false if the object is used in the main object browser tree
152 bool isInOperation() const { return myIsInOperation; }
154 void updateBy( SUIT_DataObject* );
157 Handle(HYDROData_Entity) myData; ///< object from data model
158 QString myParentEntry;
159 bool myIsValid; ///< indicates if the object is valid
160 bool myIsInOperation; ///< indicates if the object is used within an active operation
165 * \class HYDROGUI_NamedObject
166 * \brief Module data object, used for object browser tree creation.
168 * It contains only name inside, without additional data: it is just information
169 * or grouping object in the Object Browser.
170 * This class inherits CAM_DataObject virtually, so it is necessary to call in the class
171 * constructor the CAM object constructor manually for the correct initialization
173 class HYDROGUI_NamedObject : public virtual LightApp_DataObject
178 * \param theParent parent data object
179 * \param theName displayed name
180 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
182 HYDROGUI_NamedObject( SUIT_DataObject* theParent,
183 const QString& theName,
184 const QString& theParentEntry,
185 const bool theIsInOperation = false );
188 * Returns the unique object identifier string.
190 virtual QString entry() const;
193 * Returns the name of object.
195 virtual QString name() const;
198 * Returns the font of displayed object name.
200 virtual QFont font( const int = SUIT_DataObject::NameId ) const;
203 * Returns the object icon.
205 virtual QPixmap icon( const int = NameId ) const;
208 * Returns the usage within active operation flag:
209 * is the object is used in the local tree of an active operation dialog or not.
210 * \return false if the object is used in the main object browser tree
212 bool isInOperation() const { return myIsInOperation; }
214 void updateBy( SUIT_DataObject* );
217 QString myName; ///< name in the OB
218 QString myParentEntry;
220 bool myIsInOperation; ///< indicates if the object is used within an active operation
224 * \brief Module data object, used for dropping items in the object browser.
226 * It inherits NamedObject with only difference - it accepts dropping.
228 class HYDROGUI_DropTargetObject : public HYDROGUI_NamedObject
233 * \param theParent parent data object
234 * \param theName displayed name
235 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
237 HYDROGUI_DropTargetObject( SUIT_DataObject* theParent,
238 const QString& theName,
239 const QString& theParentEntry,
240 const bool theIsInOperation = false );
242 bool isDropAccepted() const { return true; }