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_DATAOBJECT_H
24 #define HYDROGUI_DATAOBJECT_H
26 #include <HYDROData_Entity.h>
29 #pragma warning( disable: 4250 )
30 #pragma warning( disable: 4251 )
33 #include <LightApp_DataObject.h>
40 #pragma warning( disable: 4250 )
41 #pragma warning( disable: 4251 )
45 * \class HYDROGUI_DataObject
46 * \brief Module data object, used for object browser tree creation.
48 * This is an Object Browser object that contains reference to data structure
50 * This class inherits CAM_DataObject virtually, so it is necessary to call in the class
51 * constructor the CAM object constructor manually for the correct initialization
53 class HYDROGUI_DataObject : public LightApp_DataObject
58 RefObjectId = RefEntryId + 1, //!< Ref.Object column
59 AltitudeObjId //!< Altitude column
64 IsInOperationRole = Qtx::AppropriateRole + 100 //!< Filter value role
69 * \param theParent parent data object
70 * \param theData reference to the corresponding object from data structure
71 * \param theParentEntry entry of the parent data object (for reference objects)
72 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
74 HYDROGUI_DataObject( SUIT_DataObject* theParent,
75 Handle(HYDROData_Entity) theData,
76 const QString& theParentEntry,
77 const bool theIsInOperation = false );
80 * Returns the unique object identifier string.
82 virtual QString entry() const;
85 * Returns the entry of the referenced object.
87 virtual QString refEntry() const;
90 * Returns the name of object.
92 virtual QString name() const;
95 * Returns the font of displayed object name.
97 virtual QFont font( const int = SUIT_DataObject::NameId ) const;
100 * Returns the object color.
102 virtual QColor color( const ColorRole, const int = NameId ) const;
105 * Returns the object icon.
107 virtual QPixmap icon( const int = NameId ) const;
110 * Returns true if renaming is allowed for the object.
112 virtual bool renameAllowed( const int = NameId ) const;
115 * Returns the model data object.
117 const Handle(HYDROData_Entity)& modelObject() const { return myData; }
120 * Redefines the object.
122 void setObject( const Handle(HYDROData_Entity)& theObject ) { myData = theObject; }
125 * Returns the entry prefix for all HYDRO data objects.
127 static QString entryPrefix() { return QString( "HYDRO:" ); }
130 * Returns the full entry for the specified data object.
132 static QString dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
133 const bool theWithPrefix = true );
135 * Sets the validity flag: if object is valid or not.
136 * \param theIsValid is true for valid objects, false for invalid
138 void setIsValid( const bool theIsValid );
141 * Returns the validity flag: is object valid or not
142 * \return false if object is not valid
144 bool isValid() const;
147 * Returns the usage within active operation flag:
148 * is the object is used in the local tree of an active operation dialog or not.
149 * \return false if the object is used in the main object browser tree
151 bool isInOperation() const { return myIsInOperation; }
153 void updateBy( SUIT_DataObject* );
156 Handle(HYDROData_Entity) myData; ///< object from data model
157 QString myParentEntry;
158 bool myIsValid; ///< indicates if the object is valid
159 bool myIsInOperation; ///< indicates if the object is used within an active operation
164 * \class HYDROGUI_NamedObject
165 * \brief Module data object, used for object browser tree creation.
167 * It contains only name inside, without additional data: it is just information
168 * or grouping object in the Object Browser.
169 * This class inherits CAM_DataObject virtually, so it is necessary to call in the class
170 * constructor the CAM object constructor manually for the correct initialization
172 class HYDROGUI_NamedObject : public virtual LightApp_DataObject
177 * \param theParent parent data object
178 * \param theName displayed name
179 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
181 HYDROGUI_NamedObject( SUIT_DataObject* theParent,
182 const QString& theName,
183 const QString& theParentEntry,
184 const bool theIsInOperation = false );
187 * Returns the unique object identifier string.
189 virtual QString entry() const;
192 * Returns the name of object.
194 virtual QString name() const;
197 * Returns the font of displayed object name.
199 virtual QFont font( const int = SUIT_DataObject::NameId ) const;
202 * Returns the object icon.
204 virtual QPixmap icon( const int = NameId ) const;
207 * Returns the usage within active operation flag:
208 * is the object is used in the local tree of an active operation dialog or not.
209 * \return false if the object is used in the main object browser tree
211 bool isInOperation() const { return myIsInOperation; }
213 void updateBy( SUIT_DataObject* );
216 QString myName; ///< name in the OB
217 QString myParentEntry;
219 bool myIsInOperation; ///< indicates if the object is used within an active operation
223 * \brief Module data object, used for dropping items in the object browser.
225 * It inherits NamedObject with only difference - it accepts dropping.
227 class HYDROGUI_DropTargetObject : public HYDROGUI_NamedObject
232 * \param theParent parent data object
233 * \param theName displayed name
234 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
236 HYDROGUI_DropTargetObject( SUIT_DataObject* theParent,
237 const QString& theName,
238 const QString& theParentEntry,
239 const bool theIsInOperation = false );
241 bool isDropAccepted() const { return true; }