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.ptrUnderLayer = 0;
282 MyCView.ptrOverLayer = 0;
283 MyCView.GContext = 0;
284 MyCView.GDisplayCB = 0;
285 MyCView.GClientData = 0;
287 Handle(Aspect_GraphicDriver) agd =
288 (MyViewManager->GraphicDevice ())->GraphicDriver ();
290 MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
294 Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager, const Visual3d_ViewOrientation& VO, const Visual3d_ViewMapping& VM, const Visual3d_ContextView& CTX):
295 MyTransformation (0, 3, 0, 3),
296 MyMatrixOfMapping (0, 3, 0, 3),
297 MyMatrixOfOrientation (0, 3, 0, 3),
298 MyTOCOMPUTESequence (),
299 MyCOMPUTEDSequence (),
300 MyDisplayedStructure ()
302 Standard_Integer i, j;
305 MyPtrViewManager = AManager.operator->();
307 MyPtrViewManager = (void *) AManager.operator->();
310 MyViewOrientation = VO;
313 MyViewOrientationReset = VO;
314 MyViewMappingReset = VM;
316 memset (&MyCView, 0, sizeof(MyCView));
317 MyCView.ViewId = int (AManager->Identification (this));
319 MyCView.IsDeleted = 0;
322 MyCView.DefWindow.IsDefined = 0;
324 MyCView.Context.NbActiveLight = 0;
325 MyCView.Context.NbActivePlane = 0;
327 MyCView.Context.ActivePlane = NULL;
332 if (i == j) MyTransformation (i, j) = 1.0;
333 else MyTransformation (i, j) = 0.0;
335 Standard_Real X, Y, Z;
337 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
338 MyCView.Orientation.ViewReferencePoint.x = float (X);
339 MyCView.Orientation.ViewReferencePoint.y = float (Y);
340 MyCView.Orientation.ViewReferencePoint.z = float (Z);
341 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
342 MyCView.Orientation.ViewReferencePlane.x = float (X);
343 MyCView.Orientation.ViewReferencePlane.y = float (Y);
344 MyCView.Orientation.ViewReferencePlane.z = float (Z);
345 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
346 MyCView.Orientation.ViewReferenceUp.x = float (X);
347 MyCView.Orientation.ViewReferenceUp.y = float (Y);
348 MyCView.Orientation.ViewReferenceUp.z = float (Z);
350 Standard_Real Sx, Sy, Sz;
352 MyViewOrientation.AxialScale(Sx, Sy, Sz);
353 MyCView.Orientation.ViewScaleX = float (Sx);
354 MyCView.Orientation.ViewScaleY = float (Sy);
355 MyCView.Orientation.ViewScaleZ = float (Sz);
357 // NKV : 23/07/07 - Define custom MODELVIEW matrix
358 if (MyViewOrientation.IsCustomMatrix()) {
359 MyCView.Orientation.IsCustomMatrix = 1;
360 for ( i = 0; i < 4; i++)
361 for ( j = 0; j < 4; j++)
362 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
365 MyCView.Orientation.IsCustomMatrix = 0;
366 memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
367 MyCView.Orientation.ModelViewMatrix[0][0] =
368 MyCView.Orientation.ModelViewMatrix[1][1] =
369 MyCView.Orientation.ModelViewMatrix[2][2] =
370 MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
374 Standard_Real um, vm, uM, vM;
376 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
377 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
378 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
379 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
380 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
381 MyCView.Mapping.ViewPlaneDistance =
382 float (MyViewMapping.ViewPlaneDistance ());
383 MyCView.Mapping.BackPlaneDistance =
384 float (MyViewMapping.BackPlaneDistance ());
385 MyCView.Mapping.FrontPlaneDistance =
386 float (MyViewMapping.FrontPlaneDistance ());
387 MyViewMapping.WindowLimit (um, vm, uM, vM);
388 MyCView.Mapping.WindowLimit.um = float (um);
389 MyCView.Mapping.WindowLimit.vm = float (vm);
390 MyCView.Mapping.WindowLimit.uM = float (uM);
391 MyCView.Mapping.WindowLimit.vM = float (vM);
393 // NKV : 23/07/07 - Define custom MODELVIEW matrix
394 if (MyViewMapping.IsCustomMatrix()) {
395 MyCView.Mapping.IsCustomMatrix = 1;
396 for ( i = 0; i < 4; i++)
397 for ( j = 0; j < 4; j++)
398 MyCView.Mapping.ProjectionMatrix[i][j] = MyViewMapping.MyProjectionMatrix->Value(i,j);
401 MyCView.Mapping.IsCustomMatrix = 0;
402 memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
403 MyCView.Mapping.ProjectionMatrix[0][0] =
404 MyCView.Mapping.ProjectionMatrix[1][1] =
405 MyCView.Mapping.ProjectionMatrix[2][2] =
406 MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
410 MyCView.Context.ZBufferActivity = -1;
412 MyMatOfMapIsModified = Standard_True;
413 MyMatOfOriIsModified = Standard_True;
414 MyMatOfMapIsEvaluated = Standard_False;
415 MyMatOfOriIsEvaluated = Standard_False;
417 AnimationModeIsActive = Standard_False;
418 MyCView.IsDegenerates = 0;
419 MyCView.IsDegeneratesPrev = 0;
420 ComputedModeIsActive = Standard_False;
423 MyCView.ptrUnderLayer = 0;
424 MyCView.ptrOverLayer = 0;
425 MyCView.GContext = 0;
426 MyCView.GDisplayCB = 0;
427 MyCView.GClientData = 0;
429 Handle(Aspect_GraphicDriver) agd =
430 (MyViewManager->GraphicDevice ())->GraphicDriver ();
432 MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
440 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow,
441 const Aspect_RenderingContext AContext,
442 const Aspect_GraphicCallbackProc& ADisplayCB,
443 const Standard_Address AClientData)
445 if (IsDeleted ()) return;
448 Visual3d_ViewDefinitionError::Raise ("Window already defined");
450 MyCView.GContext = AContext;
451 MyCView.GDisplayCB = ADisplayCB;
452 MyCView.GClientData = AClientData;
457 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow) {
459 if (IsDeleted ()) return;
462 Visual3d_ViewDefinitionError::Raise ("Window already defined");
465 MyCView.WsId = MyCView.ViewId;
466 MyCView.DefWindow.IsDefined = 1;
468 const Handle(Xw_Window) theWindow = *(Handle(Xw_Window) *) &AWindow;
469 MyCView.DefWindow.XWindow = theWindow->XWindow ();
471 MyCView.DefWindow.XParentWindow = theWindow->XParentWindow ();
475 const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AWindow;
476 MyCView.DefWindow.XWindow = ( HWND )(theWindow->HWindow());
478 MyCView.DefWindow.XParentWindow = ( HWND )(theWindow->HParentWindow());
480 wd = ( WNT_WindowData* )GetWindowLongPtr (( HWND )(theWindow->HWindow()), GWLP_USERDATA);
481 wd -> WNT_WDriver_Ptr = ( void* )this;
482 wd -> WNT_VMgr = ( void* )MyPtrViewManager;
485 Standard_Integer Width, Height;
486 AWindow->Size (Width, Height);
488 MyCView.DefWindow.dx = float( Width );
489 MyCView.DefWindow.dy = float( Height );
491 Standard_Real R, G, B;
492 MyBackground = MyWindow->Background ();
493 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
494 MyCView.DefWindow.Background.r = float (R);
495 MyCView.DefWindow.Background.g = float (G);
496 MyCView.DefWindow.Background.b = float (B);
499 if (! MyGraphicDriver->View (MyCView))
500 Visual3d_ViewDefinitionError::Raise ("Association failed");
502 MyGradientBackground = MyWindow->GradientBackground();
503 SetGradientBackground(MyGradientBackground,1);
505 Standard_Boolean AWait = Standard_False; // => immediate update
506 MyGraphicDriver->SetVisualisation (MyCView);
507 MyGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn ());
508 MyGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn ());
509 MyGraphicDriver->ClipLimit (MyCView, AWait);
510 MyGraphicDriver->Environment(MyCView);
512 // Update planses of model clipping
515 // Update light sources
519 * Association view-window does not cause the display
520 * of structures that can be displayed in the new view.
521 * In fact, association view-window is done, but the
522 * display is produced only if the view is activated (Activate).
529 Handle(Aspect_Window) Visual3d_View::Window () const {
532 Visual3d_ViewDefinitionError::Raise ("Window not defined");
538 Standard_Boolean Visual3d_View::IsDefined () const {
540 if (MyCView.DefWindow.IsDefined)
541 return (Standard_True);
543 return (Standard_False);
547 Standard_Boolean Visual3d_View::IsDeleted () const {
549 if (MyCView.IsDeleted)
550 return (Standard_True);
552 return (Standard_False);
556 void Visual3d_View::Destroy () {
559 cout << "Visual3d_View::Destroy (" << Identification () << ")\n";
562 // Since MyPtrViewManager can be already distroyed,
563 // avoid attempts to access it in SetBackground()
564 MyPtrViewManager = 0;
569 void Visual3d_View::Remove () {
572 cout << "Visual3d_View::Remove (" << Identification () << ")" << endl;
575 if (IsDeleted ()) return;
576 if (! IsDefined ()) return;
578 MyTOCOMPUTESequence.Clear ();
579 MyCOMPUTEDSequence.Clear ();
580 MyDisplayedStructure.Clear ();
582 Quantity_Color BlackColor (0.0, 0.0, 0.0, Quantity_TOC_RGB);
583 Aspect_Background BlackBackground (BlackColor);
584 SetBackground (BlackBackground);
586 Aspect_GradientBackground BlackGradBackground;
587 SetGradientBackground (BlackGradBackground,0);
589 if (MyPtrViewManager)
590 MyPtrViewManager->UnIdentification( MyCView.ViewId );
592 MyGraphicDriver->RemoveView (MyCView);
595 MyCView.IsDeleted = 1;
596 MyCView.DefWindow.IsDefined = 0;
598 MyMatOfMapIsModified = Standard_True;
599 MyMatOfOriIsModified = Standard_True;
600 MyMatOfMapIsEvaluated = Standard_False;
601 MyMatOfOriIsEvaluated = Standard_False;
607 void Visual3d_View::Resized () {
609 if (IsDeleted ()) return;
612 Visual3d_ViewDefinitionError::Raise ("Window not defined");
613 MyWindow->DoResize() ;
618 void Visual3d_View::SetRatio () {
620 if (IsDeleted ()) return;
622 Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode ();
623 MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
625 Standard_Real Umin, Vmin, Umax, Vmax;
626 Standard_Integer Dxw, Dyw;
627 Standard_Real Dxv, Dyv;
628 Standard_Real Xc, Yc;
632 MyWindow->Size (Dxw, Dyw);
633 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
634 Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
635 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
636 if( Dxw > 0 && Dyw > 0 ) Rap = (Standard_Real)Dyw/(Standard_Real)Dxw ;
666 Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
667 Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
669 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
671 // Update before SetViewMapping.
673 MyCView.DefWindow.dx = float( Dxw );
674 MyCView.DefWindow.dy = float( Dyw );
676 SetViewMapping (MyViewMapping);
677 // SetViewMappingDefault ();
678 // FMN+ Update Ratio for MyViewMappingReset
680 MyViewMappingReset.WindowLimit(Umin,Vmin,Umax,Vmax) ;
681 Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
682 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
711 Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
712 Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
714 MyViewMappingReset.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
716 // FMN- Update Ratio for MyViewMappingReset
718 MyGraphicDriver->RatioWindow (MyCView);
721 // Force recalculation of 2 matrices.
723 // The current view can help to reconstruct a copied view
724 // that is itself. Owing to SetWindow and SetRatio the
725 // recalculation of matrices of this new view is imposed.
726 MyMatOfMapIsEvaluated = Standard_False;
727 MyMatOfOriIsEvaluated = Standard_False;
729 MyViewManager->SetUpdateMode (UpdateMode);
730 if (UpdateMode == Aspect_TOU_ASAP) Update ();
734 void Visual3d_View::UpdateLights () {
736 Standard_Integer i, j;
737 CALL_DEF_LIGHT *lights=NULL;
740 if( MyContext.Model() == Visual3d_TOM_NONE ) {
741 // Activates only a white ambient light
742 MyCView.Context.NbActiveLight = 1;
743 lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
744 MyCView.Context.ActiveLight = lights;
746 lights[0].WsId = MyCView.ViewId;
747 lights[0].ViewId = MyCView.ViewId;
748 lights[0].LightType = int (Visual3d_TOLS_AMBIENT);
749 lights[0].Active = 1;
750 lights[0].LightId = 0;
751 lights[0].Headlight = 0;
752 lights[0].Color.r = lights[0].Color.g = lights[0].Color.b = 1.;
755 i = MyContext.NumberOfActivatedLights ();
756 j = MyGraphicDriver->InquireLightLimit ();
757 MyCView.Context.NbActiveLight = (i > j ? j : i);
759 if (MyCView.Context.NbActiveLight > 0) {
761 // Dynamic Allocation
762 lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
764 MyCView.Context.ActiveLight = lights;
766 Standard_Real X, Y, Z;
768 Standard_Real LightConcentration;
769 Standard_Real LightAttenuation1;
770 Standard_Real LightAttenuation2;
771 Standard_Real LightAngle;
772 Quantity_Color LightColor;
773 Graphic3d_Vertex LightPosition;
774 Graphic3d_Vector LightDirection;
775 Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT;
777 // Parcing of light sources
778 for (j=0; j<MyCView.Context.NbActiveLight; j++) {
779 LightType = (MyContext.ActivatedLight (j+1))->LightType ();
781 lights[j].WsId = MyCView.ViewId;
782 lights[j].ViewId = MyCView.ViewId;
784 lights[j].LightType = int (LightType);
785 lights[j].Active = 1;
787 int ((MyContext.ActivatedLight (j+1))->Identification ());
788 lights[j].Headlight = (MyContext.ActivatedLight (j+1))->Headlight ()? 1:0;
792 case Visual3d_TOLS_AMBIENT :
793 (MyContext.ActivatedLight (j+1))->Values (
798 case Visual3d_TOLS_POSITIONAL :
799 (MyContext.ActivatedLight (j+1))->Values (
807 case Visual3d_TOLS_DIRECTIONAL :
808 (MyContext.ActivatedLight (j+1))->Values (
814 case Visual3d_TOLS_SPOT :
815 (MyContext.ActivatedLight (j+1))->Values (
828 lights[j].Color.r = float (LightColor.Red ());
829 lights[j].Color.g = float (LightColor.Green ());
830 lights[j].Color.b = float (LightColor.Blue ());
832 if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
833 (LightType == Visual3d_TOLS_SPOT) ) {
834 LightPosition.Coord (X, Y, Z);
835 lights[j].Position.x = float (X);
836 lights[j].Position.y = float (Y);
837 lights[j].Position.z = float (Z);
840 if ( (LightType == Visual3d_TOLS_DIRECTIONAL) ||
841 (LightType == Visual3d_TOLS_SPOT) ) {
842 LightDirection.Coord (X, Y, Z);
843 lights[j].Direction.x = float (X);
844 lights[j].Direction.y = float (Y);
845 lights[j].Direction.z = float (Z);
848 if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
849 (LightType == Visual3d_TOLS_SPOT) ) {
850 lights[j].Attenuation[0] =
851 float (LightAttenuation1);
852 lights[j].Attenuation[1] =
853 float (LightAttenuation2);
856 if (LightType == Visual3d_TOLS_SPOT) {
857 lights[j].Concentration =
858 float (LightConcentration);
868 // management of light sources
871 MyGraphicDriver->SetLight (MyCView);
873 // Dynamic allocation
874 if (MyCView.Context.NbActiveLight > 0) delete [] lights;
878 void Visual3d_View::UpdatePlanes () {
880 Standard_Integer i, j;
881 CALL_DEF_PLANE *planes=NULL;
883 i = MyContext.NumberOfActivatedClipPlanes ();
884 j = MyGraphicDriver->InquirePlaneLimit ();
885 MyCView.Context.NbActivePlane = (i > j ? j : i);
887 if (MyCView.Context.NbActivePlane > 0) {
889 // Dynamic Allocation
890 #ifdef GER61454 //Keep the plane address for the next Update !
891 if( !MyCView.Context.ActivePlane )
892 MyCView.Context.ActivePlane = new CALL_DEF_PLANE [j];
893 planes = MyCView.Context.ActivePlane;
895 planes = new CALL_DEF_PLANE [MyCView.Context.NbActivePlane];
897 MyCView.Context.ActivePlane = planes;
899 Standard_Real A, B, C, D;
901 // Parcing of clipping planes
902 for (j=0; j<MyCView.Context.NbActivePlane; j++) {
904 planes[j].WsId = MyCView.ViewId;
905 planes[j].ViewId = MyCView.ViewId;
907 planes[j].Active = 1;
909 int ((MyContext.ActivatedClipPlane (j+1))->Identification ());
911 (MyContext.ActivatedClipPlane (j+1))->Plane (A, B, C, D);
912 planes[j].CoefA = float (A);
913 planes[j].CoefB = float (B);
914 planes[j].CoefC = float (C);
915 planes[j].CoefD = float (D);
920 // Management of planes of clipping model
923 MyGraphicDriver->SetPlane (MyCView);
925 // Dynamic allocation
927 if ( MyCView.Context.ActivePlane && (MyCView.Context.NbActivePlane == 0)
929 delete [] MyCView.Context.ActivePlane;
930 MyCView.Context.ActivePlane = NULL;
933 if (MyCView.Context.NbActivePlane > 0) delete [] planes;
938 void Visual3d_View::SetBackground (const Aspect_Background& ABack) {
940 if (IsDeleted ()) return;
943 Visual3d_ViewDefinitionError::Raise ("Window not defined");
945 // At this level, only GL can update the background.
946 // It is not necessary to call MyWindow->SetBackground (ABack); as
947 // this method starts update of window background by X
948 // (if the windowing is X)
950 Standard_Real R, G, B;
951 MyBackground = ABack;
952 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
953 MyCView.DefWindow.Background.r = float (R);
954 MyCView.DefWindow.Background.g = float (G);
955 MyCView.DefWindow.Background.b = float (B);
957 MyGraphicDriver->Background (MyCView);
959 if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
964 void Visual3d_View::SetGradientBackground(const Aspect_GradientBackground& ABack, const Standard_Boolean update)
967 if (IsDeleted ()) return;
970 Visual3d_ViewDefinitionError::Raise ("Window not defined");
972 MyGradientBackground = ABack;
973 Quantity_Color aCol1,aCol2;
974 MyGradientBackground.Colors(aCol1,aCol2);
975 MyGraphicDriver->GradientBackground(MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod());
979 else if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
983 void Visual3d_View::SetBackgroundImage( const Standard_CString FileName,
984 const Aspect_FillMethod FillStyle,
985 const Standard_Boolean update )
991 Visual3d_ViewDefinitionError::Raise ("Window not defined");
993 MyGraphicDriver->BackgroundImage( FileName, MyCView, FillStyle );
997 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1002 void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
1003 const Standard_Boolean update )
1009 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1011 MyGraphicDriver->SetBgImageStyle( MyCView, FillStyle );
1015 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1020 Aspect_Background Visual3d_View::Background () const {
1022 return (MyBackground);
1026 void Visual3d_View::SetBgGradientStyle( const Aspect_GradientFillMethod FillStyle,
1027 const Standard_Boolean update )
1032 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1034 MyGraphicDriver->SetBgGradientStyle( MyCView, FillStyle );
1038 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
1043 Aspect_GradientBackground Visual3d_View::GradientBackground () const {
1045 return MyGradientBackground;
1049 void Visual3d_View::SetTransform (const TColStd_Array2OfReal& AMatrix) {
1051 if (IsDeleted ()) return;
1053 Standard_Integer lr, ur, lc, uc;
1054 Standard_Integer i, j;
1056 // Assign the new transformation in an array [0..3][0..3]
1057 // Avoid problems if the has defined a matrice [1..4][1..4]
1058 // ou [3..6][-1..2] !!
1059 lr = AMatrix.LowerRow ();
1060 ur = AMatrix.UpperRow ();
1061 lc = AMatrix.LowerCol ();
1062 uc = AMatrix.UpperCol ();
1064 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
1065 Visual3d_TransformError::Raise ("Transform : not a 4x4 matrix");
1067 for (i=0; i<=3; i++)
1068 for (j=0; j<=3; j++)
1069 MyTransformation (i, j) = AMatrix (lr + i, lc + j);
1071 Graphic3d_Vector VPN;
1072 Graphic3d_Vertex VRP;
1073 Graphic3d_Vector VUP;
1074 Standard_Real Sx, Sy, Sz;
1076 Visual3d_ViewOrientation NewViewOrientation;
1078 VPN = MyViewOrientation.ViewReferencePlane ();
1079 VRP = MyViewOrientation.ViewReferencePoint ();
1080 VUP = MyViewOrientation.ViewReferenceUp ();
1081 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1083 NewViewOrientation.SetViewReferencePlane
1084 (Graphic3d_Structure::Transforms (Transform (), VPN));
1086 NewViewOrientation.SetViewReferencePoint
1087 (Graphic3d_Structure::Transforms (Transform (), VRP));
1089 NewViewOrientation.SetViewReferenceUp
1090 (Graphic3d_Structure::Transforms (Transform (), VUP));
1091 NewViewOrientation.SetAxialScale(Sx, Sy, Sz);
1093 SetViewOrientation (NewViewOrientation);
1095 MyMatOfOriIsModified = Standard_True;
1096 MyMatOfOriIsEvaluated = Standard_False;
1100 const TColStd_Array2OfReal& Visual3d_View::Transform () const {
1102 return (MyTransformation);
1106 void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
1108 if (IsDeleted ()) return;
1110 MyViewOrientation = VO;
1112 Standard_Real X, Y, Z;
1114 // Tests on modification of parameters.
1115 Standard_Boolean VUPIsModified = Standard_False;
1116 Standard_Boolean VRPIsModified = Standard_False;
1117 Standard_Boolean VRUIsModified = Standard_False;
1118 Standard_Boolean ScaleIsModified = Standard_False;
1119 Standard_Boolean CustomIsModified = Standard_False;
1121 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
1123 MyCView.Orientation.ViewReferencePoint.x != float (X)
1124 || MyCView.Orientation.ViewReferencePoint.y != float (Y)
1125 || MyCView.Orientation.ViewReferencePoint.z != float (Z);
1126 MyCView.Orientation.ViewReferencePoint.x = float (X);
1127 MyCView.Orientation.ViewReferencePoint.y = float (Y);
1128 MyCView.Orientation.ViewReferencePoint.z = float (Z);
1130 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
1132 MyCView.Orientation.ViewReferencePlane.x != float (X)
1133 || MyCView.Orientation.ViewReferencePlane.y != float (Y)
1134 || MyCView.Orientation.ViewReferencePlane.z != float (Z);
1135 MyCView.Orientation.ViewReferencePlane.x = float (X);
1136 MyCView.Orientation.ViewReferencePlane.y = float (Y);
1137 MyCView.Orientation.ViewReferencePlane.z = float (Z);
1139 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
1141 MyCView.Orientation.ViewReferenceUp.x != float (X)
1142 || MyCView.Orientation.ViewReferenceUp.y != float (Y)
1143 || MyCView.Orientation.ViewReferenceUp.z != float (Z);
1144 MyCView.Orientation.ViewReferenceUp.x = float (X);
1145 MyCView.Orientation.ViewReferenceUp.y = float (Y);
1146 MyCView.Orientation.ViewReferenceUp.z = float (Z);
1148 Standard_Real Sx, Sy, Sz;
1150 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1152 MyCView.Orientation.ViewScaleX != float (X)
1153 || MyCView.Orientation.ViewScaleY != float (Y)
1154 || MyCView.Orientation.ViewScaleZ != float (Z);
1155 MyCView.Orientation.ViewScaleX = float (Sx);
1156 MyCView.Orientation.ViewScaleY = float (Sy);
1157 MyCView.Orientation.ViewScaleZ = float (Sz);
1160 MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
1161 MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
1162 if ( MyViewOrientation.IsCustomMatrix() ) {
1163 Standard_Integer i, j;
1164 for (i = 0; i < 4; i++)
1165 for (j = 0; j < 4; j++) {
1166 if (!CustomIsModified) CustomIsModified =
1167 MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
1168 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
1173 cout << "Visual3d_View::SetViewOrientation\n";
1174 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
1175 cout << "VUPIsModified : " << VUPIsModified
1176 << ", VRPIsModified : " << VRPIsModified
1177 << ", VRUIsModified : " << VRUIsModified
1178 << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
1180 cout << "no modification\n" << flush;
1183 // restart if one of parameters is modified
1184 if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified) {
1186 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1187 MyMatOfOriIsModified = Standard_True;
1188 MyMatOfOriIsEvaluated = Standard_False;
1191 if (! IsDefined ()) return;
1193 Standard_Boolean AWait = Standard_False; // => immediate update
1194 MyGraphicDriver->ViewOrientation (MyCView, AWait);
1198 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1203 Visual3d_ViewOrientation Visual3d_View::ViewOrientation () const {
1205 return (MyViewOrientation);
1209 Visual3d_ViewOrientation Visual3d_View::ViewOrientationDefault () const {
1211 return (MyViewOrientationReset);
1215 void Visual3d_View::SetViewOrientationDefault () {
1217 MyViewOrientationReset.Assign (MyViewOrientation);
1221 void Visual3d_View::ViewOrientationReset () {
1223 if (IsDeleted ()) return;
1225 MyViewOrientation = MyViewOrientationReset;
1227 Standard_Real X, Y, Z;
1229 // Tests on modification of parameters.
1230 Standard_Boolean VUPIsModified = Standard_False;
1231 Standard_Boolean VRPIsModified = Standard_False;
1232 Standard_Boolean VRUIsModified = Standard_False;
1233 Standard_Boolean ScaleIsModified = Standard_False;
1234 Standard_Boolean CustomIsModified = Standard_False;
1236 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
1238 MyCView.Orientation.ViewReferencePoint.x != float (X)
1239 || MyCView.Orientation.ViewReferencePoint.y != float (Y)
1240 || MyCView.Orientation.ViewReferencePoint.y != float (Y);
1241 MyCView.Orientation.ViewReferencePoint.x = float (X);
1242 MyCView.Orientation.ViewReferencePoint.y = float (Y);
1243 MyCView.Orientation.ViewReferencePoint.z = float (Z);
1245 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
1247 MyCView.Orientation.ViewReferencePlane.x != float (X)
1248 || MyCView.Orientation.ViewReferencePlane.y != float (Y)
1249 || MyCView.Orientation.ViewReferencePlane.y != float (Y);
1250 MyCView.Orientation.ViewReferencePlane.x = float (X);
1251 MyCView.Orientation.ViewReferencePlane.y = float (Y);
1252 MyCView.Orientation.ViewReferencePlane.z = float (Z);
1254 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
1256 MyCView.Orientation.ViewReferenceUp.x != float (X)
1257 || MyCView.Orientation.ViewReferenceUp.y != float (Y)
1258 || MyCView.Orientation.ViewReferenceUp.y != float (Y);
1259 MyCView.Orientation.ViewReferenceUp.x = float (X);
1260 MyCView.Orientation.ViewReferenceUp.y = float (Y);
1261 MyCView.Orientation.ViewReferenceUp.z = float (Z);
1263 Standard_Real Sx, Sy, Sz;
1265 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1267 MyCView.Orientation.ViewScaleX != float (X)
1268 || MyCView.Orientation.ViewScaleY != float (Y)
1269 || MyCView.Orientation.ViewScaleZ != float (Z);
1270 MyCView.Orientation.ViewScaleX = float (Sx);
1271 MyCView.Orientation.ViewScaleY = float (Sy);
1272 MyCView.Orientation.ViewScaleZ = float (Sz);
1275 MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
1276 MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
1277 if ( MyViewOrientation.IsCustomMatrix() ) {
1278 Standard_Integer i, j;
1279 for (i = 0; i < 4; i++)
1280 for (j = 0; j < 4; j++) {
1281 if (!CustomIsModified) CustomIsModified =
1282 MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
1283 MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
1288 cout << "Visual3d_View::ViewOrientationReset\n";
1289 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
1290 cout << "VUPIsModified : " << VUPIsModified
1291 << ", VRPIsModified : " << VRPIsModified
1292 << ", VRUIsModified : " << VRUIsModified
1293 << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
1295 cout << "no modification\n" << flush;
1298 // Restart if one of parameters is modified
1299 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1301 if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
1302 MyMatOfOriIsModified = Standard_True;
1303 MyMatOfOriIsEvaluated = Standard_False;
1306 if (! IsDefined ()) return;
1308 Standard_Boolean AWait = Standard_False; // => immediate update
1309 MyGraphicDriver->ViewOrientation (MyCView, AWait);
1313 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1318 void Visual3d_View::SetViewMapping (const Visual3d_ViewMapping& VM) {
1320 if (IsDeleted ()) return;
1322 Visual3d_TypeOfProjection OldType = MyViewMapping.Projection ();
1323 Visual3d_TypeOfProjection NewType = VM.Projection ();
1327 Standard_Real X, Y, Z;
1328 Standard_Real um, vm, uM, vM;
1330 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
1331 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
1332 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
1333 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
1334 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
1335 MyCView.Mapping.ViewPlaneDistance =
1336 float (MyViewMapping.ViewPlaneDistance ());
1337 MyCView.Mapping.BackPlaneDistance =
1338 float (MyViewMapping.BackPlaneDistance ());
1339 MyCView.Mapping.FrontPlaneDistance =
1340 float (MyViewMapping.FrontPlaneDistance ());
1341 MyViewMapping.WindowLimit (um, vm, uM, vM);
1342 MyCView.Mapping.WindowLimit.um = float (um);
1343 MyCView.Mapping.WindowLimit.vm = float (vm);
1344 MyCView.Mapping.WindowLimit.uM = float (uM);
1345 MyCView.Mapping.WindowLimit.vM = float (vM);
1347 MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
1348 if (MyViewMapping.IsCustomMatrix()) {
1349 Standard_Integer i, j;
1350 for (i = 0; i < 4; i++)
1351 for (j = 0; j < 4; j++)
1352 MyCView.Mapping.ProjectionMatrix[i][j] =
1353 MyViewMapping.MyProjectionMatrix->Value(i,j);
1356 MyMatOfMapIsModified = Standard_True;
1357 MyMatOfMapIsEvaluated = Standard_False;
1359 if (! IsDefined ()) return;
1361 Standard_Boolean AWait = Standard_False; // => immediate update
1362 MyGraphicDriver->ViewMapping (MyCView, AWait);
1364 // Passage Parallele/Perspective
1365 if (OldType != NewType)
1368 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1372 Visual3d_ViewMapping Visual3d_View::ViewMapping () const {
1374 return (MyViewMapping);
1378 Visual3d_ViewMapping Visual3d_View::ViewMappingDefault () const {
1380 return (MyViewMappingReset);
1384 void Visual3d_View::SetViewMappingDefault () {
1386 MyViewMappingReset.Assign (MyViewMapping);
1390 void Visual3d_View::ViewMappingReset () {
1392 if (IsDeleted ()) return;
1394 MyViewMapping = MyViewMappingReset;
1396 Standard_Real X, Y, Z;
1397 Standard_Real um, vm, uM, vM;
1399 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
1400 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
1401 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
1402 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
1403 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
1404 MyCView.Mapping.ViewPlaneDistance =
1405 float (MyViewMapping.ViewPlaneDistance ());
1406 MyCView.Mapping.BackPlaneDistance =
1407 float (MyViewMapping.BackPlaneDistance ());
1408 MyCView.Mapping.FrontPlaneDistance =
1409 float (MyViewMapping.FrontPlaneDistance ());
1410 MyViewMapping.WindowLimit (um, vm, uM, vM);
1411 MyCView.Mapping.WindowLimit.um = float (um);
1412 MyCView.Mapping.WindowLimit.vm = float (vm);
1413 MyCView.Mapping.WindowLimit.uM = float (uM);
1414 MyCView.Mapping.WindowLimit.vM = float (vM);
1416 MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
1417 if (MyViewMapping.IsCustomMatrix()) {
1418 Standard_Integer i, j;
1419 for (i = 0; i < 4; i++)
1420 for (j = 0; j < 4; j++)
1421 MyCView.Mapping.ProjectionMatrix[i][j] =
1422 MyViewMapping.MyProjectionMatrix->Value(i,j);
1425 MyMatOfMapIsModified = Standard_True;
1426 MyMatOfMapIsEvaluated = Standard_False;
1428 if (! IsDefined ()) return;
1430 Standard_Boolean AWait = Standard_False; // => immediate update
1431 MyGraphicDriver->ViewMapping (MyCView, AWait);
1433 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1437 void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
1439 if (IsDeleted ()) return;
1441 Visual3d_TypeOfVisualization OldVisualMode;
1442 Visual3d_TypeOfVisualization NewVisualMode;
1444 // To manage display only in case of
1445 // change of visualisation mode.
1446 OldVisualMode = MyContext.Visualization ();
1447 NewVisualMode = CTX.Visualization ();
1449 Visual3d_TypeOfModel OldModel;
1450 Visual3d_TypeOfModel NewModel;
1452 // To manage change of visualisation only in case
1453 // of change of mode of visualisation or of type of shading.
1454 OldModel = MyContext.Model ();
1455 NewModel = CTX.Model ();
1457 Standard_Boolean OldAliasingMode;
1458 Standard_Boolean NewAliasingMode;
1460 // To manage antialiasing only in case of change.
1461 OldAliasingMode = MyContext.AliasingIsOn ();
1462 NewAliasingMode = CTX.AliasingIsOn ();
1464 Standard_Boolean OldDepthCueingMode;
1465 Standard_Boolean NewDepthCueingMode;
1467 Standard_Real OldDepthCueingFrontPlane;
1468 Standard_Real NewDepthCueingFrontPlane;
1469 Standard_Real OldDepthCueingBackPlane;
1470 Standard_Real NewDepthCueingBackPlane;
1472 // To manage the depth cueing only in case of change.
1473 OldDepthCueingMode = MyContext.DepthCueingIsOn ();
1474 NewDepthCueingMode = CTX.DepthCueingIsOn ();
1476 OldDepthCueingFrontPlane = MyContext.DepthCueingFrontPlane ();
1477 NewDepthCueingFrontPlane = CTX.DepthCueingFrontPlane ();
1478 OldDepthCueingBackPlane = MyContext.DepthCueingBackPlane ();
1479 NewDepthCueingBackPlane = CTX.DepthCueingBackPlane ();
1481 Standard_Boolean OldFrontZClippingMode;
1482 Standard_Boolean NewFrontZClippingMode;
1483 Standard_Boolean OldBackZClippingMode;
1484 Standard_Boolean NewBackZClippingMode;
1486 Standard_Real OldZClippingFrontPlane;
1487 Standard_Real NewZClippingFrontPlane;
1488 Standard_Real OldZClippingBackPlane;
1489 Standard_Real NewZClippingBackPlane;
1491 // To manage the Zclipping only in case of change.
1492 OldFrontZClippingMode = MyContext.FrontZClippingIsOn ();
1493 NewFrontZClippingMode = CTX.FrontZClippingIsOn ();
1494 OldBackZClippingMode = MyContext.BackZClippingIsOn ();
1495 NewBackZClippingMode = CTX.BackZClippingIsOn ();
1497 OldZClippingFrontPlane = MyContext.ZClippingFrontPlane ();
1498 NewZClippingFrontPlane = CTX.ZClippingFrontPlane ();
1499 OldZClippingBackPlane = MyContext.ZClippingBackPlane ();
1500 NewZClippingBackPlane = CTX.ZClippingBackPlane ();
1502 Standard_Integer OldTexEnvId;
1503 Standard_Integer NewTexEnvId;
1504 Visual3d_TypeOfSurfaceDetail OldSurfaceDetail;
1505 Visual3d_TypeOfSurfaceDetail NewSurfaceDetail;
1507 Handle(Graphic3d_TextureEnv) TempTextureEnv1 = MyContext.TextureEnv();
1508 if (! TempTextureEnv1.IsNull()) OldTexEnvId = TempTextureEnv1->TextureId();
1509 else OldTexEnvId = -1;
1511 Handle(Graphic3d_TextureEnv) TempTextureEnv2 = CTX.TextureEnv();
1513 if (! TempTextureEnv2.IsNull()) NewTexEnvId = TempTextureEnv2->TextureId();
1514 else NewTexEnvId = -1;
1516 OldSurfaceDetail = MyContext.SurfaceDetail();
1517 NewSurfaceDetail = CTX.SurfaceDetail();
1523 Standard_Boolean AWait = Standard_False; // => immediate update
1525 // management of visualization modes and types of shading.
1526 if ((OldVisualMode != NewVisualMode) || (OldModel != NewModel))
1527 MyGraphicDriver->SetVisualisation (MyCView);
1529 // management of antialiasing.
1530 if (OldAliasingMode != NewAliasingMode)
1531 MyGraphicDriver->AntiAliasing (MyCView, NewAliasingMode);
1533 // management of depth_cueing.
1534 if ((OldDepthCueingMode != NewDepthCueingMode) ||
1535 (OldDepthCueingFrontPlane != NewDepthCueingFrontPlane) ||
1536 (OldDepthCueingBackPlane != NewDepthCueingBackPlane)) {
1538 if( NewDepthCueingMode &&
1539 (NewDepthCueingBackPlane >= NewDepthCueingFrontPlane) )
1540 Visual3d_DepthCueingDefinitionError::Raise
1541 ("Bad value for DepthCueingPlanes position");
1543 MyGraphicDriver->DepthCueing
1544 (MyCView, NewDepthCueingMode);
1547 // management of Zclipping
1548 if ((OldFrontZClippingMode != NewFrontZClippingMode) ||
1549 (OldBackZClippingMode != NewBackZClippingMode) ||
1550 (OldZClippingFrontPlane != NewZClippingFrontPlane) ||
1551 (OldZClippingBackPlane != NewZClippingBackPlane)) {
1553 if( NewBackZClippingMode && NewFrontZClippingMode &&
1554 (NewZClippingBackPlane >= NewZClippingFrontPlane) )
1555 Visual3d_ZClippingDefinitionError::Raise
1556 ("Bad value for ZClippingPlanes position");
1558 MyGraphicDriver->ClipLimit (MyCView, AWait);
1561 // management of textures
1562 if ( (OldTexEnvId != NewTexEnvId) ||
1563 (OldSurfaceDetail != NewSurfaceDetail) )
1564 MyGraphicDriver->Environment(MyCView);
1566 // Update of planes of model clipping
1569 // Update of light sources
1573 if (OldVisualMode != NewVisualMode) {
1576 * Change of context =>
1577 * Remove structures that cannot be displayed
1578 * in the new visualisation mode.
1579 * It is not necessary to warn ViewManager as
1580 * this structure should not disappear from
1581 * the list of structures displayed in it.
1583 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
1584 Visual3d_TypeOfAnswer Answer;
1586 Standard_Integer i = MyDisplayedStructure.Extent ();
1588 Graphic3d_SequenceOfStructure FooSequence;
1590 while (S1Iterator.More ()) {
1591 Answer = AcceptDisplay (S1Iterator.Key ());
1592 // If the structure can't be displayed in the
1593 // new context of the view, it is removed.
1594 if ((Answer == Visual3d_TOA_NO) ||
1595 (Answer == Visual3d_TOA_COMPUTE))
1596 //Erase (S1Iterator.Key (), Aspect_TOU_WAIT);
1597 FooSequence.Append (S1Iterator.Key ());
1599 // S1Iterator.Next () is located on the next structure
1603 Standard_Integer Length = FooSequence.Length ();
1604 // The stored structures are removed
1605 for (i=1; i<=Length; i++)
1606 Erase (FooSequence.Value (i), Aspect_TOU_WAIT);
1607 if (Length != 0) FooSequence.Clear ();
1610 * Change of context =>
1611 * Display structures that can be displayed
1612 * with the new visualisation mode.
1613 * All structures with status Displayed are removed from the ViewManager
1614 * and displayed in the view directly, if the structure is not already
1615 * displayed and if the view accepts it in its context.
1618 i = MyViewManager->NumberOfDisplayedStructures ();
1619 Graphic3d_MapOfStructure Map;
1620 MyViewManager->DisplayedStructures(Map);
1621 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1623 for (; it.More(); it.Next()) {
1624 Handle(Graphic3d_Structure) SG = it.Key();
1625 if (! IsDisplayed (SG)) {
1626 Answer = AcceptDisplay(SG);
1627 // If the structure can be displayed in the
1628 // new context of the view, it is displayed.
1629 if ((Answer == Visual3d_TOA_YES) ||
1630 (Answer == Visual3d_TOA_COMPUTE))
1631 //Display (MyViewManager->DisplayedStructure (j),
1633 FooSequence.Append (SG);
1637 Length = FooSequence.Length ();
1638 // The stored structures are displayed
1639 for (i=1; i<=Length; i++)
1640 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
1641 if (Length != 0) FooSequence.Clear ();
1644 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1648 const Visual3d_ContextView& Visual3d_View::Context () const {
1654 void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& SG) const
1657 if (IsDeleted ()) return;
1659 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
1661 while (Iterator.More ()) {
1662 SG.Add (Iterator.Key ());
1664 // Iterator.Next () is located on the next structure
1670 void Visual3d_View::Activate () {
1672 if (IsDeleted ()) return;
1675 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1677 if (! IsActive ()) {
1679 MyGraphicDriver->ActivateView (MyCView);
1680 MyGraphicDriver->Background (MyCView);
1681 MyGraphicDriver->Transparency
1682 (MyCView, MyViewManager->Transparency ());
1687 * Activation of a new view =>
1688 * Display structures that can be displayed in this new view.
1689 * All structures with status
1690 * Displayed in ViewManager are returned and displayed in
1691 * the view directly, if the structure is not already
1692 * displayed and if the view accepts it in its context.
1695 Visual3d_TypeOfAnswer Answer;
1696 Graphic3d_MapOfStructure Map;
1697 MyViewManager->DisplayedStructures(Map);
1698 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1700 for (; it.More(); it.Next()) {
1701 Handle(Graphic3d_Structure) SG = it.Key();
1702 if (! IsDisplayed (SG)) {
1703 Answer = AcceptDisplay(SG);
1704 // If the structure can be displayed in the
1705 // new context of the view, it is displayed.
1706 if ((Answer == Visual3d_TOA_YES) ||
1707 (Answer == Visual3d_TOA_COMPUTE))
1708 Display (SG,Aspect_TOU_WAIT);
1714 // If the activation/desactivation of ZBuffer should be automatic
1715 // depending on the presence or absence of facets.
1716 if (MyViewManager->ZBufferAuto ()) {
1717 Standard_Boolean BContainsFacet = ContainsFacet ();
1718 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1719 // If the view contains facets
1720 // and if ZBuffer is not active
1721 if (BContainsFacet && ! BZBuffer)
1722 SetZBufferActivity (1);
1723 // If the view does not contain facets
1724 // and if ZBuffer is active
1725 if (! BContainsFacet && BZBuffer)
1726 SetZBufferActivity (0);
1729 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1733 Standard_Boolean Visual3d_View::IsActive () const {
1735 if (IsDeleted ()) return (Standard_False);
1738 return (Standard_True);
1740 return (Standard_False);
1744 void Visual3d_View::Deactivate () {
1746 if (IsDeleted ()) return;
1749 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1753 MyGraphicDriver->DeactivateView (MyCView);
1756 * Deactivation of a view =>
1757 * Removal of structures displayed in this view.
1758 * All structures with status
1759 * Displayed in ViewManager are returned and removed from
1760 * the view directly, if the structure is not already
1761 * displayed and if the view accepts it in its context.
1764 Visual3d_TypeOfAnswer Answer;
1765 Graphic3d_MapOfStructure Map;
1766 MyViewManager->DisplayedStructures(Map);
1767 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1769 for (; it.More(); it.Next()) {
1770 Handle(Graphic3d_Structure) SG = it.Key();
1771 if (! IsDisplayed (SG)) {
1772 Answer = AcceptDisplay(SG);
1773 // If the structure was displayed it is removed.
1774 if ((Answer == Visual3d_TOA_YES) ||
1775 (Answer == Visual3d_TOA_COMPUTE))
1776 Erase (SG,Aspect_TOU_WAIT);
1780 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1782 // No action currently possible in the view
1788 void Visual3d_View::Redraw () {
1790 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1794 void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
1796 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height);
1799 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1801 if (IsDeleted ()) return;
1803 if ((! IsDefined ()) || (! IsActive ())) return;
1805 if (! MyWindow->IsMapped ()) return;
1807 // san - 14/04/2004 - set up Z buffer state before redrawing
1808 // If the activation/desactivation of ZBuffer should be automatic
1809 // depending on the presence or absence of facets.
1810 if (MyViewManager->ZBufferAuto ()) {
1811 Standard_Boolean BContainsFacet = ContainsFacet ();
1812 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1813 // If the view contains facets
1814 // and if ZBuffer is not active
1815 if (BContainsFacet && ! BZBuffer)
1816 SetZBufferActivity (1);
1817 // If the view contains only facets
1818 // and if ZBuffer is active
1819 if (! BContainsFacet && BZBuffer)
1820 SetZBufferActivity (0);
1823 Aspect_CLayer2d OverCLayer;
1824 Aspect_CLayer2d UnderCLayer;
1825 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1826 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1827 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1828 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer);
1832 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) {
1834 if (IsDeleted ()) return;
1836 if ((! IsDefined ()) || (! IsActive ())) return;
1838 if (! MyWindow->IsMapped ()) return;
1840 // san - 14/04/2004 - set up Z buffer state before redrawing
1841 // If activation/desactivation of ZBuffer should be automatic
1842 // depending on the presence or absence of facets.
1843 if (MyViewManager->ZBufferAuto ()) {
1844 Standard_Boolean BContainsFacet = ContainsFacet ();
1845 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1846 // If the view contains facets
1847 // and if ZBuffer is not active
1848 if (BContainsFacet && ! BZBuffer)
1849 SetZBufferActivity (1);
1850 // If the view contains only facets
1851 // and if ZBuffer is active
1852 if (! BContainsFacet && BZBuffer)
1853 SetZBufferActivity (0);
1856 Aspect_CLayer2d OverCLayer;
1857 Aspect_CLayer2d UnderCLayer;
1858 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1859 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1860 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1861 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer, x, y, width, height);
1865 void Visual3d_View::Update () {
1867 Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1871 void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1873 if (IsDeleted ()) return;
1875 if ((! IsDefined ()) || (! IsActive ())) return;
1877 if (! MyWindow->IsMapped ()) return;
1879 // If activation/desactivation of ZBuffer should be automatic
1880 // depending on the presence or absence of facets.
1881 if (MyViewManager->ZBufferAuto ()) {
1882 Standard_Boolean BContainsFacet = ContainsFacet ();
1883 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1884 // If the view contains facets
1885 // and if ZBuffer is not active
1886 if (BContainsFacet && ! BZBuffer)
1887 SetZBufferActivity (1);
1888 // If the view does not contain facets
1889 // and if ZBuffer is active
1890 if (! BContainsFacet && BZBuffer)
1891 SetZBufferActivity (0);
1894 Aspect_CLayer2d OverCLayer;
1895 Aspect_CLayer2d UnderCLayer;
1896 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1897 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1898 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1899 //OSD::SetSignal (Standard_False);
1900 MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer);
1901 //OSD::SetSignal (Standard_True);
1903 MyMatOfMapIsModified = Standard_False;
1904 MyMatOfOriIsModified = Standard_False;
1908 Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const {
1910 // Return type of visualization of the view
1911 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
1913 // Return type of visualization of the structure
1914 Graphic3d_TypeOfStructure StructType = AStructure->Visual ();
1916 Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO;
1918 if (StructType == Graphic3d_TOS_ALL)
1919 // The structure accepts any type of view
1920 Result = Visual3d_TOA_YES;
1922 if ((StructType == Graphic3d_TOS_SHADING)
1923 && (ViewType == Visual3d_TOV_SHADING))
1924 Result = Visual3d_TOA_YES;
1925 if ((StructType == Graphic3d_TOS_WIREFRAME)
1926 && (ViewType == Visual3d_TOV_WIREFRAME))
1927 Result = Visual3d_TOA_YES;
1928 if ((StructType == Graphic3d_TOS_COMPUTED)
1929 && (ViewType == Visual3d_TOV_WIREFRAME))
1930 Result = Visual3d_TOA_COMPUTE;
1931 if ((StructType == Graphic3d_TOS_COMPUTED)
1932 && (ViewType == Visual3d_TOV_SHADING))
1933 Result = Visual3d_TOA_COMPUTE;
1937 if (Result == Visual3d_TOA_YES)
1938 cout << "YES = Visual3d_View" << MyCView.ViewId
1939 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1940 if (Result == Visual3d_TOA_NO)
1941 cout << "NO = Visual3d_View" << MyCView.ViewId
1942 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1943 if (Result == Visual3d_TOA_COMPUTE)
1944 cout << "COMPUTE = Visual3d_View" << MyCView.ViewId
1945 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1953 void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority) {
1955 if (IsDeleted ()) return;
1956 if (! IsDefined ()) return;
1957 if (! IsActive ()) return;
1958 if (! IsDisplayed (AStructure)) return;
1960 Standard_Integer Index = IsComputed (AStructure);
1962 if ( Index != 0 && ComputedMode () && !DegenerateModeIsOn () )
1964 if ((Index != 0) && (! DegenerateModeIsOn ()))
1968 Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification ();
1969 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1970 << AStructure->Identification () << "/" << StructId
1971 << ", " << OldPriority << ", " << NewPriority << ")\n";
1974 MyGraphicDriver->EraseStructure
1976 *(Graphic3d_CStructure *)
1977 MyCOMPUTEDSequence.Value (Index)->CStructure ());
1978 MyGraphicDriver->DisplayStructure
1980 *(Graphic3d_CStructure *)
1981 MyCOMPUTEDSequence.Value (Index)->CStructure (),
1986 Standard_Integer StructId = AStructure->Identification ();
1987 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1988 << AStructure->Identification () << "/" << StructId
1989 << ", " << OldPriority << ", " << NewPriority << ")\n";
1992 MyGraphicDriver->EraseStructure
1994 *(Graphic3d_CStructure *)AStructure->CStructure ());
1995 MyGraphicDriver->DisplayStructure
1997 *(Graphic3d_CStructure *)AStructure->CStructure (),
2003 void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) {
2006 cout << "Visual3d_View" << MyCView.ViewId << "::Clear ("
2007 << AStructure->Identification () << ")\n";
2011 Standard_Integer Index = IsComputed (AStructure);
2014 cout << "Structure " << AStructure->Identification ()
2015 << " calculated in the view "
2016 << Identification () << ", by structure "
2017 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2018 << " is emptied.\n";
2021 MyCOMPUTEDSequence.Value (Index)->GraphicClear (WithDestruction);
2022 MyCOMPUTEDSequence.Value (Index)->SetHLRValidation (Standard_False);
2027 void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
2029 #ifdef TRACE_CONNECT
2030 cout << "Visual3d_View" << MyCView.ViewId << "::Connect ("
2031 << AMother->Identification ()
2032 << ADaughter->Identification () << ")\n";
2036 Standard_Integer IndexM = IsComputed (AMother);
2037 Standard_Integer IndexD = IsComputed (ADaughter);
2039 if (IndexM != 0 && IndexD != 0) {
2040 #ifdef TRACE_CONNECT
2041 cout << "Structure " << AMother->Identification ()
2042 << " is connected to structure "
2043 << ADaughter->Identification () << endl;
2044 cout << "These structures are calculated.\n";
2045 cout << "In the view " << Identification ()
2047 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
2048 << " is connected to the structure "
2049 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
2052 MyCOMPUTEDSequence.Value (IndexM)->GraphicConnect (MyCOMPUTEDSequence.Value (IndexD));
2057 void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
2059 #ifdef TRACE_CONNECT
2060 cout << "Visual3d_View" << MyCView.ViewId << "::Disconnect ("
2061 << AMother->Identification ()
2062 << ADaughter->Identification () << ")\n";
2066 Standard_Integer IndexM = IsComputed (AMother);
2067 Standard_Integer IndexD = IsComputed (ADaughter);
2069 if (IndexM != 0 && IndexD != 0) {
2070 #ifdef TRACE_CONNECT
2071 cout << "Structure " << AMother->Identification ()
2072 << " is disconnected from the structure "
2073 << ADaughter->Identification () << endl;
2074 cout << "These structures are calculated.\n";
2075 cout << "In the view " << Identification ()
2077 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
2078 << " is disconnected from the structure "
2079 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
2082 MyCOMPUTEDSequence.Value (IndexM)->GraphicDisconnect (MyCOMPUTEDSequence.Value (IndexD));
2087 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) {
2089 Display (AStructure, MyViewManager->UpdateMode ());
2093 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
2095 if (IsDeleted ()) return;
2096 if (! IsDefined ()) return;
2097 if (! IsActive ()) return;
2099 // If Display on a structure present in the list
2100 // of calculated structures while it is not
2101 // or more, of calculated type =>
2102 // - removes it as well as the associated old computed
2103 // THis happens when hlhsr becomes again of type e
2104 // non computed after SetVisual.
2105 Standard_Integer Index = IsComputed (AStructure);
2107 if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) {
2110 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2111 cout << "In Visual3d_View::Display, ";
2112 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2113 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2117 MyTOCOMPUTESequence.Remove (Index);
2118 MyCOMPUTEDSequence.Remove (Index);
2121 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2122 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2123 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2129 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
2131 #ifdef TRACE_DISPLAY
2132 Standard_Integer StructId = AStructure->Identification ();
2133 cout << "Visual3d_View" << MyCView.ViewId << "::Display ("
2134 << StructId << ");\n";
2138 if (Answer == Visual3d_TOA_NO) {
2139 #ifdef TRACE_DISPLAY
2140 cout << "Answer : Visual3d_TOA_NO\n";
2146 // Mode degenerated active
2148 if ( !ComputedMode () || DegenerateModeIsOn () )
2149 Answer = Visual3d_TOA_YES;
2151 if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
2155 if (Answer == Visual3d_TOA_YES ) {
2156 #ifdef TRACE_DISPLAY
2157 cout << "Answer : Visual3d_TOA_YES\n";
2160 if (IsDisplayed (AStructure)) return;
2161 MyGraphicDriver->DisplayStructure (
2163 *(Graphic3d_CStructure *)AStructure->CStructure (),
2164 int (AStructure->DisplayPriority ())
2166 MyDisplayedStructure.Add (AStructure);
2167 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2170 if (Answer == Visual3d_TOA_COMPUTE) {
2171 #ifdef TRACE_DISPLAY
2172 cout << "Answer : Visual3d_TOA_COMPUTE\n";
2173 cout << "Index : " << Index << "\n" << flush;
2176 // Already computed, is COMPUTED still valid?
2177 #ifdef TRACE_DISPLAY
2178 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
2179 cout << "Structure "
2180 << MyTOCOMPUTESequence.Value (Index)->Identification ()
2181 << "already calculated, in the view "
2182 << Identification () << ", par la structure "
2183 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2184 << "\n was not recalculated as HLR is valid\n";
2188 cout << "Structure "
2189 << MyTOCOMPUTESequence.Value (Index)->Identification ()
2190 << " already calculated, in the view "
2191 << Identification () << ", by the structure "
2192 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2193 << "\n should be recalculated as HLR is invalid\n";
2197 Standard_Integer OldStructId =
2198 MyCOMPUTEDSequence.Value (Index)->Identification ();
2200 // Case COMPUTED valide
2201 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
2203 if (! IsDisplayed (AStructure)) {
2204 MyDisplayedStructure.Add (AStructure);
2205 MyGraphicDriver->DisplayStructure (
2207 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
2208 int (AStructure->DisplayPriority ())
2210 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2215 // Case COMPUTED invalid
2217 // Is there another valid representation ?
2218 // Find in the sequence of already calculated structures
2219 // 1/ Structure having the same Owner as <AStructure>
2220 // 2/ That is not <AStructure>
2221 // 3/ The COMPUTED which of is valid
2222 Standard_Integer NewIndex = HaveTheSameOwner (AStructure);
2224 // Case of COMPUTED invalid, WITH a valid of replacement
2225 if (NewIndex != 0) {
2227 if (! IsDisplayed (AStructure)) {
2228 MyCOMPUTEDSequence.SetValue
2229 (Index, MyCOMPUTEDSequence.Value (NewIndex));
2230 OldStructId = MyCOMPUTEDSequence.Value (NewIndex)->
2232 MyDisplayedStructure.Add (AStructure);
2233 MyGraphicDriver->DisplayStructure (
2235 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (NewIndex)->CStructure (),
2236 int (AStructure->DisplayPriority ())
2238 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2243 // Cas COMPUTED invalid, WITHOUT a valid of replacement
2245 // COMPUTED is removed if displayed
2246 if (IsDisplayed (AStructure))
2247 MyGraphicDriver->EraseStructure (
2249 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()
2253 } // if (Index != 0)
2255 // Compute + Validation
2257 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
2259 Handle(Graphic3d_Structure) TheStructure;
2260 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
2261 AStructure->Transform (ATrsf);
2263 TColStd_Array2OfReal Ident (0, 3, 0, 3);
2264 Standard_Integer ii, jj;
2265 for (ii=0; ii<=3; ii++)
2266 for (jj=0; jj<=3; jj++)
2267 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
2268 TheStructure = MyCOMPUTEDSequence.Value (Index);
2269 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
2270 if (AStructure->IsTransformed ()) {
2271 AStructure->Compute (this, ATrsf, TheStructure);
2274 AStructure->Compute (this, TheStructure);
2278 if (AStructure->IsTransformed ()) {
2279 TheStructure = AStructure->Compute (this, ATrsf);
2282 TheStructure = AStructure->Compute (this);
2286 TheStructure->SetHLRValidation (Standard_True);
2289 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2290 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2291 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2295 // TOCOMPUTE and COMPUTED associated to sequences are added
2296 MyTOCOMPUTESequence.Append (AStructure);
2297 MyCOMPUTEDSequence.Append (TheStructure);
2300 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2301 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2302 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2306 // The previous are removed if necessary
2308 MyTOCOMPUTESequence.Remove (Index);
2309 MyCOMPUTEDSequence.Remove (Index);
2313 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2314 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2315 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2319 // Return type of visualisation of the view
2320 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2322 // Of which type will be the computed ?
2323 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
2324 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
2326 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
2327 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
2329 if (ComputeWireframe)
2330 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
2332 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
2334 if (! ComputeShading && ! ComputeWireframe)
2335 Answer = Visual3d_TOA_NO;
2337 Answer = AcceptDisplay (TheStructure);
2339 if (AStructure->IsHighlighted()) {
2340 TheStructure->SetHighlightColor (AStructure->HighlightColor ());
2341 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
2344 #ifdef TRACE_DISPLAY
2345 cout << "Structure " << StructId
2346 << " in the view " << Identification ()
2347 << " is calculated by the structure "
2348 << TheStructure->Identification ();
2349 if (Answer == Visual3d_TOA_YES)
2350 cout << " and displayed\n";
2352 cout << " but not displayed\n";
2356 // It is displayed only if the calculated structure
2357 // has a proper type corresponding to the one of the view.
2358 if (Answer != Visual3d_TOA_NO) {
2359 if (! IsDisplayed (AStructure))
2360 MyDisplayedStructure.Add (AStructure);
2361 MyGraphicDriver->DisplayStructure (
2363 *(Graphic3d_CStructure *)TheStructure->CStructure (),
2364 int (AStructure->DisplayPriority ())
2366 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2368 } // Visual3d_TOA_COMPUTE
2371 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure) {
2373 if (IsDeleted ()) return;
2375 Erase (AStructure, MyViewManager->UpdateMode ());
2379 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
2381 Standard_Integer StructId;
2383 if (IsDeleted ()) return;
2385 // No test on window as the structure is displayed only if
2386 // the window exists, so only one test is enough.
2387 if (IsDisplayed (AStructure)) {
2388 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
2390 // Degenerated mode is active
2392 if ( !ComputedMode () || DegenerateModeIsOn () )
2393 Answer = Visual3d_TOA_YES;
2395 if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
2398 if (Answer != Visual3d_TOA_COMPUTE) {
2399 MyGraphicDriver->EraseStructure (
2401 *(Graphic3d_CStructure *)AStructure->CStructure ()
2405 if (Answer == Visual3d_TOA_COMPUTE) {
2406 Standard_Integer Index = IsComputed (AStructure);
2408 cout << "Visual3d_View" << MyCView.ViewId << "::Erase ("
2409 << AStructure->Identification () << ");\n";
2410 cout << "Index : " << Index << "\n";
2414 if ( Index != 0 && ComputedMode () &&
2415 !DegenerateModeIsOn () )
2417 if ((Index != 0) && (! DegenerateModeIsOn ()))
2421 MyCOMPUTEDSequence.Value (Index)->Identification ();
2423 cout << "Structure " << AStructure->Identification ()
2424 << " calculated, in the view "
2425 << Identification () << ", by the structure "
2426 << StructId << " is removed. \n";
2429 MyGraphicDriver->EraseStructure
2430 (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
2432 // else is impossible
2434 MyDisplayedStructure.Remove (AStructure);
2435 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2440 void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) {
2443 cout << "Visual3d_View" << MyCView.ViewId << "::Highlight ("
2444 << AStructure->Identification () << ")\n";
2448 Standard_Integer Index = IsComputed (AStructure);
2451 cout << "Structure " << AStructure->Identification ()
2452 << " calculated, in the view "
2453 << Identification () << ", by the structure "
2454 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2455 << " passes in highlight mode.\n";
2458 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
2459 (AStructure->HighlightColor ());
2460 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (AMethod);
2465 void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) {
2468 cout << "Visual3d_View" << MyCView.ViewId << "::Transform ("
2469 << AStructure->Identification () << ")\n";
2473 Standard_Integer Index = IsComputed (AStructure);
2476 cout << "The structure " << AStructure->Identification ()
2477 << " calculated, in the view "
2478 << Identification () << ", by the structure "
2479 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2480 << " is transformed.\n";
2483 // Test is somewhat light !
2484 // trsf is transferred only if it is :
2487 if (ATrsf (0, 1) != 0. || ATrsf (0, 2) != 0.
2488 || ATrsf (1, 0) != 0. || ATrsf (1, 2) != 0.
2489 || ATrsf (2, 0) != 0. || ATrsf (2, 1) != 0.)
2490 ReCompute (AStructure);
2492 MyCOMPUTEDSequence.Value (Index)->GraphicTransform (ATrsf);
2497 void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) {
2500 cout << "Visual3d_View" << MyCView.ViewId << "::UnHighlight ("
2501 << AStructure->Identification () << ")\n";
2505 Standard_Integer Index = IsComputed (AStructure);
2508 cout << "Structure " << AStructure->Identification ()
2509 << " calculated, in the view "
2510 << Identification () << ", by the structure "
2511 << MyCOMPUTEDSequence.Value (Index)->Identification ()
2512 << " passes in unhighlight mode.\n";
2515 MyCOMPUTEDSequence.Value (Index)->GraphicUnHighlight ();
2521 Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& AStructure) const {
2523 Standard_Integer StrId = AStructure->Identification ();
2525 Standard_Integer Result = 0;
2526 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2528 // Recherche de la structure <AStructure> dans la
2529 // sequence des structures deja calculees
2530 for (Standard_Integer i=1; i<=Length && Result==0; i++)
2531 if ((MyTOCOMPUTESequence.Value (i))->Identification ()
2532 == StrId) Result = i;
2534 cout << "\n In the view " << Identification () << " the structure ";
2536 cout << StrId << " is calculated by "
2537 << MyCOMPUTEDSequence.Value (Result)->Identification ()
2540 cout << StrId << " is not calculated\n" << flush;
2544 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2545 cout << "In Visual3d_View::IsComputed, ";
2546 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2547 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2556 Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& AStructure) const {
2558 Standard_Boolean Result = Standard_False;
2560 if (IsDeleted ()) return Result;
2562 Result = MyDisplayedStructure.Contains (AStructure);
2569 Standard_Boolean Visual3d_View::ContainsComputedStructure () const {
2571 Standard_Boolean Result = Standard_False;
2573 if (MyDisplayedStructure.IsEmpty ()) return Result;
2575 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
2577 Standard_Integer i = MyDisplayedStructure.Extent ();
2579 // Stop at the first structure of type TOS_COMPUTED
2580 while (! Result && Iterator.More ()) {
2582 (((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED);
2584 // Iterator.Next () is located on the
2594 Standard_Boolean Visual3d_View::ContainsFacet () const {
2596 return ContainsFacet (MyDisplayedStructure);
2600 Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& ASet) const {
2602 Standard_Boolean Result = Standard_False;
2604 if (ASet.IsEmpty ()) return Result;
2606 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
2608 // Stop at the first structure containing a facet
2609 for ( Iterator.Initialize (ASet);
2610 Iterator.More () && ! Result;
2612 Result = (Iterator.Key ())->ContainsFacet ();
2618 void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
2621 (MyDisplayedStructure, XMin, YMin, ZMin, XMax, YMax, ZMax);
2625 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 {
2627 if (ASet.IsEmpty ()) {
2628 XMin = RealFirst ();
2629 YMin = RealFirst ();
2630 ZMin = RealFirst ();
2638 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
2639 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
2645 XMax = RealFirst ();
2646 YMax = RealFirst ();
2647 ZMax = RealFirst ();
2649 for ( Iterator.Initialize (ASet);
2653 if ( (Iterator.Key ())->IsInfinite ()){
2654 //XMin, YMin .... ZMax are initialized by means of infinite line data
2655 (Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
2656 if ( Xm != RealFirst() && Xm < XMin )
2658 if ( Ym != RealFirst() && Ym < YMin )
2660 if ( Zm != RealFirst() && Zm < ZMin )
2662 if ( XM != RealLast() && XM > XMax )
2664 if ( YM != RealLast() && YM > YMax )
2666 if ( ZM != RealLast() && ZM > ZMax )
2669 // Only non-empty and non-infinite structures
2670 // are taken into account for calculation of MinMax
2671 if (! (Iterator.Key ())->IsInfinite () &&
2672 ! (Iterator.Key ())->IsEmpty ()) {
2673 (Iterator.Key ())->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM);
2674 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
2675 //"FitAll" operation ignores object with transform persitence parameter
2676 if( (Iterator.Key ())->TransformPersistenceMode() == Graphic3d_TMF_None )
2678 if (Xm < XMin) XMin = Xm;
2679 if (Ym < YMin) YMin = Ym;
2680 if (Zm < ZMin) ZMin = Zm;
2681 if (XM > XMax) XMax = XM;
2682 if (YM > YMax) YMax = YM;
2683 if (ZM > ZMax) ZMax = ZM;
2688 // The following cases are relevant
2689 // For exemple if all structures are empty or infinite
2690 if (XMax < XMin) { Xm = XMin; XMin = XMax; XMax = Xm; }
2691 if (YMax < YMin) { Ym = YMin; YMin = YMax; YMax = Ym; }
2692 if (ZMax < ZMin) { Zm = ZMin; ZMin = ZMax; ZMax = Zm; }
2694 Standard_Real Sx, Sy, Sz;
2695 MyViewOrientation.AxialScale(Sx, Sy, Sz);
2696 XMin = (Sx > 1. && XMin < RealFirst ()/Sx)?RealFirst (): XMin*Sx;
2697 XMax = (Sx > 1. && XMax > RealLast ()/Sx)?RealLast (): XMax*Sx;
2698 YMin = (Sy > 1. && YMin < RealFirst ()/Sy)?RealFirst (): YMin*Sy;
2699 YMax = (Sy > 1. && YMax > RealLast ()/Sy)?RealLast (): YMax*Sy;
2700 ZMin = (Sz > 1. && ZMin < RealFirst ()/Sz)?RealFirst (): ZMin*Sz;
2701 ZMax = (Sz > 1. && ZMax > RealLast ()/Sz)?RealLast (): ZMax*Sz;
2704 void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
2706 MinMaxValues (MyDisplayedStructure, XMin, YMin, XMax, YMax);
2710 void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
2712 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
2713 Standard_Real Xp, Yp, Zp;
2715 MinMaxValues (ASet, Xm, Ym, Zm, XM, YM, ZM);
2717 Projects (Xm, Ym, Zm, Xp, Yp, Zp);
2721 Projects (XM, YM, ZM, Xp, Yp, Zp);
2725 if (XMax < XMin) { Xp = XMax; XMax = XMin; XMin = Xp; }
2726 if (YMax < YMin) { Yp = YMax; YMax = YMin; YMin = Yp; }
2729 const TColStd_Array2OfReal& Visual3d_View::MatrixOfOrientation () {
2731 if (! MyMatOfOriIsEvaluated) {
2732 MyGraphicDriver->InquireMat
2733 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2734 MyMatOfMapIsEvaluated = Standard_True;
2735 MyMatOfOriIsEvaluated = Standard_True;
2738 return (MyMatrixOfOrientation);
2742 const TColStd_Array2OfReal& Visual3d_View::MatrixOfMapping () {
2744 if (! MyMatOfMapIsEvaluated) {
2745 MyGraphicDriver->InquireMat
2746 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2747 MyMatOfMapIsEvaluated = Standard_True;
2748 MyMatOfOriIsEvaluated = Standard_True;
2751 return (MyMatrixOfMapping);
2755 Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
2757 Standard_Integer Result = MyDisplayedStructure.Extent ();
2764 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 {
2766 math_Vector PtDC (0,3), PtWC (0,3);
2769 // Otherwise use new on Visual3d_View (constructor+destructor)
2770 // as Projects is a const method or MatrixOfOrientation and
2771 // MatrixOfMapping is not.
2772 Visual3d_View * const newthis = (Visual3d_View * const) this;
2773 newthis->MatrixOfOrientation ();
2774 newthis->MatrixOfMapping ();
2776 // World Coordinate Space
2782 // WCS -> View Reference Coordinate Space
2783 math_Vector PtVRC(0,3);
2784 PtVRC = MyMatrixOfOrientation.Multiplied (PtWC);
2786 // VRCS -> Normalized Projection Coordinate Space
2787 math_Vector PtNPC(0,3);
2788 PtNPC = MyMatrixOfMapping.Multiplied (PtVRC);
2789 for (Standard_Integer i=0; i<3; i++) PtNPC (i) = PtNPC (i) / PtNPC (3);
2792 printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
2793 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2796 Standard_Real Ratio;
2798 // NPCS -> Device Coordinate Space
2799 Standard_Real Dx = Standard_Real (MyCView.DefWindow.dx);
2800 Standard_Real Dy = Standard_Real (MyCView.DefWindow.dy);
2803 PtDC (0) = PtNPC (0) * Dx;
2804 PtDC (1) = Dy - PtNPC (1) * Dy * Ratio;
2806 printf("Display coordinates : %f,%f,%f,%f\n",
2807 PtDC(0),PtDC(1),PtDC(2),PtDC(3));
2810 // NPCS -> Window Space
2811 Standard_Real um, vm, uM, vM;
2812 MyViewMapping.WindowLimit (um, vm, uM, vM);
2814 Ratio = (uM - um) / (vM - vm);
2816 PtNPC (1) = PtNPC (1) * Ratio;
2818 PtNPC (0) = PtNPC (0) / Ratio;
2821 printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
2822 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2825 Standard_Real fpd = MyViewMapping.FrontPlaneDistance ();
2826 Standard_Real bpd = MyViewMapping.BackPlaneDistance ();
2829 * Coordinates of PtNPC are described in the space
2830 * [0-1]x[0-1]x[0-1].
2831 * It is necessary to transform x and y in the window space.
2832 * It is necessary to transform z in the space of back and front
2833 * plane, taking into account clipping planes.
2834 * Z clipping planes are defined between 0 and 1.
2837 APX = PtNPC (0) * (uM - um) + um;
2838 APY = PtNPC (1) * (vM - vm) + vm;
2839 APZ = PtNPC (2) * (fpd - bpd) + bpd;
2842 Standard_Integer l,c;
2843 printf("OrientationMatrix :");
2844 for( l=0 ; l<4 ; l++ ) {
2845 printf("\n %d->",l);
2846 for( c=0 ; c<4 ; c++ ) {
2847 printf(" %f ,",MyMatrixOfOrientation(c,l));
2851 printf("MappingMatrix :");
2852 for( l=0 ; l<4 ; l++ ) {
2853 printf("\n %d->",l);
2854 for( c=0 ; c<4 ; c++ ) {
2855 printf(" %f ,",MyMatrixOfMapping(c,l));
2859 printf("World coordinates : %f,%f,%f,%f\n",
2860 PtWC(0),PtWC(1),PtWC(2),PtWC(3));
2861 printf("View coordinates : %f,%f,%f,%f\n",
2862 PtVRC(0),PtVRC(1),PtVRC(2),PtVRC(3));
2863 printf("Display coordinates : %f,%f,%f,%f\n",
2864 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2865 printf("Window limit : %f,%f,%f,%f\n",um,vm,uM,vM);
2866 printf("Ratio : %f\n",Ratio);
2867 printf("Front-plane : %f back-plane : %f\n",fpd,bpd);
2868 printf("Projection : %f,%f,%f\n \n",APX,APY,APZ);
2872 #endif /* OLD_METHOD */
2874 // OCC18942: This method is likely to duplicate Visual3d_ViewManager::ConvertCoord() one,
2875 // therefore it is necessary to consider merging the two methods or making them call the same
2876 // graphic driver's method after OCCT 6.3.
2877 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) {
2879 Standard_Real PtX, PtY, PtZ, PtT;
2881 static Standard_Real Ratio, um, vm, uM, vM;
2882 static Standard_Real fpd, bpd;
2884 if (! MyMatOfOriIsEvaluated || ! MyMatOfMapIsEvaluated) {
2885 MyGraphicDriver->InquireMat
2886 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2887 MyMatOfOriIsEvaluated = MyMatOfMapIsEvaluated = Standard_True;
2890 // WCS -> View Reference Coordinate Space
2891 PtX = MyMatrixOfOrientation (0, 0) * AX
2892 + MyMatrixOfOrientation (0, 1) * AY
2893 + MyMatrixOfOrientation (0, 2) * AZ
2894 + MyMatrixOfOrientation (0, 3);
2895 PtY = MyMatrixOfOrientation (1, 0) * AX
2896 + MyMatrixOfOrientation (1, 1) * AY
2897 + MyMatrixOfOrientation (1, 2) * AZ
2898 + MyMatrixOfOrientation (1, 3);
2899 PtZ = MyMatrixOfOrientation (2, 0) * AX
2900 + MyMatrixOfOrientation (2, 1) * AY
2901 + MyMatrixOfOrientation (2, 2) * AZ
2902 + MyMatrixOfOrientation (2, 3);
2903 PtT = MyMatrixOfOrientation (3, 0) * AX
2904 + MyMatrixOfOrientation (3, 1) * AY
2905 + MyMatrixOfOrientation (3, 2) * AZ
2906 + MyMatrixOfOrientation (3, 3);
2908 // VRCS -> Normalized Projection Coordinate Space
2909 APX = MyMatrixOfMapping (0, 0) * PtX
2910 + MyMatrixOfMapping (0, 1) * PtY
2911 + MyMatrixOfMapping (0, 2) * PtZ
2912 + MyMatrixOfMapping (0, 3) * PtT;
2913 APY = MyMatrixOfMapping (1, 0) * PtX
2914 + MyMatrixOfMapping (1, 1) * PtY
2915 + MyMatrixOfMapping (1, 2) * PtZ
2916 + MyMatrixOfMapping (1, 3) * PtT;
2917 APZ = MyMatrixOfMapping (2, 0) * PtX
2918 + MyMatrixOfMapping (2, 1) * PtY
2919 + MyMatrixOfMapping (2, 2) * PtZ
2920 + MyMatrixOfMapping (2, 3) * PtT;
2921 APT = MyMatrixOfMapping (3, 0) * PtX
2922 + MyMatrixOfMapping (3, 1) * PtY
2923 + MyMatrixOfMapping (3, 2) * PtZ
2924 + MyMatrixOfMapping (3, 3) * PtT;
2930 // NPCS -> Window Space
2931 MyViewMapping.WindowLimit (um, vm, uM, vM);
2932 fpd = MyViewMapping.FrontPlaneDistance ();
2933 bpd = MyViewMapping.BackPlaneDistance ();
2935 if(MyCView.Mapping.IsCustomMatrix) {
2936 // OCC18942: SAN - If orientation and mapping matrices are those used by OpenGL
2937 // visualization, then X, Y and Z coordinates normally vary between -1 and 1
2938 APX = ( APX + 1 ) * 0.5 * (uM - um) + um;
2939 APY = ( APY + 1 ) * 0.5 * (vM - vm) + vm;
2941 Ratio = (uM - um) / (vM - vm);
2948 * Coordinates of APX, APY, APZ are described in the space
2949 * [0-1]x[0-1]x[0-1].
2950 * It is necessary to transform x and y in the window space.
2951 * It is necessary to transform z in the space of back and front
2952 * plane, taking into account clipping planes.
2953 * Z clipping planes are defined between 0 and 1.
2955 APX = APX * (uM - um) + um;
2956 APY = APY * (vM - vm) + vm;
2958 APZ = APZ * (fpd - bpd) + bpd;
2961 Standard_Integer Visual3d_View::Identification () const {
2963 return (Standard_Integer (MyCView.ViewId));
2968 Standard_Boolean Visual3d_View::ZBufferIsActivated () const {
2970 if (IsDeleted ()) return (Standard_False);
2972 if ((! IsDefined ()) || (! IsActive ())) return (Standard_False);
2974 // -1 => not forced by the programmer => depends on the type of visualisation
2975 // 0 ou 1 => forced by the programmer
2977 if (MyCView.Context.ZBufferActivity == -1)
2978 if (MyContext.Visualization () == Visual3d_TOV_SHADING)
2979 return (Standard_True);
2981 return (Standard_False);
2983 if (MyCView.Context.ZBufferActivity)
2984 return (Standard_True);
2986 return (Standard_False);
2990 void Visual3d_View::SetTransparency (const Standard_Boolean AnActivity) {
2992 if (IsDeleted ()) return;
2994 if ((! IsDefined ()) || (! IsActive ())) return;
2996 MyGraphicDriver->Transparency (MyCView, AnActivity);
3000 void Visual3d_View::SetZBufferActivity (const Standard_Integer AnActivity) {
3002 if (MyCView.Context.ZBufferActivity == AnActivity) return;
3004 if (IsDeleted ()) return;
3006 if ((! IsDefined ()) || (! IsActive ())) return;
3008 MyCView.Context.ZBufferActivity = AnActivity;
3009 MyGraphicDriver->SetVisualisation (MyCView);
3013 void Visual3d_View::UpdateView () {
3015 MyCView.Context.Aliasing = (MyContext.AliasingIsOn () ? 1:0);
3016 MyCView.Context.BackZClipping =
3017 (MyContext.BackZClippingIsOn () ? 1:0);
3018 MyCView.Context.FrontZClipping =
3019 (MyContext.FrontZClippingIsOn() ? 1:0);
3020 MyCView.Context.DepthCueing =
3021 (MyContext.DepthCueingIsOn () ? 1:0);
3023 MyCView.Context.ZClipFrontPlane =
3024 float (MyContext.ZClippingFrontPlane ());
3025 MyCView.Context.ZClipBackPlane =
3026 float (MyContext.ZClippingBackPlane ());
3027 MyCView.Context.DepthFrontPlane =
3028 float (MyContext.DepthCueingFrontPlane ());
3029 MyCView.Context.DepthBackPlane =
3030 float (MyContext.DepthCueingBackPlane ());
3032 MyCView.Context.Model = int (MyContext.Model ());
3033 MyCView.Context.Visualization = int (MyContext.Visualization ());
3035 Handle(Graphic3d_TextureEnv) TempTextureEnv = MyContext.TextureEnv();
3036 if (! TempTextureEnv.IsNull()) MyCView.Context.TexEnvId = TempTextureEnv->TextureId();
3037 else MyCView.Context.TexEnvId = -1;
3038 MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
3042 void Visual3d_View::Compute () {
3045 Standard_Integer Length = MyCOMPUTEDSequence.Length ();
3046 for (i=1; i<=Length; i++)
3047 (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False);
3049 // if the degenerated node is active, nothing is recomputed
3051 if ( DegenerateModeIsOn () || !ComputedMode () ) return;
3053 if (DegenerateModeIsOn ()) return;
3057 * Force HLRValidation to False on all structures
3058 * calculated in the view.
3061 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3062 cout << "In Visual3d_View::Compute, ";
3063 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3064 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3070 * Change of orientation or of projection type =>
3071 * Remove structures that were calculated for the
3072 * previous orientation.
3073 * Recalculation of new structures.
3074 * Passage of the degenerated mode ON to OFF =>
3075 * Remove structures that were calculated before
3076 * the degenerated mode passed to ON.
3077 * Recalculate new structures.
3079 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3080 Visual3d_TypeOfAnswer Answer;
3082 i = MyDisplayedStructure.Extent ();
3084 Graphic3d_SequenceOfStructure FooSequence;
3086 while (S1Iterator.More ()) {
3087 Answer = AcceptDisplay (S1Iterator.Key ());
3088 // If the structure was calculated, it is recalculated.
3089 if (Answer == Visual3d_TOA_COMPUTE) {
3091 cout << "AcceptDisplay ("
3092 << (S1Iterator.Key ())->Identification ()
3093 << ") == Visual3d_TOA_COMPUTE;\n";
3096 //Display (S1Iterator.Key (), Aspect_TOU_WAIT);
3097 FooSequence.Append (S1Iterator.Key ());
3100 // S1Iterator.Next () is located on the next structure
3104 Length = FooSequence.Length ();
3105 // All stored structures are displayed
3106 for (i=1; i<=Length; i++)
3107 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
3108 if (Length != 0) FooSequence.Clear ();
3112 void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
3114 if ( DegenerateModeIsOn () || !ComputedMode () ) return;
3116 if (DegenerateModeIsOn()) return;
3119 if (IsDeleted ()) return;
3121 if ((! IsDefined ()) || (! IsActive ())) return;
3123 if (! MyWindow->IsMapped ()) return;
3125 if (! AStructure->IsDisplayed ()) return;
3127 Visual3d_TypeOfAnswer Answer;
3129 Answer = AcceptDisplay (AStructure);
3131 if (Answer == Visual3d_TOA_COMPUTE) {
3132 Standard_Integer Index = IsComputed (AStructure);
3135 cout << "Structure " << AStructure->Identification ()
3136 << " is not calculated in the view "
3137 << Identification () << "\n";
3142 Standard_Integer OldStructId, NewStructId;
3144 MyCOMPUTEDSequence.Value (Index)->Identification ();
3146 Standard_Integer StructId = AStructure->Identification ();
3147 cout << "Structure " << StructId
3148 << " calculated, in the view "
3149 << Identification () << ", by the structure "
3150 << OldStructId << " is recalculated.\n";
3154 // Compute + Validation
3156 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
3158 Handle(Graphic3d_Structure) TheStructure;
3159 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
3160 AStructure->Transform (ATrsf);
3162 TColStd_Array2OfReal Ident (0, 3, 0, 3);
3163 Standard_Integer ii, jj;
3164 for (ii=0; ii<=3; ii++)
3165 for (jj=0; jj<=3; jj++)
3166 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
3167 TheStructure = MyCOMPUTEDSequence.Value (Index);
3168 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
3169 if (AStructure->IsTransformed ()) {
3170 AStructure->Compute (this, ATrsf, TheStructure);
3173 AStructure->Compute (this, TheStructure);
3177 if (AStructure->IsTransformed ()) {
3178 TheStructure = AStructure->Compute (this, ATrsf);
3181 TheStructure = AStructure->Compute (this);
3185 TheStructure->SetHLRValidation (Standard_True);
3187 // Return type of visualisation of the view
3188 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
3190 // Of which type will be the computed ?
3191 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
3192 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
3194 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
3195 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
3197 if (ComputeWireframe)
3198 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
3200 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
3202 if (AStructure->IsHighlighted ()) {
3203 TheStructure->SetHighlightColor
3204 (AStructure->HighlightColor ());
3205 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
3209 // Find structure <AStructure>
3210 // in the sequence of structures to be calculated.
3211 NewStructId = TheStructure->Identification ();
3213 // The previous calculation is removed and the new one is dislayed
3214 MyGraphicDriver->EraseStructure (
3216 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
3217 MyGraphicDriver->DisplayStructure (
3219 *(Graphic3d_CStructure *)TheStructure->CStructure (),
3220 int (AStructure->DisplayPriority ())
3224 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3225 cout << "In Visual3d_View::ReCompute, ";
3226 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3227 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3232 // hlhsr and the new associated compute are added
3233 MyTOCOMPUTESequence.Append (AStructure);
3234 MyCOMPUTEDSequence.Append (TheStructure);
3237 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3238 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3239 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3243 // hlhsr and the new associated compute are removed
3245 MyTOCOMPUTESequence.Remove (Index);
3246 MyCOMPUTEDSequence.Remove (Index);
3249 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3250 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3251 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3261 Visual3d_View::SetAnimationModeOn ( const Standard_Boolean degenerate ) {
3263 Visual3d_View::SetAnimationModeOn () {
3266 if (AnimationModeIsOn ()) return;
3268 AnimationModeIsActive = Standard_True;
3271 SetDegenerateModeOn ();
3273 SetDegenerateModeOff ();
3275 MyGraphicDriver->BeginAnimation (MyCView);
3279 void Visual3d_View::SetAnimationModeOff () {
3281 if (! AnimationModeIsOn ()) return;
3283 AnimationModeIsActive = Standard_False;
3285 SetDegenerateModeOff ();
3287 MyGraphicDriver->EndAnimation (MyCView);
3291 Standard_Boolean Visual3d_View::AnimationModeIsOn () const {
3293 return AnimationModeIsActive;
3297 void Visual3d_View::SetDegenerateModeOn () {
3300 cout << "Visual3d_View" << MyCView.ViewId
3301 << "::SetDegenerateModeOn ();\n";
3305 // If the degenerated mode is already active, nothing is recalculated
3306 if (DegenerateModeIsOn ()) return;
3307 DegenerateModeIsActive = Standard_True;
3310 MyCView.IsDegenerates = 1;
3313 * Change of activity of the degenerated mode
3314 * Remove structures that were calculated
3315 * and displayed when the mode was off.
3316 * Display of non-calculated structures.
3318 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3319 Visual3d_TypeOfAnswer Answer;
3320 Standard_Integer StructId;
3322 while (S1Iterator.More ()) {
3324 Answer = AcceptDisplay (S1Iterator.Key ());
3325 // If the structure was calculated, the previous one is
3326 // removed and the new one is displayed
3327 // (This is the role of passage into degenerated mode)
3329 if (Answer == Visual3d_TOA_COMPUTE) {
3330 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3333 MyCOMPUTEDSequence.Value (Index)->Identification ();
3335 cout << "Structure " << S1Iterator.Key ()->Identification ()
3336 << " calculated, in the view "
3337 << Identification () << ", by structure "
3338 << StructId << " passes in degenerated mode.\n";
3339 cout << "Remove" << StructId << " then display "
3340 << S1Iterator.Key ()->Identification () << "\n";
3343 MyGraphicDriver->EraseStructure
3344 (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
3345 MyGraphicDriver->DisplayStructure (
3347 *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure (),
3348 int (S1Iterator.Key ()->DisplayPriority ())
3352 // Else is impossible)
3353 // If the mode was not degenerated previously, the
3354 // calculated structure associated to S1Iterator.Key ()
3355 // really exists and Index != 0
3359 // S1Iterator.Next () is located on the next structure
3365 void Visual3d_View::SetDegenerateModeOff () {
3368 cout << "Visual3d_View" << MyCView.ViewId
3369 << "::SetDegenerateModeOff ();\n";
3373 // If the degenerated mode is already inactive, nothing is recalculated
3374 if (! DegenerateModeIsOn ()) return;
3376 DegenerateModeIsActive = Standard_False;
3379 MyCView.IsDegenerates = 0;
3382 * Change of activity of degenerated mode
3383 * Remove structures that were displayed
3384 * when the mode was on.
3385 * Calculation of structures.
3387 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3388 Visual3d_TypeOfAnswer Answer;
3389 Standard_Integer StructId;
3391 Standard_Integer i = MyDisplayedStructure.Extent ();
3393 while (S1Iterator.More ()) {
3395 Answer = AcceptDisplay (S1Iterator.Key ());
3396 // If the structure was calculated, the previous one is
3397 // removed and the new one is displayed
3398 // (This is the role of passage into degenerated mode)
3400 if (Answer == Visual3d_TOA_COMPUTE) {
3401 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3404 MyCOMPUTEDSequence.Value (Index)->Identification ();
3406 cout << "Structure " << S1Iterator.Key ()->Identification ()
3407 << " calculated, in the view "
3408 << Identification () << ", by the structure "
3409 << StructId << " passes into normal mode.\n";
3410 cout << "Remove " << S1Iterator.Key ()->Identification ()
3411 << " then display " << StructId << "\n";
3414 MyGraphicDriver->EraseStructure
3416 *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure ());
3417 MyGraphicDriver->DisplayStructure (
3419 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
3420 int (S1Iterator.Key ()->DisplayPriority ())
3423 Display (S1Iterator.Key (), Aspect_TOU_WAIT);
3425 if ((S1Iterator.Key ())->IsHighlighted()) {
3426 if (! (MyCOMPUTEDSequence.Value (Index))->IsHighlighted()) {
3427 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
3428 ((S1Iterator.Key ())->HighlightColor ());
3429 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (Aspect_TOHM_COLOR);
3434 // Else is impossible
3435 // Degenerated mode was activated before display of the
3436 // structure. So the structure was displayed in the
3437 // degenerated mode, but the calculated structure didn't exist.
3438 // It is calculated.
3440 // Compute + Validation
3441 Handle(Graphic3d_Structure) AStructure = (S1Iterator.Key ());
3443 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
3445 Handle(Graphic3d_Structure) TheStructure;
3446 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
3447 AStructure->Transform (ATrsf);
3449 TColStd_Array2OfReal Ident (0, 3, 0, 3);
3450 Standard_Integer ii, jj;
3451 for (ii=0; ii<=3; ii++)
3452 for (jj=0; jj<=3; jj++)
3453 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
3454 TheStructure = MyCOMPUTEDSequence.Value (Index);
3455 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
3456 if (AStructure->IsTransformed ()) {
3457 AStructure->Compute (this, ATrsf, TheStructure);
3460 AStructure->Compute (this, TheStructure);
3464 if (AStructure->IsTransformed ()) {
3465 TheStructure = AStructure->Compute (this, ATrsf);
3468 TheStructure = AStructure->Compute (this);
3472 TheStructure->SetHLRValidation (Standard_True);
3474 // Return type of visualisation of the view
3475 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
3477 // Of which type will be the computed ?
3478 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
3479 ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_SHADING));
3481 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
3482 ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
3484 if (ComputeWireframe)
3485 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
3487 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
3489 if ((S1Iterator.Key ())->IsHighlighted()) {
3490 TheStructure->SetHighlightColor
3491 ((S1Iterator.Key ())->HighlightColor ());
3492 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
3496 Standard_Integer Result = 0;
3497 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
3498 // Find structure <S1Iterator.Key ()>
3499 // in the sequence of structures to be calculated
3500 StructId = (S1Iterator.Key ())->Identification ();
3501 for (i=1; i<=Length && Result==0; i++)
3502 if ((MyTOCOMPUTESequence.Value (i))->Identification () ==
3503 StructId) Result = i;
3505 MyCOMPUTEDSequence.ChangeValue (Result) = TheStructure;
3507 // hlhsr and the associated new compute are added
3509 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3510 cout << "In Visual3d_View::SetDegenerateModeOff, ";
3511 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3512 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3516 MyTOCOMPUTESequence.Append (S1Iterator.Key ());
3517 MyCOMPUTEDSequence.Append (TheStructure);
3519 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3520 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3521 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3526 // The degenerated is removed and the calculated is displayed
3527 MyGraphicDriver->EraseStructure
3529 *(Graphic3d_CStructure *)(S1Iterator.Key ()->CStructure ()));
3530 MyGraphicDriver->DisplayStructure (
3532 *(Graphic3d_CStructure *)TheStructure->CStructure (),
3533 int (S1Iterator.Key ()->DisplayPriority ())
3538 // S1Iterator.Next () is located on the next structure
3542 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
3546 Standard_Boolean Visual3d_View::DegenerateModeIsOn () const {
3548 return DegenerateModeIsActive;
3552 Handle(Aspect_GraphicDriver) Visual3d_View::GraphicDriver () const {
3554 return MyGraphicDriver;
3558 void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& APlotter) const {
3560 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
3562 while (S1Iterator.More ()) {
3564 if (DegenerateModeIsOn ())
3565 // As the mode is degenerated the displayed structure
3566 // is plotted without taking into account if it is calculated or not
3567 (S1Iterator.Key ())->Plot (APlotter);
3569 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3570 // As the mode is not degenerated the displayed structure
3571 // is plotted as if it was not calculated, otherwise the
3572 // associated calculated structure is plotted.
3574 (S1Iterator.Key ())->Plot (APlotter);
3576 (MyCOMPUTEDSequence.Value (Index))->Plot (APlotter);
3579 // S1Iterator.Next () is located on the next structure
3585 Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const {
3587 Standard_Integer Result = 0;
3588 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
3590 // Find in the sequence of already calculated structures
3591 // 1/ Structure with the same Owner as <AStructure>
3592 // 2/ Which is not <AStructure>
3593 // 3/ COMPUTED which of is valid
3594 for (Standard_Integer i=1; i<=Length && Result==0; i++)
3595 if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ())
3596 && (MyTOCOMPUTESequence.Value (i)->Identification () !=
3597 AStructure->Identification ())
3598 && (MyCOMPUTEDSequence.Value (i)->HLRValidation ())) Result = i;
3604 Standard_Address Visual3d_View::CView () const {
3606 return Standard_Address (&MyCView);
3611 // Triedron methods : the Triedron is a non-zoomable object.
3613 void Visual3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
3614 const Quantity_NameOfColor YColor,
3615 const Quantity_NameOfColor ZColor,
3616 const Standard_Real SizeRatio,
3617 const Standard_Real AxisDiametr,
3618 const Standard_Integer NbFacettes) {
3619 MyGraphicDriver->ZBufferTriedronSetup(XColor, YColor, ZColor,
3620 SizeRatio, AxisDiametr, NbFacettes);
3625 void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition,
3626 const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe ) {
3628 MyGraphicDriver->TriedronDisplay (MyCView,APosition, AColor, AScale, AsWireframe);
3632 void Visual3d_View::TriedronErase () {
3634 MyGraphicDriver->TriedronErase (MyCView);
3639 void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
3641 MyGraphicDriver->TriedronEcho (MyCView,AType);
3645 Standard_Boolean checkFloat(const Standard_Real value)
3647 return value > -FLT_MAX && value < FLT_MAX;
3650 void SetMinMaxValuesCallback(void* Visual3dView)
3652 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
3654 Handle(Visual3d_View) view = (Handle(Visual3d_View)&) Visual3dView;
3655 view->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
3657 if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
3658 checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
3660 Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(view->GraphicDriver());
3661 driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
3662 (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
3666 Standard_Boolean Visual3d_View::GetGraduatedTrihedron
3667 (/* Names of axes */
3668 TCollection_ExtendedString& xname,
3669 TCollection_ExtendedString& yname,
3670 TCollection_ExtendedString& zname,
3672 Standard_Boolean& xdrawname,
3673 Standard_Boolean& ydrawname,
3674 Standard_Boolean& zdrawname,
3676 Standard_Boolean& xdrawvalues,
3677 Standard_Boolean& ydrawvalues,
3678 Standard_Boolean& zdrawvalues,
3680 Standard_Boolean& drawgrid,
3682 Standard_Boolean& drawaxes,
3683 /* Number of splits along axes */
3684 Standard_Integer& nbx,
3685 Standard_Integer& nby,
3686 Standard_Integer& nbz,
3687 /* Offset for drawing values */
3688 Standard_Integer& xoffset,
3689 Standard_Integer& yoffset,
3690 Standard_Integer& zoffset,
3691 /* Offset for drawing names of axes */
3692 Standard_Integer& xaxisoffset,
3693 Standard_Integer& yaxisoffset,
3694 Standard_Integer& zaxisoffset,
3695 /* Draw tickmarks */
3696 Standard_Boolean& xdrawtickmarks,
3697 Standard_Boolean& ydrawtickmarks,
3698 Standard_Boolean& zdrawtickmarks,
3699 /* Length of tickmarks */
3700 Standard_Integer& xtickmarklength,
3701 Standard_Integer& ytickmarklength,
3702 Standard_Integer& ztickmarklength,
3704 Quantity_Color& gridcolor,
3705 /* Colors of axis names */
3706 Quantity_Color& xnamecolor,
3707 Quantity_Color& ynamecolor,
3708 Quantity_Color& znamecolor,
3709 /* Colors of axis and values */
3710 Quantity_Color& xcolor,
3711 Quantity_Color& ycolor,
3712 Quantity_Color& zcolor,
3713 /* Name of font for names of axes */
3714 TCollection_AsciiString& fontOfNames,
3715 /* Style of names of axes */
3716 OSD_FontAspect& styleOfNames,
3717 /* Size of names of axes */
3718 Standard_Integer& sizeOfNames,
3719 /* Name of font for values */
3720 TCollection_AsciiString& fontOfValues,
3721 /* Style of values */
3722 OSD_FontAspect& styleOfValues,
3723 /* Size of values */
3724 Standard_Integer& sizeOfValues) const
3726 if (!MyGTrihedron.ptrVisual3dView)
3727 return Standard_False;
3730 xname = MyGTrihedron.xname;
3731 yname = MyGTrihedron.yname;
3732 zname = MyGTrihedron.zname;
3734 xdrawname = MyGTrihedron.xdrawname;
3735 ydrawname = MyGTrihedron.ydrawname;
3736 zdrawname = MyGTrihedron.zdrawname;
3738 xdrawvalues = MyGTrihedron.xdrawvalues;
3739 ydrawvalues = MyGTrihedron.ydrawvalues;
3740 zdrawvalues = MyGTrihedron.zdrawvalues;
3742 drawgrid = MyGTrihedron.drawgrid;
3744 drawaxes = MyGTrihedron.drawaxes;
3745 /* Number of splits along axes */
3746 nbx = MyGTrihedron.nbx;
3747 nby = MyGTrihedron.nby;
3748 nbz = MyGTrihedron.nbz;
3749 /* Offset for drawing values */
3750 xoffset = MyGTrihedron.xoffset;
3751 yoffset = MyGTrihedron.yoffset;
3752 zoffset = MyGTrihedron.zoffset;
3753 /* Offset for drawing names of axes */
3754 xaxisoffset = MyGTrihedron.xaxisoffset;
3755 yaxisoffset = MyGTrihedron.yaxisoffset;
3756 zaxisoffset = MyGTrihedron.zaxisoffset;
3757 /* Draw tickmarks */
3758 xdrawtickmarks = MyGTrihedron.xdrawtickmarks;
3759 ydrawtickmarks = MyGTrihedron.ydrawtickmarks;
3760 zdrawtickmarks = MyGTrihedron.zdrawtickmarks;
3761 /* Length of tickmarks */
3762 xtickmarklength = MyGTrihedron.xtickmarklength;
3763 ytickmarklength = MyGTrihedron.ytickmarklength;
3764 ztickmarklength = MyGTrihedron.ztickmarklength;
3766 gridcolor = MyGTrihedron.gridcolor;
3767 /* Colors of axis names */
3768 xnamecolor = MyGTrihedron.xnamecolor;
3769 ynamecolor = MyGTrihedron.ynamecolor;
3770 znamecolor = MyGTrihedron.znamecolor;
3771 /* Colors of axis and values */
3772 xcolor = MyGTrihedron.xcolor;
3773 ycolor = MyGTrihedron.ycolor;
3774 zcolor = MyGTrihedron.zcolor;
3775 /* Name of font for names of axes */
3776 fontOfNames = MyGTrihedron.fontOfNames;
3777 /* Style of names of axes */
3778 styleOfNames = MyGTrihedron.styleOfNames;
3779 /* Size of names of axes */
3780 sizeOfNames = MyGTrihedron.sizeOfNames;
3781 /* Name of font for values */
3782 fontOfValues = MyGTrihedron.fontOfValues;
3783 /* Style of values */
3784 styleOfValues = MyGTrihedron.styleOfValues;
3785 /* Size of values */
3786 sizeOfValues = MyGTrihedron.sizeOfValues;
3788 return Standard_True;
3791 void Visual3d_View::GraduatedTrihedronDisplay
3792 (/* Names of axes */
3793 const TCollection_ExtendedString &xname,
3794 const TCollection_ExtendedString &yname,
3795 const TCollection_ExtendedString &zname,
3797 const Standard_Boolean xdrawname,
3798 const Standard_Boolean ydrawname,
3799 const Standard_Boolean zdrawname,
3801 const Standard_Boolean xdrawvalues,
3802 const Standard_Boolean ydrawvalues,
3803 const Standard_Boolean zdrawvalues,
3805 const Standard_Boolean drawgrid,
3807 const Standard_Boolean drawaxes,
3808 /* Number of splits along axes */
3809 const Standard_Integer nbx,
3810 const Standard_Integer nby,
3811 const Standard_Integer nbz,
3812 /* Offset for drawing values */
3813 const Standard_Integer xoffset,
3814 const Standard_Integer yoffset,
3815 const Standard_Integer zoffset,
3816 /* Offset for drawing names of axes */
3817 const Standard_Integer xaxisoffset,
3818 const Standard_Integer yaxisoffset,
3819 const Standard_Integer zaxisoffset,
3820 /* Draw tickmarks */
3821 const Standard_Boolean xdrawtickmarks,
3822 const Standard_Boolean ydrawtickmarks,
3823 const Standard_Boolean zdrawtickmarks,
3824 /* Length of tickmarks */
3825 const Standard_Integer xtickmarklength,
3826 const Standard_Integer ytickmarklength,
3827 const Standard_Integer ztickmarklength,
3829 const Quantity_Color& gridcolor,
3830 /* Colors of axis names */
3831 const Quantity_Color& xnamecolor,
3832 const Quantity_Color& ynamecolor,
3833 const Quantity_Color& znamecolor,
3834 /* Colors of axis and values */
3835 const Quantity_Color& xcolor,
3836 const Quantity_Color& ycolor,
3837 const Quantity_Color& zcolor,
3838 /* Name of font for names of axes */
3839 const TCollection_AsciiString &fontOfNames,
3840 /* Style of names of axes */
3841 const OSD_FontAspect styleOfNames,
3842 /* Size of names of axes */
3843 const Standard_Integer sizeOfNames,
3844 /* Name of font for values */
3845 const TCollection_AsciiString &fontOfValues,
3846 /* Style of values */
3847 const OSD_FontAspect styleOfValues,
3848 /* Size of values */
3849 const Standard_Integer sizeOfValues)
3852 MyGTrihedron.xname = xname;
3853 MyGTrihedron.yname = yname;
3854 MyGTrihedron.zname = zname;
3856 MyGTrihedron.xdrawname = xdrawname;
3857 MyGTrihedron.ydrawname = ydrawname;
3858 MyGTrihedron.zdrawname = zdrawname;
3860 MyGTrihedron.xdrawvalues = xdrawvalues;
3861 MyGTrihedron.ydrawvalues = ydrawvalues;
3862 MyGTrihedron.zdrawvalues = zdrawvalues;
3864 MyGTrihedron.drawgrid = drawgrid;
3866 MyGTrihedron.drawaxes = drawaxes;
3867 /* Number of splits along axes */
3868 MyGTrihedron.nbx = nbx;
3869 MyGTrihedron.nby = nby;
3870 MyGTrihedron.nbz = nbz;
3871 /* Offset for drawing values */
3872 MyGTrihedron.xoffset = xoffset;
3873 MyGTrihedron.yoffset = yoffset;
3874 MyGTrihedron.zoffset = zoffset;
3875 /* Offset for drawing names of axes */
3876 MyGTrihedron.xaxisoffset = xaxisoffset;
3877 MyGTrihedron.yaxisoffset = yaxisoffset;
3878 MyGTrihedron.zaxisoffset = zaxisoffset;
3879 /* Draw tickmarks */
3880 MyGTrihedron.xdrawtickmarks = xdrawtickmarks;
3881 MyGTrihedron.ydrawtickmarks = ydrawtickmarks;
3882 MyGTrihedron.zdrawtickmarks = zdrawtickmarks;
3883 /* Length of tickmarks */
3884 MyGTrihedron.xtickmarklength = xtickmarklength;
3885 MyGTrihedron.ytickmarklength = ytickmarklength;
3886 MyGTrihedron.ztickmarklength = ztickmarklength;
3888 MyGTrihedron.gridcolor = gridcolor;
3889 /* Colors of axis names */
3890 MyGTrihedron.xnamecolor = xnamecolor;
3891 MyGTrihedron.ynamecolor = ynamecolor;
3892 MyGTrihedron.znamecolor = znamecolor;
3893 /* Colors of axis and values */
3894 MyGTrihedron.xcolor = xcolor;
3895 MyGTrihedron.ycolor = ycolor;
3896 MyGTrihedron.zcolor = zcolor;
3897 /* Name of font for names of axes */
3898 MyGTrihedron.fontOfNames = fontOfNames;
3899 /* Style of names of axes */
3900 MyGTrihedron.styleOfNames = styleOfNames;
3901 /* Size of names of axes */
3902 MyGTrihedron.sizeOfNames = sizeOfNames;
3903 /* Name of font for values */
3904 MyGTrihedron.fontOfValues = fontOfValues;
3905 /* Style of values */
3906 MyGTrihedron.styleOfValues = styleOfValues;
3907 /* Size of values */
3908 MyGTrihedron.sizeOfValues = sizeOfValues;
3910 MyGTrihedron.ptrVisual3dView = this;
3911 MyGTrihedron.cbCubicAxes = SetMinMaxValuesCallback;
3912 MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,MyGTrihedron);
3915 void Visual3d_View::GraduatedTrihedronErase()
3917 MyGTrihedron.ptrVisual3dView = NULL;
3918 MyGraphicDriver->GraduatedTrihedronErase(MyCView);
3921 const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer () const {
3923 return (MyViewManager->UnderLayer ());
3927 const Handle(Visual3d_Layer)& Visual3d_View::OverLayer () const {
3929 return (MyViewManager->OverLayer ());
3933 Standard_Integer Visual3d_View::LightLimit() const {
3935 Standard_Integer maxlight = MyGraphicDriver->InquireLightLimit ();
3936 // printf(" $$$ Visual3d_View::LightLimit() is %d\n",maxlight);
3940 Standard_Integer Visual3d_View::PlaneLimit() const {
3942 Standard_Integer maxplane = MyGraphicDriver->InquirePlaneLimit ();
3943 // printf(" $$$ Visual3d_View::PlaneLimit() is %d\n",maxplane);
3948 Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const {
3950 return MyPtrViewManager;
3955 void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode ) {
3957 if ( ( (aMode && ComputedModeIsActive) ||
3958 (!aMode && !ComputedModeIsActive)
3959 ) || DegenerateModeIsOn ()
3962 Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure );
3963 Visual3d_TypeOfAnswer Answer;
3964 Standard_Integer StructId;
3965 Standard_Integer i = MyDisplayedStructure.Extent ();
3967 if ( !( ComputedModeIsActive = aMode ) ) {
3969 while ( S1Iterator.More () ) {
3971 Answer = AcceptDisplay ( S1Iterator.Key () );
3973 if ( Answer == Visual3d_TOA_COMPUTE ) {
3975 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
3979 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
3981 MyGraphicDriver -> EraseStructure (
3983 *( Graphic3d_CStructure* )
3984 MyCOMPUTEDSequence.Value ( Index ) -> CStructure ()
3986 MyGraphicDriver -> DisplayStructure (
3988 *( Graphic3d_CStructure* )
3989 S1Iterator.Key () -> CStructure (),
3990 int ( S1Iterator.Key () -> DisplayPriority () )
3992 } // end if ( Index != 0 ) . . .
3994 } // end if ( Answer . . . )
4002 while ( S1Iterator.More () ) {
4004 Answer = AcceptDisplay ( S1Iterator.Key () );
4006 if ( Answer == Visual3d_TOA_COMPUTE ) {
4008 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
4012 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
4014 MyGraphicDriver -> EraseStructure (
4016 *( Graphic3d_CStructure* )
4017 S1Iterator.Key () -> CStructure ()
4019 MyGraphicDriver -> DisplayStructure (
4021 *( Graphic3d_CStructure* )
4022 MyCOMPUTEDSequence.Value ( Index ) -> CStructure (),
4023 int ( S1Iterator.Key () -> DisplayPriority () )
4026 Display ( S1Iterator.Key (), Aspect_TOU_WAIT );
4028 if ( S1Iterator.Key () -> IsHighlighted () ) {
4030 if ( !MyCOMPUTEDSequence.Value ( Index ) -> IsHighlighted () ) {
4032 MyCOMPUTEDSequence.Value ( Index ) -> SetHighlightColor (
4033 S1Iterator.Key () ->
4036 MyCOMPUTEDSequence.Value ( Index ) -> GraphicHighlight (
4045 Handle( Graphic3d_Structure ) AStructure = S1Iterator.Key ();
4047 Handle( Graphic3d_Structure ) TheStructure = AStructure -> Compute ( this );
4049 Handle( Graphic3d_Structure ) TheStructure;
4050 TColStd_Array2OfReal ATrsf ( 0, 3, 0, 3 );
4052 AStructure -> Transform ( ATrsf );
4056 TColStd_Array2OfReal Ident ( 0, 3, 0, 3 );
4057 Standard_Integer ii, jj;
4059 for ( ii = 0; ii <= 3; ++ii )
4061 for ( jj = 0; jj <= 3; ++jj )
4063 Ident ( ii, jj ) = ( ii == jj ? 1.0 : 0.0 );
4065 TheStructure = MyCOMPUTEDSequence.Value ( Index );
4067 TheStructure -> SetTransform ( Ident, Graphic3d_TOC_REPLACE );
4069 if ( AStructure->IsTransformed () )
4071 AStructure -> Compute ( this, ATrsf, TheStructure );
4075 AStructure -> Compute ( this, TheStructure );
4079 if ( AStructure -> IsTransformed () )
4081 TheStructure = AStructure -> Compute ( this, ATrsf );
4085 TheStructure = AStructure -> Compute ( this );
4089 TheStructure -> SetHLRValidation ( Standard_True );
4091 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
4093 Standard_Boolean ComputeWireframe =
4094 ( ( ViewType == Visual3d_TOV_WIREFRAME ) &&
4095 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_SHADING )
4098 Standard_Boolean ComputeShading =
4099 ( ( ViewType == Visual3d_TOV_SHADING ) &&
4100 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_WIREFRAME )
4103 if ( ComputeWireframe ) TheStructure -> SetVisual ( Graphic3d_TOS_WIREFRAME );
4104 if ( ComputeShading ) TheStructure -> SetVisual ( Graphic3d_TOS_SHADING );
4106 if ( S1Iterator.Key () -> IsHighlighted () ) {
4108 TheStructure -> SetHighlightColor (
4109 S1Iterator.Key () -> HighlightColor ()
4111 TheStructure -> GraphicHighlight ( Aspect_TOHM_COLOR );
4115 Standard_Integer Result = 0;
4116 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
4117 StructId = S1Iterator.Key () -> Identification ();
4119 for ( i = 1; i <= Length && Result == 0; ++i )
4121 if ( MyTOCOMPUTESequence.Value ( i ) -> Identification () == StructId )
4127 MyCOMPUTEDSequence.ChangeValue ( Result ) = TheStructure;
4131 MyTOCOMPUTESequence.Append ( S1Iterator.Key () );
4132 MyCOMPUTEDSequence.Append ( TheStructure );
4136 MyGraphicDriver -> EraseStructure (
4138 *( Graphic3d_CStructure* )
4139 S1Iterator.Key () -> CStructure ()
4141 MyGraphicDriver -> DisplayStructure (
4143 *( Graphic3d_CStructure* )TheStructure -> CStructure (),
4144 int ( S1Iterator.Key () -> DisplayPriority () )
4154 if ( MyViewManager -> UpdateMode () == Aspect_TOU_ASAP ) Update ();
4158 } // end Visual3d_View :: SetComputedMode
4160 Standard_Boolean Visual3d_View :: ComputedMode () const {
4162 return ComputedModeIsActive;
4164 } // end Visual3d_View :: ComputedMode
4166 void Visual3d_View :: SetBackFacingModel (
4167 const Visual3d_TypeOfBackfacingModel aModel
4172 case Visual3d_TOBM_AUTOMATIC:
4173 MyCView.Backfacing = 0;
4176 case Visual3d_TOBM_FORCE:
4177 MyCView.Backfacing = 1;
4180 case Visual3d_TOBM_DISABLE:
4181 MyCView.Backfacing = -1;
4186 MyGraphicDriver -> SetBackFacingModel ( MyCView );
4188 } // end Visual3d_View :: SetBackFacingModel
4190 Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const {
4192 switch ( MyCView.Backfacing ) {
4195 return Visual3d_TOBM_AUTOMATIC;
4198 return Visual3d_TOBM_FORCE;
4202 return Visual3d_TOBM_DISABLE;
4204 } // end Visual3d_View :: BackFacingModel
4207 void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const
4210 MyGraphicDriver->SetDepthTestEnabled( MyCView, enable );
4214 Standard_Boolean Visual3d_View::IsDepthTestEnabled() const
4217 return MyGraphicDriver->IsDepthTestEnabled( MyCView );
4219 return Standard_True;
4223 void Visual3d_View::ReadDepths(const Standard_Integer x,
4224 const Standard_Integer y,
4225 const Standard_Integer width,
4226 const Standard_Integer height,
4227 const Standard_Address buffer) const
4229 MyGraphicDriver->ReadDepths( MyCView, x, y, width, height, buffer );
4232 Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth,
4233 const Standard_Integer theHeight)
4235 return MyGraphicDriver->FBOCreate( MyCView, theWidth, theHeight );
4238 void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr)
4240 MyGraphicDriver->FBORelease( MyCView, theFBOPtr );
4243 void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr,
4244 Standard_Integer& theWidth, Standard_Integer& theHeight,
4245 Standard_Integer& theWidthMax, Standard_Integer& theHeightMax)
4247 MyGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr,
4248 theWidth, theHeight,
4249 theWidthMax, theHeightMax );
4252 void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr,
4253 const Standard_Integer theWidth, const Standard_Integer theHeight)
4255 MyGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr,
4256 theWidth, theHeight );
4259 Standard_Boolean Visual3d_View::BufferDump (Image_CRawBufferData& theBuffer)
4261 return MyGraphicDriver->BufferDump( MyCView, theBuffer);
4264 void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
4267 MyGraphicDriver->SetGLLightEnabled( MyCView, enable );
4272 Standard_Boolean Visual3d_View::IsGLLightEnabled() const
4275 return MyGraphicDriver->IsGLLightEnabled( MyCView );
4277 return Standard_True;
4281 Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName,
4282 const Graphic3d_ExportFormat theFormat,
4283 const Graphic3d_SortType theSortType,
4284 const Standard_Real thePrecision,
4285 const Standard_Address theProgressBarFunc,
4286 const Standard_Address theProgressObject) const
4288 Handle(Visual3d_Layer) anUnderLayer = MyViewManager->UnderLayer();
4289 Handle(Visual3d_Layer) anOverLayer = MyViewManager->OverLayer();
4291 Aspect_CLayer2d anOverCLayer;
4292 Aspect_CLayer2d anUnderCLayer;
4293 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
4295 if (!anOverLayer.IsNull())
4296 anOverCLayer = anOverLayer->CLayer();
4297 if (!anUnderLayer.IsNull())
4298 anUnderCLayer = anUnderLayer->CLayer();
4300 Standard_Integer aWidth, aHeight;
4301 Window()->Size (aWidth, aHeight);
4303 return MyGraphicDriver->Export (theFileName, theFormat, theSortType,
4304 aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
4305 thePrecision, theProgressBarFunc, theProgressObject);
4308 //=======================================================================
4309 //function : AddZLayer
4311 //=======================================================================
4313 void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
4315 MyGraphicDriver->AddZLayer (MyCView, theLayerId);
4318 //=======================================================================
4319 //function : RemoveZLayer
4321 //=======================================================================
4323 void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
4325 MyGraphicDriver->RemoveZLayer (MyCView, theLayerId);
4328 //=======================================================================
4329 //function : ChangeZLayer
4331 //=======================================================================
4333 void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
4334 const Standard_Integer theLayerId)
4336 MyGraphicDriver->ChangeZLayer (
4337 (*(Graphic3d_CStructure*)theStructure->CStructure()), MyCView, theLayerId);