7651adeb30021eb9ba063c6627992e98aaaa5c31
[occt.git] / tools / VInspector / VInspector_ItemContext.hxx
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_ItemContext_H
17 #define VInspector_ItemContext_H
18
19 #include <Standard.hxx>
20 #include <inspector/VInspector_ItemBase.hxx>
21
22 class VInspector_ItemContext;
23 typedef QExplicitlySharedDataPointer<VInspector_ItemContext> VInspector_ItemContextPtr;
24
25 //! \class VInspector_ItemContext
26 //! Parent item, that corresponds to AIS_InteractiveContext
27 //! Children of the item are:
28 //! - "Property" item to show context attributes such as selection filters and drawer properties
29 //! - presentation items to show all interactive elements displayed/erased in the context
30 class VInspector_ItemContext : public VInspector_ItemBase
31 {
32 public:
33
34   //! Creates an item wrapped by a shared pointer
35   static VInspector_ItemContextPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
36   { return VInspector_ItemContextPtr (new VInspector_ItemContext (theParent, theRow, theColumn)); }
37
38   //! Destructor
39   virtual ~VInspector_ItemContext() {}
40
41   //! Returns data object of the item.
42   //! \return object
43   virtual const Handle(Standard_Transient)& Object() const Standard_OVERRIDE { initItem(); return myContext; }
44
45   //! Returns number of displayed presentations
46   //! \return rows count
47   Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
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   //! Inits the item, fills internal containers
55   Standard_EXPORT virtual void Init() Standard_OVERRIDE;
56
57   //! Resets cached values
58   Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
59
60 protected:
61
62   //! Initializes the current item. It creates a backup of the specific item information
63   //! Does nothing as context has been already set into item
64   virtual void initItem() const Standard_OVERRIDE;
65
66   //! Returns stream value of the item to fulfill property panel.
67   //! \return stream value or dummy
68   Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
69
70 protected:
71
72   //! Creates a child item in the given position.
73   //! \param theRow the child row position
74   //! \param theColumn the child column position
75   //! \return the created item
76   virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
77
78 private:
79
80   //! Constructor
81   //! \param theParent a parent item
82   //! \param theRow the item row position in the parent item
83   //! \param theColumn the item column position in the parent item
84   VInspector_ItemContext(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
85     : VInspector_ItemBase(theParent, theRow, theColumn) {}
86 };
87
88 #endif