800e014cb1eec42f5840124b1779f454b99fbfdd
[occt.git] / tools / TreeModel / TreeModel_ItemStream.hxx
1 // Created on: 2020-01-25
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2020 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 TreeModel_ItemStream_H
17 #define TreeModel_ItemStream_H
18
19 #include <Standard.hxx>
20 #include <NCollection_IndexedDataMap.hxx>
21 #include <TCollection_AsciiString.hxx>
22
23 #include <inspector/TreeModel_ItemBase.hxx>
24
25 class TreeModel_ItemProperties;
26 class TreeModel_ItemStream;
27
28 typedef QExplicitlySharedDataPointer<TreeModel_ItemStream> TreeModel_ItemStreamPtr;
29
30 //! \class TreeModel_ItemStream
31 //! Parent item, that corresponds to AIS_InteractiveContext
32 //! Children of the item are:
33 //! - "Property" item to show context attributes such as selection filters and drawer properties
34 //! - presentation items to show all interactive elements displayed/erased in the context
35 class TreeModel_ItemStream : public TreeModel_ItemBase
36 {
37 public:
38
39   //! Creates an item wrapped by a shared pointer
40   static TreeModel_ItemStreamPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
41   { return TreeModel_ItemStreamPtr (new TreeModel_ItemStream (theParent, theRow, theColumn)); }
42
43   //! Destructor
44   virtual ~TreeModel_ItemStream() {}
45
46   //! Sets the item internal initialized state to the true. If the item has internal values,
47   //! there should be initialized here.
48   Standard_EXPORT virtual void Init() Standard_OVERRIDE;
49
50   //! Resets the item and the child items content. Sets the initialized state to false.
51   //! If the item has internal values, they should be reset here.
52   Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
53
54   //! Returns number of displayed presentations
55   //! \return rows count
56   virtual int initRowCount() const Standard_OVERRIDE { initItem(); return 0; }
57
58   //! Returns item information for the given role. Fills internal container if it was not filled yet
59   //! \param theItemRole a value role
60   //! \return the value
61   Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
62
63   //! Stores values of the item properties into the item object
64   //! \param theRow the child row position
65   //! \param theColumn the child column position
66   //! \param theValue the cell value
67   Standard_EXPORT virtual void StoreItemProperties (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
68
69 protected:
70   //! Returns stream value of the item to fulfill property panel.
71   //! \return stream value or dummy
72   Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const;
73
74   //! Initializes the current item. It creates a backup of the specific item information
75   //! Does nothing as context has been already set into item
76   Standard_EXPORT virtual void initItem() const Standard_OVERRIDE;
77
78 protected:
79
80   //! Creates a child item in the given position.
81   //! \param theRow the child row position
82   //! \param theColumn the child column position
83   //! \return the created item
84   Standard_EXPORT virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
85
86 private:
87
88   //! Constructor
89   //! \param theParent a parent item
90   //! \param theRow the item row position in the parent item
91   //! \param theColumn the item column position in the parent item
92   Standard_EXPORT TreeModel_ItemStream(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
93 };
94
95 #endif