SHAPER  9.15.0
XGUI_ViewerProxy.h
1 // Copyright (C) 2014-2025 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 XGUI_VIEWERPROXY_H
21 #define XGUI_VIEWERPROXY_H
22 
23 #include "XGUI.h"
24 #include <ModuleBase_IViewer.h>
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Result.h>
27 
28 #include <AIS_Trihedron.hxx>
29 #include <AIS_ListOfInteractive.hxx>
30 
31 #ifdef HAVE_SALOME
32 #include <OCCViewer_ViewModel.h>
33 #else
34  #include <AppElements_Viewer.h>
35  #include <AppElements_ViewWindow.h>
36 #endif
37 
38 
39 
40 class XGUI_Workshop;
48 class XGUI_EXPORT XGUI_ViewerProxy : public ModuleBase_IViewer
49 {
50 Q_OBJECT
51  public:
54  XGUI_ViewerProxy(XGUI_Workshop* theParent);
55 
57  void connectViewProxy();
58 
60  virtual Handle(AIS_InteractiveContext) AISContext() const;
61 
63  virtual Handle(AIS_Trihedron) trihedron() const;
64 
66  virtual Handle(V3d_Viewer) v3dViewer() const;
67 
69  virtual Handle(V3d_View) activeView() const;
70 
71  virtual QWidget* activeViewPort() const;
72 
74  virtual void enableSelection(bool isEnabled);
75 
77  virtual bool isSelectionEnabled() const;
78 
80  virtual void enableMultiselection(bool isEnable);
81 
83  virtual bool isMultiSelectionEnabled() const;
84 
86  virtual bool enableDrawMode(bool isEnabled);
87 
93  virtual void setViewProjection( double theX, double theY, double theZ,
94  double theTwist );
95 
103  virtual void setViewProjection( double theX, double theY, double theZ,
104  double theUpX, double theUpY, double theUpZ);
105 
107  virtual void fitAll();
108 
110  virtual void eraseAll();
111 
113  void connectToViewer();
114 
116  virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
117 
119  virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
120 
123  virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
124 
126  virtual void clearSelectionFilters();
127 
129  virtual void update();
130 
133  virtual bool canDragByMouse() const;
134 
135  virtual void updateHighlight();
136 
137  // Methods for color scale management
138 
140  virtual bool isColorScaleVisible() const;
141 
143  virtual void setColorScaleShown(bool on);
144 
146  // \param theX is X position relative to current view width
147  // \param theY is Y position relative to current view height
148  virtual void setColorScalePosition(double theX, double theY);
149 
151  // \param theW is width relative to current view width
152  // \param theh is height relative to current view height
153  virtual void setColorScaleSize(double theW, double theH);
154 
156  // \param theMin is a minimal value
157  // \param theMax is a maximal value
158  virtual void setColorScaleRange(double theMin, double theMax);
159 
161  // \param theNb is number of intervals
162  virtual void setColorScaleIntervals(int theNb);
163 
165  // \param theH is number of intervals
166  virtual void setColorScaleTextHeigth(int theH);
167 
169  // \param theH is number of intervals
170  virtual void setColorScaleTextColor(const QColor& theColor);
171 
173  // \param theText is a title
174  virtual void setColorScaleTitle(const QString& theText);
175 
177  void setupColorScale();
178 
183  virtual void setText(const ModuleBase_IViewer::TextColor& theText, const int theSize);
184 
185  // Fit all along Z (perpendicular to display)
186  //virtual void Zfitall();
187 
188 #ifdef HAVE_SALOME
189  virtual void setFitter(OCCViewer_Fitter* theFitter);
190  virtual OCCViewer_Fitter* fitter() const;
191 #else
192  virtual void setFitter(AppElements_Fitter* theFitter);
193  virtual AppElements_Fitter* fitter() const;
194 #endif
195 
196 signals:
199 
202 
203 protected:
207  bool eventFilter(QObject *theObject, QEvent *theEvent);
208 
209 private slots:
210  void onViewCreated(ModuleBase_IViewWindow* theWnd);
211 
212 #ifndef HAVE_SALOME
213  void onTryCloseView(AppElements_ViewWindow*);
214  void onDeleteView(AppElements_ViewWindow*);
215  void onViewCreated(AppElements_ViewWindow*);
216  void onActivated(AppElements_ViewWindow*);
217 
218  void onMousePress(AppElements_ViewWindow*, QMouseEvent*);
219  void onMouseRelease(AppElements_ViewWindow*, QMouseEvent*);
220  void onMouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*);
221  void onMouseMove(AppElements_ViewWindow*, QMouseEvent*);
222 
223  void onKeyPress(AppElements_ViewWindow*, QKeyEvent*);
224  void onKeyRelease(AppElements_ViewWindow*, QKeyEvent*);
225 
226  void onViewTransformed(AppElements_ViewWindow::OperationType);
227 #else
228  void onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*);
229  void onKeyPress(ModuleBase_IViewWindow*, QKeyEvent*);
230  void onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*);
231 #endif
232 
233  private:
234  void displayHighlight(FeaturePtr theFeature, const TopoDS_Shape& theIgnoreShape);
235  bool eraseHighlight();
236  void createPresentations(const ResultPtr& theRes, const TopoDS_Shape& theIgnoreShape);
237 
238 
239  XGUI_Workshop* myWorkshop;
240  ResultPtr myResult;
241  AIS_ListOfInteractive myHighlights;
242 
243 };
244 
245 #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 void fitAll()=0
Performs the fit all for the active view.
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 void setColorScaleTextHeigth(int theH)=0
Set text height of color scale.
virtual void update()=0
Update current viewer.
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 void setColorScaleIntervals(int theNb)=0
Set number of intervals of color scale.
virtual void addSelectionFilter(const Handle &&theFilter)=0
Add selection filter to the viewer.
virtual void setColorScaleTextColor(const QColor &theColor)=0
Set color of text of color scale.
virtual void updateHighlight()
Fit all along Z (perpendicular to display)
Definition: ModuleBase_IViewer.h:148
virtual bool hasSelectionFilter(const Handle &&theFilter)=0
Returns true if the selection filter is set to the viewer.
virtual void setColorScalePosition(double theX, double theY)=0
Set position of color scale.
virtual bool isSelectionEnabled() const =0
Returns true if selection is enabled.
virtual void setText(const TextColor &theText, const int theSize)=0
Sets the text displayed in right-top corner of the 3D view.
virtual void removeSelectionFilter(const Handle &&theFilter)=0
Remove selection filter from the viewer.
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.
virtual QWidget * activeViewPort() const =0
Returns currently active view port widget.
virtual void setViewProjection(double theX, double theY, double theZ, double theTwist)=0
Sets the view projection.
virtual bool isMultiSelectionEnabled() const =0
Returns true if multiselection is enabled.
virtual void enableMultiselection(bool isEnable)=0
Enable or disable multiselection in the viewer.
Proxy class which repersents or AppElements_Viewer or Salome Viewer dependently on current launching ...
Definition: XGUI_ViewerProxy.h:49
void enterViewPort()
Emits by mouse entering the view port.
void leaveViewPort()
Emits by mouse leaving of the view port.
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:83