SHAPER  9.12.0
XGUI_ViewerProxy.h
1 // Copyright (C) 2014-2023 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 
97  virtual void fitAll();
98 
100  virtual void eraseAll();
101 
103  void connectToViewer();
104 
106  virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
107 
109  virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
110 
113  virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
114 
116  virtual void clearSelectionFilters();
117 
119  virtual void update();
120 
123  virtual bool canDragByMouse() const;
124 
125  virtual void updateHighlight();
126 
127  // Methods for color scale management
128 
130  virtual bool isColorScaleVisible() const;
131 
133  virtual void setColorScaleShown(bool on);
134 
136  // \param theX is X position relative to current view width
137  // \param theY is Y position relative to current view heigth
138  virtual void setColorScalePosition(double theX, double theY);
139 
141  // \param theW is width relative to current view width
142  // \param theh is height relative to current view heigth
143  virtual void setColorScaleSize(double theW, double theH);
144 
146  // \param theMin is a minimal value
147  // \param theMax is a maximal value
148  virtual void setColorScaleRange(double theMin, double theMax);
149 
151  // \param theNb is number of intervals
152  virtual void setColorScaleIntervals(int theNb);
153 
155  // \param theH is number of intervals
156  virtual void setColorScaleTextHeigth(int theH);
157 
159  // \param theH is number of intervals
160  virtual void setColorScaleTextColor(const QColor& theColor);
161 
163  // \param theText is a title
164  virtual void setColorScaleTitle(const QString& theText);
165 
167  void setupColorScale();
168 
173  virtual void setText(const ModuleBase_IViewer::TextColor& theText, const int theSize);
174 
175  // Fit all along Z (perpendicular to display)
176  //virtual void Zfitall();
177 
178 #ifdef HAVE_SALOME
179  virtual void setFitter(OCCViewer_Fitter* theFitter);
180  virtual OCCViewer_Fitter* fitter() const;
181 #else
182  virtual void setFitter(AppElements_Fitter* theFitter);
183  virtual AppElements_Fitter* fitter() const;
184 #endif
185 
186 signals:
189 
192 
193 protected:
197  bool eventFilter(QObject *theObject, QEvent *theEvent);
198 
199 private slots:
200  void onViewCreated(ModuleBase_IViewWindow* theWnd);
201 
202 #ifndef HAVE_SALOME
203  void onTryCloseView(AppElements_ViewWindow*);
204  void onDeleteView(AppElements_ViewWindow*);
205  void onViewCreated(AppElements_ViewWindow*);
206  void onActivated(AppElements_ViewWindow*);
207 
208  void onMousePress(AppElements_ViewWindow*, QMouseEvent*);
209  void onMouseRelease(AppElements_ViewWindow*, QMouseEvent*);
210  void onMouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*);
211  void onMouseMove(AppElements_ViewWindow*, QMouseEvent*);
212 
213  void onKeyPress(AppElements_ViewWindow*, QKeyEvent*);
214  void onKeyRelease(AppElements_ViewWindow*, QKeyEvent*);
215 
216  void onViewTransformed(AppElements_ViewWindow::OperationType);
217 #else
218  void onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*);
219  void onKeyPress(ModuleBase_IViewWindow*, QKeyEvent*);
220  void onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*);
221 #endif
222 
223  private:
224  void displayHighlight(FeaturePtr theFeature, const TopoDS_Shape& theIgnoreShape);
225  bool eraseHighlight();
226  void createPresentations(const ResultPtr& theRes, const TopoDS_Shape& theIgnoreShape);
227 
228 
229  XGUI_Workshop* myWorkshop;
230  ResultPtr myResult;
231  AIS_ListOfInteractive myHighlights;
232 
233 };
234 
235 #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:132
virtual void fitAll()=0
Perfroms 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 heigth 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:138
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:191
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:82