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 <TInspectorAPI_PluginParameters.hxx>
24 #include <VInspector_CallBack.hxx>
27 #include <QItemSelection>
28 #include <QMainWindow>
30 class VInspector_ToolBar;
32 class QAbstractItemModel;
38 //! \class VInspector_Window
39 //! Window that unites all VInspector controls.
40 class VInspector_Window : public QObject
47 Standard_EXPORT VInspector_Window();
50 virtual ~VInspector_Window() Standard_OVERRIDE {}
52 //! Provides the container with a parent where this container should be inserted.
53 //! If Qt implementation, it should be QWidget with QLayout set inside
54 //! \param theParent a parent class
55 Standard_EXPORT void SetParent (void* theParent);
57 //! Sets parameters container, it should be used when the plugin is initialized or in update content
58 //! \param theParameters a parameters container
59 void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
61 //! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
62 Standard_EXPORT void UpdateContent();
64 //! Returns main control
65 QWidget* GetMainWindow() const { return myMainWindow; }
69 //! Fills controls of the plugin by parameters:
70 //! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context
71 //! \param theParameters a parameters container
72 void Init (const NCollection_List<Handle(Standard_Transient)>& theParameters);
74 //! Read BREP file, creates AIS presentation for the shape and visualize it in the current context
75 //! \param theFileName a name of BREP file
76 void OpenFile (const TCollection_AsciiString& theFileName);
80 //! Shows context menu for tree view selected item. It contains clear view or BREP operations items
81 //! \param thePosition a clicked point
82 void onTreeViewContextMenuRequested(const QPoint& thePosition);
84 //! Performs the functionality of the clicked action
85 //! \param theActionId an action identifier in tool bar
86 void onToolBarActionClicked (const int theActionId);
88 //! Synchronization selection between history and tree view. Selection by history view
89 //! \param theSelected a selected items
90 //! \param theDeselected a deselected items
91 void onHistoryViewSelectionChanged (const QItemSelection& theSelected,
92 const QItemSelection& theDeselected);
94 //! Processes selection in tree view: make presentation or owner selected in the context if corresponding
95 //! check box is checked
96 //! \param theSelected a selected items
97 //! \param theDeselected a deselected items
98 void onSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
100 //! Exports the first selected shape into ShapeViewer plugin.
101 void onExportToShapeView();
103 //! Shows selected presentation if it is not shown yet
106 //! Erase selected presentation if it is shown
111 //! Inits the window content by the given context
112 //! \param theContext a context
113 void SetContext (const Handle(AIS_InteractiveContext)& theContext);
115 //! Updates tree model
116 void UpdateTreeModel();
118 //! Creates an action with the given text connected to the slot
119 //! \param theText an action text value
120 //! \param theSlot a listener of triggered signal of the new action
121 //! \return a new action
122 QAction* createAction(const QString& theText, const char* theSlot);
124 //! Set selected in tree view presentations displayed or erased in the current context. Note that erased presentations
125 //! still belongs to the current context until Remove is called.
126 //! \param theToDisplay if true, presentation is displayed otherwise erased
127 void displaySelectedPresentations (const bool theToDisplay);
131 QMainWindow* myMainWindow; //!< main control
132 VInspector_ToolBar* myToolBar; //!< tool bar actions
133 QTreeView* myTreeView; //!< tree view of AIS content
134 QTreeView* myHistoryView; //!< history of AIS context calls
135 Handle(VInspector_CallBack) myCallBack; //!< AIS context call back, if set
137 Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container