SHAPER 9.16.0
SHAPERGUI_SalomeViewer.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef SHAPERGUI_SalomeViewer_H
21#define SHAPERGUI_SalomeViewer_H
22
23#include "SHAPER_SHAPERGUI.h"
24
25#include <ModuleBase_IViewer.h>
26#include <ModuleBase_IViewWindow.h>
27
28#include <OCCViewer_ViewWindow.h>
29
30#include <V3d_View.hxx>
31#include <AIS_Trihedron.hxx>
32
33class SUIT_ViewWindow;
34class QMouseEvent;
35class QKeyEvent;
36
38class OCCViewer_Viewer;
39class SUIT_ViewManager;
40class AIS_TextLabel;
41
48{
49public:
52 SHAPERGUI_SalomeView(OCCViewer_Viewer* theViewer);
53
54 virtual Handle(V3d_View) v3dView() const;
55
57 virtual QWidget* viewPort() const;
58
61 void setViewer(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
62
64 OCCViewer_Viewer* viewer() const { return myViewer; }
65
67 void setCurrentView(SUIT_ViewWindow* theView) { myCurrentView = theView; }
68
69private:
71 OCCViewer_Viewer* myViewer;
72 SUIT_ViewWindow* myCurrentView;
73};
74
75
82{
83Q_OBJECT
84 public:
88
90
92 virtual Handle(AIS_InteractiveContext) AISContext() const;
93
95 virtual Handle(V3d_Viewer) v3dViewer() const;
96
98 virtual Handle(AIS_Trihedron) trihedron() const;
99
101 virtual Handle(V3d_View) activeView() const;
102
104 virtual QWidget* activeViewPort() const;
105
107 virtual void enableSelection(bool isEnabled);
108
110 virtual bool isSelectionEnabled() const;
111
113 virtual void enableMultiselection(bool isEnable);
114
116 virtual bool isMultiSelectionEnabled() const;
117
119 virtual bool enableDrawMode(bool isEnabled);
120
122 void reconnectActions(SUIT_ViewWindow* theWindow, const bool theUseSHAPERSlot);
123
125 virtual void fitAll();
126
128 virtual void eraseAll();
129
135 virtual void setViewProjection( double theX, double theY, double theZ,
136 double theTwist );
137
145 virtual void setViewProjection( double theX, double theY, double theZ,
146 double theUpX, double theUpY, double theUpZ);
147
151
153 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
154
156 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
157
160 virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
161
163 virtual void clearSelectionFilters();
164
167 {
168 return mySelector;
169 }
170
172 virtual void update();
173
176 virtual bool canDragByMouse() const;
177
180 void activateViewer(bool toActivate);
181
182 // Methods for color scale management
183
185 virtual bool isColorScaleVisible() const;
186
188 virtual void setColorScaleShown(bool on);
189
191 // \param theX is X position relative to current view width
192 // \param theY is Y position relative to current view height
193 virtual void setColorScalePosition(double theX, double theY);
194
196 // \param theW is width relative to current view width
197 // \param theh is height relative to current view height
198 virtual void setColorScaleSize(double theW, double theH);
199
201 // \param theMin is a minimal value
202 // \param theMax is a maximal value
203 virtual void setColorScaleRange(double theMin, double theMax);
204
206 // \param theNb is number of intervals
207 virtual void setColorScaleIntervals(int theNb);
208
210 // \param theH is number of intervals
211 virtual void setColorScaleTextHeigth(int theH);
212
214 // \param theH is number of intervals
215 virtual void setColorScaleTextColor(const QColor& theColor);
216
218 // \param theText is a title
219 virtual void setColorScaleTitle(const QString& theText);
220
225 virtual void setText(const ModuleBase_IViewer::TextColor& theText, const int theSize);
226
227 virtual void setFitter(OCCViewer_Fitter* theFitter);
228 virtual OCCViewer_Fitter* fitter() const;
229
230 private slots:
231 void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
232 void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
233 void onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
234 void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
235 void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
236 void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
237
238 void onTryCloseView(SUIT_ViewWindow*);
239 void onDeleteView(SUIT_ViewWindow*);
240 void onViewCreated(SUIT_ViewWindow*);
241 void onActivated(SUIT_ViewManager*);
242
243 void onSelectionChanged();
244 void onViewTransformed(OCCViewer_ViewWindow::OperationType);
245
249 void onViewPortMapped();
250
252 void onAfterViewCreated();
253
254 private:
255 SHAPERGUI_OCCSelector* mySelector;
256 SHAPERGUI_SalomeView* myView;
257 bool myIsSelectionChanged;
260 NCollection_List<Handle(AIS_TextLabel)> myText;
261};
262
263
264#endif
Interface to ViewWindow object which contains 3d scene.
Definition: ModuleBase_IViewWindow.h:34
A Base object for definition of connector object to Salome Viewer.
Definition: ModuleBase_IViewer.h:47
std::list< std::pair< std::wstring, std::vector< int > > > TextColor
Type for mapping from text to color to display the names lines in different colors.
Definition: ModuleBase_IViewer.h:201
Redefinition of standard OCC selector in order to adapt it to SHAPER needs.
Definition: SHAPERGUI_OCCSelector.h:32
A class for providing access of SHAPERGUI functionality to SALOME view window functionality.
Definition: SHAPERGUI_SalomeViewer.h:48
OCCViewer_Viewer * viewer() const
Returns current viewer.
Definition: SHAPERGUI_SalomeViewer.h:64
void setCurrentView(SUIT_ViewWindow *theView)
Sets the current view.
Definition: SHAPERGUI_SalomeViewer.h:67
void setViewer(OCCViewer_Viewer *theViewer)
Set the current viewer.
Definition: SHAPERGUI_SalomeViewer.h:61
virtual Handle v3dView() const
Returns OCCT object which contains 3d view object.
Definition: SHAPERGUI_SalomeViewer.cpp:52
SHAPERGUI_SalomeView(OCCViewer_Viewer *theViewer)
Constructor.
Definition: SHAPERGUI_SalomeViewer.cpp:45
virtual QWidget * viewPort() const
Returns the view window view port.
Definition: SHAPERGUI_SalomeViewer.cpp:62
A class for providing access of SHAPERGUI functionality to SALOME viewer functionality.
Definition: SHAPERGUI_SalomeViewer.h:82
virtual bool isMultiSelectionEnabled() const
Returns true if multiselection is enabled.
Definition: SHAPERGUI_SalomeViewer.cpp:338
virtual void enableSelection(bool isEnabled)
Enable or disable selection in the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:311
virtual void fitAll()
Performs the fit all for the active view.
Definition: SHAPERGUI_SalomeViewer.cpp:381
virtual void setColorScaleSize(double theW, double theH)
Set size of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:575
virtual void setColorScaleRange(double theMin, double theMax)
Set range of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:584
virtual void setColorScaleTextColor(const QColor &theColor)
Set color of text of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:605
SHAPERGUI_OCCSelector * selector() const
Returns current selector.
Definition: SHAPERGUI_SalomeViewer.h:166
virtual bool isColorScaleVisible() const
Returns True if ColorScale is visible.
Definition: SHAPERGUI_SalomeViewer.cpp:551
void activateViewer(bool toActivate)
Activate or deactivate viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:517
void setSelector(SHAPERGUI_OCCSelector *theSel)
Set selector.
Definition: SHAPERGUI_SalomeViewer.cpp:140
virtual void eraseAll()
Erases all presentations from the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:393
virtual void setViewProjection(double theX, double theY, double theZ, double theTwist)
Sets the view projection.
Definition: SHAPERGUI_SalomeViewer.cpp:412
virtual bool hasSelectionFilter(const Handle &theFilter)
Returns true if the selection filter is set to the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:472
virtual Handle v3dViewer() const
Retrurns V3d_Vioewer from current viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:101
virtual void addSelectionFilter(const Handle &theFilter)
Add selection filter to the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:454
void reconnectActions(SUIT_ViewWindow *theWindow, const bool theUseSHAPERSlot)
For some signals it disconnects the window from usual signal and connect it to the module ones.
Definition: SHAPERGUI_SalomeViewer.cpp:355
virtual void clearSelectionFilters()
Remove all selection filters from the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:487
virtual void setColorScalePosition(double theX, double theY)
Set position of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:566
virtual Handle trihedron() const
Trihedron 3d object shown in the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:109
virtual void setColorScaleIntervals(int theNb)
Set number of intervals of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:591
virtual bool canDragByMouse() const
Method returns True if the viewer can process editing objects by mouse drugging.
Definition: SHAPERGUI_SalomeViewer.cpp:229
virtual void setColorScaleTextHeigth(int theH)
Set text height of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:598
virtual void removeSelectionFilter(const Handle &theFilter)
Remove selection filter from the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:463
virtual void setColorScaleShown(bool on)
Show/Hide ColorScale object.
Definition: SHAPERGUI_SalomeViewer.cpp:559
virtual QWidget * activeViewPort() const
Returns viewer view port.
Definition: SHAPERGUI_SalomeViewer.cpp:127
virtual bool isSelectionEnabled() const
Returns true if selection is enabled.
Definition: SHAPERGUI_SalomeViewer.cpp:323
virtual void setText(const ModuleBase_IViewer::TextColor &theText, const int theSize)
Sets the text displayed in right-top corner of the 3D view.
Definition: SHAPERGUI_SalomeViewer.cpp:620
virtual bool enableDrawMode(bool isEnabled)
Enable or disable draw mode in the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:346
SHAPERGUI_SalomeViewer(QObject *theParent)
Constructor.
Definition: SHAPERGUI_SalomeViewer.cpp:78
virtual Handle AISContext() const
Returns AIS_InteractiveContext from current OCCViewer.
Definition: SHAPERGUI_SalomeViewer.cpp:92
virtual Handle activeView() const
Returns Vsd_View object from currently active view window.
Definition: SHAPERGUI_SalomeViewer.cpp:115
virtual void enableMultiselection(bool isEnable)
Enable or disable multiselection in the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:331
virtual void setColorScaleTitle(const QString &theText)
Set title of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:613
virtual void update()
Update current viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:496