SHAPER  9.12.0
SHAPERGUI_SalomeViewer.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 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 
33 class SUIT_ViewWindow;
34 class QMouseEvent;
35 class QKeyEvent;
36 
38 class OCCViewer_Viewer;
39 class SUIT_ViewManager;
40 class AIS_TextLabel;
41 
48 {
49 public:
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 
69 private:
71  OCCViewer_Viewer* myViewer;
72  SUIT_ViewWindow* myCurrentView;
73 };
74 
75 
82 {
83 Q_OBJECT
84  public:
87  SHAPERGUI_SalomeViewer(QObject* theParent);
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 
140  void setSelector(SHAPERGUI_OCCSelector* theSel);
141 
143  virtual void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
144 
146  virtual void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
147 
150  virtual bool hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
151 
153  virtual void clearSelectionFilters();
154 
157  {
158  return mySelector;
159  }
160 
162  virtual void update();
163 
166  virtual bool canDragByMouse() const;
167 
170  void activateViewer(bool toActivate);
171 
172  // Methods for color scale management
173 
175  virtual bool isColorScaleVisible() const;
176 
178  virtual void setColorScaleShown(bool on);
179 
181  // \param theX is X position relative to current view width
182  // \param theY is Y position relative to current view heigth
183  virtual void setColorScalePosition(double theX, double theY);
184 
186  // \param theW is width relative to current view width
187  // \param theh is height relative to current view heigth
188  virtual void setColorScaleSize(double theW, double theH);
189 
191  // \param theMin is a minimal value
192  // \param theMax is a maximal value
193  virtual void setColorScaleRange(double theMin, double theMax);
194 
196  // \param theNb is number of intervals
197  virtual void setColorScaleIntervals(int theNb);
198 
200  // \param theH is number of intervals
201  virtual void setColorScaleTextHeigth(int theH);
202 
204  // \param theH is number of intervals
205  virtual void setColorScaleTextColor(const QColor& theColor);
206 
208  // \param theText is a title
209  virtual void setColorScaleTitle(const QString& theText);
210 
215  virtual void setText(const ModuleBase_IViewer::TextColor& theText, const int theSize);
216 
217  virtual void setFitter(OCCViewer_Fitter* theFitter);
218  virtual OCCViewer_Fitter* fitter() const;
219 
220  private slots:
221  void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
222  void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
223  void onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
224  void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
225  void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
226  void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
227 
228  void onTryCloseView(SUIT_ViewWindow*);
229  void onDeleteView(SUIT_ViewWindow*);
230  void onViewCreated(SUIT_ViewWindow*);
231  void onActivated(SUIT_ViewManager*);
232 
233  void onSelectionChanged();
234  void onViewTransformed(OCCViewer_ViewWindow::OperationType);
235 
239  void onViewPortMapped();
240 
242  void onAfterViewCreated();
243 
244  private:
245  SHAPERGUI_OCCSelector* mySelector;
246  SHAPERGUI_SalomeView* myView;
247  bool myIsSelectionChanged;
250  NCollection_List<Handle(AIS_TextLabel)> myText;
251 };
252 
253 
254 #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:191
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
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
SHAPERGUI_OCCSelector * selector() const
Returns current selector.
Definition: SHAPERGUI_SalomeViewer.h:156
virtual void enableSelection(bool isEnabled)
Enable or disable selection in the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:311
virtual void fitAll()
Perfroms 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:555
virtual void setColorScaleRange(double theMin, double theMax)
Set range of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:564
virtual void setColorScaleTextColor(const QColor &theColor)
Set color of text of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:585
virtual bool isColorScaleVisible() const
Returns True if ColorScale is visible.
Definition: SHAPERGUI_SalomeViewer.cpp:531
void activateViewer(bool toActivate)
Activate or deactivate viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:497
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
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:467
virtual bool hasSelectionFilter(const Handle &&theFilter)
Returns true if the selection filter is set to the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:452
virtual void setColorScalePosition(double theX, double theY)
Set position of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:546
virtual void setColorScaleIntervals(int theNb)
Set number of intervals of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:571
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 heigth of color scale.
Definition: SHAPERGUI_SalomeViewer.cpp:578
virtual void setColorScaleShown(bool on)
Show/Hide ColorScale object.
Definition: SHAPERGUI_SalomeViewer.cpp:539
virtual void removeSelectionFilter(const Handle &&theFilter)
Remove selection filter from the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:443
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:600
virtual void addSelectionFilter(const Handle &&theFilter)
Add selection filter to the viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:434
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 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:593
virtual void update()
Update current viewer.
Definition: SHAPERGUI_SalomeViewer.cpp:476