0031939: Coding - correction of spelling errors in comments [part 2]
[occt.git] / tools / DFBrowser / DFBrowser_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 DFBrowser_Window_H
17#define DFBrowser_Window_H
18
0cb512c0 19#include <inspector/TInspectorAPI_PluginParameters.hxx>
20
14bbbdcb 21#include <AIS_InteractiveObject.hxx>
22#include <AIS_ListOfInteractive.hxx>
23#include <NCollection_List.hxx>
24#include <Standard.hxx>
25#include <TCollection_AsciiString.hxx>
26#include <TDF_Label.hxx>
14bbbdcb 27
130eb114 28#include <Standard_WarningsDisable.hxx>
14bbbdcb 29#include <QObject>
30#include <QItemSelection>
31#include <QMainWindow>
32#include <QModelIndexList>
130eb114 33#include <Standard_WarningsRestore.hxx>
14bbbdcb 34
35class DFBrowser_DumpView;
36class DFBrowser_Module;
37class DFBrowser_PropertyPanel;
14bbbdcb 38class DFBrowser_Thread;
39class DFBrowser_TreeLevelLine;
40
6822a3be 41class ViewControl_MessageDialog;
7e1c1e48 42class ViewControl_PropertyView;
0cb512c0 43
14bbbdcb 44class View_ToolBar;
45class View_Window;
46
47class QAbstractItemModel;
48class QAction;
7e1c1e48 49class QDockWidget;
14bbbdcb 50class QTreeView;
51class QWidget;
52
53//! \class DFBrowser_Window
54//! Window that unites all DFBrowser controls.
55//! External functionality : it processes plugin parameters, updates controls content and places itself in parent layout.
56//! It Synchronizes controls content depending on current selection.
57//! It shows context popup menu for OCAF tree view.
58class DFBrowser_Window : public QObject
59{
60 Q_OBJECT
61public:
62
63 //! Constructor
64 Standard_EXPORT DFBrowser_Window();
65
66 //! Destructor
7e1c1e48 67 Standard_EXPORT virtual ~DFBrowser_Window();
14bbbdcb 68
69 //! Appends main window into layout of the parent if the parent is child of QWidget
70 //! \param theParent a parent class
71 Standard_EXPORT void SetParent (void* theParent);
72
73 //! Sets parameters container, it should be used when the plugin is initialized or in update content
74 //! \param theParameters a parameters container
75 void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
76
7e1c1e48 77 //! Provides container for actions available in inspector on general level
6822a3be 78 //! \param theMenu if Qt implementation, it is QMenu object
79 Standard_EXPORT virtual void FillActionsMenu (void* theMenu);
80
81 //! Returns plugin preferences: dock widgets state, tree view columns.
82 //! \param theItem container of preference elements
83 Standard_EXPORT void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem);
84
85 //! Applies plugin preferences
86 //! \param theItem container of preference elements
87 Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem);
88
a110c4a3 89 //! Applies parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
14bbbdcb 90 Standard_EXPORT void UpdateContent();
91
92 //! Fills controls of the plugin by parameters:
93 //! - Find TDocStd_Application and fills OCAF tree model if it differs from the current application
94 //! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context
95 //! - If it is the first call, it creates module, start thread to cache application information, fills selection models
96 //! \param theParameters a parameters container
97 Standard_EXPORT void Init (const NCollection_List<Handle(Standard_Transient)>& theParameters);
98
99 //! Opens application by the name, it may be either OCAF document or STEP file.
100 //! Before opening it cleans tree view history, current selections, stop threads(if it was started),
101 //! reset OCAF tree view model. After opening document, it fills all controls by the created application.
102 //! \param theFileName a file name to be opened
103 Standard_EXPORT void OpenFile (const TCollection_AsciiString& theFileName);
104
105 //! Returns main control
106 QWidget* GetMainWindow() const { return myMainWindow; }
107
108 //! Returns the current module
109 DFBrowser_Module* GetModule() const { return myModule; }
110
111 //! Clears thread cache
112 Standard_EXPORT void ClearThreadCache();
113
114 //! Returns tree level line control
115 DFBrowser_TreeLevelLine* GetTreeLevelLine() const { return myTreeLevelLine; }
116
14bbbdcb 117 //! Returns temporary directory defined by environment variables TEMP or TMP
118 //! \return string value
119 Standard_EXPORT static TCollection_AsciiString TmpDirectory();
120
14bbbdcb 121private slots:
122
123 //! Cleans history in tree level line, clears cache of thread processing, starts threads for application
124 void onBeforeUpdateTreeModel();
125
126 //! Shows context menu for tree view selected item. It contains clear view or BREP operations items
127 //! \param thePosition a clicked point
128 void onTreeViewContextMenuRequested (const QPoint& thePosition);
129
7e1c1e48 130 //! Expands two next levels for all selected item
14bbbdcb 131 void onExpand();
132
7e1c1e48 133 //! Expands all levels for all selected items
14bbbdcb 134 void onExpandAll();
135
7e1c1e48 136 //! Collapses all levels for all selected items
14bbbdcb 137 void onCollapseAll();
138
a110c4a3 139 //! Updates all controls by changed selection in OCAF tree view
14bbbdcb 140 //! \param theSelected list of selected tree view items
141 //! \param theDeselected list of deselected tree view items
142 void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
143
144 //! Changes attribute pane stack content depending on search control text
145 void onSearchActivated();
146
147 //! Processes selection change in attribute pane. Depending on selection kind, it will:
148 //! - export to shape viewer
149 //! - display presentation of the pane
150 //! - display references
151 void onPaneSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected,
152 QItemSelectionModel* theModel);
153
154 //! Selects the item in OCAF tree view
155 //! \param theIndex OCAF tree view index
156 void onTreeLevelLineSelected (const QModelIndex& theIndex);
157
158 //! Updates OCAF tree model
159 void onUpdateClicked();
160
a110c4a3 161 //! Highlights OCAF tree model item
14bbbdcb 162 //! \param thePath a container of entries to the item
163 //! \param theValue a label entry or attribute name
164 void onSearchPathSelected (const QStringList& thePath, const QString& theValue);
165
166 //! Selects OCAF tree model item
167 //! \param thePath a container of entries to the item
168 //! \param theValue a label entry or attribute name
169 void onSearchPathDoubleClicked (const QStringList& thePath, const QString& theValue);
170
a110c4a3 171 //! Highlights OCAF tree model item
14bbbdcb 172 //! \param theIndex an OCAF tree model index
173 void onLevelSelected (const QModelIndex& theIndex);
174
175 //! Selects OCAF tree model item
176 //! \param theIndex an OCAF tree model index
177 void onLevelDoubleClicked (const QModelIndex& theIndex);
178
179private:
180
181 //! Inits OCAF tree view with the given model
182 //! \param theModel a model
183 void setOCAFModel (QAbstractItemModel* theModel);
184
185 //! Sets expanded levels in OCAF tree view. Do recursive expand of items.
186 //! \param theTreeView an OCAF tree view
187 //! \param theParentIndex an index which children should be expanded
188 //! \param theLevels a number of levels to be expanded, or -1 for all levels
189 static void setExpandedLevels (QTreeView* theTreeView, const QModelIndex& theParentIndex, const int theLevels);
190
191 //! Marks items highlighted in OCAF tree view model and move view scroll to the first item
192 //! \param theIndices a container of OCAF tree view model indices
193 void highlightIndices (const QModelIndexList& theIndices);
194
14bbbdcb 195 //! Returns candidate to be the window title. It is either name of opened STEP file or the application path
196 //! \return string value
197 QString getWindowTitle() const;
198
199protected:
200
201 //! Returns presentation for the OCAF tree model index. To do this, it uses attribute pane for this item
202 //! \param theIndex a model index
203 //! \return presentation or NULL
204 Handle(AIS_InteractiveObject) findPresentation (const QModelIndex& theIndex);
205
206 //! Returns presentations for the OCAF tree model indices. To do this, it uses attribute pane for this items
207 //! \param theIndex a model index
208 //! \return container of presentations or NULL
209 void findPresentations (const QModelIndexList& theIndices, AIS_ListOfInteractive& thePresentations);
210
14bbbdcb 211private:
212
213 DFBrowser_Module* myModule; //!< current module
214 QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title
215 QMainWindow* myMainWindow; //!< main control for all components
216 DFBrowser_TreeLevelLine* myTreeLevelLine; //!< navigate line of tree levels to the selected item
217 QTreeView* myTreeView; //!< OCAF tree view
7e1c1e48 218 QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
14bbbdcb 219 DFBrowser_PropertyPanel* myPropertyPanel; //!< property panel shows full information about attribute or search view
7e1c1e48 220 ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
14bbbdcb 221 View_Window* myViewWindow; //!< V3d view to visualize presentations/references if it can be build for a selected item
222 DFBrowser_DumpView* myDumpView; //!< Text editor where "Dump" method output is shown
223 DFBrowser_Thread* myThread; //!< Threads manipulator, starting thread items, listens finalizing
6822a3be 224 ViewControl_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin
14bbbdcb 225 Handle(TInspectorAPI_PluginParameters) myParameters; //!< contains application, context, files that should be opened
042e09aa 226 QString myOpenedFileName; //!< cached name of opened file between parent is set, apply it by parent setting and nullify
14bbbdcb 227};
228
229#endif