0029807: [Regression to 7.0.0] Impossible to cut cone from prism
[occt.git] / tools / DFBrowserPane / DFBrowserPane_AttributePane.hxx
CommitLineData
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
130eb114 25#include <Standard_WarningsDisable.hxx>
14bbbdcb 26#include <QList>
27#include <QVariant>
130eb114 28#include <Standard_WarningsRestore.hxx>
14bbbdcb 29
30class DFBrowserPane_AttributePaneModel;
31class DFBrowserPane_TableView;
32
33class QAbstractTableModel;
34class QItemSelectionModel;
35
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
41class DFBrowserPane_AttributePane : public DFBrowserPane_AttributePaneAPI
42{
43public:
44
45 //! Constructor
46 Standard_EXPORT DFBrowserPane_AttributePane();
47
48 //! Destructor
49 virtual ~DFBrowserPane_AttributePane() {}
50
51 //! Creates a new widget
52 //! \param theParent a parent widget
53 //! \return pane widget
54 Standard_EXPORT virtual QWidget* CreateWidget(QWidget* theParent);
55
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;
61
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;
65
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; };
71
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(const Standard_CString& theAttributeName, int theRole, int theColumnId);
78
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);
85
d2c90917 86 //! Returns brief attribute information. In general case, it returns even values of GetValues() result.
14bbbdcb 87 //! \param theAttribute a current attribute
88 //! \param theValues a result list of values
d2c90917 89 Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues);
14bbbdcb 90
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; }
94
95protected:
96
97 //! Returns converted table view model
98 Standard_EXPORT DFBrowserPane_AttributePaneModel* getPaneModel() const;
99
100 //! Returns converted table view
101 DFBrowserPane_TableView* getTableView() const { return myTableView; }
102
d2c90917 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>(); }
108
109 //! Retuns 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; }
112
14bbbdcb 113 //! Defines widths of table columns
114 //! \return container of widths
115 Standard_EXPORT virtual QMap<int, int> getTableColumnWidths() const;
116
117protected:
118
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
123};
124
125#endif