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 <SelectBasics_EntityOwner.hxx>
22 #include <Standard.hxx>
24 #include <inspector/TInspectorAPI_PluginParameters.hxx>
25 #include <inspector/VInspector_CallBack.hxx>
26 #include <inspector/View_DisplayActionType.hxx>
28 #include <Standard_WarningsDisable.hxx>
30 #include <QItemSelection>
31 #include <QMainWindow>
32 #include <Standard_WarningsRestore.hxx>
34 class ViewControl_MessageDialog;
35 class ViewControl_PropertyView;
37 class VInspector_ToolBar;
42 class QAbstractItemModel;
48 //! \class VInspector_Window
49 //! Window that unites all VInspector controls.
50 class VInspector_Window : public QObject
57 Standard_EXPORT VInspector_Window();
60 virtual ~VInspector_Window() {}
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);
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; }
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);
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);
79 //! Applies plugin preferences
80 //! \param theItem container of preference elements
81 Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem);
83 //! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
84 Standard_EXPORT void UpdateContent();
86 //! Returns main control
87 QWidget* GetMainWindow() const { return myMainWindow; }
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);
94 //! Returns selected shapes
95 //! \param [out] container of shapes
96 void SelectedShapes (NCollection_List<Handle(Standard_Transient)>& theSelPresentations);
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);
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);
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);
115 //! Performs the functionality of the clicked action
116 //! \param theActionId an action identifier in tool bar
117 void onToolBarActionClicked (const int theActionId);
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);
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);
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);
135 //! Exports the first selected shape into ShapeViewer plugin.
136 void onExportToShapeView();
138 //! Apply activated display action
139 void onDisplayActionTypeClicked();
141 //! Expand two next levels for all selected item
144 //! Expand all levels for all selected items
147 //! Collapse all levels for all selected items
148 void onCollapseAll();
150 //! Creates a tree of inherited presentable objects
151 void OnTestAddChild();
155 //! Inits the window content by the given context
156 //! \param theContext a context
157 void SetContext (const Handle(AIS_InteractiveContext)& theContext);
159 //! Updates tree model
160 void UpdateTreeModel();
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);
167 //! Set items of the pointers highlighted in tree view
168 //! \param theType display action type
169 void highlightTreeViewItems (const QStringList& thePointers);
171 //! Set items of the pointers selected in tree view
172 //! \param theType display action type
173 void selectTreeViewItems (const QStringList& thePointers);
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();
179 //! Creates an istance of 3D view to initialize context.
180 //! \return a context of created view.
181 Handle(AIS_InteractiveContext) createView();
185 QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title
187 QMainWindow* myMainWindow; //!< main control
188 VInspector_ToolBar* myToolBar; //!< tool bar actions
190 QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
191 ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
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
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
200 Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
202 View_Displayer* myDisplayer; //!< class to display presentations/preview if myMainWindow is not used