1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15 
16 #ifndef VInspector_ItemBase_H
17 #define VInspector_ItemBase_H
18 
19 #include <AIS_InteractiveContext.hxx>
20 #include <Standard.hxx>
21 #include <TopoDS_Shape.hxx>
22 
23 #include <inspector/TreeModel_ColumnType.hxx>
24 #include <inspector/TreeModel_ItemBase.hxx>
25 
26 class VInspector_ItemBase;
27 typedef QExplicitlySharedDataPointer<VInspector_ItemBase> VInspector_ItemBasePtr;
28 
29 //! \class VInspector_ItemBase
30 //! Parent item for all ShapeView items
31 class VInspector_ItemBase : public TreeModel_ItemBase
32 {
33 public:
34   //! Resets cached values
35   Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
36 
37   //! Sets the context
38   //! \param theLabel an object where the child items structure is found
SetContext(const Handle (AIS_InteractiveContext)& theContext)39   void SetContext (const Handle(AIS_InteractiveContext)& theContext) { myContext = theContext; }
40 
41   //! Returns true if the current context is not null
42   //! \return a boolean value
HasContext() const43   bool HasContext() const { return !GetContext().IsNull(); }
44 
45   //! Returns the current context. It iterates up by list of parents to found context item and return context
46   //! \return a context
47   Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
48 
49   //! Returns item information for the given role. Fills internal container if it was not filled yet
50   //! \param theItemRole a value role
51   //! \return the value
52   Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
53 
54   //! Returns transform persistent of the item or NULL
TransformPersistence() const55   Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPersistence; }
56 
57   //! Returns shape of the item parameters
58   //! \return generated shape of the item parameters
59   Standard_EXPORT virtual TopoDS_Shape GetPresentationShape() const;
60 
61   //! Rebuild presentation shape if the item use it
62   //! \return generated shape of the item parameters
UpdatePresentationShape()63   void UpdatePresentationShape() { myPresentationShape = buildPresentationShape(); }
64 
65 protected:
66 
67   //! Build presentation shape
68   //! \return generated shape of the item parameters
buildPresentationShape()69   virtual TopoDS_Shape buildPresentationShape() { return TopoDS_Shape(); }
70 
71 protected:
72 
73   //! Constructor
74   //! \param theParent a parent item
75   //! \param theRow the item row position in the parent item
76   //! \param theColumn the item column position in the parent item
VInspector_ItemBase(TreeModel_ItemBasePtr theParent,const int theRow,const int theColumn)77   VInspector_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
78     : TreeModel_ItemBase (theParent, theRow, theColumn), myContext (0) {}
79 
80 protected:
81 
82   Handle(AIS_InteractiveContext) myContext; //!< the current context
83   TopoDS_Shape myPresentationShape; //!< item presentation shape
84   Handle(Graphic3d_TransformPers) myTransformPersistence; //!< item cached persistent
85 };
86 
87 #endif