1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef DFBrowser_Item_H
17 #define DFBrowser_Item_H
19 #include <inspector/DFBrowser_ItemBase.hxx>
21 #include <TDF_Attribute.hxx>
22 #include <Standard.hxx>
23 #include <Standard_GUID.hxx>
25 #include <Standard_WarningsDisable.hxx>
29 #include <Standard_WarningsRestore.hxx>
32 typedef QExplicitlySharedDataPointer<DFBrowser_Item> DFBrowser_ItemPtr;
34 //! \class DFBrowser_Item
35 //! \brief Declaration of the tree model root item.
36 class DFBrowser_Item : public DFBrowser_ItemBase
40 //! Creates an item wrapped by a shared pointer
41 //! \param theRow the item row position in the parent item
42 //! \param theColumn the item column position in the parent item
43 //! \return the pointer to the created item
44 static DFBrowser_ItemPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
45 { return DFBrowser_ItemPtr (new DFBrowser_Item (theParent, theRow, theColumn)); }
48 virtual ~DFBrowser_Item() {}
50 //! \return true if the attribute is set in the item, otherwise it is initialized by a label
51 Standard_EXPORT bool HasAttribute() const;
53 //! \return the item attribute
54 Standard_EXPORT Handle(TDF_Attribute) GetAttribute() const;
56 //! Finds int parent item attribute or label by this item row and store it in a field of this item.
57 Standard_EXPORT virtual void Init() Standard_OVERRIDE;
59 //! Resets the cached item values, set null attribute and calls reset of the parent class
60 Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
62 //! Inits item and calls cachedValue() for the role
63 //! \param theItemRole a value role
65 Standard_EXPORT QVariant GetAttributeInfo(int theRole) const;
69 //! \return number of children.
70 virtual int initRowCount() const Standard_OVERRIDE;
72 //! Returns data value for the role:
73 //! - if content is label, calls DFBrowser_ItemBase;
74 //! - if content is attribute, if the fole is extended display, asks additional info text or ask module about info
75 //! \param theItemRole a value role
77 virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
79 //! Returns stream value of the item to fulfill property panel.
80 //! \return stream value or dummy
81 Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
84 //! \param theParent a parent item
85 //! \param theRow the item row position in the parent item
86 //! \param theColumn the item column position in the parent item
87 DFBrowser_Item (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
88 : DFBrowser_ItemBase (theParent, theRow, theColumn) {}
90 //! Initializes the current item. It creates a backup of the specific item information
91 void initItem() const;
93 //! Sets the item attribute
94 //! \param theAttribute an item attribute
95 void SetAttribute (Handle(TDF_Attribute) theAttribute);
99 Standard_GUID myAttributeGUID; //!< if attribute, stores GUID of the attribute because label can contain only one attribute of a kind