0029807: [Regression to 7.0.0] Impossible to cut cone from prism
[occt.git] / tools / VInspector / VInspector_Window.hxx
CommitLineData
14bbbdcb 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 <SelectBasics_EntityOwner.hxx>
22#include <Standard.hxx>
6822a3be 23
0cb512c0 24#include <inspector/TInspectorAPI_PluginParameters.hxx>
25#include <inspector/VInspector_CallBack.hxx>
14bbbdcb 26
130eb114 27#include <Standard_WarningsDisable.hxx>
14bbbdcb 28#include <QObject>
29#include <QItemSelection>
30#include <QMainWindow>
130eb114 31#include <Standard_WarningsRestore.hxx>
14bbbdcb 32
6822a3be 33class ViewControl_MessageDialog;
0cb512c0 34
14bbbdcb 35class VInspector_ToolBar;
0cb512c0 36class View_Window;
14bbbdcb 37
38class QAbstractItemModel;
39class QAction;
40class QMainWindow;
41class QTreeView;
42class QWidget;
43
44//! \class VInspector_Window
45//! Window that unites all VInspector controls.
46class VInspector_Window : public QObject
47{
48 Q_OBJECT
49
50public:
51
52 //! Constructor
53 Standard_EXPORT VInspector_Window();
54
55 //! Destructor
56 virtual ~VInspector_Window() Standard_OVERRIDE {}
57
58 //! Provides the container with a parent where this container should be inserted.
59 //! If Qt implementation, it should be QWidget with QLayout set inside
60 //! \param theParent a parent class
61 Standard_EXPORT void SetParent (void* theParent);
62
63 //! Sets parameters container, it should be used when the plugin is initialized or in update content
64 //! \param theParameters a parameters container
65 void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
66
6822a3be 67 //! Provide container for actions available in inspector on general level
68 //! \param theMenu if Qt implementation, it is QMenu object
69 Standard_EXPORT void FillActionsMenu (void* theMenu);
70
71 //! Returns plugin preferences: dock widgets state, tree view columns.
72 //! \param theItem container of preference elements
73 Standard_EXPORT void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem);
74
75 //! Applies plugin preferences
76 //! \param theItem container of preference elements
77 Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem);
78
14bbbdcb 79 //! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
80 Standard_EXPORT void UpdateContent();
81
82 //! Returns main control
83 QWidget* GetMainWindow() const { return myMainWindow; }
84
85private:
86
87 //! Fills controls of the plugin by parameters:
88 //! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context
89 //! \param theParameters a parameters container
6822a3be 90 bool Init (const NCollection_List<Handle(Standard_Transient)>& theParameters);
14bbbdcb 91
92 //! Read BREP file, creates AIS presentation for the shape and visualize it in the current context
93 //! \param theFileName a name of BREP file
6822a3be 94 bool OpenFile (const TCollection_AsciiString& theFileName);
14bbbdcb 95
96private slots:
97
98 //! Shows context menu for tree view selected item. It contains clear view or BREP operations items
99 //! \param thePosition a clicked point
100 void onTreeViewContextMenuRequested(const QPoint& thePosition);
101
102 //! Performs the functionality of the clicked action
103 //! \param theActionId an action identifier in tool bar
104 void onToolBarActionClicked (const int theActionId);
105
106 //! Synchronization selection between history and tree view. Selection by history view
107 //! \param theSelected a selected items
108 //! \param theDeselected a deselected items
109 void onHistoryViewSelectionChanged (const QItemSelection& theSelected,
110 const QItemSelection& theDeselected);
111
112 //! Processes selection in tree view: make presentation or owner selected in the context if corresponding
113 //! check box is checked
114 //! \param theSelected a selected items
115 //! \param theDeselected a deselected items
116 void onSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
117
118 //! Exports the first selected shape into ShapeViewer plugin.
119 void onExportToShapeView();
120
121 //! Shows selected presentation if it is not shown yet
122 void onShow();
123
124 //! Erase selected presentation if it is shown
125 void onHide();
126
127private:
128
129 //! Inits the window content by the given context
130 //! \param theContext a context
131 void SetContext (const Handle(AIS_InteractiveContext)& theContext);
132
133 //! Updates tree model
134 void UpdateTreeModel();
135
14bbbdcb 136 //! Set selected in tree view presentations displayed or erased in the current context. Note that erased presentations
137 //! still belongs to the current context until Remove is called.
138 //! \param theToDisplay if true, presentation is displayed otherwise erased
139 void displaySelectedPresentations (const bool theToDisplay);
140
0cb512c0 141 //! Creates an istance of 3D view to initialize context.
142 //! \return a context of created view.
143 Handle(AIS_InteractiveContext) createView();
144
14bbbdcb 145private:
146
0cb512c0 147 QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title
148
14bbbdcb 149 QMainWindow* myMainWindow; //!< main control
150 VInspector_ToolBar* myToolBar; //!< tool bar actions
151 QTreeView* myTreeView; //!< tree view of AIS content
152 QTreeView* myHistoryView; //!< history of AIS context calls
153 Handle(VInspector_CallBack) myCallBack; //!< AIS context call back, if set
154
6822a3be 155 ViewControl_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin
0cb512c0 156 View_Window* myViewWindow; //!< temporary view window, it is created if Open is called but context is still NULL
157
14bbbdcb 158 Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
159};
160
161#endif