1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef DFBrowserPane_AttributePane_H
17 #define DFBrowserPane_AttributePane_H
19 #include <inspector/DFBrowserPane_AttributePaneAPI.hxx>
21 #include <TDF_Attribute.hxx>
22 #include <TDF_Label.hxx>
23 #include <Standard.hxx>
25 #include <Standard_WarningsDisable.hxx>
28 #include <Standard_WarningsRestore.hxx>
30 class DFBrowserPane_AttributePaneModel;
31 class DFBrowserPane_TableView;
33 class QAbstractTableModel;
34 class QItemSelectionModel;
36 //! \class DFBrowserPane_AttributePane
37 //! \brief This is an extension of base attribute pane:
38 //! - GetWidget() creates table view, view model and selection model. Table is vertical with one column.
39 //! - Init() obtains GetValues and give it to the table view model
40 //! If standard pane with such a table is used, only GetValues() should be redefined in children
41 class DFBrowserPane_AttributePane : public DFBrowserPane_AttributePaneAPI
46 Standard_EXPORT DFBrowserPane_AttributePane();
49 virtual ~DFBrowserPane_AttributePane() {}
51 //! Creates a new widget
52 //! \param theParent a parent widget
53 //! \return pane widget
54 Standard_EXPORT virtual QWidget* CreateWidget(QWidget* theParent);
56 //! Creates widget if it was not created and isToCreate is true
57 //! \param theParent a parent widget
58 //! \param isToCreate flag if the widget should be created if it is NULL
59 //! \return pane widget
60 Standard_EXPORT virtual QWidget* GetWidget(QWidget* theParent, const bool isToCreate) Standard_OVERRIDE;
62 //! Gets values of attribute using GetValues() and Init the view model
63 //! \param theAttribute a current attribute
64 Standard_EXPORT virtual void Init(const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
66 //! Returns values to fill the table view model
67 //! \param theAttribute a current attribute
68 //! \param theValues a container of values
69 virtual void GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
70 { (void)theAttribute; (void)theValues; };
72 //! Returns common information for the given attribute kind
73 //! \param theAttributeName a kind of attribute
74 //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
75 //! \param theColumnId a tree model column
76 //! \return value, interpreted by tree model depending on the role
77 Standard_EXPORT static QVariant GetAttributeInfoByType(Standard_CString theAttributeName, int theRole, int theColumnId);
79 //! Returns information for the given attribute
80 //! \param theAttribute a current attribute
81 //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
82 //! \param theColumnId a tree model column
83 //! \return value, interpreted by tree model depending on the role
84 Standard_EXPORT virtual QVariant GetAttributeInfo(const Handle(TDF_Attribute)& theAttribute, int theRole, int theColumnId);
86 //! Returns brief attribute information. In general case, it returns even values of GetValues() result.
87 //! \param theAttribute a current attribute
88 //! \param theValues a result list of values
89 Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues);
91 //! Returns list of selection models. In default implementation it contains a selection model for the table view
92 //! \returns container of models
93 virtual std::list<QItemSelectionModel*> GetSelectionModels() Standard_OVERRIDE { return mySelectionModels; }
97 //! Returns converted table view model
98 Standard_EXPORT DFBrowserPane_AttributePaneModel* getPaneModel() const;
100 //! Returns converted table view
101 DFBrowserPane_TableView* getTableView() const { return myTableView; }
103 //! Returns header text values for 0...n table cells in parameter orientation
104 //! \param theOrientation defines horizontal or vertical values
105 //! \param theValues output container of values
106 virtual QList<QVariant> getHeaderValues (const Qt::Orientation theOrientation)
107 { (void)theOrientation; return QList<QVariant>(); }
109 //! Returns number of columns in internal table. By default it returns 2 : method name for method value.
110 //! \return integer value
111 virtual int getColumnCount() const { return 2; }
113 //! Defines widths of table columns
114 //! \return container of widths
115 Standard_EXPORT virtual QMap<int, int> getTableColumnWidths() const;
119 QWidget* myMainWidget; //!< widget created in this pane
120 DFBrowserPane_TableView* myTableView; //!< table for visualization of attribute parameters
121 QAbstractTableModel* myPaneModel; //!< table view model. It is created before the table view, so we need to cache it
122 std::list<QItemSelectionModel*> mySelectionModels; //! selection models