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