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/ShapeView_ItemBase.hxx>
20 #include <Standard.hxx>
21 #include <TCollection_AsciiString.hxx>
22 #include <TopoDS_Shape.hxx>
24 #include <Standard_WarningsDisable.hxx>
27 #include <Standard_WarningsRestore.hxx>
29 class ShapeView_ItemShape;
30 typedef QExplicitlySharedDataPointer<ShapeView_ItemShape> ShapeView_ItemShapePtr;
32 //! \class ShapeView_ItemShape
33 //! This item is connected to TopoDS_Shape.
34 //! Parent is either ShapeView_ItemRoot or ShapeView_ItemShape, children are ShapeView_ItemShape or no children
35 class ShapeView_ItemShape : public ShapeView_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 ShapeView_ItemShapePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
44 { return ShapeView_ItemShapePtr (new ShapeView_ItemShape (theParent, theRow, theColumn)); }
47 virtual ~ShapeView_ItemShape() Standard_OVERRIDE {};
49 //! Returns the current shape
50 const TopoDS_Shape& GetItemShape() const { initItem(); return myShape; }
52 //! Returns child(extracted) shape for the current shape by the index
53 //! \param theRowId an index of child shape
54 //! \returns shape instance or NULL
55 Standard_EXPORT TopoDS_Shape GetShape (const int theRowId) const;
57 //! Returns name of BREP file for the shape if exists
58 //! \return string valuie
59 QString GetFileName() const { return myFileName; }
61 //! Sets name of BREP file for the shape if exists
62 //! \return string valuie
63 void SetFileName (const QString& theFileName) { myFileName = theFileName; }
65 //! Returns TShape pointer info of the current TopoDS Shape
66 //! \return string value
67 TCollection_AsciiString TShapePointer() const { return getPointerInfo (myShape.TShape()); }
69 //! Inits the item, fills internal containers
70 Standard_EXPORT virtual void Init() Standard_OVERRIDE;
72 //! Resets cached values
73 Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
75 //! Return data value for the role.
76 //! \param theRole a value role
78 Standard_EXPORT virtual QVariant initValue(const int theRole) const;
80 //! \return number of children.
81 Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
85 //! Initialize the current item. It is empty because Reset() is also empty.
86 virtual void initItem() const Standard_OVERRIDE;
88 //! Creates a child item in the given position.
89 //! \param theRow the child row position
90 //! \param theColumn the child column position
91 //! \return the created item
92 virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
94 //! Returns number of child shapes. Init item if it is not initialized
95 //! \return integer value
96 int getRowCount() const;
98 //! Returns current shape, initialized item if it has not been initialized yet
99 //! \return shape value
100 TopoDS_Shape getShape() const;
102 //! Convert pointer to string value
103 //! \param thePointer a pointer
104 //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
105 //! \return the string value
106 static TCollection_AsciiString getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo = true);
111 ShapeView_ItemShape(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
112 : ShapeView_ItemBase(theParent, theRow, theColumn) {}
116 TopoDS_Shape myShape; //!< current shape
117 QString myFileName; //!< BREP file name