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