0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[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 <SelectMgr_EntityOwner.hxx>
22
23 #include <inspector/TInspectorAPI_PluginParameters.hxx>
24 #include <inspector/View_DisplayActionType.hxx>
25
26 #include <Standard_WarningsDisable.hxx>
27 #include <QObject>
28 #include <QItemSelection>
29 #include <QMainWindow>
30 #include <Standard_WarningsRestore.hxx>
31
32 class ViewControl_MessageDialog;
33 class ViewControl_PropertyView;
34
35 class VInspector_ToolBar;
36
37 class View_Displayer;
38 class View_Window;
39
40 class QAbstractItemModel;
41 class QAction;
42 class QDockWidget;
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
58   virtual ~VInspector_Window() {}
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
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
81   //! Applies parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
82   Standard_EXPORT void UpdateContent();
83
84   //! Returns main control
85   QWidget* GetMainWindow() const { return myMainWindow; }
86
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
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
101   bool Init (const NCollection_List<Handle(Standard_Transient)>& theParameters);
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
105   bool OpenFile (const TCollection_AsciiString& theFileName);
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
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
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
125   void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
126
127   //! Exports the first selected shape into ShapeViewer plugin.
128   void onExportToShapeView();
129
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
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();
150
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
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.
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();
176
177   //! Creates an instance of 3D view to initialize context.
178   //! \return a context of created view.
179   Handle(AIS_InteractiveContext) createView();
180
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
186 private:
187
188   QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title
189
190   QMainWindow* myMainWindow; //!< main control
191   VInspector_ToolBar* myToolBar; //!< tool bar actions
192
193   QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
194   ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
195
196   QTreeView* myTreeView; //!< tree view of AIS content
197
198   ViewControl_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin
199   View_Window* myViewWindow; //!< temporary view window, it is created if Open is called but context is still NULL
200
201   Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
202
203   View_Displayer* myDisplayer; //!< class to display presentations/preview if myMainWindow is not used
204 };
205
206 #endif