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_Window_H |
17 | #define VInspector_Window_H |
18 | |
19 | #include <AIS_InteractiveContext.hxx> |
20 | #include <NCollection_List.hxx> |
bbd92927 |
21 | #include <SelectMgr_EntityOwner.hxx> |
6822a3be |
22 | |
0cb512c0 |
23 | #include <inspector/TInspectorAPI_PluginParameters.hxx> |
7e1c1e48 |
24 | #include <inspector/View_DisplayActionType.hxx> |
14bbbdcb |
25 | |
130eb114 |
26 | #include <Standard_WarningsDisable.hxx> |
14bbbdcb |
27 | #include <QObject> |
28 | #include <QItemSelection> |
29 | #include <QMainWindow> |
130eb114 |
30 | #include <Standard_WarningsRestore.hxx> |
14bbbdcb |
31 | |
6822a3be |
32 | class ViewControl_MessageDialog; |
7e1c1e48 |
33 | class ViewControl_PropertyView; |
0cb512c0 |
34 | |
14bbbdcb |
35 | class VInspector_ToolBar; |
7e1c1e48 |
36 | |
37 | class View_Displayer; |
0cb512c0 |
38 | class View_Window; |
14bbbdcb |
39 | |
40 | class QAbstractItemModel; |
41 | class QAction; |
7e1c1e48 |
42 | class QDockWidget; |
14bbbdcb |
43 | class QTreeView; |
44 | class QWidget; |
45 | |
46 | //! \class VInspector_Window |
47 | //! Window that unites all VInspector controls. |
48 | class VInspector_Window : public QObject |
49 | { |
50 | Q_OBJECT |
51 | |
52 | public: |
53 | |
54 | //! Constructor |
55 | Standard_EXPORT VInspector_Window(); |
56 | |
57 | //! Destructor |
7e1c1e48 |
58 | virtual ~VInspector_Window() {} |
14bbbdcb |
59 | |
60 | //! Provides the container with a parent where this container should be inserted. |
61 | //! If Qt implementation, it should be QWidget with QLayout set inside |
62 | //! \param theParent a parent class |
63 | Standard_EXPORT void SetParent (void* theParent); |
64 | |
65 | //! Sets parameters container, it should be used when the plugin is initialized or in update content |
66 | //! \param theParameters a parameters container |
67 | void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; } |
68 | |
6822a3be |
69 | //! Provide container for actions available in inspector on general level |
70 | //! \param theMenu if Qt implementation, it is QMenu object |
71 | Standard_EXPORT void FillActionsMenu (void* theMenu); |
72 | |
73 | //! Returns plugin preferences: dock widgets state, tree view columns. |
74 | //! \param theItem container of preference elements |
75 | Standard_EXPORT void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem); |
76 | |
77 | //! Applies plugin preferences |
78 | //! \param theItem container of preference elements |
79 | Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem); |
80 | |
a110c4a3 |
81 | //! Applies parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model |
14bbbdcb |
82 | Standard_EXPORT void UpdateContent(); |
83 | |
84 | //! Returns main control |
85 | QWidget* GetMainWindow() const { return myMainWindow; } |
86 | |
7e1c1e48 |
87 | //! Returns presentations of selected items in tree model |
88 | //! \param theModel selection model |
89 | //! \return container of presentations |
90 | NCollection_List<Handle(AIS_InteractiveObject)> SelectedPresentations (QItemSelectionModel* theModel); |
91 | |
92 | //! Returns selected shapes |
93 | //! \param [out] container of shapes |
94 | void SelectedShapes (NCollection_List<Handle(Standard_Transient)>& theSelPresentations); |
95 | |
14bbbdcb |
96 | private: |
97 | |
98 | //! Fills controls of the plugin by parameters: |
99 | //! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context |
100 | //! \param theParameters a parameters container |
6822a3be |
101 | bool Init (const NCollection_List<Handle(Standard_Transient)>& theParameters); |
14bbbdcb |
102 | |
103 | //! Read BREP file, creates AIS presentation for the shape and visualize it in the current context |
104 | //! \param theFileName a name of BREP file |
6822a3be |
105 | bool OpenFile (const TCollection_AsciiString& theFileName); |
14bbbdcb |
106 | |
107 | private slots: |
108 | |
109 | //! Shows context menu for tree view selected item. It contains clear view or BREP operations items |
110 | //! \param thePosition a clicked point |
111 | void onTreeViewContextMenuRequested(const QPoint& thePosition); |
112 | |
113 | //! Performs the functionality of the clicked action |
114 | //! \param theActionId an action identifier in tool bar |
115 | void onToolBarActionClicked (const int theActionId); |
116 | |
7e1c1e48 |
117 | //! Display content of selected tree view item if isToggled is true |
118 | //! \param isToggled true if the property dock widget is shown |
119 | void onPropertyPanelShown (bool isToggled); |
120 | |
14bbbdcb |
121 | //! Processes selection in tree view: make presentation or owner selected in the context if corresponding |
122 | //! check box is checked |
123 | //! \param theSelected a selected items |
124 | //! \param theDeselected a deselected items |
7e1c1e48 |
125 | void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected); |
14bbbdcb |
126 | |
127 | //! Exports the first selected shape into ShapeViewer plugin. |
128 | void onExportToShapeView(); |
129 | |
d16ecfe2 |
130 | //! Appends lights into the active V3d view |
131 | void onAddLight(); |
132 | |
133 | //! Removes selected light from the active V3d view |
134 | void onRemoveLight(); |
135 | |
136 | //! Switch On/Off for selected light |
137 | void onOnOffLight(); |
138 | |
7e1c1e48 |
139 | //! Apply activated display action |
140 | void onDisplayActionTypeClicked(); |
141 | |
142 | //! Expand two next levels for all selected item |
143 | void onExpand(); |
144 | |
145 | //! Expand all levels for all selected items |
146 | void onExpandAll(); |
147 | |
148 | //! Collapse all levels for all selected items |
149 | void onCollapseAll(); |
14bbbdcb |
150 | |
14bbbdcb |
151 | private: |
152 | |
153 | //! Inits the window content by the given context |
154 | //! \param theContext a context |
155 | void SetContext (const Handle(AIS_InteractiveContext)& theContext); |
156 | |
157 | //! Updates tree model |
158 | void UpdateTreeModel(); |
159 | |
14bbbdcb |
160 | //! Set selected in tree view presentations displayed or erased in the current context. Note that erased presentations |
161 | //! still belongs to the current context until Remove is called. |
7e1c1e48 |
162 | //! \param theType display action type |
163 | void displaySelectedPresentations (const View_DisplayActionType theType); |
164 | |
165 | //! Set items of the pointers highlighted in tree view |
166 | //! \param theType display action type |
167 | void highlightTreeViewItems (const QStringList& thePointers); |
168 | |
169 | //! Set items of the pointers selected in tree view |
170 | //! \param theType display action type |
171 | void selectTreeViewItems (const QStringList& thePointers); |
172 | |
173 | //! Returns displayer where the presentations/preview should be shown/erased |
174 | //! If default view is created, it returns displayer of this view |
175 | Standard_EXPORT View_Displayer* displayer(); |
14bbbdcb |
176 | |
a110c4a3 |
177 | //! Creates an instance of 3D view to initialize context. |
0cb512c0 |
178 | //! \return a context of created view. |
179 | Handle(AIS_InteractiveContext) createView(); |
180 | |
d16ecfe2 |
181 | //! Creates a new default light into V3d viewer |
182 | //! \param theSourceLight type of light source |
183 | //! \param theViewer viewer to add the created light |
184 | void addLight (const Graphic3d_TypeOfLightSource& theSourceLight, const Handle(V3d_Viewer)& theViewer); |
185 | |
14bbbdcb |
186 | private: |
187 | |
0cb512c0 |
188 | QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title |
189 | |
14bbbdcb |
190 | QMainWindow* myMainWindow; //!< main control |
191 | VInspector_ToolBar* myToolBar; //!< tool bar actions |
7e1c1e48 |
192 | |
193 | QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget |
194 | ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist |
195 | |
14bbbdcb |
196 | QTreeView* myTreeView; //!< tree view of AIS content |
14bbbdcb |
197 | |
6822a3be |
198 | ViewControl_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin |
0cb512c0 |
199 | View_Window* myViewWindow; //!< temporary view window, it is created if Open is called but context is still NULL |
200 | |
14bbbdcb |
201 | Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container |
7e1c1e48 |
202 | |
203 | View_Displayer* myDisplayer; //!< class to display presentations/preview if myMainWindow is not used |
14bbbdcb |
204 | }; |
205 | |
206 | #endif |