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 VInspector_Window_H
17 #define VInspector_Window_H
19 #include <AIS_InteractiveContext.hxx>
20 #include <NCollection_List.hxx>
21 #include <SelectMgr_EntityOwner.hxx>
23 #include <inspector/TInspectorAPI_PluginParameters.hxx>
24 #include <inspector/View_DisplayActionType.hxx>
26 #include <Standard_WarningsDisable.hxx>
28 #include <QItemSelection>
29 #include <QMainWindow>
30 #include <Standard_WarningsRestore.hxx>
32 class ViewControl_MessageDialog;
33 class ViewControl_PropertyView;
35 class VInspector_ToolBar;
40 class QAbstractItemModel;
46 //! \class VInspector_Window
47 //! Window that unites all VInspector controls.
48 class VInspector_Window : public QObject
55 Standard_EXPORT VInspector_Window();
58 virtual ~VInspector_Window() {}
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);
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; }
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);
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);
77 //! Applies plugin preferences
78 //! \param theItem container of preference elements
79 Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem);
81 //! Applies parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
82 Standard_EXPORT void UpdateContent();
84 //! Returns main control
85 QWidget* GetMainWindow() const { return myMainWindow; }
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);
92 //! Returns selected shapes
93 //! \param [out] container of shapes
94 void SelectedShapes (NCollection_List<Handle(Standard_Transient)>& theSelPresentations);
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);
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);
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);
113 //! Performs the functionality of the clicked action
114 //! \param theActionId an action identifier in tool bar
115 void onToolBarActionClicked (const int theActionId);
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);
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);
127 //! Exports the first selected shape into ShapeViewer plugin.
128 void onExportToShapeView();
130 //! Appends lights into the active V3d view
133 //! Removes selected light from the active V3d view
134 void onRemoveLight();
136 //! Switch On/Off for selected light
139 //! Apply activated display action
140 void onDisplayActionTypeClicked();
142 //! Expand two next levels for all selected item
145 //! Expand all levels for all selected items
148 //! Collapse all levels for all selected items
149 void onCollapseAll();
153 //! Inits the window content by the given context
154 //! \param theContext a context
155 void SetContext (const Handle(AIS_InteractiveContext)& theContext);
157 //! Updates tree model
158 void UpdateTreeModel();
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);
165 //! Set items of the pointers highlighted in tree view
166 //! \param theType display action type
167 void highlightTreeViewItems (const QStringList& thePointers);
169 //! Set items of the pointers selected in tree view
170 //! \param theType display action type
171 void selectTreeViewItems (const QStringList& thePointers);
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();
177 //! Creates an instance of 3D view to initialize context.
178 //! \return a context of created view.
179 Handle(AIS_InteractiveContext) createView();
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);
188 QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title
190 QMainWindow* myMainWindow; //!< main control
191 VInspector_ToolBar* myToolBar; //!< tool bar actions
193 QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
194 ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
196 QTreeView* myTreeView; //!< tree view of AIS content
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
201 Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
203 View_Displayer* myDisplayer; //!< class to display presentations/preview if myMainWindow is not used