1 /***********************************************************************
5 Classe Visual3d_View.cxx :
8 Declaration of variables specific to views.
10 A view is defined by :
16 HISTORIQUE DES MODIFICATIONS :
17 --------------------------------
18 Mars 1992 : NW,JPB,CAL ; Creation.
19 04-02-97 : FMN ; Suppression de PSOutput, XWDOutput ...
20 22-04-97 : CAL ; Ajout du Plot.
21 03-06-97 : FMN ; Correction calcul SetRatio
22 06-05-97 : CAL ; Ajout du Clear sur les TOS_COMPUTED.
23 28-07-97 : PCT ; Ajout lumiere frontale headlight.
24 19-09-97 : CAL ; Remplacement de Window->Position par Window->Size;
25 17-10-97 : CAL ; Le Projects nouveau est arrive. (NewProjects)
26 24-10-97 : CAL ; Retrait de DownCast.
27 24-10-97 : CAL ; Retrait des DataStructure (Vieille maquette inutilisee).
28 17-11-97 : FMN ; Ajout DoResize dans Resized()
29 20-11-97 : CAL ; Disparition de la dependance avec math
30 ??-11-97 : CAL ; Retrait de la dependance avec math. Calcul developpe.
31 ??-11-97 : CAL ; Ajout de NumberOfDisplayedStructures
32 07-08-97 : PCT ; ajout support texture mapping
33 05-01-98 : CAL ; Ajout de AnimationMode
34 15-01-98 : FMN ; FRA60019 calcul Ratio pour MyViewMappingReset
35 15-01-98 : CAL ; Ajout de la transformation d'une TOS_COMPUTED
36 26-01-98 : CAL ; Ajout de la methode HaveTheSameOwner
37 06-02-98 : FMN ; CTS19079: TOP TEN: Probleme de highlight dans EDesigner.
38 05-03-98 : CAL ; GraphicTransform que si Trsf non invalidante
39 27-03-98 : CAL ; Ajout de TheStructure = devant Compute (...) !!!!
40 16-04-98 : CAL ; Remise a ID de la Trsf sur la COMPUTED
41 20-05-98 : CAL ; Perfs. Connection entre structures COMPUTED.
42 24-06-98 : CAL ; PRO14526 SetTransparency sur une vue non active.
43 17-07-98 : CAL ; PRO14872 test sur aTrsf dans ::SetTransform.
44 16-09-98 : BGN ; Points d'entree du Triedre (S3819, Phase 1)
45 22-09-98 : BGN ; S3989 (anciennement S3819)
46 TypeOfTriedron* from Aspect (pas Visual3d)
47 06-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie.
48 16-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie.
49 02-11-98 : CAL ; Retrait de OSD::SetSignal.
50 18-11-98 : FMN ; Correction sur la gestion de la perspective
51 02-12-98 : CAL ; S4062. Ajout des layers.
52 13-09-99 : GG ; GER61454 Adds LightLimit() and PlaneLimit() methods
53 10-11-99 : GG ; PRO19603 Add Redraw( area ) method
54 14-01-00 : GG ; IMP140100 Add ViewManager( ) method
55 22-10-01 : SAV ; Added EnableDepthTest() method.
56 30-04-02 : JMB ; MyDisplayStructure : use a Map instead of a Set (very bad performance
57 in data access when a lot of objects are used)
58 Will improve performance of selection mechanisms
60 ************************************************************************/
62 #define BUC60572 //GG_03-08-99 Add protection on Zclipping & Zcueing planes
65 #define BUC60570 //GG 14-09-99 Don't activates lighting
66 // when the view shading model is NONE.
68 #define GER61454 //GG 14-09-99 Activates model clipping planes
70 #define IMP140100 //GG14-01-00 Add ViewManager( ) method
72 #define G003 //EUG 30-09-00 Degeneration management
73 // Backfacing management
75 #define RIC120302 //GG Add a NEW SetWindow method which enable
76 // to connect a graphic widget and context to OGL.
78 #define BUC61044 /* 25/10/01 SAV ; added functionality to control gl depth testing
80 #define BUC61045 /* 25/10/01 SAV ; added functionality to control gl lighting
83 #define OCC1188 //SAV Added methods to set background image
85 /*----------------------------------------------------------------------*/
93 #define NO_TRACE_ACCEPT
94 #define NO_TRACE_CLEAR
95 #define NO_TRACE_CONNECT
99 #define NO_TRACE_DISPLAY
100 #define NO_TRACE_ISCOMP
101 #define NO_TRACE_LENGTH
102 #define NO_TRACE_LAYER
104 /*----------------------------------------------------------------------*/
114 #include <Visual3d_View.ixx>
115 #include <Visual3d_View.pxx>
116 #include <Visual3d_DepthCueingDefinitionError.hxx>
117 #include <Visual3d_ZClippingDefinitionError.hxx>
120 #include <math_Vector.hxx>
121 #endif /* OLD_METHOD */
125 #include <Graphic3d_Structure.hxx>
126 #include <Graphic3d_MapOfStructure.hxx>
127 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
128 #include <Graphic3d_DataStructureManager.hxx>
130 #include <Graphic3d_GraphicDriver.hxx>
131 #include <Graphic3d_GraphicDevice.hxx>
133 #include <Graphic3d_Vector.hxx>
134 #include <Graphic3d_Vertex.hxx>
136 #include <Visual3d_Light.hxx>
137 #include <Visual3d_SetOfLight.hxx>
138 #include <Visual3d_HSetOfLight.hxx>
139 #include <Visual3d_SetIteratorOfSetOfLight.hxx>
141 #include <Visual3d_ClipPlane.hxx>
142 #include <Visual3d_SetOfClipPlane.hxx>
143 #include <Visual3d_HSetOfClipPlane.hxx>
144 #include <Visual3d_SetIteratorOfSetOfClipPlane.hxx>
146 #include <Visual3d_SetIteratorOfSetOfView.hxx>
148 #include <Graphic3d_TextureEnv.hxx>
150 #include <TColStd_HArray2OfReal.hxx>
153 # include <Xw_Window.hxx>
155 # include <WNT_Window.hxx>
162 //-Global data definitions
166 Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager):
169 MyViewMappingReset (),
170 MyViewOrientation (),
171 MyViewOrientationReset (),
172 MyTransformation (0, 3, 0, 3),
173 MyMatrixOfMapping (0, 3, 0, 3),
174 MyMatrixOfOrientation (0, 3, 0, 3),
175 MyTOCOMPUTESequence (),
176 MyCOMPUTEDSequence (),
177 MyDisplayedStructure ()
179 Standard_Integer i, j;
182 MyPtrViewManager = AManager.operator->();
184 MyPtrViewManager = (void *) AManager.operator->();
187 memset (&MyCView, 0, sizeof(MyCView));
188 MyCView.ViewId = int (AManager->Identification (this));
190 MyCView.IsDeleted = 0;
193 MyCView.DefWindow.IsDefined = 0;
195 MyCView.Context.NbActiveLight = 0;
196 MyCView.Context.NbActivePlane = 0;
198 MyCView.Context.ActivePlane = NULL;
203 if (i == j) MyTransformation (i, j) = 1.0;
204 else MyTransformation (i, j) = 0.0;
206 Standard_Real X, Y, Z;
208 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
209 MyCView.Orientation.ViewReferencePoint.x = float (X);
210 MyCView.Orientation.ViewReferencePoint.y = float (Y);
211 MyCView.Orientation.ViewReferencePoint.z = float (Z);
212 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
213 MyCView.Orientation.ViewReferencePlane.x = float (X);
214 MyCView.Orientation.ViewReferencePlane.y = float (Y);
215 MyCView.Orientation.ViewReferencePlane.z = float (Z);
216 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
217 MyCView.Orientation.ViewReferenceUp.x = float (X);
218 MyCView.Orientation.ViewReferenceUp.y = float (Y);
219 MyCView.Orientation.ViewReferenceUp.z = float (Z);
221 Standard_Real Sx, Sy, Sz;
223 MyViewOrientation.AxialScale(Sx, Sy, Sz);
224 MyCView.Orientation.ViewScaleX = float (Sx);
225 MyCView.Orientation.ViewScaleY = float (Sy);
226 MyCView.Orientation.ViewScaleZ = float (Sz);
228 // NKV : 23/07/07 - Define custom MODELVIEW matrix
229 MyCView.Orientation.IsCustomMatrix = 0;
230 memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
231 MyCView.Orientation.ModelViewMatrix[0][0] =
232 MyCView.Orientation.ModelViewMatrix[1][1] =
233 MyCView.Orientation.ModelViewMatrix[2][2] =
234 MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
237 Standard_Real um, vm, uM, vM;
239 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
240 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
241 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
242 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
243 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
244 MyCView.Mapping.ViewPlaneDistance =
245 float (MyViewMapping.ViewPlaneDistance ());
246 MyCView.Mapping.BackPlaneDistance =
247 float (MyViewMapping.BackPlaneDistance ());
248 MyCView.Mapping.FrontPlaneDistance =
249 float (MyViewMapping.FrontPlaneDistance ());
250 MyViewMapping.WindowLimit (um, vm, uM, vM);
251 MyCView.Mapping.WindowLimit.um = float (um);
252 MyCView.Mapping.WindowLimit.vm = float (vm);
253 MyCView.Mapping.WindowLimit.uM = float (uM);
254 MyCView.Mapping.WindowLimit.vM = float (vM);
256 // NKV : 23/07/07 - Define custom MODELVIEW matrix
257 MyCView.Mapping.IsCustomMatrix = 0;
258 memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
259 MyCView.Mapping.ProjectionMatrix[0][0] =
260 MyCView.Mapping.ProjectionMatrix[1][1] =
261 MyCView.Mapping.ProjectionMatrix[2][2] =
262 MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
265 MyCView.Context.ZBufferActivity = -1;
267 MyMatOfMapIsModified = Standard_True;
268 MyMatOfOriIsModified = Standard_True;
269 MyMatOfMapIsEvaluated = Standard_False;
270 MyMatOfOriIsEvaluated = Standard_False;
272 DegenerateModeIsActive = Standard_False;
273 AnimationModeIsActive = Standard_False;
275 MyCView.IsDegenerates = 0;
276 MyCView.IsDegeneratesPrev = 0;
277 ComputedModeIsActive = Standard_False;
278 MyCView.Backfacing = 0;
281 MyCView.DefBitmap.bitmap = 0;
282 MyCView.ptrUnderLayer = 0;
283 MyCView.ptrOverLayer = 0;
284 MyCView.GContext = 0;
285 MyCView.GDisplayCB = 0;
286 MyCView.GClientData = 0;
288 Handle(Aspect_GraphicDriver) agd =
289 (MyViewManager->GraphicDevice ())->GraphicDriver ();
291 MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
295 Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager, const Visual3d_ViewOrientation& VO, const Visual3d_ViewMapping& VM, const Visual3d_ContextView& CTX):
296 MyTransformation (0, 3, 0, 3),
297 MyMatrixOfMapping (0, 3, 0, 3),
298 MyMatrixOfOrientation (0, 3, 0, 3),
299 MyTOCOMPUTESequence (),
300 MyCOMPUTEDSequence (),
301 MyDisplayedStructure ()
303 Standard_Integer i, j;
306 MyPtrViewManager = AManager.operator->();
308 MyPtrViewManager = (void *) AManager.operator->();
311 MyViewOrientation = VO;
314 MyViewOrientationReset = VO;
315 MyViewMappingReset = VM;
317 memset (&MyCView, 0, sizeof(MyCView));
318 MyCView.ViewId = int (AManager->Identification (this));
320 MyCView.IsDeleted = 0;
323 MyCView.DefWindow.IsDefined = 0;
325 MyCView.Context.NbActiveLight = 0;
326 MyCView.Context.NbActivePlane = 0;
328 MyCView.Context.ActivePlane = NULL;
333 if (i == j) MyTransformation (i, j) = 1.0;
334 else MyTransformation (i, j) = 0.0;
336 Standard_Real X, Y, Z;
338 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
339 MyCView.Orientation.ViewReferencePoint.x = float (X);
340 MyCView.Orientation.ViewReferencePoint.y = float (Y);
341 MyCView.Orientation.ViewReferencePoint.z = float (Z);
342 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
343 MyCView.Orientation.ViewReferencePlane.x = float (X);
344 MyCView.Orientation.ViewReferencePlane.y = float (Y);
345 MyCView.Orientation.ViewReferencePlane.z = float (Z);
346 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
347 MyCView.Orientation.ViewReferenceUp.x = float (X);
348 MyCView.Orientation.ViewReferenceUp.y = float (Y);
349 MyCView.Orientation.ViewReferenceUp.z = float (Z);
351 Standard_Real Sx, Sy, Sz;
353 MyViewOrientation.AxialScale(Sx, Sy, Sz);
354 MyCView.Orientation.ViewScaleX = float (Sx);
355 MyCView.Orientation.ViewScaleY = float (Sy);
356 MyCView.Orientation.ViewScaleZ = float (Sz);
358 // NKV : 23/07/07 - Define custom MODELVIEW matrix
359 if (MyViewOrientation.IsCustomMatrix()) {
360 MyCView.Orientation.IsCustomMatrix = 1;
361 for ( i = 0; i < 4; i++)
362 for ( j = 0; j < 4; j++)
363 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
366 MyCView.Orientation.IsCustomMatrix = 0;
367 memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
368 MyCView.Orientation.ModelViewMatrix[0][0] =
369 MyCView.Orientation.ModelViewMatrix[1][1] =
370 MyCView.Orientation.ModelViewMatrix[2][2] =
371 MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
375 Standard_Real um, vm, uM, vM;
377 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
378 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
379 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
380 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
381 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
382 MyCView.Mapping.ViewPlaneDistance =
383 float (MyViewMapping.ViewPlaneDistance ());
384 MyCView.Mapping.BackPlaneDistance =
385 float (MyViewMapping.BackPlaneDistance ());
386 MyCView.Mapping.FrontPlaneDistance =
387 float (MyViewMapping.FrontPlaneDistance ());
388 MyViewMapping.WindowLimit (um, vm, uM, vM);
389 MyCView.Mapping.WindowLimit.um = float (um);
390 MyCView.Mapping.WindowLimit.vm = float (vm);
391 MyCView.Mapping.WindowLimit.uM = float (uM);
392 MyCView.Mapping.WindowLimit.vM = float (vM);
394 // NKV : 23/07/07 - Define custom MODELVIEW matrix
395 if (MyViewMapping.IsCustomMatrix()) {
396 MyCView.Mapping.IsCustomMatrix = 1;
397 for ( i = 0; i < 4; i++)
398 for ( j = 0; j < 4; j++)
399 MyCView.Mapping.ProjectionMatrix[i][j] = MyViewMapping.MyProjectionMatrix->Value(i,j);
402 MyCView.Mapping.IsCustomMatrix = 0;
403 memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
404 MyCView.Mapping.ProjectionMatrix[0][0] =
405 MyCView.Mapping.ProjectionMatrix[1][1] =
406 MyCView.Mapping.ProjectionMatrix[2][2] =
407 MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
411 MyCView.Context.ZBufferActivity = -1;
413 MyMatOfMapIsModified = Standard_True;
414 MyMatOfOriIsModified = Standard_True;
415 MyMatOfMapIsEvaluated = Standard_False;
416 MyMatOfOriIsEvaluated = Standard_False;
418 AnimationModeIsActive = Standard_False;
419 MyCView.IsDegenerates = 0;
420 MyCView.IsDegeneratesPrev = 0;
421 ComputedModeIsActive = Standard_False;
424 MyCView.DefBitmap.bitmap = 0;
425 MyCView.ptrUnderLayer = 0;
426 MyCView.ptrOverLayer = 0;
427 MyCView.GContext = 0;
428 MyCView.GDisplayCB = 0;
429 MyCView.GClientData = 0;
431 Handle(Aspect_GraphicDriver) agd =
432 (MyViewManager->GraphicDevice ())->GraphicDriver ();
434 MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
442 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow,
443 const Aspect_RenderingContext AContext,
444 const Aspect_GraphicCallbackProc& ADisplayCB,
445 const Standard_Address AClientData)
447 if (IsDeleted ()) return;
450 Visual3d_ViewDefinitionError::Raise ("Window already defined");
452 MyCView.GContext = AContext;
453 MyCView.GDisplayCB = ADisplayCB;
454 MyCView.GClientData = AClientData;
459 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow) {
461 if (IsDeleted ()) return;
464 Visual3d_ViewDefinitionError::Raise ("Window already defined");
467 MyCView.WsId = MyCView.ViewId;
468 MyCView.DefWindow.IsDefined = 1;
470 const Handle(Xw_Window) theWindow = *(Handle(Xw_Window) *) &AWindow;
471 MyCView.DefWindow.XWindow = theWindow->XWindow ();
473 MyCView.DefWindow.XParentWindow = theWindow->XParentWindow ();
477 const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AWindow;
478 MyCView.DefWindow.XWindow = ( HWND )(theWindow->HWindow());
480 MyCView.DefWindow.XParentWindow = ( HWND )(theWindow->HParentWindow());
482 wd = ( WNT_WindowData* )GetWindowLongPtr (( HWND )(theWindow->HWindow()), GWLP_USERDATA);
483 wd -> WNT_WDriver_Ptr = ( void* )this;
484 wd -> WNT_VMgr = ( void* )MyPtrViewManager;
487 Standard_Integer Width, Height;
488 AWindow->Size (Width, Height);
490 MyCView.DefWindow.dx = float( Width );
491 MyCView.DefWindow.dy = float( Height );
493 Standard_Real R, G, B;
494 MyBackground = MyWindow->Background ();
495 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
496 MyCView.DefWindow.Background.r = float (R);
497 MyCView.DefWindow.Background.g = float (G);
498 MyCView.DefWindow.Background.b = float (B);
501 if (! MyGraphicDriver->View (MyCView))
502 Visual3d_ViewDefinitionError::Raise ("Association failed");
504 MyGradientBackground = MyWindow->GradientBackground();
505 SetGradientBackground(MyGradientBackground,1);
507 Standard_Boolean AWait = Standard_False; // => immediate update
508 MyGraphicDriver->SetVisualisation (MyCView);
509 MyGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn ());
510 MyGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn ());
511 MyGraphicDriver->ClipLimit (MyCView, AWait);
512 MyGraphicDriver->Environment(MyCView);
514 // Update planses of model clipping
517 // Update light sources
521 * Association view-window does not cause the display
522 * of structures that can be displayed in the new view.
523 * In fact, association view-window is done, but the
524 * display is produced only if the view is activated (Activate).
531 Handle(Aspect_Window) Visual3d_View::Window () const {
534 Visual3d_ViewDefinitionError::Raise ("Window not defined");
540 Standard_Boolean Visual3d_View::IsDefined () const {
542 if (MyCView.DefWindow.IsDefined)
543 return (Standard_True);
545 return (Standard_False);
549 Standard_Boolean Visual3d_View::IsDeleted () const {
551 if (MyCView.IsDeleted)
552 return (Standard_True);
554 return (Standard_False);
558 void Visual3d_View::Destroy () {
561 cout << "Visual3d_View::Destroy (" << Identification () << ")\n";
564 // Since MyPtrViewManager can be already distroyed,
565 // avoid attempts to access it in SetBackground()
566 MyPtrViewManager = 0;
571 void Visual3d_View::Remove () {
574 cout << "Visual3d_View::Remove (" << Identification () << ")" << endl;
577 if (IsDeleted ()) return;
578 if (! IsDefined ()) return;
580 MyTOCOMPUTESequence.Clear ();
581 MyCOMPUTEDSequence.Clear ();
582 MyDisplayedStructure.Clear ();
584 Quantity_Color BlackColor (0.0, 0.0, 0.0, Quantity_TOC_RGB);
585 Aspect_Background BlackBackground (BlackColor);
586 SetBackground (BlackBackground);
588 Aspect_GradientBackground BlackGradBackground;
589 SetGradientBackground (BlackGradBackground,0);
591 if (MyPtrViewManager)
592 MyPtrViewManager->UnIdentification( MyCView.ViewId );
594 MyGraphicDriver->RemoveView (MyCView);
597 MyCView.IsDeleted = 1;
598 MyCView.DefWindow.IsDefined = 0;
600 MyMatOfMapIsModified = Standard_True;
601 MyMatOfOriIsModified = Standard_True;
602 MyMatOfMapIsEvaluated = Standard_False;
603 MyMatOfOriIsEvaluated = Standard_False;
609 void Visual3d_View::Resized () {
611 if (IsDeleted ()) return;
614 Visual3d_ViewDefinitionError::Raise ("Window not defined");
615 MyWindow->DoResize() ;
620 void Visual3d_View::SetRatio () {
622 if (IsDeleted ()) return;
624 Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode ();
625 MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
627 Standard_Real Umin, Vmin, Umax, Vmax;
628 Standard_Integer Dxw, Dyw;
629 Standard_Real Dxv, Dyv;
630 Standard_Real Xc, Yc;
634 MyWindow->Size (Dxw, Dyw);
635 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
636 Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
637 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
638 if( Dxw > 0 && Dyw > 0 ) Rap = (Standard_Real)Dyw/(Standard_Real)Dxw ;
668 Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
669 Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
671 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
673 // Update before SetViewMapping.
675 MyCView.DefWindow.dx = float( Dxw );
676 MyCView.DefWindow.dy = float( Dyw );
678 SetViewMapping (MyViewMapping);
679 // SetViewMappingDefault ();
680 // FMN+ Update Ratio for MyViewMappingReset
682 MyViewMappingReset.WindowLimit(Umin,Vmin,Umax,Vmax) ;
683 Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
684 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
713 Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
714 Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
716 MyViewMappingReset.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
718 // FMN- Update Ratio for MyViewMappingReset
720 MyGraphicDriver->RatioWindow (MyCView);
723 // Force recalculation of 2 matrices.
725 // The current view can help to reconstruct a copied view
726 // that is itself. Owing to SetWindow and SetRatio the
727 // recalculation of matrices of this new view is imposed.
728 MyMatOfMapIsEvaluated = Standard_False;
729 MyMatOfOriIsEvaluated = Standard_False;
731 MyViewManager->SetUpdateMode (UpdateMode);
732 if (UpdateMode == Aspect_TOU_ASAP) Update ();
736 void Visual3d_View::UpdateLights () {
738 Standard_Integer i, j;
739 CALL_DEF_LIGHT *lights=NULL;
742 if( MyContext.Model() == Visual3d_TOM_NONE ) {
743 // Activates only a white ambient light
744 MyCView.Context.NbActiveLight = 1;
745 lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
746 MyCView.Context.ActiveLight = lights;
748 lights[0].WsId = MyCView.ViewId;
749 lights[0].ViewId = MyCView.ViewId;
750 lights[0].LightType = int (Visual3d_TOLS_AMBIENT);
751 lights[0].Active = 1;
752 lights[0].LightId = 0;
753 lights[0].Headlight = 0;
754 lights[0].Color.r = lights[0].Color.g = lights[0].Color.b = 1.;
757 i = MyContext.NumberOfActivatedLights ();
758 j = MyGraphicDriver->InquireLightLimit ();
759 MyCView.Context.NbActiveLight = (i > j ? j : i);
761 if (MyCView.Context.NbActiveLight > 0) {
763 // Dynamic Allocation
764 lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
766 MyCView.Context.ActiveLight = lights;
768 Standard_Real X, Y, Z;
770 Standard_Real LightConcentration;
771 Standard_Real LightAttenuation1;
772 Standard_Real LightAttenuation2;
773 Standard_Real LightAngle;
774 Quantity_Color LightColor;
775 Graphic3d_Vertex LightPosition;
776 Graphic3d_Vector LightDirection;
777 Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT;
779 // Parcing of light sources
780 for (j=0; j<MyCView.Context.NbActiveLight; j++) {
781 LightType = (MyContext.ActivatedLight (j+1))->LightType ();
783 lights[j].WsId = MyCView.ViewId;
784 lights[j].ViewId = MyCView.ViewId;
786 lights[j].LightType = int (LightType);
787 lights[j].Active = 1;
789 int ((MyContext.ActivatedLight (j+1))->Identification ());
790 lights[j].Headlight = (MyContext.ActivatedLight (j+1))->Headlight ()? 1:0;
794 case Visual3d_TOLS_AMBIENT :
795 (MyContext.ActivatedLight (j+1))->Values (
800 case Visual3d_TOLS_POSITIONAL :
801 (MyContext.ActivatedLight (j+1))->Values (
809 case Visual3d_TOLS_DIRECTIONAL :
810 (MyContext.ActivatedLight (j+1))->Values (
816 case Visual3d_TOLS_SPOT :
817 (MyContext.ActivatedLight (j+1))->Values (
830 lights[j].Color.r = float (LightColor.Red ());
831 lights[j].Color.g = float (LightColor.Green ());
832 lights[j].Color.b = float (LightColor.Blue ());
834 if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
835 (LightType == Visual3d_TOLS_SPOT) ) {
836 LightPosition.Coord (X, Y, Z);
837 lights[j].Position.x = float (X);
838 lights[j].Position.y = float (Y);
839 lights[j].Position.z = float (Z);
842 if ( (LightType == Visual3d_TOLS_DIRECTIONAL) ||
843 (LightType == Visual3d_TOLS_SPOT) ) {
844 LightDirection.Coord (X, Y, Z);
845 lights[j].Direction.x = float (X);
846 lights[j].Direction.y = float (Y);
847 lights[j].Direction.z = float (Z);
850 if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
851 (LightType == Visual3d_TOLS_SPOT) ) {
852 lights[j].Attenuation[0] =
853 float (LightAttenuation1);
854 lights[j].Attenuation[1] =
855 float (LightAttenuation2);
858 if (LightType == Visual3d_TOLS_SPOT) {
859 lights[j].Concentration =
860 float (LightConcentration);
870 // management of light sources
873 MyGraphicDriver->SetLight (MyCView);
875 // Dynamic allocation
876 if (MyCView.Context.NbActiveLight > 0) delete [] lights;
880 void Visual3d_View::UpdatePlanes () {
882 Standard_Integer i, j;
883 CALL_DEF_PLANE *planes=NULL;
885 i = MyContext.NumberOfActivatedClipPlanes ();
886 j = MyGraphicDriver->InquirePlaneLimit ();
887 MyCView.Context.NbActivePlane = (i > j ? j : i);
889 if (MyCView.Context.NbActivePlane > 0) {
891 // Dynamic Allocation
892 #ifdef GER61454 //Keep the plane address for the next Update !
893 if( !MyCView.Context.ActivePlane )
894 MyCView.Context.ActivePlane = new CALL_DEF_PLANE [j];
895 planes = MyCView.Context.ActivePlane;
897 planes = new CALL_DEF_PLANE [MyCView.Context.NbActivePlane];
899 MyCView.Context.ActivePlane = planes;
901 Standard_Real A, B, C, D;
903 // Parcing of clipping planes
904 for (j=0; j<MyCView.Context.NbActivePlane; j++) {
906 planes[j].WsId = MyCView.ViewId;
907 planes[j].ViewId = MyCView.ViewId;
909 planes[j].Active = 1;
911 int ((MyContext.ActivatedClipPlane (j+1))->Identification ());
913 (MyContext.ActivatedClipPlane (j+1))->Plane (A, B, C, D);
914 planes[j].CoefA = float (A);
915 planes[j].CoefB = float (B);
916 planes[j].CoefC = float (C);
917 planes[j].CoefD = float (D);
922 // Management of planes of clipping model
925 MyGraphicDriver->SetPlane (MyCView);
927 // Dynamic allocation
929 if ( MyCView.Context.ActivePlane && (MyCView.Context.NbActivePlane == 0)
931 delete [] MyCView.Context.ActivePlane;
932 MyCView.Context.ActivePlane = NULL;
935 if (MyCView.Context.NbActivePlane > 0) delete [] planes;
940 void Visual3d_View::SetBackground (const Aspect_Background& ABack) {
942 if (IsDeleted ()) return;
945 Visual3d_ViewDefinitionError::Raise ("Window not defined");
947 // At this level, only GL can update the background.
948 // It is not necessary to call MyWindow->SetBackground (ABack); as
949 // this method starts update of window background by X
950 // (if the windowing is X)
952 Standard_Real R, G, B;
953 MyBackground = ABack;
954 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
955 MyCView.DefWindow.Background.r = float (R);
956 MyCView.DefWindow.Background.g = float (G);
957 MyCView.DefWindow.Background.b = float (B);
959 MyGraphicDriver->Background (MyCView);
961 if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
966 void Visual3d_View::SetGradientBackground(const Aspect_GradientBackground& ABack, const Standard_Boolean update)
969 if (IsDeleted ()) return;
972 Visual3d_ViewDefinitionError::Raise ("Window not defined");
974 MyGradientBackground = ABack;
975 Quantity_Color aCol1,aCol2;
976 MyGradientBackground.Colors(aCol1,aCol2);
977 MyGraphicDriver->GradientBackground(MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod());
981 else if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
985 void Visual3d_View::SetBackgroundImage( const Standard_CString FileName,
986 const Aspect_FillMethod FillStyle,
987 const Standard_Boolean update )
993 Visual3d_ViewDefinitionError::Raise ("Window not defined");
995 MyGraphicDriver->BackgroundImage( FileName, MyCView, FillStyle );
999 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1004 void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
1005 const Standard_Boolean update )
1011 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1013 MyGraphicDriver->SetBgImageStyle( MyCView, FillStyle );
1017 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1022 Aspect_Background Visual3d_View::Background () const {
1024 return (MyBackground);
1028 void Visual3d_View::SetBgGradientStyle( const Aspect_GradientFillMethod FillStyle,
1029 const Standard_Boolean update )
1034 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1036 MyGraphicDriver->SetBgGradientStyle( MyCView, FillStyle );
1040 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1045 Aspect_GradientBackground Visual3d_View::GradientBackground () const {
1047 return MyGradientBackground;
1051 void Visual3d_View::SetTransform (const TColStd_Array2OfReal& AMatrix) {
1053 if (IsDeleted ()) return;
1055 Standard_Integer lr, ur, lc, uc;
1056 Standard_Integer i, j;
1058 // Assign the new transformation in an array [0..3][0..3]
1059 // Avoid problems if the has defined a matrice [1..4][1..4]
1060 // ou [3..6][-1..2] !!
1061 lr = AMatrix.LowerRow ();
1062 ur = AMatrix.UpperRow ();
1063 lc = AMatrix.LowerCol ();
1064 uc = AMatrix.UpperCol ();
1066 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
1067 Visual3d_TransformError::Raise ("Transform : not a 4x4 matrix");
1069 for (i=0; i<=3; i++)
1070 for (j=0; j<=3; j++)
1071 MyTransformation (i, j) = AMatrix (lr + i, lc + j);
1073 Graphic3d_Vector VPN;
1074 Graphic3d_Vertex VRP;
1075 Graphic3d_Vector VUP;
1076 Standard_Real Sx, Sy, Sz;
1078 Visual3d_ViewOrientation NewViewOrientation;
1080 VPN = MyViewOrientation.ViewReferencePlane ();
1081 VRP = MyViewOrientation.ViewReferencePoint ();
1082 VUP = MyViewOrientation.ViewReferenceUp ();
1083 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1085 NewViewOrientation.SetViewReferencePlane
1086 (Graphic3d_Structure::Transforms (Transform (), VPN));
1088 NewViewOrientation.SetViewReferencePoint
1089 (Graphic3d_Structure::Transforms (Transform (), VRP));
1091 NewViewOrientation.SetViewReferenceUp
1092 (Graphic3d_Structure::Transforms (Transform (), VUP));
1093 NewViewOrientation.SetAxialScale(Sx, Sy, Sz);
1095 SetViewOrientation (NewViewOrientation);
1097 MyMatOfOriIsModified = Standard_True;
1098 MyMatOfOriIsEvaluated = Standard_False;
1102 const TColStd_Array2OfReal& Visual3d_View::Transform () const {
1104 return (MyTransformation);
1108 void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
1110 if (IsDeleted ()) return;
1112 MyViewOrientation = VO;
1114 Standard_Real X, Y, Z;
1116 // Tests on modification of parameters.
1117 Standard_Boolean VUPIsModified = Standard_False;
1118 Standard_Boolean VRPIsModified = Standard_False;
1119 Standard_Boolean VRUIsModified = Standard_False;
1120 Standard_Boolean ScaleIsModified = Standard_False;
1121 Standard_Boolean CustomIsModified = Standard_False;
1123 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
1125 MyCView.Orientation.ViewReferencePoint.x != float (X)
1126 || MyCView.Orientation.ViewReferencePoint.y != float (Y)
1127 || MyCView.Orientation.ViewReferencePoint.z != float (Z);
1128 MyCView.Orientation.ViewReferencePoint.x = float (X);
1129 MyCView.Orientation.ViewReferencePoint.y = float (Y);
1130 MyCView.Orientation.ViewReferencePoint.z = float (Z);
1132 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
1134 MyCView.Orientation.ViewReferencePlane.x != float (X)
1135 || MyCView.Orientation.ViewReferencePlane.y != float (Y)
1136 || MyCView.Orientation.ViewReferencePlane.z != float (Z);
1137 MyCView.Orientation.ViewReferencePlane.x = float (X);
1138 MyCView.Orientation.ViewReferencePlane.y = float (Y);
1139 MyCView.Orientation.ViewReferencePlane.z = float (Z);
1141 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
1143 MyCView.Orientation.ViewReferenceUp.x != float (X)
1144 || MyCView.Orientation.ViewReferenceUp.y != float (Y)
1145 || MyCView.Orientation.ViewReferenceUp.z != float (Z);
1146 MyCView.Orientation.ViewReferenceUp.x = float (X);
1147 MyCView.Orientation.ViewReferenceUp.y = float (Y);
1148 MyCView.Orientation.ViewReferenceUp.z = float (Z);
1150 Standard_Real Sx, Sy, Sz;
1152 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1154 MyCView.Orientation.ViewScaleX != float (X)
1155 || MyCView.Orientation.ViewScaleY != float (Y)
1156 || MyCView.Orientation.ViewScaleZ != float (Z);
1157 MyCView.Orientation.ViewScaleX = float (Sx);
1158 MyCView.Orientation.ViewScaleY = float (Sy);
1159 MyCView.Orientation.ViewScaleZ = float (Sz);
1162 MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
1163 MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
1164 if ( MyViewOrientation.IsCustomMatrix() ) {
1165 Standard_Integer i, j;
1166 for (i = 0; i < 4; i++)
1167 for (j = 0; j < 4; j++) {
1168 if (!CustomIsModified) CustomIsModified =
1169 MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
1170 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
1175 cout << "Visual3d_View::SetViewOrientation\n";
1176 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
1177 cout << "VUPIsModified : " << VUPIsModified
1178 << ", VRPIsModified : " << VRPIsModified
1179 << ", VRUIsModified : " << VRUIsModified
1180 << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
1182 cout << "no modification\n" << flush;
1185 // restart if one of parameters is modified
1186 if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified) {
1188 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1189 MyMatOfOriIsModified = Standard_True;
1190 MyMatOfOriIsEvaluated = Standard_False;
1193 if (! IsDefined ()) return;
1195 Standard_Boolean AWait = Standard_False; // => immediate update
1196 MyGraphicDriver->ViewOrientation (MyCView, AWait);
1200 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1205 Visual3d_ViewOrientation Visual3d_View::ViewOrientation () const {
1207 return (MyViewOrientation);
1211 Visual3d_ViewOrientation Visual3d_View::ViewOrientationDefault () const {
1213 return (MyViewOrientationReset);
1217 void Visual3d_View::SetViewOrientationDefault () {
1219 MyViewOrientationReset.Assign (MyViewOrientation);
1223 void Visual3d_View::ViewOrientationReset () {
1225 if (IsDeleted ()) return;
1227 MyViewOrientation = MyViewOrientationReset;
1229 Standard_Real X, Y, Z;
1231 // Tests on modification of parameters.
1232 Standard_Boolean VUPIsModified = Standard_False;
1233 Standard_Boolean VRPIsModified = Standard_False;
1234 Standard_Boolean VRUIsModified = Standard_False;
1235 Standard_Boolean ScaleIsModified = Standard_False;
1236 Standard_Boolean CustomIsModified = Standard_False;
1238 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
1240 MyCView.Orientation.ViewReferencePoint.x != float (X)
1241 || MyCView.Orientation.ViewReferencePoint.y != float (Y)
1242 || MyCView.Orientation.ViewReferencePoint.y != float (Y);
1243 MyCView.Orientation.ViewReferencePoint.x = float (X);
1244 MyCView.Orientation.ViewReferencePoint.y = float (Y);
1245 MyCView.Orientation.ViewReferencePoint.z = float (Z);
1247 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
1249 MyCView.Orientation.ViewReferencePlane.x != float (X)
1250 || MyCView.Orientation.ViewReferencePlane.y != float (Y)
1251 || MyCView.Orientation.ViewReferencePlane.y != float (Y);
1252 MyCView.Orientation.ViewReferencePlane.x = float (X);
1253 MyCView.Orientation.ViewReferencePlane.y = float (Y);
1254 MyCView.Orientation.ViewReferencePlane.z = float (Z);
1256 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
1258 MyCView.Orientation.ViewReferenceUp.x != float (X)
1259 || MyCView.Orientation.ViewReferenceUp.y != float (Y)
1260 || MyCView.Orientation.ViewReferenceUp.y != float (Y);
1261 MyCView.Orientation.ViewReferenceUp.x = float (X);
1262 MyCView.Orientation.ViewReferenceUp.y = float (Y);
1263 MyCView.Orientation.ViewReferenceUp.z = float (Z);
1265 Standard_Real Sx, Sy, Sz;
1267 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1269 MyCView.Orientation.ViewScaleX != float (X)
1270 || MyCView.Orientation.ViewScaleY != float (Y)
1271 || MyCView.Orientation.ViewScaleZ != float (Z);
1272 MyCView.Orientation.ViewScaleX = float (Sx);
1273 MyCView.Orientation.ViewScaleY = float (Sy);
1274 MyCView.Orientation.ViewScaleZ = float (Sz);
1277 MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
1278 MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
1279 if ( MyViewOrientation.IsCustomMatrix() ) {
1280 Standard_Integer i, j;
1281 for (i = 0; i < 4; i++)
1282 for (j = 0; j < 4; j++) {
1283 if (!CustomIsModified) CustomIsModified =
1284 MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
1285 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
1290 cout << "Visual3d_View::ViewOrientationReset\n";
1291 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
1292 cout << "VUPIsModified : " << VUPIsModified
1293 << ", VRPIsModified : " << VRPIsModified
1294 << ", VRUIsModified : " << VRUIsModified
1295 << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
1297 cout << "no modification\n" << flush;
1300 // Restart if one of parameters is modified
1301 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1303 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1304 MyMatOfOriIsModified = Standard_True;
1305 MyMatOfOriIsEvaluated = Standard_False;
1308 if (! IsDefined ()) return;
1310 Standard_Boolean AWait = Standard_False; // => immediate update
1311 MyGraphicDriver->ViewOrientation (MyCView, AWait);
1315 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1320 void Visual3d_View::SetViewMapping (const Visual3d_ViewMapping& VM) {
1322 if (IsDeleted ()) return;
1324 Visual3d_TypeOfProjection OldType = MyViewMapping.Projection ();
1325 Visual3d_TypeOfProjection NewType = VM.Projection ();
1329 Standard_Real X, Y, Z;
1330 Standard_Real um, vm, uM, vM;
1332 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
1333 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
1334 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
1335 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
1336 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
1337 MyCView.Mapping.ViewPlaneDistance =
1338 float (MyViewMapping.ViewPlaneDistance ());
1339 MyCView.Mapping.BackPlaneDistance =
1340 float (MyViewMapping.BackPlaneDistance ());
1341 MyCView.Mapping.FrontPlaneDistance =
1342 float (MyViewMapping.FrontPlaneDistance ());
1343 MyViewMapping.WindowLimit (um, vm, uM, vM);
1344 MyCView.Mapping.WindowLimit.um = float (um);
1345 MyCView.Mapping.WindowLimit.vm = float (vm);
1346 MyCView.Mapping.WindowLimit.uM = float (uM);
1347 MyCView.Mapping.WindowLimit.vM = float (vM);
1349 MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
1350 if (MyViewMapping.IsCustomMatrix()) {
1351 Standard_Integer i, j;
1352 for (i = 0; i < 4; i++)
1353 for (j = 0; j < 4; j++)
1354 MyCView.Mapping.ProjectionMatrix[i][j] =
1355 MyViewMapping.MyProjectionMatrix->Value(i,j);
1358 MyMatOfMapIsModified = Standard_True;
1359 MyMatOfMapIsEvaluated = Standard_False;
1361 if (! IsDefined ()) return;
1363 Standard_Boolean AWait = Standard_False; // => immediate update
1364 MyGraphicDriver->ViewMapping (MyCView, AWait);
1366 // Passage Parallele/Perspective
1367 if (OldType != NewType)
1370 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1374 Visual3d_ViewMapping Visual3d_View::ViewMapping () const {
1376 return (MyViewMapping);
1380 Visual3d_ViewMapping Visual3d_View::ViewMappingDefault () const {
1382 return (MyViewMappingReset);
1386 void Visual3d_View::SetViewMappingDefault () {
1388 MyViewMappingReset.Assign (MyViewMapping);
1392 void Visual3d_View::ViewMappingReset () {
1394 if (IsDeleted ()) return;
1396 MyViewMapping = MyViewMappingReset;
1398 Standard_Real X, Y, Z;
1399 Standard_Real um, vm, uM, vM;
1401 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
1402 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
1403 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
1404 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
1405 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
1406 MyCView.Mapping.ViewPlaneDistance =
1407 float (MyViewMapping.ViewPlaneDistance ());
1408 MyCView.Mapping.BackPlaneDistance =
1409 float (MyViewMapping.BackPlaneDistance ());
1410 MyCView.Mapping.FrontPlaneDistance =
1411 float (MyViewMapping.FrontPlaneDistance ());
1412 MyViewMapping.WindowLimit (um, vm, uM, vM);
1413 MyCView.Mapping.WindowLimit.um = float (um);
1414 MyCView.Mapping.WindowLimit.vm = float (vm);
1415 MyCView.Mapping.WindowLimit.uM = float (uM);
1416 MyCView.Mapping.WindowLimit.vM = float (vM);
1418 MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
1419 if (MyViewMapping.IsCustomMatrix()) {
1420 Standard_Integer i, j;
1421 for (i = 0; i < 4; i++)
1422 for (j = 0; j < 4; j++)
1423 MyCView.Mapping.ProjectionMatrix[i][j] =
1424 MyViewMapping.MyProjectionMatrix->Value(i,j);
1427 MyMatOfMapIsModified = Standard_True;
1428 MyMatOfMapIsEvaluated = Standard_False;
1430 if (! IsDefined ()) return;
1432 Standard_Boolean AWait = Standard_False; // => immediate update
1433 MyGraphicDriver->ViewMapping (MyCView, AWait);
1435 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1439 void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
1441 if (IsDeleted ()) return;
1443 Visual3d_TypeOfVisualization OldVisualMode;
1444 Visual3d_TypeOfVisualization NewVisualMode;
1446 // To manage display only in case of
1447 // change of visualisation mode.
1448 OldVisualMode = MyContext.Visualization ();
1449 NewVisualMode = CTX.Visualization ();
1451 Visual3d_TypeOfModel OldModel;
1452 Visual3d_TypeOfModel NewModel;
1454 // To manage change of visualisation only in case
1455 // of change of mode of visualisation or of type of shading.
1456 OldModel = MyContext.Model ();
1457 NewModel = CTX.Model ();
1459 Standard_Boolean OldAliasingMode;
1460 Standard_Boolean NewAliasingMode;
1462 // To manage antialiasing only in case of change.
1463 OldAliasingMode = MyContext.AliasingIsOn ();
1464 NewAliasingMode = CTX.AliasingIsOn ();
1466 Standard_Boolean OldDepthCueingMode;
1467 Standard_Boolean NewDepthCueingMode;
1469 Standard_Real OldDepthCueingFrontPlane;
1470 Standard_Real NewDepthCueingFrontPlane;
1471 Standard_Real OldDepthCueingBackPlane;
1472 Standard_Real NewDepthCueingBackPlane;
1474 // To manage the depth cueing only in case of change.
1475 OldDepthCueingMode = MyContext.DepthCueingIsOn ();
1476 NewDepthCueingMode = CTX.DepthCueingIsOn ();
1478 OldDepthCueingFrontPlane = MyContext.DepthCueingFrontPlane ();
1479 NewDepthCueingFrontPlane = CTX.DepthCueingFrontPlane ();
1480 OldDepthCueingBackPlane = MyContext.DepthCueingBackPlane ();
1481 NewDepthCueingBackPlane = CTX.DepthCueingBackPlane ();
1483 Standard_Boolean OldFrontZClippingMode;
1484 Standard_Boolean NewFrontZClippingMode;
1485 Standard_Boolean OldBackZClippingMode;
1486 Standard_Boolean NewBackZClippingMode;
1488 Standard_Real OldZClippingFrontPlane;
1489 Standard_Real NewZClippingFrontPlane;
1490 Standard_Real OldZClippingBackPlane;
1491 Standard_Real NewZClippingBackPlane;
1493 // To manage the Zclipping only in case of change.
1494 OldFrontZClippingMode = MyContext.FrontZClippingIsOn ();
1495 NewFrontZClippingMode = CTX.FrontZClippingIsOn ();
1496 OldBackZClippingMode = MyContext.BackZClippingIsOn ();
1497 NewBackZClippingMode = CTX.BackZClippingIsOn ();
1499 OldZClippingFrontPlane = MyContext.ZClippingFrontPlane ();
1500 NewZClippingFrontPlane = CTX.ZClippingFrontPlane ();
1501 OldZClippingBackPlane = MyContext.ZClippingBackPlane ();
1502 NewZClippingBackPlane = CTX.ZClippingBackPlane ();
1504 Standard_Integer OldTexEnvId;
1505 Standard_Integer NewTexEnvId;
1506 Visual3d_TypeOfSurfaceDetail OldSurfaceDetail;
1507 Visual3d_TypeOfSurfaceDetail NewSurfaceDetail;
1509 Handle(Graphic3d_TextureEnv) TempTextureEnv1 = MyContext.TextureEnv();
1510 if (! TempTextureEnv1.IsNull()) OldTexEnvId = TempTextureEnv1->TextureId();
1511 else OldTexEnvId = -1;
1513 Handle(Graphic3d_TextureEnv) TempTextureEnv2 = CTX.TextureEnv();
1515 if (! TempTextureEnv2.IsNull()) NewTexEnvId = TempTextureEnv2->TextureId();
1516 else NewTexEnvId = -1;
1518 OldSurfaceDetail = MyContext.SurfaceDetail();
1519 NewSurfaceDetail = CTX.SurfaceDetail();
1525 Standard_Boolean AWait = Standard_False; // => immediate update
1527 // management of visualization modes and types of shading.
1528 if ((OldVisualMode != NewVisualMode) || (OldModel != NewModel))
1529 MyGraphicDriver->SetVisualisation (MyCView);
1531 // management of antialiasing.
1532 if (OldAliasingMode != NewAliasingMode)
1533 MyGraphicDriver->AntiAliasing (MyCView, NewAliasingMode);
1535 // management of depth_cueing.
1536 if ((OldDepthCueingMode != NewDepthCueingMode) ||
1537 (OldDepthCueingFrontPlane != NewDepthCueingFrontPlane) ||
1538 (OldDepthCueingBackPlane != NewDepthCueingBackPlane)) {
1540 if( NewDepthCueingMode &&
1541 (NewDepthCueingBackPlane >= NewDepthCueingFrontPlane) )
1542 Visual3d_DepthCueingDefinitionError::Raise
1543 ("Bad value for DepthCueingPlanes position");
1545 MyGraphicDriver->DepthCueing
1546 (MyCView, NewDepthCueingMode);
1549 // management of Zclipping
1550 if ((OldFrontZClippingMode != NewFrontZClippingMode) ||
1551 (OldBackZClippingMode != NewBackZClippingMode) ||
1552 (OldZClippingFrontPlane != NewZClippingFrontPlane) ||
1553 (OldZClippingBackPlane != NewZClippingBackPlane)) {
1555 if( NewBackZClippingMode && NewFrontZClippingMode &&
1556 (NewZClippingBackPlane >= NewZClippingFrontPlane) )
1557 Visual3d_ZClippingDefinitionError::Raise
1558 ("Bad value for ZClippingPlanes position");
1560 MyGraphicDriver->ClipLimit (MyCView, AWait);
1563 // management of textures
1564 if ( (OldTexEnvId != NewTexEnvId) ||
1565 (OldSurfaceDetail != NewSurfaceDetail) )
1566 MyGraphicDriver->Environment(MyCView);
1568 // Update of planes of model clipping
1571 // Update of light sources
1575 if (OldVisualMode != NewVisualMode) {
1578 * Change of context =>
1579 * Remove structures that cannot be displayed
1580 * in the new visualisation mode.
1581 * It is not necessary to warn ViewManager as
1582 * this structure should not disappear from
1583 * the list of structures displayed in it.
1585 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
1586 Visual3d_TypeOfAnswer Answer;
1588 Standard_Integer i = MyDisplayedStructure.Extent ();
1590 Graphic3d_SequenceOfStructure FooSequence;
1592 while (S1Iterator.More ()) {
1593 Answer = AcceptDisplay (S1Iterator.Key ());
1594 // If the structure can't be displayed in the
1595 // new context of the view, it is removed.
1596 if ((Answer == Visual3d_TOA_NO) ||
1597 (Answer == Visual3d_TOA_COMPUTE))
1598 //Erase (S1Iterator.Key (), Aspect_TOU_WAIT);
1599 FooSequence.Append (S1Iterator.Key ());
1601 // S1Iterator.Next () is located on the next structure
1605 Standard_Integer Length = FooSequence.Length ();
1606 // The stored structures are removed
1607 for (i=1; i<=Length; i++)
1608 Erase (FooSequence.Value (i), Aspect_TOU_WAIT);
1609 if (Length != 0) FooSequence.Clear ();
1612 * Change of context =>
1613 * Display structures that can be displayed
1614 * with the new visualisation mode.
1615 * All structures with status Displayed are removed from the ViewManager
1616 * and displayed in the view directly, if the structure is not already
1617 * displayed and if the view accepts it in its context.
1620 i = MyViewManager->NumberOfDisplayedStructures ();
1621 Graphic3d_MapOfStructure Map;
1622 MyViewManager->DisplayedStructures(Map);
1623 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1625 for (; it.More(); it.Next()) {
1626 Handle(Graphic3d_Structure) SG = it.Key();
1627 if (! IsDisplayed (SG)) {
1628 Answer = AcceptDisplay(SG);
1629 // If the structure can be displayed in the
1630 // new context of the view, it is displayed.
1631 if ((Answer == Visual3d_TOA_YES) ||
1632 (Answer == Visual3d_TOA_COMPUTE))
1633 //Display (MyViewManager->DisplayedStructure (j),
1635 FooSequence.Append (SG);
1639 Length = FooSequence.Length ();
1640 // The stored structures are displayed
1641 for (i=1; i<=Length; i++)
1642 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
1643 if (Length != 0) FooSequence.Clear ();
1646 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1650 const Visual3d_ContextView& Visual3d_View::Context () const {
1656 void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& SG) const
1659 if (IsDeleted ()) return;
1661 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
1663 while (Iterator.More ()) {
1664 SG.Add (Iterator.Key ());
1666 // Iterator.Next () is located on the next structure
1672 void Visual3d_View::Activate () {
1674 if (IsDeleted ()) return;
1677 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1679 if (! IsActive ()) {
1681 MyGraphicDriver->ActivateView (MyCView);
1682 MyGraphicDriver->Background (MyCView);
1683 MyGraphicDriver->Transparency
1684 (MyCView, MyViewManager->Transparency ());
1689 * Activation of a new view =>
1690 * Display structures that can be displayed in this new view.
1691 * All structures with status
1692 * Displayed in ViewManager are returned and displayed in
1693 * the view directly, if the structure is not already
1694 * displayed and if the view accepts it in its context.
1697 Visual3d_TypeOfAnswer Answer;
1698 Graphic3d_MapOfStructure Map;
1699 MyViewManager->DisplayedStructures(Map);
1700 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1702 for (; it.More(); it.Next()) {
1703 Handle(Graphic3d_Structure) SG = it.Key();
1704 if (! IsDisplayed (SG)) {
1705 Answer = AcceptDisplay(SG);
1706 // If the structure can be displayed in the
1707 // new context of the view, it is displayed.
1708 if ((Answer == Visual3d_TOA_YES) ||
1709 (Answer == Visual3d_TOA_COMPUTE))
1710 Display (SG,Aspect_TOU_WAIT);
1716 // If the activation/desactivation of ZBuffer should be automatic
1717 // depending on the presence or absence of facets.
1718 if (MyViewManager->ZBufferAuto ()) {
1719 Standard_Boolean BContainsFacet = ContainsFacet ();
1720 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1721 // If the view contains facets
1722 // and if ZBuffer is not active
1723 if (BContainsFacet && ! BZBuffer)
1724 SetZBufferActivity (1);
1725 // If the view does not contain facets
1726 // and if ZBuffer is active
1727 if (! BContainsFacet && BZBuffer)
1728 SetZBufferActivity (0);
1731 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1735 Standard_Boolean Visual3d_View::IsActive () const {
1737 if (IsDeleted ()) return (Standard_False);
1740 return (Standard_True);
1742 return (Standard_False);
1746 void Visual3d_View::Deactivate () {
1748 if (IsDeleted ()) return;
1751 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1755 MyGraphicDriver->DeactivateView (MyCView);
1758 * Deactivation of a view =>
1759 * Removal of structures displayed in this view.
1760 * All structures with status
1761 * Displayed in ViewManager are returned and removed from
1762 * the view directly, if the structure is not already
1763 * displayed and if the view accepts it in its context.
1766 Visual3d_TypeOfAnswer Answer;
1767 Graphic3d_MapOfStructure Map;
1768 MyViewManager->DisplayedStructures(Map);
1769 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1771 for (; it.More(); it.Next()) {
1772 Handle(Graphic3d_Structure) SG = it.Key();
1773 if (! IsDisplayed (SG)) {
1774 Answer = AcceptDisplay(SG);
1775 // If the structure was displayed it is removed.
1776 if ((Answer == Visual3d_TOA_YES) ||
1777 (Answer == Visual3d_TOA_COMPUTE))
1778 Erase (SG,Aspect_TOU_WAIT);
1782 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1784 // No action currently possible in the view
1790 void Visual3d_View::Redraw () {
1792 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1796 void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
1798 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height);
1801 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1803 if (IsDeleted ()) return;
1805 if ((! IsDefined ()) || (! IsActive ())) return;
1807 if (! MyWindow->IsMapped ()) return;
1809 // san - 14/04/2004 - set up Z buffer state before redrawing
1810 // If the activation/desactivation of ZBuffer should be automatic
1811 // depending on the presence or absence of facets.
1812 if (MyViewManager->ZBufferAuto ()) {
1813 Standard_Boolean BContainsFacet = ContainsFacet ();
1814 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1815 // If the view contains facets
1816 // and if ZBuffer is not active
1817 if (BContainsFacet && ! BZBuffer)
1818 SetZBufferActivity (1);
1819 // If the view contains only facets
1820 // and if ZBuffer is active
1821 if (! BContainsFacet && BZBuffer)
1822 SetZBufferActivity (0);
1825 Aspect_CLayer2d OverCLayer;
1826 Aspect_CLayer2d UnderCLayer;
1827 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1828 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1829 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1830 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer);
1834 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer, const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
1836 if (IsDeleted ()) return;
1838 if ((! IsDefined ()) || (! IsActive ())) return;
1840 if (! MyWindow->IsMapped ()) return;
1842 // san - 14/04/2004 - set up Z buffer state before redrawing
1843 // If activation/desactivation of ZBuffer should be automatic
1844 // depending on the presence or absence of facets.
1845 if (MyViewManager->ZBufferAuto ()) {
1846 Standard_Boolean BContainsFacet = ContainsFacet ();
1847 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1848 // If the view contains facets
1849 // and if ZBuffer is not active
1850 if (BContainsFacet && ! BZBuffer)
1851 SetZBufferActivity (1);
1852 // If the view contains only facets
1853 // and if ZBuffer is active
1854 if (! BContainsFacet && BZBuffer)
1855 SetZBufferActivity (0);
1858 Aspect_CLayer2d OverCLayer;
1859 Aspect_CLayer2d UnderCLayer;
1860 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1861 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1862 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1863 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer, x, y, width, height);
1867 void Visual3d_View::Update () {
1869 Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1873 void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1875 if (IsDeleted ()) return;
1877 if ((! IsDefined ()) || (! IsActive ())) return;
1879 if (! MyWindow->IsMapped ()) return;
1881 // If activation/desactivation of ZBuffer should be automatic
1882 // depending on the presence or absence of facets.
1883 if (MyViewManager->ZBufferAuto ()) {
1884 Standard_Boolean BContainsFacet = ContainsFacet ();
1885 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1886 // If the view contains facets
1887 // and if ZBuffer is not active
1888 if (BContainsFacet && ! BZBuffer)
1889 SetZBufferActivity (1);
1890 // If the view does not contain facets
1891 // and if ZBuffer is active
1892 if (! BContainsFacet && BZBuffer)
1893 SetZBufferActivity (0);
1896 Aspect_CLayer2d OverCLayer;
1897 Aspect_CLayer2d UnderCLayer;
1898 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1899 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1900 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1901 //OSD::SetSignal (Standard_False);
1902 MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer);
1903 //OSD::SetSignal (Standard_True);
1905 MyMatOfMapIsModified = Standard_False;
1906 MyMatOfOriIsModified = Standard_False;
1910 Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const {
1912 // Return type of visualization of the view
1913 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
1915 // Return type of visualization of the structure
1916 Graphic3d_TypeOfStructure StructType = AStructure->Visual ();
1918 Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO;
1920 if (StructType == Graphic3d_TOS_ALL)
1921 // The structure accepts any type of view
1922 Result = Visual3d_TOA_YES;
1924 if ((StructType == Graphic3d_TOS_SHADING)
1925 && (ViewType == Visual3d_TOV_SHADING))
1926 Result = Visual3d_TOA_YES;
1927 if ((StructType == Graphic3d_TOS_WIREFRAME)
1928 && (ViewType == Visual3d_TOV_WIREFRAME))
1929 Result = Visual3d_TOA_YES;
1930 if ((StructType == Graphic3d_TOS_COMPUTED)
1931 && (ViewType == Visual3d_TOV_WIREFRAME))
1932 Result = Visual3d_TOA_COMPUTE;
1933 if ((StructType == Graphic3d_TOS_COMPUTED)
1934 && (ViewType == Visual3d_TOV_SHADING))
1935 Result = Visual3d_TOA_COMPUTE;
1939 if (Result == Visual3d_TOA_YES)
1940 cout << "YES = Visual3d_View" << MyCView.ViewId
1941 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1942 if (Result == Visual3d_TOA_NO)
1943 cout << "NO = Visual3d_View" << MyCView.ViewId
1944 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1945 if (Result == Visual3d_TOA_COMPUTE)
1946 cout << "COMPUTE = Visual3d_View" << MyCView.ViewId
1947 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1955 void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority) {
1957 if (IsDeleted ()) return;
1958 if (! IsDefined ()) return;
1959 if (! IsActive ()) return;
1960 if (! IsDisplayed (AStructure)) return;
1962 Standard_Integer Index = IsComputed (AStructure);
1964 if ( Index != 0 && ComputedMode () && !DegenerateModeIsOn () )
1966 if ((Index != 0) && (! DegenerateModeIsOn ()))
1970 Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification ();
1971 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1972 << AStructure->Identification () << "/" << StructId
1973 << ", " << OldPriority << ", " << NewPriority << ")\n";
1976 MyGraphicDriver->EraseStructure
1978 *(Graphic3d_CStructure *)
1979 MyCOMPUTEDSequence.Value (Index)->CStructure ());
1980 MyGraphicDriver->DisplayStructure
1982 *(Graphic3d_CStructure *)
1983 MyCOMPUTEDSequence.Value (Index)->CStructure (),
1988 Standard_Integer StructId = AStructure->Identification ();
1989 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1990 << AStructure->Identification () << "/" << StructId
1991 << ", " << OldPriority << ", " << NewPriority << ")\n";
1994 MyGraphicDriver->EraseStructure
1996 *(Graphic3d_CStructure *)AStructure->CStructure ());
1997 MyGraphicDriver->DisplayStructure
1999 *(Graphic3d_CStructure *)AStructure->CStructure (),
2005 void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) {
2008 cout << "Visual3d_View" << MyCView.ViewId << "::Clear ("
2009 << AStructure->Identification () << ")\n";
2013 Standard_Integer Index = IsComputed (AStructure);
2016 cout << "Structure " << AStructure->Identification ()
2017 << " calculated in the view "
2018 << Identification () << ", by structure "
2019 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2020 << " is emptied.\n";
2023 MyCOMPUTEDSequence.Value (Index)->GraphicClear (WithDestruction);
2024 MyCOMPUTEDSequence.Value (Index)->SetHLRValidation (Standard_False);
2029 void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
2031 #ifdef TRACE_CONNECT
2032 cout << "Visual3d_View" << MyCView.ViewId << "::Connect ("
2033 << AMother->Identification ()
2034 << ADaughter->Identification () << ")\n";
2038 Standard_Integer IndexM = IsComputed (AMother);
2039 Standard_Integer IndexD = IsComputed (ADaughter);
2041 if (IndexM != 0 && IndexD != 0) {
2042 #ifdef TRACE_CONNECT
2043 cout << "Structure " << AMother->Identification ()
2044 << " is connected to structure "
2045 << ADaughter->Identification () << endl;
2046 cout << "These structures are calculated.\n";
2047 cout << "In the view " << Identification ()
2049 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
2050 << " is connected to the structure "
2051 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
2054 MyCOMPUTEDSequence.Value (IndexM)->GraphicConnect (MyCOMPUTEDSequence.Value (IndexD));
2059 void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
2061 #ifdef TRACE_CONNECT
2062 cout << "Visual3d_View" << MyCView.ViewId << "::Disconnect ("
2063 << AMother->Identification ()
2064 << ADaughter->Identification () << ")\n";
2068 Standard_Integer IndexM = IsComputed (AMother);
2069 Standard_Integer IndexD = IsComputed (ADaughter);
2071 if (IndexM != 0 && IndexD != 0) {
2072 #ifdef TRACE_CONNECT
2073 cout << "Structure " << AMother->Identification ()
2074 << " is disconnected from the structure "
2075 << ADaughter->Identification () << endl;
2076 cout << "These structures are calculated.\n";
2077 cout << "In the view " << Identification ()
2079 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
2080 << " is disconnected from the structure "
2081 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
2084 MyCOMPUTEDSequence.Value (IndexM)->GraphicDisconnect (MyCOMPUTEDSequence.Value (IndexD));
2089 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) {
2091 Display (AStructure, MyViewManager->UpdateMode ());
2095 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
2097 if (IsDeleted ()) return;
2098 if (! IsDefined ()) return;
2099 if (! IsActive ()) return;
2101 // If Display on a structure present in the list
2102 // of calculated structures while it is not
2103 // or more, of calculated type =>
2104 // - removes it as well as the associated old computed
2105 // THis happens when hlhsr becomes again of type e
2106 // non computed after SetVisual.
2107 Standard_Integer Index = IsComputed (AStructure);
2109 if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) {
2112 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2113 cout << "In Visual3d_View::Display, ";
2114 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2115 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2119 MyTOCOMPUTESequence.Remove (Index);
2120 MyCOMPUTEDSequence.Remove (Index);
2123 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2124 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2125 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2131 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
2133 #ifdef TRACE_DISPLAY
2134 Standard_Integer StructId = AStructure->Identification ();
2135 cout << "Visual3d_View" << MyCView.ViewId << "::Display ("
2136 << StructId << ");\n";
2140 if (Answer == Visual3d_TOA_NO) {
2141 #ifdef TRACE_DISPLAY
2142 cout << "Answer : Visual3d_TOA_NO\n";
2148 // Mode degenerated active
2150 if ( !ComputedMode () || DegenerateModeIsOn () )
2151 Answer = Visual3d_TOA_YES;
2153 if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
2157 if (Answer == Visual3d_TOA_YES ) {
2158 #ifdef TRACE_DISPLAY
2159 cout << "Answer : Visual3d_TOA_YES\n";
2162 if (IsDisplayed (AStructure)) return;
2163 MyGraphicDriver->DisplayStructure (
2165 *(Graphic3d_CStructure *)AStructure->CStructure (),
2166 int (AStructure->DisplayPriority ())
2168 MyDisplayedStructure.Add (AStructure);
2169 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2172 if (Answer == Visual3d_TOA_COMPUTE) {
2173 #ifdef TRACE_DISPLAY
2174 cout << "Answer : Visual3d_TOA_COMPUTE\n";
2175 cout << "Index : " << Index << "\n" << flush;
2178 // Already computed, is COMPUTED still valid?
2179 #ifdef TRACE_DISPLAY
2180 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
2181 cout << "Structure "
2182 << MyTOCOMPUTESequence.Value (Index)->Identification ()
2183 << "already calculated, in the view "
2184 << Identification () << ", par la structure "
2185 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2186 << "\n was not recalculated as HLR is valid\n";
2190 cout << "Structure "
2191 << MyTOCOMPUTESequence.Value (Index)->Identification ()
2192 << " already calculated, in the view "
2193 << Identification () << ", by the structure "
2194 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2195 << "\n should be recalculated as HLR is invalid\n";
2199 Standard_Integer OldStructId =
2200 MyCOMPUTEDSequence.Value (Index)->Identification ();
2202 // Case COMPUTED valide
2203 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
2205 if (! IsDisplayed (AStructure)) {
2206 MyDisplayedStructure.Add (AStructure);
2207 MyGraphicDriver->DisplayStructure (
2209 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
2210 int (AStructure->DisplayPriority ())
2212 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2217 // Case COMPUTED invalid
2219 // Is there another valid representation ?
2220 // Find in the sequence of already calculated structures
2221 // 1/ Structure having the same Owner as <AStructure>
2222 // 2/ That is not <AStructure>
2223 // 3/ The COMPUTED which of is valid
2224 Standard_Integer NewIndex = HaveTheSameOwner (AStructure);
2226 // Case of COMPUTED invalid, WITH a valid of replacement
2227 if (NewIndex != 0) {
2229 if (! IsDisplayed (AStructure)) {
2230 MyCOMPUTEDSequence.SetValue
2231 (Index, MyCOMPUTEDSequence.Value (NewIndex));
2232 OldStructId = MyCOMPUTEDSequence.Value (NewIndex)->
2234 MyDisplayedStructure.Add (AStructure);
2235 MyGraphicDriver->DisplayStructure (
2237 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (NewIndex)->CStructure (),
2238 int (AStructure->DisplayPriority ())
2240 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2245 // Cas COMPUTED invalid, WITHOUT a valid of replacement
2247 // COMPUTED is removed if displayed
2248 if (IsDisplayed (AStructure))
2249 MyGraphicDriver->EraseStructure (
2251 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()
2255 } // if (Index != 0)
2257 // Compute + Validation
2259 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
2261 Handle(Graphic3d_Structure) TheStructure;
2262 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
2263 AStructure->Transform (ATrsf);
2265 TColStd_Array2OfReal Ident (0, 3, 0, 3);
2266 Standard_Integer ii, jj;
2267 for (ii=0; ii<=3; ii++)
2268 for (jj=0; jj<=3; jj++)
2269 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
2270 TheStructure = MyCOMPUTEDSequence.Value (Index);
2271 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
2272 if (AStructure->IsTransformed ()) {
2273 AStructure->Compute (this, ATrsf, TheStructure);
2276 AStructure->Compute (this, TheStructure);
2280 if (AStructure->IsTransformed ()) {
2281 TheStructure = AStructure->Compute (this, ATrsf);
2284 TheStructure = AStructure->Compute (this);
2288 TheStructure->SetHLRValidation (Standard_True);
2291 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2292 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2293 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2297 // TOCOMPUTE and COMPUTED associated to sequences are added
2298 MyTOCOMPUTESequence.Append (AStructure);
2299 MyCOMPUTEDSequence.Append (TheStructure);
2302 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2303 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2304 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2308 // The previous are removed if necessary
2310 MyTOCOMPUTESequence.Remove (Index);
2311 MyCOMPUTEDSequence.Remove (Index);
2315 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2316 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2317 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2321 // Return type of visualisation of the view
2322 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2324 // Of which type will be the computed ?
2325 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
2326 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
2328 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
2329 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
2331 if (ComputeWireframe)
2332 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
2334 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
2336 if (! ComputeShading && ! ComputeWireframe)
2337 Answer = Visual3d_TOA_NO;
2339 Answer = AcceptDisplay (TheStructure);
2341 if (AStructure->IsHighlighted()) {
2342 TheStructure->SetHighlightColor (AStructure->HighlightColor ());
2343 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
2346 #ifdef TRACE_DISPLAY
2347 cout << "Structure " << StructId
2348 << " in the view " << Identification ()
2349 << " is calculated by the structure "
2350 << TheStructure->Identification ();
2351 if (Answer == Visual3d_TOA_YES)
2352 cout << " and displayed\n";
2354 cout << " but not displayed\n";
2358 // It is displayed only if the calculated structure
2359 // has a proper type corresponding to the one of the view.
2360 if (Answer != Visual3d_TOA_NO) {
2361 if (! IsDisplayed (AStructure))
2362 MyDisplayedStructure.Add (AStructure);
2363 MyGraphicDriver->DisplayStructure (
2365 *(Graphic3d_CStructure *)TheStructure->CStructure (),
2366 int (AStructure->DisplayPriority ())
2368 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2370 } // Visual3d_TOA_COMPUTE
2373 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure) {
2375 if (IsDeleted ()) return;
2377 Erase (AStructure, MyViewManager->UpdateMode ());
2381 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
2383 Standard_Integer StructId;
2385 if (IsDeleted ()) return;
2387 // No test on window as the structure is displayed only if
2388 // the window exists, so only one test is enough.
2389 if (IsDisplayed (AStructure)) {
2390 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
2392 // Degenerated mode is active
2394 if ( !ComputedMode () || DegenerateModeIsOn () )
2395 Answer = Visual3d_TOA_YES;
2397 if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
2400 if (Answer != Visual3d_TOA_COMPUTE) {
2401 MyGraphicDriver->EraseStructure (
2403 *(Graphic3d_CStructure *)AStructure->CStructure ()
2407 if (Answer == Visual3d_TOA_COMPUTE) {
2408 Standard_Integer Index = IsComputed (AStructure);
2410 cout << "Visual3d_View" << MyCView.ViewId << "::Erase ("
2411 << AStructure->Identification () << ");\n";
2412 cout << "Index : " << Index << "\n";
2416 if ( Index != 0 && ComputedMode () &&
2417 !DegenerateModeIsOn () )
2419 if ((Index != 0) && (! DegenerateModeIsOn ()))
2423 MyCOMPUTEDSequence.Value (Index)->Identification ();
2425 cout << "Structure " << AStructure->Identification ()
2426 << " calculated, in the view "
2427 << Identification () << ", by the structure "
2428 << StructId << " is removed. \n";
2431 MyGraphicDriver->EraseStructure
2432 (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
2434 // else is impossible
2436 MyDisplayedStructure.Remove (AStructure);
2437 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2442 void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) {
2445 cout << "Visual3d_View" << MyCView.ViewId << "::Highlight ("
2446 << AStructure->Identification () << ")\n";
2450 Standard_Integer Index = IsComputed (AStructure);
2453 cout << "Structure " << AStructure->Identification ()
2454 << " calculated, in the view "
2455 << Identification () << ", by the structure "
2456 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2457 << " passes in highlight mode.\n";
2460 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
2461 (AStructure->HighlightColor ());
2462 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (AMethod);
2467 void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) {
2470 cout << "Visual3d_View" << MyCView.ViewId << "::Transform ("
2471 << AStructure->Identification () << ")\n";
2475 Standard_Integer Index = IsComputed (AStructure);
2478 cout << "The structure " << AStructure->Identification ()
2479 << " calculated, in the view "
2480 << Identification () << ", by the structure "
2481 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2482 << " is transformed.\n";
2485 // Test is somewhat light !
2486 // trsf is transferred only if it is :
2489 if (ATrsf (0, 1) != 0. || ATrsf (0, 2) != 0.
2490 || ATrsf (1, 0) != 0. || ATrsf (1, 2) != 0.
2491 || ATrsf (2, 0) != 0. || ATrsf (2, 1) != 0.)
2492 ReCompute (AStructure);
2494 MyCOMPUTEDSequence.Value (Index)->GraphicTransform (ATrsf);
2499 void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) {
2502 cout << "Visual3d_View" << MyCView.ViewId << "::UnHighlight ("
2503 << AStructure->Identification () << ")\n";
2507 Standard_Integer Index = IsComputed (AStructure);
2510 cout << "Structure " << AStructure->Identification ()
2511 << " calculated, in the view "
2512 << Identification () << ", by the structure "
2513 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2514 << " passes in unhighlight mode.\n";
2517 MyCOMPUTEDSequence.Value (Index)->GraphicUnHighlight ();
2523 Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& AStructure) const {
2525 Standard_Integer StrId = AStructure->Identification ();
2527 Standard_Integer Result = 0;
2528 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2530 // Recherche de la structure <AStructure> dans la
2531 // sequence des structures deja calculees
2532 for (Standard_Integer i=1; i<=Length && Result==0; i++)
2533 if ((MyTOCOMPUTESequence.Value (i))->Identification ()
2534 == StrId) Result = i;
2536 cout << "\n In the view " << Identification () << " the structure ";
2538 cout << StrId << " is calculated by "
2539 << MyCOMPUTEDSequence.Value (Result)->Identification ()
2542 cout << StrId << " is not calculated\n" << flush;
2546 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2547 cout << "In Visual3d_View::IsComputed, ";
2548 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2549 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2558 Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& AStructure) const {
2560 Standard_Boolean Result = Standard_False;
2562 if (IsDeleted ()) return Result;
2564 Result = MyDisplayedStructure.Contains (AStructure);
2571 Standard_Boolean Visual3d_View::ContainsComputedStructure () const {
2573 Standard_Boolean Result = Standard_False;
2575 if (MyDisplayedStructure.IsEmpty ()) return Result;
2577 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
2579 Standard_Integer i = MyDisplayedStructure.Extent ();
2581 // Stop at the first structure of type TOS_COMPUTED
2582 while (! Result && Iterator.More ()) {
2584 (((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED);
2586 // Iterator.Next () is located on the
2596 Standard_Boolean Visual3d_View::ContainsFacet () const {
2598 return ContainsFacet (MyDisplayedStructure);
2602 Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& ASet) const {
2604 Standard_Boolean Result = Standard_False;
2606 if (ASet.IsEmpty ()) return Result;
2608 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
2610 // Stop at the first structure containing a facet
2611 for ( Iterator.Initialize (ASet);
2612 Iterator.More () && ! Result;
2614 Result = (Iterator.Key ())->ContainsFacet ();
2620 void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
2623 (MyDisplayedStructure, XMin, YMin, ZMin, XMax, YMax, ZMax);
2627 void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
2629 if (ASet.IsEmpty ()) {
2630 XMin = RealFirst ();
2631 YMin = RealFirst ();
2632 ZMin = RealFirst ();
2640 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
2641 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
2647 XMax = RealFirst ();
2648 YMax = RealFirst ();
2649 ZMax = RealFirst ();
2651 for ( Iterator.Initialize (ASet);
2655 if ( (Iterator.Key ())->IsInfinite ()){
2656 //XMin, YMin .... ZMax are initialized by means of infinite line data
2657 (Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
2658 if ( Xm != RealFirst() && Xm < XMin )
2660 if ( Ym != RealFirst() && Ym < YMin )
2662 if ( Zm != RealFirst() && Zm < ZMin )
2664 if ( XM != RealLast() && XM > XMax )
2666 if ( YM != RealLast() && YM > YMax )
2668 if ( ZM != RealLast() && ZM > ZMax )
2671 // Only non-empty and non-infinite structures
2672 // are taken into account for calculation of MinMax
2673 if (! (Iterator.Key ())->IsInfinite () &&
2674 ! (Iterator.Key ())->IsEmpty ()) {
2675 (Iterator.Key ())->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM);
2676 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
2677 //"FitAll" operation ignores object with transform persitence parameter
2678 if( (Iterator.Key ())->TransformPersistenceMode() == Graphic3d_TMF_None )
2680 if (Xm < XMin) XMin = Xm;
2681 if (Ym < YMin) YMin = Ym;
2682 if (Zm < ZMin) ZMin = Zm;
2683 if (XM > XMax) XMax = XM;
2684 if (YM > YMax) YMax = YM;
2685 if (ZM > ZMax) ZMax = ZM;
2690 // The following cases are relevant
2691 // For exemple if all structures are empty or infinite
2692 if (XMax < XMin) { Xm = XMin; XMin = XMax; XMax = Xm; }
2693 if (YMax < YMin) { Ym = YMin; YMin = YMax; YMax = Ym; }
2694 if (ZMax < ZMin) { Zm = ZMin; ZMin = ZMax; ZMax = Zm; }
2696 Standard_Real Sx, Sy, Sz;
2697 MyViewOrientation.AxialScale(Sx, Sy, Sz);
2698 XMin = (Sx > 1. && XMin < RealFirst ()/Sx)?RealFirst (): XMin*Sx;
2699 XMax = (Sx > 1. && XMax > RealLast ()/Sx)?RealLast (): XMax*Sx;
2700 YMin = (Sy > 1. && YMin < RealFirst ()/Sy)?RealFirst (): YMin*Sy;
2701 YMax = (Sy > 1. && YMax > RealLast ()/Sy)?RealLast (): YMax*Sy;
2702 ZMin = (Sz > 1. && ZMin < RealFirst ()/Sz)?RealFirst (): ZMin*Sz;
2703 ZMax = (Sz > 1. && ZMax > RealLast ()/Sz)?RealLast (): ZMax*Sz;
2706 void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
2708 MinMaxValues (MyDisplayedStructure, XMin, YMin, XMax, YMax);
2712 void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
2714 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
2715 Standard_Real Xp, Yp, Zp;
2717 MinMaxValues (ASet, Xm, Ym, Zm, XM, YM, ZM);
2719 Projects (Xm, Ym, Zm, Xp, Yp, Zp);
2723 Projects (XM, YM, ZM, Xp, Yp, Zp);
2727 if (XMax < XMin) { Xp = XMax; XMax = XMin; XMin = Xp; }
2728 if (YMax < YMin) { Yp = YMax; YMax = YMin; YMin = Yp; }
2731 const TColStd_Array2OfReal& Visual3d_View::MatrixOfOrientation () {
2733 if (! MyMatOfOriIsEvaluated) {
2734 MyGraphicDriver->InquireMat
2735 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2736 MyMatOfMapIsEvaluated = Standard_True;
2737 MyMatOfOriIsEvaluated = Standard_True;
2740 return (MyMatrixOfOrientation);
2744 const TColStd_Array2OfReal& Visual3d_View::MatrixOfMapping () {
2746 if (! MyMatOfMapIsEvaluated) {
2747 MyGraphicDriver->InquireMat
2748 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2749 MyMatOfMapIsEvaluated = Standard_True;
2750 MyMatOfOriIsEvaluated = Standard_True;
2753 return (MyMatrixOfMapping);
2757 Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
2759 Standard_Integer Result = MyDisplayedStructure.Extent ();
2766 void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) const {
2768 math_Vector PtDC (0,3), PtWC (0,3);
2771 // Otherwise use new on Visual3d_View (constructor+destructor)
2772 // as Projects is a const method or MatrixOfOrientation and
2773 // MatrixOfMapping is not.
2774 Visual3d_View * const newthis = (Visual3d_View * const) this;
2775 newthis->MatrixOfOrientation ();
2776 newthis->MatrixOfMapping ();
2778 // World Coordinate Space
2784 // WCS -> View Reference Coordinate Space
2785 math_Vector PtVRC(0,3);
2786 PtVRC = MyMatrixOfOrientation.Multiplied (PtWC);
2788 // VRCS -> Normalized Projection Coordinate Space
2789 math_Vector PtNPC(0,3);
2790 PtNPC = MyMatrixOfMapping.Multiplied (PtVRC);
2791 for (Standard_Integer i=0; i<3; i++) PtNPC (i) = PtNPC (i) / PtNPC (3);
2794 printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
2795 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2798 Standard_Real Ratio;
2800 // NPCS -> Device Coordinate Space
2801 Standard_Real Dx = Standard_Real (MyCView.DefWindow.dx);
2802 Standard_Real Dy = Standard_Real (MyCView.DefWindow.dy);
2805 PtDC (0) = PtNPC (0) * Dx;
2806 PtDC (1) = Dy - PtNPC (1) * Dy * Ratio;
2808 printf("Display coordinates : %f,%f,%f,%f\n",
2809 PtDC(0),PtDC(1),PtDC(2),PtDC(3));
2812 // NPCS -> Window Space
2813 Standard_Real um, vm, uM, vM;
2814 MyViewMapping.WindowLimit (um, vm, uM, vM);
2816 Ratio = (uM - um) / (vM - vm);
2818 PtNPC (1) = PtNPC (1) * Ratio;
2820 PtNPC (0) = PtNPC (0) / Ratio;
2823 printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
2824 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2827 Standard_Real fpd = MyViewMapping.FrontPlaneDistance ();
2828 Standard_Real bpd = MyViewMapping.BackPlaneDistance ();
2831 * Coordinates of PtNPC are described in the space
2832 * [0-1]x[0-1]x[0-1].
2833 * It is necessary to transform x and y in the window space.
2834 * It is necessary to transform z in the space of back and front
2835 * plane, taking into account clipping planes.
2836 * Z clipping planes are defined between 0 and 1.
2839 APX = PtNPC (0) * (uM - um) + um;
2840 APY = PtNPC (1) * (vM - vm) + vm;
2841 APZ = PtNPC (2) * (fpd - bpd) + bpd;
2844 Standard_Integer l,c;
2845 printf("OrientationMatrix :");
2846 for( l=0 ; l<4 ; l++ ) {
2847 printf("\n %d->",l);
2848 for( c=0 ; c<4 ; c++ ) {
2849 printf(" %f ,",MyMatrixOfOrientation(c,l));
2853 printf("MappingMatrix :");
2854 for( l=0 ; l<4 ; l++ ) {
2855 printf("\n %d->",l);
2856 for( c=0 ; c<4 ; c++ ) {
2857 printf(" %f ,",MyMatrixOfMapping(c,l));
2861 printf("World coordinates : %f,%f,%f,%f\n",
2862 PtWC(0),PtWC(1),PtWC(2),PtWC(3));
2863 printf("View coordinates : %f,%f,%f,%f\n",
2864 PtVRC(0),PtVRC(1),PtVRC(2),PtVRC(3));
2865 printf("Display coordinates : %f,%f,%f,%f\n",
2866 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2867 printf("Window limit : %f,%f,%f,%f\n",um,vm,uM,vM);
2868 printf("Ratio : %f\n",Ratio);
2869 printf("Front-plane : %f back-plane : %f\n",fpd,bpd);
2870 printf("Projection : %f,%f,%f\n \n",APX,APY,APZ);
2874 #endif /* OLD_METHOD */
2876 // OCC18942: This method is likely to duplicate Visual3d_ViewManager::ConvertCoord() one,
2877 // therefore it is necessary to consider merging the two methods or making them call the same
2878 // graphic driver's method after OCCT 6.3.
2879 void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) {
2881 Standard_Real PtX, PtY, PtZ, PtT;
2883 static Standard_Real Ratio, um, vm, uM, vM;
2884 static Standard_Real fpd, bpd;
2886 if (! MyMatOfOriIsEvaluated || ! MyMatOfMapIsEvaluated) {
2887 MyGraphicDriver->InquireMat
2888 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2889 MyMatOfOriIsEvaluated = MyMatOfMapIsEvaluated = Standard_True;
2892 // WCS -> View Reference Coordinate Space
2893 PtX = MyMatrixOfOrientation (0, 0) * AX
2894 + MyMatrixOfOrientation (0, 1) * AY
2895 + MyMatrixOfOrientation (0, 2) * AZ
2896 + MyMatrixOfOrientation (0, 3);
2897 PtY = MyMatrixOfOrientation (1, 0) * AX
2898 + MyMatrixOfOrientation (1, 1) * AY
2899 + MyMatrixOfOrientation (1, 2) * AZ
2900 + MyMatrixOfOrientation (1, 3);
2901 PtZ = MyMatrixOfOrientation (2, 0) * AX
2902 + MyMatrixOfOrientation (2, 1) * AY
2903 + MyMatrixOfOrientation (2, 2) * AZ
2904 + MyMatrixOfOrientation (2, 3);
2905 PtT = MyMatrixOfOrientation (3, 0) * AX
2906 + MyMatrixOfOrientation (3, 1) * AY
2907 + MyMatrixOfOrientation (3, 2) * AZ
2908 + MyMatrixOfOrientation (3, 3);
2910 // VRCS -> Normalized Projection Coordinate Space
2911 APX = MyMatrixOfMapping (0, 0) * PtX
2912 + MyMatrixOfMapping (0, 1) * PtY
2913 + MyMatrixOfMapping (0, 2) * PtZ
2914 + MyMatrixOfMapping (0, 3) * PtT;
2915 APY = MyMatrixOfMapping (1, 0) * PtX
2916 + MyMatrixOfMapping (1, 1) * PtY
2917 + MyMatrixOfMapping (1, 2) * PtZ
2918 + MyMatrixOfMapping (1, 3) * PtT;
2919 APZ = MyMatrixOfMapping (2, 0) * PtX
2920 + MyMatrixOfMapping (2, 1) * PtY
2921 + MyMatrixOfMapping (2, 2) * PtZ
2922 + MyMatrixOfMapping (2, 3) * PtT;
2923 APT = MyMatrixOfMapping (3, 0) * PtX
2924 + MyMatrixOfMapping (3, 1) * PtY
2925 + MyMatrixOfMapping (3, 2) * PtZ
2926 + MyMatrixOfMapping (3, 3) * PtT;
2932 // NPCS -> Window Space
2933 MyViewMapping.WindowLimit (um, vm, uM, vM);
2934 fpd = MyViewMapping.FrontPlaneDistance ();
2935 bpd = MyViewMapping.BackPlaneDistance ();
2937 if(MyCView.Mapping.IsCustomMatrix) {
2938 // OCC18942: SAN - If orientation and mapping matrices are those used by OpenGL
2939 // visualization, then X, Y and Z coordinates normally vary between -1 and 1
2940 APX = ( APX + 1 ) * 0.5 * (uM - um) + um;
2941 APY = ( APY + 1 ) * 0.5 * (vM - vm) + vm;
2943 Ratio = (uM - um) / (vM - vm);
2950 * Coordinates of APX, APY, APZ are described in the space
2951 * [0-1]x[0-1]x[0-1].
2952 * It is necessary to transform x and y in the window space.
2953 * It is necessary to transform z in the space of back and front
2954 * plane, taking into account clipping planes.
2955 * Z clipping planes are defined between 0 and 1.
2957 APX = APX * (uM - um) + um;
2958 APY = APY * (vM - vm) + vm;
2960 APZ = APZ * (fpd - bpd) + bpd;
2963 Standard_Integer Visual3d_View::Identification () const {
2965 return (Standard_Integer (MyCView.ViewId));
2969 void Visual3d_View::Exploration () const {
2971 if (IsDeleted ()) return;
2973 MyGraphicDriver->DumpView (MyCView);
2977 Standard_Boolean Visual3d_View::ZBufferIsActivated () const {
2979 if (IsDeleted ()) return (Standard_False);
2981 if ((! IsDefined ()) || (! IsActive ())) return (Standard_False);
2983 // -1 => not forced by the programmer => depends on the type of visualisation
2984 // 0 ou 1 => forced by the programmer
2986 if (MyCView.Context.ZBufferActivity == -1)
2987 if (MyContext.Visualization () == Visual3d_TOV_SHADING)
2988 return (Standard_True);
2990 return (Standard_False);
2992 if (MyCView.Context.ZBufferActivity)
2993 return (Standard_True);
2995 return (Standard_False);
2999 void Visual3d_View::SetTransparency (const Standard_Boolean AnActivity) {
3001 if (IsDeleted ()) return;
3003 if ((! IsDefined ()) || (! IsActive ())) return;
3005 MyGraphicDriver->Transparency (MyCView, AnActivity);
3009 void Visual3d_View::SetZBufferActivity (const Standard_Integer AnActivity) {
3011 if (MyCView.Context.ZBufferActivity == AnActivity) return;
3013 if (IsDeleted ()) return;
3015 if ((! IsDefined ()) || (! IsActive ())) return;
3017 MyCView.Context.ZBufferActivity = AnActivity;
3018 MyGraphicDriver->SetVisualisation (MyCView);
3022 void Visual3d_View::UpdateView () {
3024 MyCView.Context.Aliasing = (MyContext.AliasingIsOn () ? 1:0);
3025 MyCView.Context.BackZClipping =
3026 (MyContext.BackZClippingIsOn () ? 1:0);
3027 MyCView.Context.FrontZClipping =
3028 (MyContext.FrontZClippingIsOn() ? 1:0);
3029 MyCView.Context.DepthCueing =
3030 (MyContext.DepthCueingIsOn () ? 1:0);
3032 MyCView.Context.ZClipFrontPlane =
3033 float (MyContext.ZClippingFrontPlane ());
3034 MyCView.Context.ZClipBackPlane =
3035 float (MyContext.ZClippingBackPlane ());
3036 MyCView.Context.DepthFrontPlane =
3037 float (MyContext.DepthCueingFrontPlane ());
3038 MyCView.Context.DepthBackPlane =
3039 float (MyContext.DepthCueingBackPlane ());
3041 MyCView.Context.Model = int (MyContext.Model ());
3042 MyCView.Context.Visualization = int (MyContext.Visualization ());
3044 Handle(Graphic3d_TextureEnv) TempTextureEnv = MyContext.TextureEnv();
3045 if (! TempTextureEnv.IsNull()) MyCView.Context.TexEnvId = TempTextureEnv->TextureId();
3046 else MyCView.Context.TexEnvId = -1;
3047 MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
3051 void Visual3d_View::Compute () {
3054 Standard_Integer Length = MyCOMPUTEDSequence.Length ();
3055 for (i=1; i<=Length; i++)
3056 (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False);
3058 // if the degenerated node is active, nothing is recomputed
3060 if ( DegenerateModeIsOn () || !ComputedMode () ) return;
3062 if (DegenerateModeIsOn ()) return;
3066 * Force HLRValidation to False on all structures
3067 * calculated in the view.
3070 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3071 cout << "In Visual3d_View::Compute, ";
3072 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3073 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3079 * Change of orientation or of projection type =>
3080 * Remove structures that were calculated for the
3081 * previous orientation.
3082 * Recalculation of new structures.
3083 * Passage of the degenerated mode ON to OFF =>
3084 * Remove structures that were calculated before
3085 * the degenerated mode passed to ON.
3086 * Recalculate new structures.
3088 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3089 Visual3d_TypeOfAnswer Answer;
3091 i = MyDisplayedStructure.Extent ();
3093 Graphic3d_SequenceOfStructure FooSequence;
3095 while (S1Iterator.More ()) {
3096 Answer = AcceptDisplay (S1Iterator.Key ());
3097 // If the structure was calculated, it is recalculated.
3098 if (Answer == Visual3d_TOA_COMPUTE) {
3100 cout << "AcceptDisplay ("
3101 << (S1Iterator.Key ())->Identification ()
3102 << ") == Visual3d_TOA_COMPUTE;\n";
3105 //Display (S1Iterator.Key (), Aspect_TOU_WAIT);
3106 FooSequence.Append (S1Iterator.Key ());
3109 // S1Iterator.Next () is located on the next structure
3113 Length = FooSequence.Length ();
3114 // All stored structures are displayed
3115 for (i=1; i<=Length; i++)
3116 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
3117 if (Length != 0) FooSequence.Clear ();
3121 void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
3123 if ( DegenerateModeIsOn () || !ComputedMode () ) return;
3125 if (DegenerateModeIsOn()) return;
3128 if (IsDeleted ()) return;
3130 if ((! IsDefined ()) || (! IsActive ())) return;
3132 if (! MyWindow->IsMapped ()) return;
3134 if (! AStructure->IsDisplayed ()) return;
3136 Visual3d_TypeOfAnswer Answer;
3138 Answer = AcceptDisplay (AStructure);
3140 if (Answer == Visual3d_TOA_COMPUTE) {
3141 Standard_Integer Index = IsComputed (AStructure);
3144 cout << "Structure " << AStructure->Identification ()
3145 << " is not calculated in the view "
3146 << Identification () << "\n";
3151 Standard_Integer OldStructId, NewStructId;
3153 MyCOMPUTEDSequence.Value (Index)->Identification ();
3155 Standard_Integer StructId = AStructure->Identification ();
3156 cout << "Structure " << StructId
3157 << " calculated, in the view "
3158 << Identification () << ", by the structure "
3159 << OldStructId << " is recalculated.\n";
3163 // Compute + Validation
3165 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
3167 Handle(Graphic3d_Structure) TheStructure;
3168 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
3169 AStructure->Transform (ATrsf);
3171 TColStd_Array2OfReal Ident (0, 3, 0, 3);
3172 Standard_Integer ii, jj;
3173 for (ii=0; ii<=3; ii++)
3174 for (jj=0; jj<=3; jj++)
3175 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
3176 TheStructure = MyCOMPUTEDSequence.Value (Index);
3177 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
3178 if (AStructure->IsTransformed ()) {
3179 AStructure->Compute (this, ATrsf, TheStructure);
3182 AStructure->Compute (this, TheStructure);
3186 if (AStructure->IsTransformed ()) {
3187 TheStructure = AStructure->Compute (this, ATrsf);
3190 TheStructure = AStructure->Compute (this);
3194 TheStructure->SetHLRValidation (Standard_True);
3196 // Return type of visualisation of the view
3197 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
3199 // Of which type will be the computed ?
3200 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
3201 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
3203 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
3204 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
3206 if (ComputeWireframe)
3207 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
3209 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
3211 if (AStructure->IsHighlighted ()) {
3212 TheStructure->SetHighlightColor
3213 (AStructure->HighlightColor ());
3214 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
3218 // Find structure <AStructure>
3219 // in the sequence of structures to be calculated.
3220 NewStructId = TheStructure->Identification ();
3222 // The previous calculation is removed and the new one is dislayed
3223 MyGraphicDriver->EraseStructure (
3225 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
3226 MyGraphicDriver->DisplayStructure (
3228 *(Graphic3d_CStructure *)TheStructure->CStructure (),
3229 int (AStructure->DisplayPriority ())
3233 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3234 cout << "In Visual3d_View::ReCompute, ";
3235 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3236 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3241 // hlhsr and the new associated compute are added
3242 MyTOCOMPUTESequence.Append (AStructure);
3243 MyCOMPUTEDSequence.Append (TheStructure);
3246 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3247 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3248 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3252 // hlhsr and the new associated compute are removed
3254 MyTOCOMPUTESequence.Remove (Index);
3255 MyCOMPUTEDSequence.Remove (Index);
3258 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3259 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3260 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3270 Visual3d_View::SetAnimationModeOn ( const Standard_Boolean degenerate ) {
3272 Visual3d_View::SetAnimationModeOn () {
3275 if (AnimationModeIsOn ()) return;
3277 AnimationModeIsActive = Standard_True;
3280 SetDegenerateModeOn ();
3282 SetDegenerateModeOff ();
3284 MyGraphicDriver->BeginAnimation (MyCView);
3288 void Visual3d_View::SetAnimationModeOff () {
3290 if (! AnimationModeIsOn ()) return;
3292 AnimationModeIsActive = Standard_False;
3294 SetDegenerateModeOff ();
3296 MyGraphicDriver->EndAnimation (MyCView);
3300 Standard_Boolean Visual3d_View::AnimationModeIsOn () const {
3302 return AnimationModeIsActive;
3306 void Visual3d_View::SetDegenerateModeOn () {
3309 cout << "Visual3d_View" << MyCView.ViewId
3310 << "::SetDegenerateModeOn ();\n";
3314 // If the degenerated mode is already active, nothing is recalculated
3315 if (DegenerateModeIsOn ()) return;
3316 DegenerateModeIsActive = Standard_True;
3319 MyCView.IsDegenerates = 1;
3322 * Change of activity of the degenerated mode
3323 * Remove structures that were calculated
3324 * and displayed when the mode was off.
3325 * Display of non-calculated structures.
3327 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3328 Visual3d_TypeOfAnswer Answer;
3329 Standard_Integer StructId;
3331 while (S1Iterator.More ()) {
3333 Answer = AcceptDisplay (S1Iterator.Key ());
3334 // If the structure was calculated, the previous one is
3335 // removed and the new one is displayed
3336 // (This is the role of passage into degenerated mode)
3338 if (Answer == Visual3d_TOA_COMPUTE) {
3339 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3342 MyCOMPUTEDSequence.Value (Index)->Identification ();
3344 cout << "Structure " << S1Iterator.Key ()->Identification ()
3345 << " calculated, in the view "
3346 << Identification () << ", by structure "
3347 << StructId << " passes in degenerated mode.\n";
3348 cout << "Remove" << StructId << " then display "
3349 << S1Iterator.Key ()->Identification () << "\n";
3352 MyGraphicDriver->EraseStructure
3353 (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
3354 MyGraphicDriver->DisplayStructure (
3356 *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure (),
3357 int (S1Iterator.Key ()->DisplayPriority ())
3361 // Else is impossible)
3362 // If the mode was not degenerated previously, the
3363 // calculated structure associated to S1Iterator.Key ()
3364 // really exists and Index != 0
3368 // S1Iterator.Next () is located on the next structure
3374 void Visual3d_View::SetDegenerateModeOff () {
3377 cout << "Visual3d_View" << MyCView.ViewId
3378 << "::SetDegenerateModeOff ();\n";
3382 // If the degenerated mode is already inactive, nothing is recalculated
3383 if (! DegenerateModeIsOn ()) return;
3385 DegenerateModeIsActive = Standard_False;
3388 MyCView.IsDegenerates = 0;
3391 * Change of activity of degenerated mode
3392 * Remove structures that were displayed
3393 * when the mode was on.
3394 * Calculation of structures.
3396 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3397 Visual3d_TypeOfAnswer Answer;
3398 Standard_Integer StructId;
3400 Standard_Integer i = MyDisplayedStructure.Extent ();
3402 while (S1Iterator.More ()) {
3404 Answer = AcceptDisplay (S1Iterator.Key ());
3405 // If the structure was calculated, the previous one is
3406 // removed and the new one is displayed
3407 // (This is the role of passage into degenerated mode)
3409 if (Answer == Visual3d_TOA_COMPUTE) {
3410 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3413 MyCOMPUTEDSequence.Value (Index)->Identification ();
3415 cout << "Structure " << S1Iterator.Key ()->Identification ()
3416 << " calculated, in the view "
3417 << Identification () << ", by the structure "
3418 << StructId << " passes into normal mode.\n";
3419 cout << "Remove " << S1Iterator.Key ()->Identification ()
3420 << " then display " << StructId << "\n";
3423 MyGraphicDriver->EraseStructure
3425 *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure ());
3426 MyGraphicDriver->DisplayStructure (
3428 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
3429 int (S1Iterator.Key ()->DisplayPriority ())
3432 Display (S1Iterator.Key (), Aspect_TOU_WAIT);
3434 if ((S1Iterator.Key ())->IsHighlighted()) {
3435 if (! (MyCOMPUTEDSequence.Value (Index))->IsHighlighted()) {
3436 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
3437 ((S1Iterator.Key ())->HighlightColor ());
3438 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (Aspect_TOHM_COLOR);
3443 // Else is impossible
3444 // Degenerated mode was activated before display of the
3445 // structure. So the structure was displayed in the
3446 // degenerated mode, but the calculated structure didn't exist.
3447 // It is calculated.
3449 // Compute + Validation
3450 Handle(Graphic3d_Structure) AStructure = (S1Iterator.Key ());
3452 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
3454 Handle(Graphic3d_Structure) TheStructure;
3455 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
3456 AStructure->Transform (ATrsf);
3458 TColStd_Array2OfReal Ident (0, 3, 0, 3);
3459 Standard_Integer ii, jj;
3460 for (ii=0; ii<=3; ii++)
3461 for (jj=0; jj<=3; jj++)
3462 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
3463 TheStructure = MyCOMPUTEDSequence.Value (Index);
3464 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
3465 if (AStructure->IsTransformed ()) {
3466 AStructure->Compute (this, ATrsf, TheStructure);
3469 AStructure->Compute (this, TheStructure);
3473 if (AStructure->IsTransformed ()) {
3474 TheStructure = AStructure->Compute (this, ATrsf);
3477 TheStructure = AStructure->Compute (this);
3481 TheStructure->SetHLRValidation (Standard_True);
3483 // Return type of visualisation of the view
3484 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
3486 // Of which type will be the computed ?
3487 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
3488 ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_SHADING));
3490 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
3491 ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
3493 if (ComputeWireframe)
3494 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
3496 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
3498 if ((S1Iterator.Key ())->IsHighlighted()) {
3499 TheStructure->SetHighlightColor
3500 ((S1Iterator.Key ())->HighlightColor ());
3501 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
3505 Standard_Integer Result = 0;
3506 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
3507 // Find structure <S1Iterator.Key ()>
3508 // in the sequence of structures to be calculated
3509 StructId = (S1Iterator.Key ())->Identification ();
3510 for (i=1; i<=Length && Result==0; i++)
3511 if ((MyTOCOMPUTESequence.Value (i))->Identification () ==
3512 StructId) Result = i;
3514 MyCOMPUTEDSequence.ChangeValue (Result) = TheStructure;
3516 // hlhsr and the associated new compute are added
3518 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3519 cout << "In Visual3d_View::SetDegenerateModeOff, ";
3520 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3521 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3525 MyTOCOMPUTESequence.Append (S1Iterator.Key ());
3526 MyCOMPUTEDSequence.Append (TheStructure);
3528 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3529 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3530 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3535 // The degenerated is removed and the calculated is displayed
3536 MyGraphicDriver->EraseStructure
3538 *(Graphic3d_CStructure *)(S1Iterator.Key ()->CStructure ()));
3539 MyGraphicDriver->DisplayStructure (
3541 *(Graphic3d_CStructure *)TheStructure->CStructure (),
3542 int (S1Iterator.Key ()->DisplayPriority ())
3547 // S1Iterator.Next () is located on the next structure
3551 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
3555 Standard_Boolean Visual3d_View::DegenerateModeIsOn () const {
3557 return DegenerateModeIsActive;
3561 Handle(Aspect_GraphicDriver) Visual3d_View::GraphicDriver () const {
3563 return MyGraphicDriver;
3567 void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& APlotter) const {
3569 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3571 while (S1Iterator.More ()) {
3573 if (DegenerateModeIsOn ())
3574 // As the mode is degenerated the displayed structure
3575 // is plotted without taking into account if it is calculated or not
3576 (S1Iterator.Key ())->Plot (APlotter);
3578 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3579 // As the mode is not degenerated the displayed structure
3580 // is plotted as if it was not calculated, otherwise the
3581 // associated calculated structure is plotted.
3583 (S1Iterator.Key ())->Plot (APlotter);
3585 (MyCOMPUTEDSequence.Value (Index))->Plot (APlotter);
3588 // S1Iterator.Next () is located on the next structure
3594 Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const {
3596 Standard_Integer Result = 0;
3597 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
3599 // Find in the sequence of already calculated structures
3600 // 1/ Structure with the same Owner as <AStructure>
3601 // 2/ Which is not <AStructure>
3602 // 3/ COMPUTED which of is valid
3603 for (Standard_Integer i=1; i<=Length && Result==0; i++)
3604 if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ())
3605 && (MyTOCOMPUTESequence.Value (i)->Identification () !=
3606 AStructure->Identification ())
3607 && (MyCOMPUTEDSequence.Value (i)->HLRValidation ())) Result = i;
3613 Standard_Address Visual3d_View::CView () const {
3615 return Standard_Address (&MyCView);
3620 // Triedron methods : the Triedron is a non-zoomable object.
3622 void Visual3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
3623 const Quantity_NameOfColor YColor,
3624 const Quantity_NameOfColor ZColor,
3625 const Standard_Real SizeRatio,
3626 const Standard_Real AxisDiametr,
3627 const Standard_Integer NbFacettes) {
3628 MyGraphicDriver->ZBufferTriedronSetup(XColor, YColor, ZColor,
3629 SizeRatio, AxisDiametr, NbFacettes);
3634 void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition,
3635 const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe ) {
3637 MyGraphicDriver->TriedronDisplay (MyCView,APosition, AColor, AScale, AsWireframe);
3641 void Visual3d_View::TriedronErase () {
3643 MyGraphicDriver->TriedronErase (MyCView);
3648 void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
3650 MyGraphicDriver->TriedronEcho (MyCView,AType);
3654 Standard_Boolean checkFloat(const Standard_Real value)
3656 return value > -FLT_MAX && value < FLT_MAX;
3659 void SetMinMaxValuesCallback(void* Visual3dView)
3661 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
3663 Handle(Visual3d_View) view = (Handle(Visual3d_View)&) Visual3dView;
3664 view->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
3666 if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
3667 checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
3669 Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(view->GraphicDriver());
3670 driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
3671 (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
3675 void Visual3d_View::GetGraduatedTrihedron(/* Names of axes */
3676 Standard_CString& xname,
3677 Standard_CString& yname,
3678 Standard_CString& zname,
3680 Standard_Boolean& xdrawname,
3681 Standard_Boolean& ydrawname,
3682 Standard_Boolean& zdrawname,
3684 Standard_Boolean& xdrawvalues,
3685 Standard_Boolean& ydrawvalues,
3686 Standard_Boolean& zdrawvalues,
3688 Standard_Boolean& drawgrid,
3690 Standard_Boolean& drawaxes,
3691 /* Number of splits along axes */
3692 Standard_Integer& nbx,
3693 Standard_Integer& nby,
3694 Standard_Integer& nbz,
3695 /* Offset for drawing values */
3696 Standard_Integer& xoffset,
3697 Standard_Integer& yoffset,
3698 Standard_Integer& zoffset,
3699 /* Offset for drawing names of axes */
3700 Standard_Integer& xaxisoffset,
3701 Standard_Integer& yaxisoffset,
3702 Standard_Integer& zaxisoffset,
3703 /* Draw tickmarks */
3704 Standard_Boolean& xdrawtickmarks,
3705 Standard_Boolean& ydrawtickmarks,
3706 Standard_Boolean& zdrawtickmarks,
3707 /* Length of tickmarks */
3708 Standard_Integer& xtickmarklength,
3709 Standard_Integer& ytickmarklength,
3710 Standard_Integer& ztickmarklength,
3712 Quantity_Color& gridcolor,
3714 Quantity_Color& xnamecolor,
3716 Quantity_Color& ynamecolor,
3718 Quantity_Color& znamecolor,
3719 /* X color of axis and values */
3720 Quantity_Color& xcolor,
3721 /* Y color of axis and values */
3722 Quantity_Color& ycolor,
3723 /* Z color of axis and values */
3724 Quantity_Color& zcolor,
3725 /* Name of font for names of axes */
3726 Standard_CString& fontOfNames,
3727 /* Style of names of axes */
3728 OSD_FontAspect& styleOfNames,
3729 /* Size of names of axes */
3730 Standard_Integer& sizeOfNames,
3731 /* Name of font for values */
3732 Standard_CString& fontOfValues,
3733 /* Style of values */
3734 OSD_FontAspect& styleOfValues,
3735 /* Size of values */
3736 Standard_Integer& sizeOfValues) const
3738 MyGraphicDriver->GetGraduatedTrihedron(MyCView,
3755 /* Number of splits along axes */
3759 /* Offset for drawing values */
3763 /* Offset for drawing names of axes */
3767 /* Draw tickmarks */
3771 /* Length of tickmarks */
3783 /* X color of axis and values */
3785 /* Y color of axis and values */
3787 /* Z color of axis and values */
3789 /* Name of font for names of axes */
3791 /* Style of names of axes */
3793 /* Size of names of axes */
3795 /* Name of font for values */
3797 /* Style of values */
3799 /* Size of values */
3803 void Visual3d_View::GraduatedTrihedronDisplay(/* Names of axes */
3804 const Standard_CString xname,
3805 const Standard_CString yname,
3806 const Standard_CString zname,
3808 const Standard_Boolean xdrawname,
3809 const Standard_Boolean ydrawname,
3810 const Standard_Boolean zdrawname,
3812 const Standard_Boolean xdrawvalues,
3813 const Standard_Boolean ydrawvalues,
3814 const Standard_Boolean zdrawvalues,
3816 const Standard_Boolean drawgrid,
3818 const Standard_Boolean drawaxes,
3819 /* Number of splits along axes */
3820 const Standard_Integer nbx,
3821 const Standard_Integer nby,
3822 const Standard_Integer nbz,
3823 /* Offset for drawing values */
3824 const Standard_Integer xoffset,
3825 const Standard_Integer yoffset,
3826 const Standard_Integer zoffset,
3827 /* Offset for drawing names of axes */
3828 const Standard_Integer xaxisoffset,
3829 const Standard_Integer yaxisoffset,
3830 const Standard_Integer zaxisoffset,
3831 /* Draw tickmarks */
3832 const Standard_Boolean xdrawtickmarks,
3833 const Standard_Boolean ydrawtickmarks,
3834 const Standard_Boolean zdrawtickmarks,
3835 /* Length of tickmarks */
3836 const Standard_Integer xtickmarklength,
3837 const Standard_Integer ytickmarklength,
3838 const Standard_Integer ztickmarklength,
3840 const Quantity_Color& gridcolor,
3842 const Quantity_Color& xnamecolor,
3844 const Quantity_Color& ynamecolor,
3846 const Quantity_Color& znamecolor,
3847 /* X color of axis and values */
3848 const Quantity_Color& xcolor,
3849 /* Y color of axis and values */
3850 const Quantity_Color& ycolor,
3851 /* Z color of axis and values */
3852 const Quantity_Color& zcolor,
3853 /* Name of font for names of axes */
3854 const Standard_CString fontOfNames,
3855 /* Style of names of axes */
3856 const OSD_FontAspect styleOfNames,
3857 /* Size of names of axes */
3858 const Standard_Integer sizeOfNames,
3859 /* Name of font for values */
3860 const Standard_CString fontOfValues,
3861 /* Style of values */
3862 const OSD_FontAspect styleOfValues,
3863 /* Size of values */
3864 const Standard_Integer sizeOfValues)
3866 CALL_DEF_GRADUATEDTRIHEDRON cubic;
3867 cubic.ptrVisual3dView = this;
3868 cubic.cbCubicAxes = SetMinMaxValuesCallback;
3869 MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,
3887 /* Number of splits along axes */
3891 /* Offset for drawing values */
3895 /* Offset for drawing names of axes */
3899 /* Draw tickmarks */
3903 /* Length of tickmarks */
3915 /* X color of axis and values */
3917 /* Y color of axis and values */
3919 /* Z color of axis and values */
3921 /* Name of font for names of axes */
3923 /* Style of names of axes */
3925 /* Size of names of axes */
3927 /* Name of font for values */
3929 /* Style of values */
3931 /* Size of values */
3935 void Visual3d_View::GraduatedTrihedronErase()
3937 MyGraphicDriver->GraduatedTrihedronErase(MyCView);
3940 const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer () const {
3942 return (MyViewManager->UnderLayer ());
3946 const Handle(Visual3d_Layer)& Visual3d_View::OverLayer () const {
3948 return (MyViewManager->OverLayer ());
3952 Standard_Integer Visual3d_View::LightLimit() const {
3954 Standard_Integer maxlight = MyGraphicDriver->InquireLightLimit ();
3955 // printf(" $$$ Visual3d_View::LightLimit() is %d\n",maxlight);
3959 Standard_Integer Visual3d_View::PlaneLimit() const {
3961 Standard_Integer maxplane = MyGraphicDriver->InquirePlaneLimit ();
3962 // printf(" $$$ Visual3d_View::PlaneLimit() is %d\n",maxplane);
3967 Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const {
3969 return MyPtrViewManager;
3974 void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode ) {
3976 if ( ( (aMode && ComputedModeIsActive) ||
3977 (!aMode && !ComputedModeIsActive)
3978 ) || DegenerateModeIsOn ()
3981 Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure );
3982 Visual3d_TypeOfAnswer Answer;
3983 Standard_Integer StructId;
3984 Standard_Integer i = MyDisplayedStructure.Extent ();
3986 if ( !( ComputedModeIsActive = aMode ) ) {
3988 while ( S1Iterator.More () ) {
3990 Answer = AcceptDisplay ( S1Iterator.Key () );
3992 if ( Answer == Visual3d_TOA_COMPUTE ) {
3994 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
3998 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
4000 MyGraphicDriver -> EraseStructure (
4002 *( Graphic3d_CStructure* )
4003 MyCOMPUTEDSequence.Value ( Index ) -> CStructure ()
4005 MyGraphicDriver -> DisplayStructure (
4007 *( Graphic3d_CStructure* )
4008 S1Iterator.Key () -> CStructure (),
4009 int ( S1Iterator.Key () -> DisplayPriority () )
4011 } // end if ( Index != 0 ) . . .
4013 } // end if ( Answer . . . )
4021 while ( S1Iterator.More () ) {
4023 Answer = AcceptDisplay ( S1Iterator.Key () );
4025 if ( Answer == Visual3d_TOA_COMPUTE ) {
4027 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
4031 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
4033 MyGraphicDriver -> EraseStructure (
4035 *( Graphic3d_CStructure* )
4036 S1Iterator.Key () -> CStructure ()
4038 MyGraphicDriver -> DisplayStructure (
4040 *( Graphic3d_CStructure* )
4041 MyCOMPUTEDSequence.Value ( Index ) -> CStructure (),
4042 int ( S1Iterator.Key () -> DisplayPriority () )
4045 Display ( S1Iterator.Key (), Aspect_TOU_WAIT );
4047 if ( S1Iterator.Key () -> IsHighlighted () ) {
4049 if ( !MyCOMPUTEDSequence.Value ( Index ) -> IsHighlighted () ) {
4051 MyCOMPUTEDSequence.Value ( Index ) -> SetHighlightColor (
4052 S1Iterator.Key () ->
4055 MyCOMPUTEDSequence.Value ( Index ) -> GraphicHighlight (
4064 Handle( Graphic3d_Structure ) AStructure = S1Iterator.Key ();
4066 Handle( Graphic3d_Structure ) TheStructure = AStructure -> Compute ( this );
4068 Handle( Graphic3d_Structure ) TheStructure;
4069 TColStd_Array2OfReal ATrsf ( 0, 3, 0, 3 );
4071 AStructure -> Transform ( ATrsf );
4075 TColStd_Array2OfReal Ident ( 0, 3, 0, 3 );
4076 Standard_Integer ii, jj;
4078 for ( ii = 0; ii <= 3; ++ii )
4080 for ( jj = 0; jj <= 3; ++jj )
4082 Ident ( ii, jj ) = ( ii == jj ? 1.0 : 0.0 );
4084 TheStructure = MyCOMPUTEDSequence.Value ( Index );
4086 TheStructure -> SetTransform ( Ident, Graphic3d_TOC_REPLACE );
4088 if ( AStructure->IsTransformed () )
4090 AStructure -> Compute ( this, ATrsf, TheStructure );
4094 AStructure -> Compute ( this, TheStructure );
4098 if ( AStructure -> IsTransformed () )
4100 TheStructure = AStructure -> Compute ( this, ATrsf );
4104 TheStructure = AStructure -> Compute ( this );
4108 TheStructure -> SetHLRValidation ( Standard_True );
4110 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
4112 Standard_Boolean ComputeWireframe =
4113 ( ( ViewType == Visual3d_TOV_WIREFRAME ) &&
4114 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_SHADING )
4117 Standard_Boolean ComputeShading =
4118 ( ( ViewType == Visual3d_TOV_SHADING ) &&
4119 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_WIREFRAME )
4122 if ( ComputeWireframe ) TheStructure -> SetVisual ( Graphic3d_TOS_WIREFRAME );
4123 if ( ComputeShading ) TheStructure -> SetVisual ( Graphic3d_TOS_SHADING );
4125 if ( S1Iterator.Key () -> IsHighlighted () ) {
4127 TheStructure -> SetHighlightColor (
4128 S1Iterator.Key () -> HighlightColor ()
4130 TheStructure -> GraphicHighlight ( Aspect_TOHM_COLOR );
4134 Standard_Integer Result = 0;
4135 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
4136 StructId = S1Iterator.Key () -> Identification ();
4138 for ( i = 1; i <= Length && Result == 0; ++i )
4140 if ( MyTOCOMPUTESequence.Value ( i ) -> Identification () == StructId )
4146 MyCOMPUTEDSequence.ChangeValue ( Result ) = TheStructure;
4150 MyTOCOMPUTESequence.Append ( S1Iterator.Key () );
4151 MyCOMPUTEDSequence.Append ( TheStructure );
4155 MyGraphicDriver -> EraseStructure (
4157 *( Graphic3d_CStructure* )
4158 S1Iterator.Key () -> CStructure ()
4160 MyGraphicDriver -> DisplayStructure (
4162 *( Graphic3d_CStructure* )TheStructure -> CStructure (),
4163 int ( S1Iterator.Key () -> DisplayPriority () )
4173 if ( MyViewManager -> UpdateMode () == Aspect_TOU_ASAP ) Update ();
4177 } // end Visual3d_View :: SetComputedMode
4179 Standard_Boolean Visual3d_View :: ComputedMode () const {
4181 return ComputedModeIsActive;
4183 } // end Visual3d_View :: ComputedMode
4185 void Visual3d_View :: SetBackFacingModel (
4186 const Visual3d_TypeOfBackfacingModel aModel
4191 case Visual3d_TOBM_AUTOMATIC:
4192 MyCView.Backfacing = 0;
4195 case Visual3d_TOBM_FORCE:
4196 MyCView.Backfacing = 1;
4199 case Visual3d_TOBM_DISABLE:
4200 MyCView.Backfacing = -1;
4205 MyGraphicDriver -> SetBackFacingModel ( MyCView );
4207 } // end Visual3d_View :: SetBackFacingModel
4209 Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const {
4211 switch ( MyCView.Backfacing ) {
4214 return Visual3d_TOBM_AUTOMATIC;
4217 return Visual3d_TOBM_FORCE;
4221 return Visual3d_TOBM_DISABLE;
4223 } // end Visual3d_View :: BackFacingModel
4226 void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const
4229 MyGraphicDriver->SetDepthTestEnabled( MyCView, enable );
4233 Standard_Boolean Visual3d_View::IsDepthTestEnabled() const
4236 return MyGraphicDriver->IsDepthTestEnabled( MyCView );
4238 return Standard_True;
4242 void Visual3d_View::ReadDepths(const Standard_Integer x,
4243 const Standard_Integer y,
4244 const Standard_Integer width,
4245 const Standard_Integer height,
4246 const Standard_Address buffer) const
4248 MyGraphicDriver->ReadDepths( MyCView, x, y, width, height, buffer );
4251 Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth,
4252 const Standard_Integer theHeight)
4254 return MyGraphicDriver->FBOCreate( MyCView, theWidth, theHeight );
4257 void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr)
4259 MyGraphicDriver->FBORelease( MyCView, theFBOPtr );
4262 void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr,
4263 Standard_Integer& theWidth, Standard_Integer& theHeight,
4264 Standard_Integer& theWidthMax, Standard_Integer& theHeightMax)
4266 MyGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr,
4267 theWidth, theHeight,
4268 theWidthMax, theHeightMax );
4271 void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr,
4272 const Standard_Integer theWidth, const Standard_Integer theHeight)
4274 MyGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr,
4275 theWidth, theHeight );
4278 Standard_Boolean Visual3d_View::BufferDump (Image_CRawBufferData& theBuffer)
4280 return MyGraphicDriver->BufferDump( MyCView, theBuffer);
4283 void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
4286 MyGraphicDriver->SetGLLightEnabled( MyCView, enable );
4291 Standard_Boolean Visual3d_View::IsGLLightEnabled() const
4294 return MyGraphicDriver->IsGLLightEnabled( MyCView );
4296 return Standard_True;
4300 void Visual3d_View::Export( const Standard_CString FileName,
4301 const Graphic3d_ExportFormat Format,
4302 const Graphic3d_SortType aSortType,
4303 const Standard_Real Precision,
4304 const Standard_Address ProgressBarFunc,
4305 const Standard_Address ProgressObject ) const
4307 Handle( Visual3d_Layer ) AnUnderLayer = MyViewManager->UnderLayer(),
4308 AnOverLayer = MyViewManager->OverLayer();
4310 Aspect_CLayer2d OverCLayer;
4311 Aspect_CLayer2d UnderCLayer;
4312 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
4314 if( !AnOverLayer.IsNull() )
4315 OverCLayer = AnOverLayer->CLayer();
4316 if( !AnUnderLayer.IsNull() )
4317 UnderCLayer = AnUnderLayer->CLayer();
4319 Standard_Integer W, H;
4320 Window()->Size( W, H );
4322 MyGraphicDriver->Export( FileName, Format, aSortType, W, H, MyCView, UnderCLayer, OverCLayer,
4323 Precision, ProgressBarFunc, ProgressObject );