Version: 9.16.0
OCCViewer_ViewModel.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
6// This library is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 2.1 of the License, or (at your option) any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23#ifndef OCCVIEWER_VIEWMODEL_H
24#define OCCVIEWER_VIEWMODEL_H
25
26#include <QColor>
27#include <QPoint>
28#include <QVector>
29
30#include "OCCViewer.h"
31#include "OCCViewer_ClipPlane.h"
33
34#include "Qtx.h"
35#include "SUIT_ViewModel.h"
36
37#include <V3d_View.hxx>
38#include <AIS_ColorScale.hxx>
39#include <AIS_Trihedron.hxx>
40#include <AIS_ViewCube.hxx>
41#include <AIS_InteractiveContext.hxx>
42#include <AIS_ListOfInteractive.hxx>
43#include <Graphic3d_SequenceOfHClipPlane.hxx>
44
45#include <Basics_OCCTVersion.hxx>
46
47class QKeyEvent;
48class QMouseEvent;
49
50class SUIT_ViewWindow;
51class SUIT_Desktop;
55
56class QtxAction;
57
58
59#ifdef WIN32
60#pragma warning( disable:4251 )
61#endif
62
67{
68public:
71 virtual void fitAll(Handle(V3d_View) theView) = 0;
72};
73
74
75
77{
78 Q_OBJECT
79
80public:
82 enum {
83 HorizontalGradient, VerticalGradient,
84 Diagonal1Gradient, Diagonal2Gradient,
85 Corner1Gradient, Corner2Gradient,
86 Corner3Gradient, Corner4Gradient,
87 LastGradient = Corner4Gradient
88 };
90 enum {
91 QuadBufferType, AnaglyphType,
92 RowInterlacedType, ColumnInterlacedType,
93 ChessBoardType, SideBySideType,
94 OverUnderType
95 };
96
97 static QString Type() { return "OCCViewer"; }
98 static QString backgroundData( QStringList&, QIntList&, QIntList& );
99 static void stereoData( QStringList&, QIntList&);
100
101 OCCViewer_Viewer( bool DisplayTrihedron = true);
102 virtual ~OCCViewer_Viewer();
103
104 void update();
105
106 virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
107
108 virtual void setViewManager(SUIT_ViewManager* theViewManager);
109 virtual QString getType() const { return Type(); }
110
111 virtual void contextMenuPopup(QMenu*);
112 virtual void applyClippingPlanes(bool theUpdateHatch);
113
114 void getSelectedObjects(AIS_ListOfInteractive& theList);
115 void setObjectsSelected(const AIS_ListOfInteractive& theList);
116 void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO,Standard_True);}
117
118 void performSelectionChanged();
119 // emit signal selectionChanged
120
121 void setDefaultLights();
122
123 QColor backgroundColor() const; // obsolete
124 void setBackgroundColor( const QColor& ); // obsolete
125 Qtx::BackgroundData background() const;
126 void setBackground( const Qtx::BackgroundData& );
127
128 QColor backgroundColor(int theViewId) const; // obsolete
129 void setBackgroundColor( int theViewId, const QColor& ); // obsolete
130 Qtx::BackgroundData background(int theViewId) const;
131 void setBackground( int theViewId, const Qtx::BackgroundData& );
132
133 bool isColorScaleVisible() const;
134 virtual void setColorScaleShown( const bool );
135
136 void initTrihedron();
137 void setTrihedronTextFont();
138 void setTrihedronTextColor();
139
141 bool trihedronActivated() const { return !myTrihedron.IsNull(); }
142
143 bool isTrihedronVisible() const;
144 virtual void setTrihedronShown( const bool );
145
146 double trihedronSize() const;
147 virtual void setTrihedronSize( const double , bool isRelative = true);
148
149 bool trihedronRelative() const {return myIsRelative; }
150
151 // a utility functions, used by SALOME_View_s methods
152 bool computeTrihedronSize( double& theNewSize, double& theSize );
153 virtual double computeSceneSize(const Handle(V3d_View)&) const;
154
155 void updateTrihedron();
156
157 // View Cube methods
158 bool viewCubeActivated() const { return !myViewCube.IsNull(); }
159 bool isViewCubeVisible() const;
160 virtual void setViewCubeShown( const bool );
161 void setViewCubeParamsFromPreferences();
162
163 virtual OCCViewer_ViewWindow* createSubWindow();
164
165 // Methods to access fitter
166
168 OCCViewer_Fitter* fitter() const { return myFitter; }
169
172 void setFitter(OCCViewer_Fitter* theFitter) {
173 myFitter = theFitter;
174 }
175
176
177public:
178 Handle(V3d_Viewer) getViewer3d() const { return myV3dViewer;}
179 Handle(AIS_InteractiveContext) getAISContext() const { return myAISContext; }
180 Handle(AIS_ColorScale) getColorScale() const { return myColorScale; }
181 Handle(AIS_Trihedron) getTrihedron() const { return myTrihedron; }
182 Handle(AIS_ViewCube) getViewCube() const { return myViewCube; }
183
184 int getTopLayerId();
185
186 int interactionStyle() const;
187 void setInteractionStyle( const int );
188
189 int projectionType() const;
190 void setProjectionType( const int );
191 int stereoType() const;
192 void setStereoType( const int );
193
194 OCCViewer_ViewWindow::SelectionStyle selectionStyle() const;
195 void setSelectionStyle(OCCViewer_ViewWindow::SelectionStyle);
196
197 int anaglyphFilter() const;
198 void setAnaglyphFilter( const int );
199
200 void setStereographicFocus( const int, const double );
201 int stereographicFocusType() const;
202 double stereographicFocusValue() const;
203
204 void setInterocularDistance( const int, const double );
205 int interocularDistanceType() const;
206 double interocularDistanceValue() const;
207
208 bool isReverseStereo() const;
209 void setReverseStereo( const bool );
210
211 bool isVSync() const;
212 void setVSync( const bool );
213
214 bool isQuadBufferSupport() const;
215 void setQuadBufferSupport( const bool );
216 int zoomingStyle() const;
217 void setZoomingStyle( const int );
218
219 void enablePreselection(bool isEnabled);
220 bool isPreselectionEnabled() const;
221
222 void enableSelection(bool isEnabled);
223 bool isSelectionEnabled() const;
224
225 void setSelectionOptions( bool, bool );
226
227 void enableMultiselection(bool isEnable);
228 bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
229
230 bool enableDrawMode( bool on );
231
232 void setClippingUseObjColor( bool use );
233 bool isClippingObjColorUsed() const;
234
235 void setClippingColor( const QColor& );
236 QColor clippingColor() const;
237
238 void setClippingTextureParams( const bool, const QString&, const bool, const double );
239 bool isDefaultTextureUsed() const;
240 QString clippingTexture() const;
241 bool isTextureModulated() const;
242 double clippingTextureScale() const;
243
244 int getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
245
246 void setStaticTrihedronDisplayed(const bool on);
247 void setStaticTrihedronTextFont();
248 void setStaticTrihedronTextColor();
249
250 OCCViewer_ViewPort3d* getViewPort();
251
252 /* Clip planes management */
253 Handle(Graphic3d_ClipPlane) createClipPlane(const gp_Pln& thePlane, const Standard_Boolean theIsOn);
254 void setClipPlanes (ClipPlanesList theList);
255 ClipPlanesList getClipPlanes() const;
256 void applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject);
257
258 OCCViewer_ClippingDlg* getClippingDlg() const;
259 void setClippingDlg(OCCViewer_ClippingDlg* theDlg);
260
261
262 /* Selection management */
263 bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
264 bool unHighlightAll( bool=true, bool=true );
265 bool isInViewer( const Handle(AIS_InteractiveObject)&, bool=false );
266 bool isVisible( const Handle(AIS_InteractiveObject)& );
267
268 void setColor( const Handle(AIS_InteractiveObject)&, const QColor&, bool=true );
269 void switchRepresentation( const Handle(AIS_InteractiveObject)&, int, bool=true );
270 void setTransparency( const Handle(AIS_InteractiveObject)&, float, bool=true );
271 void setIsos( const int u, const int v ); // number of isolines
272 void isos( int& u, int& v ) const;
273
274 void initView( OCCViewer_ViewWindow* view );
275
276signals:
279
280protected slots:
281 virtual void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
282 virtual void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
283 virtual void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
284 virtual void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
285 virtual void onViewClosed(OCCViewer_ViewPort3d*);
286 virtual void onViewMapped(OCCViewer_ViewPort3d*);
287
288 void onDumpView();
289 void onChangeBackground();
290
291protected:
292
293 double computeHatchScale() const;
294
295
296 Handle(V3d_Viewer) myV3dViewer;
297 Handle(AIS_ColorScale) myColorScale;
298 Handle(AIS_Trihedron) myTrihedron;
299 Handle(AIS_ViewCube) myViewCube;
300 Handle(AIS_InteractiveContext) myAISContext;
301
310
313
321
323
324 //QColor myBgColor;
325 QPoint myStartPnt, myEndPnt, myCurPnt;
326
328
329 QVector<Qtx::BackgroundData> myBackgrounds;
330
332
334 Graphic3d_SequenceOfHClipPlane myInternalClipPlanes;
335
342
344};
345
346#ifdef WIN32
347#pragma warning( default:4251 )
348#endif
349
350#endif
Handle(TDocStd_Application) CAF_Application
Get OCAF application.
Definition: CAF_Application.cxx:97
#define OCCVIEWER_EXPORT
Definition: OCCViewer.h:33
std::vector< OCCViewer_ClipPlane > ClipPlanesList
Definition: OCCViewer_ClipPlane.h:123
QList< int > QIntList
list of int values
Definition: Qtx.h:57
Dialog allowing to assign parameters of clipping plane.
Definition: OCCViewer_ClippingDlg.h:55
An object wich provides alternative way to fit scene in a view.
Definition: OCCViewer_ViewModel.h:67
virtual void fitAll(Handle(V3d_View) theView)=0
A method which has top be reimplemented to provide alterantive implementation FitAll command.
Definition: OCCViewer_ViewPort3d.h:43
Definition: OCCViewer_ViewWindow.h:147
SelectionStyle
Definition: OCCViewer_ViewWindow.h:173
Definition: OCCViewer_ViewModel.h:77
bool mySelectionEnabled
Definition: OCCViewer_ViewModel.h:315
void setFitter(OCCViewer_Fitter *theFitter)
Installs new fitter.
Definition: OCCViewer_ViewModel.h:172
double myTrihedronSize
Definition: OCCViewer_ViewModel.h:327
int myTopLayerId
Definition: OCCViewer_ViewModel.h:322
Handle(AIS_Trihedron) getTrihedron() const
Definition: OCCViewer_ViewModel.h:181
void setSelected(const Handle(AIS_InteractiveObject)&theIO)
Definition: OCCViewer_ViewModel.h:116
Handle(AIS_ViewCube) getViewCube() const
Definition: OCCViewer_ViewModel.h:182
Handle(V3d_Viewer) getViewer3d() const
Definition: OCCViewer_ViewModel.h:178
bool myIsRelative
Definition: OCCViewer_ViewModel.h:317
double myClippingTextureScale
Definition: OCCViewer_ViewModel.h:341
int myInteractionStyle
Definition: OCCViewer_ViewModel.h:302
QColor myClippingColor
Definition: OCCViewer_ViewModel.h:337
OCCViewer_Fitter * fitter() const
Returns currently installed fitter.
Definition: OCCViewer_ViewModel.h:168
Handle(AIS_InteractiveContext) getAISContext() const
Definition: OCCViewer_ViewModel.h:179
bool myClippingUseObjColor
Definition: OCCViewer_ViewModel.h:336
int myStereographicFocusType
Definition: OCCViewer_ViewModel.h:307
OCCViewer_ClippingDlg * myClippingDlg
Definition: OCCViewer_ViewModel.h:331
Handle(AIS_InteractiveContext) myAISContext
QPoint myCurPnt
Definition: OCCViewer_ViewModel.h:325
double myInterocularDistanceValue
Definition: OCCViewer_ViewModel.h:312
bool myPreselectionEnabled
Definition: OCCViewer_ViewModel.h:314
bool trihedronRelative() const
Definition: OCCViewer_ViewModel.h:149
QString myClippingTexture
Definition: OCCViewer_ViewModel.h:339
int getSelectionCount() const
Definition: OCCViewer_ViewModel.h:244
virtual QString getType() const
Definition: OCCViewer_ViewModel.h:109
Handle(AIS_ColorScale) myColorScale
Handle(AIS_Trihedron) myTrihedron
ClipPlanesList myClipPlanes
Definition: OCCViewer_ViewModel.h:333
double myStereographicFocusValue
Definition: OCCViewer_ViewModel.h:311
bool myVSyncMode
Definition: OCCViewer_ViewModel.h:319
bool myQuadBufferSupport
Definition: OCCViewer_ViewModel.h:320
OCCViewer_Fitter * myFitter
Definition: OCCViewer_ViewModel.h:343
int myProjectionType
Definition: OCCViewer_ViewModel.h:304
int myStereoType
Definition: OCCViewer_ViewModel.h:305
int myAnaglyphFilter
Definition: OCCViewer_ViewModel.h:306
int myInterocularDistanceType
Definition: OCCViewer_ViewModel.h:308
QVector< Qtx::BackgroundData > myBackgrounds
Definition: OCCViewer_ViewModel.h:329
int myZoomingStyle
Definition: OCCViewer_ViewModel.h:303
bool myToReverseStereo
Definition: OCCViewer_ViewModel.h:318
bool isMultiSelectionEnabled() const
Definition: OCCViewer_ViewModel.h:228
Handle(V3d_Viewer) myV3dViewer
@ HorizontalGradient
Definition: OCCViewer_ViewModel.h:83
@ Corner3Gradient
Definition: OCCViewer_ViewModel.h:86
@ Diagonal1Gradient
Definition: OCCViewer_ViewModel.h:84
@ Corner1Gradient
Definition: OCCViewer_ViewModel.h:85
@ AnaglyphType
Definition: OCCViewer_ViewModel.h:91
@ ColumnInterlacedType
Definition: OCCViewer_ViewModel.h:92
@ ChessBoardType
Definition: OCCViewer_ViewModel.h:93
bool myTextureModulated
Definition: OCCViewer_ViewModel.h:340
OCCViewer_ViewWindow::SelectionStyle mySelectionStyle
Definition: OCCViewer_ViewModel.h:309
bool myDefaultTextureUsed
Definition: OCCViewer_ViewModel.h:338
bool viewCubeActivated() const
Definition: OCCViewer_ViewModel.h:158
bool trihedronActivated() const
returns true if 3d Trihedron in viewer was created
Definition: OCCViewer_ViewModel.h:141
Graphic3d_SequenceOfHClipPlane myInternalClipPlanes
Definition: OCCViewer_ViewModel.h:334
Handle(AIS_ColorScale) getColorScale() const
Definition: OCCViewer_ViewModel.h:180
Handle(Graphic3d_ClipPlane) createClipPlane(const gp_Pln &thePlane
void selectionChanged()
Handle(AIS_ViewCube) myViewCube
bool myMultiSelectionEnabled
Definition: OCCViewer_ViewModel.h:316
static QString Type()
Definition: OCCViewer_ViewModel.h:97
Generic action class.
Definition: QtxAction.h:39
Stores background data.
Definition: Qtx.h:178
Definition: SUIT_Desktop.h:47
Definition: SUIT_ViewManager.h:50
Definition: SUIT_ViewModel.h:47
virtual void contextMenuPopup(QMenu *)
Definition: SUIT_ViewModel.h:69
virtual SUIT_ViewWindow * createView(SUIT_Desktop *theDesktop)
Definition: SUIT_ViewModel.cxx:77
virtual void applyClippingPlanes(bool theUpdateHatch)
Definition: SUIT_ViewModel.h:70
virtual void setViewManager(SUIT_ViewManager *theViewManager)
Definition: SUIT_ViewModel.cxx:85
Definition: SUIT_ViewWindow.h:42
int Type
Definition: VTKViewer_Actor.h:62