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 DFBrowserPane_TDataStdTreeNodeItem_H
17 #define DFBrowserPane_TDataStdTreeNodeItem_H
19 #include <inspector/TreeModel_ItemBase.hxx>
21 #include <Standard.hxx>
22 #include <TDF_Attribute.hxx>
24 #include <Standard_WarningsDisable.hxx>
28 #include <Standard_WarningsRestore.hxx>
30 class DFBrowserPane_TDataStdTreeNodeItem;
31 typedef QExplicitlySharedDataPointer<DFBrowserPane_TDataStdTreeNodeItem> DFBrowserPane_TDataStdTreeNodeItemPtr;
33 //! \class DFBrowserPane_TDataStdTreeNodeItem
34 //! An item connected to TDataStd_TreeNode attribute. Parent is NULL or tree node item.
35 //! Childrens are items for children of tree node attribute.
36 class DFBrowserPane_TDataStdTreeNodeItem : public TreeModel_ItemBase
41 //! Creates an item wrapped by a shared pointer
42 //! \param theRow the item row position in the parent item
43 //! \param theColumn the item column position in the parent item
44 //! \return the pointer to the created item
45 static DFBrowserPane_TDataStdTreeNodeItemPtr CreateItem (TreeModel_ItemBasePtr theParent,
46 const int theRow, const int theColumn)
47 { return DFBrowserPane_TDataStdTreeNodeItemPtr (new DFBrowserPane_TDataStdTreeNodeItem (theParent, theRow, theColumn)); }
50 virtual ~DFBrowserPane_TDataStdTreeNodeItem() Standard_OVERRIDE {}
52 //! Store a current attribute
53 //! \param theAttribute an attribute
54 void SetAttribute (const Handle(TDF_Attribute)& theAttribute) { myAttribute = theAttribute; }
56 //! Returns the current attribute
57 //! \return an attribute
58 Handle(TDF_Attribute) GetAttribute () const { initItem(); return myAttribute; }
60 //! Set state if the attribute is current(corresponds to the selected attribute in tree)
61 //! \param theCurrent boolean state
62 void setCurrentAttribute (const bool theCurrent) { Reset(); myIsCurrentItem = theCurrent; }
64 //! Returns child attribute of the current attribute
65 //! \param theChildRow an index of a child attribute
66 //! \returns an attribute
67 Standard_EXPORT Handle(TDF_Attribute) getChildAttribute (const int theChildRow) const;
69 //! Inits the item, fills internal containers
70 Standard_EXPORT virtual void Init() Standard_OVERRIDE;
72 //! Resets the cached item values. Throws down the initialized state of the item.
73 Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
77 //! Returns the data stored under the given role for the current item.
78 //! \param theRole an enumeration value of role for data obtaining
79 virtual QVariant initValue (const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
81 //! \return number of children.
82 virtual int initRowCount() const Standard_OVERRIDE { return getRowCount(); }
84 //! Creates a child item in the given position.
85 //! \param theRow the child row position
86 //! \param theColumn the child column position
87 //! \return the created item
88 virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
93 //! \param theParent a parent item
94 //! \param theRow the item row position in the parent item
95 //! \param theColumn the item column position in the parent item
96 DFBrowserPane_TDataStdTreeNodeItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
97 : TreeModel_ItemBase (theParent, theRow, theColumn), myIsCurrentItem (false) {}
99 //! Initializes the current item. It creates a backup of the specific item information
100 void initItem() const;
102 //! Returns number of children attributes, initializes item is necessary
103 int getRowCount() const;
105 //! Returns entry of the label of the current attribute tree node
106 QString getName() const { return myLabelName; }
110 Handle(TDF_Attribute) myAttribute; //! current attribute in tree node hierarchy
111 bool myIsCurrentItem; //! state whether this attribute is active in DFBrowser selected attribute in tree
113 int myRowCount; //! cached value of rows count
114 QString myLabelName; //! cached value of label name of the label of the current tree node attribute