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>
23 #include <inspector/TInspectorAPI_PluginParameters.hxx>
24 #include <inspector/VInspector_CallBack.hxx>
27 #include <QItemSelection>
28 #include <QMainWindow>
30 class TreeModel_MessageDialog;
32 class VInspector_ToolBar;
35 class QAbstractItemModel;
41 //! \class VInspector_Window
42 //! Window that unites all VInspector controls.
43 class VInspector_Window : public QObject
50 Standard_EXPORT VInspector_Window();
53 virtual ~VInspector_Window() Standard_OVERRIDE {}
55 //! Provides the container with a parent where this container should be inserted.
56 //! If Qt implementation, it should be QWidget with QLayout set inside
57 //! \param theParent a parent class
58 Standard_EXPORT void SetParent (void* theParent);
60 //! Sets parameters container, it should be used when the plugin is initialized or in update content
61 //! \param theParameters a parameters container
62 void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
64 //! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
65 Standard_EXPORT void UpdateContent();
67 //! Returns main control
68 QWidget* GetMainWindow() const { return myMainWindow; }
72 //! Fills controls of the plugin by parameters:
73 //! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context
74 //! \param theParameters a parameters container
75 void Init (const NCollection_List<Handle(Standard_Transient)>& theParameters);
77 //! Read BREP file, creates AIS presentation for the shape and visualize it in the current context
78 //! \param theFileName a name of BREP file
79 void OpenFile (const TCollection_AsciiString& theFileName);
83 //! Shows context menu for tree view selected item. It contains clear view or BREP operations items
84 //! \param thePosition a clicked point
85 void onTreeViewContextMenuRequested(const QPoint& thePosition);
87 //! Performs the functionality of the clicked action
88 //! \param theActionId an action identifier in tool bar
89 void onToolBarActionClicked (const int theActionId);
91 //! Synchronization selection between history and tree view. Selection by history view
92 //! \param theSelected a selected items
93 //! \param theDeselected a deselected items
94 void onHistoryViewSelectionChanged (const QItemSelection& theSelected,
95 const QItemSelection& theDeselected);
97 //! Processes selection in tree view: make presentation or owner selected in the context if corresponding
98 //! check box is checked
99 //! \param theSelected a selected items
100 //! \param theDeselected a deselected items
101 void onSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
103 //! Exports the first selected shape into ShapeViewer plugin.
104 void onExportToShapeView();
106 //! Shows selected presentation if it is not shown yet
109 //! Erase selected presentation if it is shown
114 //! Inits the window content by the given context
115 //! \param theContext a context
116 void SetContext (const Handle(AIS_InteractiveContext)& theContext);
118 //! Updates tree model
119 void UpdateTreeModel();
121 //! Creates an action with the given text connected to the slot
122 //! \param theText an action text value
123 //! \param theSlot a listener of triggered signal of the new action
124 //! \return a new action
125 QAction* createAction(const QString& theText, const char* theSlot);
127 //! Set selected in tree view presentations displayed or erased in the current context. Note that erased presentations
128 //! still belongs to the current context until Remove is called.
129 //! \param theToDisplay if true, presentation is displayed otherwise erased
130 void displaySelectedPresentations (const bool theToDisplay);
132 //! Creates an istance of 3D view to initialize context.
133 //! \return a context of created view.
134 Handle(AIS_InteractiveContext) createView();
138 QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title
140 QMainWindow* myMainWindow; //!< main control
141 VInspector_ToolBar* myToolBar; //!< tool bar actions
142 QTreeView* myTreeView; //!< tree view of AIS content
143 QTreeView* myHistoryView; //!< history of AIS context calls
144 Handle(VInspector_CallBack) myCallBack; //!< AIS context call back, if set
146 TreeModel_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin
147 View_Window* myViewWindow; //!< temporary view window, it is created if Open is called but context is still NULL
149 Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container