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_ItemShape_H
17 #define ShapeView_ItemShape_H
19 #include <inspector/TreeModel_ItemBase.hxx>
21 #include <TopTools_IndexedMapOfShape.hxx>
23 #include <Standard.hxx>
24 #include <TCollection_AsciiString.hxx>
25 #include <TopAbs_ShapeEnum.hxx>
26 #include <TopoDS_Shape.hxx>
28 #include <Standard_WarningsDisable.hxx>
31 #include <Standard_WarningsRestore.hxx>
33 class ShapeView_ItemShape;
34 typedef QExplicitlySharedDataPointer<ShapeView_ItemShape> ShapeView_ItemShapePtr;
36 //! \class ShapeView_ItemShape
37 //! This item is connected to TopoDS_Shape.
38 //! Parent is either ShapeView_ItemRoot or ShapeView_ItemShape, children are ShapeView_ItemShape or no children
39 class ShapeView_ItemShape : public TreeModel_ItemBase
43 //! Creates an item wrapped by a shared pointer
44 //! \param theRow the item row position in the parent item
45 //! \param theColumn the item column position in the parent item
46 //! \return the pointer to the created item
47 static ShapeView_ItemShapePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
48 { return ShapeView_ItemShapePtr (new ShapeView_ItemShape (theParent, theRow, theColumn)); }
51 virtual ~ShapeView_ItemShape() {}
53 //! Returns explode type of the item
54 TopAbs_ShapeEnum ExplodeType() const { return myExplodeType; }
57 //! \param theType type of item explode. If TopAbs_SHAPE, no explode, only iteration by shape
58 void SetExplodeType (const TopAbs_ShapeEnum theType) { myExplodeType = theType; }
60 //! Returns the current shape
61 const TopoDS_Shape& GetItemShape() const { initItem(); return myShape; }
63 //! Returns child(extracted) shape for the current shape by the index
64 //! \param theRowId an index of child shape
65 //! \returns shape instance or NULL
66 Standard_EXPORT TopoDS_Shape Shape (const int theRowId) const;
68 //! Returns name of BREP file for the shape if exists
69 //! \return string value
70 QString GetFileName() const { return myFileName; }
72 //! Sets name of BREP file for the shape if exists
73 //! \return string value
74 void SetFileName (const QString& theFileName) { myFileName = theFileName; }
76 //! Inits the item, fills internal containers
77 Standard_EXPORT virtual void Init() Standard_OVERRIDE;
79 //! Resets cached values
80 Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
82 //! Returns data value for the role.
83 //! \param theRole a value role
85 Standard_EXPORT virtual QVariant initValue(const int theRole) const;
87 //! \return number of children.
88 Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
90 //! Returns stream value of the item to fulfill property panel.
91 //! \return stream value or dummy
92 Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
96 //! Initializes the current item. It is empty because Reset() is also empty.
97 virtual void initItem() const Standard_OVERRIDE;
99 //! Creates a child item in the given position.
100 //! \param theRow the child row position
101 //! \param theColumn the child column position
102 //! \return the created item
103 virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
105 //! Returns number of child shapes. Init item if it is not initialized
106 //! \return integer value
107 int getRowCount() const;
109 //! Returns current shape, initialized item if it has not been initialized yet
110 //! \return shape value
111 TopoDS_Shape getShape() const;
116 ShapeView_ItemShape (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
117 : TreeModel_ItemBase (theParent, theRow, theColumn), myExplodeType (TopAbs_SHAPE) {}
120 TopAbs_ShapeEnum myExplodeType; //!< type of explore own shape and get children
122 TopoDS_Shape myShape; //!< current shape
123 QString myFileName; //!< BREP file name
125 TopTools_IndexedMapOfShape myChildShapes; //!< cached container of child shapes