14bbbdcb |
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_ViewModel_H |
17 | #define VInspector_ViewModel_H |
18 | |
19 | #include <AIS_InteractiveContext.hxx> |
20 | #include <NCollection_List.hxx> |
21 | #include <SelectBasics_EntityOwner.hxx> |
22 | #include <Standard.hxx> |
0cb512c0 |
23 | #include <inspector/TreeModel_ModelBase.hxx> |
24 | #include <inspector/VInspector_ItemBase.hxx> |
14bbbdcb |
25 | |
26 | #include <QByteArray> |
27 | #include <QHash> |
28 | #include <QMap> |
29 | #include <QObject> |
30 | |
31 | class OCAFSampleAPI_Module; |
32 | class OCAFSampleModel_DocumentMgr; |
33 | |
34 | class QItemSelectionModel; |
35 | |
36 | //! \class VInspector_ViewModel |
37 | //! The class that visualizes the AIS context content |
38 | class VInspector_ViewModel : public TreeModel_ModelBase |
39 | { |
40 | Q_OBJECT |
41 | |
42 | public: |
43 | |
44 | //! Constructor |
45 | Standard_EXPORT VInspector_ViewModel (QObject* theParent); |
46 | |
47 | //! Destructor |
48 | virtual ~VInspector_ViewModel() Standard_OVERRIDE {}; |
49 | |
50 | //! Initialize the model by the given context |
51 | //! \param theContext viewer context |
52 | Standard_EXPORT const Handle(AIS_InteractiveContext)& GetContext() const; |
53 | |
54 | //! Initialize the model by the given context |
55 | //! \param theContext viewer context |
56 | Standard_EXPORT void SetContext (const Handle(AIS_InteractiveContext)& theContext); |
57 | |
58 | //! Returns tree view indices for the given pointers of presentable object |
59 | //! \param thePointers a list of presentation pointers |
60 | //! \return container of indices |
61 | Standard_EXPORT QModelIndexList FindPointers (const QStringList& thePointers); |
62 | |
0cb512c0 |
63 | //! Returns tree model index of the presentation item in the tree view. |
64 | //! \param thePresentation a presentation |
65 | //! \return model index if the value is found or Null model index |
66 | Standard_EXPORT QModelIndex FindIndex (const Handle(AIS_InteractiveObject)& thePresentation) const; |
67 | |
14bbbdcb |
68 | //! Returns root item by column |
69 | //! \param theColumn an index of the column |
70 | //! \return root item instance |
71 | Standard_EXPORT virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const Standard_OVERRIDE |
72 | { return myRootItems[theColumn]; } |
73 | |
74 | //! Returns count of columns in the model |
75 | //! \param theParent an index of the parent item |
76 | //! \return integer value |
77 | Standard_EXPORT virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE |
78 | { (void)theParent; return 9; } |
79 | |
80 | //! Returns the header data for the given role and section in the header with the specified orientation. |
81 | //! \param theSection the header section. For horizontal headers - column number, for vertical headers - row number. |
82 | //! \param theOrientation a header orientation |
83 | //! \param theRole a data role |
84 | //! \return the header data |
85 | Standard_EXPORT virtual QVariant headerData (int theSection, Qt::Orientation theOrientation, |
86 | int theRole = Qt::DisplayRole ) const Standard_OVERRIDE; |
87 | |
88 | //! Returns select owners for tree view selected items |
89 | //! \param theSelectionModel a selection model |
90 | //! \param theOwners an output list of owners |
91 | Standard_EXPORT static void GetSelectedOwners (QItemSelectionModel* theSelectionModel, |
92 | NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners); |
93 | |
94 | private: |
95 | |
96 | QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item |
97 | }; |
98 | |
99 | #endif |