0024070: OpenGL capped object-level clipping planes
[occt.git] / src / Visual3d / Visual3d_View.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
4// The content of this file is subject to the Open CASCADE Technology Public
5// License Version 6.5 (the "License"). You may not use the content of this file
6// except in compliance with the License. Please obtain a copy of the License
7// at http://www.opencascade.org and read it completely before using this file.
8//
9// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11//
12// The Original Code and all software distributed under the License is
13// distributed on an "AS IS" basis, without warranty of any kind, and the
14// Initial Developer hereby disclaims all such warranties, including without
15// limitation, any warranties of merchantability, fitness for a particular
16// purpose or non-infringement. Please see the License for the specific terms
17// and conditions governing the rights and limitations under the License.
18
7fd59977 19/***********************************************************************
20
21 FONCTION :
22 ----------
23 Classe Visual3d_View.cxx :
24
25
81bba717 26 Declaration of variables specific to views.
7fd59977 27
81bba717 28 A view is defined by :
29 - ViewManager
30 - ContextView
31 - ViewMapping
32 - ViewOrientation
7fd59977 33
34 HISTORIQUE DES MODIFICATIONS :
35 --------------------------------
36 Mars 1992 : NW,JPB,CAL ; Creation.
37 04-02-97 : FMN ; Suppression de PSOutput, XWDOutput ...
38 22-04-97 : CAL ; Ajout du Plot.
39 03-06-97 : FMN ; Correction calcul SetRatio
40 06-05-97 : CAL ; Ajout du Clear sur les TOS_COMPUTED.
41 28-07-97 : PCT ; Ajout lumiere frontale headlight.
42 19-09-97 : CAL ; Remplacement de Window->Position par Window->Size;
43 17-10-97 : CAL ; Le Projects nouveau est arrive. (NewProjects)
44 24-10-97 : CAL ; Retrait de DownCast.
45 24-10-97 : CAL ; Retrait des DataStructure (Vieille maquette inutilisee).
46 17-11-97 : FMN ; Ajout DoResize dans Resized()
47 20-11-97 : CAL ; Disparition de la dependance avec math
48 ??-11-97 : CAL ; Retrait de la dependance avec math. Calcul developpe.
49 ??-11-97 : CAL ; Ajout de NumberOfDisplayedStructures
50 07-08-97 : PCT ; ajout support texture mapping
7fd59977 51 15-01-98 : FMN ; FRA60019 calcul Ratio pour MyViewMappingReset
52 15-01-98 : CAL ; Ajout de la transformation d'une TOS_COMPUTED
53 26-01-98 : CAL ; Ajout de la methode HaveTheSameOwner
54 06-02-98 : FMN ; CTS19079: TOP TEN: Probleme de highlight dans EDesigner.
55 05-03-98 : CAL ; GraphicTransform que si Trsf non invalidante
56 27-03-98 : CAL ; Ajout de TheStructure = devant Compute (...) !!!!
57 16-04-98 : CAL ; Remise a ID de la Trsf sur la COMPUTED
58 20-05-98 : CAL ; Perfs. Connection entre structures COMPUTED.
59 24-06-98 : CAL ; PRO14526 SetTransparency sur une vue non active.
60 17-07-98 : CAL ; PRO14872 test sur aTrsf dans ::SetTransform.
61 16-09-98 : BGN ; Points d'entree du Triedre (S3819, Phase 1)
62 22-09-98 : BGN ; S3989 (anciennement S3819)
63 TypeOfTriedron* from Aspect (pas Visual3d)
64 06-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie.
65 16-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie.
66 02-11-98 : CAL ; Retrait de OSD::SetSignal.
67 18-11-98 : FMN ; Correction sur la gestion de la perspective
68 02-12-98 : CAL ; S4062. Ajout des layers.
69 13-09-99 : GG ; GER61454 Adds LightLimit() and PlaneLimit() methods
70 10-11-99 : GG ; PRO19603 Add Redraw( area ) method
71 14-01-00 : GG ; IMP140100 Add ViewManager( ) method
72 22-10-01 : SAV ; Added EnableDepthTest() method.
73 30-04-02 : JMB ; MyDisplayStructure : use a Map instead of a Set (very bad performance
74 in data access when a lot of objects are used)
75 Will improve performance of selection mechanisms
76
77************************************************************************/
78
79#define BUC60572 //GG_03-08-99 Add protection on Zclipping & Zcueing planes
80// positions.
81
82#define BUC60570 //GG 14-09-99 Don't activates lighting
83// when the view shading model is NONE.
84
85#define GER61454 //GG 14-09-99 Activates model clipping planes
86
7fd59977 87#define RIC120302 //GG Add a NEW SetWindow method which enable
88// to connect a graphic widget and context to OGL.
89
b8ddfc2f 90//BUC61044 25/10/01 SAV ; added functionality to control gl depth testing from higher API
91//BUC61045 25/10/01 SAV ; added functionality to control gl lighting from higher API
7fd59977 92
b8ddfc2f 93//OCC1188 SAV Added methods to set background image
7fd59977 94
95/*----------------------------------------------------------------------*/
96/*
97 * Constantes
98 */
99
100#define NO_DEBUG
101#define NO_DESTROY
102#define NO_TRACE
103#define NO_TRACE_ACCEPT
104#define NO_TRACE_CLEAR
105#define NO_TRACE_CONNECT
106#define NO_TRACE_HIGH
107#define NO_TRACE_COMP
108#define NO_TRACE_TRSF
109#define NO_TRACE_DISPLAY
110#define NO_TRACE_ISCOMP
111#define NO_TRACE_LENGTH
112#define NO_TRACE_LAYER
113
114/*----------------------------------------------------------------------*/
115/*
116 * Includes
117 */
118
119#ifdef WNT
120#include <windows.h>
121#endif
122
123// for the class
124#include <Visual3d_View.ixx>
125#include <Visual3d_View.pxx>
126#include <Visual3d_DepthCueingDefinitionError.hxx>
127#include <Visual3d_ZClippingDefinitionError.hxx>
128
129#ifdef OLD_METHOD
130#include <math_Vector.hxx>
131#endif /* OLD_METHOD */
132
133#include <OSD.hxx>
134
135#include <Graphic3d_Structure.hxx>
136#include <Graphic3d_MapOfStructure.hxx>
137#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
138#include <Graphic3d_DataStructureManager.hxx>
139
140#include <Graphic3d_GraphicDriver.hxx>
7fd59977 141
142#include <Graphic3d_Vector.hxx>
143#include <Graphic3d_Vertex.hxx>
144
145#include <Visual3d_Light.hxx>
146#include <Visual3d_SetOfLight.hxx>
147#include <Visual3d_HSetOfLight.hxx>
148#include <Visual3d_SetIteratorOfSetOfLight.hxx>
149
7fd59977 150#include <Visual3d_SetIteratorOfSetOfView.hxx>
151
152#include <Graphic3d_TextureEnv.hxx>
153
154#include <TColStd_HArray2OfReal.hxx>
155
4fe56619 156#if (defined(_WIN32) || defined(__WIN32__))
157 #include <WNT_Window.hxx>
158#elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
159 #include <Cocoa_Window.hxx>
7fd59977 160#else
4fe56619 161 #include <Xw_Window.hxx>
162#endif
7fd59977 163
164#include <float.h>
165
166//-Aliases
167
168//-Global data definitions
169
170//-Constructors
171
172Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager):
173MyContext (),
174MyViewMapping (),
175MyViewMappingReset (),
176MyViewOrientation (),
177MyViewOrientationReset (),
178MyTransformation (0, 3, 0, 3),
179MyMatrixOfMapping (0, 3, 0, 3),
180MyMatrixOfOrientation (0, 3, 0, 3),
181MyTOCOMPUTESequence (),
182MyCOMPUTEDSequence (),
183MyDisplayedStructure ()
184{
185Standard_Integer i, j;
186
7fd59977 187 MyPtrViewManager = AManager.operator->();
7fd59977 188 MyCView.ViewId = int (AManager->Identification (this));
189 MyCView.Active = 0;
190 MyCView.IsDeleted = 0;
191
bf75be98 192 MyCView.WsId = -1;
193 MyCView.DefWindow.IsDefined = 0;
7fd59977 194
bf75be98 195 MyCView.Context.NbActiveLight = 0;
7fd59977 196
197 for (i=0; i<=3; i++)
198 for (j=0; j<=3; j++)
199 if (i == j) MyTransformation (i, j) = 1.0;
200 else MyTransformation (i, j) = 0.0;
201
202Standard_Real X, Y, Z;
203
204 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
205 MyCView.Orientation.ViewReferencePoint.x = float (X);
206 MyCView.Orientation.ViewReferencePoint.y = float (Y);
207 MyCView.Orientation.ViewReferencePoint.z = float (Z);
208 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
209 MyCView.Orientation.ViewReferencePlane.x = float (X);
210 MyCView.Orientation.ViewReferencePlane.y = float (Y);
211 MyCView.Orientation.ViewReferencePlane.z = float (Z);
212 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
213 MyCView.Orientation.ViewReferenceUp.x = float (X);
214 MyCView.Orientation.ViewReferenceUp.y = float (Y);
215 MyCView.Orientation.ViewReferenceUp.z = float (Z);
216
217Standard_Real Sx, Sy, Sz;
218
219 MyViewOrientation.AxialScale(Sx, Sy, Sz);
220 MyCView.Orientation.ViewScaleX = float (Sx);
221 MyCView.Orientation.ViewScaleY = float (Sy);
222 MyCView.Orientation.ViewScaleZ = float (Sz);
223
224 // NKV : 23/07/07 - Define custom MODELVIEW matrix
225 MyCView.Orientation.IsCustomMatrix = 0;
226 memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
227 MyCView.Orientation.ModelViewMatrix[0][0] =
228 MyCView.Orientation.ModelViewMatrix[1][1] =
229 MyCView.Orientation.ModelViewMatrix[2][2] =
230 MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
231 //
232
233Standard_Real um, vm, uM, vM;
234
235 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
236 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
237 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
238 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
239 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
240 MyCView.Mapping.ViewPlaneDistance =
241 float (MyViewMapping.ViewPlaneDistance ());
242 MyCView.Mapping.BackPlaneDistance =
243 float (MyViewMapping.BackPlaneDistance ());
244 MyCView.Mapping.FrontPlaneDistance =
245 float (MyViewMapping.FrontPlaneDistance ());
246 MyViewMapping.WindowLimit (um, vm, uM, vM);
247 MyCView.Mapping.WindowLimit.um = float (um);
248 MyCView.Mapping.WindowLimit.vm = float (vm);
249 MyCView.Mapping.WindowLimit.uM = float (uM);
250 MyCView.Mapping.WindowLimit.vM = float (vM);
251
252 // NKV : 23/07/07 - Define custom MODELVIEW matrix
253 MyCView.Mapping.IsCustomMatrix = 0;
254 memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
255 MyCView.Mapping.ProjectionMatrix[0][0] =
256 MyCView.Mapping.ProjectionMatrix[1][1] =
257 MyCView.Mapping.ProjectionMatrix[2][2] =
258 MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
259 //
260
261 MyCView.Context.ZBufferActivity = -1;
262
7fd59977 263 MyMatOfMapIsEvaluated = Standard_False;
264 MyMatOfOriIsEvaluated = Standard_False;
265
bd92cc2a 266 IsInitialized = Standard_False;
7fd59977 267 ComputedModeIsActive = Standard_False;
268 MyCView.Backfacing = 0;
7fd59977 269
7fd59977 270 MyCView.ptrUnderLayer = 0;
271 MyCView.ptrOverLayer = 0;
272 MyCView.GContext = 0;
273 MyCView.GDisplayCB = 0;
274 MyCView.GClientData = 0;
275
dc3fe572 276 MyGraphicDriver = MyViewManager->GraphicDriver();
7fd59977 277
278}
279
280Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager, const Visual3d_ViewOrientation& VO, const Visual3d_ViewMapping& VM, const Visual3d_ContextView& CTX):
281MyTransformation (0, 3, 0, 3),
282MyMatrixOfMapping (0, 3, 0, 3),
283MyMatrixOfOrientation (0, 3, 0, 3),
284MyTOCOMPUTESequence (),
285MyCOMPUTEDSequence (),
286MyDisplayedStructure ()
287{
288Standard_Integer i, j;
289
7fd59977 290 MyPtrViewManager = AManager.operator->();
7fd59977 291 MyViewOrientation = VO;
292 MyViewMapping = VM;
293 MyContext = CTX;
294 MyViewOrientationReset = VO;
295 MyViewMappingReset = VM;
296
7fd59977 297 MyCView.ViewId = int (AManager->Identification (this));
298 MyCView.Active = 0;
299 MyCView.IsDeleted = 0;
300
bf75be98 301 MyCView.WsId = -1;
302 MyCView.DefWindow.IsDefined = 0;
7fd59977 303
bf75be98 304 MyCView.Context.NbActiveLight = 0;
7fd59977 305
306 for (i=0; i<=3; i++)
307 for (j=0; j<=3; j++)
308 if (i == j) MyTransformation (i, j) = 1.0;
309 else MyTransformation (i, j) = 0.0;
310
311Standard_Real X, Y, Z;
312
313 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
314 MyCView.Orientation.ViewReferencePoint.x = float (X);
315 MyCView.Orientation.ViewReferencePoint.y = float (Y);
316 MyCView.Orientation.ViewReferencePoint.z = float (Z);
317 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
318 MyCView.Orientation.ViewReferencePlane.x = float (X);
319 MyCView.Orientation.ViewReferencePlane.y = float (Y);
320 MyCView.Orientation.ViewReferencePlane.z = float (Z);
321 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
322 MyCView.Orientation.ViewReferenceUp.x = float (X);
323 MyCView.Orientation.ViewReferenceUp.y = float (Y);
324 MyCView.Orientation.ViewReferenceUp.z = float (Z);
325
326Standard_Real Sx, Sy, Sz;
327
328 MyViewOrientation.AxialScale(Sx, Sy, Sz);
329 MyCView.Orientation.ViewScaleX = float (Sx);
330 MyCView.Orientation.ViewScaleY = float (Sy);
331 MyCView.Orientation.ViewScaleZ = float (Sz);
332
333 // NKV : 23/07/07 - Define custom MODELVIEW matrix
334 if (MyViewOrientation.IsCustomMatrix()) {
335 MyCView.Orientation.IsCustomMatrix = 1;
336 for ( i = 0; i < 4; i++)
337 for ( j = 0; j < 4; j++)
7f4c4756 338 MyCView.Orientation.ModelViewMatrix[i][j] =
339 (Standard_ShortReal)MyViewOrientation.MyModelViewMatrix->Value(i,j);
7fd59977 340 }
341 else {
342 MyCView.Orientation.IsCustomMatrix = 0;
343 memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
344 MyCView.Orientation.ModelViewMatrix[0][0] =
345 MyCView.Orientation.ModelViewMatrix[1][1] =
346 MyCView.Orientation.ModelViewMatrix[2][2] =
347 MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
348 }
349 //
350
351Standard_Real um, vm, uM, vM;
352
353 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
354 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
355 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
356 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
357 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
358 MyCView.Mapping.ViewPlaneDistance =
359 float (MyViewMapping.ViewPlaneDistance ());
360 MyCView.Mapping.BackPlaneDistance =
361 float (MyViewMapping.BackPlaneDistance ());
362 MyCView.Mapping.FrontPlaneDistance =
363 float (MyViewMapping.FrontPlaneDistance ());
364 MyViewMapping.WindowLimit (um, vm, uM, vM);
365 MyCView.Mapping.WindowLimit.um = float (um);
366 MyCView.Mapping.WindowLimit.vm = float (vm);
367 MyCView.Mapping.WindowLimit.uM = float (uM);
368 MyCView.Mapping.WindowLimit.vM = float (vM);
369
370 // NKV : 23/07/07 - Define custom MODELVIEW matrix
371 if (MyViewMapping.IsCustomMatrix()) {
372 MyCView.Mapping.IsCustomMatrix = 1;
373 for ( i = 0; i < 4; i++)
374 for ( j = 0; j < 4; j++)
7f4c4756 375 MyCView.Mapping.ProjectionMatrix[i][j] =
376 (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j);
7fd59977 377 }
378 else {
379 MyCView.Mapping.IsCustomMatrix = 0;
380 memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
381 MyCView.Mapping.ProjectionMatrix[0][0] =
382 MyCView.Mapping.ProjectionMatrix[1][1] =
383 MyCView.Mapping.ProjectionMatrix[2][2] =
384 MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
385 }
386 //
387
388 MyCView.Context.ZBufferActivity = -1;
389
7fd59977 390 MyMatOfMapIsEvaluated = Standard_False;
391 MyMatOfOriIsEvaluated = Standard_False;
bd92cc2a 392
393 IsInitialized = Standard_False;
7fd59977 394 ComputedModeIsActive = Standard_False;
7fd59977 395
7fd59977 396 MyCView.ptrUnderLayer = 0;
397 MyCView.ptrOverLayer = 0;
398 MyCView.GContext = 0;
399 MyCView.GDisplayCB = 0;
400 MyCView.GClientData = 0;
401
dc3fe572 402 MyGraphicDriver = MyViewManager->GraphicDriver();
7fd59977 403
404}
405
406//-Destructors
407
408//-Methods, in order
409// RIC120302
410void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow,
411 const Aspect_RenderingContext AContext,
412 const Aspect_GraphicCallbackProc& ADisplayCB,
413 const Standard_Address AClientData)
414{
415 if (IsDeleted ()) return;
416
417 if (IsDefined ())
418 Visual3d_ViewDefinitionError::Raise ("Window already defined");
419
420 MyCView.GContext = AContext;
421 MyCView.GDisplayCB = ADisplayCB;
422 MyCView.GClientData = AClientData;
423 SetWindow(AWindow);
424}
425// RIC120302
426
4fe56619 427void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow)
428{
7fd59977 429
430 if (IsDeleted ()) return;
431
432 if (IsDefined ())
433 Visual3d_ViewDefinitionError::Raise ("Window already defined");
434
4fe56619 435 MyWindow = theWindow;
7fd59977 436 MyCView.WsId = MyCView.ViewId;
437 MyCView.DefWindow.IsDefined = 1;
4fe56619 438
439#if (defined(_WIN32) || defined(__WIN32__))
440 const Handle(WNT_Window) aWin = Handle(WNT_Window)::DownCast (theWindow);
441 MyCView.DefWindow.XWindow = (HWND )(aWin->HWindow());
442 MyCView.DefWindow.XParentWindow = (HWND )(aWin->HParentWindow());
443 WNT_WindowData* aWinData = (WNT_WindowData* )GetWindowLongPtr ((HWND )(aWin->HWindow()), GWLP_USERDATA);
444 aWinData->WNT_WDriver_Ptr = (void* )this;
445 aWinData->WNT_VMgr = (void* )MyPtrViewManager;
446#elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
447 const Handle(Cocoa_Window) aWin = Handle(Cocoa_Window)::DownCast (theWindow);
448 MyCView.DefWindow.XWindow = (Aspect_Drawable )aWin->HView();
449 MyCView.DefWindow.XParentWindow = NULL;
450 //MyCView.DefWindow.XParentWindow = aWin->HParentWindow();
7fd59977 451#else
4fe56619 452 const Handle(Xw_Window) aWin = Handle(Xw_Window)::DownCast (theWindow);
453 MyCView.DefWindow.XWindow = aWin->XWindow();
ed97f43c 454 //MyCView.DefWindow.XParentWindow = aWin->XParentWindow();
7fd59977 455#endif
7fd59977 456
457 Standard_Integer Width, Height;
4fe56619 458 theWindow->Size (Width, Height);
7fd59977 459
460 MyCView.DefWindow.dx = float( Width );
461 MyCView.DefWindow.dy = float( Height );
462
463 Standard_Real R, G, B;
464 MyBackground = MyWindow->Background ();
465 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
466 MyCView.DefWindow.Background.r = float (R);
467 MyCView.DefWindow.Background.g = float (G);
468 MyCView.DefWindow.Background.b = float (B);
469
470 UpdateView ();
471 if (! MyGraphicDriver->View (MyCView))
472 Visual3d_ViewDefinitionError::Raise ("Association failed");
473
474 MyGradientBackground = MyWindow->GradientBackground();
475 SetGradientBackground(MyGradientBackground,1);
476
81bba717 477 Standard_Boolean AWait = Standard_False; // => immediate update
7fd59977 478 MyGraphicDriver->SetVisualisation (MyCView);
479 MyGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn ());
480 MyGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn ());
481 MyGraphicDriver->ClipLimit (MyCView, AWait);
482 MyGraphicDriver->Environment(MyCView);
483
71c4f9c6 484 // Make view manager z layer list consistent with the view's list.
485 MyViewManager->InstallZLayers (this);
486
81bba717 487 // Update planses of model clipping
7fd59977 488 UpdatePlanes ();
489
bf75be98 490 // Update light sources
7fd59977 491 UpdateLights ();
492
493 /*
81bba717 494 * Association view-window does not cause the display
495 * of structures that can be displayed in the new view.
496 * In fact, association view-window is done, but the
497 * display is produced only if the view is activated (Activate).
7fd59977 498 */
499
500 SetRatio ();
501
502}
503
504Handle(Aspect_Window) Visual3d_View::Window () const {
505
506 if (! IsDefined ())
507 Visual3d_ViewDefinitionError::Raise ("Window not defined");
508
509 return (MyWindow);
510
511}
512
513Standard_Boolean Visual3d_View::IsDefined () const {
514
515 if (MyCView.DefWindow.IsDefined)
516 return (Standard_True);
517 else
518 return (Standard_False);
519
520}
521
522Standard_Boolean Visual3d_View::IsDeleted () const {
523
524 if (MyCView.IsDeleted)
525 return (Standard_True);
526 else
527 return (Standard_False);
528
529}
530
531void Visual3d_View::Destroy () {
532
533#ifdef DESTROY
534 cout << "Visual3d_View::Destroy (" << Identification () << ")\n";
535#endif
536
537 // Since MyPtrViewManager can be already distroyed,
538 // avoid attempts to access it in SetBackground()
539 MyPtrViewManager = 0;
540 Remove ();
541
542}
543
544void Visual3d_View::Remove () {
545
546#ifdef DESTROY
547 cout << "Visual3d_View::Remove (" << Identification () << ")" << endl;
548#endif
549
550 if (IsDeleted ()) return;
551 if (! IsDefined ()) return;
552
553 MyTOCOMPUTESequence.Clear ();
554 MyCOMPUTEDSequence.Clear ();
555 MyDisplayedStructure.Clear ();
556
557 Quantity_Color BlackColor (0.0, 0.0, 0.0, Quantity_TOC_RGB);
558 Aspect_Background BlackBackground (BlackColor);
559 SetBackground (BlackBackground);
560
561 Aspect_GradientBackground BlackGradBackground;
562 SetGradientBackground (BlackGradBackground,0);
563
564 if (MyPtrViewManager)
565 MyPtrViewManager->UnIdentification( MyCView.ViewId );
566
567 MyGraphicDriver->RemoveView (MyCView);
568
569 MyCView.WsId = -1;
570 MyCView.IsDeleted = 1;
571 MyCView.DefWindow.IsDefined = 0;
572
7fd59977 573 MyMatOfMapIsEvaluated = Standard_False;
574 MyMatOfOriIsEvaluated = Standard_False;
575
bd92cc2a 576 IsInitialized = Standard_False;
577
7fd59977 578 MyWindow.Nullify ();
579
580}
581
582void Visual3d_View::Resized () {
583
584 if (IsDeleted ()) return;
585
586 if (! IsDefined ())
587 Visual3d_ViewDefinitionError::Raise ("Window not defined");
588 MyWindow->DoResize() ;
589 SetRatio ();
590
591}
592
593void Visual3d_View::SetRatio () {
594
595 if (IsDeleted ()) return;
596
597Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode ();
598 MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
599
600Standard_Real Umin, Vmin, Umax, Vmax;
601Standard_Integer Dxw, Dyw;
602Standard_Real Dxv, Dyv;
603Standard_Real Xc, Yc;
604Standard_Real Rap;
605
606 Rap = 0. ;
607 MyWindow->Size (Dxw, Dyw);
608 MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
609 Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
610 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
611 if( Dxw > 0 && Dyw > 0 ) Rap = (Standard_Real)Dyw/(Standard_Real)Dxw ;
612 if( Rap > 0.0 ) {
613
614 if( Dxv <= Dyv )
615 {
616 if (Rap <= 1.0)
617 {
618 Dyv = Dxv;
619 Dxv = Dxv/Rap;
620 }
621 else
622 {
623 Dxv = Dxv;
624 Dyv = Dxv*Rap;
625 }
626 }
627 else
628 {
629 if (Rap <= 1.0)
630 {
631 Dxv = Dyv/Rap;
632 Dyv = Dyv;
633 }
634 else
635 {
636 Dxv = Dyv;
637 Dyv = Dyv*Rap;
638 }
639 }
640
641 Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
642 Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
643
644 MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
645
81bba717 646 // Update before SetViewMapping.
7fd59977 647
648 MyCView.DefWindow.dx = float( Dxw );
649 MyCView.DefWindow.dy = float( Dyw );
650
651 SetViewMapping (MyViewMapping);
652// SetViewMappingDefault ();
81bba717 653 // FMN+ Update Ratio for MyViewMappingReset
7fd59977 654
655 MyViewMappingReset.WindowLimit(Umin,Vmin,Umax,Vmax) ;
656 Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
657 Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
658
659 if( Dxv <= Dyv )
660 {
661 if (Rap <= 1.0)
662 {
663 Dyv = Dxv;
664 Dxv = Dxv/Rap;
665 }
666 else
667 {
668 Dxv = Dxv;
669 Dyv = Dxv*Rap;
670 }
671 }
672 else
673 {
674 if (Rap <= 1.0)
675 {
676 Dxv = Dyv/Rap;
677 Dyv = Dyv;
678 }
679 else
680 {
681 Dxv = Dyv;
682 Dyv = Dyv*Rap;
683 }
684 }
685
686 Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
687 Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
688
689 MyViewMappingReset.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
690
81bba717 691 // FMN- Update Ratio for MyViewMappingReset
7fd59977 692
693 MyGraphicDriver->RatioWindow (MyCView);
694 }
695
81bba717 696 // Force recalculation of 2 matrices.
7fd59977 697 //
81bba717 698 // The current view can help to reconstruct a copied view
699 // that is itself. Owing to SetWindow and SetRatio the
700 // recalculation of matrices of this new view is imposed.
7fd59977 701 MyMatOfMapIsEvaluated = Standard_False;
702 MyMatOfOriIsEvaluated = Standard_False;
703
704 MyViewManager->SetUpdateMode (UpdateMode);
705 if (UpdateMode == Aspect_TOU_ASAP) Update ();
706
707}
708
709void Visual3d_View::UpdateLights () {
710
711Standard_Integer i, j;
712CALL_DEF_LIGHT *lights=NULL;
713
714#ifdef BUC60570
715 if( MyContext.Model() == Visual3d_TOM_NONE ) {
716// Activates only a white ambient light
717 MyCView.Context.NbActiveLight = 1;
718 lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
719 MyCView.Context.ActiveLight = lights;
720
721 lights[0].WsId = MyCView.ViewId;
722 lights[0].ViewId = MyCView.ViewId;
723 lights[0].LightType = int (Visual3d_TOLS_AMBIENT);
724 lights[0].Active = 1;
725 lights[0].LightId = 0;
726 lights[0].Headlight = 0;
727 lights[0].Color.r = lights[0].Color.g = lights[0].Color.b = 1.;
728 } else {
729#endif
730 i = MyContext.NumberOfActivatedLights ();
731 j = MyGraphicDriver->InquireLightLimit ();
732 MyCView.Context.NbActiveLight = (i > j ? j : i);
733
734 if (MyCView.Context.NbActiveLight > 0) {
735
81bba717 736 // Dynamic Allocation
7fd59977 737 lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
738
739 MyCView.Context.ActiveLight = lights;
740
741Standard_Real X, Y, Z;
742
1d47d8d0 743Standard_Real LightConcentration = 0.;
744Standard_Real LightAttenuation1 = 0.;
745Standard_Real LightAttenuation2 = 0.;
746Standard_Real LightAngle = 0.;
7fd59977 747Quantity_Color LightColor;
748Graphic3d_Vertex LightPosition;
749Graphic3d_Vector LightDirection;
750Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT;
751
81bba717 752 // Parcing of light sources
7fd59977 753 for (j=0; j<MyCView.Context.NbActiveLight; j++) {
754 LightType = (MyContext.ActivatedLight (j+1))->LightType ();
755
756 lights[j].WsId = MyCView.ViewId;
757 lights[j].ViewId = MyCView.ViewId;
758
759 lights[j].LightType = int (LightType);
760 lights[j].Active = 1;
761 lights[j].LightId =
762 int ((MyContext.ActivatedLight (j+1))->Identification ());
763 lights[j].Headlight = (MyContext.ActivatedLight (j+1))->Headlight ()? 1:0;
764
765 switch (LightType) {
766
767 case Visual3d_TOLS_AMBIENT :
768 (MyContext.ActivatedLight (j+1))->Values (
769 LightColor
770 );
771 break;
772
773 case Visual3d_TOLS_POSITIONAL :
774 (MyContext.ActivatedLight (j+1))->Values (
775 LightColor,
776 LightPosition,
777 LightAttenuation1,
778 LightAttenuation2
779 );
780 break;
781
782 case Visual3d_TOLS_DIRECTIONAL :
783 (MyContext.ActivatedLight (j+1))->Values (
784 LightColor,
785 LightDirection
786 );
787 break;
788
789 case Visual3d_TOLS_SPOT :
790 (MyContext.ActivatedLight (j+1))->Values (
791 LightColor,
792 LightPosition,
793 LightDirection,
794 LightConcentration,
795 LightAttenuation1,
796 LightAttenuation2,
797 LightAngle
798 );
799 break;
800
801 }
802
803 lights[j].Color.r = float (LightColor.Red ());
804 lights[j].Color.g = float (LightColor.Green ());
805 lights[j].Color.b = float (LightColor.Blue ());
806
807 if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
808 (LightType == Visual3d_TOLS_SPOT) ) {
809 LightPosition.Coord (X, Y, Z);
810 lights[j].Position.x = float (X);
811 lights[j].Position.y = float (Y);
812 lights[j].Position.z = float (Z);
813 }
814
815 if ( (LightType == Visual3d_TOLS_DIRECTIONAL) ||
816 (LightType == Visual3d_TOLS_SPOT) ) {
817 LightDirection.Coord (X, Y, Z);
818 lights[j].Direction.x = float (X);
819 lights[j].Direction.y = float (Y);
820 lights[j].Direction.z = float (Z);
821 }
822
823 if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
824 (LightType == Visual3d_TOLS_SPOT) ) {
825 lights[j].Attenuation[0] =
826 float (LightAttenuation1);
827 lights[j].Attenuation[1] =
828 float (LightAttenuation2);
829 }
830
831 if (LightType == Visual3d_TOLS_SPOT) {
832 lights[j].Concentration =
833 float (LightConcentration);
834 lights[j].Angle =
835 float (LightAngle);
836 }
837 }
838
839 }
840#ifdef BUC60570
841 }
842#endif
81bba717 843 // management of light sources
7fd59977 844 if (! IsDeleted ())
845 if (IsDefined ())
846 MyGraphicDriver->SetLight (MyCView);
847
81bba717 848 // Dynamic allocation
7fd59977 849 if (MyCView.Context.NbActiveLight > 0) delete [] lights;
850
851}
852
4269bd1b 853void Visual3d_View::UpdatePlanes()
854{
855 MyCView.Context.ClipPlanes = MyContext.GetClipPlanes();
856
857 if (IsDeleted() || !IsDefined())
858 return;
7fd59977 859
4269bd1b 860 MyGraphicDriver->SetClipPlanes (MyCView);
7fd59977 861}
862
863void Visual3d_View::SetBackground (const Aspect_Background& ABack) {
864
865 if (IsDeleted ()) return;
866
867 if (! IsDefined ())
868 Visual3d_ViewDefinitionError::Raise ("Window not defined");
869
81bba717 870 // At this level, only GL can update the background.
871 // It is not necessary to call MyWindow->SetBackground (ABack); as
872 // this method starts update of window background by X
873 // (if the windowing is X)
7fd59977 874
875 Standard_Real R, G, B;
876 MyBackground = ABack;
877 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
878 MyCView.DefWindow.Background.r = float (R);
879 MyCView.DefWindow.Background.g = float (G);
880 MyCView.DefWindow.Background.b = float (B);
881
882 MyGraphicDriver->Background (MyCView);
883
884 if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
885 Update ();
886
887}
888
889void Visual3d_View::SetGradientBackground(const Aspect_GradientBackground& ABack, const Standard_Boolean update)
890{
891
892 if (IsDeleted ()) return;
893
894 if (! IsDefined ())
895 Visual3d_ViewDefinitionError::Raise ("Window not defined");
896
897 MyGradientBackground = ABack;
898 Quantity_Color aCol1,aCol2;
899 MyGradientBackground.Colors(aCol1,aCol2);
900 MyGraphicDriver->GradientBackground(MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod());
901
902 if ( update )
903 Update ();
904 else if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
905 Update();
906}
907
908void Visual3d_View::SetBackgroundImage( const Standard_CString FileName,
909 const Aspect_FillMethod FillStyle,
910 const Standard_Boolean update )
911{
7fd59977 912 if ( IsDeleted() )
913 return;
914 if ( !IsDefined() )
915 Visual3d_ViewDefinitionError::Raise ("Window not defined");
916
917 MyGraphicDriver->BackgroundImage( FileName, MyCView, FillStyle );
918
919 if ( update )
920 Update();
921 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
922 Update();
7fd59977 923}
924
925void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
926 const Standard_Boolean update )
927{
7fd59977 928 if ( IsDeleted() )
929 return;
930 if ( !IsDefined() )
931 Visual3d_ViewDefinitionError::Raise ("Window not defined");
932
933 MyGraphicDriver->SetBgImageStyle( MyCView, FillStyle );
934
935 if ( update )
936 Update();
937 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
938 Update();
7fd59977 939}
940
941Aspect_Background Visual3d_View::Background () const {
942
943 return (MyBackground);
944
945}
946
947void Visual3d_View::SetBgGradientStyle( const Aspect_GradientFillMethod FillStyle,
948 const Standard_Boolean update )
949{
950 if ( IsDeleted() )
951 return;
952 if ( !IsDefined() )
953 Visual3d_ViewDefinitionError::Raise ("Window not defined");
954
955 MyGraphicDriver->SetBgGradientStyle( MyCView, FillStyle );
956
957 if ( update )
958 Update();
959 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
960 Update();
961
962}
963
964Aspect_GradientBackground Visual3d_View::GradientBackground () const {
965
966 return MyGradientBackground;
967
968}
969
970void Visual3d_View::SetTransform (const TColStd_Array2OfReal& AMatrix) {
971
972 if (IsDeleted ()) return;
973
974Standard_Integer lr, ur, lc, uc;
975Standard_Integer i, j;
976
977 // Assign the new transformation in an array [0..3][0..3]
81bba717 978 // Avoid problems if the has defined a matrice [1..4][1..4]
7fd59977 979 // ou [3..6][-1..2] !!
980 lr = AMatrix.LowerRow ();
981 ur = AMatrix.UpperRow ();
982 lc = AMatrix.LowerCol ();
983 uc = AMatrix.UpperCol ();
984
985 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
986 Visual3d_TransformError::Raise ("Transform : not a 4x4 matrix");
987
988 for (i=0; i<=3; i++)
989 for (j=0; j<=3; j++)
990 MyTransformation (i, j) = AMatrix (lr + i, lc + j);
991
992Graphic3d_Vector VPN;
993Graphic3d_Vertex VRP;
994Graphic3d_Vector VUP;
995Standard_Real Sx, Sy, Sz;
996
997Visual3d_ViewOrientation NewViewOrientation;
998
999 VPN = MyViewOrientation.ViewReferencePlane ();
1000 VRP = MyViewOrientation.ViewReferencePoint ();
1001 VUP = MyViewOrientation.ViewReferenceUp ();
1002 MyViewOrientation.AxialScale(Sx, Sy, Sz);
1003
1004 NewViewOrientation.SetViewReferencePlane
1005 (Graphic3d_Structure::Transforms (Transform (), VPN));
1006
1007 NewViewOrientation.SetViewReferencePoint
1008 (Graphic3d_Structure::Transforms (Transform (), VRP));
1009
1010 NewViewOrientation.SetViewReferenceUp
1011 (Graphic3d_Structure::Transforms (Transform (), VUP));
1012 NewViewOrientation.SetAxialScale(Sx, Sy, Sz);
1013
1014 SetViewOrientation (NewViewOrientation);
1015
7fd59977 1016 MyMatOfOriIsEvaluated = Standard_False;
1017
1018}
1019
1020const TColStd_Array2OfReal& Visual3d_View::Transform () const {
1021
1022 return (MyTransformation);
1023
1024}
1025
1026void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
1027
1028 if (IsDeleted ()) return;
1029
1030 MyViewOrientation = VO;
ed97f43c 1031
bd92cc2a 1032 Standard_Real X, Y, Z;
81bba717 1033 // Tests on modification of parameters.
bd92cc2a 1034 Standard_Boolean VUPIsModified = Standard_False;
1035 Standard_Boolean VRPIsModified = Standard_False;
1036 Standard_Boolean VRUIsModified = Standard_False;
1037 Standard_Boolean ScaleIsModified = Standard_False;
1038 Standard_Boolean CustomIsModified = Standard_False;
7fd59977 1039
1040 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
1041 VUPIsModified =
bd92cc2a 1042 MyCView.Orientation.ViewReferencePoint.x != float (X)
1043 || MyCView.Orientation.ViewReferencePoint.y != float (Y)
1044 || MyCView.Orientation.ViewReferencePoint.z != float (Z);
7fd59977 1045 MyCView.Orientation.ViewReferencePoint.x = float (X);
1046 MyCView.Orientation.ViewReferencePoint.y = float (Y);
1047 MyCView.Orientation.ViewReferencePoint.z = float (Z);
1048
1049 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
1050 VRPIsModified =
bd92cc2a 1051 MyCView.Orientation.ViewReferencePlane.x != float (X)
1052 || MyCView.Orientation.ViewReferencePlane.y != float (Y)
1053 || MyCView.Orientation.ViewReferencePlane.z != float (Z);
7fd59977 1054 MyCView.Orientation.ViewReferencePlane.x = float (X);
1055 MyCView.Orientation.ViewReferencePlane.y = float (Y);
1056 MyCView.Orientation.ViewReferencePlane.z = float (Z);
1057
1058 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
1059 VRUIsModified =
bd92cc2a 1060 MyCView.Orientation.ViewReferenceUp.x != float (X)
1061 || MyCView.Orientation.ViewReferenceUp.y != float (Y)
1062 || MyCView.Orientation.ViewReferenceUp.z != float (Z);
7fd59977 1063 MyCView.Orientation.ViewReferenceUp.x = float (X);
1064 MyCView.Orientation.ViewReferenceUp.y = float (Y);
1065 MyCView.Orientation.ViewReferenceUp.z = float (Z);
1066
bd92cc2a 1067 MyViewOrientation.AxialScale(X, Y, Z);
1068 ScaleIsModified =
1069 MyCView.Orientation.ViewScaleX != float (X)
1070 || MyCView.Orientation.ViewScaleY != float (Y)
1071 || MyCView.Orientation.ViewScaleZ != float (Z);
1072 MyCView.Orientation.ViewScaleX = float (X);
1073 MyCView.Orientation.ViewScaleY = float (Y);
1074 MyCView.Orientation.ViewScaleZ = float (Z);
7fd59977 1075
1076 CustomIsModified =
498ce76b 1077 (MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix());
7fd59977 1078 MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
1079 if ( MyViewOrientation.IsCustomMatrix() ) {
1080 Standard_Integer i, j;
1081 for (i = 0; i < 4; i++)
1082 for (j = 0; j < 4; j++) {
bd92cc2a 1083 if (!CustomIsModified) CustomIsModified =
1084 MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
7fd59977 1085 }
1086 }
1087
1088#ifdef TRACE_TRSF
bd92cc2a 1089 cout << "Visual3d_View::SetViewOrientation\n";
1090 if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified)
1091 cout << "VUPIsModified : " << VUPIsModified
1092 << ", VRPIsModified : " << VRPIsModified
1093 << ", VRUIsModified : " << VRUIsModified
1094 << ", CustomIsModified : " << CustomIsModified
1095 << ", ScaleIsModified : " << ScaleIsModified << "\n" << flush;
7fd59977 1096 else
bd92cc2a 1097 cout << "no modification\n" << flush;
7fd59977 1098#endif
1099
81bba717 1100 // restart if one of parameters is modified
bd92cc2a 1101 if (!IsInitialized || VUPIsModified || VRPIsModified
1102 || VRUIsModified || ScaleIsModified || CustomIsModified) {
7fd59977 1103
bd92cc2a 1104 MyMatOfOriIsEvaluated = !VUPIsModified && !VRPIsModified
1105 && !VRUIsModified && !ScaleIsModified;
ed97f43c 1106
bd92cc2a 1107 if (! IsDefined ()) return;
ed97f43c 1108
bd92cc2a 1109 Standard_Boolean AWait = Standard_False; // => immediate update
1110 MyGraphicDriver->ViewOrientation (MyCView, AWait);
1111 IsInitialized = Standard_True;
1112 Compute ();
7fd59977 1113
bd92cc2a 1114 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
7fd59977 1115 }
1116
1117}
1118
1119Visual3d_ViewOrientation Visual3d_View::ViewOrientation () const {
1120
1121 return (MyViewOrientation);
1122
1123}
1124
1125Visual3d_ViewOrientation Visual3d_View::ViewOrientationDefault () const {
1126
1127 return (MyViewOrientationReset);
1128
1129}
1130
1131void Visual3d_View::SetViewOrientationDefault () {
1132
1133 MyViewOrientationReset.Assign (MyViewOrientation);
1134
1135}
1136
1137void Visual3d_View::ViewOrientationReset () {
1138
1139 if (IsDeleted ()) return;
1140
1141 MyViewOrientation = MyViewOrientationReset;
1142
bd92cc2a 1143 Standard_Real X, Y, Z;
7fd59977 1144
81bba717 1145 // Tests on modification of parameters.
bd92cc2a 1146 Standard_Boolean VUPIsModified = Standard_False;
1147 Standard_Boolean VRPIsModified = Standard_False;
1148 Standard_Boolean VRUIsModified = Standard_False;
1149 Standard_Boolean ScaleIsModified = Standard_False;
1150 Standard_Boolean CustomIsModified = Standard_False;
7fd59977 1151
1152 (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
1153 VUPIsModified =
bd92cc2a 1154 MyCView.Orientation.ViewReferencePoint.x != float (X)
1155 || MyCView.Orientation.ViewReferencePoint.y != float (Y)
1156 || MyCView.Orientation.ViewReferencePoint.z != float (Z);
7fd59977 1157 MyCView.Orientation.ViewReferencePoint.x = float (X);
1158 MyCView.Orientation.ViewReferencePoint.y = float (Y);
1159 MyCView.Orientation.ViewReferencePoint.z = float (Z);
1160
1161 (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
1162 VRPIsModified =
bd92cc2a 1163 MyCView.Orientation.ViewReferencePlane.x != float (X)
1164 || MyCView.Orientation.ViewReferencePlane.y != float (Y)
1165 || MyCView.Orientation.ViewReferencePlane.z != float (Z);
7fd59977 1166 MyCView.Orientation.ViewReferencePlane.x = float (X);
1167 MyCView.Orientation.ViewReferencePlane.y = float (Y);
1168 MyCView.Orientation.ViewReferencePlane.z = float (Z);
1169
1170 (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
1171 VRUIsModified =
bd92cc2a 1172 MyCView.Orientation.ViewReferenceUp.x != float (X)
1173 || MyCView.Orientation.ViewReferenceUp.y != float (Y)
1174 || MyCView.Orientation.ViewReferenceUp.z != float (Z);
7fd59977 1175 MyCView.Orientation.ViewReferenceUp.x = float (X);
1176 MyCView.Orientation.ViewReferenceUp.y = float (Y);
1177 MyCView.Orientation.ViewReferenceUp.z = float (Z);
1178
bd92cc2a 1179 MyViewOrientation.AxialScale(X, Y, Z);
1180 ScaleIsModified =
1181 MyCView.Orientation.ViewScaleX != float (X)
1182 || MyCView.Orientation.ViewScaleY != float (Y)
1183 || MyCView.Orientation.ViewScaleZ != float (Z);
1184 MyCView.Orientation.ViewScaleX = float (X);
1185 MyCView.Orientation.ViewScaleY = float (Y);
1186 MyCView.Orientation.ViewScaleZ = float (Z);
7fd59977 1187
1188 CustomIsModified =
bd92cc2a 1189 MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
7fd59977 1190 MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
1191 if ( MyViewOrientation.IsCustomMatrix() ) {
1192 Standard_Integer i, j;
1193 for (i = 0; i < 4; i++)
1194 for (j = 0; j < 4; j++) {
bd92cc2a 1195 if (!CustomIsModified) CustomIsModified =
1196 MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
7fd59977 1197 }
1198 }
1199
bd92cc2a 1200
7fd59977 1201#ifdef TRACE_TRSF
bd92cc2a 1202 cout << "Visual3d_View::ViewOrientationReset\n";
1203 if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified)
1204 cout << "VUPIsModified : " << VUPIsModified
1205 << ", VRPIsModified : " << VRPIsModified
1206 << ", VRUIsModified : " << VRUIsModified
1207 << ", CustomIsModified : " << CustomIsModified
1208 << ", ScaleIsModified : " << ScaleIsModified << "\n" << flush;
1209 else
1210 cout << "no modification\n" << flush;
7fd59977 1211#endif
1212
81bba717 1213 // Restart if one of parameters is modified
bd92cc2a 1214 if (!IsInitialized || VUPIsModified || VRPIsModified
1215 || VRUIsModified || ScaleIsModified || CustomIsModified) {
ed97f43c 1216
bd92cc2a 1217 MyMatOfOriIsEvaluated = !VUPIsModified && !VRPIsModified
1218 && !VRUIsModified && !ScaleIsModified;
7fd59977 1219
bd92cc2a 1220 if (! IsDefined ()) return;
7fd59977 1221
bd92cc2a 1222 Standard_Boolean AWait = Standard_False; // => immediate update
1223 MyGraphicDriver->ViewOrientation (MyCView, AWait);
1224 IsInitialized = Standard_True;
1225 Compute ();
7fd59977 1226
bd92cc2a 1227 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
7fd59977 1228 }
7fd59977 1229}
1230
1231void Visual3d_View::SetViewMapping (const Visual3d_ViewMapping& VM) {
1232
1233 if (IsDeleted ()) return;
1234
1235Visual3d_TypeOfProjection OldType = MyViewMapping.Projection ();
1236Visual3d_TypeOfProjection NewType = VM.Projection ();
1237
1238 MyViewMapping = VM;
1239
1240Standard_Real X, Y, Z;
1241Standard_Real um, vm, uM, vM;
1242
1243 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
1244 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
1245 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
1246 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
1247 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
1248 MyCView.Mapping.ViewPlaneDistance =
1249 float (MyViewMapping.ViewPlaneDistance ());
1250 MyCView.Mapping.BackPlaneDistance =
1251 float (MyViewMapping.BackPlaneDistance ());
1252 MyCView.Mapping.FrontPlaneDistance =
1253 float (MyViewMapping.FrontPlaneDistance ());
1254 MyViewMapping.WindowLimit (um, vm, uM, vM);
1255 MyCView.Mapping.WindowLimit.um = float (um);
1256 MyCView.Mapping.WindowLimit.vm = float (vm);
1257 MyCView.Mapping.WindowLimit.uM = float (uM);
1258 MyCView.Mapping.WindowLimit.vM = float (vM);
1259
1260 MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
1261 if (MyViewMapping.IsCustomMatrix()) {
1262 Standard_Integer i, j;
1263 for (i = 0; i < 4; i++)
1264 for (j = 0; j < 4; j++)
1265 MyCView.Mapping.ProjectionMatrix[i][j] =
7f4c4756 1266 (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j);
7fd59977 1267 }
1268
7fd59977 1269 MyMatOfMapIsEvaluated = Standard_False;
1270
1271 if (! IsDefined ()) return;
1272
81bba717 1273Standard_Boolean AWait = Standard_False; // => immediate update
7fd59977 1274 MyGraphicDriver->ViewMapping (MyCView, AWait);
1275
1276 // Passage Parallele/Perspective
1277 if (OldType != NewType)
1278 Compute ();
1279
1280 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1281
1282}
1283
1284Visual3d_ViewMapping Visual3d_View::ViewMapping () const {
1285
1286 return (MyViewMapping);
1287
1288}
1289
1290Visual3d_ViewMapping Visual3d_View::ViewMappingDefault () const {
1291
1292 return (MyViewMappingReset);
1293
1294}
1295
1296void Visual3d_View::SetViewMappingDefault () {
1297
1298 MyViewMappingReset.Assign (MyViewMapping);
1299
1300}
1301
1302void Visual3d_View::ViewMappingReset () {
1303
1304 if (IsDeleted ()) return;
1305
1306 MyViewMapping = MyViewMappingReset;
1307
1308Standard_Real X, Y, Z;
1309Standard_Real um, vm, uM, vM;
1310
1311 MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
1312 (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
1313 MyCView.Mapping.ProjectionReferencePoint.x = float (X);
1314 MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
1315 MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
1316 MyCView.Mapping.ViewPlaneDistance =
1317 float (MyViewMapping.ViewPlaneDistance ());
1318 MyCView.Mapping.BackPlaneDistance =
1319 float (MyViewMapping.BackPlaneDistance ());
1320 MyCView.Mapping.FrontPlaneDistance =
1321 float (MyViewMapping.FrontPlaneDistance ());
1322 MyViewMapping.WindowLimit (um, vm, uM, vM);
1323 MyCView.Mapping.WindowLimit.um = float (um);
1324 MyCView.Mapping.WindowLimit.vm = float (vm);
1325 MyCView.Mapping.WindowLimit.uM = float (uM);
1326 MyCView.Mapping.WindowLimit.vM = float (vM);
1327
1328 MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
1329 if (MyViewMapping.IsCustomMatrix()) {
1330 Standard_Integer i, j;
1331 for (i = 0; i < 4; i++)
1332 for (j = 0; j < 4; j++)
1333 MyCView.Mapping.ProjectionMatrix[i][j] =
7f4c4756 1334 (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j);
7fd59977 1335 }
1336
7fd59977 1337 MyMatOfMapIsEvaluated = Standard_False;
1338
1339 if (! IsDefined ()) return;
1340
81bba717 1341Standard_Boolean AWait = Standard_False; // => immediate update
7fd59977 1342 MyGraphicDriver->ViewMapping (MyCView, AWait);
1343
1344 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1345
1346}
1347
1348void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
1349
1350 if (IsDeleted ()) return;
1351
1352Visual3d_TypeOfVisualization OldVisualMode;
1353Visual3d_TypeOfVisualization NewVisualMode;
1354
bf75be98 1355 // To manage display only in case of
81bba717 1356 // change of visualisation mode.
7fd59977 1357 OldVisualMode = MyContext.Visualization ();
1358 NewVisualMode = CTX.Visualization ();
1359
1360Visual3d_TypeOfModel OldModel;
1361Visual3d_TypeOfModel NewModel;
1362
bf75be98 1363 // To manage change of visualisation only in case
81bba717 1364 // of change of mode of visualisation or of type of shading.
7fd59977 1365 OldModel = MyContext.Model ();
1366 NewModel = CTX.Model ();
1367
1368Standard_Boolean OldAliasingMode;
1369Standard_Boolean NewAliasingMode;
1370
81bba717 1371 // To manage antialiasing only in case of change.
7fd59977 1372 OldAliasingMode = MyContext.AliasingIsOn ();
1373 NewAliasingMode = CTX.AliasingIsOn ();
1374
1375Standard_Boolean OldDepthCueingMode;
1376Standard_Boolean NewDepthCueingMode;
1377
1378Standard_Real OldDepthCueingFrontPlane;
1379Standard_Real NewDepthCueingFrontPlane;
1380Standard_Real OldDepthCueingBackPlane;
1381Standard_Real NewDepthCueingBackPlane;
1382
81bba717 1383 // To manage the depth cueing only in case of change.
7fd59977 1384 OldDepthCueingMode = MyContext.DepthCueingIsOn ();
1385 NewDepthCueingMode = CTX.DepthCueingIsOn ();
1386
1387 OldDepthCueingFrontPlane = MyContext.DepthCueingFrontPlane ();
1388 NewDepthCueingFrontPlane = CTX.DepthCueingFrontPlane ();
1389 OldDepthCueingBackPlane = MyContext.DepthCueingBackPlane ();
1390 NewDepthCueingBackPlane = CTX.DepthCueingBackPlane ();
1391
1392Standard_Boolean OldFrontZClippingMode;
1393Standard_Boolean NewFrontZClippingMode;
1394Standard_Boolean OldBackZClippingMode;
1395Standard_Boolean NewBackZClippingMode;
1396
1397Standard_Real OldZClippingFrontPlane;
1398Standard_Real NewZClippingFrontPlane;
1399Standard_Real OldZClippingBackPlane;
1400Standard_Real NewZClippingBackPlane;
1401
81bba717 1402 // To manage the Zclipping only in case of change.
7fd59977 1403 OldFrontZClippingMode = MyContext.FrontZClippingIsOn ();
1404 NewFrontZClippingMode = CTX.FrontZClippingIsOn ();
1405 OldBackZClippingMode = MyContext.BackZClippingIsOn ();
1406 NewBackZClippingMode = CTX.BackZClippingIsOn ();
1407
1408 OldZClippingFrontPlane = MyContext.ZClippingFrontPlane ();
1409 NewZClippingFrontPlane = CTX.ZClippingFrontPlane ();
1410 OldZClippingBackPlane = MyContext.ZClippingBackPlane ();
1411 NewZClippingBackPlane = CTX.ZClippingBackPlane ();
1412
bf75be98 1413 Handle(Graphic3d_TextureEnv) aTexEnvOld = MyContext.TextureEnv();
1414 Handle(Graphic3d_TextureEnv) aTexEnvNew = CTX.TextureEnv();
7fd59977 1415
bf75be98 1416 Visual3d_TypeOfSurfaceDetail OldSurfaceDetail = MyContext.SurfaceDetail();
1417 Visual3d_TypeOfSurfaceDetail NewSurfaceDetail = CTX.SurfaceDetail();
7fd59977 1418
1419 MyContext = CTX;
1420
1421 UpdateView ();
1422
81bba717 1423Standard_Boolean AWait = Standard_False; // => immediate update
7fd59977 1424 if (IsDefined ()) {
81bba717 1425 // management of visualization modes and types of shading.
7fd59977 1426 if ((OldVisualMode != NewVisualMode) || (OldModel != NewModel))
1427 MyGraphicDriver->SetVisualisation (MyCView);
1428
81bba717 1429 // management of antialiasing.
7fd59977 1430 if (OldAliasingMode != NewAliasingMode)
1431 MyGraphicDriver->AntiAliasing (MyCView, NewAliasingMode);
1432
81bba717 1433 // management of depth_cueing.
7fd59977 1434 if ((OldDepthCueingMode != NewDepthCueingMode) ||
1435 (OldDepthCueingFrontPlane != NewDepthCueingFrontPlane) ||
1436 (OldDepthCueingBackPlane != NewDepthCueingBackPlane)) {
1437#ifdef BUC60572
1438 if( NewDepthCueingMode &&
1439 (NewDepthCueingBackPlane >= NewDepthCueingFrontPlane) )
1440 Visual3d_DepthCueingDefinitionError::Raise
1441 ("Bad value for DepthCueingPlanes position");
1442#endif
1443 MyGraphicDriver->DepthCueing
1444 (MyCView, NewDepthCueingMode);
1445 }
1446
81bba717 1447 // management of Zclipping
7fd59977 1448 if ((OldFrontZClippingMode != NewFrontZClippingMode) ||
1449 (OldBackZClippingMode != NewBackZClippingMode) ||
1450 (OldZClippingFrontPlane != NewZClippingFrontPlane) ||
1451 (OldZClippingBackPlane != NewZClippingBackPlane)) {
1452#ifdef BUC60572
1453 if( NewBackZClippingMode && NewFrontZClippingMode &&
1454 (NewZClippingBackPlane >= NewZClippingFrontPlane) )
1455 Visual3d_ZClippingDefinitionError::Raise
1456 ("Bad value for ZClippingPlanes position");
1457#endif
1458 MyGraphicDriver->ClipLimit (MyCView, AWait);
1459 }
1460
81bba717 1461 // management of textures
bf75be98 1462 if ((aTexEnvOld != aTexEnvNew) || (OldSurfaceDetail != NewSurfaceDetail))
1463 {
7fd59977 1464 MyGraphicDriver->Environment(MyCView);
bf75be98 1465 }
7fd59977 1466
81bba717 1467 // Update of planes of model clipping
7fd59977 1468 UpdatePlanes ();
1469
bf75be98 1470 // Update of light sources
7fd59977 1471 UpdateLights ();
1472 }
1473
1474 if (OldVisualMode != NewVisualMode) {
1475
1476 /*
81bba717 1477 * Change of context =>
1478 * Remove structures that cannot be displayed
1479 * in the new visualisation mode.
1480 * It is not necessary to warn ViewManager as
1481 * this structure should not disappear from
1482 * the list of structures displayed in it.
7fd59977 1483 */
1484Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
1485Visual3d_TypeOfAnswer Answer;
1486
1487 Standard_Integer i = MyDisplayedStructure.Extent ();
1488
1489Graphic3d_SequenceOfStructure FooSequence;
1490
1491 while (S1Iterator.More ()) {
1492 Answer = AcceptDisplay (S1Iterator.Key ());
bf75be98 1493 // If the structure can't be displayed in the
81bba717 1494 // new context of the view, it is removed.
7fd59977 1495 if ((Answer == Visual3d_TOA_NO) ||
1496 (Answer == Visual3d_TOA_COMPUTE))
1497 //Erase (S1Iterator.Key (), Aspect_TOU_WAIT);
1498 FooSequence.Append (S1Iterator.Key ());
1499
81bba717 1500 // S1Iterator.Next () is located on the next structure
7fd59977 1501 S1Iterator.Next ();
1502 }
1503
1504Standard_Integer Length = FooSequence.Length ();
81bba717 1505 // The stored structures are removed
7fd59977 1506 for (i=1; i<=Length; i++)
1507 Erase (FooSequence.Value (i), Aspect_TOU_WAIT);
1508 if (Length != 0) FooSequence.Clear ();
1509
1510 /*
81bba717 1511 * Change of context =>
bf75be98 1512 * Display structures that can be displayed
81bba717 1513 * with the new visualisation mode.
bf75be98 1514 * All structures with status Displayed are removed from the ViewManager
1515 * and displayed in the view directly, if the structure is not already
81bba717 1516 * displayed and if the view accepts it in its context.
7fd59977 1517 */
1518
1519 i = MyViewManager->NumberOfDisplayedStructures ();
1520 Graphic3d_MapOfStructure Map;
1521 MyViewManager->DisplayedStructures(Map);
1522 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1523
1524 for (; it.More(); it.Next()) {
1525 Handle(Graphic3d_Structure) SG = it.Key();
1526 if (! IsDisplayed (SG)) {
1527 Answer = AcceptDisplay(SG);
bf75be98 1528 // If the structure can be displayed in the
81bba717 1529 // new context of the view, it is displayed.
7fd59977 1530 if ((Answer == Visual3d_TOA_YES) ||
1531 (Answer == Visual3d_TOA_COMPUTE))
1532 //Display (MyViewManager->DisplayedStructure (j),
1533 //Aspect_TOU_WAIT);
1534 FooSequence.Append (SG);
1535 }
1536 }
1537
1538 Length = FooSequence.Length ();
81bba717 1539 // The stored structures are displayed
7fd59977 1540 for (i=1; i<=Length; i++)
1541 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
1542 if (Length != 0) FooSequence.Clear ();
1543 }
1544
1545 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1546
1547}
1548
1549const Visual3d_ContextView& Visual3d_View::Context () const {
1550
1551 return (MyContext);
1552
1553}
1554
1555void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& SG) const
1556{
1557
1558 if (IsDeleted ()) return;
1559
1560 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
1561
1562 while (Iterator.More ()) {
1563 SG.Add (Iterator.Key ());
1564
81bba717 1565 // Iterator.Next () is located on the next structure
7fd59977 1566 Iterator.Next ();
1567 }
1568
1569}
1570
1571void Visual3d_View::Activate () {
1572
1573 if (IsDeleted ()) return;
1574
1575 if (! IsDefined ())
1576 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1577
1578 if (! IsActive ()) {
1579
1580 MyGraphicDriver->ActivateView (MyCView);
1581 MyGraphicDriver->Background (MyCView);
1582 MyGraphicDriver->Transparency
1583 (MyCView, MyViewManager->Transparency ());
1584
1585 MyCView.Active = 1;
1586
1587 /*
81bba717 1588 * Activation of a new view =>
1589 * Display structures that can be displayed in this new view.
1590 * All structures with status
bf75be98 1591 * Displayed in ViewManager are returned and displayed in
1592 * the view directly, if the structure is not already
81bba717 1593 * displayed and if the view accepts it in its context.
7fd59977 1594 */
1595
1596 Visual3d_TypeOfAnswer Answer;
1597 Graphic3d_MapOfStructure Map;
1598 MyViewManager->DisplayedStructures(Map);
1599 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1600
1601 for (; it.More(); it.Next()) {
1602 Handle(Graphic3d_Structure) SG = it.Key();
1603 if (! IsDisplayed (SG)) {
1604 Answer = AcceptDisplay(SG);
81bba717 1605 // If the structure can be displayed in the
1606 // new context of the view, it is displayed.
7fd59977 1607 if ((Answer == Visual3d_TOA_YES) ||
1608 (Answer == Visual3d_TOA_COMPUTE))
1609 Display (SG,Aspect_TOU_WAIT);
1610 }
1611 }
1612
1613 }
1614
81bba717 1615 // If the activation/desactivation of ZBuffer should be automatic
1616 // depending on the presence or absence of facets.
7fd59977 1617 if (MyViewManager->ZBufferAuto ()) {
1618Standard_Boolean BContainsFacet = ContainsFacet ();
1619Standard_Boolean BZBuffer = ZBufferIsActivated ();
81bba717 1620 // If the view contains facets
1621 // and if ZBuffer is not active
7fd59977 1622 if (BContainsFacet && ! BZBuffer)
1623 SetZBufferActivity (1);
81bba717 1624 // If the view does not contain facets
1625 // and if ZBuffer is active
7fd59977 1626 if (! BContainsFacet && BZBuffer)
1627 SetZBufferActivity (0);
1628 }
1629
1630 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1631
1632}
1633
1634Standard_Boolean Visual3d_View::IsActive () const {
1635
1636 if (IsDeleted ()) return (Standard_False);
1637
1638 if (MyCView.Active)
1639 return (Standard_True);
1640 else
1641 return (Standard_False);
1642
1643}
1644
1645void Visual3d_View::Deactivate () {
1646
1647 if (IsDeleted ()) return;
1648
1649 if (! IsDefined ())
1650 Visual3d_ViewDefinitionError::Raise ("Window not defined");
1651
1652 if (IsActive ()) {
1653
1654 MyGraphicDriver->DeactivateView (MyCView);
1655
1656 /*
81bba717 1657 * Deactivation of a view =>
1658 * Removal of structures displayed in this view.
1659 * All structures with status
bf75be98 1660 * Displayed in ViewManager are returned and removed from
1661 * the view directly, if the structure is not already
81bba717 1662 * displayed and if the view accepts it in its context.
1663 */
7fd59977 1664
1665 Visual3d_TypeOfAnswer Answer;
1666 Graphic3d_MapOfStructure Map;
1667 MyViewManager->DisplayedStructures(Map);
1668 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1669
1670 for (; it.More(); it.Next()) {
1671 Handle(Graphic3d_Structure) SG = it.Key();
1672 if (! IsDisplayed (SG)) {
1673 Answer = AcceptDisplay(SG);
81bba717 1674 // If the structure was displayed it is removed.
7fd59977 1675 if ((Answer == Visual3d_TOA_YES) ||
1676 (Answer == Visual3d_TOA_COMPUTE))
1677 Erase (SG,Aspect_TOU_WAIT);
1678 }
1679 }
1680
1681 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1682
81bba717 1683 // No action currently possible in the view
7fd59977 1684 MyCView.Active = 0;
1685 }
1686
1687}
1688
1689void Visual3d_View::Redraw () {
1690
1691 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1692
1693}
1694
1695void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
1696
1697 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height);
1698}
1699
1700void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1701
1702 if (IsDeleted ()) return;
1703
1704 if ((! IsDefined ()) || (! IsActive ())) return;
1705
1706 if (! MyWindow->IsMapped ()) return;
1707
1708 // san - 14/04/2004 - set up Z buffer state before redrawing
81bba717 1709 // If the activation/desactivation of ZBuffer should be automatic
1710 // depending on the presence or absence of facets.
7fd59977 1711 if (MyViewManager->ZBufferAuto ()) {
1712 Standard_Boolean BContainsFacet = ContainsFacet ();
1713 Standard_Boolean BZBuffer = ZBufferIsActivated ();
81bba717 1714 // If the view contains facets
1715 // and if ZBuffer is not active
7fd59977 1716 if (BContainsFacet && ! BZBuffer)
1717 SetZBufferActivity (1);
81bba717 1718 // If the view contains only facets
1719 // and if ZBuffer is active
7fd59977 1720 if (! BContainsFacet && BZBuffer)
1721 SetZBufferActivity (0);
1722 }
1723
1724 Aspect_CLayer2d OverCLayer;
1725 Aspect_CLayer2d UnderCLayer;
1726 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1727 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1728 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1729 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer);
1730
1731}
1732
1733void 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) {
1734
1735 if (IsDeleted ()) return;
1736
1737 if ((! IsDefined ()) || (! IsActive ())) return;
1738
1739 if (! MyWindow->IsMapped ()) return;
1740
1741 // san - 14/04/2004 - set up Z buffer state before redrawing
81bba717 1742 // If activation/desactivation of ZBuffer should be automatic
1743 // depending on the presence or absence of facets.
7fd59977 1744 if (MyViewManager->ZBufferAuto ()) {
1745 Standard_Boolean BContainsFacet = ContainsFacet ();
1746 Standard_Boolean BZBuffer = ZBufferIsActivated ();
81bba717 1747 // If the view contains facets
1748 // and if ZBuffer is not active
7fd59977 1749 if (BContainsFacet && ! BZBuffer)
1750 SetZBufferActivity (1);
81bba717 1751 // If the view contains only facets
1752 // and if ZBuffer is active
7fd59977 1753 if (! BContainsFacet && BZBuffer)
1754 SetZBufferActivity (0);
1755 }
1756
1757 Aspect_CLayer2d OverCLayer;
1758 Aspect_CLayer2d UnderCLayer;
1759 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1760 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1761 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1762 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer, x, y, width, height);
1763
1764}
1765
1766void Visual3d_View::Update () {
1767
1768 Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1769
1770}
1771
1772void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1773
1774 if (IsDeleted ()) return;
1775
1776 if ((! IsDefined ()) || (! IsActive ())) return;
1777
1778 if (! MyWindow->IsMapped ()) return;
1779
81bba717 1780 // If activation/desactivation of ZBuffer should be automatic
1781 // depending on the presence or absence of facets.
7fd59977 1782 if (MyViewManager->ZBufferAuto ()) {
1783Standard_Boolean BContainsFacet = ContainsFacet ();
1784Standard_Boolean BZBuffer = ZBufferIsActivated ();
81bba717 1785 // If the view contains facets
1786 // and if ZBuffer is not active
1787 if (BContainsFacet && ! BZBuffer)
7fd59977 1788 SetZBufferActivity (1);
81bba717 1789 // If the view does not contain facets
1790 // and if ZBuffer is active
7fd59977 1791 if (! BContainsFacet && BZBuffer)
1792 SetZBufferActivity (0);
1793 }
1794
1795Aspect_CLayer2d OverCLayer;
1796Aspect_CLayer2d UnderCLayer;
1797 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1798 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1799 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1800 //OSD::SetSignal (Standard_False);
1801 MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer);
1802 //OSD::SetSignal (Standard_True);
1803
7fd59977 1804}
1805
1806Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const {
1807
81bba717 1808// Return type of visualization of the view
7fd59977 1809Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
1810
81bba717 1811// Return type of visualization of the structure
7fd59977 1812Graphic3d_TypeOfStructure StructType = AStructure->Visual ();
1813
1814Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO;
1815
1816 if (StructType == Graphic3d_TOS_ALL)
81bba717 1817 // The structure accepts any type of view
7fd59977 1818 Result = Visual3d_TOA_YES;
1819 else {
1820 if ((StructType == Graphic3d_TOS_SHADING)
1821 && (ViewType == Visual3d_TOV_SHADING))
1822 Result = Visual3d_TOA_YES;
1823 if ((StructType == Graphic3d_TOS_WIREFRAME)
1824 && (ViewType == Visual3d_TOV_WIREFRAME))
1825 Result = Visual3d_TOA_YES;
1826 if ((StructType == Graphic3d_TOS_COMPUTED)
1827 && (ViewType == Visual3d_TOV_WIREFRAME))
1828 Result = Visual3d_TOA_COMPUTE;
1829 if ((StructType == Graphic3d_TOS_COMPUTED)
1830 && (ViewType == Visual3d_TOV_SHADING))
1831 Result = Visual3d_TOA_COMPUTE;
1832 }
1833
1834#ifdef TRACE_ACCEPT
1835 if (Result == Visual3d_TOA_YES)
1836 cout << "YES = Visual3d_View" << MyCView.ViewId
1837 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1838 if (Result == Visual3d_TOA_NO)
1839 cout << "NO = Visual3d_View" << MyCView.ViewId
1840 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1841 if (Result == Visual3d_TOA_COMPUTE)
1842 cout << "COMPUTE = Visual3d_View" << MyCView.ViewId
1843 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1844 cout << flush;
1845#endif
1846
1847 return (Result);
1848
1849}
1850
35e08fe8 1851void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer /*OldPriority*/, const Standard_Integer NewPriority) {
7fd59977 1852
1853 if (IsDeleted ()) return;
1854 if (! IsDefined ()) return;
1855 if (! IsActive ()) return;
1856 if (! IsDisplayed (AStructure)) return;
1857
1858Standard_Integer Index = IsComputed (AStructure);
de75ed09 1859 if (Index != 0 && ComputedMode())
7fd59977 1860 {
1861#ifdef TRACE
1862 Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification ();
1863 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1864 << AStructure->Identification () << "/" << StructId
1865 << ", " << OldPriority << ", " << NewPriority << ")\n";
1866 cout << flush;
1867#endif
1868 MyGraphicDriver->EraseStructure
1869 (MyCView,
1870 *(Graphic3d_CStructure *)
1871 MyCOMPUTEDSequence.Value (Index)->CStructure ());
1872 MyGraphicDriver->DisplayStructure
1873 (MyCView,
1874 *(Graphic3d_CStructure *)
1875 MyCOMPUTEDSequence.Value (Index)->CStructure (),
1876 int (NewPriority));
1877 }
1878 else {
1879#ifdef TRACE
1880 Standard_Integer StructId = AStructure->Identification ();
1881 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1882 << AStructure->Identification () << "/" << StructId
1883 << ", " << OldPriority << ", " << NewPriority << ")\n";
1884 cout << flush;
1885#endif
1886 MyGraphicDriver->EraseStructure
1887 (MyCView,
1888 *(Graphic3d_CStructure *)AStructure->CStructure ());
1889 MyGraphicDriver->DisplayStructure
1890 (MyCView,
1891 *(Graphic3d_CStructure *)AStructure->CStructure (),
1892 int (NewPriority));
1893 }
1894
1895}
1896
1897void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) {
1898
1899#ifdef TRACE_CLEAR
1900 cout << "Visual3d_View" << MyCView.ViewId << "::Clear ("
1901 << AStructure->Identification () << ")\n";
1902 cout << flush;
1903#endif
1904
1905Standard_Integer Index = IsComputed (AStructure);
1906 if (Index != 0) {
1907#ifdef TRACE_CLEAR
81bba717 1908 cout << "Structure " << AStructure->Identification ()
1909 << " calculated in the view "
1910 << Identification () << ", by structure "
7fd59977 1911 << MyCOMPUTEDSequence.Value (Index)->Identification ()
81bba717 1912 << " is emptied.\n";
7fd59977 1913 cout << flush;
1914#endif
1915 MyCOMPUTEDSequence.Value (Index)->GraphicClear (WithDestruction);
1916 MyCOMPUTEDSequence.Value (Index)->SetHLRValidation (Standard_False);
1917 }
1918
1919}
1920
1921void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
1922
1923#ifdef TRACE_CONNECT
1924 cout << "Visual3d_View" << MyCView.ViewId << "::Connect ("
1925 << AMother->Identification ()
1926 << ADaughter->Identification () << ")\n";
1927 cout << flush;
1928#endif
1929
1930Standard_Integer IndexM = IsComputed (AMother);
1931Standard_Integer IndexD = IsComputed (ADaughter);
1932
1933 if (IndexM != 0 && IndexD != 0) {
1934#ifdef TRACE_CONNECT
81bba717 1935 cout << "Structure " << AMother->Identification ()
1936 << " is connected to structure "
7fd59977 1937 << ADaughter->Identification () << endl;
81bba717 1938 cout << "These structures are calculated.\n";
1939 cout << "In the view " << Identification ()
1940 << "Structure "
7fd59977 1941 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
81bba717 1942 << " is connected to the structure "
7fd59977 1943 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
1944 << endl;
1945#endif
1946 MyCOMPUTEDSequence.Value (IndexM)->GraphicConnect (MyCOMPUTEDSequence.Value (IndexD));
1947 }
1948
1949}
1950
1951void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
1952
1953#ifdef TRACE_CONNECT
1954 cout << "Visual3d_View" << MyCView.ViewId << "::Disconnect ("
1955 << AMother->Identification ()
1956 << ADaughter->Identification () << ")\n";
1957 cout << flush;
1958#endif
1959
1960Standard_Integer IndexM = IsComputed (AMother);
1961Standard_Integer IndexD = IsComputed (ADaughter);
1962
1963 if (IndexM != 0 && IndexD != 0) {
1964#ifdef TRACE_CONNECT
81bba717 1965 cout << "Structure " << AMother->Identification ()
1966 << " is disconnected from the structure "
7fd59977 1967 << ADaughter->Identification () << endl;
81bba717 1968 cout << "These structures are calculated.\n";
1969 cout << "In the view " << Identification ()
1970 << "Structure "
7fd59977 1971 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
81bba717 1972 << " is disconnected from the structure "
7fd59977 1973 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
1974 << endl;
1975#endif
1976 MyCOMPUTEDSequence.Value (IndexM)->GraphicDisconnect (MyCOMPUTEDSequence.Value (IndexD));
1977 }
1978
1979}
1980
1981void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) {
1982
1983 Display (AStructure, MyViewManager->UpdateMode ());
1984
1985}
1986
1987void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
1988
1989 if (IsDeleted ()) return;
1990 if (! IsDefined ()) return;
1991 if (! IsActive ()) return;
1992
81bba717 1993 // If Display on a structure present in the list
bf75be98 1994 // of calculated structures while it is not
81bba717 1995 // or more, of calculated type =>
1996 // - removes it as well as the associated old computed
1997 // THis happens when hlhsr becomes again of type e
1998 // non computed after SetVisual.
7fd59977 1999Standard_Integer Index = IsComputed (AStructure);
2000
2001 if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) {
2002
2003#ifdef TRACE_LENGTH
2004 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2005 cout << "In Visual3d_View::Display, ";
2006 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2007 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2008 << "\n" << flush;
2009 }
2010#endif
2011 MyTOCOMPUTESequence.Remove (Index);
2012 MyCOMPUTEDSequence.Remove (Index);
2013
2014#ifdef TRACE_LENGTH
2015 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2016 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2017 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2018 << "\n" << flush;
2019#endif
2020 Index = 0;
2021 }
2022
2023 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
2024
2025#ifdef TRACE_DISPLAY
2026 Standard_Integer StructId = AStructure->Identification ();
2027 cout << "Visual3d_View" << MyCView.ViewId << "::Display ("
2028 << StructId << ");\n";
2029 cout << flush;
2030#endif
2031
2032 if (Answer == Visual3d_TOA_NO) {
2033#ifdef TRACE_DISPLAY
2034 cout << "Answer : Visual3d_TOA_NO\n";
2035 cout << flush;
2036#endif
2037 return;
2038 }
2039
de75ed09 2040 if (!ComputedMode())
2041 {
2042 Answer = Visual3d_TOA_YES;
2043 }
7fd59977 2044
2045 if (Answer == Visual3d_TOA_YES ) {
2046#ifdef TRACE_DISPLAY
2047 cout << "Answer : Visual3d_TOA_YES\n";
2048 cout << flush;
2049#endif
2050 if (IsDisplayed (AStructure)) return;
2051 MyGraphicDriver->DisplayStructure (
2052 MyCView,
2053 *(Graphic3d_CStructure *)AStructure->CStructure (),
2054 int (AStructure->DisplayPriority ())
2055 );
2056 MyDisplayedStructure.Add (AStructure);
2057 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2058 }
2059
2060 if (Answer == Visual3d_TOA_COMPUTE) {
2061#ifdef TRACE_DISPLAY
2062 cout << "Answer : Visual3d_TOA_COMPUTE\n";
2063 cout << "Index : " << Index << "\n" << flush;
2064#endif
2065 if (Index != 0) {
81bba717 2066 // Already computed, is COMPUTED still valid?
7fd59977 2067#ifdef TRACE_DISPLAY
2068 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
81bba717 2069 cout << "Structure "
7fd59977 2070 << MyTOCOMPUTESequence.Value (Index)->Identification ()
81bba717 2071 << "already calculated, in the view "
7fd59977 2072 << Identification () << ", par la structure "
2073 << MyCOMPUTEDSequence.Value (Index)->Identification ()
81bba717 2074 << "\n was not recalculated as HLR is valid\n";
7fd59977 2075 cout << flush;
2076 }
2077 else {
81bba717 2078 cout << "Structure "
7fd59977 2079 << MyTOCOMPUTESequence.Value (Index)->Identification ()
81bba717 2080 << " already calculated, in the view "
2081 << Identification () << ", by the structure "
7fd59977 2082 << MyCOMPUTEDSequence.Value (Index)->Identification ()
81bba717 2083 << "\n should be recalculated as HLR is invalid\n";
7fd59977 2084 cout << flush;
2085 }
2086#endif
2087Standard_Integer OldStructId =
2088 MyCOMPUTEDSequence.Value (Index)->Identification ();
2089
81bba717 2090 // Case COMPUTED valide
7fd59977 2091 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
81bba717 2092 // to be displayed
7fd59977 2093 if (! IsDisplayed (AStructure)) {
2094 MyDisplayedStructure.Add (AStructure);
2095 MyGraphicDriver->DisplayStructure (
2096 MyCView,
2097 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
2098 int (AStructure->DisplayPriority ())
2099 );
2100 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2101 }
2102 return;
2103 }
2104
81bba717 2105 // Case COMPUTED invalid
7fd59977 2106 else {
81bba717 2107 // Is there another valid representation ?
2108 // Find in the sequence of already calculated structures
2109 // 1/ Structure having the same Owner as <AStructure>
2110 // 2/ That is not <AStructure>
2111 // 3/ The COMPUTED which of is valid
7fd59977 2112 Standard_Integer NewIndex = HaveTheSameOwner (AStructure);
2113
81bba717 2114 // Case of COMPUTED invalid, WITH a valid of replacement
7fd59977 2115 if (NewIndex != 0) {
81bba717 2116 // to be displayed
7fd59977 2117 if (! IsDisplayed (AStructure)) {
2118 MyCOMPUTEDSequence.SetValue
2119 (Index, MyCOMPUTEDSequence.Value (NewIndex));
2120 OldStructId = MyCOMPUTEDSequence.Value (NewIndex)->
2121 Identification ();
2122 MyDisplayedStructure.Add (AStructure);
2123 MyGraphicDriver->DisplayStructure (
2124 MyCView,
2125 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (NewIndex)->CStructure (),
2126 int (AStructure->DisplayPriority ())
2127 );
2128 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2129 }
2130 return;
2131 }
2132
81bba717 2133 // Cas COMPUTED invalid, WITHOUT a valid of replacement
7fd59977 2134 else {
bf75be98 2135 // COMPUTED is removed if displayed
7fd59977 2136 if (IsDisplayed (AStructure))
2137 MyGraphicDriver->EraseStructure (
2138 MyCView,
2139 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()
2140 );
2141 }
2142 }
2143 } // if (Index != 0)
2144
2145 // Compute + Validation
2146#ifdef OLD
2147Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
2148#else
2149Handle(Graphic3d_Structure) TheStructure;
2150TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
2151 AStructure->Transform (ATrsf);
2152 if (Index != 0) {
2153TColStd_Array2OfReal Ident (0, 3, 0, 3);
2154Standard_Integer ii, jj;
2155 for (ii=0; ii<=3; ii++)
2156 for (jj=0; jj<=3; jj++)
2157 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
2158 TheStructure = MyCOMPUTEDSequence.Value (Index);
2159 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
2160 if (AStructure->IsTransformed ()) {
2161 AStructure->Compute (this, ATrsf, TheStructure);
2162 }
2163 else {
2164 AStructure->Compute (this, TheStructure);
2165 }
2166 }
2167 else {
2168 if (AStructure->IsTransformed ()) {
2169 TheStructure = AStructure->Compute (this, ATrsf);
2170 }
2171 else {
2172 TheStructure = AStructure->Compute (this);
2173 }
2174 }
2175#endif
2176 TheStructure->SetHLRValidation (Standard_True);
2177
2178#ifdef TRACE_LENGTH
2179 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2180 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2181 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2182 << "\n" << flush;
2183#endif
2184
81bba717 2185 // TOCOMPUTE and COMPUTED associated to sequences are added
7fd59977 2186 MyTOCOMPUTESequence.Append (AStructure);
2187 MyCOMPUTEDSequence.Append (TheStructure);
2188
2189#ifdef TRACE_LENGTH
2190 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2191 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2192 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2193 << "\n" << flush;
2194#endif
2195
81bba717 2196 // The previous are removed if necessary
7fd59977 2197 if (Index != 0) {
2198 MyTOCOMPUTESequence.Remove (Index);
2199 MyCOMPUTEDSequence.Remove (Index);
2200 }
2201
2202#ifdef TRACE_LENGTH
2203 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2204 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2205 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2206 << "\n" << flush;
2207#endif
2208
81bba717 2209// Return type of visualisation of the view
7fd59977 2210Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2211
81bba717 2212// Of which type will be the computed ?
7fd59977 2213Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
2214 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
2215
2216Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
2217 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
2218
2219 if (ComputeWireframe)
2220 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
2221 if (ComputeShading)
2222 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
2223
2224 if (! ComputeShading && ! ComputeWireframe)
2225 Answer = Visual3d_TOA_NO;
2226 else
2227 Answer = AcceptDisplay (TheStructure);
2228
2229 if (AStructure->IsHighlighted()) {
2230 TheStructure->SetHighlightColor (AStructure->HighlightColor ());
2231 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
2232 }
2233
2234#ifdef TRACE_DISPLAY
81bba717 2235 cout << "Structure " << StructId
2236 << " in the view " << Identification ()
2237 << " is calculated by the structure "
7fd59977 2238 << TheStructure->Identification ();
2239 if (Answer == Visual3d_TOA_YES)
81bba717 2240 cout << " and displayed\n";
7fd59977 2241 else
81bba717 2242 cout << " but not displayed\n";
7fd59977 2243 cout << flush;
2244#endif
2245
bf75be98 2246 // It is displayed only if the calculated structure
81bba717 2247 // has a proper type corresponding to the one of the view.
7fd59977 2248 if (Answer != Visual3d_TOA_NO) {
2249 if (! IsDisplayed (AStructure))
2250 MyDisplayedStructure.Add (AStructure);
2251 MyGraphicDriver->DisplayStructure (
2252 MyCView,
2253 *(Graphic3d_CStructure *)TheStructure->CStructure (),
2254 int (AStructure->DisplayPriority ())
2255 );
2256 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2257 }
2258 } // Visual3d_TOA_COMPUTE
2259}
2260
2261void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure) {
2262
2263 if (IsDeleted ()) return;
2264
2265 Erase (AStructure, MyViewManager->UpdateMode ());
2266
2267}
2268
2269void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
2270
2271Standard_Integer StructId;
2272
2273 if (IsDeleted ()) return;
2274
bf75be98 2275 // No test on window as the structure is displayed only if
81bba717 2276 // the window exists, so only one test is enough.
7fd59977 2277 if (IsDisplayed (AStructure)) {
2278Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
2279
de75ed09 2280 if (!ComputedMode())
2281 {
2282 Answer = Visual3d_TOA_YES;
2283 }
7fd59977 2284
2285 if (Answer != Visual3d_TOA_COMPUTE) {
2286 MyGraphicDriver->EraseStructure (
2287 MyCView,
2288 *(Graphic3d_CStructure *)AStructure->CStructure ()
2289 );
2290 }
2291
2292 if (Answer == Visual3d_TOA_COMPUTE) {
2293Standard_Integer Index = IsComputed (AStructure);
2294#ifdef TRACE_COMP
2295 cout << "Visual3d_View" << MyCView.ViewId << "::Erase ("
2296 << AStructure->Identification () << ");\n";
2297 cout << "Index : " << Index << "\n";
2298 cout << flush;
2299#endif
de75ed09 2300
2301 if (Index != 0 && ComputedMode())
7fd59977 2302 {
2303 StructId =
2304 MyCOMPUTEDSequence.Value (Index)->Identification ();
2305#ifdef TRACE_COMP
2306 cout << "Structure " << AStructure->Identification ()
81bba717 2307 << " calculated, in the view "
2308 << Identification () << ", by the structure "
2309 << StructId << " is removed. \n";
7fd59977 2310 cout << flush;
2311#endif
2312 MyGraphicDriver->EraseStructure
2313 (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
2314 }
81bba717 2315 // else is impossible
7fd59977 2316 }
2317 MyDisplayedStructure.Remove (AStructure);
2318 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
2319 }
2320
2321}
2322
2323void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) {
2324
2325#ifdef TRACE_HIGH
2326 cout << "Visual3d_View" << MyCView.ViewId << "::Highlight ("
2327 << AStructure->Identification () << ")\n";
2328 cout << flush;
2329#endif
2330
2331Standard_Integer Index = IsComputed (AStructure);
2332 if (Index != 0) {
2333#ifdef TRACE_HIGH
81bba717 2334 cout << "Structure " << AStructure->Identification ()
2335 << " calculated, in the view "
2336 << Identification () << ", by the structure "
7fd59977 2337 << MyCOMPUTEDSequence.Value (Index)->Identification ()
81bba717 2338 << " passes in highlight mode.\n";
7fd59977 2339 cout << flush;
2340#endif
2341 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
2342 (AStructure->HighlightColor ());
2343 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (AMethod);
2344 }
2345
2346}
2347
2348void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) {
2349
2350#ifdef TRACE_TRSF
2351 cout << "Visual3d_View" << MyCView.ViewId << "::Transform ("
2352 << AStructure->Identification () << ")\n";
2353 cout << flush;
2354#endif
2355
2356Standard_Integer Index = IsComputed (AStructure);
2357 if (Index != 0) {
2358#ifdef TRACE_TRSF
81bba717 2359 cout << "The structure " << AStructure->Identification ()
2360 << " calculated, in the view "
2361 << Identification () << ", by the structure "
7fd59977 2362 << MyCOMPUTEDSequence.Value (Index)->Identification ()
81bba717 2363 << " is transformed.\n";
7fd59977 2364 cout << flush;
2365#endif
81bba717 2366 // Test is somewhat light !
2367 // trsf is transferred only if it is :
2368 // a translation
2369 // a scale
7fd59977 2370 if (ATrsf (0, 1) != 0. || ATrsf (0, 2) != 0.
2371 || ATrsf (1, 0) != 0. || ATrsf (1, 2) != 0.
2372 || ATrsf (2, 0) != 0. || ATrsf (2, 1) != 0.)
2373 ReCompute (AStructure);
2374 else
2375 MyCOMPUTEDSequence.Value (Index)->GraphicTransform (ATrsf);
2376 }
2377
2378}
2379
2380void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) {
2381
2382#ifdef TRACE_HIGH
2383 cout << "Visual3d_View" << MyCView.ViewId << "::UnHighlight ("
2384 << AStructure->Identification () << ")\n";
2385 cout << flush;
2386#endif
2387
2388Standard_Integer Index = IsComputed (AStructure);
2389 if (Index != 0) {
2390#ifdef TRACE_HIGH
81bba717 2391 cout << "Structure " << AStructure->Identification ()
2392 << " calculated, in the view "
2393 << Identification () << ", by the structure "
7fd59977 2394 << MyCOMPUTEDSequence.Value (Index)->Identification ()
81bba717 2395 << " passes in unhighlight mode.\n";
7fd59977 2396 cout << flush;
2397#endif
2398 MyCOMPUTEDSequence.Value (Index)->GraphicUnHighlight ();
2399 }
2400
2401
2402}
2403
2404Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& AStructure) const {
2405
2406Standard_Integer StrId = AStructure->Identification ();
2407
2408Standard_Integer Result = 0;
2409Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2410
2411 // Recherche de la structure <AStructure> dans la
2412 // sequence des structures deja calculees
2413 for (Standard_Integer i=1; i<=Length && Result==0; i++)
2414 if ((MyTOCOMPUTESequence.Value (i))->Identification ()
2415 == StrId) Result = i;
2416#ifdef TRACE_ISCOMP
81bba717 2417 cout << "\n In the view " << Identification () << " the structure ";
7fd59977 2418 if (Result != 0)
81bba717 2419 cout << StrId << " is calculated by "
7fd59977 2420 << MyCOMPUTEDSequence.Value (Result)->Identification ()
2421 << "\n" << flush;
2422 else
81bba717 2423 cout << StrId << " is not calculated\n" << flush;
7fd59977 2424#endif
2425
2426#ifdef TRACE_LENGTH
2427 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2428 cout << "In Visual3d_View::IsComputed, ";
2429 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2430 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2431 << "\n" << flush;
2432 }
2433#endif
2434
2435 return (Result);
2436
2437}
2438
2439Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& AStructure) const {
2440
2441Standard_Boolean Result = Standard_False;
2442
2443 if (IsDeleted ()) return Result;
2444
2445 Result = MyDisplayedStructure.Contains (AStructure);
2446
2447 return Result;
2448
2449}
2450
2451#ifdef IMPLEMENTED
2452Standard_Boolean Visual3d_View::ContainsComputedStructure () const {
2453
2454Standard_Boolean Result = Standard_False;
2455
2456 if (MyDisplayedStructure.IsEmpty ()) return Result;
2457
2458Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
2459
2460 Standard_Integer i = MyDisplayedStructure.Extent ();
2461
81bba717 2462 // Stop at the first structure of type TOS_COMPUTED
7fd59977 2463 while (! Result && Iterator.More ()) {
2464 Result =
2465 (((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED);
2466
bf75be98 2467 // Iterator.Next () is located on the
81bba717 2468 // next structure
7fd59977 2469 Iterator.Next ();
2470 }
2471
2472 return Result;
2473
2474}
2475#endif
2476
2477Standard_Boolean Visual3d_View::ContainsFacet () const {
2478
2479 return ContainsFacet (MyDisplayedStructure);
2480
2481}
2482
2483Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& ASet) const {
2484
2485Standard_Boolean Result = Standard_False;
2486
2487 if (ASet.IsEmpty ()) return Result;
2488
2489Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
2490
81bba717 2491 // Stop at the first structure containing a facet
7fd59977 2492 for ( Iterator.Initialize (ASet);
2493 Iterator.More () && ! Result;
2494 Iterator.Next ())
2495 Result = (Iterator.Key ())->ContainsFacet ();
2496
2497 return Result;
2498
2499}
2500
2501void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
2502
2503 MinMaxValues
2504 (MyDisplayedStructure, XMin, YMin, ZMin, XMax, YMax, ZMax);
2505
2506}
2507
2508void 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 {
2509
2510 if (ASet.IsEmpty ()) {
2511 XMin = RealFirst ();
2512 YMin = RealFirst ();
2513 ZMin = RealFirst ();
2514
2515 XMax = RealLast ();
2516 YMax = RealLast ();
2517 ZMax = RealLast ();
2518 }
2519 else {
2520
2521 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
2522 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
2523
2524 XMin = RealLast ();
2525 YMin = RealLast ();
2526 ZMin = RealLast ();
2527
2528 XMax = RealFirst ();
2529 YMax = RealFirst ();
2530 ZMax = RealFirst ();
2531
2532 for ( Iterator.Initialize (ASet);
2533 Iterator.More ();
2534 Iterator.Next ()) {
2535
2536 if ( (Iterator.Key ())->IsInfinite ()){
2537 //XMin, YMin .... ZMax are initialized by means of infinite line data
2538 (Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
2539 if ( Xm != RealFirst() && Xm < XMin )
2540 XMin = Xm ;
2541 if ( Ym != RealFirst() && Ym < YMin )
2542 YMin = Ym ;
2543 if ( Zm != RealFirst() && Zm < ZMin )
2544 ZMin = Zm ;
2545 if ( XM != RealLast() && XM > XMax )
2546 XMax = XM ;
2547 if ( YM != RealLast() && YM > YMax )
2548 YMax = YM ;
2549 if ( ZM != RealLast() && ZM > ZMax )
2550 ZMax = ZM ;
2551 }
bf75be98 2552 // Only non-empty and non-infinite structures
81bba717 2553 // are taken into account for calculation of MinMax
7fd59977 2554 if (! (Iterator.Key ())->IsInfinite () &&
2555 ! (Iterator.Key ())->IsEmpty ()) {
2556 (Iterator.Key ())->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM);
2557 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
2558 //"FitAll" operation ignores object with transform persitence parameter
2559 if( (Iterator.Key ())->TransformPersistenceMode() == Graphic3d_TMF_None )
2560 {
2561 if (Xm < XMin) XMin = Xm;
2562 if (Ym < YMin) YMin = Ym;
2563 if (Zm < ZMin) ZMin = Zm;
2564 if (XM > XMax) XMax = XM;
2565 if (YM > YMax) YMax = YM;
2566 if (ZM > ZMax) ZMax = ZM;
2567 }
2568 }
2569 }
2570
81bba717 2571 // The following cases are relevant
2572 // For exemple if all structures are empty or infinite
7fd59977 2573 if (XMax < XMin) { Xm = XMin; XMin = XMax; XMax = Xm; }
2574 if (YMax < YMin) { Ym = YMin; YMin = YMax; YMax = Ym; }
2575 if (ZMax < ZMin) { Zm = ZMin; ZMin = ZMax; ZMax = Zm; }
2576 }
2577 Standard_Real Sx, Sy, Sz;
2578 MyViewOrientation.AxialScale(Sx, Sy, Sz);
2579 XMin = (Sx > 1. && XMin < RealFirst ()/Sx)?RealFirst (): XMin*Sx;
2580 XMax = (Sx > 1. && XMax > RealLast ()/Sx)?RealLast (): XMax*Sx;
2581 YMin = (Sy > 1. && YMin < RealFirst ()/Sy)?RealFirst (): YMin*Sy;
2582 YMax = (Sy > 1. && YMax > RealLast ()/Sy)?RealLast (): YMax*Sy;
2583 ZMin = (Sz > 1. && ZMin < RealFirst ()/Sz)?RealFirst (): ZMin*Sz;
2584 ZMax = (Sz > 1. && ZMax > RealLast ()/Sz)?RealLast (): ZMax*Sz;
2585}
2586
2587void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
2588
2589 MinMaxValues (MyDisplayedStructure, XMin, YMin, XMax, YMax);
2590
2591}
2592
2593void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
2594
2595Standard_Real Xm, Ym, Zm, XM, YM, ZM;
2596Standard_Real Xp, Yp, Zp;
2597
2598 MinMaxValues (ASet, Xm, Ym, Zm, XM, YM, ZM);
2599
2600 Projects (Xm, Ym, Zm, Xp, Yp, Zp);
2601 XMin = Xp;
2602 YMin = Yp;
2603
2604 Projects (XM, YM, ZM, Xp, Yp, Zp);
2605 XMax = Xp;
2606 YMax = Yp;
2607
2608 if (XMax < XMin) { Xp = XMax; XMax = XMin; XMin = Xp; }
2609 if (YMax < YMin) { Yp = YMax; YMax = YMin; YMin = Yp; }
2610}
2611
2612const TColStd_Array2OfReal& Visual3d_View::MatrixOfOrientation () {
2613
2614 if (! MyMatOfOriIsEvaluated) {
2615 MyGraphicDriver->InquireMat
2616 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2617 MyMatOfMapIsEvaluated = Standard_True;
2618 MyMatOfOriIsEvaluated = Standard_True;
2619 }
2620
2621 return (MyMatrixOfOrientation);
2622
2623}
2624
2625const TColStd_Array2OfReal& Visual3d_View::MatrixOfMapping () {
2626
2627 if (! MyMatOfMapIsEvaluated) {
2628 MyGraphicDriver->InquireMat
2629 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2630 MyMatOfMapIsEvaluated = Standard_True;
2631 MyMatOfOriIsEvaluated = Standard_True;
2632 }
2633
2634 return (MyMatrixOfMapping);
2635
2636}
2637
2638Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
2639
2640Standard_Integer Result = MyDisplayedStructure.Extent ();
2641
2642 return (Result);
2643
2644}
2645
2646#ifdef OLD_METHOD
2647void 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 {
2648
2649math_Vector PtDC (0,3), PtWC (0,3);
2650
2651// RLE method:
81bba717 2652// Otherwise use new on Visual3d_View (constructor+destructor)
2653// as Projects is a const method or MatrixOfOrientation and
2654// MatrixOfMapping is not.
7fd59977 2655Visual3d_View * const newthis = (Visual3d_View * const) this;
2656 newthis->MatrixOfOrientation ();
2657 newthis->MatrixOfMapping ();
2658
2659// World Coordinate Space
2660 PtWC (0) = AX;
2661 PtWC (1) = AY;
2662 PtWC (2) = AZ;
2663 PtWC (3) = 1.0;
2664
2665 // WCS -> View Reference Coordinate Space
2666 math_Vector PtVRC(0,3);
2667 PtVRC = MyMatrixOfOrientation.Multiplied (PtWC);
2668
2669 // VRCS -> Normalized Projection Coordinate Space
2670 math_Vector PtNPC(0,3);
2671 PtNPC = MyMatrixOfMapping.Multiplied (PtVRC);
2672 for (Standard_Integer i=0; i<3; i++) PtNPC (i) = PtNPC (i) / PtNPC (3);
2673
2674#ifdef DEBUG
2675 printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
2676 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2677#endif // DEBUG
2678
2679 Standard_Real Ratio;
2680#ifdef DEBUG
2681 // NPCS -> Device Coordinate Space
2682 Standard_Real Dx = Standard_Real (MyCView.DefWindow.dx);
2683 Standard_Real Dy = Standard_Real (MyCView.DefWindow.dy);
2684
2685 Ratio = Dx / Dy;
2686 PtDC (0) = PtNPC (0) * Dx;
2687 PtDC (1) = Dy - PtNPC (1) * Dy * Ratio;
2688
2689 printf("Display coordinates : %f,%f,%f,%f\n",
2690 PtDC(0),PtDC(1),PtDC(2),PtDC(3));
2691#endif // DEBUG
2692
2693 // NPCS -> Window Space
2694Standard_Real um, vm, uM, vM;
2695 MyViewMapping.WindowLimit (um, vm, uM, vM);
2696
2697 Ratio = (uM - um) / (vM - vm);
2698 if (Ratio >= 1.0)
2699 PtNPC (1) = PtNPC (1) * Ratio;
2700 else
2701 PtNPC (0) = PtNPC (0) / Ratio;
2702
2703#ifdef DEBUG
2704 printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
2705 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2706#endif // DEBUG
2707
2708 Standard_Real fpd = MyViewMapping.FrontPlaneDistance ();
2709 Standard_Real bpd = MyViewMapping.BackPlaneDistance ();
2710
2711 /*
81bba717 2712 * Coordinates of PtNPC are described in the space
7fd59977 2713 * [0-1]x[0-1]x[0-1].
81bba717 2714 * It is necessary to transform x and y in the window space.
2715 * It is necessary to transform z in the space of back and front
2716 * plane, taking into account clipping planes.
2717 * Z clipping planes are defined between 0 and 1.
7fd59977 2718 */
2719
2720 APX = PtNPC (0) * (uM - um) + um;
2721 APY = PtNPC (1) * (vM - vm) + vm;
2722 APZ = PtNPC (2) * (fpd - bpd) + bpd;
2723
2724#ifdef DEBUG
2725 Standard_Integer l,c;
2726 printf("OrientationMatrix :");
2727 for( l=0 ; l<4 ; l++ ) {
2728 printf("\n %d->",l);
2729 for( c=0 ; c<4 ; c++ ) {
2730 printf(" %f ,",MyMatrixOfOrientation(c,l));
2731 }
2732 }
2733 printf("\n\n");
2734 printf("MappingMatrix :");
2735 for( l=0 ; l<4 ; l++ ) {
2736 printf("\n %d->",l);
2737 for( c=0 ; c<4 ; c++ ) {
2738 printf(" %f ,",MyMatrixOfMapping(c,l));
2739 }
2740 }
2741 printf("\n\n");
2742 printf("World coordinates : %f,%f,%f,%f\n",
2743 PtWC(0),PtWC(1),PtWC(2),PtWC(3));
2744 printf("View coordinates : %f,%f,%f,%f\n",
2745 PtVRC(0),PtVRC(1),PtVRC(2),PtVRC(3));
2746 printf("Display coordinates : %f,%f,%f,%f\n",
2747 PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
2748 printf("Window limit : %f,%f,%f,%f\n",um,vm,uM,vM);
2749 printf("Ratio : %f\n",Ratio);
2750 printf("Front-plane : %f back-plane : %f\n",fpd,bpd);
2751 printf("Projection : %f,%f,%f\n \n",APX,APY,APZ);
2752#endif
2753
2754}
2755#endif /* OLD_METHOD */
2756
2757// OCC18942: This method is likely to duplicate Visual3d_ViewManager::ConvertCoord() one,
2758// therefore it is necessary to consider merging the two methods or making them call the same
2759// graphic driver's method after OCCT 6.3.
2760void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) {
2761
2762Standard_Real PtX, PtY, PtZ, PtT;
2763Standard_Real APT;
2764static Standard_Real Ratio, um, vm, uM, vM;
2765static Standard_Real fpd, bpd;
2766
2767 if (! MyMatOfOriIsEvaluated || ! MyMatOfMapIsEvaluated) {
2768 MyGraphicDriver->InquireMat
2769 (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
2770 MyMatOfOriIsEvaluated = MyMatOfMapIsEvaluated = Standard_True;
2771 }
2772
2773 // WCS -> View Reference Coordinate Space
2774 PtX = MyMatrixOfOrientation (0, 0) * AX
2775 + MyMatrixOfOrientation (0, 1) * AY
2776 + MyMatrixOfOrientation (0, 2) * AZ
2777 + MyMatrixOfOrientation (0, 3);
2778 PtY = MyMatrixOfOrientation (1, 0) * AX
2779 + MyMatrixOfOrientation (1, 1) * AY
2780 + MyMatrixOfOrientation (1, 2) * AZ
2781 + MyMatrixOfOrientation (1, 3);
2782 PtZ = MyMatrixOfOrientation (2, 0) * AX
2783 + MyMatrixOfOrientation (2, 1) * AY
2784 + MyMatrixOfOrientation (2, 2) * AZ
2785 + MyMatrixOfOrientation (2, 3);
2786 PtT = MyMatrixOfOrientation (3, 0) * AX
2787 + MyMatrixOfOrientation (3, 1) * AY
2788 + MyMatrixOfOrientation (3, 2) * AZ
2789 + MyMatrixOfOrientation (3, 3);
2790
2791 // VRCS -> Normalized Projection Coordinate Space
2792 APX = MyMatrixOfMapping (0, 0) * PtX
2793 + MyMatrixOfMapping (0, 1) * PtY
2794 + MyMatrixOfMapping (0, 2) * PtZ
2795 + MyMatrixOfMapping (0, 3) * PtT;
2796 APY = MyMatrixOfMapping (1, 0) * PtX
2797 + MyMatrixOfMapping (1, 1) * PtY
2798 + MyMatrixOfMapping (1, 2) * PtZ
2799 + MyMatrixOfMapping (1, 3) * PtT;
2800 APZ = MyMatrixOfMapping (2, 0) * PtX
2801 + MyMatrixOfMapping (2, 1) * PtY
2802 + MyMatrixOfMapping (2, 2) * PtZ
2803 + MyMatrixOfMapping (2, 3) * PtT;
2804 APT = MyMatrixOfMapping (3, 0) * PtX
2805 + MyMatrixOfMapping (3, 1) * PtY
2806 + MyMatrixOfMapping (3, 2) * PtZ
2807 + MyMatrixOfMapping (3, 3) * PtT;
2808
2809 APX /= APT;
2810 APY /= APT;
2811 APZ /= APT;
2812
2813 // NPCS -> Window Space
2814 MyViewMapping.WindowLimit (um, vm, uM, vM);
2815 fpd = MyViewMapping.FrontPlaneDistance ();
2816 bpd = MyViewMapping.BackPlaneDistance ();
2817
2818 if(MyCView.Mapping.IsCustomMatrix) {
2819 // OCC18942: SAN - If orientation and mapping matrices are those used by OpenGL
2820 // visualization, then X, Y and Z coordinates normally vary between -1 and 1
2821 APX = ( APX + 1 ) * 0.5 * (uM - um) + um;
2822 APY = ( APY + 1 ) * 0.5 * (vM - vm) + vm;
2823 } else {
2824 Ratio = (uM - um) / (vM - vm);
2825 if (Ratio >= 1.0)
2826 APY *= Ratio;
2827 else
2828 APX /= Ratio;
2829
2830 /*
81bba717 2831 * Coordinates of APX, APY, APZ are described in the space
2832 * [0-1]x[0-1]x[0-1].
2833 * It is necessary to transform x and y in the window space.
2834 * It is necessary to transform z in the space of back and front
2835 * plane, taking into account clipping planes.
2836 * Z clipping planes are defined between 0 and 1.
2837 */
7fd59977 2838 APX = APX * (uM - um) + um;
2839 APY = APY * (vM - vm) + vm;
2840 }
2841 APZ = APZ * (fpd - bpd) + bpd;
2842}
2843
2844Standard_Integer Visual3d_View::Identification () const {
2845
2846 return (Standard_Integer (MyCView.ViewId));
2847
2848}
2849
7fd59977 2850
2851Standard_Boolean Visual3d_View::ZBufferIsActivated () const {
2852
2853 if (IsDeleted ()) return (Standard_False);
2854
2855 if ((! IsDefined ()) || (! IsActive ())) return (Standard_False);
2856
81bba717 2857// -1 => not forced by the programmer => depends on the type of visualisation
2858// 0 ou 1 => forced by the programmer
7fd59977 2859
2860 if (MyCView.Context.ZBufferActivity == -1)
2861 if (MyContext.Visualization () == Visual3d_TOV_SHADING)
2862 return (Standard_True);
2863 else
2864 return (Standard_False);
2865 else
2866 if (MyCView.Context.ZBufferActivity)
2867 return (Standard_True);
2868 else
2869 return (Standard_False);
2870
2871}
2872
2873void Visual3d_View::SetTransparency (const Standard_Boolean AnActivity) {
2874
2875 if (IsDeleted ()) return;
2876
2877 if ((! IsDefined ()) || (! IsActive ())) return;
2878
2879 MyGraphicDriver->Transparency (MyCView, AnActivity);
2880
2881}
2882
2883void Visual3d_View::SetZBufferActivity (const Standard_Integer AnActivity) {
2884
2885 if (MyCView.Context.ZBufferActivity == AnActivity) return;
2886
2887 if (IsDeleted ()) return;
2888
2889 if ((! IsDefined ()) || (! IsActive ())) return;
2890
2891 MyCView.Context.ZBufferActivity = AnActivity;
2892 MyGraphicDriver->SetVisualisation (MyCView);
2893
2894}
2895
2896void Visual3d_View::UpdateView () {
2897
2898 MyCView.Context.Aliasing = (MyContext.AliasingIsOn () ? 1:0);
2899 MyCView.Context.BackZClipping =
2900 (MyContext.BackZClippingIsOn () ? 1:0);
2901 MyCView.Context.FrontZClipping =
2902 (MyContext.FrontZClippingIsOn() ? 1:0);
2903 MyCView.Context.DepthCueing =
2904 (MyContext.DepthCueingIsOn () ? 1:0);
2905
2906 MyCView.Context.ZClipFrontPlane =
2907 float (MyContext.ZClippingFrontPlane ());
2908 MyCView.Context.ZClipBackPlane =
2909 float (MyContext.ZClippingBackPlane ());
2910 MyCView.Context.DepthFrontPlane =
2911 float (MyContext.DepthCueingFrontPlane ());
2912 MyCView.Context.DepthBackPlane =
2913 float (MyContext.DepthCueingBackPlane ());
2914
2915 MyCView.Context.Model = int (MyContext.Model ());
2916 MyCView.Context.Visualization = int (MyContext.Visualization ());
2917
bf75be98 2918 MyCView.Context.TextureEnv = MyContext.TextureEnv();
7fd59977 2919 MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
2920
2921}
2922
2923void Visual3d_View::Compute () {
2924
2925Standard_Integer i;
2926Standard_Integer Length = MyCOMPUTEDSequence.Length ();
2927 for (i=1; i<=Length; i++)
2928 (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False);
2929
de75ed09 2930 if (!ComputedMode())
2931 {
2932 return;
2933 }
7fd59977 2934
2935 /*
81bba717 2936 * Force HLRValidation to False on all structures
2937 * calculated in the view.
7fd59977 2938 */
2939#ifdef TRACE_LENGTH
2940 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2941 cout << "In Visual3d_View::Compute, ";
2942 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2943 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2944 << "\n" << flush;
2945 }
2946#endif
2947
2948 /*
81bba717 2949 * Change of orientation or of projection type =>
2950 * Remove structures that were calculated for the
2951 * previous orientation.
2952 * Recalculation of new structures.
7fd59977 2953 */
2954Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
2955Visual3d_TypeOfAnswer Answer;
2956
2957 i = MyDisplayedStructure.Extent ();
2958
2959Graphic3d_SequenceOfStructure FooSequence;
2960
2961 while (S1Iterator.More ()) {
2962 Answer = AcceptDisplay (S1Iterator.Key ());
81bba717 2963 // If the structure was calculated, it is recalculated.
7fd59977 2964 if (Answer == Visual3d_TOA_COMPUTE) {
2965#ifdef TRACE
2966 cout << "AcceptDisplay ("
2967 << (S1Iterator.Key ())->Identification ()
2968 << ") == Visual3d_TOA_COMPUTE;\n";
2969 cout << flush;
2970#endif
2971 //Display (S1Iterator.Key (), Aspect_TOU_WAIT);
2972 FooSequence.Append (S1Iterator.Key ());
2973 }
2974
81bba717 2975 // S1Iterator.Next () is located on the next structure
7fd59977 2976 S1Iterator.Next ();
2977 }
2978
2979 Length = FooSequence.Length ();
81bba717 2980 // All stored structures are displayed
7fd59977 2981 for (i=1; i<=Length; i++)
2982 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
2983 if (Length != 0) FooSequence.Clear ();
2984
2985}
2986
2987void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
de75ed09 2988 if (!ComputedMode()) return;
7fd59977 2989
2990 if (IsDeleted ()) return;
2991
2992 if ((! IsDefined ()) || (! IsActive ())) return;
2993
2994 if (! MyWindow->IsMapped ()) return;
2995
2996 if (! AStructure->IsDisplayed ()) return;
2997
2998Visual3d_TypeOfAnswer Answer;
2999
3000 Answer = AcceptDisplay (AStructure);
3001
3002 if (Answer == Visual3d_TOA_COMPUTE) {
3003Standard_Integer Index = IsComputed (AStructure);
3004 if (Index == 0) {
3005#ifdef TRACE_COMP
81bba717 3006 cout << "Structure " << AStructure->Identification ()
3007 << " is not calculated in the view "
7fd59977 3008 << Identification () << "\n";
3009 cout << flush;
3010#endif
3011 }
3012 else {
3013 Standard_Integer OldStructId, NewStructId;
3014 OldStructId =
3015 MyCOMPUTEDSequence.Value (Index)->Identification ();
3016#ifdef TRACE_COMP
3017 Standard_Integer StructId = AStructure->Identification ();
81bba717 3018 cout << "Structure " << StructId
3019 << " calculated, in the view "
3020 << Identification () << ", by the structure "
3021 << OldStructId << " is recalculated.\n";
7fd59977 3022 cout << flush;
3023#endif
3024
3025 // Compute + Validation
3026#ifdef OLD
3027Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
3028#else
3029Handle(Graphic3d_Structure) TheStructure;
3030TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
3031 AStructure->Transform (ATrsf);
3032 if (Index != 0) {
3033TColStd_Array2OfReal Ident (0, 3, 0, 3);
3034Standard_Integer ii, jj;
3035 for (ii=0; ii<=3; ii++)
3036 for (jj=0; jj<=3; jj++)
3037 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
3038 TheStructure = MyCOMPUTEDSequence.Value (Index);
3039 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
3040 if (AStructure->IsTransformed ()) {
3041 AStructure->Compute (this, ATrsf, TheStructure);
3042 }
3043 else {
3044 AStructure->Compute (this, TheStructure);
3045 }
3046 }
3047 else {
3048 if (AStructure->IsTransformed ()) {
3049 TheStructure = AStructure->Compute (this, ATrsf);
3050 }
3051 else {
3052 TheStructure = AStructure->Compute (this);
3053 }
3054 }
3055#endif
3056 TheStructure->SetHLRValidation (Standard_True);
3057
81bba717 3058// Return type of visualisation of the view
7fd59977 3059Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
3060
81bba717 3061// Of which type will be the computed ?
7fd59977 3062Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
3063 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
3064
3065Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
3066 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
3067
3068 if (ComputeWireframe)
3069 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
3070 if (ComputeShading)
3071 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
3072
3073 if (AStructure->IsHighlighted ()) {
3074 TheStructure->SetHighlightColor
3075 (AStructure->HighlightColor ());
3076 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
3077 }
3078
81bba717 3079 // Ot is ranged
3080 // Find structure <AStructure>
3081 // in the sequence of structures to be calculated.
7fd59977 3082 NewStructId = TheStructure->Identification ();
3083
81bba717 3084 // The previous calculation is removed and the new one is dislayed
7fd59977 3085 MyGraphicDriver->EraseStructure (
3086 MyCView,
3087 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
3088 MyGraphicDriver->DisplayStructure (
3089 MyCView,
3090 *(Graphic3d_CStructure *)TheStructure->CStructure (),
3091 int (AStructure->DisplayPriority ())
3092 );
3093
3094#ifdef TRACE_LENGTH
3095 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
3096 cout << "In Visual3d_View::ReCompute, ";
3097 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3098 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3099 << "\n" << flush;
3100 }
3101#endif
3102
81bba717 3103 // hlhsr and the new associated compute are added
7fd59977 3104 MyTOCOMPUTESequence.Append (AStructure);
3105 MyCOMPUTEDSequence.Append (TheStructure);
3106
3107#ifdef TRACE_LENGTH
3108 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3109 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3110 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3111 << "\n" << flush;
3112#endif
3113
bf75be98 3114 // hlhsr and the new associated compute are removed
7fd59977 3115
3116 MyTOCOMPUTESequence.Remove (Index);
3117 MyCOMPUTEDSequence.Remove (Index);
3118
3119#ifdef TRACE_LENGTH
3120 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
3121 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
3122 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
3123 << "\n" << flush;
3124#endif
3125 }
3126 }
3127
3128}
3129
6942f04a 3130const Handle(Graphic3d_GraphicDriver)& Visual3d_View::GraphicDriver () const {
7fd59977 3131
3132 return MyGraphicDriver;
3133
3134}
3135
de75ed09 3136void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& thePlotter) const
3137{
3138 for (Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); S1Iterator.More(); S1Iterator.Next())
3139 {
3140 Standard_Integer Index = IsComputed (S1Iterator.Key ());
3141 // displayed structure is plotted as if it was not calculated
3142 if (Index == 0)
3143 (S1Iterator.Key ())->Plot (thePlotter);
3144 else
3145 (MyCOMPUTEDSequence.Value (Index))->Plot (thePlotter);
3146 }
7fd59977 3147}
3148
3149Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const {
3150
3151Standard_Integer Result = 0;
3152Standard_Integer Length = MyTOCOMPUTESequence.Length ();
3153
bf75be98 3154 // Find in the sequence of already calculated structures
81bba717 3155 // 1/ Structure with the same Owner as <AStructure>
3156 // 2/ Which is not <AStructure>
3157 // 3/ COMPUTED which of is valid
7fd59977 3158 for (Standard_Integer i=1; i<=Length && Result==0; i++)
3159 if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ())
3160 && (MyTOCOMPUTESequence.Value (i)->Identification () !=
3161 AStructure->Identification ())
3162 && (MyCOMPUTEDSequence.Value (i)->HLRValidation ())) Result = i;
3163
3164 return (Result);
3165
3166}
3167
3168Standard_Address Visual3d_View::CView () const {
3169
3170 return Standard_Address (&MyCView);
3171
3172}
3173
3174
3175// Triedron methods : the Triedron is a non-zoomable object.
3176
3177void Visual3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
3178 const Quantity_NameOfColor YColor,
3179 const Quantity_NameOfColor ZColor,
3180 const Standard_Real SizeRatio,
3181 const Standard_Real AxisDiametr,
3182 const Standard_Integer NbFacettes) {
3183 MyGraphicDriver->ZBufferTriedronSetup(XColor, YColor, ZColor,
3184 SizeRatio, AxisDiametr, NbFacettes);
3185}
3186
3187
3188
3189void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition,
3190 const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe ) {
3191
3192 MyGraphicDriver->TriedronDisplay (MyCView,APosition, AColor, AScale, AsWireframe);
3193
3194}
3195
3196void Visual3d_View::TriedronErase () {
3197
3198 MyGraphicDriver->TriedronErase (MyCView);
3199
3200
3201}
3202
3203void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
3204
3205 MyGraphicDriver->TriedronEcho (MyCView,AType);
3206
3207}
3208
3209Standard_Boolean checkFloat(const Standard_Real value)
3210{
3211 return value > -FLT_MAX && value < FLT_MAX;
3212}
3213
3214void SetMinMaxValuesCallback(void* Visual3dView)
3215{
3216 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
3217
3218 Handle(Visual3d_View) view = (Handle(Visual3d_View)&) Visual3dView;
3219 view->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
3220
3221 if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
3222 checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
3223 {
3224 Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(view->GraphicDriver());
3225 driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
3226 (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
3227 }
3228}
3229
13a22457
S
3230Standard_Boolean Visual3d_View::GetGraduatedTrihedron
3231 (/* Names of axes */
3232 TCollection_ExtendedString& xname,
3233 TCollection_ExtendedString& yname,
3234 TCollection_ExtendedString& zname,
3235 /* Draw names */
3236 Standard_Boolean& xdrawname,
3237 Standard_Boolean& ydrawname,
3238 Standard_Boolean& zdrawname,
3239 /* Draw values */
3240 Standard_Boolean& xdrawvalues,
3241 Standard_Boolean& ydrawvalues,
3242 Standard_Boolean& zdrawvalues,
3243 /* Draw grid */
3244 Standard_Boolean& drawgrid,
3245 /* Draw axes */
3246 Standard_Boolean& drawaxes,
3247 /* Number of splits along axes */
3248 Standard_Integer& nbx,
3249 Standard_Integer& nby,
3250 Standard_Integer& nbz,
3251 /* Offset for drawing values */
3252 Standard_Integer& xoffset,
3253 Standard_Integer& yoffset,
3254 Standard_Integer& zoffset,
3255 /* Offset for drawing names of axes */
3256 Standard_Integer& xaxisoffset,
3257 Standard_Integer& yaxisoffset,
3258 Standard_Integer& zaxisoffset,
3259 /* Draw tickmarks */
3260 Standard_Boolean& xdrawtickmarks,
3261 Standard_Boolean& ydrawtickmarks,
3262 Standard_Boolean& zdrawtickmarks,
3263 /* Length of tickmarks */
3264 Standard_Integer& xtickmarklength,
3265 Standard_Integer& ytickmarklength,
3266 Standard_Integer& ztickmarklength,
3267 /* Grid color */
3268 Quantity_Color& gridcolor,
3269 /* Colors of axis names */
3270 Quantity_Color& xnamecolor,
3271 Quantity_Color& ynamecolor,
3272 Quantity_Color& znamecolor,
3273 /* Colors of axis and values */
3274 Quantity_Color& xcolor,
3275 Quantity_Color& ycolor,
3276 Quantity_Color& zcolor,
3277 /* Name of font for names of axes */
3278 TCollection_AsciiString& fontOfNames,
3279 /* Style of names of axes */
eeaaaefb 3280 Font_FontAspect& styleOfNames,
13a22457
S
3281 /* Size of names of axes */
3282 Standard_Integer& sizeOfNames,
3283 /* Name of font for values */
3284 TCollection_AsciiString& fontOfValues,
3285 /* Style of values */
eeaaaefb 3286 Font_FontAspect& styleOfValues,
13a22457
S
3287 /* Size of values */
3288 Standard_Integer& sizeOfValues) const
7fd59977 3289{
13a22457
S
3290 if (!MyGTrihedron.ptrVisual3dView)
3291 return Standard_False;
3292
3293 /* Names of axes */
3294 xname = MyGTrihedron.xname;
bf75be98 3295 yname = MyGTrihedron.yname;
13a22457
S
3296 zname = MyGTrihedron.zname;
3297 /* Draw names */
bf75be98 3298 xdrawname = MyGTrihedron.xdrawname;
3299 ydrawname = MyGTrihedron.ydrawname;
13a22457
S
3300 zdrawname = MyGTrihedron.zdrawname;
3301 /* Draw values */
bf75be98 3302 xdrawvalues = MyGTrihedron.xdrawvalues;
3303 ydrawvalues = MyGTrihedron.ydrawvalues;
13a22457
S
3304 zdrawvalues = MyGTrihedron.zdrawvalues;
3305 /* Draw grid */
3306 drawgrid = MyGTrihedron.drawgrid;
3307 /* Draw axes */
3308 drawaxes = MyGTrihedron.drawaxes;
3309 /* Number of splits along axes */
3310 nbx = MyGTrihedron.nbx;
3311 nby = MyGTrihedron.nby;
3312 nbz = MyGTrihedron.nbz;
3313 /* Offset for drawing values */
3314 xoffset = MyGTrihedron.xoffset;
3315 yoffset = MyGTrihedron.yoffset;
3316 zoffset = MyGTrihedron.zoffset;
3317 /* Offset for drawing names of axes */
3318 xaxisoffset = MyGTrihedron.xaxisoffset;
3319 yaxisoffset = MyGTrihedron.yaxisoffset;
3320 zaxisoffset = MyGTrihedron.zaxisoffset;
3321 /* Draw tickmarks */
3322 xdrawtickmarks = MyGTrihedron.xdrawtickmarks;
3323 ydrawtickmarks = MyGTrihedron.ydrawtickmarks;
3324 zdrawtickmarks = MyGTrihedron.zdrawtickmarks;
3325 /* Length of tickmarks */
3326 xtickmarklength = MyGTrihedron.xtickmarklength;
3327 ytickmarklength = MyGTrihedron.ytickmarklength;
3328 ztickmarklength = MyGTrihedron.ztickmarklength;
3329 /* Grid color */
3330 gridcolor = MyGTrihedron.gridcolor;
3331 /* Colors of axis names */
3332 xnamecolor = MyGTrihedron.xnamecolor;
3333 ynamecolor = MyGTrihedron.ynamecolor;
3334 znamecolor = MyGTrihedron.znamecolor;
3335 /* Colors of axis and values */
3336 xcolor = MyGTrihedron.xcolor;
3337 ycolor = MyGTrihedron.ycolor;
3338 zcolor = MyGTrihedron.zcolor;
3339 /* Name of font for names of axes */
3340 fontOfNames = MyGTrihedron.fontOfNames;
3341 /* Style of names of axes */
3342 styleOfNames = MyGTrihedron.styleOfNames;
3343 /* Size of names of axes */
3344 sizeOfNames = MyGTrihedron.sizeOfNames;
3345 /* Name of font for values */
3346 fontOfValues = MyGTrihedron.fontOfValues;
3347 /* Style of values */
3348 styleOfValues = MyGTrihedron.styleOfValues;
3349 /* Size of values */
3350 sizeOfValues = MyGTrihedron.sizeOfValues;
3351
3352 return Standard_True;
3353}
3354
3355void Visual3d_View::GraduatedTrihedronDisplay
3356 (/* Names of axes */
3357 const TCollection_ExtendedString &xname,
3358 const TCollection_ExtendedString &yname,
3359 const TCollection_ExtendedString &zname,
3360 /* Draw names */
3361 const Standard_Boolean xdrawname,
3362 const Standard_Boolean ydrawname,
3363 const Standard_Boolean zdrawname,
3364 /* Draw values */
3365 const Standard_Boolean xdrawvalues,
3366 const Standard_Boolean ydrawvalues,
3367 const Standard_Boolean zdrawvalues,
3368 /* Draw grid */
3369 const Standard_Boolean drawgrid,
3370 /* Draw axes */
3371 const Standard_Boolean drawaxes,
3372 /* Number of splits along axes */
3373 const Standard_Integer nbx,
3374 const Standard_Integer nby,
3375 const Standard_Integer nbz,
3376 /* Offset for drawing values */
3377 const Standard_Integer xoffset,
3378 const Standard_Integer yoffset,
3379 const Standard_Integer zoffset,
3380 /* Offset for drawing names of axes */
3381 const Standard_Integer xaxisoffset,
3382 const Standard_Integer yaxisoffset,
3383 const Standard_Integer zaxisoffset,
3384 /* Draw tickmarks */
3385 const Standard_Boolean xdrawtickmarks,
3386 const Standard_Boolean ydrawtickmarks,
3387 const Standard_Boolean zdrawtickmarks,
3388 /* Length of tickmarks */
3389 const Standard_Integer xtickmarklength,
3390 const Standard_Integer ytickmarklength,
3391 const Standard_Integer ztickmarklength,
3392 /* Grid color */
3393 const Quantity_Color& gridcolor,
3394 /* Colors of axis names */
3395 const Quantity_Color& xnamecolor,
3396 const Quantity_Color& ynamecolor,
3397 const Quantity_Color& znamecolor,
3398 /* Colors of axis and values */
3399 const Quantity_Color& xcolor,
3400 const Quantity_Color& ycolor,
3401 const Quantity_Color& zcolor,
3402 /* Name of font for names of axes */
3403 const TCollection_AsciiString &fontOfNames,
3404 /* Style of names of axes */
eeaaaefb 3405 const Font_FontAspect styleOfNames,
13a22457
S
3406 /* Size of names of axes */
3407 const Standard_Integer sizeOfNames,
3408 /* Name of font for values */
3409 const TCollection_AsciiString &fontOfValues,
3410 /* Style of values */
eeaaaefb 3411 const Font_FontAspect styleOfValues,
13a22457
S
3412 /* Size of values */
3413 const Standard_Integer sizeOfValues)
7fd59977 3414{
13a22457
S
3415 /* Names of axes */
3416 MyGTrihedron.xname = xname;
3417 MyGTrihedron.yname = yname;
3418 MyGTrihedron.zname = zname;
3419 /* Draw names */
3420 MyGTrihedron.xdrawname = xdrawname;
3421 MyGTrihedron.ydrawname = ydrawname;
3422 MyGTrihedron.zdrawname = zdrawname;
3423 /* Draw values */
3424 MyGTrihedron.xdrawvalues = xdrawvalues;
3425 MyGTrihedron.ydrawvalues = ydrawvalues;
3426 MyGTrihedron.zdrawvalues = zdrawvalues;
3427 /* Draw grid */
3428 MyGTrihedron.drawgrid = drawgrid;
3429 /* Draw axes */
3430 MyGTrihedron.drawaxes = drawaxes;
3431 /* Number of splits along axes */
3432 MyGTrihedron.nbx = nbx;
3433 MyGTrihedron.nby = nby;
3434 MyGTrihedron.nbz = nbz;
3435 /* Offset for drawing values */
3436 MyGTrihedron.xoffset = xoffset;
3437 MyGTrihedron.yoffset = yoffset;
3438 MyGTrihedron.zoffset = zoffset;
3439 /* Offset for drawing names of axes */
3440 MyGTrihedron.xaxisoffset = xaxisoffset;
3441 MyGTrihedron.yaxisoffset = yaxisoffset;
3442 MyGTrihedron.zaxisoffset = zaxisoffset;
3443 /* Draw tickmarks */
3444 MyGTrihedron.xdrawtickmarks = xdrawtickmarks;
3445 MyGTrihedron.ydrawtickmarks = ydrawtickmarks;
3446 MyGTrihedron.zdrawtickmarks = zdrawtickmarks;
3447 /* Length of tickmarks */
3448 MyGTrihedron.xtickmarklength = xtickmarklength;
3449 MyGTrihedron.ytickmarklength = ytickmarklength;
3450 MyGTrihedron.ztickmarklength = ztickmarklength;
3451 /* Grid color */
3452 MyGTrihedron.gridcolor = gridcolor;
3453 /* Colors of axis names */
3454 MyGTrihedron.xnamecolor = xnamecolor;
3455 MyGTrihedron.ynamecolor = ynamecolor;
3456 MyGTrihedron.znamecolor = znamecolor;
3457 /* Colors of axis and values */
3458 MyGTrihedron.xcolor = xcolor;
3459 MyGTrihedron.ycolor = ycolor;
3460 MyGTrihedron.zcolor = zcolor;
3461 /* Name of font for names of axes */
3462 MyGTrihedron.fontOfNames = fontOfNames;
3463 /* Style of names of axes */
3464 MyGTrihedron.styleOfNames = styleOfNames;
3465 /* Size of names of axes */
3466 MyGTrihedron.sizeOfNames = sizeOfNames;
3467 /* Name of font for values */
3468 MyGTrihedron.fontOfValues = fontOfValues;
3469 /* Style of values */
3470 MyGTrihedron.styleOfValues = styleOfValues;
3471 /* Size of values */
3472 MyGTrihedron.sizeOfValues = sizeOfValues;
3473
3474 MyGTrihedron.ptrVisual3dView = this;
3475 MyGTrihedron.cbCubicAxes = SetMinMaxValuesCallback;
3476 MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,MyGTrihedron);
7fd59977 3477}
3478
3479void Visual3d_View::GraduatedTrihedronErase()
3480{
13a22457 3481 MyGTrihedron.ptrVisual3dView = NULL;
7fd59977 3482 MyGraphicDriver->GraduatedTrihedronErase(MyCView);
3483}
3484
3485const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer () const {
3486
3487 return (MyViewManager->UnderLayer ());
3488
3489}