42cf5bc1 |
1 | // Created on: 1992-01-15 |
2 | // Created by: GG |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _V3d_View_HeaderFile |
18 | #define _V3d_View_HeaderFile |
19 | |
c357e426 |
20 | #include <Graphic3d_ClipPlane.hxx> |
82598ec0 |
21 | #include <Graphic3d_Texture2D.hxx> |
dc89236f |
22 | #include <Graphic3d_TypeOfShadingModel.hxx> |
c357e426 |
23 | #include <Image_PixMap.hxx> |
c357e426 |
24 | #include <Quantity_TypeOfColor.hxx> |
3bffef55 |
25 | #include <V3d_ImageDumpOptions.hxx> |
1a96d253 |
26 | #include <V3d_Viewer.hxx> |
caf231b0 |
27 | #include <V3d_Trihedron.hxx> |
c357e426 |
28 | #include <V3d_TypeOfAxe.hxx> |
c357e426 |
29 | #include <V3d_TypeOfOrientation.hxx> |
c357e426 |
30 | #include <V3d_TypeOfView.hxx> |
42cf5bc1 |
31 | #include <V3d_TypeOfVisualization.hxx> |
c357e426 |
32 | |
42cf5bc1 |
33 | class Aspect_Grid; |
c357e426 |
34 | class Aspect_Window; |
42cf5bc1 |
35 | class Graphic3d_Group; |
c357e426 |
36 | class Graphic3d_Structure; |
42cf5bc1 |
37 | class Graphic3d_TextureEnv; |
42cf5bc1 |
38 | |
25e59720 |
39 | DEFINE_STANDARD_HANDLE(V3d_View, Standard_Transient) |
42cf5bc1 |
40 | |
41 | //! Defines the application object VIEW for the |
42 | //! VIEWER application. |
43 | //! The methods of this class allow the editing |
44 | //! and inquiring the parameters linked to the view. |
42cf5bc1 |
45 | //! Provides a set of services common to all types of view. |
46 | //! Warning: The default parameters are defined by the class |
47 | //! Viewer (Example : SetDefaultViewSize()). |
48 | //! Certain methods are mouse oriented, and it is |
49 | //! necessary to know the difference between the start and |
50 | //! the continuation of this gesture in putting the method |
51 | //! into operation. |
52 | //! Example : Shifting the eye-view along the screen axes. |
53 | //! |
54 | //! View->Move(10.,20.,0.,True) (Starting motion) |
55 | //! View->Move(15.,-5.,0.,False) (Next motion) |
25e59720 |
56 | class V3d_View : public Standard_Transient |
42cf5bc1 |
57 | { |
879768fb |
58 | DEFINE_STANDARD_RTTIEXT(V3d_View, Standard_Transient) |
42cf5bc1 |
59 | public: |
60 | |
42cf5bc1 |
61 | //! Initializes the view. |
c357e426 |
62 | Standard_EXPORT V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView theType = V3d_ORTHOGRAPHIC); |
63 | |
42cf5bc1 |
64 | //! Initializes the view by copying. |
c357e426 |
65 | Standard_EXPORT V3d_View (const Handle(V3d_Viewer)& theViewer, const Handle(V3d_View)& theView); |
66 | |
67 | //! Default destructor. |
68 | Standard_EXPORT virtual ~V3d_View(); |
69 | |
42cf5bc1 |
70 | //! Activates the view in the specified Window |
71 | //! If <aContext> is not NULL the graphic context is used |
72 | //! to draw something in this view. |
73 | //! Otherwise an internal graphic context is created. |
42cf5bc1 |
74 | //! Warning: The view is centered and resized to preserve |
75 | //! the height/width ratio of the window. |
c357e426 |
76 | Standard_EXPORT void SetWindow (const Handle(Aspect_Window)& theWindow, |
a521d90d |
77 | const Aspect_RenderingContext theContext = NULL); |
c357e426 |
78 | |
879768fb |
79 | //! Activates the view as subview of another view. |
80 | //! @param[in] theParentView parent view to put subview into |
81 | //! @param[in] theSize subview dimensions; |
82 | //! values >= 2 define size in pixels, |
83 | //! values <= 1.0 define size as a fraction of parent view |
84 | //! @param[in] theCorner corner within parent view |
85 | //! @param[in] theOffset offset from the corner; |
86 | //! values >= 1 define offset in pixels, |
87 | //! values < 1.0 define offset as a fraction of parent view |
88 | //! @param[in] theMargins subview margins in pixels |
89 | //! |
90 | //! Example: to split parent view horizontally into 2 subview, |
91 | //! define one subview with Size=(0.5,1.0),Offset=(0.0,0.0), and 2nd with Size=(0.5,1.0),Offset=(5.0,0.0); |
92 | Standard_EXPORT void SetWindow (const Handle(V3d_View)& theParentView, |
93 | const Graphic3d_Vec2d& theSize, |
94 | Aspect_TypeOfTriedronPosition theCorner = Aspect_TOTP_LEFT_UPPER, |
95 | const Graphic3d_Vec2d& theOffset = Graphic3d_Vec2d(), |
96 | const Graphic3d_Vec2i& theMargins = Graphic3d_Vec2i()); |
97 | |
c357e426 |
98 | Standard_EXPORT void SetMagnify (const Handle(Aspect_Window)& theWindow, |
99 | const Handle(V3d_View)& thePreviousView, |
100 | const Standard_Integer theX1, |
101 | const Standard_Integer theY1, |
102 | const Standard_Integer theX2, |
103 | const Standard_Integer theY2); |
104 | |
42cf5bc1 |
105 | //! Destroys the view. |
5634c81a |
106 | Standard_EXPORT void Remove(); |
c357e426 |
107 | |
42cf5bc1 |
108 | //! Deprecated, Redraw() should be used instead. |
109 | Standard_EXPORT void Update() const; |
c357e426 |
110 | |
42cf5bc1 |
111 | //! Redisplays the view even if there has not |
112 | //! been any modification. |
113 | //! Must be called if the view is shown. |
114 | //! (Ex: DeIconification ) . |
10dbdf34 |
115 | Standard_EXPORT virtual void Redraw() const; |
c357e426 |
116 | |
42cf5bc1 |
117 | //! Updates layer of immediate presentations. |
10dbdf34 |
118 | Standard_EXPORT virtual void RedrawImmediate() const; |
c357e426 |
119 | |
42cf5bc1 |
120 | //! Invalidates view content but does not redraw it. |
121 | Standard_EXPORT void Invalidate() const; |
62e1beed |
122 | |
123 | //! Returns true if cached view content has been invalidated. |
124 | Standard_EXPORT Standard_Boolean IsInvalidated() const; |
125 | |
49582f9d |
126 | //! Returns true if immediate layer content has been invalidated. |
127 | Standard_Boolean IsInvalidatedImmediate() const { return myIsInvalidatedImmediate; } |
128 | |
129 | //! Invalidates view content within immediate layer but does not redraw it. |
130 | void InvalidateImmediate() { myIsInvalidatedImmediate = Standard_True; } |
131 | |
42cf5bc1 |
132 | //! Must be called when the window supporting the |
133 | //! view changes size. |
134 | //! if the view is not mapped on a window. |
135 | //! Warning: The view is centered and resized to preserve |
136 | //! the height/width ratio of the window. |
137 | Standard_EXPORT void MustBeResized(); |
c357e426 |
138 | |
42cf5bc1 |
139 | //! Must be called when the window supporting the |
140 | //! view is mapped or unmapped. |
141 | Standard_EXPORT void DoMapping(); |
c357e426 |
142 | |
42cf5bc1 |
143 | //! Returns the status of the view regarding |
144 | //! the displayed structures inside |
145 | //! Returns True is The View is empty |
146 | Standard_EXPORT Standard_Boolean IsEmpty() const; |
c357e426 |
147 | |
761d8807 |
148 | //! Updates the lights of the view. |
42cf5bc1 |
149 | Standard_EXPORT void UpdateLights() const; |
c357e426 |
150 | |
151 | //! Sets the automatic z-fit mode and its parameters. |
152 | //! The auto z-fit has extra parameters which can controlled from application level |
153 | //! to ensure that the size of viewing volume will be sufficiently large to cover |
154 | //! the depth of unmanaged objects, for example, transformation persistent ones. |
155 | //! @param theScaleFactor [in] the scale factor for Z-range. |
156 | //! The range between Z-min, Z-max projection volume planes |
157 | //! evaluated by z fitting method will be scaled using this coefficient. |
158 | //! Program error exception is thrown if negative or zero value |
159 | //! is passed. |
160 | Standard_EXPORT void SetAutoZFitMode (const Standard_Boolean theIsOn, const Standard_Real theScaleFactor = 1.0); |
161 | |
162 | //! returns TRUE if automatic z-fit mode is turned on. |
1ec17fb4 |
163 | Standard_Boolean AutoZFitMode() const { return myAutoZFitIsOn; } |
c357e426 |
164 | |
165 | //! returns scale factor parameter of automatic z-fit mode. |
1ec17fb4 |
166 | Standard_Real AutoZFitScaleFactor() const { return myAutoZFitScaleFactor; } |
c357e426 |
167 | |
42cf5bc1 |
168 | //! If automatic z-range fitting is turned on, adjusts Z-min and Z-max |
169 | //! projection volume planes with call to ZFitAll. |
c357e426 |
170 | Standard_EXPORT void AutoZFit() const; |
171 | |
42cf5bc1 |
172 | //! Change Z-min and Z-max planes of projection volume to match the |
173 | //! displayed objects. |
c357e426 |
174 | Standard_EXPORT void ZFitAll (const Standard_Real theScaleFactor = 1.0) const; |
175 | |
3e9cb806 |
176 | public: |
177 | |
c357e426 |
178 | //! Defines the background color of the view by the color definition type and the three corresponding values. |
179 | Standard_EXPORT void SetBackgroundColor (const Quantity_TypeOfColor theType, |
ee2be2a8 |
180 | const Standard_Real theV1, |
181 | const Standard_Real theV2, |
182 | const Standard_Real theV3); |
c357e426 |
183 | |
184 | //! Defines the background color of the view. |
185 | Standard_EXPORT void SetBackgroundColor (const Quantity_Color& theColor); |
186 | |
c357e426 |
187 | //! Defines the gradient background colors of the view by supplying the colors |
188 | //! and the fill method (horizontal by default). |
189 | Standard_EXPORT void SetBgGradientColors (const Quantity_Color& theColor1, |
190 | const Quantity_Color& theColor2, |
9af0d66b |
191 | const Aspect_GradientFillMethod theFillStyle = Aspect_GradientFillMethod_Horizontal, |
c357e426 |
192 | const Standard_Boolean theToUpdate = Standard_False); |
193 | |
c357e426 |
194 | //! Defines the gradient background fill method of the view. |
9af0d66b |
195 | Standard_EXPORT void SetBgGradientStyle (const Aspect_GradientFillMethod theMethod = Aspect_GradientFillMethod_Horizontal, |
c357e426 |
196 | const Standard_Boolean theToUpdate = Standard_False); |
197 | |
198 | //! Defines the background texture of the view by supplying the texture image file name |
199 | //! and fill method (centered by default). |
200 | Standard_EXPORT void SetBackgroundImage (const Standard_CString theFileName, |
201 | const Aspect_FillMethod theFillStyle = Aspect_FM_CENTERED, |
202 | const Standard_Boolean theToUpdate = Standard_False); |
203 | |
99289bed |
204 | //! Defines the background texture of the view by supplying the texture and fill method (centered by default) |
205 | Standard_EXPORT void SetBackgroundImage (const Handle(Graphic3d_Texture2D)& theTexture, |
206 | const Aspect_FillMethod theFillStyle = Aspect_FM_CENTERED, |
207 | const Standard_Boolean theToUpdate = Standard_False); |
208 | |
c357e426 |
209 | //! Defines the textured background fill method of the view. |
210 | Standard_EXPORT void SetBgImageStyle (const Aspect_FillMethod theFillStyle, |
211 | const Standard_Boolean theToUpdate = Standard_False); |
212 | |
67312b79 |
213 | //! Sets environment cubemap as background. |
214 | //! @param theCubeMap cubemap source to be set as background |
215 | //! @param theToUpdatePBREnv defines whether IBL maps will be generated or not (see 'GeneratePBREnvironment') |
077a220c |
216 | Standard_EXPORT void SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap, |
67312b79 |
217 | Standard_Boolean theToUpdatePBREnv = Standard_True, |
077a220c |
218 | Standard_Boolean theToUpdate = Standard_False); |
219 | |
16a263dc |
220 | //! Returns skydome aspect; |
221 | const Aspect_SkydomeBackground& BackgroundSkydome() const { return myView->BackgroundSkydome(); } |
222 | |
223 | //! Sets skydome aspect |
224 | //! @param theAspect cubemap generation parameters |
225 | //! @param theToUpdatePBREnv defines whether IBL maps will be generated or not |
226 | Standard_EXPORT void SetBackgroundSkydome (const Aspect_SkydomeBackground& theAspect, |
227 | Standard_Boolean theToUpdatePBREnv = Standard_True); |
228 | |
3e9cb806 |
229 | //! Returns TRUE if IBL (Image Based Lighting) from background cubemap is enabled. |
230 | Standard_EXPORT Standard_Boolean IsImageBasedLighting() const; |
231 | |
232 | //! Enables or disables IBL (Image Based Lighting) from background cubemap. |
233 | //! Has no effect if PBR is not used. |
234 | //! @param[in] theToEnableIBL enable or disable IBL from background cubemap |
235 | //! @param[in] theToUpdate redraw the view |
236 | Standard_EXPORT void SetImageBasedLighting (Standard_Boolean theToEnableIBL, |
237 | Standard_Boolean theToUpdate = Standard_False); |
238 | |
239 | //! Activates IBL from background cubemap. |
240 | void GeneratePBREnvironment (Standard_Boolean theToUpdate = Standard_False) { SetImageBasedLighting (Standard_True, theToUpdate); } |
241 | |
242 | //! Disables IBL from background cubemap; fills PBR specular probe and irradiance map with white color. |
243 | void ClearPBREnvironment (Standard_Boolean theToUpdate = Standard_False) { SetImageBasedLighting (Standard_True, theToUpdate); } |
67312b79 |
244 | |
3e9cb806 |
245 | //! Sets the environment texture to use. No environment texture by default. |
246 | Standard_EXPORT void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTexture); |
67312b79 |
247 | |
42cf5bc1 |
248 | //! Definition of an axis from its origin and |
249 | //! its orientation . |
250 | //! This will be the current axis for rotations and movements. |
251 | //! Warning! raises BadValue from V3d if the vector normal is NULL. . |
ee2be2a8 |
252 | Standard_EXPORT void SetAxis (const Standard_Real X, const Standard_Real Y, const Standard_Real Z, |
253 | const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz); |
c357e426 |
254 | |
3e9cb806 |
255 | public: |
c357e426 |
256 | |
257 | //! Defines the visualization type in the view. |
258 | Standard_EXPORT void SetVisualization (const V3d_TypeOfVisualization theType); |
259 | |
c357e426 |
260 | //! Activates theLight in the view. |
261 | Standard_EXPORT void SetLightOn (const Handle(V3d_Light)& theLight); |
262 | |
42cf5bc1 |
263 | //! Activates all the lights defined in this view. |
264 | Standard_EXPORT void SetLightOn(); |
c357e426 |
265 | |
266 | //! Deactivate theLight in this view. |
267 | Standard_EXPORT void SetLightOff (const Handle(V3d_Light)& theLight); |
268 | |
42cf5bc1 |
269 | //! Deactivate all the Lights defined in this view. |
270 | Standard_EXPORT void SetLightOff(); |
c357e426 |
271 | |
42cf5bc1 |
272 | //! Returns TRUE when the light is active in this view. |
c357e426 |
273 | Standard_EXPORT Standard_Boolean IsActiveLight (const Handle(V3d_Light)& theLight) const; |
274 | |
42cf5bc1 |
275 | //! sets the immediate update mode and returns the previous one. |
276 | Standard_EXPORT Standard_Boolean SetImmediateUpdate (const Standard_Boolean theImmediateUpdate); |
c357e426 |
277 | |
0aeb8984 |
278 | //! Returns trihedron object. |
5634c81a |
279 | const Handle(V3d_Trihedron)& Trihedron (bool theToCreate = true) |
280 | { |
281 | if (myTrihedron.IsNull() && theToCreate) |
282 | { |
283 | myTrihedron = new V3d_Trihedron(); |
284 | } |
285 | return myTrihedron; |
286 | } |
0aeb8984 |
287 | |
42cf5bc1 |
288 | //! Customization of the ZBUFFER Triedron. |
289 | //! XColor,YColor,ZColor - colors of axis |
c357e426 |
290 | //! SizeRatio - ratio of decreasing of the trihedron size when its physical |
42cf5bc1 |
291 | //! position comes out of the view |
292 | //! AxisDiametr - diameter relatively to axis length |
c357e426 |
293 | //! NbFacettes - number of facets of cylinders and cones |
87432b82 |
294 | Standard_EXPORT void ZBufferTriedronSetup (const Quantity_Color& theXColor = Quantity_NOC_RED, |
295 | const Quantity_Color& theYColor = Quantity_NOC_GREEN, |
296 | const Quantity_Color& theZColor = Quantity_NOC_BLUE1, |
c357e426 |
297 | const Standard_Real theSizeRatio = 0.8, |
298 | const Standard_Real theAxisDiametr = 0.05, |
299 | const Standard_Integer theNbFacettes = 12); |
300 | |
42cf5bc1 |
301 | //! Display of the Triedron. |
302 | //! Initialize position, color and length of Triedron axes. |
303 | //! The scale is a percent of the window width. |
c357e426 |
304 | Standard_EXPORT void TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition = Aspect_TOTP_CENTER, |
87432b82 |
305 | const Quantity_Color& theColor = Quantity_NOC_WHITE, |
c357e426 |
306 | const Standard_Real theScale = 0.02, |
307 | const V3d_TypeOfVisualization theMode = V3d_WIREFRAME); |
308 | |
42cf5bc1 |
309 | //! Erases the Triedron. |
310 | Standard_EXPORT void TriedronErase(); |
c357e426 |
311 | |
42cf5bc1 |
312 | //! Returns data of a graduated trihedron. |
313 | Standard_EXPORT const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() const; |
c357e426 |
314 | |
42cf5bc1 |
315 | //! Displays a graduated trihedron. |
c357e426 |
316 | Standard_EXPORT void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData); |
317 | |
42cf5bc1 |
318 | //! Erases a graduated trihedron from the view. |
319 | Standard_EXPORT void GraduatedTrihedronErase(); |
c357e426 |
320 | |
42cf5bc1 |
321 | //! modify the Projection of the view perpendicularly to |
322 | //! the privileged plane of the viewer. |
323 | Standard_EXPORT void SetFront(); |
c357e426 |
324 | |
42cf5bc1 |
325 | //! Rotates the eye about the coordinate system of |
326 | //! reference of the screen |
327 | //! for which the origin is the view point of the projection, |
328 | //! with a relative angular value in RADIANS with respect to |
329 | //! the initial position expressed by Start = Standard_True |
330 | //! Warning! raises BadValue from V3d |
331 | //! If the eye, the view point, or the high point are |
332 | //! aligned or confused. |
ee2be2a8 |
333 | Standard_EXPORT void Rotate (const Standard_Real Ax, const Standard_Real Ay, const Standard_Real Az, const Standard_Boolean Start = Standard_True); |
c357e426 |
334 | |
42cf5bc1 |
335 | //! Rotates the eye about the coordinate system of |
336 | //! reference of the screen |
337 | //! for which the origin is Gravity point {X,Y,Z}, |
338 | //! with a relative angular value in RADIANS with respect to |
339 | //! the initial position expressed by Start = Standard_True |
340 | //! If the eye, the view point, or the high point are |
341 | //! aligned or confused. |
ee2be2a8 |
342 | Standard_EXPORT void Rotate (const Standard_Real Ax, const Standard_Real Ay, const Standard_Real Az, |
343 | const Standard_Real X, const Standard_Real Y, const Standard_Real Z, |
344 | const Standard_Boolean Start = Standard_True); |
c357e426 |
345 | |
42cf5bc1 |
346 | //! Rotates the eye about one of the coordinate axes of |
347 | //! of the view for which the origin is the Gravity point{X,Y,Z} |
348 | //! with an relative angular value in RADIANS with |
349 | //! respect to the initial position expressed by |
350 | //! Start = Standard_True |
ee2be2a8 |
351 | Standard_EXPORT void Rotate (const V3d_TypeOfAxe Axe, |
352 | const Standard_Real Angle, |
353 | const Standard_Real X, const Standard_Real Y, const Standard_Real Z, |
354 | const Standard_Boolean Start = Standard_True); |
c357e426 |
355 | |
42cf5bc1 |
356 | //! Rotates the eye about one of the coordinate axes of |
357 | //! of the view for which the origin is the view point of the |
358 | //! projection with an relative angular value in RADIANS with |
359 | //! respect to the initial position expressed by |
360 | //! Start = Standard_True |
ee2be2a8 |
361 | Standard_EXPORT void Rotate (const V3d_TypeOfAxe Axe, const Standard_Real Angle, const Standard_Boolean Start = Standard_True); |
c357e426 |
362 | |
42cf5bc1 |
363 | //! Rotates the eye around the current axis a relative |
364 | //! angular value in RADIANS with respect to the initial |
365 | //! position expressed by Start = Standard_True |
ee2be2a8 |
366 | Standard_EXPORT void Rotate (const Standard_Real Angle, const Standard_Boolean Start = Standard_True); |
c357e426 |
367 | |
42cf5bc1 |
368 | //! Movement of the eye parallel to the coordinate system |
369 | //! of reference of the screen a distance relative to the |
370 | //! initial position expressed by Start = Standard_True. |
ee2be2a8 |
371 | Standard_EXPORT void Move (const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start = Standard_True); |
c357e426 |
372 | |
42cf5bc1 |
373 | //! Movement of the eye parallel to one of the axes of the |
374 | //! coordinate system of reference of the view a distance |
375 | //! relative to the initial position expressed by |
376 | //! Start = Standard_True. |
ee2be2a8 |
377 | Standard_EXPORT void Move (const V3d_TypeOfAxe Axe, const Standard_Real Length, const Standard_Boolean Start = Standard_True); |
c357e426 |
378 | |
42cf5bc1 |
379 | //! Movement of the eye parllel to the current axis |
380 | //! a distance relative to the initial position |
381 | //! expressed by Start = Standard_True |
ee2be2a8 |
382 | Standard_EXPORT void Move (const Standard_Real Length, const Standard_Boolean Start = Standard_True); |
c357e426 |
383 | |
42cf5bc1 |
384 | //! Movement of the ye and the view point parallel to the |
385 | //! frame of reference of the screen a distance relative |
386 | //! to the initial position expressed by |
387 | //! Start = Standard_True |
ee2be2a8 |
388 | Standard_EXPORT void Translate (const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start = Standard_True); |
c357e426 |
389 | |
42cf5bc1 |
390 | //! Movement of the eye and the view point parallel to one |
391 | //! of the axes of the fame of reference of the view a |
392 | //! distance relative to the initial position |
393 | //! expressed by Start = Standard_True |
ee2be2a8 |
394 | Standard_EXPORT void Translate (const V3d_TypeOfAxe Axe, const Standard_Real Length, const Standard_Boolean Start = Standard_True); |
c357e426 |
395 | |
42cf5bc1 |
396 | //! Movement of the eye and view point parallel to |
397 | //! the current axis a distance relative to the initial |
398 | //! position expressed by Start = Standard_True |
ee2be2a8 |
399 | Standard_EXPORT void Translate (const Standard_Real Length, const Standard_Boolean Start = Standard_True); |
c357e426 |
400 | |
42cf5bc1 |
401 | //! places the point of the view corresponding |
402 | //! at the pixel position x,y at the center of the window |
403 | //! and updates the view. |
ee2be2a8 |
404 | Standard_EXPORT void Place (const Standard_Integer theXp, const Standard_Integer theYp, const Standard_Real theZoomFactor = 1); |
c357e426 |
405 | |
42cf5bc1 |
406 | //! Rotation of the view point around the frame of reference |
407 | //! of the screen for which the origin is the eye of the |
408 | //! projection with a relative angular value in RADIANS |
409 | //! with respect to the initial position expressed by |
410 | //! Start = Standard_True |
ee2be2a8 |
411 | Standard_EXPORT void Turn (const Standard_Real Ax, const Standard_Real Ay, const Standard_Real Az, const Standard_Boolean Start = Standard_True); |
c357e426 |
412 | |
42cf5bc1 |
413 | //! Rotation of the view point around one of the axes of the |
414 | //! frame of reference of the view for which the origin is |
415 | //! the eye of the projection with an angular value in |
416 | //! RADIANS relative to the initial position expressed by |
417 | //! Start = Standard_True |
ee2be2a8 |
418 | Standard_EXPORT void Turn (const V3d_TypeOfAxe Axe, const Standard_Real Angle, const Standard_Boolean Start = Standard_True); |
c357e426 |
419 | |
42cf5bc1 |
420 | //! Rotation of the view point around the current axis an |
421 | //! angular value in RADIANS relative to the initial |
422 | //! position expressed by Start = Standard_True |
ee2be2a8 |
423 | Standard_EXPORT void Turn (const Standard_Real Angle, const Standard_Boolean Start = Standard_True); |
c357e426 |
424 | |
42cf5bc1 |
425 | //! Defines the angular position of the high point of |
426 | //! the reference frame of the view with respect to the |
427 | //! Y screen axis with an absolute angular value in |
428 | //! RADIANS. |
ee2be2a8 |
429 | Standard_EXPORT void SetTwist (const Standard_Real Angle); |
c357e426 |
430 | |
42cf5bc1 |
431 | //! Defines the position of the eye.. |
ee2be2a8 |
432 | Standard_EXPORT void SetEye (const Standard_Real X, const Standard_Real Y, const Standard_Real Z); |
c357e426 |
433 | |
42cf5bc1 |
434 | //! Defines the Depth of the eye from the view point |
435 | //! without update the projection . |
ee2be2a8 |
436 | Standard_EXPORT void SetDepth (const Standard_Real Depth); |
c357e426 |
437 | |
42cf5bc1 |
438 | //! Defines the orientation of the projection. |
ee2be2a8 |
439 | Standard_EXPORT void SetProj (const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz); |
c357e426 |
440 | |
42cf5bc1 |
441 | //! Defines the orientation of the projection . |
fc552d84 |
442 | //! @param theOrientation camera direction |
443 | //! @param theIsYup flag indicating Y-up (TRUE) or Z-up (FALSE) convention |
444 | Standard_EXPORT void SetProj (const V3d_TypeOfOrientation theOrientation, |
445 | const Standard_Boolean theIsYup = Standard_False); |
c357e426 |
446 | |
42cf5bc1 |
447 | //! Defines the position of the view point. |
ee2be2a8 |
448 | Standard_EXPORT void SetAt (const Standard_Real X, const Standard_Real Y, const Standard_Real Z); |
c357e426 |
449 | |
42cf5bc1 |
450 | //! Defines the orientation of the high point. |
ee2be2a8 |
451 | Standard_EXPORT void SetUp (const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz); |
c357e426 |
452 | |
42cf5bc1 |
453 | //! Defines the orientation(SO) of the high point. |
454 | Standard_EXPORT void SetUp (const V3d_TypeOfOrientation Orientation); |
c357e426 |
455 | |
42cf5bc1 |
456 | //! Saves the current state of the orientation of the view |
457 | //! which will be the return state at ResetViewOrientation. |
458 | Standard_EXPORT void SetViewOrientationDefault(); |
c357e426 |
459 | |
42cf5bc1 |
460 | //! Resets the orientation of the view. |
461 | //! Updates the view |
462 | Standard_EXPORT void ResetViewOrientation(); |
c357e426 |
463 | |
42cf5bc1 |
464 | //! Translates the center of the view along "x" and "y" axes of |
465 | //! view projection. Can be used to perform interactive panning operation. |
466 | //! In that case the DXv, DXy parameters specify panning relative to the |
467 | //! point where the operation is started. |
468 | //! @param theDXv [in] the relative panning on "x" axis of view projection, in view space coordinates. |
469 | //! @param theDYv [in] the relative panning on "y" axis of view projection, in view space coordinates. |
470 | //! @param theZoomFactor [in] the zooming factor. |
471 | //! @param theToStart [in] pass TRUE when starting panning to remember view |
472 | //! state prior to panning for relative arguments. If panning is started, |
473 | //! passing {0, 0} for {theDXv, theDYv} will return view to initial state. |
474 | //! Performs update of view. |
ee2be2a8 |
475 | Standard_EXPORT void Panning (const Standard_Real theDXv, const Standard_Real theDYv, const Standard_Real theZoomFactor = 1, const Standard_Boolean theToStart = Standard_True); |
c357e426 |
476 | |
42cf5bc1 |
477 | //! Relocates center of screen to the point, determined by |
478 | //! {Xp, Yp} pixel coordinates relative to the bottom-left corner of |
479 | //! screen. To calculate pixel coordinates for any point from world |
480 | //! coordinate space, it can be projected using "Project". |
481 | //! @param theXp [in] the x coordinate. |
482 | //! @param theYp [in] the y coordinate. |
483 | Standard_EXPORT void SetCenter (const Standard_Integer theXp, const Standard_Integer theYp); |
c357e426 |
484 | |
42cf5bc1 |
485 | //! Defines the view projection size in its maximum dimension, |
4551e1be |
486 | //! keeping the initial height/width ratio unchanged. |
ee2be2a8 |
487 | Standard_EXPORT void SetSize (const Standard_Real theSize); |
c357e426 |
488 | |
42cf5bc1 |
489 | //! Defines the Depth size of the view |
490 | //! Front Plane will be set to Size/2. |
491 | //! Back Plane will be set to -Size/2. |
492 | //! Any Object located Above the Front Plane or |
493 | //! behind the Back Plane will be Clipped . |
494 | //! NOTE than the XY Size of the View is NOT modified . |
ee2be2a8 |
495 | Standard_EXPORT void SetZSize (const Standard_Real SetZSize); |
c357e426 |
496 | |
42cf5bc1 |
497 | //! Zooms the view by a factor relative to the initial |
498 | //! value expressed by Start = Standard_True |
499 | //! Updates the view. |
ee2be2a8 |
500 | Standard_EXPORT void SetZoom (const Standard_Real Coef, const Standard_Boolean Start = Standard_True); |
c357e426 |
501 | |
42cf5bc1 |
502 | //! Zooms the view by a factor relative to the value |
503 | //! initialised by SetViewMappingDefault(). |
504 | //! Updates the view. |
ee2be2a8 |
505 | Standard_EXPORT void SetScale (const Standard_Real Coef); |
c357e426 |
506 | |
42cf5bc1 |
507 | //! Sets anisotropic (axial) scale factors <Sx>, <Sy>, <Sz> for view <me>. |
508 | //! Anisotropic scaling operation is performed through multiplying |
509 | //! the current view orientation matrix by a scaling matrix: |
510 | //! || Sx 0 0 0 || |
511 | //! || 0 Sy 0 0 || |
512 | //! || 0 0 Sz 0 || |
513 | //! || 0 0 0 1 || |
514 | //! Updates the view. |
515 | Standard_EXPORT void SetAxialScale (const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz); |
c357e426 |
516 | |
42cf5bc1 |
517 | //! Adjust view parameters to fit the displayed scene, respecting height / width ratio. |
518 | //! The Z clipping range (depth range) is fitted if AutoZFit flag is TRUE. |
519 | //! Throws program error exception if margin coefficient is < 0 or >= 1. |
520 | //! Updates the view. |
521 | //! @param theMargin [in] the margin coefficient for view borders. |
522 | //! @param theToUpdate [in] flag to perform view update. |
ee2be2a8 |
523 | Standard_EXPORT void FitAll (const Standard_Real theMargin = 0.01, const Standard_Boolean theToUpdate = Standard_True); |
c357e426 |
524 | |
42cf5bc1 |
525 | //! Adjust view parameters to fit the displayed scene, respecting height / width ratio |
526 | //! according to the custom bounding box given. |
527 | //! Throws program error exception if margin coefficient is < 0 or >= 1. |
528 | //! Updates the view. |
529 | //! @param theBox [in] the custom bounding box to fit. |
530 | //! @param theMargin [in] the margin coefficient for view borders. |
531 | //! @param theToUpdate [in] flag to perform view update. |
ee2be2a8 |
532 | Standard_EXPORT void FitAll (const Bnd_Box& theBox, const Standard_Real theMargin = 0.01, const Standard_Boolean theToUpdate = Standard_True); |
c357e426 |
533 | |
42cf5bc1 |
534 | //! Adjusts the viewing volume so as not to clip the displayed objects by front and back |
535 | //! and back clipping planes. Also sets depth value automatically depending on the |
536 | //! calculated Z size and Aspect parameter. |
537 | //! NOTE than the original XY size of the view is NOT modified . |
ee2be2a8 |
538 | Standard_EXPORT void DepthFitAll (const Standard_Real Aspect = 0.01, const Standard_Real Margin = 0.01); |
c357e426 |
539 | |
42cf5bc1 |
540 | //! Centers the defined projection window so that it occupies |
541 | //! the maximum space while respecting the initial |
542 | //! height/width ratio. |
543 | //! NOTE than the original Z size of the view is NOT modified . |
544 | Standard_EXPORT void FitAll (const Standard_Real theMinXv, const Standard_Real theMinYv, const Standard_Real theMaxXv, const Standard_Real theMaxYv); |
c357e426 |
545 | |
42cf5bc1 |
546 | //! Centers the defined PIXEL window so that it occupies |
547 | //! the maximum space while respecting the initial height/width ratio. |
548 | //! NOTE than the original Z size of the view is NOT modified. |
549 | //! @param theMinXp [in] pixel coordinates of minimal corner on x screen axis. |
550 | //! @param theMinYp [in] pixel coordinates of minimal corner on y screen axis. |
551 | //! @param theMaxXp [in] pixel coordinates of maximal corner on x screen axis. |
552 | //! @param theMaxYp [in] pixel coordinates of maximal corner on y screen axis. |
553 | Standard_EXPORT void WindowFit (const Standard_Integer theMinXp, const Standard_Integer theMinYp, const Standard_Integer theMaxXp, const Standard_Integer theMaxYp); |
c357e426 |
554 | |
42cf5bc1 |
555 | //! Saves the current view mapping. This will be the |
556 | //! state returned from ResetViewmapping. |
557 | Standard_EXPORT void SetViewMappingDefault(); |
c357e426 |
558 | |
42cf5bc1 |
559 | //! Resets the centering of the view. |
560 | //! Updates the view |
561 | Standard_EXPORT void ResetViewMapping(); |
c357e426 |
562 | |
563 | //! Resets the centering and the orientation of the view. |
564 | Standard_EXPORT void Reset (const Standard_Boolean theToUpdate = Standard_True); |
565 | |
42cf5bc1 |
566 | //! Converts the PIXEL value |
567 | //! to a value in the projection plane. |
ee2be2a8 |
568 | Standard_EXPORT Standard_Real Convert (const Standard_Integer Vp) const; |
c357e426 |
569 | |
42cf5bc1 |
570 | //! Converts the point PIXEL into a point projected |
571 | //! in the reference frame of the projection plane. |
ee2be2a8 |
572 | Standard_EXPORT void Convert (const Standard_Integer Xp, const Standard_Integer Yp, |
573 | Standard_Real& Xv, Standard_Real& Yv) const; |
c357e426 |
574 | |
42cf5bc1 |
575 | //! Converts tha value of the projection plane into |
576 | //! a PIXEL value. |
ee2be2a8 |
577 | Standard_EXPORT Standard_Integer Convert (const Standard_Real Vv) const; |
c357e426 |
578 | |
42cf5bc1 |
579 | //! Converts the point defined in the reference frame |
580 | //! of the projection plane into a point PIXEL. |
ee2be2a8 |
581 | Standard_EXPORT void Convert (const Standard_Real Xv, const Standard_Real Yv, |
582 | Standard_Integer& Xp, Standard_Integer& Yp) const; |
c357e426 |
583 | |
42cf5bc1 |
584 | //! Converts the projected point into a point |
585 | //! in the reference frame of the view corresponding |
586 | //! to the intersection with the projection plane |
587 | //! of the eye/view point vector. |
ee2be2a8 |
588 | Standard_EXPORT void Convert (const Standard_Integer Xp, const Standard_Integer Yp, |
589 | Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const; |
c357e426 |
590 | |
42cf5bc1 |
591 | //! Converts the projected point into a point |
592 | //! in the reference frame of the view corresponding |
593 | //! to the intersection with the projection plane |
594 | //! of the eye/view point vector and returns the |
595 | //! projection ray for further computations. |
ee2be2a8 |
596 | Standard_EXPORT void ConvertWithProj (const Standard_Integer Xp, const Standard_Integer Yp, |
597 | Standard_Real& X, Standard_Real& Y, Standard_Real& Z, |
598 | Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const; |
c357e426 |
599 | |
42cf5bc1 |
600 | //! Converts the projected point into the nearest grid point |
601 | //! in the reference frame of the view corresponding |
602 | //! to the intersection with the projection plane |
603 | //! of the eye/view point vector and display the grid marker. |
604 | //! Warning: When the grid is not active the result is identical to the above Convert() method. |
605 | //! How to use: |
606 | //! 1) Enable the grid echo display |
607 | //! myViewer->SetGridEcho(Standard_True); |
608 | //! 2) When application receive a move event: |
609 | //! 2.1) Check if any object is detected |
610 | //! if( myInteractiveContext->MoveTo(x,y) == AIS_SOD_Nothing ) { |
611 | //! 2.2) Check if the grid is active |
612 | //! if( myViewer->Grid()->IsActive() ) { |
613 | //! 2.3) Display the grid echo and gets the grid point |
614 | //! myView->ConvertToGrid(x,y,X,Y,Z); |
615 | //! myView->Viewer()->ShowGridEcho (myView, Graphic3d_Vertex (X,Y,Z)); |
616 | //! myView->RedrawImmediate(); |
617 | //! 2.4) Else this is the standard case |
618 | //! } else myView->Convert(x,y,X,Y,Z); |
ee2be2a8 |
619 | Standard_EXPORT void ConvertToGrid (const Standard_Integer Xp, const Standard_Integer Yp, |
620 | Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const; |
c357e426 |
621 | |
42cf5bc1 |
622 | //! Converts the point into the nearest grid point |
623 | //! and display the grid marker. |
ee2be2a8 |
624 | Standard_EXPORT void ConvertToGrid (const Standard_Real X, const Standard_Real Y, const Standard_Real Z, |
625 | Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const; |
c357e426 |
626 | |
42cf5bc1 |
627 | //! Projects the point defined in the reference frame of |
628 | //! the view into the projected point in the associated window. |
ee2be2a8 |
629 | Standard_EXPORT void Convert (const Standard_Real X, const Standard_Real Y, const Standard_Real Z, |
630 | Standard_Integer& Xp, Standard_Integer& Yp) const; |
c357e426 |
631 | |
42cf5bc1 |
632 | //! Converts the point defined in the user space of |
c357e426 |
633 | //! the view to the projection plane at the depth |
634 | //! relative to theZ. |
635 | Standard_EXPORT void Project (const Standard_Real theX, |
636 | const Standard_Real theY, |
637 | const Standard_Real theZ, |
638 | Standard_Real& theXp, |
639 | Standard_Real& theYp) const; |
640 | |
641 | //! Converts the point defined in the user space of |
642 | //! the view to the projection plane at the depth |
643 | //! relative to theZ. |
644 | Standard_EXPORT void Project (const Standard_Real theX, |
645 | const Standard_Real theY, |
646 | const Standard_Real theZ, |
647 | Standard_Real& theXp, |
648 | Standard_Real& theYp, |
649 | Standard_Real& theZp) const; |
650 | |
42cf5bc1 |
651 | //! Returns the Background color values of the view |
652 | //! depending of the color Type. |
ee2be2a8 |
653 | Standard_EXPORT void BackgroundColor (const Quantity_TypeOfColor Type, Standard_Real& V1, Standard_Real& V2, Standard_Real& V3) const; |
c357e426 |
654 | |
42cf5bc1 |
655 | //! Returns the Background color object of the view. |
656 | Standard_EXPORT Quantity_Color BackgroundColor() const; |
c357e426 |
657 | |
658 | //! Returns the gradient background colors of the view. |
659 | Standard_EXPORT void GradientBackgroundColors (Quantity_Color& theColor1, Quantity_Color& theColor2) const; |
660 | |
42cf5bc1 |
661 | //! Returns the gradient background of the view. |
662 | Standard_EXPORT Aspect_GradientBackground GradientBackground() const; |
c357e426 |
663 | |
42cf5bc1 |
664 | //! Returns the current value of the zoom expressed with |
665 | //! respect to SetViewMappingDefault(). |
ee2be2a8 |
666 | Standard_EXPORT Standard_Real Scale() const; |
c357e426 |
667 | |
42cf5bc1 |
668 | //! Returns the current values of the anisotropic (axial) scale factors. |
669 | Standard_EXPORT void AxialScale (Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz) const; |
c357e426 |
670 | |
42cf5bc1 |
671 | //! Returns the height and width of the view. |
ee2be2a8 |
672 | Standard_EXPORT void Size (Standard_Real& Width, Standard_Real& Height) const; |
c357e426 |
673 | |
42cf5bc1 |
674 | //! Returns the Depth of the view . |
675 | Standard_EXPORT Standard_Real ZSize() const; |
c357e426 |
676 | |
42cf5bc1 |
677 | //! Returns the position of the eye. |
ee2be2a8 |
678 | Standard_EXPORT void Eye (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const; |
c357e426 |
679 | |
1ec17fb4 |
680 | //! Returns the position of point which emanating the projections. |
681 | void FocalReferencePoint (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const { Eye (X,Y,Z); } |
c357e426 |
682 | |
42cf5bc1 |
683 | //! Returns the coordinate of the point (Xpix,Ypix) |
684 | //! in the view (XP,YP,ZP), and the projection vector of the |
685 | //! view passing by the point (for PerspectiveView). |
ee2be2a8 |
686 | Standard_EXPORT void ProjReferenceAxe (const Standard_Integer Xpix, const Standard_Integer Ypix, |
687 | Standard_Real& XP, Standard_Real& YP, Standard_Real& ZP, |
688 | Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ) const; |
c357e426 |
689 | |
42cf5bc1 |
690 | //! Returns the Distance between the Eye and View Point. |
ee2be2a8 |
691 | Standard_EXPORT Standard_Real Depth() const; |
c357e426 |
692 | |
42cf5bc1 |
693 | //! Returns the projection vector. |
ee2be2a8 |
694 | Standard_EXPORT void Proj (Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const; |
c357e426 |
695 | |
42cf5bc1 |
696 | //! Returns the position of the view point. |
ee2be2a8 |
697 | Standard_EXPORT void At (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const; |
c357e426 |
698 | |
42cf5bc1 |
699 | //! Returns the vector giving the position of the high point. |
ee2be2a8 |
700 | Standard_EXPORT void Up (Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const; |
c357e426 |
701 | |
42cf5bc1 |
702 | //! Returns in RADIANS the orientation of the view around |
703 | //! the visual axis measured from the Y axis of the screen. |
ee2be2a8 |
704 | Standard_EXPORT Standard_Real Twist() const; |
c357e426 |
705 | |
13b36bb1 |
706 | //! Returns the current shading model; Graphic3d_TypeOfShadingModel_Phong by default. |
dc89236f |
707 | Standard_EXPORT Graphic3d_TypeOfShadingModel ShadingModel() const; |
c357e426 |
708 | |
1a96d253 |
709 | //! Defines the shading model for the visualization. |
710 | Standard_EXPORT void SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel); |
711 | |
42cf5bc1 |
712 | Standard_EXPORT Handle(Graphic3d_TextureEnv) TextureEnv() const; |
c357e426 |
713 | |
42cf5bc1 |
714 | //! Returns the current visualisation mode. |
715 | Standard_EXPORT V3d_TypeOfVisualization Visualization() const; |
c357e426 |
716 | |
f7fc0c03 |
717 | //! Returns a list of active lights. |
718 | const V3d_ListOfLight& ActiveLights() const { return myActiveLights; } |
c357e426 |
719 | |
6a24c6de |
720 | //! Return iterator for defined lights. |
721 | V3d_ListOfLightIterator ActiveLightIterator() const { return V3d_ListOfLightIterator (myActiveLights); } |
722 | |
c357e426 |
723 | //! Returns the MAX number of light associated to the view. |
724 | Standard_EXPORT Standard_Integer LightLimit() const; |
725 | |
42cf5bc1 |
726 | //! Returns the viewer in which the view has been created. |
1ec17fb4 |
727 | Handle(V3d_Viewer) Viewer() const { return MyViewer; } |
c357e426 |
728 | |
42cf5bc1 |
729 | //! Returns True if MyView is associated with a window . |
730 | Standard_EXPORT Standard_Boolean IfWindow() const; |
c357e426 |
731 | |
42cf5bc1 |
732 | //! Returns the Aspect Window associated with the view. |
1ec17fb4 |
733 | const Handle(Aspect_Window)& Window() const { return MyWindow; } |
c357e426 |
734 | |
42cf5bc1 |
735 | //! Returns the Type of the View |
736 | Standard_EXPORT V3d_TypeOfView Type() const; |
c357e426 |
737 | |
42cf5bc1 |
738 | //! Translates the center of the view along "x" and "y" axes of |
739 | //! view projection. Can be used to perform interactive panning operation. |
740 | //! In that case the DXp, DXp parameters specify panning relative to the |
741 | //! point where the operation is started. |
742 | //! @param theDXp [in] the relative panning on "x" axis of view projection, in pixels. |
743 | //! @param theDYp [in] the relative panning on "y" axis of view projection, in pixels. |
744 | //! @param theZoomFactor [in] the zooming factor. |
745 | //! @param theToStart [in] pass TRUE when starting panning to remember view |
746 | //! state prior to panning for relative arguments. Passing 0 for relative |
747 | //! panning parameter should return view panning to initial state. |
748 | //! Performs update of view. |
ee2be2a8 |
749 | Standard_EXPORT void Pan (const Standard_Integer theDXp, const Standard_Integer theDYp, const Standard_Real theZoomFactor = 1, const Standard_Boolean theToStart = Standard_True); |
c357e426 |
750 | |
42cf5bc1 |
751 | //! Zoom the view according to a zoom factor computed |
752 | //! from the distance between the 2 mouse position. |
753 | //! @param theXp1 [in] the x coordinate of first mouse position, in pixels. |
754 | //! @param theYp1 [in] the y coordinate of first mouse position, in pixels. |
755 | //! @param theXp2 [in] the x coordinate of second mouse position, in pixels. |
756 | //! @param theYp2 [in] the y coordinate of second mouse position, in pixels. |
757 | Standard_EXPORT void Zoom (const Standard_Integer theXp1, const Standard_Integer theYp1, const Standard_Integer theXp2, const Standard_Integer theYp2); |
c357e426 |
758 | |
42cf5bc1 |
759 | //! Defines starting point for ZoomAtPoint view operation. |
760 | //! @param theXp [in] the x mouse coordinate, in pixels. |
761 | //! @param theYp [in] the y mouse coordinate, in pixels. |
762 | Standard_EXPORT void StartZoomAtPoint (const Standard_Integer theXp, const Standard_Integer theYp); |
c357e426 |
763 | |
42cf5bc1 |
764 | //! Zooms the model at a pixel defined by the method StartZoomAtPoint(). |
765 | Standard_EXPORT void ZoomAtPoint (const Standard_Integer theMouseStartX, const Standard_Integer theMouseStartY, const Standard_Integer theMouseEndX, const Standard_Integer theMouseEndY); |
c357e426 |
766 | |
42cf5bc1 |
767 | //! Performs anisotropic scaling of <me> view along the given <Axis>. |
768 | //! The scale factor is calculated on a basis of |
769 | //! the mouse pointer displacement <Dx,Dy>. |
770 | //! The calculated scale factor is then passed to SetAxialScale(Sx, Sy, Sz) method. |
771 | Standard_EXPORT void AxialScale (const Standard_Integer Dx, const Standard_Integer Dy, const V3d_TypeOfAxe Axis); |
c357e426 |
772 | |
42cf5bc1 |
773 | //! Begin the rotation of the view around the screen axis |
774 | //! according to the mouse position <X,Y>. |
775 | //! Warning: Enable rotation around the Z screen axis when <zRotationThreshold> |
776 | //! factor is > 0 soon the distance from the start point and the center |
777 | //! of the view is > (medium viewSize * <zRotationThreshold> ). |
778 | //! Generally a value of 0.4 is usable to rotate around XY screen axis |
779 | //! inside the circular threshold area and to rotate around Z screen axis |
780 | //! outside this area. |
ee2be2a8 |
781 | Standard_EXPORT void StartRotation (const Standard_Integer X, const Standard_Integer Y, const Standard_Real zRotationThreshold = 0.0); |
c357e426 |
782 | |
42cf5bc1 |
783 | //! Continues the rotation of the view |
784 | //! with an angle computed from the last and new mouse position <X,Y>. |
785 | Standard_EXPORT void Rotation (const Standard_Integer X, const Standard_Integer Y); |
c357e426 |
786 | |
42cf5bc1 |
787 | //! Change View Plane Distance for Perspective Views |
788 | //! Warning! raises TypeMismatch from Standard if the view |
789 | //! is not a perspective view. |
ee2be2a8 |
790 | Standard_EXPORT void SetFocale (const Standard_Real Focale); |
c357e426 |
791 | |
42cf5bc1 |
792 | //! Returns the View Plane Distance for Perspective Views |
ee2be2a8 |
793 | Standard_EXPORT Standard_Real Focale() const; |
c357e426 |
794 | |
795 | //! Returns the associated Graphic3d view. |
1ec17fb4 |
796 | const Handle(Graphic3d_CView)& View() const { return myView; } |
c357e426 |
797 | |
798 | //! Switches computed HLR mode in the view. |
799 | Standard_EXPORT void SetComputedMode (const Standard_Boolean theMode); |
800 | |
801 | //! Returns the computed HLR mode state. |
42cf5bc1 |
802 | Standard_EXPORT Standard_Boolean ComputedMode() const; |
c357e426 |
803 | |
42cf5bc1 |
804 | //! idem than WindowFit |
1ec17fb4 |
805 | void WindowFitAll (const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax) |
806 | { |
807 | WindowFit (Xmin, Ymin, Xmax, Ymax); |
808 | } |
c357e426 |
809 | |
14823c6f |
810 | //! Transform camera eye, center and scale to fit in the passed bounding box specified in WCS. |
811 | //! @param theCamera [in] the camera |
812 | //! @param theBox [in] the bounding box |
813 | //! @param theMargin [in] the margin coefficient for view borders |
814 | //! @param theResolution [in] the minimum size of projection of bounding box in Xv or Yv direction when it considered to be a thin plane or point (without a volume); |
815 | //! in this case only the center of camera is adjusted |
816 | //! @param theToEnlargeIfLine [in] when TRUE - in cases when the whole bounding box projected into thin line going along Z-axis of screen, |
817 | //! the view plane is enlarged such thatwe see the whole line on rotation, otherwise only the center of camera is adjusted. |
818 | //! @return TRUE if the fit all operation can be done |
819 | Standard_EXPORT Standard_Boolean FitMinMax (const Handle(Graphic3d_Camera)& theCamera, |
820 | const Bnd_Box& theBox, |
821 | const Standard_Real theMargin, |
822 | const Standard_Real theResolution = 0.0, |
823 | const Standard_Boolean theToEnlargeIfLine = Standard_True) const; |
824 | |
42cf5bc1 |
825 | //! Defines or Updates the definition of the |
826 | //! grid in <me> |
827 | Standard_EXPORT void SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid); |
c357e426 |
828 | |
42cf5bc1 |
829 | //! Defines or Updates the activity of the |
830 | //! grid in <me> |
831 | Standard_EXPORT void SetGridActivity (const Standard_Boolean aFlag); |
c357e426 |
832 | |
23826183 |
833 | //! Dumps the full contents of the View into the image file. This is an alias for ToPixMap() with Image_AlienPixMap. |
834 | //! @param theFile destination image file (image format is determined by file extension like .png, .bmp, .jpg) |
835 | //! @param theBufferType buffer to dump |
836 | //! @return FALSE when the dump has failed |
42cf5bc1 |
837 | Standard_EXPORT Standard_Boolean Dump (const Standard_CString theFile, const Graphic3d_BufferType& theBufferType = Graphic3d_BT_RGB); |
c357e426 |
838 | |
3bffef55 |
839 | //! Dumps the full contents of the view to a pixmap with specified parameters. |
23826183 |
840 | //! Internally this method calls Redraw() with an offscreen render buffer of requested target size (theWidth x theHeight), |
841 | //! so that there is no need resizing a window control for making a dump of different size. |
3bffef55 |
842 | Standard_EXPORT Standard_Boolean ToPixMap (Image_PixMap& theImage, |
843 | const V3d_ImageDumpOptions& theParams); |
844 | |
845 | //! Dumps the full contents of the view to a pixmap. |
23826183 |
846 | //! Internally this method calls Redraw() with an offscreen render buffer of requested target size (theWidth x theHeight), |
847 | //! so that there is no need resizing a window control for making a dump of different size. |
3bffef55 |
848 | //! @param theImage target image, will be re-allocated to match theWidth x theHeight |
849 | //! @param theWidth target image width |
850 | //! @param theHeight target image height |
851 | //! @param theBufferType type of the view buffer to dump (color / depth) |
852 | //! @param theToAdjustAspect when true, active view aspect ratio will be overridden by (theWidth / theHeight) |
853 | //! @param theStereoOptions how to dump stereographic camera |
854 | Standard_Boolean ToPixMap (Image_PixMap& theImage, |
855 | const Standard_Integer theWidth, |
856 | const Standard_Integer theHeight, |
857 | const Graphic3d_BufferType& theBufferType = Graphic3d_BT_RGB, |
858 | const Standard_Boolean theToAdjustAspect = Standard_True, |
859 | const V3d_StereoDumpOptions theStereoOptions = V3d_SDO_MONO) |
860 | { |
861 | V3d_ImageDumpOptions aParams; |
862 | aParams.Width = theWidth; |
863 | aParams.Height = theHeight; |
864 | aParams.BufferType = theBufferType; |
865 | aParams.StereoOptions = theStereoOptions; |
866 | aParams.ToAdjustAspect = theToAdjustAspect; |
867 | return ToPixMap (theImage, aParams); |
868 | } |
c357e426 |
869 | |
42cf5bc1 |
870 | //! Manages display of the back faces |
7fd4958d |
871 | Standard_EXPORT void SetBackFacingModel (const Graphic3d_TypeOfBackfacingModel theModel = Graphic3d_TypeOfBackfacingModel_Auto); |
872 | |
873 | //! Returns current state of the back faces display; Graphic3d_TypeOfBackfacingModel_Auto by default, |
874 | //! which means that backface culling is defined by each presentation. |
875 | Standard_EXPORT Graphic3d_TypeOfBackfacingModel BackFacingModel() const; |
c357e426 |
876 | |
42cf5bc1 |
877 | //! Adds clip plane to the view. The composition of clip planes truncates the |
878 | //! rendering space to convex volume. Number of supported clip planes can be consulted |
c357e426 |
879 | //! by PlaneLimit method of associated Graphic3d_GraphicDriver. |
880 | //! Please be aware that the planes which exceed the limit are ignored during rendering. |
42cf5bc1 |
881 | //! @param thePlane [in] the clip plane to be added to view. |
882 | Standard_EXPORT virtual void AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane); |
c357e426 |
883 | |
42cf5bc1 |
884 | //! Removes clip plane from the view. |
885 | //! @param thePlane [in] the clip plane to be removed from view. |
886 | Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane); |
c357e426 |
887 | |
f4e7c307 |
888 | //! Get clip planes. |
889 | //! @return sequence clip planes that have been set for the view |
890 | Standard_EXPORT const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const; |
891 | |
42cf5bc1 |
892 | //! Sets sequence of clip planes to the view. The planes that have been set |
893 | //! before are removed from the view. The composition of clip planes |
894 | //! truncates the rendering space to convex volume. Number of supported |
c357e426 |
895 | //! clip planes can be consulted by InquirePlaneLimit method of |
896 | //! Graphic3d_GraphicDriver. Please be aware that the planes that |
897 | //! exceed the limit are ignored during rendering. |
42cf5bc1 |
898 | //! @param thePlanes [in] the clip planes to set. |
3202bf1e |
899 | Standard_EXPORT void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes); |
900 | |
c357e426 |
901 | //! Returns the MAX number of clipping planes associated to the view. |
902 | Standard_EXPORT Standard_Integer PlaneLimit() const; |
903 | |
42cf5bc1 |
904 | //! Change camera used by view. |
905 | Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera)& theCamera); |
c357e426 |
906 | |
42cf5bc1 |
907 | //! Returns camera object of the view. |
908 | //! @return: handle to camera object, or NULL if 3D view does not use |
909 | //! the camera approach. |
910 | Standard_EXPORT const Handle(Graphic3d_Camera)& Camera() const; |
c357e426 |
911 | |
1beb58d7 |
912 | //! Return default camera. |
913 | const Handle(Graphic3d_Camera)& DefaultCamera() const { return myDefaultCamera; } |
914 | |
42cf5bc1 |
915 | //! Returns current rendering parameters and effect settings. |
832ae82d |
916 | //! By default it returns default parameters of current viewer. |
917 | //! To define view-specific settings use method V3d_View::ChangeRenderingParams(). |
918 | //! @sa V3d_Viewer::DefaultRenderingParams() |
42cf5bc1 |
919 | Standard_EXPORT const Graphic3d_RenderingParams& RenderingParams() const; |
c357e426 |
920 | |
42cf5bc1 |
921 | //! Returns reference to current rendering parameters and effect settings. |
922 | Standard_EXPORT Graphic3d_RenderingParams& ChangeRenderingParams(); |
c357e426 |
923 | |
42cf5bc1 |
924 | //! @return flag value of objects culling mechanism |
0e3025bc |
925 | Standard_Boolean IsCullingEnabled() const { return RenderingParams().FrustumCullingState == Graphic3d_RenderingParams::FrustumCulling_On; } |
c357e426 |
926 | |
0e3025bc |
927 | //! Turn on/off automatic culling of objects outside frustum (ON by default) |
928 | void SetFrustumCulling (Standard_Boolean theMode) { ChangeRenderingParams().FrustumCullingState = theMode ? Graphic3d_RenderingParams::FrustumCulling_On : Graphic3d_RenderingParams::FrustumCulling_Off; } |
42cf5bc1 |
929 | |
26d9c835 |
930 | //! Fill in the dictionary with diagnostic info. |
931 | //! Should be called within rendering thread. |
932 | //! |
933 | //! This API should be used only for user output or for creating automated reports. |
934 | //! The format of returned information (e.g. key-value layout) |
935 | //! is NOT part of this API and can be changed at any time. |
936 | //! Thus application should not parse returned information to weed out specific parameters. |
937 | //! @param theDict destination map for information |
938 | //! @param theFlags defines the information to be retrieved |
939 | Standard_EXPORT void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict, |
940 | Graphic3d_DiagnosticInfo theFlags) const; |
42cf5bc1 |
941 | |
79b544e6 |
942 | //! Returns string with statistic performance info. |
943 | Standard_EXPORT TCollection_AsciiString StatisticInformation() const; |
944 | |
945 | //! Fills in the dictionary with statistic performance info. |
946 | Standard_EXPORT void StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const; |
947 | |
49582f9d |
948 | //! Returns the Objects number and the gravity center of ALL viewable points in the view |
949 | Standard_EXPORT gp_Pnt GravityPoint() const; |
950 | |
a5162275 |
951 | //! Dumps the content of me into the stream |
952 | Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; |
953 | |
879768fb |
954 | public: //! @name subvew management |
955 | |
956 | //! Return TRUE if this is a subview of another view. |
957 | bool IsSubview() const { return myParentView != nullptr; } |
958 | |
959 | //! Return parent View or NULL if this is not a subview. |
960 | V3d_View* ParentView() { return myParentView; } |
961 | |
962 | //! Return subview list. |
963 | const NCollection_Sequence<Handle(V3d_View)>& Subviews() const { return mySubviews; } |
964 | |
965 | //! Pick subview from the given 2D point. |
966 | Standard_EXPORT Handle(V3d_View) PickSubview (const Graphic3d_Vec2i& thePnt) const; |
967 | |
968 | //! Add subview to the list. |
969 | Standard_EXPORT void AddSubview (const Handle(V3d_View)& theView); |
970 | |
971 | //! Remove subview from the list. |
972 | Standard_EXPORT bool RemoveSubview (const V3d_View* theView); |
42cf5bc1 |
973 | |
f7fc0c03 |
974 | public: //! @name deprecated methods |
975 | |
976 | //! Returns True if One light more can be |
977 | //! activated in this View. |
978 | Standard_DEPRECATED ("Deprecated method - ActiveLights() should be used instead") |
979 | Standard_EXPORT Standard_Boolean IfMoreLights() const; |
980 | |
981 | //! initializes an iteration on the active Lights. |
982 | Standard_DEPRECATED ("Deprecated method - ActiveLights() should be used instead") |
983 | void InitActiveLights() { myActiveLightsIterator.Initialize (myActiveLights); } |
984 | |
985 | //! returns true if there are more active Light(s) to return. |
986 | Standard_DEPRECATED ("Deprecated method - ActiveLights() should be used instead") |
987 | Standard_Boolean MoreActiveLights() const { return myActiveLightsIterator.More(); } |
988 | |
989 | //! Go to the next active Light (if there is not, ActiveLight will raise an exception) |
990 | Standard_DEPRECATED ("Deprecated method - ActiveLights() should be used instead") |
991 | void NextActiveLights() { myActiveLightsIterator.Next(); } |
992 | |
993 | Standard_DEPRECATED ("Deprecated method - ActiveLights() should be used instead") |
994 | const Handle(V3d_Light)& ActiveLight() const { return myActiveLightsIterator.Value(); } |
995 | |
42cf5bc1 |
996 | protected: |
997 | |
42cf5bc1 |
998 | Standard_EXPORT void ImmediateUpdate() const; |
c357e426 |
999 | |
42cf5bc1 |
1000 | //! Scales camera to fit the view frame of defined width and height |
1001 | //! keeping the aspect. For orthogonal camera the method changes scale, |
1002 | //! for perspective adjusts Eye location about the Center point. |
1003 | //! @param theSizeXv [in] size of viewport frame on "x" axis. |
1004 | //! @param theSizeYv [in] size of viewport frame on "y" axis. |
1005 | Standard_EXPORT void Scale (const Handle(Graphic3d_Camera)& theCamera, const Standard_Real theSizeXv, const Standard_Real theSizeYv) const; |
42cf5bc1 |
1006 | |
c357e426 |
1007 | Standard_EXPORT void Translate (const Handle(Graphic3d_Camera)& theCamera, const Standard_Real theDXv, const Standard_Real theDYv) const; |
42cf5bc1 |
1008 | |
1009 | private: |
1010 | |
c357e426 |
1011 | //! Modifies the aspect ratio of the camera when |
1012 | //! the associated window is defined or resized. |
1013 | Standard_EXPORT void SetRatio(); |
1014 | |
42cf5bc1 |
1015 | //! Determines the screen axes in the reference |
1016 | //! framework of the view. |
21b2385f |
1017 | Standard_EXPORT static Standard_Boolean screenAxis (const gp_Dir& theVpn, const gp_Dir& theVup, |
1018 | gp_Vec& theXaxe, gp_Vec& theYaxe, gp_Vec& theZaxe); |
42cf5bc1 |
1019 | |
1020 | //! Transforms the Vertex V according to the matrice Matrix . |
475c2302 |
1021 | Standard_EXPORT static gp_XYZ TrsPoint (const Graphic3d_Vertex& V, const TColStd_Array2OfReal& Matrix); |
42cf5bc1 |
1022 | |
1023 | //! Returns the objects number and the projection window |
1024 | //! of the objects contained in the view. |
ee2be2a8 |
1025 | Standard_EXPORT Standard_Integer MinMax (Standard_Real& Umin, Standard_Real& Vmin, Standard_Real& Umax, Standard_Real& Vmax) const; |
42cf5bc1 |
1026 | |
1027 | //! Returns the objects number and the box encompassing |
1028 | //! the objects contained in the view |
ee2be2a8 |
1029 | Standard_EXPORT Standard_Integer MinMax (Standard_Real& Xmin, Standard_Real& Ymin, Standard_Real& Zmin, Standard_Real& Xmax, Standard_Real& Ymax, Standard_Real& Zmax) const; |
42cf5bc1 |
1030 | |
42cf5bc1 |
1031 | Standard_EXPORT void Init(); |
1032 | |
1033 | //! Returns a new vertex when the grid is activated. |
1034 | Standard_EXPORT Graphic3d_Vertex Compute (const Graphic3d_Vertex& AVertex) const; |
1035 | |
c357e426 |
1036 | protected: |
1037 | |
1038 | Standard_Real myOldMouseX; |
1039 | Standard_Real myOldMouseY; |
1040 | gp_Dir myCamStartOpUp; |
607e5e62 |
1041 | gp_Dir myCamStartOpDir; |
c357e426 |
1042 | gp_Pnt myCamStartOpEye; |
c357e426 |
1043 | gp_Pnt myCamStartOpCenter; |
c357e426 |
1044 | Handle(Graphic3d_Camera) myDefaultCamera; |
1045 | Handle(Graphic3d_CView) myView; |
1046 | Standard_Boolean myImmediateUpdate; |
49582f9d |
1047 | mutable Standard_Boolean myIsInvalidatedImmediate; |
c357e426 |
1048 | |
1049 | private: |
1050 | |
1a96d253 |
1051 | V3d_Viewer* MyViewer; |
879768fb |
1052 | |
1053 | NCollection_Sequence<Handle(V3d_View)> mySubviews; |
1054 | V3d_View* myParentView; |
1055 | |
6a24c6de |
1056 | V3d_ListOfLight myActiveLights; |
21b2385f |
1057 | gp_Dir myDefaultViewAxis; |
1058 | gp_Pnt myDefaultViewPoint; |
42cf5bc1 |
1059 | Handle(Aspect_Window) MyWindow; |
6a24c6de |
1060 | V3d_ListOfLight::Iterator myActiveLightsIterator; |
42cf5bc1 |
1061 | Standard_Integer sx; |
1062 | Standard_Integer sy; |
1063 | Standard_Real rx; |
1064 | Standard_Real ry; |
49582f9d |
1065 | gp_Pnt myRotateGravity; |
42cf5bc1 |
1066 | Standard_Boolean myComputedMode; |
1067 | Standard_Boolean SwitchSetFront; |
016e5959 |
1068 | Standard_Boolean myZRotation; |
42cf5bc1 |
1069 | Standard_Integer MyZoomAtPointX; |
1070 | Standard_Integer MyZoomAtPointY; |
caf231b0 |
1071 | Handle(V3d_Trihedron) myTrihedron; |
42cf5bc1 |
1072 | Handle(Aspect_Grid) MyGrid; |
1073 | gp_Ax3 MyPlane; |
42cf5bc1 |
1074 | TColStd_Array2OfReal MyTrsf; |
1075 | Handle(Graphic3d_Structure) MyGridEchoStructure; |
1076 | Handle(Graphic3d_Group) MyGridEchoGroup; |
21b2385f |
1077 | gp_Vec myXscreenAxis; |
1078 | gp_Vec myYscreenAxis; |
1079 | gp_Vec myZscreenAxis; |
1080 | gp_Dir myViewAxis; |
42cf5bc1 |
1081 | Graphic3d_Vertex myGravityReferencePoint; |
c357e426 |
1082 | Standard_Boolean myAutoZFitIsOn; |
1083 | Standard_Real myAutoZFitScaleFactor; |
caf231b0 |
1084 | |
42cf5bc1 |
1085 | }; |
1086 | |
42cf5bc1 |
1087 | #endif // _V3d_View_HeaderFile |