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 )
30 #include <LightApp_DataObject.h>
37 #pragma warning( disable: 4250 )
38 #pragma warning( disable: 4251 )
42 * \class HYDROGUI_DataObject
43 * \brief Module data object, used for object browser tree creation.
45 * This is an Object Browser object that contains reference to data structure
47 * This class inherits CAM_DataObject virtually, so it is necessary to call in the class
48 * constructor the CAM object constructor manually for the correct initialization
50 class HYDROGUI_DataObject : public LightApp_DataObject
55 RefObjectId = RefEntryId + 1, //!< Ref.Object column
56 AltitudeObjId //!< Altitude column
61 IsInOperationRole = Qtx::AppropriateRole + 100 //!< Filter value role
66 * \param theParent parent data object
67 * \param theData reference to the corresponding object from data structure
68 * \param theParentEntry entry of the parent data object (for reference objects)
69 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
71 HYDROGUI_DataObject( SUIT_DataObject* theParent,
72 Handle(HYDROData_Entity) theData,
73 const QString& theParentEntry,
74 const bool theIsInOperation = false );
77 * Returns the unique object identifier string.
79 virtual QString entry() const;
82 * Returns the entry of the referenced object.
84 virtual QString refEntry() const;
87 * Returns the name of object.
89 virtual QString name() const;
92 * Returns the font of displayed object name.
94 virtual QFont font( const int = SUIT_DataObject::NameId ) const;
97 * Returns the object color.
99 virtual QColor color( const ColorRole, const int = NameId ) const;
102 * Returns the object icon.
104 virtual QPixmap icon( const int = NameId ) const;
107 * Returns true if renaming is allowed for the object.
109 virtual bool renameAllowed( const int = NameId ) const;
112 * Returns the model data object.
114 const Handle(HYDROData_Entity)& modelObject() const { return myData; }
117 * Redefines the object.
119 void setObject( const Handle(HYDROData_Entity)& theObject ) { myData = theObject; }
122 * Returns the entry prefix for all HYDRO data objects.
124 static QString entryPrefix() { return QString( "HYDRO:" ); }
127 * Returns the full entry for the specified data object.
129 static QString dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
130 const bool theWithPrefix = true );
132 * Sets the validity flag: if object is valid or not.
133 * \param theIsValid is true for valid objects, false for invalid
135 void setIsValid( const bool theIsValid );
138 * Returns the validity flag: is object valid or not
139 * \return false if object is not valid
141 bool isValid() const;
144 * Returns the usage within active operation flag:
145 * is the object is used in the local tree of an active operation dialog or not.
146 * \return false if the object is used in the main object browser tree
148 bool isInOperation() const { return myIsInOperation; }
150 void updateBy( SUIT_DataObject* );
153 Handle(HYDROData_Entity) myData; ///< object from data model
154 QString myParentEntry;
155 bool myIsValid; ///< indicates if the object is valid
156 bool myIsInOperation; ///< indicates if the object is used within an active operation
161 * \class HYDROGUI_NamedObject
162 * \brief Module data object, used for object browser tree creation.
164 * It contains only name inside, without additional data: it is just information
165 * or grouping object in the Object Browser.
166 * This class inherits CAM_DataObject virtually, so it is necessary to call in the class
167 * constructor the CAM object constructor manually for the correct initialization
169 class HYDROGUI_NamedObject : public virtual LightApp_DataObject
174 * \param theParent parent data object
175 * \param theName displayed name
176 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
178 HYDROGUI_NamedObject( SUIT_DataObject* theParent,
179 const QString& theName,
180 const QString& theParentEntry,
181 const bool theIsInOperation = false );
184 * Returns the unique object identifier string.
186 virtual QString entry() const;
189 * Returns the name of object.
191 virtual QString name() const;
194 * Returns the font of displayed object name.
196 virtual QFont font( const int = SUIT_DataObject::NameId ) const;
199 * Returns the object icon.
201 virtual QPixmap icon( const int = NameId ) const;
204 * Returns the usage within active operation flag:
205 * is the object is used in the local tree of an active operation dialog or not.
206 * \return false if the object is used in the main object browser tree
208 bool isInOperation() const { return myIsInOperation; }
210 void updateBy( SUIT_DataObject* );
213 QString myName; ///< name in the OB
214 QString myParentEntry;
216 bool myIsInOperation; ///< indicates if the object is used within an active operation
220 * \brief Module data object, used for dropping items in the object browser.
222 * It inherits NamedObject with only difference - it accepts dropping.
224 class HYDROGUI_DropTargetObject : public HYDROGUI_NamedObject
229 * \param theParent parent data object
230 * \param theName displayed name
231 * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
233 HYDROGUI_DropTargetObject( SUIT_DataObject* theParent,
234 const QString& theName,
235 const QString& theParentEntry,
236 const bool theIsInOperation = false );
238 bool isDropAccepted() const { return true; }