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