+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
/***********************************************************************
FONCTION :
Classe Visual3d_View.cxx :
- Declaration des variables specifiques aux vues.
+ Declaration of variables specific to views.
- Une vue est definie par :
- - un ViewManager
- - un ContextView
- - un ViewMapping
- - une ViewOrientation
+ A view is defined by :
+ - ViewManager
+ - ContextView
HISTORIQUE DES MODIFICATIONS :
--------------------------------
Mars 1992 : NW,JPB,CAL ; Creation.
04-02-97 : FMN ; Suppression de PSOutput, XWDOutput ...
- 22-04-97 : CAL ; Ajout du Plot.
03-06-97 : FMN ; Correction calcul SetRatio
06-05-97 : CAL ; Ajout du Clear sur les TOS_COMPUTED.
28-07-97 : PCT ; Ajout lumiere frontale headlight.
??-11-97 : CAL ; Retrait de la dependance avec math. Calcul developpe.
??-11-97 : CAL ; Ajout de NumberOfDisplayedStructures
07-08-97 : PCT ; ajout support texture mapping
- 05-01-98 : CAL ; Ajout de AnimationMode
15-01-98 : FMN ; FRA60019 calcul Ratio pour MyViewMappingReset
15-01-98 : CAL ; Ajout de la transformation d'une TOS_COMPUTED
26-01-98 : CAL ; Ajout de la methode HaveTheSameOwner
#define BUC60572 //GG_03-08-99 Add protection on Zclipping & Zcueing planes
// positions.
-#define BUC60570 //GG 14-09-99 Don't activates lighting
-// when the view shading model is NONE.
-
#define GER61454 //GG 14-09-99 Activates model clipping planes
-#define IMP140100 //GG14-01-00 Add ViewManager( ) method
-
-#define G003 //EUG 30-09-00 Degeneration management
-// Backfacing management
-
#define RIC120302 //GG Add a NEW SetWindow method which enable
// to connect a graphic widget and context to OGL.
-#define BUC61044 /* 25/10/01 SAV ; added functionality to control gl depth testing
- from higher API */
-#define BUC61045 /* 25/10/01 SAV ; added functionality to control gl lighting
- from higher API */
+//BUC61044 25/10/01 SAV ; added functionality to control gl depth testing from higher API
+//BUC61045 25/10/01 SAV ; added functionality to control gl lighting from higher API
-#define OCC1188 //SAV Added methods to set background image
+//OCC1188 SAV Added methods to set background image
/*----------------------------------------------------------------------*/
/*
#include <Graphic3d_DataStructureManager.hxx>
#include <Graphic3d_GraphicDriver.hxx>
-#include <Graphic3d_GraphicDevice.hxx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Visual3d_Light.hxx>
-#include <Visual3d_SetOfLight.hxx>
-#include <Visual3d_HSetOfLight.hxx>
-#include <Visual3d_SetIteratorOfSetOfLight.hxx>
-
-#include <Visual3d_ClipPlane.hxx>
-#include <Visual3d_SetOfClipPlane.hxx>
-#include <Visual3d_HSetOfClipPlane.hxx>
-#include <Visual3d_SetIteratorOfSetOfClipPlane.hxx>
-
-#include <Visual3d_SetIteratorOfSetOfView.hxx>
+#include <Visual3d_HSequenceOfView.hxx>
#include <Graphic3d_TextureEnv.hxx>
#include <TColStd_HArray2OfReal.hxx>
-#ifndef WNT
-# include <Xw_Window.hxx>
+#if (defined(_WIN32) || defined(__WIN32__))
+ #include <WNT_Window.hxx>
+#elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
+ #include <Cocoa_Window.hxx>
#else
-# include <WNT_Window.hxx>
-#endif // WNT
+ #include <Xw_Window.hxx>
+#endif
#include <float.h>
Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager):
MyContext (),
-MyViewMapping (),
-MyViewMappingReset (),
-MyViewOrientation (),
-MyViewOrientationReset (),
-MyTransformation (0, 3, 0, 3),
-MyMatrixOfMapping (0, 3, 0, 3),
-MyMatrixOfOrientation (0, 3, 0, 3),
MyTOCOMPUTESequence (),
MyCOMPUTEDSequence (),
MyDisplayedStructure ()
{
-Standard_Integer i, j;
-#ifdef IMP140100
MyPtrViewManager = AManager.operator->();
-#else
- MyPtrViewManager = (void *) AManager.operator->();
-#endif
-
- memset (&MyCView, 0, sizeof(MyCView));
MyCView.ViewId = int (AManager->Identification (this));
MyCView.Active = 0;
MyCView.IsDeleted = 0;
- MyCView.WsId = -1;
- MyCView.DefWindow.IsDefined = 0;
+ MyCView.WsId = -1;
+ MyCView.DefWindow.IsDefined = 0;
- MyCView.Context.NbActiveLight = 0;
- MyCView.Context.NbActivePlane = 0;
-#ifdef GER61454
- MyCView.Context.ActivePlane = NULL;
-#endif
-
- for (i=0; i<=3; i++)
- for (j=0; j<=3; j++)
- if (i == j) MyTransformation (i, j) = 1.0;
- else MyTransformation (i, j) = 0.0;
-
-Standard_Real X, Y, Z;
-
- (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferencePoint.x = float (X);
- MyCView.Orientation.ViewReferencePoint.y = float (Y);
- MyCView.Orientation.ViewReferencePoint.z = float (Z);
- (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferencePlane.x = float (X);
- MyCView.Orientation.ViewReferencePlane.y = float (Y);
- MyCView.Orientation.ViewReferencePlane.z = float (Z);
- (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferenceUp.x = float (X);
- MyCView.Orientation.ViewReferenceUp.y = float (Y);
- MyCView.Orientation.ViewReferenceUp.z = float (Z);
-
-Standard_Real Sx, Sy, Sz;
-
- MyViewOrientation.AxialScale(Sx, Sy, Sz);
- MyCView.Orientation.ViewScaleX = float (Sx);
- MyCView.Orientation.ViewScaleY = float (Sy);
- MyCView.Orientation.ViewScaleZ = float (Sz);
-
- // NKV : 23/07/07 - Define custom MODELVIEW matrix
- MyCView.Orientation.IsCustomMatrix = 0;
- memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
- MyCView.Orientation.ModelViewMatrix[0][0] =
- MyCView.Orientation.ModelViewMatrix[1][1] =
- MyCView.Orientation.ModelViewMatrix[2][2] =
- MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
- //
-
-Standard_Real um, vm, uM, vM;
-
- MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
- (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
- MyCView.Mapping.ProjectionReferencePoint.x = float (X);
- MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
- MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
- MyCView.Mapping.ViewPlaneDistance =
- float (MyViewMapping.ViewPlaneDistance ());
- MyCView.Mapping.BackPlaneDistance =
- float (MyViewMapping.BackPlaneDistance ());
- MyCView.Mapping.FrontPlaneDistance =
- float (MyViewMapping.FrontPlaneDistance ());
- MyViewMapping.WindowLimit (um, vm, uM, vM);
- MyCView.Mapping.WindowLimit.um = float (um);
- MyCView.Mapping.WindowLimit.vm = float (vm);
- MyCView.Mapping.WindowLimit.uM = float (uM);
- MyCView.Mapping.WindowLimit.vM = float (vM);
-
- // NKV : 23/07/07 - Define custom MODELVIEW matrix
- MyCView.Mapping.IsCustomMatrix = 0;
- memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
- MyCView.Mapping.ProjectionMatrix[0][0] =
- MyCView.Mapping.ProjectionMatrix[1][1] =
- MyCView.Mapping.ProjectionMatrix[2][2] =
- MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
- //
+ MyCView.Context.NbActiveLight = 0;
MyCView.Context.ZBufferActivity = -1;
- MyMatOfMapIsModified = Standard_True;
- MyMatOfOriIsModified = Standard_True;
- MyMatOfMapIsEvaluated = Standard_False;
- MyMatOfOriIsEvaluated = Standard_False;
-
- DegenerateModeIsActive = Standard_False;
- AnimationModeIsActive = Standard_False;
-#ifdef G003
- MyCView.IsDegenerates = 0;
- MyCView.IsDegeneratesPrev = 0;
+ IsInitialized = Standard_False;
ComputedModeIsActive = Standard_False;
MyCView.Backfacing = 0;
-#endif // G003
- MyCView.DefBitmap.bitmap = 0;
MyCView.ptrUnderLayer = 0;
MyCView.ptrOverLayer = 0;
MyCView.GContext = 0;
MyCView.GDisplayCB = 0;
MyCView.GClientData = 0;
-Handle(Aspect_GraphicDriver) agd =
- (MyViewManager->GraphicDevice ())->GraphicDriver ();
-
- MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
+ MyGraphicDriver = MyViewManager->GraphicDriver();
}
-Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager, const Visual3d_ViewOrientation& VO, const Visual3d_ViewMapping& VM, const Visual3d_ContextView& CTX):
-MyTransformation (0, 3, 0, 3),
-MyMatrixOfMapping (0, 3, 0, 3),
-MyMatrixOfOrientation (0, 3, 0, 3),
-MyTOCOMPUTESequence (),
-MyCOMPUTEDSequence (),
-MyDisplayedStructure ()
-{
-Standard_Integer i, j;
-
-#ifdef IMP140100
- MyPtrViewManager = AManager.operator->();
-#else
- MyPtrViewManager = (void *) AManager.operator->();
-#endif
-
- MyViewOrientation = VO;
- MyViewMapping = VM;
- MyContext = CTX;
- MyViewOrientationReset = VO;
- MyViewMappingReset = VM;
-
- memset (&MyCView, 0, sizeof(MyCView));
- MyCView.ViewId = int (AManager->Identification (this));
- MyCView.Active = 0;
- MyCView.IsDeleted = 0;
-
- MyCView.WsId = -1;
- MyCView.DefWindow.IsDefined = 0;
-
- MyCView.Context.NbActiveLight = 0;
- MyCView.Context.NbActivePlane = 0;
-#ifdef GER61454
- MyCView.Context.ActivePlane = NULL;
-#endif
-
- for (i=0; i<=3; i++)
- for (j=0; j<=3; j++)
- if (i == j) MyTransformation (i, j) = 1.0;
- else MyTransformation (i, j) = 0.0;
-
-Standard_Real X, Y, Z;
-
- (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferencePoint.x = float (X);
- MyCView.Orientation.ViewReferencePoint.y = float (Y);
- MyCView.Orientation.ViewReferencePoint.z = float (Z);
- (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferencePlane.x = float (X);
- MyCView.Orientation.ViewReferencePlane.y = float (Y);
- MyCView.Orientation.ViewReferencePlane.z = float (Z);
- (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
- MyCView.Orientation.ViewReferenceUp.x = float (X);
- MyCView.Orientation.ViewReferenceUp.y = float (Y);
- MyCView.Orientation.ViewReferenceUp.z = float (Z);
-
-Standard_Real Sx, Sy, Sz;
-
- MyViewOrientation.AxialScale(Sx, Sy, Sz);
- MyCView.Orientation.ViewScaleX = float (Sx);
- MyCView.Orientation.ViewScaleY = float (Sy);
- MyCView.Orientation.ViewScaleZ = float (Sz);
-
- // NKV : 23/07/07 - Define custom MODELVIEW matrix
- if (MyViewOrientation.IsCustomMatrix()) {
- MyCView.Orientation.IsCustomMatrix = 1;
- for ( i = 0; i < 4; i++)
- for ( j = 0; j < 4; j++)
- MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
- }
- else {
- MyCView.Orientation.IsCustomMatrix = 0;
- memset( (float*)MyCView.Orientation.ModelViewMatrix, 0, 16*sizeof( float ) );
- MyCView.Orientation.ModelViewMatrix[0][0] =
- MyCView.Orientation.ModelViewMatrix[1][1] =
- MyCView.Orientation.ModelViewMatrix[2][2] =
- MyCView.Orientation.ModelViewMatrix[3][3] = 1.;
- }
- //
-
-Standard_Real um, vm, uM, vM;
-
- MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
- (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
- MyCView.Mapping.ProjectionReferencePoint.x = float (X);
- MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
- MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
- MyCView.Mapping.ViewPlaneDistance =
- float (MyViewMapping.ViewPlaneDistance ());
- MyCView.Mapping.BackPlaneDistance =
- float (MyViewMapping.BackPlaneDistance ());
- MyCView.Mapping.FrontPlaneDistance =
- float (MyViewMapping.FrontPlaneDistance ());
- MyViewMapping.WindowLimit (um, vm, uM, vM);
- MyCView.Mapping.WindowLimit.um = float (um);
- MyCView.Mapping.WindowLimit.vm = float (vm);
- MyCView.Mapping.WindowLimit.uM = float (uM);
- MyCView.Mapping.WindowLimit.vM = float (vM);
-
- // NKV : 23/07/07 - Define custom MODELVIEW matrix
- if (MyViewMapping.IsCustomMatrix()) {
- MyCView.Mapping.IsCustomMatrix = 1;
- for ( i = 0; i < 4; i++)
- for ( j = 0; j < 4; j++)
- MyCView.Mapping.ProjectionMatrix[i][j] = MyViewMapping.MyProjectionMatrix->Value(i,j);
- }
- else {
- MyCView.Mapping.IsCustomMatrix = 0;
- memset( (float*)MyCView.Mapping.ProjectionMatrix, 0, 16*sizeof( float ) );
- MyCView.Mapping.ProjectionMatrix[0][0] =
- MyCView.Mapping.ProjectionMatrix[1][1] =
- MyCView.Mapping.ProjectionMatrix[2][2] =
- MyCView.Mapping.ProjectionMatrix[3][3] = 1.;
- }
- //
-
- MyCView.Context.ZBufferActivity = -1;
-
- MyMatOfMapIsModified = Standard_True;
- MyMatOfOriIsModified = Standard_True;
- MyMatOfMapIsEvaluated = Standard_False;
- MyMatOfOriIsEvaluated = Standard_False;
-#ifdef G003
- AnimationModeIsActive = Standard_False;
- MyCView.IsDegenerates = 0;
- MyCView.IsDegeneratesPrev = 0;
- ComputedModeIsActive = Standard_False;
-#endif // G003
-
- MyCView.DefBitmap.bitmap = 0;
- MyCView.ptrUnderLayer = 0;
- MyCView.ptrOverLayer = 0;
- MyCView.GContext = 0;
- MyCView.GDisplayCB = 0;
- MyCView.GClientData = 0;
-
-Handle(Aspect_GraphicDriver) agd =
- (MyViewManager->GraphicDevice ())->GraphicDriver ();
-
- MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
-
-}
-
-//-Destructors
-
//-Methods, in order
// RIC120302
void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow,
}
// RIC120302
-void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow) {
+void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow)
+{
+ if (IsDeleted ()) return;
- if (IsDeleted ()) return;
+ if (IsDefined ())
+ {
+ Visual3d_ViewDefinitionError::Raise ("Window already defined");
+ }
- if (IsDefined ())
- Visual3d_ViewDefinitionError::Raise ("Window already defined");
-
- MyWindow = AWindow;
- MyCView.WsId = MyCView.ViewId;
- MyCView.DefWindow.IsDefined = 1;
-#ifndef WNT
-const Handle(Xw_Window) theWindow = *(Handle(Xw_Window) *) &AWindow;
- MyCView.DefWindow.XWindow = theWindow->XWindow ();
-#ifdef RIC120302
- MyCView.DefWindow.XParentWindow = theWindow->XParentWindow ();
-#endif
-#else
-WNT_WindowData* wd;
-const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AWindow;
- MyCView.DefWindow.XWindow = ( HWND )(theWindow->HWindow());
-#ifdef RIC120302
- MyCView.DefWindow.XParentWindow = ( HWND )(theWindow->HParentWindow());
-#endif
-#ifndef _WIN64
- wd = ( WNT_WindowData* )GetWindowLong (( HWND )(theWindow->HWindow()), GWL_USERDATA);
+ MyWindow = theWindow;
+ MyCView.WsId = MyCView.ViewId;
+ MyCView.DefWindow.IsDefined = 1;
+#if (defined(_WIN32) || defined(__WIN32__))
+ const Handle(WNT_Window) aWin = Handle(WNT_Window)::DownCast (theWindow);
+ MyCView.DefWindow.XWindow = (HWND )(aWin->HWindow());
+ MyCView.DefWindow.XParentWindow = (HWND )(aWin->HParentWindow());
+ WNT_WindowData* aWinData = (WNT_WindowData* )GetWindowLongPtr ((HWND )(aWin->HWindow()), GWLP_USERDATA);
+ aWinData->WNT_WDriver_Ptr = (void* )this;
+ aWinData->WNT_VMgr = (void* )MyPtrViewManager;
+#elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
+ const Handle(Cocoa_Window) aWin = Handle(Cocoa_Window)::DownCast (theWindow);
+ MyCView.DefWindow.XWindow = (Aspect_Drawable )aWin->HView();
+ MyCView.DefWindow.XParentWindow = NULL;
+ //MyCView.DefWindow.XParentWindow = aWin->HParentWindow();
#else
- wd = ( WNT_WindowData* )GetWindowLong (( HWND )(theWindow->HWindow()), GWLP_USERDATA);
+ const Handle(Xw_Window) aWin = Handle(Xw_Window)::DownCast (theWindow);
+ MyCView.DefWindow.XWindow = aWin->XWindow();
+ //MyCView.DefWindow.XParentWindow = aWin->XParentWindow();
#endif
- wd -> WNT_WDriver_Ptr = ( void* )this;
- wd -> WNT_VMgr = ( void* )MyPtrViewManager;
-#endif /* WNT */
Standard_Integer Width, Height;
- AWindow->Size (Width, Height);
+ theWindow->Size (Width, Height);
MyCView.DefWindow.dx = float( Width );
MyCView.DefWindow.dy = float( Height );
MyGradientBackground = MyWindow->GradientBackground();
SetGradientBackground(MyGradientBackground,1);
- Standard_Boolean AWait = Standard_False; // => mise a jour immediate
+ Standard_Boolean AWait = Standard_False; // => immediate update
MyGraphicDriver->SetVisualisation (MyCView);
MyGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn ());
MyGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn ());
MyGraphicDriver->ClipLimit (MyCView, AWait);
MyGraphicDriver->Environment(MyCView);
- // Mise a jour des plans de model clipping
+ // Make view manager z layer list consistent with the view's list.
+ MyViewManager->InstallZLayers (this);
+
+ // Update planses of model clipping
UpdatePlanes ();
- // Mise a jour des sources lumineuses
+ // Update light sources
UpdateLights ();
/*
- * Association view-window n'entraine pas le display
- * des structures qui peuvent etre affichees dans la
- * nouvelle vue.
- * En effet, l'association vue-fenetre est faite, mais
- * l'affichage ne sera realise que lorsque la vue sera
- * activee (Activate).
+ * Association view-window does not cause the display
+ * of structures that can be displayed in the new view.
+ * In fact, association view-window is done, but the
+ * display is produced only if the view is activated (Activate).
*/
SetRatio ();
MyCView.IsDeleted = 1;
MyCView.DefWindow.IsDefined = 0;
- MyMatOfMapIsModified = Standard_True;
- MyMatOfOriIsModified = Standard_True;
- MyMatOfMapIsEvaluated = Standard_False;
- MyMatOfOriIsEvaluated = Standard_False;
+ IsInitialized = Standard_False;
MyWindow.Nullify ();
}
-void Visual3d_View::SetRatio () {
-
- if (IsDeleted ()) return;
-
-Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode ();
- MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
-
-Standard_Real Umin, Vmin, Umax, Vmax;
-Standard_Integer Dxw, Dyw;
-Standard_Real Dxv, Dyv;
-Standard_Real Xc, Yc;
-Standard_Real Rap;
-
- Rap = 0. ;
- MyWindow->Size (Dxw, Dyw);
- MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
- Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
- if( Dxw > 0 && Dyw > 0 ) Rap = (Standard_Real)Dyw/(Standard_Real)Dxw ;
- if( Rap > 0.0 ) {
-
- if( Dxv <= Dyv )
- {
- if (Rap <= 1.0)
- {
- Dyv = Dxv;
- Dxv = Dxv/Rap;
- }
- else
- {
- Dxv = Dxv;
- Dyv = Dxv*Rap;
- }
- }
- else
- {
- if (Rap <= 1.0)
- {
- Dxv = Dyv/Rap;
- Dyv = Dyv;
- }
- else
- {
- Dxv = Dyv;
- Dyv = Dyv*Rap;
- }
- }
-
- Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
- Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
-
- MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
-
- // Mise a jour avant le SetViewMapping.
+void Visual3d_View::SetRatio()
+{
+ if (IsDeleted())
+ {
+ return;
+ }
- MyCView.DefWindow.dx = float( Dxw );
- MyCView.DefWindow.dy = float( Dyw );
+ Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode();
- SetViewMapping (MyViewMapping);
-// SetViewMappingDefault ();
- // FMN+ Mise a jout Ratio pour le MyViewMappingReset
+ MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
- MyViewMappingReset.WindowLimit(Umin,Vmin,Umax,Vmax) ;
- Xc = (Umin + Umax)/2. ; Yc = (Vmin + Vmax)/2. ;
- Dxv = Umax - Umin ; Dyv = Vmax - Vmin ;
+ Standard_Integer aWidth, aHeight;
- if( Dxv <= Dyv )
- {
- if (Rap <= 1.0)
- {
- Dyv = Dxv;
- Dxv = Dxv/Rap;
- }
- else
- {
- Dxv = Dxv;
- Dyv = Dxv*Rap;
- }
- }
- else
- {
- if (Rap <= 1.0)
- {
- Dxv = Dyv/Rap;
- Dyv = Dyv;
- }
- else
- {
- Dxv = Dyv;
- Dyv = Dyv*Rap;
- }
- }
+ MyWindow->Size (aWidth, aHeight);
- Umin = Xc - Dxv/2. ; Vmin = Yc - Dyv/2. ;
- Umax = Xc + Dxv/2. ; Vmax = Yc + Dyv/2. ;
+ if( aWidth > 0 && aHeight > 0 )
+ {
+ Standard_Real aRatio = (Standard_Real)aWidth / (Standard_Real)aHeight;
- MyViewMappingReset.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
+ MyCView.DefWindow.dx = Standard_ShortReal (aWidth);
+ MyCView.DefWindow.dy = Standard_ShortReal (aHeight);
- // FMN- Mise a jout Ratio pour le MyViewMappingReset
+ MyGraphicDriver->RatioWindow (MyCView);
- MyGraphicDriver->RatioWindow (MyCView);
- }
+ // Update camera aspect
+ Handle(Graphic3d_Camera) aCamera = MyCView.Context.Camera;
- // On force a recalculer les 2 matrices.
- //
- // La vue courante peut servir a reconstruire une vue copie
- // qui est elle meme. Grace au SetWindow et au SetRatio on
- // impose le recalcul des matrices de cette nouvelle vue.
- MyMatOfMapIsEvaluated = Standard_False;
- MyMatOfOriIsEvaluated = Standard_False;
+ if (!aCamera.IsNull())
+ {
+ aCamera->SetAspect (aRatio);
+ }
- MyViewManager->SetUpdateMode (UpdateMode);
- if (UpdateMode == Aspect_TOU_ASAP) Update ();
+ if (!myDefaultCamera.IsNull())
+ {
+ myDefaultCamera->SetAspect (aRatio);
+ }
+ }
+ MyViewManager->SetUpdateMode (UpdateMode);
+ if (UpdateMode == Aspect_TOU_ASAP)
+ Update();
}
-void Visual3d_View::UpdateLights () {
+void Visual3d_View::UpdateLights()
+{
+ if (IsDeleted()
+ || !IsDefined())
+ {
+ return;
+ }
-Standard_Integer i, j;
-CALL_DEF_LIGHT *lights=NULL;
+ if (MyContext.Model() == Visual3d_TOM_NONE)
+ {
+ // activate only a white ambient light
+ Graphic3d_CLight aCLight;
+ aCLight.Type = Visual3d_TOLS_AMBIENT;
+ aCLight.IsHeadlight = Standard_False;
+ aCLight.Color.r() = aCLight.Color.g() = aCLight.Color.b() = 1.0f;
-#ifdef BUC60570
- if( MyContext.Model() == Visual3d_TOM_NONE ) {
-// Activates only a white ambient light
MyCView.Context.NbActiveLight = 1;
- lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
- MyCView.Context.ActiveLight = lights;
-
- lights[0].WsId = MyCView.ViewId;
- lights[0].ViewId = MyCView.ViewId;
- lights[0].LightType = int (Visual3d_TOLS_AMBIENT);
- lights[0].Active = 1;
- lights[0].LightId = 0;
- lights[0].Headlight = 0;
- lights[0].Color.r = lights[0].Color.g = lights[0].Color.b = 1.;
- } else {
-#endif
- i = MyContext.NumberOfActivatedLights ();
- j = MyGraphicDriver->InquireLightLimit ();
- MyCView.Context.NbActiveLight = (i > j ? j : i);
-
- if (MyCView.Context.NbActiveLight > 0) {
-
- // Allocation dynamique
- lights = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
-
- MyCView.Context.ActiveLight = lights;
-
-Standard_Real X, Y, Z;
-
-Standard_Real LightConcentration;
-Standard_Real LightAttenuation1;
-Standard_Real LightAttenuation2;
-Standard_Real LightAngle;
-Quantity_Color LightColor;
-Graphic3d_Vertex LightPosition;
-Graphic3d_Vector LightDirection;
-Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT;
-
- // Parcours des sources lumineuses
- for (j=0; j<MyCView.Context.NbActiveLight; j++) {
- LightType = (MyContext.ActivatedLight (j+1))->LightType ();
-
- lights[j].WsId = MyCView.ViewId;
- lights[j].ViewId = MyCView.ViewId;
-
- lights[j].LightType = int (LightType);
- lights[j].Active = 1;
- lights[j].LightId =
- int ((MyContext.ActivatedLight (j+1))->Identification ());
- lights[j].Headlight = (MyContext.ActivatedLight (j+1))->Headlight ()? 1:0;
-
- switch (LightType) {
-
- case Visual3d_TOLS_AMBIENT :
- (MyContext.ActivatedLight (j+1))->Values (
- LightColor
- );
- break;
-
- case Visual3d_TOLS_POSITIONAL :
- (MyContext.ActivatedLight (j+1))->Values (
- LightColor,
- LightPosition,
- LightAttenuation1,
- LightAttenuation2
- );
- break;
-
- case Visual3d_TOLS_DIRECTIONAL :
- (MyContext.ActivatedLight (j+1))->Values (
- LightColor,
- LightDirection
- );
- break;
-
- case Visual3d_TOLS_SPOT :
- (MyContext.ActivatedLight (j+1))->Values (
- LightColor,
- LightPosition,
- LightDirection,
- LightConcentration,
- LightAttenuation1,
- LightAttenuation2,
- LightAngle
- );
- break;
-
- }
-
- lights[j].Color.r = float (LightColor.Red ());
- lights[j].Color.g = float (LightColor.Green ());
- lights[j].Color.b = float (LightColor.Blue ());
-
- if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
- (LightType == Visual3d_TOLS_SPOT) ) {
- LightPosition.Coord (X, Y, Z);
- lights[j].Position.x = float (X);
- lights[j].Position.y = float (Y);
- lights[j].Position.z = float (Z);
- }
-
- if ( (LightType == Visual3d_TOLS_DIRECTIONAL) ||
- (LightType == Visual3d_TOLS_SPOT) ) {
- LightDirection.Coord (X, Y, Z);
- lights[j].Direction.x = float (X);
- lights[j].Direction.y = float (Y);
- lights[j].Direction.z = float (Z);
- }
-
- if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
- (LightType == Visual3d_TOLS_SPOT) ) {
- lights[j].Attenuation[0] =
- float (LightAttenuation1);
- lights[j].Attenuation[1] =
- float (LightAttenuation2);
- }
-
- if (LightType == Visual3d_TOLS_SPOT) {
- lights[j].Concentration =
- float (LightConcentration);
- lights[j].Angle =
- float (LightAngle);
- }
- }
-
- }
-#ifdef BUC60570
+ MyCView.Context.ActiveLight = &aCLight;
+ MyGraphicDriver->SetLight (MyCView);
+ MyCView.Context.ActiveLight = NULL;
+ return;
}
-#endif
- // gestion des sources lumineuses
- if (! IsDeleted ())
- if (IsDefined ())
- MyGraphicDriver->SetLight (MyCView);
- // Desallocation dynamique
- if (MyCView.Context.NbActiveLight > 0) delete [] lights;
+ MyCView.Context.NbActiveLight = Min (MyContext.NumberOfActivatedLights(),
+ MyGraphicDriver->InquireLightLimit());
+ if (MyCView.Context.NbActiveLight < 1)
+ {
+ MyGraphicDriver->SetLight (MyCView);
+ return;
+ }
+ // parcing of light sources
+ MyCView.Context.ActiveLight = new Graphic3d_CLight[MyCView.Context.NbActiveLight];
+ for (Standard_Integer aLightIter = 0; aLightIter < MyCView.Context.NbActiveLight; ++aLightIter)
+ {
+ MyCView.Context.ActiveLight[aLightIter] = MyContext.ActivatedLight (aLightIter + 1)->CLight();
+ }
+ MyGraphicDriver->SetLight (MyCView);
+ delete[] MyCView.Context.ActiveLight;
+ MyCView.Context.ActiveLight = NULL;
}
-void Visual3d_View::UpdatePlanes () {
-
-Standard_Integer i, j;
-CALL_DEF_PLANE *planes=NULL;
-
- i = MyContext.NumberOfActivatedClipPlanes ();
- j = MyGraphicDriver->InquirePlaneLimit ();
- MyCView.Context.NbActivePlane = (i > j ? j : i);
-
- if (MyCView.Context.NbActivePlane > 0) {
-
- // Allocation dynamique
-#ifdef GER61454 //Keep the plane address for the next Update !
- if( !MyCView.Context.ActivePlane )
- MyCView.Context.ActivePlane = new CALL_DEF_PLANE [j];
- planes = MyCView.Context.ActivePlane;
-#else
- planes = new CALL_DEF_PLANE [MyCView.Context.NbActivePlane];
-
- MyCView.Context.ActivePlane = planes;
-#endif
-Standard_Real A, B, C, D;
-
- // Parcours des plans de clipping
- for (j=0; j<MyCView.Context.NbActivePlane; j++) {
-
- planes[j].WsId = MyCView.ViewId;
- planes[j].ViewId = MyCView.ViewId;
-
- planes[j].Active = 1;
- planes[j].PlaneId =
- int ((MyContext.ActivatedClipPlane (j+1))->Identification ());
-
- (MyContext.ActivatedClipPlane (j+1))->Plane (A, B, C, D);
- planes[j].CoefA = float (A);
- planes[j].CoefB = float (B);
- planes[j].CoefC = float (C);
- planes[j].CoefD = float (D);
- }
-
- }
-
- // gestion des plans de model clipping
- if (! IsDeleted ())
- if (IsDefined ())
- MyGraphicDriver->SetPlane (MyCView);
-
- // Desallocation dynamique
-#ifdef GER61454
- if ( MyCView.Context.ActivePlane && (MyCView.Context.NbActivePlane == 0)
- ) {
- delete [] MyCView.Context.ActivePlane;
- MyCView.Context.ActivePlane = NULL;
- }
-#else
- if (MyCView.Context.NbActivePlane > 0) delete [] planes;
-#endif
+void Visual3d_View::UpdatePlanes()
+{
+ MyCView.Context.ClipPlanes = MyContext.ClipPlanes();
+ if (IsDeleted() || !IsDefined())
+ {
+ return;
+ }
+ MyGraphicDriver->SetClipPlanes (MyCView);
}
void Visual3d_View::SetBackground (const Aspect_Background& ABack) {
if (! IsDefined ())
Visual3d_ViewDefinitionError::Raise ("Window not defined");
- // A ce niveau, seule la GL peut mettre a jour le background.
- // Il ne faut pas appeler MyWindow->SetBackground (ABack); car
- // cette methode lance une mise a jour du fond de fenetre par X
- // (si le fenetrage est X bien-sur)
+ // At this level, only GL can update the background.
+ // It is not necessary to call MyWindow->SetBackground (ABack); as
+ // this method starts update of window background by X
+ // (if the windowing is X)
Standard_Real R, G, B;
MyBackground = ABack;
const Aspect_FillMethod FillStyle,
const Standard_Boolean update )
{
-#ifdef OCC1188
if ( IsDeleted() )
return;
if ( !IsDefined() )
Update();
else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
Update();
-#endif
}
void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
const Standard_Boolean update )
{
-#ifdef OCC1188
if ( IsDeleted() )
return;
if ( !IsDefined() )
Update();
else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
Update();
-#endif
}
Aspect_Background Visual3d_View::Background () const {
}
-void Visual3d_View::SetTransform (const TColStd_Array2OfReal& AMatrix) {
-
- if (IsDeleted ()) return;
-
-Standard_Integer lr, ur, lc, uc;
-Standard_Integer i, j;
-
- // Assign the new transformation in an array [0..3][0..3]
- // Evite des problemes si le user a defini sa matrice [1..4][1..4]
- // ou [3..6][-1..2] !!
- lr = AMatrix.LowerRow ();
- ur = AMatrix.UpperRow ();
- lc = AMatrix.LowerCol ();
- uc = AMatrix.UpperCol ();
-
- if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
- Visual3d_TransformError::Raise ("Transform : not a 4x4 matrix");
-
- for (i=0; i<=3; i++)
- for (j=0; j<=3; j++)
- MyTransformation (i, j) = AMatrix (lr + i, lc + j);
-
-Graphic3d_Vector VPN;
-Graphic3d_Vertex VRP;
-Graphic3d_Vector VUP;
-Standard_Real Sx, Sy, Sz;
-
-Visual3d_ViewOrientation NewViewOrientation;
-
- VPN = MyViewOrientation.ViewReferencePlane ();
- VRP = MyViewOrientation.ViewReferencePoint ();
- VUP = MyViewOrientation.ViewReferenceUp ();
- MyViewOrientation.AxialScale(Sx, Sy, Sz);
-
- NewViewOrientation.SetViewReferencePlane
- (Graphic3d_Structure::Transforms (Transform (), VPN));
-
- NewViewOrientation.SetViewReferencePoint
- (Graphic3d_Structure::Transforms (Transform (), VRP));
-
- NewViewOrientation.SetViewReferenceUp
- (Graphic3d_Structure::Transforms (Transform (), VUP));
- NewViewOrientation.SetAxialScale(Sx, Sy, Sz);
-
- SetViewOrientation (NewViewOrientation);
-
- MyMatOfOriIsModified = Standard_True;
- MyMatOfOriIsEvaluated = Standard_False;
-
-}
-
-const TColStd_Array2OfReal& Visual3d_View::Transform () const {
-
- return (MyTransformation);
-
-}
-
-void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
-
- if (IsDeleted ()) return;
-
- MyViewOrientation = VO;
-
-Standard_Real X, Y, Z;
-
- // Tests sur la modification des parametres.
-Standard_Boolean VUPIsModified = Standard_False;
-Standard_Boolean VRPIsModified = Standard_False;
-Standard_Boolean VRUIsModified = Standard_False;
-Standard_Boolean ScaleIsModified = Standard_False;
-Standard_Boolean CustomIsModified = Standard_False;
-
- (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
- VUPIsModified =
- MyCView.Orientation.ViewReferencePoint.x != float (X)
- || MyCView.Orientation.ViewReferencePoint.y != float (Y)
- || MyCView.Orientation.ViewReferencePoint.z != float (Z);
- MyCView.Orientation.ViewReferencePoint.x = float (X);
- MyCView.Orientation.ViewReferencePoint.y = float (Y);
- MyCView.Orientation.ViewReferencePoint.z = float (Z);
-
- (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
- VRPIsModified =
- MyCView.Orientation.ViewReferencePlane.x != float (X)
- || MyCView.Orientation.ViewReferencePlane.y != float (Y)
- || MyCView.Orientation.ViewReferencePlane.z != float (Z);
- MyCView.Orientation.ViewReferencePlane.x = float (X);
- MyCView.Orientation.ViewReferencePlane.y = float (Y);
- MyCView.Orientation.ViewReferencePlane.z = float (Z);
-
- (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
- VRUIsModified =
- MyCView.Orientation.ViewReferenceUp.x != float (X)
- || MyCView.Orientation.ViewReferenceUp.y != float (Y)
- || MyCView.Orientation.ViewReferenceUp.z != float (Z);
- MyCView.Orientation.ViewReferenceUp.x = float (X);
- MyCView.Orientation.ViewReferenceUp.y = float (Y);
- MyCView.Orientation.ViewReferenceUp.z = float (Z);
-
-Standard_Real Sx, Sy, Sz;
-
- MyViewOrientation.AxialScale(Sx, Sy, Sz);
- ScaleIsModified =
- MyCView.Orientation.ViewScaleX != float (X)
- || MyCView.Orientation.ViewScaleY != float (Y)
- || MyCView.Orientation.ViewScaleZ != float (Z);
- MyCView.Orientation.ViewScaleX = float (Sx);
- MyCView.Orientation.ViewScaleY = float (Sy);
- MyCView.Orientation.ViewScaleZ = float (Sz);
-
- CustomIsModified =
- MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
- MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
- if ( MyViewOrientation.IsCustomMatrix() ) {
- Standard_Integer i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++) {
- if (!CustomIsModified) CustomIsModified =
- MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
- MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
- }
- }
-
-#ifdef TRACE_TRSF
-cout << "Visual3d_View::SetViewOrientation\n";
- if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
- cout << "VUPIsModified : " << VUPIsModified
- << ", VRPIsModified : " << VRPIsModified
- << ", VRUIsModified : " << VRUIsModified
- << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
- else
- cout << "no modification\n" << flush;
-#endif
-
- // Mise en route que si l'un des parametres est modifie
- if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified) {
-
- if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
- MyMatOfOriIsModified = Standard_True;
- MyMatOfOriIsEvaluated = Standard_False;
- }
-
- if (! IsDefined ()) return;
-
-Standard_Boolean AWait = Standard_False; // => mise a jour immediate
- MyGraphicDriver->ViewOrientation (MyCView, AWait);
-
- Compute ();
-
- if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
- }
-
-}
-
-Visual3d_ViewOrientation Visual3d_View::ViewOrientation () const {
-
- return (MyViewOrientation);
-
-}
-
-Visual3d_ViewOrientation Visual3d_View::ViewOrientationDefault () const {
-
- return (MyViewOrientationReset);
-
-}
-
-void Visual3d_View::SetViewOrientationDefault () {
-
- MyViewOrientationReset.Assign (MyViewOrientation);
-
-}
-
-void Visual3d_View::ViewOrientationReset () {
-
- if (IsDeleted ()) return;
-
- MyViewOrientation = MyViewOrientationReset;
-
-Standard_Real X, Y, Z;
-
- // Tests sur la modification des parametres.
-Standard_Boolean VUPIsModified = Standard_False;
-Standard_Boolean VRPIsModified = Standard_False;
-Standard_Boolean VRUIsModified = Standard_False;
-Standard_Boolean ScaleIsModified = Standard_False;
-Standard_Boolean CustomIsModified = Standard_False;
-
- (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
- VUPIsModified =
- MyCView.Orientation.ViewReferencePoint.x != float (X)
- || MyCView.Orientation.ViewReferencePoint.y != float (Y)
- || MyCView.Orientation.ViewReferencePoint.y != float (Y);
- MyCView.Orientation.ViewReferencePoint.x = float (X);
- MyCView.Orientation.ViewReferencePoint.y = float (Y);
- MyCView.Orientation.ViewReferencePoint.z = float (Z);
-
- (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
- VRPIsModified =
- MyCView.Orientation.ViewReferencePlane.x != float (X)
- || MyCView.Orientation.ViewReferencePlane.y != float (Y)
- || MyCView.Orientation.ViewReferencePlane.y != float (Y);
- MyCView.Orientation.ViewReferencePlane.x = float (X);
- MyCView.Orientation.ViewReferencePlane.y = float (Y);
- MyCView.Orientation.ViewReferencePlane.z = float (Z);
-
- (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
- VRUIsModified =
- MyCView.Orientation.ViewReferenceUp.x != float (X)
- || MyCView.Orientation.ViewReferenceUp.y != float (Y)
- || MyCView.Orientation.ViewReferenceUp.y != float (Y);
- MyCView.Orientation.ViewReferenceUp.x = float (X);
- MyCView.Orientation.ViewReferenceUp.y = float (Y);
- MyCView.Orientation.ViewReferenceUp.z = float (Z);
-
-Standard_Real Sx, Sy, Sz;
-
- MyViewOrientation.AxialScale(Sx, Sy, Sz);
- ScaleIsModified =
- MyCView.Orientation.ViewScaleX != float (X)
- || MyCView.Orientation.ViewScaleY != float (Y)
- || MyCView.Orientation.ViewScaleZ != float (Z);
- MyCView.Orientation.ViewScaleX = float (Sx);
- MyCView.Orientation.ViewScaleY = float (Sy);
- MyCView.Orientation.ViewScaleZ = float (Sz);
-
- CustomIsModified =
- MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
- MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
- if ( MyViewOrientation.IsCustomMatrix() ) {
- Standard_Integer i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++) {
- if (!CustomIsModified) CustomIsModified =
- MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
- MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
- }
- }
-
-#ifdef TRACE_TRSF
-cout << "Visual3d_View::ViewOrientationReset\n";
-if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
-cout << "VUPIsModified : " << VUPIsModified
- << ", VRPIsModified : " << VRPIsModified
- << ", VRUIsModified : " << VRUIsModified
- << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
-else
-cout << "no modification\n" << flush;
-#endif
-
- // Mise en route que si l'un des parametres est modifie
- if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
-
- if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
- MyMatOfOriIsModified = Standard_True;
- MyMatOfOriIsEvaluated = Standard_False;
- }
-
- if (! IsDefined ()) return;
-
-Standard_Boolean AWait = Standard_False; // => mise a jour immediate
- MyGraphicDriver->ViewOrientation (MyCView, AWait);
-
- Compute ();
-
- if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
- }
-
+// =======================================================================
+// function : DefaultCamera
+// purpose :
+// =======================================================================
+const Handle(Graphic3d_Camera)& Visual3d_View::DefaultCamera() const
+{
+ return myDefaultCamera;
}
-void Visual3d_View::SetViewMapping (const Visual3d_ViewMapping& VM) {
-
- if (IsDeleted ()) return;
-
-Visual3d_TypeOfProjection OldType = MyViewMapping.Projection ();
-Visual3d_TypeOfProjection NewType = VM.Projection ();
-
- MyViewMapping = VM;
-
-Standard_Real X, Y, Z;
-Standard_Real um, vm, uM, vM;
-
- MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
- (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
- MyCView.Mapping.ProjectionReferencePoint.x = float (X);
- MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
- MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
- MyCView.Mapping.ViewPlaneDistance =
- float (MyViewMapping.ViewPlaneDistance ());
- MyCView.Mapping.BackPlaneDistance =
- float (MyViewMapping.BackPlaneDistance ());
- MyCView.Mapping.FrontPlaneDistance =
- float (MyViewMapping.FrontPlaneDistance ());
- MyViewMapping.WindowLimit (um, vm, uM, vM);
- MyCView.Mapping.WindowLimit.um = float (um);
- MyCView.Mapping.WindowLimit.vm = float (vm);
- MyCView.Mapping.WindowLimit.uM = float (uM);
- MyCView.Mapping.WindowLimit.vM = float (vM);
-
- MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
- if (MyViewMapping.IsCustomMatrix()) {
- Standard_Integer i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
- MyCView.Mapping.ProjectionMatrix[i][j] =
- MyViewMapping.MyProjectionMatrix->Value(i,j);
- }
-
- MyMatOfMapIsModified = Standard_True;
- MyMatOfMapIsEvaluated = Standard_False;
-
- if (! IsDefined ()) return;
+// =======================================================================
+// function : Camera
+// purpose :
+// =======================================================================
+const Handle(Graphic3d_Camera)& Visual3d_View::Camera() const{ return MyCView.Context.Camera;}
-Standard_Boolean AWait = Standard_False; // => mise a jour immediate
- MyGraphicDriver->ViewMapping (MyCView, AWait);
-
- // Passage Parallele/Perspective
- if (OldType != NewType)
- Compute ();
+// =======================================================================
+// function : SetCamera
+// purpose :
+// =======================================================================
+void Visual3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
+{
+ MyCView.Context.Camera = theCamera;
- if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
+ MyGraphicDriver->SetCamera (MyCView);
+ if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
+ {
+ Update();
+ }
}
-Visual3d_ViewMapping Visual3d_View::ViewMapping () const {
-
- return (MyViewMapping);
+// =======================================================================
+// function : SetViewOrientationDefault
+// purpose :
+// =======================================================================
+void Visual3d_View::SetViewOrientationDefault ()
+{
+ if (myDefaultCamera.IsNull())
+ {
+ myDefaultCamera = new Graphic3d_Camera();
+ }
+ myDefaultCamera->CopyOrientationData (MyCView.Context.Camera);
}
-Visual3d_ViewMapping Visual3d_View::ViewMappingDefault () const {
+// =======================================================================
+// function : ViewOrientationReset
+// purpose :
+// =======================================================================
+void Visual3d_View::ViewOrientationReset ()
+{
+ if (IsDeleted())
+ {
+ return;
+ }
- return (MyViewMappingReset);
+ if (!myDefaultCamera.IsNull())
+ {
+ MyCView.Context.Camera->CopyOrientationData (myDefaultCamera);
+ }
+ if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
+ {
+ Update();
+ }
}
-void Visual3d_View::SetViewMappingDefault () {
-
- MyViewMappingReset.Assign (MyViewMapping);
-
+// =======================================================================
+// function : SetViewMappingDefault
+// purpose :
+// =======================================================================
+void Visual3d_View::SetViewMappingDefault()
+{
+ if (myDefaultCamera.IsNull())
+ {
+ myDefaultCamera = new Graphic3d_Camera();
+ }
+ myDefaultCamera->CopyMappingData (MyCView.Context.Camera);
}
-void Visual3d_View::ViewMappingReset () {
-
- if (IsDeleted ()) return;
-
- MyViewMapping = MyViewMappingReset;
-
-Standard_Real X, Y, Z;
-Standard_Real um, vm, uM, vM;
-
- MyCView.Mapping.Projection = int (MyViewMapping.Projection ());
- (MyViewMapping.ProjectionReferencePoint ()).Coord (X, Y, Z);
- MyCView.Mapping.ProjectionReferencePoint.x = float (X);
- MyCView.Mapping.ProjectionReferencePoint.y = float (Y);
- MyCView.Mapping.ProjectionReferencePoint.z = float (Z);
- MyCView.Mapping.ViewPlaneDistance =
- float (MyViewMapping.ViewPlaneDistance ());
- MyCView.Mapping.BackPlaneDistance =
- float (MyViewMapping.BackPlaneDistance ());
- MyCView.Mapping.FrontPlaneDistance =
- float (MyViewMapping.FrontPlaneDistance ());
- MyViewMapping.WindowLimit (um, vm, uM, vM);
- MyCView.Mapping.WindowLimit.um = float (um);
- MyCView.Mapping.WindowLimit.vm = float (vm);
- MyCView.Mapping.WindowLimit.uM = float (uM);
- MyCView.Mapping.WindowLimit.vM = float (vM);
-
- MyCView.Mapping.IsCustomMatrix = MyViewMapping.IsCustomMatrix();
- if (MyViewMapping.IsCustomMatrix()) {
- Standard_Integer i, j;
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
- MyCView.Mapping.ProjectionMatrix[i][j] =
- MyViewMapping.MyProjectionMatrix->Value(i,j);
- }
-
- MyMatOfMapIsModified = Standard_True;
- MyMatOfMapIsEvaluated = Standard_False;
-
- if (! IsDefined ()) return;
-
-Standard_Boolean AWait = Standard_False; // => mise a jour immediate
- MyGraphicDriver->ViewMapping (MyCView, AWait);
+// =======================================================================
+// function : ViewMappingReset
+// purpose :
+// =======================================================================
+void Visual3d_View::ViewMappingReset ()
+{
+ if (IsDeleted ())
+ {
+ return;
+ }
- if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
+ if (!myDefaultCamera.IsNull())
+ {
+ MyCView.Context.Camera->CopyMappingData (myDefaultCamera);
+ }
+ if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
+ {
+ Update();
+ }
}
void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
Visual3d_TypeOfVisualization OldVisualMode;
Visual3d_TypeOfVisualization NewVisualMode;
- // Pour gerer l'affichage uniquement en cas de
- // changement de mode de visualisation.
+ // To manage display only in case of
+ // change of visualisation mode.
OldVisualMode = MyContext.Visualization ();
NewVisualMode = CTX.Visualization ();
Visual3d_TypeOfModel OldModel;
Visual3d_TypeOfModel NewModel;
- // Pour gerer le changement de visualisation uniquement
- // en cas de changement de mode de visualisation ou de
- // type de shading.
+ // To manage change of visualisation only in case
+ // of change of mode of visualisation or of type of shading.
OldModel = MyContext.Model ();
NewModel = CTX.Model ();
Standard_Boolean OldAliasingMode;
Standard_Boolean NewAliasingMode;
- // Pour gerer l'antialiasing uniquement en cas de changement.
+ // To manage antialiasing only in case of change.
OldAliasingMode = MyContext.AliasingIsOn ();
NewAliasingMode = CTX.AliasingIsOn ();
Standard_Real OldDepthCueingBackPlane;
Standard_Real NewDepthCueingBackPlane;
- // Pour gerer le depth cueing uniquement en cas de changement.
+ // To manage the depth cueing only in case of change.
OldDepthCueingMode = MyContext.DepthCueingIsOn ();
NewDepthCueingMode = CTX.DepthCueingIsOn ();
Standard_Real OldZClippingBackPlane;
Standard_Real NewZClippingBackPlane;
- // Pour gerer le Zclipping uniquement en cas de changement.
+ // To manage the Zclipping only in case of change.
OldFrontZClippingMode = MyContext.FrontZClippingIsOn ();
NewFrontZClippingMode = CTX.FrontZClippingIsOn ();
OldBackZClippingMode = MyContext.BackZClippingIsOn ();
OldZClippingBackPlane = MyContext.ZClippingBackPlane ();
NewZClippingBackPlane = CTX.ZClippingBackPlane ();
-Standard_Integer OldTexEnvId;
-Standard_Integer NewTexEnvId;
-Visual3d_TypeOfSurfaceDetail OldSurfaceDetail;
-Visual3d_TypeOfSurfaceDetail NewSurfaceDetail;
-
- Handle(Graphic3d_TextureEnv) TempTextureEnv1 = MyContext.TextureEnv();
- if (! TempTextureEnv1.IsNull()) OldTexEnvId = TempTextureEnv1->TextureId();
- else OldTexEnvId = -1;
-
- Handle(Graphic3d_TextureEnv) TempTextureEnv2 = CTX.TextureEnv();
-
- if (! TempTextureEnv2.IsNull()) NewTexEnvId = TempTextureEnv2->TextureId();
- else NewTexEnvId = -1;
+ Handle(Graphic3d_TextureEnv) aTexEnvOld = MyContext.TextureEnv();
+ Handle(Graphic3d_TextureEnv) aTexEnvNew = CTX.TextureEnv();
- OldSurfaceDetail = MyContext.SurfaceDetail();
- NewSurfaceDetail = CTX.SurfaceDetail();
+ Visual3d_TypeOfSurfaceDetail OldSurfaceDetail = MyContext.SurfaceDetail();
+ Visual3d_TypeOfSurfaceDetail NewSurfaceDetail = CTX.SurfaceDetail();
MyContext = CTX;
UpdateView ();
-Standard_Boolean AWait = Standard_False; // => mise a jour immediate
+Standard_Boolean AWait = Standard_False; // => immediate update
if (IsDefined ()) {
- // gestion des modes de visualisation et des types de shading.
+ // management of visualization modes and types of shading.
if ((OldVisualMode != NewVisualMode) || (OldModel != NewModel))
MyGraphicDriver->SetVisualisation (MyCView);
- // gestion de l'antialiasing.
+ // management of antialiasing.
if (OldAliasingMode != NewAliasingMode)
MyGraphicDriver->AntiAliasing (MyCView, NewAliasingMode);
- // gestion du depth_cueing.
+ // management of depth_cueing.
if ((OldDepthCueingMode != NewDepthCueingMode) ||
(OldDepthCueingFrontPlane != NewDepthCueingFrontPlane) ||
(OldDepthCueingBackPlane != NewDepthCueingBackPlane)) {
(MyCView, NewDepthCueingMode);
}
- // gestion du Zclipping
+ // management of Zclipping
if ((OldFrontZClippingMode != NewFrontZClippingMode) ||
(OldBackZClippingMode != NewBackZClippingMode) ||
(OldZClippingFrontPlane != NewZClippingFrontPlane) ||
MyGraphicDriver->ClipLimit (MyCView, AWait);
}
- // gestion des textures
- if ( (OldTexEnvId != NewTexEnvId) ||
- (OldSurfaceDetail != NewSurfaceDetail) )
+ // management of textures
+ if ((aTexEnvOld != aTexEnvNew) || (OldSurfaceDetail != NewSurfaceDetail))
+ {
MyGraphicDriver->Environment(MyCView);
+ }
- // Mise a jour des plans de model clipping
+ // Update of planes of model clipping
UpdatePlanes ();
- // Mise a jour des sources lumineuses
+ // Update of light sources
UpdateLights ();
}
if (OldVisualMode != NewVisualMode) {
/*
- * Changement de contexte =>
- * Erase des structures qui ne peuvent pas etre affichees
- * avec le nouveau mode de visualisation.
- * On ne doit pas prevenir le ViewManager car
- * cette structure ne doit pas disparaitre de la
- * liste des structures affichees chez celui-ci.
+ * Change of context =>
+ * Remove structures that cannot be displayed
+ * in the new visualisation mode.
+ * It is not necessary to warn ViewManager as
+ * this structure should not disappear from
+ * the list of structures displayed in it.
*/
Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
Visual3d_TypeOfAnswer Answer;
while (S1Iterator.More ()) {
Answer = AcceptDisplay (S1Iterator.Key ());
- // Si la structure n'est plus affichable dans le
- // nouveau contexte de la vue, on l'efface.
+ // If the structure can't be displayed in the
+ // new context of the view, it is removed.
if ((Answer == Visual3d_TOA_NO) ||
(Answer == Visual3d_TOA_COMPUTE))
//Erase (S1Iterator.Key (), Aspect_TOU_WAIT);
FooSequence.Append (S1Iterator.Key ());
- // S1Iterator.Next () se positionne sur la
- // prochaine structure
+ // S1Iterator.Next () is located on the next structure
S1Iterator.Next ();
}
Standard_Integer Length = FooSequence.Length ();
- // On efface les structures stockees
+ // The stored structures are removed
for (i=1; i<=Length; i++)
Erase (FooSequence.Value (i), Aspect_TOU_WAIT);
if (Length != 0) FooSequence.Clear ();
/*
- * Changement de contexte =>
- * Display des structures qui peuvent etre affichees
- * avec le nouveau mode de visualisation.
- * On recupere toutes les structures ayant le statut
- * Displayed dans le ViewManager et on l'affiche dans
- * la vue directement, si la structure n'est pas deja
- * affichee et si la vue l'accepte dans son contexte.
+ * Change of context =>
+ * Display structures that can be displayed
+ * with the new visualisation mode.
+ * All structures with status Displayed are removed from the ViewManager
+ * and displayed in the view directly, if the structure is not already
+ * displayed and if the view accepts it in its context.
*/
i = MyViewManager->NumberOfDisplayedStructures ();
Handle(Graphic3d_Structure) SG = it.Key();
if (! IsDisplayed (SG)) {
Answer = AcceptDisplay(SG);
- // Si la structure est affichable dans le
- // nouveau contexte de la vue, on l'affiche.
+ // If the structure can be displayed in the
+ // new context of the view, it is displayed.
if ((Answer == Visual3d_TOA_YES) ||
(Answer == Visual3d_TOA_COMPUTE))
//Display (MyViewManager->DisplayedStructure (j),
}
Length = FooSequence.Length ();
- // On affiche les structures stockees
+ // The stored structures are displayed
for (i=1; i<=Length; i++)
Display (FooSequence.Value (i), Aspect_TOU_WAIT);
if (Length != 0) FooSequence.Clear ();
while (Iterator.More ()) {
SG.Add (Iterator.Key ());
- // Iterator.Next () se positionne sur la
- // prochaine structure
+ // Iterator.Next () is located on the next structure
Iterator.Next ();
}
MyCView.Active = 1;
/*
- * Activation d'une nouvelle vue =>
- * Display des structures qui peuvent etre affichees
- * dans cette nouvelle vue.
- * On recupere toutes les structures ayant le statut
- * Displayed dans le ViewManager et on l'affiche dans
- * la vue directement, si la structure n'est pas deja
- * affichee et si la vue l'accepte dans son contexte.
+ * Activation of a new view =>
+ * Display structures that can be displayed in this new view.
+ * All structures with status
+ * Displayed in ViewManager are returned and displayed in
+ * the view directly, if the structure is not already
+ * displayed and if the view accepts it in its context.
*/
Visual3d_TypeOfAnswer Answer;
Handle(Graphic3d_Structure) SG = it.Key();
if (! IsDisplayed (SG)) {
Answer = AcceptDisplay(SG);
- // Si la structure est affichable dans le
- // nouveau contexte de la vue, on l'affiche.
+ // If the structure can be displayed in the
+ // new context of the view, it is displayed.
if ((Answer == Visual3d_TOA_YES) ||
(Answer == Visual3d_TOA_COMPUTE))
Display (SG,Aspect_TOU_WAIT);
}
- // Si l'activation/desactivation du ZBuffer doit etre automatique
- // en fonction de la presence de facettes ou pas
+ // If the activation/desactivation of ZBuffer should be automatic
+ // depending on the presence or absence of facets.
if (MyViewManager->ZBufferAuto ()) {
Standard_Boolean BContainsFacet = ContainsFacet ();
Standard_Boolean BZBuffer = ZBufferIsActivated ();
- // Si la vue contient des facettes
- // et si le ZBuffer n'est pas actif
+ // If the view contains facets
+ // and if ZBuffer is not active
if (BContainsFacet && ! BZBuffer)
SetZBufferActivity (1);
- // Si la vue ne contient pas des facettes
- // et si le ZBuffer est actif
+ // If the view does not contain facets
+ // and if ZBuffer is active
if (! BContainsFacet && BZBuffer)
SetZBufferActivity (0);
}
MyGraphicDriver->DeactivateView (MyCView);
/*
- * Deactivation d'une vue =>
- * Effacement des structures qui sont affichees
- * dans cette vue.
- * On recupere toute structure ayant le statut
- * Displayed dans le ViewManager et on l'efface dans
- * la vue directement, si la structure n'est pas deja
- * effacee et si la vue l'accepte dans son contexte.
- */
+ * Deactivation of a view =>
+ * Removal of structures displayed in this view.
+ * All structures with status
+ * Displayed in ViewManager are returned and removed from
+ * the view directly, if the structure is not already
+ * displayed and if the view accepts it in its context.
+ */
Visual3d_TypeOfAnswer Answer;
Graphic3d_MapOfStructure Map;
Handle(Graphic3d_Structure) SG = it.Key();
if (! IsDisplayed (SG)) {
Answer = AcceptDisplay(SG);
- // Si la structure etait affichable, on l'efface.
+ // If the structure was displayed it is removed.
if ((Answer == Visual3d_TOA_YES) ||
(Answer == Visual3d_TOA_COMPUTE))
Erase (SG,Aspect_TOU_WAIT);
if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
- // Plus d'action possible sur la vue maintenant
+ // No action currently possible in the view
MyCView.Active = 0;
}
}
-void Visual3d_View::Redraw () {
-
- Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
-
+void Visual3d_View::Redraw()
+{
+ Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(), 0, 0, 0, 0);
}
-void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
-
- Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height);
+void Visual3d_View::Redraw (const Standard_Integer theX,
+ const Standard_Integer theY,
+ const Standard_Integer theWidth,
+ const Standard_Integer theHeight)
+{
+ Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(),
+ theX, theY, theWidth, theHeight);
}
-void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
-
- if (IsDeleted ()) return;
-
- if ((! IsDefined ()) || (! IsActive ())) return;
-
- if (! MyWindow->IsMapped ()) return;
-
- // san - 14/04/2004 - set up Z buffer state before redrawing
- // Si l'activation/desactivation du ZBuffer doit etre automatique
- // en fonction de la presence de facettes ou pas
- if (MyViewManager->ZBufferAuto ()) {
- Standard_Boolean BContainsFacet = ContainsFacet ();
- Standard_Boolean BZBuffer = ZBufferIsActivated ();
- // Si la vue contient des facettes
- // et si le ZBuffer n'est pas actif
- if (BContainsFacet && ! BZBuffer)
- SetZBufferActivity (1);
- // Si la vue ne contient pas des facettes
- // et si le ZBuffer est actif
- if (! BContainsFacet && BZBuffer)
- SetZBufferActivity (0);
- }
-
- Aspect_CLayer2d OverCLayer;
- Aspect_CLayer2d UnderCLayer;
- OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
- if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
- if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
- MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer);
-
+void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
+ const Handle(Visual3d_Layer)& theOverLayer)
+{
+ Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0);
}
-void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer, const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
-
- if (IsDeleted ()) return;
-
- if ((! IsDefined ()) || (! IsActive ())) return;
+void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
+ const Handle(Visual3d_Layer)& theOverLayer,
+ const Standard_Integer theX,
+ const Standard_Integer theY,
+ const Standard_Integer theWidth,
+ const Standard_Integer theHeight)
+{
+ if (IsDeleted()
+ || !IsDefined()
+ || !IsActive()
+ || !MyWindow->IsMapped())
+ {
+ return;
+ }
- if (! MyWindow->IsMapped ()) return;
+ Aspect_CLayer2d anOverCLayer, anUnderCLayer;
+ anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
+ if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer();
+ if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
- // san - 14/04/2004 - set up Z buffer state before redrawing
- // Si l'activation/desactivation du ZBuffer doit etre automatique
- // en fonction de la presence de facettes ou pas
- if (MyViewManager->ZBufferAuto ()) {
- Standard_Boolean BContainsFacet = ContainsFacet ();
- Standard_Boolean BZBuffer = ZBufferIsActivated ();
- // Si la vue contient des facettes
- // et si le ZBuffer n'est pas actif
- if (BContainsFacet && ! BZBuffer)
- SetZBufferActivity (1);
- // Si la vue ne contient pas des facettes
- // et si le ZBuffer est actif
- if (! BContainsFacet && BZBuffer)
- SetZBufferActivity (0);
- }
+ for (Standard_Integer aRetryIter = 0; aRetryIter < 2; ++aRetryIter)
+ {
+ if (MyGraphicDriver->IsDeviceLost())
+ {
+ MyViewManager->RecomputeStructures();
+ MyViewManager->RecomputeStructures (myImmediateStructures);
+ MyGraphicDriver->ResetDeviceLostFlag();
+ }
- Aspect_CLayer2d OverCLayer;
- Aspect_CLayer2d UnderCLayer;
- OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
- if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
- if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
- MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer, x, y, width, height);
+ // set up Z buffer state before redrawing
+ if (MyViewManager->ZBufferAuto())
+ {
+ const Standard_Boolean hasFacet = ContainsFacet();
+ const Standard_Boolean hasZBuffer = ZBufferIsActivated();
+ // if the view contains facets and if ZBuffer is not active
+ if (hasFacet && !hasZBuffer)
+ {
+ SetZBufferActivity (1);
+ }
+ // if the view contains only facets and if ZBuffer is active
+ if (!hasFacet && hasZBuffer)
+ {
+ SetZBufferActivity (0);
+ }
+ }
+ MyGraphicDriver->Redraw (MyCView, anUnderCLayer, anOverCLayer, theX, theY, theWidth, theHeight);
+ if (!MyGraphicDriver->IsDeviceLost())
+ {
+ return;
+ }
+ }
}
-void Visual3d_View::Update () {
-
- Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
-
+void Visual3d_View::RedrawImmediate()
+{
+ RedrawImmediate (MyViewManager->UnderLayer(), MyViewManager->OverLayer());
}
-void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
-
- if (IsDeleted ()) return;
+void Visual3d_View::RedrawImmediate (const Handle(Visual3d_Layer)& theUnderLayer,
+ const Handle(Visual3d_Layer)& theOverLayer)
+{
+ if (IsDeleted()
+ || !IsDefined()
+ || !IsActive()
+ || !MyWindow->IsMapped())
+ {
+ return;
+ }
- if ((! IsDefined ()) || (! IsActive ())) return;
+ Aspect_CLayer2d anOverCLayer, anUnderCLayer;
+ anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
+ if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer();
+ if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
+ MyGraphicDriver->RedrawImmediate (MyCView, anUnderCLayer, anOverCLayer);
+}
- if (! MyWindow->IsMapped ()) return;
+void Visual3d_View::Invalidate()
+{
+ MyGraphicDriver->Invalidate (MyCView);
+}
- // Si l'activation/desactivation du ZBuffer doit etre automatique
- // en fonction de la presence de facettes ou pas
- if (MyViewManager->ZBufferAuto ()) {
-Standard_Boolean BContainsFacet = ContainsFacet ();
-Standard_Boolean BZBuffer = ZBufferIsActivated ();
- // Si la vue contient des facettes
- // et si le ZBuffer n'est pas actif
- if (BContainsFacet && ! BZBuffer)
- SetZBufferActivity (1);
- // Si la vue ne contient pas des facettes
- // et si le ZBuffer est actif
- if (! BContainsFacet && BZBuffer)
- SetZBufferActivity (0);
- }
+void Visual3d_View::Update()
+{
+ IsInitialized = Standard_True;
+ Compute ();
-Aspect_CLayer2d OverCLayer;
-Aspect_CLayer2d UnderCLayer;
- OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
- if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
- if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
- //OSD::SetSignal (Standard_False);
- MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer);
- //OSD::SetSignal (Standard_True);
+ Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(), 0, 0, 0, 0);
+}
- MyMatOfMapIsModified = Standard_False;
- MyMatOfOriIsModified = Standard_False;
+void Visual3d_View::Update (const Handle(Visual3d_Layer)& theUnderLayer,
+ const Handle(Visual3d_Layer)& theOverLayer)
+{
+ IsInitialized = Standard_True;
+ Compute ();
+ Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0);
}
Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const {
-// Recuperation type de visualisation de la vue
+// Return type of visualization of the view
Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
-// Recuperation type de visualisation de la structure
+// Return type of visualization of the structure
Graphic3d_TypeOfStructure StructType = AStructure->Visual ();
Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO;
if (StructType == Graphic3d_TOS_ALL)
- // La structure accepte tout type de vue
+ // The structure accepts any type of view
Result = Visual3d_TOA_YES;
else {
if ((StructType == Graphic3d_TOS_SHADING)
}
-void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority) {
+void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer /*OldPriority*/, const Standard_Integer NewPriority) {
if (IsDeleted ()) return;
if (! IsDefined ()) return;
if (! IsDisplayed (AStructure)) return;
Standard_Integer Index = IsComputed (AStructure);
-#ifdef G003
- if ( Index != 0 && ComputedMode () && !DegenerateModeIsOn () )
-#else
- if ((Index != 0) && (! DegenerateModeIsOn ()))
-#endif // G003
+ if (Index != 0 && ComputedMode())
{
#ifdef TRACE
Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification ();
<< ", " << OldPriority << ", " << NewPriority << ")\n";
cout << flush;
#endif
- MyGraphicDriver->EraseStructure
- (MyCView,
- *(Graphic3d_CStructure *)
- MyCOMPUTEDSequence.Value (Index)->CStructure ());
- MyGraphicDriver->DisplayStructure
- (MyCView,
- *(Graphic3d_CStructure *)
- MyCOMPUTEDSequence.Value (Index)->CStructure (),
- int (NewPriority));
+ MyGraphicDriver->ChangePriority (*(MyCOMPUTEDSequence.Value (Index)->CStructure()), MyCView, NewPriority);
}
- else {
+ else
+ {
#ifdef TRACE
Standard_Integer StructId = AStructure->Identification ();
cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
<< ", " << OldPriority << ", " << NewPriority << ")\n";
cout << flush;
#endif
- MyGraphicDriver->EraseStructure
- (MyCView,
- *(Graphic3d_CStructure *)AStructure->CStructure ());
- MyGraphicDriver->DisplayStructure
- (MyCView,
- *(Graphic3d_CStructure *)AStructure->CStructure (),
- int (NewPriority));
+ MyGraphicDriver->ChangePriority (*(AStructure->CStructure()), MyCView, NewPriority);
}
}
Standard_Integer Index = IsComputed (AStructure);
if (Index != 0) {
#ifdef TRACE_CLEAR
- cout << "La structure " << AStructure->Identification ()
- << " calculee, dans la view "
- << Identification () << ", par la structure "
+ cout << "Structure " << AStructure->Identification ()
+ << " calculated in the view "
+ << Identification () << ", by structure "
<< MyCOMPUTEDSequence.Value (Index)->Identification ()
- << " est videe.\n";
+ << " is emptied.\n";
cout << flush;
#endif
MyCOMPUTEDSequence.Value (Index)->GraphicClear (WithDestruction);
if (IndexM != 0 && IndexD != 0) {
#ifdef TRACE_CONNECT
- cout << "La structure " << AMother->Identification ()
- << " est connectee a la structure "
+ cout << "Structure " << AMother->Identification ()
+ << " is connected to structure "
<< ADaughter->Identification () << endl;
- cout << "Ces structures sont calculees.\n";
- cout << "Dans la view " << Identification ()
- << "La structure "
+ cout << "These structures are calculated.\n";
+ cout << "In the view " << Identification ()
+ << "Structure "
<< MyCOMPUTEDSequence.Value (IndexM)->Identification ()
- << " est connectee a la structure "
+ << " is connected to the structure "
<< MyCOMPUTEDSequence.Value (IndexD)->Identification ()
<< endl;
#endif
if (IndexM != 0 && IndexD != 0) {
#ifdef TRACE_CONNECT
- cout << "La structure " << AMother->Identification ()
- << " est disconnectee de la structure "
+ cout << "Structure " << AMother->Identification ()
+ << " is disconnected from the structure "
<< ADaughter->Identification () << endl;
- cout << "Ces structures sont calculees.\n";
- cout << "Dans la view " << Identification ()
- << "La structure "
+ cout << "These structures are calculated.\n";
+ cout << "In the view " << Identification ()
+ << "Structure "
<< MyCOMPUTEDSequence.Value (IndexM)->Identification ()
- << " est disconnectee de la structure "
+ << " is disconnected from the structure "
<< MyCOMPUTEDSequence.Value (IndexD)->Identification ()
<< endl;
#endif
}
+Standard_Boolean Visual3d_View::DisplayImmediate (const Handle(Graphic3d_Structure)& theStructure,
+ const Standard_Boolean theIsSingleView)
+{
+ if (!myImmediateStructures.Add (theStructure))
+ {
+ return Standard_False;
+ }
+
+ if (theIsSingleView)
+ {
+ Handle(Visual3d_HSequenceOfView) aViews = MyViewManager->DefinedView();
+
+ for (int i=1;i<=aViews->Length();i++)
+ {
+ if (aViews->Value(i).Access() != this)
+ {
+ aViews->Value(i)->EraseImmediate (theStructure);
+ }
+ }
+ }
+
+ MyGraphicDriver->DisplayImmediateStructure (MyCView, *theStructure->CStructure());
+ return Standard_True;
+}
+
+Standard_Boolean Visual3d_View::EraseImmediate (const Handle(Graphic3d_Structure)& theStructure)
+{
+ const Standard_Boolean isErased = myImmediateStructures.Remove (theStructure);
+ if (isErased)
+ {
+ MyGraphicDriver->EraseImmediateStructure (MyCView, *theStructure->CStructure());
+ }
+
+ return isErased;
+}
+
+Standard_Boolean Visual3d_View::ClearImmediate()
+{
+ if (myImmediateStructures.IsEmpty())
+ {
+ return Standard_False;
+ }
+
+ for (Graphic3d_MapIteratorOfMapOfStructure anIter (myImmediateStructures); anIter.More(); anIter.Next())
+ {
+ MyGraphicDriver->EraseImmediateStructure (MyCView, *anIter.Key()->CStructure());
+ }
+ myImmediateStructures.Clear();
+ return Standard_True;
+}
+
void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) {
Display (AStructure, MyViewManager->UpdateMode ());
if (! IsDefined ()) return;
if (! IsActive ()) return;
- // Si Display sur une structure qui est dans la liste
- // des structures calculees alors qu'elle n'est pas
- // ou plus, du type calcule =>
- // On l'enleve ainsi que l'ancienne compute associee
- // Ceci arrive lorsque la hlhsr redevient du type
- // non computed apres un SetVisual.
+ // If Display on a structure present in the list
+ // of calculated structures while it is not
+ // or more, of calculated type =>
+ // - removes it as well as the associated old computed
+ // THis happens when hlhsr becomes again of type e
+ // non computed after SetVisual.
Standard_Integer Index = IsComputed (AStructure);
if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) {
-
-#ifdef TRACE_LENGTH
- if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
- cout << "In Visual3d_View::Display, ";
- cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
- << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
- << "\n" << flush;
- }
-#endif
MyTOCOMPUTESequence.Remove (Index);
MyCOMPUTEDSequence.Remove (Index);
-
-#ifdef TRACE_LENGTH
- if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
- cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
- << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
- << "\n" << flush;
-#endif
Index = 0;
}
Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
-#ifdef TRACE_DISPLAY
- Standard_Integer StructId = AStructure->Identification ();
- cout << "Visual3d_View" << MyCView.ViewId << "::Display ("
- << StructId << ");\n";
- cout << flush;
-#endif
-
if (Answer == Visual3d_TOA_NO) {
-#ifdef TRACE_DISPLAY
- cout << "Answer : Visual3d_TOA_NO\n";
- cout << flush;
-#endif
return;
}
- // Mode degenere actif
-#ifdef G003
- if ( !ComputedMode () || DegenerateModeIsOn () )
- Answer = Visual3d_TOA_YES;
-#else
- if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
-;
-#endif // G003
+ if (!ComputedMode())
+ {
+ Answer = Visual3d_TOA_YES;
+ }
if (Answer == Visual3d_TOA_YES ) {
-#ifdef TRACE_DISPLAY
- cout << "Answer : Visual3d_TOA_YES\n";
- cout << flush;
-#endif
if (IsDisplayed (AStructure)) return;
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)AStructure->CStructure (),
- int (AStructure->DisplayPriority ())
- );
+ AStructure->CalculateBoundBox();
+ MyGraphicDriver->DisplayStructure (MyCView, *(AStructure->CStructure()), AStructure->DisplayPriority());
MyDisplayedStructure.Add (AStructure);
if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
}
if (Answer == Visual3d_TOA_COMPUTE) {
-#ifdef TRACE_DISPLAY
- cout << "Answer : Visual3d_TOA_COMPUTE\n";
- cout << "Index : " << Index << "\n" << flush;
-#endif
if (Index != 0) {
- // Deja calculee, mais la COMPUTED est-elle encore valide ?
-#ifdef TRACE_DISPLAY
- if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
- cout << "La structure "
- << MyTOCOMPUTESequence.Value (Index)->Identification ()
- << " deja calculee, dans la view "
- << Identification () << ", par la structure "
- << MyCOMPUTEDSequence.Value (Index)->Identification ()
- << "\n n'a pas a etre recalculee car HLR est valide\n";
- cout << flush;
- }
- else {
- cout << "La structure "
- << MyTOCOMPUTESequence.Value (Index)->Identification ()
- << " deja calculee, dans la view "
- << Identification () << ", par la structure "
- << MyCOMPUTEDSequence.Value (Index)->Identification ()
- << "\n doit etre recalculee car HLR est invalide\n";
- cout << flush;
- }
-#endif
+ // Already computed, is COMPUTED still valid?
Standard_Integer OldStructId =
MyCOMPUTEDSequence.Value (Index)->Identification ();
- // Cas COMPUTED valide
+ // Case COMPUTED valide
if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
- // a afficher
+ // to be displayed
if (! IsDisplayed (AStructure)) {
MyDisplayedStructure.Add (AStructure);
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
- int (AStructure->DisplayPriority ())
- );
+ MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), AStructure->DisplayPriority ());
if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
}
return;
}
- // Cas COMPUTED invalide
+ // Case COMPUTED invalid
else {
- // Existe-t-il une autre representation valide ?
- // Recherche dans la sequence des structures deja calculees
- // 1/ D'une structure ayant le meme Owner que <AStructure>
- // 2/ Qui ne soit pas <AStructure>
- // 3/ Dont la COMPUTED soit valide
+ // Is there another valid representation ?
+ // Find in the sequence of already calculated structures
+ // 1/ Structure having the same Owner as <AStructure>
+ // 2/ That is not <AStructure>
+ // 3/ The COMPUTED which of is valid
Standard_Integer NewIndex = HaveTheSameOwner (AStructure);
- // Cas COMPUTED invalide, AVEC une valide de remplacement
+ // Case of COMPUTED invalid, WITH a valid of replacement
if (NewIndex != 0) {
- // a afficher
+ // to be displayed
if (! IsDisplayed (AStructure)) {
MyCOMPUTEDSequence.SetValue
(Index, MyCOMPUTEDSequence.Value (NewIndex));
OldStructId = MyCOMPUTEDSequence.Value (NewIndex)->
Identification ();
MyDisplayedStructure.Add (AStructure);
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (NewIndex)->CStructure (),
- int (AStructure->DisplayPriority ())
- );
+ MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (NewIndex)->CStructure()), AStructure->DisplayPriority ());
if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
}
return;
}
- // Cas COMPUTED invalide, SANS une valide de remplacement
+ // Cas COMPUTED invalid, WITHOUT a valid of replacement
else {
- // On efface la COMPUTED si affichee
+ // COMPUTED is removed if displayed
if (IsDisplayed (AStructure))
- MyGraphicDriver->EraseStructure (
- MyCView,
- *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
}
}
} // if (Index != 0)
#endif
TheStructure->SetHLRValidation (Standard_True);
-#ifdef TRACE_LENGTH
- if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
- cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
- << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
- << "\n" << flush;
-#endif
-
- // On ajoute la TOCOMPUTE et la COMPUTED associee aux sequences
+ // TOCOMPUTE and COMPUTED associated to sequences are added
MyTOCOMPUTESequence.Append (AStructure);
MyCOMPUTEDSequence.Append (TheStructure);
-#ifdef TRACE_LENGTH
- if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
- cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
- << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
- << "\n" << flush;
-#endif
-
- // On enleve, si necessaire, les anciennes
+ // The previous are removed if necessary
if (Index != 0) {
MyTOCOMPUTESequence.Remove (Index);
MyCOMPUTEDSequence.Remove (Index);
}
-#ifdef TRACE_LENGTH
- if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
- cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
- << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
- << "\n" << flush;
-#endif
-
-// Recuperation type de visualisation de la vue
+// Return type of visualisation of the view
Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
-// De quel type sera la computed ?
+// Of which type will be the computed ?
Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
(AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
}
-#ifdef TRACE_DISPLAY
- cout << "La structure " << StructId
- << " dans la view " << Identification ()
- << " est calculee par la structure "
- << TheStructure->Identification ();
- if (Answer == Visual3d_TOA_YES)
- cout << " et affichee\n";
- else
- cout << " mais pas affichee\n";
- cout << flush;
-#endif
-
- // On ne l'affiche que si la structure calculee
- // est du bon type par rapport a celui de la vue.
+ // It is displayed only if the calculated structure
+ // has a proper type corresponding to the one of the view.
if (Answer != Visual3d_TOA_NO) {
if (! IsDisplayed (AStructure))
MyDisplayedStructure.Add (AStructure);
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)TheStructure->CStructure (),
- int (AStructure->DisplayPriority ())
- );
+ MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), AStructure->DisplayPriority ());
if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
}
} // Visual3d_TOA_COMPUTE
if (IsDeleted ()) return;
- // Pas de test sur window car la structure est affichee que
- // si la window existe, donc un seul test suffit.
+ // No test on window as the structure is displayed only if
+ // the window exists, so only one test is enough.
if (IsDisplayed (AStructure)) {
Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
- // Mode degenere actif
-#ifdef G003
- if ( !ComputedMode () || DegenerateModeIsOn () )
- Answer = Visual3d_TOA_YES;
-#else
- if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
-#endif // G003
+ if (!ComputedMode())
+ {
+ Answer = Visual3d_TOA_YES;
+ }
if (Answer != Visual3d_TOA_COMPUTE) {
- MyGraphicDriver->EraseStructure (
- MyCView,
- *(Graphic3d_CStructure *)AStructure->CStructure ()
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(AStructure->CStructure()));
}
if (Answer == Visual3d_TOA_COMPUTE) {
cout << "Index : " << Index << "\n";
cout << flush;
#endif
-#ifdef G003
- if ( Index != 0 && ComputedMode () &&
- !DegenerateModeIsOn () )
-#else
- if ((Index != 0) && (! DegenerateModeIsOn ()))
-#endif // G003
+
+ if (Index != 0 && ComputedMode())
{
StructId =
MyCOMPUTEDSequence.Value (Index)->Identification ();
#ifdef TRACE_COMP
cout << "Structure " << AStructure->Identification ()
- << " calculee, dans la view "
- << Identification () << ", par la structure "
- << StructId << " est effacee. \n";
+ << " calculated, in the view "
+ << Identification () << ", by the structure "
+ << StructId << " is removed. \n";
cout << flush;
#endif
- MyGraphicDriver->EraseStructure
- (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
+ MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
}
- // Le else est impossible
+ // else is impossible
}
MyDisplayedStructure.Remove (AStructure);
if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
Standard_Integer Index = IsComputed (AStructure);
if (Index != 0) {
#ifdef TRACE_HIGH
- cout << "La structure " << AStructure->Identification ()
- << " calculee, dans la view "
- << Identification () << ", par la structure "
+ cout << "Structure " << AStructure->Identification ()
+ << " calculated, in the view "
+ << Identification () << ", by the structure "
<< MyCOMPUTEDSequence.Value (Index)->Identification ()
- << " passe en mode highlight.\n";
+ << " passes in highlight mode.\n";
cout << flush;
#endif
(MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
Standard_Integer Index = IsComputed (AStructure);
if (Index != 0) {
#ifdef TRACE_TRSF
- cout << "La structure " << AStructure->Identification ()
- << " calculee, dans la view "
- << Identification () << ", par la structure "
+ cout << "The structure " << AStructure->Identification ()
+ << " calculated, in the view "
+ << Identification () << ", by the structure "
<< MyCOMPUTEDSequence.Value (Index)->Identification ()
- << " est transformee.\n";
+ << " is transformed.\n";
cout << flush;
#endif
- // Test un peu leger !
- // On ne transmet la trsf que si c'est :
- // une translation
- // un scale
+ // Test is somewhat light !
+ // trsf is transferred only if it is :
+ // a translation
+ // a scale
if (ATrsf (0, 1) != 0. || ATrsf (0, 2) != 0.
|| ATrsf (1, 0) != 0. || ATrsf (1, 2) != 0.
|| ATrsf (2, 0) != 0. || ATrsf (2, 1) != 0.)
MyCOMPUTEDSequence.Value (Index)->GraphicTransform (ATrsf);
}
+ Standard_Integer aLayerId = AStructure->GetZLayer();
+ if (!AStructure->IsMutable()
+ && !AStructure->CStructure()->IsForHighlight
+ && !AStructure->CStructure()->IsInfinite)
+ {
+ AStructure->CalculateBoundBox();
+ MyGraphicDriver->InvalidateBVHData (MyCView, aLayerId);
+ }
}
void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) {
Standard_Integer Index = IsComputed (AStructure);
if (Index != 0) {
#ifdef TRACE_HIGH
- cout << "La structure " << AStructure->Identification ()
- << " calculee, dans la view "
- << Identification () << ", par la structure "
+ cout << "Structure " << AStructure->Identification ()
+ << " calculated, in the view "
+ << Identification () << ", by the structure "
<< MyCOMPUTEDSequence.Value (Index)->Identification ()
- << " passe en mode unhighlight.\n";
+ << " passes in unhighlight mode.\n";
cout << flush;
#endif
MyCOMPUTEDSequence.Value (Index)->GraphicUnHighlight ();
if ((MyTOCOMPUTESequence.Value (i))->Identification ()
== StrId) Result = i;
#ifdef TRACE_ISCOMP
- cout << "\nDans la vue " << Identification () << " la structure ";
+ cout << "\n In the view " << Identification () << " the structure ";
if (Result != 0)
- cout << StrId << " est calculee par "
+ cout << StrId << " is calculated by "
<< MyCOMPUTEDSequence.Value (Result)->Identification ()
<< "\n" << flush;
else
- cout << StrId << " n'est pas calculee\n" << flush;
+ cout << StrId << " is not calculated\n" << flush;
#endif
#ifdef TRACE_LENGTH
Standard_Integer i = MyDisplayedStructure.Extent ();
- // On s'arrette a la premiere structure qui est du type TOS_COMPUTED
+ // Stop at the first structure of type TOS_COMPUTED
while (! Result && Iterator.More ()) {
Result =
(((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED);
- // Iterator.Next () se positionne sur la
- // prochaine structure
+ // Iterator.Next () is located on the
+ // next structure
Iterator.Next ();
}
Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
- // On s'arrette a la premiere structure qui contient une facette
+ // Stop at the first structure containing a facet
for ( Iterator.Initialize (ASet);
Iterator.More () && ! Result;
Iterator.Next ())
}
-void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
-
- MinMaxValues
- (MyDisplayedStructure, XMin, YMin, ZMin, XMax, YMax, ZMax);
-
-}
-
-void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
-
- if (ASet.IsEmpty ()) {
- XMin = RealFirst ();
- YMin = RealFirst ();
- ZMin = RealFirst ();
-
- XMax = RealLast ();
- YMax = RealLast ();
- ZMax = RealLast ();
+//=============================================================================
+//function : MinMaxValues
+//purpose :
+//=============================================================================
+void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
+ Standard_Real& theYMin,
+ Standard_Real& theZMin,
+ Standard_Real& theXMax,
+ Standard_Real& theYMax,
+ Standard_Real& theZMax,
+ const Standard_Boolean theToIgnoreInfiniteFlag) const
+{
+ MinMaxValues (MyDisplayedStructure,
+ theXMin, theYMin, theZMin,
+ theXMax, theYMax, theZMax,
+ theToIgnoreInfiniteFlag);
+}
+
+//=============================================================================
+//function : MinMaxValues
+//purpose :
+//=============================================================================
+void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
+ Standard_Real& theXMin,
+ Standard_Real& theYMin,
+ Standard_Real& theZMin,
+ Standard_Real& theXMax,
+ Standard_Real& theYMax,
+ Standard_Real& theZMax,
+ const Standard_Boolean theToIgnoreInfiniteFlag) const
+{
+ if (theSet.IsEmpty ())
+ {
+ theXMin = RealFirst();
+ theYMin = RealFirst();
+ theZMin = RealFirst();
+
+ theXMax = RealLast();
+ theYMax = RealLast();
+ theZMax = RealLast();
}
- else {
-
- Standard_Real Xm, Ym, Zm, XM, YM, ZM;
- Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
+ else
+ {
+ Standard_Real aXm, aYm, aZm, aXM, aYM, aZM;
+ Graphic3d_MapIteratorOfMapOfStructure anIterator (theSet);
- XMin = RealLast ();
- YMin = RealLast ();
- ZMin = RealLast ();
+ theXMin = RealLast();
+ theYMin = RealLast();
+ theZMin = RealLast();
- XMax = RealFirst ();
- YMax = RealFirst ();
- ZMax = RealFirst ();
+ theXMax = RealFirst ();
+ theYMax = RealFirst ();
+ theZMax = RealFirst ();
- for ( Iterator.Initialize (ASet);
- Iterator.More ();
- Iterator.Next ()) {
+ for (anIterator.Initialize (theSet); anIterator.More(); anIterator.Next())
+ {
+ const Handle(Graphic3d_Structure)& aStructure = anIterator.Key();
- if ( (Iterator.Key ())->IsInfinite ()){
+ if (aStructure->IsInfinite() && !theToIgnoreInfiniteFlag)
+ {
//XMin, YMin .... ZMax are initialized by means of infinite line data
- (Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
- if ( Xm != RealFirst() && Xm < XMin )
- XMin = Xm ;
- if ( Ym != RealFirst() && Ym < YMin )
- YMin = Ym ;
- if ( Zm != RealFirst() && Zm < ZMin )
- ZMin = Zm ;
- if ( XM != RealLast() && XM > XMax )
- XMax = XM ;
- if ( YM != RealLast() && YM > YMax )
- YMax = YM ;
- if ( ZM != RealLast() && ZM > ZMax )
- ZMax = ZM ;
+ aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, Standard_False);
+ if (aXm != RealFirst() && aXm < theXMin)
+ {
+ theXMin = aXm;
+ }
+ if (aYm != RealFirst() && aYm < theYMin)
+ {
+ theYMin = aYm;
+ }
+ if (aZm != RealFirst() && aZm < theZMin)
+ {
+ theZMin = aZm;
+ }
+ if (aXM != RealLast() && aXM > theXMax)
+ {
+ theXMax = aXM;
+ }
+ if (aYM != RealLast() && aYM > theYMax)
+ {
+ theYMax = aYM;
+ }
+ if (aZM != RealLast() && aZM > theZMax)
+ {
+ theZMax = aZM;
+ }
}
- // Seules les structures non vides et non infinies
- // sont prises en compte pour le calcul des MinMax
- if (! (Iterator.Key ())->IsInfinite () &&
- ! (Iterator.Key ())->IsEmpty ()) {
- (Iterator.Key ())->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM);
- /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
- //"FitAll" operation ignores object with transform persitence parameter
- if( (Iterator.Key ())->TransformPersistenceMode() == Graphic3d_TMF_None )
- {
- if (Xm < XMin) XMin = Xm;
- if (Ym < YMin) YMin = Ym;
- if (Zm < ZMin) ZMin = Zm;
- if (XM > XMax) XMax = XM;
- if (YM > YMax) YMax = YM;
- if (ZM > ZMax) ZMax = ZM;
- }
+
+ // Only non-empty and non-infinite structures
+ // are taken into account for calculation of MinMax
+ if ((!aStructure->IsInfinite() || theToIgnoreInfiniteFlag) && !aStructure->IsEmpty())
+ {
+ aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag);
+
+ /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
+ //"FitAll" operation ignores object with transform persitence parameter
+ if(aStructure->TransformPersistenceMode() == Graphic3d_TMF_None )
+ {
+ theXMin = Min (aXm, theXMin);
+ theYMin = Min (aYm, theYMin);
+ theZMin = Min (aZm, theZMin);
+ theXMax = Max (aXM, theXMax);
+ theYMax = Max (aYM, theYMax);
+ theZMax = Max (aZM, theZMax);
}
+ }
}
- // Les cas suivants ne sont pas debiles
- // Par exemple si toutes les structures sont vides ou infinies
- if (XMax < XMin) { Xm = XMin; XMin = XMax; XMax = Xm; }
- if (YMax < YMin) { Ym = YMin; YMin = YMax; YMax = Ym; }
- if (ZMax < ZMin) { Zm = ZMin; ZMin = ZMax; ZMax = Zm; }
+ // The following cases are relevant
+ // For exemple if all structures are empty or infinite
+ if (theXMax < theXMin) { aXm = theXMin; theXMin = theXMax; theXMax = aXm; }
+ if (theYMax < theYMin) { aYm = theYMin; theYMin = theYMax; theYMax = aYm; }
+ if (theZMax < theZMin) { aZm = theZMin; theZMin = theZMax; theZMax = aZm; }
}
- Standard_Real Sx, Sy, Sz;
- MyViewOrientation.AxialScale(Sx, Sy, Sz);
- XMin = (Sx > 1. && XMin < RealFirst ()/Sx)?RealFirst (): XMin*Sx;
- XMax = (Sx > 1. && XMax > RealLast ()/Sx)?RealLast (): XMax*Sx;
- YMin = (Sy > 1. && YMin < RealFirst ()/Sy)?RealFirst (): YMin*Sy;
- YMax = (Sy > 1. && YMax > RealLast ()/Sy)?RealLast (): YMax*Sy;
- ZMin = (Sz > 1. && ZMin < RealFirst ()/Sz)?RealFirst (): ZMin*Sz;
- ZMax = (Sz > 1. && ZMax > RealLast ()/Sz)?RealLast (): ZMax*Sz;
-}
-
-void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
-
- MinMaxValues (MyDisplayedStructure, XMin, YMin, XMax, YMax);
-
-}
-
-void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
-
-Standard_Real Xm, Ym, Zm, XM, YM, ZM;
-Standard_Real Xp, Yp, Zp;
-
- MinMaxValues (ASet, Xm, Ym, Zm, XM, YM, ZM);
-
- Projects (Xm, Ym, Zm, Xp, Yp, Zp);
- XMin = Xp;
- YMin = Yp;
-
- Projects (XM, YM, ZM, Xp, Yp, Zp);
- XMax = Xp;
- YMax = Yp;
-
- if (XMax < XMin) { Xp = XMax; XMax = XMin; XMin = Xp; }
- if (YMax < YMin) { Yp = YMax; YMax = YMin; YMin = Yp; }
}
-const TColStd_Array2OfReal& Visual3d_View::MatrixOfOrientation () {
-
- if (! MyMatOfOriIsEvaluated) {
- MyGraphicDriver->InquireMat
- (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
- MyMatOfMapIsEvaluated = Standard_True;
- MyMatOfOriIsEvaluated = Standard_True;
- }
-
- return (MyMatrixOfOrientation);
-
-}
+//=============================================================================
+//function : MinMaxValues
+//purpose :
+//=============================================================================
+void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
+ Standard_Real& theYMin,
+ Standard_Real& theXMax,
+ Standard_Real& theYMax,
+ const Standard_Boolean theToIgnoreInfiniteFlag) const
+{
+ MinMaxValues (MyDisplayedStructure,
+ theXMin, theYMin,
+ theXMax, theYMax,
+ theToIgnoreInfiniteFlag);
+}
+
+//=============================================================================
+//function : MinMaxValues
+//purpose :
+//=============================================================================
+void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
+ Standard_Real& theXMin,
+ Standard_Real& theYMin,
+ Standard_Real& theXMax,
+ Standard_Real& theYMax,
+ const Standard_Boolean theToIgnoreInfiniteFlag) const
+{
+ Standard_Real aXm, aYm, aZm, aXM, aYM, aZM;
+ Standard_Real aXp, aYp, aZp;
-const TColStd_Array2OfReal& Visual3d_View::MatrixOfMapping () {
+ MinMaxValues (theSet, aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag);
- if (! MyMatOfMapIsEvaluated) {
- MyGraphicDriver->InquireMat
- (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
- MyMatOfMapIsEvaluated = Standard_True;
- MyMatOfOriIsEvaluated = Standard_True;
- }
+ Projects (aXm, aYm, aZm, aXp, aYp, aZp);
+ theXMin = aXp;
+ theYMin = aYp;
- return (MyMatrixOfMapping);
+ Projects (aXM, aYM, aZM, aXp, aYp, aZp);
+ theXMax = aXp;
+ theYMax = aYp;
+ if (theXMax < theXMin) { aXp = theXMax; theXMax = theXMin; theXMin = aXp; }
+ if (theYMax < theYMin) { aYp = theYMax; theYMax = theYMin; theYMin = aYp; }
}
Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
}
-#ifdef OLD_METHOD
-void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) const {
-
-math_Vector PtDC (0,3), PtWC (0,3);
-
-// RLE method:
-// Sinon utiliser un new sur une Visual3d_View (constructeur+destructeur)
-// car Projects est une const methode or MatrixOfOrientation et
-// MatrixOfMapping ne le sont pas.
-Visual3d_View * const newthis = (Visual3d_View * const) this;
- newthis->MatrixOfOrientation ();
- newthis->MatrixOfMapping ();
-
-// World Coordinate Space
- PtWC (0) = AX;
- PtWC (1) = AY;
- PtWC (2) = AZ;
- PtWC (3) = 1.0;
-
- // WCS -> View Reference Coordinate Space
- math_Vector PtVRC(0,3);
- PtVRC = MyMatrixOfOrientation.Multiplied (PtWC);
-
- // VRCS -> Normalized Projection Coordinate Space
- math_Vector PtNPC(0,3);
- PtNPC = MyMatrixOfMapping.Multiplied (PtVRC);
- for (Standard_Integer i=0; i<3; i++) PtNPC (i) = PtNPC (i) / PtNPC (3);
-
-#ifdef DEBUG
- printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
- PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
-#endif // DEBUG
-
- Standard_Real Ratio;
-#ifdef DEBUG
- // NPCS -> Device Coordinate Space
- Standard_Real Dx = Standard_Real (MyCView.DefWindow.dx);
- Standard_Real Dy = Standard_Real (MyCView.DefWindow.dy);
-
- Ratio = Dx / Dy;
- PtDC (0) = PtNPC (0) * Dx;
- PtDC (1) = Dy - PtNPC (1) * Dy * Ratio;
-
- printf("Display coordinates : %f,%f,%f,%f\n",
- PtDC(0),PtDC(1),PtDC(2),PtDC(3));
-#endif // DEBUG
-
- // NPCS -> Window Space
-Standard_Real um, vm, uM, vM;
- MyViewMapping.WindowLimit (um, vm, uM, vM);
-
- Ratio = (uM - um) / (vM - vm);
- if (Ratio >= 1.0)
- PtNPC (1) = PtNPC (1) * Ratio;
- else
- PtNPC (0) = PtNPC (0) / Ratio;
-
-#ifdef DEBUG
- printf("Display coordinates PtNPC: %f,%f,%f,%f\n",
- PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
-#endif // DEBUG
-
- Standard_Real fpd = MyViewMapping.FrontPlaneDistance ();
- Standard_Real bpd = MyViewMapping.BackPlaneDistance ();
-
- /*
- * Les coordonnees de PtNPC sont decrites dans l'espace
- * [0-1]x[0-1]x[0-1].
- * Il faut transformer x et y dans le window space.
- * Il faut transformer z dans l'espace du back et front
- * plane, en pensant aux plans de clipping.
- * Ces plans de z clipping sont definis entre 0 et 1.
- */
-
- APX = PtNPC (0) * (uM - um) + um;
- APY = PtNPC (1) * (vM - vm) + vm;
- APZ = PtNPC (2) * (fpd - bpd) + bpd;
-
-#ifdef DEBUG
- Standard_Integer l,c;
- printf("OrientationMatrix :");
- for( l=0 ; l<4 ; l++ ) {
- printf("\n %d->",l);
- for( c=0 ; c<4 ; c++ ) {
- printf(" %f ,",MyMatrixOfOrientation(c,l));
- }
- }
- printf("\n\n");
- printf("MappingMatrix :");
- for( l=0 ; l<4 ; l++ ) {
- printf("\n %d->",l);
- for( c=0 ; c<4 ; c++ ) {
- printf(" %f ,",MyMatrixOfMapping(c,l));
- }
- }
- printf("\n\n");
- printf("World coordinates : %f,%f,%f,%f\n",
- PtWC(0),PtWC(1),PtWC(2),PtWC(3));
- printf("View coordinates : %f,%f,%f,%f\n",
- PtVRC(0),PtVRC(1),PtVRC(2),PtVRC(3));
- printf("Display coordinates : %f,%f,%f,%f\n",
- PtNPC(0),PtNPC(1),PtNPC(2),PtNPC(3));
- printf("Window limit : %f,%f,%f,%f\n",um,vm,uM,vM);
- printf("Ratio : %f\n",Ratio);
- printf("Front-plane : %f back-plane : %f\n",fpd,bpd);
- printf("Projection : %f,%f,%f\n \n",APX,APY,APZ);
-#endif
-
-}
-#endif /* OLD_METHOD */
-
-// OCC18942: This method is likely to duplicate Visual3d_ViewManager::ConvertCoord() one,
-// therefore it is necessary to consider merging the two methods or making them call the same
-// graphic driver's method after OCCT 6.3.
-void Visual3d_View::Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) {
+//=======================================================================
+//function : Projects
+//purpose :
+//=======================================================================
+void Visual3d_View::Projects (const Standard_Real theX,
+ const Standard_Real theY,
+ const Standard_Real theZ,
+ Standard_Real& thePX,
+ Standard_Real& thePY,
+ Standard_Real& thePZ) const
+{
+ const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
-Standard_Real PtX, PtY, PtZ, PtT;
-Standard_Real APT;
-static Standard_Real Ratio, um, vm, uM, vM;
-static Standard_Real fpd, bpd;
+ gp_XYZ aViewSpaceDimensions = aCamera->ViewDimensions();
+ Standard_Real aXSize = aViewSpaceDimensions.X();
+ Standard_Real aYSize = aViewSpaceDimensions.Y();
+ Standard_Real aZSize = aViewSpaceDimensions.Z();
- if (! MyMatOfOriIsEvaluated || ! MyMatOfMapIsEvaluated) {
- MyGraphicDriver->InquireMat
- (MyCView, MyMatrixOfOrientation, MyMatrixOfMapping);
- MyMatOfOriIsEvaluated = MyMatOfMapIsEvaluated = Standard_True;
- }
+ gp_Pnt aPoint = aCamera->Project (gp_Pnt (theX, theY, theZ));
- // WCS -> View Reference Coordinate Space
- PtX = MyMatrixOfOrientation (0, 0) * AX
- + MyMatrixOfOrientation (0, 1) * AY
- + MyMatrixOfOrientation (0, 2) * AZ
- + MyMatrixOfOrientation (0, 3);
- PtY = MyMatrixOfOrientation (1, 0) * AX
- + MyMatrixOfOrientation (1, 1) * AY
- + MyMatrixOfOrientation (1, 2) * AZ
- + MyMatrixOfOrientation (1, 3);
- PtZ = MyMatrixOfOrientation (2, 0) * AX
- + MyMatrixOfOrientation (2, 1) * AY
- + MyMatrixOfOrientation (2, 2) * AZ
- + MyMatrixOfOrientation (2, 3);
- PtT = MyMatrixOfOrientation (3, 0) * AX
- + MyMatrixOfOrientation (3, 1) * AY
- + MyMatrixOfOrientation (3, 2) * AZ
- + MyMatrixOfOrientation (3, 3);
-
- // VRCS -> Normalized Projection Coordinate Space
- APX = MyMatrixOfMapping (0, 0) * PtX
- + MyMatrixOfMapping (0, 1) * PtY
- + MyMatrixOfMapping (0, 2) * PtZ
- + MyMatrixOfMapping (0, 3) * PtT;
- APY = MyMatrixOfMapping (1, 0) * PtX
- + MyMatrixOfMapping (1, 1) * PtY
- + MyMatrixOfMapping (1, 2) * PtZ
- + MyMatrixOfMapping (1, 3) * PtT;
- APZ = MyMatrixOfMapping (2, 0) * PtX
- + MyMatrixOfMapping (2, 1) * PtY
- + MyMatrixOfMapping (2, 2) * PtZ
- + MyMatrixOfMapping (2, 3) * PtT;
- APT = MyMatrixOfMapping (3, 0) * PtX
- + MyMatrixOfMapping (3, 1) * PtY
- + MyMatrixOfMapping (3, 2) * PtZ
- + MyMatrixOfMapping (3, 3) * PtT;
-
- APX /= APT;
- APY /= APT;
- APZ /= APT;
-
- // NPCS -> Window Space
- MyViewMapping.WindowLimit (um, vm, uM, vM);
- fpd = MyViewMapping.FrontPlaneDistance ();
- bpd = MyViewMapping.BackPlaneDistance ();
-
- if(MyCView.Mapping.IsCustomMatrix) {
- // OCC18942: SAN - If orientation and mapping matrices are those used by OpenGL
- // visualization, then X, Y and Z coordinates normally vary between -1 and 1
- APX = ( APX + 1 ) * 0.5 * (uM - um) + um;
- APY = ( APY + 1 ) * 0.5 * (vM - vm) + vm;
- } else {
- Ratio = (uM - um) / (vM - vm);
- if (Ratio >= 1.0)
- APY *= Ratio;
- else
- APX /= Ratio;
-
- /*
- * Les coordonnees de APX, APY, APZ sont decrites dans
- * l'espace [0-1]x[0-1]x[0-1].
- * Il faut transformer x et y dans le window space.
- * Il faut transformer z dans l'espace du back et front
- * plane, en pensant aux plans de clipping.
- * Ces plans de z clipping sont definis entre 0 et 1.
- */
- APX = APX * (uM - um) + um;
- APY = APY * (vM - vm) + vm;
- }
- APZ = APZ * (fpd - bpd) + bpd;
+ // NDC [-1, 1] --> PROJ [ -size / 2, +size / 2 ]
+ thePX = aPoint.X() * aXSize * 0.5;
+ thePY = aPoint.Y() * aYSize * 0.5;
+ thePZ = aPoint.Z() * aZSize * 0.5;
}
Standard_Integer Visual3d_View::Identification () const {
}
-void Visual3d_View::Exploration () const {
-
- if (IsDeleted ()) return;
-
- MyGraphicDriver->DumpView (MyCView);
-
-}
Standard_Boolean Visual3d_View::ZBufferIsActivated () const {
if ((! IsDefined ()) || (! IsActive ())) return (Standard_False);
-// -1 => non force par le programmeur => depend du type de visualisation
-// 0 ou 1 => force par le programmeur
+// -1 => not forced by the programmer => depends on the type of visualisation
+// 0 ou 1 => forced by the programmer
if (MyCView.Context.ZBufferActivity == -1)
if (MyContext.Visualization () == Visual3d_TOV_SHADING)
MyCView.Context.Model = int (MyContext.Model ());
MyCView.Context.Visualization = int (MyContext.Visualization ());
- Handle(Graphic3d_TextureEnv) TempTextureEnv = MyContext.TextureEnv();
- if (! TempTextureEnv.IsNull()) MyCView.Context.TexEnvId = TempTextureEnv->TextureId();
- else MyCView.Context.TexEnvId = -1;
+ MyCView.Context.TextureEnv = MyContext.TextureEnv();
MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
}
for (i=1; i<=Length; i++)
(MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False);
- // Si le mode degenere est actif, on ne recalcule rien
-#ifdef G003
- if ( DegenerateModeIsOn () || !ComputedMode () ) return;
-#else
- if (DegenerateModeIsOn ()) return;
-#endif // G003
+ if (!ComputedMode())
+ {
+ return;
+ }
/*
- * Forcer le HLRValidation a False sur toutes les structures
- * calculees dans la vue.
+ * Force HLRValidation to False on all structures
+ * calculated in the view.
*/
#ifdef TRACE_LENGTH
if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
#endif
/*
- * Changement d'orientation ou de type de projection =>
- * Erase des structures qui ont ete calculees pour
- * l'orientation precedente.
- * Recalcul des nouvelles structures.
- * Passage du mode degenere ON a OFF =>
- * Erase des structures qui ont ete calculees avant que
- * le mode degenere passe a ON.
- * Recalcul des nouvelles structures.
+ * Change of orientation or of projection type =>
+ * Remove structures that were calculated for the
+ * previous orientation.
+ * Recalculation of new structures.
*/
Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
Visual3d_TypeOfAnswer Answer;
while (S1Iterator.More ()) {
Answer = AcceptDisplay (S1Iterator.Key ());
- // Si la structure etait calculee, on la recalcule.
+ // If the structure was calculated, it is recalculated.
if (Answer == Visual3d_TOA_COMPUTE) {
#ifdef TRACE
cout << "AcceptDisplay ("
FooSequence.Append (S1Iterator.Key ());
}
- // S1Iterator.Next () se positionne sur la
- // prochaine structure
+ // S1Iterator.Next () is located on the next structure
S1Iterator.Next ();
}
Length = FooSequence.Length ();
- // On affiche les structures stockees
+ // All stored structures are displayed
for (i=1; i<=Length; i++)
Display (FooSequence.Value (i), Aspect_TOU_WAIT);
if (Length != 0) FooSequence.Clear ();
}
void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
-#ifdef G003
- if ( DegenerateModeIsOn () || !ComputedMode () ) return;
-#else
- if (DegenerateModeIsOn()) return;
-#endif // G003
+ if (MyCView.IsCullingEnabled)
+ {
+ AStructure->CalculateBoundBox();
+ Standard_Integer aLayerId = AStructure->DisplayPriority();
+ MyGraphicDriver->InvalidateBVHData(MyCView, aLayerId);
+ }
+
+ if (!ComputedMode()) return;
if (IsDeleted ()) return;
Standard_Integer Index = IsComputed (AStructure);
if (Index == 0) {
#ifdef TRACE_COMP
- cout << "La structure " << AStructure->Identification ()
- << " n'est pas calculee dans la view "
+ cout << "Structure " << AStructure->Identification ()
+ << " is not calculated in the view "
<< Identification () << "\n";
cout << flush;
#endif
MyCOMPUTEDSequence.Value (Index)->Identification ();
#ifdef TRACE_COMP
Standard_Integer StructId = AStructure->Identification ();
- cout << "La structure " << StructId
- << " calculee, dans la view "
- << Identification () << ", par la structure "
- << OldStructId << " est recalculee.\n";
+ cout << "Structure " << StructId
+ << " calculated, in the view "
+ << Identification () << ", by the structure "
+ << OldStructId << " is recalculated.\n";
cout << flush;
#endif
#endif
TheStructure->SetHLRValidation (Standard_True);
-// Recuperation type de visualisation de la vue
+// Return type of visualisation of the view
Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
-// De quel type sera la computed ?
+// Of which type will be the computed ?
Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
(AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
}
- // On la range
- // Recherche de la structure <AStructure>
- // dans la sequence des structures a calculer
+ // Ot is ranged
+ // Find structure <AStructure>
+ // in the sequence of structures to be calculated.
NewStructId = TheStructure->Identification ();
- // On efface l'ancienne calculee et on affiche la nouvelle
- MyGraphicDriver->EraseStructure (
- MyCView,
- *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)TheStructure->CStructure (),
- int (AStructure->DisplayPriority ())
- );
+ // The previous calculation is removed and the new one is dislayed
+ MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
+ MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), AStructure->DisplayPriority());
#ifdef TRACE_LENGTH
if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
}
#endif
- // On ajoute la hlhsr et
- // la nouvelle compute associee
+ // hlhsr and the new associated compute are added
MyTOCOMPUTESequence.Append (AStructure);
MyCOMPUTEDSequence.Append (TheStructure);
<< "\n" << flush;
#endif
- // On enleve la hlhsr et
- // l'ancienne compute associee
+ // hlhsr and the new associated compute are removed
MyTOCOMPUTESequence.Remove (Index);
MyCOMPUTEDSequence.Remove (Index);
}
-void
-#ifdef G003
-Visual3d_View::SetAnimationModeOn ( const Standard_Boolean degenerate ) {
-#else
-Visual3d_View::SetAnimationModeOn () {
-#endif
-
- if (AnimationModeIsOn ()) return;
-
- AnimationModeIsActive = Standard_True;
-#ifdef G003
- if ( degenerate )
- SetDegenerateModeOn ();
- else
- SetDegenerateModeOff ();
-#endif // G003
- MyGraphicDriver->BeginAnimation (MyCView);
-
-}
-
-void Visual3d_View::SetAnimationModeOff () {
-
- if (! AnimationModeIsOn ()) return;
-
- AnimationModeIsActive = Standard_False;
-#ifdef G003
- SetDegenerateModeOff ();
-#endif // G003
- MyGraphicDriver->EndAnimation (MyCView);
-
-}
-
-Standard_Boolean Visual3d_View::AnimationModeIsOn () const {
-
- return AnimationModeIsActive;
-
-}
-
-void Visual3d_View::SetDegenerateModeOn () {
-
-#ifdef TRACE
- cout << "Visual3d_View" << MyCView.ViewId
- << "::SetDegenerateModeOn ();\n";
- cout << flush;
-#endif
-
- // Si le mode degenere est deja actif, on ne recalcule rien
- if (DegenerateModeIsOn ()) return;
- DegenerateModeIsActive = Standard_True;
-
-#ifdef G003
- MyCView.IsDegenerates = 1;
-#else
- /*
- * Changement d'activite du mode degenere
- * Erase des structures qui ont ete calculees
- * et affichees quand le mode etait off.
- * Affichage des structures non calculees.
- */
-Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
-Visual3d_TypeOfAnswer Answer;
-Standard_Integer StructId;
-
- while (S1Iterator.More ()) {
-
- Answer = AcceptDisplay (S1Iterator.Key ());
- // Si la structure etait a calculer, on efface la
- // structure calculee et l'on l'affiche
- // (C'est le role du passage en mode degenere)
-
- if (Answer == Visual3d_TOA_COMPUTE) {
-Standard_Integer Index = IsComputed (S1Iterator.Key ());
- if (Index != 0) {
- StructId =
- MyCOMPUTEDSequence.Value (Index)->Identification ();
-#ifdef TRACE_COMP
- cout << "La structure " << S1Iterator.Key ()->Identification ()
- << " calculee, dans la view "
- << Identification () << ", par la structure "
- << StructId << " passe en mode degenere.\n";
- cout << "On efface " << StructId << " puis on affiche "
- << S1Iterator.Key ()->Identification () << "\n";
- cout << flush;
-#endif
- MyGraphicDriver->EraseStructure
- (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure (),
- int (S1Iterator.Key ()->DisplayPriority ())
- );
- }
- else {
- // Le else est impossible (OUI !)
- // Si le mode etait non degenere avant alors la
- // structure calculee associee a S1Iterator.Key ()
- // existe vraiment et donc Index != 0
- }
- }
-
- // S1Iterator.Next () se positionne sur la
- // prochaine structure
- S1Iterator.Next ();
- }
-#endif //G003
-}
-
-void Visual3d_View::SetDegenerateModeOff () {
-
-#ifdef TRACE
- cout << "Visual3d_View" << MyCView.ViewId
- << "::SetDegenerateModeOff ();\n";
- cout << flush;
-#endif
-
- // Si le mode degenere est deja inactif, on ne recalcule rien
- if (! DegenerateModeIsOn ()) return;
-
- DegenerateModeIsActive = Standard_False;
-
-#ifdef G003
- MyCView.IsDegenerates = 0;
-#else
- /*
- * Changement d'activite du mode degenere
- * Erase des structures qui ont ete affichees
- * quand le mode etait on.
- * Calcul des structures.
- */
-Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
-Visual3d_TypeOfAnswer Answer;
-Standard_Integer StructId;
-
- Standard_Integer i = MyDisplayedStructure.Extent ();
-
- while (S1Iterator.More ()) {
-
- Answer = AcceptDisplay (S1Iterator.Key ());
- // Si la structure etait a calculer, on l'efface
- // et on affiche la structure calculee
- // (C'est le role du passage en mode non degenere)
-
- if (Answer == Visual3d_TOA_COMPUTE) {
-Standard_Integer Index = IsComputed (S1Iterator.Key ());
- if (Index != 0) {
- StructId =
- MyCOMPUTEDSequence.Value (Index)->Identification ();
-#ifdef TRACE_COMP
- cout << "La structure " << S1Iterator.Key ()->Identification ()
- << " calculee, dans la view "
- << Identification () << ", par la structure "
- << StructId << " passe en mode normal.\n";
- cout << "On efface " << S1Iterator.Key ()->Identification ()
- << " puis on affiche " << StructId << "\n";
- cout << flush;
-#endif
- MyGraphicDriver->EraseStructure
- (MyCView,
- *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure ());
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
- int (S1Iterator.Key ()->DisplayPriority ())
- );
-
- Display (S1Iterator.Key (), Aspect_TOU_WAIT);
-
- if ((S1Iterator.Key ())->IsHighlighted()) {
- if (! (MyCOMPUTEDSequence.Value (Index))->IsHighlighted()) {
- (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
- ((S1Iterator.Key ())->HighlightColor ());
- (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (Aspect_TOHM_COLOR);
- }
- }
- }
- else {
- // Le else est impossible (NON !)
- // Le mode degenere a ete active avant l'affichage
- // de la structure. La structure a donc ete ensuite
- // affichee dans le mode degenere et donc sans que la
- // structure calculee existe.
- // On la calcule
-
- // Compute + Validation
-Handle(Graphic3d_Structure) AStructure = (S1Iterator.Key ());
-#ifdef OLD
-Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
-#else
-Handle(Graphic3d_Structure) TheStructure;
-TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
- AStructure->Transform (ATrsf);
- if (Index != 0) {
-TColStd_Array2OfReal Ident (0, 3, 0, 3);
-Standard_Integer ii, jj;
- for (ii=0; ii<=3; ii++)
- for (jj=0; jj<=3; jj++)
- Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
- TheStructure = MyCOMPUTEDSequence.Value (Index);
- TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
- if (AStructure->IsTransformed ()) {
- AStructure->Compute (this, ATrsf, TheStructure);
- }
- else {
- AStructure->Compute (this, TheStructure);
- }
- }
- else {
- if (AStructure->IsTransformed ()) {
- TheStructure = AStructure->Compute (this, ATrsf);
- }
- else {
- TheStructure = AStructure->Compute (this);
- }
- }
-#endif
- TheStructure->SetHLRValidation (Standard_True);
-
-// Recuperation type de visualisation de la vue
-Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
-
-// De quel type sera la computed ?
-Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
- ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_SHADING));
-
-Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
- ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
-
- if (ComputeWireframe)
- TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
- if (ComputeShading)
- TheStructure->SetVisual (Graphic3d_TOS_SHADING);
-
- if ((S1Iterator.Key ())->IsHighlighted()) {
- TheStructure->SetHighlightColor
- ((S1Iterator.Key ())->HighlightColor ());
- TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
- }
-
- // On la range
-Standard_Integer Result = 0;
-Standard_Integer Length = MyTOCOMPUTESequence.Length ();
- // Recherche de la structure <S1Iterator.Key ()>
- // dans la sequence des structures a calculer
- StructId = (S1Iterator.Key ())->Identification ();
- for (i=1; i<=Length && Result==0; i++)
- if ((MyTOCOMPUTESequence.Value (i))->Identification () ==
- StructId) Result = i;
- if (Result != 0)
- MyCOMPUTEDSequence.ChangeValue (Result) = TheStructure;
- else {
- // On ajoute la hlhsr et la nouvelle compute associee
-#ifdef TRACE_LENGTH
- if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
- cout << "In Visual3d_View::SetDegenerateModeOff, ";
- cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
- << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
- << "\n" << flush;
- }
-#endif
- MyTOCOMPUTESequence.Append (S1Iterator.Key ());
- MyCOMPUTEDSequence.Append (TheStructure);
-#ifdef TRACE_LENGTH
- if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
- cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
- << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
- << "\n" << flush;
-#endif
- }
-
- // On efface la degeneree et on affiche la calculee
- MyGraphicDriver->EraseStructure
- (MyCView,
- *(Graphic3d_CStructure *)(S1Iterator.Key ()->CStructure ()));
- MyGraphicDriver->DisplayStructure (
- MyCView,
- *(Graphic3d_CStructure *)TheStructure->CStructure (),
- int (S1Iterator.Key ()->DisplayPriority ())
- );
- }
- }
-
- // S1Iterator.Next () se positionne sur la
- // prochaine structure
- S1Iterator.Next ();
- }
-
- if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
-#endif //G003
-}
-
-Standard_Boolean Visual3d_View::DegenerateModeIsOn () const {
-
- return DegenerateModeIsActive;
-
-}
-
-Handle(Aspect_GraphicDriver) Visual3d_View::GraphicDriver () const {
+const Handle(Graphic3d_GraphicDriver)& Visual3d_View::GraphicDriver () const {
return MyGraphicDriver;
}
-void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& APlotter) const {
-
-Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
-
- while (S1Iterator.More ()) {
-
- if (DegenerateModeIsOn ())
- // Le mode etant degenere on plotte la structure
- // affichee sans s'occuper si elle est calculee
- (S1Iterator.Key ())->Plot (APlotter);
- else {
-Standard_Integer Index = IsComputed (S1Iterator.Key ());
- // Le mode n'etant pas degenere on plotte la structure
- // affichee si elle n'est pas calculee sinon
- // on plotte la structure calculee associee
- if (Index == 0)
- (S1Iterator.Key ())->Plot (APlotter);
- else
- (MyCOMPUTEDSequence.Value (Index))->Plot (APlotter);
- }
-
- // S1Iterator.Next () se positionne sur la
- // prochaine structure
- S1Iterator.Next ();
- }
-
-}
-
Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const {
Standard_Integer Result = 0;
Standard_Integer Length = MyTOCOMPUTESequence.Length ();
- // Recherche dans la sequence des structures deja calculees
- // 1/ D'une structure ayant le meme Owner que <AStructure>
- // 2/ Qui ne soit pas <AStructure>
- // 3/ Dont la COMPUTED soit valide
+ // Find in the sequence of already calculated structures
+ // 1/ Structure with the same Owner as <AStructure>
+ // 2/ Which is not <AStructure>
+ // 3/ COMPUTED which of is valid
for (Standard_Integer i=1; i<=Length && Result==0; i++)
if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ())
&& (MyTOCOMPUTESequence.Value (i)->Identification () !=
}
-Standard_Boolean checkFloat(const Standard_Real value)
+static Standard_Boolean checkFloat(const Standard_Real value)
{
return value > -FLT_MAX && value < FLT_MAX;
}
-void SetMinMaxValuesCallback(void* Visual3dView)
+static void SetMinMaxValuesCallback(Visual3d_View* theView)
{
Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
-
- Handle(Visual3d_View) view = (Handle(Visual3d_View)&) Visual3dView;
- view->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
+ theView->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
{
- Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(view->GraphicDriver());
+ Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(theView->GraphicDriver());
driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
(Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
}
}
-void Visual3d_View::GetGraduatedTrihedron(/* Names of axes */
- Standard_CString& xname,
- Standard_CString& yname,
- Standard_CString& zname,
- /* Draw names */
- Standard_Boolean& xdrawname,
- Standard_Boolean& ydrawname,
- Standard_Boolean& zdrawname,
- /* Draw values */
- Standard_Boolean& xdrawvalues,
- Standard_Boolean& ydrawvalues,
- Standard_Boolean& zdrawvalues,
- /* Draw grid */
- Standard_Boolean& drawgrid,
- /* Draw axes */
- Standard_Boolean& drawaxes,
- /* Number of splits along axes */
- Standard_Integer& nbx,
- Standard_Integer& nby,
- Standard_Integer& nbz,
- /* Offset for drawing values */
- Standard_Integer& xoffset,
- Standard_Integer& yoffset,
- Standard_Integer& zoffset,
- /* Offset for drawing names of axes */
- Standard_Integer& xaxisoffset,
- Standard_Integer& yaxisoffset,
- Standard_Integer& zaxisoffset,
- /* Draw tickmarks */
- Standard_Boolean& xdrawtickmarks,
- Standard_Boolean& ydrawtickmarks,
- Standard_Boolean& zdrawtickmarks,
- /* Length of tickmarks */
- Standard_Integer& xtickmarklength,
- Standard_Integer& ytickmarklength,
- Standard_Integer& ztickmarklength,
- /* Grid color */
- Quantity_Color& gridcolor,
- /* X name color */
- Quantity_Color& xnamecolor,
- /* Y name color */
- Quantity_Color& ynamecolor,
- /* Z name color */
- Quantity_Color& znamecolor,
- /* X color of axis and values */
- Quantity_Color& xcolor,
- /* Y color of axis and values */
- Quantity_Color& ycolor,
- /* Z color of axis and values */
- Quantity_Color& zcolor,
- /* Name of font for names of axes */
- Standard_CString& fontOfNames,
- /* Style of names of axes */
- OSD_FontAspect& styleOfNames,
- /* Size of names of axes */
- Standard_Integer& sizeOfNames,
- /* Name of font for values */
- Standard_CString& fontOfValues,
- /* Style of values */
- OSD_FontAspect& styleOfValues,
- /* Size of values */
- Standard_Integer& sizeOfValues) const
+Standard_Boolean Visual3d_View::GetGraduatedTrihedron
+ (/* Names of axes */
+ TCollection_ExtendedString& xname,
+ TCollection_ExtendedString& yname,
+ TCollection_ExtendedString& zname,
+ /* Draw names */
+ Standard_Boolean& xdrawname,
+ Standard_Boolean& ydrawname,
+ Standard_Boolean& zdrawname,
+ /* Draw values */
+ Standard_Boolean& xdrawvalues,
+ Standard_Boolean& ydrawvalues,
+ Standard_Boolean& zdrawvalues,
+ /* Draw grid */
+ Standard_Boolean& drawgrid,
+ /* Draw axes */
+ Standard_Boolean& drawaxes,
+ /* Number of splits along axes */
+ Standard_Integer& nbx,
+ Standard_Integer& nby,
+ Standard_Integer& nbz,
+ /* Offset for drawing values */
+ Standard_Integer& xoffset,
+ Standard_Integer& yoffset,
+ Standard_Integer& zoffset,
+ /* Offset for drawing names of axes */
+ Standard_Integer& xaxisoffset,
+ Standard_Integer& yaxisoffset,
+ Standard_Integer& zaxisoffset,
+ /* Draw tickmarks */
+ Standard_Boolean& xdrawtickmarks,
+ Standard_Boolean& ydrawtickmarks,
+ Standard_Boolean& zdrawtickmarks,
+ /* Length of tickmarks */
+ Standard_Integer& xtickmarklength,
+ Standard_Integer& ytickmarklength,
+ Standard_Integer& ztickmarklength,
+ /* Grid color */
+ Quantity_Color& gridcolor,
+ /* Colors of axis names */
+ Quantity_Color& xnamecolor,
+ Quantity_Color& ynamecolor,
+ Quantity_Color& znamecolor,
+ /* Colors of axis and values */
+ Quantity_Color& xcolor,
+ Quantity_Color& ycolor,
+ Quantity_Color& zcolor,
+ /* Name of font for names of axes */
+ TCollection_AsciiString& fontOfNames,
+ /* Style of names of axes */
+ Font_FontAspect& styleOfNames,
+ /* Size of names of axes */
+ Standard_Integer& sizeOfNames,
+ /* Name of font for values */
+ TCollection_AsciiString& fontOfValues,
+ /* Style of values */
+ Font_FontAspect& styleOfValues,
+ /* Size of values */
+ Standard_Integer& sizeOfValues) const
{
- MyGraphicDriver->GetGraduatedTrihedron(MyCView,
- /* Names of axes */
- xname,
- yname,
- zname,
- /* Draw names */
- xdrawname,
- ydrawname,
- zdrawname,
- /* Draw values */
- xdrawvalues,
- ydrawvalues,
- zdrawvalues,
- /* Draw grid */
- drawgrid,
- /* Draw axes */
- drawaxes,
- /* Number of splits along axes */
- nbx,
- nby,
- nbz,
- /* Offset for drawing values */
- xoffset,
- yoffset,
- zoffset,
- /* Offset for drawing names of axes */
- xaxisoffset,
- yaxisoffset,
- zaxisoffset,
- /* Draw tickmarks */
- xdrawtickmarks,
- ydrawtickmarks,
- zdrawtickmarks,
- /* Length of tickmarks */
- xtickmarklength,
- ytickmarklength,
- ztickmarklength,
- /* Grid color */
- gridcolor,
- /* X name color */
- xnamecolor,
- /* Y name color */
- ynamecolor,
- /* Z name color */
- znamecolor,
- /* X color of axis and values */
- xcolor,
- /* Y color of axis and values */
- ycolor,
- /* Z color of axis and values */
- zcolor,
- /* Name of font for names of axes */
- fontOfNames,
- /* Style of names of axes */
- styleOfNames,
- /* Size of names of axes */
- sizeOfNames,
- /* Name of font for values */
- fontOfValues,
- /* Style of values */
- styleOfValues,
- /* Size of values */
- sizeOfValues);
-}
-
-void Visual3d_View::GraduatedTrihedronDisplay(/* Names of axes */
- const Standard_CString xname,
- const Standard_CString yname,
- const Standard_CString zname,
- /* Draw names */
- const Standard_Boolean xdrawname,
- const Standard_Boolean ydrawname,
- const Standard_Boolean zdrawname,
- /* Draw values */
- const Standard_Boolean xdrawvalues,
- const Standard_Boolean ydrawvalues,
- const Standard_Boolean zdrawvalues,
- /* Draw grid */
- const Standard_Boolean drawgrid,
- /* Draw axes */
- const Standard_Boolean drawaxes,
- /* Number of splits along axes */
- const Standard_Integer nbx,
- const Standard_Integer nby,
- const Standard_Integer nbz,
- /* Offset for drawing values */
- const Standard_Integer xoffset,
- const Standard_Integer yoffset,
- const Standard_Integer zoffset,
- /* Offset for drawing names of axes */
- const Standard_Integer xaxisoffset,
- const Standard_Integer yaxisoffset,
- const Standard_Integer zaxisoffset,
- /* Draw tickmarks */
- const Standard_Boolean xdrawtickmarks,
- const Standard_Boolean ydrawtickmarks,
- const Standard_Boolean zdrawtickmarks,
- /* Length of tickmarks */
- const Standard_Integer xtickmarklength,
- const Standard_Integer ytickmarklength,
- const Standard_Integer ztickmarklength,
- /* Grid color */
- const Quantity_Color& gridcolor,
- /* X name color */
- const Quantity_Color& xnamecolor,
- /* Y name color */
- const Quantity_Color& ynamecolor,
- /* Z name color */
- const Quantity_Color& znamecolor,
- /* X color of axis and values */
- const Quantity_Color& xcolor,
- /* Y color of axis and values */
- const Quantity_Color& ycolor,
- /* Z color of axis and values */
- const Quantity_Color& zcolor,
- /* Name of font for names of axes */
- const Standard_CString fontOfNames,
- /* Style of names of axes */
- const OSD_FontAspect styleOfNames,
- /* Size of names of axes */
- const Standard_Integer sizeOfNames,
- /* Name of font for values */
- const Standard_CString fontOfValues,
- /* Style of values */
- const OSD_FontAspect styleOfValues,
- /* Size of values */
- const Standard_Integer sizeOfValues)
+ if (!MyGTrihedron.ptrVisual3dView)
+ return Standard_False;
+
+ /* Names of axes */
+ xname = MyGTrihedron.xname;
+ yname = MyGTrihedron.yname;
+ zname = MyGTrihedron.zname;
+ /* Draw names */
+ xdrawname = MyGTrihedron.xdrawname;
+ ydrawname = MyGTrihedron.ydrawname;
+ zdrawname = MyGTrihedron.zdrawname;
+ /* Draw values */
+ xdrawvalues = MyGTrihedron.xdrawvalues;
+ ydrawvalues = MyGTrihedron.ydrawvalues;
+ zdrawvalues = MyGTrihedron.zdrawvalues;
+ /* Draw grid */
+ drawgrid = MyGTrihedron.drawgrid;
+ /* Draw axes */
+ drawaxes = MyGTrihedron.drawaxes;
+ /* Number of splits along axes */
+ nbx = MyGTrihedron.nbx;
+ nby = MyGTrihedron.nby;
+ nbz = MyGTrihedron.nbz;
+ /* Offset for drawing values */
+ xoffset = MyGTrihedron.xoffset;
+ yoffset = MyGTrihedron.yoffset;
+ zoffset = MyGTrihedron.zoffset;
+ /* Offset for drawing names of axes */
+ xaxisoffset = MyGTrihedron.xaxisoffset;
+ yaxisoffset = MyGTrihedron.yaxisoffset;
+ zaxisoffset = MyGTrihedron.zaxisoffset;
+ /* Draw tickmarks */
+ xdrawtickmarks = MyGTrihedron.xdrawtickmarks;
+ ydrawtickmarks = MyGTrihedron.ydrawtickmarks;
+ zdrawtickmarks = MyGTrihedron.zdrawtickmarks;
+ /* Length of tickmarks */
+ xtickmarklength = MyGTrihedron.xtickmarklength;
+ ytickmarklength = MyGTrihedron.ytickmarklength;
+ ztickmarklength = MyGTrihedron.ztickmarklength;
+ /* Grid color */
+ gridcolor = MyGTrihedron.gridcolor;
+ /* Colors of axis names */
+ xnamecolor = MyGTrihedron.xnamecolor;
+ ynamecolor = MyGTrihedron.ynamecolor;
+ znamecolor = MyGTrihedron.znamecolor;
+ /* Colors of axis and values */
+ xcolor = MyGTrihedron.xcolor;
+ ycolor = MyGTrihedron.ycolor;
+ zcolor = MyGTrihedron.zcolor;
+ /* Name of font for names of axes */
+ fontOfNames = MyGTrihedron.fontOfNames;
+ /* Style of names of axes */
+ styleOfNames = MyGTrihedron.styleOfNames;
+ /* Size of names of axes */
+ sizeOfNames = MyGTrihedron.sizeOfNames;
+ /* Name of font for values */
+ fontOfValues = MyGTrihedron.fontOfValues;
+ /* Style of values */
+ styleOfValues = MyGTrihedron.styleOfValues;
+ /* Size of values */
+ sizeOfValues = MyGTrihedron.sizeOfValues;
+
+ return Standard_True;
+}
+
+void Visual3d_View::GraduatedTrihedronDisplay
+ (/* Names of axes */
+ const TCollection_ExtendedString &xname,
+ const TCollection_ExtendedString &yname,
+ const TCollection_ExtendedString &zname,
+ /* Draw names */
+ const Standard_Boolean xdrawname,
+ const Standard_Boolean ydrawname,
+ const Standard_Boolean zdrawname,
+ /* Draw values */
+ const Standard_Boolean xdrawvalues,
+ const Standard_Boolean ydrawvalues,
+ const Standard_Boolean zdrawvalues,
+ /* Draw grid */
+ const Standard_Boolean drawgrid,
+ /* Draw axes */
+ const Standard_Boolean drawaxes,
+ /* Number of splits along axes */
+ const Standard_Integer nbx,
+ const Standard_Integer nby,
+ const Standard_Integer nbz,
+ /* Offset for drawing values */
+ const Standard_Integer xoffset,
+ const Standard_Integer yoffset,
+ const Standard_Integer zoffset,
+ /* Offset for drawing names of axes */
+ const Standard_Integer xaxisoffset,
+ const Standard_Integer yaxisoffset,
+ const Standard_Integer zaxisoffset,
+ /* Draw tickmarks */
+ const Standard_Boolean xdrawtickmarks,
+ const Standard_Boolean ydrawtickmarks,
+ const Standard_Boolean zdrawtickmarks,
+ /* Length of tickmarks */
+ const Standard_Integer xtickmarklength,
+ const Standard_Integer ytickmarklength,
+ const Standard_Integer ztickmarklength,
+ /* Grid color */
+ const Quantity_Color& gridcolor,
+ /* Colors of axis names */
+ const Quantity_Color& xnamecolor,
+ const Quantity_Color& ynamecolor,
+ const Quantity_Color& znamecolor,
+ /* Colors of axis and values */
+ const Quantity_Color& xcolor,
+ const Quantity_Color& ycolor,
+ const Quantity_Color& zcolor,
+ /* Name of font for names of axes */
+ const TCollection_AsciiString &fontOfNames,
+ /* Style of names of axes */
+ const Font_FontAspect styleOfNames,
+ /* Size of names of axes */
+ const Standard_Integer sizeOfNames,
+ /* Name of font for values */
+ const TCollection_AsciiString &fontOfValues,
+ /* Style of values */
+ const Font_FontAspect styleOfValues,
+ /* Size of values */
+ const Standard_Integer sizeOfValues)
{
- CALL_DEF_GRADUATEDTRIHEDRON cubic;
- cubic.ptrVisual3dView = this;
- cubic.cbCubicAxes = SetMinMaxValuesCallback;
- MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,
- cubic,
- /* Names of axes */
- xname,
- yname,
- zname,
- /* Draw names */
- xdrawname,
- ydrawname,
- zdrawname,
- /* Draw values */
- xdrawvalues,
- ydrawvalues,
- zdrawvalues,
- /* Draw grid */
- drawgrid,
- /* Draw axes */
- drawaxes,
- /* Number of splits along axes */
- nbx,
- nby,
- nbz,
- /* Offset for drawing values */
- xoffset,
- yoffset,
- zoffset,
- /* Offset for drawing names of axes */
- xaxisoffset,
- yaxisoffset,
- zaxisoffset,
- /* Draw tickmarks */
- xdrawtickmarks,
- ydrawtickmarks,
- zdrawtickmarks,
- /* Length of tickmarks */
- xtickmarklength,
- ytickmarklength,
- ztickmarklength,
- /* Grid color */
- gridcolor,
- /* X name color */
- xnamecolor,
- /* Y name color */
- ynamecolor,
- /* Z name color */
- znamecolor,
- /* X color of axis and values */
- xcolor,
- /* Y color of axis and values */
- ycolor,
- /* Z color of axis and values */
- zcolor,
- /* Name of font for names of axes */
- fontOfNames,
- /* Style of names of axes */
- styleOfNames,
- /* Size of names of axes */
- sizeOfNames,
- /* Name of font for values */
- fontOfValues,
- /* Style of values */
- styleOfValues,
- /* Size of values */
- sizeOfValues);
+ /* Names of axes */
+ MyGTrihedron.xname = xname;
+ MyGTrihedron.yname = yname;
+ MyGTrihedron.zname = zname;
+ /* Draw names */
+ MyGTrihedron.xdrawname = xdrawname;
+ MyGTrihedron.ydrawname = ydrawname;
+ MyGTrihedron.zdrawname = zdrawname;
+ /* Draw values */
+ MyGTrihedron.xdrawvalues = xdrawvalues;
+ MyGTrihedron.ydrawvalues = ydrawvalues;
+ MyGTrihedron.zdrawvalues = zdrawvalues;
+ /* Draw grid */
+ MyGTrihedron.drawgrid = drawgrid;
+ /* Draw axes */
+ MyGTrihedron.drawaxes = drawaxes;
+ /* Number of splits along axes */
+ MyGTrihedron.nbx = nbx;
+ MyGTrihedron.nby = nby;
+ MyGTrihedron.nbz = nbz;
+ /* Offset for drawing values */
+ MyGTrihedron.xoffset = xoffset;
+ MyGTrihedron.yoffset = yoffset;
+ MyGTrihedron.zoffset = zoffset;
+ /* Offset for drawing names of axes */
+ MyGTrihedron.xaxisoffset = xaxisoffset;
+ MyGTrihedron.yaxisoffset = yaxisoffset;
+ MyGTrihedron.zaxisoffset = zaxisoffset;
+ /* Draw tickmarks */
+ MyGTrihedron.xdrawtickmarks = xdrawtickmarks;
+ MyGTrihedron.ydrawtickmarks = ydrawtickmarks;
+ MyGTrihedron.zdrawtickmarks = zdrawtickmarks;
+ /* Length of tickmarks */
+ MyGTrihedron.xtickmarklength = xtickmarklength;
+ MyGTrihedron.ytickmarklength = ytickmarklength;
+ MyGTrihedron.ztickmarklength = ztickmarklength;
+ /* Grid color */
+ MyGTrihedron.gridcolor = gridcolor;
+ /* Colors of axis names */
+ MyGTrihedron.xnamecolor = xnamecolor;
+ MyGTrihedron.ynamecolor = ynamecolor;
+ MyGTrihedron.znamecolor = znamecolor;
+ /* Colors of axis and values */
+ MyGTrihedron.xcolor = xcolor;
+ MyGTrihedron.ycolor = ycolor;
+ MyGTrihedron.zcolor = zcolor;
+ /* Name of font for names of axes */
+ MyGTrihedron.fontOfNames = fontOfNames;
+ /* Style of names of axes */
+ MyGTrihedron.styleOfNames = styleOfNames;
+ /* Size of names of axes */
+ MyGTrihedron.sizeOfNames = sizeOfNames;
+ /* Name of font for values */
+ MyGTrihedron.fontOfValues = fontOfValues;
+ /* Style of values */
+ MyGTrihedron.styleOfValues = styleOfValues;
+ /* Size of values */
+ MyGTrihedron.sizeOfValues = sizeOfValues;
+
+ MyGTrihedron.ptrVisual3dView = this;
+ MyGTrihedron.cbCubicAxes = SetMinMaxValuesCallback;
+ MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,MyGTrihedron);
}
void Visual3d_View::GraduatedTrihedronErase()
{
+ MyGTrihedron.ptrVisual3dView = NULL;
MyGraphicDriver->GraduatedTrihedronErase(MyCView);
}
return maxplane;
}
-#ifdef IMP140100
-Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const {
-
- return MyPtrViewManager;
+Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const
+{
+ return MyPtrViewManager;
}
-#endif
-
-#ifdef G003
-void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode ) {
- if ( ( (aMode && ComputedModeIsActive) ||
- (!aMode && !ComputedModeIsActive)
- ) || DegenerateModeIsOn ()
- ) return;
+void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode )
+{
+ if ((aMode && ComputedModeIsActive) ||
+ (!aMode && !ComputedModeIsActive))
+ {
+ return;
+ }
Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure );
Visual3d_TypeOfAnswer Answer;
Standard_Integer StructId;
Standard_Integer i = MyDisplayedStructure.Extent ();
-
- if ( !( ComputedModeIsActive = aMode ) ) {
+ ComputedModeIsActive = aMode;
+ if (!ComputedModeIsActive) {
while ( S1Iterator.More () ) {
StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
- MyGraphicDriver -> EraseStructure (
- MyCView,
- *( Graphic3d_CStructure* )
- MyCOMPUTEDSequence.Value ( Index ) -> CStructure ()
- );
- MyGraphicDriver -> DisplayStructure (
- MyCView,
- *( Graphic3d_CStructure* )
- S1Iterator.Key () -> CStructure (),
- int ( S1Iterator.Key () -> DisplayPriority () )
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
+ MyGraphicDriver->DisplayStructure (MyCView, *(S1Iterator.Key()->CStructure()), S1Iterator.Key()->DisplayPriority());
} // end if ( Index != 0 ) . . .
} // end if ( Answer . . . )
StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
- MyGraphicDriver -> EraseStructure (
- MyCView,
- *( Graphic3d_CStructure* )
- S1Iterator.Key () -> CStructure ()
- );
- MyGraphicDriver -> DisplayStructure (
- MyCView,
- *( Graphic3d_CStructure* )
- MyCOMPUTEDSequence.Value ( Index ) -> CStructure (),
- int ( S1Iterator.Key () -> DisplayPriority () )
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(S1Iterator.Key()->CStructure()));
+ MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), S1Iterator.Key()->DisplayPriority());
Display ( S1Iterator.Key (), Aspect_TOU_WAIT );
} // end else
- MyGraphicDriver -> EraseStructure (
- MyCView,
- *( Graphic3d_CStructure* )
- S1Iterator.Key () -> CStructure ()
- );
- MyGraphicDriver -> DisplayStructure (
- MyCView,
- *( Graphic3d_CStructure* )TheStructure -> CStructure (),
- int ( S1Iterator.Key () -> DisplayPriority () )
- );
+ MyGraphicDriver->EraseStructure (MyCView, *(S1Iterator.Key()->CStructure()));
+ MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), S1Iterator.Key()->DisplayPriority());
} // end else
} // end if
return Visual3d_TOBM_DISABLE;
} // end Visual3d_View :: BackFacingModel
-#endif // G003
void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const
{
-#ifdef BUC61044
MyGraphicDriver->SetDepthTestEnabled( MyCView, enable );
-#endif
}
Standard_Boolean Visual3d_View::IsDepthTestEnabled() const
{
-#ifdef BUC61044
return MyGraphicDriver->IsDepthTestEnabled( MyCView );
-#else
- return Standard_True;
-#endif
}
void Visual3d_View::ReadDepths(const Standard_Integer x,
theWidth, theHeight );
}
-Standard_Boolean Visual3d_View::BufferDump (Image_CRawBufferData& theBuffer)
+Standard_Boolean Visual3d_View::BufferDump (Image_PixMap& theImage,
+ const Graphic3d_BufferType& theBufferType)
{
- return MyGraphicDriver->BufferDump( MyCView, theBuffer);
+ return MyGraphicDriver->BufferDump (MyCView, theImage, theBufferType);
}
void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
{
-#ifdef BUC61045
MyGraphicDriver->SetGLLightEnabled( MyCView, enable );
-#endif
}
Standard_Boolean Visual3d_View::IsGLLightEnabled() const
{
-#ifdef BUC61045
return MyGraphicDriver->IsGLLightEnabled( MyCView );
-#else
- return Standard_True;
-#endif
}
-void Visual3d_View::Export( const Standard_CString FileName,
- const Graphic3d_ExportFormat Format,
- const Graphic3d_SortType aSortType,
- const Standard_Real Precision,
- const Standard_Address ProgressBarFunc,
- const Standard_Address ProgressObject ) const
+Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName,
+ const Graphic3d_ExportFormat theFormat,
+ const Graphic3d_SortType theSortType,
+ const Standard_Real thePrecision,
+ const Standard_Address theProgressBarFunc,
+ const Standard_Address theProgressObject) const
{
- Handle( Visual3d_Layer ) AnUnderLayer = MyViewManager->UnderLayer(),
- AnOverLayer = MyViewManager->OverLayer();
+ Handle(Visual3d_Layer) anUnderLayer = MyViewManager->UnderLayer();
+ Handle(Visual3d_Layer) anOverLayer = MyViewManager->OverLayer();
- Aspect_CLayer2d OverCLayer;
- Aspect_CLayer2d UnderCLayer;
- OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
+ Aspect_CLayer2d anOverCLayer;
+ Aspect_CLayer2d anUnderCLayer;
+ anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
- if( !AnOverLayer.IsNull() )
- OverCLayer = AnOverLayer->CLayer();
- if( !AnUnderLayer.IsNull() )
- UnderCLayer = AnUnderLayer->CLayer();
+ if (!anOverLayer.IsNull())
+ anOverCLayer = anOverLayer->CLayer();
+ if (!anUnderLayer.IsNull())
+ anUnderCLayer = anUnderLayer->CLayer();
- Standard_Integer W, H;
- Window()->Size( W, H );
+ Standard_Integer aWidth, aHeight;
+ Window()->Size (aWidth, aHeight);
- MyGraphicDriver->Export( FileName, Format, aSortType, W, H, MyCView, UnderCLayer, OverCLayer,
- Precision, ProgressBarFunc, ProgressObject );
+ return MyGraphicDriver->Export (theFileName, theFormat, theSortType,
+ aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
+ thePrecision, theProgressBarFunc, theProgressObject);
+}
+
+//=======================================================================
+//function : SetZLayerSettings
+//purpose :
+//=======================================================================
+
+void Visual3d_View::SetZLayerSettings (const Standard_Integer theLayerId,
+ const Graphic3d_ZLayerSettings& theSettings)
+{
+ MyGraphicDriver->SetZLayerSettings (MyCView, theLayerId, theSettings);
+}
+
+//=======================================================================
+//function : AddZLayer
+//purpose :
+//=======================================================================
+
+void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
+{
+ MyGraphicDriver->AddZLayer (MyCView, theLayerId);
+}
+
+//=======================================================================
+//function : RemoveZLayer
+//purpose :
+//=======================================================================
+
+void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
+{
+ MyGraphicDriver->RemoveZLayer (MyCView, theLayerId);
+}
+
+//=======================================================================
+//function : ChangeZLayer
+//purpose :
+//=======================================================================
+
+void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
+ const Standard_Integer theLayerId)
+{
+ MyGraphicDriver->ChangeZLayer (*(theStructure->CStructure()), MyCView, theLayerId);
}