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());
483 wd = ( WNT_WindowData* )GetWindowLong (( HWND )(theWindow->HWindow()), GWL_USERDATA);
485 wd = ( WNT_WindowData* )GetWindowLong (( HWND )(theWindow->HWindow()), GWLP_USERDATA);
487 wd -> WNT_WDriver_Ptr = ( void* )this;
488 wd -> WNT_VMgr = ( void* )MyPtrViewManager;
491 Standard_Integer Width, Height;
492 AWindow->Size (Width, Height);
494 MyCView.DefWindow.dx = float( Width );
495 MyCView.DefWindow.dy = float( Height );
497 Standard_Real R, G, B;
498 MyBackground = MyWindow->Background ();
499 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
500 MyCView.DefWindow.Background.r = float (R);
501 MyCView.DefWindow.Background.g = float (G);
502 MyCView.DefWindow.Background.b = float (B);
505 if (! MyGraphicDriver->View (MyCView))
506 Visual3d_ViewDefinitionError::Raise ("Association failed");
508 MyGradientBackground = MyWindow->GradientBackground();
509 SetGradientBackground(MyGradientBackground,1);
511 Standard_Boolean AWait = Standard_False; // => immediate update
512 MyGraphicDriver->SetVisualisation (MyCView);
513 MyGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn ());
514 MyGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn ());
515 MyGraphicDriver->ClipLimit (MyCView, AWait);
516 MyGraphicDriver->Environment(MyCView);
518 // Update planses of model clipping
521 // Update light sources
525 * Association view-window does not cause the display
526 * of structures that can be displayed in the new view.
527 * In fact, association view-window is done, but the
528 * display is produced only if the view is activated (Activate).
535 Handle(Aspect_Window) Visual3d_View::Window () const {
538 Visual3d_ViewDefinitionError::Raise ("Window not defined");
544 Standard_Boolean Visual3d_View::IsDefined () const {
546 if (MyCView.DefWindow.IsDefined)
547 return (Standard_True);
549 return (Standard_False);
553 Standard_Boolean Visual3d_View::IsDeleted () const {
555 if (MyCView.IsDeleted)
556 return (Standard_True);
558 return (Standard_False);
562 void Visual3d_View::Destroy () {
565 cout << "Visual3d_View::Destroy (" << Identification () << ")\n";
568 // Since MyPtrViewManager can be already distroyed,
569 // avoid attempts to access it in SetBackground()
570 MyPtrViewManager = 0;
575 void Visual3d_View::Remove () {
578 cout << "Visual3d_View::Remove (" << Identification () << ")" << endl;
581 if (IsDeleted ()) return;
582 if (! IsDefined ()) return;
584 MyTOCOMPUTESequence.Clear ();
585 MyCOMPUTEDSequence.Clear ();
586 MyDisplayedStructure.Clear ();
588 Quantity_Color BlackColor (0.0, 0.0, 0.0, Quantity_TOC_RGB);
589 Aspect_Background BlackBackground (BlackColor);
590 SetBackground (BlackBackground);
592 Aspect_GradientBackground BlackGradBackground;
593 SetGradientBackground (BlackGradBackground,0);
595 if (MyPtrViewManager)
596 MyPtrViewManager->UnIdentification( MyCView.ViewId );
598 MyGraphicDriver->RemoveView (MyCView);
601 MyCView.IsDeleted = 1;
602 MyCView.DefWindow.IsDefined = 0;
604 MyMatOfMapIsModified = Standard_True;
605 MyMatOfOriIsModified = Standard_True;
606 MyMatOfMapIsEvaluated = Standard_False;
607 MyMatOfOriIsEvaluated = Standard_False;
613 void Visual3d_View::Resized () {
615 if (IsDeleted ()) return;
618 Visual3d_ViewDefinitionError::Raise ("Window not defined");
619 MyWindow->DoResize() ;
624 void Visual3d_View::SetRatio () {
626 if (IsDeleted ()) return;
628 Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode ();
629 MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
631 Standard_Real Umin, Vmin, Umax, Vmax;
632 Standard_Integer Dxw, Dyw;
633 Standard_Real Dxv, Dyv;
634 Standard_Real Xc, Yc;
638 MyWindow->Size (Dxw, Dyw);
639 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
640 Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
641 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
642 if( Dxw > 0 && Dyw > 0 ) Rap = (Standard_Real)Dyw/(Standard_Real)Dxw ;
672 Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
673 Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
675 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
677 // Update before SetViewMapping.
679 MyCView.DefWindow.dx = float( Dxw );
680 MyCView.DefWindow.dy = float( Dyw );
682 SetViewMapping (MyViewMapping);
683 // SetViewMappingDefault ();
684 // FMN+ Update Ratio for MyViewMappingReset
686 MyViewMappingReset.WindowLimit(Umin,Vmin,Umax,Vmax) ;
687 Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
688 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
717 Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
718 Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
720 MyViewMappingReset.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
722 // FMN- Update Ratio for MyViewMappingReset
724 MyGraphicDriver->RatioWindow (MyCView);
727 // Force recalculation of 2 matrices.
729 // The current view can help to reconstruct a copied view
730 // that is itself. Owing to SetWindow and SetRatio the
731 // recalculation of matrices of this new view is imposed.
732 MyMatOfMapIsEvaluated = Standard_False;
733 MyMatOfOriIsEvaluated = Standard_False;
735 MyViewManager->SetUpdateMode (UpdateMode);
736 if (UpdateMode == Aspect_TOU_ASAP) Update ();
740 void Visual3d_View::UpdateLights () {
742 Standard_Integer i, j;
743 CALL_DEF_LIGHT *lights=NULL;
746 if( MyContext.Model() == Visual3d_TOM_NONE ) {
747 // Activates only a white ambient light
748 MyCView.Context.NbActiveLight = 1;
749 lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
750 MyCView.Context.ActiveLight = lights;
752 lights[0].WsId = MyCView.ViewId;
753 lights[0].ViewId = MyCView.ViewId;
754 lights[0].LightType = int (Visual3d_TOLS_AMBIENT);
755 lights[0].Active = 1;
756 lights[0].LightId = 0;
757 lights[0].Headlight = 0;
758 lights[0].Color.r = lights[0].Color.g = lights[0].Color.b = 1.;
761 i = MyContext.NumberOfActivatedLights ();
762 j = MyGraphicDriver->InquireLightLimit ();
763 MyCView.Context.NbActiveLight = (i > j ? j : i);
765 if (MyCView.Context.NbActiveLight > 0) {
767 // Dynamic Allocation
768 lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
770 MyCView.Context.ActiveLight = lights;
772 Standard_Real X, Y, Z;
774 Standard_Real LightConcentration;
775 Standard_Real LightAttenuation1;
776 Standard_Real LightAttenuation2;
777 Standard_Real LightAngle;
778 Quantity_Color LightColor;
779 Graphic3d_Vertex LightPosition;
780 Graphic3d_Vector LightDirection;
781 Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT;
783 // Parcing of light sources
784 for (j=0; j<MyCView.Context.NbActiveLight; j++) {
785 LightType = (MyContext.ActivatedLight (j+1))->LightType ();
787 lights[j].WsId = MyCView.ViewId;
788 lights[j].ViewId = MyCView.ViewId;
790 lights[j].LightType = int (LightType);
791 lights[j].Active = 1;
793 int ((MyContext.ActivatedLight (j+1))->Identification ());
794 lights[j].Headlight = (MyContext.ActivatedLight (j+1))->Headlight ()? 1:0;
798 case Visual3d_TOLS_AMBIENT :
799 (MyContext.ActivatedLight (j+1))->Values (
804 case Visual3d_TOLS_POSITIONAL :
805 (MyContext.ActivatedLight (j+1))->Values (
813 case Visual3d_TOLS_DIRECTIONAL :
814 (MyContext.ActivatedLight (j+1))->Values (
820 case Visual3d_TOLS_SPOT :
821 (MyContext.ActivatedLight (j+1))->Values (
834 lights[j].Color.r = float (LightColor.Red ());
835 lights[j].Color.g = float (LightColor.Green ());
836 lights[j].Color.b = float (LightColor.Blue ());
838 if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
839 (LightType == Visual3d_TOLS_SPOT) ) {
840 LightPosition.Coord (X, Y, Z);
841 lights[j].Position.x = float (X);
842 lights[j].Position.y = float (Y);
843 lights[j].Position.z = float (Z);
846 if ( (LightType == Visual3d_TOLS_DIRECTIONAL) ||
847 (LightType == Visual3d_TOLS_SPOT) ) {
848 LightDirection.Coord (X, Y, Z);
849 lights[j].Direction.x = float (X);
850 lights[j].Direction.y = float (Y);
851 lights[j].Direction.z = float (Z);
854 if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
855 (LightType == Visual3d_TOLS_SPOT) ) {
856 lights[j].Attenuation[0] =
857 float (LightAttenuation1);
858 lights[j].Attenuation[1] =
859 float (LightAttenuation2);
862 if (LightType == Visual3d_TOLS_SPOT) {
863 lights[j].Concentration =
864 float (LightConcentration);
874 // management of light sources
877 MyGraphicDriver->SetLight (MyCView);
879 // Dynamic allocation
880 if (MyCView.Context.NbActiveLight > 0) delete [] lights;
884 void Visual3d_View::UpdatePlanes () {
886 Standard_Integer i, j;
887 CALL_DEF_PLANE *planes=NULL;
889 i = MyContext.NumberOfActivatedClipPlanes ();
890 j = MyGraphicDriver->InquirePlaneLimit ();
891 MyCView.Context.NbActivePlane = (i > j ? j : i);
893 if (MyCView.Context.NbActivePlane > 0) {
895 // Dynamic Allocation
896 #ifdef GER61454 //Keep the plane address for the next Update !
897 if( !MyCView.Context.ActivePlane )
898 MyCView.Context.ActivePlane = new CALL_DEF_PLANE [j];
899 planes = MyCView.Context.ActivePlane;
901 planes = new CALL_DEF_PLANE [MyCView.Context.NbActivePlane];
903 MyCView.Context.ActivePlane = planes;
905 Standard_Real A, B, C, D;
907 // Parcing of clipping planes
908 for (j=0; j<MyCView.Context.NbActivePlane; j++) {
910 planes[j].WsId = MyCView.ViewId;
911 planes[j].ViewId = MyCView.ViewId;
913 planes[j].Active = 1;
915 int ((MyContext.ActivatedClipPlane (j+1))->Identification ());
917 (MyContext.ActivatedClipPlane (j+1))->Plane (A, B, C, D);
918 planes[j].CoefA = float (A);
919 planes[j].CoefB = float (B);
920 planes[j].CoefC = float (C);
921 planes[j].CoefD = float (D);
926 // Management of planes of clipping model
929 MyGraphicDriver->SetPlane (MyCView);
931 // Dynamic allocation
933 if ( MyCView.Context.ActivePlane && (MyCView.Context.NbActivePlane == 0)
935 delete [] MyCView.Context.ActivePlane;
936 MyCView.Context.ActivePlane = NULL;
939 if (MyCView.Context.NbActivePlane > 0) delete [] planes;
944 void Visual3d_View::SetBackground (const Aspect_Background& ABack) {
946 if (IsDeleted ()) return;
949 Visual3d_ViewDefinitionError::Raise ("Window not defined");
951 // At this level, only GL can update the background.
952 // It is not necessary to call MyWindow->SetBackground (ABack); as
953 // this method starts update of window background by X
954 // (if the windowing is X)
956 Standard_Real R, G, B;
957 MyBackground = ABack;
958 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
959 MyCView.DefWindow.Background.r = float (R);
960 MyCView.DefWindow.Background.g = float (G);
961 MyCView.DefWindow.Background.b = float (B);
963 MyGraphicDriver->Background (MyCView);
965 if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
970 void Visual3d_View::SetGradientBackground(const Aspect_GradientBackground& ABack, const Standard_Boolean update)
973 if (IsDeleted ()) return;
976 Visual3d_ViewDefinitionError::Raise ("Window not defined");
978 MyGradientBackground = ABack;
979 Quantity_Color aCol1,aCol2;
980 MyGradientBackground.Colors(aCol1,aCol2);
981 MyGraphicDriver->GradientBackground(MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod());
985 else if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
989 void Visual3d_View::SetBackgroundImage( const Standard_CString FileName,
990 const Aspect_FillMethod FillStyle,
991 const Standard_Boolean update )
997 Visual3d_ViewDefinitionError::Raise ("Window not defined");
999 MyGraphicDriver->BackgroundImage( FileName, MyCView, FillStyle );
1003 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1008 void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
1009 const Standard_Boolean update )
1015 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1017 MyGraphicDriver->SetBgImageStyle( MyCView, FillStyle );
1021 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1026 Aspect_Background Visual3d_View::Background () const {
1028 return (MyBackground);
1032 void Visual3d_View::SetBgGradientStyle( const Aspect_GradientFillMethod FillStyle,
1033 const Standard_Boolean update )
1038 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1040 MyGraphicDriver->SetBgGradientStyle( MyCView, FillStyle );
1044 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1049 Aspect_GradientBackground Visual3d_View::GradientBackground () const {
1051 return MyGradientBackground;
1055 void Visual3d_View::SetTransform (const TColStd_Array2OfReal& AMatrix) {
1057 if (IsDeleted ()) return;
1059 Standard_Integer lr, ur, lc, uc;
1060 Standard_Integer i, j;
1062 // Assign the new transformation in an array [0..3][0..3]
1063 // Avoid problems if the has defined a matrice [1..4][1..4]
1064 // ou [3..6][-1..2] !!
1065 lr = AMatrix.LowerRow ();
1066 ur = AMatrix.UpperRow ();
1067 lc = AMatrix.LowerCol ();
1068 uc = AMatrix.UpperCol ();
1070 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
1071 Visual3d_TransformError::Raise ("Transform : not a 4x4 matrix");
1073 for (i=0; i<=3; i++)
1074 for (j=0; j<=3; j++)
1075 MyTransformation (i, j) = AMatrix (lr + i, lc + j);
1077 Graphic3d_Vector VPN;
1078 Graphic3d_Vertex VRP;
1079 Graphic3d_Vector VUP;
1080 Standard_Real Sx, Sy, Sz;
1082 Visual3d_ViewOrientation NewViewOrientation;
1084 VPN = MyViewOrientation.ViewReferencePlane ();
1085 VRP = MyViewOrientation.ViewReferencePoint ();
1086 VUP = MyViewOrientation.ViewReferenceUp ();
1087 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1089 NewViewOrientation.SetViewReferencePlane
1090 (Graphic3d_Structure::Transforms (Transform (), VPN));
1092 NewViewOrientation.SetViewReferencePoint
1093 (Graphic3d_Structure::Transforms (Transform (), VRP));
1095 NewViewOrientation.SetViewReferenceUp
1096 (Graphic3d_Structure::Transforms (Transform (), VUP));
1097 NewViewOrientation.SetAxialScale(Sx, Sy, Sz);
1099 SetViewOrientation (NewViewOrientation);
1101 MyMatOfOriIsModified = Standard_True;
1102 MyMatOfOriIsEvaluated = Standard_False;
1106 const TColStd_Array2OfReal& Visual3d_View::Transform () const {
1108 return (MyTransformation);
1112 void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
1114 if (IsDeleted ()) return;
1116 MyViewOrientation = VO;
1118 Standard_Real X, Y, Z;
1120 // Tests on modification of parameters.
1121 Standard_Boolean VUPIsModified = Standard_False;
1122 Standard_Boolean VRPIsModified = Standard_False;
1123 Standard_Boolean VRUIsModified = Standard_False;
1124 Standard_Boolean ScaleIsModified = Standard_False;
1125 Standard_Boolean CustomIsModified = Standard_False;
1127 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
1129 MyCView.Orientation.ViewReferencePoint.x != float (X)
1130 || MyCView.Orientation.ViewReferencePoint.y != float (Y)
1131 || MyCView.Orientation.ViewReferencePoint.z != float (Z);
1132 MyCView.Orientation.ViewReferencePoint.x = float (X);
1133 MyCView.Orientation.ViewReferencePoint.y = float (Y);
1134 MyCView.Orientation.ViewReferencePoint.z = float (Z);
1136 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
1138 MyCView.Orientation.ViewReferencePlane.x != float (X)
1139 || MyCView.Orientation.ViewReferencePlane.y != float (Y)
1140 || MyCView.Orientation.ViewReferencePlane.z != float (Z);
1141 MyCView.Orientation.ViewReferencePlane.x = float (X);
1142 MyCView.Orientation.ViewReferencePlane.y = float (Y);
1143 MyCView.Orientation.ViewReferencePlane.z = float (Z);
1145 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
1147 MyCView.Orientation.ViewReferenceUp.x != float (X)
1148 || MyCView.Orientation.ViewReferenceUp.y != float (Y)
1149 || MyCView.Orientation.ViewReferenceUp.z != float (Z);
1150 MyCView.Orientation.ViewReferenceUp.x = float (X);
1151 MyCView.Orientation.ViewReferenceUp.y = float (Y);
1152 MyCView.Orientation.ViewReferenceUp.z = float (Z);
1154 Standard_Real Sx, Sy, Sz;
1156 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1158 MyCView.Orientation.ViewScaleX != float (X)
1159 || MyCView.Orientation.ViewScaleY != float (Y)
1160 || MyCView.Orientation.ViewScaleZ != float (Z);
1161 MyCView.Orientation.ViewScaleX = float (Sx);
1162 MyCView.Orientation.ViewScaleY = float (Sy);
1163 MyCView.Orientation.ViewScaleZ = float (Sz);
1166 MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
1167 MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
1168 if ( MyViewOrientation.IsCustomMatrix() ) {
1169 Standard_Integer i, j;
1170 for (i = 0; i < 4; i++)
1171 for (j = 0; j < 4; j++) {
1172 if (!CustomIsModified) CustomIsModified =
1173 MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
1174 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
1179 cout << "Visual3d_View::SetViewOrientation\n";
1180 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
1181 cout << "VUPIsModified : " << VUPIsModified
1182 << ", VRPIsModified : " << VRPIsModified
1183 << ", VRUIsModified : " << VRUIsModified
1184 << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
1186 cout << "no modification\n" << flush;
1189 // restart if one of parameters is modified
1190 if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified) {
1192 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1193 MyMatOfOriIsModified = Standard_True;
1194 MyMatOfOriIsEvaluated = Standard_False;
1197 if (! IsDefined ()) return;
1199 Standard_Boolean AWait = Standard_False; // => immediate update
1200 MyGraphicDriver->ViewOrientation (MyCView, AWait);
1204 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1209 Visual3d_ViewOrientation Visual3d_View::ViewOrientation () const {
1211 return (MyViewOrientation);
1215 Visual3d_ViewOrientation Visual3d_View::ViewOrientationDefault () const {
1217 return (MyViewOrientationReset);
1221 void Visual3d_View::SetViewOrientationDefault () {
1223 MyViewOrientationReset.Assign (MyViewOrientation);
1227 void Visual3d_View::ViewOrientationReset () {
1229 if (IsDeleted ()) return;
1231 MyViewOrientation = MyViewOrientationReset;
1233 Standard_Real X, Y, Z;
1235 // Tests on modification of parameters.
1236 Standard_Boolean VUPIsModified = Standard_False;
1237 Standard_Boolean VRPIsModified = Standard_False;
1238 Standard_Boolean VRUIsModified = Standard_False;
1239 Standard_Boolean ScaleIsModified = Standard_False;
1240 Standard_Boolean CustomIsModified = Standard_False;
1242 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
1244 MyCView.Orientation.ViewReferencePoint.x != float (X)
1245 || MyCView.Orientation.ViewReferencePoint.y != float (Y)
1246 || MyCView.Orientation.ViewReferencePoint.y != float (Y);
1247 MyCView.Orientation.ViewReferencePoint.x = float (X);
1248 MyCView.Orientation.ViewReferencePoint.y = float (Y);
1249 MyCView.Orientation.ViewReferencePoint.z = float (Z);
1251 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
1253 MyCView.Orientation.ViewReferencePlane.x != float (X)
1254 || MyCView.Orientation.ViewReferencePlane.y != float (Y)
1255 || MyCView.Orientation.ViewReferencePlane.y != float (Y);
1256 MyCView.Orientation.ViewReferencePlane.x = float (X);
1257 MyCView.Orientation.ViewReferencePlane.y = float (Y);
1258 MyCView.Orientation.ViewReferencePlane.z = float (Z);
1260 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
1262 MyCView.Orientation.ViewReferenceUp.x != float (X)
1263 || MyCView.Orientation.ViewReferenceUp.y != float (Y)
1264 || MyCView.Orientation.ViewReferenceUp.y != float (Y);
1265 MyCView.Orientation.ViewReferenceUp.x = float (X);
1266 MyCView.Orientation.ViewReferenceUp.y = float (Y);
1267 MyCView.Orientation.ViewReferenceUp.z = float (Z);
1269 Standard_Real Sx, Sy, Sz;
1271 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1273 MyCView.Orientation.ViewScaleX != float (X)
1274 || MyCView.Orientation.ViewScaleY != float (Y)
1275 || MyCView.Orientation.ViewScaleZ != float (Z);
1276 MyCView.Orientation.ViewScaleX = float (Sx);
1277 MyCView.Orientation.ViewScaleY = float (Sy);
1278 MyCView.Orientation.ViewScaleZ = float (Sz);
1281 MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
1282 MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
1283 if ( MyViewOrientation.IsCustomMatrix() ) {
1284 Standard_Integer i, j;
1285 for (i = 0; i < 4; i++)
1286 for (j = 0; j < 4; j++) {
1287 if (!CustomIsModified) CustomIsModified =
1288 MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
1289 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
1294 cout << "Visual3d_View::ViewOrientationReset\n";
1295 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
1296 cout << "VUPIsModified : " << VUPIsModified
1297 << ", VRPIsModified : " << VRPIsModified
1298 << ", VRUIsModified : " << VRUIsModified
1299 << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
1301 cout << "no modification\n" << flush;
1304 // Restart if one of parameters is modified
1305 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1307 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1308 MyMatOfOriIsModified = Standard_True;
1309 MyMatOfOriIsEvaluated = Standard_False;
1312 if (! IsDefined ()) return;
1314 Standard_Boolean AWait = Standard_False; // => immediate update
1315 MyGraphicDriver->ViewOrientation (MyCView, AWait);
1319 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1324 void Visual3d_View::SetViewMapping (const Visual3d_ViewMapping& VM) {
1326 if (IsDeleted ()) return;
1328 Visual3d_TypeOfProjection OldType = MyViewMapping.Projection ();
1329 Visual3d_TypeOfProjection NewType = VM.Projection ();
1333 Standard_Real X, Y, Z;
1334 Standard_Real um, vm, uM, vM;
1336 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
1337 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
1338 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
1339 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
1340 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
1341 MyCView.Mapping.ViewPlaneDistance =
1342 float (MyViewMapping.ViewPlaneDistance ());
1343 MyCView.Mapping.BackPlaneDistance =
1344 float (MyViewMapping.BackPlaneDistance ());
1345 MyCView.Mapping.FrontPlaneDistance =
1346 float (MyViewMapping.FrontPlaneDistance ());
1347 MyViewMapping.WindowLimit (um, vm, uM, vM);
1348 MyCView.Mapping.WindowLimit.um = float (um);
1349 MyCView.Mapping.WindowLimit.vm = float (vm);
1350 MyCView.Mapping.WindowLimit.uM = float (uM);
1351 MyCView.Mapping.WindowLimit.vM = float (vM);
1353 MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
1354 if (MyViewMapping.IsCustomMatrix()) {
1355 Standard_Integer i, j;
1356 for (i = 0; i < 4; i++)
1357 for (j = 0; j < 4; j++)
1358 MyCView.Mapping.ProjectionMatrix[i][j] =
1359 MyViewMapping.MyProjectionMatrix->Value(i,j);
1362 MyMatOfMapIsModified = Standard_True;
1363 MyMatOfMapIsEvaluated = Standard_False;
1365 if (! IsDefined ()) return;
1367 Standard_Boolean AWait = Standard_False; // => immediate update
1368 MyGraphicDriver->ViewMapping (MyCView, AWait);
1370 // Passage Parallele/Perspective
1371 if (OldType != NewType)
1374 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1378 Visual3d_ViewMapping Visual3d_View::ViewMapping () const {
1380 return (MyViewMapping);
1384 Visual3d_ViewMapping Visual3d_View::ViewMappingDefault () const {
1386 return (MyViewMappingReset);
1390 void Visual3d_View::SetViewMappingDefault () {
1392 MyViewMappingReset.Assign (MyViewMapping);
1396 void Visual3d_View::ViewMappingReset () {
1398 if (IsDeleted ()) return;
1400 MyViewMapping = MyViewMappingReset;
1402 Standard_Real X, Y, Z;
1403 Standard_Real um, vm, uM, vM;
1405 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
1406 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
1407 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
1408 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
1409 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
1410 MyCView.Mapping.ViewPlaneDistance =
1411 float (MyViewMapping.ViewPlaneDistance ());
1412 MyCView.Mapping.BackPlaneDistance =
1413 float (MyViewMapping.BackPlaneDistance ());
1414 MyCView.Mapping.FrontPlaneDistance =
1415 float (MyViewMapping.FrontPlaneDistance ());
1416 MyViewMapping.WindowLimit (um, vm, uM, vM);
1417 MyCView.Mapping.WindowLimit.um = float (um);
1418 MyCView.Mapping.WindowLimit.vm = float (vm);
1419 MyCView.Mapping.WindowLimit.uM = float (uM);
1420 MyCView.Mapping.WindowLimit.vM = float (vM);
1422 MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
1423 if (MyViewMapping.IsCustomMatrix()) {
1424 Standard_Integer i, j;
1425 for (i = 0; i < 4; i++)
1426 for (j = 0; j < 4; j++)
1427 MyCView.Mapping.ProjectionMatrix[i][j] =
1428 MyViewMapping.MyProjectionMatrix->Value(i,j);
1431 MyMatOfMapIsModified = Standard_True;
1432 MyMatOfMapIsEvaluated = Standard_False;
1434 if (! IsDefined ()) return;
1436 Standard_Boolean AWait = Standard_False; // => immediate update
1437 MyGraphicDriver->ViewMapping (MyCView, AWait);
1439 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1443 void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
1445 if (IsDeleted ()) return;
1447 Visual3d_TypeOfVisualization OldVisualMode;
1448 Visual3d_TypeOfVisualization NewVisualMode;
1450 // To manage display only in case of
1451 // change of visualisation mode.
1452 OldVisualMode = MyContext.Visualization ();
1453 NewVisualMode = CTX.Visualization ();
1455 Visual3d_TypeOfModel OldModel;
1456 Visual3d_TypeOfModel NewModel;
1458 // To manage change of visualisation only in case
1459 // of change of mode of visualisation or of type of shading.
1460 OldModel = MyContext.Model ();
1461 NewModel = CTX.Model ();
1463 Standard_Boolean OldAliasingMode;
1464 Standard_Boolean NewAliasingMode;
1466 // To manage antialiasing only in case of change.
1467 OldAliasingMode = MyContext.AliasingIsOn ();
1468 NewAliasingMode = CTX.AliasingIsOn ();
1470 Standard_Boolean OldDepthCueingMode;
1471 Standard_Boolean NewDepthCueingMode;
1473 Standard_Real OldDepthCueingFrontPlane;
1474 Standard_Real NewDepthCueingFrontPlane;
1475 Standard_Real OldDepthCueingBackPlane;
1476 Standard_Real NewDepthCueingBackPlane;
1478 // To manage the depth cueing only in case of change.
1479 OldDepthCueingMode = MyContext.DepthCueingIsOn ();
1480 NewDepthCueingMode = CTX.DepthCueingIsOn ();
1482 OldDepthCueingFrontPlane = MyContext.DepthCueingFrontPlane ();
1483 NewDepthCueingFrontPlane = CTX.DepthCueingFrontPlane ();
1484 OldDepthCueingBackPlane = MyContext.DepthCueingBackPlane ();
1485 NewDepthCueingBackPlane = CTX.DepthCueingBackPlane ();
1487 Standard_Boolean OldFrontZClippingMode;
1488 Standard_Boolean NewFrontZClippingMode;
1489 Standard_Boolean OldBackZClippingMode;
1490 Standard_Boolean NewBackZClippingMode;
1492 Standard_Real OldZClippingFrontPlane;
1493 Standard_Real NewZClippingFrontPlane;
1494 Standard_Real OldZClippingBackPlane;
1495 Standard_Real NewZClippingBackPlane;
1497 // To manage the Zclipping only in case of change.
1498 OldFrontZClippingMode = MyContext.FrontZClippingIsOn ();
1499 NewFrontZClippingMode = CTX.FrontZClippingIsOn ();
1500 OldBackZClippingMode = MyContext.BackZClippingIsOn ();
1501 NewBackZClippingMode = CTX.BackZClippingIsOn ();
1503 OldZClippingFrontPlane = MyContext.ZClippingFrontPlane ();
1504 NewZClippingFrontPlane = CTX.ZClippingFrontPlane ();
1505 OldZClippingBackPlane = MyContext.ZClippingBackPlane ();
1506 NewZClippingBackPlane = CTX.ZClippingBackPlane ();
1508 Standard_Integer OldTexEnvId;
1509 Standard_Integer NewTexEnvId;
1510 Visual3d_TypeOfSurfaceDetail OldSurfaceDetail;
1511 Visual3d_TypeOfSurfaceDetail NewSurfaceDetail;
1513 Handle(Graphic3d_TextureEnv) TempTextureEnv1 = MyContext.TextureEnv();
1514 if (! TempTextureEnv1.IsNull()) OldTexEnvId = TempTextureEnv1->TextureId();
1515 else OldTexEnvId = -1;
1517 Handle(Graphic3d_TextureEnv) TempTextureEnv2 = CTX.TextureEnv();
1519 if (! TempTextureEnv2.IsNull()) NewTexEnvId = TempTextureEnv2->TextureId();
1520 else NewTexEnvId = -1;
1522 OldSurfaceDetail = MyContext.SurfaceDetail();
1523 NewSurfaceDetail = CTX.SurfaceDetail();
1529 Standard_Boolean AWait = Standard_False; // => immediate update
1531 // management of visualization modes and types of shading.
1532 if ((OldVisualMode != NewVisualMode) || (OldModel != NewModel))
1533 MyGraphicDriver->SetVisualisation (MyCView);
1535 // management of antialiasing.
1536 if (OldAliasingMode != NewAliasingMode)
1537 MyGraphicDriver->AntiAliasing (MyCView, NewAliasingMode);
1539 // management of depth_cueing.
1540 if ((OldDepthCueingMode != NewDepthCueingMode) ||
1541 (OldDepthCueingFrontPlane != NewDepthCueingFrontPlane) ||
1542 (OldDepthCueingBackPlane != NewDepthCueingBackPlane)) {
1544 if( NewDepthCueingMode &&
1545 (NewDepthCueingBackPlane >= NewDepthCueingFrontPlane) )
1546 Visual3d_DepthCueingDefinitionError::Raise
1547 ("Bad value for DepthCueingPlanes position");
1549 MyGraphicDriver->DepthCueing
1550 (MyCView, NewDepthCueingMode);
1553 // management of Zclipping
1554 if ((OldFrontZClippingMode != NewFrontZClippingMode) ||
1555 (OldBackZClippingMode != NewBackZClippingMode) ||
1556 (OldZClippingFrontPlane != NewZClippingFrontPlane) ||
1557 (OldZClippingBackPlane != NewZClippingBackPlane)) {
1559 if( NewBackZClippingMode && NewFrontZClippingMode &&
1560 (NewZClippingBackPlane >= NewZClippingFrontPlane) )
1561 Visual3d_ZClippingDefinitionError::Raise
1562 ("Bad value for ZClippingPlanes position");
1564 MyGraphicDriver->ClipLimit (MyCView, AWait);
1567 // management of textures
1568 if ( (OldTexEnvId != NewTexEnvId) ||
1569 (OldSurfaceDetail != NewSurfaceDetail) )
1570 MyGraphicDriver->Environment(MyCView);
1572 // Update of planes of model clipping
1575 // Update of light sources
1579 if (OldVisualMode != NewVisualMode) {
1582 * Change of context =>
1583 * Remove structures that cannot be displayed
1584 * in the new visualisation mode.
1585 * It is not necessary to warn ViewManager as
1586 * this structure should not disappear from
1587 * the list of structures displayed in it.
1589 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
1590 Visual3d_TypeOfAnswer Answer;
1592 Standard_Integer i = MyDisplayedStructure.Extent ();
1594 Graphic3d_SequenceOfStructure FooSequence;
1596 while (S1Iterator.More ()) {
1597 Answer = AcceptDisplay (S1Iterator.Key ());
1598 // If the structure can't be displayed in the
1599 // new context of the view, it is removed.
1600 if ((Answer == Visual3d_TOA_NO) ||
1601 (Answer == Visual3d_TOA_COMPUTE))
1602 //Erase (S1Iterator.Key (), Aspect_TOU_WAIT);
1603 FooSequence.Append (S1Iterator.Key ());
1605 // S1Iterator.Next () is located on the next structure
1609 Standard_Integer Length = FooSequence.Length ();
1610 // The stored structures are removed
1611 for (i=1; i<=Length; i++)
1612 Erase (FooSequence.Value (i), Aspect_TOU_WAIT);
1613 if (Length != 0) FooSequence.Clear ();
1616 * Change of context =>
1617 * Display structures that can be displayed
1618 * with the new visualisation mode.
1619 * All structures with status Displayed are removed from the ViewManager
1620 * and displayed in the view directly, if the structure is not already
1621 * displayed and if the view accepts it in its context.
1624 i = MyViewManager->NumberOfDisplayedStructures ();
1625 Graphic3d_MapOfStructure Map;
1626 MyViewManager->DisplayedStructures(Map);
1627 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1629 for (; it.More(); it.Next()) {
1630 Handle(Graphic3d_Structure) SG = it.Key();
1631 if (! IsDisplayed (SG)) {
1632 Answer = AcceptDisplay(SG);
1633 // If the structure can be displayed in the
1634 // new context of the view, it is displayed.
1635 if ((Answer == Visual3d_TOA_YES) ||
1636 (Answer == Visual3d_TOA_COMPUTE))
1637 //Display (MyViewManager->DisplayedStructure (j),
1639 FooSequence.Append (SG);
1643 Length = FooSequence.Length ();
1644 // The stored structures are displayed
1645 for (i=1; i<=Length; i++)
1646 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
1647 if (Length != 0) FooSequence.Clear ();
1650 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1654 const Visual3d_ContextView& Visual3d_View::Context () const {
1660 void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& SG) const
1663 if (IsDeleted ()) return;
1665 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
1667 while (Iterator.More ()) {
1668 SG.Add (Iterator.Key ());
1670 // Iterator.Next () is located on the next structure
1676 void Visual3d_View::Activate () {
1678 if (IsDeleted ()) return;
1681 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1683 if (! IsActive ()) {
1685 MyGraphicDriver->ActivateView (MyCView);
1686 MyGraphicDriver->Background (MyCView);
1687 MyGraphicDriver->Transparency
1688 (MyCView, MyViewManager->Transparency ());
1693 * Activation of a new view =>
1694 * Display structures that can be displayed in this new view.
1695 * All structures with status
1696 * Displayed in ViewManager are returned and displayed in
1697 * the view directly, if the structure is not already
1698 * displayed and if the view accepts it in its context.
1701 Visual3d_TypeOfAnswer Answer;
1702 Graphic3d_MapOfStructure Map;
1703 MyViewManager->DisplayedStructures(Map);
1704 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1706 for (; it.More(); it.Next()) {
1707 Handle(Graphic3d_Structure) SG = it.Key();
1708 if (! IsDisplayed (SG)) {
1709 Answer = AcceptDisplay(SG);
1710 // If the structure can be displayed in the
1711 // new context of the view, it is displayed.
1712 if ((Answer == Visual3d_TOA_YES) ||
1713 (Answer == Visual3d_TOA_COMPUTE))
1714 Display (SG,Aspect_TOU_WAIT);
1720 // If the activation/desactivation of ZBuffer should be automatic
1721 // depending on the presence or absence of facets.
1722 if (MyViewManager->ZBufferAuto ()) {
1723 Standard_Boolean BContainsFacet = ContainsFacet ();
1724 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1725 // If the view contains facets
1726 // and if ZBuffer is not active
1727 if (BContainsFacet && ! BZBuffer)
1728 SetZBufferActivity (1);
1729 // If the view does not contain facets
1730 // and if ZBuffer is active
1731 if (! BContainsFacet && BZBuffer)
1732 SetZBufferActivity (0);
1735 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1739 Standard_Boolean Visual3d_View::IsActive () const {
1741 if (IsDeleted ()) return (Standard_False);
1744 return (Standard_True);
1746 return (Standard_False);
1750 void Visual3d_View::Deactivate () {
1752 if (IsDeleted ()) return;
1755 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1759 MyGraphicDriver->DeactivateView (MyCView);
1762 * Deactivation of a view =>
1763 * Removal of structures displayed in this view.
1764 * All structures with status
1765 * Displayed in ViewManager are returned and removed from
1766 * the view directly, if the structure is not already
1767 * displayed and if the view accepts it in its context.
1770 Visual3d_TypeOfAnswer Answer;
1771 Graphic3d_MapOfStructure Map;
1772 MyViewManager->DisplayedStructures(Map);
1773 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1775 for (; it.More(); it.Next()) {
1776 Handle(Graphic3d_Structure) SG = it.Key();
1777 if (! IsDisplayed (SG)) {
1778 Answer = AcceptDisplay(SG);
1779 // If the structure was displayed it is removed.
1780 if ((Answer == Visual3d_TOA_YES) ||
1781 (Answer == Visual3d_TOA_COMPUTE))
1782 Erase (SG,Aspect_TOU_WAIT);
1786 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1788 // No action currently possible in the view
1794 void Visual3d_View::Redraw () {
1796 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1800 void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
1802 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height);
1805 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1807 if (IsDeleted ()) return;
1809 if ((! IsDefined ()) || (! IsActive ())) return;
1811 if (! MyWindow->IsMapped ()) return;
1813 // san - 14/04/2004 - set up Z buffer state before redrawing
1814 // If the activation/desactivation of ZBuffer should be automatic
1815 // depending on the presence or absence of facets.
1816 if (MyViewManager->ZBufferAuto ()) {
1817 Standard_Boolean BContainsFacet = ContainsFacet ();
1818 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1819 // If the view contains facets
1820 // and if ZBuffer is not active
1821 if (BContainsFacet && ! BZBuffer)
1822 SetZBufferActivity (1);
1823 // If the view contains only facets
1824 // and if ZBuffer is active
1825 if (! BContainsFacet && BZBuffer)
1826 SetZBufferActivity (0);
1829 Aspect_CLayer2d OverCLayer;
1830 Aspect_CLayer2d UnderCLayer;
1831 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1832 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1833 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1834 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer);
1838 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) {
1840 if (IsDeleted ()) return;
1842 if ((! IsDefined ()) || (! IsActive ())) return;
1844 if (! MyWindow->IsMapped ()) return;
1846 // san - 14/04/2004 - set up Z buffer state before redrawing
1847 // If activation/desactivation of ZBuffer should be automatic
1848 // depending on the presence or absence of facets.
1849 if (MyViewManager->ZBufferAuto ()) {
1850 Standard_Boolean BContainsFacet = ContainsFacet ();
1851 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1852 // If the view contains facets
1853 // and if ZBuffer is not active
1854 if (BContainsFacet && ! BZBuffer)
1855 SetZBufferActivity (1);
1856 // If the view contains only facets
1857 // and if ZBuffer is active
1858 if (! BContainsFacet && BZBuffer)
1859 SetZBufferActivity (0);
1862 Aspect_CLayer2d OverCLayer;
1863 Aspect_CLayer2d UnderCLayer;
1864 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1865 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1866 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1867 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer, x, y, width, height);
1871 void Visual3d_View::Update () {
1873 Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1877 void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1879 if (IsDeleted ()) return;
1881 if ((! IsDefined ()) || (! IsActive ())) return;
1883 if (! MyWindow->IsMapped ()) return;
1885 // If activation/desactivation of ZBuffer should be automatic
1886 // depending on the presence or absence of facets.
1887 if (MyViewManager->ZBufferAuto ()) {
1888 Standard_Boolean BContainsFacet = ContainsFacet ();
1889 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1890 // If the view contains facets
1891 // and if ZBuffer is not active
1892 if (BContainsFacet && ! BZBuffer)
1893 SetZBufferActivity (1);
1894 // If the view does not contain facets
1895 // and if ZBuffer is active
1896 if (! BContainsFacet && BZBuffer)
1897 SetZBufferActivity (0);
1900 Aspect_CLayer2d OverCLayer;
1901 Aspect_CLayer2d UnderCLayer;
1902 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1903 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1904 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1905 //OSD::SetSignal (Standard_False);
1906 MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer);
1907 //OSD::SetSignal (Standard_True);
1909 MyMatOfMapIsModified = Standard_False;
1910 MyMatOfOriIsModified = Standard_False;
1914 Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const {
1916 // Return type of visualization of the view
1917 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
1919 // Return type of visualization of the structure
1920 Graphic3d_TypeOfStructure StructType = AStructure->Visual ();
1922 Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO;
1924 if (StructType == Graphic3d_TOS_ALL)
1925 // The structure accepts any type of view
1926 Result = Visual3d_TOA_YES;
1928 if ((StructType == Graphic3d_TOS_SHADING)
1929 && (ViewType == Visual3d_TOV_SHADING))
1930 Result = Visual3d_TOA_YES;
1931 if ((StructType == Graphic3d_TOS_WIREFRAME)
1932 && (ViewType == Visual3d_TOV_WIREFRAME))
1933 Result = Visual3d_TOA_YES;
1934 if ((StructType == Graphic3d_TOS_COMPUTED)
1935 && (ViewType == Visual3d_TOV_WIREFRAME))
1936 Result = Visual3d_TOA_COMPUTE;
1937 if ((StructType == Graphic3d_TOS_COMPUTED)
1938 && (ViewType == Visual3d_TOV_SHADING))
1939 Result = Visual3d_TOA_COMPUTE;
1943 if (Result == Visual3d_TOA_YES)
1944 cout << "YES = Visual3d_View" << MyCView.ViewId
1945 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1946 if (Result == Visual3d_TOA_NO)
1947 cout << "NO = Visual3d_View" << MyCView.ViewId
1948 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1949 if (Result == Visual3d_TOA_COMPUTE)
1950 cout << "COMPUTE = Visual3d_View" << MyCView.ViewId
1951 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1959 void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority) {
1961 if (IsDeleted ()) return;
1962 if (! IsDefined ()) return;
1963 if (! IsActive ()) return;
1964 if (! IsDisplayed (AStructure)) return;
1966 Standard_Integer Index = IsComputed (AStructure);
1968 if ( Index != 0 && ComputedMode () && !DegenerateModeIsOn () )
1970 if ((Index != 0) && (! DegenerateModeIsOn ()))
1974 Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification ();
1975 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1976 << AStructure->Identification () << "/" << StructId
1977 << ", " << OldPriority << ", " << NewPriority << ")\n";
1980 MyGraphicDriver->EraseStructure
1982 *(Graphic3d_CStructure *)
1983 MyCOMPUTEDSequence.Value (Index)->CStructure ());
1984 MyGraphicDriver->DisplayStructure
1986 *(Graphic3d_CStructure *)
1987 MyCOMPUTEDSequence.Value (Index)->CStructure (),
1992 Standard_Integer StructId = AStructure->Identification ();
1993 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1994 << AStructure->Identification () << "/" << StructId
1995 << ", " << OldPriority << ", " << NewPriority << ")\n";
1998 MyGraphicDriver->EraseStructure
2000 *(Graphic3d_CStructure *)AStructure->CStructure ());
2001 MyGraphicDriver->DisplayStructure
2003 *(Graphic3d_CStructure *)AStructure->CStructure (),
2009 void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) {
2012 cout << "Visual3d_View" << MyCView.ViewId << "::Clear ("
2013 << AStructure->Identification () << ")\n";
2017 Standard_Integer Index = IsComputed (AStructure);
2020 cout << "Structure " << AStructure->Identification ()
2021 << " calculated in the view "
2022 << Identification () << ", by structure "
2023 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2024 << " is emptied.\n";
2027 MyCOMPUTEDSequence.Value (Index)->GraphicClear (WithDestruction);
2028 MyCOMPUTEDSequence.Value (Index)->SetHLRValidation (Standard_False);
2033 void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
2035 #ifdef TRACE_CONNECT
2036 cout << "Visual3d_View" << MyCView.ViewId << "::Connect ("
2037 << AMother->Identification ()
2038 << ADaughter->Identification () << ")\n";
2042 Standard_Integer IndexM = IsComputed (AMother);
2043 Standard_Integer IndexD = IsComputed (ADaughter);
2045 if (IndexM != 0 && IndexD != 0) {
2046 #ifdef TRACE_CONNECT
2047 cout << "Structure " << AMother->Identification ()
2048 << " is connected to structure "
2049 << ADaughter->Identification () << endl;
2050 cout << "These structures are calculated.\n";
2051 cout << "In the view " << Identification ()
2053 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
2054 << " is connected to the structure "
2055 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
2058 MyCOMPUTEDSequence.Value (IndexM)->GraphicConnect (MyCOMPUTEDSequence.Value (IndexD));
2063 void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
2065 #ifdef TRACE_CONNECT
2066 cout << "Visual3d_View" << MyCView.ViewId << "::Disconnect ("
2067 << AMother->Identification ()
2068 << ADaughter->Identification () << ")\n";
2072 Standard_Integer IndexM = IsComputed (AMother);
2073 Standard_Integer IndexD = IsComputed (ADaughter);
2075 if (IndexM != 0 && IndexD != 0) {
2076 #ifdef TRACE_CONNECT
2077 cout << "Structure " << AMother->Identification ()
2078 << " is disconnected from the structure "
2079 << ADaughter->Identification () << endl;
2080 cout << "These structures are calculated.\n";
2081 cout << "In the view " << Identification ()
2083 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
2084 << " is disconnected from the structure "
2085 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
2088 MyCOMPUTEDSequence.Value (IndexM)->GraphicDisconnect (MyCOMPUTEDSequence.Value (IndexD));
2093 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) {
2095 Display (AStructure, MyViewManager->UpdateMode ());
2099 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
2101 if (IsDeleted ()) return;
2102 if (! IsDefined ()) return;
2103 if (! IsActive ()) return;
2105 // If Display on a structure present in the list
2106 // of calculated structures while it is not
2107 // or more, of calculated type =>
2108 // - removes it as well as the associated old computed
2109 // THis happens when hlhsr becomes again of type e
2110 // non computed after SetVisual.
2111 Standard_Integer Index = IsComputed (AStructure);
2113 if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) {
2116 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2117 cout << "In Visual3d_View::Display, ";
2118 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2119 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2123 MyTOCOMPUTESequence.Remove (Index);
2124 MyCOMPUTEDSequence.Remove (Index);
2127 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2128 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2129 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2135 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
2137 #ifdef TRACE_DISPLAY
2138 Standard_Integer StructId = AStructure->Identification ();
2139 cout << "Visual3d_View" << MyCView.ViewId << "::Display ("
2140 << StructId << ");\n";
2144 if (Answer == Visual3d_TOA_NO) {
2145 #ifdef TRACE_DISPLAY
2146 cout << "Answer : Visual3d_TOA_NO\n";
2152 // Mode degenerated active
2154 if ( !ComputedMode () || DegenerateModeIsOn () )
2155 Answer = Visual3d_TOA_YES;
2157 if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
2161 if (Answer == Visual3d_TOA_YES ) {
2162 #ifdef TRACE_DISPLAY
2163 cout << "Answer : Visual3d_TOA_YES\n";
2166 if (IsDisplayed (AStructure)) return;
2167 MyGraphicDriver->DisplayStructure (
2169 *(Graphic3d_CStructure *)AStructure->CStructure (),
2170 int (AStructure->DisplayPriority ())
2172 MyDisplayedStructure.Add (AStructure);
2173 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2176 if (Answer == Visual3d_TOA_COMPUTE) {
2177 #ifdef TRACE_DISPLAY
2178 cout << "Answer : Visual3d_TOA_COMPUTE\n";
2179 cout << "Index : " << Index << "\n" << flush;
2182 // Already computed, is COMPUTED still valid?
2183 #ifdef TRACE_DISPLAY
2184 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
2185 cout << "Structure "
2186 << MyTOCOMPUTESequence.Value (Index)->Identification ()
2187 << "already calculated, in the view "
2188 << Identification () << ", par la structure "
2189 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2190 << "\n was not recalculated as HLR is valid\n";
2194 cout << "Structure "
2195 << MyTOCOMPUTESequence.Value (Index)->Identification ()
2196 << " already calculated, in the view "
2197 << Identification () << ", by the structure "
2198 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2199 << "\n should be recalculated as HLR is invalid\n";
2203 Standard_Integer OldStructId =
2204 MyCOMPUTEDSequence.Value (Index)->Identification ();
2206 // Case COMPUTED valide
2207 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
2209 if (! IsDisplayed (AStructure)) {
2210 MyDisplayedStructure.Add (AStructure);
2211 MyGraphicDriver->DisplayStructure (
2213 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
2214 int (AStructure->DisplayPriority ())
2216 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2221 // Case COMPUTED invalid
2223 // Is there another valid representation ?
2224 // Find in the sequence of already calculated structures
2225 // 1/ Structure having the same Owner as <AStructure>
2226 // 2/ That is not <AStructure>
2227 // 3/ The COMPUTED which of is valid
2228 Standard_Integer NewIndex = HaveTheSameOwner (AStructure);
2230 // Case of COMPUTED invalid, WITH a valid of replacement
2231 if (NewIndex != 0) {
2233 if (! IsDisplayed (AStructure)) {
2234 MyCOMPUTEDSequence.SetValue
2235 (Index, MyCOMPUTEDSequence.Value (NewIndex));
2236 OldStructId = MyCOMPUTEDSequence.Value (NewIndex)->
2238 MyDisplayedStructure.Add (AStructure);
2239 MyGraphicDriver->DisplayStructure (
2241 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (NewIndex)->CStructure (),
2242 int (AStructure->DisplayPriority ())
2244 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2249 // Cas COMPUTED invalid, WITHOUT a valid of replacement
2251 // COMPUTED is removed if displayed
2252 if (IsDisplayed (AStructure))
2253 MyGraphicDriver->EraseStructure (
2255 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()
2259 } // if (Index != 0)
2261 // Compute + Validation
2263 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
2265 Handle(Graphic3d_Structure) TheStructure;
2266 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
2267 AStructure->Transform (ATrsf);
2269 TColStd_Array2OfReal Ident (0, 3, 0, 3);
2270 Standard_Integer ii, jj;
2271 for (ii=0; ii<=3; ii++)
2272 for (jj=0; jj<=3; jj++)
2273 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
2274 TheStructure = MyCOMPUTEDSequence.Value (Index);
2275 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
2276 if (AStructure->IsTransformed ()) {
2277 AStructure->Compute (this, ATrsf, TheStructure);
2280 AStructure->Compute (this, TheStructure);
2284 if (AStructure->IsTransformed ()) {
2285 TheStructure = AStructure->Compute (this, ATrsf);
2288 TheStructure = AStructure->Compute (this);
2292 TheStructure->SetHLRValidation (Standard_True);
2295 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2296 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2297 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2301 // TOCOMPUTE and COMPUTED associated to sequences are added
2302 MyTOCOMPUTESequence.Append (AStructure);
2303 MyCOMPUTEDSequence.Append (TheStructure);
2306 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2307 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2308 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2312 // The previous are removed if necessary
2314 MyTOCOMPUTESequence.Remove (Index);
2315 MyCOMPUTEDSequence.Remove (Index);
2319 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2320 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2321 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2325 // Return type of visualisation of the view
2326 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2328 // Of which type will be the computed ?
2329 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
2330 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
2332 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
2333 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
2335 if (ComputeWireframe)
2336 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
2338 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
2340 if (! ComputeShading && ! ComputeWireframe)
2341 Answer = Visual3d_TOA_NO;
2343 Answer = AcceptDisplay (TheStructure);
2345 if (AStructure->IsHighlighted()) {
2346 TheStructure->SetHighlightColor (AStructure->HighlightColor ());
2347 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
2350 #ifdef TRACE_DISPLAY
2351 cout << "Structure " << StructId
2352 << " in the view " << Identification ()
2353 << " is calculated by the structure "
2354 << TheStructure->Identification ();
2355 if (Answer == Visual3d_TOA_YES)
2356 cout << " and displayed\n";
2358 cout << " but not displayed\n";
2362 // It is displayed only if the calculated structure
2363 // has a proper type corresponding to the one of the view.
2364 if (Answer != Visual3d_TOA_NO) {
2365 if (! IsDisplayed (AStructure))
2366 MyDisplayedStructure.Add (AStructure);
2367 MyGraphicDriver->DisplayStructure (
2369 *(Graphic3d_CStructure *)TheStructure->CStructure (),
2370 int (AStructure->DisplayPriority ())
2372 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2374 } // Visual3d_TOA_COMPUTE
2377 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure) {
2379 if (IsDeleted ()) return;
2381 Erase (AStructure, MyViewManager->UpdateMode ());
2385 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
2387 Standard_Integer StructId;
2389 if (IsDeleted ()) return;
2391 // No test on window as the structure is displayed only if
2392 // the window exists, so only one test is enough.
2393 if (IsDisplayed (AStructure)) {
2394 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
2396 // Degenerated mode is active
2398 if ( !ComputedMode () || DegenerateModeIsOn () )
2399 Answer = Visual3d_TOA_YES;
2401 if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
2404 if (Answer != Visual3d_TOA_COMPUTE) {
2405 MyGraphicDriver->EraseStructure (
2407 *(Graphic3d_CStructure *)AStructure->CStructure ()
2411 if (Answer == Visual3d_TOA_COMPUTE) {
2412 Standard_Integer Index = IsComputed (AStructure);
2414 cout << "Visual3d_View" << MyCView.ViewId << "::Erase ("
2415 << AStructure->Identification () << ");\n";
2416 cout << "Index : " << Index << "\n";
2420 if ( Index != 0 && ComputedMode () &&
2421 !DegenerateModeIsOn () )
2423 if ((Index != 0) && (! DegenerateModeIsOn ()))
2427 MyCOMPUTEDSequence.Value (Index)->Identification ();
2429 cout << "Structure " << AStructure->Identification ()
2430 << " calculated, in the view "
2431 << Identification () << ", by the structure "
2432 << StructId << " is removed. \n";
2435 MyGraphicDriver->EraseStructure
2436 (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
2438 // else is impossible
2440 MyDisplayedStructure.Remove (AStructure);
2441 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2446 void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) {
2449 cout << "Visual3d_View" << MyCView.ViewId << "::Highlight ("
2450 << AStructure->Identification () << ")\n";
2454 Standard_Integer Index = IsComputed (AStructure);
2457 cout << "Structure " << AStructure->Identification ()
2458 << " calculated, in the view "
2459 << Identification () << ", by the structure "
2460 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2461 << " passes in highlight mode.\n";
2464 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
2465 (AStructure->HighlightColor ());
2466 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (AMethod);
2471 void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) {
2474 cout << "Visual3d_View" << MyCView.ViewId << "::Transform ("
2475 << AStructure->Identification () << ")\n";
2479 Standard_Integer Index = IsComputed (AStructure);
2482 cout << "The structure " << AStructure->Identification ()
2483 << " calculated, in the view "
2484 << Identification () << ", by the structure "
2485 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2486 << " is transformed.\n";
2489 // Test is somewhat light !
2490 // trsf is transferred only if it is :
2493 if (ATrsf (0, 1) != 0. || ATrsf (0, 2) != 0.
2494 || ATrsf (1, 0) != 0. || ATrsf (1, 2) != 0.
2495 || ATrsf (2, 0) != 0. || ATrsf (2, 1) != 0.)
2496 ReCompute (AStructure);
2498 MyCOMPUTEDSequence.Value (Index)->GraphicTransform (ATrsf);
2503 void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) {
2506 cout << "Visual3d_View" << MyCView.ViewId << "::UnHighlight ("
2507 << AStructure->Identification () << ")\n";
2511 Standard_Integer Index = IsComputed (AStructure);
2514 cout << "Structure " << AStructure->Identification ()
2515 << " calculated, in the view "
2516 << Identification () << ", by the structure "
2517 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2518 << " passes in unhighlight mode.\n";
2521 MyCOMPUTEDSequence.Value (Index)->GraphicUnHighlight ();
2527 Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& AStructure) const {
2529 Standard_Integer StrId = AStructure->Identification ();
2531 Standard_Integer Result = 0;
2532 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2534 // Recherche de la structure <AStructure> dans la
2535 // sequence des structures deja calculees
2536 for (Standard_Integer i=1; i<=Length && Result==0; i++)
2537 if ((MyTOCOMPUTESequence.Value (i))->Identification ()
2538 == StrId) Result = i;
2540 cout << "\n In the view " << Identification () << " the structure ";
2542 cout << StrId << " is calculated by "
2543 << MyCOMPUTEDSequence.Value (Result)->Identification ()
2546 cout << StrId << " is not calculated\n" << flush;
2550 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2551 cout << "In Visual3d_View::IsComputed, ";
2552 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2553 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2562 Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& AStructure) const {
2564 Standard_Boolean Result = Standard_False;
2566 if (IsDeleted ()) return Result;
2568 Result = MyDisplayedStructure.Contains (AStructure);
2575 Standard_Boolean Visual3d_View::ContainsComputedStructure () const {
2577 Standard_Boolean Result = Standard_False;
2579 if (MyDisplayedStructure.IsEmpty ()) return Result;
2581 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
2583 Standard_Integer i = MyDisplayedStructure.Extent ();
2585 // Stop at the first structure of type TOS_COMPUTED
2586 while (! Result && Iterator.More ()) {
2588 (((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED);
2590 // Iterator.Next () is located on the
2600 Standard_Boolean Visual3d_View::ContainsFacet () const {
2602 return ContainsFacet (MyDisplayedStructure);
2606 Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& ASet) const {
2608 Standard_Boolean Result = Standard_False;
2610 if (ASet.IsEmpty ()) return Result;
2612 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
2614 // Stop at the first structure containing a facet
2615 for ( Iterator.Initialize (ASet);
2616 Iterator.More () && ! Result;
2618 Result = (Iterator.Key ())->ContainsFacet ();
2624 void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
2627 (MyDisplayedStructure, XMin, YMin, ZMin, XMax, YMax, ZMax);
2631 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 {
2633 if (ASet.IsEmpty ()) {
2634 XMin = RealFirst ();
2635 YMin = RealFirst ();
2636 ZMin = RealFirst ();
2644 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
2645 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
2651 XMax = RealFirst ();
2652 YMax = RealFirst ();
2653 ZMax = RealFirst ();
2655 for ( Iterator.Initialize (ASet);
2659 if ( (Iterator.Key ())->IsInfinite ()){
2660 //XMin, YMin .... ZMax are initialized by means of infinite line data
2661 (Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
2662 if ( Xm != RealFirst() && Xm < XMin )
2664 if ( Ym != RealFirst() && Ym < YMin )
2666 if ( Zm != RealFirst() && Zm < ZMin )
2668 if ( XM != RealLast() && XM > XMax )
2670 if ( YM != RealLast() && YM > YMax )
2672 if ( ZM != RealLast() && ZM > ZMax )
2675 // Only non-empty and non-infinite structures
2676 // are taken into account for calculation of MinMax
2677 if (! (Iterator.Key ())->IsInfinite () &&
2678 ! (Iterator.Key ())->IsEmpty ()) {
2679 (Iterator.Key ())->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM);
2680 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
2681 //"FitAll" operation ignores object with transform persitence parameter
2682 if( (Iterator.Key ())->TransformPersistenceMode() == Graphic3d_TMF_None )
2684 if (Xm < XMin) XMin = Xm;
2685 if (Ym < YMin) YMin = Ym;
2686 if (Zm < ZMin) ZMin = Zm;
2687 if (XM > XMax) XMax = XM;
2688 if (YM > YMax) YMax = YM;
2689 if (ZM > ZMax) ZMax = ZM;
2694 // The following cases are relevant
2695 // For exemple if all structures are empty or infinite
2696 if (XMax < XMin) { Xm = XMin; XMin = XMax; XMax = Xm; }
2697 if (YMax < YMin) { Ym = YMin; YMin = YMax; YMax = Ym; }
2698 if (ZMax < ZMin) { Zm = ZMin; ZMin = ZMax; ZMax = Zm; }
2700 Standard_Real Sx, Sy, Sz;
2701 MyViewOrientation.AxialScale(Sx, Sy, Sz);
2702 XMin = (Sx > 1. && XMin < RealFirst ()/Sx)?RealFirst (): XMin*Sx;
2703 XMax = (Sx > 1. && XMax > RealLast ()/Sx)?RealLast (): XMax*Sx;
2704 YMin = (Sy > 1. && YMin < RealFirst ()/Sy)?RealFirst (): YMin*Sy;
2705 YMax = (Sy > 1. && YMax > RealLast ()/Sy)?RealLast (): YMax*Sy;
2706 ZMin = (Sz > 1. && ZMin < RealFirst ()/Sz)?RealFirst (): ZMin*Sz;
2707 ZMax = (Sz > 1. && ZMax > RealLast ()/Sz)?RealLast (): ZMax*Sz;
2710 void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
2712 MinMaxValues (MyDisplayedStructure, XMin, YMin, XMax, YMax);
2716 void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
2718 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
2719 Standard_Real Xp, Yp, Zp;
2721 MinMaxValues (ASet, Xm, Ym, Zm, XM, YM, ZM);
2723 Projects (Xm, Ym, Zm, Xp, Yp, Zp);
2727 Projects (XM, YM, ZM, Xp, Yp, Zp);
2731 if (XMax < XMin) { Xp = XMax; XMax = XMin; XMin = Xp; }
2732 if (YMax < YMin) { Yp = YMax; YMax = YMin; YMin = Yp; }
2735 const TColStd_Array2OfReal& Visual3d_View::MatrixOfOrientation () {
2737 if (! MyMatOfOriIsEvaluated) {
2738 MyGraphicDriver->InquireMat
2739 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2740 MyMatOfMapIsEvaluated = Standard_True;
2741 MyMatOfOriIsEvaluated = Standard_True;
2744 return (MyMatrixOfOrientation);
2748 const TColStd_Array2OfReal& Visual3d_View::MatrixOfMapping () {
2750 if (! MyMatOfMapIsEvaluated) {
2751 MyGraphicDriver->InquireMat
2752 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2753 MyMatOfMapIsEvaluated = Standard_True;
2754 MyMatOfOriIsEvaluated = Standard_True;
2757 return (MyMatrixOfMapping);
2761 Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
2763 Standard_Integer Result = MyDisplayedStructure.Extent ();
2770 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 {
2772 math_Vector PtDC (0,3), PtWC (0,3);
2775 // Otherwise use new on Visual3d_View (constructor+destructor)
2776 // as Projects is a const method or MatrixOfOrientation and
2777 // MatrixOfMapping is not.
2778 Visual3d_View * const newthis = (Visual3d_View * const) this;
2779 newthis->MatrixOfOrientation ();
2780 newthis->MatrixOfMapping ();
2782 // World Coordinate Space
2788 // WCS -> View Reference Coordinate Space
2789 math_Vector PtVRC(0,3);
2790 PtVRC = MyMatrixOfOrientation.Multiplied (PtWC);
2792 // VRCS -> Normalized Projection Coordinate Space
2793 math_Vector PtNPC(0,3);
2794 PtNPC = MyMatrixOfMapping.Multiplied (PtVRC);
2795 for (Standard_Integer i=0; i<3; i++) PtNPC (i) = PtNPC (i) / PtNPC (3);
2798 printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
2799 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2802 Standard_Real Ratio;
2804 // NPCS -> Device Coordinate Space
2805 Standard_Real Dx = Standard_Real (MyCView.DefWindow.dx);
2806 Standard_Real Dy = Standard_Real (MyCView.DefWindow.dy);
2809 PtDC (0) = PtNPC (0) * Dx;
2810 PtDC (1) = Dy - PtNPC (1) * Dy * Ratio;
2812 printf("Display coordinates : %f,%f,%f,%f\n",
2813 PtDC(0),PtDC(1),PtDC(2),PtDC(3));
2816 // NPCS -> Window Space
2817 Standard_Real um, vm, uM, vM;
2818 MyViewMapping.WindowLimit (um, vm, uM, vM);
2820 Ratio = (uM - um) / (vM - vm);
2822 PtNPC (1) = PtNPC (1) * Ratio;
2824 PtNPC (0) = PtNPC (0) / Ratio;
2827 printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
2828 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2831 Standard_Real fpd = MyViewMapping.FrontPlaneDistance ();
2832 Standard_Real bpd = MyViewMapping.BackPlaneDistance ();
2835 * Coordinates of PtNPC are described in the space
2836 * [0-1]x[0-1]x[0-1].
2837 * It is necessary to transform x and y in the window space.
2838 * It is necessary to transform z in the space of back and front
2839 * plane, taking into account clipping planes.
2840 * Z clipping planes are defined between 0 and 1.
2843 APX = PtNPC (0) * (uM - um) + um;
2844 APY = PtNPC (1) * (vM - vm) + vm;
2845 APZ = PtNPC (2) * (fpd - bpd) + bpd;
2848 Standard_Integer l,c;
2849 printf("OrientationMatrix :");
2850 for( l=0 ; l<4 ; l++ ) {
2851 printf("\n %d->",l);
2852 for( c=0 ; c<4 ; c++ ) {
2853 printf(" %f ,",MyMatrixOfOrientation(c,l));
2857 printf("MappingMatrix :");
2858 for( l=0 ; l<4 ; l++ ) {
2859 printf("\n %d->",l);
2860 for( c=0 ; c<4 ; c++ ) {
2861 printf(" %f ,",MyMatrixOfMapping(c,l));
2865 printf("World coordinates : %f,%f,%f,%f\n",
2866 PtWC(0),PtWC(1),PtWC(2),PtWC(3));
2867 printf("View coordinates : %f,%f,%f,%f\n",
2868 PtVRC(0),PtVRC(1),PtVRC(2),PtVRC(3));
2869 printf("Display coordinates : %f,%f,%f,%f\n",
2870 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2871 printf("Window limit : %f,%f,%f,%f\n",um,vm,uM,vM);
2872 printf("Ratio : %f\n",Ratio);
2873 printf("Front-plane : %f back-plane : %f\n",fpd,bpd);
2874 printf("Projection : %f,%f,%f\n \n",APX,APY,APZ);
2878 #endif /* OLD_METHOD */
2880 // OCC18942: This method is likely to duplicate Visual3d_ViewManager::ConvertCoord() one,
2881 // therefore it is necessary to consider merging the two methods or making them call the same
2882 // graphic driver's method after OCCT 6.3.
2883 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) {
2885 Standard_Real PtX, PtY, PtZ, PtT;
2887 static Standard_Real Ratio, um, vm, uM, vM;
2888 static Standard_Real fpd, bpd;
2890 if (! MyMatOfOriIsEvaluated || ! MyMatOfMapIsEvaluated) {
2891 MyGraphicDriver->InquireMat
2892 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2893 MyMatOfOriIsEvaluated = MyMatOfMapIsEvaluated = Standard_True;
2896 // WCS -> View Reference Coordinate Space
2897 PtX = MyMatrixOfOrientation (0, 0) * AX
2898 + MyMatrixOfOrientation (0, 1) * AY
2899 + MyMatrixOfOrientation (0, 2) * AZ
2900 + MyMatrixOfOrientation (0, 3);
2901 PtY = MyMatrixOfOrientation (1, 0) * AX
2902 + MyMatrixOfOrientation (1, 1) * AY
2903 + MyMatrixOfOrientation (1, 2) * AZ
2904 + MyMatrixOfOrientation (1, 3);
2905 PtZ = MyMatrixOfOrientation (2, 0) * AX
2906 + MyMatrixOfOrientation (2, 1) * AY
2907 + MyMatrixOfOrientation (2, 2) * AZ
2908 + MyMatrixOfOrientation (2, 3);
2909 PtT = MyMatrixOfOrientation (3, 0) * AX
2910 + MyMatrixOfOrientation (3, 1) * AY
2911 + MyMatrixOfOrientation (3, 2) * AZ
2912 + MyMatrixOfOrientation (3, 3);
2914 // VRCS -> Normalized Projection Coordinate Space
2915 APX = MyMatrixOfMapping (0, 0) * PtX
2916 + MyMatrixOfMapping (0, 1) * PtY
2917 + MyMatrixOfMapping (0, 2) * PtZ
2918 + MyMatrixOfMapping (0, 3) * PtT;
2919 APY = MyMatrixOfMapping (1, 0) * PtX
2920 + MyMatrixOfMapping (1, 1) * PtY
2921 + MyMatrixOfMapping (1, 2) * PtZ
2922 + MyMatrixOfMapping (1, 3) * PtT;
2923 APZ = MyMatrixOfMapping (2, 0) * PtX
2924 + MyMatrixOfMapping (2, 1) * PtY
2925 + MyMatrixOfMapping (2, 2) * PtZ
2926 + MyMatrixOfMapping (2, 3) * PtT;
2927 APT = MyMatrixOfMapping (3, 0) * PtX
2928 + MyMatrixOfMapping (3, 1) * PtY
2929 + MyMatrixOfMapping (3, 2) * PtZ
2930 + MyMatrixOfMapping (3, 3) * PtT;
2936 // NPCS -> Window Space
2937 MyViewMapping.WindowLimit (um, vm, uM, vM);
2938 fpd = MyViewMapping.FrontPlaneDistance ();
2939 bpd = MyViewMapping.BackPlaneDistance ();
2941 if(MyCView.Mapping.IsCustomMatrix) {
2942 // OCC18942: SAN - If orientation and mapping matrices are those used by OpenGL
2943 // visualization, then X, Y and Z coordinates normally vary between -1 and 1
2944 APX = ( APX + 1 ) * 0.5 * (uM - um) + um;
2945 APY = ( APY + 1 ) * 0.5 * (vM - vm) + vm;
2947 Ratio = (uM - um) / (vM - vm);
2954 * Coordinates of APX, APY, APZ are described in the space
2955 * [0-1]x[0-1]x[0-1].
2956 * It is necessary to transform x and y in the window space.
2957 * It is necessary to transform z in the space of back and front
2958 * plane, taking into account clipping planes.
2959 * Z clipping planes are defined between 0 and 1.
2961 APX = APX * (uM - um) + um;
2962 APY = APY * (vM - vm) + vm;
2964 APZ = APZ * (fpd - bpd) + bpd;
2967 Standard_Integer Visual3d_View::Identification () const {
2969 return (Standard_Integer (MyCView.ViewId));
2973 void Visual3d_View::Exploration () const {
2975 if (IsDeleted ()) return;
2977 MyGraphicDriver->DumpView (MyCView);
2981 Standard_Boolean Visual3d_View::ZBufferIsActivated () const {
2983 if (IsDeleted ()) return (Standard_False);
2985 if ((! IsDefined ()) || (! IsActive ())) return (Standard_False);
2987 // -1 => not forced by the programmer => depends on the type of visualisation
2988 // 0 ou 1 => forced by the programmer
2990 if (MyCView.Context.ZBufferActivity == -1)
2991 if (MyContext.Visualization () == Visual3d_TOV_SHADING)
2992 return (Standard_True);
2994 return (Standard_False);
2996 if (MyCView.Context.ZBufferActivity)
2997 return (Standard_True);
2999 return (Standard_False);
3003 void Visual3d_View::SetTransparency (const Standard_Boolean AnActivity) {
3005 if (IsDeleted ()) return;
3007 if ((! IsDefined ()) || (! IsActive ())) return;
3009 MyGraphicDriver->Transparency (MyCView, AnActivity);
3013 void Visual3d_View::SetZBufferActivity (const Standard_Integer AnActivity) {
3015 if (MyCView.Context.ZBufferActivity == AnActivity) return;
3017 if (IsDeleted ()) return;
3019 if ((! IsDefined ()) || (! IsActive ())) return;
3021 MyCView.Context.ZBufferActivity = AnActivity;
3022 MyGraphicDriver->SetVisualisation (MyCView);
3026 void Visual3d_View::UpdateView () {
3028 MyCView.Context.Aliasing = (MyContext.AliasingIsOn () ? 1:0);
3029 MyCView.Context.BackZClipping =
3030 (MyContext.BackZClippingIsOn () ? 1:0);
3031 MyCView.Context.FrontZClipping =
3032 (MyContext.FrontZClippingIsOn() ? 1:0);
3033 MyCView.Context.DepthCueing =
3034 (MyContext.DepthCueingIsOn () ? 1:0);
3036 MyCView.Context.ZClipFrontPlane =
3037 float (MyContext.ZClippingFrontPlane ());
3038 MyCView.Context.ZClipBackPlane =
3039 float (MyContext.ZClippingBackPlane ());
3040 MyCView.Context.DepthFrontPlane =
3041 float (MyContext.DepthCueingFrontPlane ());
3042 MyCView.Context.DepthBackPlane =
3043 float (MyContext.DepthCueingBackPlane ());
3045 MyCView.Context.Model = int (MyContext.Model ());
3046 MyCView.Context.Visualization = int (MyContext.Visualization ());
3048 Handle(Graphic3d_TextureEnv) TempTextureEnv = MyContext.TextureEnv();
3049 if (! TempTextureEnv.IsNull()) MyCView.Context.TexEnvId = TempTextureEnv->TextureId();
3050 else MyCView.Context.TexEnvId = -1;
3051 MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
3055 void Visual3d_View::Compute () {
3058 Standard_Integer Length = MyCOMPUTEDSequence.Length ();
3059 for (i=1; i<=Length; i++)
3060 (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False);
3062 // if the degenerated node is active, nothing is recomputed
3064 if ( DegenerateModeIsOn () || !ComputedMode () ) return;
3066 if (DegenerateModeIsOn ()) return;
3070 * Force HLRValidation to False on all structures
3071 * calculated in the view.
3074 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3075 cout << "In Visual3d_View::Compute, ";
3076 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3077 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3083 * Change of orientation or of projection type =>
3084 * Remove structures that were calculated for the
3085 * previous orientation.
3086 * Recalculation of new structures.
3087 * Passage of the degenerated mode ON to OFF =>
3088 * Remove structures that were calculated before
3089 * the degenerated mode passed to ON.
3090 * Recalculate new structures.
3092 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3093 Visual3d_TypeOfAnswer Answer;
3095 i = MyDisplayedStructure.Extent ();
3097 Graphic3d_SequenceOfStructure FooSequence;
3099 while (S1Iterator.More ()) {
3100 Answer = AcceptDisplay (S1Iterator.Key ());
3101 // If the structure was calculated, it is recalculated.
3102 if (Answer == Visual3d_TOA_COMPUTE) {
3104 cout << "AcceptDisplay ("
3105 << (S1Iterator.Key ())->Identification ()
3106 << ") == Visual3d_TOA_COMPUTE;\n";
3109 //Display (S1Iterator.Key (), Aspect_TOU_WAIT);
3110 FooSequence.Append (S1Iterator.Key ());
3113 // S1Iterator.Next () is located on the next structure
3117 Length = FooSequence.Length ();
3118 // All stored structures are displayed
3119 for (i=1; i<=Length; i++)
3120 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
3121 if (Length != 0) FooSequence.Clear ();
3125 void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
3127 if ( DegenerateModeIsOn () || !ComputedMode () ) return;
3129 if (DegenerateModeIsOn()) return;
3132 if (IsDeleted ()) return;
3134 if ((! IsDefined ()) || (! IsActive ())) return;
3136 if (! MyWindow->IsMapped ()) return;
3138 if (! AStructure->IsDisplayed ()) return;
3140 Visual3d_TypeOfAnswer Answer;
3142 Answer = AcceptDisplay (AStructure);
3144 if (Answer == Visual3d_TOA_COMPUTE) {
3145 Standard_Integer Index = IsComputed (AStructure);
3148 cout << "Structure " << AStructure->Identification ()
3149 << " is not calculated in the view "
3150 << Identification () << "\n";
3155 Standard_Integer OldStructId, NewStructId;
3157 MyCOMPUTEDSequence.Value (Index)->Identification ();
3159 Standard_Integer StructId = AStructure->Identification ();
3160 cout << "Structure " << StructId
3161 << " calculated, in the view "
3162 << Identification () << ", by the structure "
3163 << OldStructId << " is recalculated.\n";
3167 // Compute + Validation
3169 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
3171 Handle(Graphic3d_Structure) TheStructure;
3172 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
3173 AStructure->Transform (ATrsf);
3175 TColStd_Array2OfReal Ident (0, 3, 0, 3);
3176 Standard_Integer ii, jj;
3177 for (ii=0; ii<=3; ii++)
3178 for (jj=0; jj<=3; jj++)
3179 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
3180 TheStructure = MyCOMPUTEDSequence.Value (Index);
3181 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
3182 if (AStructure->IsTransformed ()) {
3183 AStructure->Compute (this, ATrsf, TheStructure);
3186 AStructure->Compute (this, TheStructure);
3190 if (AStructure->IsTransformed ()) {
3191 TheStructure = AStructure->Compute (this, ATrsf);
3194 TheStructure = AStructure->Compute (this);
3198 TheStructure->SetHLRValidation (Standard_True);
3200 // Return type of visualisation of the view
3201 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
3203 // Of which type will be the computed ?
3204 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
3205 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
3207 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
3208 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
3210 if (ComputeWireframe)
3211 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
3213 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
3215 if (AStructure->IsHighlighted ()) {
3216 TheStructure->SetHighlightColor
3217 (AStructure->HighlightColor ());
3218 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
3222 // Find structure <AStructure>
3223 // in the sequence of structures to be calculated.
3224 NewStructId = TheStructure->Identification ();
3226 // The previous calculation is removed and the new one is dislayed
3227 MyGraphicDriver->EraseStructure (
3229 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
3230 MyGraphicDriver->DisplayStructure (
3232 *(Graphic3d_CStructure *)TheStructure->CStructure (),
3233 int (AStructure->DisplayPriority ())
3237 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3238 cout << "In Visual3d_View::ReCompute, ";
3239 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3240 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3245 // hlhsr and the new associated compute are added
3246 MyTOCOMPUTESequence.Append (AStructure);
3247 MyCOMPUTEDSequence.Append (TheStructure);
3250 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3251 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3252 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3256 // hlhsr and the new associated compute are removed
3258 MyTOCOMPUTESequence.Remove (Index);
3259 MyCOMPUTEDSequence.Remove (Index);
3262 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3263 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3264 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3274 Visual3d_View::SetAnimationModeOn ( const Standard_Boolean degenerate ) {
3276 Visual3d_View::SetAnimationModeOn () {
3279 if (AnimationModeIsOn ()) return;
3281 AnimationModeIsActive = Standard_True;
3284 SetDegenerateModeOn ();
3286 SetDegenerateModeOff ();
3288 MyGraphicDriver->BeginAnimation (MyCView);
3292 void Visual3d_View::SetAnimationModeOff () {
3294 if (! AnimationModeIsOn ()) return;
3296 AnimationModeIsActive = Standard_False;
3298 SetDegenerateModeOff ();
3300 MyGraphicDriver->EndAnimation (MyCView);
3304 Standard_Boolean Visual3d_View::AnimationModeIsOn () const {
3306 return AnimationModeIsActive;
3310 void Visual3d_View::SetDegenerateModeOn () {
3313 cout << "Visual3d_View" << MyCView.ViewId
3314 << "::SetDegenerateModeOn ();\n";
3318 // If the degenerated mode is already active, nothing is recalculated
3319 if (DegenerateModeIsOn ()) return;
3320 DegenerateModeIsActive = Standard_True;
3323 MyCView.IsDegenerates = 1;
3326 * Change of activity of the degenerated mode
3327 * Remove structures that were calculated
3328 * and displayed when the mode was off.
3329 * Display of non-calculated structures.
3331 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3332 Visual3d_TypeOfAnswer Answer;
3333 Standard_Integer StructId;
3335 while (S1Iterator.More ()) {
3337 Answer = AcceptDisplay (S1Iterator.Key ());
3338 // If the structure was calculated, the previous one is
3339 // removed and the new one is displayed
3340 // (This is the role of passage into degenerated mode)
3342 if (Answer == Visual3d_TOA_COMPUTE) {
3343 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3346 MyCOMPUTEDSequence.Value (Index)->Identification ();
3348 cout << "Structure " << S1Iterator.Key ()->Identification ()
3349 << " calculated, in the view "
3350 << Identification () << ", by structure "
3351 << StructId << " passes in degenerated mode.\n";
3352 cout << "Remove" << StructId << " then display "
3353 << S1Iterator.Key ()->Identification () << "\n";
3356 MyGraphicDriver->EraseStructure
3357 (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
3358 MyGraphicDriver->DisplayStructure (
3360 *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure (),
3361 int (S1Iterator.Key ()->DisplayPriority ())
3365 // Else is impossible)
3366 // If the mode was not degenerated previously, the
3367 // calculated structure associated to S1Iterator.Key ()
3368 // really exists and Index != 0
3372 // S1Iterator.Next () is located on the next structure
3378 void Visual3d_View::SetDegenerateModeOff () {
3381 cout << "Visual3d_View" << MyCView.ViewId
3382 << "::SetDegenerateModeOff ();\n";
3386 // If the degenerated mode is already inactive, nothing is recalculated
3387 if (! DegenerateModeIsOn ()) return;
3389 DegenerateModeIsActive = Standard_False;
3392 MyCView.IsDegenerates = 0;
3395 * Change of activity of degenerated mode
3396 * Remove structures that were displayed
3397 * when the mode was on.
3398 * Calculation of structures.
3400 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3401 Visual3d_TypeOfAnswer Answer;
3402 Standard_Integer StructId;
3404 Standard_Integer i = MyDisplayedStructure.Extent ();
3406 while (S1Iterator.More ()) {
3408 Answer = AcceptDisplay (S1Iterator.Key ());
3409 // If the structure was calculated, the previous one is
3410 // removed and the new one is displayed
3411 // (This is the role of passage into degenerated mode)
3413 if (Answer == Visual3d_TOA_COMPUTE) {
3414 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3417 MyCOMPUTEDSequence.Value (Index)->Identification ();
3419 cout << "Structure " << S1Iterator.Key ()->Identification ()
3420 << " calculated, in the view "
3421 << Identification () << ", by the structure "
3422 << StructId << " passes into normal mode.\n";
3423 cout << "Remove " << S1Iterator.Key ()->Identification ()
3424 << " then display " << StructId << "\n";
3427 MyGraphicDriver->EraseStructure
3429 *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure ());
3430 MyGraphicDriver->DisplayStructure (
3432 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
3433 int (S1Iterator.Key ()->DisplayPriority ())
3436 Display (S1Iterator.Key (), Aspect_TOU_WAIT);
3438 if ((S1Iterator.Key ())->IsHighlighted()) {
3439 if (! (MyCOMPUTEDSequence.Value (Index))->IsHighlighted()) {
3440 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
3441 ((S1Iterator.Key ())->HighlightColor ());
3442 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (Aspect_TOHM_COLOR);
3447 // Else is impossible
3448 // Degenerated mode was activated before display of the
3449 // structure. So the structure was displayed in the
3450 // degenerated mode, but the calculated structure didn't exist.
3451 // It is calculated.
3453 // Compute + Validation
3454 Handle(Graphic3d_Structure) AStructure = (S1Iterator.Key ());
3456 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
3458 Handle(Graphic3d_Structure) TheStructure;
3459 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
3460 AStructure->Transform (ATrsf);
3462 TColStd_Array2OfReal Ident (0, 3, 0, 3);
3463 Standard_Integer ii, jj;
3464 for (ii=0; ii<=3; ii++)
3465 for (jj=0; jj<=3; jj++)
3466 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
3467 TheStructure = MyCOMPUTEDSequence.Value (Index);
3468 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
3469 if (AStructure->IsTransformed ()) {
3470 AStructure->Compute (this, ATrsf, TheStructure);
3473 AStructure->Compute (this, TheStructure);
3477 if (AStructure->IsTransformed ()) {
3478 TheStructure = AStructure->Compute (this, ATrsf);
3481 TheStructure = AStructure->Compute (this);
3485 TheStructure->SetHLRValidation (Standard_True);
3487 // Return type of visualisation of the view
3488 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
3490 // Of which type will be the computed ?
3491 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
3492 ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_SHADING));
3494 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
3495 ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
3497 if (ComputeWireframe)
3498 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
3500 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
3502 if ((S1Iterator.Key ())->IsHighlighted()) {
3503 TheStructure->SetHighlightColor
3504 ((S1Iterator.Key ())->HighlightColor ());
3505 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
3509 Standard_Integer Result = 0;
3510 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
3511 // Find structure <S1Iterator.Key ()>
3512 // in the sequence of structures to be calculated
3513 StructId = (S1Iterator.Key ())->Identification ();
3514 for (i=1; i<=Length && Result==0; i++)
3515 if ((MyTOCOMPUTESequence.Value (i))->Identification () ==
3516 StructId) Result = i;
3518 MyCOMPUTEDSequence.ChangeValue (Result) = TheStructure;
3520 // hlhsr and the associated new compute are added
3522 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3523 cout << "In Visual3d_View::SetDegenerateModeOff, ";
3524 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3525 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3529 MyTOCOMPUTESequence.Append (S1Iterator.Key ());
3530 MyCOMPUTEDSequence.Append (TheStructure);
3532 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3533 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3534 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3539 // The degenerated is removed and the calculated is displayed
3540 MyGraphicDriver->EraseStructure
3542 *(Graphic3d_CStructure *)(S1Iterator.Key ()->CStructure ()));
3543 MyGraphicDriver->DisplayStructure (
3545 *(Graphic3d_CStructure *)TheStructure->CStructure (),
3546 int (S1Iterator.Key ()->DisplayPriority ())
3551 // S1Iterator.Next () is located on the next structure
3555 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
3559 Standard_Boolean Visual3d_View::DegenerateModeIsOn () const {
3561 return DegenerateModeIsActive;
3565 Handle(Aspect_GraphicDriver) Visual3d_View::GraphicDriver () const {
3567 return MyGraphicDriver;
3571 void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& APlotter) const {
3573 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3575 while (S1Iterator.More ()) {
3577 if (DegenerateModeIsOn ())
3578 // As the mode is degenerated the displayed structure
3579 // is plotted without taking into account if it is calculated or not
3580 (S1Iterator.Key ())->Plot (APlotter);
3582 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3583 // As the mode is not degenerated the displayed structure
3584 // is plotted as if it was not calculated, otherwise the
3585 // associated calculated structure is plotted.
3587 (S1Iterator.Key ())->Plot (APlotter);
3589 (MyCOMPUTEDSequence.Value (Index))->Plot (APlotter);
3592 // S1Iterator.Next () is located on the next structure
3598 Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const {
3600 Standard_Integer Result = 0;
3601 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
3603 // Find in the sequence of already calculated structures
3604 // 1/ Structure with the same Owner as <AStructure>
3605 // 2/ Which is not <AStructure>
3606 // 3/ COMPUTED which of is valid
3607 for (Standard_Integer i=1; i<=Length && Result==0; i++)
3608 if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ())
3609 && (MyTOCOMPUTESequence.Value (i)->Identification () !=
3610 AStructure->Identification ())
3611 && (MyCOMPUTEDSequence.Value (i)->HLRValidation ())) Result = i;
3617 Standard_Address Visual3d_View::CView () const {
3619 return Standard_Address (&MyCView);
3624 // Triedron methods : the Triedron is a non-zoomable object.
3626 void Visual3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
3627 const Quantity_NameOfColor YColor,
3628 const Quantity_NameOfColor ZColor,
3629 const Standard_Real SizeRatio,
3630 const Standard_Real AxisDiametr,
3631 const Standard_Integer NbFacettes) {
3632 MyGraphicDriver->ZBufferTriedronSetup(XColor, YColor, ZColor,
3633 SizeRatio, AxisDiametr, NbFacettes);
3638 void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition,
3639 const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe ) {
3641 MyGraphicDriver->TriedronDisplay (MyCView,APosition, AColor, AScale, AsWireframe);
3645 void Visual3d_View::TriedronErase () {
3647 MyGraphicDriver->TriedronErase (MyCView);
3652 void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
3654 MyGraphicDriver->TriedronEcho (MyCView,AType);
3658 Standard_Boolean checkFloat(const Standard_Real value)
3660 return value > -FLT_MAX && value < FLT_MAX;
3663 void SetMinMaxValuesCallback(void* Visual3dView)
3665 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
3667 Handle(Visual3d_View) view = (Handle(Visual3d_View)&) Visual3dView;
3668 view->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
3670 if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
3671 checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
3673 Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(view->GraphicDriver());
3674 driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
3675 (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
3679 void Visual3d_View::GetGraduatedTrihedron(/* Names of axes */
3680 Standard_CString& xname,
3681 Standard_CString& yname,
3682 Standard_CString& zname,
3684 Standard_Boolean& xdrawname,
3685 Standard_Boolean& ydrawname,
3686 Standard_Boolean& zdrawname,
3688 Standard_Boolean& xdrawvalues,
3689 Standard_Boolean& ydrawvalues,
3690 Standard_Boolean& zdrawvalues,
3692 Standard_Boolean& drawgrid,
3694 Standard_Boolean& drawaxes,
3695 /* Number of splits along axes */
3696 Standard_Integer& nbx,
3697 Standard_Integer& nby,
3698 Standard_Integer& nbz,
3699 /* Offset for drawing values */
3700 Standard_Integer& xoffset,
3701 Standard_Integer& yoffset,
3702 Standard_Integer& zoffset,
3703 /* Offset for drawing names of axes */
3704 Standard_Integer& xaxisoffset,
3705 Standard_Integer& yaxisoffset,
3706 Standard_Integer& zaxisoffset,
3707 /* Draw tickmarks */
3708 Standard_Boolean& xdrawtickmarks,
3709 Standard_Boolean& ydrawtickmarks,
3710 Standard_Boolean& zdrawtickmarks,
3711 /* Length of tickmarks */
3712 Standard_Integer& xtickmarklength,
3713 Standard_Integer& ytickmarklength,
3714 Standard_Integer& ztickmarklength,
3716 Quantity_Color& gridcolor,
3718 Quantity_Color& xnamecolor,
3720 Quantity_Color& ynamecolor,
3722 Quantity_Color& znamecolor,
3723 /* X color of axis and values */
3724 Quantity_Color& xcolor,
3725 /* Y color of axis and values */
3726 Quantity_Color& ycolor,
3727 /* Z color of axis and values */
3728 Quantity_Color& zcolor,
3729 /* Name of font for names of axes */
3730 Standard_CString& fontOfNames,
3731 /* Style of names of axes */
3732 OSD_FontAspect& styleOfNames,
3733 /* Size of names of axes */
3734 Standard_Integer& sizeOfNames,
3735 /* Name of font for values */
3736 Standard_CString& fontOfValues,
3737 /* Style of values */
3738 OSD_FontAspect& styleOfValues,
3739 /* Size of values */
3740 Standard_Integer& sizeOfValues) const
3742 MyGraphicDriver->GetGraduatedTrihedron(MyCView,
3759 /* Number of splits along axes */
3763 /* Offset for drawing values */
3767 /* Offset for drawing names of axes */
3771 /* Draw tickmarks */
3775 /* Length of tickmarks */
3787 /* X color of axis and values */
3789 /* Y color of axis and values */
3791 /* Z color of axis and values */
3793 /* Name of font for names of axes */
3795 /* Style of names of axes */
3797 /* Size of names of axes */
3799 /* Name of font for values */
3801 /* Style of values */
3803 /* Size of values */
3807 void Visual3d_View::GraduatedTrihedronDisplay(/* Names of axes */
3808 const Standard_CString xname,
3809 const Standard_CString yname,
3810 const Standard_CString zname,
3812 const Standard_Boolean xdrawname,
3813 const Standard_Boolean ydrawname,
3814 const Standard_Boolean zdrawname,
3816 const Standard_Boolean xdrawvalues,
3817 const Standard_Boolean ydrawvalues,
3818 const Standard_Boolean zdrawvalues,
3820 const Standard_Boolean drawgrid,
3822 const Standard_Boolean drawaxes,
3823 /* Number of splits along axes */
3824 const Standard_Integer nbx,
3825 const Standard_Integer nby,
3826 const Standard_Integer nbz,
3827 /* Offset for drawing values */
3828 const Standard_Integer xoffset,
3829 const Standard_Integer yoffset,
3830 const Standard_Integer zoffset,
3831 /* Offset for drawing names of axes */
3832 const Standard_Integer xaxisoffset,
3833 const Standard_Integer yaxisoffset,
3834 const Standard_Integer zaxisoffset,
3835 /* Draw tickmarks */
3836 const Standard_Boolean xdrawtickmarks,
3837 const Standard_Boolean ydrawtickmarks,
3838 const Standard_Boolean zdrawtickmarks,
3839 /* Length of tickmarks */
3840 const Standard_Integer xtickmarklength,
3841 const Standard_Integer ytickmarklength,
3842 const Standard_Integer ztickmarklength,
3844 const Quantity_Color& gridcolor,
3846 const Quantity_Color& xnamecolor,
3848 const Quantity_Color& ynamecolor,
3850 const Quantity_Color& znamecolor,
3851 /* X color of axis and values */
3852 const Quantity_Color& xcolor,
3853 /* Y color of axis and values */
3854 const Quantity_Color& ycolor,
3855 /* Z color of axis and values */
3856 const Quantity_Color& zcolor,
3857 /* Name of font for names of axes */
3858 const Standard_CString fontOfNames,
3859 /* Style of names of axes */
3860 const OSD_FontAspect styleOfNames,
3861 /* Size of names of axes */
3862 const Standard_Integer sizeOfNames,
3863 /* Name of font for values */
3864 const Standard_CString fontOfValues,
3865 /* Style of values */
3866 const OSD_FontAspect styleOfValues,
3867 /* Size of values */
3868 const Standard_Integer sizeOfValues)
3870 CALL_DEF_GRADUATEDTRIHEDRON cubic;
3871 cubic.ptrVisual3dView = this;
3872 cubic.cbCubicAxes = SetMinMaxValuesCallback;
3873 MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,
3891 /* Number of splits along axes */
3895 /* Offset for drawing values */
3899 /* Offset for drawing names of axes */
3903 /* Draw tickmarks */
3907 /* Length of tickmarks */
3919 /* X color of axis and values */
3921 /* Y color of axis and values */
3923 /* Z color of axis and values */
3925 /* Name of font for names of axes */
3927 /* Style of names of axes */
3929 /* Size of names of axes */
3931 /* Name of font for values */
3933 /* Style of values */
3935 /* Size of values */
3939 void Visual3d_View::GraduatedTrihedronErase()
3941 MyGraphicDriver->GraduatedTrihedronErase(MyCView);
3944 const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer () const {
3946 return (MyViewManager->UnderLayer ());
3950 const Handle(Visual3d_Layer)& Visual3d_View::OverLayer () const {
3952 return (MyViewManager->OverLayer ());
3956 Standard_Integer Visual3d_View::LightLimit() const {
3958 Standard_Integer maxlight = MyGraphicDriver->InquireLightLimit ();
3959 // printf(" $$$ Visual3d_View::LightLimit() is %d\n",maxlight);
3963 Standard_Integer Visual3d_View::PlaneLimit() const {
3965 Standard_Integer maxplane = MyGraphicDriver->InquirePlaneLimit ();
3966 // printf(" $$$ Visual3d_View::PlaneLimit() is %d\n",maxplane);
3971 Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const {
3973 return MyPtrViewManager;
3978 void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode ) {
3980 if ( ( (aMode && ComputedModeIsActive) ||
3981 (!aMode && !ComputedModeIsActive)
3982 ) || DegenerateModeIsOn ()
3985 Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure );
3986 Visual3d_TypeOfAnswer Answer;
3987 Standard_Integer StructId;
3988 Standard_Integer i = MyDisplayedStructure.Extent ();
3990 if ( !( ComputedModeIsActive = aMode ) ) {
3992 while ( S1Iterator.More () ) {
3994 Answer = AcceptDisplay ( S1Iterator.Key () );
3996 if ( Answer == Visual3d_TOA_COMPUTE ) {
3998 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
4002 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
4004 MyGraphicDriver -> EraseStructure (
4006 *( Graphic3d_CStructure* )
4007 MyCOMPUTEDSequence.Value ( Index ) -> CStructure ()
4009 MyGraphicDriver -> DisplayStructure (
4011 *( Graphic3d_CStructure* )
4012 S1Iterator.Key () -> CStructure (),
4013 int ( S1Iterator.Key () -> DisplayPriority () )
4015 } // end if ( Index != 0 ) . . .
4017 } // end if ( Answer . . . )
4025 while ( S1Iterator.More () ) {
4027 Answer = AcceptDisplay ( S1Iterator.Key () );
4029 if ( Answer == Visual3d_TOA_COMPUTE ) {
4031 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
4035 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
4037 MyGraphicDriver -> EraseStructure (
4039 *( Graphic3d_CStructure* )
4040 S1Iterator.Key () -> CStructure ()
4042 MyGraphicDriver -> DisplayStructure (
4044 *( Graphic3d_CStructure* )
4045 MyCOMPUTEDSequence.Value ( Index ) -> CStructure (),
4046 int ( S1Iterator.Key () -> DisplayPriority () )
4049 Display ( S1Iterator.Key (), Aspect_TOU_WAIT );
4051 if ( S1Iterator.Key () -> IsHighlighted () ) {
4053 if ( !MyCOMPUTEDSequence.Value ( Index ) -> IsHighlighted () ) {
4055 MyCOMPUTEDSequence.Value ( Index ) -> SetHighlightColor (
4056 S1Iterator.Key () ->
4059 MyCOMPUTEDSequence.Value ( Index ) -> GraphicHighlight (
4068 Handle( Graphic3d_Structure ) AStructure = S1Iterator.Key ();
4070 Handle( Graphic3d_Structure ) TheStructure = AStructure -> Compute ( this );
4072 Handle( Graphic3d_Structure ) TheStructure;
4073 TColStd_Array2OfReal ATrsf ( 0, 3, 0, 3 );
4075 AStructure -> Transform ( ATrsf );
4079 TColStd_Array2OfReal Ident ( 0, 3, 0, 3 );
4080 Standard_Integer ii, jj;
4082 for ( ii = 0; ii <= 3; ++ii )
4084 for ( jj = 0; jj <= 3; ++jj )
4086 Ident ( ii, jj ) = ( ii == jj ? 1.0 : 0.0 );
4088 TheStructure = MyCOMPUTEDSequence.Value ( Index );
4090 TheStructure -> SetTransform ( Ident, Graphic3d_TOC_REPLACE );
4092 if ( AStructure->IsTransformed () )
4094 AStructure -> Compute ( this, ATrsf, TheStructure );
4098 AStructure -> Compute ( this, TheStructure );
4102 if ( AStructure -> IsTransformed () )
4104 TheStructure = AStructure -> Compute ( this, ATrsf );
4108 TheStructure = AStructure -> Compute ( this );
4112 TheStructure -> SetHLRValidation ( Standard_True );
4114 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
4116 Standard_Boolean ComputeWireframe =
4117 ( ( ViewType == Visual3d_TOV_WIREFRAME ) &&
4118 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_SHADING )
4121 Standard_Boolean ComputeShading =
4122 ( ( ViewType == Visual3d_TOV_SHADING ) &&
4123 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_WIREFRAME )
4126 if ( ComputeWireframe ) TheStructure -> SetVisual ( Graphic3d_TOS_WIREFRAME );
4127 if ( ComputeShading ) TheStructure -> SetVisual ( Graphic3d_TOS_SHADING );
4129 if ( S1Iterator.Key () -> IsHighlighted () ) {
4131 TheStructure -> SetHighlightColor (
4132 S1Iterator.Key () -> HighlightColor ()
4134 TheStructure -> GraphicHighlight ( Aspect_TOHM_COLOR );
4138 Standard_Integer Result = 0;
4139 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
4140 StructId = S1Iterator.Key () -> Identification ();
4142 for ( i = 1; i <= Length && Result == 0; ++i )
4144 if ( MyTOCOMPUTESequence.Value ( i ) -> Identification () == StructId )
4150 MyCOMPUTEDSequence.ChangeValue ( Result ) = TheStructure;
4154 MyTOCOMPUTESequence.Append ( S1Iterator.Key () );
4155 MyCOMPUTEDSequence.Append ( TheStructure );
4159 MyGraphicDriver -> EraseStructure (
4161 *( Graphic3d_CStructure* )
4162 S1Iterator.Key () -> CStructure ()
4164 MyGraphicDriver -> DisplayStructure (
4166 *( Graphic3d_CStructure* )TheStructure -> CStructure (),
4167 int ( S1Iterator.Key () -> DisplayPriority () )
4177 if ( MyViewManager -> UpdateMode () == Aspect_TOU_ASAP ) Update ();
4181 } // end Visual3d_View :: SetComputedMode
4183 Standard_Boolean Visual3d_View :: ComputedMode () const {
4185 return ComputedModeIsActive;
4187 } // end Visual3d_View :: ComputedMode
4189 void Visual3d_View :: SetBackFacingModel (
4190 const Visual3d_TypeOfBackfacingModel aModel
4195 case Visual3d_TOBM_AUTOMATIC:
4196 MyCView.Backfacing = 0;
4199 case Visual3d_TOBM_FORCE:
4200 MyCView.Backfacing = 1;
4203 case Visual3d_TOBM_DISABLE:
4204 MyCView.Backfacing = -1;
4209 MyGraphicDriver -> SetBackFacingModel ( MyCView );
4211 } // end Visual3d_View :: SetBackFacingModel
4213 Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const {
4215 switch ( MyCView.Backfacing ) {
4218 return Visual3d_TOBM_AUTOMATIC;
4221 return Visual3d_TOBM_FORCE;
4225 return Visual3d_TOBM_DISABLE;
4227 } // end Visual3d_View :: BackFacingModel
4230 void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const
4233 MyGraphicDriver->SetDepthTestEnabled( MyCView, enable );
4237 Standard_Boolean Visual3d_View::IsDepthTestEnabled() const
4240 return MyGraphicDriver->IsDepthTestEnabled( MyCView );
4242 return Standard_True;
4246 void Visual3d_View::ReadDepths(const Standard_Integer x,
4247 const Standard_Integer y,
4248 const Standard_Integer width,
4249 const Standard_Integer height,
4250 const Standard_Address buffer) const
4252 MyGraphicDriver->ReadDepths( MyCView, x, y, width, height, buffer );
4255 Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth,
4256 const Standard_Integer theHeight)
4258 return MyGraphicDriver->FBOCreate( MyCView, theWidth, theHeight );
4261 void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr)
4263 MyGraphicDriver->FBORelease( MyCView, theFBOPtr );
4266 void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr,
4267 Standard_Integer& theWidth, Standard_Integer& theHeight,
4268 Standard_Integer& theWidthMax, Standard_Integer& theHeightMax)
4270 MyGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr,
4271 theWidth, theHeight,
4272 theWidthMax, theHeightMax );
4275 void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr,
4276 const Standard_Integer theWidth, const Standard_Integer theHeight)
4278 MyGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr,
4279 theWidth, theHeight );
4282 Standard_Boolean Visual3d_View::BufferDump (Image_CRawBufferData& theBuffer)
4284 return MyGraphicDriver->BufferDump( MyCView, theBuffer);
4287 void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
4290 MyGraphicDriver->SetGLLightEnabled( MyCView, enable );
4295 Standard_Boolean Visual3d_View::IsGLLightEnabled() const
4298 return MyGraphicDriver->IsGLLightEnabled( MyCView );
4300 return Standard_True;
4304 void Visual3d_View::Export( const Standard_CString FileName,
4305 const Graphic3d_ExportFormat Format,
4306 const Graphic3d_SortType aSortType,
4307 const Standard_Real Precision,
4308 const Standard_Address ProgressBarFunc,
4309 const Standard_Address ProgressObject ) const
4311 Handle( Visual3d_Layer ) AnUnderLayer = MyViewManager->UnderLayer(),
4312 AnOverLayer = MyViewManager->OverLayer();
4314 Aspect_CLayer2d OverCLayer;
4315 Aspect_CLayer2d UnderCLayer;
4316 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
4318 if( !AnOverLayer.IsNull() )
4319 OverCLayer = AnOverLayer->CLayer();
4320 if( !AnUnderLayer.IsNull() )
4321 UnderCLayer = AnUnderLayer->CLayer();
4323 Standard_Integer W, H;
4324 Window()->Size( W, H );
4326 MyGraphicDriver->Export( FileName, Format, aSortType, W, H, MyCView, UnderCLayer, OverCLayer,
4327 Precision, ProgressBarFunc, ProgressObject );