1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef HYDROGUI_DATAOBJECT_H
21 #define HYDROGUI_DATAOBJECT_H
23 #include <HYDROData_Entity.h>
26 #pragma warning( disable: 4250 )
27 #pragma warning( disable: 4251 )
31 #include <CAM_DataObject.h>
33 EntryId = CAM_DataObject::VisibilityId + 1, //!< entry column
34 RefEntryId //!< reference entry column
36 #define PARENT CAM_DataObject
38 #include <LightApp_DataObject.h>
39 #define PARENT LightApp_DataObject
48 #pragma warning( default: 4250 )
49 #pragma warning( default: 4251 )
53 * \class HYDROGUI_DataObject
54 * \brief Module data object, used for object browser tree creation.
56 * This is an Object Browser object that contains reference to data structure
58 * This class inherits CAM_DataObject virtually, so it is necessary to call in the class
59 * constructor the CAM object constructor manually for the correct initialization
61 class HYDROGUI_DataObject : public PARENT
66 RefObjectId = RefEntryId + 1, //!< Ref.Object column
67 AltitudeObjId //!< Altitude column
72 IsInOperationRole = Qtx::AppropriateRole + 100 //!< Filter value role
77 * \param theParent parent data object
78 * \param theData reference to the corresponding object from data structure
79 * \param theParentEntry entry of the parent data object (for reference objects)
80 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
82 HYDROGUI_DataObject( SUIT_DataObject* theParent,
83 Handle(HYDROData_Entity) theData,
84 const QString& theParentEntry,
85 const bool theIsInOperation = false );
88 * Returns the unique object identifier string.
90 virtual QString entry() const;
93 * Returns the entry of the referenced object.
95 virtual QString refEntry() const;
98 * Returns the name of object.
100 virtual QString name() const;
103 * Returns the font of displayed object name.
105 virtual QFont font( const int = SUIT_DataObject::NameId ) const;
108 * Returns the object color.
110 virtual QColor color( const ColorRole, const int = NameId ) const;
113 * Returns the object icon.
115 virtual QPixmap icon( const int = NameId ) const;
118 * Returns true if renaming is allowed for the object.
120 virtual bool renameAllowed( const int = NameId ) const;
123 * Returns the model data object.
125 const Handle(HYDROData_Entity)& modelObject() const { return myData; }
128 * Redefines the object.
130 void setObject( const Handle(HYDROData_Entity)& theObject ) { myData = theObject; }
133 * Returns the entry prefix for all HYDRO data objects.
135 static QString entryPrefix() { return QString( "HYDRO:" ); }
138 * Returns the full entry for the specified data object.
140 static QString dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
141 const bool theWithPrefix = true );
143 * Sets the validity flag: if object is valid or not.
144 * \param theIsValid is true for valid objects, false for invalid
146 void setIsValid( const bool theIsValid );
149 * Returns the validity flag: is object valid or not
150 * \return false if object is not valid
152 bool isValid() const;
155 * Returns the usage within active operation flag:
156 * is the object is used in the local tree of an active operation dialog or not.
157 * \return false if the object is used in the main object browser tree
159 bool isInOperation() const { return myIsInOperation; }
161 void updateBy( SUIT_DataObject* );
164 Handle(HYDROData_Entity) myData; ///< object from data model
165 QString myParentEntry;
166 bool myIsValid; ///< indicates if the object is valid
167 bool myIsInOperation; ///< indicates if the object is used within an active operation
172 * \class HYDROGUI_NamedObject
173 * \brief Module data object, used for object browser tree creation.
175 * It contains only name inside, without additional data: it is just information
176 * or grouping object in the Object Browser.
177 * This class inherits CAM_DataObject virtually, so it is necessary to call in the class
178 * constructor the CAM object constructor manually for the correct initialization
180 class HYDROGUI_NamedObject : public virtual PARENT
185 * \param theParent parent data object
186 * \param theName displayed name
187 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
189 HYDROGUI_NamedObject( SUIT_DataObject* theParent,
190 const QString& theName,
191 const QString& theParentEntry,
192 const bool theIsInOperation = false );
195 * Returns the unique object identifier string.
197 virtual QString entry() const;
200 * Returns the name of object.
202 virtual QString name() const;
205 * Returns the font of displayed object name.
207 virtual QFont font( const int = SUIT_DataObject::NameId ) const;
210 * Returns the object icon.
212 virtual QPixmap icon( const int = NameId ) const;
215 * Returns the usage within active operation flag:
216 * is the object is used in the local tree of an active operation dialog or not.
217 * \return false if the object is used in the main object browser tree
219 bool isInOperation() const { return myIsInOperation; }
221 void updateBy( SUIT_DataObject* );
224 QString myName; ///< name in the OB
225 QString myParentEntry;
227 bool myIsInOperation; ///< indicates if the object is used within an active operation
231 * \brief Module data object, used for dropping items in the object browser.
233 * It inherits NamedObject with only difference - it accepts dropping.
235 class HYDROGUI_DropTargetObject : public HYDROGUI_NamedObject
240 * \param theParent parent data object
241 * \param theName displayed name
242 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
244 HYDROGUI_DropTargetObject( SUIT_DataObject* theParent,
245 const QString& theName,
246 const QString& theParentEntry,
247 const bool theIsInOperation = false );
249 bool isDropAccepted() const { return true; }