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>
28 class DFBrowserPane_TDataStdTreeNodeItem;
29 typedef QExplicitlySharedDataPointer<DFBrowserPane_TDataStdTreeNodeItem> DFBrowserPane_TDataStdTreeNodeItemPtr;
31 //! \class DFBrowserPane_TDataStdTreeNodeItem
32 //! An item connected to TDataStd_TreeNode attribute. Parent is NULL or tree node item.
33 //! Childrens are items for children of tree node attribute.
34 class DFBrowserPane_TDataStdTreeNodeItem : public TreeModel_ItemBase
39 //! Creates an item wrapped by a shared pointer
40 //! \param theRow the item row positition in the parent item
41 //! \param theColumn the item column positition in the parent item
42 //! \return the pointer to the created item
43 static DFBrowserPane_TDataStdTreeNodeItemPtr CreateItem (TreeModel_ItemBasePtr theParent,
44 const int theRow, const int theColumn)
45 { return DFBrowserPane_TDataStdTreeNodeItemPtr (new DFBrowserPane_TDataStdTreeNodeItem (theParent, theRow, theColumn)); }
48 virtual ~DFBrowserPane_TDataStdTreeNodeItem() Standard_OVERRIDE {};
50 //! Store a current attribute
51 //! \param theAttribute an attribute
52 void SetAttribute (const Handle(TDF_Attribute)& theAttribute) { myAttribute = theAttribute; }
54 //! Returns the current attribute
55 //! \return an attribute
56 Handle(TDF_Attribute) GetAttribute () const { initItem(); return myAttribute; }
58 //! Set state if the attribute is current(corresponds to the selected attribute in tree)
59 //! \param theCurrent boolean state
60 void setCurrentAttribute (const bool theCurrent) { Reset(); myIsCurrentItem = theCurrent; }
62 //! Returns child attribute of the current attribute
63 //! \param theChildRow an index of a child attribute
64 //! \returns an attribute
65 Standard_EXPORT Handle(TDF_Attribute) getChildAttribute (const int theChildRow) const;
67 //! Inits the item, fills internal containers
68 Standard_EXPORT virtual void Init() Standard_OVERRIDE;
70 //! Resets the cached item values. Throws down the initialized state of the item.
71 Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
75 //! Returns the data stored under the given role for the current item.
76 //! \param theRole an enumeration value of role for data obtaining
77 virtual QVariant initValue (const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
79 //! \return number of children.
80 virtual int initRowCount() const Standard_OVERRIDE { return getRowCount(); }
82 //! Creates a child item in the given position.
83 //! \param theRow the child row position
84 //! \param theColumn the child column position
85 //! \return the created item
86 virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
91 //! param theParent a parent item
92 //! \param theRow the item row positition in the parent item
93 //! \param theColumn the item column positition in the parent item
94 DFBrowserPane_TDataStdTreeNodeItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
95 : TreeModel_ItemBase (theParent, theRow, theColumn), myIsCurrentItem (false) {}
97 //! Initialize the current item. It creates a backup of the specific item information
98 void initItem() const;
100 //! Returns number of children attributes, initializes item is necessary
101 int getRowCount() const;
103 //! Returns entry of the label of the current attribute tree node
104 QString getName() const { return myLabelName; }
108 Handle(TDF_Attribute) myAttribute; //! current attribute in tree node hierarchy
109 bool myIsCurrentItem; //! state whether this attribute is active in DFBrowser selected attribute in tree
111 int myRowCount; //! cached value of rows count
112 QString myLabelName; //! cached value of label name of the label of the current tree node attribute