SHAPER 9.16.0
ModuleBase_IViewer.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 ModuleBase_IViewer_H
21#define ModuleBase_IViewer_H
22
23#include "ModuleBase.h"
24
25#include <QObject>
26#include <QMap>
27#include <AIS_InteractiveContext.hxx>
28#include <V3d_View.hxx>
29#include <AIS_Trihedron.hxx>
30
31class QMouseEvent;
32class QKeyEvent;
33class QContextMenuEvent;
35#ifdef HAVE_SALOME
36class OCCViewer_Fitter;
37#else
39#endif
40
46class MODULEBASE_EXPORT ModuleBase_IViewer : public QObject
47{
48Q_OBJECT
49 public:
52 ModuleBase_IViewer(QObject* theParent);
53
55 virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
56
58 virtual Handle(AIS_Trihedron) trihedron() const = 0;
59
61 virtual Handle(V3d_Viewer) v3dViewer() const = 0;
62
64 virtual Handle(V3d_View) activeView() const = 0;
65
67 virtual QWidget* activeViewPort() const = 0;
68
71 virtual void enableSelection(bool isEnabled) = 0;
72
74 virtual bool isSelectionEnabled() const = 0;
75
78 virtual void enableMultiselection(bool isEnable) = 0;
79
81 virtual bool isMultiSelectionEnabled() const = 0;
82
84 virtual bool enableDrawMode(bool isEnabled) = 0;
85
87 virtual void fitAll() = 0;
88
90 virtual void eraseAll() = 0;
91
97 virtual void setViewProjection( double theX, double theY, double theZ,
98 double theTwist ) = 0;
99
107 virtual void setViewProjection( double theX, double theY, double theZ,
108 double theUpX, double theUpY, double theUpZ) = 0;
109
112 virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
113
116 virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
117
120 virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) = 0;
121
123 virtual void update() = 0;
124
127 const double Scale(const Handle(V3d_View)& theView)
128 {
129 if (!myWindowScale.contains(theView))
130 myWindowScale.insert(theView, theView->Camera()->Scale());
131 return myWindowScale[theView];
132 }
133
137 void SetScale(const Handle(V3d_View)& theView, const double theVal)
138 { myWindowScale[theView] = theVal; }
139
142 virtual bool canDragByMouse() const { return true; }
143
145 //virtual void Zfitall() = 0;
146
148 virtual void updateHighlight() {}
149
152 void set2dMode(bool is2d) {
153 myIs2dMode = is2d;
154 }
155
157 bool is2dMode() const {
158 return myIs2dMode;
159 }
160
161 // Methods for color scale management
162
164 virtual bool isColorScaleVisible() const = 0;
165
167 virtual void setColorScaleShown(bool on) = 0;
168
170 // \param theX is X position relative to current view width
171 // \param theY is Y position relative to current view height
172 virtual void setColorScalePosition(double theX, double theY) = 0;
173
175 // \param theW is width relative to current view width
176 // \param theh is height relative to current view height
177 virtual void setColorScaleSize(double theW, double theH) = 0;
178
180 // \param theMin is a minimal value
181 // \param theMax is a maximal value
182 virtual void setColorScaleRange(double theMin, double theMax) = 0;
183
185 // \param theNb is number of intervals
186 virtual void setColorScaleIntervals(int theNb) = 0;
187
189 // \param theH is number of intervals
190 virtual void setColorScaleTextHeigth(int theH) = 0;
191
193 // \param theH is number of intervals
194 virtual void setColorScaleTextColor(const QColor& theColor) = 0;
195
197 // \param theText is a title
198 virtual void setColorScaleTitle(const QString& theText) = 0;
199
201 typedef std::list<std::pair<std::wstring, std::vector<int> > > TextColor;
202
207 virtual void setText(const TextColor& theText, const int theSize) = 0;
208
209
212 myShowHighlight = true;
213 }
214
217 myShowHighlight = false;
218 }
219
220#ifdef HAVE_SALOME
221 virtual void setFitter(OCCViewer_Fitter* theFitter) = 0;
222 virtual OCCViewer_Fitter* fitter() const = 0;
223#else
224 virtual void setFitter(AppElements_Fitter* theFitter) = 0;
225 virtual AppElements_Fitter* fitter() const = 0;
226#endif
227
228 static Handle(Prs3d_Drawer) DefaultHighlightDrawer;
229
230
231signals:
234
237
240
243
246
248 void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
249
251 void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
252
254 void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
255
257 void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
258
260 void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
261
263 void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
264
267
269 void contextMenuRequested(QContextMenuEvent*);
270
273 void viewTransformed(int theTransformation);
274
276 void trihedronVisibilityChanged(bool theState);
277
278 protected:
280 QMap<Handle(V3d_View), double> myWindowScale;
281
282 bool myIs2dMode;
283
284 bool myShowHighlight;
285};
286
287#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
virtual bool canDragByMouse() const
Method returns True if the viewer can process editing objects by mouse drugging.
Definition: ModuleBase_IViewer.h:142
virtual bool hasSelectionFilter(const Handle &theFilter)=0
Returns true if the selection filter is set to the viewer.
virtual void fitAll()=0
Performs the fit all for the active view.
virtual Handle activeView() const =0
Returns Vsd_View object from currently active view window.
virtual void setColorScaleTitle(const QString &theText)=0
Set title of color scale.
virtual void enableSelection(bool isEnabled)=0
Enable or disable selection in the viewer.
virtual void setColorScaleShown(bool on)=0
Show/Hide ColorScale object.
virtual Handle v3dViewer() const =0
Retrurns V3d_Vioewer from current viewer.
virtual void setColorScaleTextHeigth(int theH)=0
Set text height of color scale.
virtual void update()=0
Update current viewer.
QMap< Handle, double > myWindowScale
A map for storing a scale factors dependent on view object.
Definition: ModuleBase_IViewer.h:280
void mousePress(ModuleBase_IViewWindow *theWnd, QMouseEvent *theEvent)
Signal emitted on mouse press.
void contextMenuRequested(QContextMenuEvent *)
Signal emitted on selection changed.
void viewTransformed(int theTransformation)
Signal emitted on transformation of view point in view window.
virtual void setColorScaleSize(double theW, double theH)=0
Set size of color scale.
virtual bool enableDrawMode(bool isEnabled)=0
Enable or disable draw mode in the viewer.
virtual void setColorScaleRange(double theMin, double theMax)=0
Set range of color scale.
virtual QWidget * activeViewPort() const =0
Returns currently active view port widget.
void selectionChanged()
Signal emitted on selection changed.
void viewCreated(ModuleBase_IViewWindow *theWnd)
Signal emitted on creation of view window.
bool is2dMode() const
Returns current state of 2d mode flag.
Definition: ModuleBase_IViewer.h:157
void tryCloseView(ModuleBase_IViewWindow *theWnd)
Signal emitted before view window is closed.
void showSelectionHighlight()
Switches On additional highlight for objects preselection.
Definition: ModuleBase_IViewer.h:211
virtual void setColorScaleIntervals(int theNb)=0
Set number of intervals of color scale.
void mouseDoubleClick(ModuleBase_IViewWindow *theWnd, QMouseEvent *theEvent)
Signal emitted on mouse double click.
virtual Handle AISContext() const =0
Returns AIS_InteractiveContext from current OCCViewer.
void trihedronVisibilityChanged(bool theState)
Signal emitted on selection changed.
virtual void setColorScaleTextColor(const QColor &theColor)=0
Set color of text of color scale.
const double Scale(const Handle &theView)
Returns a scale factor of the given view.
Definition: ModuleBase_IViewer.h:127
void keyPress(ModuleBase_IViewWindow *theWnd, QKeyEvent *theEvent)
Signal emitted on key press.
virtual void updateHighlight()
Fit all along Z (perpendicular to display)
Definition: ModuleBase_IViewer.h:148
virtual void setColorScalePosition(double theX, double theY)=0
Set position of color scale.
virtual bool isSelectionEnabled() const =0
Returns true if selection is enabled.
void SetScale(const Handle &theView, const double theVal)
Remember a scale factor for the view object.
Definition: ModuleBase_IViewer.h:137
virtual Handle trihedron() const =0
Trihedron 3d object shown in the viewer.
void set2dMode(bool is2d)
Set flag which indicates that viewer is used for 2d operations.
Definition: ModuleBase_IViewer.h:152
virtual void setViewProjection(double theX, double theY, double theZ, double theUpX, double theUpY, double theUpZ)=0
Sets the view projection and up direction.
void lastViewClosed()
Signal emitted when last view window is closed.
virtual void setText(const TextColor &theText, const int theSize)=0
Sets the text displayed in right-top corner of the 3D view.
virtual void eraseAll()=0
Erases all presentations from the viewer.
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
virtual bool isColorScaleVisible() const =0
Returns True if ColorScale is visible.
void mouseRelease(ModuleBase_IViewWindow *theWnd, QMouseEvent *theEvent)
Signal emitted on mouse release.
virtual void setViewProjection(double theX, double theY, double theZ, double theTwist)=0
Sets the view projection.
virtual void removeSelectionFilter(const Handle &theFilter)=0
Remove selection filter from the viewer.
virtual void addSelectionFilter(const Handle &theFilter)=0
Add selection filter to the viewer.
virtual bool isMultiSelectionEnabled() const =0
Returns true if multiselection is enabled.
void keyRelease(ModuleBase_IViewWindow *theWnd, QKeyEvent *theEvent)
Signal emitted on key release.
virtual void enableMultiselection(bool isEnable)=0
Enable or disable multiselection in the viewer.
void activated(ModuleBase_IViewWindow *theWnd)
Signal emitted on key release.
void hideSelectionHighlight()
Switches Off additional highlight for objects preselection.
Definition: ModuleBase_IViewer.h:216
void mouseMove(ModuleBase_IViewWindow *theWnd, QMouseEvent *theEvent)
Signal emitted on mouse move.
void deleteView(ModuleBase_IViewWindow *theWnd)
Signal emitted on delete view window.