1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

1
src/V3d/EXTERNLIB Normal file
View File

@@ -0,0 +1 @@
CSF_FreeImagePlus

12
src/V3d/FILES Executable file
View File

@@ -0,0 +1,12 @@
EXTERNLIB
V3d_Static.hxx
V3d_View_1.cxx
V3d_View_2.cxx
V3d_View_3.cxx
V3d_View_4.cxx
V3d_Viewer_1.cxx
V3d_Viewer_2.cxx
V3d_Viewer_3.cxx
V3d_Viewer_4.cxx
V3d_View_Print.cxx
V3d_View_5.cxx

273
src/V3d/V3d.cdl Executable file
View File

@@ -0,0 +1,273 @@
--
-- Package: V3d.cdl
-- Author: GG
-- Created: Mercredi 22 Janvier 1992
-- Modified: stt:25-02-98; S3558: ajout ViewStdAdapter
-- ZOV - Mars 30 1998
-- stt:08-04-98; suppr. ViewStdAdapter
-- 16-09-98 ; BGN : Ajout TypeOfTriedronEcho,
-- TypeOfTriedronPosition.
-- 22-09-98; BGN: S3989 (anciennement S3819): report
-- dans Aspect des TypeOfTriedron*
---Copyright: MatraDatavision 1991,1992
--
-- Purpose: Specifications provisoires
--
--
-- Date: Vendredi 13 Novembre 1992
--
--
package V3d
---Purpose: This package contains the set of commands and services
-- of the 3D Viewer. It provides a set of high level commands
-- to control the views and viewing modes. This package is
-- complementary to the Visual3D graphic package.
-- Warning
-- The CSF_WALKTHROUGH variable enables you to
-- manage the perspective of the view in the viewer by
-- defining setenv CSF_WALKTHROUGH "Yes".
-- If you use the syntax unsetenv
-- CSF_WALKTHROUGH, you undefine the variable
-- (you make sure that the variable is deactivated). In
-- this case, the eye is located outside the 3D bounding
-- box of the view. This is the default behavior for
-- managing the view perspective.
uses
Viewer,
TColStd,
Graphic3d,
Visual3d,
MMgt,
TCollection,
Quantity,
Aspect,
PlotMgt,
Image,
gp,
OSD
is
------------------------------
---Category: The extern types
------------------------------
alias Coordinate is Length from Quantity;
---Purpose: User-defined coordinate in the reference plane of
-- view (Projection or Mapping).
alias Parameter is Parameter from Quantity;
--------------------------
--Category: The Exceptions
--------------------------
exception UnMapped inherits DomainError;
-----------------------------
---Category: The Enumerations
-----------------------------
enumeration TypeOfView is ORTHOGRAPHIC,PERSPECTIVE
end TypeOfView ;
---Purpose: Defines the type of projection of the view.
enumeration TypeOfShadingModel is COLOR,MULTICOLOR,FLAT,GOURAUD,HIDDEN
end TypeOfShadingModel ;
---Purpose:
-- Defines the type of shading for the graphic object:
-- - V3d_COLOR: simple surface color,
-- - V3d_MULTICOLOR: interpolated colors,
-- - V3d_FLAT: flat shading,
-- - V3d_GOURAUD: Gouraud shading,
-- - V3d_HIDDEN: hidden line removal.
enumeration TypeOfSurfaceDetail is TEX_NONE, TEX_ENVIRONMENT, TEX_ALL
end TypeOfSurfaceDetail;
---Purpose: Modes of visualization for objects in a view
-- - V3d_TEX_NONE: no texture mapping,
-- - V3d_TEX_ENVIRONMENT: environment mapping only,
-- - V3d_TEX_ALL: environment and texture mapping.
enumeration TypeOfVisualization is WIREFRAME,ZBUFFER
end TypeOfVisualization ;
---Purpose: Determines the type of visualization in the view, either
-- WIREFRAME or ZBUFFER (shading).
enumeration TypeOfZclipping is OFF,BACK,FRONT,SLICE
-- Type "BACK" Remove rear part
-- Type "FRONT" Remove front part
-- "SLICE" Keep the slice between the front plane
-- plane depth + half the thickness
-- and the rear plane
-- plane depth - half the thickness.
-- "OFF" ZClipping deactivated.
end TypeOfZclipping ;
---Purpose: The available options are
-- - V3d_OFF: Zclipping (clipping executed in the
-- depth of the view) is deactivated,
-- - V3d_BACK: back Zclipping is activated,
-- - V3d_FRONT: front Zclipping is activated,
-- - V3d_SLICE: both front and back Zclippings are activated.
enumeration TypeOfLight is AMBIENT,DIRECTIONAL,POSITIONAL,SPOT
end TypeOfLight ;
---Purpose: Determines the type of light.
enumeration TypeOfUpdate is ASAP,WAIT
end TypeOfUpdate ;
---Purpose: Determines the type of update of the view
-- - V3d_ASAP: as soon as possible. The view is updated immediately after a modification.
-- - V3d_WAIT: deferred. The view is updated when the Update function is called.
enumeration TypeOfAxe is X,Y,Z
end TypeOfAxe ;
---Purpose: Determines the axis type through the coordinates X, Y, Z.
enumeration TypeOfOrientation is Xpos,Ypos,Zpos,Xneg,Yneg,Zneg,
XposYpos,XposZpos,YposZpos,XnegYneg,XnegYpos,XnegZneg,
XnegZpos,YnegZneg,YnegZpos,XposYneg,XposZneg,YposZneg,
XposYposZpos,XposYnegZpos,XposYposZneg,XnegYposZpos,
XposYnegZneg,XnegYposZneg,XnegYnegZpos,XnegYnegZneg
end TypeOfOrientation ;
---Purpose: Determines the type of orientation.
enumeration TypeOfRepresentation is SIMPLE,COMPLETE,PARTIAL,SAMELAST
end TypeOfRepresentation;
enumeration TypeOfPickLight is POSITIONLIGHT,SPACELIGHT,
RADIUSTEXTLIGHT,ExtRADIUSLIGHT,IntRADIUSLIGHT,
NOTHING
end TypeOfPickLight;
enumeration TypeOfPickCamera is POSITIONCAMERA,SPACECAMERA,
RADIUSTEXTCAMERA,ExtRADIUSCAMERA,IntRADIUSCAMERA,
NOTHINGCAMERA
end TypeOfPickCamera;
enumeration TypeOfProjectionModel is
TPM_SCREEN,TPM_WALKTHROUGH
end TypeOfProjectionModel;
enumeration TypeOfBackfacingModel is
TOBM_AUTOMATIC, TOBM_ALWAYS_DISPLAYED, TOBM_NEVER_DISPLAYED
end TypeOfBackfacingModel;
---Purpose : Modes of display of back faces in the view
--
-- TOBM_AUTOMATIC graphic's structure setting is in use
-- TOBM_ALWAYS_DISPLAYED force display of back faces
-- TOBM_NEVER_DISPLAYED disable display of back faces
------------------------
---Category: The classes
------------------------
class Viewer;
---Purpose: Provides the services of a 3D viewer.
deferred class View;
---Purpose: Provides a set of services common to all types of view.
class OrthographicView;
---Purpose: Services of an orthogonal view.
class PerspectiveView;
---Purpose: Services of a perspective view.
class LayerMgr;
---Purpose: Services of layer management.
deferred class Light;
---Purpose: Provides services common to all types of luminous source.
-- (base class for AmbientLight and PositionLight)
class AmbientLight;
---Purpose: Services of ambient light sources.
deferred class PositionLight;
---Purpose: Provides services common to Positional,Directional,Spot Lights.
class PositionalLight;
---Purpose: Services of positional light sources.
class DirectionalLight;
---Purpose: Services of directional light sources.
class SpotLight;
---Purpose: Services of spot light sources.
class Camera;
---Purpose: Services of camera, edition tool of view.
class Plane;
---Pupose: Services of any kind of clipping plane.
---------------------------------
---Category: Instantiated classes
---------------------------------
private class ListOfTransient;
pointer ViewerPointer to Viewer from V3d;
pointer ViewPointer to View from V3d;
pointer LayerMgrPointer to LayerMgr from V3d;
private class RectangularGrid;
private class CircularGrid;
private class ColorScale;
private class ColorScaleLayerItem;
---------------------------------
---Category: Methodes de package
---------------------------------
GetProjAxis( Orientation : TypeOfOrientation )
returns Vector from Graphic3d ;
---Purpose: Determines the orientation vector corresponding
-- to the predefined orientation type.
ArrowOfRadius ( garrow : mutable Group from Graphic3d;
X0,Y0,Z0 : Coordinate;
DX,DY,DZ : Parameter;
Alpha : PlaneAngle from Quantity;
Lng : Parameter ) is protected;
---Level: Advanced
---Purpose: Compute the graphic structure of arrow.
-- X0,Y0,Z0 : coordinate of the arrow.
-- DX,DY,DZ : Direction of the arrow.
-- Alpha : Angle of arrow.
-- Lng : Length of arrow.
CircleInPlane ( gcircle : mutable Group from Graphic3d;
X0,Y0,Z0 : Coordinate;
VX,VY,VZ : Parameter;
Radius : Parameter ) is protected;
---Level: Advanced
---Purpose: Compute the graphic structure of circle.
-- X0,Y0,Z0 : Center of circle.
-- VX,VY,VZ : Axis of circle.
-- Radius : Radius of circle.
SwitchViewsinWindow(aPreviousView: View from V3d;
aNextView: View from V3d);
DrawSphere(aViewer: Viewer from V3d; aRadius: Length from Quantity =1000);
---Purpose: test.
PickGrid(aViewer: Viewer from V3d; aRadius: Length from Quantity =1000);
---Purpose: test.
SetPlane(aViewer: Viewer from V3d; x1,y1,z1,x2,y2,z2: Length from Quantity);
---Purpose: test.
end V3d;

334
src/V3d/V3d.cxx Executable file
View File

@@ -0,0 +1,334 @@
// File V3d.cxx
// Created September 1992
// Author GG
// Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI
// 02.15.100 : JR : Clutter
//-Copyright MatraDatavision 1991,1992
//-Version
//-Design
//-Warning
//-References
//-Language C++ 2.1
//-Declarations
// for the class
#include <V3d.ixx>
#include <V3d_View.hxx>
#include <Quantity_NameOfColor.hxx>
#include <Aspect_Grid.hxx>
#include <Aspect_Window.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Visual3d_HSetOfView.hxx>
#include <Visual3d_SetIteratorOfSetOfView.hxx>
#include <Visual3d_View.hxx>
#include <Visual3d_ViewManager.hxx>
Graphic3d_Vector V3d::GetProjAxis(const V3d_TypeOfOrientation Orientation) {
Standard_Real Xpn=0,Ypn=0,Zpn=0 ;
Graphic3d_Vector Vec ;
switch (Orientation) {
case V3d_Xpos :
Xpn = 1. ; Ypn = 0. ; Zpn = 0. ;
break ;
case V3d_Ypos :
Xpn = 0. ; Ypn = 1. ; Zpn = 0. ;
break ;
case V3d_Zpos :
Xpn = 0. ; Ypn = 0. ; Zpn = 1. ;
break ;
case V3d_Xneg :
Xpn = -1. ; Ypn = 0. ; Zpn = 0. ;
break ;
case V3d_Yneg :
Xpn = 0. ; Ypn = -1. ; Zpn = 0. ;
break ;
case V3d_Zneg :
Xpn = 0. ; Ypn = 0. ; Zpn = -1. ;
break ;
case V3d_XposYposZpos :
Xpn = 1. ; Ypn = 1. ; Zpn = 1. ;
break ;
case V3d_XposYposZneg :
Xpn = 1. ; Ypn = 1. ; Zpn = -1. ;
break ;
case V3d_XposYnegZpos :
Xpn = 1. ; Ypn = -1. ; Zpn = 1. ;
break ;
case V3d_XposYnegZneg :
Xpn = 1. ; Ypn = -1. ; Zpn = -1. ;
break ;
case V3d_XnegYposZpos :
Xpn = -1. ; Ypn = 1. ; Zpn = 1. ;
break ;
case V3d_XnegYposZneg :
Xpn = -1. ; Ypn = 1. ; Zpn = -1. ;
break ;
case V3d_XnegYnegZpos :
Xpn = -1. ; Ypn = -1. ; Zpn = 1. ;
break ;
case V3d_XnegYnegZneg :
Xpn = -1. ; Ypn = -1. ; Zpn = -1. ;
break ;
case V3d_XposYpos :
Xpn = 1. ; Ypn = 1. ; Zpn = 0. ;
break ;
case V3d_XposYneg :
Xpn = 1. ; Ypn = -1. ; Zpn = 0. ;
break ;
case V3d_XnegYpos :
Xpn = -1. ; Ypn = 1. ; Zpn = 0. ;
break ;
case V3d_XnegYneg :
Xpn = -1. ; Ypn = -1. ; Zpn = 0. ;
break ;
case V3d_XposZpos :
Xpn = 1. ; Ypn = 0. ; Zpn = 1. ;
break ;
case V3d_XposZneg :
Xpn = 1. ; Ypn = 0. ; Zpn = -1. ;
break ;
case V3d_XnegZpos :
Xpn = -1. ; Ypn = 0. ; Zpn = 1. ;
break ;
case V3d_XnegZneg :
Xpn = -1. ; Ypn = 0. ; Zpn = -1. ;
break ;
case V3d_YposZpos :
Xpn = 0. ; Ypn = 1. ; Zpn = 1. ;
break ;
case V3d_YposZneg :
Xpn = 0. ; Ypn = 1. ; Zpn = -1. ;
break ;
case V3d_YnegZpos :
Xpn = 0. ; Ypn = -1. ; Zpn = 1. ;
break ;
case V3d_YnegZneg :
Xpn = 0. ; Ypn = -1. ; Zpn = -1. ;
break ;
}
Vec.SetCoord(Xpn,Ypn,Zpn) ; Vec.Normalize() ;
return Vec ;
}
void V3d::ArrowOfRadius(const Handle(Graphic3d_Group)& garrow,const Standard_Real X0,const Standard_Real Y0,const Standard_Real Z0,const Standard_Real Dx,const Standard_Real Dy,const Standard_Real Dz,const Standard_Real Alpha,const Standard_Real Lng) {
Standard_Real Xc,Yc,Zc,Xi,Yi,Zi,Xj,Yj,Zj;
Standard_Real Xn,Yn,Zn,X,Y,Z,Norme;
Standard_Integer NbPoints = 10, i;
Graphic3d_Array1OfVertex VN(1,NbPoints+1);
Graphic3d_Array1OfVertex V2(1,2);
// Centre du cercle base de la fleche :
Xc = X0 - Dx * Lng;
Yc = Y0 - Dy * Lng;
Zc = Z0 - Dz * Lng;
// Construction d'un repere i,j pour le cercle:
Xn=0., Yn=0., Zn=0.;
if ( Abs(Dx) <= Abs(Dy) && Abs(Dx) <= Abs(Dz)) Xn=1.;
else if ( Abs(Dy) <= Abs(Dz) && Abs(Dy) <= Abs(Dx)) Yn=1.;
else Zn=1.;
Xi = Dy * Zn - Dz * Yn;
Yi = Dz * Xn - Dx * Zn;
Zi = Dx * Yn - Dy * Xn;
Norme = Sqrt ( Xi*Xi + Yi*Yi + Zi*Zi );
Xi= Xi / Norme; Yi = Yi / Norme; Zi = Zi/Norme;
Xj = Dy * Zi - Dz * Yi;
Yj = Dz * Xi - Dx * Zi;
Zj = Dx * Yi - Dy * Xi;
V2(1).SetCoord(X0,Y0,Z0);
Standard_Real cosinus,sinus, Tg=Tan(Alpha);
for (i = 1 ; i <= NbPoints ; i++) {
cosinus = Cos ( 2 * Standard_PI / NbPoints * (i-1) );
sinus = Sin ( 2 * Standard_PI / NbPoints * (i-1) );
X = Xc + (cosinus * Xi + sinus * Xj) * Lng * Tg;
Y = Yc + (cosinus * Yi + sinus * Yj) * Lng * Tg;
Z = Zc + (cosinus * Zi + sinus * Zj) * Lng * Tg;
VN(i).SetCoord(X,Y,Z);
if(i==1) VN(NbPoints+1).SetCoord(X,Y,Z);
V2(2).SetCoord(X,Y,Z);
garrow->Polyline(V2);
}
garrow->Polyline(VN);
}
void V3d::CircleInPlane(const Handle(Graphic3d_Group)& gcircle,const Standard_Real X0,const Standard_Real Y0,const Standard_Real Z0,const Standard_Real DX,const Standard_Real DY,const Standard_Real DZ,const Standard_Real Rayon) {
Standard_Real VX,VY,VZ,X,Y,Z,Xn,Yn,Zn,Xi,Yi,Zi,Xj,Yj,Zj,Norme;
Standard_Integer NFACES = 30 , i;
Standard_Real Alpha = 0. ;
Standard_Real Dalpha = 2.*Standard_PI/NFACES ;
Graphic3d_Array1OfVertex Points(0,NFACES);
Norme = Sqrt ( DX*DX + DY*DY + DZ*DZ );
if ( Norme >= 0.0001 ) {
VX= DX/Norme; VY = DY/Norme; VZ = DZ/Norme;
//Construction d'un repere i,j pour le cercle:
Xn=0., Yn=0., Zn=0.;
if ( Abs(VX) <= Abs(VY) && Abs(VX) <= Abs(VZ)) Xn=1.;
else if ( Abs(VY) <= Abs(VZ) && Abs(VY) <= Abs(VX)) Yn=1.;
else Zn=1.;
Xi = VY * Zn - VZ * Yn;
Yi = VZ * Xn - VX * Zn;
Zi = VX * Yn - VY * Xn;
Norme = Sqrt ( Xi*Xi + Yi*Yi + Zi*Zi );
Xi= Xi / Norme; Yi = Yi / Norme; Zi = Zi/Norme;
Xj = VY * Zi - VZ * Yi;
Yj = VZ * Xi - VX * Zi;
Zj = VX * Yi - VY * Xi;
for (i = 0 ; i <= NFACES ; i++) {
X = X0 + (Cos(Alpha) * Xi + Sin(Alpha) * Xj) * Rayon;
Y = Y0 + (Cos(Alpha) * Yi + Sin(Alpha) * Yj) * Rayon;
Z = Z0 + (Cos(Alpha) * Zi + Sin(Alpha) * Zj) * Rayon;
Alpha +=Dalpha;
Points(i).SetCoord(X,Y,Z);
}
gcircle->Polyline(Points);
}
}
void V3d::SwitchViewsinWindow(const Handle(V3d_View)& aPreviousView,
const Handle(V3d_View)& aNextView) {
aPreviousView->Viewer()->SetViewOff(aPreviousView);
if(!aNextView->IfWindow())
aNextView->SetWindow(aPreviousView->Window());
aNextView->Viewer()->SetViewOn(aNextView);
}
void V3d::DrawSphere(const Handle(V3d_Viewer)& aViewer,const Quantity_Length ray) {
Standard_Boolean inf = ray < 0;
Standard_Real aRadius = Abs(ray);
Handle(Graphic3d_Structure) Struct = new Graphic3d_Structure(aViewer->Viewer()) ;
Handle(Graphic3d_Group) Group = new Graphic3d_Group(Struct) ;
Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d() ;
LineAttrib->SetColor(Quantity_Color(Quantity_NOC_YELLOW));
Struct->SetPrimitivesAspect(LineAttrib) ;
Standard_Integer NFACES = 30;
Graphic3d_Array1OfVertex Points(0,NFACES) ;
Standard_Real R,X,Y,Z ;
Standard_Real Beta = 0. ;
Standard_Real Alpha = 0. ;
Standard_Real Dbeta = 2.*Standard_PI/NFACES ;
Standard_Real Dalpha = 2.*Standard_PI/NFACES ;
Standard_Integer i,j ;
for( j=0 ; j<NFACES/2 ; j++ ) {
Alpha = 0. ;
R = aRadius*sin(Beta) ;
Z = aRadius*cos(Beta) ;
Beta += Dbeta ;
for( i=0 ; i<NFACES ; i++ ) {
X = R*cos(Alpha) ;
Y = R*sin(Alpha) ;
Alpha += Dalpha ;
Points(i).SetCoord(X,Y,Z);
}
Points(0).Coord(X,Y,Z) ;
Points(NFACES).SetCoord(X,Y,Z) ;
Group->Polyline(Points) ;
}
for( j=0 ; j<NFACES/2 ; j++ ) {
Alpha = 0. ;
R = aRadius*sin(Beta) ;
Y = aRadius*cos(Beta) ;
Beta += Dbeta ;
for( i=0 ; i<NFACES ; i++ ) {
X = R*cos(Alpha) ;
Z = R*sin(Alpha) ;
Alpha += Dalpha ;
Points(i).SetCoord(X,Y,Z);
}
Points(0).Coord(X,Y,Z) ;
Points(NFACES).SetCoord(X,Y,Z) ;
Group->Polyline(Points) ;
}
if(inf) Struct->SetInfiniteState(Standard_True);
Struct->Display();
aViewer->Update();
}
void V3d::SetPlane(const Handle(V3d_Viewer)& aViewer,
const Standard_Real x1,
const Standard_Real y1,
const Standard_Real z1,
const Standard_Real x2,
const Standard_Real y2,
const Standard_Real z2) {
gp_Ax3 a(gp_Pnt(0.,0.,0),gp_Dir(x1,y1,z1),gp_Dir(x2,y2,z2));
aViewer->SetPrivilegedPlane(a);
}
void V3d::PickGrid(const Handle(V3d_Viewer)& aViewer,
// const Quantity_Length ray) {
const Quantity_Length ) {
Standard_Real x1, y1, z1;
Standard_Real x2, y2, z2;
cout << "Direction ? " << flush;
cin >> x1; cin >> y1; cin >> z1;
cout << "XDirection ? " << flush;
cin >> x2; cin >> y2; cin >> z2;
Standard_Integer u, v;
cout << "u, v ? " << flush;
cin >> u; cin >> v;
V3d::SetPlane (aViewer, x1, y1, z1, x2, y2, z2);
// Pour relancer le calcul selon le nouveau plan
if (aViewer->Grid ()->IsActive ()) {
Standard_Real xo, yo;
Quantity_PlaneAngle angle;
switch (aViewer->GridType ()) {
case Aspect_GT_Rectangular :
Standard_Real xstep, ystep;
aViewer->RectangularGridValues
(xo, yo, xstep, ystep, angle);
aViewer->SetRectangularGridValues
(xo, yo, xstep, ystep, angle);
break;
case Aspect_GT_Circular :
Standard_Real radiusstep;
Standard_Integer division;
aViewer->CircularGridValues
(xo, yo, radiusstep, division, angle);
aViewer->SetCircularGridValues
(xo, yo, radiusstep, division, angle);
break;
}
}
for (aViewer->InitActiveViews ();
aViewer->MoreActiveViews ();
aViewer->NextActiveViews()) {
Standard_Real X, Y, Z;
aViewer->ActiveView ()->Convert (u, v, X, Y, Z);
}
}

35
src/V3d/V3d_AmbientLight.cdl Executable file
View File

@@ -0,0 +1,35 @@
-- File: AmbientLight.cdl
-- Created: Tue Jan 21 18:24:40 1992
-- Author: GG
-- Update: FDA Oct 15 1994,
-- ZOV - Mars 30 1998
---Copyright: Matra Datavision 1992
class AmbientLight from V3d
---Purpose: Creation of an ambient light source in a viewer.
inherits Light from V3d
uses
Viewer from V3d,
TypeOfRepresentation from V3d,
NameOfColor from Quantity,
View from V3d,
Coordinate from V3d,
Structure from Graphic3d,
Vertex from Graphic3d,
Group from Graphic3d
is
Create ( VM : mutable Viewer ;
Color : NameOfColor = Quantity_NOC_WHITE )
returns mutable AmbientLight;
---Purpose: Constructs an ambient light source in the viewer VM.
-- The default Color of this light source is WHITE.
end AmbientLight;

18
src/V3d/V3d_AmbientLight.cxx Executable file
View File

@@ -0,0 +1,18 @@
// File V3d_AmbientLight.cxx
// Created September 1992
// Modified 30-03-98 : ZOV ; PRO6774 (reconstruction of the class hierarchy and suppressing useless methods)
// Author GG
//-Copyright MatraDatavision 1991,1992
#include <V3d.hxx>
#include <V3d_AmbientLight.ixx>
#include <Visual3d_Light.hxx>
V3d_AmbientLight::V3d_AmbientLight(const Handle(V3d_Viewer)& VM, const Quantity_NameOfColor Name):V3d_Light(VM) {
Quantity_Color C(Name) ;
MyType = V3d_AMBIENT ;
MyLight = new Visual3d_Light(C) ;
}

221
src/V3d/V3d_Camera.cdl Executable file
View File

@@ -0,0 +1,221 @@
-- File: Camera.cdl
-- Created: Thu Oct 20 10:14:50 1994
-- Author: FDA
---Copyright: Matra Datavision 1994
class Camera from V3d
---Version:
---Purpose: Creation and modification of a spot.
---Keywords:
---Warning:
---References:
inherits
TShared
uses
TypeOfOrientation from V3d,
TypeOfRepresentation from V3d,
TypeOfPickCamera from V3d,
Coordinate from V3d,
PlaneAngle from Quantity,
Coefficient from Quantity,
Parameter from Quantity,
View from V3d,
Structure from Graphic3d,
Vertex from Graphic3d,
Group from Graphic3d
raises BadValue from Viewer
is
Create ( aView : View from V3d ) returns mutable Camera;
---Level: Public
---Purpose: Creates the camera which relatives of View
-----------------------------------------------------------
---Category: Methods to modify the Attributes of the camera
-----------------------------------------------------------
SetPosition ( me : mutable; X,Y,Z : Coordinate ) is static;
---Level: Public
---Purpose: Defines the position of the camera. .
SetAngle ( me : mutable; Angle : PlaneAngle )
---Level: Public
---Purpose: Defines the angular position of camera.
raises BadValue from Viewer
---Purpose: Warning! raises BadValue from Viewer if Abs(Angle) > 2*PI;
-- If the angle is <= 0 ou > PI .
is static;
SetAperture ( me : mutable; Angle : PlaneAngle )
---Level: Public
---Purpose: Defines the Aperture.
raises BadValue from Viewer
---Purpose: Warning! raises BadValue from Viewer if angle <= 0 or > PI
is static;
SetTarget (me : mutable; X,Y,Z : Coordinate)
---Level: Public
---Purpose: Defines the target of the camera.
is static;
SetRadius ( me : mutable; Radius : Parameter)
---Level: Public
---Purpose: Define the radius.
raises BadValue from Viewer
---Purpose: Warning! raises BadValue from Viewer if radius <= 0 .
is static;
OnHideFace (me : mutable; aView : View from V3d) is static;
---Level: Public
---Purpose: Calculate the position of the camera, on the hide face
-- of the picking sphere.
OnSeeFace (me : mutable; aView : View from V3d) is static;
---Level: Public
---Purpose: Calculate the position of the camera, on the seen face
-- of the picking sphere.
Tracking (me : mutable; aView : View from V3d;
WathPick : TypeOfPickCamera from V3d;
Xpix,Ypix : Integer from Standard) is static;
---Level: Public
---Purpose: Tracking the camera position, or the picking sphere,
-- or the radius of the picking sphere, that depends of
-- initial picking "WhatPick" (see the pick method).
-- If WhatPick is SPACECAMERA, then the parameters
-- Xpix, Ypix are the coordinates of a translation vector.
AerialPilot (me : mutable; aView : View from V3d;
Xpix,Ypix : Integer from Standard) is static;
---Level: Public
---Purpose: Permits the driving of the camera in aerial mode.
-- The user believes fly in plane ...
EarthPilot (me : mutable; aView : View from V3d;
Xpix,Ypix : Integer from Standard) is static;
---Level: Public
---Purpose: Permits the driving of the camera in earth mode.
-- The user believes drive a car ...
Move (me : mutable; Dist : Parameter) is static;
---Level: Public
---Purpose: The camera move or move back in the direction camera,
-- target of camera.
GoUp (me : mutable; Haut : Parameter) is static;
---Level: Public
---Purpose: The camera go up or go down on the z axis,
-- the direction of camera is the same.
---------------------------------------------------
---Category: display methods
---------------------------------------------------
Display(me: mutable; aView: View from V3d;
Representation : TypeOfRepresentation)
is static;
---Level: Public
---Purpose: Display the graphic structure of camera
-- in the choosen view. We have two types of representation.
-- - SIMPLE : Only the camera position is displayed.
-- - COMPLETE : The position camera, the picking sphere and
-- the radius of sphere are displayed.
Erase(me: mutable) is static;
---Level: Public
---Purpose: Erase the graphic structure of camera.
---------------------------------------------------
---Category: Inquire methods
---------------------------------------------------
Position ( me; X,Y,Z : out Coordinate ) is static;
---Level: Public
---Purpose : Returns the position of the camera.
Target ( me; X,Y,Z : out Coordinate) is static;
---Level: Public
---Purpose: Returns the position of the target of camera.
Angle ( me ) returns PlaneAngle is static;
---Level: Public
---Purpose: Returns the angle.
Aperture ( me ) returns PlaneAngle is static;
---Level: Public
---Purpose: Returns the Aperture.
Radius (me ) returns Parameter is static;
---Level: Public
---Purpose: Returns the radius of the picking sphere.
SeeOrHide (me; aView: View from V3d) returns Boolean is static;
---Level: Public
---Purpose: Returns a Boolean on the status seen or hidden of the
-- camera.
-- If True the camera has seen.
-- If False the camera has hidden.
Pick ( me; aView: View from V3d; Xpix, Ypix: Integer from Standard)
returns TypeOfPickCamera from V3d is static;
---Level: Public
---Purpose: Returns the type of pick element.
-- "POSITIONCAMERA" : Representation of camera position.
-- "SPACECAMERA" : Representation of picking sphere.
-- "ExtRADIUSCAMERA" : Representation of extern arrow.
-- "IntRADIUSCAMERA" : Representation of intern arrow.
-- "RADIUSTEXTCAMERA": Representation of radius value.
-- "NOTHINGCAMERA" : Any component of camera.
-- Determinate which type of tracking apply.
-----------------------------------------
---Category: Private or Protected methods
-----------------------------------------
Symbol ( me ; gsymbol : mutable Group from Graphic3d ;
aView : View from V3d ) is static private;
---Level: Internal
---Purpose: Defined the representation of camera position.
SymetricPointOnSphere ( myclass ; aView : View from V3d;
Center : Vertex from Graphic3d;
aPoint : Vertex from Graphic3d;
Radius : Parameter;
X,Y,Z : out Coordinate;
VX,VY,VZ : out Parameter )
is private ;
---Level: Internal
---Purpose: Returns the symetric point coordinates of "aPoint"
-- on the sphere of center "Center" and radius "Radius".
-- VX,VY,VZ is the project vector of view.
fields
MyPosition: Vertex from Graphic3d;
MyTarget: Vertex from Graphic3d;
MyAngle: PlaneAngle from Quantity;
MyAperture: PlaneAngle from Quantity;
MyGraphicStructure: Structure from Graphic3d;
MyGraphicStructure1: Structure from Graphic3d;
MyTypeOfRepresentation: TypeOfRepresentation from V3d;
end Camera;

839
src/V3d/V3d_Camera.cxx Executable file
View File

@@ -0,0 +1,839 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_Camera :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
18-06-96 : FMN ; Ajout MyGraphicStructure1 pour sauvegarder snopick
24-12-97 : FMN ; Remplacement de math par MathGra
31-12-97 : CAL ; Suppression de MathGra
21-01-98 : CAL ; Window de Xw et WNT remplacee par Aspect_Window
23-02-98 : FMN ; Remplacement PI par Standard_PI
02.15.100 : JR : Clutter
************************************************************************/
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_Camera.ixx>
#include <V3d.hxx>
#include <V3d_PerspectiveView.hxx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Visual3d_ViewManager.hxx>
#include <Visual3d_ContextPick.hxx>
#include <Visual3d_PickDescriptor.hxx>
#include <Visual3d_HSequenceOfPickPath.hxx>
#include <Visual3d_PickPath.hxx>
#include <Viewer_BadValue.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <TCollection_AsciiString.hxx>
#include <Aspect_Window.hxx>
//-Declarations
#define DEUXPI (2.*Standard_PI)
//-Constructors
V3d_Camera::V3d_Camera(const Handle(V3d_View)& aView) {
Standard_Real X,Y,Z;
Graphic3d_Vertex P,T;
// Le point oeil definit la position de la camera
aView->Eye(X,Y,Z);
P.SetCoord(X,Y,Z);
MyPosition = P;
// Le point vise definit la cible de la camera
aView->At(X,Y,Z);
T.SetCoord(X,Y,Z);
MyTarget = T;
// Angle d'inclinaison de la camera
MyAngle = aView->Twist();
// Angle d'ouverture de la camera
MyAperture = (aView->DynamicType()==STANDARD_TYPE(V3d_PerspectiveView)) ?
((Handle(V3d_PerspectiveView)&)aView)->Angle() : 0.;
}
//-Methods, in order
void V3d_Camera::SetPosition(const Standard_Real Xp, const Standard_Real Yp, const Standard_Real Zp) {
MyPosition.SetCoord(Xp,Yp,Zp) ;
}
void V3d_Camera::SetAngle(const Standard_Real Angle) {
Viewer_BadValue_Raise_if( Abs(Angle) > DEUXPI, "V3d_Camera::SetAngle, bad angle" );
MyAngle = Angle ;
}
void V3d_Camera::SetAperture(const Standard_Real Angle) {
Viewer_BadValue_Raise_if( Angle <= 0. || Angle >= Standard_PI ,"V3d_Camera::SetAperture, bad angle");
MyAperture = Angle ;
}
void V3d_Camera::SetTarget(const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
MyTarget.SetCoord(X,Y,Z);
}
void V3d_Camera::SetRadius(const Standard_Real Radius) {
Viewer_BadValue_Raise_if( Radius <= 0., "V3d_Camera::SetRadius, bad radius");
Standard_Real X0,Y0,Z0,Xn,Yn,Zn;
// Le point cible reste inchange, seul la position de la camera est modifiee
// en conservant la direction.
Graphic3d_Vector D(MyTarget,MyPosition);
D.Normalize();
D.Coord(Xn,Yn,Zn);
MyTarget.Coord(X0,Y0,Z0);
Xn = X0 + Radius*Xn;
Yn = Y0 + Radius*Yn;
Zn = Z0 + Radius*Zn;
MyPosition.SetCoord(Xn,Yn,Zn) ;
}
void V3d_Camera::OnHideFace(const Handle(V3d_View)& aView) {
Standard_Real XP,YP,ZP,Rayon,X,Y,Z,VX,VY,VZ;
Rayon = this->Radius();
MyPosition.Coord(XP,YP,ZP);
SymetricPointOnSphere(aView,MyTarget,MyPosition,Rayon,X,Y,Z,VX,VY,VZ);
// Actuellement est on sur le point vu
if ( (VX*(X-XP) < 0.) && (VY*(Y-YP) < 0.) && (VZ*(Z-ZP) < 0.) ) {
this->SetPosition(X,Y,Z);
}
}
void V3d_Camera::OnSeeFace(const Handle(V3d_View)& aView) {
Standard_Real XP,YP,ZP,Rayon,X,Y,Z,VX,VY,VZ;
Rayon = this->Radius();
MyPosition.Coord(XP,YP,ZP);
SymetricPointOnSphere(aView,MyTarget,MyPosition,Rayon,X,Y,Z,VX,VY,VZ);
// Actuellement est on sur le point cache
if ( (VX*(X-XP) > 0.) && (VY*(Y-YP) > 0.) && (VZ*(Z-ZP) > 0.) ) {
this->SetPosition(X,Y,Z);
}
}
Standard_Boolean V3d_Camera::SeeOrHide(const Handle(V3d_View)& aView) const {
Standard_Real XP,YP,ZP,Rayon,X,Y,Z,VX,VY,VZ;
Standard_Boolean Val;
Rayon = this->Radius();
MyPosition.Coord(XP,YP,ZP);
SymetricPointOnSphere(aView,MyTarget,MyPosition,Rayon,X,Y,Z,VX,VY,VZ);
// Avons nous le point cache ou le point vu
if ( (VX*(X-XP) > 0.) || (VY*(Y-YP) > 0.) || (VZ*(Z-ZP) > 0.) )
// la source est sur la face cachee
Val = Standard_False;
else
// la source est sur la face vue.
Val = Standard_True;
return Val;
}
void V3d_Camera::Position(Standard_Real& Xp, Standard_Real& Yp, Standard_Real& Zp)const {
MyPosition.Coord(Xp,Yp,Zp) ;
}
Standard_Real V3d_Camera::Angle()const {
return MyAngle ;
}
Standard_Real V3d_Camera::Aperture()const {
return MyAperture ;
}
void V3d_Camera::Target(Standard_Real& Xp, Standard_Real& Yp, Standard_Real& Zp)const {
// Graphic3d_Vertex P ;
MyTarget.Coord(Xp,Yp,Zp) ;
}
Standard_Real V3d_Camera::Radius() const {
Standard_Real Xp,Yp,Zp,Xc,Yc,Zc,Radius;
MyPosition.Coord(Xp,Yp,Zp);
MyTarget.Coord(Xc,Yc,Zc);
Radius = Square(Xc - Xp) + Square(Yc - Yp) + Square(Zc - Zp);
Radius = Sqrt(Radius);
return Radius ;
}
void V3d_Camera::Symbol (const Handle(Graphic3d_Group)& gsymbol,
// const Handle(V3d_View)& aView) const {
const Handle(V3d_View)& ) const {
Standard_Real X0,Y0,Z0,XP,YP,ZP,Dx,Dy,Dz,Lng;
Standard_Real Xc1,Yc1,Zc1,Xc2,Yc2,Zc2,Xi,Yi,Zi,Xj,Yj,Zj;
Standard_Real Xn,Yn,Zn,X,Y,Z,Norme;
Standard_Real cosinus,sinus;
Standard_Real Alpha = Standard_PI/4.;
Standard_Integer NbPoints = 4, i;
Graphic3d_Array1OfVertex VN1(1,NbPoints+1);
Graphic3d_Array1OfVertex VN2(1,NbPoints+1);
Graphic3d_Array1OfVertex V2(1,2);
// Direction de la camera
MyPosition.Coord(XP,YP,ZP);
MyTarget.Coord(X0,Y0,Z0);
Dx = X0 - XP; Dy = Y0 - YP; Dz = Z0 - ZP;
Lng = this->Radius()/10.;
// Recherche des centres des carres de base du boitier de la camera :
Xc1 = XP - Dx * Lng; Yc1 = YP - Dy * Lng; Zc1 = ZP - Dz * Lng;
Xc2 = XP + Dx * Lng; Yc2 = YP + Dy * Lng; Zc2 = ZP + Dz * Lng;
// Construction d'un repere i,j pour les rectangles :
Xn=0., Yn=0., Zn=0.;
if ( Abs(Dx) <= Abs(Dy) && Abs(Dx) <= Abs(Dz)) Xn=1.;
else if ( Abs(Dy) <= Abs(Dz) && Abs(Dy) <= Abs(Dx)) Yn=1.;
else Zn=1.;
Xi = Dy * Zn - Dz * Yn;
Yi = Dz * Xn - Dx * Zn;
Zi = Dx * Yn - Dy * Xn;
Norme = Sqrt ( Xi*Xi + Yi*Yi + Zi*Zi );
Xi= Xi / Norme; Yi = Yi / Norme; Zi = Zi/Norme;
Xj = Dy * Zi - Dz * Yi;
Yj = Dz * Xi - Dx * Zi;
Zj = Dx * Yi - Dy * Xi;
// Dessin du boitier
for (i = 1 ; i <= NbPoints ; i++) {
cosinus = Cos ( Alpha + (i - 1) * Standard_PI/2. );
sinus = Sin ( Alpha + (i - 1) * Standard_PI/2. );
// Premier carre de base
X = Xc1 + (cosinus * Xi + sinus * Xj) * Lng / 2.;
Y = Yc1 + (cosinus * Yi + sinus * Yj) * Lng / 2.;
Z = Zc1 + (cosinus * Zi + sinus * Zj) * Lng / 2.;
VN1(i).SetCoord(X,Y,Z);
if(i==1) VN1(NbPoints+1).SetCoord(X,Y,Z);
V2(1).SetCoord(X,Y,Z);
// Second carre de base
X = Xc2 + (cosinus * Xi + sinus * Xj) * Lng / 2.;
Y = Yc2 + (cosinus * Yi + sinus * Yj) * Lng / 2.;
Z = Zc2 + (cosinus * Zi + sinus * Zj) * Lng / 2.;
VN2(i).SetCoord(X,Y,Z);
if(i==1) VN2(NbPoints+1).SetCoord(X,Y,Z);
V2(2).SetCoord(X,Y,Z);
gsymbol->Polyline(V2);
}
gsymbol->Polyline(VN1);
gsymbol->Polyline(VN2);
// Dessin de l'objectif
for (i = 1 ; i <= NbPoints ; i++) {
cosinus = Cos ( Alpha + (i - 1) * Standard_PI/2. );
sinus = Sin ( Alpha + (i - 1) * Standard_PI/2. );
// Premier carre de base
X = Xc2 + (cosinus * Xi + sinus * Xj) * Lng / 6.;
Y = Yc2 + (cosinus * Yi + sinus * Yj) * Lng / 6.;
Z = Zc2 + (cosinus * Zi + sinus * Zj) * Lng / 6.;
VN1(i).SetCoord(X,Y,Z);
if(i==1) VN1(NbPoints+1).SetCoord(X,Y,Z);
V2(1).SetCoord(X,Y,Z);
// Second carre de base
X = Xc2 + Dx * Lng / 6. + (cosinus * Xi + sinus * Xj) * Lng / 3.;
Y = Yc2 + Dy * Lng / 6. + (cosinus * Yi + sinus * Yj) * Lng / 3.;
Z = Zc2 + Dz * Lng / 6. + (cosinus * Zi + sinus * Zj) * Lng / 3.;
VN2(i).SetCoord(X,Y,Z);
if(i==1) VN2(NbPoints+1).SetCoord(X,Y,Z);
V2(2).SetCoord(X,Y,Z);
gsymbol->Polyline(V2);
}
gsymbol->Polyline(VN1);
gsymbol->Polyline(VN2);
}
void V3d_Camera::Display( const Handle(V3d_View)& aView,
const V3d_TypeOfRepresentation TPres) {
Graphic3d_Array1OfVertex PRadius(0,1);
Graphic3d_Vertex PText ;
Standard_Real X,Y,Z,Rayon;
Standard_Real X0,Y0,Z0,VX,VY,VZ;
Standard_Real X1,Y1,Z1,XT,YT,ZT,PXT,PYT;
Standard_Real DXRef,DYRef,DZRef,DXini,DYini,DZini;
Standard_Integer IXP,IYP;
V3d_TypeOfRepresentation Pres;
V3d_TypeOfUpdate UpdSov;
// Creation d'une structure d'elements reperables (la position de
// la camera, et la sphere de deplacement de cette camera)
Pres = TPres;
Handle(V3d_Viewer) TheViewer = aView->Viewer();
UpdSov = TheViewer->UpdateMode();
TheViewer->SetUpdateMode(V3d_WAIT);
if (!MyGraphicStructure.IsNull()) {
MyGraphicStructure->Disconnect(MyGraphicStructure1);
MyGraphicStructure->Clear();
MyGraphicStructure1->Clear();
if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation;
}
else {
if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE;
Handle(Graphic3d_Structure) scamera = new Graphic3d_Structure(TheViewer->Viewer());
MyGraphicStructure = scamera;
Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer());
MyGraphicStructure1 = snopick;
}
Handle(Graphic3d_Group) gradius;
Handle(Graphic3d_Group) gExtArrow;
Handle(Graphic3d_Group) gIntArrow;
if (Pres == V3d_COMPLETE) {
gradius = new Graphic3d_Group(MyGraphicStructure);
gExtArrow = new Graphic3d_Group(MyGraphicStructure);
gIntArrow = new Graphic3d_Group(MyGraphicStructure);
}
Handle(Graphic3d_Group) gcamera = new Graphic3d_Group(MyGraphicStructure);
Handle(Graphic3d_Group) gsphere;
if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) gsphere = new Graphic3d_Group(MyGraphicStructure);
// Creation d'une structure d'elements non reperables ( meridien et
// parallele ).
Handle(Graphic3d_Group) gnopick = new Graphic3d_Group(MyGraphicStructure1);
MyGraphicStructure1->SetPick(Standard_False);
MyTarget.Coord(X0,Y0,Z0);
//Affichage de la position de la camera.
gcamera->SetPickId(1);
if (Pres == V3d_SIMPLE) {
// on dessine un viseur
Graphic3d_Array1OfVertex PViseur(1,2);
aView->Project(X0,Y0,Z0,PXT,PYT);
aView->Convert(PXT,PYT,IXP,IYP);
aView->Convert(IXP,IYP,XT,YT,ZT);
aView->Convert(IXP+20,IYP,X,Y,Z);
PViseur(1).SetCoord(X+X0-XT,Y+Y0-YT,Z+Z0-ZT);
aView->Convert(IXP-20,IYP,X,Y,Z);
PViseur(2).SetCoord(X+X0-XT,Y+Y0-YT,Z+Z0-ZT);
gcamera->Polyline(PViseur);
aView->Convert(IXP,IYP-20,X,Y,Z);
PViseur(1).SetCoord(X+X0-XT,Y+Y0-YT,Z+Z0-ZT);
aView->Convert(IXP,IYP+20,X,Y,Z);
PViseur(2).SetCoord(X+X0-XT,Y+Y0-YT,Z+Z0-ZT);
gcamera->Polyline(PViseur);
}
// on dessine une camera
else this->Symbol(gcamera,aView);
//Affichage de la sphere de reperage (limite au cercle).
if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) {
Rayon = this->Radius();
aView->Proj(VX,VY,VZ);
gsphere->SetPickId(2);
V3d::CircleInPlane(gsphere,X0,Y0,Z0,VX,VY,VZ,Rayon);
//Affichage du rayon de la sphere (ligne + texte)
if (Pres == V3d_COMPLETE) {
gradius->SetPickId(3);
gExtArrow->SetPickId(4);
gIntArrow->SetPickId(5);
PRadius(0).SetCoord(X0,Y0,Z0);
MyPosition.Coord(X,Y,Z);
PRadius(1).SetCoord(X,Y,Z);
gnopick->Polyline(PRadius);
V3d::ArrowOfRadius(gExtArrow,X-(X-X0)/10.,
Y-(Y-Y0)/10.,
Z-(Z-Z0)/10.,X-X0,Y-Y0,Z-Z0,Standard_PI/15.,Rayon/20.);
V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,Standard_PI/15.,
Rayon/20.);
TCollection_AsciiString ValOfRadius(Rayon);
PText.SetCoord( (X0+X)/2., (Y0+Y)/2. , (Z0+Z)/2. );
gradius->Text(ValOfRadius.ToCString(),PText,0.01);
}
//Affichage du meridien
Quantity_Color Col2(Quantity_NOC_GREEN);
Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d
(Col2,Aspect_TOL_SOLID,1.);
gnopick->SetPrimitivesAspect(Asp2);
// Definition de l'axe du cercle
aView->Up(DXRef,DYRef,DZRef);
this->Position(X,Y,Z);
DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
VX = DYRef*DZini - DZRef*DYini;
VY = DZRef*DXini - DXRef*DZini;
VZ = DXRef*DYini - DYRef*DXini;
V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
//Affichage de la parallele
// Definition de l'axe du cercle
aView->Proj(VX,VY,VZ);
aView->Up(X1,Y1,Z1);
DXRef = VY * Z1 - VZ * Y1;
DYRef = VZ * X1 - VX * Z1;
DZRef = VX * Y1 - VY * X1;
this->Position(X,Y,Z);
DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
VX = DYRef*DZini - DZRef*DYini;
VY = DZRef*DXini - DXRef*DZini;
VZ = DXRef*DYini - DYRef*DXini;
V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
}
MyGraphicStructure->Connect(MyGraphicStructure1,Graphic3d_TOC_DESCENDANT);
MyTypeOfRepresentation = Pres;
MyGraphicStructure->Display();
TheViewer->SetUpdateMode(UpdSov);
}
void V3d_Camera::Erase() {
if (!MyGraphicStructure.IsNull()) MyGraphicStructure->Erase();
if (!MyGraphicStructure1.IsNull()) MyGraphicStructure1->Erase();
}
V3d_TypeOfPickCamera V3d_Camera::Pick(const Handle(V3d_View)& aView,
const Standard_Integer Xpix,
const Standard_Integer Ypix) const
{
Standard_Integer i, Lng, Id;
Standard_Boolean kcont;
V3d_TypeOfPickCamera TPick;
Handle(Visual3d_ViewManager) VM = (aView->Viewer())->Viewer();
Visual3d_ContextPick CTXP;
Visual3d_PickDescriptor Pdes = VM->Pick(CTXP,aView->Window (),Xpix,Ypix);
Visual3d_PickPath OnePPath;
Handle(Visual3d_HSequenceOfPickPath) PPath = Pdes.PickPath();
Lng = PPath->Length();
kcont = Standard_True;
TPick = V3d_NOTHINGCAMERA;
for (i=1; i<=Lng && kcont; i++) {
OnePPath = PPath->Value(i);
Id = OnePPath.PickIdentifier();
if (MyGraphicStructure == OnePPath.StructIdentifier()){
switch (Id) {
case 1 : TPick = V3d_POSITIONCAMERA;
break;
case 2 : TPick = V3d_SPACECAMERA;
break;
case 3 : TPick = V3d_RADIUSTEXTCAMERA;
break;
case 4 : TPick = V3d_ExtRADIUSCAMERA;
break;
case 5 : TPick = V3d_IntRADIUSCAMERA;
break;
}
kcont = Standard_False;
}
}
return TPick;
}
void V3d_Camera::Tracking( const Handle(V3d_View)& aView,
const V3d_TypeOfPickCamera WhatPick,
const Standard_Integer Xpix,
const Standard_Integer Ypix) {
Standard_Real XPp,YPp,PXT,PYT,X,Y,Z,Rayon,Ylim;
Standard_Real XMinTrack,XMaxTrack,YMinTrack,YMaxTrack;
Standard_Real XT,YT,ZT,X0,Y0,Z0,XP,YP,ZP,VX,VY,VZ,A,B,C,Delta;
Standard_Real DX,DY,PXP,PYP,Xproj,Yproj;
Standard_Real A1,A2,B1,B2,Rap,OldRprj,NewRprj;
Standard_Real Xi,Yi,Zi,DeltaX,DeltaY,DeltaZ,Lambda;
Standard_Integer IPX,IPY;
aView->Convert(Xpix,Ypix,XPp,YPp);
MyTarget.Coord(X0,Y0,Z0);
aView->Project(X0,Y0,Z0,PXT,PYT);
aView->Convert(PXT,PYT,IPX,IPY);
// Coord 3d dans le plan de projection de la cible.
aView->Convert(IPX,IPY,XT,YT,ZT);
switch (WhatPick) {
case V3d_POSITIONCAMERA :
// Les Coordonnees doivent rester a l'interieur de la sphere
Rayon = this->Radius();
XMinTrack = PXT - Rayon;
XMaxTrack = PXT + Rayon;
Ylim = Sqrt( Square(Rayon) - Square(XPp - PXT) );
YMinTrack = PYT - Ylim;
YMaxTrack = PYT + Ylim;
if (XPp >= XMinTrack && XPp <= XMaxTrack) {
if (YPp >= YMinTrack && YPp <= YMaxTrack) {
aView->ProjReferenceAxe(Xpix,Ypix,XP,YP,ZP,VX,VY,VZ);
DeltaX = X0 - XP;
DeltaY = Y0 - YP;
DeltaZ = Z0 - ZP;
// On recherche le point d'intersection des droites definies
// par :
// - Droite passant par le point de projection et l'oeil
// si on est en perspective, parralele a la normale de la
// vue si on a une vue axonometrique.
// position dans la vue est // a la normale de la vue
// - La distance position de la camera cible est egale au
// rayon.
A = VX*VX + VY*VY + VZ*VZ ;
B = -2. * (VX*DeltaX + VY*DeltaY + VZ*DeltaZ);
C = DeltaX*DeltaX + DeltaY*DeltaY + DeltaZ*DeltaZ
- Rayon*Rayon ;
Delta = B*B - 4.*A*C;
if ( Delta >= 0 ) {
Lambda = (-B + Sqrt(Delta))/(2.*A);
X = XP + Lambda*VX;
Y = YP + Lambda*VY;
Z = ZP + Lambda*VZ;
MyPosition.SetCoord(X,Y,Z);
this->Display(aView,MyTypeOfRepresentation);
aView->Update();
}
}
break;
}
case V3d_SPACECAMERA :
aView->Convert(PXT,PYT,IPX,IPY);
// Dans ce cas Xpix,Ypix correspondent a une distance , relative
// a la translation que l'on veut effectuer sur la sphere.
aView->Convert(IPX+Xpix,IPY+Ypix,X,Y,Z);
X = X+X0-XT;
Y = Y+Y0-YT;
Z = Z+Z0-ZT;
MyTarget.SetCoord(X,Y,Z);
MyPosition.Coord(Xi,Yi,Zi);
Xi = Xi + (X - X0);
Yi = Yi + (Y - Y0);
Zi = Zi + (Z - Z0);
MyPosition.SetCoord(Xi,Yi,Zi);
this->Display(aView,MyTypeOfRepresentation);
aView->Update();
break;
case V3d_ExtRADIUSCAMERA :
// on cherche a conserver la direction cible positionnement de la
// camera ==> on projette le point sur la direction cible camera.
this->Position(Xi,Yi,Zi);
aView->Project(Xi,Yi,Zi,PXP,PYP);
DX = PXP - PXT;
DY = PYP - PYT;
A1 = DY/DX ; B1 = PYT - A1*PXT;
A2 = -DX/DY; B2 = YPp - A2*XPp;
Xproj = (B2 - B1) / (A1 - A2);
Yproj = A1*Xproj + B1;
if ( (DX*(Xproj-PXT) > 0.) && (DY*(Yproj-PYT) > 0.) ) {
OldRprj = Sqrt ( Square (PXP-PXT) + Square (PYP-PYT) );
NewRprj = Sqrt ( Square (Xproj-PXT) + Square (Yproj-PYT) );
Rap = NewRprj/OldRprj;
Rayon = this->Radius();
Rayon = Rayon * Rap;
this->SetRadius(Rayon);
this->Display(aView,MyTypeOfRepresentation);
aView->Update();
}
break;
case V3d_IntRADIUSCAMERA :
// on cherche a conserver la direction cible positionnement
// de la camera ==> on projette le point sur la direction
// cible camera.
this->Position(Xi,Yi,Zi);
aView->Project(Xi,Yi,Zi,PXP,PYP);
DX = PXP - PXT;
DY = PYP - PYT;
A1 = DY/DX ; B1 = PYT - A1*PXT;
A2 = -DX/DY; B2 = YPp - A2*XPp;
Xproj = (B2 - B1) / (A1 - A2);
Yproj = A1*Xproj + B1;
if ( (DX*(Xproj-PXP) < 0.) && (DY*(Yproj-PYP) < 0.) ) {
OldRprj = Sqrt ( Square (PXP-PXT) + Square (PYP-PYT) );
NewRprj = Sqrt ( Square (Xproj-PXP) + Square (Yproj-PYP) );
Rap = NewRprj/OldRprj;
Rayon = this->Radius();
Rayon = Rayon * Rap;
// la camera doit rester a une position fixe, seule la cible
// est modifie.
Graphic3d_Vector Dir(MyPosition,MyTarget);
Dir.Normalize();
Dir.Coord(X,Y,Z);
X = Xi + Rayon*X;
Y = Yi + Rayon*Y;
Z = Zi + Rayon*Z;
MyTarget.SetCoord(X,Y,Z);
this->Display(aView,MyTypeOfRepresentation);
aView->Update();
}
break;
case V3d_RADIUSTEXTCAMERA :
break;
case V3d_NOTHINGCAMERA :
break;
}
}
void V3d_Camera::AerialPilot( const Handle(V3d_View)& aView,
const Standard_Integer Xpix,
const Standard_Integer Ypix) {
Standard_Real Xp,Yp,Zp,Xc,Yc,Zc,Xv,Yv,Zv,Xf,Yf,Zf;
Standard_Real VX,VY,VZ,DXH,DYH,DZH,A,B,C,PXT,PYT,X1,Y1,Z1,Dist;
Standard_Real Height,Width,Beta,CosBeta,SinBeta,Coef;
Standard_Integer IPX,IPY,IHeight,IWidth;
TColStd_Array2OfReal MatRot(0,2,0,2);
MyPosition.Coord(Xp,Yp,Zp);
MyTarget.Coord(Xc,Yc,Zc);
aView->At(Xv,Yv,Zv);
aView->Project(Xv,Yv,Zv,PXT,PYT);
aView->Convert(PXT,PYT,IPX,IPY);
// Recherche de tangage ==> Xpix = IPX et Ypix inverse
// C'est le point vise qui tourne autour de l'axe passant par l'oeil et
// de direction un vecteur appartenant au plan de la vue et
// perpendiculaire au vecteur haut de la vue.
if ( Ypix != IPY ) {
aView->Size(Width,Height);
IHeight = aView->Convert(Height);
Beta = ((IPY - Ypix)*Standard_PI)/(IHeight*2.);
aView->Proj(VX,VY,VZ);
aView->Up(DXH,DYH,DZH);
A = VY*DZH - VZ*DYH;
B = VZ*DXH - VX*DZH;
C = VX*DYH - VY*DXH;
Dist = Sqrt( A*A + B*B + C*C);
A = A/Dist; B = B/Dist; C = C/Dist;
CosBeta = Cos(Beta);
SinBeta = Sin(Beta);
Coef = 1. - CosBeta;
MatRot(0,0) = A * A + (1. - A * A) * CosBeta;
MatRot(0,1) = -C * SinBeta + Coef * A * B;
MatRot(0,2) = B * SinBeta + Coef * A * C;
MatRot(1,0) = C * SinBeta + Coef * A * B;
MatRot(1,1) = B * B + (1. - B * B) * CosBeta;
MatRot(1,2) = -A * SinBeta + Coef * B * C;
MatRot(2,0) = -B * SinBeta + Coef * A * C;
MatRot(2,1) = A * SinBeta + Coef * B * C;
MatRot(2,2) = C * C + (1. - C * C) * CosBeta;
Xf = Xp * MatRot(0,0) + Yp * MatRot(0,1) + Zp * MatRot(0,2);
Yf = Xp * MatRot(1,0) + Yp * MatRot(1,1) + Zp * MatRot(1,2);
Zf = Xp * MatRot(2,0) + Yp * MatRot(2,1) + Zp * MatRot(2,2);
// Rotation du point vise (cible de la camera)
X1 = Xc * MatRot(0,0) + Yc * MatRot(0,1) + Zc * MatRot(0,2);
Y1 = Xc * MatRot(1,0) + Yc * MatRot(1,1) + Zc * MatRot(1,2);
Z1 = Xc * MatRot(2,0) + Yc * MatRot(2,1) + Zc * MatRot(2,2);
Xc = X1 + Xp - Xf ; Yc = Y1 + Yp - Yf ; Zc = Z1 + Zp - Zf;
MyTarget.SetCoord(Xc,Yc,Zc);
}
// Recherche de roulis determine par Xpix
if ( Xpix != IPX ) {
IWidth = aView->Convert(Width);
Beta = ((IPX - Xpix)*Standard_PI)/(IWidth*2.);
MyAngle = MyAngle + Beta;
}
}
void V3d_Camera::EarthPilot( const Handle(V3d_View)& aView,
const Standard_Integer Xpix,
const Standard_Integer Ypix) {
// Le pilotage en mode terrestre, ressemble a la conduite d'une voiture
// Dans ce cas, seul le point cible est modifie.
Standard_Real Xp,Yp,Zp,Xc,Yc,Zc,Xv,Yv,Zv,Xf,Yf,Zf;
Standard_Real VX,VY,VZ,DXH,DYH,DZH,A,B,C,PXT,PYT,X1,Y1,Z1,Dist;
Standard_Real Height,Width,Beta,CosBeta,SinBeta,Coef;
Standard_Integer IPX,IPY,IHeight,IWidth;
TColStd_Array2OfReal MatRot(0,2,0,2);
MyPosition.Coord(Xp,Yp,Zp);
MyTarget.Coord(Xc,Yc,Zc);
aView->At(Xv,Yv,Zv);
aView->Project(Xv,Yv,Zv,PXT,PYT);
aView->Convert(PXT,PYT,IPX,IPY);
// Recherche d' inclinaison==> Xpix = IPX et Ypix inverse
// C'est le point vise qui tourne autour de l'axe passant par l'oeil et
// de direction un vecteur appartenant au plan de la vue et
// perpendiculaire au vecteur haut de la vue.
if ( Ypix != IPY ) {
aView->Size(Width,Height);
IHeight = aView->Convert(Height);
Beta = ((IPY - Ypix)*Standard_PI)/(IHeight*2.);
aView->Proj(VX,VY,VZ);
aView->Up(DXH,DYH,DZH);
A = VY*DZH - VZ*DYH;
B = VZ*DXH - VX*DZH;
C = VX*DYH - VY*DXH;
Dist = Sqrt( A*A + B*B + C*C);
A = A/Dist; B = B/Dist; C = C/Dist;
CosBeta = Cos(Beta);
SinBeta = Sin(Beta);
Coef = 1. - CosBeta;
MatRot(0,0) = A * A + (1. - A * A) * CosBeta;
MatRot(0,1) = -C * SinBeta + Coef * A * B;
MatRot(0,2) = B * SinBeta + Coef * A * C;
MatRot(1,0) = C * SinBeta + Coef * A * B;
MatRot(1,1) = B * B + (1. - B * B) * CosBeta;
MatRot(1,2) = -A * SinBeta + Coef * B * C;
MatRot(2,0) = -B * SinBeta + Coef * A * C;
MatRot(2,1) = A * SinBeta + Coef * B * C;
MatRot(2,2) = C * C + (1. - C * C) * CosBeta;
Xf = Xp * MatRot(0,0) + Yp * MatRot(0,1) + Zp * MatRot(0,2);
Yf = Xp * MatRot(1,0) + Yp * MatRot(1,1) + Zp * MatRot(1,2);
Zf = Xp * MatRot(2,0) + Yp * MatRot(2,1) + Zp * MatRot(2,2);
// Rotation du point vise (cible de la camera)
X1 = Xc * MatRot(0,0) + Yc * MatRot(0,1) + Zc * MatRot(0,2);
Y1 = Xc * MatRot(1,0) + Yc * MatRot(1,1) + Zc * MatRot(1,2);
Z1 = Xc * MatRot(2,0) + Yc * MatRot(2,1) + Zc * MatRot(2,2);
Xc = X1 + Xp - Xf ; Yc = Y1 + Yp - Yf ; Zc = Z1 + Zp - Zf;
}
// Recherche de virage ==> Ypix = IPY . Le point vise tourne aoutour
// d'un axe // au vecteur haut passant par l'oeil
if ( Xpix != IPX ) {
IWidth = aView->Convert(Width);
Beta = ((IPX - Xpix)*Standard_PI)/(IWidth*2.);
aView->Up(A,B,C);
Dist = Sqrt( A*A + B*B + C*C);
A = A/Dist; B = B/Dist; C = C/Dist;
CosBeta = Cos(Beta);
SinBeta = Sin(Beta);
Coef = 1. - CosBeta;
MatRot(0,0) = A * A + (1. - A * A) * CosBeta;
MatRot(0,1) = -C * SinBeta + Coef * A * B;
MatRot(0,2) = B * SinBeta + Coef * A * C;
MatRot(1,0) = C * SinBeta + Coef * A * B;
MatRot(1,1) = B * B + (1. - B * B) * CosBeta;
MatRot(1,2) = -A * SinBeta + Coef * B * C;
MatRot(2,0) = -B * SinBeta + Coef * A * C;
MatRot(2,1) = A * SinBeta + Coef * B * C;
MatRot(2,2) = C * C + (1. - C * C) * CosBeta;
Xf = Xp * MatRot(0,0) + Yp * MatRot(0,1) + Zp * MatRot(0,2);
Yf = Xp * MatRot(1,0) + Yp * MatRot(1,1) + Zp * MatRot(1,2);
Zf = Xp * MatRot(2,0) + Yp * MatRot(2,1) + Zp * MatRot(2,2);
// Rotation du point vise (cible de la camera)
X1 = Xc * MatRot(0,0) + Yc * MatRot(0,1) + Zc * MatRot(0,2);
Y1 = Xc * MatRot(1,0) + Yc * MatRot(1,1) + Zc * MatRot(1,2);
Z1 = Xc * MatRot(2,0) + Yc * MatRot(2,1) + Zc * MatRot(2,2);
Xc = X1 + Xp - Xf ; Yc = Y1 + Yp - Yf ; Zc = Z1 + Zp - Zf;
}
MyTarget.SetCoord(Xc,Yc,Zc);
}
void V3d_Camera::Move (const Standard_Real Dist) {
// Deplacement de la camera en conservant la direction camera - cible.
Standard_Real XP,YP,ZP,X0,Y0,Z0,DX,DY,DZ,Norme;
MyPosition.Coord(XP,YP,ZP);
MyTarget.Coord(X0,Y0,Z0);
DX = X0 - XP; DY = Y0 - YP; DZ = Z0 - ZP;
Norme = Sqrt(DX*DX + DY*DY + DZ*DZ);
DX = Dist*DX/Norme; DY = Dist*DY/Norme; DZ = Dist*DZ/Norme;
XP = XP + DX; YP = YP + DY; ZP = ZP + DZ;
X0 = X0 + DX; Y0 = Y0 + DY; Z0 = Z0 + DZ;
MyPosition.SetCoord(XP,YP,ZP);
MyTarget.SetCoord(X0,Y0,Z0);
}
void V3d_Camera::GoUp (const Standard_Real Haut) {
// Deplacement de la camera suivant l'axe z, en conservant la direction camera
// cible de la camera
MyPosition.SetZCoord(MyPosition.Z()+Haut);
MyTarget.SetZCoord(MyTarget.Z()+Haut);
}
void V3d_Camera::SymetricPointOnSphere (const Handle(V3d_View)& aView, const Graphic3d_Vertex &Center, const Graphic3d_Vertex &aPoint, const Standard_Real Rayon, Standard_Real& X, Standard_Real& Y, Standard_Real& Z, Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ ) {
Standard_Real X0,Y0,Z0,XP,YP,ZP;
Standard_Real PXP,PYP,DeltaX,DeltaY,DeltaZ;
Standard_Real A,B,C,Delta,Lambda;
Standard_Integer IPX,IPY;
Center.Coord(X0,Y0,Z0);
aPoint.Coord(XP,YP,ZP);
aView->Project(XP,YP,ZP,PXP,PYP);
aView->Convert(PXP,PYP,IPX,IPY);
aView->ProjReferenceAxe(IPX,IPY,X,Y,Z,VX,VY,VZ);
DeltaX = X0 - XP;
DeltaY = Y0 - YP;
DeltaZ = Z0 - ZP;
// On recherche le point d'intersection des droites definies
// par :
// - Droite passant par le point de projection et l'oeil
// si on est en perspective, parralele a la normale de la
// vue si on a une vue axonometrique.
// position dans la vue est // a la normale de la vue
// - La distance position de la camera cible est egale au
// rayon.
A = VX*VX + VY*VY + VZ*VZ ;
B = -2. * (VX*DeltaX + VY*DeltaY + VZ*DeltaZ);
C = DeltaX*DeltaX + DeltaY*DeltaY + DeltaZ*DeltaZ
- Rayon*Rayon ;
Delta = B*B - 4.*A*C;
if ( Delta >= 0 ) {
Lambda = (-B + Sqrt(Delta))/(2.*A);
if ( Lambda >= -0.0001 && Lambda <= 0.0001 )
Lambda = (-B - Sqrt(Delta))/(2.*A);
X = XP + Lambda*VX;
Y = YP + Lambda*VY;
Z = ZP + Lambda*VZ;
}
else {
X = XP; Y = YP; Z = ZP;
}
}

75
src/V3d/V3d_CircularGrid.cdl Executable file
View File

@@ -0,0 +1,75 @@
--
-- File: V3d_CircularGrid.cdl
-- Created: Jeudi 16 Juillet 1998
-- Author: CAL
-- Updated: GG IMP230300 The color fields are moved in Aspect_Grid
--
---Copyright: Matra Datavision 1998
private class CircularGrid from V3d inherits CircularGrid from Aspect
uses
Ax3 from gp,
Color from Quantity,
Group from Graphic3d,
Structure from Graphic3d,
GridDrawMode from Aspect,
ViewerPointer from V3d
is
Create ( aViewer : ViewerPointer from V3d;
aColor : Color from Quantity;
aTenthColor : Color from Quantity )
returns mutable CircularGrid from V3d;
SetColors ( me : mutable;
aColor : Color from Quantity;
aTenthColor : Color from Quantity )
is redefined static;
Display ( me : mutable )
is redefined static;
Erase ( me )
is redefined static;
IsDisplayed ( me )
returns Boolean from Standard
is redefined static;
GraphicValues ( me;
Radius : out Real from Standard;
OffSet : out Real from Standard )
is static;
SetGraphicValues ( me : mutable;
Radius : Real from Standard;
OffSet : Real from Standard )
is static;
DefineLines ( me : mutable )
is static private;
DefinePoints ( me : mutable )
is static private;
UpdateDisplay ( me : mutable )
is redefined static protected;
fields
myStructure : Structure from Graphic3d;
myGroup1, myGroup2 : Group from Graphic3d;
myCurViewPlane : Ax3 from gp;
-- myColor, myTenthColor : Color from Quantity;
-- myCurColor1, myCurColor2: Color from Quantity;
myViewer : ViewerPointer from V3d;
myCurAreDefined : Boolean from Standard;
myCurDrawMode : GridDrawMode from Aspect;
myCurXo, myCurYo : Real from Standard;
myCurAngle : Real from Standard;
myCurStep : Real from Standard;
myCurDivi : Integer from Standard;
myRadius : Real from Standard;
myOffSet : Real from Standard;
end CircularGrid from V3d;

420
src/V3d/V3d_CircularGrid.cxx Executable file
View File

@@ -0,0 +1,420 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_CircularGrid :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
16-08-98 : CAL ; S3892. Ajout grilles 3d.
13-10-98 : CAL ; S3892. Ajout de la gestion de la taille des grilles 3d.
23-10-98 : CAL ; PRO 15885. Patch K4403 et K4404
03-11-98 : CAL ; PRO 16161. Patch K4418 et K4419
IMP230300: GG The color fields and methods have moved in Aspect_Grid
************************************************************************/
#define IMP200100 //GG
// -> Compute the case Aspect_GDM_None
// -> Initialize the grid size according to the
// viewer default size.
#define IMP200300 //GG
// -> Recompute the grid when any graphic parameter is
// modified.
#define IMP300300 //GG
// -> Draw circles with 2 colors (tenth and normal colors)
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_CircularGrid.ixx>
#include <TColStd_Array2OfReal.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Visual3d_ViewManager.hxx>
#include <V3d_Viewer.hxx>
/*----------------------------------------------------------------------*/
/*
* Constant
*/
#define NO_TRACE_MINMAX
#define NO_TRACE_MAKE
#define NO_TRACE_VALUES
#define DIVISION 8
#define MYMINMAX 25.
#define MYFACTOR 50.
/*----------------------------------------------------------------------*/
V3d_CircularGrid::V3d_CircularGrid (const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor):
Aspect_CircularGrid (1.,8),
myStructure (new Graphic3d_Structure (aViewer->Viewer ())),
myGroup1 (new Graphic3d_Group (myStructure)),
myGroup2 (new Graphic3d_Group (myStructure)),
// myColor (aColor),
// myTenthColor (aTenthColor),
myViewer (aViewer),
myCurAreDefined (Standard_False)
{
myColor = aColor;
myTenthColor = aTenthColor;
myStructure->SetInfiniteState (Standard_True);
Standard_Real step = 10.;
#ifdef IMP200100
Standard_Real size = myViewer->DefaultViewSize()/2.;
SetGraphicValues (size, step/MYFACTOR);
#else
SetGraphicValues (25., step/MYFACTOR);
#endif
SetRadiusStep (step);
}
void V3d_CircularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) {
if( myColor != aColor || myTenthColor != aTenthColor ) {
myColor = aColor;
myTenthColor = aTenthColor;
myCurAreDefined = Standard_False;
UpdateDisplay();
}
}
void V3d_CircularGrid::Display () {
myStructure->Display (1);
}
void V3d_CircularGrid::Erase () const {
myStructure->Erase ();
}
Standard_Boolean V3d_CircularGrid::IsDisplayed () const {
return myStructure->IsDisplayed ();
}
void V3d_CircularGrid::UpdateDisplay () {
#ifdef TRACE_MINMAX
cout << "V3d_CircularGrid::UpdateDisplay ()\n";
#endif
gp_Ax3 ThePlane;
ThePlane = myViewer->PrivilegedPlane ();
Standard_Boolean MakeTransform = Standard_False;
Standard_Real xl, yl, zl;
Standard_Real xdx, xdy, xdz;
Standard_Real ydx, ydy, ydz;
Standard_Real dx, dy, dz;
ThePlane.Location ().Coord (xl, yl, zl);
ThePlane.XDirection ().Coord (xdx, xdy, xdz);
ThePlane.YDirection ().Coord (ydx, ydy, ydz);
ThePlane.Direction ().Coord (dx, dy, dz);
if (! myCurAreDefined)
MakeTransform = Standard_True;
else {
if (RotationAngle () != myCurAngle
|| XOrigin () != myCurXo || YOrigin () != myCurYo)
MakeTransform = Standard_True;
if (! MakeTransform) {
Standard_Real curxl, curyl, curzl;
Standard_Real curxdx, curxdy, curxdz;
Standard_Real curydx, curydy, curydz;
Standard_Real curdx, curdy, curdz;
myCurViewPlane.Location ().Coord (curxl, curyl, curzl);
myCurViewPlane.XDirection ().Coord (curxdx, curxdy, curxdz);
myCurViewPlane.YDirection ().Coord (curydx, curydy, curydz);
myCurViewPlane.Direction ().Coord (curdx, curdy, curdz);
if (xl != curxl || yl != curyl || zl != curzl
|| xdx != curxdx || xdy != curxdy || xdz != curxdz
|| ydx != curydx || ydy != curydy || ydz != curydz
|| dx != curdx || dy != curdy || dz != curdz)
MakeTransform = Standard_True;
}
}
if (MakeTransform) {
#ifdef TRACE_MAKE
cout << "MakeTransform" << endl;
#endif
Standard_Real CosAlpha = Cos (RotationAngle ());
Standard_Real SinAlpha = Sin (RotationAngle ());
TColStd_Array2OfReal Trsf (1, 4, 1, 4);
Trsf (4, 4) = 1.0;
Trsf (4, 1) = Trsf (4, 2) = Trsf (4, 3) = 0.0;
// Translation
Trsf (1, 4) = xl,
Trsf (2, 4) = yl,
Trsf (3, 4) = zl;
// Transformation de changement de repere
Trsf (1, 1) = xdx,
Trsf (2, 1) = xdy,
Trsf (3, 1) = xdz,
Trsf (1, 2) = ydx,
Trsf (2, 2) = ydy,
Trsf (3, 2) = ydz,
Trsf (1, 3) = dx,
Trsf (2, 3) = dy,
Trsf (3, 3) = dz;
myStructure->SetTransform (Trsf, Graphic3d_TOC_REPLACE);
// Translation de l'origine
Trsf (1, 4) = -XOrigin (),
Trsf (2, 4) = -YOrigin (),
Trsf (3, 4) = 0.0;
// Rotation Alpha autour de l'axe -Z
Trsf (1, 1) = CosAlpha,
Trsf (2, 1) = -SinAlpha,
Trsf (3, 1) = 0.0,
Trsf (1, 2) = SinAlpha,
Trsf (2, 2) = CosAlpha,
Trsf (3, 2) = 0.0,
Trsf (1, 3) = 0.0,
Trsf (2, 3) = 0.0,
Trsf (3, 3) = 1.0;
myStructure->SetTransform (Trsf,Graphic3d_TOC_POSTCONCATENATE);
// CAL : 19 aout 1998
// Il y avait aussi la possibilite de faire le calcul
// de changement de repere par :
// gp_Trsf::SetTransformation
// (myGridPlane, myViewer->PrivilegedPlane ());
#ifdef TRACE_VALUES
Standard_Integer i, j;
TColStd_Array2OfReal TheMatrix (1, 4, 1, 4);
myStructure->Transform (TheMatrix);
for (i=1; i<=4; i++) {
for (j=1; j<=4; j++)
cout << TheMatrix (i, j) << "\t";
cout << endl;
}
#endif
myCurAngle = RotationAngle ();
myCurXo = XOrigin (), myCurYo = YOrigin ();
myCurViewPlane = ThePlane;
}
switch (DrawMode ()) {
default:
case Aspect_GDM_Points:
if (! myCurAreDefined || myCurAreDefined &&
myCurDrawMode == Aspect_GDM_Lines)
myGroup2->Clear ();
DefinePoints ();
myCurDrawMode = Aspect_GDM_Points;
break;
case Aspect_GDM_Lines:
DefineLines ();
myCurDrawMode = Aspect_GDM_Lines;
break;
#ifdef IMP210100
case Aspect_GDM_None:
myCurDrawMode = Aspect_GDM_None;
break;
#endif
}
myCurAreDefined = Standard_True;
#ifdef TRACE_VALUES
Standard_Real a11, a12, a13, a21, a22, a23, a31, a32, a33;
ThePlane.XDirection ().Coord (a11, a12, a13);
ThePlane.YDirection ().Coord (a21, a22, a23);
ThePlane.Direction ().Coord (a31, a32, a33);
cout << "Test Plane XDirection " << a11 << ", " << a12 << ", " << a13 << endl;
cout << "Test Plane YDirection " << a21 << ", " << a22 << ", " << a23 << endl;
cout << "Test Plane Direction " << a31 << ", " << a32 << ", " << a33 << endl;
#endif
}
void V3d_CircularGrid::DefineLines () {
Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d ();
LineAttrib->SetColor (myColor);
LineAttrib->SetType (Aspect_TOL_SOLID);
LineAttrib->SetWidth (1.0);
Standard_Real r;
Standard_Real aStep = RadiusStep ();
Standard_Real aDivision = DivisionNumber ();
Standard_Real alpha = Standard_PI / aDivision;
Standard_Integer Division = (Standard_Integer )( (aDivision >= DIVISION ? aDivision : DIVISION));
Graphic3d_Array1OfVertex Cercle (0, 2*Division);
Standard_Real xl, yl, zl = myOffSet;
Standard_Integer i;
Graphic3d_Vertex P1, P2;
Standard_Boolean MakeDiametres = Standard_False;
if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Points)
MakeDiametres = Standard_True;
else {
if (aDivision != myCurDivi)
MakeDiametres = Standard_True;
}
if (MakeDiametres) {
#ifdef TRACE_MAKE
cout << "MakeDiametres" << endl;
#endif
// diametres
myGroup1->Clear ();
#ifdef IMP300300
LineAttrib->SetColor (myTenthColor);
#endif
myGroup1->SetGroupPrimitivesAspect (LineAttrib);
myGroup1->BeginPrimitives ();
P1.SetCoord (0.0, 0.0, -zl);
for (i=1; i<=2*aDivision; i++) {
xl = Cos (alpha*i)*myRadius;
yl = Sin (alpha*i)*myRadius;
P2.SetCoord (xl, yl, -zl);
myGroup1->Polyline (P1, P2, Standard_False);
}
myGroup1->EndPrimitives ();
myGroup1->SetMinMaxValues
(-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0);
}
Standard_Boolean MakeCercles = Standard_False;
if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Points)
MakeCercles = Standard_True;
else {
if (aStep != myCurStep || aDivision != myCurDivi)
MakeCercles = Standard_True;
}
if (MakeCercles) {
#ifdef TRACE_MAKE
cout << "MakeCercles" << endl;
#endif
// cercles
#ifdef IMP300300
Standard_Integer nblines = 0;
#endif
myGroup2->Clear ();
#ifndef IMP300300
myGroup2->SetGroupPrimitivesAspect (LineAttrib);
#endif
myGroup2->BeginPrimitives ();
alpha = Standard_PI / Division;
for (r=aStep; r<=myRadius; r+=aStep) {
for (i=0; i<=2*Division; i++) {
xl = Cos (alpha*i)*r;
yl = Sin (alpha*i)*r;
Cercle (i).SetCoord (xl, yl, -zl);
}
#ifdef IMP300300
if (Modulus (nblines, 10) != 0) {
myGroup2->Polyline (Cercle, Standard_False);
} else {
LineAttrib->SetColor (myTenthColor);
myGroup2->SetPrimitivesAspect (LineAttrib);
myGroup2->Polyline (Cercle, Standard_False);
LineAttrib->SetColor (myColor);
myGroup2->SetPrimitivesAspect (LineAttrib);
}
nblines++;
#else
myGroup2->Polyline (Cercle, Standard_False);
#endif
}
myGroup2->EndPrimitives ();
myGroup2->SetMinMaxValues
(-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0);
}
myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision;
}
void V3d_CircularGrid::DefinePoints () {
Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d ();
MarkerAttrib->SetColor (myColor);
MarkerAttrib->SetType (Aspect_TOM_POINT);
MarkerAttrib->SetScale (3.);
Standard_Real r;
Standard_Real aStep = RadiusStep ();
Standard_Real aDivision = DivisionNumber ();
Standard_Real alpha = Standard_PI / aDivision;
Graphic3d_Array1OfVertex Cercle (0,(Standard_Integer )(2*aDivision));
Standard_Real xl, yl, zl = myOffSet;
Standard_Integer i;
Graphic3d_Vertex Point (0.0, 0.0, -zl);
Standard_Boolean MakeDiametres = Standard_False;
if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Lines)
MakeDiametres = Standard_True;
else {
if (aDivision != myCurDivi || aStep != myCurStep)
MakeDiametres = Standard_True;
}
if (MakeDiametres) {
#ifdef TRACE_MAKE
cout << "MakeDiametres" << endl;
#endif
// diametres
myGroup1->Clear ();
myGroup1->SetGroupPrimitivesAspect (MarkerAttrib);
myGroup1->BeginPrimitives ();
myGroup1->Marker (Point, Standard_False);
for (r=aStep; r<=myRadius; r+=aStep) {
for (i=0; i<=2*aDivision; i++) {
xl = Cos (alpha*i)*r;
yl = Sin (alpha*i)*r;
Cercle (i).SetCoord (xl, yl, -zl);
}
myGroup1->MarkerSet (Cercle, Standard_False);
}
myGroup1->EndPrimitives ();
myGroup1->SetMinMaxValues
(-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0);
}
myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision;
}
void V3d_CircularGrid::GraphicValues (Standard_Real& theRadius, Standard_Real& theOffSet) const {
theRadius = myRadius;
theOffSet = myOffSet;
}
void V3d_CircularGrid::SetGraphicValues (const Standard_Real theRadius, const Standard_Real theOffSet) {
#ifdef TRACE_MINMAX
cout << "theRadius " << theRadius << " theOffSet " << theOffSet << endl;
#endif
if (! myCurAreDefined) {
myRadius = theRadius;
myOffSet = theOffSet;
}
if (myRadius != theRadius) {
myRadius = theRadius;
myCurAreDefined = Standard_False;
}
if (myOffSet != theOffSet) {
myOffSet = theOffSet;
myCurAreDefined = Standard_False;
}
#ifdef IMP200300
if( !myCurAreDefined ) UpdateDisplay();
#endif
}

92
src/V3d/V3d_ColorScale.cdl Executable file
View File

@@ -0,0 +1,92 @@
-- File: V3d_ColorScale.cdl
-- Created: 24/06/2004
-- Author: STV
--
---Copyright: Open Cascade 2004
--
private class ColorScale from V3d inherits ColorScale from Aspect
---Purpose: A colorscale class
uses
--View from V3d,
LayerMgr from V3d,
LayerMgrPointer from V3d,
--Layer from Visual3d,
Color from Quantity,
ExtendedString from TCollection
is
---Category: Public
Create(aMgr : LayerMgr from V3d)
returns ColorScale from V3d;
---Purpose: Returns returns ColorScale from V3d.
--View(me)
--returns View from V3d;
---Purpose: Returns View from V3d.
Display(me : mutable);
Erase(me : mutable);
IsDisplayed(me)
returns Boolean from Standard;
---Category: Protected
UpdateColorScale(me : mutable)
is redefined protected;
--BeginPaint(me : mutable)
--returns Boolean from Standard
--is redefined protected;
--EndPaint(me : mutable)
--returns Boolean from Standard
--is redefined protected;
PaintRect(me : mutable; X, Y, W, H : Integer from Standard;
aColor : Color from Quantity;
aFilled : Boolean from Standard = Standard_False)
is redefined;
PaintText(me : mutable; aText : ExtendedString from TCollection;
X, Y : Integer from Standard;
aColor : Color from Quantity)
is redefined;
TextWidth(me; aText : ExtendedString from TCollection)
returns Integer from Standard
is redefined;
TextHeight(me; aText : ExtendedString from TCollection)
returns Integer from Standard
is redefined;
TextSize( me;
AText : ExtendedString from TCollection;
AHeight : Integer from Standard;
AWidth : in out Integer from Standard;
AnAscent : in out Integer from Standard;
ADescent : in out Integer from Standard );
DrawScale(me : mutable);
---Category: Private
--Overlay(me)
--returns Layer from Visual3d
--is private;
fields
--myView : View from V3d;
myLayerMgr : LayerMgrPointer from V3d;
--myOverlay : Layer from Visual3d;
myDisplay : Boolean from Standard;
end ColorScale;

145
src/V3d/V3d_ColorScale.cxx Executable file
View File

@@ -0,0 +1,145 @@
// File: V3d_ColorScale.cxx
// Created: Tue Jun 22 17:44:25 2004
// Author: STV
//Copyright: Open Cascade 2004
#include <V3d_ColorScale.ixx>
#include <V3d_View.hxx>
#include <V3d_LayerMgr.hxx>
#include <Visual3d_View.hxx>
#include <Visual3d_Layer.hxx>
#include <Visual3d_ViewManager.hxx>
#include <Aspect_Window.hxx>
#include <Aspect_ColorMap.hxx>
#include <Aspect_ColorMapEntry.hxx>
#include <Aspect_SequenceOfColor.hxx>
#include <Aspect_TypeOfColorScaleData.hxx>
#include <Aspect_TypeOfColorScalePosition.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_SequenceOfExtendedString.hxx>
#include <Graphic3d_NameOfFont.hxx>
V3d_ColorScale::V3d_ColorScale( const Handle(V3d_LayerMgr)& aMgr )
: Aspect_ColorScale(),
myLayerMgr( aMgr.operator->() ),
myDisplay( Standard_False )
{
}
void V3d_ColorScale::Display()
{
myDisplay = Standard_True;
UpdateColorScale();
}
void V3d_ColorScale::Erase()
{
myDisplay = Standard_False;
UpdateColorScale();
}
Standard_Boolean V3d_ColorScale::IsDisplayed() const
{
return myDisplay;
}
void V3d_ColorScale::UpdateColorScale()
{
myLayerMgr->Compute();
}
void V3d_ColorScale::PaintRect( const Standard_Integer X, const Standard_Integer Y,
const Standard_Integer W, const Standard_Integer H,
const Quantity_Color& aColor, const Standard_Boolean aFilled )
{
const Handle(Visual3d_Layer) &theLayer = myLayerMgr->Overlay();
if ( theLayer.IsNull() )
return;
theLayer->SetColor( aColor );
if ( aFilled )
theLayer->DrawRectangle( X, Y, W, H );
else {
theLayer->SetLineAttributes( Aspect_TOL_SOLID, 0.5 );
theLayer->BeginPolyline();
theLayer->AddVertex( X, Y, Standard_False );
theLayer->AddVertex( X, Y + H, Standard_True );
theLayer->AddVertex( X + W, Y + H, Standard_True );
theLayer->AddVertex( X + W, Y, Standard_True );
theLayer->AddVertex( X, Y, Standard_True );
theLayer->ClosePrimitive();
}
}
void V3d_ColorScale::PaintText( const TCollection_ExtendedString& aText,
const Standard_Integer X, const Standard_Integer Y,
const Quantity_Color& aColor )
{
const Handle(Visual3d_Layer) &theLayer = myLayerMgr->Overlay();
if ( theLayer.IsNull() )
return;
theLayer->SetColor( aColor );
theLayer->SetTextAttributes( Graphic3d_NOF_ASCII_MONO, Aspect_TODT_SUBTITLE, aColor );
TCollection_AsciiString theText( aText.ToExtString(), '?' );
Standard_Integer aTextH = GetTextHeight();
Standard_Integer aWidth, anAscent, aDescent;
TextSize(aText, aTextH, aWidth, anAscent, aDescent);
theLayer->DrawText( theText.ToCString(), X, Y + anAscent, aTextH);
}
Standard_Integer V3d_ColorScale::TextWidth( const TCollection_ExtendedString& aText ) const
{
Standard_Integer aWidth, anAscent, aDescent;
TextSize(aText, GetTextHeight(), aWidth, anAscent, aDescent);
return aWidth;
}
Standard_Integer V3d_ColorScale::TextHeight( const TCollection_ExtendedString& aText ) const
{
Standard_Integer aWidth, anAscent, aDescent;
TextSize(aText, GetTextHeight(), aWidth, anAscent, aDescent);
return anAscent+aDescent;
}
void V3d_ColorScale::TextSize (const TCollection_ExtendedString& AText, const Standard_Integer AHeight, Standard_Integer& AWidth, Standard_Integer& AnAscent, Standard_Integer& ADescent) const
{
const Handle(Visual3d_Layer) &theLayer = myLayerMgr->Overlay();
if ( !theLayer.IsNull() ) {
Standard_Real aWidth, anAscent, aDescent;
TCollection_AsciiString theText( AText.ToExtString(), '?' );
theLayer->TextSize(theText.ToCString(),AHeight,aWidth,anAscent,aDescent);
AWidth = (Standard_Integer)aWidth;
AnAscent = (Standard_Integer)anAscent;
ADescent = (Standard_Integer)aDescent;
}
else {
AWidth=AnAscent=ADescent=0;
}
}
void V3d_ColorScale::DrawScale ()
{
const Handle(V3d_View) &theView = myLayerMgr->View();
if ( theView.IsNull() )
return;
const Handle(Aspect_Window) &theWin = theView->Window();
if ( theWin.IsNull() )
return;
Standard_Integer WinWidth( 0 ), WinHeight( 0 );
theWin->Size( WinWidth, WinHeight );
const Standard_Integer X = RealToInt(GetXPosition() * WinWidth);
const Standard_Integer Y = RealToInt(GetYPosition() * WinHeight);
const Standard_Integer W = RealToInt(GetWidth() * WinWidth);
const Standard_Integer H = RealToInt(GetHeight() * WinHeight);
Aspect_ColorScale::DrawScale( theView->BackgroundColor(), X, Y, W, H );
}

View File

@@ -0,0 +1,48 @@
--
-- File: V3d_ColorScaleLayerItem.cdl
-- Created: March 20 2009
-- Author: ABD
--
private class ColorScaleLayerItem from V3d inherits LayerItem from Visual3d
---Version:
---Purpose: This class is drawable unit of ColorScale of 2d scene
---Keywords:
---Warning:
---References:
uses
ColorScale from V3d
is
-------------------------
-- Category: Constructors
-------------------------
Create ( aColorScale: ColorScale from V3d )
returns ColorScaleLayerItem;
---Level: Public
---Purpose: Creates a layer item
---Category: Constructors
---------------------------------------------------
-- Category: Methods to modify the class definition
---------------------------------------------------
ComputeLayerPrs( me : mutable )
is redefined;
---Level: Public
---Purpose: virtual function for recompute 2D
-- presentation (empty by default)
RedrawLayerPrs( me : mutable )
is redefined;
---Level: Public
---Purpose: virtual function for recompute 2D
-- presentation (empty by default)
fields
MyColorScale : ColorScale from V3d;
end ColorScaleLayerItem from V3d;

View File

@@ -0,0 +1,29 @@
/***********************************************************************
************************************************************************/
// for the class
#include <V3d_ColorScaleLayerItem.ixx>
//
//-Constructors
//
V3d_ColorScaleLayerItem::V3d_ColorScaleLayerItem (
const Handle(V3d_ColorScale)& aColorScale ):
Visual3d_LayerItem(),
MyColorScale(aColorScale)
{
}
void V3d_ColorScaleLayerItem::ComputeLayerPrs()
{
Visual3d_LayerItem::ComputeLayerPrs();
}
void V3d_ColorScaleLayerItem::RedrawLayerPrs()
{
Visual3d_LayerItem::RedrawLayerPrs();
if ( !MyColorScale.IsNull() )
MyColorScale->DrawScale();
}

126
src/V3d/V3d_DirectionalLight.cdl Executable file
View File

@@ -0,0 +1,126 @@
-- File: DirectionalLight.cdl
-- Created: Wed Jan 22 15:51:06 1992
-- Author: GG
-- Update: FDA Oct 15 1994
-- ZOV - Mars 30 1998
---Copyright: Matra Datavision 1992
class DirectionalLight from V3d
---Purpose: Create and modify a directional light source
-- in a viewer.
inherits PositionLight from V3d
uses
Viewer from V3d,
TypeOfOrientation from V3d,
TypeOfRepresentation from V3d,
Coordinate from V3d,
NameOfColor from Quantity,
Parameter from Quantity,
Vertex from Graphic3d,
Structure from Graphic3d,
Group from Graphic3d,
View from V3d
raises BadValue from Viewer
is
Create ( VM : mutable Viewer ;
Direction : TypeOfOrientation = V3d_XposYposZpos;
Color : NameOfColor = Quantity_NOC_WHITE;
Headlight : Boolean from Standard = Standard_False)
returns mutable DirectionalLight ;
---Level: Public
---Purpose : Creates a directional light source in the viewer.
Create ( VM : mutable Viewer ; Xt,Yt,Zt : Coordinate;
Xp,Yp,Zp : Coordinate;
Color : NameOfColor = Quantity_NOC_WHITE;
Headlight : Boolean from Standard = Standard_False)
returns mutable DirectionalLight;
---Level: Public
---Purpose: Creates a directional light source in the viewer.
-- Xt,Yt,Zt : Coordinate of light source Target.
-- Xp,Yp,Zp : Coordinate of light source Position.
-- The others parameters describe before.
--------------------------------------------------------
---Category: Methods to modify the attributes of the light
--------------------------------------------------------
SetDirection ( me : mutable; Direction : TypeOfOrientation ) is static;
---Level: Public
---Purpose : Defines the direction of the light source
-- by a predefined orientation.
SetDirection ( me : mutable; Xm, Ym, Zm : Parameter ) raises BadValue from Viewer is static;
---Level: Public
---Purpose : Defines the direction of the light source by the predefined
-- vector Xm,Ym,Zm.
-- Warning: raises BadValue from Viewer if the vector is null.
SetDisplayPosition (me : mutable; X,Y,Z : Coordinate) is static;
---Level: Public
---Purpose: Defines the point of light source representation.
SetPosition (me : mutable; Xp,Yp,Zp : Coordinate) is redefined;
---Level: Public
---Purpose: Calls SetDisplayPosition method.
---------------------------------------------------
---Category: display methods
---------------------------------------------------
Display(me: mutable; aView: View from V3d;
Representation : TypeOfRepresentation)
is redefined static;
---Level: Public
---Purpose: Display the graphic structure of light source
-- in the choosen view. We have three type of representation
-- - SIMPLE : Only the light source is displayed.
-- - PARTIAL : The light source and the light space are
-- displayed.
-- - COMPLETE : The same representation as PARTIAL.
-- We can choose the "SAMELAST" as parameter of representation
-- In this case the graphic structure representation will be
-- the last displayed.
---------------------------------------------------
---Category: Inquiry methods
---------------------------------------------------
Position ( me; X,Y,Z : out Coordinate ) is redefined;
---Level: Public
---Purpose: Calls DisplayPosition method.
DisplayPosition ( me; X,Y,Z : out Coordinate ) is static;
---Level: Public
---Purpose: Returns the choosen position to represent the light
-- source.
Direction ( me; Vx,Vy,Vz : out Parameter ) is static;
---Level: Public
---Purpose : Returns the Vx,Vy,Vz direction of the light source.
-----------------------------------------
---Category: Private or Protected methods
-----------------------------------------
Symbol ( me ; gsymbol : mutable Group from Graphic3d ;
aView : View from V3d ) is redefined static private;
---Level: Internal
---Purpose: Defines the representation of the directional light source.
fields
MyDisplayPosition: Vertex from Graphic3d;
end DirectionalLight;

297
src/V3d/V3d_DirectionalLight.cxx Executable file
View File

@@ -0,0 +1,297 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_DirectionalLight :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
18-06-96 : FMN ; Ajout MyGraphicStructure1 pour sauvegarder snopick
24-12-97 : FMN ; Remplacement de math par MathGra
31-12-97 : CAL ; Suppression de MathGra
21-01-98 : CAL ; Window de Xw et WNT remplacee par Aspect_Window
23-02-98 : FMN ; Remplacement PI par Standard_PI
30-03-98 : ZOV ; PRO6774 (reconstruction of the class hierarchy and suppressing useless methods)
************************************************************************/
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d.hxx>
#include <V3d_DirectionalLight.ixx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Visual3d_Light.hxx>
#include <Visual3d_ViewManager.hxx>
#include <Visual3d_ContextPick.hxx>
#include <Visual3d_PickDescriptor.hxx>
#include <Visual3d_HSequenceOfPickPath.hxx>
#include <Visual3d_PickPath.hxx>
#include <Viewer_BadValue.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <Aspect_Window.hxx>
//-Constructors
V3d_DirectionalLight::V3d_DirectionalLight(const Handle(V3d_Viewer)& VM, const
V3d_TypeOfOrientation Direction,const Quantity_NameOfColor Name,const Standard_Boolean Headlight):V3d_PositionLight(VM) {
Quantity_Color C(Name) ;
Graphic3d_Vertex T(0.,0.,0.) ;
Graphic3d_Vertex P ;
Graphic3d_Vector V = V3d::GetProjAxis(Direction) ;
MyType = V3d_DIRECTIONAL ;
MyLight = new Visual3d_Light(C,V, Headlight) ;
// On choisit aleatoirement comme cible l'origine
MyTarget = T;
// On deduit une position
P.SetCoord(-V.X(),-V.Y(),-V.Z());
MyDisplayPosition = P;
}
V3d_DirectionalLight::V3d_DirectionalLight(const Handle(V3d_Viewer)& VM,const Standard_Real Xt,const Standard_Real Yt,const Standard_Real Zt,const Standard_Real Xp,const Standard_Real Yp,const Standard_Real Zp,const Quantity_NameOfColor Name,const Standard_Boolean Headlight):V3d_PositionLight(VM) {
Quantity_Color C(Name) ;
Graphic3d_Vertex T(Xt,Yt,Zt) ;
Graphic3d_Vertex P(Xp,Yp,Zp) ;
Graphic3d_Vector V(P,T);
MyType = V3d_DIRECTIONAL ;
V.Normalize();
MyLight = new Visual3d_Light(C,V, Headlight) ;
MyTarget = T;
MyDisplayPosition = P;
}
//-Methods, in order
void V3d_DirectionalLight::SetDirection(const V3d_TypeOfOrientation Direction) {
Graphic3d_Vector V = V3d::GetProjAxis(Direction) ;
MyLight->SetDirection(V) ;
}
void V3d_DirectionalLight::SetDirection(const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz) {
Viewer_BadValue_Raise_if( sqrt( Vx*Vx + Vy*Vy + Vz*Vz ) <= 0.,"V3d_DirectionalLight::SetDirection, null vector" );
Graphic3d_Vector V(Vx,Vy,Vz) ;
V.Normalize() ;
MyLight->SetDirection(V) ;
}
void V3d_DirectionalLight::SetDisplayPosition(const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
Standard_Real Xt,Yt,Zt;
MyDisplayPosition.SetCoord(X,Y,Z) ;
MyTarget.Coord(Xt,Yt,Zt);
SetDirection(Xt-X,Yt-Y,Zt-Z);
}
void V3d_DirectionalLight::SetPosition(const Standard_Real Xp, const Standard_Real Yp, const Standard_Real Zp) {
SetDisplayPosition (Xp,Yp,Zp);
}
void V3d_DirectionalLight::Position(Standard_Real& Xp, Standard_Real& Yp, Standard_Real& Zp)const {
DisplayPosition (Xp,Yp,Zp) ;
}
void V3d_DirectionalLight::DisplayPosition(Standard_Real& Xp, Standard_Real& Yp, Standard_Real& Zp)const {
MyDisplayPosition.Coord(Xp,Yp,Zp) ;
}
void V3d_DirectionalLight::Symbol (const Handle(Graphic3d_Group)& gsymbol, const Handle(V3d_View)& aView) const {
Standard_Real Xi,Yi,Zi,Xf,Yf,Zf,Rayon,PXT,PYT,X,Y,Z,XT,YT,ZT;
Standard_Real A,B,C,Dist,Beta,CosBeta,SinBeta,Coef,X1,Y1,Z1;
Standard_Real DX,DY,DZ,VX,VY,VZ;
Standard_Integer IXP,IYP,j;
TColStd_Array2OfReal MatRot(0,2,0,2);
Graphic3d_Array1OfVertex Line(0,1);
aView->Proj(VX,VY,VZ);
this->DisplayPosition(Xi,Yi,Zi);
Rayon = this->Radius();
aView->Project(Xi,Yi,Zi,PXT,PYT);
aView->Convert(PXT,PYT,IXP,IYP);
// Coord 3d dans le plan de projection de la source.
aView->Convert(IXP,IYP,XT,YT,ZT);
aView->Convert(PXT,PYT+Rayon,IXP,IYP);
aView->Convert(IXP,IYP,X,Y,Z);
X = X+Xi-XT; Y = Y+Yi-YT; Z = Z+Zi-ZT;
Dist = Sqrt( Square(X-Xi) + Square(Y-Yi) + Square(Z-Zi) );
// Axe de rotation.
A = (X-Xi)/Dist;
B = (Y-Yi)/Dist;
C = (Z-Zi)/Dist;
// On dessine une sphere
V3d::CircleInPlane(gsymbol,Xi,Yi,Zi,VX,VY,VZ,Rayon/40.);
for( j=1 ; j<=3 ; j++ ) {
Beta = j * Standard_PI/4.;
CosBeta = Cos(Beta);
SinBeta = Sin(Beta);
Coef = 1. - CosBeta;
MatRot(0,0) = A * A + (1. - A * A) * CosBeta;
MatRot(0,1) = -C * SinBeta + Coef * A * B;
MatRot(0,2) = B * SinBeta + Coef * A * C;
MatRot(1,0) = C * SinBeta + Coef * A * B;
MatRot(1,1) = B * B + (1. - B * B) * CosBeta;
MatRot(1,2) = -A * SinBeta + Coef * B * C;
MatRot(2,0) = -B * SinBeta + Coef * A * C;
MatRot(2,1) = A * SinBeta + Coef * B * C;
MatRot(2,2) = C * C + (1. - C * C) * CosBeta;
Xf = Xi * MatRot(0,0) + Yi * MatRot(0,1) + Zi * MatRot(0,2);
Yf = Xi * MatRot(1,0) + Yi * MatRot(1,1) + Zi * MatRot(1,2);
Zf = Xi * MatRot(2,0) + Yi * MatRot(2,1) + Zi * MatRot(2,2);
// Rotation de la normale
X1 = VX * MatRot(0,0) + VY * MatRot(0,1) + VZ * MatRot(0,2);
Y1 = VX * MatRot(1,0) + VY * MatRot(1,1) + VZ * MatRot(1,2);
Z1 = VX * MatRot(2,0) + VY * MatRot(2,1) + VZ * MatRot(2,2);
VX = X1 + Xi - Xf ; VY = Y1 + Yi - Yf ; VZ = Z1 + Zi - Zf;
V3d::CircleInPlane(gsymbol,Xi,Yi,Zi,VX,VY,VZ,Rayon/40.);
}
// On dessine la fleche
Rayon = this->Radius();
this->Direction(DX,DY,DZ);
X = Xi + DX*Rayon/10.; Y = Yi + DY*Rayon/10.; Z = Zi + DZ*Rayon/10.;
Line(0).SetCoord(Xi,Yi,Zi);
Line(1).SetCoord(X,Y,Z);
gsymbol->Polyline(Line);
V3d::ArrowOfRadius(gsymbol,X,Y,Z,DX,DY,DZ,Standard_PI/15.,Rayon/20.);
}
void V3d_DirectionalLight::Display( const Handle(V3d_View)& aView,
const V3d_TypeOfRepresentation TPres) {
Standard_Real X,Y,Z,Rayon;
Standard_Real X0,Y0,Z0,VX,VY,VZ;
Standard_Real X1,Y1,Z1;
Standard_Real DXRef,DYRef,DZRef,DXini,DYini,DZini;
Standard_Real R1,G1,B1;
V3d_TypeOfRepresentation Pres;
V3d_TypeOfUpdate UpdSov;
// Creation d'une structure slight d'elements reperables (la position de
// la light, et le domaine d'eclairage represente par un cercle)
// Creation d'une structure snopick d'elements non reperables ( cible, meridien et
// parallele ).
Pres = TPres;
Handle(V3d_Viewer) TheViewer = aView->Viewer();
UpdSov = TheViewer->UpdateMode();
TheViewer->SetUpdateMode(V3d_WAIT);
if (!MyGraphicStructure.IsNull()) {
MyGraphicStructure->Disconnect(MyGraphicStructure1);
MyGraphicStructure->Clear();
MyGraphicStructure1->Clear();
if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation;
}
else {
if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE;
Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer());
MyGraphicStructure = slight;
Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer());
MyGraphicStructure1 = snopick;
}
Handle(Graphic3d_Group) glight = new Graphic3d_Group(MyGraphicStructure);
Handle(Graphic3d_Group) gsphere;
if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) gsphere = new Graphic3d_Group(MyGraphicStructure);
Handle(Graphic3d_Group) gnopick = new Graphic3d_Group(MyGraphicStructure1);
MyGraphicStructure1->SetPick(Standard_False);
X0 = MyTarget.X();
Y0 = MyTarget.Y();
Z0 = MyTarget.Z();
//Affichage de la position de la light.
glight->SetPickId(1);
this->Color(Quantity_TOC_RGB,R1,G1,B1);
Quantity_Color Col1(R1,G1,B1,Quantity_TOC_RGB);
Handle(Graphic3d_AspectLine3d) Asp1 = new Graphic3d_AspectLine3d();
Asp1->SetColor(Col1);
glight->SetPrimitivesAspect(Asp1);
this->Symbol(glight,aView);
//Affichage de la sphere de reperage (limite au cercle).
if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) {
Rayon = this->Radius();
aView->Proj(VX,VY,VZ);
gsphere->SetPickId(2);
V3d::CircleInPlane(gsphere,X0,Y0,Z0,VX,VY,VZ,Rayon);
//Affichage du meridien
Quantity_Color Col2(Quantity_NOC_GREEN);
Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d
(Col2,Aspect_TOL_SOLID,1.);
gnopick->SetPrimitivesAspect(Asp2);
// Definition de l'axe du cercle
aView->Up(DXRef,DYRef,DZRef);
this->DisplayPosition(X,Y,Z);
DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
VX = DYRef*DZini - DZRef*DYini;
VY = DZRef*DXini - DXRef*DZini;
VZ = DXRef*DYini - DYRef*DXini;
V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
// Affichage de la parallele
// Definition de l'axe du cercle
aView->Proj(VX,VY,VZ);
aView->Up(X1,Y1,Z1);
DXRef = VY * Z1 - VZ * Y1;
DYRef = VZ * X1 - VX * Z1;
DZRef = VX * Y1 - VY * X1;
this->DisplayPosition(X,Y,Z);
DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
VX = DYRef*DZini - DZRef*DYini;
VY = DZRef*DXini - DXRef*DZini;
VZ = DXRef*DYini - DYRef*DXini;
V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
}
MyGraphicStructure->Connect(MyGraphicStructure1,Graphic3d_TOC_DESCENDANT);
// cout << "MyGraphicStructure exploration \n" << flush; MyGraphicStructure->Exploration();
MyTypeOfRepresentation = Pres;
MyGraphicStructure->Display();
TheViewer->SetUpdateMode(UpdSov);
}
void V3d_DirectionalLight::Direction(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz)const {
Quantity_Color C ;
Graphic3d_Vector V ;
MyLight->Values(C,V) ;
V.Coord(Vx,Vy,Vz) ;
}

69
src/V3d/V3d_LayerMgr.cdl Executable file
View File

@@ -0,0 +1,69 @@
-- File: V3d_LayerMgr.cdl
-- Created: 17/04/2008
-- Author: Customer Support
--
---Copyright: Open Cascade 2008
--
class LayerMgr from V3d inherits TShared from MMgt
---Purpose: Class to manage layers
uses
ExtendedString from TCollection,
Color from Quantity,
Layer from Visual3d,
ColorScale from Aspect,
ColorScale from V3d,
ColorScaleLayerItem from V3d,
View from V3d,
ViewPointer from V3d
is
---Category: Public
Create (aView : View from V3d)
returns mutable LayerMgr from V3d;
Overlay (me)
returns mutable Layer from Visual3d;
---C++: return const &
---C++: inline
View (me)
returns mutable View from V3d;
---C++: inline
ColorScaleDisplay (me : mutable);
ColorScaleErase (me : mutable);
ColorScaleIsDisplayed (me) returns Boolean from Standard;
ColorScale (me) returns mutable ColorScale from Aspect;
Compute (me : mutable);
---Purpose: Recompute layer with objects
Resized(me : mutable);
---Category: Protected
Begin (me : mutable) returns Boolean from Standard is virtual protected;
---Purpose: Begin layers recomputation
Redraw (me : mutable) is virtual protected;
---Purpose: Perform layers recomputation
End (me : mutable) is virtual protected;
---Purpose: End layers recomputation
fields
myView : ViewPointer from V3d is protected;
myOverlay : Layer from Visual3d is protected;
myColorScale : ColorScale from V3d is protected;
myColorScaleLayerItem: ColorScaleLayerItem from V3d is protected;
end LayerMgr;

101
src/V3d/V3d_LayerMgr.cxx Executable file
View File

@@ -0,0 +1,101 @@
// File: V3d_LayerMgr.cxx
// Created: Thu Apr 17 12:34:25 2008
// Author: Customer Support
//Copyright: Open Cascade 2008
#include <V3d_LayerMgr.ixx>
#include <Aspect_Window.hxx>
#include <Visual3d_View.hxx>
#include <V3d_ColorScale.hxx>
#include <Graphic3d_NameOfFont.hxx>
V3d_LayerMgr::V3d_LayerMgr( const Handle(V3d_View)& AView )
: myView(AView.operator->())
{
Handle(Visual3d_View) theView = View()->View();
if ( !theView.IsNull() ) {
Handle(Visual3d_ViewManager) theViewMgr = theView->ViewManager();
if ( !theViewMgr.IsNull() ) {
V3d_LayerMgr* that = (V3d_LayerMgr*)this;
that->myOverlay = new Visual3d_Layer( theViewMgr, Aspect_TOL_OVERLAY, Standard_False );
}
}
}
void V3d_LayerMgr::Compute()
{
if (Begin())
{
Redraw();
End();
}
}
void V3d_LayerMgr::Resized()
{
Compute();
}
void V3d_LayerMgr::ColorScaleDisplay()
{
ColorScale();
myColorScale->Display();
myOverlay->AddLayerItem( myColorScaleLayerItem );
}
void V3d_LayerMgr::ColorScaleErase()
{
if ( !myColorScale.IsNull() )
myColorScale->Erase();
myOverlay->RemoveLayerItem( myColorScaleLayerItem );
}
Standard_Boolean V3d_LayerMgr::ColorScaleIsDisplayed() const
{
return ( myColorScale.IsNull() ? Standard_False : myColorScale->IsDisplayed() );
}
Handle(Aspect_ColorScale) V3d_LayerMgr::ColorScale() const
{
if ( myColorScale.IsNull() ) {
Handle(V3d_LayerMgr) that = this;
that->myColorScale = new V3d_ColorScale( this );
that->myColorScaleLayerItem = new V3d_ColorScaleLayerItem( that->myColorScale );
}
return myColorScale;
}
Standard_Boolean V3d_LayerMgr::Begin()
{
if ( myOverlay.IsNull() )
return Standard_False;
const Handle(Aspect_Window) &theWin = View()->Window();
if ( theWin.IsNull() )
return Standard_False;
Standard_Integer aW( 0 ), aH( 0 );
theWin->Size( aW, aH );
myOverlay->Clear();
myOverlay->SetViewport( aW, aH ); //szv:!!!
myOverlay->Begin();
myOverlay->SetTextAttributes( Graphic3d_NOF_ASCII_MONO, Aspect_TODT_SUBTITLE, Quantity_Color() );
myOverlay->SetOrtho( 0, Max( aW, aH ), Max( aW, aH ), 0, Aspect_TOC_TOP_LEFT );
return Standard_True;
}
void V3d_LayerMgr::Redraw()
{
}
void V3d_LayerMgr::End()
{
if ( !myOverlay.IsNull() )
myOverlay->End();
}

15
src/V3d/V3d_LayerMgr.lxx Executable file
View File

@@ -0,0 +1,15 @@
// File: V3d_LayerMgr.lxx
// Created: Thu Apr 17 12:34:25 2008
// Author: Customer Support
//Copyright: Open Cascade 2008
inline const Handle(Visual3d_Layer)& V3d_LayerMgr::Overlay() const
{
return myOverlay;
}
inline Handle(V3d_View) V3d_LayerMgr::View() const
{
return Handle(V3d_View)(myView);
}

133
src/V3d/V3d_Light.cdl Executable file
View File

@@ -0,0 +1,133 @@
-- File: Light.cdl
-- Created: Fri Jan 17 11:54:50 1992
-- Author: GG
-- Update: FDA Oct 15 1994
-- ZOV - Mars 30 1998
-- GG IMP230300 Add SetColor() and Color() methods
-- GG - 23/11/00 Add IsDisplayed() method
---Copyright: Matra Datavision 1992
deferred class Light from V3d
---Purpose: Defines services on Light type objects..
inherits
TShared
uses
TypeOfLight from V3d,
TypeOfRepresentation from V3d,
TypeOfPickLight from V3d,
View from V3d,
Viewer from V3d,
Coordinate from V3d,
Light from Visual3d,
TypeOfColor from Quantity,
NameOfColor from Quantity,
Color from Quantity,
Parameter from Quantity,
PlaneAngle from Quantity,
Group from Graphic3d,
Vertex from Graphic3d,
Structure from Graphic3d
raises
BadValue from Viewer
is
Initialize( VM : mutable Viewer ) ;
--------------------------------------------------------
---Category: Methods to modify the attributes of the Light
--------------------------------------------------------
SetColor( me : mutable; Type: TypeOfColor ; V1 , V2 , V3 : Parameter)
is static;
---Level: Public
---Purpose: Defines the colour of a light source
-- according to the type of colour definition
-- and the three corresponding values.
SetColor( me : mutable; Name : NameOfColor ) is static;
---Level: Public
---Purpose: Defines the colour of a light source by giving
-- the name of the colour in the form Quantity_NOC_xxxx .
SetColor( me : mutable; Name : Color ) is static;
---Level: Public
---Purpose: Defines the colour of a light source by giving
-- the basic colour.
---------------------------------------------------
---Category: Inquire methods
---------------------------------------------------
Color ( me; Type: TypeOfColor ; V1 , V2 , V3 : out Parameter )
is static;
---Level: Public
---Purpose: Returns the colour of the light source depending of
-- the color type.
Color( me ; Name : out NameOfColor ) is static;
---Level: Public
---Purpose: Returns the colour of the light source.
Color( me ) returns Color is static;
---Level: Public
---Purpose: Returns the colour of the light source.
Type ( me ) returns TypeOfLight from V3d is static;
---Level: Public
---Purpose: Returns the Type of the Light
Headlight ( me ) returns Boolean from Standard is static;
---Level: Public
---Purpose: returns true if the light is a headlight
IsDisplayed( me ) returns Boolean from Standard;
---Level: Public
---Purpose: Returns TRUE when a light representation is displayed
-----------------------------------------
---Category: Private or Protected methods
-----------------------------------------
SymetricPointOnSphere ( myclass ; aView : View from V3d;
Center : Vertex from Graphic3d;
aPoint : Vertex from Graphic3d;
Radius : Parameter;
X,Y,Z : out Coordinate;
VX,VY,VZ : out Parameter )
is protected ;
---Level: Internal
---Purpose: Returns the symetric point coordinates of "aPoint"
-- on the sphere of center "Center" and radius "Radius".
-- VX,VY,VZ is the project vector of view.
Light ( me ) returns mutable Light from Visual3d is static private ;
---Level: Internal
---Purpose: Returns the Light of the associated Visual3d.
fields
MyType: TypeOfLight from V3d is protected ;
MyLight: Light from Visual3d is protected ;
MyGraphicStructure: Structure from Graphic3d is protected;
MyGraphicStructure1: Structure from Graphic3d is protected;
friends
SetLightOn from class View from V3d
( me : mutable ; MyLight : Light from V3d ),
SetLightOn from class View from V3d ( me : mutable ),
SetLightOff from class View from V3d
( me : mutable ; MyLight : Light from V3d ),
SetLightOff from class View from V3d ( me : mutable )
end Light;

147
src/V3d/V3d_Light.cxx Executable file
View File

@@ -0,0 +1,147 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_SpotLight :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
18-06-96 : FMN ; Ajout MyGraphicStructure1 pour sauvegarder snopick
30-03-98 : ZOV ; PRO6774 (reconstruction of the class hierarchy and suppressing useless methods)
IMP230300: GG Add SetColor() and Color() methods
IMP231100: GG Add IsDisplayed() method
************************************************************************/
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d.hxx>
#include <V3d_Light.ixx>
//-Declarations
//-Aliases
//-Global data definitions
//-Local data definitions
//-Constructors
V3d_Light::V3d_Light(const Handle(V3d_Viewer)& VM) {
MyType = V3d_AMBIENT ;
VM->AddLight(this) ;
}
//-Methods, in order
Handle(Visual3d_Light) V3d_Light::Light() const {
return MyLight ;
}
void V3d_Light::SetColor(const Quantity_TypeOfColor Type, const Standard_Real v1, const Standard_Real v2, const Standard_Real v3) {
Standard_Real V1 = v1 ;
Standard_Real V2 = v2 ;
Standard_Real V3 = v3 ;
if( V1 < 0. ) V1 = 0. ; else if( V1 > 1. ) V1 = 1. ;
if( V2 < 0. ) V2 = 0. ; else if( V2 > 1. ) V2 = 1. ;
if( V3 < 0. ) V3 = 0. ; else if( V3 > 1. ) V3 = 1. ;
Quantity_Color C(V1,V2,V3,Type) ;
MyLight->SetColor(C) ;
}
void V3d_Light::SetColor(const Quantity_NameOfColor Name) {
Quantity_Color C(Name) ;
MyLight->SetColor(C) ;
}
void V3d_Light::SetColor(const Quantity_Color& aColor) {
MyLight->SetColor(aColor) ;
}
void V3d_Light::Color(const Quantity_TypeOfColor Type, Standard_Real& V1, Standard_Real& V2, Standard_Real& V3) const {
Quantity_Color C ;
C = MyLight->Color() ;
C.Values(V1,V2,V3,Type) ;
}
void V3d_Light::Color(Quantity_NameOfColor& Name) const{
Quantity_Color C ;
C = MyLight->Color() ;
Name = C.Name();
}
Quantity_Color V3d_Light::Color() const{
return MyLight->Color();
}
V3d_TypeOfLight V3d_Light::Type() const {
return MyType;
}
Standard_Boolean V3d_Light::Headlight() const {
return MyLight->Headlight();
}
void V3d_Light::SymetricPointOnSphere (const Handle(V3d_View)& aView, const Graphic3d_Vertex &Center, const Graphic3d_Vertex &aPoint, const Standard_Real Rayon, Standard_Real& X, Standard_Real& Y, Standard_Real& Z, Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ ) {
Standard_Real X0,Y0,Z0,XP,YP,ZP;
Standard_Real PXP,PYP,DeltaX,DeltaY,DeltaZ;
Standard_Real A,B,C,Delta,Lambda;
Standard_Integer IPX,IPY;
Center.Coord(X0,Y0,Z0);
aPoint.Coord(XP,YP,ZP);
aView->Project(XP,YP,ZP,PXP,PYP);
aView->Convert(PXP,PYP,IPX,IPY);
aView->ProjReferenceAxe(IPX,IPY,X,Y,Z,VX,VY,VZ);
DeltaX = X0 - XP;
DeltaY = Y0 - YP;
DeltaZ = Z0 - ZP;
// On recherche le point d'intersection des droites definies
// par :
// - Droite passant par le point de projection et l'oeil
// si on est en perspective, parralele a la normale de la
// vue si on a une vue axonometrique.
// position dans la vue est // a la normale de la vue
// - La distance position de la camera cible est egale au
// rayon.
A = VX*VX + VY*VY + VZ*VZ ;
B = -2. * (VX*DeltaX + VY*DeltaY + VZ*DeltaZ);
C = DeltaX*DeltaX + DeltaY*DeltaY + DeltaZ*DeltaZ
- Rayon*Rayon ;
Delta = B*B - 4.*A*C;
if ( Delta >= 0 ) {
Lambda = (-B + Sqrt(Delta))/(2.*A);
if ( Lambda >= -0.0001 && Lambda <= 0.0001 )
Lambda = (-B - Sqrt(Delta))/(2.*A);
X = XP + Lambda*VX;
Y = YP + Lambda*VY;
Z = ZP + Lambda*VZ;
}
else {
X = XP; Y = YP; Z = ZP;
}
}
Standard_Boolean V3d_Light::IsDisplayed() const {
if( MyGraphicStructure.IsNull() ) return Standard_False;
return MyGraphicStructure->IsDisplayed();
}

21
src/V3d/V3d_ListOfTransient.cdl Executable file
View File

@@ -0,0 +1,21 @@
-- File: V3d_ListOfTransient.cdl
-- Created: Wed May 17 15:17:30 1995
-- Author: Mister rmi
-- <rmi@pernox>
---Copyright: Matra Datavision 1995
private class ListOfTransient from V3d inherits ListOfTransient from TColStd
is
Create returns ListOfTransient from V3d;
Contains(me; aTransient: Transient from Standard)
returns Boolean from Standard
is static;
Remove(me: in out; aTransient: Transient from Standard)
is static;
end ListOfTransient from V3d;

29
src/V3d/V3d_ListOfTransient.cxx Executable file
View File

@@ -0,0 +1,29 @@
#include <TColStd_ListOfTransient.hxx>
#include <V3d_ListOfTransient.ixx>
#include <TColStd_ListIteratorOfListOfTransient.hxx>
V3d_ListOfTransient::V3d_ListOfTransient():TColStd_ListOfTransient() {}
Standard_Boolean V3d_ListOfTransient::Contains(const Handle(Standard_Transient)& aTransient) const {
if(IsEmpty()) return Standard_False;
TColStd_ListIteratorOfListOfTransient i(*this);
Standard_Boolean found = Standard_False;
for(; i.More() && !found; i.Next()) {
found = i.Value() == aTransient;
}
return found;
}
void V3d_ListOfTransient::Remove(const Handle(Standard_Transient)& aTransient){
if(!IsEmpty()){
TColStd_ListIteratorOfListOfTransient i(*this);
Standard_Boolean found = Standard_False;
while(i.More() && !found)
if( i.Value() == aTransient ) {
TColStd_ListOfTransient::Remove(i);}
else {
i.Next();}
}
}

View File

@@ -0,0 +1,54 @@
-- File: OrthographicView.cdl
-- Created: Tue Jan 21 16:21:26 1992
-- Author: GG
--
---Copyright: Matra Datavision 1992
class OrthographicView from V3d
---Version:
---Purpose: Define an orthographic view.
-- See the methods of the Class View
---Keywords: View,Orthographic
---Warning:
---References:
inherits View from V3d
uses
Viewer from V3d,
PerspectiveView from V3d
is
Create ( VM : mutable Viewer ) returns mutable OrthographicView;
---Level : Public
---Purpose: Define an orthographic view in the viewer VM.
Create ( VM : mutable Viewer ; V : PerspectiveView )
returns mutable OrthographicView;
---Level : Public
---Purpose: Defines an orthographic view from a Perspective view.
-- The parameters of the original view are duplicated
-- in the resulting view (Projection,Mapping,Context) .
-- The view thus created must be activated in a new
-- window.
Create ( VM : mutable Viewer ; V : OrthographicView )
returns mutable OrthographicView;
---Level : Public
---Purpose: Defines one orthographic view from another.
-- The parameters of the original view are duplicated
-- in the resulting view. (Projection,Mapping,Context) .
-- The view thus created must be activated in a new window.
Copy ( me ) returns mutable OrthographicView from V3d is static;
---Level : Public
end OrthographicView;

View File

@@ -0,0 +1,59 @@
// File V3d_OrthographicView.cxx
// Created September 1992
// Author GG
// Modified 25-02-98 : FMN ; PERF.27: Optimization of view creation from an existing view
//-Copyright MatraDatavision 1991,1992
//-Version
//-Design
//-Warning
//-References
//-Language C++ 2.1
// for Test method
// for the class
#include <V3d_View.hxx>
#include <V3d_OrthographicView.ixx>
#include <V3d_PerspectiveView.hxx>
//-Declarations
//-Aliases
//-Global data definitions
//-Constructors
V3d_OrthographicView::V3d_OrthographicView (const Handle(V3d_Viewer)& VM):V3d_View (VM) {
MyType = V3d_ORTHOGRAPHIC ;
MyViewMapping.SetProjection(Visual3d_TOP_PARALLEL) ;
SetViewMappingDefault() ;
SetViewOrientationDefault() ;
}
V3d_OrthographicView::V3d_OrthographicView (const Handle(V3d_Viewer)& VM, const Handle(V3d_PerspectiveView)& V):V3d_View (VM,V) {
MyType = V3d_ORTHOGRAPHIC ;
MyViewMapping.SetProjection(Visual3d_TOP_PARALLEL) ;
SetZoom(0.1, Standard_True);
SetViewMappingDefault() ;
SetViewOrientationDefault() ;
}
V3d_OrthographicView::V3d_OrthographicView (const Handle(V3d_Viewer)& VM, const Handle(V3d_OrthographicView)& V):V3d_View (VM,V) {
MyType = V3d_ORTHOGRAPHIC ;
MyViewMapping.SetProjection(Visual3d_TOP_PARALLEL) ;
SetViewMappingDefault() ;
SetViewOrientationDefault() ;
}
Handle(V3d_OrthographicView) V3d_OrthographicView::Copy () const {
return new V3d_OrthographicView(this->Viewer(),this);}

94
src/V3d/V3d_PerspectiveView.cdl Executable file
View File

@@ -0,0 +1,94 @@
-- File: PerspectiveView.cdl
-- Created: Tue Jan 21 15:28:48 1992
-- Author: GG
-- Update:
---Copyright: Matra Datavision 1992
class PerspectiveView from V3d
---Purpose : Creates and modifies a perspective
-- See the methods of the class View
inherits View from V3d
uses
Viewer from V3d,
OrthographicView from V3d,
PlaneAngle from Quantity
raises
BadValue from Viewer
is
Create ( VM : mutable Viewer ) returns mutable PerspectiveView;
---Level: Public
---Purpose: Defines a perspective view in a viewer VM.
-- The default angle of opening is given
-- by the viewer.
Create ( VM : mutable Viewer ; V : OrthographicView )
returns mutable PerspectiveView;
---Level: Public
---Purpose: Creates a perspective view from the parameters
-- of an orthographic view.
-- The parameters of the original view are duplicated
-- in the resulting view (Projection,Mapping,Context) .
-- The view thus created must be activated in a new window.
-- The default angle of opening is given
-- by the viewer.
Create ( VM : mutable Viewer ; V : PerspectiveView )
returns mutable PerspectiveView ;
---Level: Public
---Purpose: Creates one perspective view from another.
-- The parameters of the original view are duplicated
-- in the resulting view (Projection,Mapping,Context) .
-- The view thus created must be activated in a new window.
Copy ( me ) returns mutable PerspectiveView from V3d is static;
---Level: Public
--------------------------------------------------------
---Category: Methods to modify the status of the view
--------------------------------------------------------
SetAngle ( me : mutable ; Angle : PlaneAngle )
---Level: Public
---Purpose: Modifies the angle of opening of the perspective in RADIANS.
-- The projection window is resized according to the
-- formula :
-- TAN(Angle/2) = Size/Length
-- Size expresses the smallest dimension of the window.
-- Length expresses the focal length.
raises BadValue from Viewer
---Purpose: Warning! raises BadValue from Viewer
-- if the opening angle is <= 0 or >= PI
is static;
Angle ( me ) returns PlaneAngle is static;
---Level: Public
---Purpose: Returns the value of the angle of opening.
SetPerspective ( me : mutable ; Angle : PlaneAngle;
UVRatio, ZNear, ZFar : Real )
---Level: Public
---Purpose: Modifies the viewing perspective volume by given
-- angle of opening of the perspective in RADIANS,
-- aspect ratio of window width to its height and
-- near and far clipping planes
raises BadValue from Viewer
-- if the opening angle is <= 0 or >= PI or
-- the ZNear<0, ZFar<0 or ZNear>=Zfar.
is static;
end PerspectiveView;

137
src/V3d/V3d_PerspectiveView.cxx Executable file
View File

@@ -0,0 +1,137 @@
// File V3d_PerspectiveView.cxx
// Created September 1992
// Author GG
// Modified 07-10-96 : CQ ; correction PRO4522
// Modified 23-02-98 : FMN ; Replace PI by Standard_PI
// Modified 25-02-98 : FMN ; PERF.27: Optimisation of view creation from an existing view
// Modified 02-09-98 : FMN ; Correction problem of angle calculation in V3d_PerspectiveView::Angle().
// Modified 23-11-98 : FMN ; PRO14896: Correction of the management of the perspective (cf Programming Guide)
// If the angle is modified the WindowLimit changes not the focal.
// 22-12-98 : FMN ; Rename CSF_WALKTHROW into CSF_WALKTHROUGH
// IMP240100 //GG -> Activates WalkThrough model.
//-Copyright MatraDatavision 1991,1992
//-Version
//-Design
//-Warning
//-References
//-Language C++ 2.1
// for Test method
// for the class
#include <V3d_View.hxx>
#include <V3d_PerspectiveView.ixx>
#include <Visual3d_View.hxx>
#include <Viewer_BadValue.hxx>
V3d_PerspectiveView::V3d_PerspectiveView (const Handle(V3d_Viewer)& VM):V3d_View (VM,V3d_PERSPECTIVE) {
MyViewMapping.SetProjection(Visual3d_TOP_PERSPECTIVE) ;
SetAngle(VM->DefaultAngle()) ;
// SetZoom(10.0, Standard_True);
SetViewMappingDefault() ;
SetViewOrientationDefault() ;
}
V3d_PerspectiveView::V3d_PerspectiveView (const Handle(V3d_Viewer)& VM, const Handle(V3d_OrthographicView)& V):V3d_View (VM,V,V3d_PERSPECTIVE) {
MyViewMapping.SetProjection(Visual3d_TOP_PERSPECTIVE) ;
SetAngle(VM->DefaultAngle()) ;
// SetZoom(10.0, Standard_True);
SetViewMappingDefault() ;
SetViewOrientationDefault() ;
}
V3d_PerspectiveView::V3d_PerspectiveView (const Handle(V3d_Viewer)& VM, const Handle(V3d_PerspectiveView)& V):V3d_View (VM,V,V3d_PERSPECTIVE) {
MyViewMapping.SetProjection(Visual3d_TOP_PERSPECTIVE) ;
// SetZoom(10.0, Standard_True);
SetViewMappingDefault() ;
SetViewOrientationDefault() ;
}
Handle(V3d_PerspectiveView) V3d_PerspectiveView::Copy() const {
return new V3d_PerspectiveView(this->Viewer(),this);}
//-Methods, in order
void V3d_PerspectiveView::SetAngle(const Standard_Real Angle) {
Standard_Real focale,Umin,Vmin,Umax,Vmax,Dxv,Dyv,Rap,Xrp,Yrp;
Viewer_BadValue_Raise_if ( Angle <= 0. || Angle >= Standard_PI, "V3d_PerspectiveView::SetAngle, bad angle");
MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
Dxv = Abs(Umax - Umin)/2. ; Dyv = Abs(Vmax - Vmin)/2.;
focale = Focale();
Xrp = (Umin + Umax)/2. ; Yrp = (Vmin + Vmax)/2. ;
Rap = Dxv / Dyv;
if( Dxv >= Dyv ) {
Dyv = Abs(focale * tan(Angle/2.)) ;
Dxv = Rap * Dyv;
} else {
Dxv = Abs(focale * tan(Angle/2.)) ;
Dyv = Dxv / Rap;
}
Umin = Xrp - Dxv ; Umax = Xrp + Dxv ;
Vmin = Yrp - Dyv ; Vmax = Yrp + Dyv ;
MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ;
MyView->SetViewMapping(MyViewMapping) ;
ImmediateUpdate();
}
Standard_Real V3d_PerspectiveView::Angle()const {
// Graphic3d_Vertex Prp ;
Standard_Real focale,Umin,Vmin,Umax,Vmax,Dxv,Dyv ;
Standard_Real angle = Standard_PI ;
MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ;
focale = Focale() ;
Dxv = (Umax - Umin)/2. ; Dyv = (Vmax - Vmin)/2. ;
if( focale > 0. ) {
if( Dxv >= Dyv ) {
angle = 2.*atan(Dyv/focale) ;
} else {
angle = 2.*atan(Dxv/focale) ;
}
}
return angle ;
}
void V3d_PerspectiveView::SetPerspective(const Standard_Real Angle, const Standard_Real UVRatio,
const Standard_Real ZNear, const Standard_Real ZFar)
{
Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Zrp,du,dv;
Viewer_BadValue_Raise_if ( ZNear <= 0. || ZFar <= 0. || ZNear >= ZFar, "V3d_PerspectiveView::SetPerspective, bad distances");
Viewer_BadValue_Raise_if ( Angle <= 0. || Angle >= Standard_PI, "V3d_PerspectiveView::SetAngle, bad angle");
Graphic3d_Vertex PRP = MyViewMapping.ProjectionReferencePoint() ;
Xrp = Yrp = Zrp = 0.;
PRP.SetCoord(Zrp, Yrp, Zrp);
MyViewMapping.SetProjectionReferencePoint(PRP);
Standard_Real size = (ZFar - ZNear) / 2.;
MyViewMapping.SetFrontPlaneDistance(size);
MyViewMapping.SetBackPlaneDistance(-size);
MyViewMapping.SetViewPlaneDistance(size);
// recompute window limits by mapping to view plane
dv = Abs(ZNear * tan(Angle/2.));
du = dv * UVRatio;
Umin = -du; Umax = du;
Vmin = -dv; Vmax = dv;
MyViewMapping.SetWindowLimit(Umin, Vmin, Umax, Vmax);
MyView->SetViewMapping(MyViewMapping) ;
ImmediateUpdate();
}

116
src/V3d/V3d_Plane.cdl Executable file
View File

@@ -0,0 +1,116 @@
-- File: Plane.cdl
-- Created: Fri Jan 17 11:54:50 1992
-- Author: GG
-- Modified: GG 23/11/00 Add Display(),Erase(),IsDisplayed() methods
---Copyright: Matra Datavision 1992
class Plane from V3d
inherits
TShared
---Purpose: Defines the services of Plane type objects. Only
-- the creation and editing of the functions is dealt
-- with here.
-- Warning: The representation of the clipping plane must be
-- calculated by the application by means of Graphic3d.
-- Editing of this representation must be coherent with
-- respect to the position of the plane.
uses
Viewer from V3d,
View from V3d,
ClipPlane from Visual3d,
Structure from Graphic3d,
Parameter from Quantity,
Color from Quantity
raises
BadValue from Viewer
is
--
-- The methods :
--
Create ( VM : Viewer ; A: Parameter = 0.0;
B: Parameter = 0.0;
C: Parameter = 1.0;
D: Parameter = 0.0
) returns mutable Plane
---Level : Public
---Purpose: Creates a clipping plane using the equation :
-- <A>*X + <B>*Y + <C>*Z + <D> = 0.0
raises BadValue from Viewer;
---Purpose: Warning! raises BadValue from Viewer
-- if the norm of the plane is NULL.
--------------------------------------------------------
---Category: Methods to modify the Attributs of the Plane
--------------------------------------------------------
SetPlane( me : mutable; A,B,C,D : Parameter)
---Level : Public
---Purpose: Modifies the plane equation.
raises BadValue from Viewer
---Purpose: Warning! raises BadValue from Viewer
-- if the norm of the plane is NULL.
-- If the norm of the plane is NULL.
is static;
Display(me: mutable; aView: View from V3d;
aColor: Color from Quantity= Quantity_NOC_GRAY)
---Level : Public
---Purpose: Display the plane representation
-- in the choosen view.
is virtual;
Erase(me: mutable) is static;
---Level: Public
---Purpose: Erase the plane representation.
---------------------------------------------------
---Category: Inquire methods
---------------------------------------------------
Plane( me ; A,B,C,D : out Parameter ) is static;
---Level : Public
---Purpose: Returns the parameters of the plane .
IsDisplayed( me ) returns Boolean from Standard is static;
---Level : Public
---Purpose: Returns TRUE when the plane representation is displayed
-----------------------------------------
---Category: Private or Protected methods
-----------------------------------------
Plane( me) returns mutable ClipPlane from Visual3d is static private ;
---Level : Internal
---Purpose: Returns the associated plane from Visual3d.
Update( me : mutable ) is static private;
---Level : Internal
---Purpose: Updates the the plane representation.
fields
MyPlane: ClipPlane from Visual3d ;
MyGraphicStructure: Structure from Graphic3d is protected;
friends
SetPlaneOn from class View from V3d ( me : mutable ),
SetPlaneOn from class View from V3d
( me : mutable ; Plane : Plane from V3d ),
SetPlaneOff from class View from V3d ( me : mutable ),
SetPlaneOff from class View from V3d
( me : mutable ; Plane : Plane from V3d )
end Plane;

121
src/V3d/V3d_Plane.cxx Executable file
View File

@@ -0,0 +1,121 @@
// File V3d_Plane.cxx
// Created September 1992
// Author GG
//-Copyright MatraDatavision 1991,1992
//-Version
//-Design
//-Warning
//-References
//-Language C++ 2.1
// for the class
#include <V3d.hxx>
#include <V3d_Plane.ixx>
#include <Viewer_BadValue.hxx>
//-Constructors
V3d_Plane::V3d_Plane(const Handle(V3d_Viewer)& VM, const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D) {
Viewer_BadValue_Raise_if( sqrt(A*A + B*B + C*C) <= 0., "V3d_Plane::V3d_Plane, bad plane coefficients");
MyPlane = new Visual3d_ClipPlane(A,B,C,D) ;
VM->AddPlane(this) ;
}
//-Methods, in order
void V3d_Plane::SetPlane( const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D) {
Viewer_BadValue_Raise_if( sqrt(A*A + B*B + C*C) <= 0., "V3d_Plane::SetPlane, bad plane coefficients");
MyPlane->SetPlane(A,B,C,D) ;
if( IsDisplayed() ) {
Update();
}
}
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
void V3d_Plane::Display(const Handle(V3d_View)& aView,
const Quantity_Color& aColor) {
Handle(V3d_Viewer) theViewer = aView->Viewer();
if (!MyGraphicStructure.IsNull()) {
MyGraphicStructure->Clear();
}
Standard_Real size = theViewer->DefaultViewSize();
Standard_Real offset = size/10000.;
MyGraphicStructure = new Graphic3d_Structure(theViewer->Viewer());
Handle(Graphic3d_Group) group = new Graphic3d_Group(MyGraphicStructure);
Handle(Graphic3d_AspectFillArea3d) aspect =
new Graphic3d_AspectFillArea3d();
Graphic3d_MaterialAspect plastic(Graphic3d_NOM_PLASTIC);
plastic.SetColor(aColor);
plastic.SetTransparency(0.5);
aView->SetTransparency(Standard_True);
aspect->SetFrontMaterial(plastic);
// aspect->SetInteriorStyle (Aspect_IS_SOLID);
aspect->SetInteriorStyle (Aspect_IS_HATCH);
aspect->SetHatchStyle (Aspect_HS_GRID_DIAGONAL_WIDE);
MyGraphicStructure->SetPrimitivesAspect(aspect);
Graphic3d_Array1OfVertex p(1,4);
p(1).SetCoord(-size/2.,-size/2.,offset);
p(2).SetCoord(-size/2., size/2.,offset);
p(3).SetCoord( size/2., size/2.,offset);
p(4).SetCoord( size/2.,-size/2.,offset);
group->Polygon(p);
MyGraphicStructure->Display(0);
Update();
}
void V3d_Plane::Erase() {
if (!MyGraphicStructure.IsNull()) MyGraphicStructure->Erase();
}
void V3d_Plane::Plane(Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D)const {
MyPlane->Plane(A,B,C,D) ;
}
Handle(Visual3d_ClipPlane) V3d_Plane::Plane()const {
return MyPlane ;
}
Standard_Boolean V3d_Plane::IsDisplayed() const {
if( MyGraphicStructure.IsNull() ) return Standard_False;
return MyGraphicStructure->IsDisplayed();
}
#include <gp_Pln.hxx>
void V3d_Plane::Update() {
if( !MyGraphicStructure.IsNull() ) {
TColStd_Array2OfReal matrix(1,4,1,4);
Standard_Real A,B,C,D;
MyPlane->Plane(A,B,C,D) ;
gp_Pln plan(A,B,C,D);
gp_Trsf trsf;
trsf.SetTransformation(plan.Position());
trsf.Invert();
for (Standard_Integer i=1; i<=3; i++){
for (Standard_Integer j=1; j<=4; j++){
matrix.SetValue(i,j,trsf.Value(i,j));
}
}
matrix.SetValue(4,1,0.);
matrix.SetValue(4,2,0.);
matrix.SetValue(4,3,0.);
matrix.SetValue(4,4,1.);
MyGraphicStructure->SetTransform(matrix,Graphic3d_TOC_REPLACE);
}
}

145
src/V3d/V3d_PositionLight.cdl Executable file
View File

@@ -0,0 +1,145 @@
-- File: PositionLight.cdl
-- Created: Fri Nov 21 17:49:00 1997
-- Author: ZOV
-- ZOV - Mars 30 1998
---Copyright: Matra Datavision 1992
deferred class PositionLight from V3d
inherits Light from V3d
---Purpose: Base class for Positional, Spot and Directional Light classes
uses
Viewer from V3d,
Coordinate from V3d,
View from V3d,
TypeOfRepresentation from V3d,
TypeOfPickLight from V3d,
NameOfColor from Quantity,
Coefficient from Quantity,
Parameter from Quantity,
Structure from Graphic3d,
Vertex from Graphic3d,
Group from Graphic3d
raises BadValue from Viewer
is
Initialize( VM : mutable Viewer ) ;
--------------------------------------------------------
---Category: Methods to modify the Attributes of the Light
--------------------------------------------------------
SetPosition ( me : mutable; X,Y,Z : Coordinate ) is deferred;
---Level: Public
---Purpose: Defines the position of the light source. Should be redefined!
SetTarget (me : mutable; X,Y,Z : Coordinate);
---Level: Public
---Purpose: Defines the target of the light (the center
-- of the sphere)
SetRadius ( me : mutable; Radius : Parameter) raises BadValue from Viewer is static;
---Level: Public
---Purpose: Define the radius.
---Warning: raises BadValue from Viewer if the radius is <= 0 or if the light is directional
OnHideFace (me : mutable; aView : View from V3d);
---Level: Public
---Purpose: Calculate the position of the light, on the hide face
-- of the picking sphere.
OnSeeFace (me : mutable; aView : View from V3d);
---Level: Public
---Purpose: Calculate the position of the light, on the seen face
-- of the picking sphere.
Tracking (me : mutable; aView : View from V3d;
WathPick : TypeOfPickLight from V3d;
Xpix,Ypix : Integer from Standard) is static;
---Level: Public
---Purpose: Tracking the light position, or the light space,
-- or the radius of the light space, that depends of
-- initial picking "WhatPick" (see the pick method).
-- If WhatPick is SPACELIGHT, then the parameters
-- Xpix, Ypix are the coordinates of a translation vector.
---------------------------------------------------
---Category: Displaying methods
---------------------------------------------------
Display(me: mutable; aView: View from V3d; Representation : TypeOfRepresentation = V3d_SIMPLE)
is virtual;
---Level: Public
---Purpose: Display the graphic structure of light source
-- in the choosen view. We have three type of representation
-- - SIMPLE : Only the light source is displayed.
-- - PARTIAL : The light source and the light space are
-- displayed.
-- - COMPLETE : The light source, the light space and the
-- radius of light space are displayed.
-- We can choose the "SAMELAST" as parameter of representation
-- In this case the graphic structure representation will be
-- the last displayed.
Erase(me: mutable) is static;
---Level: Public
---Purpose: Erase the graphic structure of light source.
---------------------------------------------------
---Category: Inquire methods
---------------------------------------------------
Pick ( me; aView: View from V3d; Xpix, Ypix: Integer from Standard)
returns TypeOfPickLight from V3d is virtual;
---Level: Public
---Purpose: Returns the type of pick element.
-- "POSITIONLIGHT" : Representation of position light.
-- "SPACELIGHT" : Representation of lighting space.
-- "RADIUSLIGHT" : Representation of lighting space radius.
-- "NOTHING" : Any component of light.
-- Determinate which type of tracking apply.
Radius (me ) returns Parameter is static;
---Level: Public
---Purpose: Returns the radius of the picking sphere.
SeeOrHide (me; aView: View from V3d) returns Boolean is static;
---Level: Public
---Purpose: Returns the visibility status
-- If True the source is visible.
-- If False it's hidden.
Position ( me; X,Y,Z : out Coordinate ) is deferred;
---Level: Public
---Purpose : Returns the position of the light source.
Target ( me; X,Y,Z : out Coordinate) is static;
---Level: Public
---Purpose: Returns the position of the target of the light source.
-----------------------------------------
---Category: Private or Protected methods
-----------------------------------------
Symbol ( me ; gsymbol : mutable Group from Graphic3d ;
aView : View from V3d ) is deferred private;
---Level: Internal
---Purpose: Defines representation of the light source.
fields
MyTarget: Vertex from Graphic3d is protected;
MyTypeOfRepresentation: TypeOfRepresentation from V3d is protected;
end PositionalLight;

488
src/V3d/V3d_PositionLight.cxx Executable file
View File

@@ -0,0 +1,488 @@
/***********************************************************************
V3d_PositionLight.cxx
Created: 30-03-98 ZOV (ZELENKOV Oleg)
************************************************************************/
#include <V3d.hxx>
#include <V3d_PositionLight.ixx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <V3d_SpotLight.hxx>
#include <Visual3d_Light.hxx>
#include <Visual3d_ViewManager.hxx>
#include <Visual3d_ContextPick.hxx>
#include <Visual3d_PickDescriptor.hxx>
#include <Visual3d_HSequenceOfPickPath.hxx>
#include <Visual3d_PickPath.hxx>
#include <Viewer_BadValue.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <TCollection_AsciiString.hxx>
#ifdef WNT
# include <WNT_Window.hxx>
#else
# include <Xw_Window.hxx>
#endif
V3d_PositionLight::V3d_PositionLight(const Handle(V3d_Viewer)& VM) : V3d_Light(VM) {
}
void V3d_PositionLight::SetTarget(const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
Standard_Real Xc,Yc,Zc, Xp,Yp,Zp;
// Recalcul de la position
MyTarget.Coord(Xc,Yc,Zc);
Position (Xp,Yp,Zp) ;
Xp = Xp + (X - Xc);
Yp = Yp + (Y - Yc);
Zp = Zp + (Z - Zc);
// Affectation
MyTarget.SetCoord(X,Y,Z);
SetPosition(Xp,Yp,Zp) ;
}
void V3d_PositionLight::SetRadius(const Standard_Real Radius) {
Viewer_BadValue_Raise_if( Radius <= 0. , "V3d_PositionLight::SetRadius, bad radius");
Viewer_BadValue_Raise_if( MyType == V3d_DIRECTIONAL , "V3d_PositionLight::SetRadius, bad light type");
Standard_Real X0,Y0,Z0, Xn,Yn,Zn, Xp,Yp,Zp;
// Le point cible reste inchange, seul la position de la lumiere est modifiee
// en conservant la direction.
Position (Xp,Yp,Zp);
Graphic3d_Vector D(MyTarget, Graphic3d_Vertex(Xp, Yp, Zp));
D.Normalize();
D.Coord(Xn,Yn,Zn);
MyTarget.Coord(X0,Y0,Z0);
Xn = X0 + Radius*Xn;
Yn = Y0 + Radius*Yn;
Zn = Z0 + Radius*Zn;
SetPosition(Xn,Yn,Zn) ;
}
void V3d_PositionLight::OnHideFace(const Handle(V3d_View)& aView) {
Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
Position (Xp,Yp,Zp);
V3d_Light::SymetricPointOnSphere (aView,
MyTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
// Actuellement est on sur le point vu
if ((VX*(X-Xp) < 0.) && (VY*(Y-Yp) < 0.) && (VZ*(Z-Zp) < 0.))
SetPosition (X,Y,Z);
}
void V3d_PositionLight::OnSeeFace(const Handle(V3d_View)& aView) {
Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
Position (Xp,Yp,Zp);
V3d_Light::SymetricPointOnSphere (aView,
MyTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
// Actuellement est on sur le point cache
if ((VX*(X-Xp) > 0.) && (VY*(Y-Yp) > 0.) && (VZ*(Z-Zp) > 0.))
SetPosition (X,Y,Z);
}
Standard_Boolean V3d_PositionLight::SeeOrHide(const Handle(V3d_View)& aView) const {
Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
Position (Xp,Yp,Zp);
V3d_Light::SymetricPointOnSphere (aView,
MyTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
// Avons nous le point cache ou le point vu
return ( (VX*(X-Xp) > 0.) || (VY*(Y-Yp) > 0.) || (VZ*(Z-Zp) > 0.) )?
// la source est sur la face cachee
Standard_False:
// la source est sur la face vue.
Standard_True;
}
void V3d_PositionLight::Target(Standard_Real& Xp, Standard_Real& Yp, Standard_Real& Zp)const {
MyTarget.Coord(Xp,Yp,Zp) ;
}
void V3d_PositionLight::Display( const Handle(V3d_View)& aView,
const V3d_TypeOfRepresentation TPres ) {
Graphic3d_Array1OfVertex PRadius(0,1);
Graphic3d_Vertex PText ;
Standard_Real X,Y,Z,Rayon;
Standard_Real X0,Y0,Z0,VX,VY,VZ;
Standard_Real X1,Y1,Z1;
Standard_Real DXRef,DYRef,DZRef,DXini,DYini,DZini;
Standard_Real R1,G1,B1;
V3d_TypeOfRepresentation Pres;
V3d_TypeOfUpdate UpdSov;
// Creation d'une structure slight d'elements reperables (la position de
// la light, et le domaine d'eclairage represente par un cercle)
// Creation d'une structure snopick d'elements non reperables ( cible, meridien et
// parallele ).
Pres = TPres;
Handle(V3d_Viewer) TheViewer = aView->Viewer();
UpdSov = TheViewer->UpdateMode();
TheViewer->SetUpdateMode(V3d_WAIT);
if (!MyGraphicStructure.IsNull()) {
MyGraphicStructure->Disconnect(MyGraphicStructure1);
MyGraphicStructure->Clear();
MyGraphicStructure1->Clear();
if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation;
}
else {
if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE;
Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer());
MyGraphicStructure = slight;
Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer());
MyGraphicStructure1 = snopick;
}
Handle(Graphic3d_Group) gradius;
Handle(Graphic3d_Group) gExtArrow;
Handle(Graphic3d_Group) gIntArrow;
if (MyType != V3d_DIRECTIONAL) {
if (Pres == V3d_COMPLETE) {
gradius = new Graphic3d_Group(MyGraphicStructure);
gExtArrow = new Graphic3d_Group(MyGraphicStructure);
gIntArrow = new Graphic3d_Group(MyGraphicStructure);
}
}
Handle(Graphic3d_Group) glight = new Graphic3d_Group(MyGraphicStructure);
Handle(Graphic3d_Group) gsphere;
if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) gsphere = new Graphic3d_Group(MyGraphicStructure);
Handle(Graphic3d_Group) gnopick = new Graphic3d_Group(MyGraphicStructure1);
MyGraphicStructure1->SetPick(Standard_False);
X0 = MyTarget.X();
Y0 = MyTarget.Y();
Z0 = MyTarget.Z();
//Affichage de la position de la light.
glight->SetPickId(1);
this->Color(Quantity_TOC_RGB,R1,G1,B1);
Quantity_Color Col1(R1,G1,B1,Quantity_TOC_RGB);
Handle(Graphic3d_AspectLine3d) Asp1 = new Graphic3d_AspectLine3d();
Asp1->SetColor(Col1);
glight->SetPrimitivesAspect(Asp1);
this->Symbol(glight,aView);
//Affichage de la sphere de reperage (limite au cercle).
if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) {
Rayon = this->Radius();
aView->Proj(VX,VY,VZ);
gsphere->SetPickId(2);
V3d::CircleInPlane(gsphere,X0,Y0,Z0,VX,VY,VZ,Rayon);
if (MyType != V3d_DIRECTIONAL) {
//Affichage du rayon de la sphere (ligne + texte)
if (Pres == V3d_COMPLETE) {
gradius->SetPickId(3);
gExtArrow->SetPickId(4);
gIntArrow->SetPickId(5);
PRadius(0).SetCoord(X0,Y0,Z0);
this->Position(X,Y,Z);
PRadius(1).SetCoord(X,Y,Z);
gnopick->Polyline(PRadius);
V3d::ArrowOfRadius(gExtArrow,X-(X-X0)/10.,
Y-(Y-Y0)/10.,
Z-(Z-Z0)/10.,X-X0,Y-Y0,Z-Z0,PI/15.,Rayon/20.);
V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,PI/15.,Rayon/20.);
TCollection_AsciiString ValOfRadius(Rayon);
PText.SetCoord( (X0+X)/2., (Y0+Y)/2. , (Z0+Z)/2. );
gradius->Text(ValOfRadius.ToCString(),PText,0.01);
}
}
//Affichage du meridien
Quantity_Color Col2(Quantity_NOC_GREEN);
Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d
(Col2,Aspect_TOL_SOLID,1.);
gnopick->SetPrimitivesAspect(Asp2);
// Definition de l'axe du cercle
aView->Up(DXRef,DYRef,DZRef);
this->Position(X,Y,Z);
DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
VX = DYRef*DZini - DZRef*DYini;
VY = DZRef*DXini - DXRef*DZini;
VZ = DXRef*DYini - DYRef*DXini;
V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
// Affichage de la parallele
// Definition de l'axe du cercle
aView->Proj(VX,VY,VZ);
aView->Up(X1,Y1,Z1);
DXRef = VY * Z1 - VZ * Y1;
DYRef = VZ * X1 - VX * Z1;
DZRef = VX * Y1 - VY * X1;
this->Position(X,Y,Z);
DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
VX = DYRef*DZini - DZRef*DYini;
VY = DZRef*DXini - DXRef*DZini;
VZ = DXRef*DYini - DYRef*DXini;
V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
}
MyGraphicStructure->Connect(MyGraphicStructure1,Graphic3d_TOC_DESCENDANT);
MyTypeOfRepresentation = Pres;
MyGraphicStructure->Display();
TheViewer->SetUpdateMode(UpdSov);
}
V3d_TypeOfPickLight V3d_PositionLight::Pick(const Handle(V3d_View)& aView,
const Standard_Integer Xpix,
const Standard_Integer Ypix)
const {
Standard_Integer i, Lng, Id;
Standard_Boolean kcont;
V3d_TypeOfPickLight TPick;
Handle(Visual3d_ViewManager) VM = (aView->Viewer())->Viewer();
#ifdef WNT
Handle( WNT_Window ) WW = Handle( WNT_Window ) :: DownCast ( aView -> Window () );
#else
Handle( Xw_Window ) WW = Handle( Xw_Window ) :: DownCast ( aView -> Window () );
#endif
Visual3d_ContextPick CTXP;
Visual3d_PickDescriptor Pdes = VM->Pick(CTXP,WW,Xpix,Ypix);
Visual3d_PickPath OnePPath;
Handle(Visual3d_HSequenceOfPickPath) PPath = Pdes.PickPath();
Lng = PPath->Length();
kcont = Standard_True;
TPick = V3d_NOTHING;
for (i=1; i<=Lng && kcont; i++) {
OnePPath = PPath->Value(i);
Id = OnePPath.PickIdentifier();
if (MyGraphicStructure == OnePPath.StructIdentifier()){
switch (Id) {
case 1 :
TPick = V3d_POSITIONLIGHT;
break;
case 2 :
TPick = V3d_SPACELIGHT;
break;
case 3 :
if (MyType != V3d_DIRECTIONAL)
TPick = V3d_RADIUSTEXTLIGHT;
break;
case 4 :
if (MyType != V3d_DIRECTIONAL)
TPick = V3d_ExtRADIUSLIGHT;
break;
case 5 :
if (MyType != V3d_DIRECTIONAL)
TPick = V3d_IntRADIUSLIGHT;
break;
}
kcont = Standard_False;
}
}
return TPick;
}
void V3d_PositionLight::Tracking( const Handle(V3d_View)& aView,
const V3d_TypeOfPickLight WhatPick,
const Standard_Integer Xpix,
const Standard_Integer Ypix) {
// Quantity_Color Col ;
Standard_Real xPos, yPos, zPos;
Standard_Real XPp,YPp,PXT,PYT,X,Y,Z,Rayon,Ylim;
Standard_Real XMinTrack,XMaxTrack,YMinTrack,YMaxTrack;
Standard_Real XT,YT,ZT,X0,Y0,Z0,XP,YP,ZP,VX,VY,VZ,A,B,C,Delta;
Standard_Real DX,DY,PXP,PYP,Xproj,Yproj;
Standard_Real A1,A2,B1,B2,Rap,OldRprj,NewRprj;
Standard_Real Xi,Yi,Zi,DeltaX,DeltaY,DeltaZ,Lambda;
Standard_Integer IPX,IPY;
aView->Convert(Xpix,Ypix,XPp,YPp);
X0 = MyTarget.X();
Y0 = MyTarget.Y();
Z0 = MyTarget.Z();
aView->Project(X0,Y0,Z0,PXT,PYT);
aView->Convert(PXT,PYT,IPX,IPY);
// Coord 3d dans le plan de projection de la cible.
aView->Convert(IPX,IPY,XT,YT,ZT);
switch (WhatPick) {
case V3d_POSITIONLIGHT :
// Les Coordonnees doivent rester a l'interieur de la sphere
Rayon = Radius();
XMinTrack = PXT - Rayon;
XMaxTrack = PXT + Rayon;
Ylim = Sqrt( Square(Rayon) - Square(XPp - PXT) );
YMinTrack = PYT - Ylim;
YMaxTrack = PYT + Ylim;
if (XPp >= XMinTrack && XPp <= XMaxTrack) {
if (YPp >= YMinTrack && YPp <= YMaxTrack) {
aView->ProjReferenceAxe(Xpix,Ypix,XP,YP,ZP,VX,VY,VZ);
DeltaX = X0 - XP;
DeltaY = Y0 - YP;
DeltaZ = Z0 - ZP;
// On recherche le point d'intersection des droites definies
// par :
// - Droite passant par le point de projection et l'oeil
// si on est en perspective, parralele a la normale de la
// vue si on a une vue axonometrique.
// position dans la vue est // a la normale de la vue
// - La distance position de la camera cible est egale au
// rayon.
A = VX*VX + VY*VY + VZ*VZ ;
B = -2. * (VX*DeltaX + VY*DeltaY + VZ*DeltaZ);
C = DeltaX*DeltaX + DeltaY*DeltaY + DeltaZ*DeltaZ
- Rayon*Rayon ;
Delta = B*B - 4.*A*C;
if ( Delta >= 0 ) {
Lambda = (-B + Sqrt(Delta))/(2.*A);
X = XP + Lambda*VX;
Y = YP + Lambda*VY;
Z = ZP + Lambda*VZ;
SetPosition(X,Y,Z);
if (MyType == V3d_SPOT)
((V3d_SpotLight*)this)->SetDirection(X0-X,Y0-Y,Z0-Z);
Display(aView,MyTypeOfRepresentation);
(aView->Viewer())->UpdateLights();
}
}
}
break;
case V3d_SPACELIGHT :
aView->Convert(PXT,PYT,IPX,IPY);
// Dans ce cas Xpix,Ypix correspondent a une distance , relative
// a la translation que l'on veut effectuer sur la sphere.
aView->Convert(IPX+Xpix,IPY+Ypix,X,Y,Z);
X = X+X0-XT;
Y = Y+Y0-YT;
Z = Z+Z0-ZT;
SetTarget(X,Y,Z);
Display(aView,MyTypeOfRepresentation);
(aView->Viewer())->UpdateLights();
break;
case V3d_ExtRADIUSLIGHT :
if (MyType == V3d_DIRECTIONAL)
break;
// on cherche a conserver la direction cible positionnement de la
// source ==> on projette le point sur la direction cible source.
this->Position(Xi,Yi,Zi);
aView->Project(Xi,Yi,Zi,PXP,PYP);
DX = PXP - PXT;
DY = PYP - PYT;
A1 = DY/DX ; B1 = PYT - A1*PXT;
A2 = -DX/DY; B2 = YPp - A2*XPp;
Xproj = (B2 - B1) / (A1 - A2);
Yproj = A1*Xproj + B1;
if ( (DX*(Xproj-PXT) > 0.) && (DY*(Yproj-PYT) > 0.) ) {
OldRprj = Sqrt ( Square (PXP-PXT) + Square (PYP-PYT) );
NewRprj = Sqrt ( Square (Xproj-PXT) + Square (Yproj-PYT) );
Rap = NewRprj/OldRprj;
Rayon = Radius();
Rayon = Rayon * Rap;
SetRadius(Rayon);
Display(aView,MyTypeOfRepresentation);
(aView->Viewer())->UpdateLights();
}
break;
case V3d_IntRADIUSLIGHT :
if (MyType == V3d_DIRECTIONAL)
break;
// on cherche a conserver la direction cible positionnement
// de la source ==> on projette le point sur la direction
// cible source.
Position(Xi,Yi,Zi);
aView->Project(Xi,Yi,Zi,PXP,PYP);
DX = PXP - PXT;
DY = PYP - PYT;
A1 = DY/DX ; B1 = PYT - A1*PXT;
A2 = -DX/DY; B2 = YPp - A2*XPp;
Xproj = (B2 - B1) / (A1 - A2);
Yproj = A1*Xproj + B1;
if ( (DX*(Xproj-PXP) < 0.) && (DY*(Yproj-PYP) < 0.) ) {
OldRprj = Sqrt ( Square (PXP-PXT) + Square (PYP-PYT) );
NewRprj = Sqrt ( Square (Xproj-PXP) + Square (Yproj-PYP) );
Rap = NewRprj/OldRprj;
Rayon = Radius();
Rayon = Rayon * Rap;
// la source doit rester a une position fixe, seule la cible
// est modifie.
Position (xPos, yPos, zPos);
Graphic3d_Vector Dir(Graphic3d_Vertex(xPos,yPos,zPos), MyTarget);
Dir.Normalize();
Dir.Coord(X,Y,Z);
X = Xi + Rayon*X;
Y = Yi + Rayon*Y;
Z = Zi + Rayon*Z;
// la source doit rester a une position fixe, seule la cible
// est modifie.
MyTarget.SetCoord(X,Y,Z);
Display(aView,MyTypeOfRepresentation);
(aView->Viewer())->UpdateLights();
}
break;
case V3d_RADIUSTEXTLIGHT :
break;
case V3d_NOTHING :
break;
}
}
Standard_Real V3d_PositionLight::Radius() const {
Standard_Real Xp,Yp,Zp, Xc,Yc,Zc;
Position (Xp,Yp,Zp);
MyTarget.Coord(Xc,Yc,Zc);
return Sqrt (Square(Xc - Xp) + Square(Yc - Yp) + Square(Zc - Zp));
}
void V3d_PositionLight::Erase() {
if (!MyGraphicStructure.IsNull()) MyGraphicStructure->Erase();
if (!MyGraphicStructure1.IsNull()) MyGraphicStructure1->Erase();
}

142
src/V3d/V3d_PositionalLight.cdl Executable file
View File

@@ -0,0 +1,142 @@
-- File: PositionalLight.cdl
-- Created: Wed Jan 22 11:39:37 1992
-- Author: GG
-- Update: FDA Oct 15 1994
-- ZOV - Mars 30 1998
---Copyright: Matra Datavision 1992
class PositionalLight from V3d
---Version:
---Purpose: Creation and modification of an isolated
-- light source.
---Keywords: Light,Positional
---Warning:
---References:
inherits PositionLight from V3d
uses
Viewer from V3d,
Coordinate from V3d,
View from V3d,
TypeOfRepresentation from V3d,
NameOfColor from Quantity,
Coefficient from Quantity,
Parameter from Quantity,
Structure from Graphic3d,
Vertex from Graphic3d,
Group from Graphic3d
raises BadValue from Viewer
is
Create ( VM : mutable Viewer ; X,Y,Z : Coordinate ;
Color : NameOfColor = Quantity_NOC_WHITE ;
Attenuation1 : Coefficient = 1.0 ;
Attenuation2 : Coefficient = 0.0 )
returns mutable PositionalLight
---Level: Public
---Purpose: Creates an isolated light source X,Y,Z in the viewer.
-- It is also defined by the color Color and
-- two attenuation factors Attenuation1, Attenuation2.
-- The resulting attenuation factor determining the
-- illumination of a surface depends on the following
-- formula :
-- F = 1/(A1 + A2*Length)
-- A1,A2 being the two factors of attenuation
-- Length is the distance of the isolated source
-- from the surface.
raises BadValue from Viewer;
---Purpose: Warning! raises BadValue from Viewer
-- if one of the attenuation coefficients is not between 0 et 1.
Create ( VM : mutable Viewer ; Xt,Yt,Zt : Coordinate;
Xp,Yp,Zp : Coordinate;
Color : NameOfColor = Quantity_NOC_WHITE ;
Attenuation1 : Coefficient = 1.0 ;
Attenuation2 : Coefficient = 0.0 )
returns mutable PositionalLight
---Level: Public
---Purpose: Creates a light source of the Positional type
-- in the viewer.
-- Xt,Yt,Zt : Coordinate of Target light source.
-- Xp,Yp,Zp : Coordinate of Position light source.
-- The light source is also defined by the color Color
-- and two attenuation factors Attenuation1,
-- Attenuation2 that determine the illumination of a
-- surface using the following formula :
-- F = 1/(A1 + A2*Length) where:
-- - A1,A2 are the two attenuation factors, and
-- - Length is the distance from the isolated source.
raises BadValue from Viewer;
---Purpose: Warning! raises BadValue from Viewer
-- if one of the attenuation coefficients is not between 0 et 1.
--------------------------------------------------------
---Category: Methods to modify the Attributes of the Light
--------------------------------------------------------
SetPosition ( me : mutable; X,Y,Z : Coordinate ) is redefined;
---Level: Public
---Purpose: Defines the position of the light source.
SetAttenuation( me : mutable; A1,A2 : Coefficient ) raises BadValue from Viewer is static;
---Level: Public
---Purpose: Defines the attenuation factors.
-- Warning: raises BadValue from Viewer
-- if one of the attenuation coefficients is not between 0 et 1.
---------------------------------------------------
---Category: Displaying methods
---------------------------------------------------
Display(me: mutable; aView: View from V3d;
Representation : TypeOfRepresentation)
is redefined static;
---Level: Public
---Purpose: Display the graphic structure of light source
-- in the choosen view. We have three type of representation
-- - SIMPLE : Only the light source is displayed.
-- - PARTIAL : The light source and the light space are
-- displayed.
-- - COMPLETE : The light source, the light space and the
-- radius of light space are displayed.
-- We can choose the "SAMELAST" as parameter of representation
-- In this case the graphic structure representation will be
-- the last displayed.
---------------------------------------------------
---Category: Inquire methods
---------------------------------------------------
Position ( me; X,Y,Z : out Coordinate ) is redefined static;
---Level: Public
---Purpose : Returns the position of the light source.
Attenuation ( me; A1,A2 : out Coefficient ) is static;
---Level: Public
---Purpose : Returns the attenuation factors A1,A2 of the light
-- source used at construction time.
-----------------------------------------
---Category: Private or Protected methods
-----------------------------------------
Symbol ( me ; gsymbol : mutable Group from Graphic3d ;
aView : View from V3d ) is redefined static private;
---Level: Internal
---Purpose: Defined the representation of the positional light source.
end PositionalLight;

302
src/V3d/V3d_PositionalLight.cxx Executable file
View File

@@ -0,0 +1,302 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_PositionalLight :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
18-06-96 : FMN ; Ajout MyGraphicStructure1 pour sauvegarder snopick
24-12-97 : FMN ; Remplacement de math par MathGra
31-12-97 : CAL ; Suppression de MathGra
21-01-98 : CAL ; Window de Xw et WNT remplacee par Aspect_Window
23-02-98 : FMN ; Remplacement PI par Standard_PI
30-03-98 : ZOV ; PRO6774 (reconstruction of the class hierarchy and suppressing useless methods)
************************************************************************/
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d.hxx>
#include <V3d_PositionalLight.ixx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Visual3d_Light.hxx>
#include <Visual3d_ViewManager.hxx>
#include <Visual3d_ContextPick.hxx>
#include <Visual3d_PickDescriptor.hxx>
#include <Visual3d_HSequenceOfPickPath.hxx>
#include <Visual3d_PickPath.hxx>
#include <Viewer_BadValue.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <TCollection_AsciiString.hxx>
#include <Aspect_Window.hxx>
//-Declarations
//-Constructors
V3d_PositionalLight::V3d_PositionalLight(const Handle(V3d_Viewer)& VM, const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Quantity_NameOfColor Name, const Standard_Real A1, const Standard_Real A2):V3d_PositionLight(VM) {
Quantity_Color C(Name) ;
Graphic3d_Vertex P(X,Y,Z) ;
Graphic3d_Vertex T(0.,0.,0.);
Viewer_BadValue_Raise_if ( A1 < 0 || A1 > 1. || A2 < 0 || A2 > 1,
"V3d_PositionalLight, bad coefficients");
MyType = V3d_POSITIONAL ;
MyLight = new Visual3d_Light(C,P,A1,A2) ;
MyTarget = T;
}
V3d_PositionalLight::V3d_PositionalLight(const Handle(V3d_Viewer)& VM, const Standard_Real Xt, const Standard_Real Yt, const Standard_Real Zt, const Standard_Real Xp, const Standard_Real Yp, const Standard_Real Zp, const Quantity_NameOfColor Name, const Standard_Real A1, const Standard_Real A2):V3d_PositionLight(VM) {
Quantity_Color C(Name) ;
Graphic3d_Vertex T(Xt,Yt,Zt) ;
Graphic3d_Vertex P(Xp,Yp,Zp) ;
Viewer_BadValue_Raise_if ( A1 < 0 || A1 > 1. || A2 < 0 || A2 > 1,
"V3d_PositionalLight, bad coefficients");
MyType = V3d_POSITIONAL ;
MyLight = new Visual3d_Light(C,P,A1,A2) ;
MyTarget = T;
// La Structure graphique sera initialisee lors de l'affichage.
}
//-Methods, in order
void V3d_PositionalLight::SetPosition(const Standard_Real Xp, const Standard_Real Yp, const Standard_Real Zp) {
MyLight->SetPosition (Graphic3d_Vertex (Xp,Yp,Zp));
}
void V3d_PositionalLight::SetAttenuation(const Standard_Real A1, const Standard_Real A2) {
Viewer_BadValue_Raise_if ( A1 < 0 || A1 > 1. || A2 < 0 || A2 > 1,
"V3d_PositionalLight::SetAttenuation, bad coefficients");
MyLight->SetAttenuation1(A1) ;
MyLight->SetAttenuation2(A2) ;
}
void V3d_PositionalLight::Position(Standard_Real& X, Standard_Real& Y, Standard_Real& Z)const {
Quantity_Color C ;
Graphic3d_Vertex P ;
Standard_Real A1,A2 ;
MyLight->Values(C,P,A1,A2) ;
P.Coord(X,Y,Z) ;
}
void V3d_PositionalLight::Attenuation(Standard_Real& A1, Standard_Real& A2)const {
Quantity_Color C ;
Graphic3d_Vertex P ;
MyLight->Values(C,P,A1,A2) ;
}
void V3d_PositionalLight::Symbol (const Handle(Graphic3d_Group)& gsymbol, const Handle(V3d_View)& aView) const {
Standard_Real Xi,Yi,Zi,Xf,Yf,Zf,Rayon,PXT,PYT,X,Y,Z,XT,YT,ZT;
Standard_Real A,B,C,Dist,Beta,CosBeta,SinBeta,Coef,X1,Y1,Z1;
Standard_Real VX,VY,VZ;
Standard_Integer IXP,IYP,j;
TColStd_Array2OfReal MatRot(0,2,0,2);
aView->Proj(VX,VY,VZ);
this->Position(Xi,Yi,Zi);
Rayon = this->Radius();
aView->Project(Xi,Yi,Zi,PXT,PYT);
aView->Convert(PXT,PYT,IXP,IYP);
// Coord 3d dans le plan de projection de la source.
aView->Convert(IXP,IYP,XT,YT,ZT);
aView->Convert(PXT,PYT+Rayon,IXP,IYP);
aView->Convert(IXP,IYP,X,Y,Z);
X = X+Xi-XT; Y = Y+Yi-YT; Z = Z+Zi-ZT;
Dist = Sqrt( Square(X-Xi) + Square(Y-Yi) + Square(Z-Zi) );
// Axe de rotation.
A = (X-Xi)/Dist;
B = (Y-Yi)/Dist;
C = (Z-Zi)/Dist;
// On dessine une sphere
V3d::CircleInPlane(gsymbol,Xi,Yi,Zi,VX,VY,VZ,Rayon/40.);
for( j=1 ; j<=3 ; j++ ) {
Beta = j * Standard_PI/4.;
CosBeta = Cos(Beta);
SinBeta = Sin(Beta);
Coef = 1. - CosBeta;
MatRot(0,0) = A * A + (1. - A * A) * CosBeta;
MatRot(0,1) = -C * SinBeta + Coef * A * B;
MatRot(0,2) = B * SinBeta + Coef * A * C;
MatRot(1,0) = C * SinBeta + Coef * A * B;
MatRot(1,1) = B * B + (1. - B * B) * CosBeta;
MatRot(1,2) = -A * SinBeta + Coef * B * C;
MatRot(2,0) = -B * SinBeta + Coef * A * C;
MatRot(2,1) = A * SinBeta + Coef * B * C;
MatRot(2,2) = C * C + (1. - C * C) * CosBeta;
Xf = Xi * MatRot(0,0) + Yi * MatRot(0,1) + Zi * MatRot(0,2);
Yf = Xi * MatRot(1,0) + Yi * MatRot(1,1) + Zi * MatRot(1,2);
Zf = Xi * MatRot(2,0) + Yi * MatRot(2,1) + Zi * MatRot(2,2);
// Rotation de la normale
X1 = VX * MatRot(0,0) + VY * MatRot(0,1) + VZ * MatRot(0,2);
Y1 = VX * MatRot(1,0) + VY * MatRot(1,1) + VZ * MatRot(1,2);
Z1 = VX * MatRot(2,0) + VY * MatRot(2,1) + VZ * MatRot(2,2);
VX = X1 + Xi - Xf ; VY = Y1 + Yi - Yf ; VZ = Z1 + Zi - Zf;
V3d::CircleInPlane(gsymbol,Xi,Yi,Zi,VX,VY,VZ,Rayon/40.);
}
}
void V3d_PositionalLight::Display( const Handle(V3d_View)& aView,
const V3d_TypeOfRepresentation TPres ) {
Graphic3d_Array1OfVertex PRadius(0,1);
Graphic3d_Vertex PText ;
Standard_Real X,Y,Z,Rayon;
Standard_Real X0,Y0,Z0,VX,VY,VZ;
Standard_Real X1,Y1,Z1;
Standard_Real DXRef,DYRef,DZRef,DXini,DYini,DZini;
Standard_Real R1,G1,B1;
V3d_TypeOfRepresentation Pres;
V3d_TypeOfUpdate UpdSov;
// Creation d'une structure slight d'elements reperables (la position de
// la light, et le domaine d'eclairage represente par un cercle)
// Creation d'une structure snopick d'elements non reperables ( cible, meridien et
// parallele ).
Pres = TPres;
Handle(V3d_Viewer) TheViewer = aView->Viewer();
UpdSov = TheViewer->UpdateMode();
TheViewer->SetUpdateMode(V3d_WAIT);
if (!MyGraphicStructure.IsNull()) {
MyGraphicStructure->Disconnect(MyGraphicStructure1);
MyGraphicStructure->Clear();
MyGraphicStructure1->Clear();
if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation;
}
else {
if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE;
Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer());
MyGraphicStructure = slight;
Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer());
MyGraphicStructure1 = snopick;
}
Handle(Graphic3d_Group) gradius;
Handle(Graphic3d_Group) gExtArrow;
Handle(Graphic3d_Group) gIntArrow;
if (Pres == V3d_COMPLETE) {
gradius = new Graphic3d_Group(MyGraphicStructure);
gExtArrow = new Graphic3d_Group(MyGraphicStructure);
gIntArrow = new Graphic3d_Group(MyGraphicStructure);
}
Handle(Graphic3d_Group) glight = new Graphic3d_Group(MyGraphicStructure);
Handle(Graphic3d_Group) gsphere;
if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) gsphere = new Graphic3d_Group(MyGraphicStructure);
Handle(Graphic3d_Group) gnopick = new Graphic3d_Group(MyGraphicStructure1);
MyGraphicStructure1->SetPick(Standard_False);
X0 = MyTarget.X();
Y0 = MyTarget.Y();
Z0 = MyTarget.Z();
//Affichage de la position de la light.
glight->SetPickId(1);
this->Color(Quantity_TOC_RGB,R1,G1,B1);
Quantity_Color Col1(R1,G1,B1,Quantity_TOC_RGB);
Handle(Graphic3d_AspectLine3d) Asp1 = new Graphic3d_AspectLine3d();
Asp1->SetColor(Col1);
glight->SetPrimitivesAspect(Asp1);
this->Symbol(glight,aView);
//Affichage de la sphere de reperage (limite au cercle).
if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) {
Rayon = this->Radius();
aView->Proj(VX,VY,VZ);
gsphere->SetPickId(2);
V3d::CircleInPlane(gsphere,X0,Y0,Z0,VX,VY,VZ,Rayon);
//Affichage du rayon de la sphere (ligne + texte)
if (Pres == V3d_COMPLETE) {
gradius->SetPickId(3);
gExtArrow->SetPickId(4);
gIntArrow->SetPickId(5);
PRadius(0).SetCoord(X0,Y0,Z0);
this->Position(X,Y,Z);
PRadius(1).SetCoord(X,Y,Z);
gnopick->Polyline(PRadius);
V3d::ArrowOfRadius(gExtArrow,X-(X-X0)/10.,
Y-(Y-Y0)/10.,
Z-(Z-Z0)/10.,X-X0,Y-Y0,Z-Z0,Standard_PI/15.,Rayon/20.);
V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,Standard_PI/15.,Rayon/20.);
TCollection_AsciiString ValOfRadius(Rayon);
PText.SetCoord( (X0+X)/2., (Y0+Y)/2. , (Z0+Z)/2. );
gradius->Text(ValOfRadius.ToCString(),PText,0.01);
}
//Affichage du meridien
Quantity_Color Col2(Quantity_NOC_GREEN);
Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d
(Col2,Aspect_TOL_SOLID,1.);
gnopick->SetPrimitivesAspect(Asp2);
// Definition de l'axe du cercle
aView->Up(DXRef,DYRef,DZRef);
this->Position(X,Y,Z);
DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
VX = DYRef*DZini - DZRef*DYini;
VY = DZRef*DXini - DXRef*DZini;
VZ = DXRef*DYini - DYRef*DXini;
V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
// Affichage de la parallele
// Definition de l'axe du cercle
aView->Proj(VX,VY,VZ);
aView->Up(X1,Y1,Z1);
DXRef = VY * Z1 - VZ * Y1;
DYRef = VZ * X1 - VX * Z1;
DZRef = VX * Y1 - VY * X1;
this->Position(X,Y,Z);
DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
VX = DYRef*DZini - DZRef*DYini;
VY = DZRef*DXini - DXRef*DZini;
VZ = DXRef*DYini - DYRef*DXini;
V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
}
MyGraphicStructure->Connect(MyGraphicStructure1,Graphic3d_TOC_DESCENDANT);
MyTypeOfRepresentation = Pres;
MyGraphicStructure->Display();
TheViewer->SetUpdateMode(UpdSov);
}

81
src/V3d/V3d_RectangularGrid.cdl Executable file
View File

@@ -0,0 +1,81 @@
--
-- File: V3d_RectangularGrid.cdl
-- Created: Jeudi 16 Juillet 1998
-- Author: CAL
-- Updated: GG IMP230300 The color fields have moved Aspect_Grid
--
---Copyright: Matra Datavision 1998
private class RectangularGrid from V3d inherits RectangularGrid from Aspect
uses
Ax3 from gp,
Color from Quantity,
Group from Graphic3d,
Structure from Graphic3d,
GridDrawMode from Aspect,
ViewerPointer from V3d
is
Create ( aViewer : ViewerPointer from V3d;
aColor : Color from Quantity;
aTenthColor : Color from Quantity )
returns mutable RectangularGrid from V3d;
SetColors ( me : mutable;
aColor : Color from Quantity;
aTenthColor : Color from Quantity )
is redefined static;
Display ( me : mutable )
is redefined static;
Erase ( me )
is redefined static;
IsDisplayed ( me )
returns Boolean from Standard
is redefined static;
GraphicValues ( me;
XSize, YSize : out Real from Standard;
OffSet : out Real from Standard )
is static;
SetGraphicValues ( me : mutable;
XSize, YSize : Real from Standard;
OffSet : Real from Standard )
is static;
DefineLines ( me : mutable )
is static private;
DefinePoints ( me : mutable )
is static private;
UpdateDisplay ( me : mutable )
is redefined static protected;
fields
myStructure : Structure from Graphic3d;
myGroup1, myGroup2 : Group from Graphic3d;
myCurViewPlane : Ax3 from gp;
-- myColor, myTenthColor : Color from Quantity;
-- myCurColor1, myCurColor2: Color from Quantity;
myViewer : ViewerPointer from V3d;
myCurAreDefined : Boolean from Standard;
myCurDrawMode : GridDrawMode from Aspect;
myCurXo, myCurYo : Real from Standard;
myCurAngle : Real from Standard;
myCurXStep, myCurYStep : Real from Standard;
myXSize, myYSize : Real from Standard;
myOffSet : Real from Standard;
-- Debug
-- myStructureGridPlane : Structure from Graphic3d;
-- myStructureViewPlane : Structure from Graphic3d;
-- myGroupGridPlane : Group from Graphic3d;
-- myGroupViewPlane : Group from Graphic3d;
-- myGridPlane : Ax3 from gp;
end RectangularGrid from V3d;

546
src/V3d/V3d_RectangularGrid.cxx Executable file
View File

@@ -0,0 +1,546 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_CircularGrid :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
16-08-98 : CAL ; S3892. Ajout grilles 3d.
13-10-98 : CAL ; S3892. Ajout de la gestion de la taille des grilles 3d.
23-10-98 : CAL ; PRO 15885. Patch K4403 et K4404
03-11-98 : CAL ; PRO 16161. Patch K4418 et K4419
IMP230300: GG The color fields and methods have moved in Aspect_Grid
************************************************************************/
#define IMP200100 //GG
// -> Compute the case Aspect_GDM_None
// -> Initialize the grid size according to the
// viewer default size.
#define IMP200300 //GG
// -> Recompute the grid when any graphic parameter is
// modified.
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_RectangularGrid.ixx>
#include <TColStd_Array2OfReal.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Visual3d_ViewManager.hxx>
#include <V3d_Viewer.hxx>
/*----------------------------------------------------------------------*/
/*
* Constant
*/
#define NO_TRACE_MINMAX
#define NO_TRACE_MAKE
#define NO_TRACE_VALUES
#define NO_TRACE_PLANE // Penser a virer du cdl my*GridPlane my*ViewPlane
#define MYMINMAX 25.
#define MYFACTOR 50.
/*----------------------------------------------------------------------*/
V3d_RectangularGrid::V3d_RectangularGrid (const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor):
Aspect_RectangularGrid (1.,1.),
myStructure (new Graphic3d_Structure (aViewer->Viewer ())),
myGroup1 (new Graphic3d_Group (myStructure)),
myGroup2 (new Graphic3d_Group (myStructure)),
myViewer (aViewer),
myCurAreDefined (Standard_False)
#ifdef TRACE_PLANE
,myStructureGridPlane (new Graphic3d_Structure (aViewer->Viewer ())),
myStructureViewPlane (new Graphic3d_Structure (aViewer->Viewer ())),
myGroupGridPlane (new Graphic3d_Group (myStructureGridPlane)),
myGroupViewPlane (new Graphic3d_Group (myStructureViewPlane)),
myGridPlane (gp_Ax3 (gp_Pnt (0.,0.,0), gp_Dir (0.,0.,1.), gp_Dir (1.,0.,0.)))
#endif
{
myColor = aColor;
myTenthColor = aTenthColor;
myStructure->SetInfiniteState (Standard_True);
#ifdef TRACE_PLANE
myStructureGridPlane->SetInfiniteState (Standard_True);
myStructureViewPlane->SetInfiniteState (Standard_True);
#endif
#ifdef IMP200100
Standard_Real step = 10.;
Standard_Real gstep = step/MYFACTOR;
Standard_Real size = myViewer->DefaultViewSize()/2.;
#else
Standard_Real step = 10.;
Standard_Real gstep = step/MYFACTOR;
Standard_Real size = MYMINMAX;
#endif
SetGraphicValues (size, size, gstep);
SetXStep (step);
SetYStep (step);
}
void V3d_RectangularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) {
if( myColor != aColor || myTenthColor != aTenthColor ) {
myColor = aColor;
myTenthColor = aTenthColor;
myCurAreDefined = Standard_False;
UpdateDisplay();
}
}
void V3d_RectangularGrid::Display () {
myStructure->Display (1);
#ifdef TRACE_PLANE
myStructureGridPlane->Display (1);
myStructureViewPlane->Display (1);
#endif
}
void V3d_RectangularGrid::Erase () const {
myStructure->Erase ();
#ifdef TRACE_PLANE
myStructureGridPlane->Erase ();
myStructureViewPlane->Erase ();
#endif
}
Standard_Boolean V3d_RectangularGrid::IsDisplayed () const {
return myStructure->IsDisplayed ();
}
void V3d_RectangularGrid::UpdateDisplay () {
#ifdef TRACE_MINMAX
cout << "V3d_RectangularGrid::UpdateDisplay ()" << endl;
#endif
gp_Ax3 ThePlane;
ThePlane = myViewer->PrivilegedPlane ();
Standard_Boolean MakeTransform = Standard_False;
Standard_Real xl, yl, zl;
Standard_Real xdx, xdy, xdz;
Standard_Real ydx, ydy, ydz;
Standard_Real dx, dy, dz;
ThePlane.Location ().Coord (xl, yl, zl);
ThePlane.XDirection ().Coord (xdx, xdy, xdz);
ThePlane.YDirection ().Coord (ydx, ydy, ydz);
ThePlane.Direction ().Coord (dx, dy, dz);
if (! myCurAreDefined)
MakeTransform = Standard_True;
else {
if (RotationAngle () != myCurAngle
|| XOrigin () != myCurXo || YOrigin () != myCurYo)
MakeTransform = Standard_True;
if (! MakeTransform) {
Standard_Real curxl, curyl, curzl;
Standard_Real curxdx, curxdy, curxdz;
Standard_Real curydx, curydy, curydz;
Standard_Real curdx, curdy, curdz;
myCurViewPlane.Location ().Coord (curxl, curyl, curzl);
myCurViewPlane.XDirection ().Coord (curxdx, curxdy, curxdz);
myCurViewPlane.YDirection ().Coord (curydx, curydy, curydz);
myCurViewPlane.Direction ().Coord (curdx, curdy, curdz);
if (xl != curxl || yl != curyl || zl != curzl
|| xdx != curxdx || xdy != curxdy || xdz != curxdz
|| ydx != curydx || ydy != curydy || ydz != curydz
|| dx != curdx || dy != curdy || dz != curdz)
MakeTransform = Standard_True;
}
}
if (MakeTransform) {
#ifdef TRACE_MAKE
cout << "MakeTransform" << endl;
#endif
Standard_Real CosAlpha = Cos (RotationAngle ());
Standard_Real SinAlpha = Sin (RotationAngle ());
TColStd_Array2OfReal Trsf (1, 4, 1, 4);
Trsf (4, 4) = 1.0;
Trsf (4, 1) = Trsf (4, 2) = Trsf (4, 3) = 0.0;
// Translation
Trsf (1, 4) = xl,
Trsf (2, 4) = yl,
Trsf (3, 4) = zl;
// Transformation de changement de repere
Trsf (1, 1) = xdx,
Trsf (2, 1) = xdy,
Trsf (3, 1) = xdz,
Trsf (1, 2) = ydx,
Trsf (2, 2) = ydy,
Trsf (3, 2) = ydz,
Trsf (1, 3) = dx,
Trsf (2, 3) = dy,
Trsf (3, 3) = dz;
myStructure->SetTransform (Trsf, Graphic3d_TOC_REPLACE);
// Translation de l'origine
Trsf (1, 4) = -XOrigin (),
Trsf (2, 4) = -YOrigin (),
Trsf (3, 4) = 0.0;
// Rotation Alpha autour de l'axe -Z
Trsf (1, 1) = CosAlpha,
Trsf (2, 1) = -SinAlpha,
Trsf (3, 1) = 0.0,
Trsf (1, 2) = SinAlpha,
Trsf (2, 2) = CosAlpha,
Trsf (3, 2) = 0.0,
Trsf (1, 3) = 0.0,
Trsf (2, 3) = 0.0,
Trsf (3, 3) = 1.0;
myStructure->SetTransform (Trsf,Graphic3d_TOC_POSTCONCATENATE);
// CAL : 19 aout 1998
// Il y avait aussi la possibilite de faire le calcul
// de changement de repere par :
// gp_Trsf::SetTransformation
// (myGridPlane, myViewer->PrivilegedPlane ());
#ifdef TRACE_VALUES
Standard_Integer i, j;
TColStd_Array2OfReal TheMatrix (1, 4, 1, 4);
myStructure->Transform (TheMatrix);
for (i=1; i<=4; i++) {
for (j=1; j<=4; j++)
cout << TheMatrix (i, j) << "\t";
cout << endl;
}
#endif
myCurAngle = RotationAngle ();
myCurXo = XOrigin (), myCurYo = YOrigin ();
myCurViewPlane = ThePlane;
}
switch (DrawMode ()) {
default:
case Aspect_GDM_Points:
#ifdef IMP210100
if (! myCurAreDefined ||
(myCurDrawMode == Aspect_GDM_Lines) )
#else
if (! myCurAreDefined || myCurAreDefined &&
myCurDrawMode == Aspect_GDM_Lines)
#endif
myGroup2->Clear ();
DefinePoints ();
myCurDrawMode = Aspect_GDM_Points;
break;
case Aspect_GDM_Lines:
DefineLines ();
myCurDrawMode = Aspect_GDM_Lines;
break;
#ifdef IMP210100
case Aspect_GDM_None:
myCurDrawMode = Aspect_GDM_None;
break;
#endif
}
myCurAreDefined = Standard_True;
#ifdef TRACE_PLANE
Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d ();
Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d ();
Graphic3d_Array1OfVertex Points (0, 1);
Standard_Real ay, by, cy;
myGroupViewPlane->Clear ();
LineAttrib->SetColor (Quantity_Color (Quantity_NOC_GREEN));
myGroupViewPlane->SetGroupPrimitivesAspect (LineAttrib);
TextAttrib->SetColor (Quantity_Color(Quantity_NOC_GREEN));
myGroupViewPlane->SetGroupPrimitivesAspect (TextAttrib);
ThePlane.Location ().Coord (xl, yl, zl);
Points (0).SetCoord (xl, yl, zl);
myGroupViewPlane->BeginPrimitives ();
myGroupViewPlane->Text ("VIEWER PLANE", Points (0), 1./81.);
myViewer->PrivilegedPlane ().XDirection ().Coord (ay, by, cy);
Points (1).SetCoord
(xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy);
myGroupViewPlane->Polyline (Points);
myGroupViewPlane->Text ("X", Points (1), 1./81.);
myViewer->PrivilegedPlane ().YDirection ().Coord (ay, by, cy);
Points (1).SetCoord
(xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy);
myGroupViewPlane->Polyline (Points);
myGroupViewPlane->Text ("Y", Points (1), 1./81.);
myViewer->PrivilegedPlane ().Direction ().Coord (ay, by, cy);
Points (1).SetCoord
(xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy);
myGroupViewPlane->Polyline (Points);
myGroupViewPlane->Text ("Z", Points (1), 1./81.);
myGroupViewPlane->EndPrimitives ();
#ifdef TRACE_VALUES
Standard_Real xangle, yangle, angle;
Standard_Real a11, a12, a13, a21, a22, a23, a31, a32, a33;
xangle = ThePlane.XDirection ().Angle (myGridPlane.XDirection ());
yangle = ThePlane.YDirection ().Angle (myGridPlane.YDirection ());
angle = ThePlane.Direction ().Angle (myGridPlane.Direction ());
cout << "Angle entre Directions " << angle << endl;
cout << "Angle entre XDirections " << xangle << endl;
cout << "Angle entre YDirections " << yangle << endl;
ThePlane.XDirection ().Coord (a11, a12, a13);
ThePlane.YDirection ().Coord (a21, a22, a23);
ThePlane.Direction ().Coord (a31, a32, a33);
cout << "Test Plane XDirection " << a11 << ", " << a12 << ", " << a13 << endl;
cout << "Test Plane YDirection " << a21 << ", " << a22 << ", " << a23 << endl;
cout << "Test Plane Direction " << a31 << ", " << a32 << ", " << a33 << endl;
#endif
myGroupGridPlane->Clear ();
LineAttrib->SetColor (Quantity_Color (Quantity_NOC_RED));
myGroupGridPlane->SetGroupPrimitivesAspect (LineAttrib);
TextAttrib->SetColor (Quantity_Color(Quantity_NOC_RED));
myGroupGridPlane->SetGroupPrimitivesAspect (TextAttrib);
myGridPlane.Location ().Coord (xl, yl, zl);
Points (0).SetCoord (xl, yl, zl);
myGroupGridPlane->BeginPrimitives ();
myGroupGridPlane->Text ("GRID PLANE", Points (0), 1./81.);
myGridPlane.XDirection ().Coord (ay, by, cy);
Points (1).SetCoord
(xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy);
myGroupGridPlane->Polyline (Points);
myGroupGridPlane->Text ("X", Points (1), 1./81.);
myGridPlane.YDirection ().Coord (ay, by, cy);
Points (1).SetCoord
(xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy);
myGroupGridPlane->Polyline (Points);
myGroupGridPlane->Text ("Y", Points (1), 1./81.);
myGridPlane.Direction ().Coord (ay, by, cy);
Points (1).SetCoord
(xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy);
myGroupGridPlane->Polyline (Points);
myGroupGridPlane->Text ("Z", Points (1), 1./81.);
myGroupGridPlane->EndPrimitives ();
#endif
}
void V3d_RectangularGrid::DefineLines () {
Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d ();
LineAttrib->SetColor (myColor);
LineAttrib->SetType (Aspect_TOL_SOLID);
LineAttrib->SetWidth (1.0);
Standard_Real aXStep = XStep ();
Standard_Real aYStep = YStep ();
Standard_Integer nblines, p;
Standard_Real xl, yl, zl = myOffSet;
Graphic3d_Vertex P1, P2;
Standard_Boolean MakeVerticales = Standard_False;
if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Points)
MakeVerticales = Standard_True;
else {
if (aXStep != myCurXStep)
MakeVerticales = Standard_True;
}
if (MakeVerticales) {
#ifdef TRACE_MAKE
cout << "MakeVerticales" << endl;
#endif
// verticales
myGroup1->Clear ();
LineAttrib->SetColor (myTenthColor);
myGroup1->SetGroupPrimitivesAspect (LineAttrib);
myGroup1->BeginPrimitives ();
P1.SetCoord (0.0, -myYSize, -zl);
P2.SetCoord (0.0, myYSize, -zl);
myGroup1->Polyline (P1, P2, Standard_False);
nblines = 1; // on commence par une ligne gris fonce
LineAttrib->SetColor (myColor);
myGroup1->SetPrimitivesAspect (LineAttrib);
for (xl = aXStep; xl < myXSize; xl += aXStep) {
P1.SetCoord (xl, -myYSize, -zl);
P2.SetCoord (xl, myYSize, -zl);
p = Modulus (nblines, 10);
if (p != 0) {
myGroup1->Polyline (P1, P2, Standard_False);
P1.SetCoord (-xl, -myYSize, -zl);
P2.SetCoord (-xl, myYSize, -zl);
myGroup1->Polyline (P1, P2, Standard_False);
}
else {
LineAttrib->SetColor (myTenthColor);
myGroup1->SetPrimitivesAspect (LineAttrib);
myGroup1->Polyline (P1, P2, Standard_False);
P1.SetCoord (-xl, -myYSize, -zl);
P2.SetCoord (-xl, myYSize, -zl);
myGroup1->Polyline (P1, P2, Standard_False);
LineAttrib->SetColor (myColor);
myGroup1->SetPrimitivesAspect (LineAttrib);
}
nblines ++;
}
myGroup1->EndPrimitives ();
myGroup1->SetMinMaxValues
(-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0);
}
Standard_Boolean MakeHorizontales = Standard_False;
if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Points)
MakeHorizontales = Standard_True;
else {
if (aYStep != myCurYStep)
MakeHorizontales = Standard_True;
}
if (MakeHorizontales) {
#ifdef TRACE_MAKE
cout << "MakeHorizontales" << endl;
#endif
// horizontales
myGroup2->Clear ();
LineAttrib->SetColor (myTenthColor);
myGroup2->SetGroupPrimitivesAspect (LineAttrib);
myGroup2->BeginPrimitives ();
P1.SetCoord (-myXSize, 0., -zl);
P2.SetCoord (myXSize, 0., -zl);
myGroup2->Polyline (P1, P2, Standard_False);
nblines = 1; // on commence par une ligne gris fonce
LineAttrib->SetColor (myColor);
myGroup2->SetPrimitivesAspect (LineAttrib);
for (yl = aYStep; yl < myYSize; yl += aYStep) {
P1.SetCoord (-myXSize, yl, -zl);
P2.SetCoord (myXSize, yl, -zl);
p = Modulus (nblines, 10);
if (p != 0) {
myGroup2->Polyline (P1, P2, Standard_False);
P1.SetCoord (-myXSize, -yl, -zl);
P2.SetCoord (myXSize, -yl, -zl);
myGroup2->Polyline (P1, P2, Standard_False);
}
else {
LineAttrib->SetColor (myTenthColor);
myGroup2->SetPrimitivesAspect (LineAttrib);
myGroup2->Polyline (P1, P2, Standard_False);
P1.SetCoord (-myXSize, -yl, -zl);
P2.SetCoord (myXSize, -yl, -zl);
myGroup2->Polyline (P1, P2, Standard_False);
LineAttrib->SetColor (myColor);
myGroup2->SetPrimitivesAspect (LineAttrib);
}
nblines ++;
}
myGroup2->EndPrimitives ();
myGroup2->SetMinMaxValues
(-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0);
}
myCurXStep = aXStep, myCurYStep = aYStep;
}
void V3d_RectangularGrid::DefinePoints () {
Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d ();
MarkerAttrib->SetColor (myColor);
MarkerAttrib->SetType (Aspect_TOM_POINT);
MarkerAttrib->SetScale (3.);
Standard_Real aXStep = XStep ();
Standard_Real aYStep = YStep ();
Standard_Integer i, nbpoints;
nbpoints = Standard_Integer (myYSize/aYStep);
nbpoints = 4 * nbpoints + 2;
Graphic3d_Array1OfVertex Vertical (1, nbpoints);
Standard_Real xl, yl, zl = myOffSet;
Standard_Boolean MakeHorizontales = Standard_False;
if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Lines)
MakeHorizontales = Standard_True;
else {
if (aXStep != myCurXStep || aYStep != myCurYStep)
MakeHorizontales = Standard_True;
}
if (MakeHorizontales) {
#ifdef TRACE_MAKE
cout << "MakeHorizontales" << endl;
#endif
// horizontales
myGroup1->Clear ();
myGroup1->SetGroupPrimitivesAspect (MarkerAttrib);
myGroup1->BeginPrimitives ();
for (xl = 0.0; xl <= myXSize; xl += aXStep) {
i = 1;
Vertical (i++).SetCoord (xl, 0.0, -zl);
Vertical (i++).SetCoord (-xl, 0.0, -zl);
for (yl = aYStep; yl <= myYSize; yl += aYStep) {
if (i<=nbpoints) Vertical (i++).SetCoord (xl, yl, -zl);
if (i<=nbpoints) Vertical (i++).SetCoord (xl, -yl, -zl);
if (i<=nbpoints) Vertical (i++).SetCoord (-xl, yl, -zl);
if (i<=nbpoints) Vertical (i++).SetCoord (-xl, -yl, -zl);
}
myGroup1->MarkerSet (Vertical, Standard_False);
}
myGroup1->EndPrimitives ();
myGroup1->SetMinMaxValues
(-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0);
}
myCurXStep = aXStep, myCurYStep = aYStep;
}
void V3d_RectangularGrid::GraphicValues (Standard_Real& theXSize, Standard_Real& theYSize, Standard_Real& theOffSet) const {
theXSize = myXSize;
theYSize = myYSize;
theOffSet = myOffSet;
}
void V3d_RectangularGrid::SetGraphicValues (const Standard_Real theXSize, const Standard_Real theYSize, const Standard_Real theOffSet) {
#ifdef TRACE_MINMAX
cout << "theXSize " << theXSize << " theYSize " << theYSize
<< " theOffSet " << theOffSet << endl;
#endif
if (! myCurAreDefined) {
myXSize = theXSize;
myYSize = theYSize;
myOffSet = theOffSet;
}
if (myXSize != theXSize) {
myXSize = theXSize;
myCurAreDefined = Standard_False;
}
if (myYSize != theYSize) {
myYSize = theYSize;
myCurAreDefined = Standard_False;
}
if (myOffSet != theOffSet) {
myOffSet = theOffSet;
myCurAreDefined = Standard_False;
}
#ifdef IMP200300
if( !myCurAreDefined ) UpdateDisplay();
#endif
}

167
src/V3d/V3d_SpotLight.cdl Executable file
View File

@@ -0,0 +1,167 @@
-- File: SpotLight.cdl
-- Created: Wed Jan 22 17:03:34 1992
-- Author: GG
-- Update: FDA - Oct 15 1994,
-- ZOV - Mars 30 1998
---Copyright: Matra Datavision 1992
class SpotLight from V3d
---Purpose: Creation and modification of a spot.
inherits PositionLight from V3d
uses
Viewer from V3d,
TypeOfOrientation from V3d,
TypeOfRepresentation from V3d,
Coordinate from V3d,
NameOfColor from Quantity,
PlaneAngle from Quantity,
Coefficient from Quantity,
Parameter from Quantity,
View from V3d,
Structure from Graphic3d,
Vertex from Graphic3d,
Group from Graphic3d
raises BadValue from Viewer
is
Create ( VM : mutable Viewer ; X,Y,Z : Coordinate ;
Direction : TypeOfOrientation = V3d_XnegYnegZpos ;
Color : NameOfColor = Quantity_NOC_WHITE ;
Attenuation1 : Coefficient = 1.0 ;
Attenuation2 : Coefficient = 0.0 ;
Concentration : Coefficient = 1.0 ;
Angle : PlaneAngle = 0.523599 )
returns mutable SpotLight
---Level: Public
---Purpose: Creates a light source of the Spot type in the viewer.
-- The attenuation factor F which determines
-- the illumination of a surface depends on the following formula :
-- F = 1/(A1 + A2*Length)
-- A1,A2 being the 2 factors of attenuation
-- Length is the distance from the source to the surface.
-- The default values (1.0,0.0) correspond to a minimum
-- of attenuation .
-- The concentration factor determines the dispersion
-- of the light on the surface, the default value
-- (1.0) corresponds to a minimum of dispersion .
raises BadValue from Viewer;
---Purpose: Warning! raises BadValue from Viewer -
-- If one of the coefficients is not between 0 and 1 .
-- If the lighting angle is <= 0 ou > PI .
Create ( VM : mutable Viewer ; Xt,Yt,Zt : Coordinate;
Xp,Yp,Zp : Coordinate;
Color : NameOfColor = Quantity_NOC_WHITE ;
Attenuation1 : Coefficient = 1.0 ;
Attenuation2 : Coefficient = 0.0 ;
Concentration : Coefficient = 1.0 ;
Angle : PlaneAngle = 0.523599 )
returns mutable SpotLight
---Level: Public
---Purpose: Creates a light source of the Spot type in the viewer.
-- Xt,Yt,Zt : Coordinate of light source Target.
-- Xp,Yp,Zp : Coordinate of light source Position.
-- The others parameters describe before.
raises BadValue from Viewer;
---Purpose: Warning! raises BadValue from Viewer -
-- If one of the coefficients is not between 0 and 1 .
-- If the lighting angle is <= 0 ou > PI .
--------------------------------------------------------
---Category: Methods to modify the Attributes of the light
--------------------------------------------------------
SetPosition ( me : mutable; X,Y,Z : Coordinate ) is redefined;
---Level: Public
---Purpose: Defines the position of the light source.
SetDirection ( me : mutable; Vx, Vy, Vz : Parameter ) raises BadValue from Viewer is static;
---Level: Public
---Purpose : Defines the direction of the light source.
-- If the normal vector is NULL.
SetDirection ( me : mutable; Orientation : TypeOfOrientation ) is static;
---Level: Public
---Purpose : Defines the direction of the light source
-- according to a predefined directional vector.
SetAttenuation( me : mutable; A1,A2 : Coefficient ) raises BadValue from Viewer is static;
---Level: Public
---Purpose: Defines the coefficients of attenuation.
-- Warning! raises BadValue from Viewer
-- if one of the coefficient is <0 ou >1 .
SetConcentration( me : mutable; C : Coefficient ) raises BadValue from Viewer is static;
---Level: Public
---Purpose: Defines the coefficient of concentration.
-- if the coefficient is <0 ou >1 .
SetAngle ( me : mutable; Angle : PlaneAngle ) raises BadValue from Viewer is static;
---Level: Public
---Purpose: Defines the spot angle in RADIANS.
-- Warning: raises BadValue from from Viewer
-- If the angle is <= 0 ou > PI .
---------------------------------------------------
---Category: display methods
---------------------------------------------------
Display(me: mutable; aView: View from V3d;
Representation : TypeOfRepresentation)
is redefined static;
---Level: Public
---Purpose: Display the graphic structure of light source
-- in the choosen view. We have three type of representation
-- - SIMPLE : Only the light source is displayed.
-- - PARTIAL : The light source and the light space are
-- displayed.
-- - COMPLETE : The light source, the light space and the
-- radius of light space are displayed.
-- We can choose the "SAMELAST" as parameter of representation
-- In this case the graphic structure representation will be
-- the last displayed.
---------------------------------------------------
---Category: Inquire methods
---------------------------------------------------
Direction ( me; Vx, Vy, Vz : out Parameter ) is static;
---Level: Public
---Purpose : Returns the direction of the light source defined by Vx,Vy,Vz.
Position ( me; X,Y,Z : out Coordinate ) is redefined static;
---Level: Public
---Purpose : Returns the position of the light source.
Attenuation ( me; A1,A2 : out Coefficient ) is static;
---Level: Public
---Purpose : Returns the attenuation factors A1,A2 of the light source.
Concentration( me ) returns Coefficient is static;
---Level: Public
Angle ( me ) returns PlaneAngle is static;
---Level: Public
---Purpose: Returns the spot angle.
-----------------------------------------
---Category: Private or Protected methods
-----------------------------------------
Symbol ( me ; gsymbol : mutable Group from Graphic3d ;
aView : View from V3d ) is redefined static private;
---Level: Internal
---Purpose: Defines the representation of the spot light source.
end SpotLight;

329
src/V3d/V3d_SpotLight.cxx Executable file
View File

@@ -0,0 +1,329 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_SpotLight :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
18-06-96 : FMN ; Ajout MyGraphicStructure1 pour sauvegarder snopick
30-03-98 : ZOV ; PRO6774 (reconstruction of the class hierarchy and suppressing useless methods)
02.15.100 : JR : Clutter
************************************************************************/
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d.hxx>
#include <V3d_SpotLight.ixx>
#include <Graphic3d_Vector.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Visual3d_Light.hxx>
#include <Visual3d_ViewManager.hxx>
#include <Visual3d_ContextPick.hxx>
#include <Visual3d_PickDescriptor.hxx>
#include <Visual3d_HSequenceOfPickPath.hxx>
#include <Visual3d_PickPath.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <TCollection_AsciiString.hxx>
#ifdef WNT
# include <WNT_Window.hxx>
#else
# include <Xw_Window.hxx>
#endif
V3d_SpotLight::V3d_SpotLight(const Handle(V3d_Viewer)& VM, const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const V3d_TypeOfOrientation Direction, const Quantity_NameOfColor Name, const Standard_Real A1, const Standard_Real A2, const Standard_Real CN, const Standard_Real AN):V3d_PositionLight(VM) {
Viewer_BadValue_Raise_if( A1 < 0 || A1 > 1. || A2 < 0 || A2 > 1
|| AN < 0. || AN > PI, "V3d_SpotLight, bad coefficient or angle");
Quantity_Color C(Name) ;
Graphic3d_Vector D = V3d::GetProjAxis(Direction) ;
Graphic3d_Vertex P(X,Y,Z) ;
Graphic3d_Vertex T;
MyType = V3d_SPOT ;
MyLight = new Visual3d_Light(C,P,D,CN,A1,A2,AN) ;
// On fixe la cible, a partir de la position de la light et de la direction.
T.SetCoord(X + D.X(), Y + D.Y(), Z + D.Z());
MyTarget = T;
}
V3d_SpotLight::V3d_SpotLight(const Handle(V3d_Viewer)& VM, const Standard_Real Xt, const Standard_Real Yt, const Standard_Real Zt, const Standard_Real Xp, const Standard_Real Yp, const Standard_Real Zp, const Quantity_NameOfColor Name, const Standard_Real A1, const Standard_Real A2, const Standard_Real CN, const Standard_Real AN):V3d_PositionLight(VM) {
Viewer_BadValue_Raise_if( A1 < 0 || A1 > 1. || A2 < 0 || A2 > 1
|| AN < 0. || AN > PI, "V3d_SpotLight, bad coefficient or angle");
Quantity_Color C(Name) ;
Graphic3d_Vertex T(Xt,Yt,Zt) ;
Graphic3d_Vertex P(Xp,Yp,Zp) ;
Graphic3d_Vector D(P,T);
MyType = V3d_SPOT ;
D.Normalize();
MyLight = new Visual3d_Light(C,P,D,CN,A1,A2,AN) ;
MyTarget = T;
// La Structure graphique sera initialisee lors de l'affichage.
}
//-Methods, in order
void V3d_SpotLight::SetPosition(const Standard_Real Xp, const Standard_Real Yp, const Standard_Real Zp) {
MyLight->SetPosition (Graphic3d_Vertex (Xp,Yp,Zp));
}
void V3d_SpotLight::SetDirection(const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz) {
Graphic3d_Vector D ;
D.SetCoord(Vx,Vy,Vz) ; D.Normalize() ;
MyLight->SetDirection(D) ;
}
void V3d_SpotLight::SetDirection(const V3d_TypeOfOrientation Direction) {
Graphic3d_Vector D = V3d::GetProjAxis(Direction) ;
MyLight->SetDirection(D) ;
}
void V3d_SpotLight::SetAttenuation(const Standard_Real A1, const Standard_Real A2) {
Viewer_BadValue_Raise_if( A1 < 0 || A1 > 1. || A2 < 0 || A2 > 1 ,
"V3d_SpotLight::SetAttenuation, bad coefficients");
MyLight->SetAttenuation1(A1) ;
MyLight->SetAttenuation2(A2) ;
}
void V3d_SpotLight::SetConcentration(const Standard_Real C) {
Viewer_BadValue_Raise_if( C < 0 || C > 1.,
"V3d_SpotLight::SetConcentration, bad coefficient");
MyLight->SetConcentration(C) ;
}
void V3d_SpotLight::SetAngle(const Standard_Real Angle) {
Viewer_BadValue_Raise_if( Angle <= 0. || Angle >= PI,
"V3d_SpotLight::SetAngle, bad angle");
MyLight->SetAngle(Angle) ;
}
void V3d_SpotLight::Direction(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz)const {
Quantity_Color C ;
Graphic3d_Vector D ;
Graphic3d_Vertex P ;
Standard_Real CN,A1,A2,AN ;
MyLight->Values(C,P,D,CN,A1,A2,AN) ;
D.Coord(Vx,Vy,Vz) ;
}
void V3d_SpotLight::Position(Standard_Real& Xp, Standard_Real& Yp, Standard_Real& Zp)const {
Quantity_Color C ;
Graphic3d_Vector D ;
Graphic3d_Vertex P ;
Standard_Real CN,A1,A2,AN ;
MyLight->Values(C,P,D,CN,A1,A2,AN) ;
P.Coord(Xp,Yp,Zp) ;
}
void V3d_SpotLight::Attenuation(Standard_Real& A1, Standard_Real& A2) const {
Quantity_Color C ;
Graphic3d_Vector D ;
Graphic3d_Vertex P ;
Standard_Real CN,AN ;
MyLight->Values(C,P,D,CN,A1,A2,AN) ;
}
Standard_Real V3d_SpotLight::Concentration()const {
Quantity_Color C ;
Graphic3d_Vector D ;
Graphic3d_Vertex P ;
Standard_Real AN,A1,A2,CN ;
MyLight->Values(C,P,D,CN,A1,A2,AN) ;
return CN ;
}
Standard_Real V3d_SpotLight::Angle()const {
Quantity_Color C ;
Graphic3d_Vector D ;
Graphic3d_Vertex P ;
Standard_Real CN,A1,A2,AN ;
MyLight->Values(C,P,D,CN,A1,A2,AN) ;
return AN ;
}
void V3d_SpotLight::Symbol (const Handle(Graphic3d_Group)& gsymbol,
// const Handle(V3d_View)& aView) const {
const Handle(V3d_View)& ) const {
Standard_Real X,Y,Z,Rayon;
Standard_Real DX,DY,DZ;
this->Position(X,Y,Z);
this->Direction(DX,DY,DZ);
Rayon = this->Radius();
V3d::ArrowOfRadius(gsymbol,X,Y,Z,-DX,-DY,-DZ,PI/8.,Rayon/15.);
}
void V3d_SpotLight::Display( const Handle(V3d_View)& aView,
const V3d_TypeOfRepresentation TPres) {
Graphic3d_Array1OfVertex PRadius(0,1);
Graphic3d_Vertex PText ;
Standard_Real X,Y,Z,Rayon;
Standard_Real X0,Y0,Z0,VX,VY,VZ;
Standard_Real X1,Y1,Z1;
Standard_Real DXRef,DYRef,DZRef,DXini,DYini,DZini;
Standard_Real R1,G1,B1;
V3d_TypeOfRepresentation Pres;
V3d_TypeOfUpdate UpdSov;
// Creation d'une structure slight d'elements reperables (la position de
// la light, et le domaine d'eclairage represente par un cercle)
// Creation d'une structure snopick d'elements non reperables ( cible, meridien et
// parallele ).
Pres = TPres;
Handle(V3d_Viewer) TheViewer = aView->Viewer();
UpdSov = TheViewer->UpdateMode();
TheViewer->SetUpdateMode(V3d_WAIT);
if (!MyGraphicStructure.IsNull()) {
MyGraphicStructure->Disconnect(MyGraphicStructure1);
MyGraphicStructure->Clear();
MyGraphicStructure1->Clear();
if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation;
}
else {
if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE;
Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer());
MyGraphicStructure = slight;
Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer());
MyGraphicStructure1 = snopick;
}
Handle(Graphic3d_Group) gradius;
Handle(Graphic3d_Group) gExtArrow;
Handle(Graphic3d_Group) gIntArrow;
if (Pres == V3d_COMPLETE) {
gradius = new Graphic3d_Group(MyGraphicStructure);
gExtArrow = new Graphic3d_Group(MyGraphicStructure);
gIntArrow = new Graphic3d_Group(MyGraphicStructure);
}
Handle(Graphic3d_Group) glight = new Graphic3d_Group(MyGraphicStructure);
Handle(Graphic3d_Group) gsphere;
if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) gsphere = new Graphic3d_Group(MyGraphicStructure);
Handle(Graphic3d_Group) gnopick = new Graphic3d_Group(MyGraphicStructure1);
MyGraphicStructure1->SetPick(Standard_False);
X0 = MyTarget.X();
Y0 = MyTarget.Y();
Z0 = MyTarget.Z();
//Affichage de la position de la light.
glight->SetPickId(1);
this->Color(Quantity_TOC_RGB,R1,G1,B1);
Quantity_Color Col1(R1,G1,B1,Quantity_TOC_RGB);
Handle(Graphic3d_AspectLine3d) Asp1 = new Graphic3d_AspectLine3d();
Asp1->SetColor(Col1);
glight->SetPrimitivesAspect(Asp1);
this->Symbol(glight,aView);
//Affichage de la sphere de reperage (limite au cercle).
if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) {
Rayon = this->Radius();
aView->Proj(VX,VY,VZ);
gsphere->SetPickId(2);
V3d::CircleInPlane(gsphere,X0,Y0,Z0,VX,VY,VZ,Rayon);
//Affichage du rayon de la sphere (ligne + texte)
if (Pres == V3d_COMPLETE) {
gradius->SetPickId(3);
gExtArrow->SetPickId(4);
gIntArrow->SetPickId(5);
PRadius(0).SetCoord(X0,Y0,Z0);
this->Position(X,Y,Z);
PRadius(1).SetCoord(X,Y,Z);
gnopick->Polyline(PRadius);
V3d::ArrowOfRadius(gExtArrow,X-(X-X0)/10.,
Y-(Y-Y0)/10.,
Z-(Z-Z0)/10.,X-X0,Y-Y0,Z-Z0,Standard_PI/15.,Rayon/20.);
V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,Standard_PI/15.,Rayon/20.);
TCollection_AsciiString ValOfRadius(Rayon);
PText.SetCoord( (X0+X)/2., (Y0+Y)/2. , (Z0+Z)/2. );
gradius->Text(ValOfRadius.ToCString(),PText,0.01);
}
//Affichage du meridien
Quantity_Color Col2(Quantity_NOC_GREEN);
Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d
(Col2,Aspect_TOL_SOLID,1.);
gnopick->SetPrimitivesAspect(Asp2);
// Definition de l'axe du cercle
aView->Up(DXRef,DYRef,DZRef);
this->Position(X,Y,Z);
DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
VX = DYRef*DZini - DZRef*DYini;
VY = DZRef*DXini - DXRef*DZini;
VZ = DXRef*DYini - DYRef*DXini;
V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
// Affichage de la parallele
// Definition de l'axe du cercle
aView->Proj(VX,VY,VZ);
aView->Up(X1,Y1,Z1);
DXRef = VY * Z1 - VZ * Y1;
DYRef = VZ * X1 - VX * Z1;
DZRef = VX * Y1 - VY * X1;
this->Position(X,Y,Z);
DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
VX = DYRef*DZini - DZRef*DYini;
VY = DZRef*DXini - DXRef*DZini;
VZ = DXRef*DYini - DYRef*DXini;
V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
}
MyGraphicStructure->Connect(MyGraphicStructure1,Graphic3d_TOC_DESCENDANT);
MyTypeOfRepresentation = Pres;
MyGraphicStructure->Display();
TheViewer->SetUpdateMode(UpdSov);
}

13
src/V3d/V3d_Static.hxx Executable file
View File

@@ -0,0 +1,13 @@
//static Standard_Real MyXwindowCenter ;
//static Standard_Real MyYwindowCenter ;
//static Standard_Real MyWindowWidth ;
//static Standard_Real MyWindowHeight ;
static Graphic3d_Vector MyXscreenAxis ;
static Graphic3d_Vector MyYscreenAxis ;
static Graphic3d_Vector MyZscreenAxis ;
static Graphic3d_Vector MyViewReferencePlane ;
static Graphic3d_Vector MyViewReferenceUp ;
static Graphic3d_Vector MyViewAxis ;
static Graphic3d_Vertex MyViewReferencePoint ;
static Graphic3d_Vertex MyGravityReferencePoint ;
static Graphic3d_Vertex MyProjReferencePoint ;

1773
src/V3d/V3d_View.cdl Executable file

File diff suppressed because it is too large Load Diff

3576
src/V3d/V3d_View.cxx Executable file

File diff suppressed because it is too large Load Diff

173
src/V3d/V3d_View_1.cxx Executable file
View File

@@ -0,0 +1,173 @@
/***********************************************************************
FONCTION :
----------
File V3d_View_1.cxx :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
01-03-92 : NW,JPB,CAL ; Creation.
13-07-97 : FMN: Debug sur le ZClipping BUC40193
Debug sur le ZCueing aussi
24-12-97 : FMN ; Suppression de GEOMLITE
************************************************************************/
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_View.jxx>
/*----------------------------------------------------------------------*/
void V3d_View::SetAntialiasingOn() {
MyViewContext.SetAliasingOn() ;
MyView->SetContext(MyViewContext) ;
}
void V3d_View::SetAntialiasingOff() {
MyViewContext.SetAliasingOff() ;
MyView->SetContext(MyViewContext) ;
}
/*----------------------------------------------------------------------*/
void V3d_View::SetZClippingDepth(const Standard_Real Depth) {
Standard_Real Front,Back,Width ;
Front = MyViewContext.ZClippingFrontPlane() ;
Back = MyViewContext.ZClippingBackPlane() ;
Width = Front - Back ;
Front = Depth + Width/2. ;
Back = Depth - Width/2. ;
MyViewContext.SetZClippingBackPlane(Back) ;
MyViewContext.SetZClippingFrontPlane(Front) ;
MyView->SetContext(MyViewContext) ;
}
/*----------------------------------------------------------------------*/
void V3d_View::SetZClippingWidth(const Standard_Real Width) {
Standard_Real Front,Back,Depth ;
Viewer_BadValue_Raise_if( Width <= 0.,"V3d_View::SetZClippingWidth, bad width");
Front = MyViewContext.ZClippingFrontPlane() ;
Back = MyViewContext.ZClippingBackPlane() ;
Depth = (Front + Back)/2. ;
Front = Depth + Width/2. ;
Back = Depth - Width/2. ;
MyViewContext.SetZClippingBackPlane(Back) ;
MyViewContext.SetZClippingFrontPlane(Front) ;
MyView->SetContext(MyViewContext) ;
}
/*----------------------------------------------------------------------*/
void V3d_View::SetZClippingType(const V3d_TypeOfZclipping Type) {
switch (Type) {
case V3d_OFF :
MyViewContext.SetZClippingOff() ;
break ;
case V3d_BACK :
MyViewContext.SetBackZClippingOn() ;
MyViewContext.SetFrontZClippingOff() ;
break ;
case V3d_FRONT :
MyViewContext.SetFrontZClippingOn() ;
MyViewContext.SetBackZClippingOff() ;
break ;
case V3d_SLICE :
MyViewContext.SetZClippingOn() ;
break ;
}
MyView->SetContext(MyViewContext) ;
}
/*----------------------------------------------------------------------*/
V3d_TypeOfZclipping V3d_View::ZClipping(Standard_Real& Depth, Standard_Real& Width) const {
V3d_TypeOfZclipping T = V3d_OFF ;
Standard_Real Front,Back ;
Standard_Boolean Aback,Afront ;
Back = MyViewContext.ZClippingBackPlane() ;
Front = MyViewContext.ZClippingFrontPlane() ;
Aback = MyViewContext.BackZClippingIsOn() ;
Afront = MyViewContext.FrontZClippingIsOn() ;
Width = Front - Back ;
Depth = (Front + Back)/2. ;
if( Aback ) {
if( Afront ) T = V3d_SLICE ;
else T = V3d_BACK ;
} else if( Afront ) T = V3d_FRONT ;
return T ;
}
/*----------------------------------------------------------------------*/
void V3d_View::SetZCueingDepth(const Standard_Real Depth) {
Standard_Real Front,Back,Width ;
Front = MyViewContext.DepthCueingFrontPlane() ;
Back = MyViewContext.DepthCueingBackPlane() ;
Width = Front - Back ;
Front = Depth + Width/2. ;
Back = Depth - Width/2. ;
MyViewContext.SetDepthCueingBackPlane(Back) ;
MyViewContext.SetDepthCueingFrontPlane(Front) ;
MyView->SetContext(MyViewContext) ;
}
/*----------------------------------------------------------------------*/
void V3d_View::SetZCueingWidth(const Standard_Real Width) {
Standard_Real Front,Back,Depth ;
Viewer_BadValue_Raise_if( Width <= 0.,"V3d_View::SetZCueingWidth, bad width");
Front = MyViewContext.DepthCueingFrontPlane() ;
Back = MyViewContext.DepthCueingBackPlane() ;
Depth = (Front + Back)/2. ;
Front = Depth + Width/2. ;
Back = Depth - Width/2. ;
MyViewContext.SetDepthCueingBackPlane(Back) ;
MyViewContext.SetDepthCueingFrontPlane(Front) ;
MyView->SetContext(MyViewContext) ;
}
/*----------------------------------------------------------------------*/
void V3d_View::SetZCueingOn() {
MyViewContext.SetDepthCueingOn() ;
MyView->SetContext(MyViewContext) ;
}
/*----------------------------------------------------------------------*/
void V3d_View::SetZCueingOff() {
MyViewContext.SetDepthCueingOff() ;
MyView->SetContext(MyViewContext) ;
}
/*----------------------------------------------------------------------*/
Standard_Boolean V3d_View::ZCueing(Standard_Real& Depth, Standard_Real& Width)const {
Standard_Boolean Z = MyViewContext.DepthCueingIsOn() ;
Standard_Real Front,Back ;
Back = MyViewContext.DepthCueingBackPlane() ;
Front = MyViewContext.DepthCueingFrontPlane() ;
Width = Front - Back ;
Depth = (Front + Back)/2. ;
return Z ;
}
/*----------------------------------------------------------------------*/

213
src/V3d/V3d_View_2.cxx Executable file
View File

@@ -0,0 +1,213 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_View_2.cxx :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
24-12-97 : FMN ; Suppression de GEOMLITE
21-02-00 : GG ; Add Transparency() method
23-11-00 : GG ; Add IsActiveLight() and IsActivePlane() methods
************************************************************************/
#define GER61454 //GG 13-09-99 Activates model clipping planes
// Use myView->PlaneLimit() instead Visual3d_ClipPlane::Limit()
// Use myView->LightLimit() instead Visual3d_Light::Limit()
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_View.jxx>
#include <Visual3d_View.hxx>
#include <Visual3d_Light.hxx>
#include <Visual3d_ClipPlane.hxx>
#include <V3d_Static.hxx>
#include <V3d.hxx>
/*----------------------------------------------------------------------*/
void V3d_View::SetLightOn( const Handle(V3d_Light)& TheLight ) {
if( !MyActiveLights.Contains(TheLight)){
#ifdef GER61454
Viewer_BadValue_Raise_if( MyActiveLights.Extent() >= MyView->LightLimit(),
"too many lights");
#else
// Viewer_BadValue_Raise_if( MyActiveLights.Extent() >= Visual3d_Light::Limit(),
// "too many lights");
#endif
MyActiveLights.Append(TheLight) ;
MyViewContext.SetLightOn(TheLight->Light());
MyView->SetContext(MyViewContext);
}
}
void V3d_View::SetLightOff( const Handle(V3d_Light)& TheLight ) {
Standard_TypeMismatch_Raise_if(MyViewer->IsGlobalLight(TheLight),"the light is global");
MyActiveLights.Remove(TheLight);
MyViewContext.SetLightOff(TheLight->Light()) ;
MyView->SetContext(MyViewContext) ;
}
Standard_Boolean V3d_View::IsActiveLight(const Handle(V3d_Light)& aLight) const {
if( aLight.IsNull() ) return Standard_False;
return MyActiveLights.Contains(aLight);
}
void V3d_View::SetLightOn( ) {
for(MyViewer->InitDefinedLights();MyViewer->MoreDefinedLights();MyViewer->NextDefinedLights()){
if(!MyActiveLights.Contains(MyViewer->DefinedLight())){
MyActiveLights.Append(MyViewer->DefinedLight()) ;
MyViewContext.SetLightOn(MyViewer->DefinedLight()->Light());
}
}
MyView->SetContext(MyViewContext) ;
}
void V3d_View::SetLightOff( ) {
InitActiveLights();
while(MoreActiveLights()) {
if (!MyViewer->IsGlobalLight(ActiveLight())) {
MyActiveLights.Remove(ActiveLight());
MyViewContext.SetLightOff(ActiveLight()->Light());
}
else
NextActiveLights();
}
MyView->SetContext(MyViewContext) ;
}
void V3d_View::SetTransparency(const Standard_Boolean AnActivity) {
MyTransparencyFlag = AnActivity;
MyView->SetTransparency(AnActivity);
}
Standard_Boolean V3d_View::Transparency() const {
return MyTransparencyFlag;
}
void V3d_View::SetPlaneOn( const Handle(V3d_Plane)& ThePlane ) {
#ifdef GER61454
if( !MyActivePlanes.Contains(ThePlane)) {
Viewer_BadValue_Raise_if( MyActivePlanes.Extent() >= MyView->PlaneLimit(), "too many planes");
MyActivePlanes.Append(ThePlane) ;
}
MyViewContext.SetClipPlaneOn(ThePlane->Plane()) ;
MyView->SetContext(MyViewContext);
#else //GER61454
if( !MyActivePlanes.Contains(ThePlane)) {
Viewer_BadValue_Raise_if( MyActivePlanes.Extent() >= Visual3d_ClipPlane::Limit(), "too many planes");
MyActivePlanes.Append(ThePlane) ;
MyViewContext.SetClipPlaneOn(ThePlane->Plane()) ;
MyView->SetContext(MyViewContext);
}
#endif //GER61454
}
void V3d_View::SetPlaneOff( const Handle(V3d_Plane)& ThePlane ) {
MyActivePlanes.Remove(ThePlane);
MyViewContext.SetClipPlaneOff(ThePlane->Plane()) ;
MyView->SetContext(MyViewContext) ;
}
Standard_Boolean V3d_View::IsActivePlane(const Handle(V3d_Plane)& aPlane) const {
if( aPlane.IsNull() ) return Standard_False;
return MyActivePlanes.Contains(aPlane);
}
void V3d_View::SetPlaneOn( ) {
#ifdef GER61454
for(MyViewer->InitDefinedPlanes();MyViewer->MoreDefinedPlanes();MyViewer->NextDefinedPlanes()) {
if(!MyActivePlanes.Contains(MyViewer->DefinedPlane())) {
Viewer_BadValue_Raise_if( MyActivePlanes.Extent() >= MyView->PlaneLimit(), "too many planes");
MyActivePlanes.Append(MyViewer->DefinedPlane());
}
MyViewContext.SetClipPlaneOn(MyViewer->DefinedPlane()->Plane());
}
MyView->SetContext(MyViewContext) ;
#else //GER61454
for(MyViewer->InitDefinedPlanes();MyViewer->MoreDefinedPlanes();MyViewer->NextDefinedPlanes()) {
if(!MyActivePlanes.Contains(MyViewer->DefinedPlane())) {
Viewer_BadValue_Raise_if( MyActivePlanes.Extent() >= Visual3d_ClipPlane::Limit(),
"too many planes");
MyActivePlanes.Append(MyViewer->DefinedPlane());
MyViewContext.SetClipPlaneOn(MyViewer->DefinedPlane()->Plane());
MyView->SetContext(MyViewContext) ;
}
}
#endif //GER61454
}
void V3d_View::SetPlaneOff( ) {
for(InitActivePlanes();MoreActivePlanes();NextActivePlanes()) {
MyViewContext.SetClipPlaneOff(ActivePlane()->Plane());}
MyActivePlanes.Clear();
MyView->SetContext(MyViewContext) ;
}
void V3d_View::InitActiveLights() {
myActiveLightsIterator.Initialize(MyActiveLights);
}
Standard_Boolean V3d_View::MoreActiveLights () const {
return myActiveLightsIterator.More();
}
void V3d_View::NextActiveLights () {
myActiveLightsIterator.Next();
}
Handle(V3d_Light) V3d_View::ActiveLight() const {
return (Handle(V3d_Light)&)(myActiveLightsIterator.Value());}
void V3d_View::InitActivePlanes() {
myActivePlanesIterator.Initialize(MyActivePlanes);
}
Standard_Boolean V3d_View::MoreActivePlanes () const {
return myActivePlanesIterator.More();
}
void V3d_View::NextActivePlanes () {
myActivePlanesIterator.Next();
}
Handle(V3d_Plane) V3d_View::ActivePlane() const {
return (Handle(V3d_Plane)&)(myActivePlanesIterator.Value());}
Standard_Boolean V3d_View::IfMorePlanes() const {
#ifdef GER61454
return MyActivePlanes.Extent() < MyView->PlaneLimit();
#else
return MyActivePlanes.Extent() < Visual3d_ClipPlane::Limit();
#endif
}
Standard_Boolean V3d_View::IfMoreLights() const {
#ifdef GER61454
return MyActiveLights.Extent() < MyView->LightLimit();
#else
// return MyActiveLights.Extent() < Visual3d_Light::Limit();
return MyActiveLights.Extent();
#endif
}

252
src/V3d/V3d_View_3.cxx Executable file
View File

@@ -0,0 +1,252 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_View_3.cxx :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
24-12-97 : FMN ; Suppression de GEOMLITE
13-06-98 : FMN ; PRO14896: Correction sur la gestion de la perspective (cf Programming Guide)
22-12-98 : FMN ; Rename CSF_WALKTHROW en CSF_WALKTHROUGH
IMP240100: GG -> Activates WalkThrough model.
************************************************************************/
#define IMP020300 //GG Don't use ZFitAll in during Rotation
// for perf improvment
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_View.jxx>
#include <V3d_Static.hxx>
#define Zmargin 1.
/*----------------------------------------------------------------------*/
void V3d_View::Move(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) {
Graphic3d_Vertex Prp ;
Graphic3d_Vector Vpn ;
Standard_Real XX,XY,XZ,YX,YY,YZ,ZX,ZY,ZZ ;
Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xeye,Yeye,Zeye ;
if( Start ) {
MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
Viewer_BadValue::Raise ("V3d_View::Move, alignment of Eye,At,Up");
}
MyXscreenAxis.Coord(XX,XY,XZ) ;
MyYscreenAxis.Coord(YX,YY,YZ) ;
MyZscreenAxis.Coord(ZX,ZY,ZZ) ;
MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
Xeye = Zrp*Xpn + Dx*XX + Dy*YX + Dz*ZX ;
Yeye = Zrp*Ypn + Dx*XY + Dy*YY + Dz*ZY ;
Zeye = Zrp*Zpn + Dx*XZ + Dy*YZ + Dz*ZZ ;
Zrp = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
Viewer_BadValue_Raise_if( Zrp <= 0. ,"V3d_View::Move:: Eye,At are Confused");
#ifdef DEB
Standard_Real focale =
#endif
Focale();
Prp.SetCoord(Xrp,Yrp,Zrp) ;
MyViewMapping.SetProjectionReferencePoint(Prp) ;
Xpn = Xeye / Zrp ; Ypn = Yeye / Zrp ; Zpn = Zeye / Zrp ;
Vpn.SetCoord(Xpn,Ypn,Zpn) ;
MyViewOrientation.SetViewReferencePlane(Vpn) ;
MyView->SetViewOrientation(MyViewOrientation) ;
// Check ZClipping planes
#ifdef IMP020300
MyView->SetViewMapping(MyViewMapping) ;
SetZSize(0.);
#else
Standard_Real Zmax,Xat,Yat,Zat ;
MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
Xeye += Xat ; Yeye += Yat ; Zeye += Zat ;
Zmax = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
if( Zmax > MyViewMapping.FrontPlaneDistance() &&
MyProjModel == V3d_TPM_SCREEN ) {
SetZSize(2.*Zmax+Zmax*Zmargin) ;
} else {
if( MyType == V3d_PERSPECTIVE ) {
SetFocale(focale) ;
}
MyView->SetViewMapping(MyViewMapping) ;
}
#endif
ImmediateUpdate();
}
void V3d_View::Move(const Standard_Real Length, const Standard_Boolean Start) {
Graphic3d_Vertex Prp ;
Graphic3d_Vector Vpn ;
Standard_Real Vx,Vy,Vz ;
Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xeye,Yeye,Zeye ;
if( Start ) {
MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
}
MyDefaultViewAxis.Coord(Vx,Vy,Vz) ;
MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
Xeye = Zrp*Xpn + Vx*Length ;
Yeye = Zrp*Ypn + Vy*Length ;
Zeye = Zrp*Zpn + Vz*Length ;
Zrp = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
Viewer_BadValue_Raise_if( Zrp <= 0. ,"V3d_View::Move:: Eye,At are Confused");
#ifdef DEB
Standard_Real focale =
#endif
Focale();
Prp.SetCoord(Xrp,Yrp,Zrp) ;
MyViewMapping.SetProjectionReferencePoint(Prp) ;
Xpn = Xeye / Zrp ; Ypn = Yeye / Zrp ; Zpn = Zeye / Zrp ;
Vpn.SetCoord(Xpn,Ypn,Zpn) ;
MyViewOrientation.SetViewReferencePlane(Vpn) ;
MyView->SetViewOrientation(MyViewOrientation) ;
#ifdef IMP020300
MyView->SetViewMapping(MyViewMapping) ;
SetZSize(0.);
#else
// Check ZClipping planes
Standard_Real Zmax,Xat,Yat,Zat ;
MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
Xeye += Xat ; Yeye += Yat ; Zeye += Zat ;
Zmax = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
if( Zmax > MyViewMapping.FrontPlaneDistance() &&
MyProjModel == V3d_TPM_SCREEN ) {
SetZSize(2.*Zmax+Zmax*Zmargin) ;
} else {
if( MyType == V3d_PERSPECTIVE ) {
SetFocale(focale) ;
}
MyView->SetViewMapping(MyViewMapping) ;
}
#endif
ImmediateUpdate();
}
void V3d_View::Move(const V3d_TypeOfAxe Axe , const Standard_Real Length, const Standard_Boolean Start) {
switch (Axe) {
case V3d_X :
Move(Length,0.,0.,Start);
break ;
case V3d_Y :
Move(0.,Length,0.,Start);
break ;
case V3d_Z :
Move(0.,0.,Length,Start);
break ;
}
}
void V3d_View::Translate(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) {
Graphic3d_Vertex Vrp ;
Standard_Real XX,XY,XZ,YX,YY,YZ,ZX,ZY,ZZ ;
Standard_Real Xat,Yat,Zat ;
if( Start ) {
MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
Viewer_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up");
}
MyXscreenAxis.Coord(XX,XY,XZ) ;
MyYscreenAxis.Coord(YX,YY,YZ) ;
MyZscreenAxis.Coord(ZX,ZY,ZZ) ;
MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
Xat -= Dx*XX + Dy*YX + Dz*ZX ;
Yat -= Dx*XY + Dy*YY + Dz*ZY ;
Zat -= Dx*XZ + Dy*YZ + Dz*ZZ ;
Vrp.SetCoord(Xat,Yat,Zat) ;
MyViewOrientation.SetViewReferencePoint(Vrp) ;
MyView->SetViewOrientation(MyViewOrientation) ;
#ifdef IMP020300
SetZSize(0.);
#else
// Check ZClipping planes
Standard_Real Xpn,Ypn,Zpn,Xrp,Yrp,Zrp,Xeye,Yeye,Zeye,Zmax ;
MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
Zmax = Max(sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ,
sqrt( Xat*Xat + Yat*Yat + Zat*Zat )) ;
if( Zmax > MyViewMapping.FrontPlaneDistance() &&
MyProjModel == V3d_TPM_SCREEN ) {
SetZSize(2.*Zmax+Zmax*Zmargin) ;
}
#endif
ImmediateUpdate();
}
void V3d_View::Translate(const V3d_TypeOfAxe Axe, const Standard_Real Length,const Standard_Boolean Start) {
switch (Axe) {
case V3d_X :
Translate(Length,0.,0., Start);
break ;
case V3d_Y :
Translate(0.,Length,0., Start);
break ;
case V3d_Z :
Translate(0.,0.,Length, Start);
break ;
}
}
void V3d_View::Place (const Standard_Integer ix, const Standard_Integer iy,
const Quantity_Factor aZoomFactor) {
Standard_Real xpos,ypos;
Standard_Integer xc,yc;
Center(xpos,ypos);
Convert(xpos,ypos,xc,yc);
Pan(xc-ix,iy-yc,aZoomFactor/Scale());
}
void V3d_View::Translate(const Standard_Real Length,const Standard_Boolean Start) {
Graphic3d_Vertex Vrp ;
Standard_Real Xat,Yat,Zat,Vx,Vy,Vz ;
if( Start ) {
MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
}
MyDefaultViewAxis.Coord(Vx,Vy,Vz) ;
MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
Xat -= Vx*Length ; Yat -= Vy*Length ; Zat -= Vz*Length ;
Vrp.SetCoord(Xat,Yat,Zat) ;
MyViewOrientation.SetViewReferencePoint(Vrp) ;
MyView->SetViewOrientation(MyViewOrientation) ;
#ifdef IMP020300
SetZSize(0.);
#else
// Check ZClipping planes
Standard_Real Xpn,Ypn,Zpn,Xrp,Yrp,Zrp,Xeye,Yeye,Zeye,Zmax ;
MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
Zmax = Max(sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ,
sqrt( Xat*Xat + Yat*Yat + Zat*Zat )) ;
if( Zmax > MyViewMapping.FrontPlaneDistance() &&
MyProjModel == V3d_TPM_SCREEN ) {
SetZSize(2.*Zmax+Zmax*Zmargin) ;
}
#endif
ImmediateUpdate();
}

755
src/V3d/V3d_View_4.cxx Executable file
View File

@@ -0,0 +1,755 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_View :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
16-08-98 : CAL ; S3892. Ajout grilles 3d.
16-09-98 : BGN ; Points d'entree du Triedre (S3819, Phase 1)
21-09-98 : CAL ; Activation de l'echo que si CSF_GraphicEcho est definie.
22-09-98 : BGN ; S3989 (anciennement S3819)
TypeOfTriedron* from Aspect (pas V3d)
02.15.100 : JR : Clutter
28/05/02 : VSV: ZBUFFER mode of Trihedron
************************************************************************/
#define IMP240100 //GG
// -> In Compute() method call MyViewer->ShowGridEcho()
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_View.jxx>
#include <TColStd_Array2OfReal.hxx>
#include <gp_Dir2d.hxx>
#include <Aspect.hxx>
#include <V3d_RectangularGrid.hxx>
#include <V3d_CircularGrid.hxx>
// Pour l'echo du point choisi
#include <Visual3d_TransientManager.hxx>
/*----------------------------------------------------------------------*/
/*
* Constant
*/
// en cas NO_TRACE_ECHO et de NO_TRACE_POINTS, dans V3d_View_4.cxx ET dans
// V3d_View.cxx, virer MyGridEchoStructure et MyGridEchoGroup dans le cdl
#define TRACE_ECHO
#define NO_TRACE_VALUES
#define NO_TRACE_POINTS
#define MYEPSILON1 0.0001 // Comparaison avec 0.0
#define MYEPSILON2 Standard_PI / 180. // Delta entre 2 angles
#ifdef TRACE_POINTS
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#endif
#ifdef TRACE_VALUES
#include <Visual3d_ViewOrientation.hxx>
#endif
#if defined TRACE_VALUES || defined TRACE_POINTS
static char *CAR [26] = {"a", "b", "c", "d", "e", "f", "g", "h",
"i", "j", "k", "l", "m", "n", "o", "p",
"q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
#endif
/*----------------------------------------------------------------------*/
void V3d_View::SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid) {
MyPlane = aPlane;
MyGrid = aGrid;
#ifdef TRACE_VALUES
if (MyGrid->IsKind (STANDARD_TYPE (Aspect_RectangularGrid))) {
cout << "Aspect_RectangularGrid" << endl;
Handle(Aspect_RectangularGrid) theGrid = *(Handle(Aspect_RectangularGrid) *) &MyGrid;
cout << "\tOrigine : " << theGrid->XOrigin () << ", "
<< theGrid->YOrigin () << endl;
cout << "\tAngle : " << theGrid->RotationAngle () << endl;
cout << "\tSteps : " << theGrid->XStep () << ", "
<< theGrid->YStep () << endl;
}
else {
cout << "Aspect_CircularGrid" << endl;
Handle(Aspect_CircularGrid) theGrid = *(Handle(Aspect_CircularGrid) *) &MyGrid;
cout << "\tOrigine : " << theGrid->XOrigin () << ", "
<< theGrid->YOrigin () << endl;
cout << "\tAngle : " << theGrid->RotationAngle () << endl;
cout << "\tRadiusStep, Division : " << theGrid->RadiusStep ()
<< ", " << theGrid->DivisionNumber () << endl;
}
#endif
Standard_Real xl, yl, zl;
Standard_Real xdx, xdy, xdz;
Standard_Real ydx, ydy, ydz;
Standard_Real dx, dy, dz;
aPlane.Location ().Coord (xl, yl, zl);
aPlane.XDirection ().Coord (xdx, xdy, xdz);
aPlane.YDirection ().Coord (ydx, ydy, ydz);
aPlane.Direction ().Coord (dx, dy, dz);
#ifdef TRACE_VALUES
cout << "Grid Plane " << xl << ", " << yl << ", " << zl << endl;
cout << "\tLocation " << xl << ", " << yl << ", " << zl << endl;
cout << "\tDirection " << dx << ", " << dy << ", " << dz << endl;
cout << "\tXDirection " << xdx << ", " << xdy << ", " << xdz << endl;
cout << "\tYDirection " << ydx << ", " << ydy << ", " << ydz << endl;
#endif
Standard_Real CosAlpha = Cos (MyGrid->RotationAngle ());
Standard_Real SinAlpha = Sin (MyGrid->RotationAngle ());
TColStd_Array2OfReal Trsf1 (1, 4, 1, 4);
Trsf1 (4, 4) = 1.0;
Trsf1 (4, 1) = Trsf1 (4, 2) = Trsf1 (4, 3) = 0.0;
// Translation
Trsf1 (1, 4) = xl,
Trsf1 (2, 4) = yl,
Trsf1 (3, 4) = zl;
// Transformation de changement de repere
Trsf1 (1, 1) = xdx,
Trsf1 (2, 1) = xdy,
Trsf1 (3, 1) = xdz,
Trsf1 (1, 2) = ydx,
Trsf1 (2, 2) = ydy,
Trsf1 (3, 2) = ydz,
Trsf1 (1, 3) = dx,
Trsf1 (2, 3) = dy,
Trsf1 (3, 3) = dz;
TColStd_Array2OfReal Trsf2 (1, 4, 1, 4);
Trsf2 (4, 4) = 1.0;
Trsf2 (4, 1) = Trsf2 (4, 2) = Trsf2 (4, 3) = 0.0;
// Translation de l'origine
Trsf2 (1, 4) = -MyGrid->XOrigin (),
Trsf2 (2, 4) = -MyGrid->YOrigin (),
Trsf2 (3, 4) = 0.0;
// Rotation Alpha autour de l'axe -Z
Trsf2 (1, 1) = CosAlpha,
Trsf2 (2, 1) = -SinAlpha,
Trsf2 (3, 1) = 0.0,
Trsf2 (1, 2) = SinAlpha,
Trsf2 (2, 2) = CosAlpha,
Trsf2 (3, 2) = 0.0,
Trsf2 (1, 3) = 0.0,
Trsf2 (2, 3) = 0.0,
Trsf2 (3, 3) = 1.0;
Standard_Real valuetrsf;
Standard_Real valueoldtrsf;
Standard_Real valuenewtrsf;
Standard_Integer i, j, k;
// Le calcul de produit de matrices
for (i=1; i<=4; i++)
for (j=1; j<=4; j++) {
MyTrsf (i, j) = 0.0;
for (k=1; k<=4; k++) {
valueoldtrsf = Trsf1 (i, k);
valuetrsf = Trsf2 (k, j);
valuenewtrsf = MyTrsf (i, j) + valueoldtrsf * valuetrsf;
MyTrsf (i, j) = valuenewtrsf;
}
}
}
void V3d_View::SetGridActivity (const Standard_Boolean AFlag) {
if (AFlag) MyGrid->Activate ();
else MyGrid->Deactivate ();
}
void V3d_View::SetGridGraphicValues (const Handle(Aspect_Grid)&
#ifdef TRACE_VALUES
aGrid
#endif
) {
#ifdef TRACE_VALUES
Standard_Real XSize, YSize, Radius, OffSet;
if (aGrid->IsKind (STANDARD_TYPE (V3d_RectangularGrid))) {
cout << "V3d_RectangularGrid" << endl;
Handle(V3d_RectangularGrid) theGrid = *(Handle(V3d_RectangularGrid) *) &aGrid;
theGrid->GraphicValues (XSize, YSize, OffSet);
cout << "\tSizes : " << XSize << ", " << YSize << endl;
cout << "\tOffSet : " << OffSet << endl;
}
else {
cout << "V3d_CircularGrid" << endl;
Handle(V3d_CircularGrid) theGrid = *(Handle(V3d_CircularGrid) *) &aGrid;
theGrid->GraphicValues (Radius, OffSet);
cout << "\tRadius : " << Radius << endl;
cout << "\tOffSet : " << OffSet << endl;
}
#endif
}
Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex & AVertex) const {
Graphic3d_Vertex CurPoint, NewPoint;
Standard_Real X1, Y1, Z1, X2, Y2, Z2;
Standard_Real XPp, YPp;
MyView->ViewOrientation ().ViewReferencePlane ().Coord (X1, Y1, Z1);
MyPlane.Direction ().Coord (X2, Y2, Z2);
gp_Dir VPN (X1, Y1, Z1);
gp_Dir GPN (X2, Y2, Z2);
#ifdef TRACE_VALUES
cout << "View Plane : " << X1 << ", " << Y1 << ", " << Z1 << endl;
cout << "Grid Plane " << X2 << ", " << Y2 << ", " << Z2 << endl;
cout << "Angle VPN GPN : " << VPN.Angle (GPN) << endl;
#endif
AVertex.Coord (X1, Y1, Z1);
Project (X1, Y1, Z1, XPp, YPp);
#ifdef TRACE_VALUES
cout << "AVertex : " << X1 << ", " << Y1 << ", " << Z1 << endl;
#endif
// Cas ou le plan de la grille et le plan de la vue
// sont perpendiculaires a MYEPSILON2 radians pres
if (Abs (VPN.Angle (GPN) - Standard_PI / 2.) < MYEPSILON2) {
NewPoint.SetCoord (X1, Y1, Z1);
#ifdef TRACE_POINTS
TextAttrib->SetColor (Quantity_Color (Quantity_NOC_RED));
MyGridEchoGroup->SetPrimitivesAspect (TextAttrib);
MyGridEchoGroup->Text ("Q", NewPoint, 1./81.);
MyGridEchoGroup->Polyline (AVertex, NewPoint);
Update ();
#endif
#ifdef IMP240100
MyViewer->ShowGridEcho(this,NewPoint);
#else
#ifdef TRACE_ECHO
char *trace_echo = NULL;
trace_echo = (char *)(getenv ("CSF_GraphicEcho"));
if (trace_echo) {
MyGridEchoGroup->Clear ();
MyGridEchoGroup->Marker (NewPoint);
Visual3d_TransientManager::BeginDraw
(MyView, Standard_False, Standard_False);
Visual3d_TransientManager::DrawStructure (MyGridEchoStructure);
Visual3d_TransientManager::EndDraw (Standard_True);
}
#endif
#endif //IMP240100
return NewPoint;
}
#ifdef TRACE_POINTS
Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d ();
Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d ();
MyGridEchoGroup->Clear ();
LineAttrib->SetColor (Quantity_Color (Quantity_NOC_RED));
MyGridEchoGroup->SetGroupPrimitivesAspect (LineAttrib);
TextAttrib->SetColor (Quantity_Color (Quantity_NOC_RED));
MyGridEchoGroup->SetGroupPrimitivesAspect (TextAttrib);
MyGridEchoGroup->Text ("P", AVertex, 1./81.);
CurPoint.SetCoord (AVertex.X (), AVertex.Y (), AVertex.Z ());
TextAttrib->SetColor (Quantity_Color (Quantity_NOC_GREEN));
MyGridEchoGroup->SetPrimitivesAspect (TextAttrib);
#endif
Standard_Boolean IsRectangular =
MyGrid->IsKind (STANDARD_TYPE (Aspect_RectangularGrid));
Graphic3d_Vertex P1;
Standard_Real XO = 0.0, YO = 0.0;
Standard_Real XOp, YOp;
Standard_Real XAp, YAp;
Standard_Real XBp, YBp;
X1 = XO, Y1 = YO, Z1 = 0.0;
// MyTrsf * Point pour se retrouver sur le plan de la grille 3D
P1.SetCoord (X1, Y1, Z1);
CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
CurPoint.Coord (X2, Y2, Z2);
Project (X2, Y2, Z2, XOp, YOp);
XPp = XPp - XOp, YPp = YPp - YOp;
#ifdef TRACE_POINTS
MyGridEchoGroup->Text ("O", CurPoint, 1./81.);
#endif
#ifdef TRACE_VALUES
cout << "Projection de P : " << XPp << ", " << YPp << endl;
cout << "Projection de O : " << XOp << ", " << YOp << endl;
#endif
if (IsRectangular) {
Standard_Real XS, YS;
Handle(Aspect_RectangularGrid) theGrid =
*(Handle(Aspect_RectangularGrid) *) &MyGrid;
XS = theGrid->XStep (), YS = theGrid->YStep ();
X1 = XO + XS, Y1 = YO, Z1 = 0.0;
// MyTrsf * Point pour se retrouver sur le plan de la grille 3D
P1.SetCoord (X1, Y1, Z1);
CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
CurPoint.Coord (X2, Y2, Z2);
Project (X2, Y2, Z2, XAp, YAp);
XAp = XAp - XOp, YAp = YAp - YOp;
#ifdef TRACE_POINTS
MyGridEchoGroup->Text ("A", CurPoint, 1./81.);
#endif
X1 = XO, Y1 = YO + YS, Z1 = 0.0;
// MyTrsf * Point pour se retrouver sur le plan de la grille 3D
P1.SetCoord (X1, Y1, Z1);
CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
CurPoint.Coord (X2, Y2, Z2);
Project (X2, Y2, Z2, XBp, YBp);
XBp = XBp - XOp, YBp = YBp - YOp;
#ifdef TRACE_POINTS
MyGridEchoGroup->Text ("B", CurPoint, 1./81.);
#endif
#ifdef TRACE_VALUES
cout << "Projection de A : " << XAp << ", " << YAp << endl;
cout << "Projection de B : " << XBp << ", " << YBp << endl;
#endif
Standard_Real Determin = XAp*YBp - XBp*YAp;
Z1 = 0.0;
if (Abs (Determin) > MYEPSILON1) {
X1 = (YBp*XPp - XBp*YPp) / Determin;
Y1 = (XAp*YPp - YAp*XPp) / Determin;
X1 = (X1 > 0. ?
Standard_Real (Standard_Integer (Abs (X1)+0.5)) * XS :
- Standard_Real (Standard_Integer (Abs (X1)+0.5)) * XS);
Y1 = (Y1 > 0. ?
Standard_Real (Standard_Integer (Abs (Y1)+0.5)) * YS :
- Standard_Real (Standard_Integer (Abs (Y1)+0.5)) * YS);
#ifdef TRACE_VALUES
cout << "Point choisi : " << X1 << ", " << Y1 << endl;
#endif
// MyTrsf * Point pour se retrouver sur le plan
// de la grille 3D
P1.SetCoord (X1, Y1, Z1);
CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
CurPoint.Coord (X2, Y2, Z2);
}
else {
cout << "*****************" << endl;
cout << "Determinant nul !" << endl;
cout << "*****************" << endl;
#ifdef TRACE_VALUES
cout << "Determinant nul !" << endl;
#endif
AVertex.Coord (X2, Y2, Z2);
CurPoint.SetCoord (X2, Y2, Z2);
}
} // IsRectangular
else {
Standard_Real RS;
Standard_Integer DN;
Standard_Real Alpha;
Handle(Aspect_CircularGrid) theGrid =
*(Handle(Aspect_CircularGrid) *) &MyGrid;
RS = theGrid->RadiusStep ();
DN = theGrid->DivisionNumber ();
Alpha = Standard_PI / Standard_Real (DN);
Standard_Real DistOP = Sqrt (XPp*XPp + YPp*YPp);
Standard_Integer i, ICur=0;
Standard_Real Angle, AngleCur;
Standard_Real XCurp=0, YCurp=0;
gp_Dir2d OP (XPp, YPp);
AngleCur = 2 * Standard_PI;
for (i=1; i<=DN*2; i++) {
X1 = XO + Cos (Alpha * i) * RS,
Y1 = YO + Sin (Alpha * i) * RS,
Z1 = 0.0;
// MyTrsf * Point pour se retrouver sur le plan
// de la grille 3D
P1.SetCoord (X1, Y1, Z1);
CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
CurPoint.Coord (X2, Y2, Z2);
Project (X2, Y2, Z2, XAp, YAp);
XAp = XAp - XOp, YAp = YAp - YOp;
gp_Dir2d OA (XAp, YAp);
Angle = OP.Angle (OA);
if (Abs (AngleCur) > Abs (Angle)) {
ICur = i;
AngleCur = Angle;
XCurp = XAp, YCurp = YAp;
#ifdef TRACE_VALUES
cout << "Angle entre OP et O" << CAR [i-1]
<< " : " << Angle << endl;
#endif
}
#ifdef TRACE_POINTS
MyGridEchoGroup->Text (CAR [i-1], CurPoint, 1./81.);
#endif
} // for (i=1; i<=DN*2; i++)
Standard_Real DistOCur = Sqrt (XCurp*XCurp + YCurp*YCurp);
// Determination du cercle de la grille le plus proche de P
Standard_Integer N = Standard_Integer (DistOP / DistOCur + 0.5);
Standard_Real Radius = N * RS;
#ifdef TRACE_VALUES
cout << "Cercle : " << N << " Radius : " << Radius << endl;
#endif
X1 = Cos (Alpha * ICur) * Radius,
Y1 = Sin (Alpha * ICur) * Radius,
Z1 = 0.0;
#ifdef TRACE_VALUES
cout << "Point choisi : " << X1 << ", " << Y1 << endl;
#endif
// MyTrsf * Point pour se retrouver sur le plan de la grille 3D
P1.SetCoord (X1, Y1, Z1);
CurPoint = V3d_View::TrsPoint (P1, MyTrsf);
CurPoint.Coord (X2, Y2, Z2);
} // IsCircular
NewPoint.SetCoord (CurPoint.X (), CurPoint.Y (), CurPoint.Z ());
#ifdef TRACE_POINTS
TextAttrib->SetColor (Quantity_Color (Quantity_NOC_RED));
MyGridEchoGroup->SetPrimitivesAspect (TextAttrib);
MyGridEchoGroup->Text ("Q", NewPoint, 1./81.);
MyGridEchoGroup->Polyline (AVertex, NewPoint);
Update ();
#endif
#ifdef IMP240100
MyViewer->ShowGridEcho(this,NewPoint);
#else
#ifdef TRACE_ECHO
char *trace_echo = NULL;
trace_echo = (char *)(getenv ("CSF_GraphicEcho"));
if (trace_echo) {
MyGridEchoGroup->Clear ();
MyGridEchoGroup->Marker (NewPoint);
Visual3d_TransientManager::BeginDraw
(MyView, Standard_False, Standard_False);
Visual3d_TransientManager::DrawStructure (MyGridEchoStructure);
Visual3d_TransientManager::EndDraw (Standard_True);
}
#endif
#endif //IMP240100
return NewPoint;
}
// Triedron methods : the Triedron is a non-zoomable object.
void V3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
const Quantity_NameOfColor YColor,
const Quantity_NameOfColor ZColor,
const Standard_Real SizeRatio,
const Standard_Real AxisDiametr,
const Standard_Integer NbFacettes)
{
MyView->ZBufferTriedronSetup(XColor, YColor, ZColor, SizeRatio, AxisDiametr, NbFacettes);
}
void V3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition,
const Quantity_NameOfColor AColor, const Standard_Real AScale, const V3d_TypeOfVisualization AMode ) {
MyView->TriedronDisplay (APosition, AColor, AScale, (AMode == V3d_WIREFRAME));
}
void V3d_View::TriedronErase ( ) {
MyView->TriedronErase ( );
}
void V3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
MyView->TriedronEcho (AType);
}
void V3d_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
{
MyView->GetGraduatedTrihedron(/* 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 V3d_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)
{
MyView->GraduatedTrihedronDisplay(/* 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 V3d_View::GraduatedTrihedronErase()
{
MyView->GraduatedTrihedronErase();
}

99
src/V3d/V3d_View_5.cxx Executable file
View File

@@ -0,0 +1,99 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_View :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
22-10-01 : SAV ; Created
************************************************************************/
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_View.jxx>
#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 */
void V3d_View::EnableDepthTest( const Standard_Boolean enable ) const
{
#ifdef BUC61044
MyView->EnableDepthTest( enable );
#endif
}
Standard_Boolean V3d_View::IsDepthTestEnabled() const
{
#ifdef BUC61044
return MyView->IsDepthTestEnabled();
#else
return Standard_True;
#endif
}
void V3d_View::EnableGLLight( const Standard_Boolean enable ) const
{
#ifdef BUC61045
MyView->EnableGLLight( enable );
#endif
}
Standard_Boolean V3d_View::IsGLLightEnabled() const
{
#ifdef BUC61045
return MyView->IsGLLightEnabled();
#else
return Standard_True;
#endif
}
void V3d_View::SetLayerMgr(const Handle(V3d_LayerMgr)& aMgr)
{
MyLayerMgr = aMgr;
}
void V3d_View::ColorScaleDisplay()
{
if ( MyLayerMgr.IsNull() )
MyLayerMgr = new V3d_LayerMgr( this );
MyLayerMgr->ColorScaleDisplay();
MustBeResized();
if ( !Window().IsNull() ) {
Standard_Integer aW( 0 ), aH( 0 );
Window()->Size( aW, aH );
Redraw( 0, 0, aW, aH );
}
}
void V3d_View::ColorScaleErase()
{
if ( !MyLayerMgr.IsNull() )
MyLayerMgr->ColorScaleErase();
}
Standard_Boolean V3d_View::ColorScaleIsDisplayed() const
{
Standard_Boolean aStatus = Standard_False;
if ( !MyLayerMgr.IsNull() )
aStatus = MyLayerMgr->ColorScaleIsDisplayed();
return aStatus;
}
Handle(Aspect_ColorScale) V3d_View::ColorScale() const
{
if ( MyLayerMgr.IsNull() ) {
Handle(V3d_View) that = this;
that->MyLayerMgr = new V3d_LayerMgr( this );
}
return MyLayerMgr->ColorScale();
}

112
src/V3d/V3d_View_Print.cxx Executable file
View File

@@ -0,0 +1,112 @@
// File V3d_View_Print.cxx
// Created March 2000
// Author THA
// e-mail t-hartl@muenchen.matra-dtv.fr
/************************************************************************/
/* Includes */
/************************************************************************/
#ifdef WNT
#include <windows.h>
#pragma comment( lib, "comdlg32.lib" )
#endif
#include <V3d_View.jxx>
#include <Standard_NotImplemented.hxx>
#ifdef WNT
struct Device
{
Device();
~Device();
PRINTDLG _pd;
};
//**********************************************************************
static Device device;
//**********************************************************************
Device::Device()
{
memset(&_pd, 0, sizeof(PRINTDLG));
_pd.hDevNames = NULL;
_pd.hDevMode = NULL;
_pd.lStructSize = sizeof(PRINTDLG);
}
//**********************************************************************
Device::~Device()
{
// :TODO:
if (_pd.hDevNames) GlobalFree(_pd.hDevNames);
if (_pd.hDevMode) GlobalFree(_pd.hDevMode);
if (_pd.hDC) DeleteDC(_pd.hDC);
}
#endif
/************************************************************************/
/* Print Method */
/************************************************************************/
void V3d_View::Print (const Aspect_Handle hPrnDC,
const Standard_Boolean showDialog,
const Standard_Boolean showBackground,
const Standard_CString filename) const
{
#ifdef WNT
if( MyView->IsDefined() )
{
if (hPrnDC != NULL)
{
MyView->Print(hPrnDC, showBackground, filename) ;
return;
}
if (device._pd.hDC == NULL || showDialog )
{
if (device._pd.hDC)
DeleteDC(device._pd.hDC);
if ( !showDialog )
{
device._pd.Flags = PD_RETURNDC | PD_NOSELECTION | PD_RETURNDEFAULT;
}
else
{
device._pd.Flags = PD_RETURNDC | PD_NOSELECTION;
}
BOOL ispd;
ispd = PrintDlg((LPPRINTDLG)(&(device._pd)));
if (!ispd)
{
return;
}
if (!(device._pd.hDC))
{
if (device._pd.hDevNames)
{
GlobalFree(device._pd.hDevNames);
device._pd.hDevNames = NULL;
}
if (device._pd.hDevMode)
{
GlobalFree(device._pd.hDevMode);
device._pd.hDevMode = NULL;
}
MessageBox(0, "Couldn't create Printer Device Context", "Error", MB_OK | MB_ICONSTOP);
return;
}
}
MyView->Print(device._pd.hDC, showBackground, filename) ;
}
#else
Standard_NotImplemented::Raise ("V3d_View::Print is implemented only on Windows");
#endif
}

709
src/V3d/V3d_Viewer.cdl Executable file
View File

@@ -0,0 +1,709 @@
-- File: Viewer.cdl
-- Created: Fri Jan 17 11:23:08 1992
-- Author: GG
-- Modified FMN - 02/02/98 -> Specifique UNIX
-- CAL - 16/07/98 -> S3892. Ajout grilles 3d.
-- GG - 15/12/99 -> GER61351 Add SetDefaultBackgroundColor()
-- and DefaultBackgroundColor() methods
-- GG - 20/01/00 -> IMP200100 Add GridDrawMode() method
-- GG - 24/01/00 -> IMP240100 Add SetGridEcho() methods
-- Add GridEcho() method.
-- Add ShowGridEcho() private method
-- SAV - 26/11/02 -> Add new field to store grid echo aspect
--
---Copyright: Matra Datavision 1992
class Viewer from V3d
---Version:
---Purpose: Defines services on Viewer type objects.
-- The methods of this class allow editing and
-- interrogation of the parameters linked to the viewer
-- its friend classes (View,light,plane).
---Keywords: Viewer,Default Attributes
---References:
inherits
Viewer from Viewer
uses
-- GraphicDevice from Graphic3d,
GraphicDevice from Aspect,
TypeOfUpdate from V3d,
TypeOfVisualization from V3d,
TypeOfShadingModel from V3d,
TypeOfSurfaceDetail from V3d,
TypeOfOrientation from V3d,
View from V3d,
Light from V3d,
Plane from V3d,
ListOfTransient from V3d,
ListIteratorOfListOfTransient from TColStd,
TypeOfView from V3d,
Vector from Graphic3d,
ViewManager from Visual3d,
NameOfColor from Quantity,
TypeOfColor from Quantity,
Color from Quantity,
Length from Quantity,
PlaneAngle from Quantity,
Background from Aspect,
GradientBackground from Aspect,
Parameter from Quantity,
OrthographicView from V3d,
PerspectiveView from V3d,
AsciiString,ExtendedString from TCollection,
Ax3 from gp,Structure from Graphic3d,
Vertex from Graphic3d,
Group from Graphic3d,
AspectMarker3d from Graphic3d,
RectangularGrid from V3d,
CircularGrid from V3d,
Grid from Aspect,
GridType from Aspect,
GridDrawMode from Aspect,
GradientFillMethod from Aspect
raises
BadValue from Viewer
is
-- Create ( Device : GraphicDevice from Graphic3d;
Create ( Device : GraphicDevice from Aspect;
aName : ExtString from Standard;
aDomain : CString from Standard = "";
ViewSize : Length from Quantity = 1000.0 ;
ViewProj : TypeOfOrientation from V3d= V3d_XposYnegZpos ;
ViewBackground : NameOfColor from Quantity = Quantity_NOC_GRAY30;
Visualization : TypeOfVisualization from V3d = V3d_ZBUFFER;
ShadingModel : TypeOfShadingModel from V3d = V3d_GOURAUD ;
UpdateMode : TypeOfUpdate from V3d = V3d_WAIT;
ComputedMode : Boolean from Standard = Standard_True;
DefaultComputedMode: Boolean from Standard = Standard_True;
SurfaceDetail : TypeOfSurfaceDetail from V3d = V3d_TEX_NONE)
returns mutable Viewer from V3d
---Purpose: Create a Viewer on the given device with the given parameters or
-- with their default values.
raises BadValue from Viewer ;
---Purpose: If the size of the view is <= 0
-- if ComputedMode is false, only the degenerate mode will be used.
--
-- Warning: Client must creates a graphic-device of type
-- Graphic3d_GraphicDevice under UNIX
-- or Graphic3d_WNTGraphicDevice under WindowsNT
CreateView (me: mutable) returns mutable View from V3d;
---Level: Public
---Purpose: creates a view in the viewer according to its
-- default parameters.
DefaultOrthographicView(me: mutable) returns mutable OrthographicView from V3d;
DefaultPerspectiveView(me: mutable) returns mutable PerspectiveView from V3d;
-------------------------------------------------------
---Category: Methods to modify the status of the viewer
-------------------------------------------------------
SetViewOn (me:mutable );
---Level: Public
---Purpose: Activates all of the views of a viewer attached
-- to a window.
SetViewOn (me:mutable; View : View from V3d )
---Level: Public
---Purpose: Activates a particular view in the Viewer .
-- Must be call if the Window attached to the view
-- has been Deiconified .
raises BadValue from Viewer;
-- If the view is not mapped on the window.
SetViewOff (me:mutable);
---Level: Public
---Purpose: Deactivates all the views of a Viewer
-- attached to a window.
SetViewOff (me:mutable; View : View from V3d)
---Level: Public
---Purpose: Deactivates a particular view in the Viewer.
-- Must be call if the Window attached to the view
-- has been Iconified .
raises BadValue from Viewer;
-- If the view is not mapped on the window.
Update (me:mutable ) is redefined static;
---Level: Public
---Purpose: Updates the display of all the views of a viewer.
-- Must be called when the views must be updated
-- simultaneously while the Update mode is deferred (WAIT).
UpdateLights (me: mutable);
---Level: Public
---Purpose: Updates the lights of all the views of a viewer.
Redraw ( me );
---Level: Public
---Purpose: Redraws all the views of the Viewer even if no
-- modification has taken place. Must be called if
-- all the views of the Viewer are exposed, as for
-- example in a global DeIconification.
Remove (me:mutable);
---Level: Public
---Purpose: Suppresses the Viewer.
Erase ( me );
---Level: Public
---Purpose: Erase all Objects in All the views.
UnHighlight ( me );
---Level: Public
---Purpose: UnHighlight all Objects in All the views.
SetDefaultBackgroundColor (me:mutable; Type : TypeOfColor; V1, V2, V3 : Parameter );
---Level: Public
---Purpose: Defines the default base colour of views attached
-- to the Viewer by supplying the type of colour
-- definition and the three component values..
SetDefaultBackgroundColor (me:mutable; Name : NameOfColor );
---Level: Public
---Purpose: Defines the default background colour of views
-- attached to the viewer by supplying the name of the
-- colour under the form Quantity_NOC_xxxx .
SetDefaultBackgroundColor (me:mutable; Color : Color from Quantity);
---Level: Public
---Purpose: Defines the default background colour of views
-- attached to the viewer by supplying the color object
SetDefaultBgGradientColors ( me:mutable;
Name1 : NameOfColor;
Name2 : NameOfColor;
FillStyle : GradientFillMethod from Aspect = Aspect_GFM_HOR );
---Level: Public
---Purpose: Defines the default gradient background colours of view
-- attached to the viewer by supplying the name of the
-- colours under the form Quantity_NOC_xxxx .
SetDefaultBgGradientColors ( me : mutable ;
Color1 : Color from Quantity;
Color2 : Color from Quantity;
FillStyle : GradientFillMethod from Aspect = Aspect_GFM_HOR );
---Level: Public
---Purpose: Defines the default gradient background colours of views
-- attached to the viewer by supplying the colour objects
SetDefaultViewSize (me:mutable; Size : Length )
---Level: Public
---Purpose: Gives a default size for the creation of views of
-- the viewer.
raises BadValue from Viewer;
-- If the size of the view is <= 0
SetDefaultViewProj (me:mutable; Orientation : TypeOfOrientation );
---Level: Public
---Purpose: Gives the default projection for creating views
-- in the viewer.
SetDefaultVisualization(me:mutable; Type : TypeOfVisualization from V3d);
---Level: Public
---Purpose: Gives the default visualisation mode..
SetZBufferManagment(me: mutable; Automatic: Boolean from Standard);
---Level: Public
---Purpose: defines the strategy concerning the ZBuffer activity.
-- If Automatic is true, ZBuffer will be activated or
-- deactivated depending on the fact that faces exist or
-- not in the Viewer. This will optimize the response time
-- in the case where only wireframe objects are displayed.
-- If Automatic is False, ZBuffer will be activated or
-- deactivated depending on the choice of SetVisualization
-- in each View.
-- Note that by default, the ZBufferManagment is not automatic.
ZBufferManagment(me) returns Boolean from Standard;
---Level: Public
---Purpose: returns the ZBuffer stategy choice.
SetDefaultShadingModel(me:mutable; Type : TypeOfShadingModel from V3d);
---Level: Public
---Purpose: Gives the default type of SHADING.
SetDefaultSurfaceDetail(me:mutable; Type : TypeOfSurfaceDetail from V3d);
---Level: Public
---Purpose: Gives the default type of texture mapping.
SetDefaultAngle (me:mutable; Angle : PlaneAngle from Quantity);
---Level: Public
SetUpdateMode ( me: mutable ; Mode : TypeOfUpdate from V3d );
---Level: Public
---Purpose: Defines the mode of regenerating the views making
-- up the viewer. This can be immediate <ASAP> or
-- deferred <WAIT>. In this latter case, the views are
-- updated when the method Update(me) is called.
SetDefaultTypeOfView(me:mutable; Type : TypeOfView from V3d);
---Level: Public
SetPrivilegedPlane(me: mutable; aPlane: Ax3 from gp);
---Level: Public
PrivilegedPlane(me) returns Ax3 from gp;
---Level: Public
DisplayPrivilegedPlane(me: mutable; OnOff: Boolean from Standard; aSize: Length from Quantity = 1);
---Level: Public
SetLightOn(me:mutable; MyLight : Light from V3d )
---Level: Public
---Purpose: Activates MyLight in the viewer.
raises BadValue from Viewer;
-- If No More Light can be activated in MyViewer .
SetLightOn(me:mutable)
---Level: Public
---Purpose: Activates all the lights defined in this viewer.
raises BadValue from Viewer;
-- If No More Light can be activated in MyViewer .
SetLightOff(me:mutable; MyLight : Light from V3d );
---Level: Public
---Purpose: Desactivate MyLight in this viewer.
SetLightOff(me:mutable);
---Level: Public
---Purpose: Deactivate all the Lights defined in this viewer.
DelLight(me:mutable; MyLight : Light from V3d);
---Level: Internal
---Purpose: Delete Light in Sequence Of Lights.
SetCurrentSelectedLight (me : mutable; TheLight : Light from V3d);
---Level: Advanced
---Purpose: Defines the selected light.
ClearCurrentSelectedLight (me : mutable);
---Level: Advanced
---Purpose: Defines the selected light at NULL.
-----------------------------------------
---Category: Inquire methods
-----------------------------------------
DefaultBackgroundColor ( me ; Type : TypeOfColor ; V1,V2,V3 : out Parameter);
---Level: Public
---Purpose: Returns the default background colour depending of the type.
DefaultBackgroundColor ( me ) returns Color from Quantity;
---Level: Public
---Purpose: Returns the default background colour object.
DefaultBgGradientColors( me;
Color1 : out Color from Quantity;
Color2 : out Color from Quantity) ;
---Level: Public
---Purpose: Returns the gradient background colour objects of the view.
DefaultViewSize ( me) returns Length;
---Level: Public
---Purpose: Returns the default size of the view.
DefaultViewProj ( me) returns TypeOfOrientation;
---Level: Public
---Purpose: Returns the default Projection.
DefaultVisualization ( me ) returns TypeOfVisualization from V3d;
---Level: Public
---Purpose: Returns the default type of Visualization.
DefaultShadingModel ( me ) returns TypeOfShadingModel from V3d;
---Level: Public
---Purpose: Returns the default type of Shading
DefaultSurfaceDetail ( me ) returns TypeOfSurfaceDetail from V3d;
---Level: Public
---Purpose: Returns the default type of texture mapping
DefaultAngle ( me ) returns PlaneAngle from Quantity;
---Level: Public
UpdateMode ( me ) returns TypeOfUpdate from V3d;
---Level: Public
---Purpose: Returns the regeneration mode of views in the viewer.
IfMoreViews( me ) returns Boolean;
---Level: Advanced
---Purpose: Returns True if One View more can be
-- activated in this Viewer.
--
------------------------------
---Category: iteration methods
------------------------------
InitActiveViews(me: mutable);
---Level: Advanced
---Purpose: initializes an iteration on the active views.
MoreActiveViews (me) returns Boolean from Standard;
---Level: Advanced
---Purpose: returns true if there are more active view(s) to return.
NextActiveViews (me: mutable);
---Level: Advanced
---Purpose : Go to the next active view
-- (if there is not, ActiveView will raise an exception)
ActiveView(me) returns mutable View from V3d;
---Level: Advanced
LastActiveView(me) returns Boolean from Standard;
---Level: Advanced
---Purpose: returns true if there is only
-- one active view.
InitDefinedViews(me: mutable);
---Level: Advanced
---Purpose: initializes an iteration on the Defined views.
MoreDefinedViews (me) returns Boolean from Standard;
---Level: Advanced
---Purpose: returns true if there are more Defined view(s) to return.
NextDefinedViews (me: mutable);
---Level: Advanced
---Purpose : Go to the next Defined view
-- (if there is not, DefinedView will raise an exception)
DefinedView(me) returns View from V3d;
---Level: Advanced
InitActiveLights(me: mutable);
---Level: Advanced
---Purpose: initializes an iteration on the active Lights.
MoreActiveLights (me) returns Boolean from Standard;
---Level: Advanced
---Purpose: returns true if there are more active Light(s) to return.
NextActiveLights (me: mutable);
---Level: Advanced
---Purpose : Go to the next active Light
-- (if there is not, ActiveLight will raise an exception)
ActiveLight(me) returns mutable Light from V3d;
---Level: Advanced
InitDefinedLights(me: mutable);
---Level: Advanced
---Purpose: initializes an iteration on the Defined Lights.
MoreDefinedLights (me) returns Boolean from Standard;
---Level: Advanced
---Purpose: returns true if there are more Defined Light(s) to return.
NextDefinedLights (me: mutable);
---Level: Advanced
---Purpose : Go to the next Defined Light
-- (if there is not, DefinedLight will raise an exception)
DefinedLight(me) returns Light from V3d;
---Level: Advanced
InitDefinedPlanes(me: mutable);
---Level: Advanced
---Purpose: initializes an iteration on the Defined Planes.
MoreDefinedPlanes (me) returns Boolean from Standard;
---Level: Advanced
---Purpose: returns true if there are more Defined Plane(s) to return.
NextDefinedPlanes (me: mutable);
---Level: Advanced
---Purpose : Go to the next Defined Plane
-- (if there is not, DefinedPlane will raise an exception)
DefinedPlane(me) returns Plane from V3d;
---Level: Advanced
Viewer (me) returns mutable ViewManager ;
---Level: Advanced
---Purpose: Returns the viewer associated to Visual3d .
CurrentSelectedLight (me) returns Light from V3d;
---Level: Advanced
---Purpose: Returns the Selected Light.
IsGlobalLight (me; TheLight : Light from V3d) returns Boolean;
---Level: Advanced
ComputedMode(me) returns Boolean from Standard;
---Level: Public
---Purpose: returns true if the computed mode can be used.
DefaultComputedMode(me) returns Boolean from Standard;
---Level: Public
---Purpose: returns true if by default the computed mode must be used.
-----------------------------------------
---Category: grid management
-----------------------------------------
ActivateGrid (me : mutable;
aGridType : GridType from Aspect;
aGridDrawMode : GridDrawMode from Aspect)
is static;
---Purpose: Activates the grid in all views of <me>.
---Level : Public
---Category: grid management
DeactivateGrid (me : mutable)
is static;
---Purpose: Deactivates the grid in all views of <me>.
---Level : Public
---Category: grid management
SetGridEcho (me : mutable;
showGrid: Boolean from Standard = Standard_True) is static;
---Purpose: Show/Don't show grid echo to the hit point.
-- If TRUE,the grid echo will be shown at ConvertToGrid() time.
---Level : Public
---Category: grid management
SetGridEcho (me : mutable;
aMarker: AspectMarker3d from Graphic3d) is static;
---Purpose: Show grid echo <aMarker> to the hit point.
-- Warning: When the grid echo marker is not set,
-- a default marker is build with the attributes:
-- marker type : Aspect_TOM_STAR
-- marker color : Quantity_NOC_GRAY90
-- marker size : 3.0
---Level : Public
---Category: grid management
GridEcho (me) returns Boolean from Standard is static;
---Purpose: Returns TRUE when grid echo must be displayed
-- at hit point.
---Level : Public
---Category: grid management
IsActive (me)
returns Boolean from Standard
is static;
---Purpose: Returns Standard_True if a grid is activated in <me>.
---Level : Public
---Category: grid management
Grid (me)
returns mutable Grid from Aspect
is static;
---Purpose : Returns the defined grid in <me>.
---Level : Public
---Category: grid management
GridType (me)
returns GridType from Aspect
is static;
---Purpose: Returns the current grid type defined in <me>.
---Level : Public
---Category: grid management
GridDrawMode (me)
returns GridDrawMode from Aspect
is static;
---Purpose: Returns the current grid draw mode defined in <me>.
---Level : Public
---Category: grid management
RectangularGridValues (me;
XOrigin, YOrigin : out Length from Quantity;
XStep, YStep : out Length from Quantity;
RotationAngle : out PlaneAngle from Quantity)
is static;
---Purpose: Returns the definition of the rectangular grid.
---Level : Public
---Category: grid management
SetRectangularGridValues (me : mutable;
XOrigin, YOrigin : Length from Quantity;
XStep, YStep : Length from Quantity;
RotationAngle : PlaneAngle from Quantity)
is static;
---Purpose: Sets the definition of the rectangular grid.
--- <XOrigin>, <YOrigin> defines the origin of the grid.
--- <XStep> defines the interval between 2 vertical lines.
--- <YStep> defines the interval between 2 horizontal lines.
--- <RotationAngle> defines the rotation angle of the grid.
---Level : Public
---Category: grid management
CircularGridValues (me;
XOrigin, YOrigin : out Length from Quantity;
RadiusStep : out Length from Quantity;
DivisionNumber : out Integer from Standard;
RotationAngle : out PlaneAngle from Quantity)
is static;
---Purpose: Returns the definition of the circular grid.
---Level : Public
---Category: grid management
SetCircularGridValues (me : mutable;
XOrigin, YOrigin : Length from Quantity;
RadiusStep : Length from Quantity;
DivisionNumber : Integer from Standard;
RotationAngle : PlaneAngle from Quantity)
is static;
---Purpose: Sets the definition of the circular grid.
--- <XOrigin>, <YOrigin> defines the origin of the grid.
--- <RadiusStep> defines the interval between 2 circles.
--- <DivisionNumber> defines the section number of one half circle.
--- <RotationAngle> defines the rotation angle of the grid.
---Level : Public
---Category: grid management
CircularGridGraphicValues (me;
Radius : out Length from Quantity;
OffSet : out Length from Quantity)
is static;
---Purpose: Returns the location and the size of the grid.
---Level : Public
---Category: grid management
SetCircularGridGraphicValues (me : mutable;
Radius : Length from Quantity;
OffSet : Length from Quantity)
is static;
---Purpose: Sets the location and the size of the grid.
--- <XSize> defines the width of the grid.
--- <YSize> defines the height of the grid.
--- <OffSet> defines the displacement along the plane normal.
---Level : Public
---Category: grid management
RectangularGridGraphicValues (me;
XSize, YSize : out Length from Quantity;
OffSet : out Length from Quantity)
is static;
---Purpose: Returns the location and the size of the grid.
---Level : Public
---Category: grid management
SetRectangularGridGraphicValues (me : mutable;
XSize, YSize : Length from Quantity;
OffSet : Length from Quantity)
is static;
---Purpose: Sets the location and the size of the grid.
--- <XSize> defines the width of the grid.
--- <YSize> defines the height of the grid.
--- <OffSet> defines the displacement along the plane normal.
---Level : Public
---Category: grid management
-----------------------------------------
---Category: Private or Protected methods
-----------------------------------------
GetBackgroundColor ( me )
returns Background from Aspect is private;
---Purpose: Returns the default background colour.
GetGradientBackground ( me ) returns GradientBackground from Aspect;
---Level: Public
---Purpose: Returns the gradient background of the view.
AddView( me: mutable; MyView : View from V3d) is private;
---Purpose: Adds View in Sequence Of Views.
DelView( me: mutable; MyView : View from V3d) is private;
---Purpose: Delete View in Sequence Of Views.
AddLight( me: mutable; MyLight : Light from V3d) is private;
---Purpose: Adds Light in Sequence Of Lights.
AddPlane( me: mutable; MyPlane : Plane from V3d) is private ;
---Purpose: Adds Plane in Sequence Of Planes.
DelPlane( me: mutable; MyPlane : Plane from V3d) is private;
---Purpose: Delete Plane in Sequence Of Planes.
SetDefaultLights(me: mutable);
---Purpose: defines default lights -
-- positional-light 0.3 0. 0.
-- directional-light V3d_XnegYposZpos
-- directional-light V3d_XnegYneg
-- ambient-light
Init(me: mutable);
IsActive(me; aView: View from V3d)
returns Boolean from Standard is private;
ShowGridEcho(me : mutable;
aView: View from V3d;
aPoint: Vertex from Graphic3d) is private;
---Purpose:
-- Display grid echo at requested point in the view.
fields
MyViewer: ViewManager from Visual3d ;
MyDefinedViews: ListOfTransient from V3d;
MyActiveViews: ListOfTransient from V3d;
MyDefinedLights: ListOfTransient from V3d;
MyActiveLights: ListOfTransient from V3d;
MyDefinedPlanes: ListOfTransient from V3d;
MyBackground: Background from Aspect ;
MyGradientBackground: GradientBackground from Aspect ;
MyViewSize: Real ;
MyViewProj: TypeOfOrientation from V3d ;
MyVisualization: TypeOfVisualization from V3d ;
MyShadingModel: TypeOfShadingModel from V3d ;
MySurfaceDetail: TypeOfSurfaceDetail from V3d ;
MyDefaultAngle: PlaneAngle from Quantity;
MyDefaultTypeOfView: TypeOfView from V3d;
MyDefaultOrthographicView: OrthographicView from V3d;
MyDefaultPerspectiveView: PerspectiveView from V3d;
MyCurrentSelectedLight: Light from V3d;
myActiveViewsIterator: ListIteratorOfListOfTransient from TColStd;
myDefinedViewsIterator: ListIteratorOfListOfTransient from TColStd;
myActiveLightsIterator: ListIteratorOfListOfTransient from TColStd;
myDefinedLightsIterator: ListIteratorOfListOfTransient from TColStd;
myDefinedPlanesIterator: ListIteratorOfListOfTransient from TColStd;
myComputedMode: Boolean from Standard;
myDefaultComputedMode: Boolean from Standard;
myPrivilegedPlane: Ax3 from gp;
myPlaneStructure: Structure from Graphic3d;
myDisplayPlane: Boolean from Standard;
myDisplayPlaneLength: Length from Quantity;
myRGrid: RectangularGrid from V3d;
myCGrid: CircularGrid from V3d;
myGridType: GridType from Aspect;
myGridEcho: Boolean from Standard;
myGridEchoStructure: Structure from Graphic3d;
myGridEchoGroup: Group from Graphic3d;
myGridEchoAspect : AspectMarker3d from Graphic3d;
friends
class View from V3d,
class Light from V3d,
class Plane from V3d,
SetPlane from package V3d (aViewer: Viewer from V3d; x1,y1,z1,x2,y2,z2: Length from Quantity)
end Viewer;

368
src/V3d/V3d_Viewer.cxx Executable file
View File

@@ -0,0 +1,368 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_Viewer :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
15-11-97 : FMN ; Ajout texture mapping
02-02-98 : FMN ; Mise a niveau WNT
23-02-98 : FMN ; Remplacement PI par Standard_PI
16-07-98 : CAL ; S3892. Ajout grilles 3d.
************************************************************************/
#define GER61351 //GG_15/12/99 Adds SetDefaultBackgroundColor()
// and DefaultBackgroundColor() methods
#define IMP240100 //GG
// Initalize grid echo fields
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d.hxx>
#include <Visual3d_View.hxx>
#include <Visual3d_Light.hxx>
#include <V3d_Viewer.ixx>
#include <V3d_View.hxx>
#include <Viewer_BadValue.hxx>
#include <V3d_OrthographicView.hxx>
#include <V3d_PerspectiveView.hxx>
#ifdef WNT
#include <WNT_GraphicDevice.hxx>
#endif
/*----------------------------------------------------------------------*/
//-Constructor:
V3d_Viewer::V3d_Viewer(const Handle(Aspect_GraphicDevice)& Device , const Standard_ExtString aName, const Standard_CString aDomain,const Standard_Real ViewSize , const V3d_TypeOfOrientation ViewProj , const Quantity_NameOfColor ViewBackground , const V3d_TypeOfVisualization Visualization , const V3d_TypeOfShadingModel ShadingModel , const V3d_TypeOfUpdate UpdateMode, const Standard_Boolean ComputedMode , const Standard_Boolean DefaultComputedMode , const V3d_TypeOfSurfaceDetail SurfaceDetail )
:Viewer_Viewer(Device,aName,aDomain,-1),
MyDefinedViews(),
MyActiveViews(),
MyDefinedLights(),
MyActiveLights(),
MyDefinedPlanes(),
myActiveViewsIterator(),
myDefinedViewsIterator(),
myActiveLightsIterator(),
myDefinedLightsIterator(),
myDefinedPlanesIterator(),
myComputedMode(ComputedMode),
myDefaultComputedMode(DefaultComputedMode),
myPrivilegedPlane(gp_Ax3(gp_Pnt(0.,0.,0),gp_Dir(0.,0.,1.),gp_Dir(1.,0.,0.))),
myDisplayPlane(Standard_False),
myDisplayPlaneLength(ViewSize)
#ifdef IMP240100
,myGridEcho(Standard_True),myGridEchoStructure(),myGridEchoGroup()
#endif
{
MyViewer = new Visual3d_ViewManager(Device) ;
// san (16/09/2010): It has been decided to turn depth test ON
// by default, as this is important for new font rendering
// (without it, there are numerous texture rendering artefacts)
MyViewer->SetZBufferAuto (Standard_False);
SetUpdateMode( UpdateMode ) ;
SetDefaultViewSize(ViewSize) ;
SetDefaultViewProj(ViewProj) ;
SetDefaultBackgroundColor(ViewBackground) ;
SetDefaultVisualization(Visualization) ;
SetDefaultShadingModel(ShadingModel) ;
SetDefaultSurfaceDetail(SurfaceDetail) ;
SetDefaultAngle(Standard_PI/2.);
SetDefaultTypeOfView(V3d_ORTHOGRAPHIC);
Quantity_Color Color1 (Quantity_NOC_GRAY50);
Quantity_Color Color2 (Quantity_NOC_GRAY70);
// Quantity_Color White (Quantity_NOC_WHITE);
myRGrid = new V3d_RectangularGrid(this,Color1,Color2);
myCGrid = new V3d_CircularGrid(this,Color1,Color2);
myGridType = Aspect_GT_Rectangular;
}
//-Methods, in order
Handle(V3d_View) V3d_Viewer::CreateView () {
if (MyDefaultTypeOfView == V3d_ORTHOGRAPHIC)
return new V3d_OrthographicView(this);
else
return new V3d_PerspectiveView(this);
}
void V3d_Viewer::SetViewOn( ) {
for (InitDefinedViews();MoreDefinedViews();NextDefinedViews()){
SetViewOn(ActiveView());};
}
Handle(V3d_OrthographicView) V3d_Viewer::DefaultOrthographicView() {
return MyDefaultOrthographicView;
}
Handle(V3d_PerspectiveView) V3d_Viewer::DefaultPerspectiveView () {
return MyDefaultPerspectiveView;
}
void V3d_Viewer::SetViewOff( ) {
for (InitDefinedViews();MoreDefinedViews();NextDefinedViews()){
SetViewOff(ActiveView());};
}
void V3d_Viewer::SetViewOn( const Handle(V3d_View)& TheView ) {
Handle(Visual3d_View) MyView = TheView->View() ;
if( MyView->IsDefined() && !IsActive(TheView)) {
MyActiveViews.Append(TheView) ;
MyView->Activate();
for (InitActiveLights();MoreActiveLights();NextActiveLights()){
TheView->SetLightOn(ActiveLight());}
// Grid
TheView->SetGrid (myPrivilegedPlane, Grid ());
TheView->SetGridActivity (Grid ()->IsActive ());
// Update
MyView->Redraw() ;
}
}
void V3d_Viewer::SetViewOff( const Handle(V3d_View)& TheView ) {
Handle(Visual3d_View) MyView =TheView->View();
if( MyView->IsDefined() && IsActive(TheView) ) {
MyActiveViews.Remove(TheView);
MyView->Deactivate() ;
}
}
Standard_Boolean V3d_Viewer::ComputedMode() const {
return myComputedMode;
}
Standard_Boolean V3d_Viewer::DefaultComputedMode() const {
return myDefaultComputedMode;
}
void V3d_Viewer::Update() {
MyViewer->Update();
}
void V3d_Viewer::Redraw()const {
MyViewer->Redraw();
}
void V3d_Viewer::Remove() {
MyViewer->Remove();
}
void V3d_Viewer::Erase() const {
MyViewer->Erase();
}
void V3d_Viewer::UnHighlight() const {
//FMN MyViewer->UnHighlight();
}
void V3d_Viewer::SetDefaultBackgroundColor(const Quantity_TypeOfColor Type, const Standard_Real v1, const Standard_Real v2, const Standard_Real v3) {
Standard_Real V1 = v1 ;
Standard_Real V2 = v2 ;
Standard_Real V3 = v3 ;
if( V1 < 0. ) V1 = 0. ; else if( V1 > 1. ) V1 = 1. ;
if( V2 < 0. ) V2 = 0. ; else if( V2 > 1. ) V2 = 1. ;
if( V3 < 0. ) V3 = 0. ; else if( V3 > 1. ) V3 = 1. ;
Quantity_Color C(V1,V2,V3,Type) ;
#ifdef GER61351
SetDefaultBackgroundColor(C);
#else
MyBackground.SetColor(C) ;
#endif
}
void V3d_Viewer::SetDefaultBackgroundColor(const Quantity_NameOfColor Name) {
Quantity_Color C(Name) ;
#ifdef GER61351
SetDefaultBackgroundColor(C);
#else
MyBackground.SetColor(C) ;
#endif
}
#ifdef GER61351
void V3d_Viewer::SetDefaultBackgroundColor(const Quantity_Color &Color) {
MyBackground.SetColor(Color) ;
}
#endif
void V3d_Viewer::SetDefaultBgGradientColors( const Quantity_NameOfColor Name1,
const Quantity_NameOfColor Name2,
const Aspect_GradientFillMethod FillStyle){
Quantity_Color C1(Name1) ;
Quantity_Color C2(Name2) ;
MyGradientBackground.SetColors(C1, C2, FillStyle);
}
void V3d_Viewer::SetDefaultBgGradientColors( const Quantity_Color& Color1,
const Quantity_Color& Color2,
const Aspect_GradientFillMethod FillStyle ){
MyGradientBackground.SetColors(Color1, Color2, FillStyle);
}
void V3d_Viewer::SetDefaultViewSize(const Standard_Real Size) {
Viewer_BadValue_Raise_if( Size <= 0. ,"V3d_Viewer::SetDefaultViewSize, bad size");
MyViewSize = Size ;
}
void V3d_Viewer::SetDefaultViewProj(const V3d_TypeOfOrientation Orientation) {
MyViewProj = Orientation ;
}
void V3d_Viewer::SetDefaultVisualization(const V3d_TypeOfVisualization Type) {
MyVisualization = Type ;
}
void V3d_Viewer::SetZBufferManagment(const Standard_Boolean Automatic) {
MyViewer->SetZBufferAuto (Automatic);
}
Standard_Boolean V3d_Viewer::ZBufferManagment() const {
return MyViewer->ZBufferAuto();
}
void V3d_Viewer::SetDefaultShadingModel(const V3d_TypeOfShadingModel Type) {
MyShadingModel = Type ;
}
void V3d_Viewer::SetDefaultSurfaceDetail(const V3d_TypeOfSurfaceDetail Type) {
MySurfaceDetail = Type ;
}
void V3d_Viewer::SetDefaultAngle(const Quantity_PlaneAngle Angle) {
MyDefaultAngle = Angle;
}
void V3d_Viewer::SetDefaultTypeOfView(const V3d_TypeOfView Type) {
MyDefaultTypeOfView = Type;}
void V3d_Viewer::SetUpdateMode(const V3d_TypeOfUpdate Mode) {
MyViewer->SetUpdateMode((Aspect_TypeOfUpdate)Mode) ;
}
void V3d_Viewer::DefaultBackgroundColor(const Quantity_TypeOfColor Type,Standard_Real &V1,Standard_Real &V2,Standard_Real &V3) const {
#ifdef GER61351
Quantity_Color C = DefaultBackgroundColor();
#else
Quantity_Color C = MyBackground.Color() ;
#endif
C.Values(V1,V2,V3,Type) ;
}
#ifdef GER61351
Quantity_Color V3d_Viewer::DefaultBackgroundColor() const {
return MyBackground.Color() ;
}
#endif
void V3d_Viewer::DefaultBgGradientColors(Quantity_Color& Color1,Quantity_Color& Color2) const{
MyGradientBackground.Colors(Color1,Color2);
}
Standard_Real V3d_Viewer::DefaultViewSize() const {
return MyViewSize ;
}
V3d_TypeOfOrientation V3d_Viewer::DefaultViewProj() const {
return MyViewProj ;
}
V3d_TypeOfVisualization V3d_Viewer::DefaultVisualization() const {
return MyVisualization ;
}
V3d_TypeOfShadingModel V3d_Viewer::DefaultShadingModel() const {
return MyShadingModel ;
}
V3d_TypeOfSurfaceDetail V3d_Viewer::DefaultSurfaceDetail() const {
return MySurfaceDetail ;
}
Quantity_PlaneAngle V3d_Viewer::DefaultAngle() const {
return MyDefaultAngle;
}
V3d_TypeOfUpdate V3d_Viewer::UpdateMode() const {
V3d_TypeOfUpdate Mode = (V3d_TypeOfUpdate) MyViewer->UpdateMode() ;
return Mode ;
}
Standard_Boolean V3d_Viewer::IfMoreViews() const {
Standard_Boolean TheStatus = Standard_False ;
#ifdef NEW
if( MyActiveViews->Length() < Visual3d_View::Limit() )
#endif /*NEW*/
TheStatus = Standard_True ;
return TheStatus ;
}
Handle(Visual3d_ViewManager) V3d_Viewer::Viewer() const {
return MyViewer ;
}
Aspect_Background V3d_Viewer::GetBackgroundColor() const {
return MyBackground ;
}
Aspect_GradientBackground V3d_Viewer::GetGradientBackground() const {
return MyGradientBackground;
}
void V3d_Viewer::AddView( const Handle(V3d_View)& TheView ) {
MyDefinedViews.Append(TheView);
IncrCount();
}
void V3d_Viewer::DelView( const Handle(V3d_View)& TheView ) {
MyActiveViews.Remove(TheView);
MyDefinedViews.Remove(TheView);
}
void V3d_Viewer::AddPlane( const Handle(V3d_Plane)& ThePlane ) {
MyDefinedPlanes.Append(ThePlane) ;
}
void V3d_Viewer::DelPlane( const Handle(V3d_Plane)& ThePlane ) {
MyDefinedPlanes.Remove(ThePlane);
}

68
src/V3d/V3d_Viewer_1.cxx Executable file
View File

@@ -0,0 +1,68 @@
#include <V3d_Viewer.jxx>
#include <V3d.hxx>
void V3d_Viewer::InitActiveViews() {
myActiveViewsIterator.Initialize(MyActiveViews);
}
Standard_Boolean V3d_Viewer::MoreActiveViews () const {
return myActiveViewsIterator.More();
}
void V3d_Viewer::NextActiveViews () {
if(!MyActiveViews.IsEmpty())myActiveViewsIterator.Next();
}
Handle(V3d_View) V3d_Viewer::ActiveView() const {
return (Handle(V3d_View)&)(myActiveViewsIterator.Value());}
Standard_Boolean V3d_Viewer::LastActiveView() const {
return MyActiveViews.Extent() == 1;}
Standard_Boolean V3d_Viewer::IsActive(const Handle(V3d_View)& aView) const {
return MyActiveViews.Contains(aView);
}
void V3d_Viewer::InitDefinedViews() {
myDefinedViewsIterator.Initialize(MyDefinedViews);
}
Standard_Boolean V3d_Viewer::MoreDefinedViews () const {
return myDefinedViewsIterator.More();
}
void V3d_Viewer::NextDefinedViews () {
if(!MyDefinedViews.IsEmpty())myDefinedViewsIterator.Next();
}
Handle(V3d_View) V3d_Viewer::DefinedView() const {
return (Handle(V3d_View)&)(myDefinedViewsIterator.Value());}
void V3d_Viewer::InitActiveLights() {
myActiveLightsIterator.Initialize(MyActiveLights);
}
Standard_Boolean V3d_Viewer::MoreActiveLights () const {
return myActiveLightsIterator.More();
}
void V3d_Viewer::NextActiveLights () {
myActiveLightsIterator.Next();
}
Handle(V3d_Light) V3d_Viewer::ActiveLight() const {
return (Handle(V3d_Light)&)(myActiveLightsIterator.Value());}
void V3d_Viewer::InitDefinedLights() {
myDefinedLightsIterator.Initialize(MyDefinedLights);
}
Standard_Boolean V3d_Viewer::MoreDefinedLights () const {
return myDefinedLightsIterator.More();
}
void V3d_Viewer::NextDefinedLights () {
if(!MyDefinedLights.IsEmpty())myDefinedLightsIterator.Next();
}
Handle(V3d_Light) V3d_Viewer::DefinedLight() const {
return (Handle(V3d_Light)&)(myDefinedLightsIterator.Value());}
void V3d_Viewer::InitDefinedPlanes() {
myDefinedPlanesIterator.Initialize(MyDefinedPlanes);
}
Standard_Boolean V3d_Viewer::MoreDefinedPlanes () const {
return myDefinedPlanesIterator.More();
}
void V3d_Viewer::NextDefinedPlanes () {
myDefinedPlanesIterator.Next();
}
Handle(V3d_Plane) V3d_Viewer::DefinedPlane() const {
return (Handle(V3d_Plane)&)(myDefinedPlanesIterator.Value());}

102
src/V3d/V3d_Viewer_2.cxx Executable file
View File

@@ -0,0 +1,102 @@
#include <V3d_Viewer.jxx>
#include <Visual3d_Light.hxx>
#include <V3d_DirectionalLight.hxx>
#include <V3d_PositionalLight.hxx>
#include <V3d_AmbientLight.hxx>
#include <Viewer_BadValue.hxx>
#include <V3d.hxx>
void V3d_Viewer::UpdateLights() {
for (InitActiveViews();MoreActiveViews();NextActiveViews()){
ActiveView()->UpdateLights();
}
}
void V3d_Viewer::SetLightOn( const Handle(V3d_Light)& TheLight ) {
if(!MyActiveLights.Contains(TheLight)) {
// Viewer_BadValue_Raise_if( MyActiveLights.Extent() >= Visual3d_Light::Limit(),
// "too many lights");
MyActiveLights.Append(TheLight) ;
}
for (InitActiveViews();MoreActiveViews();NextActiveViews()){
ActiveView()->SetLightOn(TheLight);}
}
void V3d_Viewer::SetLightOff( const Handle(V3d_Light)& TheLight ) {
MyActiveLights.Remove(TheLight);
for (InitActiveViews();MoreActiveViews();NextActiveViews()) {
ActiveView()->SetLightOff(TheLight);}
}
void V3d_Viewer::SetLightOn() {
for (InitDefinedLights();MoreDefinedLights();NextDefinedLights()) {
if(!MyActiveLights.Contains(DefinedLight())) {
// Viewer_BadValue_Raise_if( MyActiveLights.Extent() >= Visual3d_Light::Limit(),
// "too many lights");
MyActiveLights.Append(DefinedLight());
for (InitActiveViews();MoreActiveViews();NextActiveViews()) {
ActiveView()->SetLightOn(DefinedLight());}
}
}
}
void V3d_Viewer::SetLightOff() {
for (InitActiveLights();MoreActiveLights();NextActiveLights()) {
for(InitActiveViews();MoreActiveViews();NextActiveViews()){
ActiveView()->SetLightOff(ActiveLight());}
}
MyActiveLights.Clear();
}
void V3d_Viewer::SetCurrentSelectedLight(const Handle(V3d_Light)& TheLight) {
MyCurrentSelectedLight = TheLight;
}
void V3d_Viewer::ClearCurrentSelectedLight() {
MyCurrentSelectedLight = NULL;
}
Handle(V3d_Light) V3d_Viewer::CurrentSelectedLight() const {
return MyCurrentSelectedLight;
}
Standard_Boolean V3d_Viewer::IsGlobalLight(const Handle(V3d_Light)& TheLight)
const {
return MyActiveLights.Contains(TheLight);
}
void V3d_Viewer::AddLight( const Handle(V3d_Light)& TheLight ) {
MyDefinedLights.Append(TheLight);
}
void V3d_Viewer::DelLight( const Handle(V3d_Light)& TheLight ) {
SetLightOff(TheLight);
MyDefinedLights.Remove(TheLight);
}
void V3d_Viewer::SetDefaultLights () {
// SetLightOn ( new V3d_DirectionalLight(this,V3d_XposYpos));
// SetLightOn ( new V3d_DirectionalLight(this,V3d_Zpos));
// SetLightOn ( new V3d_DirectionalLight(this,V3d_XnegYneg));
// SetLightOn ( new V3d_DirectionalLight(this,V3d_Zneg));
SetLightOn( new V3d_DirectionalLight(this, V3d_Zneg, Quantity_NOC_WHITE, Standard_True) );
SetLightOn ( new V3d_AmbientLight(this));
}
void V3d_Viewer::Init() {
MyDefaultPerspectiveView = new V3d_PerspectiveView(this);
MyDefaultOrthographicView = new V3d_OrthographicView(this);
SetDefaultLights();
}

158
src/V3d/V3d_Viewer_3.cxx Executable file
View File

@@ -0,0 +1,158 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_Viewer_3.cxx :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
27-12-98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM)
REMARQUES :
-----------
************************************************************************/
#define IMP240300 //GG
// -> Remove the grid plane axis when it is requested.
// -> Redraw the privilegied grid plane after any change
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_Viewer.jxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
/*----------------------------------------------------------------------*/
/*
* Static variable
*/
#define LOPTIM
#ifndef LOPTIM
static TCollection_AsciiString XLetter("X");
static TCollection_AsciiString YLetter("Y");
static TCollection_AsciiString ZLetter("Z");
#else
static TCollection_AsciiString _XLetter() {
static TCollection_AsciiString XLetter("X");
return XLetter;
}
#define XLetter _XLetter()
static TCollection_AsciiString _YLetter() {
static TCollection_AsciiString YLetter("Y");
return YLetter;
}
#define YLetter _YLetter()
static TCollection_AsciiString _ZLetter() {
static TCollection_AsciiString ZLetter("Z");
return ZLetter;
}
#define ZLetter _ZLetter()
#endif // LOPTIM
/*----------------------------------------------------------------------*/
void V3d_Viewer::SetPrivilegedPlane(const gp_Ax3& aPlane) {
myPrivilegedPlane = aPlane;
#ifdef IMP240300
Grid()->SetDrawMode(Grid()->DrawMode());
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
ActiveView ()->SetGrid (myPrivilegedPlane, Grid ());
}
#endif
if(myDisplayPlane) {
Standard_Real s = myDisplayPlaneLength;
DisplayPrivilegedPlane(Standard_True,s);
#ifdef IMP240300
} else {
Update();
#else
Update();
#endif
}
}
/*----------------------------------------------------------------------*/
gp_Ax3 V3d_Viewer::PrivilegedPlane() const {
return myPrivilegedPlane;
}
/*----------------------------------------------------------------------*/
void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Quantity_Length aSize) {
Standard_Boolean Change = myDisplayPlane != OnOff;
myDisplayPlane = OnOff;
myDisplayPlaneLength = aSize;
if(myDisplayPlane) {
if(myPlaneStructure.IsNull()) {
myPlaneStructure = new Graphic3d_Structure(MyViewer);
myPlaneStructure->SetInfiniteState(Standard_True);
myPlaneStructure->Display();
}
else
myPlaneStructure->Clear();
// Handle(Graphic3d_Structure) thePlaneStructure = new Graphic3d_Structure(MyViewer);
Handle(Graphic3d_Group) Group = new Graphic3d_Group(myPlaneStructure) ;
Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d() ;
LineAttrib->SetColor(Quantity_Color(Quantity_NOC_GRAY60));
Group->SetPrimitivesAspect(LineAttrib) ;
Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d();
TextAttrib->SetColor(Quantity_Color(Quantity_NOC_ROYALBLUE1));
Group->SetPrimitivesAspect(TextAttrib);
Graphic3d_Array1OfVertex Points(0,1) ;
Standard_Real xl,yl,zl;
myPrivilegedPlane.Location().Coord(xl,yl,zl);
Points(0).SetCoord(xl,yl,zl);
Standard_Real ay,by,cy;
myPrivilegedPlane.XDirection().Coord(ay,by,cy);
Points(1).SetCoord(xl+myDisplayPlaneLength*ay,
yl+myDisplayPlaneLength*by,
zl+myDisplayPlaneLength*cy);
Group->Polyline(Points);
Group->Text(XLetter.ToCString(),Points(1),1./81.);
myPrivilegedPlane.YDirection().Coord(ay,by,cy);
Points(1).SetCoord(xl+myDisplayPlaneLength*ay,
yl+myDisplayPlaneLength*by,
zl+myDisplayPlaneLength*cy);
Group->Polyline(Points);
Group->Text(YLetter.ToCString(),Points(1),1./81.);
myPrivilegedPlane.Direction().Coord(ay,by,cy);
Points(1).SetCoord(xl+myDisplayPlaneLength*ay,
yl+myDisplayPlaneLength*by,
zl+myDisplayPlaneLength*cy);
Group->Polyline(Points);
Group->Text(ZLetter.ToCString(),Points(1),1./81.);
#ifdef IMP240300
myPlaneStructure->Display();
} else {
if( !myPlaneStructure.IsNull() ) myPlaneStructure->Erase();
#endif
}
if(Change) Update();
}
/*----------------------------------------------------------------------*/

211
src/V3d/V3d_Viewer_4.cxx Executable file
View File

@@ -0,0 +1,211 @@
/***********************************************************************
FONCTION :
----------
Classe V3d_Viewer :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
16-07-98 : CAL ; S3892. Ajout grilles 3d.
22-09-98 : CAL ; Erreur de compilation sur WNT dans V3d_Viewer_4.cxx.
************************************************************************/
#define IMP200100 //GG
// -> Add GridDrawMode() method.
// -> Compute the case Aspect_TDM_None
// in ActivateGrid(..)
#define IMP240100 //GG
// -> Add SetGridEcho() & GridEcho() methods
// -> Add ShowGridEcho() private method.
#define OCC281 //SAV added new field to store grid echo aspect
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <V3d_Viewer.jxx>
/*----------------------------------------------------------------------*/
Handle(Aspect_Grid) V3d_Viewer::Grid () const {
if (myGridType == Aspect_GT_Circular)
return myCGrid;
else if (myGridType == Aspect_GT_Rectangular)
return myRGrid;
else
return myRGrid;
}
Aspect_GridType V3d_Viewer::GridType () const {
return myGridType;
}
#ifdef IMP200100
Aspect_GridDrawMode V3d_Viewer::GridDrawMode () const {
return Grid()->DrawMode();
}
#endif
void V3d_Viewer::ActivateGrid (const Aspect_GridType aType, const Aspect_GridDrawMode aMode) {
Grid ()->Erase ();
myGridType = aType;
Grid ()->SetDrawMode (aMode);
#ifdef IMP200100
if( aMode != Aspect_GDM_None ) Grid ()->Display ();
#else
Grid ()->Display ();
#endif
Grid ()->Activate ();
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
ActiveView ()->SetGrid (myPrivilegedPlane, Grid ());
#ifndef IMP200100 //Do nothing more than the previous Grid()->Activate()
ActiveView ()->SetGridActivity (Standard_True);
#endif
}
Update ();
}
void V3d_Viewer::DeactivateGrid () {
Grid ()->Erase ();
myGridType = Aspect_GT_Rectangular;
Grid ()->Deactivate ();
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
ActiveView ()->SetGridActivity (Standard_False);
}
Update ();
}
Standard_Boolean V3d_Viewer::IsActive () const {
return Grid ()->IsActive ();
}
void V3d_Viewer::RectangularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theXStep, Quantity_Length& theYStep, Quantity_PlaneAngle& theRotationAngle) const {
theXOrigin = myRGrid->XOrigin ();
theYOrigin = myRGrid->YOrigin ();
theXStep = myRGrid->XStep ();
theYStep = myRGrid->YStep ();
theRotationAngle = myRGrid->RotationAngle ();
}
void V3d_Viewer::SetRectangularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theXStep, const Quantity_Length theYStep, const Quantity_PlaneAngle theRotationAngle) {
myRGrid->SetGridValues
(theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
ActiveView ()->SetGrid (myPrivilegedPlane, myRGrid);
Update ();
}
void V3d_Viewer::CircularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theRadiusStep, Standard_Integer& theDivisionNumber, Quantity_PlaneAngle& theRotationAngle) const {
theXOrigin = myCGrid->XOrigin ();
theYOrigin = myCGrid->YOrigin ();
theRadiusStep = myCGrid->RadiusStep ();
theDivisionNumber = myCGrid->DivisionNumber ();
theRotationAngle = myCGrid->RotationAngle ();
}
void V3d_Viewer::SetCircularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theRadiusStep, const Standard_Integer theDivisionNumber, const Quantity_PlaneAngle theRotationAngle) {
myCGrid->SetGridValues
(theXOrigin, theYOrigin, theRadiusStep,
theDivisionNumber, theRotationAngle);
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
ActiveView ()->SetGrid (myPrivilegedPlane, myCGrid);
Update ();
}
void V3d_Viewer::RectangularGridGraphicValues (Quantity_Length& theXSize, Quantity_Length& theYSize, Quantity_Length& theOffSet) const {
myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
}
void V3d_Viewer::SetRectangularGridGraphicValues (const Quantity_Length theXSize, const Quantity_Length theYSize, const Quantity_Length theOffSet) {
myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
ActiveView ()->SetGridGraphicValues (myRGrid);
Update ();
}
void V3d_Viewer::CircularGridGraphicValues (Quantity_Length& theRadius, Quantity_Length& theOffSet) const {
myCGrid->GraphicValues (theRadius, theOffSet);
}
void V3d_Viewer::SetCircularGridGraphicValues (const Quantity_Length theRadius, const Quantity_Length theOffSet) {
myCGrid->SetGraphicValues (theRadius, theOffSet);
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
ActiveView ()->SetGridGraphicValues (myCGrid);
Update ();
}
#ifdef IMP240100
void V3d_Viewer::SetGridEcho( const Standard_Boolean showGrid ) {
myGridEcho = showGrid;
}
void V3d_Viewer::SetGridEcho( const Handle(Graphic3d_AspectMarker3d)& aMarker ) {
if( myGridEchoStructure.IsNull() ) {
myGridEchoStructure = new Graphic3d_Structure(Viewer());
myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
}
#ifdef OCC281
myGridEchoAspect = aMarker;
#endif
myGridEchoGroup->SetPrimitivesAspect (aMarker);
}
Standard_Boolean V3d_Viewer::GridEcho() const {
return myGridEcho;
}
#include <Visual3d_TransientManager.hxx>
void V3d_Viewer::ShowGridEcho( const Handle(V3d_View)& aView,
const Graphic3d_Vertex& aVertex ) {
if( myGridEcho ) {
if( myGridEchoStructure.IsNull() ) {
myGridEchoStructure = new Graphic3d_Structure(Viewer());
myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
#ifdef OCC281
myGridEchoAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_STAR,
Quantity_Color( Quantity_NOC_GRAY90 ),
3.0 );
myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect );
#else
Handle(Graphic3d_AspectMarker3d) markerAttrib =
new Graphic3d_AspectMarker3d(Aspect_TOM_STAR,
Quantity_Color(Quantity_NOC_GRAY90),3.0);
myGridEchoGroup->SetPrimitivesAspect (markerAttrib);
#endif
}
static Graphic3d_Vertex lastVertex;
if( Graphic3d_Vertex::Distance(aVertex,lastVertex) != 0.0 ) {
lastVertex = aVertex;
myGridEchoGroup->Clear();
#ifdef OCC281
myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect );
#endif
myGridEchoGroup->Marker(aVertex);
Visual3d_TransientManager::BeginDraw(
aView->View(), Standard_False, Standard_False);
Visual3d_TransientManager::DrawStructure (myGridEchoStructure);
Visual3d_TransientManager::EndDraw (Standard_True);
}
}
}
#endif