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 DFBrowserPane_AttributePane_H |
17 | #define DFBrowserPane_AttributePane_H |
18 | |
0cb512c0 |
19 | #include <inspector/DFBrowserPane_AttributePaneAPI.hxx> |
14bbbdcb |
20 | |
21 | #include <TDF_Attribute.hxx> |
22 | #include <TDF_Label.hxx> |
23 | #include <Standard.hxx> |
24 | |
25 | #ifdef _MSC_VER |
26 | #pragma warning(disable : 4127) // conditional expression is constant |
27 | #endif |
28 | #include <QList> |
29 | #include <QVariant> |
30 | |
31 | class DFBrowserPane_AttributePaneModel; |
32 | class DFBrowserPane_TableView; |
33 | |
34 | class QAbstractTableModel; |
35 | class QItemSelectionModel; |
36 | |
37 | //! \class DFBrowserPane_AttributePane |
38 | //! \brief This is an extension of base attribute pane: |
39 | //! - GetWidget() creates table view, view model and selection model. Table is vertical with one column. |
40 | //! - Init() obtains GetValues and give it to the table view model |
41 | //! If standard pane with such a table is used, only GetValues() should be redefined in children |
42 | class DFBrowserPane_AttributePane : public DFBrowserPane_AttributePaneAPI |
43 | { |
44 | public: |
45 | |
46 | //! Constructor |
47 | Standard_EXPORT DFBrowserPane_AttributePane(); |
48 | |
49 | //! Destructor |
50 | virtual ~DFBrowserPane_AttributePane() {} |
51 | |
52 | //! Creates a new widget |
53 | //! \param theParent a parent widget |
54 | //! \return pane widget |
55 | Standard_EXPORT virtual QWidget* CreateWidget(QWidget* theParent); |
56 | |
57 | //! Creates widget if it was not created and isToCreate is true |
58 | //! \param theParent a parent widget |
59 | //! \param isToCreate flag if the widget should be created if it is NULL |
60 | //! \return pane widget |
61 | Standard_EXPORT virtual QWidget* GetWidget(QWidget* theParent, const bool isToCreate) Standard_OVERRIDE; |
62 | |
63 | //! Gets values of attribute using GetValues() and Init the view model |
64 | //! \param theAttribute a current attribute |
65 | Standard_EXPORT virtual void Init(const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE; |
66 | |
67 | //! Returns values to fill the table view model |
68 | //! \param theAttribute a current attribute |
69 | //! \param theValues a container of values |
70 | virtual void GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues) |
71 | { (void)theAttribute; (void)theValues; }; |
72 | |
73 | //! Returns common information for the given attribute kind |
74 | //! \param theAttributeName a kind of attribute |
75 | //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on) |
76 | //! \param theColumnId a tree model column |
77 | //! \return value, interpreted by tree model depending on the role |
78 | Standard_EXPORT static QVariant GetAttributeInfoByType(const Standard_CString& theAttributeName, int theRole, int theColumnId); |
79 | |
80 | //! Returns information for the given attribute |
81 | //! \param theAttribute a current attribute |
82 | //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on) |
83 | //! \param theColumnId a tree model column |
84 | //! \return value, interpreted by tree model depending on the role |
85 | Standard_EXPORT virtual QVariant GetAttributeInfo(const Handle(TDF_Attribute)& theAttribute, int theRole, int theColumnId); |
86 | |
87 | //! Returns brief attribute information. In general case, it returns GetValues() result. |
88 | //! \param theAttribute a current attribute |
89 | //! \param theValues a result list of values |
90 | virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues) |
91 | { GetValues(theAttribute, theValues); } |
92 | |
93 | //! Returns list of selection models. In default implementation it contains a selection model for the table view |
94 | //! \returns container of models |
95 | virtual std::list<QItemSelectionModel*> GetSelectionModels() Standard_OVERRIDE { return mySelectionModels; } |
96 | |
97 | protected: |
98 | |
99 | //! Returns converted table view model |
100 | Standard_EXPORT DFBrowserPane_AttributePaneModel* getPaneModel() const; |
101 | |
102 | //! Returns converted table view |
103 | DFBrowserPane_TableView* getTableView() const { return myTableView; } |
104 | |
105 | //! Defines widths of table columns |
106 | //! \return container of widths |
107 | Standard_EXPORT virtual QMap<int, int> getTableColumnWidths() const; |
108 | |
109 | protected: |
110 | |
111 | QWidget* myMainWidget; //!< widget created in this pane |
112 | DFBrowserPane_TableView* myTableView; //!< table for visualization of attribute parameters |
113 | QAbstractTableModel* myPaneModel; //!< table view model. It is created before the table view, so we need to cache it |
114 | std::list<QItemSelectionModel*> mySelectionModels; //! selection models |
115 | }; |
116 | |
117 | #endif |