Commit | Line | Data |
---|---|---|
973c2be1 | 1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 2 | // |
973c2be1 | 3 | // This file is part of Open CASCADE Technology software library. |
b311480e | 4 | // |
d5f74e42 | 5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
9 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 10 | // |
973c2be1 | 11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. | |
b311480e | 13 | |
3bffef55 | 14 | #include <V3d_View.hxx> |
7fd59977 | 15 | |
478862fc | 16 | #include <Aspect_CircularGrid.hxx> |
42cf5bc1 | 17 | #include <Aspect_GradientBackground.hxx> |
18 | #include <Aspect_Grid.hxx> | |
478862fc | 19 | #include <Aspect_RectangularGrid.hxx> |
42cf5bc1 | 20 | #include <Aspect_Window.hxx> |
21 | #include <Bnd_Box.hxx> | |
22 | #include <gp_Ax3.hxx> | |
7fd59977 | 23 | #include <gp_Dir.hxx> |
b5ac8292 | 24 | #include <gp_Pln.hxx> |
42cf5bc1 | 25 | #include <Graphic3d_AspectMarker3d.hxx> |
26 | #include <Graphic3d_GraphicDriver.hxx> | |
27 | #include <Graphic3d_Group.hxx> | |
b5ac8292 | 28 | #include <Graphic3d_MapIteratorOfMapOfStructure.hxx> |
29 | #include <Graphic3d_MapOfStructure.hxx> | |
42cf5bc1 | 30 | #include <Graphic3d_Structure.hxx> |
b5ac8292 | 31 | #include <Graphic3d_TextureEnv.hxx> |
42cf5bc1 | 32 | #include <Image_AlienPixMap.hxx> |
3bffef55 | 33 | #include <Message.hxx> |
34 | #include <Message_Messenger.hxx> | |
42cf5bc1 | 35 | #include <NCollection_Array1.hxx> |
36 | #include <Precision.hxx> | |
37 | #include <Quantity_Color.hxx> | |
38 | #include <Standard_Assert.hxx> | |
39 | #include <Standard_DivideByZero.hxx> | |
40 | #include <Standard_ErrorHandler.hxx> | |
41 | #include <Standard_MultiplyDefined.hxx> | |
42 | #include <Standard_ShortReal.hxx> | |
43 | #include <Standard_Type.hxx> | |
44 | #include <Standard_TypeMismatch.hxx> | |
c357e426 | 45 | #include <TColgp_Array1OfPnt.hxx> |
42cf5bc1 | 46 | #include <TColStd_Array2OfReal.hxx> |
47 | #include <TColStd_HSequenceOfInteger.hxx> | |
48 | #include <V3d.hxx> | |
49 | #include <V3d_BadValue.hxx> | |
42cf5bc1 | 50 | #include <V3d_Light.hxx> |
51 | #include <V3d_StereoDumpOptions.hxx> | |
52 | #include <V3d_UnMapped.hxx> | |
42cf5bc1 | 53 | #include <V3d_Viewer.hxx> |
7fd59977 | 54 | |
25e59720 | 55 | IMPLEMENT_STANDARD_RTTIEXT(V3d_View,Standard_Transient) |
92efcf78 | 56 | |
c6541a0c | 57 | #define DEUXPI (2. * M_PI) |
7fd59977 | 58 | |
4af098ba | 59 | namespace |
60 | { | |
61 | static const Standard_Integer THE_NB_BOUND_POINTS = 8; | |
62 | } | |
63 | ||
197ac94e | 64 | //============================================================================= |
65 | //function : Constructor | |
66 | //purpose : | |
67 | //============================================================================= | |
c357e426 | 68 | V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView theType) |
49582f9d | 69 | : myIsInvalidatedImmediate (Standard_True), |
70 | MyViewer (theViewer.operator->()), | |
c357e426 | 71 | SwitchSetFront (Standard_False), |
016e5959 | 72 | myZRotation (Standard_False), |
6bc6a6fc | 73 | MyTrsf (1, 4, 1, 4) |
7fd59977 | 74 | { |
c357e426 | 75 | myView = theViewer->Driver()->CreateView (theViewer->StructureManager()); |
7fd59977 | 76 | |
c357e426 | 77 | myView->SetBackground (theViewer->GetBackgroundColor()); |
78 | myView->SetGradientBackground (theViewer->GetGradientBackground()); | |
7fd59977 | 79 | |
832ae82d | 80 | ChangeRenderingParams() = theViewer->DefaultRenderingParams(); |
81 | ||
b5ac8292 | 82 | // camera init |
83 | Handle(Graphic3d_Camera) aCamera = new Graphic3d_Camera(); | |
84 | aCamera->SetFOVy (45.0); | |
85 | aCamera->SetIOD (Graphic3d_Camera::IODType_Relative, 0.05); | |
86 | aCamera->SetZFocus (Graphic3d_Camera::FocusType_Relative, 1.0); | |
c357e426 | 87 | aCamera->SetProjectionType ((theType == V3d_ORTHOGRAPHIC) |
88 | ? Graphic3d_Camera::Projection_Orthographic | |
89 | : Graphic3d_Camera::Projection_Perspective); | |
b5ac8292 | 90 | |
c357e426 | 91 | myDefaultCamera = new Graphic3d_Camera(); |
92 | ||
93 | myImmediateUpdate = Standard_False; | |
c357e426 | 94 | SetAutoZFitMode (Standard_True, 1.0); |
95 | SetBackFacingModel (V3d_TOBM_AUTOMATIC); | |
96 | SetCamera (aCamera); | |
b5ac8292 | 97 | SetAxis (0.,0.,0.,1.,1.,1.); |
c357e426 | 98 | SetVisualization (theViewer->DefaultVisualization()); |
99 | SetShadingModel (theViewer->DefaultShadingModel()); | |
b5ac8292 | 100 | SetTwist (0.); |
101 | SetAt (0.,0.,0.); | |
c357e426 | 102 | SetProj (theViewer->DefaultViewProj()); |
103 | SetSize (theViewer->DefaultViewSize()); | |
104 | Standard_Real zsize = theViewer->DefaultViewSize(); | |
b5ac8292 | 105 | SetZSize (2.*zsize); |
c357e426 | 106 | SetDepth (theViewer->DefaultViewSize() / 2.0); |
7fd59977 | 107 | SetViewMappingDefault(); |
fc8eab5e | 108 | SetViewOrientationDefault(); |
c357e426 | 109 | theViewer->AddView (this); |
7fd59977 | 110 | Init(); |
111 | myImmediateUpdate = Standard_True; | |
7fd59977 | 112 | } |
113 | ||
197ac94e | 114 | //============================================================================= |
115 | //function : Constructor | |
116 | //purpose : | |
117 | //============================================================================= | |
c357e426 | 118 | V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const Handle(V3d_View)& theView) |
49582f9d | 119 | : myIsInvalidatedImmediate (Standard_True), |
120 | MyViewer (theViewer.operator->()), | |
197ac94e | 121 | SwitchSetFront(Standard_False), |
016e5959 | 122 | myZRotation (Standard_False), |
197ac94e | 123 | MyTrsf (1, 4, 1, 4) |
7fd59977 | 124 | { |
c357e426 | 125 | myView = theViewer->Driver()->CreateView (theViewer->StructureManager()); |
7fd59977 | 126 | |
c357e426 | 127 | myView->CopySettings (theView->View()); |
9e04ccdc | 128 | myDefaultViewPoint = theView->myDefaultViewPoint; |
129 | myDefaultViewAxis = theView->myDefaultViewAxis; | |
7fd59977 | 130 | |
9e04ccdc | 131 | myDefaultCamera = new Graphic3d_Camera (theView->DefaultCamera()); |
b5ac8292 | 132 | |
c357e426 | 133 | myImmediateUpdate = Standard_False; |
134 | SetAutoZFitMode (theView->AutoZFitMode(), theView->AutoZFitScaleFactor()); | |
c357e426 | 135 | theViewer->AddView (this); |
7fd59977 | 136 | Init(); |
137 | myImmediateUpdate = Standard_True; | |
7fd59977 | 138 | } |
139 | ||
197ac94e | 140 | //============================================================================= |
c357e426 | 141 | //function : Destructor |
197ac94e | 142 | //purpose : |
143 | //============================================================================= | |
c357e426 | 144 | V3d_View::~V3d_View() |
145 | { | |
146 | if (!myView->IsRemoved()) | |
147 | { | |
148 | myView->Remove(); | |
7fd59977 | 149 | } |
7fd59977 | 150 | } |
151 | ||
197ac94e | 152 | //============================================================================= |
c357e426 | 153 | //function : SetMagnify |
197ac94e | 154 | //purpose : |
155 | //============================================================================= | |
c357e426 | 156 | void V3d_View::SetMagnify (const Handle(Aspect_Window)& theWindow, |
157 | const Handle(V3d_View)& thePreviousView, | |
158 | const Standard_Integer theX1, | |
159 | const Standard_Integer theY1, | |
160 | const Standard_Integer theX2, | |
161 | const Standard_Integer theY2) | |
7fd59977 | 162 | { |
c357e426 | 163 | if (!myView->IsRemoved() && !myView->IsDefined()) |
164 | { | |
165 | Standard_Real aU1, aV1, aU2, aV2; | |
166 | thePreviousView->Convert (theX1, theY1, aU1, aV1); | |
167 | thePreviousView->Convert (theX2, theY2, aU2, aV2); | |
168 | myView->SetWindow (theWindow); | |
434ffc09 | 169 | FitAll (aU1, aV1, aU2, aV2); |
c357e426 | 170 | MyViewer->SetViewOn (this); |
171 | MyWindow = theWindow; | |
172 | SetRatio(); | |
173 | Redraw(); | |
174 | SetViewMappingDefault(); | |
175 | } | |
7fd59977 | 176 | } |
177 | ||
197ac94e | 178 | //============================================================================= |
179 | //function : SetWindow | |
180 | //purpose : | |
181 | //============================================================================= | |
a521d90d | 182 | void V3d_View::SetWindow (const Handle(Aspect_Window)& theWindow, |
183 | const Aspect_RenderingContext theContext) | |
7fd59977 | 184 | { |
c357e426 | 185 | if (myView->IsRemoved()) |
186 | { | |
187 | return; | |
188 | } | |
189 | ||
05e2200b | 190 | // method V3d_View::SetWindow() should assign the field MyWindow before calling Redraw() |
c357e426 | 191 | MyWindow = theWindow; |
a521d90d | 192 | myView->SetWindow (theWindow, theContext); |
c357e426 | 193 | MyViewer->SetViewOn (this); |
194 | SetRatio(); | |
39235bed | 195 | if (myImmediateUpdate) |
196 | { | |
197 | Redraw(); | |
198 | } | |
7fd59977 | 199 | } |
7fd59977 | 200 | |
197ac94e | 201 | //============================================================================= |
202 | //function : Remove | |
203 | //purpose : | |
204 | //============================================================================= | |
5634c81a | 205 | void V3d_View::Remove() |
5e27df78 | 206 | { |
475c2302 | 207 | if (!MyGrid.IsNull()) |
208 | { | |
209 | MyGrid->Erase(); | |
210 | } | |
211 | if (!myTrihedron.IsNull()) | |
212 | { | |
213 | myTrihedron->Erase(); | |
214 | } | |
215 | ||
5e27df78 | 216 | MyViewer->DelView (this); |
c357e426 | 217 | myView->Remove(); |
5e27df78 | 218 | Handle(Aspect_Window)& aWin = const_cast<Handle(Aspect_Window)&> (MyWindow); |
219 | aWin.Nullify(); | |
7fd59977 | 220 | } |
221 | ||
197ac94e | 222 | //============================================================================= |
223 | //function : Update | |
224 | //purpose : | |
225 | //============================================================================= | |
b8ddfc2f | 226 | void V3d_View::Update() const |
227 | { | |
c357e426 | 228 | if (!myView->IsDefined() |
229 | || !myView->IsActive()) | |
230 | { | |
231 | return; | |
232 | } | |
233 | ||
49582f9d | 234 | myIsInvalidatedImmediate = Standard_False; |
cfece3ef | 235 | myView->Update(); |
236 | myView->Compute(); | |
b40cdc2b | 237 | AutoZFit(); |
cfece3ef | 238 | myView->Redraw(); |
7fd59977 | 239 | } |
240 | ||
197ac94e | 241 | //============================================================================= |
242 | //function : Redraw | |
243 | //purpose : | |
244 | //============================================================================= | |
b8ddfc2f | 245 | void V3d_View::Redraw() const |
246 | { | |
c357e426 | 247 | if (!myView->IsDefined() |
248 | || !myView->IsActive()) | |
249 | { | |
250 | return; | |
251 | } | |
252 | ||
49582f9d | 253 | myIsInvalidatedImmediate = Standard_False; |
c357e426 | 254 | Handle(Graphic3d_StructureManager) aStructureMgr = MyViewer->StructureManager(); |
255 | for (Standard_Integer aRetryIter = 0; aRetryIter < 2; ++aRetryIter) | |
256 | { | |
851dacdb | 257 | if (aStructureMgr->IsDeviceLost()) |
c357e426 | 258 | { |
259 | aStructureMgr->RecomputeStructures(); | |
c357e426 | 260 | } |
261 | ||
262 | AutoZFit(); | |
263 | ||
264 | myView->Redraw(); | |
265 | ||
851dacdb | 266 | if (!aStructureMgr->IsDeviceLost()) |
c357e426 | 267 | { |
268 | return; | |
269 | } | |
270 | } | |
7fd59977 | 271 | } |
b8ddfc2f | 272 | |
679ecdee | 273 | //============================================================================= |
274 | //function : RedrawImmediate | |
275 | //purpose : | |
276 | //============================================================================= | |
277 | void V3d_View::RedrawImmediate() const | |
278 | { | |
c357e426 | 279 | if (!myView->IsDefined() |
280 | || !myView->IsActive()) | |
679ecdee | 281 | { |
c357e426 | 282 | return; |
679ecdee | 283 | } |
c357e426 | 284 | |
49582f9d | 285 | myIsInvalidatedImmediate = Standard_False; |
c357e426 | 286 | myView->RedrawImmediate(); |
679ecdee | 287 | } |
288 | ||
289 | //============================================================================= | |
290 | //function : Invalidate | |
291 | //purpose : | |
292 | //============================================================================= | |
293 | void V3d_View::Invalidate() const | |
294 | { | |
c357e426 | 295 | if (!myView->IsDefined()) |
679ecdee | 296 | { |
c357e426 | 297 | return; |
679ecdee | 298 | } |
c357e426 | 299 | |
300 | myView->Invalidate(); | |
679ecdee | 301 | } |
302 | ||
6bc6a6fc | 303 | //============================================================================= |
62e1beed | 304 | //function : IsInvalidated |
305 | //purpose : | |
306 | //============================================================================= | |
307 | Standard_Boolean V3d_View::IsInvalidated() const | |
308 | { | |
c357e426 | 309 | return !myView->IsDefined() |
310 | || myView->IsInvalidated(); | |
62e1beed | 311 | } |
312 | ||
c357e426 | 313 | // ======================================================================== |
314 | // function : SetAutoZFitMode | |
315 | // purpose : | |
316 | // ======================================================================== | |
317 | void V3d_View::SetAutoZFitMode (const Standard_Boolean theIsOn, | |
318 | const Standard_Real theScaleFactor) | |
319 | { | |
320 | Standard_ASSERT_RAISE (theScaleFactor > 0.0, "Zero or negative scale factor is not allowed."); | |
321 | myAutoZFitScaleFactor = theScaleFactor; | |
322 | myAutoZFitIsOn = theIsOn; | |
323 | } | |
324 | ||
6bc6a6fc | 325 | //============================================================================= |
c357e426 | 326 | //function : AutoZFit |
6bc6a6fc | 327 | //purpose : |
328 | //============================================================================= | |
c357e426 | 329 | void V3d_View::AutoZFit() const |
6bc6a6fc | 330 | { |
c357e426 | 331 | if (!AutoZFitMode()) |
332 | { | |
333 | return; | |
334 | } | |
335 | ||
336 | ZFitAll (myAutoZFitScaleFactor); | |
6bc6a6fc | 337 | } |
338 | ||
197ac94e | 339 | //============================================================================= |
c357e426 | 340 | //function : ZFitAll |
197ac94e | 341 | //purpose : |
342 | //============================================================================= | |
c357e426 | 343 | void V3d_View::ZFitAll (const Standard_Real theScaleFactor) const |
7fd59977 | 344 | { |
c357e426 | 345 | Bnd_Box aMinMaxBox = myView->MinMaxValues (Standard_False); // applicative min max boundaries |
346 | Bnd_Box aGraphicBox = myView->MinMaxValues (Standard_True); // real graphical boundaries (not accounting infinite flag). | |
347 | ||
348 | myView->Camera()->ZFitAll (theScaleFactor, aMinMaxBox, aGraphicBox); | |
7fd59977 | 349 | } |
350 | ||
197ac94e | 351 | //============================================================================= |
352 | //function : IsEmpty | |
353 | //purpose : | |
354 | //============================================================================= | |
b8ddfc2f | 355 | Standard_Boolean V3d_View::IsEmpty() const |
356 | { | |
7fd59977 | 357 | Standard_Boolean TheStatus = Standard_True ; |
c357e426 | 358 | if( myView->IsDefined() ) { |
359 | Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ; | |
7fd59977 | 360 | if( Nstruct > 0 ) TheStatus = Standard_False ; |
361 | } | |
362 | return (TheStatus) ; | |
7fd59977 | 363 | } |
364 | ||
197ac94e | 365 | //============================================================================= |
366 | //function : UpdateLights | |
367 | //purpose : | |
368 | //============================================================================= | |
b8ddfc2f | 369 | void V3d_View::UpdateLights() const |
370 | { | |
992ed6b3 | 371 | Handle(Graphic3d_LightSet) aLights = new Graphic3d_LightSet(); |
6a24c6de | 372 | for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More(); anActiveLightIter.Next()) |
c357e426 | 373 | { |
992ed6b3 | 374 | aLights->Add (anActiveLightIter.Value()); |
c357e426 | 375 | } |
c357e426 | 376 | myView->SetLights (aLights); |
7fd59977 | 377 | } |
378 | ||
197ac94e | 379 | //============================================================================= |
380 | //function : DoMapping | |
381 | //purpose : | |
382 | //============================================================================= | |
b8ddfc2f | 383 | void V3d_View::DoMapping() |
384 | { | |
c357e426 | 385 | if (!myView->IsDefined()) |
386 | { | |
387 | return; | |
7fd59977 | 388 | } |
c357e426 | 389 | |
390 | myView->Window()->DoMapping(); | |
7fd59977 | 391 | } |
392 | ||
197ac94e | 393 | //============================================================================= |
394 | //function : MustBeResized | |
395 | //purpose : | |
396 | //============================================================================= | |
b8ddfc2f | 397 | void V3d_View::MustBeResized() |
398 | { | |
c357e426 | 399 | if (!myView->IsDefined()) |
400 | { | |
401 | return; | |
7fd59977 | 402 | } |
c357e426 | 403 | |
404 | myView->Resized(); | |
405 | ||
406 | SetRatio(); | |
39235bed | 407 | if (myImmediateUpdate) |
408 | { | |
409 | Redraw(); | |
410 | } | |
7fd59977 | 411 | } |
412 | ||
197ac94e | 413 | //============================================================================= |
414 | //function : SetBackgroundColor | |
415 | //purpose : | |
416 | //============================================================================= | |
c357e426 | 417 | void V3d_View::SetBackgroundColor (const Quantity_TypeOfColor theType, |
418 | const Standard_Real theV1, | |
419 | const Standard_Real theV2, | |
420 | const Standard_Real theV3) | |
7fd59977 | 421 | { |
c357e426 | 422 | Standard_Real aV1 = Max (Min (theV1, 1.0), 0.0); |
423 | Standard_Real aV2 = Max (Min (theV2, 1.0), 0.0); | |
424 | Standard_Real aV3 = Max (Min (theV3, 1.0), 0.0); | |
7fd59977 | 425 | |
c357e426 | 426 | SetBackgroundColor (Quantity_Color (aV1, aV2, aV3, theType)); |
7fd59977 | 427 | } |
428 | ||
197ac94e | 429 | //============================================================================= |
430 | //function : SetBackgroundColor | |
431 | //purpose : | |
432 | //============================================================================= | |
c357e426 | 433 | void V3d_View::SetBackgroundColor (const Quantity_Color& theColor) |
7fd59977 | 434 | { |
c357e426 | 435 | myView->SetBackground (Aspect_Background (theColor)); |
436 | ||
437 | if (myImmediateUpdate) | |
438 | { | |
439 | Redraw(); | |
440 | } | |
7fd59977 | 441 | } |
7fd59977 | 442 | |
197ac94e | 443 | //============================================================================= |
444 | //function : SetBgGradientColors | |
445 | //purpose : | |
446 | //============================================================================= | |
c357e426 | 447 | void V3d_View::SetBgGradientColors (const Quantity_Color& theColor1, |
448 | const Quantity_Color& theColor2, | |
449 | const Aspect_GradientFillMethod theFillStyle, | |
450 | const Standard_Boolean theToUpdate) | |
7fd59977 | 451 | { |
c357e426 | 452 | Aspect_GradientBackground aGradientBg (theColor1, theColor2, theFillStyle); |
453 | ||
454 | myView->SetGradientBackground (aGradientBg); | |
455 | ||
456 | if (myImmediateUpdate || theToUpdate) | |
457 | { | |
458 | Redraw(); | |
459 | } | |
7fd59977 | 460 | } |
461 | ||
197ac94e | 462 | //============================================================================= |
463 | //function : SetBgGradientStyle | |
464 | //purpose : | |
465 | //============================================================================= | |
c357e426 | 466 | void V3d_View::SetBgGradientStyle (const Aspect_GradientFillMethod theFillStyle, const Standard_Boolean theToUpdate) |
7fd59977 | 467 | { |
c357e426 | 468 | Quantity_Color aColor1; |
469 | Quantity_Color aColor2; | |
470 | GradientBackground().Colors (aColor1, aColor2); | |
471 | ||
472 | SetBgGradientColors (aColor1, aColor2, theFillStyle, theToUpdate); | |
7fd59977 | 473 | } |
474 | ||
197ac94e | 475 | //============================================================================= |
476 | //function : SetBackgroundImage | |
477 | //purpose : | |
478 | //============================================================================= | |
c357e426 | 479 | void V3d_View::SetBackgroundImage (const Standard_CString theFileName, |
480 | const Aspect_FillMethod theFillStyle, | |
481 | const Standard_Boolean theToUpdate) | |
7fd59977 | 482 | { |
99289bed | 483 | Handle(Graphic3d_Texture2D) aTextureMap = new Graphic3d_Texture2Dmanual (theFileName); |
484 | aTextureMap->DisableModulate(); | |
485 | SetBackgroundImage (aTextureMap, theFillStyle, theToUpdate); | |
486 | } | |
c357e426 | 487 | |
99289bed | 488 | //============================================================================= |
489 | //function : SetBackgroundImage | |
490 | //purpose : | |
491 | //============================================================================= | |
492 | void V3d_View::SetBackgroundImage (const Handle(Graphic3d_Texture2D)& theTexture, | |
493 | const Aspect_FillMethod theFillStyle, | |
494 | const Standard_Boolean theToUpdate) | |
495 | { | |
496 | myView->SetBackgroundImage (theTexture); | |
497 | myView->SetBackgroundImageStyle (theFillStyle); | |
c357e426 | 498 | if (myImmediateUpdate || theToUpdate) |
499 | { | |
500 | Redraw(); | |
501 | } | |
7fd59977 | 502 | } |
503 | ||
197ac94e | 504 | //============================================================================= |
505 | //function : SetBgImageStyle | |
506 | //purpose : | |
507 | //============================================================================= | |
c357e426 | 508 | void V3d_View::SetBgImageStyle (const Aspect_FillMethod theFillStyle, const Standard_Boolean theToUpdate) |
7fd59977 | 509 | { |
c357e426 | 510 | myView->SetBackgroundImageStyle (theFillStyle); |
511 | ||
512 | if (myImmediateUpdate || theToUpdate) | |
513 | { | |
514 | Redraw(); | |
515 | } | |
7fd59977 | 516 | } |
517 | ||
197ac94e | 518 | //============================================================================= |
077a220c | 519 | //function : SetBackgroundCubeMap |
520 | //purpose : | |
521 | //============================================================================= | |
522 | void V3d_View::SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap, | |
67312b79 | 523 | Standard_Boolean theToUpdatePBREnv, |
077a220c | 524 | Standard_Boolean theToUpdate) |
525 | { | |
99289bed | 526 | myView->SetBackgroundImage (theCubeMap, theToUpdatePBREnv); |
67312b79 | 527 | if (myImmediateUpdate || theToUpdate) |
528 | { | |
529 | Redraw(); | |
530 | } | |
531 | } | |
077a220c | 532 | |
67312b79 | 533 | //============================================================================= |
534 | //function : GeneratePBREnvironment | |
535 | //purpose : | |
536 | //============================================================================= | |
537 | void V3d_View::GeneratePBREnvironment (Standard_Boolean theToUpdate) | |
538 | { | |
539 | myView->GeneratePBREnvironment(); | |
540 | if (myImmediateUpdate || theToUpdate) | |
541 | { | |
542 | Redraw(); | |
543 | } | |
544 | } | |
545 | ||
546 | //============================================================================= | |
547 | //function : ClearPBREnvironment | |
548 | //purpose : | |
549 | //============================================================================= | |
550 | void V3d_View::ClearPBREnvironment (Standard_Boolean theToUpdate) | |
551 | { | |
552 | myView->ClearPBREnvironment(); | |
077a220c | 553 | if (myImmediateUpdate || theToUpdate) |
554 | { | |
555 | Redraw(); | |
556 | } | |
557 | } | |
558 | ||
559 | //============================================================================= | |
197ac94e | 560 | //function : SetAxis |
561 | //purpose : | |
562 | //============================================================================= | |
21b2385f | 563 | void V3d_View::SetAxis (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ, |
564 | const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz) | |
b8ddfc2f | 565 | { |
21b2385f | 566 | myDefaultViewPoint.SetCoord (theX, theY, theZ); |
567 | myDefaultViewAxis.SetCoord (theVx, theVy, theVz); | |
7fd59977 | 568 | } |
569 | ||
197ac94e | 570 | //============================================================================= |
571 | //function : SetShadingModel | |
572 | //purpose : | |
573 | //============================================================================= | |
dc89236f | 574 | void V3d_View::SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel) |
b8ddfc2f | 575 | { |
dc89236f | 576 | myView->SetShadingModel (theShadingModel); |
7fd59977 | 577 | } |
578 | ||
197ac94e | 579 | //============================================================================= |
580 | //function : SetTextureEnv | |
581 | //purpose : | |
582 | //============================================================================= | |
c357e426 | 583 | void V3d_View::SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTexture) |
b8ddfc2f | 584 | { |
c357e426 | 585 | myView->SetTextureEnv (theTexture); |
586 | ||
587 | if (myImmediateUpdate) | |
588 | { | |
589 | Redraw(); | |
590 | } | |
7fd59977 | 591 | } |
592 | ||
197ac94e | 593 | //============================================================================= |
594 | //function : SetVisualization | |
595 | //purpose : | |
596 | //============================================================================= | |
c357e426 | 597 | void V3d_View::SetVisualization (const V3d_TypeOfVisualization theType) |
b8ddfc2f | 598 | { |
c357e426 | 599 | myView->SetVisualizationType (static_cast <Graphic3d_TypeOfVisualization> (theType)); |
600 | ||
601 | if (myImmediateUpdate) | |
602 | { | |
603 | Redraw(); | |
604 | } | |
7fd59977 | 605 | } |
606 | ||
197ac94e | 607 | //============================================================================= |
608 | //function : SetFront | |
609 | //purpose : | |
610 | //============================================================================= | |
b8ddfc2f | 611 | void V3d_View::SetFront() |
612 | { | |
7fd59977 | 613 | gp_Ax3 a = MyViewer->PrivilegedPlane(); |
b5ac8292 | 614 | Standard_Real xo, yo, zo, vx, vy, vz, xu, yu, zu; |
7fd59977 | 615 | |
616 | a.Direction().Coord(vx,vy,vz); | |
617 | a.YDirection().Coord(xu,yu,zu); | |
618 | a.Location().Coord(xo,yo,zo); | |
619 | ||
c357e426 | 620 | Handle(Graphic3d_Camera) aCamera = Camera(); |
621 | ||
622 | aCamera->SetCenter (gp_Pnt (xo, yo, zo)); | |
623 | ||
7fd59977 | 624 | if(SwitchSetFront) |
c357e426 | 625 | { |
626 | aCamera->SetDirection (gp_Dir (vx, vy, vz)); | |
627 | } | |
7fd59977 | 628 | else |
c357e426 | 629 | { |
630 | aCamera->SetDirection (gp_Dir (vx, vy, vz).Reversed()); | |
631 | } | |
632 | ||
633 | aCamera->SetUp (gp_Dir (xu, yu, zu)); | |
7fd59977 | 634 | |
b5ac8292 | 635 | SwitchSetFront = !SwitchSetFront; |
7fd59977 | 636 | |
637 | ImmediateUpdate(); | |
7fd59977 | 638 | } |
639 | ||
197ac94e | 640 | //============================================================================= |
641 | //function : Rotate | |
642 | //purpose : | |
643 | //============================================================================= | |
b5ac8292 | 644 | void V3d_View::Rotate (const Standard_Real ax, |
645 | const Standard_Real ay, | |
646 | const Standard_Real az, | |
647 | const Standard_Boolean Start) | |
b8ddfc2f | 648 | { |
b5ac8292 | 649 | Standard_Real Ax = ax; |
650 | Standard_Real Ay = ay; | |
651 | Standard_Real Az = az; | |
7fd59977 | 652 | |
b5ac8292 | 653 | if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI; |
654 | else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI; | |
655 | if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI; | |
656 | else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI; | |
657 | if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI; | |
658 | else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI; | |
659 | ||
c357e426 | 660 | Handle(Graphic3d_Camera) aCamera = Camera(); |
661 | ||
b5ac8292 | 662 | if (Start) |
663 | { | |
c357e426 | 664 | myCamStartOpUp = aCamera->Up(); |
607e5e62 | 665 | myCamStartOpDir = aCamera->Direction(); |
c357e426 | 666 | myCamStartOpEye = aCamera->Eye(); |
667 | myCamStartOpCenter = aCamera->Center(); | |
b5ac8292 | 668 | } |
669 | ||
607e5e62 | 670 | aCamera->SetUp (myCamStartOpUp); |
671 | aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter); | |
672 | aCamera->SetDirectionFromEye (myCamStartOpDir); | |
b5ac8292 | 673 | |
674 | // rotate camera around 3 initial axes | |
607e5e62 | 675 | gp_Dir aBackDir = -myCamStartOpDir; |
b5ac8292 | 676 | gp_Dir aXAxis (myCamStartOpUp.Crossed (aBackDir)); |
677 | gp_Dir aYAxis (aBackDir.Crossed (aXAxis)); | |
678 | gp_Dir aZAxis (aXAxis.Crossed (aYAxis)); | |
679 | ||
680 | gp_Trsf aRot[3], aTrsf; | |
681 | aRot[0].SetRotation (gp_Ax1 (myCamStartOpCenter, aYAxis), -Ax); | |
682 | aRot[1].SetRotation (gp_Ax1 (myCamStartOpCenter, aXAxis), Ay); | |
683 | aRot[2].SetRotation (gp_Ax1 (myCamStartOpCenter, aZAxis), Az); | |
684 | aTrsf.Multiply (aRot[0]); | |
685 | aTrsf.Multiply (aRot[1]); | |
686 | aTrsf.Multiply (aRot[2]); | |
687 | ||
c357e426 | 688 | aCamera->Transform (aTrsf); |
b5ac8292 | 689 | |
7fd59977 | 690 | ImmediateUpdate(); |
7fd59977 | 691 | } |
692 | ||
197ac94e | 693 | //============================================================================= |
694 | //function : Rotate | |
695 | //purpose : | |
696 | //============================================================================= | |
7fd59977 | 697 | void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, |
698 | const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start) | |
699 | { | |
b5ac8292 | 700 | |
7fd59977 | 701 | Standard_Real Ax = ax ; |
702 | Standard_Real Ay = ay ; | |
703 | Standard_Real Az = az ; | |
7fd59977 | 704 | |
705 | if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ; | |
706 | else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ; | |
707 | if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI ; | |
708 | else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI ; | |
709 | if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ; | |
710 | else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ; | |
711 | ||
c357e426 | 712 | Handle(Graphic3d_Camera) aCamera = Camera(); |
713 | ||
b5ac8292 | 714 | if (Start) |
715 | { | |
716 | myGravityReferencePoint.SetCoord (X, Y, Z); | |
c357e426 | 717 | myCamStartOpUp = aCamera->Up(); |
607e5e62 | 718 | myCamStartOpDir = aCamera->Direction(); |
c357e426 | 719 | myCamStartOpEye = aCamera->Eye(); |
720 | myCamStartOpCenter = aCamera->Center(); | |
b5ac8292 | 721 | } |
722 | ||
723 | const Graphic3d_Vertex& aVref = myGravityReferencePoint; | |
724 | ||
607e5e62 | 725 | aCamera->SetUp (myCamStartOpUp); |
726 | aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter); | |
727 | aCamera->SetDirectionFromEye (myCamStartOpDir); | |
b5ac8292 | 728 | |
729 | // rotate camera around 3 initial axes | |
730 | gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z()); | |
731 | ||
c357e426 | 732 | gp_Dir aZAxis (aCamera->Direction().Reversed()); |
733 | gp_Dir aYAxis (aCamera->Up()); | |
b5ac8292 | 734 | gp_Dir aXAxis (aYAxis.Crossed (aZAxis)); |
735 | ||
736 | gp_Trsf aRot[3], aTrsf; | |
737 | aRot[0].SetRotation (gp_Ax1 (aRCenter, aYAxis), -Ax); | |
738 | aRot[1].SetRotation (gp_Ax1 (aRCenter, aXAxis), Ay); | |
739 | aRot[2].SetRotation (gp_Ax1 (aRCenter, aZAxis), Az); | |
740 | aTrsf.Multiply (aRot[0]); | |
741 | aTrsf.Multiply (aRot[1]); | |
742 | aTrsf.Multiply (aRot[2]); | |
743 | ||
c357e426 | 744 | aCamera->Transform (aTrsf); |
b5ac8292 | 745 | |
7fd59977 | 746 | ImmediateUpdate(); |
7fd59977 | 747 | } |
748 | ||
197ac94e | 749 | //============================================================================= |
750 | //function : Rotate | |
751 | //purpose : | |
752 | //============================================================================= | |
b8ddfc2f | 753 | void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start) |
754 | { | |
7fd59977 | 755 | switch (Axe) { |
756 | case V3d_X : | |
757 | Rotate(angle,0.,0.,Start); | |
758 | break ; | |
759 | case V3d_Y : | |
760 | Rotate(0.,angle,0.,Start); | |
761 | break ; | |
762 | case V3d_Z : | |
763 | Rotate(0.,0.,angle,Start); | |
764 | break ; | |
765 | } | |
7fd59977 | 766 | } |
767 | ||
197ac94e | 768 | //============================================================================= |
769 | //function : Rotate | |
770 | //purpose : | |
771 | //============================================================================= | |
21b2385f | 772 | void V3d_View::Rotate (const V3d_TypeOfAxe theAxe, const Standard_Real theAngle, |
773 | const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ, const Standard_Boolean theStart) | |
7fd59977 | 774 | { |
21b2385f | 775 | Standard_Real anAngle = theAngle; |
7fd59977 | 776 | |
21b2385f | 777 | if (anAngle > 0.0) while (anAngle > DEUXPI) anAngle -= DEUXPI; |
778 | else if (anAngle < 0.0) while (anAngle < -DEUXPI) anAngle += DEUXPI; | |
7fd59977 | 779 | |
c357e426 | 780 | Handle(Graphic3d_Camera) aCamera = Camera(); |
781 | ||
21b2385f | 782 | if (theStart) |
b5ac8292 | 783 | { |
21b2385f | 784 | myGravityReferencePoint.SetCoord (theX, theY, theZ); |
c357e426 | 785 | myCamStartOpUp = aCamera->Up(); |
607e5e62 | 786 | myCamStartOpDir = aCamera->Direction(); |
c357e426 | 787 | myCamStartOpEye = aCamera->Eye(); |
788 | myCamStartOpCenter = aCamera->Center(); | |
21b2385f | 789 | switch (theAxe) |
790 | { | |
791 | case V3d_X: myViewAxis = gp::DX(); break; | |
792 | case V3d_Y: myViewAxis = gp::DY(); break; | |
793 | case V3d_Z: myViewAxis = gp::DZ(); break; | |
7fd59977 | 794 | } |
795 | } | |
796 | ||
b5ac8292 | 797 | const Graphic3d_Vertex& aVref = myGravityReferencePoint; |
798 | ||
607e5e62 | 799 | aCamera->SetUp (myCamStartOpUp); |
800 | aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter); | |
801 | aCamera->SetDirectionFromEye (myCamStartOpDir); | |
b5ac8292 | 802 | |
803 | // rotate camera around passed axis | |
804 | gp_Trsf aRotation; | |
805 | gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z()); | |
21b2385f | 806 | gp_Dir aRAxis ((theAxe == V3d_X) ? 1.0 : 0.0, |
807 | (theAxe == V3d_Y) ? 1.0 : 0.0, | |
808 | (theAxe == V3d_Z) ? 1.0 : 0.0); | |
b5ac8292 | 809 | |
21b2385f | 810 | aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), anAngle); |
b5ac8292 | 811 | |
c357e426 | 812 | aCamera->Transform (aRotation); |
813 | ||
7fd59977 | 814 | ImmediateUpdate(); |
7fd59977 | 815 | } |
816 | ||
197ac94e | 817 | //============================================================================= |
818 | //function : Rotate | |
819 | //purpose : | |
820 | //============================================================================= | |
b8ddfc2f | 821 | void V3d_View::Rotate(const Standard_Real angle, const Standard_Boolean Start) |
822 | { | |
b5ac8292 | 823 | Standard_Real Angle = angle; |
7fd59977 | 824 | |
825 | if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ; | |
826 | else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ; | |
827 | ||
c357e426 | 828 | Handle(Graphic3d_Camera) aCamera = Camera(); |
829 | ||
607e5e62 | 830 | if (Start) |
831 | { | |
c357e426 | 832 | myCamStartOpUp = aCamera->Up(); |
607e5e62 | 833 | myCamStartOpDir = aCamera->Direction(); |
c357e426 | 834 | myCamStartOpEye = aCamera->Eye(); |
835 | myCamStartOpCenter = aCamera->Center(); | |
7fd59977 | 836 | } |
837 | ||
607e5e62 | 838 | aCamera->SetUp (myCamStartOpUp); |
839 | aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter); | |
840 | aCamera->SetDirectionFromEye (myCamStartOpDir); | |
b5ac8292 | 841 | |
842 | gp_Trsf aRotation; | |
21b2385f | 843 | gp_Pnt aRCenter (myDefaultViewPoint); |
844 | gp_Dir aRAxis (myDefaultViewAxis); | |
b5ac8292 | 845 | aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle); |
b5ac8292 | 846 | |
c357e426 | 847 | aCamera->Transform (aRotation); |
848 | ||
7fd59977 | 849 | ImmediateUpdate(); |
7fd59977 | 850 | } |
851 | ||
197ac94e | 852 | //============================================================================= |
853 | //function : Turn | |
854 | //purpose : | |
855 | //============================================================================= | |
7fd59977 | 856 | void V3d_View::Turn(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Boolean Start) |
857 | { | |
b5ac8292 | 858 | Standard_Real Ax = ax; |
859 | Standard_Real Ay = ay; | |
860 | Standard_Real Az = az; | |
7fd59977 | 861 | |
862 | if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ; | |
863 | else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ; | |
864 | if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI ; | |
865 | else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI ; | |
866 | if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ; | |
867 | else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ; | |
868 | ||
c357e426 | 869 | Handle(Graphic3d_Camera) aCamera = Camera(); |
870 | ||
607e5e62 | 871 | if (Start) |
872 | { | |
c357e426 | 873 | myCamStartOpUp = aCamera->Up(); |
607e5e62 | 874 | myCamStartOpDir = aCamera->Direction(); |
c357e426 | 875 | myCamStartOpEye = aCamera->Eye(); |
876 | myCamStartOpCenter = aCamera->Center(); | |
b5ac8292 | 877 | } |
878 | ||
607e5e62 | 879 | aCamera->SetUp (myCamStartOpUp); |
880 | aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter); | |
881 | aCamera->SetDirectionFromEye (myCamStartOpDir); | |
b5ac8292 | 882 | |
883 | // rotate camera around 3 initial axes | |
c357e426 | 884 | gp_Pnt aRCenter = aCamera->Eye(); |
885 | gp_Dir aZAxis (aCamera->Direction().Reversed()); | |
886 | gp_Dir aYAxis (aCamera->Up()); | |
b5ac8292 | 887 | gp_Dir aXAxis (aYAxis.Crossed (aZAxis)); |
888 | ||
889 | gp_Trsf aRot[3], aTrsf; | |
890 | aRot[0].SetRotation (gp_Ax1 (aRCenter, aYAxis), -Ax); | |
891 | aRot[1].SetRotation (gp_Ax1 (aRCenter, aXAxis), Ay); | |
892 | aRot[2].SetRotation (gp_Ax1 (aRCenter, aZAxis), Az); | |
893 | aTrsf.Multiply (aRot[0]); | |
894 | aTrsf.Multiply (aRot[1]); | |
895 | aTrsf.Multiply (aRot[2]); | |
896 | ||
c357e426 | 897 | aCamera->Transform (aTrsf); |
b5ac8292 | 898 | |
b5ac8292 | 899 | ImmediateUpdate(); |
7fd59977 | 900 | } |
901 | ||
197ac94e | 902 | //============================================================================= |
903 | //function : Turn | |
904 | //purpose : | |
905 | //============================================================================= | |
7fd59977 | 906 | void V3d_View::Turn(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start) |
907 | { | |
7fd59977 | 908 | switch (Axe) { |
909 | case V3d_X : | |
910 | Turn(angle,0.,0.,Start); | |
911 | break ; | |
912 | case V3d_Y : | |
913 | Turn(0.,angle,0.,Start); | |
914 | break ; | |
915 | case V3d_Z : | |
916 | Turn(0.,0.,angle,Start); | |
917 | break ; | |
918 | } | |
919 | } | |
920 | ||
197ac94e | 921 | //============================================================================= |
922 | //function : Turn | |
923 | //purpose : | |
924 | //============================================================================= | |
b8ddfc2f | 925 | void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start) |
926 | { | |
7fd59977 | 927 | Standard_Real Angle = angle ; |
7fd59977 | 928 | |
929 | if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ; | |
930 | else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ; | |
931 | ||
c357e426 | 932 | Handle(Graphic3d_Camera) aCamera = Camera(); |
933 | ||
607e5e62 | 934 | if (Start) |
935 | { | |
c357e426 | 936 | myCamStartOpUp = aCamera->Up(); |
607e5e62 | 937 | myCamStartOpDir = aCamera->Direction(); |
c357e426 | 938 | myCamStartOpEye = aCamera->Eye(); |
939 | myCamStartOpCenter = aCamera->Center(); | |
b5ac8292 | 940 | } |
941 | ||
607e5e62 | 942 | aCamera->SetUp (myCamStartOpUp); |
943 | aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter); | |
944 | aCamera->SetDirectionFromEye (myCamStartOpDir); | |
b5ac8292 | 945 | |
b5ac8292 | 946 | gp_Trsf aRotation; |
c357e426 | 947 | gp_Pnt aRCenter = aCamera->Eye(); |
21b2385f | 948 | gp_Dir aRAxis (myDefaultViewAxis); |
b5ac8292 | 949 | aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle); |
b5ac8292 | 950 | |
c357e426 | 951 | aCamera->Transform (aRotation); |
952 | ||
b5ac8292 | 953 | ImmediateUpdate(); |
7fd59977 | 954 | } |
955 | ||
197ac94e | 956 | //============================================================================= |
957 | //function : SetTwist | |
958 | //purpose : | |
959 | //============================================================================= | |
b8ddfc2f | 960 | void V3d_View::SetTwist(const Standard_Real angle) |
961 | { | |
7fd59977 | 962 | Standard_Real Angle = angle ; |
7fd59977 | 963 | |
964 | if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ; | |
965 | else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ; | |
966 | ||
c357e426 | 967 | Handle(Graphic3d_Camera) aCamera = Camera(); |
968 | ||
21b2385f | 969 | const gp_Dir aReferencePlane (aCamera->Direction().Reversed()); |
970 | if (!screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis) | |
971 | && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis) | |
972 | && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)) | |
973 | { | |
974 | throw V3d_BadValue ("V3d_ViewSetTwist, alignment of Eye,At,Up,"); | |
7fd59977 | 975 | } |
b5ac8292 | 976 | |
c357e426 | 977 | gp_Pnt aRCenter = aCamera->Center(); |
978 | gp_Dir aZAxis (aCamera->Direction().Reversed()); | |
b5ac8292 | 979 | |
980 | gp_Trsf aTrsf; | |
981 | aTrsf.SetRotation (gp_Ax1 (aRCenter, aZAxis), Angle); | |
982 | ||
21b2385f | 983 | aCamera->SetUp (gp_Dir (myYscreenAxis)); |
c357e426 | 984 | aCamera->Transform (aTrsf); |
b5ac8292 | 985 | |
7fd59977 | 986 | ImmediateUpdate(); |
7fd59977 | 987 | } |
988 | ||
197ac94e | 989 | //============================================================================= |
990 | //function : SetEye | |
991 | //purpose : | |
992 | //============================================================================= | |
993 | void V3d_View::SetEye(const Standard_Real X,const Standard_Real Y,const Standard_Real Z) | |
994 | { | |
995 | Standard_Real aTwistBefore = Twist(); | |
7fd59977 | 996 | |
197ac94e | 997 | Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False); |
b5ac8292 | 998 | |
c357e426 | 999 | Handle(Graphic3d_Camera) aCamera = Camera(); |
1000 | ||
1001 | aCamera->SetEye (gp_Pnt (X, Y, Z)); | |
1002 | ||
197ac94e | 1003 | SetTwist (aTwistBefore); |
b5ac8292 | 1004 | |
197ac94e | 1005 | SetImmediateUpdate (wasUpdateEnabled); |
1006 | ||
b5ac8292 | 1007 | ImmediateUpdate(); |
7fd59977 | 1008 | } |
1009 | ||
197ac94e | 1010 | //============================================================================= |
1011 | //function : SetDepth | |
1012 | //purpose : | |
1013 | //============================================================================= | |
b8ddfc2f | 1014 | void V3d_View::SetDepth(const Standard_Real Depth) |
1015 | { | |
b5ac8292 | 1016 | V3d_BadValue_Raise_if (Depth == 0. ,"V3d_View::SetDepth, bad depth"); |
7fd59977 | 1017 | |
c357e426 | 1018 | Handle(Graphic3d_Camera) aCamera = Camera(); |
1019 | ||
7fd59977 | 1020 | if( Depth > 0. ) |
7fd59977 | 1021 | { |
b5ac8292 | 1022 | // Move eye using center (target) as anchor. |
c357e426 | 1023 | aCamera->SetDistance (Depth); |
b5ac8292 | 1024 | } |
1025 | else | |
197ac94e | 1026 | { |
b5ac8292 | 1027 | // Move the view ref point instead of the eye. |
c357e426 | 1028 | gp_Vec aDir (aCamera->Direction()); |
1029 | gp_Pnt aCameraEye = aCamera->Eye(); | |
197ac94e | 1030 | gp_Pnt aCameraCenter = aCameraEye.Translated (aDir.Multiplied (Abs (Depth))); |
1031 | ||
c357e426 | 1032 | aCamera->SetCenter (aCameraCenter); |
7fd59977 | 1033 | } |
7fd59977 | 1034 | |
b5ac8292 | 1035 | ImmediateUpdate(); |
7fd59977 | 1036 | } |
1037 | ||
197ac94e | 1038 | //============================================================================= |
1039 | //function : SetProj | |
1040 | //purpose : | |
1041 | //============================================================================= | |
7fd59977 | 1042 | void V3d_View::SetProj( const Standard_Real Vx,const Standard_Real Vy, const Standard_Real Vz ) |
1043 | { | |
6942f04a | 1044 | V3d_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0., |
7fd59977 | 1045 | "V3d_View::SetProj, null projection vector"); |
1046 | ||
197ac94e | 1047 | Standard_Real aTwistBefore = Twist(); |
b5ac8292 | 1048 | |
197ac94e | 1049 | Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False); |
b5ac8292 | 1050 | |
c357e426 | 1051 | Camera()->SetDirection (gp_Dir (Vx, Vy, Vz).Reversed()); |
b5ac8292 | 1052 | |
1521659a | 1053 | SetTwist(aTwistBefore); |
b5ac8292 | 1054 | |
197ac94e | 1055 | SetImmediateUpdate (wasUpdateEnabled); |
1056 | ||
7fd59977 | 1057 | ImmediateUpdate(); |
7fd59977 | 1058 | } |
1059 | ||
197ac94e | 1060 | //============================================================================= |
1061 | //function : SetProj | |
1062 | //purpose : | |
1063 | //============================================================================= | |
fc552d84 | 1064 | void V3d_View::SetProj (const V3d_TypeOfOrientation theOrientation, |
1065 | const Standard_Boolean theIsYup) | |
b8ddfc2f | 1066 | { |
fc552d84 | 1067 | Graphic3d_Vec3d anUp = theIsYup ? Graphic3d_Vec3d (0.0, 1.0, 0.0) : Graphic3d_Vec3d (0.0, 0.0, 1.0); |
1068 | if (theIsYup) | |
1069 | { | |
1070 | if (theOrientation == V3d_Ypos | |
1071 | || theOrientation == V3d_Yneg) | |
1072 | { | |
1073 | anUp.SetValues (0.0, 0.0, -1.0); | |
1074 | } | |
1075 | } | |
1076 | else | |
1077 | { | |
1078 | if (theOrientation == V3d_Zpos) | |
1079 | { | |
1080 | anUp.SetValues (0.0, 1.0, 0.0); | |
1081 | } | |
1082 | else if (theOrientation == V3d_Zneg) | |
1083 | { | |
1084 | anUp.SetValues (0.0, -1.0, 0.0); | |
1085 | } | |
7fd59977 | 1086 | } |
b5ac8292 | 1087 | |
fc552d84 | 1088 | const gp_Dir aBck = V3d::GetProjAxis (theOrientation); |
197ac94e | 1089 | |
1090 | // retain camera panning from origin when switching projection | |
fc552d84 | 1091 | const Handle(Graphic3d_Camera)& aCamera = Camera(); |
1092 | const gp_Pnt anOriginVCS = aCamera->ConvertWorld2View (gp::Origin()); | |
197ac94e | 1093 | |
607e5e62 | 1094 | const Standard_Real aNewDist = aCamera->Eye().Distance (gp_Pnt (0, 0, 0)); |
1095 | aCamera->SetEyeAndCenter (gp_XYZ (0, 0, 0) + aBck.XYZ() * aNewDist, | |
1096 | gp_XYZ (0, 0, 0)); | |
1097 | aCamera->SetDirectionFromEye (-aBck); | |
fc552d84 | 1098 | aCamera->SetUp (gp_Dir (anUp.x(), anUp.y(), anUp.z())); |
c357e426 | 1099 | aCamera->OrthogonalizeUp(); |
197ac94e | 1100 | |
fc552d84 | 1101 | Panning (anOriginVCS.X(), anOriginVCS.Y()); |
b5ac8292 | 1102 | |
7fd59977 | 1103 | ImmediateUpdate(); |
7fd59977 | 1104 | } |
1105 | ||
197ac94e | 1106 | //============================================================================= |
1107 | //function : SetAt | |
1108 | //purpose : | |
1109 | //============================================================================= | |
b8ddfc2f | 1110 | void V3d_View::SetAt(const Standard_Real X,const Standard_Real Y,const Standard_Real Z) |
1111 | { | |
197ac94e | 1112 | Standard_Real aTwistBefore = Twist(); |
b5ac8292 | 1113 | |
197ac94e | 1114 | Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False); |
b5ac8292 | 1115 | |
c357e426 | 1116 | Camera()->SetCenter (gp_Pnt (X, Y, Z)); |
b5ac8292 | 1117 | |
197ac94e | 1118 | SetTwist (aTwistBefore); |
b5ac8292 | 1119 | |
197ac94e | 1120 | SetImmediateUpdate (wasUpdateEnabled); |
1121 | ||
7fd59977 | 1122 | ImmediateUpdate(); |
7fd59977 | 1123 | } |
1124 | ||
197ac94e | 1125 | //============================================================================= |
1126 | //function : SetUp | |
1127 | //purpose : | |
1128 | //============================================================================= | |
21b2385f | 1129 | void V3d_View::SetUp (const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz) |
b8ddfc2f | 1130 | { |
c357e426 | 1131 | Handle(Graphic3d_Camera) aCamera = Camera(); |
1132 | ||
21b2385f | 1133 | const gp_Dir aReferencePlane (aCamera->Direction().Reversed()); |
1134 | const gp_Dir anUp (theVx, theVy, theVz); | |
1135 | if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis) | |
1136 | && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis) | |
1137 | && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis) | |
1138 | && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis)) | |
1139 | { | |
1140 | throw V3d_BadValue ("V3d_View::Setup, alignment of Eye,At,Up"); | |
7fd59977 | 1141 | } |
b5ac8292 | 1142 | |
21b2385f | 1143 | aCamera->SetUp (gp_Dir (myYscreenAxis)); |
197ac94e | 1144 | |
7fd59977 | 1145 | ImmediateUpdate(); |
7fd59977 | 1146 | } |
1147 | ||
197ac94e | 1148 | //============================================================================= |
1149 | //function : SetUp | |
1150 | //purpose : | |
1151 | //============================================================================= | |
21b2385f | 1152 | void V3d_View::SetUp (const V3d_TypeOfOrientation theOrientation) |
b8ddfc2f | 1153 | { |
c357e426 | 1154 | Handle(Graphic3d_Camera) aCamera = Camera(); |
1155 | ||
21b2385f | 1156 | const gp_Dir aReferencePlane (aCamera->Direction().Reversed()); |
1157 | const gp_Dir anUp = V3d::GetProjAxis (theOrientation); | |
1158 | if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis) | |
1159 | && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis) | |
1160 | && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis) | |
1161 | && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis)) | |
1162 | { | |
1163 | throw V3d_BadValue ("V3d_View::SetUp, alignment of Eye,At,Up"); | |
7fd59977 | 1164 | } |
b5ac8292 | 1165 | |
21b2385f | 1166 | aCamera->SetUp (gp_Dir (myYscreenAxis)); |
197ac94e | 1167 | |
7fd59977 | 1168 | ImmediateUpdate(); |
1169 | } | |
1170 | ||
197ac94e | 1171 | //============================================================================= |
1172 | //function : SetViewOrientationDefault | |
1173 | //purpose : | |
1174 | //============================================================================= | |
b8ddfc2f | 1175 | void V3d_View::SetViewOrientationDefault() |
1176 | { | |
c357e426 | 1177 | myDefaultCamera->CopyOrientationData (Camera()); |
1178 | } | |
b5ac8292 | 1179 | |
c357e426 | 1180 | //======================================================================= |
1181 | //function : SetViewMappingDefault | |
1182 | //purpose : | |
1183 | //======================================================================= | |
1184 | void V3d_View::SetViewMappingDefault() | |
1185 | { | |
1186 | myDefaultCamera->CopyMappingData (Camera()); | |
7fd59977 | 1187 | } |
1188 | ||
197ac94e | 1189 | //============================================================================= |
1190 | //function : ResetViewOrientation | |
1191 | //purpose : | |
1192 | //============================================================================= | |
b8ddfc2f | 1193 | void V3d_View::ResetViewOrientation() |
1194 | { | |
c357e426 | 1195 | Camera()->CopyOrientationData (myDefaultCamera); |
c357e426 | 1196 | ImmediateUpdate(); |
1197 | } | |
1198 | ||
1199 | //======================================================================= | |
1200 | //function : ResetViewMapping | |
1201 | //purpose : | |
1202 | //======================================================================= | |
1203 | void V3d_View::ResetViewMapping() | |
1204 | { | |
1205 | Camera()->CopyMappingData (myDefaultCamera); | |
7fd59977 | 1206 | ImmediateUpdate(); |
1207 | } | |
1208 | ||
197ac94e | 1209 | //============================================================================= |
1210 | //function : Reset | |
1211 | //purpose : | |
1212 | //============================================================================= | |
c357e426 | 1213 | void V3d_View::Reset (const Standard_Boolean theToUpdate) |
b8ddfc2f | 1214 | { |
c357e426 | 1215 | Camera()->Copy (myDefaultCamera); |
197ac94e | 1216 | |
7fd59977 | 1217 | SwitchSetFront = Standard_False; |
b5ac8292 | 1218 | |
c357e426 | 1219 | if (myImmediateUpdate || theToUpdate) |
1220 | { | |
1221 | Update(); | |
1222 | } | |
7fd59977 | 1223 | } |
1224 | ||
197ac94e | 1225 | //======================================================================= |
1226 | //function : SetCenter | |
1227 | //purpose : | |
1228 | //======================================================================= | |
1229 | void V3d_View::SetCenter (const Standard_Integer theXp, | |
1230 | const Standard_Integer theYp) | |
b8ddfc2f | 1231 | { |
197ac94e | 1232 | Standard_Real aXv, aYv; |
1233 | Convert (theXp, theYp, aXv, aYv); | |
c357e426 | 1234 | Translate (Camera(), aXv, aYv); |
7fd59977 | 1235 | |
7fd59977 | 1236 | ImmediateUpdate(); |
7fd59977 | 1237 | } |
1238 | ||
197ac94e | 1239 | //============================================================================= |
1240 | //function : SetSize | |
1241 | //purpose : | |
1242 | //============================================================================= | |
3dfe95cd | 1243 | void V3d_View::SetSize (const Standard_Real theSize) |
7fd59977 | 1244 | { |
3dfe95cd | 1245 | V3d_BadValue_Raise_if (theSize <= 0.0, "V3d_View::SetSize, Window Size is NULL"); |
7fd59977 | 1246 | |
c357e426 | 1247 | Handle(Graphic3d_Camera) aCamera = Camera(); |
1248 | ||
1249 | aCamera->SetScale (aCamera->Aspect() >= 1.0 ? theSize / aCamera->Aspect() : theSize); | |
197ac94e | 1250 | |
7fd59977 | 1251 | ImmediateUpdate(); |
7fd59977 | 1252 | } |
1253 | ||
197ac94e | 1254 | //============================================================================= |
1255 | //function : SetZSize | |
1256 | //purpose : | |
1257 | //============================================================================= | |
c357e426 | 1258 | void V3d_View::SetZSize (const Standard_Real theSize) |
7fd59977 | 1259 | { |
c357e426 | 1260 | Handle(Graphic3d_Camera) aCamera = Camera(); |
7fd59977 | 1261 | |
c357e426 | 1262 | Standard_Real Zmax = theSize / 2.; |
b5ac8292 | 1263 | |
c357e426 | 1264 | Standard_Real aDistance = aCamera->Distance(); |
1265 | ||
1266 | if (theSize <= 0.) | |
1267 | { | |
b5ac8292 | 1268 | Zmax = aDistance; |
7fd59977 | 1269 | } |
7fd59977 | 1270 | |
197ac94e | 1271 | // ShortReal precision factor used to add meaningful tolerance to |
1272 | // ZNear, ZFar values in order to avoid equality after type conversion | |
1273 | // to ShortReal matrices type. | |
1274 | const Standard_Real aPrecision = 1.0 / Pow (10.0, ShortRealDigits() - 1); | |
1275 | ||
1276 | Standard_Real aZFar = Zmax + aDistance * 2.0; | |
1277 | Standard_Real aZNear = -Zmax + aDistance; | |
1278 | aZNear -= Abs (aZNear) * aPrecision; | |
1279 | aZFar += Abs (aZFar) * aPrecision; | |
1280 | ||
c357e426 | 1281 | if (!aCamera->IsOrthographic()) |
197ac94e | 1282 | { |
1283 | if (aZFar < aPrecision) | |
1284 | { | |
1285 | // Invalid case when both values are negative | |
1286 | aZNear = aPrecision; | |
1287 | aZFar = aPrecision * 2.0; | |
1288 | } | |
1289 | else if (aZNear < Abs (aZFar) * aPrecision) | |
1290 | { | |
1291 | // Z is less than 0.0, try to fix it using any appropriate z-scale | |
1292 | aZNear = Abs (aZFar) * aPrecision; | |
1293 | } | |
1294 | } | |
1295 | ||
1296 | // If range is too small | |
1297 | if (aZFar < (aZNear + Abs (aZFar) * aPrecision)) | |
1298 | { | |
1299 | aZFar = aZNear + Abs (aZFar) * aPrecision; | |
1300 | } | |
1301 | ||
c357e426 | 1302 | aCamera->SetZRange (aZNear, aZFar); |
7fd59977 | 1303 | |
c357e426 | 1304 | if (myImmediateUpdate) |
b8ddfc2f | 1305 | { |
c357e426 | 1306 | Redraw(); |
b8ddfc2f | 1307 | } |
7fd59977 | 1308 | } |
1309 | ||
197ac94e | 1310 | //============================================================================= |
1311 | //function : SetZoom | |
1312 | //purpose : | |
1313 | //============================================================================= | |
e44b0af4 | 1314 | void V3d_View::SetZoom (const Standard_Real theCoef,const Standard_Boolean theToStart) |
7fd59977 | 1315 | { |
e44b0af4 | 1316 | V3d_BadValue_Raise_if (theCoef <= 0., "V3d_View::SetZoom, bad coefficient"); |
7fd59977 | 1317 | |
c357e426 | 1318 | Handle(Graphic3d_Camera) aCamera = Camera(); |
1319 | ||
e44b0af4 | 1320 | if (theToStart) |
b5ac8292 | 1321 | { |
c357e426 | 1322 | myCamStartOpEye = aCamera->Eye(); |
1323 | myCamStartOpCenter = aCamera->Center(); | |
7fd59977 | 1324 | } |
1325 | ||
c357e426 | 1326 | Standard_Real aViewWidth = aCamera->ViewDimensions().X(); |
1327 | Standard_Real aViewHeight = aCamera->ViewDimensions().Y(); | |
b5ac8292 | 1328 | |
7fd59977 | 1329 | // ensure that zoom will not be too small or too big |
e44b0af4 | 1330 | Standard_Real aCoef = theCoef; |
1331 | if (aViewWidth < aCoef * Precision::Confusion()) | |
b5ac8292 | 1332 | { |
e44b0af4 | 1333 | aCoef = aViewWidth / Precision::Confusion(); |
b5ac8292 | 1334 | } |
e44b0af4 | 1335 | else if (aViewWidth > aCoef * 1e12) |
b5ac8292 | 1336 | { |
e44b0af4 | 1337 | aCoef = aViewWidth / 1e12; |
b5ac8292 | 1338 | } |
e44b0af4 | 1339 | if (aViewHeight < aCoef * Precision::Confusion()) |
b5ac8292 | 1340 | { |
e44b0af4 | 1341 | aCoef = aViewHeight / Precision::Confusion(); |
b5ac8292 | 1342 | } |
e44b0af4 | 1343 | else if (aViewHeight > aCoef * 1e12) |
b5ac8292 | 1344 | { |
e44b0af4 | 1345 | aCoef = aViewHeight / 1e12; |
b5ac8292 | 1346 | } |
1347 | ||
c357e426 | 1348 | aCamera->SetEye (myCamStartOpEye); |
1349 | aCamera->SetCenter (myCamStartOpCenter); | |
e44b0af4 | 1350 | aCamera->SetScale (aCamera->Scale() / aCoef); |
c357e426 | 1351 | |
7fd59977 | 1352 | ImmediateUpdate(); |
1353 | } | |
1354 | ||
197ac94e | 1355 | //============================================================================= |
1356 | //function : SetScale | |
1357 | //purpose : | |
1358 | //============================================================================= | |
b8ddfc2f | 1359 | void V3d_View::SetScale( const Standard_Real Coef ) |
1360 | { | |
6942f04a | 1361 | V3d_BadValue_Raise_if( Coef <= 0. ,"V3d_View::SetScale, bad coefficient"); |
7fd59977 | 1362 | |
c357e426 | 1363 | Handle(Graphic3d_Camera) aCamera = Camera(); |
b5ac8292 | 1364 | |
c357e426 | 1365 | Standard_Real aDefaultScale = myDefaultCamera->Scale(); |
1366 | aCamera->SetAspect (myDefaultCamera->Aspect()); | |
1367 | aCamera->SetScale (aDefaultScale / Coef); | |
b5ac8292 | 1368 | |
7fd59977 | 1369 | ImmediateUpdate(); |
7fd59977 | 1370 | } |
1371 | ||
197ac94e | 1372 | //============================================================================= |
1373 | //function : SetAxialScale | |
1374 | //purpose : | |
1375 | //============================================================================= | |
b8ddfc2f | 1376 | void V3d_View::SetAxialScale( const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz ) |
1377 | { | |
6942f04a | 1378 | V3d_BadValue_Raise_if( Sx <= 0. || Sy <= 0. || Sz <= 0.,"V3d_View::SetAxialScale, bad coefficient"); |
7fd59977 | 1379 | |
c357e426 | 1380 | Camera()->SetAxialScale (gp_XYZ (Sx, Sy, Sz)); |
c357e426 | 1381 | } |
1382 | ||
1383 | //============================================================================= | |
1384 | //function : SetRatio | |
1385 | //purpose : | |
1386 | //============================================================================= | |
1387 | void V3d_View::SetRatio() | |
1388 | { | |
1389 | if (MyWindow.IsNull()) | |
1390 | { | |
1391 | return; | |
1392 | } | |
1393 | ||
1394 | Standard_Integer aWidth = 0; | |
1395 | Standard_Integer aHeight = 0; | |
1396 | MyWindow->Size (aWidth, aHeight); | |
1397 | if (aWidth > 0 && aHeight > 0) | |
1398 | { | |
1399 | Standard_Real aRatio = static_cast<Standard_Real> (aWidth) / | |
1400 | static_cast<Standard_Real> (aHeight); | |
1401 | ||
1402 | Camera() ->SetAspect (aRatio); | |
1403 | myDefaultCamera->SetAspect (aRatio); | |
1404 | } | |
7fd59977 | 1405 | } |
1406 | ||
197ac94e | 1407 | //============================================================================= |
1408 | //function : FitAll | |
1409 | //purpose : | |
1410 | //============================================================================= | |
ee2be2a8 | 1411 | void V3d_View::FitAll (const Standard_Real theMargin, const Standard_Boolean theToUpdate) |
7fd59977 | 1412 | { |
c357e426 | 1413 | FitAll (myView->MinMaxValues(), theMargin, theToUpdate); |
b586500b | 1414 | } |
1415 | ||
1416 | //============================================================================= | |
1417 | //function : FitAll | |
1418 | //purpose : | |
1419 | //============================================================================= | |
ee2be2a8 | 1420 | void V3d_View::FitAll (const Bnd_Box& theBox, const Standard_Real theMargin, const Standard_Boolean theToUpdate) |
b586500b | 1421 | { |
1422 | Standard_ASSERT_RAISE(theMargin >= 0.0 && theMargin < 1.0, "Invalid margin coefficient"); | |
197ac94e | 1423 | |
c357e426 | 1424 | if (myView->NumberOfDisplayedStructures() == 0) |
197ac94e | 1425 | { |
1426 | return; | |
1427 | } | |
35617823 | 1428 | |
c357e426 | 1429 | if (!FitMinMax (Camera(), theBox, theMargin, 10.0 * Precision::Confusion())) |
35617823 | 1430 | { |
35617823 K |
1431 | return; |
1432 | } | |
7fd59977 | 1433 | |
197ac94e | 1434 | if (myImmediateUpdate || theToUpdate) |
35617823 | 1435 | { |
b5ac8292 | 1436 | Update(); |
35617823 | 1437 | } |
b5ac8292 | 1438 | } |
35617823 | 1439 | |
197ac94e | 1440 | //============================================================================= |
1441 | //function : DepthFitAll | |
1442 | //purpose : | |
1443 | //============================================================================= | |
ee2be2a8 | 1444 | void V3d_View::DepthFitAll(const Standard_Real Aspect, |
1445 | const Standard_Real Margin) | |
7fd59977 | 1446 | { |
1447 | Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W,U1,V1,W1 ; | |
1448 | Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ; | |
b5ac8292 | 1449 | Standard_Real Dx,Dy,Dz,Size; |
7fd59977 | 1450 | |
c357e426 | 1451 | Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ; |
7fd59977 | 1452 | |
b5ac8292 | 1453 | if((Nstruct <= 0) || (Aspect < 0.) || (Margin < 0.) || (Margin > 1.)) { |
7fd59977 | 1454 | ImmediateUpdate(); |
1455 | return ; | |
1456 | } | |
1457 | ||
c357e426 | 1458 | Bnd_Box aBox = myView->MinMaxValues(); |
ed063270 | 1459 | if (aBox.IsVoid()) |
1460 | { | |
1461 | ImmediateUpdate(); | |
1462 | return ; | |
1463 | } | |
1464 | aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax); | |
c357e426 | 1465 | Project (Xmin,Ymin,Zmin,U,V,W) ; |
1466 | Project (Xmax,Ymax,Zmax,U1,V1,W1) ; | |
7fd59977 | 1467 | Umin = Min(U,U1) ; Umax = Max(U,U1) ; |
1468 | Vmin = Min(V,V1) ; Vmax = Max(V,V1) ; | |
1469 | Wmin = Min(W,W1) ; Wmax = Max(W,W1) ; | |
c357e426 | 1470 | Project (Xmin,Ymin,Zmax,U,V,W) ; |
7fd59977 | 1471 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1472 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1473 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
c357e426 | 1474 | Project (Xmax,Ymin,Zmax,U,V,W) ; |
7fd59977 | 1475 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1476 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1477 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
c357e426 | 1478 | Project (Xmax,Ymin,Zmin,U,V,W) ; |
7fd59977 | 1479 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1480 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1481 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
c357e426 | 1482 | Project (Xmax,Ymax,Zmin,U,V,W) ; |
7fd59977 | 1483 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1484 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1485 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
c357e426 | 1486 | Project (Xmin,Ymax,Zmax,U,V,W) ; |
7fd59977 | 1487 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1488 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1489 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
c357e426 | 1490 | Project (Xmin,Ymax,Zmin,U,V,W) ; |
7fd59977 | 1491 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1492 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1493 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
1494 | ||
1495 | // Adjust Z size | |
1496 | Wmax = Max(Abs(Wmin),Abs(Wmax)) ; | |
1497 | Dz = 2.*Wmax + Margin * Wmax; | |
1498 | ||
1499 | // Compute depth value | |
1500 | Dx = Abs(Umax - Umin) ; Dy = Abs(Vmax - Vmin) ; // Dz = Abs(Wmax - Wmin); | |
1501 | Dx += Margin * Dx; Dy += Margin * Dy; | |
1502 | Size = Sqrt(Dx*Dx + Dy*Dy + Dz*Dz); | |
1503 | if( Size > 0. ) { | |
1504 | SetZSize(Size) ; | |
1505 | SetDepth( Aspect * Size / 2.); | |
1506 | } | |
1507 | ||
1508 | ImmediateUpdate(); | |
1509 | } | |
1510 | ||
197ac94e | 1511 | //======================================================================= |
1512 | //function : WindowFit | |
1513 | //purpose : | |
1514 | //======================================================================= | |
1515 | void V3d_View::WindowFit (const Standard_Integer theMinXp, | |
1516 | const Standard_Integer theMinYp, | |
1517 | const Standard_Integer theMaxXp, | |
1518 | const Standard_Integer theMaxYp) | |
b8ddfc2f | 1519 | { |
197ac94e | 1520 | Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False); |
1521 | ||
c357e426 | 1522 | Handle(Graphic3d_Camera) aCamera = Camera(); |
1523 | ||
1524 | if (!aCamera->IsOrthographic()) | |
b5ac8292 | 1525 | { |
ab1c121b | 1526 | // normalize view coordinates |
b5ac8292 | 1527 | Standard_Integer aWinWidth, aWinHeight; |
1528 | MyWindow->Size (aWinWidth, aWinHeight); | |
7fd59977 | 1529 | |
b5ac8292 | 1530 | // z coordinate of camera center |
c357e426 | 1531 | Standard_Real aDepth = aCamera->Project (aCamera->Center()).Z(); |
b5ac8292 | 1532 | |
1533 | // camera projection coordinate are in NDC which are normalized [-1, 1] | |
197ac94e | 1534 | Standard_Real aUMin = (2.0 / aWinWidth) * theMinXp - 1.0; |
1535 | Standard_Real aUMax = (2.0 / aWinWidth) * theMaxXp - 1.0; | |
1536 | Standard_Real aVMin = (2.0 / aWinHeight) * theMinYp - 1.0; | |
1537 | Standard_Real aVMax = (2.0 / aWinHeight) * theMaxYp - 1.0; | |
b5ac8292 | 1538 | |
1539 | // compute camera panning | |
1540 | gp_Pnt aScreenCenter (0.0, 0.0, aDepth); | |
1541 | gp_Pnt aFitCenter ((aUMin + aUMax) * 0.5, (aVMin + aVMax) * 0.5, aDepth); | |
c357e426 | 1542 | gp_Pnt aPanTo = aCamera->ConvertProj2View (aFitCenter); |
1543 | gp_Pnt aPanFrom = aCamera->ConvertProj2View (aScreenCenter); | |
b5ac8292 | 1544 | gp_Vec aPanVec (aPanFrom, aPanTo); |
1545 | ||
b5ac8292 | 1546 | // compute section size |
1547 | gp_Pnt aFitTopRight (aUMax, aVMax, aDepth); | |
1548 | gp_Pnt aFitBotLeft (aUMin, aVMin, aDepth); | |
c357e426 | 1549 | gp_Pnt aViewBotLeft = aCamera->ConvertProj2View (aFitBotLeft); |
1550 | gp_Pnt aViewTopRight = aCamera->ConvertProj2View (aFitTopRight); | |
b5ac8292 | 1551 | |
1552 | Standard_Real aUSize = aViewTopRight.X() - aViewBotLeft.X(); | |
1553 | Standard_Real aVSize = aViewTopRight.Y() - aViewBotLeft.Y(); | |
1554 | ||
c357e426 | 1555 | Translate (aCamera, aPanVec.X(), -aPanVec.Y()); |
1556 | Scale (aCamera, aUSize, aVSize); | |
b5ac8292 | 1557 | } |
1558 | else | |
1559 | { | |
197ac94e | 1560 | Standard_Real aX1, aY1, aX2, aY2; |
1561 | Convert (theMinXp, theMinYp, aX1, aY1); | |
1562 | Convert (theMaxXp, theMaxYp, aX2, aY2); | |
1563 | FitAll (aX1, aY1, aX2, aY2); | |
b5ac8292 | 1564 | } |
197ac94e | 1565 | |
1566 | SetImmediateUpdate (wasUpdateEnabled); | |
1567 | ||
1568 | ImmediateUpdate(); | |
7fd59977 | 1569 | } |
1570 | ||
197ac94e | 1571 | //======================================================================= |
1572 | //function : ConvertToGrid | |
1573 | //purpose : | |
1574 | //======================================================================= | |
5634c81a | 1575 | void V3d_View::ConvertToGrid(const Standard_Integer theXp, |
1576 | const Standard_Integer theYp, | |
1577 | Standard_Real& theXg, | |
1578 | Standard_Real& theYg, | |
1579 | Standard_Real& theZg) const | |
b5ac8292 | 1580 | { |
5634c81a | 1581 | Graphic3d_Vec3d anXYZ; |
1582 | Convert (theXp, theYp, anXYZ.x(), anXYZ.y(), anXYZ.z()); | |
b5ac8292 | 1583 | |
5634c81a | 1584 | Graphic3d_Vertex aVrp; |
1585 | aVrp.SetCoord (anXYZ.x(), anXYZ.y(), anXYZ.z()); | |
1586 | if (MyViewer->IsGridActive()) | |
1587 | { | |
1588 | Graphic3d_Vertex aNewVrp = Compute (aVrp); | |
1589 | aNewVrp.Coord (theXg, theYg, theZg); | |
1590 | } | |
1591 | else | |
1592 | { | |
1593 | aVrp.Coord (theXg, theYg, theZg); | |
1594 | } | |
b5ac8292 | 1595 | } |
1596 | ||
197ac94e | 1597 | //======================================================================= |
1598 | //function : ConvertToGrid | |
1599 | //purpose : | |
1600 | //======================================================================= | |
5634c81a | 1601 | void V3d_View::ConvertToGrid(const Standard_Real theX, |
1602 | const Standard_Real theY, | |
1603 | const Standard_Real theZ, | |
1604 | Standard_Real& theXg, | |
1605 | Standard_Real& theYg, | |
1606 | Standard_Real& theZg) const | |
1607 | { | |
1608 | if (MyViewer->IsGridActive()) | |
1609 | { | |
1610 | Graphic3d_Vertex aVrp (theX, theY, theZ); | |
1611 | Graphic3d_Vertex aNewVrp = Compute (aVrp); | |
1612 | aNewVrp.Coord (theXg, theYg, theZg); | |
1613 | } | |
1614 | else | |
1615 | { | |
1616 | theXg = theX; theYg = theY; theZg = theZ; | |
b5ac8292 | 1617 | } |
1618 | } | |
1619 | ||
197ac94e | 1620 | //======================================================================= |
1621 | //function : Convert | |
1622 | //purpose : | |
1623 | //======================================================================= | |
b8ddfc2f | 1624 | Standard_Real V3d_View::Convert(const Standard_Integer Vp) const |
1625 | { | |
b5ac8292 | 1626 | Standard_Integer aDxw, aDyw ; |
7fd59977 | 1627 | |
c357e426 | 1628 | V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window"); |
7fd59977 | 1629 | |
b5ac8292 | 1630 | MyWindow->Size (aDxw, aDyw); |
1631 | Standard_Real aValue; | |
197ac94e | 1632 | |
c357e426 | 1633 | gp_Pnt aViewDims = Camera()->ViewDimensions(); |
b5ac8292 | 1634 | aValue = aViewDims.X() * (Standard_Real)Vp / (Standard_Real)aDxw; |
7fd59977 | 1635 | |
b5ac8292 | 1636 | return aValue; |
7fd59977 | 1637 | } |
1638 | ||
197ac94e | 1639 | //======================================================================= |
1640 | //function : Convert | |
1641 | //purpose : | |
1642 | //======================================================================= | |
1643 | void V3d_View::Convert(const Standard_Integer Xp, | |
1644 | const Standard_Integer Yp, | |
1645 | Standard_Real& Xv, | |
1646 | Standard_Real& Yv) const | |
b8ddfc2f | 1647 | { |
b5ac8292 | 1648 | Standard_Integer aDxw, aDyw; |
7fd59977 | 1649 | |
c357e426 | 1650 | V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window"); |
b5ac8292 | 1651 | |
1652 | MyWindow->Size (aDxw, aDyw); | |
1653 | ||
1654 | gp_Pnt aPoint (Xp * 2.0 / aDxw - 1.0, (aDyw - Yp) * 2.0 / aDyw - 1.0, 0.0); | |
c357e426 | 1655 | aPoint = Camera()->ConvertProj2View (aPoint); |
7fd59977 | 1656 | |
b5ac8292 | 1657 | Xv = aPoint.X(); |
1658 | Yv = aPoint.Y(); | |
7fd59977 | 1659 | } |
1660 | ||
197ac94e | 1661 | //======================================================================= |
1662 | //function : Convert | |
1663 | //purpose : | |
1664 | //======================================================================= | |
7fd59977 | 1665 | Standard_Integer V3d_View::Convert(const Standard_Real Vv) const |
1666 | { | |
c357e426 | 1667 | V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window"); |
b5ac8292 | 1668 | |
1669 | Standard_Integer aDxw, aDyw; | |
1670 | MyWindow->Size (aDxw, aDyw); | |
7fd59977 | 1671 | |
c357e426 | 1672 | gp_Pnt aViewDims = Camera()->ViewDimensions(); |
b5ac8292 | 1673 | Standard_Integer aValue = RealToInt (aDxw * Vv / (aViewDims.X())); |
7fd59977 | 1674 | |
b5ac8292 | 1675 | return aValue; |
7fd59977 | 1676 | } |
1677 | ||
197ac94e | 1678 | //======================================================================= |
1679 | //function : Convert | |
1680 | //purpose : | |
1681 | //======================================================================= | |
1682 | void V3d_View::Convert(const Standard_Real Xv, | |
1683 | const Standard_Real Yv, | |
1684 | Standard_Integer& Xp, | |
1685 | Standard_Integer& Yp) const | |
7fd59977 | 1686 | { |
c357e426 | 1687 | V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window"); |
7fd59977 | 1688 | |
b5ac8292 | 1689 | Standard_Integer aDxw, aDyw; |
1690 | MyWindow->Size (aDxw, aDyw); | |
7fd59977 | 1691 | |
b5ac8292 | 1692 | gp_Pnt aPoint (Xv, Yv, 0.0); |
c357e426 | 1693 | aPoint = Camera()->ConvertView2Proj (aPoint); |
b5ac8292 | 1694 | aPoint = gp_Pnt ((aPoint.X() + 1.0) * aDxw / 2.0, aDyw - (aPoint.Y() + 1.0) * aDyw / 2.0, 0.0); |
7fd59977 | 1695 | |
b5ac8292 | 1696 | Xp = RealToInt (aPoint.X()); |
1697 | Yp = RealToInt (aPoint.Y()); | |
7fd59977 | 1698 | } |
1699 | ||
197ac94e | 1700 | //======================================================================= |
1701 | //function : Convert | |
1702 | //purpose : | |
1703 | //======================================================================= | |
1704 | void V3d_View::Convert(const Standard_Integer Xp, | |
1705 | const Standard_Integer Yp, | |
1706 | Standard_Real& X, | |
1707 | Standard_Real& Y, | |
1708 | Standard_Real& Z) const | |
b8ddfc2f | 1709 | { |
c357e426 | 1710 | V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window"); |
b5ac8292 | 1711 | Standard_Integer aHeight, aWidth; |
1712 | MyWindow->Size (aWidth, aHeight); | |
1713 | ||
1714 | Standard_Real anX = 2.0 * Xp / aWidth - 1.0; | |
1715 | Standard_Real anY = 2.0 * (aHeight - 1 - Yp) / aHeight - 1.0; | |
1716 | Standard_Real aZ = 2.0 * 0.0 - 1.0; | |
1717 | ||
c357e426 | 1718 | gp_Pnt aResult = Camera()->UnProject (gp_Pnt (anX, anY, aZ)); |
b5ac8292 | 1719 | |
1720 | X = aResult.X(); | |
1721 | Y = aResult.Y(); | |
1722 | Z = aResult.Z(); | |
7fd59977 | 1723 | } |
1724 | ||
197ac94e | 1725 | //======================================================================= |
1726 | //function : ConvertWithProj | |
1727 | //purpose : | |
1728 | //======================================================================= | |
3ed88fac | 1729 | void V3d_View::ConvertWithProj(const Standard_Integer theXp, |
1730 | const Standard_Integer theYp, | |
1731 | Standard_Real& theX, | |
1732 | Standard_Real& theY, | |
1733 | Standard_Real& theZ, | |
1734 | Standard_Real& theDx, | |
1735 | Standard_Real& theDy, | |
1736 | Standard_Real& theDz) const | |
7fd59977 | 1737 | { |
c357e426 | 1738 | V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window"); |
3ed88fac | 1739 | Standard_Integer aHeight = 0, aWidth = 0; |
b5ac8292 | 1740 | MyWindow->Size (aWidth, aHeight); |
7fd59977 | 1741 | |
3ed88fac | 1742 | const Standard_Real anX = 2.0 * theXp / aWidth - 1.0; |
1743 | const Standard_Real anY = 2.0 * (aHeight - 1 - theYp) / aHeight - 1.0; | |
1744 | const Standard_Real aZ = 2.0 * 0.0 - 1.0; | |
b5ac8292 | 1745 | |
3ed88fac | 1746 | const Handle(Graphic3d_Camera)& aCamera = Camera(); |
1747 | const gp_Pnt aResult1 = aCamera->UnProject (gp_Pnt (anX, anY, aZ)); | |
1748 | const gp_Pnt aResult2 = aCamera->UnProject (gp_Pnt (anX, anY, aZ - 10.0)); | |
b5ac8292 | 1749 | |
3ed88fac | 1750 | theX = aResult1.X(); |
1751 | theY = aResult1.Y(); | |
1752 | theZ = aResult1.Z(); | |
1753 | Graphic3d_Vec3d aNormDir (theX - aResult2.X(), | |
1754 | theY - aResult2.Y(), | |
1755 | theZ - aResult2.Z()); | |
3910bc65 | 1756 | aNormDir.Normalize(); |
1757 | ||
3ed88fac | 1758 | theDx = aNormDir.x(); |
1759 | theDy = aNormDir.y(); | |
1760 | theDz = aNormDir.z(); | |
7fd59977 | 1761 | } |
7fd59977 | 1762 | |
197ac94e | 1763 | //======================================================================= |
1764 | //function : Convert | |
1765 | //purpose : | |
1766 | //======================================================================= | |
1767 | void V3d_View::Convert(const Standard_Real X, | |
1768 | const Standard_Real Y, | |
1769 | const Standard_Real Z, | |
1770 | Standard_Integer& Xp, | |
1771 | Standard_Integer& Yp) const | |
b8ddfc2f | 1772 | { |
c357e426 | 1773 | V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window"); |
b5ac8292 | 1774 | Standard_Integer aHeight, aWidth; |
1775 | MyWindow->Size (aWidth, aHeight); | |
1776 | ||
c357e426 | 1777 | gp_Pnt aPoint = Camera()->Project (gp_Pnt (X, Y, Z)); |
b5ac8292 | 1778 | |
1779 | Xp = RealToInt ((aPoint.X() + 1) * 0.5 * aWidth); | |
72b11796 | 1780 | Yp = RealToInt (aHeight - 1 - (aPoint.Y() + 1) * 0.5 * aHeight); |
7fd59977 | 1781 | } |
1782 | ||
197ac94e | 1783 | //======================================================================= |
1784 | //function : Project | |
1785 | //purpose : | |
1786 | //======================================================================= | |
c357e426 | 1787 | void V3d_View::Project (const Standard_Real theX, |
1788 | const Standard_Real theY, | |
1789 | const Standard_Real theZ, | |
1790 | Standard_Real& theXp, | |
1791 | Standard_Real& theYp) const | |
7fd59977 | 1792 | { |
c357e426 | 1793 | Standard_Real aZp; |
1794 | Project (theX, theY, theZ, theXp, theYp, aZp); | |
1795 | } | |
1796 | ||
1797 | //======================================================================= | |
1798 | //function : Project | |
1799 | //purpose : | |
1800 | //======================================================================= | |
1801 | void V3d_View::Project (const Standard_Real theX, | |
1802 | const Standard_Real theY, | |
1803 | const Standard_Real theZ, | |
1804 | Standard_Real& theXp, | |
1805 | Standard_Real& theYp, | |
1806 | Standard_Real& theZp) const | |
1807 | { | |
1808 | Handle(Graphic3d_Camera) aCamera = Camera(); | |
1809 | ||
1810 | gp_XYZ aViewSpaceDimensions = aCamera->ViewDimensions(); | |
1811 | Standard_Real aXSize = aViewSpaceDimensions.X(); | |
1812 | Standard_Real aYSize = aViewSpaceDimensions.Y(); | |
1813 | Standard_Real aZSize = aViewSpaceDimensions.Z(); | |
1814 | ||
1815 | gp_Pnt aPoint = aCamera->Project (gp_Pnt (theX, theY, theZ)); | |
1816 | ||
1817 | // NDC [-1, 1] --> PROJ [ -size / 2, +size / 2 ] | |
1818 | theXp = aPoint.X() * aXSize * 0.5; | |
1819 | theYp = aPoint.Y() * aYSize * 0.5; | |
1820 | theZp = aPoint.Z() * aZSize * 0.5; | |
7fd59977 | 1821 | } |
1822 | ||
197ac94e | 1823 | //======================================================================= |
1824 | //function : BackgroundColor | |
1825 | //purpose : | |
1826 | //======================================================================= | |
1827 | void V3d_View::BackgroundColor(const Quantity_TypeOfColor Type, | |
1828 | Standard_Real& V1, | |
1829 | Standard_Real& V2, | |
1830 | Standard_Real& V3) const | |
b8ddfc2f | 1831 | { |
7fd59977 | 1832 | Quantity_Color C = BackgroundColor() ; |
7fd59977 | 1833 | C.Values(V1,V2,V3,Type) ; |
1834 | } | |
1835 | ||
197ac94e | 1836 | //======================================================================= |
1837 | //function : BackgroundColor | |
1838 | //purpose : | |
1839 | //======================================================================= | |
b8ddfc2f | 1840 | Quantity_Color V3d_View::BackgroundColor() const |
1841 | { | |
c357e426 | 1842 | return myView->Background().Color() ; |
7fd59977 | 1843 | } |
7fd59977 | 1844 | |
197ac94e | 1845 | //======================================================================= |
1846 | //function : GradientBackgroundColors | |
1847 | //purpose : | |
1848 | //======================================================================= | |
c357e426 | 1849 | void V3d_View::GradientBackgroundColors (Quantity_Color& theColor1, Quantity_Color& theColor2) const |
b8ddfc2f | 1850 | { |
c357e426 | 1851 | myView->GradientBackground().Colors (theColor1, theColor2); |
7fd59977 | 1852 | } |
1853 | ||
197ac94e | 1854 | //======================================================================= |
1855 | //function : GradientBackground | |
1856 | //purpose : | |
1857 | //======================================================================= | |
b8ddfc2f | 1858 | Aspect_GradientBackground V3d_View::GradientBackground() const |
1859 | { | |
c357e426 | 1860 | return myView->GradientBackground(); |
7fd59977 | 1861 | } |
1862 | ||
197ac94e | 1863 | //======================================================================= |
1864 | //function : Scale | |
1865 | //purpose : | |
1866 | //======================================================================= | |
b8ddfc2f | 1867 | Standard_Real V3d_View::Scale() const |
1868 | { | |
c357e426 | 1869 | return myDefaultCamera->Scale() / Camera()->Scale(); |
7fd59977 | 1870 | } |
1871 | ||
197ac94e | 1872 | //======================================================================= |
1873 | //function : AxialScale | |
1874 | //purpose : | |
1875 | //======================================================================= | |
b8ddfc2f | 1876 | void V3d_View::AxialScale(Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz) const |
1877 | { | |
c357e426 | 1878 | gp_Pnt anAxialScale = Camera()->AxialScale(); |
b5ac8292 | 1879 | Sx = anAxialScale.X(); |
1880 | Sy = anAxialScale.Y(); | |
1881 | Sz = anAxialScale.Z(); | |
7fd59977 | 1882 | } |
1883 | ||
197ac94e | 1884 | //======================================================================= |
1885 | //function : Size | |
1886 | //purpose : | |
1887 | //======================================================================= | |
b8ddfc2f | 1888 | void V3d_View::Size(Standard_Real& Width, Standard_Real& Height) const |
1889 | { | |
c357e426 | 1890 | gp_Pnt aViewDims = Camera()->ViewDimensions(); |
7fd59977 | 1891 | |
b5ac8292 | 1892 | Width = aViewDims.X(); |
1893 | Height = aViewDims.Y(); | |
7fd59977 | 1894 | } |
1895 | ||
197ac94e | 1896 | //======================================================================= |
1897 | //function : ZSize | |
1898 | //purpose : | |
1899 | //======================================================================= | |
b8ddfc2f | 1900 | Standard_Real V3d_View::ZSize() const |
1901 | { | |
c357e426 | 1902 | gp_Pnt aViewDims = Camera()->ViewDimensions(); |
7fd59977 | 1903 | |
b5ac8292 | 1904 | return aViewDims.Z(); |
7fd59977 | 1905 | } |
1906 | ||
197ac94e | 1907 | //======================================================================= |
1908 | //function : MinMax | |
1909 | //purpose : | |
1910 | //======================================================================= | |
1911 | Standard_Integer V3d_View::MinMax(Standard_Real& Umin, | |
1912 | Standard_Real& Vmin, | |
1913 | Standard_Real& Umax, | |
1914 | Standard_Real& Vmax) const | |
b8ddfc2f | 1915 | { |
7fd59977 | 1916 | Standard_Real Wmin,Wmax,U,V,W ; |
1917 | Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax ; | |
1918 | // CAL 6/11/98 | |
c357e426 | 1919 | Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ; |
7fd59977 | 1920 | |
1921 | if( Nstruct ) { | |
c357e426 | 1922 | Bnd_Box aBox = myView->MinMaxValues(); |
ed063270 | 1923 | aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax); |
c357e426 | 1924 | Project (Xmin,Ymin,Zmin,Umin,Vmin,Wmin) ; |
1925 | Project (Xmax,Ymax,Zmax,Umax,Vmax,Wmax) ; | |
1926 | Project (Xmin,Ymin,Zmax,U,V,W) ; | |
7fd59977 | 1927 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1928 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1929 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
c357e426 | 1930 | Project (Xmax,Ymin,Zmax,U,V,W) ; |
7fd59977 | 1931 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1932 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1933 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
c357e426 | 1934 | Project (Xmax,Ymin,Zmin,U,V,W) ; |
7fd59977 | 1935 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1936 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1937 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
c357e426 | 1938 | Project (Xmax,Ymax,Zmin,U,V,W) ; |
7fd59977 | 1939 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1940 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1941 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
c357e426 | 1942 | Project (Xmin,Ymax,Zmax,U,V,W) ; |
7fd59977 | 1943 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1944 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1945 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
c357e426 | 1946 | Project (Xmin,Ymax,Zmin,U,V,W) ; |
7fd59977 | 1947 | Umin = Min(U,Umin) ; Umax = Max(U,Umax) ; |
1948 | Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ; | |
1949 | Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ; | |
1950 | } | |
1951 | return Nstruct ; | |
1952 | } | |
1953 | ||
197ac94e | 1954 | //======================================================================= |
1955 | //function : MinMax | |
1956 | //purpose : | |
1957 | //======================================================================= | |
1958 | Standard_Integer V3d_View::MinMax(Standard_Real& Xmin, | |
1959 | Standard_Real& Ymin, | |
1960 | Standard_Real& Zmin, | |
1961 | Standard_Real& Xmax, | |
1962 | Standard_Real& Ymax, | |
1963 | Standard_Real& Zmax) const | |
b8ddfc2f | 1964 | { |
7fd59977 | 1965 | // CAL 6/11/98 |
1966 | // Standard_Integer Nstruct = (MyView->DisplayedStructures())->Extent() ; | |
c357e426 | 1967 | Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ; |
7fd59977 | 1968 | |
1969 | if( Nstruct ) { | |
c357e426 | 1970 | Bnd_Box aBox = myView->MinMaxValues(); |
ed063270 | 1971 | aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax); |
7fd59977 | 1972 | } |
1973 | return Nstruct ; | |
1974 | } | |
1975 | ||
197ac94e | 1976 | //======================================================================= |
49582f9d | 1977 | //function : GravityPoint |
197ac94e | 1978 | //purpose : |
1979 | //======================================================================= | |
49582f9d | 1980 | gp_Pnt V3d_View::GravityPoint() const |
b8ddfc2f | 1981 | { |
4af098ba | 1982 | Graphic3d_MapOfStructure aSetOfStructures; |
c357e426 | 1983 | myView->DisplayedStructures (aSetOfStructures); |
4af098ba | 1984 | |
1985 | Standard_Boolean hasSelection = Standard_False; | |
1986 | for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures); | |
1987 | aStructIter.More(); aStructIter.Next()) | |
1988 | { | |
1989 | if (aStructIter.Key()->IsHighlighted() | |
1990 | && aStructIter.Key()->IsVisible()) | |
1991 | { | |
1992 | hasSelection = Standard_True; | |
1993 | break; | |
1994 | } | |
1995 | } | |
7fd59977 | 1996 | |
4af098ba | 1997 | Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; |
1998 | Standard_Integer aNbPoints = 0; | |
1999 | gp_XYZ aResult (0.0, 0.0, 0.0); | |
2000 | for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures); | |
2001 | aStructIter.More(); aStructIter.Next()) | |
2002 | { | |
2003 | const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key(); | |
2004 | if (!aStruct->IsVisible() | |
770fa4d4 | 2005 | || aStruct->IsInfinite() |
2006 | || (hasSelection && !aStruct->IsHighlighted())) | |
4af098ba | 2007 | { |
2008 | continue; | |
2009 | } | |
2010 | ||
7c3ef2f7 | 2011 | const Graphic3d_BndBox3d& aBox = aStruct->CStructure()->BoundingBox(); |
770fa4d4 | 2012 | if (!aBox.IsValid()) |
2013 | { | |
2014 | continue; | |
2015 | } | |
2016 | ||
2017 | // skip transformation-persistent objects | |
778cd667 | 2018 | if (!aStruct->TransformPersistence().IsNull()) |
4af098ba | 2019 | { |
2020 | continue; | |
2021 | } | |
2022 | ||
2023 | // use camera projection to find gravity point | |
7c3ef2f7 | 2024 | Xmin = aBox.CornerMin().x(); |
2025 | Ymin = aBox.CornerMin().y(); | |
2026 | Zmin = aBox.CornerMin().z(); | |
2027 | Xmax = aBox.CornerMax().x(); | |
2028 | Ymax = aBox.CornerMax().y(); | |
2029 | Zmax = aBox.CornerMax().z(); | |
4af098ba | 2030 | gp_Pnt aPnts[THE_NB_BOUND_POINTS] = |
2031 | { | |
2032 | gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax), | |
2033 | gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax), | |
2034 | gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax), | |
2035 | gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax) | |
2036 | }; | |
7fd59977 | 2037 | |
4af098ba | 2038 | for (Standard_Integer aPntIt = 0; aPntIt < THE_NB_BOUND_POINTS; ++aPntIt) |
2039 | { | |
2040 | const gp_Pnt& aBndPnt = aPnts[aPntIt]; | |
c357e426 | 2041 | const gp_Pnt aProjected = Camera()->Project (aBndPnt); |
4af098ba | 2042 | if (Abs (aProjected.X()) <= 1.0 |
2043 | && Abs (aProjected.Y()) <= 1.0) | |
2044 | { | |
2045 | aResult += aBndPnt.XYZ(); | |
2046 | ++aNbPoints; | |
2047 | } | |
2048 | } | |
2049 | } | |
7fd59977 | 2050 | |
4af098ba | 2051 | if (aNbPoints == 0) |
b5ac8292 | 2052 | { |
770fa4d4 | 2053 | // fallback - just use bounding box of entire scene |
3fe9ce0e | 2054 | Bnd_Box aBox = myView->MinMaxValues(); |
770fa4d4 | 2055 | if (!aBox.IsVoid()) |
b5ac8292 | 2056 | { |
4af098ba | 2057 | aBox.Get (Xmin, Ymin, Zmin, |
2058 | Xmax, Ymax, Zmax); | |
2059 | gp_Pnt aPnts[THE_NB_BOUND_POINTS] = | |
2060 | { | |
b5ac8292 | 2061 | gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax), |
2062 | gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax), | |
2063 | gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax), | |
4af098ba | 2064 | gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax) |
2065 | }; | |
b5ac8292 | 2066 | |
4af098ba | 2067 | for (Standard_Integer aPntIt = 0; aPntIt < THE_NB_BOUND_POINTS; ++aPntIt) |
b5ac8292 | 2068 | { |
2069 | const gp_Pnt& aBndPnt = aPnts[aPntIt]; | |
4af098ba | 2070 | aResult += aBndPnt.XYZ(); |
2071 | ++aNbPoints; | |
b5ac8292 | 2072 | } |
7fd59977 | 2073 | } |
2074 | } | |
7fd59977 | 2075 | |
4af098ba | 2076 | if (aNbPoints > 0) |
2077 | { | |
2078 | aResult /= aNbPoints; | |
2079 | } | |
49582f9d | 2080 | |
2081 | return aResult; | |
7fd59977 | 2082 | } |
2083 | ||
197ac94e | 2084 | //======================================================================= |
2085 | //function : Eye | |
2086 | //purpose : | |
2087 | //======================================================================= | |
b8ddfc2f | 2088 | void V3d_View::Eye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const |
2089 | { | |
c357e426 | 2090 | gp_Pnt aCameraEye = Camera()->Eye(); |
b5ac8292 | 2091 | X = aCameraEye.X(); |
2092 | Y = aCameraEye.Y(); | |
2093 | Z = aCameraEye.Z(); | |
7fd59977 | 2094 | } |
2095 | ||
197ac94e | 2096 | //============================================================================= |
2097 | //function : ProjReferenceAxe | |
2098 | //purpose : | |
2099 | //============================================================================= | |
2100 | void V3d_View::ProjReferenceAxe(const Standard_Integer Xpix, | |
2101 | const Standard_Integer Ypix, | |
2102 | Standard_Real& XP, | |
2103 | Standard_Real& YP, | |
2104 | Standard_Real& ZP, | |
2105 | Standard_Real& VX, | |
2106 | Standard_Real& VY, | |
2107 | Standard_Real& VZ) const | |
b8ddfc2f | 2108 | { |
7fd59977 | 2109 | Standard_Real Xo,Yo,Zo; |
2110 | ||
b5ac8292 | 2111 | Convert (Xpix, Ypix, XP, YP, ZP); |
2112 | if ( Type() == V3d_PERSPECTIVE ) | |
2113 | { | |
2114 | FocalReferencePoint (Xo,Yo,Zo); | |
7fd59977 | 2115 | VX = Xo - XP; |
2116 | VY = Yo - YP; | |
2117 | VZ = Zo - ZP; | |
2118 | } | |
b5ac8292 | 2119 | else |
2120 | { | |
2121 | Proj (VX,VY,VZ); | |
7fd59977 | 2122 | } |
2123 | } | |
2124 | ||
197ac94e | 2125 | //============================================================================= |
2126 | //function : Depth | |
2127 | //purpose : | |
2128 | //============================================================================= | |
b8ddfc2f | 2129 | Standard_Real V3d_View::Depth() const |
2130 | { | |
c357e426 | 2131 | return Camera()->Distance(); |
7fd59977 | 2132 | } |
2133 | ||
197ac94e | 2134 | //============================================================================= |
2135 | //function : Proj | |
2136 | //purpose : | |
2137 | //============================================================================= | |
b8ddfc2f | 2138 | void V3d_View::Proj(Standard_Real& Dx, Standard_Real& Dy, Standard_Real& Dz) const |
2139 | { | |
c357e426 | 2140 | gp_Dir aCameraDir = Camera()->Direction().Reversed(); |
b5ac8292 | 2141 | Dx = aCameraDir.X(); |
2142 | Dy = aCameraDir.Y(); | |
2143 | Dz = aCameraDir.Z(); | |
7fd59977 | 2144 | } |
2145 | ||
197ac94e | 2146 | //============================================================================= |
2147 | //function : At | |
2148 | //purpose : | |
2149 | //============================================================================= | |
b8ddfc2f | 2150 | void V3d_View::At(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const |
2151 | { | |
c357e426 | 2152 | gp_Pnt aCameraCenter = Camera()->Center(); |
b5ac8292 | 2153 | X = aCameraCenter.X(); |
2154 | Y = aCameraCenter.Y(); | |
2155 | Z = aCameraCenter.Z(); | |
7fd59977 | 2156 | } |
2157 | ||
197ac94e | 2158 | //============================================================================= |
2159 | //function : Up | |
2160 | //purpose : | |
2161 | //============================================================================= | |
b8ddfc2f | 2162 | void V3d_View::Up(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const |
2163 | { | |
c357e426 | 2164 | gp_Dir aCameraUp = Camera()->Up(); |
b5ac8292 | 2165 | Vx = aCameraUp.X(); |
2166 | Vy = aCameraUp.Y(); | |
2167 | Vz = aCameraUp.Z(); | |
7fd59977 | 2168 | } |
2169 | ||
197ac94e | 2170 | //============================================================================= |
2171 | //function : Twist | |
2172 | //purpose : | |
2173 | //============================================================================= | |
b8ddfc2f | 2174 | Standard_Real V3d_View::Twist() const |
2175 | { | |
21b2385f | 2176 | gp_Vec Xaxis, Yaxis, Zaxis; |
2177 | const gp_Dir aReferencePlane (Camera()->Direction().Reversed()); | |
2178 | if (!screenAxis (aReferencePlane, gp::DZ(), Xaxis, Yaxis, Zaxis) | |
2179 | && !screenAxis (aReferencePlane, gp::DY(), Xaxis, Yaxis, Zaxis) | |
2180 | && !screenAxis (aReferencePlane, gp::DX(), Xaxis, Yaxis, Zaxis)) | |
2181 | { | |
2182 | // | |
2183 | } | |
7fd59977 | 2184 | |
21b2385f | 2185 | // Compute Cross Vector From Up & Origin |
2186 | const gp_Dir aCameraUp = Camera()->Up(); | |
2187 | const gp_XYZ aP = Yaxis.XYZ().Crossed (aCameraUp.XYZ()); | |
b5ac8292 | 2188 | |
21b2385f | 2189 | // compute Angle |
2190 | Standard_Real anAngle = ASin (Max (Min (aP.Modulus(), 1.0), -1.0)); | |
2191 | if (Yaxis.Dot (aCameraUp.XYZ()) < 0.0) | |
2192 | { | |
2193 | anAngle = M_PI - anAngle; | |
7fd59977 | 2194 | } |
21b2385f | 2195 | if (anAngle > 0.0 |
2196 | && anAngle < M_PI) | |
2197 | { | |
2198 | const gp_Dir aProjDir = Camera()->Direction().Reversed(); | |
2199 | if (aP.Dot (aProjDir.XYZ()) < 0.0) | |
2200 | { | |
2201 | anAngle = DEUXPI - anAngle; | |
2202 | } | |
7fd59977 | 2203 | } |
21b2385f | 2204 | return anAngle; |
7fd59977 | 2205 | } |
2206 | ||
197ac94e | 2207 | //============================================================================= |
2208 | //function : ShadingModel | |
2209 | //purpose : | |
2210 | //============================================================================= | |
dc89236f | 2211 | Graphic3d_TypeOfShadingModel V3d_View::ShadingModel() const |
b8ddfc2f | 2212 | { |
dc89236f | 2213 | return myView->ShadingModel(); |
7fd59977 | 2214 | } |
2215 | ||
197ac94e | 2216 | //============================================================================= |
2217 | //function : TextureEnv | |
2218 | //purpose : | |
2219 | //============================================================================= | |
857ffd5e | 2220 | Handle(Graphic3d_TextureEnv) V3d_View::TextureEnv() const |
b8ddfc2f | 2221 | { |
c357e426 | 2222 | return myView->TextureEnv(); |
7fd59977 | 2223 | } |
2224 | ||
197ac94e | 2225 | //============================================================================= |
2226 | //function : Visualization | |
2227 | //purpose : | |
2228 | //============================================================================= | |
b8ddfc2f | 2229 | V3d_TypeOfVisualization V3d_View::Visualization() const |
2230 | { | |
c357e426 | 2231 | return static_cast<V3d_TypeOfVisualization> (myView->VisualizationType()); |
7fd59977 | 2232 | } |
2233 | ||
197ac94e | 2234 | //============================================================================= |
2235 | //function : IfWindow | |
2236 | //purpose : | |
2237 | //============================================================================= | |
b8ddfc2f | 2238 | Standard_Boolean V3d_View::IfWindow() const |
2239 | { | |
c357e426 | 2240 | return myView->IsDefined(); |
7fd59977 | 2241 | } |
2242 | ||
197ac94e | 2243 | //============================================================================= |
2244 | //function : Type | |
2245 | //purpose : | |
2246 | //============================================================================= | |
b8ddfc2f | 2247 | V3d_TypeOfView V3d_View::Type() const |
2248 | { | |
c357e426 | 2249 | return Camera()->IsOrthographic() ? V3d_ORTHOGRAPHIC : V3d_PERSPECTIVE; |
7fd59977 | 2250 | } |
2251 | ||
197ac94e | 2252 | //============================================================================= |
2253 | //function : SetFocale | |
2254 | //purpose : | |
2255 | //============================================================================= | |
b8ddfc2f | 2256 | void V3d_View::SetFocale( const Standard_Real focale ) |
2257 | { | |
c357e426 | 2258 | Handle(Graphic3d_Camera) aCamera = Camera(); |
2259 | ||
2260 | if (aCamera->IsOrthographic()) | |
b5ac8292 | 2261 | { |
2262 | return; | |
7fd59977 | 2263 | } |
b5ac8292 | 2264 | |
c357e426 | 2265 | Standard_Real aFOVyRad = ATan (focale / (aCamera->Distance() * 2.0)); |
b5ac8292 | 2266 | |
c357e426 | 2267 | aCamera->SetFOVy (aFOVyRad * (360 / M_PI)); |
7fd59977 | 2268 | |
2269 | ImmediateUpdate(); | |
2270 | } | |
2271 | ||
197ac94e | 2272 | //============================================================================= |
2273 | //function : Focale | |
2274 | //purpose : | |
2275 | //============================================================================= | |
b5ac8292 | 2276 | Standard_Real V3d_View::Focale() const |
b8ddfc2f | 2277 | { |
c357e426 | 2278 | Handle(Graphic3d_Camera) aCamera = Camera(); |
2279 | ||
2280 | if (aCamera->IsOrthographic()) | |
b5ac8292 | 2281 | { |
2282 | return 0.0; | |
7fd59977 | 2283 | } |
b5ac8292 | 2284 | |
c357e426 | 2285 | return aCamera->Distance() * 2.0 * Tan (aCamera->FOVy() * M_PI / 360.0); |
7fd59977 | 2286 | } |
2287 | ||
197ac94e | 2288 | //============================================================================= |
21b2385f | 2289 | //function : screenAxis |
197ac94e | 2290 | //purpose : |
2291 | //============================================================================= | |
21b2385f | 2292 | Standard_Boolean V3d_View::screenAxis (const gp_Dir& theVpn, const gp_Dir& theVup, |
2293 | gp_Vec& theXaxe, gp_Vec& theYaxe, gp_Vec& theZaxe) | |
b5ac8292 | 2294 | { |
21b2385f | 2295 | theXaxe = theVup.XYZ().Crossed (theVpn.XYZ()); |
2296 | if (theXaxe.Magnitude() <= gp::Resolution()) | |
2297 | { | |
2298 | return Standard_False; | |
2299 | } | |
2300 | theXaxe.Normalize(); | |
b5ac8292 | 2301 | |
21b2385f | 2302 | theYaxe = theVpn.XYZ().Crossed (theXaxe.XYZ()); |
2303 | if (theYaxe.Magnitude() <= gp::Resolution()) | |
2304 | { | |
2305 | return Standard_False; | |
2306 | } | |
2307 | theYaxe.Normalize(); | |
b5ac8292 | 2308 | |
21b2385f | 2309 | theZaxe = theVpn.XYZ(); |
2310 | theZaxe.Normalize(); | |
7fd59977 | 2311 | return Standard_True; |
2312 | } | |
2313 | ||
197ac94e | 2314 | //============================================================================= |
2315 | //function : TrsPoint | |
2316 | //purpose : | |
2317 | //============================================================================= | |
475c2302 | 2318 | gp_XYZ V3d_View::TrsPoint (const Graphic3d_Vertex& thePnt, const TColStd_Array2OfReal& theMat) |
b8ddfc2f | 2319 | { |
7fd59977 | 2320 | // CAL. S3892 |
475c2302 | 2321 | const Standard_Integer lr = theMat.LowerRow(); |
2322 | const Standard_Integer ur = theMat.UpperRow(); | |
2323 | const Standard_Integer lc = theMat.LowerCol(); | |
2324 | const Standard_Integer uc = theMat.UpperCol(); | |
2325 | if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4)) | |
2326 | { | |
2327 | return gp_XYZ (thePnt.X(), thePnt.Y(), thePnt.Z()); | |
2328 | } | |
2329 | ||
2330 | Standard_Real X, Y, Z; | |
2331 | thePnt.Coord (X,Y,Z); | |
2332 | const Standard_Real XX = (theMat(lr,lc+3) + X*theMat(lr,lc) + Y*theMat(lr,lc+1) + Z*theMat(lr,lc+2)) / theMat(lr+3,lc+3); | |
2333 | const Standard_Real YY = (theMat(lr+1,lc+3) + X*theMat(lr+1,lc) + Y*theMat(lr+1,lc+1) + Z*theMat(lr+1,lc+2))/theMat(lr+3,lc+3); | |
2334 | const Standard_Real ZZ = (theMat(lr+2,lc+3) + X*theMat(lr+2,lc) + Y*theMat(lr+2,lc+1) + Z*theMat(lr+2,lc+2))/theMat(lr+3,lc+3); | |
2335 | return gp_XYZ (XX, YY, ZZ); | |
7fd59977 | 2336 | } |
2337 | ||
197ac94e | 2338 | //======================================================================= |
2339 | //function : Pan | |
2340 | //purpose : | |
2341 | //======================================================================= | |
2342 | void V3d_View::Pan (const Standard_Integer theDXp, | |
2343 | const Standard_Integer theDYp, | |
ee2be2a8 | 2344 | const Standard_Real theZoomFactor, |
197ac94e | 2345 | const Standard_Boolean theToStart) |
b8ddfc2f | 2346 | { |
197ac94e | 2347 | Panning (Convert (theDXp), Convert (theDYp), theZoomFactor, theToStart); |
7fd59977 | 2348 | } |
2349 | ||
197ac94e | 2350 | //======================================================================= |
2351 | //function : Panning | |
2352 | //purpose : | |
2353 | //======================================================================= | |
2354 | void V3d_View::Panning (const Standard_Real theDXv, | |
2355 | const Standard_Real theDYv, | |
ee2be2a8 | 2356 | const Standard_Real theZoomFactor, |
197ac94e | 2357 | const Standard_Boolean theToStart) |
7fd59977 | 2358 | { |
197ac94e | 2359 | Standard_ASSERT_RAISE (theZoomFactor > 0.0, "Bad zoom factor"); |
7fd59977 | 2360 | |
c357e426 | 2361 | Handle(Graphic3d_Camera) aCamera = Camera(); |
2362 | ||
197ac94e | 2363 | if (theToStart) |
2364 | { | |
607e5e62 | 2365 | myCamStartOpDir = aCamera->Direction(); |
c357e426 | 2366 | myCamStartOpEye = aCamera->Eye(); |
2367 | myCamStartOpCenter = aCamera->Center(); | |
7fd59977 | 2368 | } |
197ac94e | 2369 | |
2370 | Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False); | |
2371 | ||
c357e426 | 2372 | gp_Pnt aViewDims = aCamera->ViewDimensions(); |
197ac94e | 2373 | |
607e5e62 | 2374 | aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter); |
2375 | aCamera->SetDirectionFromEye (myCamStartOpDir); | |
c357e426 | 2376 | Translate (aCamera, -theDXv, -theDYv); |
2377 | Scale (aCamera, aViewDims.X() / theZoomFactor, aViewDims.Y() / theZoomFactor); | |
197ac94e | 2378 | |
2379 | SetImmediateUpdate (wasUpdateEnabled); | |
2380 | ||
2381 | ImmediateUpdate(); | |
7fd59977 | 2382 | } |
2383 | ||
197ac94e | 2384 | //======================================================================= |
2385 | //function : Zoom | |
2386 | //purpose : | |
2387 | //======================================================================= | |
2388 | void V3d_View::Zoom (const Standard_Integer theXp1, | |
2389 | const Standard_Integer theYp1, | |
2390 | const Standard_Integer theXp2, | |
2391 | const Standard_Integer theYp2) | |
2392 | { | |
2393 | Standard_Integer aDx = theXp2 - theXp1; | |
2394 | Standard_Integer aDy = theYp2 - theYp1; | |
2395 | if (aDx != 0 || aDy != 0) | |
2396 | { | |
2397 | Standard_Real aCoeff = Sqrt( (Standard_Real)(aDx * aDx + aDy * aDy) ) / 100.0 + 1.0; | |
2398 | aCoeff = (aDx > 0) ? aCoeff : 1.0 / aCoeff; | |
2399 | SetZoom (aCoeff, Standard_True); | |
2400 | } | |
7fd59977 | 2401 | } |
2402 | ||
197ac94e | 2403 | //======================================================================= |
2404 | //function : StartZoomAtPoint | |
2405 | //purpose : | |
2406 | //======================================================================= | |
2407 | void V3d_View::StartZoomAtPoint (const Standard_Integer theXp, | |
2408 | const Standard_Integer theYp) | |
7fd59977 | 2409 | { |
197ac94e | 2410 | MyZoomAtPointX = theXp; |
2411 | MyZoomAtPointY = theYp; | |
7fd59977 | 2412 | } |
2413 | ||
197ac94e | 2414 | //======================================================================= |
2415 | //function : ZoomAtPoint | |
2416 | //purpose : | |
2417 | //======================================================================= | |
2418 | void V3d_View::ZoomAtPoint (const Standard_Integer theMouseStartX, | |
2419 | const Standard_Integer theMouseStartY, | |
2420 | const Standard_Integer theMouseEndX, | |
2421 | const Standard_Integer theMouseEndY) | |
7fd59977 | 2422 | { |
197ac94e | 2423 | Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False); |
7fd59977 | 2424 | |
197ac94e | 2425 | // zoom |
2426 | Standard_Real aDxy = Standard_Real ((theMouseEndX + theMouseEndY) - (theMouseStartX + theMouseStartY)); | |
2427 | Standard_Real aDZoom = Abs (aDxy) / 100.0 + 1.0; | |
2428 | aDZoom = (aDxy > 0.0) ? aDZoom : 1.0 / aDZoom; | |
7fd59977 | 2429 | |
197ac94e | 2430 | V3d_BadValue_Raise_if (aDZoom <= 0.0, "V3d_View::ZoomAtPoint, bad coefficient"); |
7fd59977 | 2431 | |
c357e426 | 2432 | Handle(Graphic3d_Camera) aCamera = Camera(); |
2433 | ||
2434 | Standard_Real aViewWidth = aCamera->ViewDimensions().X(); | |
2435 | Standard_Real aViewHeight = aCamera->ViewDimensions().Y(); | |
7fd59977 | 2436 | |
197ac94e | 2437 | // ensure that zoom will not be too small or too big. |
2438 | Standard_Real aCoef = aDZoom; | |
2439 | if (aViewWidth < aCoef * Precision::Confusion()) | |
2440 | { | |
2441 | aCoef = aViewWidth / Precision::Confusion(); | |
2442 | } | |
2443 | else if (aViewWidth > aCoef * 1e12) | |
2444 | { | |
2445 | aCoef = aViewWidth / 1e12; | |
2446 | } | |
2447 | if (aViewHeight < aCoef * Precision::Confusion()) | |
2448 | { | |
2449 | aCoef = aViewHeight / Precision::Confusion(); | |
2450 | } | |
2451 | else if (aViewHeight > aCoef * 1e12) | |
2452 | { | |
2453 | aCoef = aViewHeight / 1e12; | |
2454 | } | |
7fd59977 | 2455 | |
197ac94e | 2456 | Standard_Real aZoomAtPointXv = 0.0; |
2457 | Standard_Real aZoomAtPointYv = 0.0; | |
2458 | Convert (MyZoomAtPointX, MyZoomAtPointY, aZoomAtPointXv, aZoomAtPointYv); | |
7fd59977 | 2459 | |
ee2be2a8 | 2460 | Standard_Real aDxv = aZoomAtPointXv / aCoef; |
2461 | Standard_Real aDyv = aZoomAtPointYv / aCoef; | |
7fd59977 | 2462 | |
c357e426 | 2463 | aCamera->SetScale (aCamera->Scale() / aCoef); |
2464 | Translate (aCamera, aZoomAtPointXv - aDxv, aZoomAtPointYv - aDyv); | |
b5ac8292 | 2465 | |
197ac94e | 2466 | SetImmediateUpdate (wasUpdateEnabled); |
7fd59977 | 2467 | |
197ac94e | 2468 | ImmediateUpdate(); |
7fd59977 | 2469 | } |
2470 | ||
197ac94e | 2471 | //============================================================================= |
2472 | //function : AxialScale | |
2473 | //purpose : | |
2474 | //============================================================================= | |
7fd59977 | 2475 | void V3d_View::AxialScale (const Standard_Integer Dx, |
2476 | const Standard_Integer Dy, | |
2477 | const V3d_TypeOfAxe Axis) | |
2478 | { | |
2479 | if( Dx != 0. || Dy != 0. ) { | |
2480 | Standard_Real Sx, Sy, Sz; | |
2481 | AxialScale( Sx, Sy, Sz ); | |
2482 | Standard_Real dscale = Sqrt(Dx*Dx + Dy*Dy) / 100. + 1; | |
2483 | dscale = (Dx > 0) ? dscale : 1./dscale; | |
2484 | if( Axis == V3d_X ) Sx = dscale; | |
2485 | if( Axis == V3d_Y ) Sy = dscale; | |
2486 | if( Axis == V3d_Z ) Sz = dscale; | |
2487 | SetAxialScale( Sx, Sy, Sz ); | |
2488 | } | |
2489 | } | |
2490 | ||
197ac94e | 2491 | //============================================================================= |
2492 | //function : FitAll | |
2493 | //purpose : | |
2494 | //============================================================================= | |
434ffc09 | 2495 | void V3d_View::FitAll(const Standard_Real theXmin, |
2496 | const Standard_Real theYmin, | |
2497 | const Standard_Real theXmax, | |
2498 | const Standard_Real theYmax) | |
7fd59977 | 2499 | { |
434ffc09 | 2500 | Handle(Graphic3d_Camera) aCamera = Camera(); |
2501 | Standard_Real anAspect = aCamera->Aspect(); | |
7fd59977 | 2502 | |
434ffc09 | 2503 | Standard_Real aFitSizeU = Abs (theXmax - theXmin); |
2504 | Standard_Real aFitSizeV = Abs (theYmax - theYmin); | |
197ac94e | 2505 | Standard_Real aFitAspect = aFitSizeU / aFitSizeV; |
434ffc09 | 2506 | if (aFitAspect >= anAspect) |
197ac94e | 2507 | { |
434ffc09 | 2508 | aFitSizeV = aFitSizeU / anAspect; |
197ac94e | 2509 | } |
2510 | else | |
2511 | { | |
434ffc09 | 2512 | aFitSizeU = aFitSizeV * anAspect; |
197ac94e | 2513 | } |
b5ac8292 | 2514 | |
434ffc09 | 2515 | Translate (aCamera, (theXmin + theXmax) * 0.5, (theYmin + theYmax) * 0.5); |
c357e426 | 2516 | Scale (aCamera, aFitSizeU, aFitSizeV); |
2517 | ||
197ac94e | 2518 | ImmediateUpdate(); |
7fd59977 | 2519 | } |
2520 | ||
197ac94e | 2521 | //============================================================================= |
2522 | //function : StartRotation | |
2523 | //purpose : | |
2524 | //============================================================================= | |
7fd59977 | 2525 | void V3d_View::StartRotation(const Standard_Integer X, |
2526 | const Standard_Integer Y, | |
ee2be2a8 | 2527 | const Standard_Real zRotationThreshold) |
7fd59977 | 2528 | { |
7fd59977 | 2529 | sx = X; sy = Y; |
2530 | Standard_Real x,y; | |
2531 | Size(x,y); | |
2532 | rx = Standard_Real(Convert(x)); | |
2533 | ry = Standard_Real(Convert(y)); | |
49582f9d | 2534 | myRotateGravity = GravityPoint(); |
2535 | Rotate (0.0, 0.0, 0.0, | |
2536 | myRotateGravity.X(), myRotateGravity.Y(), myRotateGravity.Z(), | |
2537 | Standard_True); | |
016e5959 | 2538 | myZRotation = Standard_False; |
7fd59977 | 2539 | if( zRotationThreshold > 0. ) { |
2540 | Standard_Real dx = Abs(sx - rx/2.); | |
2541 | Standard_Real dy = Abs(sy - ry/2.); | |
016e5959 | 2542 | // if( dx > rx/3. || dy > ry/3. ) myZRotation = Standard_True; |
7fd59977 | 2543 | Standard_Real dd = zRotationThreshold * (rx + ry)/2.; |
016e5959 | 2544 | if( dx > dd || dy > dd ) myZRotation = Standard_True; |
7fd59977 | 2545 | } |
7fd59977 | 2546 | |
2547 | } | |
2548 | ||
197ac94e | 2549 | //============================================================================= |
2550 | //function : Rotation | |
2551 | //purpose : | |
2552 | //============================================================================= | |
7fd59977 | 2553 | void V3d_View::Rotation(const Standard_Integer X, |
2554 | const Standard_Integer Y) | |
2555 | { | |
7fd59977 | 2556 | if( rx == 0. || ry == 0. ) { |
2557 | StartRotation(X,Y); | |
2558 | return; | |
2559 | } | |
7fd59977 | 2560 | Standard_Real dx=0.,dy=0.,dz=0.; |
016e5959 | 2561 | if( myZRotation ) { |
7fd59977 | 2562 | dz = atan2(Standard_Real(X)-rx/2., ry/2.-Standard_Real(Y)) - |
2563 | atan2(sx-rx/2.,ry/2.-sy); | |
2564 | } else { | |
c6541a0c D |
2565 | dx = (Standard_Real(X) - sx) * M_PI / rx; |
2566 | dy = (sy - Standard_Real(Y)) * M_PI / ry; | |
7fd59977 | 2567 | } |
b12a3e54 | 2568 | |
49582f9d | 2569 | Rotate (dx, dy, dz, |
2570 | myRotateGravity.X(), myRotateGravity.Y(), myRotateGravity.Z(), | |
2571 | Standard_False); | |
7fd59977 | 2572 | } |
2573 | ||
197ac94e | 2574 | //============================================================================= |
2575 | //function : SetComputedMode | |
2576 | //purpose : | |
2577 | //============================================================================= | |
c357e426 | 2578 | void V3d_View::SetComputedMode (const Standard_Boolean theMode) |
7fd59977 | 2579 | { |
c357e426 | 2580 | if (theMode) |
197ac94e | 2581 | { |
2582 | if (myComputedMode) | |
2583 | { | |
c357e426 | 2584 | myView->SetComputedMode (Standard_True); |
7fd59977 | 2585 | } |
c357e426 | 2586 | } |
2587 | else | |
197ac94e | 2588 | { |
c357e426 | 2589 | myView->SetComputedMode (Standard_False); |
7fd59977 | 2590 | } |
b8ddfc2f | 2591 | } |
7fd59977 | 2592 | |
197ac94e | 2593 | //============================================================================= |
2594 | //function : ComputedMode | |
2595 | //purpose : | |
2596 | //============================================================================= | |
2597 | Standard_Boolean V3d_View::ComputedMode() const | |
7fd59977 | 2598 | { |
c357e426 | 2599 | return myView->ComputedMode(); |
b8ddfc2f | 2600 | } |
7fd59977 | 2601 | |
197ac94e | 2602 | //============================================================================= |
2603 | //function : SetBackFacingModel | |
2604 | //purpose : | |
2605 | //============================================================================= | |
c357e426 | 2606 | void V3d_View::SetBackFacingModel (const V3d_TypeOfBackfacingModel theModel) |
7fd59977 | 2607 | { |
c357e426 | 2608 | myView->SetBackfacingModel (static_cast<Graphic3d_TypeOfBackfacingModel> (theModel)); |
7fd59977 | 2609 | Redraw(); |
b8ddfc2f | 2610 | } |
7fd59977 | 2611 | |
197ac94e | 2612 | //============================================================================= |
2613 | //function : BackFacingModel | |
2614 | //purpose : | |
2615 | //============================================================================= | |
2616 | V3d_TypeOfBackfacingModel V3d_View::BackFacingModel() const | |
b8ddfc2f | 2617 | { |
c357e426 | 2618 | return static_cast<V3d_TypeOfBackfacingModel> (myView->BackfacingModel()); |
b8ddfc2f | 2619 | } |
7fd59977 | 2620 | |
c357e426 | 2621 | //============================================================================= |
2622 | //function : Init | |
2623 | //purpose : | |
2624 | //============================================================================= | |
b8ddfc2f | 2625 | void V3d_View::Init() |
2626 | { | |
7fd59977 | 2627 | myComputedMode = MyViewer->ComputedMode(); |
c357e426 | 2628 | if (!myComputedMode || !MyViewer->DefaultComputedMode()) |
2629 | { | |
2630 | SetComputedMode (Standard_False); | |
7fd59977 | 2631 | } |
7fd59977 | 2632 | } |
2633 | ||
197ac94e | 2634 | //============================================================================= |
2635 | //function : Dump | |
2636 | //purpose : | |
2637 | //============================================================================= | |
692613e5 | 2638 | Standard_Boolean V3d_View::Dump (const Standard_CString theFile, |
2639 | const Graphic3d_BufferType& theBufferType) | |
7fd59977 | 2640 | { |
2641 | Standard_Integer aWinWidth, aWinHeight; | |
2642 | MyWindow->Size (aWinWidth, aWinHeight); | |
692613e5 | 2643 | Image_AlienPixMap anImage; |
b5ac8292 | 2644 | |
692613e5 | 2645 | return ToPixMap (anImage, aWinWidth, aWinHeight, theBufferType) && anImage.Save (theFile); |
7fd59977 | 2646 | } |
2647 | ||
197ac94e | 2648 | //============================================================================= |
2649 | //function : ToPixMap | |
2650 | //purpose : | |
2651 | //============================================================================= | |
692613e5 | 2652 | Standard_Boolean V3d_View::ToPixMap (Image_PixMap& theImage, |
3bffef55 | 2653 | const V3d_ImageDumpOptions& theParams) |
7fd59977 | 2654 | { |
3bffef55 | 2655 | Graphic3d_Vec2i aTargetSize (theParams.Width, theParams.Height); |
2656 | if (aTargetSize.x() != 0 | |
2657 | && aTargetSize.y() != 0) | |
2658 | { | |
2659 | // allocate image buffer for dumping | |
2660 | if (theImage.IsEmpty() | |
2661 | || theImage.SizeX() != Standard_Size(aTargetSize.x()) | |
2662 | || theImage.SizeY() != Standard_Size(aTargetSize.y())) | |
2663 | { | |
dc858f4c | 2664 | Image_Format aFormat = Image_Format_UNKNOWN; |
3bffef55 | 2665 | switch (theParams.BufferType) |
2666 | { | |
38d90bb3 | 2667 | case Graphic3d_BT_RGB: aFormat = Image_Format_RGB; break; |
2668 | case Graphic3d_BT_RGBA: aFormat = Image_Format_RGBA; break; | |
2669 | case Graphic3d_BT_Depth: aFormat = Image_Format_GrayF; break; | |
2670 | case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF; break; | |
4eff0c04 | 2671 | case Graphic3d_BT_Red: aFormat = Image_Format_Gray; break; |
3bffef55 | 2672 | } |
2673 | ||
2674 | if (!theImage.InitZero (aFormat, Standard_Size(aTargetSize.x()), Standard_Size(aTargetSize.y()))) | |
2675 | { | |
a87b1b37 | 2676 | Message::SendFail (TCollection_AsciiString ("Fail to allocate an image ") + aTargetSize.x() + "x" + aTargetSize.y() + " for view dump"); |
3bffef55 | 2677 | return Standard_False; |
2678 | } | |
2679 | } | |
2680 | } | |
2681 | if (theImage.IsEmpty()) | |
2682 | { | |
a87b1b37 | 2683 | Message::SendFail ("V3d_View::ToPixMap() has been called without image dimensions"); |
3bffef55 | 2684 | return Standard_False; |
2685 | } | |
2686 | aTargetSize.x() = (Standard_Integer )theImage.SizeX(); | |
2687 | aTargetSize.y() = (Standard_Integer )theImage.SizeY(); | |
2688 | ||
b128c892 | 2689 | Handle(Standard_Transient) aFBOPtr; |
2690 | Handle(Standard_Transient) aPrevFBOPtr = myView->FBO(); | |
3bffef55 | 2691 | Graphic3d_Vec2i aFBOVPSize = aTargetSize; |
2692 | ||
2693 | bool isTiling = false; | |
2694 | if (theParams.TileSize > 0) | |
2695 | { | |
2696 | if (aFBOVPSize.x() > theParams.TileSize | |
2697 | || aFBOVPSize.y() > theParams.TileSize) | |
2698 | { | |
2699 | aFBOVPSize.x() = Min (aFBOVPSize.x(), theParams.TileSize); | |
2700 | aFBOVPSize.y() = Min (aFBOVPSize.y(), theParams.TileSize); | |
2701 | isTiling = true; | |
2702 | } | |
2703 | } | |
2704 | ||
2705 | Graphic3d_Vec2i aPrevFBOVPSize; | |
b128c892 | 2706 | if (!aPrevFBOPtr.IsNull()) |
7fd59977 | 2707 | { |
3bffef55 | 2708 | Graphic3d_Vec2i aPrevFBOSizeMax; |
c357e426 | 2709 | myView->FBOGetDimensions (aPrevFBOPtr, |
3bffef55 | 2710 | aPrevFBOVPSize.x(), aPrevFBOVPSize.y(), |
2711 | aPrevFBOSizeMax.x(), aPrevFBOSizeMax.y()); | |
2712 | if (aFBOVPSize.x() <= aPrevFBOSizeMax.x() | |
2713 | && aFBOVPSize.y() <= aPrevFBOSizeMax.y()) | |
7fd59977 | 2714 | { |
7fd59977 | 2715 | aFBOPtr = aPrevFBOPtr; |
2716 | } | |
2717 | } | |
2718 | ||
b128c892 | 2719 | if (aFBOPtr.IsNull()) |
7fd59977 | 2720 | { |
6997ff1c | 2721 | Standard_Integer aMaxTexSizeX = MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxViewDumpSizeX); |
2722 | Standard_Integer aMaxTexSizeY = MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxViewDumpSizeY); | |
2723 | if (theParams.TileSize > aMaxTexSizeX | |
2724 | || theParams.TileSize > aMaxTexSizeY) | |
85e096c3 | 2725 | { |
a87b1b37 | 2726 | Message::SendFail (TCollection_AsciiString ("Image dump can not be performed - specified tile size (") |
2727 | + theParams.TileSize + ") exceeds hardware limits (" + aMaxTexSizeX + "x" + aMaxTexSizeY + ")"); | |
3bffef55 | 2728 | return Standard_False; |
85e096c3 | 2729 | } |
3bffef55 | 2730 | |
6997ff1c | 2731 | if (aFBOVPSize.x() > aMaxTexSizeX |
2732 | || aFBOVPSize.y() > aMaxTexSizeY) | |
3bffef55 | 2733 | { |
6997ff1c | 2734 | if (MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_IsWorkaroundFBO)) |
2735 | { | |
a87b1b37 | 2736 | Message::SendWarning ("Warning, workaround for Intel driver problem with empty FBO for images with big width is applied"); |
6997ff1c | 2737 | } |
a87b1b37 | 2738 | Message::SendInfo (TCollection_AsciiString ("Info, tiling image dump is used, image size (") |
2739 | + aFBOVPSize.x() + "x" + aFBOVPSize.y() + ") exceeds hardware limits (" + aMaxTexSizeX + "x" + aMaxTexSizeY + ")"); | |
6997ff1c | 2740 | aFBOVPSize.x() = Min (aFBOVPSize.x(), aMaxTexSizeX); |
2741 | aFBOVPSize.y() = Min (aFBOVPSize.y(), aMaxTexSizeY); | |
3bffef55 | 2742 | isTiling = true; |
2743 | } | |
2744 | ||
2745 | // Try to create hardware accelerated buffer | |
2746 | aFBOPtr = myView->FBOCreate (aFBOVPSize.x(), aFBOVPSize.y()); | |
7fd59977 | 2747 | } |
c357e426 | 2748 | myView->SetFBO (aFBOPtr); |
7fd59977 | 2749 | |
b128c892 | 2750 | if (aFBOPtr.IsNull()) |
7fd59977 | 2751 | { |
3bffef55 | 2752 | // try to use on-screen buffer |
2753 | Graphic3d_Vec2i aWinSize; | |
2754 | MyWindow->Size (aWinSize.x(), aWinSize.y()); | |
2755 | if (aFBOVPSize.x() != aWinSize.x() | |
2756 | || aFBOVPSize.y() != aWinSize.y()) | |
7fd59977 | 2757 | { |
3bffef55 | 2758 | isTiling = true; |
7fd59977 | 2759 | } |
3bffef55 | 2760 | aFBOVPSize = aWinSize; |
2761 | ||
a87b1b37 | 2762 | Message::SendWarning ("Warning, on screen buffer is used for image dump - content might be invalid"); |
7fd59977 | 2763 | } |
2764 | ||
3bffef55 | 2765 | // backup camera parameters |
b5ac8292 | 2766 | Handle(Graphic3d_Camera) aStoreMapping = new Graphic3d_Camera(); |
c357e426 | 2767 | Handle(Graphic3d_Camera) aCamera = Camera(); |
c357e426 | 2768 | aStoreMapping->Copy (aCamera); |
c357e426 | 2769 | if (aCamera->IsStereo()) |
b5ac8292 | 2770 | { |
3bffef55 | 2771 | switch (theParams.StereoOptions) |
b5ac8292 | 2772 | { |
f978241f | 2773 | case V3d_SDO_MONO: |
2774 | { | |
c357e426 | 2775 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective); |
b5ac8292 | 2776 | break; |
f978241f | 2777 | } |
2778 | case V3d_SDO_LEFT_EYE: | |
2779 | { | |
c357e426 | 2780 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye); |
b5ac8292 | 2781 | break; |
f978241f | 2782 | } |
2783 | case V3d_SDO_RIGHT_EYE: | |
2784 | { | |
c357e426 | 2785 | aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye); |
b5ac8292 | 2786 | break; |
f978241f | 2787 | } |
2788 | case V3d_SDO_BLENDED: | |
2789 | { | |
2790 | break; // dump as is | |
2791 | } | |
b5ac8292 | 2792 | } |
2793 | } | |
3bffef55 | 2794 | if (theParams.ToAdjustAspect) |
197ac94e | 2795 | { |
3bffef55 | 2796 | aCamera->SetAspect (Standard_Real(aTargetSize.x()) / Standard_Real(aTargetSize.y())); |
7fd59977 | 2797 | } |
2798 | ||
3bffef55 | 2799 | // render immediate structures into back buffer rather than front |
2800 | const Standard_Boolean aPrevImmediateMode = myView->SetImmediateModeDrawToFront (Standard_False); | |
7fd59977 | 2801 | |
692613e5 | 2802 | Standard_Boolean isSuccess = Standard_True; |
3bffef55 | 2803 | if (!isTiling) |
7fd59977 | 2804 | { |
3bffef55 | 2805 | if (!aFBOPtr.IsNull()) |
692613e5 | 2806 | { |
3bffef55 | 2807 | myView->FBOChangeViewport (aFBOPtr, aTargetSize.x(), aTargetSize.y()); |
692613e5 | 2808 | } |
3bffef55 | 2809 | Redraw(); |
2810 | isSuccess = isSuccess && myView->BufferDump (theImage, theParams.BufferType); | |
2811 | } | |
2812 | else | |
2813 | { | |
2814 | Image_PixMap aTilePixMap; | |
2815 | aTilePixMap.SetTopDown (theImage.IsTopDown()); | |
692613e5 | 2816 | |
3bffef55 | 2817 | Graphic3d_Vec2i anOffset (0, 0); |
2818 | for (; anOffset.y() < aTargetSize.y(); anOffset.y() += aFBOVPSize.y()) | |
2819 | { | |
2820 | anOffset.x() = 0; | |
2821 | for (; anOffset.x() < aTargetSize.x(); anOffset.x() += aFBOVPSize.x()) | |
2822 | { | |
c8fe0e2d | 2823 | Graphic3d_CameraTile aTileUncropped; |
2824 | aTileUncropped.Offset = anOffset; | |
2825 | aTileUncropped.TotalSize = aTargetSize; | |
2826 | aTileUncropped.TileSize = aFBOVPSize; | |
2827 | const Graphic3d_CameraTile aTile = aTileUncropped.Cropped(); | |
3bffef55 | 2828 | if (aTile.TileSize.x() < 1 |
2829 | || aTile.TileSize.y() < 1) | |
2830 | { | |
2831 | continue; | |
2832 | } | |
2833 | ||
2834 | const Standard_Integer aLeft = aTile.Offset.x(); | |
2835 | Standard_Integer aBottom = aTile.Offset.y(); | |
2836 | if (theImage.IsTopDown()) | |
2837 | { | |
2838 | const Standard_Integer aTop = aTile.Offset.y() + aTile.TileSize.y(); | |
2839 | aBottom = aTargetSize.y() - aTop; | |
2840 | } | |
2841 | aTilePixMap.InitWrapper (theImage.Format(), theImage.ChangeData() | |
2842 | + theImage.SizeRowBytes() * aBottom + theImage.SizePixelBytes() * aLeft, | |
2843 | aTile.TileSize.x(), aTile.TileSize.y(), | |
2844 | theImage.SizeRowBytes()); | |
2845 | ||
3bffef55 | 2846 | if (!aFBOPtr.IsNull()) |
2847 | { | |
c8fe0e2d | 2848 | aCamera->SetTile (aTile); |
3bffef55 | 2849 | myView->FBOChangeViewport (aFBOPtr, aTile.TileSize.x(), aTile.TileSize.y()); |
2850 | } | |
c8fe0e2d | 2851 | else |
2852 | { | |
2853 | // no API to resize viewport of on-screen buffer - render uncropped | |
2854 | aCamera->SetTile (aTileUncropped); | |
2855 | } | |
3bffef55 | 2856 | Redraw(); |
2857 | isSuccess = isSuccess && myView->BufferDump (aTilePixMap, theParams.BufferType); | |
2858 | if (!isSuccess) | |
2859 | { | |
2860 | break; | |
2861 | } | |
2862 | } | |
2863 | if (!isSuccess) | |
2864 | { | |
2865 | break; | |
2866 | } | |
2867 | } | |
7fd59977 | 2868 | } |
2869 | ||
3bffef55 | 2870 | // restore state |
2871 | myView->SetImmediateModeDrawToFront (aPrevImmediateMode); | |
2872 | aCamera->Copy (aStoreMapping); | |
7fd59977 | 2873 | if (aFBOPtr != aPrevFBOPtr) |
2874 | { | |
c357e426 | 2875 | myView->FBORelease (aFBOPtr); |
7fd59977 | 2876 | } |
b128c892 | 2877 | else if (!aPrevFBOPtr.IsNull()) |
7fd59977 | 2878 | { |
3bffef55 | 2879 | myView->FBOChangeViewport (aPrevFBOPtr, aPrevFBOVPSize.x(), aPrevFBOVPSize.y()); |
7fd59977 | 2880 | } |
c357e426 | 2881 | myView->SetFBO (aPrevFBOPtr); |
692613e5 | 2882 | return isSuccess; |
7fd59977 | 2883 | } |
6942f04a | 2884 | |
c357e426 | 2885 | //============================================================================= |
2886 | //function : ImmediateUpdate | |
2887 | //purpose : | |
2888 | //============================================================================= | |
6942f04a | 2889 | void V3d_View::ImmediateUpdate() const |
2890 | { | |
c357e426 | 2891 | if (myImmediateUpdate) |
2892 | { | |
2893 | Update(); | |
2894 | } | |
6942f04a | 2895 | } |
2896 | ||
c357e426 | 2897 | //============================================================================= |
2898 | //function : SetImmediateUpdate | |
2899 | //purpose : | |
2900 | //============================================================================= | |
6942f04a | 2901 | Standard_Boolean V3d_View::SetImmediateUpdate (const Standard_Boolean theImmediateUpdate) |
2902 | { | |
2903 | Standard_Boolean aPreviousMode = myImmediateUpdate; | |
2904 | myImmediateUpdate = theImmediateUpdate; | |
2905 | return aPreviousMode; | |
2906 | } | |
b5ac8292 | 2907 | |
2908 | // ======================================================================= | |
2909 | // function : SetCamera | |
2910 | // purpose : | |
2911 | // ======================================================================= | |
2912 | void V3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera) | |
2913 | { | |
c357e426 | 2914 | myView->SetCamera (theCamera); |
197ac94e | 2915 | |
c357e426 | 2916 | ImmediateUpdate(); |
b5ac8292 | 2917 | } |
2918 | ||
2919 | // ======================================================================= | |
2920 | // function : GetCamera | |
2921 | // purpose : | |
2922 | // ======================================================================= | |
197ac94e | 2923 | const Handle(Graphic3d_Camera)& V3d_View::Camera() const |
b5ac8292 | 2924 | { |
c357e426 | 2925 | return myView->Camera(); |
b5ac8292 | 2926 | } |
2927 | ||
2928 | // ======================================================================= | |
197ac94e | 2929 | // function : FitMinMax |
2930 | // purpose : Internal | |
b5ac8292 | 2931 | // ======================================================================= |
197ac94e | 2932 | Standard_Boolean V3d_View::FitMinMax (const Handle(Graphic3d_Camera)& theCamera, |
ed063270 | 2933 | const Bnd_Box& theBox, |
197ac94e | 2934 | const Standard_Real theMargin, |
2935 | const Standard_Real theResolution, | |
2936 | const Standard_Boolean theToEnlargeIfLine) const | |
2937 | { | |
f3a53980 | 2938 | if (!theCamera->FitMinMax (theBox, theResolution, theToEnlargeIfLine)) |
b5ac8292 | 2939 | { |
197ac94e | 2940 | return Standard_False; // bounding box is out of bounds... |
2941 | } | |
2942 | ||
50d06d8f | 2943 | const Standard_Real aZoomCoef = myView->ConsiderZoomPersistenceObjects(); |
50d06d8f | 2944 | Scale (theCamera, theCamera->ViewDimensions().X() * (aZoomCoef + theMargin), theCamera->ViewDimensions().Y() * (aZoomCoef + theMargin)); |
197ac94e | 2945 | return Standard_True; |
b5ac8292 | 2946 | } |
2947 | ||
2948 | // ======================================================================= | |
197ac94e | 2949 | // function : Scale |
2950 | // purpose : Internal | |
b5ac8292 | 2951 | // ======================================================================= |
197ac94e | 2952 | void V3d_View::Scale (const Handle(Graphic3d_Camera)& theCamera, |
2953 | const Standard_Real theSizeXv, | |
2954 | const Standard_Real theSizeYv) const | |
b5ac8292 | 2955 | { |
197ac94e | 2956 | Standard_Real anAspect = theCamera->Aspect(); |
ab1c121b | 2957 | if (anAspect > 1.0) |
2958 | { | |
2959 | theCamera->SetScale (Max (theSizeXv / anAspect, theSizeYv)); | |
2960 | } | |
2961 | else | |
2962 | { | |
2963 | theCamera->SetScale (Max (theSizeXv, theSizeYv * anAspect)); | |
2964 | } | |
b5ac8292 | 2965 | } |
2966 | ||
2967 | // ======================================================================= | |
197ac94e | 2968 | // function : Translate |
2969 | // purpose : Internal | |
b5ac8292 | 2970 | // ======================================================================= |
197ac94e | 2971 | void V3d_View::Translate (const Handle(Graphic3d_Camera)& theCamera, |
2972 | const Standard_Real theDXv, | |
2973 | const Standard_Real theDYv) const | |
2974 | { | |
2975 | const gp_Pnt& aCenter = theCamera->Center(); | |
2976 | const gp_Dir& aDir = theCamera->Direction(); | |
2977 | const gp_Dir& anUp = theCamera->Up(); | |
2978 | gp_Ax3 aCameraCS (aCenter, aDir.Reversed(), aDir ^ anUp); | |
2979 | ||
2980 | gp_Vec aCameraPanXv = gp_Vec (aCameraCS.XDirection()) * theDXv; | |
2981 | gp_Vec aCameraPanYv = gp_Vec (aCameraCS.YDirection()) * theDYv; | |
2982 | gp_Vec aCameraPan = aCameraPanXv + aCameraPanYv; | |
2983 | gp_Trsf aPanTrsf; | |
2984 | aPanTrsf.SetTranslation (aCameraPan); | |
2985 | ||
2986 | theCamera->Transform (aPanTrsf); | |
b5ac8292 | 2987 | } |
b7cd4ba7 | 2988 | |
2989 | // ======================================================================= | |
26d9c835 | 2990 | // function : DiagnosticInformation |
2991 | // purpose : | |
2992 | // ======================================================================= | |
2993 | void V3d_View::DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict, | |
2994 | Graphic3d_DiagnosticInfo theFlags) const | |
2995 | { | |
2996 | myView->DiagnosticInformation (theDict, theFlags); | |
2997 | } | |
ebc369da | 2998 | |
79b544e6 | 2999 | //======================================================================= |
3000 | //function : StatisticInformation | |
3001 | //purpose : | |
3002 | //======================================================================= | |
3003 | void V3d_View::StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const | |
3004 | { | |
3005 | myView->StatisticInformation (theDict); | |
3006 | } | |
3007 | ||
3008 | // ======================================================================= | |
3009 | // function : StatisticInformation | |
3010 | // purpose : | |
3011 | // ======================================================================= | |
3012 | TCollection_AsciiString V3d_View::StatisticInformation() const | |
3013 | { | |
3014 | return myView->StatisticInformation(); | |
3015 | } | |
3016 | ||
ebc369da | 3017 | //============================================================================= |
3018 | //function : RenderingParams | |
3019 | //purpose : | |
3020 | //============================================================================= | |
3021 | const Graphic3d_RenderingParams& V3d_View::RenderingParams() const | |
3022 | { | |
3023 | return myView->RenderingParams(); | |
3024 | } | |
3025 | ||
3026 | //============================================================================= | |
3027 | //function : ChangeRenderingParams | |
3028 | //purpose : | |
3029 | //============================================================================= | |
3030 | Graphic3d_RenderingParams& V3d_View::ChangeRenderingParams() | |
3031 | { | |
3032 | return myView->ChangeRenderingParams(); | |
3033 | } | |
a5162275 | 3034 | |
478862fc | 3035 | |
3036 | //============================================================================= | |
3037 | //function : SetLightOn | |
3038 | //purpose : | |
3039 | //============================================================================= | |
3040 | void V3d_View::SetLightOn (const Handle(V3d_Light)& theLight) | |
3041 | { | |
3042 | if (!myActiveLights.Contains (theLight)) | |
3043 | { | |
3044 | myActiveLights.Append (theLight); | |
3045 | UpdateLights(); | |
3046 | } | |
3047 | } | |
3048 | ||
3049 | //============================================================================= | |
3050 | //function : SetLightOff | |
3051 | //purpose : | |
3052 | //============================================================================= | |
3053 | void V3d_View::SetLightOff (const Handle(V3d_Light)& theLight) | |
3054 | { | |
3055 | if (MyViewer->IsGlobalLight (theLight)) | |
3056 | throw Standard_TypeMismatch("V3d_View::SetLightOff, the light is global"); | |
3057 | myActiveLights.Remove (theLight); | |
3058 | UpdateLights(); | |
3059 | } | |
3060 | ||
3061 | //============================================================================= | |
3062 | //function : IsActiveLight | |
3063 | //purpose : | |
3064 | //============================================================================= | |
3065 | Standard_Boolean V3d_View::IsActiveLight (const Handle(V3d_Light)& theLight) const | |
3066 | { | |
3067 | return !theLight.IsNull() | |
3068 | && myActiveLights.Contains (theLight); | |
3069 | } | |
3070 | ||
3071 | //============================================================================= | |
3072 | //function : SetLightOn | |
3073 | //purpose : | |
3074 | //============================================================================= | |
3075 | void V3d_View::SetLightOn() | |
3076 | { | |
3077 | for (V3d_ListOfLightIterator aDefLightIter (MyViewer->DefinedLightIterator()); aDefLightIter.More(); aDefLightIter.Next()) | |
3078 | { | |
3079 | if (!myActiveLights.Contains (aDefLightIter.Value())) | |
3080 | { | |
3081 | myActiveLights.Append (aDefLightIter.Value()); | |
3082 | } | |
3083 | } | |
3084 | UpdateLights(); | |
3085 | } | |
3086 | ||
3087 | //============================================================================= | |
3088 | //function : SetLightOff | |
3089 | //purpose : | |
3090 | //============================================================================= | |
3091 | void V3d_View::SetLightOff() | |
3092 | { | |
3093 | for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More();) | |
3094 | { | |
3095 | if (!MyViewer->IsGlobalLight (anActiveLightIter.Value())) | |
3096 | { | |
3097 | myActiveLights.Remove (anActiveLightIter); | |
3098 | } | |
3099 | else | |
3100 | { | |
3101 | anActiveLightIter.Next(); | |
3102 | } | |
3103 | } | |
3104 | UpdateLights(); | |
3105 | } | |
3106 | ||
3107 | //============================================================================= | |
3108 | //function : IfMoreLights | |
3109 | //purpose : | |
3110 | //============================================================================= | |
3111 | Standard_Boolean V3d_View::IfMoreLights() const | |
3112 | { | |
3113 | return myActiveLights.Extent() < LightLimit(); | |
3114 | } | |
3115 | ||
3116 | //======================================================================= | |
3117 | //function : LightLimit | |
3118 | //purpose : | |
3119 | //======================================================================= | |
3120 | Standard_Integer V3d_View::LightLimit() const | |
3121 | { | |
3122 | return Viewer()->Driver()->InquireLightLimit(); | |
3123 | } | |
3124 | ||
3125 | //======================================================================= | |
3126 | //function : AddClipPlane | |
3127 | //purpose : | |
3128 | //======================================================================= | |
3129 | void V3d_View::AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane) | |
3130 | { | |
3131 | Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes(); | |
3132 | if (aSeqOfPlanes.IsNull()) | |
3133 | { | |
3134 | aSeqOfPlanes = new Graphic3d_SequenceOfHClipPlane(); | |
3135 | } | |
3136 | else | |
3137 | { | |
3138 | for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next()) | |
3139 | { | |
3140 | const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value(); | |
3141 | if (aPlane == thePlane) | |
3142 | { | |
3143 | // plane is already defined in view | |
3144 | return; | |
3145 | } | |
3146 | } | |
3147 | } | |
3148 | ||
3149 | aSeqOfPlanes->Append (thePlane); | |
3150 | SetClipPlanes (aSeqOfPlanes); | |
3151 | } | |
3152 | ||
3153 | //======================================================================= | |
3154 | //function : RemoveClipPlane | |
3155 | //purpose : | |
3156 | //======================================================================= | |
3157 | void V3d_View::RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane) | |
3158 | { | |
3159 | Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes(); | |
3160 | if (aSeqOfPlanes.IsNull()) | |
3161 | { | |
3162 | return; | |
3163 | } | |
3164 | ||
3165 | for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next()) | |
3166 | { | |
3167 | const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value(); | |
3168 | if (aPlane != thePlane) | |
3169 | { | |
3170 | continue; | |
3171 | } | |
3172 | ||
3173 | aSeqOfPlanes->Remove (aPlaneIt); | |
3174 | SetClipPlanes (aSeqOfPlanes); | |
3175 | return; | |
3176 | } | |
3177 | } | |
3178 | ||
3179 | //======================================================================= | |
3180 | //function : SetClipPlanes | |
3181 | //purpose : | |
3182 | //======================================================================= | |
3183 | void V3d_View::SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) | |
3184 | { | |
3185 | myView->SetClipPlanes (thePlanes); | |
3186 | } | |
3187 | ||
3188 | //======================================================================= | |
3189 | //function : ClipPlanes | |
3190 | //purpose : | |
3191 | //======================================================================= | |
3192 | const Handle(Graphic3d_SequenceOfHClipPlane)& V3d_View::ClipPlanes() const | |
3193 | { | |
3194 | return myView->ClipPlanes(); | |
3195 | } | |
3196 | ||
3197 | //======================================================================= | |
3198 | //function : PlaneLimit | |
3199 | //purpose : | |
3200 | //======================================================================= | |
3201 | Standard_Integer V3d_View::PlaneLimit() const | |
3202 | { | |
3203 | return Viewer()->Driver()->InquirePlaneLimit(); | |
3204 | } | |
3205 | ||
3206 | //============================================================================= | |
3207 | //function : Move | |
3208 | //purpose : | |
3209 | //============================================================================= | |
3210 | void V3d_View::Move (const Standard_Real theDx, | |
3211 | const Standard_Real theDy, | |
3212 | const Standard_Real theDz, | |
3213 | const Standard_Boolean theStart) | |
3214 | { | |
3215 | Handle(Graphic3d_Camera) aCamera = Camera(); | |
3216 | if (theStart) | |
3217 | { | |
3218 | myCamStartOpEye = aCamera->Eye(); | |
3219 | ||
3220 | gp_Dir aReferencePlane (aCamera->Direction().Reversed()); | |
3221 | gp_Dir anUp (aCamera->Up()); | |
3222 | if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis)) | |
3223 | { | |
3224 | throw V3d_BadValue ("V3d_View::Translate, alignment of Eye,At,Up"); | |
3225 | } | |
3226 | } | |
3227 | ||
3228 | Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ; | |
3229 | myXscreenAxis.Coord (XX,XY,XZ); | |
3230 | myYscreenAxis.Coord (YX,YY,YZ); | |
3231 | myZscreenAxis.Coord (ZX,ZY,ZZ); | |
3232 | ||
3233 | aCamera->SetEye (myCamStartOpEye); | |
3234 | ||
3235 | aCamera->SetEye (aCamera->Eye().XYZ() | |
3236 | + theDx * gp_Pnt (XX, XY, XZ).XYZ() | |
3237 | + theDy * gp_Pnt (YX, YY, YZ).XYZ() | |
3238 | + theDz * gp_Pnt (ZX, ZY, ZZ).XYZ() | |
3239 | ); | |
3240 | ||
3241 | ImmediateUpdate(); | |
3242 | } | |
3243 | ||
3244 | //============================================================================= | |
3245 | //function : Move | |
3246 | //purpose : | |
3247 | //============================================================================= | |
3248 | void V3d_View::Move (const Standard_Real theLength, const Standard_Boolean theStart) | |
3249 | { | |
3250 | Handle(Graphic3d_Camera) aCamera = Camera(); | |
3251 | if (theStart) | |
3252 | { | |
3253 | myCamStartOpEye = aCamera->Eye(); | |
3254 | } | |
3255 | aCamera->SetEye (myCamStartOpEye); | |
3256 | aCamera->SetEye (aCamera->Eye().XYZ() + theLength * myDefaultViewAxis.XYZ()); | |
3257 | ||
3258 | ImmediateUpdate(); | |
3259 | } | |
3260 | ||
3261 | //============================================================================= | |
3262 | //function : Move | |
3263 | //purpose : | |
3264 | //============================================================================= | |
3265 | void V3d_View::Move (const V3d_TypeOfAxe theAxe, | |
3266 | const Standard_Real theLength, | |
3267 | const Standard_Boolean theStart) | |
3268 | { | |
3269 | switch (theAxe) | |
3270 | { | |
3271 | case V3d_X: | |
3272 | Move (theLength,0.,0.,theStart); | |
3273 | break; | |
3274 | case V3d_Y: | |
3275 | Move (0.,theLength,0.,theStart); | |
3276 | break; | |
3277 | case V3d_Z: | |
3278 | Move (0.,0.,theLength,theStart); | |
3279 | break; | |
3280 | } | |
3281 | } | |
3282 | ||
3283 | //============================================================================= | |
3284 | //function : Translate | |
3285 | //purpose : | |
3286 | //============================================================================= | |
3287 | void V3d_View::Translate (const Standard_Real theDx, | |
3288 | const Standard_Real theDy, | |
3289 | const Standard_Real theDz, | |
3290 | const Standard_Boolean theStart) | |
3291 | { | |
3292 | Handle(Graphic3d_Camera) aCamera = Camera(); | |
3293 | if (theStart) | |
3294 | { | |
3295 | myCamStartOpEye = aCamera->Eye(); | |
3296 | myCamStartOpCenter = aCamera->Center(); | |
3297 | ||
3298 | gp_Dir aReferencePlane (aCamera->Direction().Reversed()); | |
3299 | gp_Dir anUp (aCamera->Up()); | |
3300 | if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis)) | |
3301 | { | |
3302 | throw V3d_BadValue ("V3d_View::Translate, alignment of Eye,At,Up"); | |
3303 | } | |
3304 | } | |
3305 | ||
3306 | aCamera->SetEye (myCamStartOpEye); | |
3307 | aCamera->SetCenter (myCamStartOpCenter); | |
3308 | ||
3309 | aCamera->SetCenter (aCamera->Center().XYZ() | |
3310 | - theDx * myXscreenAxis.XYZ() | |
3311 | - theDy * myYscreenAxis.XYZ() | |
3312 | - theDz * myZscreenAxis.XYZ() | |
3313 | ); | |
3314 | ||
3315 | aCamera->SetEye (aCamera->Eye().XYZ() | |
3316 | - theDx * myXscreenAxis.XYZ() | |
3317 | - theDy * myYscreenAxis.XYZ() | |
3318 | - theDz * myZscreenAxis.XYZ() | |
3319 | ); | |
3320 | ||
3321 | ImmediateUpdate(); | |
3322 | } | |
3323 | ||
3324 | //============================================================================= | |
3325 | //function : Translate | |
3326 | //purpose : | |
3327 | //============================================================================= | |
3328 | void V3d_View::Translate (const V3d_TypeOfAxe theAxe, const Standard_Real theLength,const Standard_Boolean theStart) | |
3329 | { | |
3330 | switch (theAxe) | |
3331 | { | |
3332 | case V3d_X: | |
3333 | Translate (theLength,0.,0., theStart); | |
3334 | break; | |
3335 | case V3d_Y: | |
3336 | Translate (0.,theLength,0., theStart); | |
3337 | break; | |
3338 | case V3d_Z: | |
3339 | Translate (0.,0.,theLength, theStart); | |
3340 | break; | |
3341 | } | |
3342 | } | |
3343 | ||
3344 | //======================================================================= | |
3345 | //function : Place | |
3346 | //purpose : | |
3347 | //======================================================================= | |
3348 | void V3d_View::Place (const Standard_Integer theXp, | |
3349 | const Standard_Integer theYp, | |
3350 | const Standard_Real theZoomFactor) | |
3351 | { | |
3352 | Standard_Integer aWinWidth = 0; | |
3353 | Standard_Integer aWinHeight = 0; | |
3354 | View()->Window()->Size (aWinWidth, aWinHeight); | |
3355 | ||
3356 | Standard_Integer aWinCXp = aWinWidth / 2; | |
3357 | Standard_Integer aWinCYp = aWinHeight / 2; | |
3358 | Pan (aWinCXp - theXp, -(aWinCYp - theYp), theZoomFactor / Scale()); | |
3359 | } | |
3360 | ||
3361 | //======================================================================= | |
3362 | //function : Translate | |
3363 | //purpose : | |
3364 | //======================================================================= | |
3365 | void V3d_View::Translate (const Standard_Real theLength, const Standard_Boolean theStart) | |
3366 | { | |
3367 | Handle(Graphic3d_Camera) aCamera = Camera(); | |
3368 | if (theStart) | |
3369 | { | |
3370 | myCamStartOpCenter = aCamera->Center() ; | |
3371 | } | |
3372 | ||
3373 | gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - myDefaultViewAxis.XYZ() * theLength); | |
3374 | aCamera->SetCenter (aNewCenter); | |
3375 | ||
3376 | ImmediateUpdate(); | |
3377 | } | |
3378 | ||
3379 | //============================================================================= | |
3380 | //function : SetGrid | |
3381 | //purpose : | |
3382 | //============================================================================= | |
3383 | void V3d_View::SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid) | |
3384 | { | |
3385 | MyPlane = aPlane; | |
3386 | MyGrid = aGrid; | |
3387 | ||
3388 | Standard_Real xl, yl, zl; | |
3389 | Standard_Real xdx, xdy, xdz; | |
3390 | Standard_Real ydx, ydy, ydz; | |
3391 | Standard_Real dx, dy, dz; | |
3392 | aPlane.Location ().Coord (xl, yl, zl); | |
3393 | aPlane.XDirection ().Coord (xdx, xdy, xdz); | |
3394 | aPlane.YDirection ().Coord (ydx, ydy, ydz); | |
3395 | aPlane.Direction ().Coord (dx, dy, dz); | |
3396 | ||
3397 | Standard_Real CosAlpha = Cos (MyGrid->RotationAngle ()); | |
3398 | Standard_Real SinAlpha = Sin (MyGrid->RotationAngle ()); | |
3399 | ||
3400 | TColStd_Array2OfReal Trsf1 (1, 4, 1, 4); | |
3401 | Trsf1 (4, 4) = 1.0; | |
3402 | Trsf1 (4, 1) = Trsf1 (4, 2) = Trsf1 (4, 3) = 0.0; | |
3403 | // Translation | |
3404 | Trsf1 (1, 4) = xl, | |
3405 | Trsf1 (2, 4) = yl, | |
3406 | Trsf1 (3, 4) = zl; | |
3407 | // Transformation change of marker | |
3408 | Trsf1 (1, 1) = xdx, | |
3409 | Trsf1 (2, 1) = xdy, | |
3410 | Trsf1 (3, 1) = xdz, | |
3411 | Trsf1 (1, 2) = ydx, | |
3412 | Trsf1 (2, 2) = ydy, | |
3413 | Trsf1 (3, 2) = ydz, | |
3414 | Trsf1 (1, 3) = dx, | |
3415 | Trsf1 (2, 3) = dy, | |
3416 | Trsf1 (3, 3) = dz; | |
3417 | ||
3418 | TColStd_Array2OfReal Trsf2 (1, 4, 1, 4); | |
3419 | Trsf2 (4, 4) = 1.0; | |
3420 | Trsf2 (4, 1) = Trsf2 (4, 2) = Trsf2 (4, 3) = 0.0; | |
3421 | // Translation of the origin | |
3422 | Trsf2 (1, 4) = -MyGrid->XOrigin (), | |
3423 | Trsf2 (2, 4) = -MyGrid->YOrigin (), | |
3424 | Trsf2 (3, 4) = 0.0; | |
3425 | // Rotation Alpha around axis -Z | |
3426 | Trsf2 (1, 1) = CosAlpha, | |
3427 | Trsf2 (2, 1) = -SinAlpha, | |
3428 | Trsf2 (3, 1) = 0.0, | |
3429 | Trsf2 (1, 2) = SinAlpha, | |
3430 | Trsf2 (2, 2) = CosAlpha, | |
3431 | Trsf2 (3, 2) = 0.0, | |
3432 | Trsf2 (1, 3) = 0.0, | |
3433 | Trsf2 (2, 3) = 0.0, | |
3434 | Trsf2 (3, 3) = 1.0; | |
3435 | ||
3436 | Standard_Real valuetrsf; | |
3437 | Standard_Real valueoldtrsf; | |
3438 | Standard_Real valuenewtrsf; | |
3439 | Standard_Integer i, j, k; | |
3440 | // Calculation of the product of matrices | |
3441 | for (i=1; i<=4; i++) | |
3442 | for (j=1; j<=4; j++) { | |
3443 | MyTrsf (i, j) = 0.0; | |
3444 | for (k=1; k<=4; k++) { | |
3445 | valueoldtrsf = Trsf1 (i, k); | |
3446 | valuetrsf = Trsf2 (k, j); | |
3447 | valuenewtrsf = MyTrsf (i, j) + valueoldtrsf * valuetrsf; | |
3448 | MyTrsf (i, j) = valuenewtrsf; | |
3449 | } | |
3450 | } | |
3451 | } | |
3452 | ||
3453 | //============================================================================= | |
3454 | //function : SetGridActivity | |
3455 | //purpose : | |
3456 | //============================================================================= | |
3457 | void V3d_View::SetGridActivity (const Standard_Boolean AFlag) | |
3458 | { | |
3459 | if (AFlag) MyGrid->Activate (); | |
3460 | else MyGrid->Deactivate (); | |
3461 | } | |
3462 | ||
3463 | //============================================================================= | |
3464 | //function : toPolarCoords | |
3465 | //purpose : | |
3466 | //============================================================================= | |
3467 | void toPolarCoords (const Standard_Real theX, const Standard_Real theY, | |
3468 | Standard_Real& theR, Standard_Real& thePhi) | |
3469 | { | |
3470 | theR = Sqrt (theX * theX + theY * theY); | |
3471 | thePhi = ATan2 (theY, theX); | |
3472 | } | |
3473 | ||
3474 | //============================================================================= | |
3475 | //function : toCartesianCoords | |
3476 | //purpose : | |
3477 | //============================================================================= | |
3478 | void toCartesianCoords (const Standard_Real theR, const Standard_Real thePhi, | |
3479 | Standard_Real& theX, Standard_Real& theY) | |
3480 | { | |
3481 | theX = theR * Cos (thePhi); | |
3482 | theY = theR * Sin (thePhi); | |
3483 | } | |
3484 | ||
3485 | //============================================================================= | |
3486 | //function : Compute | |
3487 | //purpose : | |
3488 | //============================================================================= | |
3489 | Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex& theVertex) const | |
3490 | { | |
3491 | const Handle(Graphic3d_Camera)& aCamera = Camera(); | |
3492 | gp_Dir VPN = aCamera->Direction().Reversed(); // RefPlane | |
3493 | gp_Dir GPN = MyPlane.Direction(); | |
3494 | ||
3495 | Standard_Real XPp = 0.0, YPp = 0.0; | |
3496 | Project (theVertex.X(), theVertex.Y(), theVertex.Z(), XPp, YPp); | |
3497 | ||
3498 | // Casw when the plane of the grid and the plane of the view | |
3499 | // are perpendicular to MYEPSILON2 close radians | |
3500 | #define MYEPSILON2 M_PI / 180.0 // Delta between 2 angles | |
3501 | if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2) | |
3502 | { | |
3503 | return theVertex; | |
3504 | } | |
3505 | ||
3506 | const gp_XYZ aPnt0 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 0.0, 0.0), MyTrsf); | |
3507 | ||
3508 | // get grid axes in world space | |
3509 | const gp_XYZ aPnt1 = V3d_View::TrsPoint (Graphic3d_Vertex (1.0, 0.0, 0.0), MyTrsf); | |
3510 | gp_Vec aGridX (aPnt0, aPnt1); | |
3511 | aGridX.Normalize(); | |
3512 | ||
3513 | const gp_XYZ aPnt2 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 1.0, 0.0), MyTrsf); | |
3514 | gp_Vec aGridY (aPnt0, aPnt2); | |
3515 | aGridY.Normalize(); | |
3516 | ||
3517 | // project ray from camera onto grid plane | |
3518 | const gp_Vec aProjection = aCamera->IsOrthographic() | |
3519 | ? gp_Vec (aCamera->Direction()) | |
3520 | : gp_Vec (aCamera->Eye(), gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z())).Normalized(); | |
3521 | const gp_Vec aPointOrigin = gp_Vec (gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z()), aPnt0); | |
3522 | const Standard_Real aT = aPointOrigin.Dot (MyPlane.Direction()) / aProjection.Dot (MyPlane.Direction()); | |
3523 | const gp_XYZ aPointOnPlane = gp_XYZ (theVertex.X(), theVertex.Y(), theVertex.Z()) + aProjection.XYZ() * aT; | |
3524 | ||
3525 | if (Handle(Aspect_RectangularGrid) aRectGrid = Handle(Aspect_RectangularGrid)::DownCast (MyGrid)) | |
3526 | { | |
3527 | // project point on plane to grid local space | |
3528 | const gp_Vec aToPoint (aPnt0, aPointOnPlane); | |
3529 | const Standard_Real anXSteps = Round (aGridX.Dot (aToPoint) / aRectGrid->XStep()); | |
3530 | const Standard_Real anYSteps = Round (aGridY.Dot (aToPoint) / aRectGrid->YStep()); | |
3531 | ||
3532 | // clamp point to grid | |
3533 | const gp_Vec aResult = aGridX * anXSteps * aRectGrid->XStep() | |
3534 | + aGridY * anYSteps * aRectGrid->YStep() | |
3535 | + gp_Vec (aPnt0); | |
3536 | return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z()); | |
3537 | } | |
3538 | else if (Handle(Aspect_CircularGrid) aCircleGrid = Handle(Aspect_CircularGrid)::DownCast (MyGrid)) | |
3539 | { | |
3540 | const Standard_Real anAlpha = M_PI / Standard_Real (aCircleGrid->DivisionNumber()); | |
3541 | ||
3542 | // project point on plane to grid local space | |
3543 | const gp_Vec aToPoint (aPnt0, aPointOnPlane); | |
3544 | Standard_Real aLocalX = aGridX.Dot (aToPoint); | |
3545 | Standard_Real aLocalY = aGridY.Dot (aToPoint); | |
3546 | Standard_Real anR = 0.0, aPhi = 0.0; | |
3547 | toPolarCoords (aLocalX, aLocalY, anR, aPhi); | |
3548 | ||
3549 | // clamp point to grid | |
3550 | const Standard_Real anRSteps = Round (anR / aCircleGrid->RadiusStep()); | |
3551 | const Standard_Real aPhiSteps = Round (aPhi / anAlpha); | |
3552 | toCartesianCoords (anRSteps * aCircleGrid->RadiusStep(), aPhiSteps * anAlpha, aLocalX, aLocalY); | |
3553 | ||
3554 | const gp_Vec aResult = aGridX * aLocalX + aGridY * aLocalY + gp_Vec (aPnt0); | |
3555 | return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z()); | |
3556 | } | |
3557 | return Graphic3d_Vertex (0.0, 0.0, 0.0); | |
3558 | } | |
3559 | ||
3560 | //============================================================================= | |
3561 | //function : ZBufferTriedronSetup | |
3562 | //purpose : | |
3563 | //============================================================================= | |
3564 | void V3d_View::ZBufferTriedronSetup (const Quantity_Color& theXColor, | |
3565 | const Quantity_Color& theYColor, | |
3566 | const Quantity_Color& theZColor, | |
3567 | const Standard_Real theSizeRatio, | |
3568 | const Standard_Real theAxisDiametr, | |
3569 | const Standard_Integer theNbFacettes) | |
3570 | { | |
3571 | const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true); | |
3572 | aTrihedron->SetArrowsColor (theXColor, theYColor, theZColor); | |
3573 | aTrihedron->SetSizeRatio (theSizeRatio); | |
3574 | aTrihedron->SetNbFacets (theNbFacettes); | |
3575 | aTrihedron->SetArrowDiameter (theAxisDiametr); | |
3576 | } | |
3577 | ||
3578 | //============================================================================= | |
3579 | //function : TriedronDisplay | |
3580 | //purpose : | |
3581 | //============================================================================= | |
3582 | void V3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition, | |
3583 | const Quantity_Color& theColor, | |
3584 | const Standard_Real theScale, | |
3585 | const V3d_TypeOfVisualization theMode) | |
3586 | { | |
3587 | const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true); | |
3588 | aTrihedron->SetLabelsColor (theColor); | |
3589 | aTrihedron->SetScale (theScale); | |
3590 | aTrihedron->SetPosition (thePosition); | |
3591 | aTrihedron->SetWireframe (theMode == V3d_WIREFRAME); | |
3592 | ||
3593 | aTrihedron->Display (*this); | |
3594 | } | |
3595 | ||
3596 | //============================================================================= | |
3597 | //function : TriedronErase | |
3598 | //purpose : | |
3599 | //============================================================================= | |
3600 | void V3d_View::TriedronErase() | |
3601 | { | |
3602 | if (!myTrihedron.IsNull()) | |
3603 | { | |
3604 | myTrihedron->Erase(); | |
3605 | } | |
3606 | } | |
3607 | ||
3608 | //============================================================================= | |
3609 | //function : GetGraduatedTrihedron | |
3610 | //purpose : | |
3611 | //============================================================================= | |
3612 | const Graphic3d_GraduatedTrihedron& V3d_View::GetGraduatedTrihedron() const | |
3613 | { | |
3614 | return myView->GetGraduatedTrihedron(); | |
3615 | } | |
3616 | ||
3617 | //============================================================================= | |
3618 | //function : GraduatedTrihedronDisplay | |
3619 | //purpose : | |
3620 | //============================================================================= | |
3621 | void V3d_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData) | |
3622 | { | |
3623 | myView->GraduatedTrihedronDisplay (theTrihedronData); | |
3624 | } | |
3625 | ||
3626 | //============================================================================= | |
3627 | //function : GraduatedTrihedronErase | |
3628 | //purpose : | |
3629 | //============================================================================= | |
3630 | void V3d_View::GraduatedTrihedronErase() | |
3631 | { | |
3632 | myView->GraduatedTrihedronErase(); | |
3633 | } | |
3634 | ||
a5162275 | 3635 | // ======================================================================= |
3636 | // function : DumpJson | |
3637 | // purpose : | |
3638 | // ======================================================================= | |
3639 | void V3d_View::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const | |
3640 | { | |
3641 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) | |
3642 | ||
3643 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOldMouseX) | |
3644 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOldMouseY) | |
3645 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpUp) | |
3646 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpDir) | |
3647 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpEye) | |
3648 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpCenter) | |
3649 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDefaultCamera.get()) | |
3650 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myView.get()) | |
3651 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myImmediateUpdate) | |
3652 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsInvalidatedImmediate) | |
3653 | ||
3654 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, MyViewer) | |
3655 | for (V3d_ListOfLight::Iterator anIterator (myActiveLights); anIterator.More(); anIterator.Next()) | |
3656 | { | |
3657 | class Handle(Graphic3d_CLight)& anActiveLight = anIterator.Value(); | |
3658 | OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, anActiveLight) | |
3659 | } | |
3660 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultViewAxis) | |
3661 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultViewPoint) | |
3662 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyWindow.get()) | |
3663 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, sx) | |
3664 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, sy) | |
3665 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, rx) | |
3666 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, ry) | |
3667 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myRotateGravity) | |
3668 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputedMode) | |
3669 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, SwitchSetFront) | |
3670 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myZRotation) | |
3671 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, MyZoomAtPointX) | |
3672 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, MyZoomAtPointY) | |
3673 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTrihedron.get()) | |
3674 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyGrid.get()) | |
3675 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &MyPlane) | |
3676 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyGridEchoStructure.get()) | |
3677 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyGridEchoGroup.get()) | |
3678 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myXscreenAxis) | |
3679 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myYscreenAxis) | |
3680 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myZscreenAxis) | |
3681 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myViewAxis) | |
3682 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myGravityReferencePoint) | |
3683 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoZFitIsOn) | |
3684 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoZFitScaleFactor) | |
3685 | } |