a5704b9665d144869eecc0e54dd3f8d6f30fe661
[occt.git] / tools / VInspector / VInspector_ItemPresentableObject.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_ItemPresentableObject_H
17 #define VInspector_ItemPresentableObject_H
18
19 #include <Standard.hxx>
20 #include <inspector/VInspector_ItemBase.hxx>
21
22 #include <AIS_InteractiveObject.hxx>
23 #include <NCollection_List.hxx>
24
25 class QItemSelectionModel;
26
27 class VInspector_ItemPresentableObject;
28 typedef QExplicitlySharedDataPointer<VInspector_ItemPresentableObject> VInspector_ItemPresentableObjectPtr;
29
30 //! \class VInspector_ItemPresentableObject
31 //! Item presents information about AIS_InteractiveObject.
32 //! Parent is item context, children are item selections.
33 class VInspector_ItemPresentableObject : public VInspector_ItemBase
34 {
35
36 public:
37
38   //! Creates an item wrapped by a shared pointer
39   static VInspector_ItemPresentableObjectPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
40   { return VInspector_ItemPresentableObjectPtr (new VInspector_ItemPresentableObject (theParent, theRow, theColumn)); }
41   //! Destructor
42   virtual ~VInspector_ItemPresentableObject() {}
43
44   //! Returns data object of the item.
45   //! \return object
46   virtual const Handle(Standard_Transient)& Object() const Standard_OVERRIDE { initItem(); return myIO; }
47
48   //! Returns the current interactive object, init item if it was not initialized yet
49   //! \return interactive object
50   Handle(AIS_InteractiveObject) GetInteractiveObject() const { return Handle(AIS_InteractiveObject)::DownCast (Object()); }
51
52   //! Returns pointer information for the current interactive object, init item if it was not initialized yet
53   //! \return string value
54   Standard_EXPORT QString PointerInfo() const;
55
56   //! Inits the item, fills internal containers
57   Standard_EXPORT virtual void Init() Standard_OVERRIDE;
58
59   //! Resets cached values
60   Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
61
62   //! Returns presentation of the attribute to be visualized in the view
63   //! \thePresentations [out] container of presentation handles to be visualized
64   Standard_EXPORT virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations) Standard_OVERRIDE;
65
66 protected:
67
68   //! Initialize the current item. It is empty because Reset() is also empty.
69   virtual void initItem() const Standard_OVERRIDE;
70
71   //! Returns number of item selected
72   //! \return rows count
73   virtual int initRowCount() const Standard_OVERRIDE;
74
75   //! Returns item information for the given role. Fills internal container if it was not filled yet
76   //! \param theItemRole a value role
77   //! \return the value
78   virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
79
80   //! Returns stream value of the item to fulfill property panel.
81   //! \return stream value or dummy
82   Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
83
84 protected:
85   //! Build presentation shape
86   //! \return generated shape of the item parameters
87   virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
88
89   //! Set interactive object into the current field
90   //! \param theIO a presentation
91   void setInteractiveObject (Handle(AIS_InteractiveObject) theIO) { myIO = theIO; }
92
93 private:
94
95   //! Constructor
96   //! \param theParent a parent item
97   VInspector_ItemPresentableObject(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
98   : VInspector_ItemBase(theParent, theRow, theColumn) {}
99
100 protected:
101
102   Handle(AIS_InteractiveObject) myIO; //!< the current interactive context
103 };
104
105 #endif