0023712: Remove dependency on Aspect_GraphicDevice from Aspect_Window
[occt.git] / src / V3d / V3d_View.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18/***********************************************************************
19
20FONCTION :
21----------
22Classe V3d_View :
23
24HISTORIQUE DES MODIFICATIONS :
25--------------------------------
2600-09-92 : GG ; Creation.
2702-10-96 : FMN ; Suppression appel Redraw sans MustBeResized()
2805-06-97 : FMN ; Correction FitAll()
2930-06-97 : GG ; Correction + Optimisation de Panning(...)
30On fait la translation + le zoom en une seule
31operation au lieu de 2 precedemment qui etait buggee.
3209-07-97 : FMN ; Correction FitAll() sur le Ratio
3316-07-97 : FMN ; Correction FitAll() sur le calcul de la Box
3422-07-97 : FMN ; Ajout mode RetainMode pour le Transient
3515-12-97 : FMN ; Ajout texture mapping
3617-12-97 : FMN ; CTS19129 Correction FitAll() multiple
3718-12-97 : FMN ; Ajout mode Ajout
3824-12-97 : FMN ; Remplacement de math par MathGra
3924-12-97 : CQO ; BUC50037 Xw_Window -> Aspect_Window
4031-12-97 : CAL ; Remplacement de MathGra par Array2OfReal
4107-01-98 : CAL ; Ajout de la methode DoMapping.
4207-01-98 : CAL ; Retrait de tous les "this->" inutiles
4321-01-98 : CAL ; Remplacement des Window->Position () par Window->Size ()
4427-01-98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM)
4512-02-98 : GG ; Reactivation du Redraw dans MustBeResized()
4623-02-98 : FMN ; Remplacement PI par Standard_PI
4725-02-98 : FMN ; PERF.27: Optimisation of view creation from existing view
4811-03-98 : STT ; S3558
4919-03-98 : FMN ; Probleme dans FitAll car la methode WNT_Window::Size(Real,Real)
50ne marche pas.
5108-04-98 : STT ; suppr. S3558
5210-04-98 : CAL ; Ajout des methodes RefToPix et PixToRef
5313-06-98 : FMN ; Probleme dans FitAll car la methode WNT_Window::Size(Real,Real)
54ne marche pas. Contournement en appelant WNT_Window::Size(Int,Int).
5516-08-98 : CAL ; S3892. Ajout grilles 3d.
5609-09-98 : CAL ; S3892. Generalisation de TrsPoint.
5724-09-98 : CAL ; Ajout d'un parametre a V3d_View::SetPlotter.
5806-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie.
5916-10-98 : CAL ; Retrait d'un TIMER si CSF_GraphicTimer est definie.
6006-11-98 : CAL ; PRO ?????. Probleme dans ZFitAll si un point dans la vue.
6113-06-98 : FMN ; PRO14896: Correction sur la gestion de la perspective (cf Programming Guinde)
6229-OCT-98 : DCB : Adding ScreenCopy () method.
6322-12-98 : FMN ; Rename CSF_WALKTHROW en CSF_WALKTHROUGH
6410-11-99 : GG ; PRO19603 Add Redraw( area ) method
65IMP130100 : GG
66-> Don't increase too much the ZSize.
67-> Initialize correctly the Z clipping and D cueing
68planes.
69IMP100701 : SZV ; Add ToPixMap() method
70
71REMARQUES :
72-----------
73About FitAll() multiple. This probleme is caused by missing
74precision of transformation matrices. If it is supposed that
75projection is made in the plane (U,V), there is a difference
76after several Zoom - compared to the exact value (cf ZoomX).
77Don't forget that the matrices work in float and not in double.
78To solve the problem (for lack of a better solution) I make 2 passes.
79
80************************************************************************/
81
b8ddfc2f 82//GER61351 //GG_15/12/99 Add SetBackgroundColor() and BackgroundColor() methods
7fd59977 83
84
85#define IMP240100 //GG
86// -> Remove PixToRef() method ,use
87// instead the equivalent Convert() method.
88// -> Rename RefToPix() to Convert() method.
89// -> Remove the grid computation in Convert()
90// method. Use instead the NEW ConvertToGrid() methods.
91// Reason is the Convert() method is call by
92// StdSelect_ViewSelector3d_Pick() from
93// AIS_InteractiveContext() and it's not possible
94// to select an object vertex when the grid is active!
95// -> Remove grid echo marker definition
96// (reported in the viewer)
97// -> Add SetProjModel() methods.
98
99#define G003 //EUG 04-10-99
100// -> computed mode management
101// Add SetComputedMode(..) method
102// -> animation mode management
103// Add SetAnimationMode()
104// -> backfacing management
105// Add SetBackFacingModel() method
106
107#define G004 //VKH 15-11-99
108// -> Add Dump() methods
109// -> GG 07/03/00 Use the new MMSize()
110// method from Aspect_Window class.
111
112#define IMP210200 //GG Add Transparency() method
113
114#define IMP250200 //GG With SetDepth() method, when the requested
115// depth is < 0.,
116// move the view ref point and the eye,instead
117// only the eye.
118
119#define IMP020300 //GG Don't use ZFitAll in during Rotation
120// for perf improvment
121
122#define IMP210600 //GG Avoid to have infinite loop when call Rotation() method
123// without call before StartRotation().
124// This problem occurs when CTRL MB3 is maintain press betwwen 2 views.
125
126#define IMP250900 //GG Enable rotation around screen Z axis when
127// rotation begin far the center of the screen.
128// Thanks to Patrick REGINSTER (SAMTECH)
129// GG 21/12/00 Due to a regression on the previous specifications
130// this new functionnality is right now deactivated
131// by default (see StartRotation(...,zRotationThreshold)
132// method.
133
134#define BUC60952 //GG Enable to rotate around the view axis
135// and the required view point
136
137#define RIC120302 //GG Add a NEW SetWindow method which enable
138// to connect a graphic widget and context to OGL.
139
140#define IMP260302 //GG To avoid conflicting in Window destructor
141// nullify this handle in Remove method
142
143#define OCC280 //SAV fix for FitAll problem in the perspective view.
144
145#define OCC1188 //SAV Added methods to set background image
146
147/*----------------------------------------------------------------------*/
148/*
149* Includes
150*/
151
152#include <Standard_TypeMismatch.hxx>
153#include <Visual3d_ViewManager.hxx>
154#include <Visual3d_Light.hxx>
155#include <Visual3d_ClipPlane.hxx>
156#include <Graphic3d_Structure.hxx>
157#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
158#include <Graphic3d_MapOfStructure.hxx>
159#include <Graphic3d_TextureEnv.hxx>
692613e5 160#include <Image_AlienPixMap.hxx>
7fd59977 161#include <V3d.hxx>
162#include <V3d_View.ixx>
163#include <Viewer_BadValue.hxx>
164#include <Standard_ShortReal.hxx>
165#include <gp_Dir.hxx>
166#include <TColStd_Array2OfReal.hxx>
167#include <Visual3d_TransientManager.hxx>
168#include <Precision.hxx>
169
170// S3892
171#include <Graphic3d_AspectMarker3d.hxx>
1981cb22 172#include <Graphic3d_GraphicDriver.hxx>
7fd59977 173
174// S3603
175#include <Aspect_GenericColorMap.hxx>
176#include <Aspect_TypeMap.hxx>
177#include <Aspect_WidthMap.hxx>
178#include <Aspect_MarkMap.hxx>
179#include <Aspect_FontMap.hxx>
7fd59977 180#include <TColStd_HSequenceOfInteger.hxx>
7fd59977 181
182#ifdef G003
183# define V3d_FLAG_ANIMATION 0x00000001
184# define V3d_FLAG_DEGENERATION 0x00000002
185# define V3d_FLAG_COMPUTATION 0x00000004
186#endif // G003
187
188// Tumble
189#include <OSD_Timer.hxx>
190static OSD_Timer FullTimer;
191
192// Perspective
193#include <OSD_Environment.hxx>
194
195/*----------------------------------------------------------------------*/
196/*
197* Constant
198*/
199
200#define Zmargin 1.
c6541a0c 201#define DEUXPI (2. * M_PI)
7fd59977 202
7fd59977 203/*----------------------------------------------------------------------*/
204/*
205* Local data definitions
206*/
207
208
209static Standard_Real MyXwindowCenter ;
210static Standard_Real MyYwindowCenter ;
211static Standard_Real MyWindowWidth ;
212static Standard_Real MyWindowHeight ;
213
214#define LOPTIM
215#ifndef LOPTIM
216static Graphic3d_Vector MyXscreenAxis ;
217static Graphic3d_Vector MyYscreenAxis ;
218static Graphic3d_Vector MyZscreenAxis ;
219static Graphic3d_Vector MyViewReferencePlane ;
220static Graphic3d_Vector MyViewReferenceUp ;
221static Graphic3d_Vector MyViewAxis ;
222static Graphic3d_Vertex MyViewReferencePoint ;
223static Graphic3d_Vertex MyGravityReferencePoint ;
224static Graphic3d_Vertex MyProjReferencePoint ;
225#else
226static Graphic3d_Vector& _MyXscreenAxis() {
227 static Graphic3d_Vector MyXscreenAxis;
228 return MyXscreenAxis;
229}
230#define MyXscreenAxis _MyXscreenAxis()
231
232static Graphic3d_Vector& _MyYscreenAxis() {
233 static Graphic3d_Vector MyYscreenAxis;
234 return MyYscreenAxis;
235}
236#define MyYscreenAxis _MyYscreenAxis()
237
238static Graphic3d_Vector& _MyZscreenAxis() {
239 static Graphic3d_Vector MyZscreenAxis;
240 return MyZscreenAxis;
241}
242#define MyZscreenAxis _MyZscreenAxis()
243
244static Graphic3d_Vector& _MyViewReferencePlane() {
245 static Graphic3d_Vector MyViewReferencePlane;
246 return MyViewReferencePlane;
247}
248#define MyViewReferencePlane _MyViewReferencePlane()
249
250static Graphic3d_Vector& _MyViewReferenceUp() {
251 static Graphic3d_Vector MyViewReferenceUp;
252 return MyViewReferenceUp;
253}
254#define MyViewReferenceUp _MyViewReferenceUp()
255
256static Graphic3d_Vector& _MyViewAxis() {
257 static Graphic3d_Vector MyViewAxis;
258 return MyViewAxis;
259}
260#define MyViewAxis _MyViewAxis()
261
262static Graphic3d_Vertex& _MyViewReferencePoint() {
263 static Graphic3d_Vertex MyViewReferencePoint;
264 return MyViewReferencePoint;
265}
266#define MyViewReferencePoint _MyViewReferencePoint()
267
268static Graphic3d_Vertex& _MyGravityReferencePoint() {
269 static Graphic3d_Vertex MyGravityReferencePoint;
270 return MyGravityReferencePoint;
271}
272#define MyGravityReferencePoint _MyGravityReferencePoint()
273
274static Graphic3d_Vertex& _MyProjReferencePoint() {
275 static Graphic3d_Vertex MyProjReferencePoint;
276 return MyProjReferencePoint;
277}
278#define MyProjReferencePoint _MyProjReferencePoint()
279#endif // LOPTIM
280
281/*----------------------------------------------------------------------*/
282//-Constructors
283
284V3d_View::V3d_View(const Handle(V3d_Viewer)& VM, const V3d_TypeOfView Type ) :
285MyType ( Type ),
286MyViewer(VM.operator->()),
287MyActiveLights(),
288MyActivePlanes(),
289MyViewContext (),
290myActiveLightsIterator(),
291myActivePlanesIterator(),
292SwitchSetFront(Standard_False),
293MyTrsf (1, 4, 1, 4), // S3892
294MyProjModel(V3d_TPM_SCREEN)
7fd59977 295{
7fd59977 296 myImmediateUpdate = Standard_False;
297 MyView = new Visual3d_View(MyViewer->Viewer());
298
299 // { Begin to retrieve the definition from ViewContext.
300 // Step MyViewContext = MyView->Context() ;
301 // to permit MyView->SetContext to compare
302 // the old and the new context.
303 // No problem for MyViewMapping, MyViewOrientation
304 // as MyView->SetViewMapping and MyView->SetViewOrientation
305 // don't try to optimize the modifications introduced to
306 // viewmapping and vieworientation.
307
308 // Aliasing
309 if ((MyView->Context ()).AliasingIsOn ())
310 MyViewContext.SetAliasingOn ();
311 else
312 MyViewContext.SetAliasingOff ();
313
314 // DepthCueing
315 MyViewContext.SetDepthCueingBackPlane
316 ((MyView->Context ()).DepthCueingBackPlane ());
317 MyViewContext.SetDepthCueingFrontPlane
318 ((MyView->Context ()).DepthCueingFrontPlane ());
319
320 if ((MyView->Context ()).DepthCueingIsOn ())
321 MyViewContext.SetDepthCueingOn ();
322 else
323 MyViewContext.SetDepthCueingOff ();
324
325 // ZClipping
326 MyViewContext.SetZClippingBackPlane
327 ((MyView->Context ()).ZClippingBackPlane ());
328 MyViewContext.SetZClippingFrontPlane
329 ((MyView->Context ()).ZClippingFrontPlane ());
330
331 if ((MyView->Context ()).FrontZClippingIsOn ())
332 MyViewContext.SetFrontZClippingOn ();
333 else
334 MyViewContext.SetFrontZClippingOff ();
335
336 if ((MyView->Context ()).BackZClippingIsOn ())
337 MyViewContext.SetBackZClippingOn ();
338 else
339 MyViewContext.SetBackZClippingOff ();
340
341 // Visualisation and Shading Model
342 MyViewContext.SetModel ((MyView->Context ()).Model ());
343 MyViewContext.SetVisualization ((MyView->Context ()).Visualization ());
344
345 // Texture Mapping
346 MyViewContext.SetSurfaceDetail (MyView->Context ().SurfaceDetail ());
347 MyViewContext.SetTextureEnv (MyView->Context ().TextureEnv ());
348 // } End of retrieval of the definition of ViewContext.
349
350 MyViewMapping = MyView->ViewMapping() ;
351 MyViewOrientation = MyView->ViewOrientation() ;
352 MyBackground = VM->GetBackgroundColor() ;
353 MyGradientBackground = VM->GetGradientBackground() ;
354
355 SetAxis(0.,0.,0.,1.,1.,1.) ;
356 SetVisualization(VM->DefaultVisualization()) ;
357 SetShadingModel(VM->DefaultShadingModel()) ;
358 SetSurfaceDetail(VM->DefaultSurfaceDetail()) ;
359 SetTwist(0.) ;
360 SetAt(0.,0.,0.) ;
361 SetProj(VM->DefaultViewProj()) ;
362 SetSize(VM->DefaultViewSize()) ;
363 Standard_Real zsize = VM->DefaultViewSize();
364 SetZSize(2.*zsize+zsize*Zmargin) ;
365 SetZClippingDepth(0.);
366 SetZClippingWidth(zsize);
367 SetZCueingDepth(0.);
368 SetZCueingWidth(zsize);
369 SetDepth(VM->DefaultViewSize()/2.) ;
370 SetCenter(0.,0.) ;
371 SetViewMappingDefault();
372 VM->AddView(this) ;
373 Init();
374 myImmediateUpdate = Standard_True;
375
376 // S3892
377#ifndef IMP240100
7fd59977 378#endif //IMP240100
379
380#ifdef G003
381 MyAnimationFlags = 0;
382#endif // G003
383
384#ifdef IMP210200
385 MyTransparencyFlag = Standard_False;
386#endif
7fd59977 387}
388
389/*----------------------------------------------------------------------*/
390
391V3d_View::V3d_View(const Handle(V3d_Viewer)& VM,const Handle(V3d_View)& V, const V3d_TypeOfView Type ) :
392MyType ( Type ),
393MyViewer(VM.operator->()),
394MyActiveLights(),
395MyActivePlanes(),
396MyViewContext (),
397myActiveLightsIterator(),
398myActivePlanesIterator(),
399SwitchSetFront(Standard_False),
400MyTrsf (1, 4, 1, 4), // S3892
401MyProjModel(V3d_TPM_SCREEN)
7fd59977 402{
7fd59977 403 Handle(Visual3d_View) FromView = V->View() ;
404
405 myImmediateUpdate = Standard_False;
406 MyView = new Visual3d_View(MyViewer->Viewer());
407
408 for (V->InitActiveLights();V->MoreActiveLights();V->NextActiveLights()){
409 MyActiveLights.Append(V->ActiveLight());}
410 for (V->InitActivePlanes();V->MoreActivePlanes();V->NextActivePlanes()){
411 MyActivePlanes.Append(V->ActivePlane());}
412
413 MyViewContext = FromView->Context() ;
414
415 MyViewMapping = FromView->ViewMapping() ;
416 MyViewOrientation = FromView->ViewOrientation() ;
417 MyBackground = FromView->Background() ;
418 MyGradientBackground = FromView->GradientBackground();
419
420 MyView->SetContext(MyViewContext) ;
421
422 SetAxis(0.,0.,0.,1.,1.,1.) ;
423 VM->AddView(this) ;
424 Init();
425 myImmediateUpdate = Standard_True;
426
7fd59977 427#ifdef G003
428 MyAnimationFlags = 0;
429#endif
7fd59977 430}
431
432/*----------------------------------------------------------------------*/
433
434//-Methods, in order
435
436void V3d_View::SetMagnify(const Handle(Aspect_Window)& TheWindow,
437 const Handle(V3d_View)& aPreviousView,
438 const Standard_Integer x1,
439 const Standard_Integer y1,
440 const Standard_Integer x2,
441 const Standard_Integer y2)
442{
7fd59977 443 if( !MyView->IsDefined() ) {
444 Standard_Real a,b,c,d;
445 aPreviousView->Convert(x1,y1,a,b);
446 aPreviousView->Convert(x2,y2,c,d);
447 MyView->SetWindow(TheWindow) ;
448 FitAll(TheWindow,a,b,c,d);
449 MyView->SetContext(MyViewContext) ;
450 MyView->SetViewOrientation(MyViewOrientation) ;
451 MyView->SetBackground(MyBackground) ;
452 MyViewer->SetViewOn(this) ;
453 MyWindow = TheWindow;
454 MyView->Redraw() ;
455 SetViewMappingDefault();
456 }
7fd59977 457}
458
459/*----------------------------------------------------------------------*/
460
461void V3d_View::SetWindow(const Handle(Aspect_Window)& TheWindow)
462{
7fd59977 463 Standard_MultiplyDefined_Raise_if( MyView->IsDefined(),
464 "V3d_View::SetWindow, window of view already defined");
465
466 MyView->SetWindow(TheWindow) ;
cdc2203b
M
467 // AGV: Method V3d_View::SetWindow() should assign the field MyWindow before
468 // calling Redraw(). Otherwise it is impossible to call certain methods of
469 // V3d_View like Convert() inside the context of Redraw(),
470 // particularly in class NIS_View.
471 MyWindow = TheWindow;
7fd59977 472 // SetWindow carries out SetRatio and modifies
473 // ViewMapping and ViewMappingDefault of MyView.
474 MyViewMapping = MyView->ViewMapping() ;
475 MyView->SetContext(MyViewContext) ;
476 MyView->SetViewMapping(MyViewMapping) ;
477 MyView->SetViewOrientation(MyViewOrientation) ;
478 MyView->SetBackground(MyBackground) ;
479 MyViewer->SetViewOn(this) ;
7fd59977 480 MyView->Redraw() ;
7fd59977 481}
482
483// RIC120302
484/*----------------------------------------------------------------------*/
485
486void V3d_View::SetWindow(const Handle(Aspect_Window)& aWindow,
487 const Aspect_RenderingContext aContext,
488 const Aspect_GraphicCallbackProc& aDisplayCB,
489 const Standard_Address aClientData)
490{
7fd59977 491 Standard_MultiplyDefined_Raise_if( MyView->IsDefined(),
492 "V3d_View::SetWindow, "
493 "window of view already defined");
cdc2203b
M
494 // AGV: Method V3d_View::SetWindow() should assign the field MyWindow before
495 // calling Redraw(). Otherwise it is impossible to call certain methods of
496 // V3d_View like Convert() inside the context of Redraw(),
497 // particularly in class NIS_View.
498 MyWindow = aWindow;
7fd59977 499 MyView->SetWindow(aWindow, aContext, aDisplayCB, aClientData) ;
500 MyViewMapping = MyView->ViewMapping() ;
501 MyView->SetContext(MyViewContext) ;
502 MyView->SetViewMapping(MyViewMapping) ;
503 MyView->SetViewOrientation(MyViewOrientation) ;
504 MyView->SetBackground(MyBackground) ;
505 MyViewer->SetViewOn(this) ;
506 MyView->Redraw() ;
7fd59977 507}
508// RIC120302
509
510/*----------------------------------------------------------------------*/
511
5e27df78 512void V3d_View::Remove() const
513{
514 MyViewer->DelView (this);
515 MyView->Remove();
516 Handle(Aspect_Window)& aWin = const_cast<Handle(Aspect_Window)&> (MyWindow);
517 aWin.Nullify();
7fd59977 518}
519
520/*----------------------------------------------------------------------*/
521
b8ddfc2f 522void V3d_View::Update() const
523{
7fd59977 524 if( MyView->IsDefined() ) MyView->Update() ;
525}
526
527/*----------------------------------------------------------------------*/
528
b8ddfc2f 529void V3d_View::Redraw() const
530{
7fd59977 531 if( MyView->IsDefined() ) MyView->Redraw() ;
532}
b8ddfc2f 533
7fd59977 534/*----------------------------------------------------------------------*/
535
536void V3d_View::Redraw(const Standard_Integer xc,const Standard_Integer yc,
537 const Standard_Integer width,const Standard_Integer height) const
538{
539 if( MyView->IsDefined() ) MyView->Redraw(xc,yc,width,height) ;
540}
541
542/*----------------------------------------------------------------------*/
543
b8ddfc2f 544Standard_Boolean V3d_View::IsEmpty() const
545{
7fd59977 546 Standard_Boolean TheStatus = Standard_True ;
547 if( MyView->IsDefined() ) {
548 Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
549 if( Nstruct > 0 ) TheStatus = Standard_False ;
550 }
551 return (TheStatus) ;
7fd59977 552}
553
554/*----------------------------------------------------------------------*/
555
b8ddfc2f 556void V3d_View::UpdateLights() const
557{
7fd59977 558 MyView->SetContext(MyViewContext);
559 Update();
560}
561
562/*----------------------------------------------------------------------*/
563
b8ddfc2f 564void V3d_View::DoMapping()
565{
7fd59977 566 if( MyView->IsDefined() ) {
567 (MyView->Window())->DoMapping() ;
568 }
569}
570
571/*----------------------------------------------------------------------*/
572
b8ddfc2f 573void V3d_View::MustBeResized()
574{
7fd59977 575 if ( !MyLayerMgr.IsNull() )
576 MyLayerMgr->Resized();
577
578 if( MyView->IsDefined() ) {
579 MyView->Resized() ;
580 MyViewMapping = MyView->ViewMapping();
581 MyView->Redraw();
582 }
7fd59977 583}
584
585/*----------------------------------------------------------------------*/
586
587void V3d_View::SetBackgroundColor(const Quantity_TypeOfColor Type, const Standard_Real v1, const Standard_Real v2, const Standard_Real v3)
588{
589 Standard_Real V1 = Max( Min( v1, 1.0 ), 0.0 );
590 Standard_Real V2 = Max( Min( v2, 1.0 ), 0.0 );
591 Standard_Real V3 = Max( Min( v3, 1.0 ), 0.0 );
592
593 Quantity_Color C( V1, V2, V3, Type );
7fd59977 594 SetBackgroundColor( C );
7fd59977 595}
596
7fd59977 597/*----------------------------------------------------------------------*/
598
599void V3d_View::SetBackgroundColor(const Quantity_Color &Color)
600{
601 MyBackground.SetColor( Color );
602 if ( MyView->IsDefined() )
603 MyView->SetBackground( MyBackground );
604 //szv: Why?
605 if ( !MyLayerMgr.IsNull() )
606 MyLayerMgr->Resized();
607}
7fd59977 608
609/*----------------------------------------------------------------------*/
610
611void V3d_View::SetBackgroundColor(const Quantity_NameOfColor Name)
612{
613 Quantity_Color C( Name );
7fd59977 614 SetBackgroundColor( C );
7fd59977 615}
616
617/*----------------------------------------------------------------------*/
618
619void V3d_View::SetBgGradientColors( const Quantity_Color& Color1,
620 const Quantity_Color& Color2,
621 const Aspect_GradientFillMethod FillStyle,
622 const Standard_Boolean status)
623{
7fd59977 624 MyGradientBackground.SetColors(Color1, Color2, FillStyle);
625 if ( MyView->IsDefined() )
626 MyView->SetGradientBackground( MyGradientBackground, status );
7fd59977 627}
628
629/*----------------------------------------------------------------------*/
630
631void V3d_View::SetBgGradientColors( const Quantity_NameOfColor Color1,
632 const Quantity_NameOfColor Color2,
633 const Aspect_GradientFillMethod FillStyle,
634 const Standard_Boolean status )
635{
636 Quantity_Color C1( Color1 );
637 Quantity_Color C2( Color2 );
638 MyGradientBackground.SetColors( C1, C2, FillStyle );
639 if ( MyView->IsDefined() )
640 MyView->SetGradientBackground( MyGradientBackground, status );
641}
642
643/*----------------------------------------------------------------------*/
644
645void V3d_View::SetBgGradientStyle( const Aspect_GradientFillMethod FillStyle,
f8b2ed36 646 const Standard_Boolean update)
7fd59977 647{
f8b2ed36 648 Quantity_Color Color1, Color2;
649 MyGradientBackground.Colors( Color1, Color2 );
650 MyGradientBackground.SetColors( Color1, Color2, FillStyle );
7fd59977 651 if( MyView->IsDefined() )
f8b2ed36 652 MyView->SetBgGradientStyle( FillStyle, update ) ;
7fd59977 653}
654
655/*----------------------------------------------------------------------*/
656
657void V3d_View::SetBackgroundImage( const Standard_CString FileName,
658 const Aspect_FillMethod FillStyle,
659 const Standard_Boolean update )
660{
661#ifdef OCC1188
662 if( MyView->IsDefined() )
663 MyView->SetBackgroundImage( FileName, FillStyle, update ) ;
664#endif
665}
666
667/*----------------------------------------------------------------------*/
668
669void V3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
670 const Standard_Boolean update )
671{
672#ifdef OCC1188
673 if( MyView->IsDefined() )
674 MyView->SetBgImageStyle( FillStyle, update ) ;
675#endif
676}
677
678/*----------------------------------------------------------------------*/
679
b8ddfc2f 680void V3d_View::SetAxis(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz)
681{
7fd59977 682 Standard_Real D,Nx = Vx,Ny = Vy,Nz = Vz ;
683
684 D = Sqrt( Vx*Vx + Vy*Vy + Vz*Vz ) ;
685 Viewer_BadValue_Raise_if ( D <= 0. , "V3d_View::SetAxis, bad axis");
686 Nx /= D ; Ny /= D ; Nz /= D ;
687 MyDefaultViewPoint.SetCoord(X,Y,Z) ;
688 MyDefaultViewAxis.SetCoord(Nx,Ny,Nz) ;
689 MyDefaultViewAxis.Normalize() ;
7fd59977 690}
691
692/*----------------------------------------------------------------------*/
693
b8ddfc2f 694void V3d_View::SetShadingModel(const V3d_TypeOfShadingModel Model)
695{
7fd59977 696 MyViewContext.SetModel((Visual3d_TypeOfModel) Model) ;
697 MyView->SetContext(MyViewContext) ;
7fd59977 698}
699
700/*----------------------------------------------------------------------*/
701
b8ddfc2f 702void V3d_View::SetSurfaceDetail(const V3d_TypeOfSurfaceDetail Model)
703{
7fd59977 704 MyViewContext.SetSurfaceDetail((Visual3d_TypeOfSurfaceDetail) Model) ;
705 MyView->SetContext(MyViewContext) ;
7fd59977 706}
707
708/*----------------------------------------------------------------------*/
709
b8ddfc2f 710void V3d_View::SetTextureEnv(const Handle(Graphic3d_TextureEnv)& ATexture)
711{
7fd59977 712 MyViewContext.SetTextureEnv(ATexture) ;
713 MyView->SetContext(MyViewContext) ;
7fd59977 714}
715
716/*----------------------------------------------------------------------*/
717
b8ddfc2f 718void V3d_View::SetVisualization(const V3d_TypeOfVisualization Mode)
719{
7fd59977 720 MyViewContext.SetVisualization((Visual3d_TypeOfVisualization) Mode);
721 MyView->SetContext(MyViewContext) ;
7fd59977 722}
723
724/*----------------------------------------------------------------------*/
725
b8ddfc2f 726void V3d_View::SetFront()
727{
7fd59977 728 gp_Ax3 a = MyViewer->PrivilegedPlane();
729 Standard_Real xo,yo,zo,vx,vy,vz,xu,yu,zu;
730
731 a.Direction().Coord(vx,vy,vz);
732 a.YDirection().Coord(xu,yu,zu);
733 a.Location().Coord(xo,yo,zo);
734
735 if(SwitchSetFront)
736 MyViewOrientation.SetViewReferencePlane(Graphic3d_Vector(-vx,-vy,-vz));
737 else
738 MyViewOrientation.SetViewReferencePlane(Graphic3d_Vector(vx,vy,vz));
739
740 SwitchSetFront = !SwitchSetFront;
741
742 MyViewOrientation.SetViewReferenceUp(Graphic3d_Vector(xu,yu,zu));
743 MyViewOrientation.SetViewReferencePoint(Graphic3d_Vertex(xo,yo,zo));
744
745 MyView->SetViewOrientation(MyViewOrientation) ;
746
747 ImmediateUpdate();
7fd59977 748}
749
750/*----------------------------------------------------------------------*/
751
b8ddfc2f 752void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Boolean Start)
753{
7fd59977 754 Standard_Real Ax = ax ;
755 Standard_Real Ay = ay ;
756 Standard_Real Az = az ;
757 Graphic3d_Vector Vpn,Vup ;
758 TColStd_Array2OfReal Matrix(0,3,0,3) ;
759 TColStd_Array2OfReal Rmatrix(0,3,0,3) ;
760
761 if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ;
762 else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ;
763 if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI ;
764 else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI ;
765 if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ;
766 else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ;
767
768 if( Start ) {
769 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
770 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
771 MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
772 if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
773 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
774 Viewer_BadValue::Raise ("V3d_View::Rotate, alignment of Eye,At,Up");
775 }
776
777 InitMatrix(Matrix) ;
778
779 if( Ax != 0. ) RotAxis(MyViewReferencePoint,MyYscreenAxis,-Ax,Matrix);
780 if( Ay != 0. ) {
781 RotAxis(MyViewReferencePoint,MyXscreenAxis,Ay,Rmatrix) ;
782 Multiply(Matrix, Rmatrix, Matrix);
783 }
784 if( Az != 0. ) {
785 RotAxis(MyViewReferencePoint,MyZscreenAxis,Az,Rmatrix) ;
786 Multiply(Matrix, Rmatrix, Matrix);
787 }
788 Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
789 MyViewOrientation.SetViewReferencePlane(Vpn) ;
790 Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
791 MyViewOrientation.SetViewReferenceUp(Vup) ;
792 MyView->SetViewOrientation(MyViewOrientation) ;
793#ifdef IMP020300
794 SetZSize(0.) ;
795#endif
796 ImmediateUpdate();
7fd59977 797}
798
799/*----------------------------------------------------------------------*/
800
801void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Standard_Real az,
802 const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start)
803{
7fd59977 804 Standard_Real Ax = ax ;
805 Standard_Real Ay = ay ;
806 Standard_Real Az = az ;
807 Graphic3d_Vector Vpn,Vup ;
808 Graphic3d_Vertex Vrp ;
809 TColStd_Array2OfReal Matrix(0,3,0,3) ;
810 TColStd_Array2OfReal Rmatrix(0,3,0,3) ;
811
812 if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ;
813 else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ;
814 if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI ;
815 else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI ;
816 if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ;
817 else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ;
818
819 if( Start ) {
820 MyGravityReferencePoint.SetCoord(X,Y,Z) ;
821 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
822 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
823 MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
824 if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
825 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
826 Viewer_BadValue::Raise ("V3d_View::Rotate, alignment of Eye,At,Up");
827 }
828
829 InitMatrix(Matrix) ;
830
831 if( Ax != 0. ) RotAxis(MyGravityReferencePoint,MyYscreenAxis,-Ax,Matrix);
832 if( Ay != 0. ) {
833 RotAxis(MyGravityReferencePoint,MyXscreenAxis,Ay,Rmatrix) ;
834 Multiply(Matrix, Rmatrix, Matrix);
835 }
836 if( Az != 0. ) {
837 RotAxis(MyGravityReferencePoint,MyZscreenAxis,Az,Rmatrix) ;
838 Multiply(Matrix, Rmatrix, Matrix);
839 }
840 Vrp = TrsPoint(MyViewReferencePoint,Matrix) ;
841 MyViewOrientation.SetViewReferencePoint(Vrp) ;
842 Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
843 MyViewOrientation.SetViewReferencePlane(Vpn) ;
844 Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
845 MyViewOrientation.SetViewReferenceUp(Vup) ;
846 MyView->SetViewOrientation(MyViewOrientation) ;
847#ifdef IMP020300
848 SetZSize(0.) ;
849#endif
850 ImmediateUpdate();
7fd59977 851}
852
853/*----------------------------------------------------------------------*/
854
b8ddfc2f 855void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start)
856{
7fd59977 857 switch (Axe) {
858 case V3d_X :
859 Rotate(angle,0.,0.,Start);
860 break ;
861 case V3d_Y :
862 Rotate(0.,angle,0.,Start);
863 break ;
864 case V3d_Z :
865 Rotate(0.,0.,angle,Start);
866 break ;
867 }
7fd59977 868}
869
870/*----------------------------------------------------------------------*/
871
872void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle,
873 const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start)
874{
7fd59977 875 Standard_Real Angle = angle ;
876 Graphic3d_Vector Vpn,Vup ;
877 Graphic3d_Vertex Vrp ;
878 TColStd_Array2OfReal Matrix(0,3,0,3) ;
879
880 if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
881 else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
882
883 if( Start ) {
884 MyGravityReferencePoint.SetCoord(X,Y,Z) ;
885 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
886 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
887 MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
888 switch (Axe) {
889 case V3d_X :
890 MyViewAxis.SetCoord(1.,0.,0.) ;
891 break ;
892 case V3d_Y :
893 MyViewAxis.SetCoord(0.,1.,0.) ;
894 break ;
895 case V3d_Z :
896 MyViewAxis.SetCoord(0.,0.,1.) ;
897 break ;
898 }
899 }
900
901 RotAxis(MyGravityReferencePoint,MyViewAxis,Angle,Matrix) ;
902 Vrp = TrsPoint(MyViewReferencePoint,Matrix) ;
903 MyViewOrientation.SetViewReferencePoint(Vrp) ;
904 Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
905 MyViewOrientation.SetViewReferencePlane(Vpn) ;
906 Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
907 MyViewOrientation.SetViewReferenceUp(Vup) ;
908 MyView->SetViewOrientation(MyViewOrientation) ;
909#ifdef IMP020300
910 SetZSize(0.) ;
911#endif
912 ImmediateUpdate();
7fd59977 913}
914
915/*----------------------------------------------------------------------*/
916
b8ddfc2f 917void V3d_View::Rotate(const Standard_Real angle, const Standard_Boolean Start)
918{
7fd59977 919 Standard_Real Angle = angle ;
920 Graphic3d_Vector Vpn,Vup ;
921 TColStd_Array2OfReal Matrix(0,3,0,3) ;
922
923 if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
924 else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
925
926 if( Start ) {
927 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
928 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
929 MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
930 }
931
932 RotAxis(MyDefaultViewPoint,MyDefaultViewAxis,Angle,Matrix) ;
933#ifdef BUC60952
934 Graphic3d_Vertex Vrp ;
935 Vrp = TrsPoint(MyViewReferencePoint,Matrix) ;
936 MyViewOrientation.SetViewReferencePoint(Vrp) ;
937#endif
938 Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
939 MyViewOrientation.SetViewReferencePlane(Vpn) ;
940 Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
941 MyViewOrientation.SetViewReferenceUp(Vup) ;
942 MyView->SetViewOrientation(MyViewOrientation) ;
943#ifdef IMP020300
944 SetZSize(0.) ;
945#endif
946 ImmediateUpdate();
7fd59977 947}
948
949/*----------------------------------------------------------------------*/
950
951void V3d_View::Turn(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Boolean Start)
952{
7fd59977 953 Standard_Real Ax = ax ;
954 Standard_Real Ay = ay ;
955 Standard_Real Az = az ;
956 Graphic3d_Vertex Vrp,Eye ;
957 Graphic3d_Vector Vpn,Vup ;
958 Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xat,Yat,Zat,Xeye,Yeye,Zeye ;
959 TColStd_Array2OfReal Matrix(0,3,0,3) ;
960 TColStd_Array2OfReal Rmatrix(0,3,0,3) ;
961
962 if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ;
963 else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ;
964 if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI ;
965 else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI ;
966 if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ;
967 else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ;
968
969 if( Start ) {
970 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
971 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
972 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
973 MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
974 if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
975 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
976 Viewer_BadValue::Raise ("V3d_View::Turn, alignment of Eye,At,Up");
977 }
978
979 InitMatrix(Matrix) ;
980 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
981 MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
982 MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
983 Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
984 Eye.SetCoord(Xeye,Yeye,Zeye) ;
985 if( Ax != 0. ) RotAxis(Eye,MyYscreenAxis,-Ax,Matrix) ;
986 if( Ay != 0. ) {
987 RotAxis(Eye,MyXscreenAxis,Ay,Rmatrix) ;
988 Multiply(Matrix, Rmatrix, Matrix);
989 }
990 if( Az != 0. ) {
991 RotAxis(Eye,MyZscreenAxis,Az,Rmatrix) ;
992 Multiply(Matrix, Rmatrix, Matrix);
993 }
994 Vrp = TrsPoint(MyViewReferencePoint,Matrix) ;
995 MyViewOrientation.SetViewReferencePoint(Vrp) ;
996 Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
997 MyViewOrientation.SetViewReferenceUp(Vpn) ;
998 Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
999 MyViewOrientation.SetViewReferenceUp(Vup) ;
1000 MyView->SetViewOrientation(MyViewOrientation) ;
1001#ifdef IMP020300
1002 SetZSize(0.) ;
1003#else
1004 // Check ZClipping planes
1005 Standard_Real Zmax ;
1006 Vrp.Coord(Xat,Yat,Zat) ;
1007 Zmax = Sqrt( Xat*Xat + Yat*Yat + Zat*Zat) ;
1008 if( Zmax > MyViewMapping.FrontPlaneDistance() &&
1009 MyProjModel == V3d_TPM_SCREEN ) {
1010 SetZSize(2.*Zmax+Zmax*Zmargin) ;
1011 }
1012#endif
1013 ImmediateUpdate();
7fd59977 1014}
1015
1016/*----------------------------------------------------------------------*/
1017
1018void V3d_View::Turn(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start)
1019{
7fd59977 1020 switch (Axe) {
1021 case V3d_X :
1022 Turn(angle,0.,0.,Start);
1023 break ;
1024 case V3d_Y :
1025 Turn(0.,angle,0.,Start);
1026 break ;
1027 case V3d_Z :
1028 Turn(0.,0.,angle,Start);
1029 break ;
1030 }
1031}
1032
b8ddfc2f 1033void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start)
1034{
7fd59977 1035 Standard_Real Angle = angle ;
1036 Graphic3d_Vertex Vrp,Eye ;
1037 Graphic3d_Vector Vpn,Vup ;
1038 Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xat,Yat,Zat,Xeye,Yeye,Zeye ;
1039 TColStd_Array2OfReal Matrix(0,3,0,3) ;
1040
1041 if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
1042 else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
1043
1044 if( Start ) {
1045 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
1046 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
1047 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
1048 MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
1049 }
1050 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
1051 MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
1052 MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
1053 Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
1054 Eye.SetCoord(Xeye,Yeye,Zeye) ;
1055 RotAxis(Eye,MyDefaultViewAxis,Angle,Matrix) ;
1056 Vrp = TrsPoint(MyViewReferencePoint,Matrix) ;
1057 MyViewOrientation.SetViewReferencePoint(Vrp) ;
1058 Vpn = TrsPoint(MyViewReferencePlane,Matrix) ;
1059 MyViewOrientation.SetViewReferencePlane(Vpn) ;
1060 Vup = TrsPoint(MyViewReferenceUp,Matrix) ;
1061 MyViewOrientation.SetViewReferenceUp(Vup) ;
1062 MyView->SetViewOrientation(MyViewOrientation) ;
1063#ifdef IMP020300
1064 SetZSize(0.) ;
1065#else
1066 // Check ZClipping planes
1067 Standard_Real Zmax ;
1068 Vrp.Coord(Xat,Yat,Zat) ;
1069 Zmax = Sqrt( Xat*Xat + Yat*Yat + Zat*Zat ) ;
1070 if( Zmax > MyViewMapping.FrontPlaneDistance() &&
1071 MyProjModel == V3d_TPM_SCREEN ) {
1072 SetZSize(2.*Zmax+Zmax*Zmargin) ;
1073 }
1074#endif
1075 ImmediateUpdate();
7fd59977 1076}
1077
b8ddfc2f 1078void V3d_View::SetTwist(const Standard_Real angle)
1079{
7fd59977 1080 Standard_Real Angle = angle ;
1081 TColStd_Array2OfReal Matrix(0,3,0,3) ;
1082 Standard_Boolean TheStatus ;
1083
1084 if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
1085 else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
1086
1087 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
1088 MyViewReferenceUp.SetCoord(0.,0.,1.) ;
1089 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1090 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1091 if( !TheStatus ) {
1092 MyViewReferenceUp.SetCoord(0.,1.,0.) ;
1093 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1094 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1095 }
1096 if( !TheStatus ) {
1097 MyViewReferenceUp.SetCoord(1.,0.,0.) ;
1098 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1099 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1100 }
1101
1102 Viewer_BadValue_Raise_if( !TheStatus,"V3d_ViewSetTwist, alignment of Eye,At,Up,");
1103
1104 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
1105 RotAxis(MyViewReferencePoint,MyZscreenAxis,Angle,Matrix) ;
1106 MyViewReferenceUp = TrsPoint(MyYscreenAxis,Matrix) ;
1107 MyViewOrientation.SetViewReferenceUp(MyViewReferenceUp) ;
1108 MyView->SetViewOrientation(MyViewOrientation) ;
1109 ImmediateUpdate();
7fd59977 1110}
1111
1112#ifdef IMP240100
1113void V3d_View::SetProjModel( const V3d_TypeOfProjectionModel aModel )
1114{
7fd59977 1115 MyProjModel = aModel;
7fd59977 1116}
1117
b8ddfc2f 1118V3d_TypeOfProjectionModel V3d_View::ProjModel() const
1119{
7fd59977 1120 return MyProjModel;
7fd59977 1121}
1122#endif
1123
b8ddfc2f 1124void V3d_View::SetEye(const Standard_Real X,const Standard_Real Y,const Standard_Real Z)
1125{
7fd59977 1126 Standard_Real Angle,Xat,Yat,Zat,Xrp,Yrp,Zrp,Xpn,Ypn,Zpn ;
1127 Angle = Twist() ;
1128 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
1129 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
1130 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
1131 MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
1132 MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
1133 Xpn = X - Xat ; Ypn = Y - Yat ; Zpn = Z - Zat ;
1134 Zrp = Sqrt(Xpn*Xpn + Ypn*Ypn + Zpn*Zpn) ;
1135 Viewer_BadValue_Raise_if( Zrp <= 0. , "V3d_View::SetEye:: Eye,At are Confused");
1136
1137 Xpn /= Zrp ; Ypn /= Zrp ; Zpn /= Zrp ;
1138 MyViewReferencePlane.SetCoord(Xpn,Ypn,Zpn) ;
1139 MyViewOrientation.SetViewReferencePlane(MyViewReferencePlane) ;
1140 MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
1141 MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
1142
1143 Standard_Boolean update = myImmediateUpdate;
1144 myImmediateUpdate = Standard_False;
1145 if( MyProjModel == V3d_TPM_WALKTHROUGH ) {
1146 //FMN desactivation temp SetTwist(Angle) ;
1147 // Set infos.
1148 MyView->SetViewOrientation(MyViewOrientation) ;
1149 MyView->SetViewMapping(MyViewMapping) ;
1150 } else {
1151 SetTwist(Angle) ;
1152 }
1153#ifdef IMP020300
1154 SetZSize(0.) ;
1155#else
1156 // Check ZClipping planes
1157 Standard_Real Zmax = Sqrt( X*X + Y*Y + Z*Z ) ;
1158 if( Zmax > MyViewMapping.FrontPlaneDistance() &&
1159 MyProjModel == V3d_TPM_SCREEN ) {
1160 SetZSize(2.*Zmax+Zmax*Zmargin) ;
1161 } else {
1162 if( MyType == V3d_PERSPECTIVE ) SetFocale(focale) ;
1163 MyView->SetViewMapping(MyViewMapping);
1164 }
1165#endif
1166 myImmediateUpdate = update;
1167 ImmediateUpdate();
7fd59977 1168}
1169
b8ddfc2f 1170void V3d_View::SetDepth(const Standard_Real Depth)
1171{
7fd59977 1172 Standard_Real Xrp,Yrp,Zrp ;
1173#ifdef IMP250200
1174 Viewer_BadValue_Raise_if( Depth == 0. ,"V3d_View::SetDepth, bad depth");
1175#else
1176 Viewer_BadValue_Raise_if( Depth <= 0. ,"V3d_View::SetDepth, bad depth");
1177#endif
1178
7fd59977 1179 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
1180 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
1181 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
1182 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
1183#ifdef IMP250200
1184 if( Depth > 0. )
1185#endif
1186 {
1187 Zrp = Depth;
1188 MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
1189 MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
1190 }
1191
1192 // Check ZClipping planes
1193 Standard_Real Xat,Yat,Zat,Xpn,Ypn,Zpn,Xeye,Yeye,Zeye ;
1194 MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
1195 MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
1196#ifdef IMP250200
1197 if( Depth < 0. ) { // Move the view ref point instead of the eye.
1198 Xeye = Xpn*Zrp + Xat ; Yeye = Ypn*Zrp + Yat ; Zeye = Zpn*Zrp + Zat ;
1199 Zrp = Abs(Depth) ;
1200 Xat = Xeye - Xpn*Zrp ; Yat = Yeye - Ypn*Zrp ; Zat = Zeye - Zpn*Zrp;
1201 MyViewReferencePoint.SetCoord(Xat,Yat,Zat) ;
1202 MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
1203 MyViewOrientation.SetViewReferencePoint(MyViewReferencePoint) ;
1204 MyView->SetViewOrientation(MyViewOrientation);
1205 }
1206#endif
1207#ifdef IMP020300
1208 MyView->SetViewMapping(MyViewMapping) ;
1209 SetZSize(0.) ;
1210#else
1211 Xeye = Xpn*Zrp + Xat ; Yeye = Ypn*Zrp + Yat ; Zeye = Zpn*Zrp + Zat ;
1212 Standard_Real Zmax = Sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye );
1213
1214 if( Zmax > MyViewMapping.FrontPlaneDistance() &&
1215 MyProjModel == V3d_TPM_SCREEN ) {
1216 SetZSize(2.*Zmax+Zmax*Zmargin) ;
1217 } else {
1218 if( MyType == V3d_PERSPECTIVE ) SetFocale(focale) ;
1219#ifdef IMP250200
1220 if( Depth > 0. )
1221#endif
1222 MyView->SetViewMapping(MyViewMapping) ;
1223 }
1224#endif
1225
1226 ImmediateUpdate();
7fd59977 1227}
1228
1229
1230void V3d_View::SetProj( const Standard_Real Vx,const Standard_Real Vy, const Standard_Real Vz )
1231{
7fd59977 1232 Standard_Real Angle ;
1233
1234 Viewer_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0.,
1235 "V3d_View::SetProj, null projection vector");
1236
1237 Angle = Twist() ;
1238 MyViewReferencePlane.SetCoord(Vx,Vy,Vz) ;
1239 MyViewReferencePlane.Normalize() ;
1240 MyViewOrientation.SetViewReferencePlane(MyViewReferencePlane) ;
1241 Standard_Boolean update = myImmediateUpdate;
1242 myImmediateUpdate = Standard_False;
1243 if( MyProjModel == V3d_TPM_SCREEN ) SetTwist(Angle) ;
1244#ifdef IMP020300
1245 SetZSize(0.) ;
1246#endif
1247 myImmediateUpdate = update;
1248 ImmediateUpdate();
7fd59977 1249}
1250
b8ddfc2f 1251void V3d_View::SetProj( const V3d_TypeOfOrientation Orientation )
1252{
7fd59977 1253 MyViewReferencePlane = V3d::GetProjAxis(Orientation) ;
1254 MyViewOrientation.SetViewReferencePlane(MyViewReferencePlane) ;
1255 // MSV 14.03.2007: reset ViewReferencePoint to debug LH3D14955
b8ddfc2f 1256 MyViewOrientation.SetViewReferencePoint(Graphic3d_Vertex (0.0f, 0.0f, 0.0f));
7fd59977 1257 Standard_Real Xpn=0;
1258 Standard_Real Ypn=0;
1259 Standard_Real Zpn=0;
1260
1261 switch (Orientation) {
1262 case V3d_Zpos :
1263 Ypn = 1. ;
1264 break ;
1265 case V3d_Zneg :
1266 Ypn = -1. ;
1267 break ;
1268 default:
1269 Zpn = 1.;
1270 }
1271 SetUp(Xpn,Ypn,Zpn);
1272#ifdef IMP020300
1273 SetZSize(0.) ;
1274#endif
1275 ImmediateUpdate();
7fd59977 1276}
1277
b8ddfc2f 1278void V3d_View::SetAt(const Standard_Real X,const Standard_Real Y,const Standard_Real Z)
1279{
7fd59977 1280 Standard_Real Angle,Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xat,Yat,Zat ;
1281 Standard_Real Xeye,Yeye,Zeye ;
1282
1283 Angle = Twist() ;
1284 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
1285 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
1286 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
1287 MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
1288 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
1289 MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
1290 Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
1291 Xpn = Xeye - X ; Ypn = Yeye - Y ; Zpn = Zeye - Z ;
1292 Zrp = Sqrt(Xpn*Xpn + Ypn*Ypn + Zpn*Zpn) ;
1293 Viewer_BadValue_Raise_if( Zrp <= 0.,
1294 "V3d_View::SetAt, Eye,At are Confused");
1295
1296 Xpn /= Zrp ; Ypn /= Zrp ; Zpn /= Zrp ;
1297 MyViewReferencePoint.SetCoord(X,Y,Z) ;
1298 MyViewOrientation.SetViewReferencePoint(MyViewReferencePoint) ;
1299 MyViewReferencePlane.SetCoord(Xpn,Ypn,Zpn) ;
1300 MyViewOrientation.SetViewReferencePlane(MyViewReferencePlane) ;
1301 MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
1302 MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
1303 Standard_Boolean update = myImmediateUpdate;
1304 myImmediateUpdate = Standard_False;
1305 if( MyProjModel == V3d_TPM_WALKTHROUGH ) {
1306 //FMN desactivation temp SetTwist(Angle) ;
1307 // Set infos.
1308 MyView->SetViewOrientation(MyViewOrientation) ;
1309 MyView->SetViewMapping(MyViewMapping) ;
1310 } else {
1311 SetTwist(Angle) ;
1312 }
1313#ifdef IMP020300
1314 MyView->SetViewMapping(MyViewMapping);
1315 SetZSize(0.) ;
1316#else
1317 ImmediateUpdate();
1318 // Check ZClipping planes
1319 Standard_Real Zmax = Sqrt( X*X + Y*Y + Z*Z ) ;
1320 if( Zmax > MyViewMapping.FrontPlaneDistance() &&
1321 MyProjModel == V3d_TPM_SCREEN ) {
1322 SetZSize(2.*Zmax+Zmax*Zmargin) ;
1323 } else {
1324 if( MyType == V3d_PERSPECTIVE ) SetFocale(focale) ;
1325 MyView->SetViewMapping(MyViewMapping);
1326 }
1327#endif
1328 myImmediateUpdate = update;
1329 ImmediateUpdate();
7fd59977 1330}
1331
b8ddfc2f 1332void V3d_View::SetUp(const Standard_Real Vx,const Standard_Real Vy,const Standard_Real Vz)
1333{
7fd59977 1334 Standard_Boolean TheStatus ;
1335 Viewer_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0. ,
1336 "V3d_View::SetUp, nullUp vector");
1337
1338 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
1339 MyViewReferenceUp.SetCoord(Vx,Vy,Vz) ;
1340 MyViewReferenceUp.Normalize() ;
1341 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1342 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1343 if( !TheStatus ) {
1344 MyViewReferenceUp.SetCoord(0.,0.,1.) ;
1345 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1346 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1347 }
1348 if( !TheStatus ) {
1349 MyViewReferenceUp.SetCoord(0.,1.,0.) ;
1350 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1351 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1352 }
1353 if( !TheStatus ) {
1354 MyViewReferenceUp.SetCoord(1.,0.,0.) ;
1355 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1356 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1357 }
1358 Viewer_BadValue_Raise_if( !TheStatus,"V3d_View::Setup, alignment of Eye,At,Up");
1359
1360 MyViewReferenceUp = MyYscreenAxis ;
1361 MyViewOrientation.SetViewReferenceUp(MyViewReferenceUp) ;
1362 MyView->SetViewOrientation(MyViewOrientation) ;
1363 ImmediateUpdate();
7fd59977 1364}
1365
b8ddfc2f 1366void V3d_View::SetUp( const V3d_TypeOfOrientation Orientation )
1367{
7fd59977 1368 Standard_Boolean TheStatus ;
1369
1370 MyViewReferenceUp = V3d::GetProjAxis(Orientation) ;
1371 MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
1372 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1373 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1374 if( !TheStatus ) {
1375 MyViewReferenceUp.SetCoord(0.,0.,1.) ;
1376 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1377 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1378 }
1379 if( !TheStatus ) {
1380 MyViewReferenceUp.SetCoord(0.,1.,0.) ;
1381 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1382 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1383 }
1384 if( !TheStatus ) {
1385 MyViewReferenceUp.SetCoord(1.,0.,0.) ;
1386 TheStatus = ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
1387 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis) ;
1388 }
1389 Viewer_BadValue_Raise_if( !TheStatus, "V3d_View::SetUp, alignment of Eye,At,Up");
1390
1391 MyViewReferenceUp = MyYscreenAxis ;
1392 MyViewOrientation.SetViewReferenceUp(MyViewReferenceUp) ;
1393 MyView->SetViewOrientation(MyViewOrientation) ;
1394 ImmediateUpdate();
7fd59977 1395}
1396
1397void V3d_View::SetViewOrientation(const Visual3d_ViewOrientation& VO)
1398{
1399 MyViewOrientation = VO;
1400 MyView->SetViewOrientation(MyViewOrientation) ;
1401 ImmediateUpdate();
1402}
1403
b8ddfc2f 1404void V3d_View::SetViewOrientationDefault()
1405{
7fd59977 1406 MyView->SetViewOrientation(MyViewOrientation) ;
1407 MyView->SetViewOrientationDefault() ;
1408 ImmediateUpdate();
1409}
1410
b8ddfc2f 1411void V3d_View::ResetViewOrientation()
1412{
7fd59977 1413 MyView->ViewOrientationReset() ;
1414 MyViewOrientation = MyView->ViewOrientation() ;
1415 ImmediateUpdate();
1416}
1417
b8ddfc2f 1418void V3d_View::Reset( const Standard_Boolean update )
1419{
7fd59977 1420 MyView->ViewOrientationReset() ;
1421 MyViewOrientation = MyView->ViewOrientation() ;
1422 MyView->ViewMappingReset();
1423 MyViewMapping = MyView->ViewMapping() ;
1424
1425 ZFitAll (Zmargin);
1426 SwitchSetFront = Standard_False;
1427#ifdef IMP020300
1428 if( !myImmediateUpdate && update ) Update();
1429#else
1430 ImmediateUpdate();
1431#endif
7fd59977 1432}
1433
1434void V3d_View::Panning(const Standard_Real Dx, const Standard_Real Dy, const Quantity_Factor aZoomFactor, const Standard_Boolean Start)
1435{
7fd59977 1436 Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Zrp,Dxv,Dyv ;
1437 Viewer_BadValue_Raise_if( aZoomFactor <= 0.,"V3d_View::Panning, bad zoom factor");
1438
1439 if( Start ) {
1440 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
1441 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
1442 MyXwindowCenter = (Umin + Umax)/2. ;
1443 MyYwindowCenter = (Vmin + Vmax)/2. ;
1444 MyWindowWidth = Abs(Umax - Umin) ;
1445 MyWindowHeight = Abs(Vmax - Vmin) ;
1446 Viewer_BadValue_Raise_if( MyWindowWidth <= 0. || MyWindowHeight <= 0. ,
1447 "V3d_View::Panning, Window Size is NULL");
1448 }
1449 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
1450 Xrp = MyXwindowCenter - Dx ;
1451 Yrp = MyYwindowCenter - Dy ;
1452 Dxv = MyWindowWidth/aZoomFactor ; Dyv = MyWindowHeight/aZoomFactor ;
1453 Umin = Xrp - Dxv/2. ; Umax = Xrp + Dxv/2. ;
1454 Vmin = Yrp - Dyv/2. ; Vmax = Yrp + Dyv/2. ;
1455 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
1456 if( MyType != V3d_PERSPECTIVE ) {
1457 MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
1458 MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint) ;
1459 }
1460 MyView->SetViewMapping(MyViewMapping) ;
1461 ImmediateUpdate();
7fd59977 1462}
b8ddfc2f 1463
1464void V3d_View::SetCenter(const Standard_Integer X, const Standard_Integer Y)
1465{
7fd59977 1466 Standard_Real x,y;
1467 Convert(X,Y,x,y);
1468 SetCenter(x,y);
1469}
1470
b8ddfc2f 1471void V3d_View::SetCenter(const Standard_Real Xc, const Standard_Real Yc)
1472{
7fd59977 1473 Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Zrp ;
1474
1475 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
1476 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
1477 MyXwindowCenter = Xrp = Xc ; MyYwindowCenter = Yrp = Yc ;
1478 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
1479 MyWindowWidth = Abs(Umax - Umin) ; MyWindowHeight = Abs(Vmax - Vmin) ;
1480 Viewer_BadValue_Raise_if( MyWindowWidth <= 0. || MyWindowHeight <= 0. ,
1481 "V3d_View::SetCenter, Window Size is NULL");
1482
1483 Umin = Xc - MyWindowWidth/2. ; Vmin = Yc - MyWindowHeight/2. ;
1484 Umax = Xc + MyWindowWidth/2. ; Vmax = Yc + MyWindowHeight/2. ;
1485 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
1486 if( MyType != V3d_PERSPECTIVE ) {
1487 MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
1488 MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint) ;
1489 }
1490 MyView->SetViewMapping(MyViewMapping) ;
1491 ImmediateUpdate();
7fd59977 1492}
1493
1494void V3d_View::SetSize(const Standard_Real Size)
1495{
7fd59977 1496 Standard_Real Umin,Vmin,Umax,Vmax,Rap ;
1497
1498 Viewer_BadValue_Raise_if( Size <= 0.,
1499 "V3d_View::SetSize, Window Size is NULL");
1500
1501
1502 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
1503 MyWindowWidth = Abs(Umax - Umin) ;
1504 MyWindowHeight = Abs(Vmax - Vmin) ;
1505 MyXwindowCenter = (Umin + Umax)/2. ;
1506 MyYwindowCenter = (Vmin + Vmax)/2. ;
1507 Rap = MyWindowWidth/MyWindowHeight ;
1508 if( MyWindowWidth >= MyWindowHeight ) {
1509 MyWindowWidth = Size ; MyWindowHeight = Size/Rap ;
1510 } else {
1511 MyWindowHeight = Size ; MyWindowWidth = Size*Rap ;
1512 }
1513 Umin = MyXwindowCenter - MyWindowWidth/2. ;
1514 Vmin = MyYwindowCenter - MyWindowHeight/2. ;
1515 Umax = MyXwindowCenter + MyWindowWidth/2. ;
1516 Vmax = MyYwindowCenter + MyWindowHeight/2. ;
1517 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
1518 MyView->SetViewMapping(MyViewMapping) ;
1519 ImmediateUpdate();
7fd59977 1520}
1521
1522void V3d_View::SetZSize(const Standard_Real Size)
1523{
7fd59977 1524 Standard_Real Zmax = Size/2.;
1525
1526#ifdef IMP020300
1527 if( Size <= 0. ) {
1528 Standard_Real Xat,Yat,Zat,Xpn,Ypn,Zpn,Xrp,Yrp,Zrp,Xeye,Yeye,Zeye;
1529 MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
1530 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
1531 MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
1532 Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat;
1533 Zmax = Sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye );
1534 if( Zmax <= MyViewMapping.FrontPlaneDistance() ) return;
1535 }
1536#else
1537 Viewer_BadValue_Raise_if( Size <= 0.,
1538 "V3d_View::SetZSize, Window ZSize is NULL");
1539#endif
1540
1541 Standard_Real Front = MyViewContext.ZClippingFrontPlane() ;
1542 Standard_Real Back = MyViewContext.ZClippingBackPlane() ;
1543 Standard_Real focale= Focale();
1544
1545 MyViewMapping.SetFrontPlaneDistance(Zmax) ;
1546 MyViewMapping.SetBackPlaneDistance(-Zmax) ;
1547
1548 // OCC18942
1549 if( MyProjModel != V3d_TPM_WALKTHROUGH ) {
1550 MyViewMapping.SetViewPlaneDistance(MyType == V3d_PERSPECTIVE ? 0. : Zmax) ;
1551 }
1552
1553 MyView->SetViewMapping(MyViewMapping) ;
1554 if( MyViewContext.FrontZClippingIsOn() ||
b8ddfc2f 1555 MyViewContext.BackZClippingIsOn() )
1556 {
1557 MyViewContext.SetZClippingFrontPlane(Front) ;
1558 MyViewContext.SetZClippingBackPlane(Back) ;
1559 MyView->SetContext(MyViewContext) ;
1560 }
7fd59977 1561}
1562
1563void V3d_View::SetZoom(const Standard_Real Coef,const Standard_Boolean Start)
1564{
7fd59977 1565 Standard_Real Umin,Vmin,Umax,Vmax,Dxv,Dyv ;
1566 Viewer_BadValue_Raise_if( Coef <= 0.,"V3d_View::SetZoom, bad coefficient");
1567
1568 if( Start ) {
1569 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
1570 MyXwindowCenter = (Umin + Umax)/2. ;
1571 MyYwindowCenter = (Vmin + Vmax)/2. ;
1572 MyWindowWidth = Abs(Umax - Umin) ;
1573 MyWindowHeight = Abs(Vmax - Vmin) ;
1574 }
1575
1576 // ensure that zoom will not be too small or too big
1577 Standard_Real coef = Coef;
1578 if ( MyWindowWidth < coef * Precision::Confusion() )
1579 coef = MyWindowWidth / Precision::Confusion();
1580 else if ( MyWindowWidth > coef * 1e12 )
1581 coef = MyWindowWidth / 1e12;
1582 if ( MyWindowHeight < coef * Precision::Confusion() )
1583 coef = MyWindowHeight / Precision::Confusion();
1584 else if ( MyWindowHeight > coef * 1e12 )
1585 coef = MyWindowHeight / 1e12;
1586
1587 Dxv = MyWindowWidth/coef;
1588 Dyv = MyWindowHeight/coef;
1589 Umin = MyXwindowCenter - Dxv/2. ; Umax = MyXwindowCenter + Dxv/2. ;
1590 Vmin = MyYwindowCenter - Dyv/2. ; Vmax = MyYwindowCenter + Dyv/2. ;
1591 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
1592 MyView->SetViewMapping(MyViewMapping) ;
1593 ImmediateUpdate();
1594}
1595
b8ddfc2f 1596void V3d_View::SetScale( const Standard_Real Coef )
1597{
7fd59977 1598 Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Dxv,Dyv ;
1599 Visual3d_ViewMapping VMD = MyView->ViewMappingDefault() ;
1600
1601 Viewer_BadValue_Raise_if( Coef <= 0. ,"V3d_View::SetScale, bad coefficient");
1602
1603 VMD.WindowLimit(Umin,Vmin,Umax,Vmax) ;
1604 Dxv = Abs(Umax - Umin) ; Dyv = Abs(Vmax - Vmin) ;
1605 Dxv /= Coef ; Dyv /= Coef ;
1606 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
1607 Xrp = (Umin + Umax)/2. ; Yrp = (Vmin + Vmax)/2. ;
1608 Umin = Xrp - Dxv/2. ; Umax = Xrp + Dxv/2. ;
1609 Vmin = Yrp - Dyv/2. ; Vmax = Yrp + Dyv/2. ;
1610 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
1611 MyView->SetViewMapping(MyViewMapping) ;
1612 ImmediateUpdate();
7fd59977 1613}
1614
b8ddfc2f 1615void V3d_View::SetAxialScale( const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz )
1616{
7fd59977 1617 Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ;
1618 Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ;
1619 Viewer_BadValue_Raise_if( Sx <= 0. || Sy <= 0. || Sz <= 0.,"V3d_View::SetAxialScale, bad coefficient");
1620
1621 MyViewOrientation.SetAxialScale( Sx, Sy, Sz );
1622 Aspect_TypeOfUpdate updateMode = MyView->ViewManager()->UpdateMode();
1623 MyView->ViewManager()->SetUpdateMode(Aspect_TOU_ASAP);
1624 MyView->SetViewOrientation(MyViewOrientation);
1625 MyView->ViewManager()->SetUpdateMode(updateMode);
1626
1627 MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
1628
1629 Standard_Real LIM = ShortRealLast() -1.;
1630 if (Abs(Xmin) > LIM || Abs(Ymin) > LIM || Abs(Zmin) > LIM
1631 || Abs(Xmax) > LIM || Abs(Ymax) > LIM || Abs(Zmax) > LIM ) {
1632 return;
1633 }
1634
1635 MyView->Projects(Xmin,Ymin,Zmin,Umin,Vmin,Wmin) ;
1636 MyView->Projects(Xmax,Ymax,Zmax,Umax,Vmax,Wmax) ;
1637 Umax = Max(Umin,Umax) ; Vmax = Max(Vmin,Vmax) ;
1638 MyView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
1639 Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
1640 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1641 MyView->Projects(Xmax,Ymin,Zmax,U,V,W) ;
1642 Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
1643 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1644 MyView->Projects(Xmax,Ymin,Zmin,U,V,W) ;
1645 Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
1646 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1647 MyView->Projects(Xmax,Ymax,Zmin,U,V,W) ;
1648 Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
1649 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1650 MyView->Projects(Xmin,Ymax,Zmax,U,V,W) ;
1651 Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
1652 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1653 MyView->Projects(Xmin,Ymax,Zmin,U,V,W) ;
1654 Umax = Max(Umax,U) ; Vmax = Max(Vmax,V) ;
1655 Umax = Max(Umax,Vmax) ;
1656 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1657 Wmax = Max(Abs(Wmin),Abs(Wmax)) ;
1658 Wmax = Max(Abs(Umax),Abs(Wmax)) ;
1659
1660 if( Wmax > 0. ) {
1661 SetZSize(2.*Wmax + Wmax) ;
1662 }
7fd59977 1663}
1664
1665void V3d_View::FitAll(const Standard_Real Coef, const Standard_Boolean FitZ,
1666 const Standard_Boolean update)
1667{
35617823
K
1668 Standard_Real Umin, Umax, Vmin, Vmax, Xrp, Yrp, Zrp, U, V, W, U1, V1, W1;
1669 Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
1670 Standard_Real DxvOld, DyvOld, DxvNew, DyvNew;
1671 Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures();
7fd59977 1672
35617823
K
1673 if ((Nstruct <= 0) || (Coef < 0.0) || (Coef > 1.0))
1674 {
7fd59977 1675#ifndef IMP020300
1676 ImmediateUpdate();
1677#endif
35617823 1678 return;
7fd59977 1679 }
7fd59977 1680
35617823
K
1681 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
1682 MyProjReferencePoint.Coord (Xrp, Yrp, Zrp);
1683 if (MyView->IsDefined())
1684 {
1685 Standard_Integer Xpixel, Ypixel;
1686 MyWindow->Size (Xpixel, Ypixel);
1687 DxvOld = Xpixel;
1688 DyvOld = Ypixel;
7fd59977 1689 }
35617823
K
1690 else
1691 {
1692 MyViewMapping.WindowLimit (Umin, Vmin, Umax, Vmax);
1693 DxvOld = Abs (Umax - Umin);
1694 DyvOld = Abs (Vmax - Vmin);
7fd59977 1695 }
35617823
K
1696 if ((DxvOld == 0.0) || (DyvOld == 0.0))
1697 {
1698 return;
7fd59977 1699 }
1700
35617823
K
1701 Standard_Real aWinRatio = DxvOld / DyvOld;
1702
1703 // retrieve min / max values for current displayed objects
1704 MyView->MinMaxValues (Xmin, Ymin, Zmin,
1705 Xmax, Ymax, Zmax);
1706
1707 Standard_Real LIM = ShortRealLast() - 1.0;
1708 if (Abs(Xmin) > LIM || Abs(Ymin) > LIM || Abs(Zmin) > LIM
1709 || Abs(Xmax) > LIM || Abs(Ymax) > LIM || Abs(Zmax) > LIM)
1710 {
7fd59977 1711#ifndef IMP020300
35617823 1712 ImmediateUpdate();
7fd59977 1713#endif
35617823
K
1714 return;
1715 }
7fd59977 1716
35617823
K
1717 // eliminate fluctuations between sequential FitAll() calls
1718 MyViewMapping.SetWindowLimit (-1.0 * aWinRatio, -1.0, 1.0 * aWinRatio, 1.0);
1719 if (MyType != V3d_PERSPECTIVE)
1720 {
1721 MyProjReferencePoint.SetCoord (0.0, 0.0, Zrp);
1722 MyViewMapping.SetProjectionReferencePoint (MyProjReferencePoint);
1723 }
1724 MyView->SetViewMapping (MyViewMapping);
1725
1726 // iterate 2 times to find optimal view plane size
1727 // (use view plane values computed on previous iteration)
1728 for (Standard_Integer aIteration = 2; aIteration > 0; --aIteration)
1729 {
1730 MyView->Projects (Xmin, Ymin, Zmin, U, V, W);
1731 MyView->Projects (Xmax, Ymax, Zmax, U1, V1, W1);
1732 Umin = Min (U, U1); Umax = Max (U, U1);
1733 Vmin = Min (V, V1); Vmax = Max (V, V1);
1734
1735 MyView->Projects (Xmin, Ymin, Zmax, U, V, W);
1736 Umin = Min (U, Umin); Umax = Max (U, Umax);
1737 Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
1738
1739 MyView->Projects (Xmax, Ymin, Zmax, U, V, W);
1740 Umin = Min (U, Umin); Umax = Max (U, Umax);
1741 Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
1742
1743 MyView->Projects (Xmax, Ymin, Zmin, U, V, W);
1744 Umin = Min (U, Umin); Umax = Max (U, Umax);
1745 Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
1746
1747 MyView->Projects (Xmax, Ymax, Zmin, U, V, W);
1748 Umin = Min (U, Umin); Umax = Max (U, Umax);
1749 Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
7fd59977 1750
35617823
K
1751 MyView->Projects (Xmin, Ymax, Zmax, U, V, W);
1752 Umin = Min (U, Umin); Umax = Max (U, Umax);
1753 Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
7fd59977 1754
35617823
K
1755 MyView->Projects (Xmin, Ymax, Zmin, U, V, W);
1756 Umin = Min (U, Umin); Umax = Max (U, Umax);
1757 Vmin = Min (V, Vmin); Vmax = Max (V, Vmax);
1758
1759 DxvNew = Abs (Umax - Umin);
1760 DyvNew = Abs (Vmax - Vmin);
1761
1762 if (DyvNew < 10.0 * Precision::Confusion())
1763 {
1764 if (DxvNew < 10.0 * Precision::Confusion())
1765 {
1766 // whole scene projected to point
1767 DxvNew = Max (Abs (Zmax - Zmin), (Max (Abs (Xmax - Xmin), Abs (Ymax - Ymin))));
1768 if (DxvNew < 10.0 * Precision::Confusion())
1769 {
1770 // this is really just one (!) point and zooming has no any effect
1771 // just center the view
1772 DyvNew = DyvOld;
1773 DxvNew = DxvOld;
7fd59977 1774 }
35617823
K
1775 else
1776 {
1777 // we look along some line
1778 // fit view like that to see whole scene on rotation
1779 DxvNew += Coef * DxvNew;
1780 DyvNew = DxvNew / aWinRatio;
1781 }
1782 }
1783 else
1784 {
1785 // whole scene projected to horizontal line
1786 DxvNew += Coef * DxvNew;
1787 DyvNew = DxvNew / aWinRatio;
7fd59977 1788 }
35617823
K
1789 }
1790 else
1791 {
1792 // general case (or DxvNew == 0.0 - vertical line)
1793 // safe original ratio
1794 Standard_Real aFitRatio = DxvNew / DyvNew;
1795 if (aFitRatio >= aWinRatio)
1796 {
1797 DxvNew += Coef * DxvNew;
1798 DyvNew = DxvNew / aWinRatio;
1799 }
1800 else
1801 {
1802 DyvNew += Coef * DyvNew;
1803 DxvNew = DyvNew * aWinRatio;
1804 }
1805 }
7fd59977 1806
35617823
K
1807 // new scene center
1808 Xrp = 0.5 * (Umin + Umax);
1809 Yrp = 0.5 * (Vmin + Vmax);
7fd59977 1810
35617823
K
1811 // new window limits
1812 Umin = Xrp - 0.5 * DxvNew;
1813 Umax = Xrp + 0.5 * DxvNew;
1814 Vmin = Yrp - 0.5 * DyvNew;
1815 Vmax = Yrp + 0.5 * DyvNew;
1816 MyViewMapping.SetWindowLimit (Umin, Vmin, Umax, Vmax);
1817
1818 if (MyType != V3d_PERSPECTIVE)
1819 {
1820 // center the view
1821 MyProjReferencePoint.SetCoord (Xrp, Yrp, Zrp);
1822 MyViewMapping.SetProjectionReferencePoint (MyProjReferencePoint);
1823 }
1824 MyView->SetViewMapping (MyViewMapping);
1825 }
1826
1827 if (FitZ)
1828 {
1829 ZFitAll (Zmargin);
7fd59977 1830#ifdef IMP020300
35617823
K
1831 }
1832 else
1833 {
1834 ImmediateUpdate();
7fd59977 1835#endif
35617823 1836 }
7fd59977 1837#ifdef IMP020300
35617823
K
1838 if (!myImmediateUpdate && update)
1839 {
1840 Update();
1841 }
7fd59977 1842#endif
1843}
1844
b8ddfc2f 1845void V3d_View::ZFitAll(const Standard_Real Coef)
1846{
7fd59977 1847 Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ;
1848 Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ;
1849 // CAL 6/11/98
1850 Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
1851
1852 if( MyType == V3d_PERSPECTIVE ) {
1853 ImmediateUpdate();
1854 return ;
1855 }
1856
1857 if( (Nstruct <= 0) || (Coef < 0.) ) {
1858 ImmediateUpdate();
1859 return ;
1860 }
1861
1862 MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
1863
1864 Standard_Real LIM = ShortRealLast() -1.;
1865 if (Abs(Xmin) > LIM || Abs(Ymin) > LIM || Abs(Zmin) > LIM
1866 || Abs(Xmax) > LIM || Abs(Ymax) > LIM || Abs(Zmax) > LIM ) {
1867 ImmediateUpdate();
1868 return ;
1869 }
1870
7fd59977 1871 // CAL 6/11/98
1872 // Case when view contains only a point
1873 if (Xmin == Xmax && Ymin == Ymax && Zmin == Zmax) {
1874 ImmediateUpdate();
1875 return ;
1876 }
1877 MyView->Projects(Xmin,Ymin,Zmin,Umin,Vmin,Wmin) ;
1878 MyView->Projects(Xmax,Ymax,Zmax,Umax,Vmax,Wmax) ;
1879 MyView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
1880 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1881 MyView->Projects(Xmax,Ymin,Zmax,U,V,W) ;
1882 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1883 MyView->Projects(Xmax,Ymin,Zmin,U,V,W) ;
1884 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1885 MyView->Projects(Xmax,Ymax,Zmin,U,V,W) ;
1886 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1887 MyView->Projects(Xmin,Ymax,Zmax,U,V,W) ;
1888 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1889 MyView->Projects(Xmin,Ymax,Zmin,U,V,W) ;
1890 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1891 Wmax = Max(Abs(Wmin),Abs(Wmax)) ;
1892 if( Wmax > 0. ) {
1893 SetZSize(2.*Wmax + Coef * Wmax) ;
1894 }
1895 ImmediateUpdate();
1896}
1897
1898void V3d_View::DepthFitAll(const Quantity_Coefficient Aspect,
1899 const Quantity_Coefficient Margin)
1900{
1901 Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W,U1,V1,W1 ;
1902 Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ;
1903 Standard_Real Xrp,Yrp,Zrp,Dx,Dy,Dz,Size;
1904
1905 Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
1906
1907 if( (Nstruct <= 0) || (Aspect < 0.) || (Margin < 0.) || (Margin > 1.)) {
1908 ImmediateUpdate();
1909 return ;
1910 }
1911
1912 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
1913 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
1914
1915 MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
1916
1917 Standard_Real LIM = ShortRealLast() -1.;
1918 if (Abs(Xmin) > LIM || Abs(Ymin) > LIM || Abs(Zmin) > LIM
1919 || Abs(Xmax) > LIM || Abs(Ymax) > LIM || Abs(Zmax) > LIM ) {
1920 ImmediateUpdate();
1921 return ;
1922 }
1923
7fd59977 1924 if (Xmin == Xmax && Ymin == Ymax && Zmin == Zmax) {
1925 ImmediateUpdate();
1926 return ;
1927 }
1928 MyView->Projects(Xmin,Ymin,Zmin,U,V,W) ;
1929 MyView->Projects(Xmax,Ymax,Zmax,U1,V1,W1) ;
1930 Umin = Min(U,U1) ; Umax = Max(U,U1) ;
1931 Vmin = Min(V,V1) ; Vmax = Max(V,V1) ;
1932 Wmin = Min(W,W1) ; Wmax = Max(W,W1) ;
1933 MyView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
1934 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1935 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1936 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1937 MyView->Projects(Xmax,Ymin,Zmax,U,V,W) ;
1938 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1939 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1940 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1941 MyView->Projects(Xmax,Ymin,Zmin,U,V,W) ;
1942 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1943 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1944 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1945 MyView->Projects(Xmax,Ymax,Zmin,U,V,W) ;
1946 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1947 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1948 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1949 MyView->Projects(Xmin,Ymax,Zmax,U,V,W) ;
1950 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1951 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1952 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1953 MyView->Projects(Xmin,Ymax,Zmin,U,V,W) ;
1954 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1955 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1956 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1957
1958 // Adjust Z size
1959 Wmax = Max(Abs(Wmin),Abs(Wmax)) ;
1960 Dz = 2.*Wmax + Margin * Wmax;
1961
1962 // Compute depth value
1963 Dx = Abs(Umax - Umin) ; Dy = Abs(Vmax - Vmin) ; // Dz = Abs(Wmax - Wmin);
1964 Dx += Margin * Dx; Dy += Margin * Dy;
1965 Size = Sqrt(Dx*Dx + Dy*Dy + Dz*Dz);
1966 if( Size > 0. ) {
1967 SetZSize(Size) ;
1968 SetDepth( Aspect * Size / 2.);
1969 }
1970
1971 ImmediateUpdate();
1972}
1973
b8ddfc2f 1974void V3d_View::FitAll(const Standard_Real Xmin, const Standard_Real Ymin, const Standard_Real Xmax, const Standard_Real Ymax)
1975{
7fd59977 1976 FitAll(MyWindow,Xmin,Ymin,Xmax,Ymax);
1977#ifndef IMP020300
1978 ImmediateUpdate();
1979#endif
1980}
1981
b8ddfc2f 1982void V3d_View::WindowFitAll(const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax)
1983{
7fd59977 1984 WindowFit(Xmin,Ymin,Xmax,Ymax);
7fd59977 1985}
b8ddfc2f 1986
1987void V3d_View::WindowFit(const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax)
1988{
7fd59977 1989 Standard_Real x1,y1,x2,y2;
1990 Convert(Xmin,Ymin,x1,y1);
1991 Convert(Xmax,Ymax,x2,y2);
1992 FitAll(x1,y1,x2,y2);
1993}
1994
1995void V3d_View::SetViewMapping(const Visual3d_ViewMapping& VM)
1996{
1997 MyViewMapping = VM;
1998 // ajust view type according to mapping projection
1999 // NOTE: Might be dangerous, potentially conflicts with the C++ view class
2000 // (orthographic or perspective)! Use with care!
2001 if ( VM.Projection() == Visual3d_TOP_PERSPECTIVE )
2002 MyType = V3d_PERSPECTIVE;
2003 else MyType = V3d_ORTHOGRAPHIC;
2004
2005 MyView->SetViewMapping(MyViewMapping) ;
2006 ImmediateUpdate();
2007}
2008
b8ddfc2f 2009void V3d_View::SetViewMappingDefault()
2010{
7fd59977 2011 MyView->SetViewMapping(MyViewMapping) ;
2012 MyView->SetViewMappingDefault();
2013 ImmediateUpdate();
2014}
2015
b8ddfc2f 2016void V3d_View::ResetViewMapping()
2017{
7fd59977 2018 MyView->ViewMappingReset();
2019 MyViewMapping = MyView->ViewMapping() ;
2020#ifdef IMP020300
2021 ZFitAll (Zmargin);
2022 Update();
2023#else
2024 ImmediateUpdate();
2025#endif
2026}
2027
b8ddfc2f 2028Standard_Real V3d_View::Convert(const Standard_Integer Vp) const
2029{
7fd59977 2030 Standard_Real Umin,Umax,Vmin,Vmax,Dxv,Vv ;
2031 Standard_Integer Dxw,Dyw ;
2032
2033 V3d_UnMapped_Raise_if( !MyView->IsDefined(), "view has no window");
2034
2035 MyWindow->Size(Dxw,Dyw);
2036 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
2037 Dxv = Umax - Umin ;
2038 Vv = Dxv*(Standard_Real)Vp/(Standard_Real)Dxw ;
2039
2040 return Vv ;
2041}
2042
b8ddfc2f 2043void V3d_View::Convert(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& Xv, Standard_Real& Yv) const
2044{
7fd59977 2045 Standard_Real Umin,Umax,Vmin,Vmax,Dxv,Dyv ;
2046 Standard_Integer Dxw,Dyw ;
2047
2048 V3d_UnMapped_Raise_if( !MyView->IsDefined(), "view has no window");
2049
2050 MyWindow->Size(Dxw,Dyw);
2051 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
2052 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
2053 Xv = Umin + Dxv*(Standard_Real)Xp/(Standard_Real)Dxw ;
2054 Yv = Vmin + Dyv*(Standard_Real)(Dyw-Yp)/(Standard_Real)Dyw ;
2055}
2056
2057Standard_Integer V3d_View::Convert(const Standard_Real Vv) const
2058{
2059 V3d_UnMapped_Raise_if( !MyView->IsDefined(), "view has no window");
2060
2061 Standard_Integer Dxw, Dyw;
2062 MyWindow->Size(Dxw,Dyw);
2063
2064 Standard_Real Umin,Umax,Vmin,Vmax;
2065 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
2066 Standard_Real Dxv = Umax - Umin;
2067 return RealToInt ( Dxw * Vv / Dxv );
2068}
2069
2070void V3d_View::Convert(const Standard_Real Xv, const Standard_Real Yv, Standard_Integer& Xp, Standard_Integer& Yp) const
2071{
2072 V3d_UnMapped_Raise_if( !MyView->IsDefined(), "view has no window");
2073
2074 Standard_Integer Dxw, Dyw;
2075 MyWindow->Size(Dxw,Dyw);
2076
2077 Standard_Real Umin,Umax,Vmin,Vmax;
2078 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
2079 Standard_Real Dxv = Umax - Umin;
2080 Standard_Real Dyv = Vmax - Vmin;
2081
2082 // CAL 15/12/93 warning: double assigned to int
2083 Xp = RealToInt (Dxw*(Xv - Umin)/Dxv);
2084 // CAL 15/12/93 warning: double assigned to int
2085 Yp = Dyw - RealToInt (Dyw*(Yv - Vmin)/Dyv);
2086}
2087
b8ddfc2f 2088void V3d_View::Convert(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
2089{
7fd59977 2090 Graphic3d_Vertex Vrp ;
2091 Vrp = (MyViewer->Viewer())->ConvertCoord(MyWindow,Xp,Yp) ;
2092 Vrp.Coord(X,Y,Z) ;
2093#ifndef IMP240100
2094 if( MyViewer->Grid()->IsActive() ) {
2095 Graphic3d_Vertex NewVrp = Compute(Vrp) ;
2096 NewVrp.Coord(X,Y,Z) ;
2097 }
2098#endif
2099}
2100
2101void V3d_View::ConvertWithProj(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& X, Standard_Real& Y, Standard_Real& Z, Standard_Real& Dx, Standard_Real& Dy, Standard_Real& Dz) const
2102{
2103 Graphic3d_Vertex Vrp ;
2104 Graphic3d_Vector Proj ;
2105 (MyViewer->Viewer())->ConvertCoordWithProj(MyWindow,Xp,Yp, Vrp, Proj) ;
2106 Vrp.Coord(X,Y,Z) ;
2107 Proj.Coord(Dx,Dy,Dz) ;
2108#ifndef IMP240100
2109 if( MyViewer->Grid()->IsActive() ) {
2110 Graphic3d_Vertex NewVrp = Compute(Vrp) ;
2111 NewVrp.Coord(X,Y,Z) ;
2112 }
2113#endif
2114}
2115
2116#ifdef IMP240100
b8ddfc2f 2117void V3d_View::ConvertToGrid(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const
2118{
7fd59977 2119 Graphic3d_Vertex Vrp ;
2120 Vrp = (MyViewer->Viewer())->ConvertCoord(MyWindow,Xp,Yp) ;
2121 if( MyViewer->Grid()->IsActive() ) {
2122 Graphic3d_Vertex NewVrp = Compute(Vrp) ;
2123 NewVrp.Coord(Xg,Yg,Zg) ;
2124 } else
2125 Vrp.Coord(Xg,Yg,Zg) ;
2126}
2127
b8ddfc2f 2128void V3d_View::ConvertToGrid(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const
2129{
7fd59977 2130 if( MyViewer->Grid()->IsActive() ) {
2131 Graphic3d_Vertex Vrp(X,Y,Z) ;
2132 Graphic3d_Vertex NewVrp = Compute(Vrp) ;
2133 NewVrp.Coord(Xg,Yg,Zg) ;
2134 } else {
2135 Xg = X; Yg = Y; Zg = Z;
2136 }
2137}
2138#endif
2139
2140#ifndef IMP240100
b8ddfc2f 2141void V3d_View::PixToRef(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
2142{
7fd59977 2143 Graphic3d_Vertex Vrp ;
2144 Vrp = (MyViewer->Viewer())->ConvertCoord(MyWindow,Xp,Yp) ;
2145 Vrp.Coord(X,Y,Z) ;
2146 if( MyViewer->Grid()->IsActive() ) {
2147 Graphic3d_Vertex NewVrp = Compute(Vrp) ;
2148 NewVrp.Coord(X,Y,Z) ;
2149 }
2150}
2151#endif
2152
2153#ifdef IMP240100
b8ddfc2f 2154void V3d_View::Convert(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Integer& Xp, Standard_Integer& Yp) const
7fd59977 2155#else
b8ddfc2f 2156void V3d_View::RefToPix(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Integer& Xp, Standard_Integer& Yp) const
7fd59977 2157#endif
b8ddfc2f 2158{
7fd59977 2159 Graphic3d_Vertex Vrp(X,Y,Z) ;
2160 (MyViewer->Viewer())->ConvertCoord(MyWindow,Vrp,Xp,Yp) ;
2161}
2162
2163void V3d_View::Project(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Real &Xp, Standard_Real &Yp) const
2164{
2165 if ( MyType != V3d_PERSPECTIVE )
2166 {
2167 // use old implementation
2168 Standard_Real Zp;
2169 MyView->Projects( X, Y, Z, Xp, Yp, Zp );
2170 }
2171 else
2172 {
2173 // NKV - Using raster projection
2174 Standard_Integer Xpx, Ypx;
2175 Convert(X, Y, Z, Xpx, Ypx);
2176 Convert(Xpx, Ypx, Xp, Yp);
2177 }
2178}
2179
b8ddfc2f 2180void V3d_View::BackgroundColor(const Quantity_TypeOfColor Type,Standard_Real& V1, Standard_Real& V2, Standard_Real& V3) const
2181{
7fd59977 2182 Quantity_Color C = BackgroundColor() ;
7fd59977 2183 C.Values(V1,V2,V3,Type) ;
2184}
2185
b8ddfc2f 2186Quantity_Color V3d_View::BackgroundColor() const
2187{
7fd59977 2188 return MyBackground.Color() ;
2189}
7fd59977 2190
b8ddfc2f 2191void V3d_View::GradientBackgroundColors(Quantity_Color& Color1,Quantity_Color& Color2) const
2192{
7fd59977 2193 MyGradientBackground.Colors(Color1, Color2);
2194}
2195
b8ddfc2f 2196Aspect_GradientBackground V3d_View::GradientBackground() const
2197{
7fd59977 2198 return MyGradientBackground;
2199}
2200
b8ddfc2f 2201Standard_Real V3d_View::Scale() const
2202{
7fd59977 2203 Standard_Real Umin,Vmin,Umax,Vmax,Dxv ;
2204 Visual3d_ViewMapping VMD = MyView->ViewMappingDefault() ;
2205 Standard_Real S = 0. ;
2206
2207 VMD.WindowLimit(Umin,Vmin,Umax,Vmax) ;
2208 Dxv = Umax - Umin ;
2209 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
2210 if( Umax > Umin && Vmax > Vmin ) S = Dxv/(Umax - Umin) ;
2211 return S ;
2212}
2213
b8ddfc2f 2214void V3d_View::AxialScale(Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz) const
2215{
7fd59977 2216 MyViewOrientation.AxialScale( Sx, Sy, Sz );
2217}
2218
b8ddfc2f 2219void V3d_View::Center(Standard_Real& Xc, Standard_Real& Yc) const
2220{
7fd59977 2221 Standard_Real Umin,Vmin,Umax,Vmax ;
2222
2223 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
2224 Xc = (Umin + Umax)/2. ;
2225 Yc = (Vmin + Vmax)/2. ;
2226}
2227
b8ddfc2f 2228void V3d_View::Size(Standard_Real& Width, Standard_Real& Height) const
2229{
7fd59977 2230 Standard_Real Umin,Vmin,Umax,Vmax ;
2231
2232 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
2233 Width = Umax - Umin ;
2234 Height = Vmax - Vmin ;
2235}
2236
b8ddfc2f 2237Standard_Real V3d_View::ZSize() const
2238{
7fd59977 2239 Standard_Real Wmin,Wmax,Depth ;
2240
2241 Wmax = MyViewMapping.FrontPlaneDistance() ;
2242 Wmin = MyViewMapping.BackPlaneDistance() ;
2243 Depth = 2. * Max(Wmin,Wmax) ;
2244 return (Depth) ;
2245}
2246
b8ddfc2f 2247Standard_Integer V3d_View::MinMax(Standard_Real& Umin, Standard_Real& Vmin, Standard_Real& Umax, Standard_Real& Vmax) const
2248{
7fd59977 2249 Standard_Real Wmin,Wmax,U,V,W ;
2250 Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax ;
2251 // CAL 6/11/98
2252 Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
2253
2254 if( Nstruct ) {
2255 MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
2256 MyView->Projects(Xmin,Ymin,Zmin,Umin,Vmin,Wmin) ;
2257 MyView->Projects(Xmax,Ymax,Zmax,Umax,Vmax,Wmax) ;
2258 MyView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
2259 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
2260 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
2261 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
2262 MyView->Projects(Xmax,Ymin,Zmax,U,V,W) ;
2263 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
2264 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
2265 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
2266 MyView->Projects(Xmax,Ymin,Zmin,U,V,W) ;
2267 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
2268 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
2269 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
2270 MyView->Projects(Xmax,Ymax,Zmin,U,V,W) ;
2271 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
2272 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
2273 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
2274 MyView->Projects(Xmin,Ymax,Zmax,U,V,W) ;
2275 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
2276 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
2277 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
2278 MyView->Projects(Xmin,Ymax,Zmin,U,V,W) ;
2279 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
2280 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
2281 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
2282 }
2283 return Nstruct ;
2284}
2285
b8ddfc2f 2286Standard_Integer V3d_View::MinMax(Standard_Real& Xmin, Standard_Real& Ymin, Standard_Real& Zmin, Standard_Real& Xmax, Standard_Real& Ymax, Standard_Real& Zmax) const
2287{
7fd59977 2288 // CAL 6/11/98
2289 // Standard_Integer Nstruct = (MyView->DisplayedStructures())->Extent() ;
2290 Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
2291
2292 if( Nstruct ) {
2293 MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
2294 }
2295 return Nstruct ;
2296}
2297
b8ddfc2f 2298Standard_Integer V3d_View::Gravity(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
2299{
7fd59977 2300 Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ;
2301 Standard_Real Umin,Vmin,Umax,Vmax ;
2302 Standard_Integer Nstruct,Npoint ;
2303 Graphic3d_MapOfStructure MySetOfStructures;
2304
2305 MyView->DisplayedStructures (MySetOfStructures);
2306 Nstruct = MySetOfStructures.Extent() ;
2307
2308 Graphic3d_MapIteratorOfMapOfStructure MyIterator(MySetOfStructures) ;
2309
2310 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
2311 Npoint = 0 ; X = Y = Z = 0. ;
2312 for( ; MyIterator.More(); MyIterator.Next()) {
2313 if (!(MyIterator.Key())->IsEmpty()) {
2314 (MyIterator.Key())->MinMaxValues(Xmin,Ymin,Zmin,
2315 Xmax,Ymax,Zmax) ;
2316
2317 Standard_Real LIM = ShortRealLast() -1.;
2318 if (! (Abs(Xmin) > LIM || Abs(Ymin) > LIM || Abs(Zmin) > LIM
2319 || Abs(Xmax) > LIM || Abs(Ymax) > LIM || Abs(Zmax) > LIM )) {
2320
2321 MyView->Projects(Xmin,Ymin,Zmin,U,V,W) ;
2322 if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
2323 Npoint++ ; X += Xmin ; Y += Ymin ; Z += Zmin ;
2324 }
2325 MyView->Projects(Xmax,Ymin,Zmin,U,V,W) ;
2326 if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
2327 Npoint++ ; X += Xmax ; Y += Ymin ; Z += Zmin ;
2328 }
2329 MyView->Projects(Xmin,Ymax,Zmin,U,V,W) ;
2330 if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
2331 Npoint++ ; X += Xmin ; Y += Ymax ; Z += Zmin ;
2332 }
2333 MyView->Projects(Xmax,Ymax,Zmin,U,V,W) ;
2334 if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
2335 Npoint++ ; X += Xmax ; Y += Ymax ; Z += Zmin ;
2336 }
2337 MyView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
2338 if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
2339 Npoint++ ; X += Xmin ; Y += Ymin ; Z += Zmax ;
2340 }
2341 MyView->Projects(Xmax,Ymin,Zmax,U,V,W) ;
2342 if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
2343 Npoint++ ; X += Xmax ; Y += Ymin ; Z += Zmax ;
2344 }
2345 MyView->Projects(Xmin,Ymax,Zmax,U,V,W) ;
2346 if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
2347 Npoint++ ; X += Xmin ; Y += Ymax ; Z += Zmax ;
2348 }
2349 MyView->Projects(Xmax,Ymax,Zmax,U,V,W) ;
2350 if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
2351 Npoint++ ; X += Xmax ; Y += Ymax ; Z += Zmax ;
2352 }
2353 }
2354 }
2355 }
2356 if( Npoint > 0 ) {
2357 X /= Npoint ; Y /= Npoint ; Z /= Npoint ;
2358 }
2359
2360 return Nstruct ;
2361}
2362
b8ddfc2f 2363void V3d_View::Eye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
2364{
7fd59977 2365 Graphic3d_Vertex Prp ;
2366 Graphic3d_Vector Vpn ;
2367 Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xat,Yat,Zat ;
2368
2369 MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
2370 MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
2371 Prp = MyViewMapping.ProjectionReferencePoint() ;
2372 Prp.Coord(Xrp,Yrp,Zrp) ;
2373 Vpn = MyViewOrientation.ViewReferencePlane() ;
2374 Vpn.Coord(Xpn,Ypn,Zpn) ;
2375 X = Zrp*Xpn + Xat; Y = Zrp*Ypn + Yat; Z = Zrp*Zpn + Zat;
2376}
2377
b8ddfc2f 2378void V3d_View::FocalReferencePoint(Standard_Real& X, Standard_Real& Y,Standard_Real& Z) const
2379{
7fd59977 2380 Graphic3d_Vertex PRP,VRPoint;
2381 Graphic3d_Vector VRPlane;
2382 Standard_Real FPD,Xprp,Yprp,Zprp;
2383 Standard_Real Xvrp,Yvrp,Zvrp,DXvrp,DYvrp,DZvrp;
2384
2385 if ( MyType == V3d_PERSPECTIVE ) {
2386 PRP = MyViewMapping.ProjectionReferencePoint() ;
2387 FPD = MyViewMapping.FrontPlaneDistance();
2388 PRP.Coord(Xprp,Yprp,Zprp);
2389 VRPoint = MyViewOrientation.ViewReferencePoint();
2390 VRPoint.Coord(Xvrp,Yvrp,Zvrp);
2391 VRPlane = MyViewOrientation.ViewReferencePlane();
2392 VRPlane.Coord(DXvrp,DYvrp,DZvrp);
2393 X = (FPD + Zprp) * DXvrp + Xvrp;
2394 Y = (FPD + Zprp) * DYvrp + Yvrp;
2395 Z = (FPD + Zprp) * DZvrp + Zvrp;
2396 }
2397 else Eye(X,Y,Z);
2398}
2399
b8ddfc2f 2400void V3d_View::ProjReferenceAxe(const Standard_Integer Xpix, const Standard_Integer Ypix, Standard_Real& XP, Standard_Real& YP, Standard_Real& ZP, Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ) const
2401{
7fd59977 2402 Standard_Real Xo,Yo,Zo;
2403
2404 Convert(Xpix,Ypix,XP,YP,ZP);
2405 if ( MyType == V3d_PERSPECTIVE ) {
2406 FocalReferencePoint(Xo,Yo,Zo);
2407 VX = Xo - XP;
2408 VY = Yo - YP;
2409 VZ = Zo - ZP;
2410 }
2411 else {
2412 Proj(VX,VY,VZ);
2413 }
2414}
2415
b8ddfc2f 2416Standard_Real V3d_View::Depth() const
2417{
7fd59977 2418 Graphic3d_Vertex Prp ;
2419 Standard_Real Xrp,Yrp,Zrp ;
2420
2421 Prp = MyViewMapping.ProjectionReferencePoint() ;
2422 Prp.Coord(Xrp,Yrp,Zrp) ;
2423 return Zrp ;
2424}
2425
b8ddfc2f 2426void V3d_View::Proj(Standard_Real& Dx, Standard_Real& Dy, Standard_Real& Dz) const
2427{
7fd59977 2428 Graphic3d_Vector Vpn ;
2429
2430 Vpn = MyViewOrientation.ViewReferencePlane() ;
2431 Vpn.Coord(Dx,Dy,Dz) ;
2432}
2433
b8ddfc2f 2434void V3d_View::At(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
2435{
7fd59977 2436 Graphic3d_Vertex Vrp ;
2437
2438 Vrp = MyViewOrientation.ViewReferencePoint() ;
2439 Vrp.Coord(X,Y,Z) ;
2440}
2441
b8ddfc2f 2442void V3d_View::Up(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const
2443{
7fd59977 2444 Graphic3d_Vector Vup ;
2445
2446 Vup = MyViewOrientation.ViewReferenceUp() ;
2447 Vup.Coord(Vx,Vy,Vz) ;
2448}
2449
b8ddfc2f 2450Standard_Real V3d_View::Twist() const
2451{
7fd59977 2452 Standard_Real Xup,Yup,Zup,Xpn,Ypn,Zpn,X0,Y0,Z0 ;
2453 Standard_Real pvx,pvy,pvz,pvn,sca,angle ;
2454 Graphic3d_Vector Vpn,Vup,Xaxis,Yaxis,Zaxis ;
2455 Standard_Boolean TheStatus ;
2456
2457 Vpn = MyViewOrientation.ViewReferencePlane() ;
2458 Vpn.Coord(Xpn,Ypn,Zpn) ;
2459 Vup.SetCoord(0.,0.,1.) ;
2460 TheStatus = ScreenAxis(Vpn,Vup,Xaxis,Yaxis,Zaxis) ;
2461 if( !TheStatus ) {
2462 Vup.SetCoord(0.,1.,0.) ;
2463 TheStatus = ScreenAxis(Vpn,Vup,Xaxis,Yaxis,Zaxis) ;
2464 }
2465 if( !TheStatus ) {
2466 Vup.SetCoord(1.,0.,0.) ;
2467 TheStatus = ScreenAxis(Vpn,Vup,Xaxis,Yaxis,Zaxis) ;
2468 }
2469 Yaxis.Coord(X0,Y0,Z0) ;
2470 Vup = MyViewOrientation.ViewReferenceUp() ;
2471 Vup.Coord(Xup,Yup,Zup) ;
2472 /* Compute Cross Vector From Up & Origin */
2473 pvx = Y0*Zup - Z0*Yup ;
2474 pvy = Z0*Xup - X0*Zup ;
2475 pvz = X0*Yup - Y0*Xup ;
2476 pvn = pvx*pvx + pvy*pvy + pvz*pvz ;
2477 sca = X0*Xup + Y0*Yup + Z0*Zup ;
2478 /* Compute Angle */
2479 angle = Sqrt(pvn) ;
2480 if( angle > 1. ) angle = 1. ;
2481 else if( angle < -1. ) angle = -1. ;
2482 angle = asin(angle) ;
c6541a0c
D
2483 if( sca < 0. ) angle = M_PI - angle ;
2484 if( angle > 0. && angle < M_PI ) {
7fd59977 2485 sca = pvx*Xpn + pvy*Ypn + pvz*Zpn ;
2486 if( sca < 0. ) angle = DEUXPI - angle ;
2487 }
2488 return angle ;
2489}
2490
b8ddfc2f 2491V3d_TypeOfShadingModel V3d_View::ShadingModel() const
2492{
7fd59977 2493 V3d_TypeOfShadingModel SM = (V3d_TypeOfShadingModel)MyViewContext.Model() ;
2494 return SM ;
2495}
2496
b8ddfc2f 2497V3d_TypeOfSurfaceDetail V3d_View::SurfaceDetail() const
2498{
7fd59977 2499 V3d_TypeOfSurfaceDetail SM = (V3d_TypeOfSurfaceDetail)MyViewContext.SurfaceDetail() ;
2500 return SM ;
2501}
2502
b8ddfc2f 2503Handle_Graphic3d_TextureEnv V3d_View::TextureEnv() const
2504{
7fd59977 2505 Handle(Graphic3d_TextureEnv) SM = MyViewContext.TextureEnv() ;
2506 return SM ;
2507}
2508
b8ddfc2f 2509V3d_TypeOfVisualization V3d_View::Visualization() const
2510{
7fd59977 2511 V3d_TypeOfVisualization V =
2512 (V3d_TypeOfVisualization)MyViewContext.Visualization() ;
2513 return V ;
2514}
2515
b8ddfc2f 2516Standard_Boolean V3d_View::Antialiasing() const
2517{
7fd59977 2518 Standard_Boolean A = MyViewContext.AliasingIsOn() ;
2519 return A ;
2520}
2521
b8ddfc2f 2522Handle(V3d_Viewer) V3d_View::Viewer() const
2523{
7fd59977 2524 return MyViewer ;
2525}
2526
b8ddfc2f 2527Standard_Boolean V3d_View::IfWindow() const
2528{
7fd59977 2529 Standard_Boolean TheStatus = MyView->IsDefined() ;
2530 return TheStatus ;
2531}
2532
b8ddfc2f 2533Handle(Aspect_Window) V3d_View::Window() const
2534{
7fd59977 2535 return MyWindow;
2536}
2537
b8ddfc2f 2538V3d_TypeOfView V3d_View::Type() const
2539{
7fd59977 2540 return (MyType) ;
2541}
2542
b8ddfc2f 2543void V3d_View::SetFocale( const Standard_Real focale )
2544{
7fd59977 2545 Standard_TypeMismatch_Raise_if (MyType != V3d_PERSPECTIVE,
2546 "the view is not a perspective view");
2547 Standard_Real Xrp,Yrp,Zrp,ViewPlane,FrontPlane ;
2548 Graphic3d_Vertex Prp ;
2549 Prp = MyViewMapping.ProjectionReferencePoint() ;
2550 Prp.Coord(Xrp,Yrp,Zrp) ;
2551 if( MyProjModel == V3d_TPM_WALKTHROUGH ) {
2552 ViewPlane = Zrp - focale ;
2553 } else {
2554 FrontPlane = MyViewMapping.FrontPlaneDistance() ;
2555 ViewPlane = FrontPlane + Zrp - focale ;
2556 }
2557 MyViewMapping.SetViewPlaneDistance(ViewPlane) ;
2558 MyView->SetViewMapping(MyViewMapping) ;
2559
2560 ImmediateUpdate();
2561}
2562
b8ddfc2f 2563Standard_Real V3d_View::Focale( ) const
2564{
7fd59977 2565 Standard_Real Xrp,Yrp,Zrp,ViewPlane,FrontPlane ;
2566 Standard_Real focale = 0.0 ;
2567 Graphic3d_Vertex Prp ;
2568
2569 if( MyType == V3d_PERSPECTIVE ) {
2570 Prp = MyViewMapping.ProjectionReferencePoint() ;
2571 Prp.Coord(Xrp,Yrp,Zrp) ;
2572 ViewPlane = MyViewMapping.ViewPlaneDistance() ;
2573 if( MyProjModel == V3d_TPM_WALKTHROUGH ) {
2574 focale = Zrp - ViewPlane ;
2575 } else {
2576 FrontPlane = MyViewMapping.FrontPlaneDistance() ;
2577 focale = FrontPlane + Zrp - ViewPlane ;
2578 }
2579 }
2580 return (focale) ;
2581}
2582
2583void V3d_View::SetViewingVolume(const Standard_Real Left, const Standard_Real Right,
2584 const Standard_Real Bottom, const Standard_Real Top,
2585 const Standard_Real ZNear, const Standard_Real ZFar)
2586{
2587 Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Zrp;
2588
2589 Viewer_BadValue_Raise_if ( ZNear <= 0. || ZFar <= 0. || ZNear >= ZFar, "V3d_View::SetVolume, bad distances");
2590
2591 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
2592 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
2593 Zrp = ZNear;
2594
2595 Standard_Real size = (ZFar - ZNear) / 2.;
2596
2597 MyViewMapping.SetFrontPlaneDistance(size);
2598 MyViewMapping.SetBackPlaneDistance(-size);
2599
2600 // keep view plane at front plane distance
2601 MyViewMapping.SetViewPlaneDistance(MyType == V3d_PERSPECTIVE ? 0. : size);
2602
2603 // set window limits
2604 Umin = Left; Umax = Right;
2605 Vmin = Bottom; Vmax = Top;
2606 MyViewMapping.SetWindowLimit(Left, Bottom, Right, Top);
2607
2608 // Update window center
2609 if ( MyType == V3d_PERSPECTIVE ) {
2610 Xrp = Yrp = 0.0;
2611 }
2612 else {
2613 Xrp = (Umin + Umax)/2. ; Yrp = (Vmin + Vmax)/2. ;
2614 }
2615 MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
2616 MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
2617
2618 MyView->SetViewMapping(MyViewMapping) ;
2619 // SetZSize(0.);
2620 ImmediateUpdate();
2621}
2622
2623Handle(Visual3d_View) V3d_View::View() const
2624{
2625 return MyView ;
2626}
2627
2628Visual3d_ViewMapping V3d_View::ViewMapping() const
2629{
2630 return MyViewMapping;
2631}
2632
2633Visual3d_ViewOrientation V3d_View::ViewOrientation() const
2634{
2635 return MyViewOrientation;
2636}
2637
b8ddfc2f 2638Standard_Boolean V3d_View::ScreenAxis( const Graphic3d_Vector &Vpn, const Graphic3d_Vector &Vup, Graphic3d_Vector &Xaxe, Graphic3d_Vector &Yaxe, Graphic3d_Vector &Zaxe)
2639{
7fd59977 2640 Standard_Real Xpn,Ypn,Zpn,Xup,Yup,Zup ;
2641 Standard_Real dx1,dy1,dz1,dx2,dy2,dz2,xx,yy,zz ;
2642
2643 Vpn.Coord(Xpn,Ypn,Zpn) ;
2644 Vup.Coord(Xup,Yup,Zup) ;
2645 xx = Yup*Zpn - Zup*Ypn ;
2646 yy = Zup*Xpn - Xup*Zpn ;
2647 zz = Xup*Ypn - Yup*Xpn ;
2648 Xaxe.SetCoord(xx,yy,zz) ;
2649 if( Xaxe.LengthZero() ) return Standard_False;
2650 Xaxe.Normalize() ; Xaxe.Coord(dx1,dy1,dz1) ;
2651 xx = Ypn*dz1 - Zpn*dy1 ;
2652 yy = Zpn*dx1 - Xpn*dz1 ;
2653 zz = Xpn*dy1 - Ypn*dx1 ;
2654 Yaxe.SetCoord(xx,yy,zz) ;
2655 if( Yaxe.LengthZero() ) return Standard_False;
2656 Yaxe.Normalize() ; Yaxe.Coord(dx2,dy2,dz2) ;
2657 xx = dy1*dz2 - dz1*dy2 ;
2658 yy = dz1*dx2 - dx1*dz2 ;
2659 zz = dx1*dy2 - dy1*dx2 ;
2660 Zaxe.SetCoord(xx,yy,zz) ;
2661 if( Zaxe.LengthZero() ) return Standard_False;
2662 Zaxe.Normalize() ;
2663 return Standard_True ;
2664}
2665
b8ddfc2f 2666void V3d_View::InitMatrix( TColStd_Array2OfReal& Matrix )
2667{
7fd59977 2668 Standard_Integer LR = Matrix.LowerRow() ;
2669 Standard_Integer UR = Matrix.UpperRow() ;
2670 Standard_Integer LC = Matrix.LowerCol() ;
2671 Standard_Integer UC = Matrix.UpperCol() ;
2672 Standard_Integer I,J ;
2673
2674 for( I=LR ; I<=UR ; I++ ) {
2675 for( J=LC ; J<=UC ; J++ ) Matrix(I,J) = 0. ;
2676 }
2677 for( I=LR,J=LC ; I<=UR ; I++,J++ ) Matrix(I,J) = 1. ;
2678}
2679
b8ddfc2f 2680Standard_Boolean V3d_View::Multiply (const TColStd_Array2OfReal& Left, const TColStd_Array2OfReal& Right, TColStd_Array2OfReal& Matrix)
2681{
7fd59977 2682 Standard_Integer llr = Left.LowerRow ();
2683 Standard_Integer llc = Left.LowerCol ();
2684 Standard_Integer luc = Left.UpperCol ();
2685
2686 Standard_Integer rlr = Right.LowerRow ();
2687 Standard_Integer rur = Right.UpperRow ();
2688 Standard_Integer rlc = Right.LowerCol ();
2689
2690 Standard_Integer mlr = Matrix.LowerRow ();
2691 Standard_Integer mur = Matrix.UpperRow ();
2692 Standard_Integer mlc = Matrix.LowerCol ();
2693 Standard_Integer muc = Matrix.UpperCol ();
2694
2695 TColStd_Array2OfReal Result (mlr, mur, mlc, muc);
2696
2697 InitMatrix (Result);
2698
2699 // Left et Right incompatibles
2700 if (luc - llc + 1 != rur - rlr + 1)
2701 return Standard_False;
2702
2703 Standard_Integer i, j, k;
2704
2705 Standard_Real Som;
2706 Standard_Integer I1 = llr;
2707
2708 for (i=mlr; i<=mur; i++) {
2709 Standard_Integer J2 = rlc;
2710 for (j=mlc; j<=muc; j++) {
2711 Som = 0.0;
2712 Standard_Integer J1 = llc;
2713 Standard_Integer I2 = rlr;
2714 for (k=llc; k<=luc; k++) {
2715 Som = Som + Left (I1, J1) * Right (I2, J2);
2716 J1++;
2717 I2++;
2718 }
2719 Result (i, j) = Som;
2720 J2++;
2721 }
2722 I1++;
2723 }
2724
2725 for (i=mlr; i<=mur; i++)
2726 for (j=mlc; j<=muc; j++)
2727 Matrix (i, j) = Result (i, j);
2728
2729 return Standard_True;
2730}
2731
2732/*----------------------------------------------------------------------*/
2733
b8ddfc2f 2734void V3d_View::RotAxis( const Graphic3d_Vertex &Vrp, const Graphic3d_Vector &Axe, const Standard_Real angle, TColStd_Array2OfReal& Matrix )
2735{
7fd59977 2736 Standard_Real Xrp,Yrp,Zrp,Xaxe,Yaxe,Zaxe ;
2737 Standard_Real sina,cosa,cos1m,terms1,terms2,terms3 ;
2738 Standard_Real termc12,termc13,termc23,vcal ;
2739 TColStd_Array2OfReal Tmatrix(0,3,0,3) ;
2740 TColStd_Array2OfReal Rmatrix(0,3,0,3) ;
2741
2742 InitMatrix(Matrix) ;
2743 InitMatrix(Tmatrix) ;
2744
2745 Vrp.Coord(Xrp,Yrp,Zrp) ;
2746 Axe.Coord(Xaxe,Yaxe,Zaxe) ;
2747 /* translation of x,y,z */
2748 Tmatrix(0,3) = Xrp ; Tmatrix(1,3) = Yrp ; Tmatrix(2,3) = Zrp ;
2749 /* rotation around an axis */
2750 cosa = cos(angle); sina = sin(angle); cos1m = 1. - cosa ;
2751 termc12 = Xaxe * Yaxe * cos1m ;
2752 termc13 = Xaxe * Zaxe * cos1m ;
2753 termc23 = Yaxe * Zaxe * cos1m ;
2754 terms1 = Xaxe * sina ;
2755 terms2 = Yaxe * sina ;
2756 terms3 = Zaxe * sina ;
2757
2758 vcal = Xaxe * Xaxe ;
2759 Rmatrix(0,0) = vcal + ( 1. - vcal ) * cosa ;
2760 Rmatrix(1,0) = termc12 + terms3 ;
2761 Rmatrix(2,0) = termc13 - terms2 ;
2762 Rmatrix(3,0) = 0. ;
2763 Rmatrix(0,1) = termc12 - terms3 ;
2764 vcal = Yaxe * Yaxe ;
2765 Rmatrix(1,1) = vcal + ( 1. - vcal ) * cosa ;
2766 Rmatrix(2,1) = termc23 + terms1 ;
2767 Rmatrix(3,1) = 0. ;
2768 Rmatrix(0,2) = termc13 + terms2 ;
2769 Rmatrix(1,2) = termc23 - terms1 ;
2770 vcal = Zaxe * Zaxe ;
2771 Rmatrix(2,2) = vcal + ( 1. - vcal ) * cosa ;
2772 Rmatrix(3,2) = 0. ;
2773 Rmatrix(0,3) = 0. ;
2774 Rmatrix(1,3) = 0. ;
2775 Rmatrix(2,3) = 0. ;
2776 Rmatrix(3,3) = 1. ;
2777 /* produced by two matrices */
2778 Multiply(Tmatrix, Rmatrix, Matrix);
2779 /* translation invert */
2780 Tmatrix(0,3) = -Xrp;
2781 Tmatrix(1,3) = -Yrp;
2782 Tmatrix(2,3) = -Zrp;
2783 /* product final */
2784 Multiply(Matrix, Tmatrix, Matrix);
2785}
2786
2787/*----------------------------------------------------------------------*/
2788
b8ddfc2f 2789Graphic3d_Vertex V3d_View::TrsPoint( const Graphic3d_Vertex &P, const TColStd_Array2OfReal &Matrix )
2790{
7fd59977 2791 Graphic3d_Vertex PP ;
2792 Standard_Real X,Y,Z,XX,YY,ZZ ;
2793
2794 // CAL. S3892
2795 Standard_Integer lr, ur, lc, uc;
2796 lr = Matrix.LowerRow ();
2797 ur = Matrix.UpperRow ();
2798 lc = Matrix.LowerCol ();
2799 uc = Matrix.UpperCol ();
2800 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) ) {
2801 P.Coord(X,Y,Z) ;
2802 PP.SetCoord(X,Y,Z) ;
2803 return PP ;
2804 }
2805 P.Coord(X,Y,Z) ;
2806 XX = (Matrix(lr,lc+3) + X*Matrix(lr,lc) + Y*Matrix(lr,lc+1)+
2807 Z*Matrix(lr,lc+2))/Matrix(lr+3,lc+3) ;
2808
2809 YY = (Matrix(lr+1,lc+3) + X*Matrix(lr+1,lc) + Y*Matrix(lr+1,lc+1) +
2810 Z*Matrix(lr+1,lc+2))/Matrix(lr+3,lc+3) ;
2811
2812 ZZ = (Matrix(lr+2,lc+3) + X*Matrix(lr+2,lc) + Y*Matrix(lr+2,lc+1) +
2813 Z*Matrix(lr+2,lc+2))/Matrix(lr+3,lc+3) ;
2814 PP.SetCoord(XX,YY,ZZ) ;
2815 return PP ;
2816}
2817
b8ddfc2f 2818Graphic3d_Vector V3d_View::TrsPoint( const Graphic3d_Vector& V, const TColStd_Array2OfReal& Matrix )
2819{
7fd59977 2820 Graphic3d_Vector VV ;
2821 Standard_Real X,Y,Z,XX,YY,ZZ ;
2822
2823 // CAL. S3892
2824 Standard_Integer lr, ur, lc, uc;
2825 lr = Matrix.LowerRow ();
2826 ur = Matrix.UpperRow ();
2827 lc = Matrix.LowerCol ();
2828 uc = Matrix.UpperCol ();
2829 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) ) {
2830 V.Coord(X,Y,Z) ;
2831 VV.SetCoord(X,Y,Z) ;
2832 return VV ;
2833 }
2834 V.Coord(X,Y,Z) ;
2835 XX = X*Matrix(lr,lc)+Y*Matrix(lr,lc+1)+Z*Matrix(lr,lc+2) ;
2836 YY = X*Matrix(lr+1,lc)+Y*Matrix(lr+1,lc+1)+Z*Matrix(lr+1,lc+2) ;
2837 ZZ = X*Matrix(lr+2,lc)+Y*Matrix(lr+2,lc+1)+Z*Matrix(lr+2,lc+2) ;
2838 VV.SetCoord(XX,YY,ZZ) ; VV.Normalize() ;
2839 return VV ;
2840}
2841
b8ddfc2f 2842void V3d_View::Pan(const Standard_Integer Dx, const Standard_Integer Dy,const Quantity_Factor aZoomFactor)
2843{
7fd59977 2844 Panning(Convert(Dx),Convert(Dy),aZoomFactor,Standard_True);
7fd59977 2845}
2846
2847void V3d_View::Zoom (const Standard_Integer X1,
2848 const Standard_Integer Y1,
2849 const Standard_Integer X2,
2850 const Standard_Integer Y2)
2851{
2852
2853 Standard_Real dx = Standard_Real (X2-X1);
2854 Standard_Real dy = Standard_Real (Y2-Y1);
2855 if ( dx != 0. || dy != 0. ) {
2856 Standard_Real dzoom = Sqrt(dx*dx + dy*dy) / 100. + 1;
2857 dzoom = (dx > 0) ? dzoom : 1./dzoom;
2858 SetZoom(dzoom, Standard_True);
2859 }
2860}
2861
2862void V3d_View::Zoom (const Standard_Integer X1,
2863 const Standard_Integer Y1)
2864{
2865 Standard_Real x,y;
2866 Center(x,y);
2867 Standard_Integer ix,iy;
2868 Convert(x,y,ix,iy);
2869 Zoom(ix,iy,X1,Y1);
2870}
2871
2872// Defines the point (pixel) of zooming (for the method ZoomAtPoint()).
2873void V3d_View::StartZoomAtPoint(const Standard_Integer xpix, const Standard_Integer ypix)
2874{
2875 MyZoomAtPointX = xpix;
2876 MyZoomAtPointY = ypix;
2877}
2878
2879// Zooms the model at a pixel defined by the method StartZoomAtPoint().
2880void V3d_View::ZoomAtPoint(const Standard_Integer mouseStartX,
2881 const Standard_Integer mouseStartY,
2882 const Standard_Integer mouseEndX,
2883 const Standard_Integer mouseEndY)
2884{
2885 Standard_Boolean update;
2886 V3d_Coordinate X0, Y0, XS, YS;
2887
2888 // Forbid any update.
2889 update = SetImmediateUpdate(Standard_False);
2890
2891 // Get center point
2892 Center(X0, Y0);
2893
2894 // Pan the point to the center of window.
2895 Convert(MyZoomAtPointX, MyZoomAtPointY, XS, YS);
2896 Panning(X0-XS, Y0-YS);
2897
2898 // Zoom
2899 Standard_Real d = Standard_Real ((mouseEndX + mouseEndY) - (mouseStartX + mouseStartY));
2900
2901 Standard_Real dzoom = fabs(d) / 100.0 + 1.0;
2902 dzoom = (d > 0) ? dzoom : 1.0 / dzoom;
2903 Viewer_BadValue_Raise_if( dzoom <= 0.,"V3d_View::ZoomAtPoint, bad coefficient");
2904
2905 Standard_Real Umin,Vmin,Umax,Vmax;
2906 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax);
2907
2908 MyXwindowCenter = (Umin + Umax) / 2.0;
2909 MyYwindowCenter = (Vmin + Vmax) / 2.0;
2910 MyWindowWidth = Abs(Umax - Umin);
2911 MyWindowHeight = Abs(Vmax - Vmin);
2912
2913 // Ensure that zoom will not be too small or too big.
2914 Standard_Real coef = dzoom;
2915 if (MyWindowWidth < coef * Precision::Confusion())
2916 coef = MyWindowWidth / Precision::Confusion();
2917 else if (MyWindowWidth > coef * 1e12)
2918 coef = MyWindowWidth / 1e12;
2919 if (MyWindowHeight < coef * Precision::Confusion())
2920 coef = MyWindowHeight / Precision::Confusion();
2921 else if (MyWindowHeight > coef * 1e12)
2922 coef = MyWindowHeight / 1e12;
2923
2924 Standard_Real Dxv = MyWindowWidth / coef;
2925 Standard_Real Dyv = MyWindowHeight / coef;
2926
2927 Umin = MyXwindowCenter - Dxv/2.0; Umax = MyXwindowCenter + Dxv/2.0;
2928 Vmin = MyYwindowCenter - Dyv/2.0; Vmax = MyYwindowCenter + Dyv/2.0;
2929
2930 // Pan the point backwards.
2931 Dxv = (XS - X0) / coef;
2932 Dyv = (YS - Y0) / coef;
2933
2934 MyXwindowCenter = (Umin + Umax) / 2.0;
2935 MyYwindowCenter = (Vmin + Vmax) / 2.0;
2936 MyWindowWidth = Abs(Umax - Umin);
2937 MyWindowHeight = Abs(Vmax - Vmin);
2938
2939 Standard_Real Xrp,Yrp,Zrp;
2940 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
2941 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp);
2942
2943 Xrp = MyXwindowCenter - Dxv;
2944 Yrp = MyYwindowCenter - Dyv;
2945
2946 Umin = Xrp - MyWindowWidth / 2.0; Umax = Xrp + MyWindowWidth / 2.0;
2947 Vmin = Yrp - MyWindowHeight / 2.0; Vmax = Yrp + MyWindowHeight / 2.0;
2948
2949 // Set new reference plane coordintes of the window.
2950 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax);
2951 if (MyType != V3d_PERSPECTIVE)
2952 {
2953 MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp);
2954 MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
2955 }
2956 MyView->SetViewMapping(MyViewMapping);
2957
2958 // Update the view.
2959 SetImmediateUpdate(update);
2960 ImmediateUpdate();
2961}
2962
2963void V3d_View::AxialScale (const Standard_Integer Dx,
2964 const Standard_Integer Dy,
2965 const V3d_TypeOfAxe Axis)
2966{
2967 if( Dx != 0. || Dy != 0. ) {
2968 Standard_Real Sx, Sy, Sz;
2969 AxialScale( Sx, Sy, Sz );
2970 Standard_Real dscale = Sqrt(Dx*Dx + Dy*Dy) / 100. + 1;
2971 dscale = (Dx > 0) ? dscale : 1./dscale;
2972 if( Axis == V3d_X ) Sx = dscale;
2973 if( Axis == V3d_Y ) Sy = dscale;
2974 if( Axis == V3d_Z ) Sz = dscale;
2975 SetAxialScale( Sx, Sy, Sz );
2976 }
2977}
2978
2979void V3d_View::FitAll(const Handle(Aspect_Window)& aWindow,
2980 const Standard_Real Xmin,
2981 const Standard_Real Ymin,
2982 const Standard_Real Xmax,
2983 const Standard_Real Ymax)
2984{
2985
2986 Standard_Real Umin,Umax,Vmin,Vmax,Xrp,Yrp,Zrp ;
2987 Standard_Real DxvOld,DyvOld,DxvNew,DyvNew,RapOld,RapNew ;
2988 Standard_Integer Xpixel,Ypixel;
2989 //Standard_Integer Xleft,Yup,Xright,Ylow ;
2990
2991 Viewer_BadValue_Raise_if( (Xmin == Xmax) || (Ymin == Ymax) ,
2992 "V3d_View::FitAll, Window Size is NULL");
2993
2994 MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
2995 MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
2996 aWindow->Size(Xpixel,Ypixel);
2997 DxvOld = Xpixel; DyvOld = Ypixel;
2998
2999 if( (DxvOld == 0.) || (DyvOld == 0.) ) return ;
3000 RapOld = DxvOld/DyvOld ;
3001 DxvNew = Abs(Xmax - Xmin) ; DyvNew = Abs(Ymax - Ymin) ;
3002 RapNew = DxvNew/DyvNew ;
3003 if( RapNew >= RapOld ) {
3004 DyvNew = DxvNew/RapOld ;
3005 } else {
3006 DxvNew = DyvNew*RapOld ;
3007 }
3008 Xrp = (Xmin + Xmax)/2. ; Yrp = (Ymin + Ymax)/2. ;
3009 Umin = Xrp - DxvNew/2. ; Vmin = Yrp - DyvNew/2. ;
3010 Umax = Xrp + DxvNew/2. ; Vmax = Yrp + DyvNew/2. ;
3011 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
3012 if( MyType != V3d_PERSPECTIVE ) {
3013 MyProjReferencePoint.SetCoord(Xrp,Yrp,Zrp) ;
3014 MyViewMapping.SetProjectionReferencePoint(MyProjReferencePoint);
3015 }
3016 MyView->SetViewMapping(MyViewMapping) ;
3017#ifdef IMP020300
3018 Update();
3019#else
3020 ImmediateUpdate();
3021#endif
3022}
3023
3024#ifdef IMP250900
3025static Standard_Boolean zRotation = Standard_False;
3026#endif
3027void V3d_View::StartRotation(const Standard_Integer X,
3028 const Standard_Integer Y,
3029 const Quantity_Ratio zRotationThreshold)
3030{
3031
3032 sx = X; sy = Y;
3033 Standard_Real x,y;
3034 Size(x,y);
3035 rx = Standard_Real(Convert(x));
3036 ry = Standard_Real(Convert(y));
3037 Gravity(gx,gy,gz);
3038 Rotate(0.,0.,0.,gx,gy,gz,Standard_True);
3039#ifdef IMP250900
3040 zRotation = Standard_False;
3041 if( zRotationThreshold > 0. ) {
3042 Standard_Real dx = Abs(sx - rx/2.);
3043 Standard_Real dy = Abs(sy - ry/2.);
3044 // if( dx > rx/3. || dy > ry/3. ) zRotation = Standard_True;
3045 Standard_Real dd = zRotationThreshold * (rx + ry)/2.;
3046 if( dx > dd || dy > dd ) zRotation = Standard_True;
3047 }
3048#endif
3049
3050}
3051
3052void V3d_View::Rotation(const Standard_Integer X,
3053 const Standard_Integer Y)
3054{
3055
3056#ifdef IMP210600
3057 if( rx == 0. || ry == 0. ) {
3058 StartRotation(X,Y);
3059 return;
3060 }
3061#endif
3062#ifdef IMP250900
3063 Standard_Real dx=0.,dy=0.,dz=0.;
3064 if( zRotation ) {
3065 dz = atan2(Standard_Real(X)-rx/2., ry/2.-Standard_Real(Y)) -
3066 atan2(sx-rx/2.,ry/2.-sy);
3067 } else {
c6541a0c
D
3068 dx = (Standard_Real(X) - sx) * M_PI / rx;
3069 dy = (sy - Standard_Real(Y)) * M_PI / ry;
7fd59977 3070 }
3071 Rotate(dx, dy, dz, gx, gy, gz, Standard_False);
3072#else
c6541a0c
D
3073 Standard_Real dx = (Standard_Real(X - sx)) * M_PI;
3074 Standard_Real dy = (Standard_Real(sy - Y)) * M_PI;
7fd59977 3075 Rotate(dx/rx, dy/ry, 0., gx, gy, gz, Standard_False);
3076#endif
3077#ifdef IMP020300
3078 if( !myImmediateUpdate ) Update();
3079#else
3080 myImmediateUpdate = Standard_False;
3081 Rotate(dx/rx, dy/ry, 0., gx, gy, gz, Standard_False);
3082 ZFitAll (Zmargin); //Don't do that, perf improvment
3083 myImmediateUpdate = Standard_True;
3084 ImmediateUpdate();
3085#endif
3086}
3087
3088void V3d_View::SetAnimationModeOn () {
3089#ifdef G003
3090 if ( MyAnimationFlags & V3d_FLAG_ANIMATION ) {
3091 if( ComputedMode() ) { // Deactivates computed mode during animation
3092 MyAnimationFlags |= V3d_FLAG_COMPUTATION;
3093 Standard_Boolean immediatUpdate = myImmediateUpdate;
3094 myImmediateUpdate = Standard_False;
3095 SetComputedMode(Standard_False);
3096 myImmediateUpdate = immediatUpdate;
3097 }
3098 MyView -> SetAnimationModeOn ( MyAnimationFlags & V3d_FLAG_DEGENERATION );
3099 }
3100#else
3101 MyView->SetAnimationModeOn();
3102#endif
3103}
3104
3105void V3d_View::SetAnimationModeOff () {
3106#ifdef G003
3107 if ( MyAnimationFlags & V3d_FLAG_ANIMATION ) {
3108 MyView -> SetAnimationModeOff ();
3109 if ( MyAnimationFlags & V3d_FLAG_COMPUTATION ) {
3110 // Reactivates computed mode after animation
3111 MyAnimationFlags &= ~V3d_FLAG_COMPUTATION;
3112 SetComputedMode(Standard_True);
3113 } else if( MyAnimationFlags & V3d_FLAG_DEGENERATION ) {
3114 Update();
3115 }
3116 }
3117#else
3118 MyView->SetAnimationModeOff();
3119#endif
3120}
3121
b8ddfc2f 3122Standard_Boolean V3d_View::AnimationModeIsOn () const
3123{
7fd59977 3124 return MyView->AnimationModeIsOn();
3125}
3126
3127#ifdef G003
3128void V3d_View :: SetAnimationMode
3129(
3130 const Standard_Boolean anAnimationFlag,
3131 const Standard_Boolean aDegenerationFlag
3132 )
3133{
7fd59977 3134 if ( anAnimationFlag )
3135 MyAnimationFlags |= V3d_FLAG_ANIMATION;
3136 else
3137 MyAnimationFlags &= ~V3d_FLAG_ANIMATION;
3138
3139 if ( aDegenerationFlag )
3140 MyAnimationFlags |= V3d_FLAG_DEGENERATION;
3141 else
3142 MyAnimationFlags &= ~V3d_FLAG_DEGENERATION;
3143
3144} // end V3d_View :: SetAnimationMode
3145
3146Standard_Boolean V3d_View::AnimationMode( Standard_Boolean& isDegenerate ) const
3147{
7fd59977 3148 isDegenerate = MyAnimationFlags & V3d_FLAG_DEGENERATION;
3149 return MyAnimationFlags & V3d_FLAG_ANIMATION;
3150}
3151#endif
3152
b8ddfc2f 3153void V3d_View::SetDegenerateModeOn()
3154{
7fd59977 3155#ifdef G003
3156 SetComputedMode(Standard_False);
3157#else
3158 MyView->SetDegenerateModeOn();
3159 ImmediateUpdate();
3160#endif
3161}
3162
3163void V3d_View::SetDegenerateModeOff()
3164{
3165#ifdef G003
3166 SetComputedMode(Standard_True);
3167#else
3168 if(myComputedMode) {
3169 MyView->SetDegenerateModeOff();
3170 ImmediateUpdate();
3171 }
3172#endif
3173}
3174
3175Standard_Boolean V3d_View::DegenerateModeIsOn() const
3176{
3177#ifdef G003
3178 return !ComputedMode();
3179#else
3180 return MyView->DegenerateModeIsOn();
3181#endif
3182}
3183
3184#ifdef G003
3185void V3d_View :: SetComputedMode ( const Standard_Boolean aMode )
3186{
7fd59977 3187 if( aMode ) {
3188 if( myComputedMode ) {
3189 MyView -> SetComputedMode ( Standard_True );
3190 Update ();
3191 }
3192 } else {
3193 MyView -> SetComputedMode ( Standard_False );
3194 Update ();
3195 }
b8ddfc2f 3196}
7fd59977 3197
3198Standard_Boolean V3d_View :: ComputedMode () const
3199{
7fd59977 3200 return MyView -> ComputedMode ();
b8ddfc2f 3201}
7fd59977 3202
b8ddfc2f 3203void V3d_View :: SetBackFacingModel (const V3d_TypeOfBackfacingModel aModel)
7fd59977 3204{
7fd59977 3205 MyView -> SetBackFacingModel ( Visual3d_TypeOfBackfacingModel(aModel) );
3206 Redraw();
b8ddfc2f 3207}
7fd59977 3208
b8ddfc2f 3209V3d_TypeOfBackfacingModel V3d_View :: BackFacingModel () const
3210{
7fd59977 3211 return V3d_TypeOfBackfacingModel(MyView -> BackFacingModel ());
b8ddfc2f 3212}
7fd59977 3213#endif
3214
b8ddfc2f 3215Standard_Boolean V3d_View::TransientManagerBeginDraw(const Standard_Boolean DoubleBuffer,const Standard_Boolean RetainMode) const
3216{
7fd59977 3217 return Visual3d_TransientManager::BeginDraw(MyView,DoubleBuffer,RetainMode);
3218}
3219
b8ddfc2f 3220void V3d_View::TransientManagerClearDraw() const
3221{
7fd59977 3222 Visual3d_TransientManager::ClearDraw(MyView);
3223}
3224
b8ddfc2f 3225Standard_Boolean V3d_View::TransientManagerBeginAddDraw() const
3226{
7fd59977 3227 return Visual3d_TransientManager::BeginAddDraw(MyView);
3228}
3229
b8ddfc2f 3230void V3d_View::Init()
3231{
7fd59977 3232 myComputedMode = MyViewer->ComputedMode();
3233#ifdef G003
3234 if( !myComputedMode || !MyViewer->DefaultComputedMode() ) {
3235 SetComputedMode(Standard_False);
3236 }
3237#else
3238 if(!myComputedMode)
3239 MyView->SetDegenerateModeOn();
3240 else
3241 if(!MyViewer->DefaultComputedMode()) MyView->SetDegenerateModeOn();
3242#endif
3243
3244#ifdef IMP240100
3245 OSD_Environment env_walkthrow("CSF_WALKTHROUGH");
3246 env_walkthrow.SetName( "CSF_WALKTHROUGH" );
3247 if ( env_walkthrow.Value () != "" ) MyProjModel = V3d_TPM_WALKTHROUGH;
3248 else MyProjModel = V3d_TPM_SCREEN;
3249#endif
7fd59977 3250}
3251
b8ddfc2f 3252void V3d_View::SetPlotter(const Handle(Graphic3d_Plotter)& aPlotter)
3253{
7fd59977 3254 MyPlotter = aPlotter;
3255}
3256
3257void V3d_View::Plot()
3258{
7fd59977 3259 Viewer_BadValue_Raise_if( !MyPlotter.IsNull(), "view has no plotter");
7fd59977 3260 MyView->Plot(MyPlotter);
3261}
3262
3263Standard_Real V3d_View::Tumble (const Standard_Integer NbImages, const Standard_Boolean AnimationMode)
3264{
7fd59977 3265 FullTimer.Reset ();
3266 FullTimer.Start ();
3267
3268 if (AnimationMode) MyView->SetAnimationModeOn();
3269 Standard_Integer i;
3270 Standard_Real delta = 0.01;
3271 Standard_Real xangle, yangle;
3272 xangle = yangle = delta*int(NbImages/3);
3273
3274 Rotate (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Standard_True);
3275 for (i=1; i<=int(NbImages/3); i++)
3276 Rotate (delta*i, 0.0, 0.0, 0.0, 0.0, 0.0, Standard_False);
3277 for (i=1; i<=int(NbImages/3); i++)
3278 Rotate (xangle, delta*i, 0.0, 0.0, 0.0, 0.0, Standard_False);
3279 for (i=1; i<=int(NbImages/3); i++)
3280 Rotate (xangle, yangle, delta*i, 0.0, 0.0, 0.0, Standard_False);
3281 if (AnimationMode) MyView->SetAnimationModeOff();
3282
3283 FullTimer.Stop ();
3284 cout << "For " << NbImages << " Images : " << endl;
3285 FullTimer.Show (cout);
3286 cout << flush;
3287
3288 Standard_Real Seconds, CPUtime;
3289 Standard_Integer Minutes, Hours;
3290
3291 FullTimer.Show (Seconds, Minutes, Hours, CPUtime);
3292 cout << "Result " << (AnimationMode ? "with " : "without ")
3293 << "display list : " << NbImages/CPUtime << " images/Second."
3294 << endl;
3295
3296 return NbImages/CPUtime;
7fd59977 3297}
3298
7fd59977 3299#include <Aspect.hxx>
3300#include <Visual3d_Layer.hxx>
3301
3302////////////////////////////////////////////////////////////////
692613e5 3303Standard_Boolean V3d_View::Dump (const Standard_CString theFile,
3304 const Graphic3d_BufferType& theBufferType)
7fd59977 3305{
3306 Standard_Integer aWinWidth, aWinHeight;
3307 MyWindow->Size (aWinWidth, aWinHeight);
692613e5 3308 Image_AlienPixMap anImage;
3309 return ToPixMap (anImage, aWinWidth, aWinHeight, theBufferType) && anImage.Save (theFile);
7fd59977 3310}
3311
7fd59977 3312////////////////////////////////////////////////////////////////
692613e5 3313Standard_Boolean V3d_View::ToPixMap (Image_PixMap& theImage,
3314 const Standard_Integer theWidth,
3315 const Standard_Integer theHeight,
3316 const Graphic3d_BufferType& theBufferType,
3317 const Standard_Boolean theIsForceCentred)
7fd59977 3318{
7fd59977 3319 Graphic3d_CView* cView = (Graphic3d_CView* )MyView->CView();
1981cb22 3320
3321 // always prefer hardware accelerated offscreen buffer
7fd59977 3322 Graphic3d_PtrFrameBuffer aFBOPtr = NULL;
3323 Graphic3d_PtrFrameBuffer aPrevFBOPtr = (Graphic3d_PtrFrameBuffer )cView->ptrFBO;
85e096c3 3324 Standard_Integer aFBOVPSizeX (theWidth), aFBOVPSizeY (theHeight), aFBOSizeXMax (0), aFBOSizeYMax (0);
7fd59977 3325 Standard_Integer aPrevFBOVPSizeX (0), aPrevFBOVPSizeY (0), aPrevFBOSizeXMax (0), aPrevFBOSizeYMax (0);
3326 if (aPrevFBOPtr != NULL)
3327 {
3328 MyView->FBOGetDimensions (aPrevFBOPtr,
3329 aPrevFBOVPSizeX, aPrevFBOVPSizeY,
3330 aPrevFBOSizeXMax, aPrevFBOSizeYMax);
85e096c3 3331 if (aFBOVPSizeX <= aPrevFBOSizeXMax && aFBOVPSizeY <= aPrevFBOSizeYMax)
7fd59977 3332 {
85e096c3 3333 MyView->FBOChangeViewport (aPrevFBOPtr, aFBOVPSizeX, aFBOVPSizeY);
7fd59977 3334 aFBOPtr = aPrevFBOPtr;
3335 }
3336 }
3337
3338 if (aFBOPtr == NULL)
3339 {
3340 // Try to create hardware accelerated buffer
85e096c3 3341 aFBOPtr = MyView->FBOCreate (aFBOVPSizeX, aFBOVPSizeY);
3342 if (aFBOPtr != NULL)
3343 {
3344 MyView->FBOGetDimensions (aFBOPtr,
3345 aFBOVPSizeX, aFBOVPSizeY,
3346 aFBOSizeXMax, aFBOSizeYMax);
3347 // reduce viewport in case of hardware limits
3348 if (aFBOVPSizeX > aFBOSizeXMax) aFBOVPSizeX = aFBOSizeXMax;
3349 if (aFBOVPSizeY > aFBOSizeYMax) aFBOVPSizeY = aFBOSizeYMax;
3350 MyView->FBOChangeViewport (aFBOPtr, aFBOVPSizeX, aFBOVPSizeY);
3351 }
7fd59977 3352 }
3353 cView->ptrFBO = aFBOPtr;
3354
3355 // If hardware accelerated buffer - try to use onscreen buffer
3356 // Results may be bad!
3357 if (aFBOPtr == NULL)
3358 {
3359 // retrieve window sizes
3360 Standard_Integer aWinWidth, aWinHeight;
3361 MyWindow->Size (aWinWidth, aWinHeight);
3362
3363 // technically we can reduce existing viewport...
3364 // but currently allow only dumping the window itself
85e096c3 3365 if (aFBOVPSizeX != aWinWidth || aFBOVPSizeY != aWinHeight)
7fd59977 3366 {
692613e5 3367 return Standard_False;
7fd59977 3368 }
3369 }
3370
3371 //szv: save mapping
3372 Visual3d_ViewMapping prevMapping = MyView->ViewMapping();
3373 Standard_Real Umin, Vmin, Umax, Vmax;
3374
3375 if (theIsForceCentred)
3376 {
3377 //szv: get mapping frame
3378 Standard_Real PUmin, PVmin, PUmax, PVmax;
3379 prevMapping.WindowLimit (PUmin, PVmin, PUmax, PVmax);
3380
3381 //szv: calculate expansion
3382 Umin = PUmin; Vmin = PVmin; Umax = PUmax; Vmax = PVmax;
3383 Standard_Real oldWidth = (PUmax - PUmin), oldHeight = (PVmax - PVmin);
85e096c3 3384 Standard_Real newWidth = (oldHeight * aFBOVPSizeX) / aFBOVPSizeY;
7fd59977 3385 if (newWidth < oldWidth)
3386 {
85e096c3 3387 Standard_Real newHeight = (oldWidth * aFBOVPSizeY) / aFBOVPSizeX;
7fd59977 3388 // Expand height
3389 Standard_Real delta = 0.5 * (newHeight - oldHeight);
3390 Vmin = PVmin - delta;
3391 Vmax = PVmax + delta;
3392 }
3393 else
3394 {
3395 // Expand width
3396 Standard_Real delta = 0.5 * (newWidth - oldWidth);
3397 Umin = PUmin - delta;
3398 Umax = PUmax + delta;
3399 }
3400
3401 //szv: apply expanded mapping
3402 MyViewMapping.SetWindowLimit (Umin, Vmin, Umax, Vmax);
3403 MyView->SetViewMapping (MyViewMapping);
3404 }
3405
3406 //workround for rendering list of Over and Under Layers
3407 if (!MyLayerMgr.IsNull())
3408 {
3409 MyLayerMgr->Compute();
3410 }
1981cb22 3411
3412 // render immediate structures into back buffer rather than front
3413 Handle(Graphic3d_GraphicDriver) aDriver = Handle(Graphic3d_GraphicDriver)::DownCast (MyView->GraphicDriver());
3414 const Standard_Boolean aPrevImmediateMode = aDriver.IsNull() ? Standard_True : aDriver->SetImmediateModeDrawToFront (*cView, Standard_False);
3415
7fd59977 3416 Redraw();
3417
1981cb22 3418 if (!aDriver.IsNull())
3419 {
3420 aDriver->SetImmediateModeDrawToFront (*cView, aPrevImmediateMode);
3421 }
3422
7fd59977 3423 //szv: restore mapping
3424 MyViewMapping = prevMapping;
3425 MyView->SetViewMapping (prevMapping);
3426
692613e5 3427 Standard_Boolean isSuccess = Standard_True;
3428
7fd59977 3429 // allocate image buffer for dumping
692613e5 3430 if (theImage.IsEmpty()
3431 || (Standard_Size )aFBOVPSizeX != theImage.SizeX()
3432 || (Standard_Size )aFBOVPSizeY != theImage.SizeY())
7fd59977 3433 {
692613e5 3434 bool isBigEndian = Image_PixMap::IsBigEndianHost();
3435 Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgUNKNOWN;
3436 switch (theBufferType)
3437 {
3438 case Graphic3d_BT_RGB: aFormat = isBigEndian ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR; break;
3439 case Graphic3d_BT_RGBA: aFormat = isBigEndian ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA; break;
3440 case Graphic3d_BT_Depth: aFormat = Image_PixMap::ImgGrayF; break;
3441 }
3442
3443 isSuccess = isSuccess && theImage.InitZero (aFormat, aFBOVPSizeX, aFBOVPSizeY);
7fd59977 3444 }
692613e5 3445 isSuccess = isSuccess && MyView->BufferDump (theImage, theBufferType);
7fd59977 3446
3447 // FBO now useless, free resources
3448 if (aFBOPtr != aPrevFBOPtr)
3449 {
3450 MyView->FBORelease (aFBOPtr);
3451 }
3452 else if (aPrevFBOPtr != NULL)
3453 {
3454 MyView->FBOChangeViewport (aPrevFBOPtr, aPrevFBOVPSizeX, aPrevFBOVPSizeY);
3455 }
3456 cView->ptrFBO = aPrevFBOPtr;
692613e5 3457 return isSuccess;
7fd59977 3458}