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 ShapeView_ItemRoot_H
17 #define ShapeView_ItemRoot_H
19 #include <NCollection_List.hxx>
20 #include <inspector/TreeModel_ItemBase.hxx>
21 #include <Standard.hxx>
22 #include <TopoDS_Shape.hxx>
24 class ShapeView_ItemRoot;
25 typedef QExplicitlySharedDataPointer<ShapeView_ItemRoot> ShapeView_ItemRootPtr;
27 //! \class ShapeView_ItemRoot
28 //! Collects shapes that should be visualized in tree view. Shapes are cached and if shapes are not needed,
29 //! cache should be cleared using RemoveAllShapes.
30 //! Parent is NULL, children are ShapeView_ItemShape items.
31 class ShapeView_ItemRoot : public TreeModel_ItemBase
35 //! Creates an item wrapped by a shared pointer
36 static ShapeView_ItemRootPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
37 { return ShapeView_ItemRootPtr (new ShapeView_ItemRoot (theParent, theRow, theColumn)); }
40 virtual ~ShapeView_ItemRoot() {}
43 //! \param theShape a shape instance
44 void AddShape (const TopoDS_Shape& theShape) { myShapes.Append (theShape); }
46 //! Clears internal container of added shapes
47 void RemoveAllShapes() { myShapes.Clear(); }
49 //! Returns shape by the number
50 //! \param theRowId an index of the shape in the internal container.
51 Standard_EXPORT const TopoDS_Shape& Shape (const int theRowId);
55 //! Returns data value for the role.
56 //! \param theItemRole a value role
58 virtual QVariant initValue(const int theItemRole) const;
60 //! \return number of children.
61 virtual int initRowCount() const Standard_OVERRIDE { return myShapes.Size(); }
63 //! Creates a child item in the given position.
64 //! \param theRow the child row position
65 //! \param theColumn the child column position
66 //! \return the created item
67 virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
72 //! \param theParent a parent item
73 ShapeView_ItemRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
74 : TreeModel_ItemBase (theParent, theRow, theColumn) {}
78 NCollection_List<TopoDS_Shape> myShapes; //!< shapes presented in tree view