1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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

674
src/AIS/AIS.cdl Executable file
View File

@@ -0,0 +1,674 @@
-- File: AIS.cdl
-- Created: Wed Dec 11 11:16:37 1996
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
package AIS
---Purpose: Application Interactive Services provide the means to
-- create links between an application GUI viewer and
-- the packages which are used to manage selection
-- and presentation. The tools AIS defined in order to
-- do this include different sorts of entities: both the
-- selectable viewable objects themselves and the
-- context and attribute managers to define their
-- selection and display.
-- To orient the user as he works in a modeling
-- environment, views and selections must be
-- comprehensible. There must be several different sorts
-- of selectable and viewable object defined. These must
-- also be interactive, that is, connecting graphic
-- representation and the underlying reference
-- geometry. These entities are called Interactive
-- Objects, and are divided into four types:
-- - the Datum
-- - the Relation
-- - the Object
-- - None.
-- The Datum groups together the construction elements
-- such as lines, circles, points, trihedra, plane trihedra,
-- planes and axes.
-- The Relation is made up of constraints on one or
-- more interactive shapes and the corresponding
-- reference geometry. For example, you might want to
-- constrain two edges in a parallel relation. This
-- contraint is considered as an object in its own right,
-- and is shown as a sensitive primitive. This takes the
-- graphic form of a perpendicular arrow marked with
-- the || symbol and lying between the two edges.
-- The Object type includes topological shapes, and
-- connections between shapes.
-- None, in order not to eliminate the object, tells the
-- application to look further until it finds an object
-- definition in its generation which is accepted.
-- Inside these categories, you have the possibility
-- of an additional characterization by means of a
-- signature. The signature provides an index to the
-- further characterization. By default, the Interactive
-- Object has a None type and a signature of 0
-- (equivalent to None.) If you want to give a particular
-- type and signature to your interactive object, you must
-- redefine the two virtual methods: Type and Signature.
-- In the C++ inheritance structure of the package, each
-- class representing a specific Interactive Object
-- inherits AIS_InteractiveObject. Among these
-- inheriting classes, AIS_Relation functions as the
-- abstract mother class for tinheriting classes defining
-- display of specific relational constraints and types of
-- dimension. Some of these include:
-- - display of constraints based on relations of
-- symmetry, tangency, parallelism and concentricity
-- - display of dimensions for angles, offsets,
-- diameters, radii and chamfers.
-- No viewer can show everything at once with any
-- coherence or clarity. Views must be managed
-- carefully both sequentially and at any given instant.
-- Another function of the view is that of a context to
-- carry out design in. The design changes are applied
-- to the objects in the view and then extended to the
-- underlying reference geometry by a solver. To make
-- sense of this complicated visual data, several display
-- and selection tools are required. To facilitate
-- management, each object and each construction
-- element has a selection priority. There are also
-- means to modify the default priority.
-- To define an environment of dynamic detection, you
-- can use standard filter classes or create your own. A
-- filter questions the owner of the sensitive primitive in
-- local context to determine if it has the the desired
-- qualities. If it answers positively, it is kept. If not, it is rejected.
-- The standard filters supplied in AIS include:
-- AIS_AttributeFilter
-- AIS_SignatureFilter
-- AIS_TypeFilter.
-- Only the type filter can be used in the default
-- operating mode, the neutral point. The others can
-- only be used in open local contexts.
-- Neutral point and local context constitute the two
-- operating modes of the central entity which pilots
-- visualizations and selections, the Interactive Context.
-- It is linked to a main viewer and if you like, a trash bin
-- viewer as well.
-- The neutral point, which is the default mode, allows
-- you to easily visualize and select interactive objects
-- which have been loaded into the context. Opening
-- local contexts allows you to prepare and use a
-- temporary selection environment without disturbing
-- the neutral point. A set of functions allows you to
-- choose the interactive objects which you want to act
-- on, the selection modes which you want to activate,
-- and the temporary visualizations which you will
-- execute. When the operation is finished, you close the
-- current local context and return to the state in which
-- you were before opening it (neutral point or previous
-- local context).
-- An interactive object can have a certain number of
-- graphic attributes which are specific to it, such as
-- visualization mode, color, and material. By the same
-- token, the interactive context has a set of graphic
-- attributes, the Drawer which is valid by default for the
-- objects it controls. When an interactive object is
-- visualized, the required graphic attributes are first
-- taken from the object's own Drawer if one exists, or
-- from the context drawer for the others.
uses
TCollection,
MMgt,
Quantity,
TColgp,
TColStd,
TopLoc,
gp,
Geom,
Bnd,
Aspect,
Graphic2d,
Graphic3d,
V3d,
TopAbs,
TopoDS,
Prs3d,
PrsMgr,
Select3D,
SelectMgr,
StdSelect,
DsgPrs,
TopTools,
Poly
is
enumeration DisplayMode is WireFrame, Shaded, QuickHLR, ExactHLR;
---Purpose:
-- Sets display modes other than neutral point ones,
-- for interactive objects. The possibilities include:
-- - wireframe,
-- - shaded,
enumeration ConnectStatus is
CS_None,
CS_Connection,
CS_Transform,
CS_Both;
---Purpose: Gives the status of connection of an Interactive
-- Object. This will be one of the following:
-- - No connection
-- - Connection
-- - Transformation
-- - Both connection and transformation
-- This enumeration is used in
-- AIS_ConnectedInteractive. Transform indicates
-- that the Interactive Object reference geometry has
-- changed location relative to the reference geometry.
enumeration TypeOfIso is
TOI_IsoU,
TOI_IsoV,
TOI_Both;
---Purpose: Declares the type of isoparameter displayed.
enumeration DisplayStatus is
DS_Displayed,
DS_Erased,
DS_FullErased,
DS_Temporary,
DS_None;
---Purpose:
-- To give the display status of an Interactive Object.
-- This will be one of the following:
-- - DS_Displayed: the Interactive Object is
-- displayed in the main viewer;
-- - DS_Erased: the Interactive Object is erased in the collector;
-- - DS_FullErased: the Interactive Object is erased
-- but not in the collector;
-- - DS_Temporary: the Interactive Object is temporarily displayed;
-- - DS_None: the Interactive Object is nowhere displayed.
enumeration SelectStatus is
SS_Added,
SS_Removed,
SS_NotDone
end SelectStatus;
enumeration StatusOfPick is
SOP_Error,
SOP_NothingSelected,
SOP_Removed,
SOP_OneSelected,
SOP_SeveralSelected
end StatusOfPick;
enumeration StatusOfDetection is
SOD_Error,
SOD_Nothing,
SOD_AllBad,
SOD_Selected,
SOD_OnlyOneDetected,
SOD_OnlyOneGood,
SOD_SeveralGood
end StatusOfDetection;
enumeration KindOfDimension is
KOD_NONE,
KOD_LENGTH,
KOD_PLANEANGLE,
KOD_SOLIDANGLE,
KOD_AREA,
KOD_VOLUME,
KOD_MASS,
KOD_TIME,
KOD_RADIUS,
KOD_DIAMETER,
KOD_CHAMF2D,
KOD_CHAMF3D,
KOD_OFFSET,
KOD_ELLIPSERADIUS;
---Purpose: Declares the kinds of dimensions needed in the
-- display of Interactive Objects.
enumeration KindOfInteractive is
KOI_None,
KOI_Datum,
KOI_Shape,
KOI_Object,
KOI_Relation;
--- Purpose: Declares the type of Interactive Object.
-- This is one of the following:
-- - the Datum
-- - the Object
-- - the Relation
-- - the None type.
-- The Datum is the construction element. These include
-- points, lines, axes and planes. The object brings
-- together topological shapes. The Relation includes
-- dimensions and constraints. When the object is of an
-- unknown type, the None type is declared.
enumeration ClearMode is
CM_All,
CM_Interactive,
CM_Filters,
CM_StandardModes,
CM_TemporaryShapePrs
end ClearMode;
---Purpose: Declares which entities in an opened local context
-- are to be cleared of mode settings. Temporary
-- graphic presentations such as those for sub-shapes,
-- for example, are only created for the selection
-- process. By means of these enumerations, they can
-- be cleared from local context.
enumeration KindOfUnit is
TOU_LENGTH,
TOU_SURFACE,
TOU_VOLUME,
TOU_PLANE_ANGLE,
TOU_SOLID_ANGLE,
TOU_MASS,
TOU_FORCE,
TOU_TIME;
---Purpose: Declares the type of Interactive Object unit.
enumeration TypeOfAxis is TOAX_Unknown,TOAX_XAxis,TOAX_YAxis,TOAX_ZAxis;
---Purpose: Declares the type of axis.
enumeration TypeOfPlane is TOPL_Unknown,TOPL_XYPlane,TOPL_XZPlane,TOPL_YZPlane;
---Purpose: Declares the type of plane.
enumeration TypeOfDist is TOD_Unknown,TOD_Horizontal,TOD_Vertical;
---Purpose: To declare the type of distance.
enumeration TypeOfAttribute is
TOA_Line,
TOA_Angle,
TOA_Wire,
TOA_Plane,
TOA_Vector,
TOA_UIso,
TOA_VIso,
TOA_Free,
TOA_UnFree,
TOA_Section,
TOA_Hidden,
TOA_Seen,
TOA_FirstAxis,
TOA_SecondAxis,
TOA_ThirdAxis;
enumeration StandardDatum is SD_None,SD_Point,SD_Axis,SD_Trihedron,SD_PlaneTrihedron,SD_Line,SD_Circle,SD_Plane;
--- Purpose: Declares the type of standard datum of an Interactive Object.
-- New ------------------------------------------------
enumeration KindOfSurface is KOS_Plane, KOS_Cylinder, KOS_Cone, KOS_Sphere, KOS_Torus,
KOS_Revolution, KOS_Extrusion, KOS_OtherSurface;
-------------------------------------------------------
class Triangulation;
class TexturedShape;
class Drawer;
class InteractiveContext;
class GraphicTool;
private class LocalContext;
private class LocalStatus;
private class GlobalStatus;
deferred class InteractiveObject;
---Category: VARIOUS STANDARD INTERACTIVE OBJECTS
-- each type of Datum has a given signature.
-- the other interactive objects don't
-- implement this signature.
-- Mainly used for selection with Filters...
---Category: Datum
class Point; --signature 1
class Axis; --signature 2
class Trihedron; --signature 3
class PlaneTrihedron; --signature 4
class Line; --signature 5
class Circle; --signature 6
class Plane; --signature 7
---Category: Object of type Shape
class Shape; --signature 0
class ConnectedShape; --signature 1
class MultipleConnectedShape; --signature 2
---Category: General Objects
class ConnectedInteractive; --signature 0
class MultipleConnectedInteractive; --signature 1
---Category: DIMENSIONS AND RELATIONS
class DimensionOwner;
deferred class Relation;
deferred class EllipseRadiusDimension;
class MaxRadiusDimension;
class MinRadiusDimension;
class LengthDimension;
class AngleDimension;
class RadiusDimension;
class DiameterDimension;
class Chamf2dDimension;
class Chamf3dDimension;
class OffsetDimension;
class FixRelation;
class PerpendicularRelation;
class ParallelRelation;
class TangentRelation;
class ConcentricRelation;
class IdenticRelation;
class SymmetricRelation; -- axial symmetry
class MidPointRelation; -- equal distance from point
class EqualRadiusRelation;
class EqualDistanceRelation;
---Category: FILTERS
class TypeFilter;
class SignatureFilter;
class ExclusionFilter;
class AttributeFilter;
class C0RegularityFilter;
class BadEdgeFilter;
pointer PToContext to InteractiveContext from AIS;
class Selection;
---Category: The Collections
class ListOfInteractive instantiates List from TCollection
(InteractiveObject from AIS);
class SequenceOfInteractive instantiates Sequence from TCollection
(InteractiveObject from AIS);
class SequenceOfDimension instantiates Sequence from TCollection
(Relation from AIS);
class MapOfInteractive instantiates Map from TCollection
(InteractiveObject from AIS,MapTransientHasher from TColStd);
class DataMapofIntegerListOfinteractive instantiates DataMap from
TCollection(Integer from Standard, ListOfInteractive from AIS,MapIntegerHasher from TColStd);
-- for further management of layers
private class DataMapOfIOStatus instantiates DataMap from
TCollection(InteractiveObject from AIS,GlobalStatus from AIS,MapTransientHasher from TColStd);
-- Management of interactiveObjects Status...
class IndexedDataMapOfOwnerPrs instantiates IndexedDataMap from TCollection
(EntityOwner from SelectMgr,Presentation from Prs3d ,MapTransientHasher from TColStd);
-- for dynamic selection management in local context...
-- san: 18/04/2003 AIS_Selection class optimization
-- agv: 04/05/2003 Replace NCollection_List for CDL list
imported NListTransient;
imported NListIteratorOfListTransient;
imported NDataMapOfTransientIteratorOfListTransient;
-- service map for AIS_Selection class optimized logic
private class DataMapOfILC instantiates DataMap from TCollection
(Integer from Standard, LocalContext from AIS, MapIntegerHasher from TColStd);
private class DataMapOfSelStat instantiates DataMap from TCollection
(SelectableObject from SelectMgr,LocalStatus from AIS,MapTransientHasher from TColStd);
-- to tell if an object is sensitive to Standard Modes Of Selection....
-- Methods for dimensions
Nearest( aShape : Shape from TopoDS;
aPoint : Pnt from gp )
returns Pnt from gp;
---Purpose:
-- Returns the nearest point in a shape. This is used by
-- several classes in calculation of dimensions.
Farest( aShape : Shape from TopoDS;
aPoint : Pnt from gp )
returns Pnt from gp;
ComputeGeometry(anEdge : Edge from TopoDS;
aCurve : out Curve from Geom;
FirstPnt : out Pnt from gp;
LastPnt : out Pnt from gp)
---Purpose: Used by 2d Relation only
-- Computes the 3d geometry of <anEdge> in the current WorkingPlane
-- and the extremities if any
-- Return TRUE if ok
returns Boolean from Standard;
ComputeGeometry(anEdge : Edge from TopoDS;
aCurve : out Curve from Geom;
FirstPnt : out Pnt from gp;
LastPnt : out Pnt from gp;
extCurve : out Curve from Geom;
isinfinite: out Boolean from Standard;
isOnPlane : out Boolean from Standard;
aPlane : Plane from Geom)
---Purpose: Used by 2d Relation only
-- Computes the 3d geometry of <anEdge> in the current WorkingPlane
-- and the extremities if any.
-- If <aCurve> is not in the current plane, <extCurve> contains
-- the not projected curve associated to <anEdge>.
-- If <anEdge> is infinite, <isinfinite> = true and the 2
-- parameters <FirstPnt> and <LastPnt> have no signification.
-- Return TRUE if ok
returns Boolean from Standard;
ComputeGeometry (anEdge1 : Edge from TopoDS;
anEdge2 : Edge from TopoDS;
aCurve1 : out Curve from Geom;
aCurve2 : out Curve from Geom;
FirstPnt1 : out Pnt from gp;
LastPnt1 : out Pnt from gp;
FirstPnt2 : out Pnt from gp;
LastPnt2 : out Pnt from gp;
aPlane : Plane from Geom)
---Purpose: Used by 2d Relation only
-- Computes the 3d geometry of <anEdge> in the current WorkingPlane
-- and the extremities if any
-- Return TRUE if ok
returns Boolean from Standard;
ComputeGeometry (anEdge1 : Edge from TopoDS;
anEdge2 : Edge from TopoDS;
indexExt : out Integer from Standard;
aCurve1 : out Curve from Geom;
aCurve2 : out Curve from Geom;
FirstPnt1 : out Pnt from gp;
LastPnt1 : out Pnt from gp;
FirstPnt2 : out Pnt from gp;
LastPnt2 : out Pnt from gp;
ExtCurve : out Curve from Geom;
isinfinite1 : out Boolean from Standard;
isinfinite2 : out Boolean from Standard;
aPlane : Plane from Geom)
---Purpose: Used by 2d Relation only Computes the 3d geometry
-- of<anEdge1> and <anEdge2> in the current Plane and the
-- extremities if any. Return in ExtCurve the 3d curve
-- (not projected in the plane) of the first edge if
-- <indexExt> =1 or of the 2nd edge if <indexExt> = 2. If
-- <indexExt> = 0, ExtCurve is Null. if there is an edge
-- external to the plane, <isinfinite> is true if this
-- edge is infinite. So, the extremities of it are not
-- significant. Return TRUE if ok
returns Boolean from Standard;
ComputeGeomCurve (aCurve : in out Curve from Geom;
first1 : Real from Standard;
last1 : Real from Standard;
FirstPnt1 : out Pnt from gp;
LastPnt1 : out Pnt from gp;
aPlane : Plane from Geom;
isOnPlane: out Boolean from Standard)
---Purpose: Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane
-- and returns aCurve;
-- Return TRUE if ok
returns Boolean from Standard;
ComputeGeometry(aVertex : Vertex from TopoDS;
point : out Pnt from gp;
aPlane : Plane from Geom;
isOnPlane: out Boolean from Standard)
returns Boolean from Standard;
GetPlaneFromFace( aFace : Face from TopoDS;
aPlane : out Pln from gp;
aSurf : out Surface from Geom;
aSurfType : out KindOfSurface from AIS;
Offset : out Real from Standard )
returns Boolean from Standard;
---Purpose: Tryes to get Plane from Face. Returns Surface of Face
-- in aSurf. Returns Standard_True and Plane of Face in
-- aPlane in following cases:
-- Face is Plane, Offset of Plane,
-- Extrusion of Line and Offset of Extrusion of Line
-- Returns pure type of Surface which can be:
-- Plane, Cylinder, Cone, Sphere, Torus,
-- SurfaceOfRevolution, SurfaceOfExtrusion
InitFaceLength( aFace : Face from TopoDS;
aPlane : out Pln from gp;
aSurface : out Surface from Geom;
aSurfaceType : out KindOfSurface from AIS;
anOffset : out Real from Standard );
ComputeLengthBetweenPlanarFaces( FirstFace : Face from TopoDS;
SecondFace : Face from TopoDS;
Plane1 : Pln from gp;
Plane2 : Pln from gp;
Value : out Real from Standard;
FirstAttach : out Pnt from gp ;
SecondAttach : out Pnt from gp ;
DirAttach : out Dir from gp ;
AutomaticPos : Boolean from Standard;
Position : in out Pnt from gp);
ComputeLengthBetweenCurvilinearFaces( FirstFace : Face from TopoDS;
SecondFace : Face from TopoDS;
FirstSurf : in out Surface from Geom;
SecondSurf : in out Surface from Geom;
AutomaticPos : Boolean from Standard;
Value : out Real from Standard;
Position : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
DirAttach : out Dir from gp );
ComputeAngleBetweenPlanarFaces( FirstFace : Face from TopoDS;
SecondFace : Face from TopoDS;
Surf2 : Surface from Geom;
Axis : Ax1 from gp;
Value : Real from Standard;
AutomaticPos : Boolean from Standard;
Position : out Pnt from gp;
Center : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
FirstDir : out Dir from gp;
SecondDir : out Dir from gp);
---Purpose: Computes geometric parameters for planar faces for
-- Angular dimensions
ComputeAngleBetweenCurvilinearFaces( FirstFace : Face from TopoDS;
SecondFace : Face from TopoDS;
FirstSurf : Surface from Geom;
SecondSurf : Surface from Geom;
FirstSurfType : KindOfSurface from AIS;
SecondSurfType : KindOfSurface from AIS;
Axis : Ax1 from gp;
Value : Real from Standard;
AutomaticPos : Boolean from Standard;
Position : out Pnt from gp;
Center : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
FirstDir : out Dir from gp;
SecondDir : out Dir from gp;
Plane : out Plane from Geom );
---Purpose: Computes geometric parameters for curvilinear faces for
-- Angular dimensions
ProjectPointOnPlane( aPoint : Pnt from gp; aPlane : Pln from gp )
returns Pnt from gp;
ProjectPointOnLine( aPoint : Pnt from gp; aLine : Lin from gp )
returns Pnt from gp;
TranslatePointToBound( aPoint : Pnt from gp; aDir : Dir from gp; aBndBox: Box from Bnd )
returns Pnt from gp;
InDomain( aFirstPar : Real from Standard;
aLastPar : Real from Standard;
anAttachPar : Real from Standard)
returns Boolean from Standard;
---Purpose: returns True if point with anAttachPar is
-- in domain of arc
NearestApex(elips : Elips from gp;
pApex : Pnt from gp;
nApex : Pnt from gp;
fpara : Real from Standard ;
lpara : Real from Standard ;
IsInDomain : out Boolean from Standard)
returns Pnt from gp;
---Purpose: computes nearest to ellipse arc apex
DistanceFromApex(elips : Elips from gp;
Apex : Pnt from gp;
par : Real from Standard )
returns Real from Standard;
---Purpose: computes length of ellipse arc in parametric units
ComputeProjEdgePresentation(aPres : mutable Presentation from Prs3d;
aDrawer : mutable Drawer from AIS;
anEdge : Edge from TopoDS;
ProjCurve: Curve from Geom;
FirstP : Pnt from gp;
LastP : Pnt from gp;
aColor : NameOfColor from Quantity = Quantity_NOC_PURPLE;
aWidth : Real from Standard = 2;
aProjTOL : TypeOfLine from Aspect = Aspect_TOL_DASH;
aCallTOL : TypeOfLine from Aspect = Aspect_TOL_DOT);
ComputeProjVertexPresentation(aPres : mutable Presentation from Prs3d;
aDrawer : mutable Drawer from AIS;
aVertex : Vertex from TopoDS;
ProjPoint: Pnt from gp;
aColor : NameOfColor from Quantity = Quantity_NOC_PURPLE;
aWidth : Real from Standard = 2;
aProjTOM : TypeOfMarker from Aspect = Aspect_TOM_PLUS;
aCallTOL : TypeOfLine from Aspect = Aspect_TOL_DOT);
end AIS;

1485
src/AIS/AIS.cxx Executable file

File diff suppressed because it is too large Load Diff

280
src/AIS/AIS_AngleDimension.cdl Executable file
View File

@@ -0,0 +1,280 @@
-- File: AIS_AngleDimension.cdl
-- Created: Tue Dec 3 17:37:06 1996
-- Author: Arnaud BOUZY/Odile Olivier
-- <odl@sacadox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class AngleDimension from AIS inherits Relation from AIS
---Purpose: A framework to define display of angles.
-- These displays are particularly useful in viewing draft prisms.
-- The angle displayed may define an intersection
-- can be between two edges or two faces of a shape
-- or a plane. The display consists of arrows and text.
uses Shape from TopoDS,
Presentation from Prs3d,
PresentationManager3d from PrsMgr,
Selection from SelectMgr,
Pnt from gp,
Dir from gp,
Circ from gp,
Line from Geom,
Ax1 from gp,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Plane from Geom,
Surface from Geom,
ExtendedString from TCollection,
ArrowSide from DsgPrs,
KindOfDimension from AIS,
Edge from TopoDS,
Face from TopoDS
is
Create (aFirstEdge : Edge from TopoDS;
aSecondEdge : Edge from TopoDS;
aPlane : Plane from Geom;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
---Purpose: Constructs the angle display object defined by the
-- shapes aFShape, aSShape, the plane aPlane, the
-- value aVal and the text aText.
-- aFShape and aSShape are edges.
returns mutable AngleDimension from AIS;
Create (aFirstEdge : Edge from TopoDS;
aSecondEdge : Edge from TopoDS;
aPlane : Plane from Geom;
aVal : Real from Standard;
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
anArrowSize : Real from Standard = 0.0)
---Purpose: Constructs the angle display object defined by the
-- shapes aFShape, aSShape, the plane aPlane, the
-- value aVal, the text aText, the point aPosition, the
-- type of arrow aSymbolPrs, and the arrow length anArrowSize.
-- aFShape and aSShape are edges.
returns mutable AngleDimension from AIS;
Create (aCone : Face from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
---Purpose: Angle of cone
returns mutable AngleDimension from AIS;
Create (aCone : Face from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
anArrowSize : Real from Standard = 0.01 )
---Purpose: Angle of cone
returns mutable AngleDimension from AIS;
--===================================================================
Create (aFirstFace : Face from TopoDS;
aSecondFace : Face from TopoDS;
anAxis : Ax1 from gp;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
---Purpose: TwoPlanarFaceAngle dimension
returns mutable AngleDimension from AIS;
Create (aFirstFace : Face from TopoDS;
aSecondFace : Face from TopoDS;
anAxis : Ax1 from gp;
aVal : Real from Standard;
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
anArrowSize : Real from Standard = 0.0)
---Purpose: TwoPlanarFacesAngle dimension with position
-- and text Face can be Plane or Extrusion of line
-- or Offset of those
returns mutable AngleDimension from AIS;
Create (aFFace : Face from TopoDS;
aSFace : Face from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
---Purpose: Angle dimension between two curvilinear faces
-- Warning:
-- Requaired 0 <= aVal < PI,
-- aVal must be defined exactly.
returns mutable AngleDimension from AIS;
Create (aFFace : Face from TopoDS;
aSFace : Face from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
anArrowSize : Real from Standard = 0.001)
---Purpose: Angle dimension between two curvilinear faces
-- with position and text. Face can be Cone, Cylinder
-- Offset of Cone, Offset of Cylinder
returns mutable AngleDimension from AIS;
Axis (me)
---Purpose:
-- Returns the axis set by the SetAxis method, which
-- serves to locate the angle between two faces.
---C++: return const &
---C++: inline
returns Ax1 from gp
is static;
SetAxis(me: mutable;anAxis : Ax1 from gp)
---C++: inline
---Purpose:
-- Sets the axis, anAxis, which serves to locate the
-- angle between two faces.
is static;
SetConeFace( me: mutable; aConeFace : Face from TopoDS )
is static;
SetFirstShape( me: mutable; aFShape : Shape from TopoDS )
is redefined static;
SetSecondShape( me: mutable; aSShape : Shape from TopoDS )
is redefined static;
KindOfDimension(me)
---Purpose: Returns PLANEANGLE as the kind of dimension.
---C++: inline
returns KindOfDimension from AIS
is redefined;
IsMovable(me) returns Boolean from Standard
---C++: inline
---Purpose: Returns true if the angle dimension is movable.
is redefined;
-- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined static private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: Computes the presentation according to a point of view
-- given by <aProjector>.
-- This method should be used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
--
-- Computation private methods
--
ComputeConeAngle(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeTwoFacesAngle(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeTwoPlanarFacesAngle(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeTwoCurvilinearFacesAngle(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeTwoEdgesAngle(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeTwoEdgesNullAngle(me: mutable;
aPresentation : mutable Presentation from Prs3d;
l1 : Line from Geom;
l2 : Line from Geom;
ptat11 : Pnt from gp;
ptat12 : Pnt from gp;
ptat21 : Pnt from gp;
ptat22 : Pnt from gp;
isInf1 : Boolean from Standard;
isInf2 : Boolean from Standard )
is private;
ComputeTwoEdgesNotNullAngle(me: mutable;
aPresentation : mutable Presentation from Prs3d;
l1 : Line from Geom;
l2 : Line from Geom;
ptat11 : Pnt from gp;
ptat12 : Pnt from gp;
ptat21 : Pnt from gp;
ptat22 : Pnt from gp;
isInf1 : Boolean from Standard;
isInf2 : Boolean from Standard )
is private;
Compute3DSelection(me : mutable;
aSelection : mutable Selection from SelectMgr)
is private;
Compute2DSelection(me : mutable;
aSelection : mutable Selection from SelectMgr)
is private;
ComputeNull2DSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
distFS : Real from Standard)
is private;
ComputeConeAngleSelection(me : mutable;
aSelection : mutable Selection from SelectMgr)
is private;
fields
myNbShape : Integer from Standard;
myCenter : Pnt from gp;
myFAttach : Pnt from gp;
mySAttach : Pnt from gp;
myFDir : Dir from gp;
mySDir : Dir from gp;
myAxis : Ax1 from gp;
myCone : Face from TopoDS;
end AngleDimension;

2057
src/AIS/AIS_AngleDimension.cxx Executable file

File diff suppressed because it is too large Load Diff

39
src/AIS/AIS_AngleDimension.lxx Executable file
View File

@@ -0,0 +1,39 @@
// File: AIS_AngleDimension.lxx
// Created: Fri Feb 28 10:09:45 1997
// Author: Jean-Pierre COMBE
// <jpr>
//=======================================================================
//function : KindOfDimension
//purpose :
//=======================================================================
inline AIS_KindOfDimension AIS_AngleDimension::KindOfDimension() const
{
return AIS_KOD_PLANEANGLE;
}
//=======================================================================
//function : IsMovable
//purpose :
//=======================================================================
inline Standard_Boolean AIS_AngleDimension::IsMovable() const
{
return Standard_True;
}
//=======================================================================
//function : Axis
//purpose :
//=======================================================================
inline const gp_Ax1& AIS_AngleDimension::Axis() const
{
return myAxis;
}
//=======================================================================
//function : SetAxis
//purpose :
//=======================================================================
inline void AIS_AngleDimension::SetAxis(const gp_Ax1& anAxis)
{
myAxis = anAxis;
}

97
src/AIS/AIS_AttributeFilter.cdl Executable file
View File

@@ -0,0 +1,97 @@
-- File: AIS_AttributeFilter.cdl
-- Created: Tue Mar 4 17:58:52 1997
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class AttributeFilter from AIS inherits Filter from SelectMgr
---Purpose: Selects Interactive Objects, which have the desired width or color.
-- The filter questions each Interactive Object in local
-- context to determine whether it has an non-null
-- owner, and if so, whether it has the required color
-- and width attributes. If the object returns true in each
-- case, it is kept. If not, it is rejected.
-- This filter is used only in an open local context.
-- In the Collector viewer, you can only locate
-- Interactive Objects, which answer positively to the
-- filters, which are in position when a local context is open.
uses
NameOfColor from Quantity,
EntityOwner from SelectMgr
is
Create returns mutable AttributeFilter from AIS;
---Purpose:
-- Constructs an empty attribute filter object.
-- This filter object determines whether selectable
-- interactive objects have a non-null owner.
Create (aCol: NameOfColor from Quantity)
returns mutable AttributeFilter from AIS;
---Purpose:
-- Constructs an attribute filter object defined by the
-- color attribute aCol.
Create (aWidth : Real from Standard)
returns mutable AttributeFilter from AIS;
---Purpose:
-- Constructs an attribute filter object defined by the line
-- width attribute aWidth.
HasColor(me) returns Boolean from Standard;
---C++: inline
---Purpose:
-- Indicates that the Interactive Object has the color
-- setting specified by the argument aCol at construction time.
HasWidth(me) returns Boolean from Standard;
---C++: inline
---Purpose:
-- Indicates that the Interactive Object has the width
-- setting specified by the argument aWidth at
-- construction time.
SetColor(me:mutable;aCol: NameOfColor from Quantity);
---C++: inline
---Purpose: Sets the color aCol.
-- This must be chosen from the list of colors in Quantity_NameOfColor.
SetWidth(me:mutable;aWidth : Real from Standard);
---C++: inline
---Purpose: Sets the line width aWidth.
UnsetColor(me:mutable);
---C++: inline
---Purpose:
-- Removes the setting for color from the filter.
UnsetWidth(me:mutable);
---C++: inline
---Purpose:
-- Removes the setting for width from the filter.
IsOk(me;anObj : EntityOwner from SelectMgr)
returns Boolean from Standard is redefined virtual;
---Purpose: Indicates that the selected Interactive Object passes
-- the filter. The owner, anObj, can be either direct or
-- user. A direct owner is the corresponding
-- construction element, whereas a user is the
-- compound shape of which the entity forms a part.
-- If the Interactive Object returns Standard_True
-- when detected by the Local Context selector through
-- the mouse, the object is kept; if not, it is rejected.
fields
myCol : NameOfColor from Quantity;
myWid : Real from Standard;
hasC,hasW : Boolean from Standard;
end AttributeFilter;

52
src/AIS/AIS_AttributeFilter.cxx Executable file
View File

@@ -0,0 +1,52 @@
// File: AIS_AttributeFilter.cxx
// Created: Tue Mar 4 18:13:59 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
#include <AIS_AttributeFilter.ixx>
#include <AIS_InteractiveObject.hxx>
AIS_AttributeFilter::AIS_AttributeFilter():
hasC(Standard_False),
hasW(Standard_False){}
AIS_AttributeFilter::AIS_AttributeFilter(const Quantity_NameOfColor aCol):
myCol(aCol),
hasC(Standard_True),
hasW(Standard_False){}
AIS_AttributeFilter::AIS_AttributeFilter(const Standard_Real aWid):
myWid(aWid),
hasC(Standard_False),
hasW(Standard_True){}
Standard_Boolean AIS_AttributeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
{
if (Handle(AIS_InteractiveObject)::DownCast(anObj->Selectable()).IsNull()) return Standard_False;
Standard_Boolean okstat = Standard_True;
//#ifndef DEB
Handle_SelectMgr_SelectableObject aSelectable = anObj->Selectable() ;
if( hasC && ((Handle(AIS_InteractiveObject)&) aSelectable)->HasColor() )
//#else
// if(hasC && ((Handle(AIS_InteractiveObject)&) anObj->Selectable())->HasColor())
//#endif
okstat = (myCol == ((Handle(AIS_InteractiveObject)&) anObj)->Color());
//#ifndef DEB
aSelectable = anObj->Selectable() ;
if( hasW && ((Handle(AIS_InteractiveObject)&) aSelectable)->HasWidth() )
//#else
// if(hasW && ((Handle(AIS_InteractiveObject)&) anObj->Selectable())->HasWidth())
//#endif
okstat = (myWid == ((Handle(AIS_InteractiveObject)&) anObj)->Width()) && okstat;
return okstat;
}

22
src/AIS/AIS_AttributeFilter.lxx Executable file
View File

@@ -0,0 +1,22 @@
// File: AIS_AttributeFilter.lxx
// Created: Tue Mar 4 18:10:08 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
inline void AIS_AttributeFilter::SetColor(const Quantity_NameOfColor aCol)
{myCol = aCol;hasC = Standard_True;}
inline void AIS_AttributeFilter::SetWidth(const Standard_Real aWid)
{myWid=aWid;hasW = Standard_True;}
inline void AIS_AttributeFilter::UnsetColor()
{hasC = Standard_False;}
inline void AIS_AttributeFilter::UnsetWidth()
{hasW = Standard_False;}
inline Standard_Boolean AIS_AttributeFilter::HasColor() const
{return hasC;}
inline Standard_Boolean AIS_AttributeFilter::HasWidth() const
{return hasW;}

187
src/AIS/AIS_Axis.cdl Executable file
View File

@@ -0,0 +1,187 @@
-- File: AIS_Axis.cdl
-- Created: Wed Aug 9 16:28:13 1995
-- Author: Arnaud BOUZY/Odile Olivier
-- <adn@houblon>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
-- the restricted NameOfColor.
---Copyright: Matra Datavision 1995
class Axis from AIS inherits InteractiveObject from AIS
---Purpose: Locates the x, y and z axes in an Interactive Object.
-- These are used to orient it correctly in presentations
-- from different viewpoints, or to construct a revolved
-- shape, for example, from one of the axes. Conversely,
-- an axis can be created to build a revolved shape and
-- then situated relative to one of the axes of the view.
uses
Line from Geom,
Presentation from Prs3d,
PresentationManager3d from PrsMgr,
NameOfColor from Quantity,
Color from Quantity,
Selection from SelectMgr,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Pnt from gp,
Dir from gp,
LineAspect from Prs3d,
TypeOfAxis from AIS,
Axis2Placement from Geom,
Axis1Placement from Geom,
KindOfInteractive from AIS
is
Create(aComponent : Line from Geom)
returns mutable Axis from AIS;
--- Purpose: Initializes the line aComponent
Create( aComponent : Axis2Placement from Geom;
anAxisType: TypeOfAxis from AIS)
---Purpose: initializes the axis2 position
-- aComponent. The coordinate system used is right-handed.
returns mutable Axis from AIS;
Create(anAxis : Axis1Placement from Geom)
returns mutable Axis from AIS;
---Purpose: Initializes the axis1 position anAxis.
Component(me)
---Purpose:
-- Returns the axis entity aComponent and identifies it
-- as a component of a shape.
---C++: inline
---C++: return const &
returns any Line from Geom
is static;
SetComponent(me: mutable;aComponent : Line from Geom)
is static;
---Purpose: Sets the coordinates of the lin aComponent.
Axis2Placement(me)
---C++: inline
---C++: return const &
---Purpose:
-- Returns the position of axis2 and positions it by
-- identifying it as the x, y, or z axis and giving its
-- direction in 3D space. The coordinate system used is right-handed.
returns any Axis2Placement from Geom
is static;
SetAxis2Placement(me: mutable;
aComponent : Axis2Placement from Geom;
anAxisType : TypeOfAxis from AIS)
is static;
---Purpose:
-- Allows you to provide settings for aComponent:the
-- position and direction of an axis in 3D space. The
-- coordinate system used is right-handed.
SetAxis1Placement(me: mutable; anAxis : Axis1Placement from Geom)
is static;
---Purpose: Constructs a new line to serve as the axis anAxis in 3D space.
TypeOfAxis (me)
---C++: inline
---Purpose: Returns the type of axis.
returns TypeOfAxis from AIS;
SetTypeOfAxis (me : mutable;aTypeAxis: TypeOfAxis from AIS)
---C++: inline
---Purpose:
-- Constructs the entity aTypeAxis to stock information
-- concerning type of axis.
is static;
IsXYZAxis (me)
---C++: inline
---Purpose:
-- Returns a signature of 2 for axis datums. When you
-- activate mode 2 by a signature, you pick AIS objects
-- of type AIS_Axis.
returns Boolean from Standard;
AcceptDisplayMode(me;aMode:Integer from Standard) returns Boolean from Standard is redefined static;
---Purpose: Returns true if the interactive object accepts the display mode aMode.
-- -- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard = 0)
is redefined static private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)is private;
-- -- Methods from InteractiveObject
Signature(me) returns Integer from Standard is redefined;
---C++: inline
Type(me) returns KindOfInteractive from AIS is redefined;
---C++: inline
SetColor(me :mutable; aColor : NameOfColor from Quantity)
is redefined static;
SetColor(me :mutable; aColor : Color from Quantity)
is redefined static;
SetWidth(me:mutable; aValue:Real from Standard) is redefined static;
UnsetColor(me:mutable) is redefined static;
UnsetWidth(me:mutable) is redefined static;
ComputeFields(me: mutable)
is private;
fields
myComponent : Line from Geom;
myAx2 : Axis2Placement from Geom;
myPfirst : Pnt from gp;
myPlast : Pnt from gp;
myTypeOfAxis : TypeOfAxis from AIS;
myIsXYZAxis : Boolean from Standard;
myDir : Dir from gp;
myVal : Real from Standard;
myText : CString from Standard;
myLineAspect : LineAspect from Prs3d;
end Axis;

354
src/AIS/AIS_Axis.cxx Executable file
View File

@@ -0,0 +1,354 @@
// File: AIS_Axis.cxx
// Created: Wed Aug 9 16:28:42 1995
// Author: Arnaud BOUZY/Odile Olivier
// <adn>
#define GER61351 //GG_171199 Enable to set an object RGB color
// instead a restricted object NameOfColor.
#include <AIS_Axis.ixx>
#include <Aspect_TypeOfLine.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_DatumAspect.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_Structure.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <StdPrs_Curve.hxx>
#include <TopoDS.hxx>
#include <Geom_Axis1Placement.hxx>
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>
#include <Geom_Line.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <AIS_Drawer.hxx>
#include <DsgPrs_XYZAxisPresentation.hxx>
#include <UnitsAPI.hxx>
//=======================================================================
//function : AIS_Axis
//purpose :
//=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Line)& aComponent):
myComponent(aComponent),
myTypeOfAxis(AIS_TOAX_Unknown),
myIsXYZAxis(Standard_False)
{
myDrawer->SetLineAspect(new Prs3d_LineAspect
(Quantity_NOC_RED,Aspect_TOL_DOTDASH,1.));
SetInfiniteState();
gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location();
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ();
}
//=======================================================================
//function : AIS_Axis
//purpose : Xaxis, YAxis, ZAxis
//=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType):
myAx2(aComponent),
myTypeOfAxis(anAxisType),
myIsXYZAxis(Standard_True)
{
Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (100. ,"LENGTH");
Standard_Real aLength;
try {
aLength = UnitsAPI::AnyToLS(100. ,"mm");
} catch (Standard_Failure) {
aLength = 0.1;
}
DA->SetAxisLength(aLength,aLength,aLength);
Quantity_NameOfColor col = Quantity_NOC_TURQUOISE;
DA->FirstAxisAspect()->SetColor(col);
DA->SecondAxisAspect()->SetColor(col);
DA->ThirdAxisAspect()->SetColor(col);
myDrawer->SetDatumAspect(DA);
ComputeFields();
}
//=======================================================================
//function : AIS_Axis
//purpose :
//=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis)
:myComponent(new Geom_Line(anAxis->Ax1())),
myTypeOfAxis(AIS_TOAX_Unknown),
myIsXYZAxis(Standard_False)
{
myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED,Aspect_TOL_DOTDASH,1.));
SetInfiniteState();
gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location();
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ();
}
//=======================================================================
//function : SetComponent
//purpose :
//=======================================================================
void AIS_Axis::SetComponent(const Handle(Geom_Line)& aComponent)
{
myComponent = aComponent;
myTypeOfAxis = AIS_TOAX_Unknown;
myIsXYZAxis = Standard_False;
SetInfiniteState();
gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location();
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ();
}
//=======================================================================
//function : SetAxis2Placement
//purpose :
//=======================================================================
void AIS_Axis::SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType)
{
myAx2 = aComponent;
myTypeOfAxis = anAxisType;
myIsXYZAxis = Standard_True;
ComputeFields();
}
//=======================================================================
//function : SetAxis1Placement
//purpose :
//=======================================================================
void AIS_Axis::SetAxis1Placement(const Handle(Geom_Axis1Placement)& anAxis)
{
SetComponent(new Geom_Line(anAxis->Ax1()));
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Axis::Compute(const Handle(PrsMgr_PresentationManager3d)&,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer)
{
aPresentation->Clear();
//Pro.... : pas de prise en compte des axes lors du FITALL (jmi)
aPresentation->SetInfiniteState (myInfiniteState);
aPresentation->SetDisplayPriority(5);
if (!myIsXYZAxis ){
GeomAdaptor_Curve curv(myComponent);
Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable();
StdPrs_Curve::Add(aPresentation,curv,myDrawer);
if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable();
}
else {
DsgPrs_XYZAxisPresentation::Add(aPresentation,myLineAspect,myDir,myVal,myText,myPfirst,myPlast);
}
}
void AIS_Axis::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_Axis::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Axis::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer)
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
eown -> SelectBasics_EntityOwner::Set(3);
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown,
myPfirst,
myPlast);
aSelection->Add(seg);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Axis::SetColor(const Quantity_NameOfColor aCol)
#ifdef GER61351
{
SetColor(Quantity_Color(aCol));
}
void AIS_Axis::SetColor(const Quantity_Color &aCol)
#endif
{
hasOwnColor=Standard_True;
myOwnColor=aCol;
myDrawer->LineAspect()->SetColor(aCol);
const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect();
DA->FirstAxisAspect()->SetColor(aCol);
DA->SecondAxisAspect()->SetColor(aCol);
DA->ThirdAxisAspect()->SetColor(aCol);
}
//=======================================================================
//function : SetWidth
//purpose :
//=======================================================================
void AIS_Axis::SetWidth(const Standard_Real aValue)
{
if(aValue<0.0) return;
if(aValue==0) UnsetWidth();
myDrawer->LineAspect()->SetWidth(aValue);
const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect();
DA->FirstAxisAspect()->SetWidth(aValue);
DA->SecondAxisAspect()->SetWidth(aValue);
DA->ThirdAxisAspect()->SetWidth(aValue);
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Axis::Compute(const Handle(PrsMgr_PresentationManager2d)&,
const Handle(Graphic2d_GraphicObject)&,
const Standard_Integer)
{
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Axis::Compute(const Handle(Prs3d_Projector)&,
const Handle(Prs3d_Presentation)&)
{
}
//=======================================================================
//function : ComputeFields
//purpose :
//=======================================================================
void AIS_Axis::ComputeFields()
{
if (myIsXYZAxis){
// calcul de myPFirst,myPlast
Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
gp_Pnt Orig = myAx2->Ax2().Location();
gp_Dir oX = myAx2->Ax2().XDirection();
gp_Dir oY = myAx2->Ax2().YDirection();
gp_Dir oZ = myAx2->Ax2().Direction();
Quantity_Length xo,yo,zo,x,y,z;
Orig.Coord(xo,yo,zo);
myPfirst.SetCoord(xo,yo,zo);
switch (myTypeOfAxis) {
case AIS_TOAX_XAxis:
{
oX.Coord(x,y,z);
myVal = DA->FirstAxisLength();
myDir = oX;
myLineAspect = DA->FirstAxisAspect();
myText = Standard_CString ("X");
break;
}
case AIS_TOAX_YAxis:
{
oY.Coord(x,y,z);
myVal = DA->SecondAxisLength();
myDir = oY;
myLineAspect = DA->SecondAxisAspect();
myText = Standard_CString ("Y");
break;
}
case AIS_TOAX_ZAxis:
{
oZ.Coord(x,y,z);
myVal = DA->ThirdAxisLength();
myDir = oZ;
myLineAspect = DA->ThirdAxisAspect();
myText = Standard_CString ("Z");
break;
}
default:
break;
}
myComponent = new Geom_Line(Orig,myDir);
x = xo + x*myVal; y = yo + y*myVal; z = zo + z*myVal;
myPlast.SetCoord(x,y,z);
SetInfiniteState();
}
}
//=======================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
Standard_Boolean AIS_Axis::
AcceptDisplayMode(const Standard_Integer aMode) const
{return aMode == 0;}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Axis::UnsetColor()
{
myDrawer->LineAspect()->SetColor(Quantity_NOC_RED);
hasOwnColor=Standard_False;
myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(Quantity_NOC_TURQUOISE);
myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(Quantity_NOC_TURQUOISE);
myDrawer->DatumAspect()->ThirdAxisAspect()->SetColor(Quantity_NOC_TURQUOISE);
}
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
void AIS_Axis::UnsetWidth()
{
myOwnWidth = 0.0;
myDrawer->LineAspect()->SetWidth(1.);
myDrawer->DatumAspect()->FirstAxisAspect()->SetWidth(1.);
myDrawer->DatumAspect()->SecondAxisAspect()->SetWidth(1.);
myDrawer->DatumAspect()->ThirdAxisAspect()->SetWidth(1.);
}

58
src/AIS/AIS_Axis.lxx Executable file
View File

@@ -0,0 +1,58 @@
// File: AIS_Axis.lxx
// Created: Mon Mar 3 14:54:41 1997
// Author: Jean-Pierre COMBE
// <jpr>
//=======================================================================
//function : Component
//purpose :
//=======================================================================
inline const Handle(Geom_Line)& AIS_Axis::Component() const
{
return myComponent;
}
//=======================================================================
//function : Axis2Placement
//purpose :
//=======================================================================
inline const Handle(Geom_Axis2Placement)& AIS_Axis::Axis2Placement() const
{
return myAx2;
}
//=======================================================================
//function : TypeOfAxis:
//purpose :
//=======================================================================
inline AIS_TypeOfAxis AIS_Axis::TypeOfAxis() const
{
return myTypeOfAxis;
}
//=======================================================================
//function : SetTypeOfAxis
//purpose :
//=======================================================================
inline void AIS_Axis::SetTypeOfAxis(const AIS_TypeOfAxis aTypeAxis)
{
myTypeOfAxis = aTypeAxis;
}
//=======================================================================
//function : IsXYZAxis
//purpose :
//=======================================================================
inline Standard_Boolean AIS_Axis::IsXYZAxis() const
{
return myIsXYZAxis;
}
inline AIS_KindOfInteractive AIS_Axis::Type() const
{return AIS_KOI_Datum;}
inline Standard_Integer AIS_Axis::Signature() const
{return 2;}

48
src/AIS/AIS_BadEdgeFilter.cdl Executable file
View File

@@ -0,0 +1,48 @@
-- File: AIS_BadEdgeFilter.cdl
-- Created: Wed Mar 4 11:44:30 1998
-- Author: Julia Gerasimova
-- <j-gerasimova@hankox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class BadEdgeFilter from AIS inherits Filter from SelectMgr
---Purpose: A Class
uses
EntityOwner from SelectMgr,
Edge from TopoDS,
DataMapOfIntegerListOfShape from TopTools,
ShapeEnum from TopAbs
is
Create
returns mutable BadEdgeFilter from AIS;
--- Purpose: Constructs an empty filter object for bad edges.
ActsOn( me; aType : ShapeEnum from TopAbs )
returns Boolean from Standard
is redefined;
IsOk( me; EO : EntityOwner from SelectMgr )
returns Boolean from Standard is redefined virtual;
SetContour( me : mutable ; Index : Integer from Standard );
---Purpose: sets <myContour> with current contour. used by
-- IsOk.
AddEdge( me: mutable ; anEdge : Edge from TopoDS;
Index : Integer from Standard );
---Purpose: Adds an edge to the list of non-selectionnable
-- edges.
RemoveEdges( me: mutable ; Index : Integer from Standard );
---Purpose: removes from the list of non-selectionnable edges
-- all edges in the contour <Index>.
fields
myBadEdges : DataMapOfIntegerListOfShape from TopTools;
myContour : Integer from Standard;
end BadEdgeFilter;

97
src/AIS/AIS_BadEdgeFilter.cxx Executable file
View File

@@ -0,0 +1,97 @@
// File: AIS_BadEdgeFilter.cxx
// Created: Wed Mar 4 12:01:13 1998
// Author: Julia Gerasimova
// <g_design>
#include <AIS_BadEdgeFilter.ixx>
#include <StdSelect_BRepOwner.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape.hxx>
//=======================================================================
//function : AIS_BadEdgeFilter
//purpose :
//=======================================================================
AIS_BadEdgeFilter::AIS_BadEdgeFilter()
{
myContour=0;
}
//=======================================================================
//function : ActsOn
//purpose :
//=======================================================================
Standard_Boolean AIS_BadEdgeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
{
return (aType == TopAbs_EDGE);
}
//=======================================================================
//function : IsOk
//purpose :
//=======================================================================
Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull())
return Standard_True;
if (myContour==0)
return Standard_True;
const TopoDS_Shape& aShape = ((Handle(StdSelect_BRepOwner)&)EO)->Shape();
if (myBadEdges.IsBound(myContour)) {
TopTools_ListIteratorOfListOfShape it(myBadEdges.Find(myContour));
for (; it.More(); it.Next()) {
if (it.Value().IsSame(aShape))
return Standard_False;
}
}
return Standard_True;
}
//=======================================================================
//function : AddEdge
//purpose :
//=======================================================================
void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge,
const Standard_Integer Index)
{
if (myBadEdges.IsBound(Index)) {
myBadEdges.ChangeFind(Index).Append(anEdge);
}
else {
TopTools_ListOfShape LS;
LS.Append(anEdge);
myBadEdges.Bind(Index,LS);
}
}
//=======================================================================
//function : RemoveEdges
//purpose :
//=======================================================================
void AIS_BadEdgeFilter::RemoveEdges(const Standard_Integer Index)
{
myBadEdges.UnBind(Index);
}
//=======================================================================
//function : RemoveEdges
//purpose :
//=======================================================================
void AIS_BadEdgeFilter::SetContour(const Standard_Integer Index)
{
myContour = Index;
}

View File

@@ -0,0 +1,33 @@
-- File: AIS_C0RegularityFilter.cdl
-- Created: Wed Feb 4 17:46:39 1998
-- Author: Julia GERASIMOVA
-- <jgv@orthodox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class C0RegularityFilter from AIS inherits Filter from SelectMgr
---Purpose:
uses
EntityOwner from SelectMgr,
Shape from TopoDS,
ShapeEnum from TopAbs,
MapOfShape from TopTools
is
Create( aShape : Shape from TopoDS )
returns mutable C0RegularityFilter from AIS;
ActsOn( me; aType : ShapeEnum from TopAbs )
returns Boolean from Standard
is redefined;
IsOk( me; EO : EntityOwner from SelectMgr )
returns Boolean from Standard is redefined virtual;
fields
myMapOfEdges : MapOfShape from TopTools;
end C0RegularityFilter;

View File

@@ -0,0 +1,79 @@
// File: AIS_C0RegularityFilter.cxx
// Created: Wed Feb 4 19:04:30 1998
// Author: Julia GERASIMOVA
// <jgv@orthodox.nnov.matra-dtv.fr>
#include <AIS_C0RegularityFilter.ixx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopExp.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <GeomAbs_Shape.hxx>
#include <BRep_Tool.hxx>
#include <StdSelect_BRepOwner.hxx>
//=======================================================================
//function : AIS_C0RegularityFilter
//purpose :
//=======================================================================
AIS_C0RegularityFilter::AIS_C0RegularityFilter(const TopoDS_Shape& aShape)
{
TopTools_IndexedDataMapOfShapeListOfShape SubShapes;
TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,SubShapes);
Standard_Boolean Ok;
for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++) {
Ok = Standard_False;
TopTools_ListIteratorOfListOfShape it(SubShapes(i));
TopoDS_Face Face1, Face2;
if (it.More()) {
Face1 = TopoDS::Face(it.Value());
it.Next();
if (it.More()) {
Face2 = TopoDS::Face(it.Value());
it.Next();
if (!it.More()) {
GeomAbs_Shape ShapeContinuity =
BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)),Face1,Face2);
Ok = (ShapeContinuity == GeomAbs_C0);
}
}
}
if (Ok) {
TopoDS_Shape curEdge = SubShapes.FindKey( i );
myMapOfEdges.Add(curEdge);
}
}
}
//=======================================================================
//function : ActsOn
//purpose :
//=======================================================================
Standard_Boolean AIS_C0RegularityFilter::ActsOn(const TopAbs_ShapeEnum aType) const
{
return (aType == TopAbs_EDGE);
}
//=======================================================================
//function : IsOk
//purpose :
//=======================================================================
Standard_Boolean AIS_C0RegularityFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull())
return Standard_False;
const TopoDS_Shape& aShape = ((Handle(StdSelect_BRepOwner)&)EO)->Shape();
if(aShape.ShapeType()!= TopAbs_EDGE)
return Standard_False;
return (myMapOfEdges.Contains(aShape));
}

113
src/AIS/AIS_Chamf2dDimension.cdl Executable file
View File

@@ -0,0 +1,113 @@
-- File: AIS_Chamf2dDimension.cdl
-- Created: Thu Dec 5 09:19:29 1996
-- Author: Flore Lantheaume/Odile Olivier
-- <odl@sacadox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class Chamf2dDimension from AIS inherits Relation from AIS
---Purpose: A framework to define display of 2D chamfers.
-- A chamfer is displayed with arrows and text. The text
-- gives the length of the chamfer if it is a symmetrical
-- chamfer, or the angle if it is not.
uses
PresentationManager3d from PrsMgr,
Presentation from Prs3d,
Selection from SelectMgr,
Shape from TopoDS,
Pnt from gp,
Plane from Geom,
Dir from gp,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
ExtendedString from TCollection,
ArrowSide from DsgPrs,
KindOfDimension from AIS
is
Create (aFShape : Shape from TopoDS;
aPlane : Plane from Geom;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
---Purpose: Constructs the display object for 2D chamfers.
-- This object is defined by the face aFShape, the
-- dimension aVal, the plane aPlane and the text aText.
returns mutable Chamf2dDimension from AIS;
Create (aFShape : Shape from TopoDS;
aPlane : Plane from Geom;
aVal : Real from Standard;
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
anArrowSize : Real from Standard = 0.0)
---Purpose: Constructs the display object for 2D chamfers.
-- This object is defined by the face aFShape, the plane
-- aPlane, the dimension aVal, the position aPosition,
-- the type of arrow aSymbolPrs with the size
-- anArrowSize, and the text aText.
returns mutable Chamf2dDimension from AIS;
KindOfDimension(me)
---Purpose: Indicates that we are concerned with a 2d length.
---C++: inline
returns KindOfDimension from AIS
is redefined;
IsMovable(me) returns Boolean from Standard
---Purpose: Returns true if the 2d chamfer dimension is movable.
---C++: inline
is redefined;
-- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined static private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
fields
myPntAttach : Pnt from gp;
myDir : Dir from gp;
end Chamf2dDimension;

271
src/AIS/AIS_Chamf2dDimension.cxx Executable file
View File

@@ -0,0 +1,271 @@
// File: AIS_Chamf2dDimension.cdl
// Created: Tue Dec 5 15:09:04 1996
// Author: Flore Lantheaume/Odile Olivier
// <ODL>
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
// if any in all dimensions.
#include <Standard_NotImplemented.hxx>
#include <AIS_Chamf2dDimension.ixx>
#include <DsgPrs_Chamf2dPresentation.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LengthAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopAbs_Orientation.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <gp_Dir.hxx>
#include <gp_Pln.hxx>
#include <gp_Vec.hxx>
#include <Geom_Line.hxx>
#include <ElCLib.hxx>
#include <Precision.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <ProjLib.hxx>
#include <Select3D_SensitiveBox.hxx>
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_Chamf2dDimension::AIS_Chamf2dDimension(const TopoDS_Shape& aFShape,
const Handle(Geom_Plane)& aPlane,
const Standard_Real aVal,
const TCollection_ExtendedString& aText)
:AIS_Relation()
{
myFShape = aFShape;
myPlane = aPlane;
myVal = aVal;
myText = aText;
mySymbolPrs = DsgPrs_AS_LASTAR;
myAutomaticPosition = Standard_True;
myArrowSize = myVal / 100.;
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_Chamf2dDimension::AIS_Chamf2dDimension(const TopoDS_Shape& aFShape,
const Handle(Geom_Plane)& aPlane,
const Standard_Real aVal,
const TCollection_ExtendedString& aText,
const gp_Pnt& aPosition,
const DsgPrs_ArrowSide aSymbolPrs ,
const Standard_Real anArrowSize)
:AIS_Relation()
{
myFShape = aFShape;
myPlane = aPlane;
myVal = aVal;
myText = aText;
myPosition = aPosition;
mySymbolPrs = aSymbolPrs;
#ifdef BUC60915
SetArrowSize( anArrowSize );
#else
myArrowSize = anArrowSize;
#endif
myAutomaticPosition = Standard_False;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Chamf2dDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer)
{
aPresentation->Clear();
Handle(Geom_Line) glin;
gp_Pnt pfirst,plast;
const TopoDS_Edge& thechamfedge = TopoDS::Edge(myFShape);
if (!AIS::ComputeGeometry(thechamfedge, glin,pfirst,plast) )
return;
gp_Dir dir1 (glin->Position().Direction());
gp_Dir norm1 = myPlane->Pln().Axis().Direction();
myDir = norm1.Crossed(dir1);
//-------------------------------------------------
// calcul d'une direction orthogonale a l'edge du
// chanfrein et dirigee vers l'ext. du contour
//-------------------------------------------------
// recup. d'une edge adjacente a l'edge du chanfrein
/*TopoDS_Edge nextedge = TopoDS::Edge(mySShape);
gp_Pnt pfirstnext,plastnext;
Handle(Geom_Line) glinnext;
if (!AIS::ComputeGeometry(nextedge,glinnext,pfirstnext,plastnext) )
return;
gp_Vec v1(pfirst,plast);
gp_Vec v2;
if (pfirst.IsEqual(plastnext, Precision::Confusion()))
v2.SetXYZ(pfirstnext.XYZ() - pfirst.XYZ());
else
v2.SetXYZ(plastnext.XYZ() - pfirst.XYZ());
gp_Vec crossvec = v1.Crossed(v2);
myDir = dimserv.GetDirection().Crossed(glin->Position().Direction());
if (crossvec.Dot(dimserv.GetDirection()) > 0 )
myDir.Reverse();*/ // myDir => donne a la creation
//--------------------------------------------
//Calcul du point de positionnement du texte
//--------------------------------------------
gp_Pnt curpos;
if (myAutomaticPosition) {
myPntAttach.SetXYZ((pfirst.XYZ()+plast.XYZ())/2);
gp_Vec transVec(myDir);
transVec*=myVal;
curpos = myPntAttach.Translated(transVec);
if (myIsSetBndBox)
curpos = AIS::TranslatePointToBound( curpos, myDir, myBndBox );
myPosition = curpos;
}
else {
myPntAttach.SetXYZ((pfirst.XYZ()+plast.XYZ())/2);
Handle(Geom_Line) dimLin = new Geom_Line(myPntAttach, myDir);
Standard_Real parcurpos = ElCLib::Parameter(dimLin->Lin(),myPosition);
curpos = ElCLib::Value(parcurpos,dimLin->Lin());
//static Standard_Real minlength = 0.005;
//taille minimale de la dimension
if ( curpos.Distance(myPntAttach) < 5. ) {
gp_Vec transVec(myDir);
transVec*=5.;
curpos = myPntAttach.Translated(transVec);
}
myPosition = curpos;
}
Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
//-------------------------------------------------
//Calcul de la boite englobante du component pour
//determiner la taille de la fleche
//-------------------------------------------------
#ifdef BUC60915
if( !myArrowSizeIsDefined ) {
#endif
Standard_Real arrsize = myArrowSize;
if ( (myVal/4) < arrsize)
arrsize = myVal/4;
if (arrsize > 30.)
arrsize = 30.;
else if (arrsize < 8.)
arrsize = 8.;
#ifdef BUC60915
myArrowSize = arrsize;
}
arr->SetLength(myArrowSize);
#else
arr->SetLength(arrsize);
#endif
//Calcul de la presentation
DsgPrs_Chamf2dPresentation::Add(aPresentation,
myDrawer,
myPntAttach,
curpos,
myText,
mySymbolPrs);
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Chamf2dDimension::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_Chamf2dDimension::Compute(const Handle(Prs3d_Projector)&,const Handle(Prs3d_Presentation)&)");
PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Chamf2dDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d,
const Handle(Graphic2d_GraphicObject)& aGraphicObject,
const Standard_Integer anInteger)
{
// Standard_NotImplemented::Raise("AIS_Chamf2dDimension::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)");
PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
void AIS_Chamf2dDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_Chamf2dDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Chamf2dDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer)
{
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(own,myPntAttach,myPosition);
aSelection->Add(seg);
// Text
Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
myPosition.X(),
myPosition.Y(),
myPosition.Z(),
myPosition.X() + size,
myPosition.Y() + size,
myPosition.Z() + size);
aSelection->Add(box);
}

View File

@@ -0,0 +1,22 @@
// File: AIS_Chamf2dDimension.lxx
// Created: Fri Feb 28 10:12:51 1997
// Author: Jean-Pierre COMBE
// <jpr>
//=======================================================================
//function : KindOfDimension
//purpose :
//=======================================================================
inline AIS_KindOfDimension AIS_Chamf2dDimension::KindOfDimension() const
{
return AIS_KOD_LENGTH;
}
//=======================================================================
//function : IsMovable
//purpose :
//=======================================================================
inline Standard_Boolean AIS_Chamf2dDimension::IsMovable() const
{
return Standard_True;
}

108
src/AIS/AIS_Chamf3dDimension.cdl Executable file
View File

@@ -0,0 +1,108 @@
-- File: AIS_Chamf3dDimension.cdl
-- Created: Thu Dec 5 09:19:29 1996
-- Author: Odile Olivier
-- <odl@sacadox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class Chamf3dDimension from AIS inherits Relation from AIS
---Purpose: A framework to define display of 3D chamfers.
-- A chamfer is displayed with arrows and text. The text
-- gives the length of the chamfer if it is a symmetrical
-- chamfer, or the angle if it is not.
uses
PresentationManager3d from PrsMgr,
Presentation from Prs3d,
Selection from SelectMgr,
Shape from TopoDS,
Pnt from gp,
Dir from gp,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
ExtendedString from TCollection,
ArrowSide from DsgPrs,
KindOfDimension from AIS
is
Create (aFShape : Shape from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
---Purpose: Constructs a display object for 3D chamfers.
-- This object is defined by the shape aFShape, the
-- dimension aVal and the text aText.
returns mutable Chamf3dDimension from AIS;
Create (aFShape : Shape from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
anArrowSize : Real from Standard = 0.0)
---Purpose: Constructs a display object for 3D chamfers.
-- This object is defined by the shape aFShape, the
-- dimension aVal, the text aText, the point of origin of
-- the chamfer aPosition, the type of arrow aSymbolPrs
-- with the size anArrowSize.
returns mutable Chamf3dDimension from AIS;
KindOfDimension(me)
---Purpose: Indicates that we are concerned with a 3d length.
---C++: inline
returns KindOfDimension from AIS
is redefined;
IsMovable(me) returns Boolean from Standard
---C++: inline
---Purpose: Returns true if the 3d chamfer dimension is movable.
is redefined;
-- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined static private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
fields
myPntAttach : Pnt from gp;
myDir : Dir from gp;
end Chamf3dDimension;

246
src/AIS/AIS_Chamf3dDimension.cxx Executable file
View File

@@ -0,0 +1,246 @@
// File: AIS_Chamf3dDimension.cdl
// Created: Tue Dec 5 15:09:04 1996
// Author: Odile Olivier
// <ODL>
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
// if any in all dimensions.
#include <Standard_NotImplemented.hxx>
#include <AIS_Chamf3dDimension.ixx>
#include <DsgPrs_Chamf2dPresentation.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LengthAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopAbs_Orientation.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <gp_Dir.hxx>
#include <gp_Pln.hxx>
#include <gp_Vec.hxx>
#include <Geom_Line.hxx>
#include <ElCLib.hxx>
#include <Precision.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <ProjLib.hxx>
#include <Select3D_SensitiveBox.hxx>
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_Chamf3dDimension::AIS_Chamf3dDimension(const TopoDS_Shape& aFShape,
const Standard_Real aVal,
const TCollection_ExtendedString& aText)
:AIS_Relation()
{
myFShape = aFShape;
myVal = aVal;
myText = aText;
mySymbolPrs = DsgPrs_AS_LASTAR;
myAutomaticPosition = Standard_True;
myArrowSize = myVal / 100.;
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_Chamf3dDimension::AIS_Chamf3dDimension(const TopoDS_Shape& aFShape,
const Standard_Real aVal,
const TCollection_ExtendedString& aText,
const gp_Pnt& aPosition,
const DsgPrs_ArrowSide aSymbolPrs ,
const Standard_Real anArrowSize)
:AIS_Relation()
{
myFShape = aFShape;
myVal = aVal;
myText = aText;
myPosition = aPosition;
mySymbolPrs = aSymbolPrs;
#ifdef BUC60915
SetArrowSize( anArrowSize );
#else
myArrowSize = anArrowSize;
#endif
myAutomaticPosition = Standard_False;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Chamf3dDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer)
{
aPresentation->Clear();
//----------------------------
// Calcul du centre de la face
//----------------------------
BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape));
Standard_Real uFirst, uLast, vFirst, vLast;
uFirst = surfAlgo.FirstUParameter();
uLast = surfAlgo.LastUParameter();
vFirst = surfAlgo.FirstVParameter();
vLast = surfAlgo.LastVParameter();
Standard_Real uMoy = (uFirst + uLast)/2;
Standard_Real vMoy = (vFirst + vLast)/2;
gp_Pnt apos ;
gp_Vec d1u, d1v;
surfAlgo.D1(uMoy, vMoy, apos, d1u, d1v);
myPntAttach = apos;
myDir = d1u ^ d1v;
// myDir = surfAlgo.Plane().Axis().Direction();
//--------------------------------------------
//Calcul du point de positionnement du texte
//--------------------------------------------
gp_Pnt curpos;
if (myAutomaticPosition) {
gp_Vec transVec(myDir);
transVec*=myVal;
curpos = myPntAttach.Translated(transVec);
if (myIsSetBndBox)
curpos = AIS::TranslatePointToBound( curpos, myDir, myBndBox );
myPosition = curpos;
}
else {
Handle(Geom_Line) dimLin = new Geom_Line(myPntAttach, myDir);
Standard_Real parcurpos = ElCLib::Parameter(dimLin->Lin(),myPosition);
curpos = ElCLib::Value(parcurpos,dimLin->Lin());
if ( curpos.Distance(myPntAttach) < 5. ) {
gp_Vec transVec(myDir);
transVec*=5.;
curpos = myPntAttach.Translated(transVec);
}
myPosition = curpos;
}
Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
//-------------------------------------------------
//Calcul de la boite englobante du component pour
//determiner la taille de la fleche
//-------------------------------------------------
#ifdef BUC60915
if( !myArrowSizeIsDefined ) {
#endif
Standard_Real arrsize = myArrowSize;
if ( (myVal/4) < arrsize)
arrsize = myVal/4;
if (arrsize > 30.)
arrsize = 30.;
else if (arrsize < 8.)
arrsize = 8.;
#ifdef BUC60915
myArrowSize = arrsize;
}
arr->SetLength(myArrowSize);
#else
arr->SetLength(arrsize);
#endif
//Calcul de la presentation
DsgPrs_Chamf2dPresentation::Add(aPresentation,
myDrawer,
myPntAttach,
curpos,
myText,
mySymbolPrs);
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Chamf3dDimension::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_Chamf3dDimension::Compute(const Handle(Prs3d_Projector)&,const Handle(Prs3d_Presentation)&)");
PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Chamf3dDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d,
const Handle(Graphic2d_GraphicObject)& aGraphicObject,
const Standard_Integer anInteger)
{
// Standard_NotImplemented::Raise("AIS_Chamf3dDimension::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)");
PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
void AIS_Chamf3dDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_Chamf3dDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Chamf3dDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer)
{
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(own,myPntAttach,myPosition);
aSelection->Add(seg);
// Text
Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
myPosition.X(),
myPosition.Y(),
myPosition.Z(),
myPosition.X() + size,
myPosition.Y() + size,
myPosition.Z() + size);
aSelection->Add(box);
}

View File

@@ -0,0 +1,22 @@
// File: AIS_Chamf3dDimension.lxx
// Created: Fri Feb 28 10:12:51 1997
// Author: Jean-Pierre COMBE
// <jpr>
//=======================================================================
//function : KindOfDimension
//purpose :
//=======================================================================
inline AIS_KindOfDimension AIS_Chamf3dDimension::KindOfDimension() const
{
return AIS_KOD_LENGTH;
}
//=======================================================================
//function : IsMovable
//purpose :
//=======================================================================
inline Standard_Boolean AIS_Chamf3dDimension::IsMovable() const
{
return Standard_True;
}

157
src/AIS/AIS_Circle.cdl Executable file
View File

@@ -0,0 +1,157 @@
-- File: AIS_Circle.cdl
-- Created: Tue Jan 21 11:45:01 1997
-- Author: Prestataire Christiane ARMAND
-- <car@chamalox.paris1.matra-dtv.fr>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
-- the restricted NameOfColor.
---Copyright: Matra Datavision 1997
class Circle from AIS inherits InteractiveObject from AIS
---Purpose: Constructs circle datums to be used in construction of
-- composite shapes.
uses
Circle from Geom,
Point from Geom,
Presentation from Prs3d,
PresentationManager3d from PrsMgr,
NameOfColor from Quantity,
Color from Quantity,
Selection from SelectMgr,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Line from AIS,
KindOfInteractive from AIS
is
Create(aCircle : Circle from Geom)
returns mutable Circle from AIS;
---Purpose: Initializes this algorithm for constructing AIS circle
-- datums initializes the circle aCircle
Create(aCircle : Circle from Geom;
aUStart : Real from Standard;
aUEnd : Real from Standard;
aSens : Boolean from Standard = Standard_True)
returns mutable Circle from AIS;
---Purpose: Initializes this algorithm for constructing AIS circle datums.
-- Initializes the circle aCircle, the arc
-- starting point UStart, the arc ending point UEnd,
-- and the direction aSens.
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard = 0)
is redefined static private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)is private;
-- Methods from InteractiveObject
Signature(me) returns Integer from Standard is redefined;
---C++: inline
---Purpose: Returns index 6 by default.
Type(me) returns KindOfInteractive from AIS is redefined;
---C++: inline
---Purpose: Indicates that the type of Interactive Object is a datum.
Circle(me) returns any Circle from Geom;
---C++: inline
---C++: return const &
---Purpose: Returns the circle component defined in SetCircle.
Parameters(me; u1,u2 : in out Real from Standard);
---C++: inline
---Purpose:
-- Constructs instances of the starting point and the end
-- point parameters, u1 and u2.
SetCircle(me:mutable;aCircle : Circle from Geom);
---C++: inline
---Purpose: Allows you to provide settings for the circle datum aCircle.
SetFirstParam(me:mutable;u:Real);
---C++: inline
---Purpose: Allows you to set the parameter u for the starting point of an arc.
SetLastParam(me:mutable;u:Real);
---C++: inline
---Purpose: Allows you to provide the parameter u for the end point of an arc.
SetColor(me :mutable; aColor : NameOfColor from Quantity)
is redefined static;
--- Purpose: Assigns the color aColor to the solid line boundary of the circle datum.
SetColor(me :mutable; aColor : Color from Quantity)
is redefined static;
SetWidth(me:mutable; aValue:Real from Standard)
is redefined static;
---Purpose: Assigns the width aValue to the solid line boundary of the circle datum.
UnsetColor(me:mutable)
is redefined static;
---Purpose: Removes color from the solid line boundary of the circle datum.
UnsetWidth(me:mutable)
is redefined static;
---Purpose: Removes width settings from the solid line boundary of the circle datum.
ComputeCircle(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeArc(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeCircleSelection(me: mutable;
aSelection : mutable Selection from SelectMgr)
is private;
ComputeArcSelection(me: mutable;
aSelection : mutable Selection from SelectMgr)
is private;
fields
myComponent : Circle from Geom;
myUStart : Real from Standard;
myUEnd : Real from Standard;
myCircleIsArc : Boolean from Standard;
mySens : Boolean from Standard;
end Circle ;

283
src/AIS/AIS_Circle.cxx Executable file
View File

@@ -0,0 +1,283 @@
// File: AIS_Circle.cxx
// Created: Tue Jan 21 11:45:01 1997
// Author: Prestataire Christiane ARMAND
// <car@chamalox.paris1.matra-dtv.fr>
// Copyright: Matra Datavision 1997
#define GER61351 //GG_171199 Enable to set an object RGB color
// instead a restricted object NameOfColor.
#include <AIS_Circle.ixx>
#include <Aspect_TypeOfLine.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_Structure.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <StdPrs_DeflectionCurve.hxx>
#include <TopoDS.hxx>
#include <Geom_Circle.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <AIS_Drawer.hxx>
#include <GC_MakeArcOfCircle.hxx>
#include <Quantity_Color.hxx>
#include <AIS_GraphicTool.hxx>
//=======================================================================
//function : AIS_Circle
//purpose :
//=======================================================================
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent):
AIS_InteractiveObject(PrsMgr_TOP_AllView),
myComponent(aComponent),
myUStart(0.),
myUEnd(2*PI),
myCircleIsArc(Standard_False)
{
}
//=======================================================================
//function : AIS_Circle
//purpose :
//=======================================================================
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent,
const Standard_Real aUStart,
const Standard_Real aUEnd,
const Standard_Boolean aSens):
AIS_InteractiveObject(PrsMgr_TOP_AllView)
{
myComponent = aComponent;
myUStart = aUStart;
myUEnd = aUEnd;
mySens = aSens;
myCircleIsArc = Standard_True;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer /*aMode*/)
{
aPresentation->Clear();
aPresentation->SetDisplayPriority(5);
if (myCircleIsArc) ComputeArc(aPresentation);
else ComputeCircle(aPresentation);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Circle::Compute(const Handle_Prs3d_Projector& aProjector,
const Handle_Geom_Transformation& aTransformation,
const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_Circle::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer /*aMode*/)
{
if (myCircleIsArc) ComputeArcSelection(aSelection);
else ComputeCircleSelection(aSelection);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Circle::SetColor(const Quantity_NameOfColor aCol)
#ifdef GER61351
{
SetColor(Quantity_Color(aCol));
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Circle::SetColor(const Quantity_Color &aCol)
#endif
{
hasOwnColor=Standard_True;
myOwnColor=aCol;
Standard_Real WW = HasWidth()? myOwnWidth:
AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
if (!myDrawer->HasLineAspect ())
myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
else
myDrawer->LineAspect()->SetColor(aCol);
}
//=======================================================================
//function : SetWidth
//purpose :
//=======================================================================
void AIS_Circle::SetWidth(const Standard_Real aValue)
{
myOwnWidth=aValue;
#ifndef GER61351
Quantity_NameOfColor CC =
HasColor() ? myOwnColor : AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line);
#endif
if (!myDrawer->HasLineAspect ()) {
#ifdef GER61351
Quantity_Color CC;
if( HasColor() ) CC = myOwnColor;
else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
#endif
myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue));
} else
myDrawer->LineAspect()->SetWidth(aValue);
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Circle::UnsetColor()
{
hasOwnColor = Standard_False;
Handle(Prs3d_LineAspect) NullAsp;
if (!HasWidth()) myDrawer->SetLineAspect(NullAsp);
else{
#ifdef GER61351
Quantity_Color CC;
if( HasColor() ) CC = myOwnColor;
else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
#else
Quantity_NameOfColor CC =
#endif
AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line);
myDrawer->LineAspect()->SetColor(CC);
myOwnColor = CC;
}
}
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
void AIS_Circle::UnsetWidth()
{
Handle(Prs3d_LineAspect) NullAsp;
if (!HasColor()) myDrawer->SetLineAspect(NullAsp);
else{
Standard_Real WW = AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
myDrawer->LineAspect()->SetWidth(WW);
myOwnWidth = WW;
}
}
//=======================================================================
//function : ComputeCircle
//purpose :
//=======================================================================
void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation)
{
GeomAdaptor_Curve curv(myComponent);
Standard_Real prevdev = myDrawer->DeviationCoefficient();
myDrawer->SetDeviationCoefficient(1.e-5);
Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable();
StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable();
myDrawer->SetDeviationCoefficient(prevdev);
}
//=======================================================================
//function : ComputeArc
//purpose :
//=======================================================================
void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation)
{
GeomAdaptor_Curve curv(myComponent,myUStart,myUEnd);
Standard_Real prevdev = myDrawer->DeviationCoefficient();
myDrawer->SetDeviationCoefficient(1.e-5);
Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable();
StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable();
myDrawer->SetDeviationCoefficient(prevdev);
}
//=======================================================================
//function : ComputeCircleSelection
//purpose :
//=======================================================================
void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection)
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle(eown,
myComponent);
aSelection->Add(seg);
}
//=======================================================================
//function : ComputeArcSelection
//purpose :
//=======================================================================
void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection)
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle(eown,
myComponent,myUStart,myUEnd);
aSelection->Add(seg);
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager2d)&,
const Handle(Graphic2d_GraphicObject)&,
const Standard_Integer)
{
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Circle::Compute(const Handle(Prs3d_Projector)&,
const Handle(Prs3d_Presentation)&)
{
}

25
src/AIS/AIS_Circle.lxx Executable file
View File

@@ -0,0 +1,25 @@
// File: AIS_Circle.lxx
// Created: Thu Mar 6 14:25:37 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
inline AIS_KindOfInteractive AIS_Circle::Type() const
{return AIS_KOI_Datum;}
inline Standard_Integer AIS_Circle::Signature() const
{return 6;}
inline const Handle(Geom_Circle)&
AIS_Circle::Circle() const
{return myComponent;}
inline void AIS_Circle::Parameters(Standard_Real& U1,Standard_Real& U2) const
{U1=myUStart;U2=myUEnd;}
inline void AIS_Circle::SetCircle(const Handle(Geom_Circle)& C)
{myComponent=C;}
inline void AIS_Circle::SetFirstParam(const Standard_Real U)
{myUStart=U;myCircleIsArc = Standard_True;}
inline void AIS_Circle::SetLastParam(const Standard_Real U)
{myUEnd=U; myCircleIsArc = Standard_True;}

View File

@@ -0,0 +1,102 @@
-- File: AIS_ConcentricRelation.cdl
-- Created: Thu Dec 5 10:28:03 1996
-- Author: Flore Lantheaume/Odile Olivier
-- <odl@sacadox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class ConcentricRelation from AIS inherits Relation from AIS
---Purpose: A framework to define a constraint by a relation of
-- concentricity between two or more interactive datums.
-- The display of this constraint is also defined.
-- A plane is used to create an axis along which the
-- relation of concentricity can be extended.
uses
PresentationManager3d from PrsMgr,
Presentation from Prs3d,
Selection from SelectMgr,
Shape from TopoDS,
Pnt from gp,
Dir from gp,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d ,
Plane from Geom
is
Create (aFShape : Shape from TopoDS;
aSShape : Shape from TopoDS;
aPlane : Plane from Geom)
---Purpose: Constructs the display object for concentric relations
-- between shapes.
-- This object is defined by the two shapes, aFShape
-- and aSShape and the plane aPlane.
-- aPlane is provided to create an axis along which the
-- relation of concentricity can be extended.
returns mutable ConcentricRelation from AIS;
-- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined static private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
ComputeTwoEdgesConcentric(me:mutable;
aPresentationManager: Presentation from Prs3d)
is private;
ComputeEdgeVertexConcentric(me:mutable;
aPresentationManager: Presentation from Prs3d)
is private;
ComputeTwoVerticesConcentric(me:mutable;
aPresentationManager: Presentation from Prs3d)
is private;
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
fields
myCenter : Pnt from gp;
myRad : Real from Standard;
myDir : Dir from gp;
myPnt : Pnt from gp;
end ConcentricRelation;

View File

@@ -0,0 +1,277 @@
// File: AIS_ConcentricRelation.cdl
// Created: Tue Dec 5 15:09:04 1996
// Author: Flore Lantheaume/Odile Olivier
// <ODL>
#include <Standard_NotImplemented.hxx>
#include <AIS_ConcentricRelation.ixx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <DsgPrs_ConcentricPresentation.hxx>
#include <TopoDS.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <GeomAbs_CurveType.hxx>
#include <Geom_Circle.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <gp_Ax2.hxx>
#include <gp_Ax1.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pln.hxx>
#include <TopoDS_Vertex.hxx>
#include <AIS.hxx>
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_ConcentricRelation::AIS_ConcentricRelation(
const TopoDS_Shape& aFShape,
const TopoDS_Shape& aSShape,
const Handle(Geom_Plane)& aPlane)
{
myFShape = aFShape;
mySShape = aSShape;
myPlane = aPlane;
myDir = aPlane->Pln().Axis().Direction();
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ConcentricRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer)
{
aPresentation->Clear();
TopAbs_ShapeEnum type2(mySShape.ShapeType());
aPresentation->SetInfiniteState(Standard_True);
switch (myFShape.ShapeType()) {
case TopAbs_EDGE:
{
if (type2 == TopAbs_EDGE) ComputeTwoEdgesConcentric(aPresentation);
else if (type2 == TopAbs_VERTEX) ComputeEdgeVertexConcentric(aPresentation);
}
break;
case TopAbs_VERTEX:
{
if (type2 == TopAbs_VERTEX) ComputeTwoVerticesConcentric(aPresentation);
else if (type2 == TopAbs_EDGE) ComputeEdgeVertexConcentric(aPresentation);
}
break;
default: {return;}
}
}
void AIS_ConcentricRelation::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_ConcentricRelation::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeTwoEdgesConcentric
//purpose :
//=======================================================================
void AIS_ConcentricRelation::ComputeEdgeVertexConcentric(const Handle(Prs3d_Presentation)& aPresentation)
{
TopoDS_Edge E;
TopoDS_Vertex V;
if (myFShape.ShapeType() == TopAbs_EDGE) {
E = TopoDS::Edge(myFShape);
V = TopoDS::Vertex(mySShape);
}
else {
E = TopoDS::Edge(myFShape);
V = TopoDS::Vertex(mySShape);
}
gp_Pnt p1,p2;
Handle(Geom_Curve) C;
Handle(Geom_Curve) extCurv;
Standard_Boolean isInfinite;
Standard_Boolean isOnPlanEdge, isOnPlanVertex;
if (!AIS::ComputeGeometry(E,C,p1,p2,extCurv,isInfinite,isOnPlanEdge,myPlane)) return;
gp_Pnt P;
AIS::ComputeGeometry(V,P, myPlane, isOnPlanVertex);
const Handle(Geom_Circle)& CIRCLE = (Handle(Geom_Circle)&) C;
myCenter = CIRCLE->Location();
myRad = Min(CIRCLE->Radius()/5.,15.);
gp_Dir vec(p1.XYZ() - myCenter.XYZ() );
gp_Vec vectrans(vec);
myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
DsgPrs_ConcentricPresentation::Add(aPresentation,myDrawer,myCenter,myRad,myDir,myPnt);
if (!isOnPlanEdge) AIS::ComputeProjEdgePresentation(aPresentation,myDrawer,E,CIRCLE,p1,p2);
if (!isOnPlanVertex) AIS::ComputeProjVertexPresentation(aPresentation,myDrawer,V,P);
}
//=======================================================================
//function : ComputeTwoEdgesConcentric
//purpose :
//=======================================================================
void AIS_ConcentricRelation::ComputeTwoVerticesConcentric(const Handle(Prs3d_Presentation)& aPresentation)
{
TopoDS_Vertex V1,V2;
V1 = TopoDS::Vertex(myFShape);
V2 = TopoDS::Vertex(myFShape);
Standard_Boolean isOnPlanVertex1(Standard_True),isOnPlanVertex2(Standard_True);
gp_Pnt P1,P2;
AIS::ComputeGeometry(V1,P1, myPlane,isOnPlanVertex1);
AIS::ComputeGeometry(V2,P2, myPlane,isOnPlanVertex2);
myCenter = P1;
myRad = 15.;
gp_Dir vec(myPlane->Pln().Position().XDirection());
gp_Vec vectrans(vec);
myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
DsgPrs_ConcentricPresentation::Add(aPresentation,myDrawer,myCenter,myRad,myDir,myPnt);
if (!isOnPlanVertex1) AIS::ComputeProjVertexPresentation(aPresentation,myDrawer,V1,P1);
if (!isOnPlanVertex1) AIS::ComputeProjVertexPresentation(aPresentation,myDrawer,V2,P2);
}
//=======================================================================
//function : ComputeTwoEdgesConcentric
//purpose :
//=======================================================================
void AIS_ConcentricRelation::ComputeTwoEdgesConcentric(const Handle(Prs3d_Presentation)& aPresentation)
{
BRepAdaptor_Curve curv1(TopoDS::Edge(myFShape));
BRepAdaptor_Curve curv2(TopoDS::Edge(mySShape));
gp_Pnt ptat11,ptat12,ptat21,ptat22;
Handle(Geom_Curve) geom1,geom2;
Standard_Boolean isInfinite1,isInfinite2;
Handle(Geom_Curve) extCurv;
if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),
TopoDS::Edge(mySShape),
myExtShape,
geom1,
geom2,
ptat11,
ptat12,
ptat21,
ptat22,
extCurv,
isInfinite1,isInfinite2,
myPlane)) {
return;
}
const Handle(Geom_Circle)& gcirc1 = (Handle(Geom_Circle)&) geom1;
const Handle(Geom_Circle)& gcirc2 = (Handle(Geom_Circle)&) geom2;
myCenter = gcirc1->Location();
// on choisit le rayon egal a 1/5 ieme du rayon du plus petit des
// 2 cercles. On impose une borne sup au rayon( 0.02 au hasard)
Standard_Real rad1 = gcirc1->Radius();
Standard_Real rad2 = gcirc2->Radius();
myRad = (rad1 > rad2 ) ? rad2 : rad1;
myRad /= 5;
if (myRad > 15.) myRad =15.;
//Calcul d'un point du cercle de rayon myRad
gp_Dir vec(ptat11.XYZ() - myCenter.XYZ() );
gp_Vec vectrans(vec);
myPnt = myCenter.Translated(vectrans.Multiplied(myRad));
DsgPrs_ConcentricPresentation::Add(aPresentation,
myDrawer,
myCenter,
myRad,
myDir,
myPnt);
if ( (myExtShape != 0) && !extCurv.IsNull()) {
gp_Pnt pf, pl;
if ( myExtShape == 1 ) {
if (!isInfinite1) {
pf = ptat11;
pl = ptat12;
}
ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(myFShape),gcirc1,pf,pl);
}
else {
if (!isInfinite2) {
pf = ptat21;
pl = ptat22;
}
ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(mySShape),gcirc2,pf,pl);
}
}
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_ConcentricRelation::Compute(const Handle(Prs3d_Projector)&,
const Handle(Prs3d_Presentation)&)
{
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_ConcentricRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,
const Handle(Graphic2d_GraphicObject)&,
const Standard_Integer)
{
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_ConcentricRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer)
{
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
//Creation de 2 sensitives cercles
// le plus grand
gp_Ax2 ax(myCenter, myDir);
Handle(Geom_Circle) Circ = new Geom_Circle(ax, myRad) ;
Handle(Select3D_SensitiveCircle)
sensit = new Select3D_SensitiveCircle (own,
Circ);
aSelection->Add(sensit);
// le plus petit
Circ->SetRadius(myRad/2);
sensit = new Select3D_SensitiveCircle (own,
Circ);
aSelection->Add(sensit);
//Creation de 2 segments sensitifs pour la croix
Handle(Select3D_SensitiveSegment) seg;
gp_Pnt otherPnt = myPnt.Mirrored(myCenter);
seg = new Select3D_SensitiveSegment(own,
otherPnt,
myPnt);
aSelection->Add(seg);
gp_Ax1 RotateAxis(myCenter, myDir);
gp_Pnt FPnt = myCenter.Rotated(RotateAxis, PI/2);
gp_Pnt SPnt = myCenter.Rotated(RotateAxis, -PI/2);
seg = new Select3D_SensitiveSegment(own,
FPnt,
SPnt);
aSelection->Add(seg);
}

View File

@@ -0,0 +1,174 @@
-- File: AIS_ConnectedInteractive.cdl
-- Created: Wed Jan 8 13:33:22 1997
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class ConnectedInteractive from AIS inherits InteractiveObject from AIS
---Purpose: Defines an Interactive Object through a connection to
-- another Interactive Object, which serves as a
-- reference, and which is located elsewhere in the viewer.
-- This allows you to use the Connected Interactive
-- Object without having to recalculate presentation,
-- selection or graphic structure. These are deduced
-- from your reference object.
-- The relation between the connected interactive object
-- and its source is generally one of geometric transformation.
-- Warning
-- An Interactive entity which is view (or projector)
-- dependent requires recalculation of views in hidden
-- parts mode depending on the position of the
-- projector in each view. You should derive the entity's
-- inheritance from ConnectedInteractive and redefine
-- its compute method to enable this type of calculation.
uses
Location from TopLoc,
Transformation from Geom,
PresentationManager3d from PrsMgr,
GraphicObject from Graphic2d,
PresentationManager2d from PrsMgr,
Presentation from Prs3d,
TypeOfPresentation3d from PrsMgr,
Selection from SelectMgr,
Projector from Prs3d,
KindOfInteractive from AIS
raises
NotImplemented from Standard
is
Create (aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView)
returns mutable ConnectedInteractive from AIS;
---Purpose:
-- Disconnects the previous view and sets highlight
-- mode to 0. This highlights the wireframe presentation
-- aTypeOfPresentation3d.
-- Top_AllView deactivates hidden line removal.
Type(me) returns KindOfInteractive from AIS
is redefined virtual;
---Purpose: Returns KOI_Object
Signature(me) returns Integer from Standard
is redefined virtual;
---Purpose: Returns 1
Connect(me : mutable;
anotherIObj : InteractiveObject from AIS) is virtual;
---Purpose: Establishes the connection between the Connected
-- Interactive Object, anotherIobj, and its reference
-- entity. If a previous connection with an Interactive
-- Object already exists, it is removed by Disconnect.
-- The second syntax also initiates the location of the
-- Connected Interactive Object.
Connect(me:mutable;
anotherIobj: InteractiveObject from AIS;
aLocation : Location from TopLoc) is virtual;
---Purpose:
HasConnection(me) returns Boolean from Standard;
---C++: inline
---Purpose:
-- Returns true if there is a connection established
-- between the presentation and its source reference.
ConnectedTo(me) returns any InteractiveObject from AIS;
---C++: inline
---C++: return const&
---Purpose:
-- Returns the connection with the reference Interactive Object.
Disconnect(me:mutable);
---Purpose: Clears the connection with a source reference. The
-- presentation will no longer be displayed.
-- Warning Must be done before deleting the presentation.
Compute(me : mutable;
aPresentationManager : PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard = 0)
---Level: Public
---Purpose: Calculates the view aPresentation and its updates.
-- The latter are managed by aPresentationManager.
-- The display mode aMode is 0 by default.
-- this method is redefined virtual;
-- when the instance is connected to another
-- InteractiveObject,this method doesn't
-- compute anything, but just uses the
-- presentation of this last object, with
-- a transformation if there's one stored.
is redefined virtual private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: Computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
---Level: Internal
---Purpose: this method should fill the presentation according to the
-- enumerated mode of the application and to the display parameter
-- of the application.
raises NotImplemented from Standard
is redefined;
ComputeSelection(me:mutable; aSelection :mutable Selection from SelectMgr;
aMode : Integer) is redefined virtual private;
---Level: Public
---Purpose: Recovers and calculates any sensitive primitive,
-- aSelection, available in Shape mode, specified by
-- aMode. As a rule, these are sensitive faces.
-- This method is defined as virtual. This enables you to
-- implement it in the creation of a new class of
-- Interactive Object. You need to do this and in so
-- doing, redefine this method, if you create a class
-- which enriches the list of signatures and types.
AcceptShapeDecomposition(me) returns Boolean from Standard is
redefined virtual;
---C++: inline
UpdateLocation(me:mutable) is redefined virtual;
UpdateLocation(me:mutable;aSel:Selection from SelectMgr) is redefined virtual;
---Purpose: For this class, the location effect is treated in the
-- compute & computeSelection methods. So the
-- UpdateLocation Methods are redefined to do nothing else
-- UpdateLocation(me:mutable;P : mutable Presentation from Prs3d) is redefined virtual;
fields
myReference : InteractiveObject from AIS is protected;
---Purpose: To have the time to Disconnect below, the old is kept for a while.
myOldReference : InteractiveObject from AIS is protected;
end ConnectedInteractive;

View File

@@ -0,0 +1,189 @@
// File: AIS_ConnectedInteractive.cxx
// Created: Wed Jan 8 15:24:35 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
#include <Standard_NotImplemented.hxx>
#include <AIS_ConnectedInteractive.ixx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <Geom_Transformation.hxx>
#include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_Presentation3d.hxx>
#include <OSD_Timer.hxx>
//=======================================================================
//function : AIS_ConnectedInteractive
//purpose :
//=======================================================================
AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
AIS_InteractiveObject(aTypeOfPresentation3d)
{
SetHilightMode(0);
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const
{return AIS_KOI_Object;}
Standard_Integer AIS_ConnectedInteractive::Signature() const
{return 0; }
//=======================================================================
//function : Connect
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::
Connect(const Handle(AIS_InteractiveObject)& anotherIObj)
{
// Pour Avoir le temps de faire le Disconnect en dessous,
// on garde l'ancien un peu. SMO.
if(myReference==anotherIObj) return;
myOldReference = myReference;
//Disconnect();
myReference = anotherIObj ;
}
//=======================================================================
//function : Connect
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::
Connect(const Handle(AIS_InteractiveObject)& anotherIobj,
const TopLoc_Location& aLocation)
{
if(myLocation!=aLocation)
myLocation = aLocation;
if(myReference!=anotherIobj) {
myOldReference = myReference; // necessaire pour pouvoir faire le disconnect en dessous..
// Disconnect();
myReference = anotherIobj;}
}
//=======================================================================
//function : Disconnect
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::Disconnect()
{
for(Standard_Integer i =1;i<=myPresentations.Length();i++)
{
Handle(PrsMgr_Presentation3d) P = Handle(PrsMgr_Presentation3d)::DownCast(myPresentations(i).Presentation());
if(!P.IsNull()) {
P->Presentation()->DisconnectAll(Graphic3d_TOC_DESCENDANT);
}
}
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::
Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer aMode)
{
static Handle(Geom_Transformation) myPrsTrans ;
if(!(HasLocation() ||HasConnection())) return;
if(HasConnection()){
aPresentation->Clear(Standard_False);
aPresentation->RemoveAll();
aPresentationManager->Connect( this,myReference, aMode, aMode);
if(aPresentationManager->Presentation(myReference,aMode)->MustBeUpdated())
aPresentationManager->Update(myReference,aMode);
}
if(HasLocation()){
myPrsTrans = new Geom_Transformation(myLocation.Transformation());
aPresentationManager->Transform(this, myPrsTrans, aMode); }
aPresentation->ReCompute();
}
void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
void AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d, const Handle_Graphic2d_GraphicObject& aGraphicObject, const int anInteger)
{
// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)");
PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
const Standard_Integer aMode)
{
if(!(HasLocation() ||HasConnection())) return;
aSel->Clear();
if(!myReference->HasSelection(aMode))
myReference->UpdateSelection(aMode);
// static OSD_Timer KronSel;
// cout<<"debut calcul connexion primitives pour le mode "<<aMode<<endl;
// KronSel.Reset();
// KronSel.Start();
const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(aMode);
Handle(SelectMgr_EntityOwner) OWN = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveEntity) SE3D,SNew;
if(TheRefSel->IsEmpty())
myReference->UpdateSelection(aMode);
for(TheRefSel->Init();TheRefSel->More();TheRefSel->Next()){
SE3D = *((Handle(Select3D_SensitiveEntity)*) &(TheRefSel->Sensitive()));
if(!SE3D.IsNull()){
SNew = SE3D->GetConnected(myLocation);
if(aMode==0)
SNew->Set(OWN);
aSel->Add(SNew);
}
}
// KronSel.Stop();
// cout<<"fin calcul connexion primitives pour le mode "<<aMode<<endl;
// KronSel.Show();
}
void AIS_ConnectedInteractive::UpdateLocation()
{
// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation()");
SelectMgr_SelectableObject::UpdateLocation() ;
}
void AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)
{
// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)");
SelectMgr_SelectableObject::UpdateLocation(Sel) ;
}
/*void AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation&)");
SelectMgr_SelectableObject::UpdateLocation(aPresentation) ;
}*/

View File

@@ -0,0 +1,15 @@
// File: AIS_ConnectedInteractive.lxx
// Created: Wed Jan 8 15:25:08 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
inline const Handle(AIS_InteractiveObject)& AIS_ConnectedInteractive::ConnectedTo() const
{return myReference;}
inline Standard_Boolean AIS_ConnectedInteractive::HasConnection() const
{return !myReference.IsNull();}
inline Standard_Boolean AIS_ConnectedInteractive::AcceptShapeDecomposition() const
{return myReference.IsNull()? Standard_False : myReference->AcceptShapeDecomposition();}

162
src/AIS/AIS_ConnectedShape.cdl Executable file
View File

@@ -0,0 +1,162 @@
-- File: AIS_ConnectedShape.cdl
-- Created: Wed Jan 8 17:57:55 1997
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
--Modified by rob on Jul-28-97
---Copyright: Matra Datavision 1997
class ConnectedShape from AIS inherits ConnectedInteractive from AIS
---Purpose: Constructs a Connected Interactive Object with an
-- AIS_Shape presentation as its reference Interactive Object.
-- In topological decomposition of the shape, this class
-- assigns the same owners to the sensitive primitives
-- as those in AIS_Shape. Like AIS_Shape, it allows a
-- presentation of hidden parts. These are calculated
-- automatically from the shape of its reference entity.
uses
Shape from TopoDS,
Projector from Prs3d,
Presentation from Prs3d,
Selection from SelectMgr,
Integer from Standard,
Shape from AIS,
TypeOfPresentation3d from PrsMgr,
GraphicObject from Graphic2d,
PresentationManager3d from PrsMgr,
PresentationManager2d from PrsMgr,
InteractiveObject from AIS,
KindOfInteractive from AIS,
Location from TopLoc,
Transformation from Geom
raises
NotImplemented from Standard
is
Create (aTypeOfPresentation : TypeOfPresentation3d from PrsMgr
=PrsMgr_TOP_ProjectorDependant)
returns mutable ConnectedShape from AIS;
---Purpose: Initializes the type of 3d presentation aTypeOfPresentation
Create (aInteractiveShape : Shape from AIS;
aTypeOfPresentation : TypeOfPresentation3d from PrsMgr
=PrsMgr_TOP_ProjectorDependant)
returns mutable ConnectedShape from AIS;
---Purpose: Initializes the entity aInteractiveShape and the type of 3d presentation aTypeOfPresentation.
Create(aConnectedShape : ConnectedShape from AIS;
aTypeOfPresentation : TypeOfPresentation3d from PrsMgr
=PrsMgr_TOP_ProjectorDependant)
returns mutable ConnectedShape from AIS;
---Purpose: Initializes the entity aConnectedShape and the type of 3d presentation aTypeOfPresentation.
---Category: Redefined methods...
Type(me) returns KindOfInteractive from AIS
is redefined virtual;
Signature(me) returns Integer from Standard
is redefined virtual;
AcceptShapeDecomposition(me)
returns Boolean from Standard is redefined;
Connect(me : mutable;
anotherIObj : InteractiveObject from AIS) is redefined ;
---Purpose: Establishes the connection between the Connected
-- Interactive Object, anotherIobj, and its reference
-- entity. If there is already a previous connection with
-- an Interactive Object, this connection is removed.
Connect(me:mutable;
anotherIobj: InteractiveObject from AIS;
aLocation : Location from TopLoc) is redefined;
---Purpose: Establishes the connection between the Connected
-- Interactive Object, anotherIobj, and its reference
-- entity. If there is already a previous connection with
-- an Interactive Object, this connection is removed.
-- This syntax also initiates the location of the Connected Interactive Object.
Compute(me:mutable;
aProjector : Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined virtual private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined virtual private;
Compute(me : mutable;
aPresentationManager : PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard = 0)
---Level: Public
---Purpose: this method is redefined virtual;
-- when the instance is connected to another
-- InteractiveObject,this method doesn't
-- compute anything, but just uses the
-- presentation of this last object, with
-- a transformation if there's one stored.
is redefined;
ComputeSelection(me:mutable; aSelection :mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined virtual private;
---Purpose:
-- Recovers and calculates any sensitive primitive,
-- aSelection, available in Shape mode, specified by
-- aMode . As a rule, these are sensitive faces.
-- This method is defined as virtual. This enables you to
-- implement it in the creation of a new class of
-- Interactive Object. You need to do this and in so
-- doing, redefine this method, if you create a class
-- which enriches the list of signatures and types.
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
---Level: Internal
---Purpose: this method should fill the presentation according to the
-- enumerated mode of the application and to the display parameter
-- of the application.
raises NotImplemented from Standard
is redefined;
Shape(me:mutable) returns Shape from TopoDS;
---C++: return const&
---Purpose: Returns the topological shape which is the reference
-- for the connected shape. Sets hilight mode to index
-- 0. This returns a wireframe presentation.
UpdateShape(me:mutable;WithLocation:Boolean from Standard = Standard_True)
is static private;
Compute(me:mutable;
aProjector : Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d;
aShape : Shape from TopoDS)
is private;
fields
myOwnSh : Shape from TopoDS; -- used for HLR and selection...
end ConnectedShape;

344
src/AIS/AIS_ConnectedShape.cxx Executable file
View File

@@ -0,0 +1,344 @@
// File: AIS_ConnectedShape.cxx
// Created: Wed Apr 10 16:40:43 1996
// Author: Guest Design
// <g_design>
#include <Standard_NotImplemented.hxx>
#include <AIS_ConnectedShape.ixx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Drawer.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <StdPrs_WFDeflectionShape.hxx>
#include <StdPrs_HLRPolyShape.hxx>
#include <Prs3d_Drawer.hxx>
#include <Aspect_TypeOfDeflection.hxx>
#include <BRepTools.hxx>
#include <OSD_Timer.hxx>
#include <StdSelect_BRepSelectionTool.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <StdSelect.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <AIS_MultipleConnectedShape.hxx>
#include <Precision.hxx>
//=======================================================================
//function : AIS_ConnectedShape
//purpose :
//=======================================================================
AIS_ConnectedShape::AIS_ConnectedShape (const Handle(AIS_Shape)& TheAISShape,
const PrsMgr_TypeOfPresentation3d TheType):
AIS_ConnectedInteractive(TheType)
{
myReference = TheAISShape;
}
AIS_ConnectedShape::AIS_ConnectedShape (const Handle(AIS_ConnectedShape)& TheConnectedShape,
const PrsMgr_TypeOfPresentation3d TheType):
AIS_ConnectedInteractive(TheType)
{
myReference = TheConnectedShape;
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
AIS_KindOfInteractive AIS_ConnectedShape::Type() const
{return AIS_KOI_Shape;}
//=======================================================================
//function : Signature
//purpose :
//=======================================================================
Standard_Integer AIS_ConnectedShape::Signature() const
{return 1;}
//=======================================================================
//function : AcceptShapeDecomposition
//purpose :
//=======================================================================
Standard_Boolean AIS_ConnectedShape::AcceptShapeDecomposition() const
{return Standard_True;}
//=======================================================================
//function : Compute Hidden Lines
//purpose :
//=======================================================================
void AIS_ConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation)
{
UpdateShape(Standard_True);
Compute(aProjector,aPresentation,myOwnSh);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Geom_Transformation)& TheTrsf,
const Handle(Prs3d_Presentation)& aPresentation)
{
UpdateShape(Standard_False);
const TopLoc_Location& loc = myOwnSh.Location();
TopoDS_Shape shbis = myOwnSh.Located(TopLoc_Location(TheTrsf->Trsf())*loc);
Compute(aProjector,aPresentation,shbis);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation,
const TopoDS_Shape& SH)
{
// Standard_Boolean recompute = Standard_False;
// Standard_Boolean myFirstCompute = Standard_True;
switch (SH.ShapeType()){
case TopAbs_VERTEX:
case TopAbs_EDGE:
case TopAbs_WIRE:
{
aPresentation->SetDisplayPriority(4);
StdPrs_WFDeflectionShape::Add(aPresentation,SH,myDrawer);
break;
}
default:
{
Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
if (defdrawer->DrawHiddenLine())
{myDrawer->EnableDrawHiddenLine();}
else {myDrawer->DisableDrawHiddenLine();}
Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
// traitement HLRAngle et HLRDeviationCoefficient()
Standard_Real prevangl = myDrawer->HLRAngle();
Standard_Real newangl = defdrawer->HLRAngle();
if (Abs(newangl- prevangl) > Precision::Angular()) {
#ifdef DEB
cout << "AIS_MultipleConnectedShape : compute"<<endl;
cout << "newangl : " << newangl << " # de " << "prevangl : " << prevangl << endl;
#endif
BRepTools::Clean(SH);
}
myDrawer->SetHLRAngle(newangl);
myDrawer->SetHLRDeviationCoefficient(defdrawer->HLRDeviationCoefficient());
StdPrs_HLRPolyShape::Add(aPresentation,SH,myDrawer,aProjector);
defdrawer->SetTypeOfDeflection (prevdef);
}
}
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d,
const Handle_Graphic2d_GraphicObject& aGraphicObject,
const int anInteger)
{
// Standard_NotImplemented::Raise("AIS_ConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)");
AIS_ConnectedInteractive::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ConnectedShape::Compute(const Handle_PrsMgr_PresentationManager3d& /*aPresentationManager3d*/,
const Handle_Prs3d_Presentation& /*aPresentation*/,
const int /*anInteger*/)
{
Standard_NotImplemented::Raise("AIS_ConnectedShape::Compute(const Handle_PrsMgr_PresentationManager3d&, const Handle_Prs3d_Presentation&, const int)");
// AIS_ConnectedInteractive::Compute( aPresentationManager3d ,aPresentation,anInteger) ; not accessible
}
//=======================================================================
//function : ComputeSelection
//purpose : Attention fragile...
//=======================================================================
void AIS_ConnectedShape::ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
{
UpdateShape();
aSelection->Clear();
// On regarde s'il n'y a pas des choses a faire sur la reference,
// du type mise a jour...
if(!myReference->HasSelection(aMode))
myReference->UpdateSelection(aMode);
const Handle(SelectMgr_Selection)& RefSel = myReference->Selection(aMode);
if(RefSel->IsEmpty())
myReference->UpdateSelection(aMode);
if(RefSel->UpdateStatus()==SelectMgr_TOU_Full)
myReference->UpdateSelection(aMode);
//suivant le type de decomposition, on deduit les primitives connectees.
// il faut suivre l'ordre de creation de StdSelect_BRepSelectionTool...
TopAbs_ShapeEnum TheType = AIS_Shape::SelectionType(aMode);
Handle(StdSelect_BRepOwner) OWNR;
Handle(Select3D_SensitiveEntity) SE,NiouSE;
TopLoc_Location BidLoc;
switch(TheType){
case TopAbs_VERTEX:
case TopAbs_EDGE:
case TopAbs_WIRE:
case TopAbs_FACE:
case TopAbs_SHELL:
{
TopTools_IndexedMapOfShape subshaps;
TopExp::MapShapes(myOwnSh,TheType,subshaps);
RefSel->Init();
for(Standard_Integer I=1;
I<=subshaps.Extent()&& RefSel->More();
RefSel->Next(),I++){
SE = *((Handle(Select3D_SensitiveEntity)*) &(RefSel->Sensitive()));
if(!SE.IsNull()){
OWNR = new StdSelect_BRepOwner(subshaps(I),this,SE->OwnerId()->Priority());
if(myLocation.IsIdentity())
NiouSE = SE->GetConnected(BidLoc);
else
NiouSE = SE->GetConnected(myLocation);
NiouSE->Set(OWNR);
aSelection->Add(NiouSE);
}
}
break;
}
case TopAbs_SHAPE:
default:
{
// Dans ce cas on n'a qu'un seul proprietaire pour l'ensemble des
// primitives sensibles...
OWNR = new StdSelect_BRepOwner(myOwnSh,this);
Standard_Boolean FirstIncr(Standard_True);
for(RefSel->Init();RefSel->More();RefSel->Next()){
SE = *((Handle(Select3D_SensitiveEntity)*) &(RefSel->Sensitive()));
if(FirstIncr){
Standard_Integer Prior = SE->OwnerId()->Priority();
Handle(SelectBasics_EntityOwner)::DownCast(OWNR)->Set(Prior);
FirstIncr = Standard_False;}
if(myLocation.IsIdentity())
NiouSE = SE->GetConnected(BidLoc);
else
NiouSE = SE->GetConnected(myLocation);
NiouSE->Set(OWNR);
aSelection->Add(NiouSE);
}
break;
}
}
StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape& AIS_ConnectedShape::Shape()
{
UpdateShape();
return myOwnSh;
}
AIS_ConnectedShape::AIS_ConnectedShape(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
AIS_ConnectedInteractive(aTypeOfPresentation3d)
{
SetHilightMode(0);
}
//=======================================================================
//function : UpdateShape
//purpose : if<WithLocation=False> computes only the deducted shape
// from reference; does not put "myLocation"
//=======================================================================
void AIS_ConnectedShape::UpdateShape(const Standard_Boolean WithTheLocation)
{
if(myReference.IsNull()) return;
// attention grosse ligne...
if(myReference->Type()!=AIS_KOI_Shape) return;
Standard_Integer Sig = myReference->Signature();
TopoDS_Shape S ;
switch(Sig){
case 0:
S = (*((Handle(AIS_Shape)*) &myReference))->Shape();
break;
case 1:
S = (*((Handle(AIS_ConnectedShape)*) &myReference))->Shape();
break;
case 2:
S=(*((Handle(AIS_MultipleConnectedShape)*) &myReference))->Shape();
break;
default:
S = myOwnSh;
}
if(S.IsNull()) return;
if(myLocation.IsIdentity() || !WithTheLocation)
myOwnSh = S;
else
myOwnSh = S.Moved(myLocation);
}
//=======================================================================
//function : Connect
//purpose :
//=======================================================================
void AIS_ConnectedShape::
Connect(const Handle(AIS_InteractiveObject)& anotherIObj)
{
if(anotherIObj->Type()== AIS_KOI_Shape){
Standard_Integer Sig = anotherIObj->Signature();
if(Sig <=2)
AIS_ConnectedInteractive::Connect(anotherIObj);
}
}
//=======================================================================
//function : Connect
//purpose :
//=======================================================================
void AIS_ConnectedShape::
Connect(const Handle(AIS_InteractiveObject)& anotherIObj,
const TopLoc_Location& aLocation)
{
if(anotherIObj->Type()== AIS_KOI_Shape){
Standard_Integer Sig = anotherIObj->Signature();
if(Sig <=2)
AIS_ConnectedInteractive::Connect(anotherIObj,aLocation);
}
}

185
src/AIS/AIS_DiameterDimension.cdl Executable file
View File

@@ -0,0 +1,185 @@
-- File: AIS_DiameterDimension.cdl
-- Created: Thu Dec 5 09:10:24 1996
-- Modified Mon 12-january-98
-- Author: Jacques MINOT/Odile Olivier/Serguei ZARITCHNY
-- <odl@sacadox.paris1.matra-dtv.fr>,
-- <szy@orthodox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class DiameterDimension from AIS inherits Relation from AIS
---Purpose: A framework to display diameter dimensions.
-- A diameter is displayed with arrows and text. The
-- text gives the length of the diameter.
-- The algorithm takes a length along a face and
-- analyzes it as an arc. It then reconstructs the circle
-- corresponding to the arc and calculates the
-- diameter of this circle. This diameter serves as a
-- relational reference in 3d presentations of the surface.
uses
Shape from TopoDS,
Circ from gp,
Pnt from gp,
Pln from gp,
Plane from Geom,
Surface from Geom,
Presentation from Prs3d,
PresentationManager3d from PrsMgr,
Selection from SelectMgr,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
ExtendedString from TCollection,
ArrowSide from DsgPrs,
KindOfSurface from AIS,
KindOfDimension from AIS
raises ConstructionError from Standard
is
Create (aShape : Shape from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
---Purpose: Constructs a diameter display object defined by the
-- shape aFShape, the dimension aVal and the text aText.
returns mutable DiameterDimension from AIS;
Create (aShape : Shape from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
aDiamSymbol : Boolean from Standard;
anArrowSize : Real from Standard = 0.0)
---Purpose: Constructs a diameter display object defined by the
-- shape aFShape, the dimension aVal and the text
-- aText, the point of origin of the diameter aPosition,
-- and the type of arrow aSymbolPrs with the size anArrowSize.
-- If the Boolean aDiamSymbol is true.
returns mutable DiameterDimension from AIS;
KindOfDimension(me) returns KindOfDimension from AIS
---C++: inline
---Purpose:
-- Indicates that we are concerned with a length.
is redefined;
IsMovable(me) returns Boolean from Standard
---C++: inline
---Purpose:
-- Returns true if the diameter dimension is movable
is redefined;
DiamSymbol(me: mutable) returns Boolean from Standard
---C++: inline
---Purpose:
-- Returns the symbol for diameter dimension. This will
-- be either arrow, text, or a combination of both.
is static;
SetDiamSymbol(me: mutable;aDiamSymbol: Boolean from Standard)
---C++: inline
---Purpose:
-- Sets the symbol for diameter dimension aDiamSymbol.
-- This can be an arrow, a text or both.
is static;
-- SetPlane(me: mutable; aPlane : Plane from Geom)
-- is static;
-- ---C++: inline
-- Plane(me) returns any Plane from Geom
-- is static;
-- ---C++: inline
-- ---C++: return const &
-- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
--
-- Computation private methods
--
ComputeOneFaceDiameter(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeOneCylFaceDiameter(me: mutable;
aPresentation : mutable Presentation from Prs3d;
aSurfType : KindOfSurface from AIS;
aSurf : Surface from Geom )
is private;
ComputeOnePlanarFaceDiameter(me: mutable;
aPresentation : mutable Presentation from Prs3d )
is private;
ComputeOneEdgeDiameter(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeCircleDiameter(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeArcDiameter(me: mutable;
aPresentation : mutable Presentation from Prs3d;
ptFirst : Pnt from gp;
ptend : Pnt from gp)
is private;
ComputeArcSelection(me : mutable;
aSelection : mutable Selection from SelectMgr)
is private;
fields
myCircle : Circ from gp;
myIsAnArc : Boolean from Standard;
myDiamSymbol : Boolean from Standard;
myFirstPar : Real from Standard;
myLastPar : Real from Standard;
end DiameterDimension;

720
src/AIS/AIS_DiameterDimension.cxx Executable file
View File

@@ -0,0 +1,720 @@
// File: AIS_DiameterDimension.cdl
// Created: Tue Dec 5 15:09:04 1996
// Modified Mon 12-january-98
// Author: Jacques MINOT/Odile Olivier/Sergey ZARITCHNY
// <ODL>, <SZY>
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
// if any in all dimensions.
#include <Standard_NotImplemented.hxx>
#include <AIS_DiameterDimension.ixx>
#include <AIS_DimensionOwner.hxx>
#include <DsgPrs_DiameterPresentation.hxx>
#include <DsgPrs_RadiusPresentation.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Prs3d_LengthAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_Text.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <TopoDS.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Adaptor3d_HCurve.hxx>
#include <Geom_Circle.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
#include <GC_MakeCircle.hxx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_DiameterDimension::AIS_DiameterDimension(const TopoDS_Shape& aShape,
const Standard_Real aVal,
const TCollection_ExtendedString& aText)
:AIS_Relation(),
myDiamSymbol(Standard_True)
{
myPosition = gp_Pnt(0.,0.,0.);
myFShape = aShape;
myVal = aVal;
myText = aText;
mySymbolPrs = DsgPrs_AS_LASTAR;
myAutomaticPosition = Standard_True;
myArrowSize = myVal / 100.;
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_DiameterDimension::AIS_DiameterDimension(const TopoDS_Shape& aShape,
const Standard_Real aVal,
const TCollection_ExtendedString& aText,
const gp_Pnt& aPosition,
const DsgPrs_ArrowSide aSymbolPrs,
const Standard_Boolean aDiamSymbol,
const Standard_Real anArrowSize)
:AIS_Relation(),
myDiamSymbol(aDiamSymbol)
{
myFShape = aShape;
myVal = aVal;
myText = aText;
mySymbolPrs = aSymbolPrs;
myPosition = aPosition;
myAutomaticPosition = Standard_False;
#ifdef BUC60915
SetArrowSize( anArrowSize );
#else
myArrowSize = anArrowSize;
#endif
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_DiameterDimension::Compute(
const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer /*aMode*/)
{
aPresentation->Clear();
switch (myFShape.ShapeType()) {
case TopAbs_FACE :
{
// compute one face case
ComputeOneFaceDiameter (aPresentation);
break;
}
case TopAbs_EDGE:
{
ComputeOneEdgeDiameter (aPresentation);
break;
}
default:
break;
}
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_DiameterDimension::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_DiameterDimension::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation)");
PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_DiameterDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager,
const Handle(Graphic2d_GraphicObject)& aPresentation,
const Standard_Integer aMode)
{
// Standard_NotImplemented::Raise("AIS_DiameterDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, const Handle(Graphic2d_GraphicObject)& aPresentation, const Standard_Integer aMode)");
PrsMgr_PresentableObject::Compute( aPresentationManager ,aPresentation,aMode) ;
}
void AIS_DiameterDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_DiameterDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_DiameterDimension::ComputeSelection(
const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer /*aMode*/)
{
Handle(AIS_DimensionOwner) own = new AIS_DimensionOwner(this,7);
own->SetShape(myFShape);
if (!myIsAnArc) {
gp_Pnt AttachmentPoint = myPosition;
Standard_Real parat = ElCLib::Parameter(myCircle,AttachmentPoint);
gp_Pnt ptoncirc = ElCLib::Value (parat,myCircle);
// ligne de cote
gp_Pnt center = myCircle.Location();
gp_Vec vecrap (ptoncirc,center);
Standard_Real dist = center.Distance(AttachmentPoint);
Standard_Real aRadius = myCircle.Radius();
Standard_Real inside = Standard_False;
gp_Pnt pt1 = AttachmentPoint;
if (dist < aRadius) {
pt1 = ptoncirc;
dist = aRadius;
inside = Standard_True;
}
vecrap.Normalize();
vecrap *= (dist+aRadius);
gp_Pnt OppositePoint = pt1.Translated(vecrap);
if ( pt1.Distance(OppositePoint)>=Precision::Confusion()) {
Handle(Select3D_SensitiveSegment)
seg = new Select3D_SensitiveSegment(own,pt1 ,OppositePoint);
aSelection->Add(seg);
}
}
else
ComputeArcSelection(aSelection);
// Text
Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
myPosition.X(),
myPosition.Y(),
myPosition.Z(),
myPosition.X() + size,
myPosition.Y() + size,
myPosition.Z() + size);
aSelection->Add(box);
}
//==========================================================================
// function : ComputeArcSelection
// purpose :
//
//==========================================================================
void AIS_DiameterDimension::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection)
{
Standard_Real fpara;
Standard_Real lpara;
fpara = myFirstPar;
lpara = myLastPar;
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
gp_Pnt theCenter = myCircle.Location();
while (lpara > 2*PI) {
fpara -= 2*PI;
lpara -= 2*PI;
}
Standard_Real parat = ElCLib::Parameter(myCircle,myPosition);
Standard_Boolean otherside(Standard_False);
gp_Pnt attpoint = myPosition;
if (!AIS::InDomain(fpara,lpara,parat)) {
Standard_Real otherpar = parat + PI;
if (otherpar > 2*PI) otherpar -= 2*PI;
if (AIS::InDomain(fpara,lpara,otherpar)) {
parat = otherpar;
otherside = Standard_True;
}
else {
Standard_Real ecartpar = Min(Abs(fpara-parat),
Abs(lpara-parat));
Standard_Real ecartoth = Min(Abs(fpara-otherpar),
Abs(lpara-otherpar));
if (ecartpar <= ecartoth) {
if (parat < fpara) parat = fpara;
else parat = lpara;
}
else {
otherside = Standard_True;
if (otherpar < fpara) parat = fpara;
else parat = lpara;
}
gp_Pnt ptdir = ElCLib::Value(parat,myCircle);
gp_Lin lsup(theCenter,
gp_Dir(ptdir.XYZ()-theCenter.XYZ()));
Standard_Real parpos = ElCLib::Parameter(lsup,myPosition);
attpoint = ElCLib::Value(parpos,lsup);
}
}
gp_Pnt ptoncirc = ElCLib::Value(parat,myCircle);
gp_Lin L (theCenter,gp_Dir(attpoint.XYZ()-theCenter.XYZ()));
gp_Pnt firstpoint = attpoint;
gp_Pnt drawtopoint = ptoncirc;
if (!otherside) {
Standard_Real uatt = ElCLib::Parameter(L,attpoint);
Standard_Real uptc = ElCLib::Parameter(L,ptoncirc);
if (Abs(uatt) > Abs(uptc)) {
drawtopoint = theCenter;
}
else {
firstpoint = theCenter;
}
}
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(own,firstpoint,drawtopoint);
aSelection->Add(seg);
}
//=======================================================================
//function : ComputeOneFaceDiameter
//purpose :
//=======================================================================
void AIS_DiameterDimension::ComputeOneFaceDiameter(
const Handle(Prs3d_Presentation)& aPresentation)
{
//cout<<"AIS_DiameterDimension::ComputeOneFaceDiameter"<<endl;
gp_Pln aPln;
Handle( Geom_Surface ) aBasisSurf;
AIS_KindOfSurface aSurfType;
Standard_Real Offset;
if( myAutomaticPosition )
AIS::GetPlaneFromFace( TopoDS::Face( myFShape),
aPln,
aBasisSurf,
aSurfType,
Offset ) ;
if ( aSurfType == AIS_KOS_Plane )
ComputeOnePlanarFaceDiameter( aPresentation );
else
ComputeOneCylFaceDiameter( aPresentation, aSurfType, aBasisSurf );
}
//=======================================================================
//function : ComputeOneCylFaceDiameter
//purpose :
//=======================================================================
void AIS_DiameterDimension::ComputeOneCylFaceDiameter
(const Handle(Prs3d_Presentation)& aPresentation,
const AIS_KindOfSurface aSurfType,
const Handle( Geom_Surface )& aBasisSurf )
{
gp_Pnt curPos;
if( myAutomaticPosition )
{
BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
Standard_Real uFirst, uLast, vFirst, vLast;
uFirst = surf1.FirstUParameter();
uLast = surf1.LastUParameter();
vFirst = surf1.FirstVParameter();
vLast = surf1.LastVParameter();
Standard_Real uMid = (uFirst + uLast)*0.5;
Standard_Real vMid = (vFirst + vLast)*0.5;
surf1.D0(uMid, vMid, curPos);
Handle( Adaptor3d_HCurve ) BasisCurve;
//Standard_Real Param;
Standard_Boolean ExpectedType = Standard_False;
if (aSurfType == AIS_KOS_Cylinder)
{
ExpectedType = Standard_True;
}
else
if (aSurfType == AIS_KOS_Revolution)
{
BasisCurve = surf1.BasisCurve();
if (BasisCurve->GetType() == GeomAbs_Line)
ExpectedType = Standard_True;
}
else if (aSurfType == AIS_KOS_Extrusion)
{
BasisCurve = surf1.BasisCurve();
if ( BasisCurve->GetType() == GeomAbs_Circle )
ExpectedType = Standard_True;
}
if(!ExpectedType) {
Standard_ConstructionError::Raise("AIS:: Not expected type of surface") ;
return;
}
//
Handle(Geom_Curve) aCurve;
aCurve = aBasisSurf->VIso(vMid);
if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Circle))
{
myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ();//gp_Circ
}
else if (aCurve->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) {
Handle(Geom_TrimmedCurve) tCurve = Handle(Geom_TrimmedCurve)::DownCast(aCurve);
aCurve = tCurve->BasisCurve();
uFirst = tCurve->FirstParameter();
uLast = tCurve->LastParameter();
if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Circle))
myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ();//gp_Circ
}
else {
// compute a circle from 3 points on "aCurve"
gp_Pnt P1, P2;
surf1.D0(uFirst, vMid, P1);
surf1.D0(uLast, vMid, P2);
GC_MakeCircle mkCirc(P1, curPos, P2);
myCircle = mkCirc.Value()->Circ();
}
myCircle.SetRadius(myVal/2.);
myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position())));//gp_Circ
gp_Vec v1(myCircle.Location(), curPos);
v1.Normalize();
v1 = v1 * myVal*1.2;
myPosition = myCircle.Location().Translated(v1);
// IsArc ?
gp_Pnt p1, p2;
p1 = ElCLib::Value (uFirst, myCircle);
p2 = ElCLib::Value (uLast, myCircle);
if ( p1.IsEqual(p2, Precision::Confusion()) )
myIsAnArc = Standard_False;
else myIsAnArc = Standard_True;
myFirstPar = uFirst;
myLastPar = uLast;
// myPosition = curPos;
myAutomaticPosition = Standard_True;
if ( myIsSetBndBox )
myPosition = AIS::TranslatePointToBound( myPosition, gp_Dir( gp_Vec( myCircle.Location(),
myPosition ) ), myBndBox );
}
else { // !AutomaticPosition
curPos = myPosition;
curPos = AIS::ProjectPointOnPlane( curPos, myPlane->Pln() );
myPosition = curPos;
}
Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
// size
#ifdef BUC60915
if( !myArrowSizeIsDefined ) {
myArrowSize = Min(myArrowSize,myCircle.Radius()/5.);
}
arr->SetLength(myArrowSize);
#else
if (myCircle.Radius()/5. > myArrowSize) {
arr->SetLength(myArrowSize);
}
else {
arr->SetLength(myCircle.Radius()/5.);
}
#endif
//cout<<"AIS_DiameterDimension:: add Prs"<<endl;
if( myIsAnArc )
DsgPrs_DiameterPresentation::Add(aPresentation, myDrawer, myText, myPosition,
myCircle, myFirstPar, myLastPar, mySymbolPrs, myDiamSymbol);
else
DsgPrs_DiameterPresentation::Add(aPresentation, myDrawer, myText, myPosition,
myCircle, DsgPrs_AS_BOTHAR, myDiamSymbol);
}
//=======================================================================
//function : ComputeCircleDiameter
//purpose :
//=======================================================================
void AIS_DiameterDimension::ComputeCircleDiameter(const Handle(Prs3d_Presentation)& aPresentation)
{
gp_Pnt center = myCircle.Location();
Standard_Real rad = myCircle.Radius();
gp_Pnt curpos;
if (myAutomaticPosition) {
// we compute 1 point on the circle
myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position())));//gp_Circ
gp_Dir xdir = myCircle.XAxis().Direction();
Standard_Real deport = rad *1.2;
curpos = center.Translated( gp_Vec(xdir)*deport );
SetPosition (curpos);// myPosition = curpos
myAutomaticPosition = Standard_True;
if (myIsSetBndBox)
myPosition = AIS::TranslatePointToBound( myPosition, gp_Dir( gp_Vec( myCircle.Location(),
myPosition ) ), myBndBox );
}
else {
curpos = myPosition;
// VRO (2007-05-17) inserted this IF.
if (myPlane.IsNull())
myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position())));
myPosition = AIS::ProjectPointOnPlane( curpos, myPlane->Pln() );
}
// size
Handle(Prs3d_LengthAspect) LA = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = LA->Arrow1Aspect();
#ifdef BUC60915
if( !myArrowSizeIsDefined ) {
myArrowSize = Min(myArrowSize,myCircle.Radius()/5.);
}
arr->SetLength(myArrowSize);
#else
if (myCircle.Radius()/5. > myArrowSize) {
arr->SetLength(myArrowSize);
}
else {
arr->SetLength(myCircle.Radius()/5.);
}
#endif
DsgPrs_DiameterPresentation::Add(aPresentation, myDrawer, myText, myPosition, myCircle,
DsgPrs_AS_BOTHAR, myDiamSymbol );
}
//==========================================================================
// function : ComputeArcDiameter
// purpose :
//
//==========================================================================
void AIS_DiameterDimension::ComputeArcDiameter(
const Handle(Prs3d_Presentation)& aPresentation,
const gp_Pnt& pfirst,
const gp_Pnt& pend)
{
gp_Pnt center = myCircle.Location();
Standard_Real rad = myCircle.Radius();
gp_Pnt curpos;
Standard_Real parfirst, parend;
parfirst = ElCLib::Parameter(myCircle, pfirst);
parend = ElCLib::Parameter(myCircle, pend);
myFirstPar = parfirst;
myLastPar = parend;
if ( parfirst > parend) {
parfirst -= 2*PI;
}
if (myAutomaticPosition) {
Standard_Real pcurpos = (parfirst + parend)/2.;
curpos = ElCLib::Value(pcurpos, myCircle);
myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position())));//gp_Circ
gp_Dir vdir(gp_Vec(myCircle.Location(),curpos));
Standard_Real deport = rad * 1.2;
curpos = center.Translated( gp_Vec(vdir)*deport );
SetPosition (curpos);
myAutomaticPosition = Standard_True;
if ( myIsSetBndBox )
myPosition = AIS::TranslatePointToBound( myPosition, gp_Dir( gp_Vec( myCircle.Location(),
myPosition ) ), myBndBox );
}
else {
curpos = myPosition;
myPosition = AIS::ProjectPointOnPlane( curpos, myPlane->Pln() );
}
// size
Handle(Prs3d_LengthAspect) LA = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = LA->Arrow1Aspect();
#ifdef BUC60915
if( !myArrowSizeIsDefined ) {
myArrowSize = Min(myArrowSize,myCircle.Radius()/5.);
}
arr->SetLength(myArrowSize);
#else
if (myCircle.Radius()/5. > myArrowSize) {
arr->SetLength(myArrowSize);
}
else {
arr->SetLength(myCircle.Radius()/5.);
}
#endif
// Display
DsgPrs_DiameterPresentation::Add (aPresentation, myDrawer, myText, myPosition, myCircle,
parfirst, parend, mySymbolPrs, myDiamSymbol);
}
//==========================================================================
// function : ComputeOneEdgeDiameter
// purpose :
//
//==========================================================================
void AIS_DiameterDimension::ComputeOneEdgeDiameter(const Handle(Prs3d_Presentation)& aPresentation)
{
gp_Pnt ptfirst,ptend;
Handle(Geom_Curve) curv;
if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),curv,ptfirst,ptend)) return;
Handle(Geom_Circle) circ = Handle(Geom_Circle)::DownCast(curv);
if ( circ.IsNull()) return;
myCircle = circ->Circ();
myCircle.SetRadius(myVal/2.);
if ( ptfirst.IsEqual(ptend, Precision::Confusion()) ) {
myIsAnArc = Standard_False;
ComputeCircleDiameter(aPresentation);
}
else {
myIsAnArc = Standard_True;
ComputeArcDiameter(aPresentation,ptfirst,ptend );
}
}
//===================================================================
//function : CircleFromPlanarFace
//purpose : if possible computes circle from planar face
//=======================================================================
static Standard_Boolean CircleFromPlanarFace(const TopoDS_Face& aFace,
Handle(Geom_Curve)& aCurve,
gp_Pnt & ptfirst, gp_Pnt & ptend)
{
TopExp_Explorer ExploEd( aFace, TopAbs_EDGE );
for ( ; ExploEd.More(); ExploEd.Next())
{
TopoDS_Edge curedge = TopoDS::Edge( ExploEd.Current() );
if (AIS::ComputeGeometry(curedge, aCurve, ptfirst, ptend))
if(aCurve->IsInstance(STANDARD_TYPE(Geom_Circle)) &&
!Handle(Geom_Circle)::DownCast(aCurve).IsNull())
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : ComputeOnePlanarFaceDiameter
//purpose :
//=======================================================================
void AIS_DiameterDimension::ComputeOnePlanarFaceDiameter(const Handle(Prs3d_Presentation)& aPresentation)
{
gp_Pnt curPos ;
#ifndef DEB
Standard_Real parfirst =0., parend =0.;
#else
Standard_Real parfirst, parend;
#endif
if (myAutomaticPosition) {
Handle(Geom_Curve) curv;
gp_Pnt ptfirst,ptend;
if( !CircleFromPlanarFace( TopoDS::Face( myFShape ), curv, ptfirst, ptend) ) {
Standard_ConstructionError::Raise("AIS:: Curve is not a circle or is Null") ;
return;
}
myCircle = Handle(Geom_Circle)::DownCast(curv)->Circ();
if ( ptfirst.IsEqual(ptend, Precision::Confusion()) )
myIsAnArc = Standard_False;
else
myIsAnArc = Standard_True;
myCircle.SetRadius(myVal/2.);//
BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape));
myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position())));//gp_Circ
gp_Pnt center = myCircle.Location();
Standard_Real rad = myCircle.Radius();
Standard_Real deport = rad * 1.2;
if(! myIsAnArc ) { // Circle
gp_Dir xdir = myCircle.XAxis().Direction();
curPos = center.Translated( gp_Vec(xdir)*deport );
}
else { // Arc
parfirst = ElCLib::Parameter(myCircle, ptfirst);
parend = ElCLib::Parameter(myCircle, ptend);
if ( parfirst > parend) {
parfirst -= 2*PI;
}
Standard_Real parcurPos = (parfirst + parend) * 0.5;
curPos = ElCLib::Value(parcurPos, myCircle);
gp_Vec v1( center, curPos );
v1.Normalize();
curPos = center.Translated( v1 * deport );
}
myFirstPar = parfirst;
myLastPar = parend;
myPosition = curPos;
myAutomaticPosition = Standard_True;
if ( myIsSetBndBox )
myPosition = AIS::TranslatePointToBound( myPosition, gp_Dir( gp_Vec( myCircle.Location(),
myPosition ) ), myBndBox );
} else
{
// !myAutomaticPosition
// Project point on the plane of face
curPos = myPosition;
curPos = AIS::ProjectPointOnPlane( curPos, myPlane->Pln() );
myPosition = curPos;
}
Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
// size
#ifdef BUC60915
if( !myArrowSizeIsDefined ) {
myArrowSize = Min(myArrowSize,myCircle.Radius()/5.);
}
arr->SetLength(myArrowSize);
#else
if (myCircle.Radius()/5. > myArrowSize) {
arr->SetLength(myArrowSize);
}
else {
arr->SetLength(myCircle.Radius()/5.);
}
#endif
if(! myIsAnArc )
DsgPrs_DiameterPresentation::Add(aPresentation, myDrawer, myText, myPosition,
myCircle, DsgPrs_AS_BOTHAR, myDiamSymbol);
else
DsgPrs_DiameterPresentation::Add(aPresentation, myDrawer, myText, myPosition,
myCircle, myFirstPar, myLastPar, mySymbolPrs, myDiamSymbol );
}

View File

@@ -0,0 +1,44 @@
// File: AIS_DiameterDimension.lxx
// Created: Fri Feb 28 10:14:18 1997
// Modified Mon 12-january-98
// Author: Jean-Pierre COMBE, Serguei ZARITCHNY
// <jpr> <szy>
//=======================================================================
//function : KindOfDimension
//purpose :
//=======================================================================
inline AIS_KindOfDimension AIS_DiameterDimension::KindOfDimension() const
{
return AIS_KOD_DIAMETER;
}
//=======================================================================
//function : IsMovable
//purpose :
//=======================================================================
inline Standard_Boolean AIS_DiameterDimension::IsMovable() const
{
return Standard_True;
}
//=======================================================================
//function : DiamSymbol
//purpose :
//=======================================================================
inline Standard_Boolean AIS_DiameterDimension::DiamSymbol()
{
return myDiamSymbol;
}
//=======================================================================
//function : SetDiamSymbol
//purpose :
//=======================================================================
inline void AIS_DiameterDimension::SetDiamSymbol(const Standard_Boolean aDiamSymbol)
{
myDiamSymbol = aDiamSymbol;
}

54
src/AIS/AIS_DimensionOwner.cdl Executable file
View File

@@ -0,0 +1,54 @@
-- File: AIS_DimensionOwner.cdl
-- Created: Thu Dec 5 17:04:35 1996
-- Author: Odile Olivier
-- <odl@sacadox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class DimensionOwner from AIS inherits EntityOwner from SelectMgr
---Purpose: The owner is the entity which makes it possible to link
-- the sensitive primitives and the reference shapes that
-- you want to detect. It stocks the various pieces of
-- information which make it possible to find objects. An
-- owner has a priority which you can modulate, so as to
-- make one entity more selectable than another. You
-- might want to make edges more selectable than
-- faces, for example. In that case, you could attribute sa
-- higher priority to the one compared to the other. An
-- edge, could have priority 5, for example, and a face,
-- priority 4. The default priority is 5.
uses
SelectableObject from SelectMgr,
Shape from TopoDS
is
Create ( aSO : SelectableObject;
aPriority : Integer from Standard =0)
returns mutable DimensionOwner from AIS;
---Purpose:
-- Initializes the dimension owner, aSO, and attributes it
-- the priority, aPriority.
SetShape(me : mutable; aShape : Shape from TopoDS);
---C++: inline
---Purpose:
-- Constructs the reference shape owner aShape for
-- presentation primitives.
FixedShape(me)
---C++: return const &
---C++: inline
---Purpose:
-- Returns the owner shape whose primitives we are concerned with.
returns Shape from TopoDS;
fields
myFixedShape : Shape from TopoDS;
end DimensionOwner;

19
src/AIS/AIS_DimensionOwner.cxx Executable file
View File

@@ -0,0 +1,19 @@
// File: AIS_LengthDimension.cdl
// Created: Tue Dec 5 17:04:35 1996
// Author: Odile Olivier
// <ODL>
#include <AIS_DimensionOwner.ixx>
//-----------------------------------------------------------------------
// function : create
// purpose :
//-----------------------------------------------------------------------
AIS_DimensionOwner::AIS_DimensionOwner(const Handle(SelectMgr_SelectableObject)& aSO,
const Standard_Integer aPriority)
:SelectMgr_EntityOwner(aSO,aPriority)
{
}

22
src/AIS/AIS_DimensionOwner.lxx Executable file
View File

@@ -0,0 +1,22 @@
// File: AIS_DimensionOwner.lxx
// Created: Mon Mar 3 15:16:06 1997
// Author: Jean-Pierre COMBE
// <jpr>
//=======================================================================
//function : SetShape
//purpose :
//=======================================================================
inline void AIS_DimensionOwner::SetShape(const TopoDS_Shape& aShape)
{
myFixedShape = aShape;
}
//=======================================================================
//function : FixedShape
//purpose :
//=======================================================================
inline const TopoDS_Shape& AIS_DimensionOwner::FixedShape() const
{
return myFixedShape;
}

583
src/AIS/AIS_Drawer.cdl Executable file
View File

@@ -0,0 +1,583 @@
-- File: Drawer.cdl
-- Created: Fri Sep 18 15:18:45 1992
-- Author: Odile Olivier
-- <jlf@mastox>
---Copyright: Matra Datavision 1992
class Drawer from AIS inherits Drawer from Prs3d
---Purpose:
-- A framework to manage display attributes of interactive objects.
-- An interactive object can have a certain number of
-- display attributes specific to it. These include
-- visualization mode, color, material
-- and so on. To deal with this information, the
-- interactive context has a Drawer attribute manager
-- which is valid by default for the objects it
-- controls. When an interactive object is visualized, the
-- required graphic display attributes are first taken from
-- its own Drawer if it has the ones required, or from the
-- context drawer for those it does not have them.
-- The set of display attributes of an interactive object is
-- stocked in an AIS_Drawer, which is, in fact, a
-- Prs3d_Drawer with the possibility of a link to another
-- display attribute manager. This drawer then manages
-- the stocked graphic display attributes by specifying
-- how the presentation algorithms compute the
-- presentation of a specific kind of object. These
-- factors involved include color, width and type of line,
-- and maximal chordal deviation. The Drawer includes
-- instances of the aspect classes providing the default
-- values for them.
-- Prs3d_Drawer completes AIS_Drawer by adding
-- functions for setting deviation angle and deviation
-- coefficient in presentations using hidden line removal.
uses
Drawer from Prs3d,
DatumAspect from Prs3d,
LineAspect from Prs3d,
TextAspect from Prs3d,
PointAspect from Prs3d,
ShadingAspect from Prs3d,
IsoAspect from Prs3d,
LengthAspect from Prs3d,
AngleAspect from Prs3d,
PlaneAspect from Prs3d,
RadiusAspect from Prs3d,
ArrowAspect from Prs3d,
TypeOfDeflection from Aspect,
NameOfColor from Quantity,
PlaneAngle from Quantity,
Length from Quantity
is
Create returns mutable Drawer from AIS;
---Purpose:
-- Constructs an empty attribute management framework.
TypeOfDeflection(me) returns TypeOfDeflection from Aspect
is redefined static;
--- Purpose:
-- Returns the type of chordal deflection: relative to the
-- size of the object or absolute.
MaximalChordialDeviation (me) returns Length from Quantity
---Purpose: Returns the maximal chordal deviation. The default
-- value is 0.1. Drawings of curves or patches are
-- made with respect to an absolute maximal chordal deviation.
is redefined static;
------------------------------------------------------------
SetDeviationCoefficient(me: mutable) ;
---Purpose: Sets the hasOwnDeviationCoefficient flag to Standard_False
---C++: inline
SetHLRDeviationCoefficient(me: mutable) ;
---Purpose: Sets the deviation coefficient aCoefficient for
-- removal of hidden lines created by different
-- viewpoints in different presentations. The Default value is 0.02.
---C++: inline
SetDeviationAngle(me: mutable) ;
---Purpose: Sets the hasOwnDeviationAngle flag to Standard_False
---C++: inline
SetHLRAngle(me: mutable) ;
---Purpose: Sets the angle of maximum chordal deviation for
-- removal of hidden lines created by different viewpoints
-- in different presentations. The default value is 20*PI/180.
---C++: inline
SetDeviationCoefficient(me: mutable; aCoefficient: Real from Standard )
---Purpose: Sets the hasOwnDeviationCoefficient flag to Standard_True,
-- sets myOwnDeviationCoefficient and myPreviousDeviationCoefficient
is redefined static;
SetHLRDeviationCoefficient(me: mutable; aCoefficient: Real from Standard )
---Purpose: Sets the hasOwnHLRDeviationCoefficient flag to Standard_True,
-- sets myOwnHLRDeviationCoefficient and myPreviousHLRDeviationCoefficient
is redefined static;
SetDeviationAngle(me: mutable; anAngle: Real from Standard ) is redefined ;
---Purpose: Sets the hasOwnDeviationAngle flag to Standard_True,
-- sets myOwnDeviationAngle and myPreviousDeviationAngle
SetHLRAngle(me: mutable; anAngle: Real from Standard )
---Purpose: Sets the hasOwnHLRDeviationAngle flag to Standard_True,
-- sets myOwnHLRDeviationAngle and myPreviousHLRDeviationAngle
is redefined static;
DeviationCoefficient(me) returns Real from Standard
---Purpose: Drawings of curves or patches are made with respect
-- to a maximal chordal deviation. A Deviation coefficient
-- is used in the shading display mode. The shape is
-- seen decomposed into triangles. These are used to
-- calculate reflection of light from the surface of the
-- object. The triangles are formed from chords of the
-- curves in the shape. The deviation coefficient gives
-- the highest value of the angle with which a chord can
-- deviate from a tangent to a curve. If this limit is
-- reached, a new triangle is begun.
-- This deviation is absolute and is set through the
-- method: SetMaximalChordialDeviation. The default value is 0.001.
-- In drawing shapes, however, you are allowed to ask
-- for a relative deviation. This deviation will be:
-- SizeOfObject * DeviationCoefficient.
is redefined static;
HLRDeviationCoefficient(me) returns Real from Standard
---Purpose: Returns the real number value of the HLR deviation
-- coefficient in this framework, if the flag
-- hasOwnHLRDeviationCoefficient is true.
-- If hasOwnHLRDeviationCoefficient is false, the
-- shape's HLR deviation coefficient is used.
-- A Deviation coefficient is used in the shading display
-- mode. The shape is seen decomposed into triangles.
-- These are used to calculate reflection of light from the
-- surface of the object.
-- The triangles are formed from chords of the curves in
-- the shape. The deviation coefficient give the highest
-- value of the angle with which a chord can deviate
-- from a tangent to a curve. If this limit is reached, a
-- new triangle is begun.
-- To find the hidden lines, hidden line display mode
-- entails recalculation of the view at each different
-- projector perspective.
-- Since hidden lines entail calculations of more than
-- usual complexity to decompose them into these
-- triangles, a deviation coefficient allowing greater
-- tolerance is used. This increases efficiency in calculation.
-- The Default value is 0.02.
is redefined static;
DeviationAngle(me) returns Real from Standard
---Purpose: Returns myOwnDeviationAngle if hasOwnDeviationAngle is True
-- else gets myDeviationAngle field from Prs3d_Drawer
is redefined;
HLRAngle(me) returns Real from Standard
---Purpose: Returns the real number value of the deviation angle
-- in hidden line removal views. The default value is 20*PI/180.
is redefined static;
PreviousDeviationCoefficient(me) returns Real from Standard
---Purpose: Saves the previous value used for the chordal
-- deviation coefficient. The default value is 0.1.
---C++: inline
is static;
PreviousHLRDeviationCoefficient(me) returns Real from Standard
---Purpose: returns myPreviousHLRDeviationCoefficient
---C++: inline
is static;
PreviousDeviationAngle(me) returns Real from Standard
---Purpose: returns myPreviousDeviationAngle
---C++: inline
is static;
PreviousHLRDeviationAngle(me) returns Real from Standard
---Purpose: returns myPreviousHLRDeviationAngle
---C++: inline
is static;
IsOwnDeviationCoefficient(me) returns Boolean from Standard;
---Purpose: Returns true if the there is a local setting for deviation
-- coefficient in this framework for a specific interactive object.
---C++: inline
IsOwnHLRDeviationCoefficient(me) returns Boolean from Standard;
---Purpose: Returns true if the there is a setting for HLR deviation
-- coefficient in this framework for a specific interactive object.
---C++: inline
IsOwnDeviationAngle(me) returns Boolean from Standard;
---Purpose: Returns true if the there is a local setting for deviation
-- angle in this framework for a specific interactive object.
---C++: inline
IsOwnHLRDeviationAngle(me) returns Boolean from Standard;
---Purpose: Returns true if the there is a setting for HLR deviation
-- angle in this framework for a specific interactive object.
---C++: inline
Discretisation(me) returns Integer from Standard
is redefined static;
---Purpose: Draws algorithms using discretisation, a default
-- number of points has been set to 17. You can use the
-- method Prs3d_Drawer_SetDiscretisation to change this value.
MaximalParameterValue(me) returns Real from Standard
is redefined static;
---Purpose:
-- Sets the maximum value allowed for the first and last
-- parameters of an infinite curve. By default, this value is 500000.
IsoOnPlane(me) returns Boolean from Standard
---Purpose: returns True if the drawing of isos on planes is enabled.
is redefined static;
--
-- Attributes for the U Isoparametric lines of patches.
--
UIsoAspect (me:mutable) returns mutable IsoAspect from Prs3d
---Purpose: Defines the attributes which are used when drawing an
-- U isoparametric curve of a face. Defines the number
-- of U isoparametric curves to be drawn for a single face.
-- The LineAspect for U isoparametric lines can be edited
-- (methods SetColor, SetTypeOfLine, SetWidth, SetNumber)
-- The default values are:
-- COLOR : Quantity_NOC_GRAY75
-- TYPE OF LINE: Aspect_TOL_SOLID
-- WIDTH : 0.5
-- These attributes are used by the following algorithms:
-- Prs3d_WFDeflectionSurface
-- Prs3d_WFDeflectionRestrictedFace
is redefined static;
-- Attributes for the V Isoparametric line of patches.
VIsoAspect (me:mutable) returns mutable IsoAspect from Prs3d
---Purpose: Defines the attributes which are used when drawing an
-- V isoparametric curve of a face. Defines the number
-- of V isoparametric curves to be drawn for a single face.
-- The LineAspect for V isoparametric lines can be edited
-- (methods SetColor, SetTypeOfLine, SetWidth, SetNumber)
-- The default values are:
-- COLOR : Quantity_NOC_GRAY82
-- TYPE OF LINE: Aspect_TOL_SOLID
-- WIDTH : 0.5
-- These attributes are used by the following algorithms:
-- Prs3d_WFDeflectionSurface
-- Prs3d_WFDeflectionRestrictedFace
is redefined static;
-- Attributes for the free boundaries
FreeBoundaryAspect (me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns a link with
-- Prs3d_Drawer_FreeBoundaryAspect. Stores the
-- values for presentation of free boundaries, in other
-- words, boundaries which are not shared . The
-- LineAspect for the free boundaries can be edited. The
-- default values are: Color: Quantity_NOC_GREEN
-- Type of line: Aspect_TOL_SOLID Width: 1.
-- These attributes are used by Prs3d_WFShape.
is redefined static;
FreeBoundaryDraw(me) returns Boolean from Standard
---Purpose: returns True if the drawing of the free boundaries is enabled.
is redefined static;
-- Attributes for the wires
WireAspect (me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns a link with Prs3d_Drawer_WireAspect.
-- This method provides wire aspect settings.
-- The LineAspect for wires can be edited. The default values are:
-- Color: Quantity_NOC_RED
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
-- These attributes are used by the following algorithms:
-- Prs3d_WFShape
is redefined static;
HasLineAspect (me) returns Boolean from Standard
---Purpose: Returns true if the Interactive Object has a line
-- visualization aspect.
---C++: inline
is static;
HasWireAspect (me) returns Boolean from Standard
---Purpose: Returns true if the Drawer has a wire aspect setting active.
---C++: inline
is static;
WireDraw(me) returns Boolean from Standard
---Purpose: Returns a link with Prs3d_Drawer_WireDraw. This
-- method returns true if drawing of wires is enabled.
-- The default setting is true.
is redefined static;
-- Attributes for the unfree boundaries
UnFreeBoundaryAspect (me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns a link with
-- Prs3d_Drawer_UnFreeBoundaryAspect, which
-- provides settings for shared boundary line aspects.
-- The LineAspect for shared boundaries can be edited.
-- The default values are:
-- Color: Quantity_NOC_YELLOW
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
-- These attributes are used by the following algorithms:
-- Prs3d_WFShape
is redefined static;
UnFreeBoundaryDraw(me) returns Boolean from Standard
---Purpose: Returns True if the drawing of the shared boundaries
-- is enabled. True is the default setting.
is redefined static;
--
-- Attributes for the lines.
--
LineAspect(me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns a link with Prs3d_Drawer_LineAspect,
-- which provides settings for line aspects. These
-- settings can be edited. The default values are:
-- Color: Quantity_NOC_YELLOW
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
-- These attributes are used by the following algorithms:
-- Prs3d_Curve
-- Prs3d_Line
-- Prs3d_HLRShape
is redefined static;
HasTextAspect(me) returns Boolean from Standard
is static;
---C++: inline
TextAspect(me:mutable) returns mutable TextAspect from Prs3d
--
-- Color: Quantity_NOC_YELLOW
is redefined static;
LineArrowDraw(me) returns Boolean from Standard
---Purpose: Returns True if the drawing of an arrow at the end of
-- each line is enabled. The default setting is False.
is redefined static;
ArrowAspect(me:mutable) returns mutable ArrowAspect from Prs3d
is redefined static;
-- --
-- Attributes for the points
--
PointAspect(me:mutable) returns mutable PointAspect from Prs3d
---Purpose: Returns the point aspect setting. The default values
-- are: Color: Quantity_NOC_YELLOW
-- Type of marker: Aspect_TOM_PLUS
-- Scale: 1.
-- These attributes are used by the following algorithms:
-- Prs3d_Point
is redefined static;
HasPointAspect (me) returns Boolean from Standard
---Purpose: Returns true if the Drawer has a point aspect setting active.
is static;
---C++: inline
-- Attributes for the faces:
--
ShadingAspect (me:mutable) returns mutable ShadingAspect from Prs3d
---Purpose:
-- Returns a link with Prs3d_Drawer_ShadingAspect,
-- which provides settings for shading aspects.
-- These settings can be edited. The default values are:
-- Color: Quantity_NOC_YELLOW
-- Material: Graphic3d_NOM_BRASS
-- hading aspect is obtained through decomposition of
-- 3D faces into triangles, each side of each triangle
-- being a chord of the corresponding curved edge in
-- the face. Reflection of light in each projector
-- perspective is then calculated for each of the
-- resultant triangular planes.
is redefined static;
HasShadingAspect (me) returns Boolean from Standard
---C++: inline
---Purpose: Returns True if the Drawer has shading aspect active.
is static;
ShadingAspectGlobal(me) returns Boolean from Standard
is redefined static;
---Purpose: Provides the attributes for hidden line removal.
DrawHiddenLine(me) returns Boolean from Standard
---Purpose: Returns Standard_True if the hidden lines are to be drawn.
-- By default the hidden lines are not drawn.
is redefined static;
HiddenLineAspect(me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns a link with
-- Prs3d_Drawer_HiddenLineAspect, which provides
-- settings for hidden line aspects.
-- These settings can be edited. The default values are:
-- Color: Quantity_NOC_YELLOW
-- Type of line: Aspect_TOL_DASH
-- Width: 1.
is redefined static;
SeenLineAspect(me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns a link with
-- Prs3d_Drawer_SeenLineAspect, which provides
-- settings for seen line aspects.
-- These settings can be edited. The default values are:
-- Color: Quantity_NOC_YELLOW
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
is redefined static;
HasPlaneAspect(me) returns Boolean from Standard;
---C++: inline
PlaneAspect(me:mutable) returns mutable PlaneAspect from Prs3d
is redefined static;
---Purpose:
-- Returns a link with Prs3d_Drawer_PlaneAspect.
-- This method provides settings for the appearance of planes.
VectorAspect(me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns a link with Prs3d_Drawer_VectorAspect,
-- which provides settings for the appearance of vectors.
-- These settings can be edited. The default values are:
-- Color: Quantity_NOC_SKYBLUE
-- Type of line: Aspect_TOL_SOLID Width: 1.
is redefined static;
--
-- Attributes for the presentation of a Datum.
--
HasDatumAspect(me) returns Boolean from Standard;
---C++: inline
DatumAspect(me:mutable) returns mutable DatumAspect from Prs3d
---Purpose: Returns a link with Prs3d_Drawer_DatumAspect,
-- which provides settings for the appearance of datums.
-- These settings can be edited. The default values for
-- the three axes are:
-- Color: Quantity_NOC_PEACHPUFF
-- Type of line: Aspect_TOL_SOLID Width: 1.
is redefined static;
--
-- Attributes for the presentation of a Length.
--
LengthAspect(me:mutable) returns mutable LengthAspect from Prs3d
---Purpose: Returns a link with Prs3d_Drawer_LengthAspect,
-- which provides settings for the appearance of lengths.
is redefined static;
HasLengthAspect (me) returns Boolean from Standard
---C++: inline
---Purpose: Returns true if the Drawer has a length aspect setting active.
is static;
--
-- Attributes for the presentation of a Angle.
--
AngleAspect(me:mutable) returns mutable AngleAspect from Prs3d
---Purpose: Returns a link with Prs3d_Drawer_AngleAspect,
-- which provides settings for lines used to display angles.
is redefined static;
HasAngleAspect (me) returns Boolean from Standard
---C++: inline
---Purpose: Returns true if the Drawer has an angle aspect
-- setting active.
is static;
--
-- Attributes for the presentation of a Radius.
--
RadiusAspect(me) returns mutable RadiusAspect from Prs3d
---Purpose: Returns a link with Prs3d_Drawer_RadiusAspect,
-- which provides settings for lines which serve to display radii.
is redefined static;
-- Attributes for the sections
SectionAspect (me:mutable) returns mutable LineAspect from Prs3d
---Purpose: Returns a link with Prs3d_Drawer_SectionAspect,
-- which provides settings for wires which highlight sections.
-- The LineAspect for the wire can be edited.
-- The default values are:
-- Color: Quantity_NOC_ORANGE
-- Type of line: Aspect_TOL_SOLID
-- Width: 1.
-- These attributes are used by the following algorithms:
-- Prs3d_WFShape
is redefined static;
Link(me:mutable) returns any Drawer from Prs3d
is static;
---C++: return const&
HasLink(me) returns Boolean from Standard
is static;
---C++: inline
Link (me:mutable; aDrawer: Drawer from Prs3d)
is static;
---C++: inline
ClearLocalAttributes(me:mutable) is virtual;
---Purpose: Removes attributes stored in a Local Context.
WasLastLocal(me) returns Boolean from Standard;
---C++: inline
---Purpose: Returns true if the last called attribute was local; false if it was global.
HasLocalAttributes(me) returns Boolean from Standard;
---C++: inline
---Purpose:
-- Returns true if a Local Context has stored attributes
-- for Interactive Objects.
fields
myLink : Drawer from Prs3d;
hasLocalAttributes : Boolean from Standard;
myhasOwnDeviationCoefficient : Boolean from Standard;
myOwnDeviationCoefficient : Real from Standard;
myPreviousDeviationCoefficient : Real from Standard;
myhasOwnHLRDeviationCoefficient : Boolean from Standard;
myOwnHLRDeviationCoefficient : Real from Standard;
myPreviousHLRDeviationCoefficient: Real from Standard;
myhasOwnDeviationAngle : Boolean from Standard;
myOwnDeviationAngle : Real from Standard;
myPreviousDeviationAngle : Real from Standard;
myhasOwnHLRDeviationAngle : Boolean from Standard;
myOwnHLRDeviationAngle : Real from Standard;
myPreviousHLRDeviationAngle : Real from Standard;
end Drawer;

253
src/AIS/AIS_Drawer.cxx Executable file
View File

@@ -0,0 +1,253 @@
#include <AIS_Drawer.ixx>
#include <Standard_ProgramError.hxx>
AIS_Drawer::AIS_Drawer():
myLink(new Prs3d_Drawer()),
hasLocalAttributes(Standard_False),
myhasOwnDeviationCoefficient(Standard_False),
myPreviousDeviationCoefficient(0.1),
myhasOwnHLRDeviationCoefficient (Standard_False),
myhasOwnDeviationAngle (Standard_False),
myhasOwnHLRDeviationAngle (Standard_False)
{
SetMaximalParameterValue(500000.);
myLink->SetMaximalParameterValue(500000.);
}
Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const
{
return myLink->TypeOfDeflection();
}
Standard_Boolean AIS_Drawer::IsoOnPlane() const
{
return myLink->IsoOnPlane();
}
Standard_Integer AIS_Drawer::Discretisation() const
{
return myLink->Discretisation();
}
Quantity_Length AIS_Drawer::MaximalChordialDeviation() const
{
return myLink->MaximalChordialDeviation();
}
//=======================================================================
//function : SetDeviationCoefficient
//purpose :
//=======================================================================
void AIS_Drawer::SetDeviationCoefficient ( const Standard_Real aCoefficient )
{
myPreviousDeviationCoefficient = DeviationCoefficient() ;
myOwnDeviationCoefficient = aCoefficient ;
myhasOwnDeviationCoefficient = Standard_True;
}
//=======================================================================
//function : SetHLRDeviationCoefficient
//purpose :
//=======================================================================
void AIS_Drawer::SetHLRDeviationCoefficient ( const Standard_Real aCoefficient )
{
myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient() ;
myOwnHLRDeviationCoefficient = aCoefficient ;
myhasOwnHLRDeviationCoefficient = Standard_True;
}
//=======================================================================
//function : SetDeviationAngle
//purpose :
//=======================================================================
void AIS_Drawer::SetDeviationAngle ( const Standard_Real anAngle )
{
myPreviousDeviationAngle = DeviationAngle() ;
myOwnDeviationAngle = anAngle ;
myhasOwnDeviationAngle = Standard_True;
}
//=======================================================================
//function : SetHLRAngle
//purpose :
//=======================================================================
void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle )
{
myPreviousHLRDeviationAngle = HLRAngle() ;
myOwnHLRDeviationAngle = anAngle ;
myhasOwnHLRDeviationAngle = Standard_True;
}
/////// Get
//=======================================================================
//function : DeviationCoefficient
//purpose :
//=======================================================================
Standard_Real AIS_Drawer::DeviationCoefficient () const
{
return myhasOwnDeviationCoefficient? myOwnDeviationCoefficient :myLink->DeviationCoefficient();
}
//=======================================================================
//function : HLRDeviationCoefficient
//purpose :
//=======================================================================
Standard_Real AIS_Drawer::HLRDeviationCoefficient () const
{
return myhasOwnHLRDeviationCoefficient?myOwnHLRDeviationCoefficient : myLink->HLRDeviationCoefficient() ;
}
//=======================================================================
//function : DeviationAngle
//purpose :
//=======================================================================
Standard_Real AIS_Drawer::DeviationAngle () const
{
return myhasOwnDeviationAngle ? myOwnDeviationAngle : myLink->DeviationAngle();
}
//=======================================================================
//function : HLRAngle
//purpose :
//=======================================================================
Standard_Real AIS_Drawer::HLRAngle () const
{
return myhasOwnHLRDeviationAngle ? myOwnHLRDeviationAngle : myLink->HLRAngle();
}
Standard_Real AIS_Drawer::MaximalParameterValue () const
{ return myLink->MaximalParameterValue();}
Handle (Prs3d_IsoAspect) AIS_Drawer::UIsoAspect ()
{ return myUIsoAspect.IsNull() ? myLink->UIsoAspect (): myUIsoAspect;}
Handle (Prs3d_IsoAspect) AIS_Drawer::VIsoAspect ()
{ return myVIsoAspect.IsNull() ? myLink->VIsoAspect (): myVIsoAspect;}
Handle (Prs3d_LineAspect) AIS_Drawer::FreeBoundaryAspect ()
{return myFreeBoundaryAspect.IsNull() ? myLink->FreeBoundaryAspect (): myFreeBoundaryAspect;}
Standard_Boolean AIS_Drawer::FreeBoundaryDraw () const
{return myLink->FreeBoundaryDraw();}
Handle (Prs3d_LineAspect) AIS_Drawer::UnFreeBoundaryAspect ()
{return myUnFreeBoundaryAspect.IsNull() ? myLink->UnFreeBoundaryAspect (): myUnFreeBoundaryAspect;}
Standard_Boolean AIS_Drawer::UnFreeBoundaryDraw () const
{return myLink->UnFreeBoundaryDraw ();}
Handle (Prs3d_LineAspect) AIS_Drawer::WireAspect ()
{ return myWireAspect.IsNull()? myLink->WireAspect (): myWireAspect;}
Standard_Boolean AIS_Drawer::WireDraw () const
{ return myLink->WireDraw();}
Handle (Prs3d_LineAspect) AIS_Drawer::LineAspect ()
{ return myLineAspect.IsNull() ? myLink->LineAspect (): myLineAspect;}
Handle (Prs3d_TextAspect) AIS_Drawer::TextAspect ()
{ return myTextAspect.IsNull() ? myLink->TextAspect () : myTextAspect ;}
Handle (Prs3d_ShadingAspect) AIS_Drawer::ShadingAspect ()
{
return myShadingAspect.IsNull() ? myLink->ShadingAspect () : myShadingAspect ;
}
Standard_Boolean AIS_Drawer::ShadingAspectGlobal() const
{ return myLink->ShadingAspectGlobal();}
Standard_Boolean AIS_Drawer::LineArrowDraw () const
{ return myLink->LineArrowDraw();}
Handle (Prs3d_ArrowAspect) AIS_Drawer::ArrowAspect()
{return myArrowAspect.IsNull()? myLink->ArrowAspect () : myArrowAspect;}
Handle (Prs3d_PointAspect) AIS_Drawer::PointAspect()
{return myPointAspect.IsNull()? myLink->PointAspect () : myPointAspect;}
Standard_Boolean AIS_Drawer::DrawHiddenLine () const
{return myLink->DrawHiddenLine();}
Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect ()
{return myHiddenLineAspect.IsNull()? myLink->HiddenLineAspect () : myHiddenLineAspect;}
Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect ()
{ return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;}
Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect ()
{return myVectorAspect.IsNull()? myLink->VectorAspect () : myVectorAspect;}
Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect ()
{return myDatumAspect.IsNull()? myLink->DatumAspect () : myDatumAspect; }
Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect ()
{return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
Handle (Prs3d_LengthAspect) AIS_Drawer::LengthAspect ()
{return myLengthAspect.IsNull()? myLink->LengthAspect () : myLengthAspect ;}
Handle (Prs3d_AngleAspect) AIS_Drawer::AngleAspect ()
{return myAngleAspect.IsNull()? myLink->AngleAspect () :myAngleAspect ;}
Handle (Prs3d_RadiusAspect) AIS_Drawer::RadiusAspect () const
{return myRadiusAspect.IsNull()? myLink->RadiusAspect():myRadiusAspect; }
Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
{return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
const Handle (Prs3d_Drawer)& AIS_Drawer::Link()
{
if(myLink.IsNull()) myLink = new Prs3d_Drawer();
return myLink;
}
void AIS_Drawer::ClearLocalAttributes()
{
if(myLink.IsNull()) return;
// attention pas beau....
// The Handles
if(!myUIsoAspect.IsNull()) myUIsoAspect.Nullify();
if(!myVIsoAspect.IsNull()) myVIsoAspect.Nullify();
if(!myFreeBoundaryAspect.IsNull()) myFreeBoundaryAspect.Nullify();
if(!myUnFreeBoundaryAspect.IsNull()) myUnFreeBoundaryAspect.Nullify();
if(!myWireAspect.IsNull()) myWireAspect.Nullify();
if(!myLineAspect.IsNull()) myLineAspect.Nullify();
if(!myTextAspect.IsNull()) myTextAspect.Nullify();
if(!myShadingAspect.IsNull()) myShadingAspect.Nullify();
if(!myPointAspect.IsNull()) myPointAspect.Nullify();
if(!myPlaneAspect.IsNull()) myPlaneAspect.Nullify();
if(!myArrowAspect.IsNull()) myArrowAspect.Nullify();
if(!myHiddenLineAspect.IsNull()) myHiddenLineAspect.Nullify();
if(!mySeenLineAspect.IsNull()) mySeenLineAspect.Nullify();
if(!myVectorAspect.IsNull()) myVectorAspect .Nullify();
if(!myDatumAspect.IsNull()) myDatumAspect.Nullify();
if(!myLengthAspect.IsNull()) myLengthAspect.Nullify();
if(!myAngleAspect.IsNull()) myAngleAspect.Nullify();
if(!myRadiusAspect.IsNull()) myRadiusAspect.Nullify();
if(!mySectionAspect.IsNull()) mySectionAspect.Nullify();
if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False;
if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False;
hasLocalAttributes = Standard_False;
}

80
src/AIS/AIS_Drawer.lxx Executable file
View File

@@ -0,0 +1,80 @@
// File: AIS_Drawer.lxx
// Created: Thu Dec 19 15:49:32 1996
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
inline Standard_Boolean AIS_Drawer::WasLastLocal() const
{return Standard_False;}
inline Standard_Boolean AIS_Drawer::HasLocalAttributes() const
{return hasLocalAttributes;}
inline Standard_Real AIS_Drawer::PreviousDeviationCoefficient () const
{return (myhasOwnDeviationCoefficient) ? myPreviousDeviationCoefficient : 0.0;}
inline Standard_Real AIS_Drawer::PreviousHLRDeviationCoefficient () const
{return (myhasOwnHLRDeviationCoefficient) ? myPreviousHLRDeviationCoefficient : 0.0;}
inline Standard_Real AIS_Drawer::PreviousDeviationAngle () const
{return (myhasOwnDeviationAngle) ? myPreviousDeviationAngle : 0.0;}
inline Standard_Real AIS_Drawer::PreviousHLRDeviationAngle () const
{return (myhasOwnHLRDeviationAngle) ? myPreviousHLRDeviationAngle : 0.0;}
inline void AIS_Drawer::Link ( const Handle(Prs3d_Drawer)& aDrawer)
{ myLink = aDrawer;}
inline Standard_Boolean AIS_Drawer::HasLink() const
{ return ! myLink.IsNull();}
inline void AIS_Drawer::SetDeviationCoefficient ()
{ myhasOwnDeviationCoefficient = Standard_False; }
inline void AIS_Drawer::SetHLRDeviationCoefficient ()
{ myhasOwnHLRDeviationCoefficient = Standard_False; }
inline void AIS_Drawer::SetDeviationAngle ()
{ myhasOwnDeviationAngle = Standard_False;}
inline void AIS_Drawer::SetHLRAngle ()
{ myhasOwnHLRDeviationAngle = Standard_False;}
inline Standard_Boolean AIS_Drawer::IsOwnDeviationCoefficient () const
{ return myhasOwnDeviationCoefficient;}
inline Standard_Boolean AIS_Drawer::IsOwnDeviationAngle () const
{ return myhasOwnDeviationAngle;}
inline Standard_Boolean AIS_Drawer::IsOwnHLRDeviationCoefficient () const
{ return myhasOwnHLRDeviationCoefficient;}
inline Standard_Boolean AIS_Drawer::IsOwnHLRDeviationAngle () const
{ return myhasOwnHLRDeviationAngle;}
inline Standard_Boolean AIS_Drawer::HasTextAspect () const
{ return (!myTextAspect.IsNull());}
inline Standard_Boolean AIS_Drawer::HasWireAspect () const
{ return (!myWireAspect.IsNull());}
inline Standard_Boolean AIS_Drawer::HasLineAspect () const
{return !myLineAspect.IsNull(); }
inline Standard_Boolean AIS_Drawer::HasShadingAspect () const
{ return !myShadingAspect.IsNull();}
inline Standard_Boolean AIS_Drawer::HasPointAspect () const
{ return !myPointAspect.IsNull();}
inline Standard_Boolean AIS_Drawer::HasAngleAspect () const
{ return !myAngleAspect.IsNull();}
inline Standard_Boolean AIS_Drawer::HasDatumAspect () const
{ return !myDatumAspect.IsNull();}
inline Standard_Boolean AIS_Drawer::HasPlaneAspect () const
{ return !myPlaneAspect.IsNull();}
inline Standard_Boolean AIS_Drawer::HasLengthAspect () const
{ return !myLengthAspect.IsNull();}

View File

@@ -0,0 +1,77 @@
-- File: AIS_EllipseRadiusDimension.cdl
-- Created: Thu Jan 22 09:01:38 1998
-- Author: Sergey ZARITCHNY
-- <szy@androx.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
deferred class EllipseRadiusDimension from AIS inherits Relation from AIS
---Purpose:
-- Computes geometry ( basis curve and plane of dimension)
-- for input shape aShape from TopoDS
-- Root class for MinRadiusDimension and MaxRadiusDimension
uses
Shape from TopoDS,
Elips from gp,
Pnt from gp,
Pln from gp,
Curve from Geom,
OffsetCurve from Geom,
Ellipse from Geom,
Plane from Geom,
Surface from Geom,
ExtendedString from TCollection,
KindOfSurface from AIS,
KindOfDimension from AIS
is
Initialize(aShape : Shape from TopoDS;
aText : ExtendedString from TCollection);
-- Ellipse radius dimension of a Shape which can be Edge
-- or Face (planar or cylindrical(surface of extrusion or
-- surface of offset))
KindOfDimension(me) returns KindOfDimension from AIS
is redefined;
IsMovable(me) returns Boolean from Standard
is redefined;
--
-- Computation private methods
--
ComputeGeometry( me: mutable ) ;
-- is private;
ComputeFaceGeometry(me: mutable)
is private;
ComputeCylFaceGeometry(me: mutable;
aSurfType : KindOfSurface from AIS;
aSurf : Surface from Geom;
Offset : Real from Standard )
is private;
ComputePlanarFaceGeometry(me: mutable)
is private;
ComputeEdgeGeometry(me: mutable)
is private;
fields
myEllipse : Elips from gp is protected;
myFirstPar : Real from Standard is protected;
myLastPar : Real from Standard is protected;
myIsAnArc : Boolean from Standard is protected;
myOffsetCurve : OffsetCurve from Geom is protected;
myOffset : Real from Standard is protected;
myIsOffset : Boolean from Standard is protected;
end EllipseRadiusDimension;

View File

@@ -0,0 +1,288 @@
// File: AIS_EllipseRadiusDimension.cxx
// Created: Thu Jan 22 10:24:00 1998
// Author: Sergey ZARITCHNY
// <szy@androx.nnov.matra-dtv.fr>
#include <AIS_EllipseRadiusDimension.ixx>
#include <TCollection_ExtendedString.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <TopoDS.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <GeomAPI_ExtremaCurveCurve.hxx>
#include <Geom_Line.hxx>
#include <GeomAPI.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <gp_Elips.hxx>
#include <AIS.hxx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
//=======================================================================
//function : AIS_EllipseRadiusDimension
//purpose :
//=======================================================================
AIS_EllipseRadiusDimension::AIS_EllipseRadiusDimension(const TopoDS_Shape& aShape,
const TCollection_ExtendedString& aText)
:AIS_Relation()
{
myFShape = aShape;
myText = aText;
// ComputeGeometry( );
}
//=======================================================================
//function : ComputeGeometry
//purpose :
//=======================================================================
void AIS_EllipseRadiusDimension::ComputeGeometry()
{
switch (myFShape.ShapeType()) {
case TopAbs_FACE :
{
// compute one face case
ComputeFaceGeometry ();
break;
}
case TopAbs_EDGE:
{
ComputeEdgeGeometry ();
break;
}
default:
break;
}
while (myFirstPar > 2*PI) myFirstPar -= 2*PI;
while (myLastPar > 2*PI) myLastPar -= 2*PI;
while (myFirstPar < 0.0) myFirstPar += 2*PI;
while (myLastPar < 0.0) myLastPar += 2*PI;
}
//=======================================================================
//function : ComputeFaceGeometry
//purpose :
//=======================================================================
void AIS_EllipseRadiusDimension::ComputeFaceGeometry()
{
gp_Pln aPln;
Handle( Geom_Surface ) aBasisSurf;
AIS_KindOfSurface aSurfType;
Standard_Real Offset;
AIS::GetPlaneFromFace( TopoDS::Face( myFShape),
aPln,
aBasisSurf,
aSurfType,
Offset ) ;
if ( aSurfType == AIS_KOS_Plane )
ComputePlanarFaceGeometry( );
else
ComputeCylFaceGeometry( aSurfType, aBasisSurf, Offset );
}
//=======================================================================
//function : ComputeCylFaceGeometry
//purpose : defines Ellipse and plane of dimension
//=======================================================================
void AIS_EllipseRadiusDimension::ComputeCylFaceGeometry(const AIS_KindOfSurface aSurfType,
const Handle( Geom_Surface )& aBasisSurf,
const Standard_Real Offset)
{
BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
Standard_Real vFirst, vLast;
vFirst = surf1.FirstVParameter();
vLast = surf1.LastVParameter();
Standard_Real vMid = (vFirst + vLast)*0.5;
gp_Pln aPlane;
gp_Ax1 Axis;
// Standard_Real Param;
if (aSurfType == AIS_KOS_Extrusion)
{
Axis.SetDirection((Handle( Geom_SurfaceOfLinearExtrusion )::DownCast( aBasisSurf ))
->Direction() );
Axis.SetLocation( gp_Pnt((Handle( Geom_SurfaceOfLinearExtrusion )::DownCast( aBasisSurf ))
->Direction().XYZ() ) );
aPlane.SetAxis(Axis);
aPlane.SetLocation(myEllipse.Location());
myPlane = new Geom_Plane(aPlane);
Handle(Geom_Curve) aCurve;
aCurve = aBasisSurf->VIso(vMid);
if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Ellipse))
{
myEllipse = Handle(Geom_Ellipse)::DownCast(aCurve)-> Elips();//gp_Elips
myIsAnArc = Standard_False;
}
else if (aCurve->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) {
Handle(Geom_TrimmedCurve) tCurve = Handle(Geom_TrimmedCurve)::DownCast(aCurve);
aCurve = tCurve->BasisCurve();
myFirstPar = tCurve->FirstParameter();
myLastPar = tCurve->LastParameter();
myIsAnArc = Standard_True;
if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Ellipse))
{
myEllipse = Handle(Geom_Ellipse)::DownCast(aCurve)->Elips();//gp_Elips
}
}
else
{
Standard_ConstructionError::Raise("AIS:: Not expected type of surface") ;
return;
}
// Offset
if(surf1.GetType() == GeomAbs_OffsetSurface)
{
if(Offset <0.0 && Abs(Offset) > myEllipse.MinorRadius ())
{
Standard_ConstructionError::Raise("AIS:: Absolute value of negative offset is larger than MinorRadius");
return;
}
myOffsetCurve = new Geom_OffsetCurve(new Geom_Ellipse(myEllipse), Offset,
myPlane->Pln().Axis().Direction());
myOffset = Offset;
myIsOffset = Standard_True;
gp_Elips elips = myEllipse;
Standard_Real Val = Offset + elips.MajorRadius ();//simulation
myEllipse.SetMajorRadius (Val);
Val = Offset + elips.MinorRadius ();
myEllipse.SetMinorRadius (Val);
}
else
myIsOffset = Standard_False;
}
}
//=======================================================================
//function : ComputePlanarFaceGeometry
//purpose :
//=======================================================================
void AIS_EllipseRadiusDimension::ComputePlanarFaceGeometry()
{
Standard_Boolean find = Standard_False;
gp_Pnt ptfirst,ptend;
TopExp_Explorer ExploEd( TopoDS::Face(myFShape), TopAbs_EDGE );
for ( ; ExploEd.More(); ExploEd.Next())
{
TopoDS_Edge curedge = TopoDS::Edge( ExploEd.Current() );
Handle(Geom_Curve) curv;
Handle(Geom_Ellipse) ellips;
if (AIS::ComputeGeometry(curedge,curv,ptfirst,ptend))
{
if (curv->DynamicType() == STANDARD_TYPE(Geom_Ellipse))
{
ellips = Handle(Geom_Ellipse)::DownCast(curv);
if ( !ellips.IsNull() ) {
myEllipse = ellips->Elips();
find = Standard_True;
break;
}
}
}
}
if( !find )
{
Standard_ConstructionError::Raise("AIS:: Curve is not an ellipsee or is Null") ;
return;
}
if ( !ptfirst.IsEqual(ptend, Precision::Confusion()) )
{
myIsAnArc = Standard_True;
myFirstPar = ElCLib::Parameter(myEllipse, ptfirst);
myLastPar = ElCLib::Parameter(myEllipse, ptend);
}
else
myIsAnArc = Standard_False;
BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape));
myPlane = new Geom_Plane( surfAlgo.Plane() );
}
//=======================================================================
//function : ComputeEdgeGeometry
//purpose :
//=======================================================================
void AIS_EllipseRadiusDimension::ComputeEdgeGeometry()
{
gp_Pnt ptfirst,ptend;
Handle(Geom_Curve) curv;
if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),curv,ptfirst,ptend)) return;
Handle(Geom_Ellipse) elips = Handle(Geom_Ellipse)::DownCast(curv);
if ( elips.IsNull()) return;
myEllipse = elips->Elips();
gp_Pln aPlane;
aPlane.SetPosition(gp_Ax3(myEllipse.Position()));
myPlane = new Geom_Plane(aPlane);
if ( ptfirst.IsEqual(ptend, Precision::Confusion()) ) {
myIsAnArc = Standard_False;
}
else {
myIsAnArc = Standard_True;
myFirstPar = ElCLib::Parameter(myEllipse, ptfirst);
myLastPar = ElCLib::Parameter(myEllipse, ptend);
}
}
//=======================================================================
//function : KindOfDimension
//purpose :
//=======================================================================
AIS_KindOfDimension AIS_EllipseRadiusDimension::KindOfDimension() const
{
return AIS_KOD_ELLIPSERADIUS;
}
//=======================================================================
//function : IsMovable
//purpose :
//=======================================================================
Standard_Boolean AIS_EllipseRadiusDimension::IsMovable() const
{
return Standard_True;
}

View File

@@ -0,0 +1,194 @@
-- File: AIS_EqualDistanceRelation.cdl
-- Created: Sat Jan 24 18:23:51 1998
-- Author: Julia GERASIMOVA
-- <jgv@leonox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class EqualDistanceRelation from AIS inherits Relation from AIS
---Purpose: A framework to display equivalent distances between
-- shapes and a given plane.
-- The distance is the length of a projection from the
-- shape to the plane.
-- These distances are used to compare shapes by this vector alone.
uses
Shape from TopoDS,
Plane from Geom,
PresentationManager3d from PrsMgr,
Presentation from Prs3d,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Selection from SelectMgr,
Pnt from gp,
Drawer from AIS,
ExtendedString from TCollection,
Edge from TopoDS,
Vertex from TopoDS,
Box from Bnd,
Dir from gp,
ArrowSide from DsgPrs,
TypeOfDist from AIS
is
Create( aShape1 : Shape from TopoDS;
aShape2 : Shape from TopoDS;
aShape3 : Shape from TopoDS;
aShape4 : Shape from TopoDS;
aPlane : Plane from Geom )
---Purpose: Constructs a framework to display equivalent
-- distances between the shapes aShape1, aShape2,
-- aShape3, aShape4 and the plane aPlane.
-- The distance is the length of a projection from the
-- shape to the plane.
returns mutable EqualDistanceRelation from AIS;
SetShape3( me: mutable; aShape : Shape from TopoDS )
is static;
---Purpose:
-- Sets the shape aShape to be used as the shape
-- aShape3 in the framework created at construction time.
---C++: inline
Shape3(me) returns Shape from TopoDS
is static;
---Purpose:
-- Returns the shape aShape3 from the framework
-- created at construction time.
---C++: return const &
---C++: inline
SetShape4( me: mutable; aShape : Shape from TopoDS )
is static;
---C++: inline
---Purpose:
-- Sets the shape aShape to be used as the shape
-- aShape4 in the framework created at construction time.
Shape4(me) returns Shape from TopoDS
is static;
---C++: return const &
---C++: inline
---Purpose:
-- Returns the shape aShape4 from the framework
-- created at construction time.
-- Methods from PresentableObject
Compute( me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0 )
is redefined static private;
Compute( me : mutable;
aProjector : Projector from Prs3d;
aPresentation : mutable Presentation from Prs3d )
is redefined static private;
Compute( me : mutable;
aPresentationManager : PresentationManager2d from PrsMgr;
aPresentation : mutable GraphicObject from Graphic2d;
aMode : Integer from Standard = 0 )
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: Computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection( me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is private;
-- ota -- begin
ComputeTwoEdgesLength (myclass;
aPresentation : mutable Presentation from Prs3d;
aDrawer : Drawer from AIS;
ArrowSize : Real from Standard;
FirstEdge : Edge from TopoDS;
SecondEdge : Edge from TopoDS;
Plane : Plane from Geom;
AutomaticPos : Boolean from Standard;
IsSetBndBox : Boolean from Standard;
BndBox : Box from Bnd;
Position : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
FirstExtreme : out Pnt from gp;
SecondExtreme : out Pnt from gp;
SymbolPrs : out ArrowSide from DsgPrs );
---Purpose: Computes the location of an intreval between
-- between two edges. FirstAttach , SecondAttach
-- are the returned extreme points of the interval.
ComputeTwoVerticesLength(myclass;
aPresentation : mutable Presentation from Prs3d;
aDrawer : Drawer from AIS;
ArrowSize : Real from Standard;
FirstVertex : Vertex from TopoDS;
SecondVertex : Vertex from TopoDS;
Plane : Plane from Geom;
AutomaticPos : Boolean from Standard;
IsSetBndBox : Boolean from Standard;
BndBox : Box from Bnd;
TypeDist : TypeOfDist from AIS;
Position : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
FirstExtreme : out Pnt from gp;
SecondExtreme : out Pnt from gp;
SymbolPrs : out ArrowSide from DsgPrs );
---Purpose: Computes the interval position between two vertexs. FirstAttach,
-- SecondAttach are the returned extreme points of the interval.
ComputeOneEdgeOneVertexLength(myclass;
aPresentation : mutable Presentation from Prs3d;
aDrawer : Drawer from AIS;
ArrowSize : Real from Standard;
FirstShape : Shape from TopoDS;
SecondShape : Shape from TopoDS;
Plane : Plane from Geom;
AutomaticPos : Boolean from Standard;
IsSetBndBox : Boolean from Standard;
BndBox : Box from Bnd;
Position : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
FirstExtreme : out Pnt from gp;
SecondExtreme : out Pnt from gp;
SymbolPrs : out ArrowSide from DsgPrs );
---Purpose: Compute the interval location between a vertex and an edge. Edge may be
-- a line or a circle.
-- ota -- end
fields
myShape3 : Shape from TopoDS;
myShape4 : Shape from TopoDS;
myAttachPoint1 : Pnt from gp; -- the start points of constraint curves
myAttachPoint2 : Pnt from gp;
myAttachPoint3 : Pnt from gp;
myAttachPoint4 : Pnt from gp;
myPoint1 : Pnt from gp; -- the end points constraint curves
myPoint2 : Pnt from gp;
myPoint3 : Pnt from gp;
myPoint4 : Pnt from gp;
end EqualDistanceRelation;

View File

@@ -0,0 +1,836 @@
// File: AIS_EqualDistanceRelation.cxx
// Created: Sat Jan 24 19:03:18 1998
// Author: Julia GERASIMOVA
// <jgv@leonox.nnov.matra-dtv.fr>
#include <Standard_NotImplemented.hxx>
#include <AIS_EqualDistanceRelation.ixx>
#include <DsgPrs_EqualDistancePresentation.hxx>
#include <AIS_LengthDimension.hxx>
#include <gp_Lin.hxx>
#include <DsgPrs_EqualDistancePresentation.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <Precision.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRep_Tool.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Prs3d_LengthAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <AIS_Drawer.hxx>
#include <ElCLib.hxx>
//=======================================================================
//function : AIS_EqualDistanceRelation
//purpose :
//=======================================================================
AIS_EqualDistanceRelation::AIS_EqualDistanceRelation( const TopoDS_Shape& aShape1,
const TopoDS_Shape& aShape2,
const TopoDS_Shape& aShape3,
const TopoDS_Shape& aShape4,
const Handle( Geom_Plane )& aPlane )
:AIS_Relation()
{
myFShape = aShape1;
mySShape = aShape2;
myShape3 = aShape3;
myShape4 = aShape4;
myPlane = aPlane;
//Temporary
myArrowSize = 3.0; //set the concrete value
mySymbolPrs = DsgPrs_AS_BOTHAR;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManager3d )&,
const Handle( Prs3d_Presentation )& aPresentation,
const Standard_Integer )
{
aPresentation->Clear();
gp_Pnt Position12 = myPosition, Position34 = myPosition;
Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
arr->SetLength(myArrowSize);
// -- ota -- begin
if (!myAutomaticPosition ){
gp_Pnt aMiddle12 ((myPoint1.XYZ() + myPoint2.XYZ())*0.5);
gp_Pnt aMiddle34 ((myPoint3.XYZ() + myPoint4.XYZ())*0.5);
if (myPosition.Distance(aMiddle12) > myPosition.Distance(aMiddle34))
Position12.SetXYZ((myPoint1.XYZ() + myPoint2.XYZ())*0.5);
else
Position34.SetXYZ((myPoint3.XYZ() + myPoint4.XYZ())*0.5);
}
if (myFShape.ShapeType() == TopAbs_EDGE && mySShape.ShapeType() == TopAbs_EDGE)
AIS_EqualDistanceRelation::ComputeTwoEdgesLength(aPresentation,
myDrawer,
myArrowSize,
TopoDS::Edge(myFShape),
TopoDS::Edge(mySShape),
myPlane,
myAutomaticPosition,
myIsSetBndBox,
myBndBox,
Position12,
myAttachPoint1,
myAttachPoint2,
myPoint1,
myPoint2,
mySymbolPrs );
else if (myFShape.ShapeType() == TopAbs_VERTEX && mySShape.ShapeType() == TopAbs_VERTEX)
AIS_EqualDistanceRelation::ComputeTwoVerticesLength( aPresentation,
myDrawer,
myArrowSize,
TopoDS::Vertex(myFShape),
TopoDS::Vertex(mySShape),
myPlane,
myAutomaticPosition,
myIsSetBndBox,
myBndBox,
AIS_TOD_Unknown,
Position12,
myAttachPoint1,
myAttachPoint2,
myPoint1,
myPoint2,
mySymbolPrs );
else
AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( aPresentation,
myDrawer,
myArrowSize,
myFShape,
mySShape,
myPlane,
myAutomaticPosition,
myIsSetBndBox,
myBndBox,
Position12,
myAttachPoint1,
myAttachPoint2,
myPoint1,
myPoint2,
mySymbolPrs );
if (myShape3.ShapeType() == TopAbs_EDGE && myShape4.ShapeType() == TopAbs_EDGE)
AIS_EqualDistanceRelation::ComputeTwoEdgesLength(aPresentation,
myDrawer,
myArrowSize,
TopoDS::Edge(myShape3),
TopoDS::Edge(myShape4),
myPlane,
myAutomaticPosition,
myIsSetBndBox,
myBndBox,
Position34,
myAttachPoint3,
myAttachPoint4,
myPoint3,
myPoint4,
mySymbolPrs );
else if (myShape3.ShapeType() == TopAbs_VERTEX && myShape4.ShapeType() == TopAbs_VERTEX)
AIS_EqualDistanceRelation::ComputeTwoVerticesLength( aPresentation,
myDrawer,
myArrowSize,
TopoDS::Vertex(myShape3),
TopoDS::Vertex(myShape4),
myPlane,
myAutomaticPosition,
myIsSetBndBox,
myBndBox,
AIS_TOD_Unknown,
Position34,
myAttachPoint3,
myAttachPoint4,
myPoint3,
myPoint4,
mySymbolPrs );
else
AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( aPresentation,
myDrawer,
myArrowSize,
myShape3,
myShape4,
myPlane,
myAutomaticPosition,
myIsSetBndBox,
myBndBox,
Position34,
myAttachPoint3,
myAttachPoint4,
myPoint3,
myPoint4,
mySymbolPrs );
DsgPrs_EqualDistancePresentation::Add( aPresentation, myDrawer,
myPoint1, myPoint2, myPoint3, myPoint4, myPlane );
}
//=======================================================================
//function : Compute
//purpose : to avoid warning at compilation (SUN)
//=======================================================================
void AIS_EqualDistanceRelation::Compute( const Handle( Prs3d_Projector )& aProjector,
const Handle( Prs3d_Presentation )& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_EqualDistanceRelation::Compute( const Handle( Prs3d_Projector )&,
// const Handle( Prs3d_Presentation )& )");
// PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
//=======================================================================
//function : Compute
//purpose : to avoid warning at compilation (SUN)
//=======================================================================
void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManager2d )& aPresentationManager2d,
const Handle( Graphic2d_GraphicObject )& aGraphicObject,
const Standard_Integer anInteger)
{
// Standard_NotImplemented::Raise("AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManager2d )&,
// const Handle( Graphic2d_GraphicObject )&,const Standard_Integer )");
// PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
//=======================================================================
//function : Compute
//purpose : to avoid warning at compilation (SUN)
//=======================================================================
void AIS_EqualDistanceRelation::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Geom_Transformation)& aTransformation,
const Handle(Prs3d_Presentation)& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_EqualDistanceRelation::Compute(const Handle(Prs3d_Projector)&,
// const Handle(Geom_Transformation)&,const Handle(Prs3d_Presentation)&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Selection )& aSelection,
const Standard_Integer )
{
Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 );
Handle( Select3D_SensitiveSegment ) seg;
seg = new Select3D_SensitiveSegment( own, myPoint1, myPoint2 );
aSelection->Add( seg );
seg = new Select3D_SensitiveSegment( own, myPoint3, myPoint4 );
aSelection->Add( seg );
// Line between two middles
gp_Pnt Middle12( (myPoint1.XYZ() + myPoint2.XYZ()) * 0.5 ),
Middle34( (myPoint3.XYZ() + myPoint4.XYZ()) *0.5 );
seg = new Select3D_SensitiveSegment( own, Middle12, Middle34 );
aSelection->Add( seg );
gp_Pnt Middle((Middle12.XYZ() + Middle34.XYZ())*0.5);
Standard_Real SmallDist = .001;
Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
Middle.X() - SmallDist,
Middle.Y() - SmallDist,
Middle.Z() - SmallDist,
Middle.X() + SmallDist,
Middle.Y() + SmallDist,
Middle.Z() + SmallDist );
aSelection->Add(box);
if (myFShape.ShapeType() == TopAbs_EDGE){
BRepAdaptor_Curve aCurve(TopoDS::Edge(myFShape));
if (aCurve.GetType() == GeomAbs_Line){
//add sensetive element - line
seg = new Select3D_SensitiveSegment( own, myAttachPoint1, myPoint1);
aSelection->Add( seg );
}
else if (aCurve.GetType() == GeomAbs_Circle){
Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint1),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint1);
if (LastPar < FirstPar ) LastPar+=PI*2;
//add sensetive arc
Handle(Select3D_SensitiveCircle) circ =
new Select3D_SensitiveCircle( own, aCircle, FirstPar, LastPar);
aSelection->Add( circ );
}
}
else {
seg = new Select3D_SensitiveSegment( own, myAttachPoint1, myPoint1);
aSelection->Add( seg );
}
if (mySShape.ShapeType() == TopAbs_EDGE){
BRepAdaptor_Curve aCurve(TopoDS::Edge(mySShape));
if (aCurve.GetType() == GeomAbs_Line) {
//add sensetive element - line
seg = new Select3D_SensitiveSegment( own, myAttachPoint2, myPoint2);
aSelection->Add( seg );
}
else if (aCurve.GetType() == GeomAbs_Circle){
Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint2),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint2);
if (LastPar < FirstPar ) LastPar+=PI*2;
//add sensetive arc
Handle(Select3D_SensitiveCircle) circ =
new Select3D_SensitiveCircle( own,aCircle, FirstPar, LastPar);
aSelection->Add( circ );
}
}
else {
seg = new Select3D_SensitiveSegment( own, myAttachPoint2, myPoint2);
aSelection->Add( seg );
}
if (myShape3.ShapeType() == TopAbs_EDGE){
BRepAdaptor_Curve aCurve(TopoDS::Edge(myShape3));
if (aCurve.GetType() == GeomAbs_Line) {
//add sensetive element - line
seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
aSelection->Add( seg );
}
else if (aCurve.GetType() == GeomAbs_Circle){
Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint3),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint3);
if (LastPar < FirstPar ) LastPar+=PI*2;
Handle(Select3D_SensitiveCircle) circ =
new Select3D_SensitiveCircle( own, aCircle, FirstPar, LastPar);
aSelection->Add( circ );
}
else {
seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
aSelection->Add( seg );
}
}
else {
seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
aSelection->Add( seg );
}
if (myShape4.ShapeType() == TopAbs_EDGE){
BRepAdaptor_Curve aCurve(TopoDS::Edge(myShape4));
if (aCurve.GetType() == GeomAbs_Line) {
//add sensetive element - line
seg = new Select3D_SensitiveSegment( own, myAttachPoint4, myPoint4);
aSelection->Add( seg );
}
else if (aCurve.GetType() == GeomAbs_Circle){
Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint4),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint4);
if (LastPar < FirstPar ) LastPar+=PI*2;
//add sensetive arc
Handle(Select3D_SensitiveCircle) circ =
new Select3D_SensitiveCircle( own,aCircle, FirstPar, LastPar);
aSelection->Add( circ );
}
}
else {
seg = new Select3D_SensitiveSegment( own, myAttachPoint4, myPoint4);
aSelection->Add( seg );
}
}
//=======================================================================
//function : ComputeTwoEdgesLength
//purpose :
//=======================================================================
void AIS_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Presentation )& aPresentation,
const Handle( AIS_Drawer )& aDrawer,
const Standard_Real ArrowSize,
const TopoDS_Edge & FirstEdge,
const TopoDS_Edge & SecondEdge,
const Handle( Geom_Plane )& Plane,
const Standard_Boolean AutomaticPos,
const Standard_Boolean IsSetBndBox,
const Bnd_Box & BndBox,
gp_Pnt& Position,
gp_Pnt& FirstAttach,
gp_Pnt& SecondAttach,
gp_Pnt& FirstExtreme,
gp_Pnt& SecondExtreme,
DsgPrs_ArrowSide & SymbolPrs )
{
gp_Dir DirAttach;
BRepAdaptor_Curve cu1( FirstEdge );
BRepAdaptor_Curve cu2( SecondEdge );
// 3d lines
Handle(Geom_Curve) geom1,geom2;
gp_Pnt ptat11,ptat12,ptat21,ptat22;
Standard_Boolean isInfinite1(Standard_False),isInfinite2(Standard_False);
Handle(Geom_Curve) extCurv;
Standard_Real arrsize = ArrowSize;// size
Standard_Real Val=0.;
Standard_Boolean isInPlane1, isInPlane2;
if(!AIS::ComputeGeometry(FirstEdge,geom1, ptat11, ptat12,extCurv,isInfinite1,isInPlane1, Plane ))
return;
if(!AIS::ComputeGeometry(SecondEdge, geom2, ptat21, ptat22, extCurv, isInfinite2,isInPlane2, Plane))
return;
aPresentation->SetInfiniteState(isInfinite1 || isInfinite2);
if (cu1.GetType() == GeomAbs_Line && cu2.GetType() == GeomAbs_Line)
{
const Handle(Geom_Line)& geom_lin1 = (Handle(Geom_Line)&) geom1;
const Handle(Geom_Line)& geom_lin2 = (Handle(Geom_Line)&) geom2;
const gp_Lin& l1 = geom_lin1->Lin();
const gp_Lin& l2 = geom_lin2->Lin();
//Get Val value
Val = l1.Distance( l2 );
DirAttach = l1.Direction();
if (AutomaticPos) {
// compute position of offset point
gp_Pnt curpos;
Standard_Real par1=0., par2=0.;
if(!(isInfinite1 || isInfinite2))
{
par1 = ElCLib::Parameter(l1,ptat11);
par2 = ElCLib::Parameter(l1,ptat21);
if (par1 <par2){//project ptat11 on l2
gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l2,ptat11),l2);
curpos.SetXYZ((ptat11.XYZ()+p2.XYZ())*0.5);
}
else {//project ptat21 on l1
gp_Pnt p2 = ElCLib::Value(par2, l1);
curpos.SetXYZ((ptat21.XYZ()+p2.XYZ())*0.5);
}
}
else if (!isInfinite1){
par2 = ElCLib::Parameter(l1,ptat21);
gp_Pnt p2 = ElCLib::Value(par2,l1);
curpos.SetXYZ((ptat21.XYZ()+p2.XYZ())/2.);
}
else if (!isInfinite2) {
gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l2,ptat11),l2);
curpos.SetXYZ((ptat11.XYZ()+p2.XYZ())*0.5);
}
else
curpos.SetXYZ((l1.Location().XYZ()+l2.Location().XYZ())*0.5);
// compute offset
gp_Vec offset(DirAttach);
offset = offset*ArrowSize*(-10.);
curpos.Translate(offset);
Position = curpos;
}
else { // project point on the plane
Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );
}
// recherche points attache
if (!isInfinite1) {
if (Position.Distance(ptat11) > Position.Distance(ptat12)) FirstAttach = ptat12;
else FirstAttach = ptat11;
}
else {
FirstAttach = ElCLib::Value(ElCLib::Parameter(l1,Position),l1);
}
if (!isInfinite2) {
if (Position.Distance(ptat21) > Position.Distance(ptat22)) SecondAttach = ptat22;
else SecondAttach = ptat21;
}
else {
SecondAttach = ElCLib::Value(ElCLib::Parameter(l2,Position),l2);
}
Standard_Real confusion(Precision::Confusion());
if (arrsize < confusion) arrsize = Val*0.1;
if (Abs(Val) <= confusion) {arrsize = 0.;}
Handle(Prs3d_LengthAspect) la = aDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
arr->SetLength(arrsize);
arr = la->Arrow2Aspect();
arr->SetLength(arrsize);
if (AutomaticPos && IsSetBndBox)
Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox );
DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
aDrawer,
FirstAttach,
SecondAttach,
DirAttach,
Position,
SymbolPrs,
FirstExtreme,
SecondExtreme);
}
if (cu1.GetType() == GeomAbs_Circle && cu2.GetType() == GeomAbs_Circle){
//Get first and last points of circles
const Handle(Geom_Circle)& aCir1 = Handle(Geom_Circle)::DownCast(geom1);
const Handle(Geom_Circle)& aCir2 = Handle(Geom_Circle)::DownCast(geom2);
gp_Circ aCirc1 = aCir1->Circ();
gp_Circ aCirc2 = aCir2->Circ();
//To avoid circles with different orientaion
Standard_Real aTol = Precision::Confusion();
if(aCirc2.Axis().IsOpposite(aCirc1.Axis(), aTol) ||
aCirc2.XAxis().IsOpposite(aCirc1.XAxis(), aTol) ||
aCirc2.YAxis().IsOpposite(aCirc1.YAxis(), aTol) )
{
aCirc2.SetPosition(aCirc1.Position());
aCirc2.SetAxis(aCirc1.Axis());
}
if (AutomaticPos){
Standard_Real par1 = 0, par2 = 0;
gp_Pln aPln = Plane->Pln();
//Project ptat12 and ptat22 on constraint plane
gp_Pnt PrPnt12 = AIS::ProjectPointOnPlane(ptat12, aPln);
gp_Pnt PrPnt22 = AIS::ProjectPointOnPlane(ptat22, aPln);
//Project circles center on constraint plane
gp_Pnt PrCenter = AIS::ProjectPointOnPlane(aCirc1.Location(), aPln);
gp_Dir XDir = aPln.XAxis().Direction();
gp_Dir YDir = aPln.YAxis().Direction();
if (PrPnt12.Distance(PrCenter) >Precision::Confusion())
{
gp_Dir aDir1(PrPnt12.XYZ() - PrCenter.XYZ());
Standard_Real anAngle = aDir1.Angle(XDir); //Get the angle in range [0, PI]
if (aDir1.Dot(YDir) < 0)
anAngle = 2*Standard_PI - anAngle;
par1 = anAngle;
}
if (PrPnt22.Distance(PrCenter) >Precision::Confusion())
{
gp_Dir aDir2(PrPnt22.XYZ() - PrCenter.XYZ());
Standard_Real anAngle = aDir2.Angle(XDir); //Get the angle in range [0, PI]
if (aDir2.Dot(YDir) < 0)
anAngle = 2*Standard_PI - anAngle;
par2 = anAngle;
}
if(par1 > par2 ){
FirstExtreme = ptat12;
Standard_Real aPar1 = ElCLib::Parameter(aCirc2, ptat12);
SecondExtreme = ElCLib::Value(aPar1, aCirc2);
}
else {
Standard_Real aPar2 = ElCLib::Parameter(aCirc1, ptat22);
FirstExtreme = ElCLib::Value(aPar2, aCirc1);
SecondExtreme = ptat22;
}
}
else {
Standard_Real pospar = ElCLib::Parameter(aCirc1, Position);
FirstExtreme = ElCLib::Value(pospar, aCirc1);
pospar = ElCLib::Parameter(aCirc2, Position);
SecondExtreme = ElCLib::Value(pospar, aCirc2);
}
DsgPrs_EqualDistancePresentation::AddIntervalBetweenTwoArcs(aPresentation,
aDrawer,
aCirc1,
aCirc2,
ptat12,
FirstExtreme,
ptat22,
SecondExtreme,
SymbolPrs);
FirstAttach = ptat12; SecondAttach = ptat22; //assign attach points
Position.SetXYZ( (FirstAttach.XYZ() + SecondAttach.XYZ())*0.5);
}
if (arrsize < Precision::Confusion()) arrsize = Val*0.1;
if (Abs(Val) <= Precision::Confusion()) {arrsize = 0.;}
// gp_Pnt pf, pl;
if (!isInPlane1) {
AIS::ComputeProjEdgePresentation( aPresentation, aDrawer, FirstEdge, geom1, ptat11, ptat12);
}
if(!isInPlane2) {
AIS::ComputeProjEdgePresentation( aPresentation, aDrawer, SecondEdge, geom2, ptat21, ptat22);
}
}
//=======================================================================
//function : ComputeTwoVerticesLength
//purpose :
//=======================================================================
void AIS_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Presentation )& aPresentation,
const Handle( AIS_Drawer )& aDrawer,
const Standard_Real ArrowSize,
const TopoDS_Vertex& FirstVertex,
const TopoDS_Vertex& SecondVertex,
const Handle( Geom_Plane )& Plane,
const Standard_Boolean AutomaticPos,
const Standard_Boolean IsSetBndBox,
const Bnd_Box& BndBox,
const AIS_TypeOfDist TypeDist,
gp_Pnt& Position,
gp_Pnt& FirstAttach,
gp_Pnt& SecondAttach,
gp_Pnt& FirstExtreme,
gp_Pnt& SecondExtreme,
DsgPrs_ArrowSide& SymbolPrs )
{
Standard_Boolean isOnPlane1, isOnPlane2;
gp_Dir DirAttach;
AIS::ComputeGeometry( FirstVertex, FirstAttach, Plane, isOnPlane1);
AIS::ComputeGeometry( SecondVertex, SecondAttach, Plane, isOnPlane2);
//Computation of Val
Standard_Real Val = FirstAttach.Distance( SecondAttach );
Standard_Real confusion(Precision::Confusion());
Standard_Boolean samePoint(FirstAttach.IsEqual(SecondAttach,confusion));
if (TypeDist == AIS_TOD_Vertical) DirAttach = Plane->Pln().XAxis().Direction();
else if (TypeDist == AIS_TOD_Horizontal) DirAttach = Plane->Pln().YAxis().Direction();
else {
if (!samePoint) {
DirAttach.SetXYZ(SecondAttach.XYZ() - FirstAttach.XYZ());
DirAttach.Rotate(Plane->Pln().Axis(),PI/2.);
}
}
// size
Standard_Real arrsize = ArrowSize;
if (Abs(Val) <= confusion) arrsize =0.;
if (AutomaticPos) {
if (!samePoint) {
gp_Pnt curpos((FirstAttach.XYZ()+SecondAttach.XYZ())*0.5);
// make offset of curpos
gp_Vec offset(DirAttach);
offset = offset*ArrowSize*(-10.);
curpos.Translate(offset);
Position = curpos;
}
else {
const gp_Dir& aDir = Plane->Pln().Axis().Direction();
gp_Vec aVec (aDir.XYZ()*10*ArrowSize);
//Position = gp_Pnt(FirstAttach.XYZ()+gp_XYZ(1.,1.,1.)); // not correct
Position = FirstAttach.Translated(aVec);
Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );//not needed really
DirAttach.SetXYZ(Position.XYZ() - FirstAttach.XYZ());
}
}
else {
Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );
}
Handle(Prs3d_LengthAspect) la = aDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
arr->SetLength(ArrowSize);
arr = la->Arrow2Aspect();
arr->SetLength(ArrowSize);
if (AutomaticPos && IsSetBndBox)
Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox );
DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
aDrawer,
FirstAttach,
SecondAttach,
DirAttach,
Position,
SymbolPrs,
FirstExtreme, //returned
SecondExtreme); //returned
// Compute projection
if ( !isOnPlane1)
AIS::ComputeProjVertexPresentation(aPresentation, aDrawer, FirstVertex, FirstAttach);
if ( !isOnPlane2)
AIS::ComputeProjVertexPresentation(aPresentation, aDrawer, SecondVertex, SecondAttach);
}
//=======================================================================
//function : ComputeOneEdgeOneVertexLength
//purpose :
//=======================================================================
void AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( const Handle( Prs3d_Presentation )& aPresentation,
const Handle( AIS_Drawer )& aDrawer,
const Standard_Real ArrowSize,
const TopoDS_Shape & FirstShape,
const TopoDS_Shape & SecondShape,
const Handle( Geom_Plane )& Plane,
const Standard_Boolean AutomaticPos,
const Standard_Boolean IsSetBndBox,
const Bnd_Box & BndBox,
gp_Pnt & Position,
gp_Pnt & FirstAttach,
gp_Pnt & SecondAttach,
gp_Pnt& FirstExtreme,
gp_Pnt& SecondExtreme,
DsgPrs_ArrowSide & SymbolPrs )
{
TopoDS_Vertex thevertex;
TopoDS_Edge theedge;
gp_Pnt ptonedge1,ptonedge2;
Handle(Geom_Curve) aCurve;
Handle(Geom_Curve) extCurv;
Standard_Boolean isInfinite;
Standard_Real Val;
Standard_Boolean isOnPlanEdge, isOnPlanVertex;
Standard_Integer edgenum ;
if (FirstShape.ShapeType() == TopAbs_VERTEX) {
thevertex = TopoDS::Vertex(FirstShape);
theedge = TopoDS::Edge(SecondShape);
edgenum = 2; //edge is the second shape
}
else {
thevertex = TopoDS::Vertex(SecondShape);
theedge = TopoDS::Edge(FirstShape);
edgenum = 1;//edge is the first shape
}
if (!AIS::ComputeGeometry(theedge,aCurve,ptonedge1,ptonedge2,extCurv,isInfinite,isOnPlanEdge,Plane))
return;
aPresentation->SetInfiniteState(isInfinite);
AIS::ComputeGeometry(thevertex, FirstAttach, Plane, isOnPlanVertex);
if ( aCurve->IsInstance(STANDARD_TYPE(Geom_Line)) )
{
const Handle(Geom_Line)& geom_lin = (Handle(Geom_Line)&) aCurve;
const gp_Lin& l = geom_lin->Lin();
// computation of Val
Val = l.Distance( FirstAttach );
gp_Dir DirAttach = l.Direction();
// size
Standard_Real arrsize = ArrowSize;
if (Abs(Val) <= Precision::Confusion()) {arrsize = 0.;}
if (AutomaticPos) {
gp_Pnt p = ElCLib::Value(ElCLib::Parameter(l,FirstAttach),l);
gp_Pnt curpos((FirstAttach.XYZ()+p.XYZ())*0.5);
// make offset
gp_Vec offset(DirAttach);
offset = offset*ArrowSize*(-10.);
curpos.Translate(offset);
Position = curpos;
}
else { // project point on the plane
Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );
}
if (!isInfinite) {
if (Position.Distance(ptonedge1) > Position.Distance(ptonedge2)) SecondAttach = ptonedge2;
else SecondAttach = ptonedge1;
}
else {
SecondAttach = ElCLib::Value(ElCLib::Parameter(l,Position),l);
}
Handle(Prs3d_LengthAspect) la = aDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
arr->SetLength(arrsize);
arr = la->Arrow2Aspect();
arr->SetLength(arrsize);
if (AutomaticPos && IsSetBndBox)
Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox );
DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
aDrawer,
FirstAttach,
SecondAttach,
DirAttach,
Position,
SymbolPrs,
FirstExtreme,
SecondExtreme);
}
if (aCurve->IsInstance(STANDARD_TYPE(Geom_Circle))){
gp_Circ aCirc1 = (Handle(Geom_Circle)::DownCast(aCurve))->Circ();
gp_Circ aCirc2(aCirc1); aCirc2.SetRadius(0); //create the second formal circle
if(AutomaticPos)
{
SecondAttach = ptonedge2; //a vertex
Position.SetXYZ((SecondAttach.XYZ() + aCirc1.Location().XYZ())*0.5);
}
else {
Standard_Real aPar = ElCLib::Parameter(aCirc1, Position);
SecondAttach = ElCLib::Value(aPar, aCirc1);
}
Handle(Geom_Circle) aCurve2 = new Geom_Circle(aCirc2);
DsgPrs_EqualDistancePresentation::AddIntervalBetweenTwoArcs(aPresentation,
aDrawer,
aCirc1, //circle or arc
aCirc2, //really vertex
ptonedge2, //last point of aCirc1
SecondAttach,
FirstAttach, //vertex really
FirstAttach,
SymbolPrs);
//Assign arc points
if (edgenum == 1){
FirstExtreme = SecondAttach; SecondExtreme = FirstAttach;
SecondAttach = FirstAttach; FirstAttach = ptonedge2;
} else { //vertex is the first shape, circle is sthe last.
FirstExtreme = FirstAttach; SecondExtreme = SecondAttach;
SecondAttach = ptonedge2;
}
}
// computation of Val
Val = FirstAttach.Distance(SecondAttach);
//Display des morceaux de raccordement vers la curve si elle
// n'est pas dans le WP
if (!isOnPlanEdge) { // add presentation of projection of the edge in WP
AIS::ComputeProjEdgePresentation(aPresentation,aDrawer,theedge,aCurve,ptonedge1,ptonedge2);
}
if (!isOnPlanVertex) { // add presentation of projection of the vertex in WP
AIS::ComputeProjVertexPresentation(aPresentation,aDrawer,thevertex,FirstAttach);
}
}
// -- ota -- end

View File

@@ -0,0 +1,46 @@
// File: AIS_EqualDistanceRelation.lxx
// Created: Sat Jan 24 18:56:29 1998
// Author: Julia GERASIMOVA
// <jgv@leonox.nnov.matra-dtv.fr>
//=======================================================================
//function : SetShape3
//purpose :
//=======================================================================
inline void AIS_EqualDistanceRelation::SetShape3( const TopoDS_Shape& aShape )
{
myShape3 = aShape;
}
//=======================================================================
//function : Shape3
//purpose :
//=======================================================================
inline const TopoDS_Shape& AIS_EqualDistanceRelation::Shape3() const
{
return myShape3;
}
//=======================================================================
//function : SetShape4
//purpose :
//=======================================================================
inline void AIS_EqualDistanceRelation::SetShape4( const TopoDS_Shape& aShape )
{
myShape4 = aShape;
}
//=======================================================================
//function : Shape4
//purpose :
//=======================================================================
inline const TopoDS_Shape& AIS_EqualDistanceRelation::Shape4() const
{
return myShape4;
}

View File

@@ -0,0 +1,81 @@
-- File: AIS_EqualRadiusRelation.cdl
-- Created: Sat Jan 17 13:42:18 1998
-- Author: Julia GERASIMOVA
-- <jgv@orthodox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class EqualRadiusRelation from AIS inherits Relation from AIS
---Purpose:
uses
Edge from TopoDS,
Plane from Geom,
PresentationManager3d from PrsMgr,
Presentation from Prs3d,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Selection from SelectMgr,
Pnt from gp
is
Create( aFirstEdge : Edge from TopoDS;
aSecondEdge : Edge from TopoDS;
aPlane : Plane from Geom )
---Purpose: Creates equal relation of two arc's radiuses.
-- If one of edges is not in the given plane,
-- the presentation method projects it onto the plane.
returns mutable EqualRadiusRelation from AIS;
-- Methods from PresentableObject
Compute( me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0 )
is redefined static private;
Compute( me : mutable;
aProjector : Projector from Prs3d;
aPresentation : mutable Presentation from Prs3d )
is redefined static private;
Compute( me : mutable;
aPresentationManager : PresentationManager2d from PrsMgr;
aPresentation : mutable GraphicObject from Graphic2d;
aMode : Integer from Standard = 0 )
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection( me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is private;
ComputeRadiusPosition(me: mutable) is private;
fields
myFirstCenter : Pnt from gp;
mySecondCenter : Pnt from gp;
myFirstPoint : Pnt from gp;
mySecondPoint : Pnt from gp;
end EqualRadiusRelation;

View File

@@ -0,0 +1,251 @@
// File: AIS_EqualRadiusRelation.cxx
// Created: Tue Jan 20 19:19:54 1998
// Author: Julia GERASIMOVA
// <jgv@orthodox.nnov.matra-dtv.fr>
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
// if any in all dimensions.
#include <Standard_NotImplemented.hxx>
#include <AIS_EqualRadiusRelation.ixx>
#include <AIS.hxx>
#include <DsgPrs_EqualRadiusPresentation.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopoDS.hxx>
#include <gp_Circ.hxx>
#include <Geom_Circle.hxx>
#include <ElCLib.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Precision.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Prs3d_LengthAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <AIS_Drawer.hxx>
//=======================================================================
//function : AIS_EqualRadiusRelation
//purpose :
//=======================================================================
AIS_EqualRadiusRelation::AIS_EqualRadiusRelation( const TopoDS_Edge& aFirstEdge,
const TopoDS_Edge& aSecondEdge,
const Handle( Geom_Plane )& aPlane )
:AIS_Relation()
{
myFShape = aFirstEdge;
mySShape = aSecondEdge;
myPlane = aPlane;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_EqualRadiusRelation::Compute( const Handle( PrsMgr_PresentationManager3d )&,
const Handle( Prs3d_Presentation )& aPresentation,
const Standard_Integer )
{
aPresentation->Clear();
BRepAdaptor_Curve FirstCurve( TopoDS::Edge( myFShape ) ), SecondCurve( TopoDS::Edge( mySShape ) );
Standard_Real FirstPar1 = FirstCurve.FirstParameter(), LastPar1 = FirstCurve.LastParameter(),
FirstPar2 = SecondCurve.FirstParameter(), LastPar2 = SecondCurve.LastParameter();
Handle( Geom_Curve ) FirstProjCurve = FirstCurve.Curve().Curve(),
SecondProjCurve = SecondCurve.Curve().Curve();
gp_Pnt FirstPoint1, LastPoint1, FirstPoint2, LastPoint2;
Standard_Boolean isFirstOnPlane, isSecondOnPlane;
AIS::ComputeGeomCurve( FirstProjCurve, FirstPar1, LastPar1, FirstPoint1, LastPoint1, myPlane, isFirstOnPlane );
AIS::ComputeGeomCurve( SecondProjCurve, FirstPar2, LastPar2, FirstPoint2, LastPoint2, myPlane, isSecondOnPlane );
if (!isFirstOnPlane)
ComputeProjEdgePresentation( aPresentation, TopoDS::Edge( myFShape ), FirstProjCurve, FirstPoint1, LastPoint1 );
if (! isSecondOnPlane)
ComputeProjEdgePresentation( aPresentation, TopoDS::Edge( mySShape ), SecondProjCurve, FirstPoint2, LastPoint2 );
gp_Circ FirstCirc = (Handle( Geom_Circle )::DownCast( FirstProjCurve ))->Circ();
gp_Circ SecondCirc = (Handle( Geom_Circle )::DownCast( SecondProjCurve ))->Circ();
myFirstCenter = FirstCirc.Location();
mySecondCenter = SecondCirc.Location();
//ota -- begin --
if (myAutomaticPosition)
{
myFirstPoint = ElCLib::Value( (FirstPar1 + LastPar1)*0.5, FirstCirc );
mySecondPoint = ElCLib::Value( (FirstPar2 + LastPar2)*0.5, SecondCirc );
}
else {
Standard_Real aPar = ElCLib::Parameter(FirstCirc, myFirstPoint);
if (IntegerPart(0.5*LastPar1/PI) != 0 && aPar < FirstPar1 )
aPar +=2*PI*IntegerPart(0.5*LastPar1/PI);
Standard_Real aRadius = FirstCirc.Radius();
if (Abs(myFirstPoint.Distance(myFirstCenter) - aRadius) >= Precision::Confusion())
myFirstPoint = ElCLib::Value(aPar, FirstCirc);
if ( FirstPoint1.Distance(LastPoint1) > Precision::Confusion()){
//check where is myFirstPoint
if (aPar > LastPar1 || aPar < FirstPar1)
{
//myFirstPoint is out of Arc of FirstCircle
if (FirstPoint1.Distance(myFirstPoint)< LastPoint1.Distance(myFirstPoint))
myFirstPoint = FirstPoint1;
else
myFirstPoint = LastPoint1;
}
}
aPar = ElCLib::Parameter(SecondCirc, mySecondPoint);
if (IntegerPart(0.5*LastPar2/PI) != 0 && aPar < FirstPar2 )
aPar +=2*PI*IntegerPart(0.5*LastPar2/PI);
aRadius = SecondCirc.Radius();
if (Abs(mySecondPoint.Distance(mySecondCenter) - aRadius) >= Precision::Confusion())
mySecondPoint = ElCLib::Value(aPar, SecondCirc);
if (FirstPoint2.Distance(LastPoint2) > Precision::Confusion()){
if (aPar > LastPar2 || aPar < FirstPar2)
{ //mySecondPoint is out of Arc of mySecondCircle
if (FirstPoint2.Distance(mySecondPoint)< LastPoint2.Distance(mySecondPoint))
mySecondPoint = FirstPoint2;
else
mySecondPoint = LastPoint2;
}
}
}
#ifdef BUC60915
if( !myArrowSizeIsDefined )
#endif
myArrowSize = (Min(myFirstCenter.Distance(myFirstPoint),
mySecondCenter.Distance(mySecondPoint)))*0.05;
Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
arr->SetLength(myArrowSize);
//ota -- end --
DsgPrs_EqualRadiusPresentation::Add(aPresentation, myDrawer,
myFirstCenter, mySecondCenter, myFirstPoint, mySecondPoint, myPlane );
}
//=======================================================================
//function : Compute
//purpose : to avoid warning at compilation (SUN)
//=======================================================================
void AIS_EqualRadiusRelation::Compute( const Handle( Prs3d_Projector )& /*aProjector*/,
const Handle( Prs3d_Presentation )& /*aPresentation*/)
{
// Standard_NotImplemented::Raise("AIS_EqualRadiusRelation::Compute( const Handle( Prs3d_Projector )&,const Handle( Prs3d_Presentation )& )");
// PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
//=======================================================================
//function : Compute
//purpose : to avoid warning at compilation (SUN)
//=======================================================================
void AIS_EqualRadiusRelation::Compute( const Handle( PrsMgr_PresentationManager2d )& /*aPresentationManager2d*/,
const Handle( Graphic2d_GraphicObject )& /*aGraphicObject*/,
const Standard_Integer /*anInteger*/)
{
// Standard_NotImplemented::Raise("AIS_EqualRadiusRelation::Compute( const Handle( PrsMgr_PresentationManager2d )&,const Handle( Graphic2d_GraphicObject )&,const Standard_Integer )");
// PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_EqualRadiusRelation::Compute(const Handle_Prs3d_Projector& aProjector,
const Handle_Geom_Transformation& aTransformation,
const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_EqualRadiusRelation::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_EqualRadiusRelation::ComputeSelection( const Handle( SelectMgr_Selection )& aSelection,
const Standard_Integer )
{
Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 );
Handle( Select3D_SensitiveSegment ) seg;
seg = new Select3D_SensitiveSegment( own, myFirstCenter, myFirstPoint );
aSelection->Add( seg );
if(!myAutomaticPosition)
ComputeRadiusPosition();
seg = new Select3D_SensitiveSegment( own, mySecondCenter, mySecondPoint );
aSelection->Add( seg );
seg = new Select3D_SensitiveSegment( own, myFirstCenter, mySecondCenter );
aSelection->Add( seg );
// Two small lines
gp_Pnt Middle( (myFirstCenter.XYZ() + mySecondCenter.XYZ())*0.5 );
Standard_Real SmallDist = .001;
//Should be changed as the domain of small lines could be changed.
Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox(own,
Middle.X() - SmallDist,
Middle.Y() - SmallDist,
Middle.Z() - SmallDist,
Middle.X() + SmallDist,
Middle.Y() + SmallDist,
Middle.Z() + SmallDist );
aSelection->Add(box);
}
//=================================================================
//function : ComputeRadiusPosition
//purpose :
//=================================================================
void AIS_EqualRadiusRelation::ComputeRadiusPosition()
{
if (myAutomaticPosition ||
myFirstCenter.Distance(myPosition) < Precision::Confusion() ||
mySecondCenter.Distance(myPosition) < Precision::Confusion())
return;
gp_Pnt aPosition;
//project myPosition to the plane of constraint
GeomAPI_ProjectPointOnSurf aProj(myPosition, myPlane);
aPosition = aProj.NearestPoint();
Standard_Real aDist1 = myFirstPoint.Distance(aPosition);
Standard_Real aDist2 = mySecondPoint.Distance(aPosition);
if(aDist1<aDist2)
{
Standard_Real Rad1 = myFirstPoint.Distance(myFirstCenter);
const gp_Dir aNewDir1(aPosition.XYZ() - myFirstCenter.XYZ());
const gp_Vec aTVec (aNewDir1.XYZ()*Rad1);
myFirstPoint = myFirstCenter.Translated(aTVec);
}
else {
Standard_Real Rad2 = mySecondPoint.Distance(mySecondCenter);
const gp_Dir aNewDir2(aPosition.XYZ() - mySecondCenter.XYZ());
gp_Vec aTVec (aNewDir2.XYZ()*Rad2);
mySecondPoint = mySecondCenter.Translated(aTVec);
}
}

112
src/AIS/AIS_ExclusionFilter.cdl Executable file
View File

@@ -0,0 +1,112 @@
-- File: AIS_ExclusionFilter.cdl
-- Created: Fri Nov 28 11:04:30 1997
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class ExclusionFilter from AIS inherits Filter from SelectMgr
---Purpose: A framework to reject or to accept only objects of
-- given types and/or signatures.
-- Objects are stored, and the stored objects - along
-- with the flag settings - are used to define the filter.
-- Objects to be filtered are compared with the stored
-- objects added to the filter, and are accepted or
-- rejected according to the exclusion flag setting.
-- - Exclusion flag on
-- - the function IsOk answers true for all objects,
-- except those of the types and signatures stored
-- in the filter framework
-- - Exclusion flag off
-- - the funciton IsOk answers true for all objects
-- which have the same type and signature as the stored ones.
uses
EntityOwner from SelectMgr,
KindOfInteractive from AIS,
ListOfInteger from TColStd,
DataMapOfIntegerListOfInteger from TColStd
is
Create(ExclusionFlagOn:Boolean from Standard = Standard_True)
returns mutable ExclusionFilter from AIS;
---Purpose: Constructs an empty exclusion filter object defined by
-- the flag setting ExclusionFlagOn.
-- By default, the flag is set to true.
Create(TypeToExclude : KindOfInteractive from AIS;
ExclusionFlagOn : Boolean from Standard = Standard_True)
returns mutable ExclusionFilter from AIS;
---Purpose: All the AIS objects of <TypeToExclude>
-- Will be rejected by the IsOk Method.
Create(TypeToExclude : KindOfInteractive from AIS;
SignatureInType :Integer from Standard ;
ExclusionFlagOn : Boolean from Standard = Standard_True)
returns mutable ExclusionFilter from AIS;
---Purpose: Constructs an exclusion filter object defined by the
-- enumeration value TypeToExclude, the signature
-- SignatureInType, and the flag setting ExclusionFlagOn.
-- By default, the flag is set to true.
IsOk(me; anObj : EntityOwner from SelectMgr)
returns Boolean from Standard
is redefined virtual;
---Category: Load Filter...
Add(me:mutable;TypeToExclude : KindOfInteractive from AIS)
returns Boolean from Standard;
---Purpose: Adds the type TypeToExclude to the list of types.
Add(me:mutable;
TypeToExclude : KindOfInteractive from AIS;
SignatureInType : Integer from Standard)
returns Boolean from Standard;
Remove(me:mutable;
TypeToExclude:KindOfInteractive from AIS)
returns Boolean from Standard;
Remove(me:mutable;
TypeToExclude:KindOfInteractive from AIS;
SignatureInType : Integer from Standard)
returns Boolean from Standard;
Clear(me:mutable);
---Category: Information about Filter...
IsExclusionFlagOn(me) returns Boolean from Standard;
---C++: inline
SetExclusionFlag(me:mutable; Status : Boolean from Standard);
---C++: inline
IsStored(me;aType:KindOfInteractive from AIS) returns Boolean from Standard;
ListOfStoredTypes( me; TheList: in out ListOfInteger from TColStd);
ListOfSignature(me;
aType : KindOfInteractive from AIS;
TheStoredList : in out ListOfInteger from TColStd);
IsSignatureIn(me;aType:KindOfInteractive from AIS;aSignature:Integer from Standard)
returns Boolean from Standard is static private;
fields
myIsExclusionFlagOn : Boolean from Standard;
myStoredTypes : DataMapOfIntegerListOfInteger from TColStd;
end ExclusionFilter;

196
src/AIS/AIS_ExclusionFilter.cxx Executable file
View File

@@ -0,0 +1,196 @@
// File: AIS_ExclusionFilter.cxx
// Created: Fri Nov 28 14:20:52 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
#include <AIS_ExclusionFilter.ixx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
#include <AIS_InteractiveObject.hxx>
//=======================================================================
//function : AIS_ExclusionFilter
//purpose : Constructors
//=======================================================================
AIS_ExclusionFilter::AIS_ExclusionFilter(const Standard_Boolean ExclusionFlagOn):
myIsExclusionFlagOn(ExclusionFlagOn)
{
}
AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
const Standard_Boolean ExclusionFlagOn):
myIsExclusionFlagOn(ExclusionFlagOn)
{
TColStd_ListOfInteger L;
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L);
}
AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType,
const Standard_Boolean ExclusionFlagOn):
myIsExclusionFlagOn(ExclusionFlagOn)
{
TColStd_ListOfInteger L;
L.Append(SignatureInType);
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L);
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExclude)
{
if(IsStored(TypeToExclude))
return Standard_False;
TColStd_ListOfInteger L;
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L);
return Standard_True;
}
Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType)
{
if(!IsStored(TypeToExclude)){
TColStd_ListOfInteger L;
L.Append(SignatureInType);
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L);
return Standard_True;
}
myStoredTypes((Standard_Integer)TypeToExclude).Append(SignatureInType);
return Standard_True;
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToExclude)
{
if(!IsStored(TypeToExclude)) return Standard_False;
myStoredTypes((Standard_Integer)TypeToExclude).Clear();
myStoredTypes.UnBind((Standard_Integer)TypeToExclude);
return Standard_True;
}
Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType)
{
if(!IsStored(TypeToExclude)) return Standard_False;
TColStd_ListOfInteger& LL = myStoredTypes.ChangeFind((Standard_Integer)TypeToExclude);
for(TColStd_ListIteratorOfListOfInteger it(LL);it.More();it.Next()){
if(it.Value()==SignatureInType){
LL.Remove(it);
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void AIS_ExclusionFilter::Clear()
{
TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger Mit(myStoredTypes);
for(;Mit.More();Mit.Next())
myStoredTypes.ChangeFind(Mit.Key()).Clear();
myStoredTypes.Clear();
}
//=======================================================================
//function : IsStored
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::IsStored(const AIS_KindOfInteractive aType) const
{
return myStoredTypes.IsBound(Standard_Integer(aType));
}
//=======================================================================
//function : IsSignatureIn
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::IsSignatureIn(const AIS_KindOfInteractive aType,
const Standard_Integer SignatureInType) const
{
if(!myStoredTypes.IsBound(aType)) return Standard_False;
for(TColStd_ListIteratorOfListOfInteger Lit(myStoredTypes((Standard_Integer)aType));
Lit.More();
Lit.Next()){
if(Lit.Value()==SignatureInType)
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : ListOfStoredTypes
//purpose :
//=======================================================================
void AIS_ExclusionFilter::ListOfStoredTypes(TColStd_ListOfInteger& TheList) const
{
TheList.Clear();
TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger MIT(myStoredTypes);
for(;MIT.More();MIT.Next())
TheList.Append(MIT.Key());
}
//=======================================================================
//function : ListOfSignature
//purpose :
//=======================================================================
void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,TColStd_ListOfInteger& TheStoredList) const
{
TheStoredList.Clear();
if(IsStored(aType))
for(TColStd_ListIteratorOfListOfInteger it(myStoredTypes(aType));it.More();it.Next())
TheStoredList.Append(it.Value());
}
//=======================================================================
//function : IsOk
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
if(myStoredTypes.IsEmpty())
return myIsExclusionFlagOn;
if(EO.IsNull())
return Standard_False;
Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable());
if(IO.IsNull())
return Standard_False;
// le type de l'ais n'est pas dans la map...
if(!myStoredTypes.IsBound(IO->Type()))
return myIsExclusionFlagOn ;
// le type de l'ais est dans la map et il n'y a pas de signature precisee
if(myStoredTypes(IO->Type()).IsEmpty())
return !myIsExclusionFlagOn ;
// il y a une ou des signatures precisees...
if(IsSignatureIn(IO->Type(),IO->Signature()))
return !myIsExclusionFlagOn;
return myIsExclusionFlagOn;
}

12
src/AIS/AIS_ExclusionFilter.lxx Executable file
View File

@@ -0,0 +1,12 @@
inline Standard_Boolean AIS_ExclusionFilter::IsExclusionFlagOn() const
{
return myIsExclusionFlagOn;
}
inline void AIS_ExclusionFilter::SetExclusionFlag(const Standard_Boolean Status)
{
myIsExclusionFlagOn = Status;
}

194
src/AIS/AIS_FixRelation.cdl Executable file
View File

@@ -0,0 +1,194 @@
-- File: AIS_FixRelation.cdl
-- Created: Thu Dec 5 10:08:10 1996
-- Author: Flore Lantheaume/Odile Olivier
-- <odl@sacadox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class FixRelation from AIS inherits Relation from AIS
---Purpose: Constructs and manages a constraint by a fixed
-- relation between two or more interactive datums. This
-- constraint is represented by a wire from a shape -
-- point, vertex, or edge - in the first datum and a
-- corresponding shape in the second.
-- Warning: This relation is not bound with any kind of parametric
-- constraint : it represents the "status" of an parametric
-- object.
uses
PresentationManager3d from PrsMgr,
Presentation from Prs3d,
Selection from SelectMgr,
Shape from TopoDS,
Vertex from TopoDS,
Edge from TopoDS,
Wire from TopoDS,
Curve from Geom,
Circ from gp,
Lin from gp,
Pnt from gp,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Plane from Geom
is
Create (aShape : Shape from TopoDS;
aPlane : Plane from Geom;
aWire : Wire from TopoDS)
---Purpose: initializes the vertex aShape, the
-- plane aPlane and the wire aWire, which connects
-- the two vertices in a fixed relation.
returns mutable FixRelation from AIS;
Create (aShape : Shape from TopoDS;
aPlane : Plane from Geom;
aWire : Wire from TopoDS;
aPosition : Pnt from gp;
anArrowSize : Real from Standard = 0.01)
---Purpose: initializes the vertex aShape, the
-- plane aPlane and the wire aWire, the position
-- aPosition, the arrow size anArrowSize and the
-- wire aWire, which connects the two vertices in a fixed relation.
returns mutable FixRelation from AIS;
Create (aShape : Shape from TopoDS;
aPlane : Plane from Geom)
---Purpose: initializes the edge aShape and the plane aPlane.
returns mutable FixRelation from AIS;
Create (aShape : Shape from TopoDS;
aPlane : Plane from Geom;
aPosition : Pnt from gp;
anArrowSize : Real from Standard = 0.01)
---Purpose: initializes the edge aShape, the
-- plane aPlane, the position aPosition and the arrow
-- size anArrowSize.
returns mutable FixRelation from AIS;
Wire(me: mutable) returns Wire from TopoDS
is static;
---Purpose: Returns the wire which connects vertices in a fixed relation.
SetWire(me: mutable;aWire : Wire from TopoDS)
is static;
--- Purpose: Constructs the wire aWire. This connects vertices
-- which are in a fixed relation.
IsMovable(me) returns Boolean from Standard
---C++: inline
---Purpose: Returns true if the Interactive Objects in the relation
-- are movable.
is redefined;
-- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined static private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
--
-- Computation private methods
--
ComputeVertex(me : mutable;
FixVertex : Vertex from TopoDS;
curpos : out Pnt from gp)
---Purpose: computes the presentation for <myFixShape> if it's a
-- vertex.
is private;
ComputePosition(me;
curv1 : Curve from Geom;
curv2 : Curve from Geom;
firstp1 : Pnt from gp;
lastp1 : Pnt from gp ;
firstp2 : Pnt from gp;
lastp2 : Pnt from gp)
returns Pnt from gp
is private;
ComputePosition(me;
curv : Curve from Geom;
firstp : Pnt from gp;
lastp : Pnt from gp)
returns Pnt from gp
is private;
ComputeEdge(me : mutable;
FixEdge : Edge from TopoDS;
curpos : out Pnt from gp)
---Purpose: computes the presentation for <myFixShape> if it's a
-- edge.
is private;
ComputeLinePosition(me : mutable;
glin : Lin from gp;
pos : out Pnt from gp;
pfirst : out Real from Standard;
plast : out Real from Standard)
is private;
ComputeCirclePosition(me : mutable;
gcirc : Circ from gp;
pos : out Pnt from gp;
pfirst : out Real from Standard;
plast : out Real from Standard)
is private;
ConnectedEdges(myclass; aWire : Wire from TopoDS;
aVertex : Vertex from TopoDS;
Edge1,Edge2 : out Edge from TopoDS)
returns Boolean from Standard
is private;
fields
myWire : Wire from TopoDS;
myPntAttach : Pnt from gp;
haspos : Boolean from Standard;
end FixRelation;

628
src/AIS/AIS_FixRelation.cxx Executable file
View File

@@ -0,0 +1,628 @@
// File: AIS_FixRelation.cdl
// Created: Tue Dec 5 15:09:04 1996
// Author: Flore Lantheaume/Odile Olivier
// <ODL>
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
// if any in all dimensions.
#include <Standard_NotImplemented.hxx>
#include <AIS_FixRelation.ixx>
#include <AIS_Shape.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopExp.hxx>
#include <TopLoc_Location.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TColStd_ListIteratorOfListOfTransient.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Plane.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_XYZ.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <Precision.hxx>
#include <Standard_DomainError.hxx>
#include <DsgPrs_FixPresentation.hxx>
#include <AIS.hxx>
static Standard_Boolean InDomain(const Standard_Real fpar,
const Standard_Real lpar,
const Standard_Real para)
{
if (fpar >= 0.) {
return ((para >= fpar) && (para <= lpar));
}
if (para >= (fpar+2*PI)) return Standard_True;
if (para <= lpar) return Standard_True;
return Standard_False;
}
//=======================================================================
//function : Constructor
//purpose : vertex Fix Relation
//=======================================================================
AIS_FixRelation::AIS_FixRelation(const TopoDS_Shape& aShape,
const Handle(Geom_Plane)& aPlane,
const TopoDS_Wire& aWire)
:AIS_Relation(),
myWire(aWire),
haspos(Standard_False)
{
myFShape = aShape;
myPlane = aPlane;
myAutomaticPosition = Standard_True;
myArrowSize = 5.;
}
//=======================================================================
//function : Constructor
//purpose : vertex Fix Relation
//=======================================================================
AIS_FixRelation::AIS_FixRelation(const TopoDS_Shape& aShape,
const Handle(Geom_Plane)& aPlane,
const TopoDS_Wire& aWire,
const gp_Pnt& aPosition,
const Standard_Real anArrowSize)
:AIS_Relation(),
myWire(aWire),
haspos(Standard_False)
{
myFShape = aShape;
myPlane = aPlane;
myPosition = aPosition;
#ifdef BUC60915
SetArrowSize( anArrowSize );
#else
myArrowSize = anArrowSize;
#endif
myAutomaticPosition = Standard_False;
}
//=======================================================================
//function : Constructor
//purpose : edge (line or circle) Fix Relation
//=======================================================================
AIS_FixRelation::AIS_FixRelation(const TopoDS_Shape& aShape,
const Handle(Geom_Plane)& aPlane):
haspos(Standard_False)
{
myFShape = aShape;
myPlane = aPlane;
myAutomaticPosition = Standard_True;
myArrowSize = 5.;
}
//=======================================================================
//function : Constructor
//purpose : edge (line or circle) Fix Relation
//=======================================================================
AIS_FixRelation::AIS_FixRelation(
const TopoDS_Shape& aShape,
const Handle(Geom_Plane)& aPlane,
const gp_Pnt& aPosition,
const Standard_Real anArrowSize):
haspos(Standard_False)
{
myFShape = aShape;
myPlane = aPlane;
myPosition = aPosition;
#ifdef BUC60915
SetArrowSize( anArrowSize );
#else
myArrowSize = anArrowSize;
#endif
myAutomaticPosition = Standard_False;
}
//=======================================================================
//function : Wire
//purpose :
//=======================================================================
TopoDS_Wire AIS_FixRelation::Wire()
{
return myWire;
}
//=======================================================================
//function : SetWire
//purpose :
//=======================================================================
void AIS_FixRelation::SetWire(const TopoDS_Wire& aWire)
{
myWire = aWire;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_FixRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer)
{
aPresentation->Clear();
// Calcul du point de positionnement du symbole et du
// point d'attache du segment de raccord sur la shape
gp_Pnt curpos;
if (myFShape.ShapeType() == TopAbs_VERTEX)
ComputeVertex(TopoDS::Vertex(myFShape), curpos);
else if (myFShape.ShapeType() == TopAbs_EDGE)
ComputeEdge(TopoDS::Edge(myFShape), curpos);
const gp_Dir& nor = myPlane->Axis().Direction();
// calcul de la presentation
//definition de la taille du symbole
#ifdef BUC60915
if( !myArrowSizeIsDefined )
#endif
myArrowSize = 5.;
//creation du presentable
DsgPrs_FixPresentation::Add(aPresentation,
myDrawer,
myPntAttach,
curpos,
nor,
myArrowSize);
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_FixRelation::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_FixRelation::Compute(const Handle(Prs3d_Projector)&,const Handle(Prs3d_Presentation)&)");
PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_FixRelation::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d,
const Handle(Graphic2d_GraphicObject)& aGraphicObject,
const Standard_Integer anInteger)
{
// Standard_NotImplemented::Raise("AIS_FixRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)");
PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_FixRelation::Compute(const Handle_Prs3d_Projector& aProjector,
const Handle_Geom_Transformation& aTransformation,
const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_FixRelation::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_FixRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer)
{
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
// creation d'un segment sensible pour le segment de raccordement
// de la shape fixe au symbole 'Fix'
Handle(Select3D_SensitiveSegment) seg;
seg = new Select3D_SensitiveSegment(own,
myPntAttach,
myPosition);
aSelection->Add(seg);
// Creation de la zone sensible du symbole 'Fix'
gp_Dir norm = myPlane->Axis().Direction();
gp_Vec dirac(myPntAttach,myPosition);
dirac.Normalize();
gp_Vec norac = dirac.Crossed(gp_Vec(norm));
gp_Ax1 ax(myPosition, norm);
norac.Rotate(ax, PI/8);
norac*=(myArrowSize/2);
gp_Pnt P1 = myPosition.Translated(norac);
gp_Pnt P2 = myPosition.Translated(-norac);
seg = new Select3D_SensitiveSegment(own,
P1,
P2);
aSelection->Add(seg);
norac*=0.8;
P1 = myPosition.Translated(norac);
P2 = myPosition.Translated(-norac);
dirac*=(myArrowSize/2);
gp_Pnt PF(P1.XYZ());
gp_Pnt PL = PF.Translated(dirac);
PL.Translate(norac);
seg = new Select3D_SensitiveSegment(own,
PF,
PL);
aSelection->Add(seg);
PF.SetXYZ(P2.XYZ());
PL = PF.Translated(dirac);
PL.Translate(norac);
seg = new Select3D_SensitiveSegment(own,
PF,
PL);
aSelection->Add(seg);
PF.SetXYZ( (P1.XYZ() + P2.XYZ()) /2 );
PL = PF.Translated(dirac);
PL.Translate(norac);
seg = new Select3D_SensitiveSegment(own,
PF,
PL);
}
//=======================================================================
//function : ComputeVertex
//purpose : computes myPntAttach and the position of the presentation
// when you fix a vertex
//=======================================================================
void AIS_FixRelation::ComputeVertex(const TopoDS_Vertex& /*FixVertex*/,
gp_Pnt& curpos)
{
myPntAttach = BRep_Tool::Pnt(TopoDS::Vertex(myFShape));
curpos = myPosition;
if (myAutomaticPosition) {
gp_Pln pln(myPlane->Pln());
gp_Dir dir(pln.XAxis().Direction());
gp_Vec transvec = gp_Vec(dir)*myArrowSize;
curpos = myPntAttach.Translated(transvec);;
myPosition = curpos;
myAutomaticPosition = Standard_True;
}
}
//=======================================================================
//function : ComputePosition
//purpose :
//=======================================================================
gp_Pnt AIS_FixRelation::ComputePosition(const Handle(Geom_Curve)& curv1,
const Handle(Geom_Curve)& curv2,
const gp_Pnt& firstp1,
const gp_Pnt& lastp1,
const gp_Pnt& firstp2,
const gp_Pnt& lastp2) const
{
//---------------------------------------------------------
// calcul du point d'attache
//---------------------------------------------------------
gp_Pnt curpos;
if (curv1->IsInstance(STANDARD_TYPE(Geom_Circle)) || curv2->IsInstance(STANDARD_TYPE(Geom_Circle))) {
Handle(Geom_Circle) gcirc = Handle(Geom_Circle)::DownCast(curv1);
if (gcirc.IsNull()) gcirc = Handle(Geom_Circle)::DownCast(curv2);
gp_Dir dir( gcirc->Location().XYZ() + myPntAttach.XYZ() );
gp_Vec transvec = gp_Vec(dir)*myArrowSize;
curpos = myPntAttach.Translated(transvec);
}
else {
gp_Vec vec1(firstp1,lastp1);
gp_Vec vec2(firstp2,lastp2);
if (!vec1.IsParallel(vec2, Precision::Angular()) ) {
gp_Dir dir;
Standard_Real conf =Precision::Confusion();
if (lastp1.IsEqual(firstp2,conf) || firstp1.IsEqual(lastp2,conf)) dir.SetXYZ(vec1.XYZ() - vec2.XYZ());
else dir.SetXYZ(vec1.XYZ() + vec2.XYZ());
gp_Vec transvec = gp_Vec(dir)*myArrowSize;
curpos = myPntAttach.Translated(transvec);
}
else {
gp_Vec crossvec = vec1.Crossed(vec2);
vec1.Cross(crossvec);
gp_Dir dir(vec1);
curpos = myPntAttach.Translated(gp_Vec(dir)*myArrowSize);
}
}
return curpos;
}
//=======================================================================
//function : ComputePosition
//purpose : Computes the position of the "fix dimension" when the
// fixed object is a vertex which is set at the intersection
// of two curves.
// The "dimension" is in the "middle" of the two edges.
//=======================================================================
gp_Pnt AIS_FixRelation::ComputePosition(const Handle(Geom_Curve)& curv,
const gp_Pnt& firstp,
const gp_Pnt& lastp) const
{
//---------------------------------------------------------
// calcul du point d'attache
//---------------------------------------------------------
gp_Pnt curpos;
if (curv->IsKind(STANDARD_TYPE(Geom_Circle))) {
Handle(Geom_Circle) gcirc = Handle(Geom_Circle)::DownCast(curv);
gp_Dir dir( gcirc->Location().XYZ() + myPntAttach.XYZ() );
gp_Vec transvec = gp_Vec(dir)*myArrowSize;
curpos = myPntAttach.Translated(transvec);
} //if (curv->IsKind(STANDARD_TYPE(Geom_Circle))
else {
// gp_Pln pln(Component()->WorkingPlane()->Plane()->GetValue()->Pln());
gp_Pln pln(myPlane->Pln());
gp_Dir NormPln = pln.Axis().Direction();
gp_Vec vec(firstp,lastp);
vec.Cross( gp_Vec(NormPln));
vec.Normalize();
gp_Vec transvec = vec*myArrowSize;
curpos = myPntAttach.Translated(transvec);
gp_Ax1 RotAx( myPntAttach, NormPln);
curpos.Rotate(RotAx, PI/10);
}
return curpos;
}
//=======================================================================
//function : ComputeEdge
//purpose : computes myPntAttach and the position of the presentation
// when you fix an edge
//=======================================================================
void AIS_FixRelation::ComputeEdge(const TopoDS_Edge& FixEdge, gp_Pnt& curpos)
{
Handle(Geom_Curve) curEdge;
gp_Pnt ptbeg,ptend;
if (!AIS::ComputeGeometry(FixEdge,curEdge,ptbeg,ptend)) return;
//---------------------------------------------------------
// calcul du point de positionnement du symbole 'fix'
//---------------------------------------------------------
//--> Dans le cas d'une droite
if (curEdge->IsKind(STANDARD_TYPE(Geom_Line))){
gp_Lin glin = Handle(Geom_Line)::DownCast(curEdge)->Lin();
Standard_Real pfirst(ElCLib::Parameter(glin,ptbeg));
Standard_Real plast(ElCLib::Parameter(glin,ptend));
ComputeLinePosition(glin, curpos, pfirst, plast);
}
//--> Dans le cas d'un cercle
else if (curEdge->IsKind(STANDARD_TYPE(Geom_Circle))) {
gp_Circ gcirc = Handle(Geom_Circle)::DownCast(curEdge)->Circ();
Standard_Real pfirst, plast;
BRepAdaptor_Curve cu(FixEdge);
pfirst = cu.FirstParameter();
plast = cu.LastParameter();
ComputeCirclePosition(gcirc, curpos, pfirst, plast);
}
else
return;
}
//=======================================================================
//function : ComputeLinePosition
//purpose : compute the values of myPntAttach and the position <pos> of
// the symbol when the fixed edge has a geometric support equal
// to a line.
//=======================================================================
void AIS_FixRelation::ComputeLinePosition(const gp_Lin& glin,
gp_Pnt& pos,
Standard_Real& pfirst,
Standard_Real& plast)
{
if (myAutomaticPosition) {
// le point d'attache est choisi comme milieu du segment
myPntAttach = ElCLib::Value((pfirst+ plast)/2, glin);
gp_Dir norm = myPlane ->Axis().Direction();
norm.Cross(glin.Position().Direction());
pos = myPntAttach.Translated(gp_Vec(norm)*myArrowSize);
myAutomaticPosition = Standard_True;
} // if (myAutomaticPosition)
else {
pos = myPosition;
Standard_Real linparam = ElCLib::Parameter(glin, pos);
//cas ou la projection de position se situe entre les 2 vertex
// de l'edge
if ( (linparam >= pfirst) && (linparam <= plast) )
myPntAttach = ElCLib::Value(linparam,glin);
// cas ou la projection de Position est en dehors des limites
// de l'edge : alors on choisit comme point d'attache le point
// le plus proche de la projection
else {
Standard_Real pOnLin;
if (linparam > plast)
pOnLin = plast;
else
pOnLin = pfirst;
myPntAttach = ElCLib::Value(pOnLin,glin);
gp_Dir norm = myPlane->Axis().Direction();
norm.Cross(glin.Position().Direction());
gp_Lin lsup(myPntAttach, norm);
Standard_Real parpos = ElCLib::Parameter(lsup,myPosition);
pos = ElCLib::Value(parpos,lsup);
}
}
myPosition = pos;
}
//=======================================================================
//function : ComputeCirclePosition
//purpose : compute the values of myPntAttach and the position <pos> of
// the symbol when the fixed edge has a geometric support equal
// to a circle.
//=======================================================================
void AIS_FixRelation::ComputeCirclePosition(
const gp_Circ& gcirc,
gp_Pnt& pos,
Standard_Real& pfirst,
Standard_Real& plast)
{
// reajustement des parametres sur le cercle
if (plast > 2*PI ) {
Standard_Real nbtours = Floor(plast / (2*PI));
plast -= nbtours*2*PI;
pfirst -= nbtours*2*PI;
}
if (myAutomaticPosition) {
// le point d'attache est le "milieu" du segment (par rapport
// aux parametres des vertex de debut et de fin de l'edge
Standard_Real circparam = (pfirst + plast)/2.;
if ( !InDomain(pfirst,plast,circparam)) {
Standard_Real otherpar = circparam + PI;
if (otherpar > 2*PI) otherpar -= 2*PI;
circparam = otherpar;
}
myPntAttach = ElCLib::Value(circparam, gcirc );
gp_Vec dir( gcirc.Location().XYZ(), myPntAttach.XYZ() );
dir.Normalize();
gp_Vec transvec = dir*myArrowSize;
pos = myPntAttach.Translated(transvec);
myPosition = pos;
myAutomaticPosition = Standard_True;
} // if (myAutomaticPosition)
else {
// cas ou la projection de myPosition est en dehors des 2
// vertex de l'edge. Dans ce cas on reajuste le parametre
// dans la portion valable du cercle
pos = myPosition;
Standard_Real circparam = ElCLib::Parameter(gcirc, pos);
if ( !InDomain(pfirst,plast,circparam)) {
Standard_Real otherpar = circparam + PI;
if (otherpar > 2*PI) otherpar -= 2*PI;
circparam = otherpar;
}
myPntAttach = ElCLib::Value(circparam,gcirc);
}
}
//=======================================================================
//function : ConnectedEdges
//purpose :
//=======================================================================
Standard_Boolean AIS_FixRelation::ConnectedEdges(const TopoDS_Wire& WIRE,
const TopoDS_Vertex& V,
TopoDS_Edge& E1,
TopoDS_Edge& E2)
{
TopTools_IndexedDataMapOfShapeListOfShape vertexMap;
TopExp::MapShapesAndAncestors (WIRE,TopAbs_VERTEX,TopAbs_EDGE,vertexMap);
Standard_Boolean found(Standard_False);
TopoDS_Vertex theVertex;
for (Standard_Integer i=1; i<=vertexMap.Extent() && !found; i++) {
if (vertexMap.FindKey(i).IsSame(V)) {
theVertex = TopoDS::Vertex(vertexMap.FindKey(i));
found = Standard_True;
}
}
if (!found) {
E1.Nullify();
E2.Nullify();
return Standard_False;
}
TopTools_ListIteratorOfListOfShape iterator(vertexMap.FindFromKey(theVertex));
if (iterator.More()) {
E1 = TopoDS::Edge(iterator.Value());
BRepAdaptor_Curve curv(E1);
iterator.Next();
}
else {
E1.Nullify();
return Standard_False;
}
if (iterator.More()) {
E2 = TopoDS::Edge(iterator.Value());
BRepAdaptor_Curve curv(E2);
iterator.Next();
}
else {
E2.Nullify();
return Standard_False;
}
if (iterator.More()) {
E1.Nullify();
E2.Nullify();
return Standard_False;
}
return Standard_True;
}

12
src/AIS/AIS_FixRelation.lxx Executable file
View File

@@ -0,0 +1,12 @@
// File: AIS_FixRelation.lxx
// Created: Fri Feb 28 14:36:13 1997
// Author: Jean-Pierre COMBE
// <jpr>
//=======================================================================
//function : IsMovable
//purpose :
//=======================================================================
inline Standard_Boolean AIS_FixRelation::IsMovable() const
{
return Standard_True;
}

109
src/AIS/AIS_GlobalStatus.cdl Executable file
View File

@@ -0,0 +1,109 @@
-- File: AIS_GlobalStatus.cdl
-- Created: Fri Jan 24 14:34:35 1997
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
private class GlobalStatus from AIS inherits TShared from MMgt
---Purpose: Stores information about objects in graphic context:
-- - Status Of Display : in the main viewer
-- in the collector
-- fully Erased
-- - Displayed Modes
-- - Active Selection Modes
-- - is the Interactive Object Current ?
-- - Layer Index
uses
ListOfInteger from TColStd,
DisplayStatus from AIS,
NameOfColor from Quantity
is
Create returns mutable GlobalStatus from AIS;
Create (aStat : DisplayStatus from AIS;
aDispMode,aSelMode: Integer from Standard;
ishilighted : Boolean from Standard=Standard_False;
TheHiCol : NameOfColor from Quantity = Quantity_NOC_WHITE;
aLayerIndex : Integer from Standard = 0)
returns mutable GlobalStatus from AIS;
---Category: Modifications.
SetGraphicStatus(me:mutable; aStat : DisplayStatus from AIS);
---C++: inline
AddDisplayMode(me:mutable; aMode: Integer from Standard);
---C++: inline
AddSelectionMode(me:mutable; aMode : Integer from Standard);
---C++: inline
SetLayerIndex (me: mutable ; AnIndex : Integer from Standard);
---C++: inline
SetHilightStatus (me: mutable; aStat:Boolean from Standard);
---C++: inline
SetHilightColor(me:mutable;aHiCol : NameOfColor from Quantity);
---C++: inline
IsSubIntensityOn(me) returns Boolean from Standard;
---C++: inline
SubIntensityOn (me: mutable);
---C++: inline
SubIntensityOff (me: mutable);
---C++: inline
RemoveDisplayMode(me:mutable; aMode : Integer from Standard);
RemoveSelectionMode(me:mutable; aMode : Integer from Standard);
ClearSelectionModes(me:mutable);
---Category: Information.
GraphicStatus(me) returns DisplayStatus from AIS;
---C++: inline
DisplayedModes(me) returns ListOfInteger from TColStd;
---C++: return const &
---C++: inline
---Purpose: keeps the information of displayed modes in the
-- main viewer.
-- (The convention is that the object is displayed
-- with the mode 0 in the collector...)
SelectionModes(me) returns ListOfInteger from TColStd;
---C++: return const &
---C++: inline
---Purpose: keeps the active selection modes of the object
-- in the main viewer.
-- (The convention is that the active selection mode
-- for an object in the collector is the mode 0).
IsHilighted(me) returns Boolean from Standard;
---C++: inline
HilightColor(me) returns NameOfColor from Quantity;
---C++: inline
IsDModeIn(me; aMode : Integer from Standard) returns Boolean from Standard;
IsSModeIn(me; aMode : Integer from Standard) returns Boolean from Standard;
fields
myStatus : DisplayStatus from AIS;
myDispModes : ListOfInteger from TColStd;
mySelModes : ListOfInteger from TColStd;
myLayerIndex : Integer from Standard;
myIsHilit : Boolean from Standard;
myHiCol : NameOfColor from Quantity;
mySubInt : Boolean;
end GlobalStatus;

75
src/AIS/AIS_GlobalStatus.cxx Executable file
View File

@@ -0,0 +1,75 @@
// File: AIS_GlobalStatus.cxx
// Created: Fri Jan 24 16:54:46 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
#include <AIS_GlobalStatus.ixx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
static TColStd_ListIteratorOfListOfInteger It;
AIS_GlobalStatus::AIS_GlobalStatus():
myStatus(AIS_DS_None),
myLayerIndex(0),
myIsHilit(Standard_False),
myHiCol(Quantity_NOC_WHITE),
mySubInt(Standard_False)
{
}
AIS_GlobalStatus::AIS_GlobalStatus(const AIS_DisplayStatus DS,
const Standard_Integer DMode,
const Standard_Integer SMode,
const Standard_Boolean ishilighted,
const Quantity_NameOfColor TheHiCol,
const Standard_Integer Layer):
myStatus(DS),
myLayerIndex(Layer),
myIsHilit(Standard_False),
myHiCol(TheHiCol),
mySubInt(Standard_False)
{
myDispModes.Append(DMode);
mySelModes.Append(SMode);
}
void AIS_GlobalStatus::RemoveDisplayMode(const Standard_Integer aMode)
{
for(It.Initialize(myDispModes);It.More();It.Next()){
if(It.Value()==aMode){ myDispModes.Remove(It);
return;}
}
}
void AIS_GlobalStatus::RemoveSelectionMode(const Standard_Integer aMode)
{
for(It.Initialize(mySelModes);It.More();It.Next()){
if(It.Value()==aMode){ mySelModes.Remove(It);
return;}
}
}
void AIS_GlobalStatus::ClearSelectionModes()
{
mySelModes.Clear();
}
Standard_Boolean AIS_GlobalStatus::IsDModeIn(const Standard_Integer aMode) const
{
for(It.Initialize(myDispModes);It.More();It.Next())
if(It.Value()==aMode) return Standard_True;
return Standard_False;
}
Standard_Boolean AIS_GlobalStatus::IsSModeIn(const Standard_Integer aMode) const
{
for(It.Initialize(mySelModes);It.More();It.Next())
if(It.Value()==aMode) return Standard_True;
return Standard_False;
}

68
src/AIS/AIS_GlobalStatus.lxx Executable file
View File

@@ -0,0 +1,68 @@
// File: AIS_GlobalStatus.lxx
// Created: Fri Jan 24 16:55:27 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
inline void AIS_GlobalStatus::SetGraphicStatus(const AIS_DisplayStatus aStat)
{
myStatus = aStat;
}
inline void AIS_GlobalStatus::AddDisplayMode(const Standard_Integer aMode)
{
if(!IsDModeIn(aMode)) myDispModes.Append(aMode);
}
inline void AIS_GlobalStatus::AddSelectionMode(const Standard_Integer aMode)
{
if(!IsSModeIn(aMode)) mySelModes.Append(aMode);
}
inline void AIS_GlobalStatus::SetLayerIndex(const Standard_Integer AnIndex)
{
myLayerIndex=AnIndex;
}
inline void AIS_GlobalStatus::SetHilightStatus(const Standard_Boolean aStat)
{
myIsHilit = aStat;
}
inline void AIS_GlobalStatus::SetHilightColor(const Quantity_NameOfColor aCol)
{myHiCol = aCol;}
inline Standard_Boolean AIS_GlobalStatus::IsSubIntensityOn() const
{
return mySubInt;
}
inline void AIS_GlobalStatus::SubIntensityOn()
{
mySubInt = Standard_True;
}
inline void AIS_GlobalStatus::SubIntensityOff()
{
mySubInt = Standard_False;
}
inline AIS_DisplayStatus AIS_GlobalStatus::GraphicStatus() const
{
return myStatus;
}
inline const TColStd_ListOfInteger& AIS_GlobalStatus::DisplayedModes() const
{
return myDispModes;
}
inline const TColStd_ListOfInteger& AIS_GlobalStatus::SelectionModes() const
{
return mySelModes;
}
inline Standard_Boolean AIS_GlobalStatus::IsHilighted() const
{
return myIsHilit;
}
inline Quantity_NameOfColor AIS_GlobalStatus::HilightColor() const
{return myHiCol;}

59
src/AIS/AIS_GraphicTool.cdl Executable file
View File

@@ -0,0 +1,59 @@
-- File: AIS_GraphicTool.cdl
-- Created: Mon Feb 10 16:17:04 1997
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
-- the restricted NameOfColor.
---Copyright: Matra Datavision 1997
class GraphicTool from AIS
---Purpose:
uses
Drawer from Prs3d,
TypeOfAttribute from AIS,
NameOfColor from Quantity,
Color from Quantity,
TypeOfLine from Aspect,
MaterialAspect from Graphic3d
is
GetLineColor(myclass; aDrawer : Drawer from Prs3d; TheTypeOfAttributes : TypeOfAttribute from AIS)
returns NameOfColor from Quantity;
GetLineColor(myclass; aDrawer : Drawer from Prs3d;
TheTypeOfAttributes : TypeOfAttribute from AIS;
TheLineColor: out Color from Quantity);
GetLineWidth(myclass; aDrawer : Drawer from Prs3d; TheTypeOfAttributes : TypeOfAttribute from AIS)
returns Real from Standard;
GetLineType (myclass; aDrawer : Drawer from Prs3d; TheTypeOfAttributes : TypeOfAttribute from AIS)
returns TypeOfLine from Aspect;
GetLineAtt(myclass;
aDrawer : Drawer from Prs3d;
TheTypeOfAttributes : TypeOfAttribute from AIS;
aCol : in out NameOfColor from Quantity;
aWidth : in out Real from Standard;
aTyp : in out TypeOfLine from Aspect);
GetInteriorColor(myclass;
aDrawer : Drawer from Prs3d)
returns NameOfColor from Quantity;
GetInteriorColor(myclass;
aDrawer : Drawer from Prs3d;
aColor: out Color from Quantity);
GetMaterial(myclass; aDrawer:Drawer from Prs3d)
returns MaterialAspect from Graphic3d;
end GraphicTool;

174
src/AIS/AIS_GraphicTool.cxx Executable file
View File

@@ -0,0 +1,174 @@
// File: AIS_GraphicTool.cxx
// Created: Mon Feb 10 16:39:03 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
#define GER61351 //GG_171199 Enable to get an object RGB color
// instead a restricted object NameOfColor.
#include <AIS_GraphicTool.ixx>
#include <Quantity_Color.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Aspect_AspectLine.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Prs3d_AngleAspect.hxx>
#include <Prs3d_PlaneAspect.hxx>
#include <Prs3d_DatumAspect.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Aspect_InteriorStyle.hxx>
#include <Prs3d_ShadingAspect.hxx>
static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
{
switch(Att){
case AIS_TOA_Line:
return Dr->LineAspect();
break;
case AIS_TOA_Angle:
return Dr->AngleAspect()->LineAspect();
break;
case AIS_TOA_Wire:
return Dr->WireAspect();
break;
case AIS_TOA_Plane:
return Dr->PlaneAspect()->EdgesAspect();
break;
case AIS_TOA_Vector:
return Dr->VectorAspect();
break;
case AIS_TOA_UIso:
return Dr->UIsoAspect();
break;
case AIS_TOA_VIso:
return Dr->VIsoAspect();
break;
case AIS_TOA_Free:
return Dr->FreeBoundaryAspect();
break;
case AIS_TOA_UnFree:
return Dr->UnFreeBoundaryAspect();
break;
case AIS_TOA_Section:
return Dr->SectionAspect();
break;
case AIS_TOA_Hidden:
return Dr->HiddenLineAspect();
break;
case AIS_TOA_Seen:
return Dr->SeenLineAspect();
break;
case AIS_TOA_FirstAxis:
return Dr->DatumAspect()->FirstAxisAspect();
case AIS_TOA_SecondAxis:
return Dr->DatumAspect()->SecondAxisAspect();
case AIS_TOA_ThirdAxis:
return Dr->DatumAspect()->SecondAxisAspect();
}
Handle(Prs3d_LineAspect) bid;
return bid;
}
Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att)
#ifdef GER61351
{
Quantity_Color color;
GetLineColor(Dr,Att,color);
return color.Name();
}
void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor)
#endif
{
Standard_Real W;
Aspect_TypeOfLine TYP;
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
#ifdef GER61351
LA->Aspect()->Values(aColor,TYP,W);
#else
Quantity_Color QCol;
LA->Aspect()->Values(QCol,TYP,W);
return QCol.Name();
#endif
}
Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
{
// Quantity_NameOfColor Col;
Standard_Real W;
Aspect_TypeOfLine TYP;
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
Quantity_Color QCol;
LA->Aspect()->Values(QCol,TYP,W);
return W;
}
Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
{
// Quantity_NameOfColor Col;
Standard_Real W;
Aspect_TypeOfLine TYP;
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
Quantity_Color QCol;
LA->Aspect()->Values(QCol,TYP,W);
return TYP;
}
void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att,
Quantity_NameOfColor& Col,
Standard_Real& W,
Aspect_TypeOfLine& TYP)
{
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
Quantity_Color QCol;
LA->Aspect()->Values(QCol,TYP,W);
Col = QCol.Name();
}
Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr)
#ifdef GER61351
{
Quantity_Color color;
GetInteriorColor(Dr,color);
return color.Name();
}
void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor)
#endif
{
Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect();
Aspect_InteriorStyle IS;
Aspect_TypeOfLine T;
Standard_Real W;
#ifdef GER61351
Quantity_Color EC;
AFA->Values(IS,aColor,EC,T,W);
#else
Quantity_Color IC,EC;
AFA->Values(IS,IC,EC,T,W);
return IC.Name();
#endif
}
Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr)
{
return Dr->ShadingAspect()->Aspect()->BackMaterial();
}

213
src/AIS/AIS_IdenticRelation.cdl Executable file
View File

@@ -0,0 +1,213 @@
-- File: AIS_IdenticRelation.cdl
-- Created: Mon Mar 3 15:51:18 1997
-- Author: Jean-Pierre COMBE
-- <jpr@chariox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class IdenticRelation from AIS inherits Relation from AIS
---Purpose: Constructs a constraint by a relation of identity
-- between two or more datums figuring in shape
-- Interactive Objects.
uses
Shape from TopoDS,
Vertex from TopoDS,
Wire from TopoDS,
Presentation from Prs3d,
PresentationManager3d from PrsMgr,
Selection from SelectMgr,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Plane from Geom,
Curve from Geom,
Line from Geom,
Circle from Geom,
Ellipse from Geom,
Pnt from gp,
Dir from gp
is
Create(FirstShape : Shape from TopoDS;
SecondShape : Shape from TopoDS;
aPlane : Plane from Geom)
returns mutable IdenticRelation from AIS;
---Purpose:
-- Initializes the relation of identity between the two
-- entities, FirstShape and SecondShape. The plane
-- aPlane is initialized in case a visual reference is
-- needed to show identity.
IsMovable(me) returns Boolean from Standard
---C++: inline
---Purpose:
-- Returns true if the interactive object is movable.
is redefined;
-- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
--
-- Computation private methods
--
ComputeOneEdgeOVertexPresentation(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeTwoEdgesPresentation(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeTwoLinesPresentation(me: mutable;
aPresentation : mutable Presentation from Prs3d;
aLin : Line from Geom;
Pnt1On1 : in out Pnt from gp;
Pnt2On1 : in out Pnt from gp;
Pnt1On2 : in out Pnt from gp;
Pnt2On2 : in out Pnt from gp;
isInf1 : Boolean from Standard;
isInf2 : Boolean from Standard)
is private;
ComputeTwoCirclesPresentation(me: mutable;
aPresentation : mutable Presentation from Prs3d;
aCircle : Circle from Geom;
Pnt1On1 : Pnt from gp;
Pnt2On1 : Pnt from gp;
Pnt1On2 : Pnt from gp;
Pnt2On2 : Pnt from gp)
is private;
-- jfa 17/10/2000
ComputeAutoArcPresentation(me: mutable;
aCircle : Circle from Geom;
firstp : Pnt from gp;
lastp : Pnt from gp;
isstatic: Boolean from Standard = Standard_False)
---Purpose: Computes the presentation of the identic constraint
-- between 2 arcs in the case of automatic presentation
is private;
ComputeNotAutoCircPresentation(me: mutable;
aCircle : Circle from Geom)
---Purpose: Computes the presentation of the identic constraint
-- between 2 circles in the case of non automatic presentation
is private;
ComputeNotAutoArcPresentation(me: mutable;
aCircle : Circle from Geom;
pntfirst: Pnt from gp;
pntlast : Pnt from gp)
---Purpose: Computes the presentation of the identic constraint
-- between 2 arcs in the case of non automatic presentation
is private;
-- jfa 17/10/2000 end
-- jfa 10/10/2000
ComputeTwoEllipsesPresentation(me: mutable;
aPrs : mutable Presentation from Prs3d;
anEll : Ellipse from Geom;
Pnt1On1 : Pnt from gp;
Pnt2On1 : Pnt from gp;
Pnt1On2 : Pnt from gp;
Pnt2On2 : Pnt from gp)
is private;
-- jfa 10/10/2000 end
-- jfa 18/10/2000
ComputeAutoArcPresentation(me: mutable;
theEll : Ellipse from Geom;
firstp : Pnt from gp;
lastp : Pnt from gp;
isstatic: Boolean from Standard = Standard_False)
---Purpose: Computes the presentation of the identic constraint
-- between 2 arcs in the case of automatic presentation
is private;
ComputeNotAutoElipsPresentation(me: mutable;
theEll : Ellipse from Geom)
---Purpose: Computes the presentation of the identic constraint
-- between 2 ellipses in the case of non automatic presentation
is private;
ComputeNotAutoArcPresentation(me: mutable;
theEll : Ellipse from Geom;
pntfirst: Pnt from gp;
pntlast : Pnt from gp)
---Purpose: Computes the presentation of the identic constraint
-- between 2 arcs in the case of non automatic presentation
is private;
-- jfa 18/10/2000 end
ComputeTwoVerticesPresentation(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeSegSize(me)
returns Real from Standard
is private;
ComputeDirection(me; aWire : Wire from TopoDS;
aVertex : Vertex from TopoDS;
aDir : out Dir from gp)
returns Boolean from Standard
is private;
ComputeLineDirection(me; aLin : Line from Geom;
anExtremity : Pnt from gp)
returns Dir from gp
is private;
ComputeCircleDirection(me; aCirc : Circle from Geom;
ConnectedVertex : Vertex from TopoDS)
returns Dir from gp
is private;
fields
isCircle : Boolean from Standard;
myFAttach : Pnt from gp;
mySAttach : Pnt from gp;
myCenter : Pnt from gp;
end IdenticRelation;

1743
src/AIS/AIS_IdenticRelation.cxx Executable file

File diff suppressed because it is too large Load Diff

13
src/AIS/AIS_IdenticRelation.lxx Executable file
View File

@@ -0,0 +1,13 @@
// File: AIS_IdenticRelation.lxx
// Created: Tue Mar 4 09:41:04 1997
// Author: Jean-Pierre COMBE
// <jpr>
//=======================================================================
//function : IsMovable
//purpose :
//=======================================================================
inline Standard_Boolean AIS_IdenticRelation::IsMovable() const
{
return Standard_True;
}

2197
src/AIS/AIS_InteractiveContext.cdl Executable file

File diff suppressed because it is too large Load Diff

3151
src/AIS/AIS_InteractiveContext.cxx Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,118 @@
inline const Handle(V3d_Viewer)& AIS_InteractiveContext::CurrentViewer() const
{
return myMainVwr;
}
inline const Handle(V3d_Viewer)& AIS_InteractiveContext::Collector() const
{
return myCollectorVwr;
}
inline Quantity_NameOfColor AIS_InteractiveContext::HilightColor() const
{
return myHilightColor;
}
inline Quantity_NameOfColor AIS_InteractiveContext::SelectionColor() const
{
return mySelectionColor;
}
inline Quantity_NameOfColor AIS_InteractiveContext::PreSelectionColor() const
{
return myPreselectionColor;
}
inline Quantity_NameOfColor AIS_InteractiveContext::DefaultColor() const
{ return myDefaultColor;
}
inline Standard_Boolean AIS_InteractiveContext::IsCollectorClosed() const
{return myIsCollClosed;}
inline void AIS_InteractiveContext::CloseCollector()
{myIsCollClosed = Standard_True;}
inline Quantity_NameOfColor AIS_InteractiveContext::SubIntensityColor() const
{
return mySubIntensity;
}
inline void AIS_InteractiveContext::SetHilightColor(const Quantity_NameOfColor aHiCol)
{
myHilightColor = aHiCol;
}
inline void AIS_InteractiveContext::SelectionColor(const Quantity_NameOfColor aCol)
{
mySelectionColor = aCol;
}
inline void AIS_InteractiveContext::SetPreselectionColor(const Quantity_NameOfColor aCol)
{
myPreselectionColor = aCol;
}
inline void AIS_InteractiveContext::SetSubIntensityColor(const Quantity_NameOfColor aCol)
{
mySubIntensity = aCol;
}
inline Standard_Integer AIS_InteractiveContext::DisplayMode() const
{
return myDisplayMode;
}
inline const Handle(Prs3d_Drawer)& AIS_InteractiveContext::DefaultDrawer() const
{return myDefaultDrawer;}
inline const Handle(SelectMgr_SelectionManager)& AIS_InteractiveContext::SelectionManager() const
{return mgrSelector ;}
inline const Handle(PrsMgr_PresentationManager3d)& AIS_InteractiveContext::MainPrsMgr() const
{return myMainPM ;}
inline const Handle(PrsMgr_PresentationManager3d)& AIS_InteractiveContext::CollectorPrsMgr() const
{return myCollectorPM ;}
inline Standard_Boolean AIS_InteractiveContext::HasOpenedContext() const
{return myCurLocalIndex != 0;}
inline const TCollection_AsciiString& AIS_InteractiveContext::CurrentName() const
{return myCurrentName;}
inline Standard_Boolean AIS_InteractiveContext::WasCurrentTouched() const
{return myCurrentTouched;}
inline void AIS_InteractiveContext::SetOkCurrent()
{myCurrentTouched= Standard_False;}
inline const Handle(StdSelect_ViewerSelector3d)& AIS_InteractiveContext::MainSelector() const
{return myMainSel;}
inline const Handle(StdSelect_ViewerSelector3d)& AIS_InteractiveContext::CollectorSelector() const
{return myCollectorSel;}
inline void AIS_InteractiveContext::SetToHilightSelected(const Standard_Boolean toHilight)
{
myToHilightSelected = toHilight;
}
inline Standard_Boolean AIS_InteractiveContext::ToHilightSelected() const
{
return myToHilightSelected;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,943 @@
// File: AIS_InteractiveContext_2.cxx
// Created: Wed Jan 29 10:55:05 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
#define IMP051001 //GG Adds SetZDetected() and ZDetected() methods
#include <AIS_InteractiveContext.jxx>
#include <AIS_LocalContext.hxx>
#include <AIS_GlobalStatus.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
#include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_MapOfStructure.hxx>
#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
#include <AIS_Selection.hxx>
static TColStd_ListIteratorOfListOfInteger ItL;
//=======================================================================
//function : OpenLocalContext
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveContext::
OpenLocalContext(const Standard_Boolean UseDisplayedObjects,
const Standard_Boolean AllowShapeDecomposition,
const Standard_Boolean AcceptEraseOfTemporary,
const Standard_Boolean /*BothViewers*/)
{
// on dehilighte les eventuelles entitees detectees juste avant l'ouverture
// du contexte...
if(!IsCurrent(myLastPicked)){
if(!myLastPicked.IsNull()){
Standard_Integer HiMod = myLastPicked->HasHilightMode()?myLastPicked->HilightMode():0;
myMainPM->Unhighlight(myLastPicked,HiMod);
}}
if(!mylastmoveview.IsNull()){
if(myCurLocalIndex>0)
myLocalContexts(myCurLocalIndex)->UnhilightLastDetected(mylastmoveview);
}
// on met a 0 les entites liees a la selection dynamique au point neutre.
myLastinMain.Nullify();
myLastinColl.Nullify();
myLastPicked.Nullify();
myWasLastMain = Standard_True;
Standard_Integer untilnow = myCurLocalIndex;
myCurLocalIndex = HighestIndex() + 1;
Handle(AIS_LocalContext) NewLocal= new AIS_LocalContext(this,myCurLocalIndex,
UseDisplayedObjects,
AllowShapeDecomposition,
AcceptEraseOfTemporary);
// rob 16/04/97 pour les Pbs d'ordres asynchrones
if(myLocalContexts.Extent()>0){
const Select3D_Projector& Prj = myLocalContexts(untilnow)->MainSelector()->Projector();
NewLocal->MainSelector()->Set(Prj);
}
else{
const Select3D_Projector& Prj = myMainSel->Projector();
NewLocal->MainSelector()->Set(Prj);
}
NewLocal->MainSelector()->UpdateConversion();
myLocalContexts.Bind(myCurLocalIndex,NewLocal);
#ifdef DEB
cout<<"\tOpen Local Context No "<<myCurLocalIndex<<endl;
if(UseDisplayedObjects){
cout<<"\t\tObjects from Neutral Point loaded"<<endl;
if(AllowShapeDecomposition)
cout<<"\t\tDecomposition Authorized for Loaded Shapes"<<endl;
else
cout<<"\t\tNo Decomposition Authorized for Loaded Shapes"<<endl;
}
else
cout<<"\t\tNo Objects Were Loaded "<<endl;
#endif
return myCurLocalIndex;
}
//=======================================================================
//function : CloseLocalContext
//purpose :
//=======================================================================
void AIS_InteractiveContext::CloseLocalContext(const Standard_Integer Index,
const Standard_Boolean updateviewer)
{
Standard_Boolean debugmode(Standard_False);
#ifdef DEB
debugmode = Standard_True;
#endif
Standard_Integer GoodIndex = (Index ==-1) ? myCurLocalIndex : Index;
if(debugmode) cout<<"Call to CloseLocalContext - Index "<<GoodIndex<<endl;
if(!HasOpenedContext()){
if(debugmode) cout<<"\t But No Local Context is opened"<<endl;
return;
}
if(!myLocalContexts.IsBound(GoodIndex)) {
if(debugmode) cout<<" Attempt to Close a non-existent Local Context"<<endl;
return;
}
// On va fermer le seul contexte local ouvert...
if(myLocalContexts.Extent()==1 && GoodIndex == myCurLocalIndex){
Standard_Boolean updateproj = !(myLocalContexts(myCurLocalIndex)->HasSameProjector(myMainSel->Projector()));
myLocalContexts(myCurLocalIndex)->Terminate( updateviewer );
myLocalContexts.UnBind(myCurLocalIndex);
myCurLocalIndex = 0;
ResetOriginalState(Standard_False);
if(updateproj)
myMainSel->UpdateConversion();
else{
myMainSel->ReactivateProjector();
myMainSel->UpdateSort();
}
if(debugmode)
cout<<"No More Opened Local Context "<<endl;
}
// Sinon on aura encore un contexte local d'ouvert apres la fermeture du courant
else{
Handle(StdSelect_ViewerSelector3d) VS = myLocalContexts(GoodIndex)->MainSelector();
myLocalContexts(GoodIndex)->Terminate();
myLocalContexts.UnBind(GoodIndex);
// on ferme le courant...
if(GoodIndex==myCurLocalIndex){
myCurLocalIndex = HighestIndex();
const Handle(AIS_LocalContext)& LocCtx = myLocalContexts(myCurLocalIndex);
if(LocCtx->HasSameProjector(VS->Projector())){
LocCtx->MainSelector()->ReactivateProjector();
}
else
LocCtx->MainSelector()->UpdateConversion();
}
else if(debugmode)
cout<<"a No Current Local Context WasClosed"<<endl;
if(debugmode) cout<<"Index Of CurrentLocalContext:"<<myCurLocalIndex<<endl;
}
if(updateviewer) myMainVwr->Update();
}
//=======================================================================
//function : CloseAllContexts
//purpose :
//=======================================================================
void AIS_InteractiveContext::CloseAllContexts(const Standard_Boolean updateviewer)
{
while(!myLocalContexts.IsEmpty()){
CloseLocalContext(myCurLocalIndex,Standard_False);
}
ResetOriginalState(Standard_False);
myMainSel->UpdateSort();
if(!myIsCollClosed && !myCollectorSel.IsNull())
myCollectorSel->UpdateSort();
if(updateviewer) myMainVwr->Update();
}
//=======================================================================
//function : IndexOfCurrentLocal
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveContext::IndexOfCurrentLocal() const
{
return myCurLocalIndex;
}
//=======================================================================
//function : ClearLocalContext
//purpose :
//=======================================================================
void AIS_InteractiveContext::ClearLocalContext(const AIS_ClearMode aMode)
{
if (!HasOpenedContext()) return;
myLocalContexts(myCurLocalIndex)->Clear(aMode);
}
//=======================================================================
//function : HighestIndex
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveContext::HighestIndex() const
{
AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
Standard_Integer HiInd = 0;
for(;It.More();It.Next())
HiInd = (It.Key()>HiInd) ? It.Key() : HiInd;
return HiInd;
}
//=======================================================================
//function : Activate
//purpose :
//=======================================================================
void AIS_InteractiveContext::
Activate(const Handle(AIS_InteractiveObject)& anIObj,
const Standard_Integer aMode)
{
if(!HasOpenedContext()){
if(!myObjects.IsBound(anIObj)) return;
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
if(STAT->GraphicStatus()==AIS_DS_Displayed)
mgrSelector->Activate(anIObj,aMode,myMainSel);
STAT ->AddSelectionMode(aMode);
}
else{
myLocalContexts(myCurLocalIndex)->ActivateMode(anIObj,aMode);
}
}
//=======================================================================
//function : LocalSelector
//purpose :
//=======================================================================
Handle( StdSelect_ViewerSelector3d ) AIS_InteractiveContext::LocalSelector() const
{
if( !HasOpenedContext() )
return Handle( StdSelect_ViewerSelector3d )();
else
return myLocalContexts( myCurLocalIndex )->MainSelector();
}
//=======================================================================
//function : DeActivate
//purpose :
//=======================================================================
void AIS_InteractiveContext::
Deactivate(const Handle(AIS_InteractiveObject)& anIObj)
{
if(!HasOpenedContext()){
if(!myObjects.IsBound(anIObj)) return;
for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
ItL.More();
ItL.Next()){
if(myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed)
mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
}
myObjects(anIObj)->ClearSelectionModes();
}
else{
const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex);
LC->Deactivate(anIObj);
}
}
//=======================================================================
//function : Deactivate
//purpose :
//=======================================================================
void AIS_InteractiveContext::Deactivate(const Handle(AIS_InteractiveObject)& anIObj,
const Standard_Integer aMode)
{
if(!HasOpenedContext()){
if(!myObjects.IsBound(anIObj)) return;
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
if(STAT->GraphicStatus() == AIS_DS_Displayed)
mgrSelector->Deactivate(anIObj,aMode,myMainSel);
STAT->RemoveSelectionMode(aMode);
}
else{
myLocalContexts(myCurLocalIndex)->DeactivateMode(anIObj,aMode);
}
}
//=======================================================================
//function : ActivatedModes
//purpose :
//=======================================================================
void AIS_InteractiveContext::
ActivatedModes(const Handle(AIS_InteractiveObject)& anIObj,
TColStd_ListOfInteger& theList) const
{
if(!HasOpenedContext()){
if(myObjects.IsBound(anIObj)){
//ItL est une variable statique...
for(ItL.Initialize(myObjects(anIObj)->SelectionModes());
ItL.More();
ItL.Next())
theList.Append(ItL.Value());
}
}
else{
if(myLocalContexts(myCurLocalIndex)->IsIn(anIObj)){
for(ItL.Initialize(myLocalContexts(myCurLocalIndex)->SelectionModes(anIObj));
ItL.More();
ItL.Next())
theList.Append(ItL.Value());
}
}
}
//=======================================================================
//function : SetShapeDecomposition
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetShapeDecomposition(const Handle(AIS_InteractiveObject)& anIObj,
const Standard_Boolean StdModeSensitive)
{
if(!HasOpenedContext()) return;
myLocalContexts(myCurLocalIndex)->SetShapeDecomposition(anIObj,StdModeSensitive);
}
//=======================================================================
//function : SetTemporaryAttributes
//purpose :
//=======================================================================
void AIS_InteractiveContext::
SetTemporaryAttributes(const Handle(AIS_InteractiveObject)& /*anObj*/,
const Handle(Prs3d_Drawer)& /*aDrawer*/,
const Standard_Boolean /*updateviewer*/)
{
}
//=======================================================================
//function : SubIntensityOn
//purpose :
//=======================================================================
void AIS_InteractiveContext::
SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj,
const Standard_Boolean updateviewer)
{
if(!HasOpenedContext()){
if(!myObjects.IsBound(anIObj))
return;
const Handle(AIS_GlobalStatus)& GB=myObjects(anIObj);
if(GB->IsSubIntensityOn())
return;
GB->SubIntensityOn();
Standard_Boolean UpdMain(Standard_False),UpdColl(Standard_False);
for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){
if(GB->GraphicStatus()==AIS_DS_Displayed){
myMainPM->Color(anIObj,mySubIntensity,It.Value());
UpdMain = Standard_True;}
else if(GB->GraphicStatus()==AIS_DS_Erased){
myCollectorPM->Color(anIObj,mySubIntensity,It.Value());
UpdColl=Standard_True;
}
}
if(updateviewer){
if(UpdMain)
myMainVwr->Update();
if(UpdColl)
myCollectorVwr->Update();
}
}
else {
if(myObjects.IsBound(anIObj)){
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
STAT->SubIntensityOn();
for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
}
else
myLocalContexts(myCurLocalIndex)->SubIntensityOn(anIObj);
if(updateviewer) myMainVwr->Update();
}
}
//=======================================================================
//function : SubIntensityOff
//purpose :
//=======================================================================
void AIS_InteractiveContext::
SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj,
const Standard_Boolean updateviewer)
{
if(!HasOpenedContext()){
if(!myObjects.IsBound(anIObj))
return;
const Handle(AIS_GlobalStatus)& GB=myObjects(anIObj);
if(!GB->IsSubIntensityOn())
return;
GB->SubIntensityOff();
Standard_Boolean UpdMain(Standard_False),UpdColl(Standard_False);
for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){
if(GB->GraphicStatus()!=AIS_DS_Erased){
myMainPM->Unhighlight(anIObj,It.Value());
UpdMain = Standard_True;}
else {
myCollectorPM->Unhighlight(anIObj,It.Value());
UpdColl=Standard_True;
}
}
Standard_Integer DM,HM,SM;
GetDefModes(anIObj,DM,HM,SM);
if(AIS_Selection::IsSelected(anIObj))
myMainPM->Highlight(anIObj,HM);
if(updateviewer){
if(UpdMain)
myMainVwr->Update();
if(UpdColl)
myCollectorVwr->Update();
}
}
else {
if(myObjects.IsBound(anIObj)){
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
STAT->SubIntensityOff();
for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
myMainPM->Unhighlight(anIObj,ItL.Value());
if(STAT->IsHilighted())
Hilight(anIObj);
}
else
myLocalContexts(myCurLocalIndex)->SubIntensityOff(anIObj);
if(IsSelected(anIObj))
Hilight(anIObj);
if(updateviewer) myMainVwr->Update();
}
}
//=======================================================================
//function : SubIntensityOn
//purpose : ALL THE DISPLAYED OBJECTS HAVE SUBINTENSITY...
//=======================================================================
void AIS_InteractiveContext::SubIntensityOn(const Standard_Boolean updateviewer)
{
if(!HasOpenedContext()) return;
AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
TColStd_ListIteratorOfListOfInteger ItM;
for(;It.More();It.Next()){
const Handle(AIS_GlobalStatus)& STAT = It.Value();
if(STAT->GraphicStatus()==AIS_DS_Displayed)
{
STAT->SubIntensityOn();
for(ItM.Initialize(STAT->DisplayedModes());ItM.More();ItM.Next())
{myMainPM->Color(It.Key(),mySubIntensity,ItM.Value());}
}
}
if(updateviewer) myMainVwr->Update();
}
//=======================================================================
//function : SubIntensityOff
//purpose :
//=======================================================================
void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer)
{
if(!HasOpenedContext()) return;
AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
for(;It.More();It.Next()){
const Handle(AIS_GlobalStatus)& STAT = It.Value();
if(STAT->IsSubIntensityOn())
STAT->SubIntensityOff();
for(ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
myMainPM->Unhighlight(It.Key());
}
if(updateviewer) myMainVwr->Update();
}
//=======================================================================
//function : AddFilter
//purpose :
//=======================================================================
void AIS_InteractiveContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter)
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->AddFilter(aFilter);
else
myFilters->Add(aFilter);
}
//=======================================================================
//function : ActivateStandardMode
//purpose :
//=======================================================================
void AIS_InteractiveContext::ActivateStandardMode(const TopAbs_ShapeEnum aStandardActivation)
{
if(!HasOpenedContext()) return;
myLocalContexts(myCurLocalIndex)->ActivateStandardMode (aStandardActivation);
}
//=======================================================================
//function : DeActivateStandardMode
//purpose :
//=======================================================================
void AIS_InteractiveContext::DeactivateStandardMode(const TopAbs_ShapeEnum aStandardActivation)
{
if(!HasOpenedContext()) return;
myLocalContexts(myCurLocalIndex)->DeactivateStandardMode (aStandardActivation);
}
//=======================================================================
//function : RemoveFilter
//purpose :
//=======================================================================
void AIS_InteractiveContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter)
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->RemoveFilter (aFilter);
else
myFilters->Remove(aFilter);
}
//=======================================================================
//function : RemoveFilters
//purpose :
//=======================================================================
void AIS_InteractiveContext::RemoveFilters()
{
if(!HasOpenedContext())
myFilters->Clear();
else
myLocalContexts(myCurLocalIndex)->Clear(AIS_CM_Filters);
}
//=======================================================================
//function : ActivatedStandardModes
//purpose :
//=======================================================================
const TColStd_ListOfInteger& AIS_InteractiveContext::ActivatedStandardModes() const
{
return myLocalContexts(myCurLocalIndex)->StandardModes();
}
//=======================================================================
//function : Filters
//purpose :
//=======================================================================
const SelectMgr_ListOfFilter& AIS_InteractiveContext::Filters() const
{
if(HasOpenedContext())
return myLocalContexts(myCurLocalIndex)->ListOfFilter();
return myFilters->StoredFilters();
}
//=======================================================================
//function : DisplayActiveAreas
//purpose :
//=======================================================================
void AIS_InteractiveContext::DisplayActiveAreas(const Handle(V3d_View)& aviou)
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->DisplayAreas(aviou);
else
myMainSel->DisplayAreas(aviou);
}
//=======================================================================
//function : ClearActiveAreas
//purpose :
//=======================================================================
void AIS_InteractiveContext::ClearActiveAreas(const Handle(V3d_View)& aviou)
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->ClearAreas(aviou);
else
myMainSel->ClearAreas(aviou);
}
//=======================================================================
//function : DisplayActiveSensitive
//purpose :
//=======================================================================
void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(V3d_View)& aviou)
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->DisplaySensitive(aviou);
else
myMainSel->DisplaySensitive(aviou);
}
//=======================================================================
//function : DisplayActiveSensitive
//purpose :
//=======================================================================
void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(AIS_InteractiveObject)& anIObj,
const Handle(V3d_View)& aviou)
{
TColStd_ListIteratorOfListOfInteger It;
Handle(StdSelect_ViewerSelector3d) VS;
if(HasOpenedContext()){
const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex);
if(!LC->IsIn(anIObj)) return;
It.Initialize(LC->SelectionModes(anIObj));
VS = LC->MainSelector();
}
else{
if(!myObjects.IsBound(anIObj)) return;
It.Initialize(myObjects(anIObj)->SelectionModes());
VS = myMainSel;
}
for(;It.More();It.Next()){
const Handle(SelectMgr_Selection)& Sel = anIObj->Selection(It.Value());
VS->DisplaySensitive(Sel,aviou,Standard_False);
}
}
//=======================================================================
//function : DisplayActiveAreas
//purpose :
//=======================================================================
void AIS_InteractiveContext::DisplayActiveAreas(const Handle(AIS_InteractiveObject)& anIObj,
const Handle(V3d_View)& aviou)
{
TColStd_ListIteratorOfListOfInteger It;
Handle(StdSelect_ViewerSelector3d) VS;
if(HasOpenedContext()){
const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex);
if(!LC->IsIn(anIObj)) return;
It.Initialize(LC->SelectionModes(anIObj));
VS = LC->MainSelector();
}
else{
if(!myObjects.IsBound(anIObj)) return;
It.Initialize(myObjects(anIObj)->SelectionModes());
VS = myMainSel;
}
for(;It.More();It.Next()){
const Handle(SelectMgr_Selection)& Sel = anIObj->Selection(It.Value());
VS->DisplayAreas(Sel,aviou,Standard_False);
}
}
//=======================================================================
//function : ClearActiveSensitive
//purpose :
//=======================================================================
void AIS_InteractiveContext::ClearActiveSensitive(const Handle(V3d_View)& aviou)
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->ClearSensitive(aviou);
else
myMainSel->ClearSensitive(aviou);
}
//=======================================================================
//function : SetAutomaticHilight
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetAutomaticHilight(const Standard_Boolean aStatus)
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->SetAutomaticHilight(aStatus);
}
//=======================================================================
//function : AutomaticHilight
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::AutomaticHilight() const
{
if(HasOpenedContext())
return myLocalContexts(myCurLocalIndex)->AutomaticHilight();
return Standard_True;
}
//=======================================================================
//function : UseDisplayedObjects
//purpose :
//=======================================================================
void AIS_InteractiveContext::UseDisplayedObjects()
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->LoadContextObjects();
}
//=======================================================================
//function : NotUseDisplayedObjects
//purpose :
//=======================================================================
void AIS_InteractiveContext::NotUseDisplayedObjects()
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->UnloadContextObjects();
}
//=======================================================================
//function : PurgeDisplay
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveContext::PurgeDisplay(const Standard_Boolean CollectorToo)
{
if(HasOpenedContext()) return 0;
Standard_Integer NbStr = PurgeViewer(myMainVwr);
if(!myCollectorVwr.IsNull())
if(CollectorToo){
NbStr+=PurgeViewer(myCollectorVwr);
if(!IsCollectorClosed())
myCollectorVwr->Update();
}
myMainVwr->Update();
return NbStr;
}
//=======================================================================
//function : PurgeViewer
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveContext::PurgeViewer(const Handle(V3d_Viewer)& Vwr)
{
const Handle(Graphic3d_StructureManager)& GSM = Vwr->Viewer();
Standard_Integer NbCleared(0);
Graphic3d_MapOfStructure SOS;
GSM->DisplayedStructures(SOS);
Handle(Graphic3d_Structure) G;
for(Graphic3d_MapIteratorOfMapOfStructure It(SOS); It.More();It.Next()){
G = It.Key();
Standard_Address Add = G->Owner();
if(Add==NULL){
G->Erase();
G->Clear();// ca veut dire qu'elle n'est pas reference comme une presentation d'un InterfactiveObject...
NbCleared++;
}
Handle(AIS_InteractiveObject) IO = (AIS_InteractiveObject*)Add;
if(!myObjects.IsBound(IO)){
G->Erase();
NbCleared++;
}
}
return NbCleared;
}
//=======================================================================
//function : IsImmediateModeOn
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::IsImmediateModeOn() const
{
if(!HasOpenedContext()) return Standard_False;
return myLocalContexts(myCurLocalIndex)->IsImmediateModeOn();
}
Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw()
{
if(HasOpenedContext())
return myLocalContexts(myCurLocalIndex)->BeginImmediateDraw();
return Standard_False;
}
//=======================================================================
//function : ImmediateAdd
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::ImmediateAdd(const Handle(AIS_InteractiveObject)& anIObj,
const Standard_Integer AMode)
{
if(HasOpenedContext()){
return myLocalContexts(myCurLocalIndex)->ImmediateAdd(anIObj,AMode);}
return Standard_False;
}
//=======================================================================
//function : ImmediateRemove
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::ImmediateRemove(const Handle(AIS_InteractiveObject)& anIObj,
const Standard_Integer aMode)
{
if(HasOpenedContext())
return myLocalContexts(myCurLocalIndex)->ImmediateRemove(anIObj,aMode);
return Standard_False;
}
//=======================================================================
//function : EndImmediateDraw
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::EndImmediateDraw(const Handle(V3d_View)& aView,
const Standard_Boolean DoubleBuf)
{
if(HasOpenedContext())
return myLocalContexts(myCurLocalIndex)->EndImmediateDraw(aView,DoubleBuf);
return Standard_False;
}
//=======================================================================
//function : EndImmediateDraw
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::EndImmediateDraw(const Standard_Boolean DoubleBuf)
{
if(HasOpenedContext()){
Handle(V3d_View) V ;
myMainVwr->InitActiveViews();
if(myMainVwr->MoreActiveViews()){
V = myMainVwr->ActiveView();
return myLocalContexts(myCurLocalIndex)->EndImmediateDraw(V,DoubleBuf);
}
}
return Standard_False;
}
//=======================================================================
//function : ResetOriginalState
//purpose :
//=======================================================================
void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updateviewer)
{
Standard_Boolean upd_main(Standard_False),upd_col(Standard_False);
TColStd_ListIteratorOfListOfInteger itl;
for (AIS_DataMapIteratorOfDataMapOfIOStatus it(myObjects);it.More();it.Next()){
const Handle(AIS_InteractiveObject)& iobj = it.Key();
const Handle(AIS_GlobalStatus)& STAT = it.Value();
switch(STAT->GraphicStatus()){
case AIS_DS_Displayed:{
upd_main = Standard_True;
// partie display...
for(itl.Initialize(STAT->DisplayedModes());itl.More();itl.Next())
myMainPM->Display(iobj,itl.Value());
if(STAT->IsHilighted()){
if(STAT->HilightColor()!=Quantity_NOC_WHITE)
HilightWithColor(iobj,STAT->HilightColor(),Standard_False);
else
Hilight(iobj,Standard_False);
}
//partie selection
for(itl.Initialize(STAT->SelectionModes());itl.More();itl.Next()){
if(itl.Value()!=-1)
mgrSelector->Activate(iobj,itl.Value(),myMainSel);
}
break;
}
case AIS_DS_Erased:{
upd_col = Standard_True;
EraseGlobal(iobj,Standard_False,Standard_True);
break;
}
case AIS_DS_FullErased:{
EraseGlobal(iobj,Standard_False,Standard_False);
break;
}
default:
break;
}
}
if(updateviewer){
if(upd_main)
myMainVwr->Update();
if(upd_col)
myCollectorVwr->Update();
}
}
#ifdef IMP051001
//=======================================================================
//function : SetZDetection
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetZDetection(const Standard_Boolean aStatus)
{
myZDetectionFlag = aStatus;
}
//=======================================================================
//function : ZDetection
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::ZDetection() const
{
return myZDetectionFlag;
}
#endif

View File

@@ -0,0 +1,88 @@
// File: AIS_InteractiveContext_3.cxx
// Created: Tue Jan 09 17:21:39 2001
// Author: Sergey Altukhov
// <s-altukhov@nnov.matra-dtv.fr>
// Modified: 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets
#include <AIS_InteractiveContext.jxx>
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
#include <AIS_GlobalStatus.hxx>
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
//=======================================================================
//function : Erase
//purpose : display an interactive object from the collector.
//=======================================================================
void AIS_InteractiveContext::DisplayFromCollector(const Handle(AIS_InteractiveObject)& anIObj,
const Standard_Boolean updateviewer)
{
if ( !IsInCollector( anIObj ) ) return;
if ( !HasOpenedContext() ){
if ( DisplayStatus( anIObj ) == AIS_DS_Erased )
Display( anIObj,Standard_False);
if( updateviewer ){
myMainVwr->Update();
if( !myCollectorVwr.IsNull() )
myCollectorVwr->Update();
}
}
}
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
//=======================================================================
//function : SetPolygonOffsets
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetPolygonOffsets(
const Handle(AIS_InteractiveObject)& anObj,
const Standard_Integer aMode,
const Standard_Real aFactor,
const Standard_Real aUnits,
const Standard_Boolean updateviewer)
{
if ( anObj.IsNull() )
return;
if( !anObj->HasInteractiveContext() )
anObj->SetContext( this );
anObj->SetPolygonOffsets( aMode, aFactor, aUnits );
if ( updateviewer ) {
if( myObjects.IsBound( anObj ) ) {
Handle(AIS_GlobalStatus) STATUS = myObjects(anObj);
if ( STATUS->GraphicStatus() == AIS_DS_Displayed )
myMainVwr->Update();
}
}
}
//=======================================================================
//function : HasPolygonOffsets
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::HasPolygonOffsets(const Handle(AIS_InteractiveObject)& anObj) const
{
return ( !anObj.IsNull() && anObj->HasPolygonOffsets() );
}
//=======================================================================
//function : PolygonOffsets
//purpose :
//=======================================================================
void AIS_InteractiveContext::PolygonOffsets(
const Handle(AIS_InteractiveObject)& anObj,
Standard_Integer& aMode,
Standard_Real& aFactor,
Standard_Real& aUnits) const
{
if ( HasPolygonOffsets( anObj ) )
anObj->PolygonOffsets( aMode, aFactor, aUnits );
}
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets

698
src/AIS/AIS_InteractiveObject.cdl Executable file
View File

@@ -0,0 +1,698 @@
-- File: AIS_InteractiveObject.cdl
-- Created: Wed Dec 11 11:29:18 1996
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible
-- Quantity_Color instead the restricted NameOfColor.
-- Add SetCurrentFacingModel() methods
-- EUG : G003 05/11/1999 Degeneration mode support
-- Add SetDegenerateModel() methods
-- GG : IMP140100 Add HasPresentation() and Presentation() methods
-- Add SetAspect() method
-- SAN : OCC4895 22/03/04 High-level interface for controlling polygon offsets
--
---Copyright: Matra Datavision 1996
deferred class InteractiveObject from AIS inherits SelectableObject from SelectMgr
---Purpose:
-- Defines a class of objects with display and selection services.
-- Entities which are visualized and selected are
-- Interactive Objects. You can make use of classes of
-- standard Interactive Objects for which all necessary
-- methods have already been programmed, or you can
-- implement your own classes of Interactive Objects.
-- Specific attributes of entities such as arrow aspect for
-- dimensions must be loaded in a Drawer. This Drawer
-- is then applied to the Interactive Object in view.
-- There are four types of Interactive Object in AIS: the
-- construction element or Datum, the Relation, which
-- includes both dimensions and constraints, the Object,
-- and finally, when the object is of an unknown type, the None type.
-- Inside these categories, a signature, or index,
-- provides the possibility of additional characterization.
-- By default, the Interactive Object has a None type
-- and a signature of 0. If you want to give a particular
-- type and signature to your interactive object, you must
-- redefine the methods, Signature and Type.
-- Warning
-- In the case of attribute methods, methods for
-- standard attributes are virtual. They must be
-- redefined by the inheriting classes. Setcolor for a
-- point and Setcolor for a plane, for example, do not
-- affect the same attributes in the Drawer.
uses
Trsf from gp,
NameOfColor from Quantity,
Color from Quantity,
Ratio from Quantity,
ListOfTransient from TColStd,
ListOfInteger from TColStd,
Box from Bnd,
NameOfMaterial from Graphic3d,
MaterialAspect from Graphic3d,
Drawer from AIS,
PToContext from AIS,
TypeOfPresentation3d from PrsMgr,
InteractiveContext from AIS,
KindOfInteractive from AIS,
TypeOfFacingModel from Aspect,
TypeOfDegenerateModel from Aspect,
Transformation from Geom,
Presentation from Prs3d,
BasicAspect from Prs3d,
-- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
PresentationManager from PrsMgr,
Presentation from PrsMgr
-- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
is
Initialize (aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView) ;
---Purpose: The TypeOfPresention3d means that the interactive object
-- may have a presentation dependant of the view of Display
---Category: Virtual methods to be redefined...
Type (me) returns KindOfInteractive from AIS is virtual;
---Purpose:
-- Returns the kind of Interactive Object:
-- - None
-- - Datum
-- - Relation
-- - Object
-- By default, the interactive object has a None type.
-- Because specific shapes entail different behavior
-- according to their sub-shapes, you may need to
-- create a Local Context. This will allow you to
-- specify the additional characteristics which you
-- need to handle these shapes.
Signature(me) returns Integer from Standard is virtual;
---Purpose: Specifies additional characteristics of Interactive
-- Objects. A signature is, in fact, an index with integer
-- values assigned different properties.
-- This method is frequently used in conjuction with
-- Type to give a particular type and signature to an
-- Interactive Object. By default, the Interactive Object
-- has a None type and a signature of 0. Among the
-- datums, this signature is attributed to the shape
-- The remaining datums have the following default signatures:
-- - Point signature 1
-- - Axis signature 2
-- - Trihedron signature 3
-- - PlaneTrihedron signature 4
-- - Line signature 5
-- - Circle signature 6
-- - Plane signature 7.
AcceptShapeDecomposition(me) returns Boolean from Standard is virtual;
---C++: inline
---Purpose: Informs the graphic context that the interactive Object
-- may be decomposed into sub-shapes for dynamic selection.
-- The most used Interactive Object is AIS_Shape.
-- Activation methods for standard selection modes are
-- proposed in the Interactive Context. These include
-- selection by vertex or by edges. For datums with the
-- same behavior as AIS_Shape, such as vetices and
-- edges, we must redefine the virtual method so that
-- AcceptShapeDecomposition returns false.
-- Rule for selection :
-- Mode 0 : Selection of the interactive Object itself
-- Mode 1 : Selection of vertices
-- Mode 2 : Selection Of Edges
-- Mode 3 : Selection Of Wires
-- Mode 4 : Selection Of Faces ...
SetCurrentFacingModel(me: mutable;
aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_BOTH_SIDE);
---Purpose: change the current facing model apply on polygons for
-- SetColor(), SetTransparency(), SetMaterial() methods
-- default facing model is Aspect_TOFM_TWO_SIDE. This mean that attributes is
-- applying both on the front and back face.
CurrentFacingModel(me) returns TypeOfFacingModel from Aspect;
---Purpose: Returns the current facing model which is in effect.
SetColor(me:mutable;aColor:Color from Quantity) is virtual;
SetColor(me:mutable;aColor:NameOfColor from Quantity) is virtual;
---Purpose: only the interactive obj knowns which Drawer attribute
-- is affected by the color (ex: for a wire, it's the
-- wireaspect field of the drawer, but for a vertex, only
-- the point aspect field is affected by the color)
-- WARNING : Do not forget to set the corresponding fields
-- here (hasOwnColor and myOwnColor)
UnsetColor(me:mutable) is virtual;
---Purpose: Removes color settings. Only the Interactive Object
-- knows which Drawer attribute is affected by the color
-- setting. For a wire, for example, wire aspect is the
-- attribute affected. For a vertex, however, only point
-- aspect is affected by the color setting.
SetWidth(me:mutable; aValue:Real from Standard) is virtual;
---Purpose: Allows you to provide the setting aValue for width.
-- Only the Interactive Object knows which Drawer
-- attribute is affected by the width setting.
UnsetWidth(me:mutable) is virtual;
AcceptDisplayMode(me;aMode:Integer from Standard) returns Boolean from Standard is virtual;
---Purpose: Returns true if the class of objects accepts the display mode aMode.
-- The interactive context can have a default mode of
-- representation for the set of Interactive Objects. This
-- mode may not be accepted by a given class of
-- objects. Consequently, this virtual method allowing us
-- to get information about the class in question must be implemented.
DefaultDisplayMode(me) returns Integer from Standard is virtual;
---Purpose: Returns the default display mode. This method is to
-- be implemented when the main mode is not mode 0.
Redisplay (me:mutable; AllModes:Boolean from Standard =Standard_False);
---Purpose: Updates the active presentation; if <AllModes> = Standard_True
-- all the presentations inside are recomputed.
SetInfiniteState(me:mutable;aFlag:Boolean from Standard = Standard_True);
---Purpose: Sets the infinite state flag aFlage.
-- if <aFlag> = True , the interactiveObject is
-- considered as infinite, i.e. its graphic presentations
-- are not taken in account for View FitAll...
IsInfinite(me) returns Boolean from Standard;
---C++: inline
---Purpose:
-- Returns true if the interactive object is infinite. In this
-- case, its graphic presentations are not taken into
-- account in the fit-all view.
---Category: Link To InteractiveContext
HasInteractiveContext(me) returns Boolean from Standard;
---Purpose: Indicates whether the Interactive Object has a pointer
-- to an interactive context.
GetContext(me) returns InteractiveContext from AIS;
---Purpose: Returns the context pointer to the interactive context.
SetContext(me:mutable; aCtx : InteractiveContext from AIS) is virtual;
---Purpose: Sets the interactive context aCtx and provides a link
-- to the default drawing tool or "Drawer" if there is none.
HasOwner (me) returns Boolean from Standard;
---Purpose: Returns true if the object has an owner attributed to it.
-- The owner can be a shape for a set of sub-shapes or
-- a sub-shape for sub-shapes which it is composed of,
-- and takes the form of a transient.
GetOwner (me) returns any Transient from Standard;
---Purpose: Returns the owner of the Interactive Object.
-- The owner can be a shape for a set of sub-shapes or
-- a sub-shape for sub-shapes which it is composed of,
-- and takes the form of a transient.
-- There are two types of owners:
-- - Direct owners, decomposition shapes such as
-- edges, wires, and faces.
-- - Users, presentable objects connecting to sensitive
-- primitives, or a shape which has been decomposed.
---C++: inline
---C++: return const&
SetOwner (me : mutable;
ApplicativeEntity : Transient from Standard);
---Purpose: Allows you to attribute the owner ApplicativeEntity to
-- an Interactive Object. This can be a shape for a set of
-- sub-shapes or a sub-shape for sub-shapes which it
-- is composed of. The owner takes the form of a transient.
---C++: inline
ClearOwner(me:mutable);
---Purpose: Each Interactive Object has methods which allow us
-- to attribute an Owner to it in the form of a Transient.
-- This method removes the owner from the graphic entity.
HasUsers(me) returns Boolean from Standard;
Users(me) returns ListOfTransient from TColStd;
---C++: inline
---C++: return const&
AddUser(me:mutable; aUser : Transient from Standard);
ClearUsers(me:mutable);
---Category: "STANDARD" LOCAL ATTRIBUTES :
--
-- -Local DisplayMode
-- -Color
-- -width of lines or points
-- -typeOfLine or Marker Aspect
-- -material name (if needed)
-- -transparency (if needed)
--
-- Specific attributes of entities (such as
-- arrow aspect for dimensions) must be
-- loaded in a Drawer; this drawer is then
-- applied to InteractiveObject WARNING :
-- Here the Methods for standard attributes
-- are virtual and do nothing they must be
-- redefined by the inheriting classes
-- (setcolor for a point and setcolor for a plane
-- don't affect the same attributes in the Drawer)
HasDisplayMode (me)
returns Boolean from Standard;
---Purpose:
-- Returns true if the Interactive Object has a display
-- mode setting. Otherwise, it is displayed in Neutral Point.
---C++: inline
SetDisplayMode(me : mutable; aMode : Integer from Standard);
---Purpose: Sets the display mode aMode for the interactive object.
-- An object can have its own temporary display mode,
-- which is different from that proposed by the interactive context.
-- The range of possibilities currently proposed is the following:
-- - AIS_WireFrame
-- - AIS_Shaded
-- - AIS_QuickHLR
-- - AIS_ExactHLR
-- This range can, however, be extended through the creation of new display modes.
UnsetDisplayMode(me : mutable);
---Purpose: Removes display mode settings from the interactive object.
---C++: inline
DisplayMode(me)
returns Integer;
---C++: inline
---Purpose: Returns the display mode setting of the Interactive Object.
-- The range of possibilities is the following:
-- - AIS_WireFrame
-- - AIS_Shaded
-- - AIS_QuickHLR
-- - AIS_ExactHLR
-- This range can, however, be extended through the
-- creation of new display modes.
HasSelectionMode(me) returns Boolean from Standard;
---Purpose: Allows you to change the selection mode of an
-- Interactive Object.
-- The default selection mode setting is 0.
-- For shapes, for example, the selection modes are as follows:
-- - mode 0 - selection of the shape itself
-- - mode 1 - selection of vertices
-- - mode 2 - selection of edges
-- - mode 3 - selection of wires
-- - mode 4 - selection of faces
-- - mode 5 - selection of shells
-- - mode 6 - selection of solids
-- - mode 7 - selection of compounds
-- For trihedra, on the other hand, the selection modes are the following four:
-- - mode 0 - selection of a trihedron
-- - mode 1 - selection of its origin
-- - mode 2 - selection of its axes
-- - mode 3 - selection of its planes
SelectionMode(me) returns Integer from Standard;
---Purpose: Returns the selection mode of the interactive object.
SetSelectionMode(me:mutable; aMode: Integer from Standard);
---Purpose: You can change the default selection mode index
-- aMode of an Interactive Object.
-- This is only of interest if you decide that mode 0
-- adopted by convention will not do.
UnsetSelectionMode(me:mutable);
---Purpose: You can change the default selection mode index of
-- an Interactive Object.
-- This is only of interest if you decide that the 0 mode
-- adopted by convention will not do.
---C++: inline
SelectionPriority(me) returns Integer from Standard;
---C++: inline
---Purpose: Returns the selection priority setting. -1 indicates that there is none.
-- You can modify the selection priority of an owner to
-- make one entity more selectionable than another one.
-- The default selection priority for an owner is 5, for
-- example. To increase selection priority, choose a
-- setting between 5 and 10. An entity with priority 7 will
-- take priority over one with a setting of 6 if both
-- objects are selected at the same time.
-- You could give vertices priority 8, edges priority 7,
-- faces priority 6, and shapes priority 5. If a vertex, an
-- edge and a face are simultaneously detected during
-- selection, only the vertex will then be highlighted.
-- For trihedra, for example, the default priorities are the following four:
-- - priority 1 - a trihedron
-- - priority 5 - its origin
-- - priority 3 - its axes
-- - priority 2 - its planes
SetSelectionPriority(me:mutable; aPriority : Integer from Standard);
---C++: inline
---Purpose: Allows you to provide a setting aPriority for selection priority.
-- You can modify selection priority of an owner to make
-- one entity more selectionable than another one. The
-- default selection priority for an owner is 5, for
-- example. To increase selection priority, choose a
-- setting between 5 and 10. An entity with priority 7 will
-- take priority over one with a setting of 6.
UnsetSelectionPriority(me:mutable);
---C++: inline
---Purpose: Removes the setting for selection priority. SelectionPriority then returns -1.
HasSelectionPriority(me) returns Boolean from Standard;
---C++: inline
---Purpose: Returns true if there is a setting for selection priority.
-- You can modify selection priority of an owner to make
-- one entity more selectionable than another one. The
-- default selection priority for an owner is 5, for
-- example. To increase selection priority, choose a
-- setting between 5 and 10. An entity with priority 7 will
-- take priority over one with a setting of 6.
HasHilightMode(me) returns Boolean from Standard;
---C++: inline
---Purpose: Returns true if the Interactive Object is in highlight mode.
HilightMode(me) returns Integer from Standard ;
---C++: inline
---Purpose: Returns the setting for highlight mode.
-- At dynamic detection, the presentation echoed by the
-- Interactive Context, is by default the presentation
-- already on the screen. You can specify a Highlight
-- presentation mode which is valid no matter what the
-- active representation of the object. It makes no
-- difference whether this choice is temporary or
-- definitive. To do this, we use the following functions:
-- - SetHilightMode
-- - UnSetHilightMode
-- In the case of a shape, whether it is visualized in
-- wireframe presentation or with shading, we want to
-- systematically highlight the wireframe presentation.
-- Consequently, we set the highlight mode to 0.
SetHilightMode(me:mutable;anIndex : Integer from Standard);
---C++: inline
---Purpose: Sets the highlight mode anIndex for the interactive object.
-- If, for example, you want to systematically highlight
-- the wireframe presentation of a shape - whether
-- visualized in wireframe presentation or with shading -
-- you set the highlight mode to 0.
UnsetHilightMode(me:mutable);
---C++: inline
---Purpose: Allows the user to take a given Prs for hilight
-- ex : for a shape which would be displayed in shading mode
-- the hilight Prs is the wireframe mode.
-- if No specific hilight mode is defined, the displayed Prs
-- will be the hilighted one.
HasColor (me) returns Boolean from Standard;
---C++: inline
---Purpose: Returns true if the Interactive Object has color.
Color(me) returns NameOfColor from Quantity is virtual;
---C++: inline
---Purpose: Returns the color setting of the Interactive Object.
Color(me; aColor: out Color from Quantity) is virtual;
---C++: inline
HasWidth(me) returns Boolean from Standard;
---C++: inline
---Purpose: Returns true if the Interactive Object has width.
Width(me) returns Real from Standard ;
--- Purpose: Returns the width setting of the Interactive Object.
HasMaterial(me) returns Boolean from Standard ;
---Purpose: Returns true if the Interactive Object has a setting for material.
Material(me) returns NameOfMaterial from Graphic3d is virtual;
---Purpose: Returns the current material setting.
-- This will be on of the following materials:
-- - Brass
-- - Bronze
-- - Gold
-- - Pewter
-- - Silver
-- - Stone.
SetMaterial(me:mutable;aName:NameOfMaterial from Graphic3d) is virtual;
---Purpose: Sets the name aName for material defining this
-- display attribute for the interactive object.
-- Material aspect determines shading aspect, color and
-- transparency of visible entities.
SetMaterial(me:mutable;aName:MaterialAspect from Graphic3d) is virtual;
--- Purpose: Sets the material aMat defining this display attribute
-- for the interactive object.
-- Material aspect determines shading aspect, color and
-- transparency of visible entities.
UnsetMaterial(me:mutable) is virtual;
---Purpose: Removes the setting for material.
SetTransparency(me:mutable;aValue : Real from Standard=0.6) is virtual;
---Purpose: Attributes a setting aValue for transparency.
-- The transparency value should be between 0.0 and 1.0.
-- At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
-- Warning At a value of 1.0, there may be nothing visible.
IsTransparent(me) returns Boolean from Standard;
---C++: inline
---Purpose: Returns true if there is a transparency setting.
Transparency(me) returns Real from Standard is virtual;
---Purpose: Returns the transparency setting.
-- This will be between 0.0 and 1.0.
-- At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
UnsetTransparency(me:mutable) is virtual;
---Purpose: Removes the transparency setting. The object is opaque by default.
SetAttributes(me:mutable; aDrawer: Drawer from AIS) is virtual;
---Purpose: Initializes the drawing tool aDrawer.
Attributes(me) returns any Drawer from AIS;
---C++: return const&
---C++: inline
---Purpose: Returns the attributes settings.
UnsetAttributes(me:mutable) is virtual;
---Purpose: Clears settings provided by the drawing tool aDrawer.
---Category: information about Prs to be recomputed
-- after local attributes change... to be removed...
RecomputeEveryPrs(me) returns Boolean is virtual private;
MustRecomputePrs(me;aMode : Integer from Standard) is private;
ListOfRecomputeModes(me)returns ListOfInteger from TColStd is private;
---C++: return const&
SetRecomputeOk(me:mutable) is private;
-- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
Fill(me: mutable;
aPresentationManager: PresentationManager from PrsMgr;
aPresentation: mutable Presentation from PrsMgr;
aMode: Integer from Standard = 0)
is redefined protected;
-- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
State(me:mutable;theState: Integer from Standard) ;
---C++: inline
State(me) returns Integer from Standard ;
---C++: inline
SetDegenerateModel ( me : mutable;
aModel : TypeOfDegenerateModel from Aspect =
Aspect_TDM_WIREFRAME;
aRatio : Ratio from Quantity = 0.0) is virtual;
---Level: Public
---Purpose: Sets the model of degeneration for the shaded representation
-- according to the degenerate ratio >= 0. & <= 1. where :
-- <aRatio> = 0. indicate that all polygons of the object
-- will be displayed.
-- <aRatio> = 1. indicate that no polygons will be displayed !!
-- When <ARatio> is > 0 & < 1. the corresponding amount
-- of object polygons will be displayed with a random method.
-- Warning: the degenerate structure is shown only when
-- the animation and degenerate flags are set to TRUE
-- in V3d_View::SetAnimationMode(..)
-- Category: Methods to manage the object degeneration
DegenerateModel ( me ;
aRatio: out Ratio from Quantity )
returns TypeOfDegenerateModel from Aspect is virtual;
---Level: Public
---Purpose: returns the current degeneration model and ratio
-- for the polygons
---Category: Inquire methods
SetTransformation ( me : mutable;
aTranformation: Transformation from Geom;
postConcatenate: Boolean from Standard = Standard_False;
updateSelection: Boolean from Standard = Standard_True)
is static;
---Level: Public
---Purpose: Transforms all presentations of the object
-- and replace the actual transformation matrix if <postConcatenate> is FALSE.
-- Note that the selection must be updated only at the end of
-- object animation when <updateSelection> is TRUE
---Category: Transformation method
UnsetTransformation ( me : mutable )
is static;
---Level: Public
---Purpose: Deactivate the current transformation
---Category: Transformation method
Transformation ( me : mutable ) returns Transformation from Geom
is static;
---Level: Public
---Purpose: Returns the current transformation associated
-- to the first available presentation of this object.
---Category: Inquire transformation method
HasTransformation ( me ) returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns TRUE when this object is transformed
---Category: Inquire transformation method
HasPresentation ( me ) returns Boolean from Standard
is static;
---Level: Public
---Purpose: Returns TRUE when this object has a presentation
-- in the current DisplayMode()
---Category: Inquire transformation method
Presentation ( me ) returns Presentation from Prs3d
is static;
---Level: Public
---Purpose: Returns the current presentation of this object
-- according to the current DisplayMode()
---Category: Inquire transformation method
SetAspect ( me : mutable; anAspect: any BasicAspect from Prs3d;
globalChange: Boolean from Standard = Standard_True)
is static;
---Level: Public
---Purpose: Sets the graphic basic aspect to the current presentation.
-- When <globalChange> is TRUE , the full object presentation
-- is changed.
-- When <globalChange> is FALSE , only the current group
-- of the object presentation is changed.
---Category: Graphic attributes management
-- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
SetPolygonOffsets ( me : mutable;
aMode : Integer from Standard;
aFactor : Real from Standard = 1.0;
aUnits : Real from Standard = 0.0 ) is virtual;
---Level: Public
---Purpose: Sets up polygon offsets for this object.
-- It modifies all existing presentations of <anObj> (if any),
-- so it is reasonable to call this method after <anObj> has been displayed.
-- Otherwise, Compute() method should pass Graphic3d_AspectFillArea3d
-- aspect from <myDrawer> to Graphic3d_Group to make polygon offsets work.
--
-- <aMode> parameter can contain various combinations of
-- Aspect_PolygonOffsetMode enumeration elements (Aspect_POM_None means
-- that polygon offsets are not changed).
-- If <aMode> is different from Aspect_POM_Off and Aspect_POM_None, then <aFactor> and <aUnits>
-- arguments are used by graphic renderer to calculate a depth offset value:
--
-- offset = <aFactor> * m + <aUnits> * r, where
-- m - maximum depth slope for the polygon currently being displayed,
-- r - minimum window coordinates depth resolution (implementation-specific).
--
-- Deafult settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0.
--
-- Negative offset values move polygons closer to the viewport,
-- while positive values shift polygons away.
-- Consult OpenGL reference for details (glPolygonOffset function description).
--
-- NOTE: This method has a side effect - it creates own shading aspect
-- if not yet created, so it is better to set up object material,
-- color, etc. first.
---Category: Graphic attributes management
HasPolygonOffsets ( me )
returns Boolean from Standard
is virtual;
---Level: Public
---Purpose: Returns Standard_True if <myDrawer> has non-null shading aspect
---Category: Inquire methods
PolygonOffsets ( me;
aMode : out Integer from Standard;
aFactor : out Real from Standard;
aUnits : out Real from Standard ) is virtual;
---Level: Public
---Purpose: Retrieves current polygon offsets settings from <myDrawer>.
---Category: Inquire methods
fields
myCTXPtr : PToContext from AIS;
-- The reference to applicative World...
myOwner : Transient from Standard;
myUsers : ListOfTransient from TColStd;
-- The Information Fields
myDrawer : Drawer from AIS is protected ;
myTransparency : Real from Standard is protected;
-- GER61351 myOwnColor : NameOfColor from Quantity is protected;
myOwnColor : Color from Quantity is protected;
myOwnMaterial : NameOfMaterial from Graphic3d is protected;
---myOwnMaterial : NameOfPhysicalMaterial from Graphic3d is protected;
mySelPriority : Integer from Standard;
myDisplayMode : Integer from Standard ;
mySelectionMode : Integer from Standard;
myHilightMode : Integer from Standard is protected;
myOwnWidth : Real from Standard is protected;
myInfiniteState : Boolean from Standard is protected;
hasOwnColor : Boolean from Standard is protected;
hasOwnMaterial : Boolean from Standard is protected ;
myCurrentFacingModel: TypeOfFacingModel from Aspect is protected;
-- the management field (to be removed)...
myRecomputeEveryPrs : Boolean from Standard is protected;
myToRecomputeModes : ListOfInteger from TColStd is protected;
mystate : Integer from Standard;
myHasTransformation : Boolean from Standard;
friends
class InteractiveContext from AIS
end InteractiveObject;

809
src/AIS/AIS_InteractiveObject.cxx Executable file
View File

@@ -0,0 +1,809 @@
// File: AIS_InteractiveObject.cxx
// Created: Wed Dec 18 14:44:37 1996
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
// Modified : 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets
#define BUC60577 //GG_101099 Enable to compute correctly
// transparency with more than one object in the view.
#define GER61351 //GG_171199 Enable to set an object RGB color
// instead a restricted object NameOfColor.
// Add SetCurrentFacingModel() method
//
#define G003 //EUG/GG 260100 DEgenerate mode support
// Add SetDegenerateModel() methods
#define IMP020200 //GG Add SetTransformation() method
#define IMP140200 //GG Add HasPresentation() and Presentation() methods
// Add SetAspect() method.
#define BUC60632 //GG 15/03/00 Add protection on SetDisplayMode()
// method, compute only authorized presentation.
#define IMP220501 //GG CADPAK_V2 Update selection properly
#define OCC708 //SAV unsetting transformation correctly
#include <AIS_InteractiveObject.ixx>
#include <Aspect_PolygonOffsetMode.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Root.hxx>
#include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <AIS_GraphicTool.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
//=======================================================================
//function : AIS_InteractiveObject
//purpose :
//=======================================================================
AIS_InteractiveObject::
AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
SelectMgr_SelectableObject(aTypeOfPresentation3d),
myDrawer(new AIS_Drawer()),
myTransparency(0.),
myOwnColor(Quantity_NOC_WHITE),
myHilightMode(-1),
myOwnWidth(0.0),
myInfiniteState(Standard_False),
hasOwnColor(Standard_False),
hasOwnMaterial(Standard_False),
myRecomputeEveryPrs(Standard_True),
mySelPriority(-1),
myDisplayMode (-1),
mySelectionMode(0),
mystate(0)
{
Handle (AIS_InteractiveContext) Bid;
myCTXPtr = Bid.operator->();
#ifdef GER61351
SetCurrentFacingModel();
#endif
}
//=======================================================================
//function : Redisplay
//purpose :
//=======================================================================
void AIS_InteractiveObject::Redisplay(const Standard_Boolean AllModes)
{
Update(AllModes);
UpdateSelection();
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
AIS_KindOfInteractive AIS_InteractiveObject::Type() const
{return AIS_KOI_None;}
//=======================================================================
//function : Signature
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveObject::Signature() const
{return -1;}
//=======================================================================
//function : RecomputeEveryPrs
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::RecomputeEveryPrs() const
{return myRecomputeEveryPrs;}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasInteractiveContext() const
{
Handle (AIS_InteractiveContext) aNull;
return (myCTXPtr != aNull.operator->());
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const
{
return myCTXPtr;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetContext(const Handle(AIS_InteractiveContext)& aCtx)
{
myCTXPtr = aCtx.operator->();
if (myDrawer.IsNull()) {
myDrawer = new AIS_Drawer;
#ifdef DEB
cout << "AIS_InteractiveObject::SetContext DRAWER NUL!" << endl;
#endif
}
myDrawer->Link(aCtx->DefaultDrawer());
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasOwner() const
{
return (!myOwner.IsNull());
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::ClearOwner()
{
myOwner.Nullify();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasUsers() const
{
return (!myUsers.IsEmpty());
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::AddUser(const Handle(Standard_Transient)& aUser)
{
myUsers.Append(aUser);
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::ClearUsers()
{
myUsers.Clear();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetDisplayMode(const Standard_Integer aMode)
{
#ifdef BUC60632
if( AcceptDisplayMode(aMode) )
#endif
myDisplayMode = aMode;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetSelectionMode(const Standard_Integer aMode)
{
mySelectionMode = aMode;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
#ifdef GER61351
void AIS_InteractiveObject::SetCurrentFacingModel(const Aspect_TypeOfFacingModel aModel) {
myCurrentFacingModel = aModel;
}
//=======================================================================
//function : CurrentFacingModel
//purpose :
//=======================================================================
Aspect_TypeOfFacingModel AIS_InteractiveObject::CurrentFacingModel() const {
return myCurrentFacingModel;
}
#endif
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetColor(const Quantity_NameOfColor aColor)
#ifdef GER61351
{
SetColor(Quantity_Color(aColor));
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetColor(const Quantity_Color &aColor)
#endif
{
myOwnColor = aColor;
hasOwnColor = Standard_True;
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetColor()
{
hasOwnColor = Standard_False;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetWidth(const Standard_Real aValue)
{
myOwnWidth = aValue;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetWidth()
{
myOwnWidth = 0.;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
//POP pour K4L
void AIS_InteractiveObject::SetMaterial(const Graphic3d_NameOfMaterial aName)
//void AIS_InteractiveObject::SetMaterial(const Graphic3d_NameOfPhysicalMaterial aName)
{
if( HasColor() || IsTransparent() || HasMaterial() )
{
myDrawer->ShadingAspect()->SetMaterial(aName);
}
else
{
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->SetMaterial(aName);
#ifndef BUC60577 //???
myDrawer->ShadingAspect()->SetColor(AIS_GraphicTool::GetInteriorColor(myDrawer->Link()));
#endif
}
myOwnMaterial = aName;
hasOwnMaterial = Standard_True;
}
//=======================================================================
//function : SetMaterial
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetMaterial(const Graphic3d_MaterialAspect& aMat)
{
#ifdef BUC60577
if( HasColor() || IsTransparent() || HasMaterial() )
#else
if(hasOwnColor ||(myTransparency==0.0) || hasOwnMaterial )
#endif
{
myDrawer->ShadingAspect()->SetMaterial(aMat);
}
else
{
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->SetMaterial(aMat);
}
hasOwnMaterial = Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetMaterial()
{
#ifdef BUC60577
if( !HasMaterial() ) return;
if( HasColor() || IsTransparent()) {
myDrawer->ShadingAspect()->SetMaterial(
AIS_GraphicTool::GetMaterial(myDrawer->Link()));
if( HasColor() ) SetColor(myOwnColor);
if( IsTransparent() ) SetTransparency(myTransparency);
}
#else
if(!hasOwnMaterial) return;
if(hasOwnColor ||(myTransparency==0.0))
{
myDrawer->ShadingAspect()->SetMaterial(AIS_GraphicTool::GetMaterial(myDrawer->Link()));
}
#endif
else{
Handle(Prs3d_ShadingAspect) SA;
myDrawer->SetShadingAspect(SA);
}
hasOwnMaterial = Standard_False;
}
//=======================================================================
//function : SetTransparency
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetTransparency(const Standard_Real aValue)
{
#ifdef BUC60577 // Back & Front material can be different !
if(!HasColor() && !IsTransparent() && !HasMaterial() ) {
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
if(!myDrawer->Link().IsNull())
myDrawer->ShadingAspect()->SetMaterial(AIS_GraphicTool::GetMaterial(myDrawer->Link()));
}
Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
FMat.SetTransparency(aValue); BMat.SetTransparency(aValue);
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
#else
if(aValue<0.0 || aValue>1.0) return;
if(aValue<=0.05)
{
UnsetTransparency();
return;
}
if(hasOwnColor || hasOwnMaterial || myTransparency> 0.0)
{
Graphic3d_MaterialAspect Mat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
Mat.SetTransparency(aValue);
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(Mat);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Mat);
}
else
{
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
if(!myDrawer->Link().IsNull())
myDrawer->ShadingAspect()->SetMaterial(AIS_GraphicTool::GetMaterial(myDrawer->Link()));
Graphic3d_MaterialAspect Mat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
Mat.SetTransparency(aValue);
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(Mat);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Mat);
}
#endif
myTransparency = aValue;
}
//=======================================================================
//function : UnsetTransparency
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetTransparency()
{
#ifdef BUC60577 // Back & Front material can be different !
if(HasColor() || HasMaterial() )
{
Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
FMat.SetTransparency(0.); BMat.SetTransparency(0.);
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
}
#else
if(hasOwnColor || hasOwnMaterial )
{
Graphic3d_MaterialAspect Mat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
Mat.SetTransparency(0.0);
// myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(Mat);
// myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Mat);
myDrawer->ShadingAspect()->SetMaterial(Mat);
}
#endif
else{
Handle (Prs3d_ShadingAspect) SA;
myDrawer->SetShadingAspect(SA);
}
myTransparency =0.0;
}
//=======================================================================
//function : Transparency
//purpose :
//=======================================================================
Standard_Real AIS_InteractiveObject::Transparency() const
{
return (myTransparency<=0.05 ? 0 : myTransparency);
// Graphic3d_MaterialAspect Mat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
// return Mat.Transparency();
}
//=======================================================================
//function : SetAttributes
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetAttributes(const Handle(AIS_Drawer)& aDrawer)
{myDrawer = aDrawer;}
//=======================================================================
//function : UnsetAttributes
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetAttributes()
{
Handle(AIS_Drawer) dr = new AIS_Drawer();
if(myDrawer->HasLink())
dr->Link(myDrawer->Link());
myDrawer = dr;
hasOwnColor = Standard_False;
hasOwnMaterial = Standard_False;
myOwnWidth = 0.0;
myTransparency = 0.0;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::MustRecomputePrs(const Standard_Integer ) const
{}
//=======================================================================
//function :
//purpose :
//=======================================================================
const TColStd_ListOfInteger& AIS_InteractiveObject::ListOfRecomputeModes() const
{return myToRecomputeModes;}
//=======================================================================
//function :
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetRecomputeOk()
{myToRecomputeModes.Clear();}
//=======================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::AcceptDisplayMode(const Standard_Integer ) const
{return Standard_True;}
//=======================================================================
//function : DefaultDisplayMode
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveObject::DefaultDisplayMode() const
{return 0;}
//=======================================================================
//function : SetInfiniteState
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetInfiniteState(const Standard_Boolean aFlag)
{
myInfiniteState = aFlag;
Handle(Prs3d_Presentation) P;
for(Standard_Integer i =1; i<=myPresentations.Length();i++){
P = Handle(Prs3d_Presentation)::DownCast(myPresentations(i).Presentation());
if(!P.IsNull())
P->SetInfiniteState(myInfiniteState);}
}
#ifdef G003
//=======================================================================
//function : SetDegenerateModel
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetDegenerateModel(
const Aspect_TypeOfDegenerateModel aModel,
const Quantity_Ratio aRatio ) {
if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
}
myDrawer->ShadingAspect()->Aspect()->SetDegenerateModel(aModel,aRatio);
if(!GetContext().IsNull()){
if( GetContext()->MainPrsMgr()->HasPresentation(this,1)){
Handle(Prs3d_Presentation) P =
GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
Handle(Graphic3d_AspectFillArea3d) a4bis =
myDrawer->ShadingAspect()->Aspect();
P->SetPrimitivesAspect(a4bis);
}
}
}
//=======================================================================
//function : DegenerateModel
//purpose :
//=======================================================================
Aspect_TypeOfDegenerateModel AIS_InteractiveObject::DegenerateModel(
Quantity_Ratio& aRatio) const
{
return myDrawer->ShadingAspect()->Aspect()->DegenerateModel(aRatio);
}
#endif
#ifdef IMP020200
//=======================================================================
//function : SetTransformation
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetTransformation(const Handle(Geom_Transformation)& aTrsf, const Standard_Boolean postConcatenate, const Standard_Boolean updateSelection) {
if(!GetContext().IsNull()){
const PrsMgr_Presentations& prs = Presentations();
Handle(Prs3d_Presentation) P;
Standard_Integer mode;
myHasTransformation = Standard_True;
for( Standard_Integer i=1 ; i<=prs.Length() ; i++ ) {
mode = prs(i).Mode();
P = GetContext()->MainPrsMgr()->CastPresentation(this,mode)->Presentation();
if( postConcatenate ) P->Multiply(aTrsf);
else P->Transform(aTrsf);
if( updateSelection ) {
#ifdef IMP220501
myCTXPtr->ClearSelected(Standard_True);
myCTXPtr->RecomputeSelectionOnly(this);
#else
if( HasSelection(mode) ) {
UpdateSelection(mode);
}
#endif
}
}
}
}
//=======================================================================
//function : SetTransformation
//purpose :
//=======================================================================
void AIS_InteractiveObject::UnsetTransformation() {
#ifdef OCC708
static Handle(Geom_Transformation) trsf = new Geom_Transformation( gp_Trsf() );
#else
Handle(Geom_Transformation) trsf;
#endif
SetTransformation(trsf); // Set identity transformation
myHasTransformation = Standard_False;
}
//=======================================================================
//function : Transformation
//purpose :
//=======================================================================
Handle(Geom_Transformation) AIS_InteractiveObject::Transformation() {
Handle(Geom_Transformation) trsf;
if(!GetContext().IsNull() ) {
const PrsMgr_Presentations& prs = Presentations();
if( prs.Length() > 0 ) {
Handle(Prs3d_Presentation) P =
GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
trsf = P->Transformation();
}
}
return trsf;
}
//=======================================================================
//function : HasTransformation
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasTransformation() const {
return myHasTransformation;
}
#endif
#ifdef IMP140200
//=======================================================================
//function : HasPresentation
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasPresentation() const {
if( !GetContext().IsNull() &&
GetContext()->MainPrsMgr()->HasPresentation(this,myDisplayMode) ) {
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Presentation
//purpose :
//=======================================================================
Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const {
Handle(Prs3d_Presentation) prs;
if( HasPresentation() ) {
prs = GetContext()->MainPrsMgr()->
CastPresentation(this,myDisplayMode)->Presentation();
}
return prs;
}
//=======================================================================
//function : SetAspect
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& anAspect,
const Standard_Boolean globalChange) {
if( HasPresentation() ) {
Handle(Prs3d_Presentation) prs = Presentation();
{ Handle(Prs3d_ShadingAspect) aspect =
Handle(Prs3d_ShadingAspect)::DownCast(anAspect);
if( !aspect.IsNull() ) {
if( globalChange ) prs->SetPrimitivesAspect(aspect->Aspect());
Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
return;
}
}
{ Handle(Prs3d_LineAspect) aspect =
Handle(Prs3d_LineAspect)::DownCast(anAspect);
if( !aspect.IsNull() ) {
if( globalChange ) prs->SetPrimitivesAspect(aspect->Aspect());
Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
return;
}
}
{ Handle(Prs3d_PointAspect) aspect =
Handle(Prs3d_PointAspect)::DownCast(anAspect);
if( !aspect.IsNull() ) {
if( globalChange ) prs->SetPrimitivesAspect(aspect->Aspect());
Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
return;
}
}
{ Handle(Prs3d_TextAspect) aspect =
Handle(Prs3d_TextAspect)::DownCast(anAspect);
if( !aspect.IsNull() ) {
if( globalChange ) prs->SetPrimitivesAspect(aspect->Aspect());
Prs3d_Root::CurrentGroup(prs)->SetGroupPrimitivesAspect(aspect->Aspect());
return;
}
}
}
}
#endif
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
//=======================================================================
//function : SetPolygonOffsets
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetPolygonOffsets(const Standard_Integer aMode,
const Standard_Real aFactor,
const Standard_Real aUnits)
{
if ( !HasPolygonOffsets() )
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->Aspect()->SetPolygonOffsets( aMode, aFactor, aUnits );
// Modify existing presentations
Handle(Graphic3d_Structure) aStruct;
for( Standard_Integer i = 1, n = myPresentations.Length(); i <= n; i++ ) {
Handle(PrsMgr_Presentation3d) aPrs3d =
Handle(PrsMgr_Presentation3d)::DownCast( myPresentations(i).Presentation() );
if ( !aPrs3d.IsNull() ) {
aStruct = Handle(Graphic3d_Structure)::DownCast( aPrs3d->Presentation() );
if( !aStruct.IsNull() )
aStruct->SetPrimitivesAspect( myDrawer->ShadingAspect()->Aspect() );
}
}
}
//=======================================================================
//function : HasPolygonOffsets
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasPolygonOffsets() const
{
return !( myDrawer->ShadingAspect().IsNull() ||
( !myDrawer->Link().IsNull() &&
myDrawer->ShadingAspect() == myDrawer->Link()->ShadingAspect() ) );
}
//=======================================================================
//function : PolygonOffsets
//purpose :
//=======================================================================
void AIS_InteractiveObject::PolygonOffsets(Standard_Integer& aMode,
Standard_Real& aFactor,
Standard_Real& aUnits) const
{
if( HasPolygonOffsets() )
myDrawer->ShadingAspect()->Aspect()->PolygonOffsets( aMode, aFactor, aUnits );
}
void AIS_InteractiveObject::Fill(const Handle(PrsMgr_PresentationManager)& aPresentationManager,
const Handle(PrsMgr_Presentation)& aPresentation,
const Standard_Integer aMode)
{
PrsMgr_PresentableObject::Fill(aPresentationManager, aPresentation, aMode);
// Update polygon offsets for <aPresentation> using <myDrawer> data
if ( !myDrawer->ShadingAspect().IsNull() )
{
Standard_Integer aMode1 = Aspect_POM_Fill;
Standard_Real aFactor = 1., aUnits = 0.;
myDrawer->ShadingAspect()->Aspect()->PolygonOffsets( aMode1, aFactor, aUnits );
// Here we force this object to have default polygon offsets , if they are not
// turned on for this object explicitly
if ( ( aMode1 & Aspect_POM_None ) == Aspect_POM_None )
{
aMode1 = Aspect_POM_Fill;
aFactor = 1.;
aUnits = 0.;
myDrawer->ShadingAspect()->Aspect()->SetPolygonOffsets( aMode1, aFactor, aUnits );
}
}
Handle(PrsMgr_Presentation3d) aPrs3d =
Handle(PrsMgr_Presentation3d)::DownCast( aPresentation );
if ( !aPrs3d.IsNull() ) {
Handle(Graphic3d_Structure) aStruct =
Handle(Graphic3d_Structure)::DownCast( aPrs3d->Presentation() );
if( !aStruct.IsNull() )
aStruct->SetPrimitivesAspect( myDrawer->ShadingAspect()->Aspect() );
}
}
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets

114
src/AIS/AIS_InteractiveObject.lxx Executable file
View File

@@ -0,0 +1,114 @@
// File: AIS_InteractiveObject.lxx
// Created: Wed Jan 8 10:28:40 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
#define GER61351 //GG_171199 Enable to set an object RGB color
// instead a restricted object NameOfColor.
inline Standard_Boolean AIS_InteractiveObject::AcceptShapeDecomposition() const
{return Standard_False;}
inline Standard_Boolean AIS_InteractiveObject::IsInfinite() const
{return myInfiniteState;}
inline Standard_Boolean AIS_InteractiveObject::HasColor() const
{return hasOwnColor;}
inline const Handle(Standard_Transient)&
AIS_InteractiveObject::GetOwner() const
{return myOwner;}
inline void AIS_InteractiveObject::SetOwner(const Handle(Standard_Transient)& ApplicativeEntity)
{myOwner = ApplicativeEntity;}
inline const TColStd_ListOfTransient&
AIS_InteractiveObject::Users() const
{return myUsers;}
inline Standard_Boolean AIS_InteractiveObject::HasDisplayMode() const
{return myDisplayMode!=-1;}
inline void AIS_InteractiveObject::UnsetDisplayMode()
{myDisplayMode =-1;}
inline Standard_Integer AIS_InteractiveObject::DisplayMode() const
{return myDisplayMode;}
inline Standard_Boolean AIS_InteractiveObject::HasSelectionMode() const
{return mySelectionMode!=-1;}
inline void AIS_InteractiveObject::UnsetSelectionMode()
{mySelectionMode =-1;}
inline Standard_Integer AIS_InteractiveObject::SelectionMode() const
{return mySelectionMode;}
inline Quantity_NameOfColor AIS_InteractiveObject::Color() const
{
#ifdef GER61351
return myOwnColor.Name();
#else
return myOwnColor;
#endif
}
#ifdef GER61351
inline void AIS_InteractiveObject::Color(Quantity_Color& aColor) const
{
aColor = myOwnColor;
}
#endif
inline Standard_Boolean AIS_InteractiveObject::HasWidth() const
{return (!myOwnWidth == 0.);}
inline Standard_Real AIS_InteractiveObject::Width() const
{return myOwnWidth;}
inline Standard_Boolean AIS_InteractiveObject::HasMaterial() const
{return hasOwnMaterial;}
//POP pour K4L
inline Graphic3d_NameOfMaterial AIS_InteractiveObject::Material() const
//inline Graphic3d_NameOfPhysicalMaterial AIS_InteractiveObject::Material() const
{return myOwnMaterial;}
inline const Handle(AIS_Drawer)&
AIS_InteractiveObject::Attributes() const
{return myDrawer;}
inline Standard_Boolean AIS_InteractiveObject::HasHilightMode() const
{return myHilightMode!=-1;}
inline Standard_Integer AIS_InteractiveObject::HilightMode() const
{return myHilightMode;}
inline void AIS_InteractiveObject::SetHilightMode(const Standard_Integer aMode)
{myHilightMode = aMode;}
inline void AIS_InteractiveObject::UnsetHilightMode()
{myHilightMode = -1;}
inline Standard_Boolean AIS_InteractiveObject::IsTransparent() const
{return myTransparency >0.005;}
inline Standard_Boolean AIS_InteractiveObject::HasSelectionPriority() const
{return mySelPriority != -1;}
inline void AIS_InteractiveObject::SetSelectionPriority(const Standard_Integer P)
{mySelPriority = P;}
inline void AIS_InteractiveObject::UnsetSelectionPriority()
{mySelPriority = -1;}
inline Standard_Integer AIS_InteractiveObject::SelectionPriority() const
{return mySelPriority;}
inline Standard_Integer AIS_InteractiveObject::State() const
{return mystate;}
inline void AIS_InteractiveObject::State(const Standard_Integer TheState)
{mystate = TheState;}

267
src/AIS/AIS_LengthDimension.cdl Executable file
View File

@@ -0,0 +1,267 @@
-- File: AIS_LengthDimension.cdl
-- Created: Tue Dec 3 13:43:59 1996
-- Author: Arnaud BOUZY/Odile Olivier
-- <odl@sacadox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class LengthDimension from AIS inherits Relation from AIS
---Purpose: A framework to display lengths.
-- These can be lengths along a face or edge, or
-- between two faces or two edges.
-- The value of the length is given in a text figuring in this display.
uses Shape from TopoDS,
Face from TopoDS,
Presentation from Prs3d,
PresentationManager3d from PrsMgr,
Selection from SelectMgr,
Dir from gp,
Pnt from gp,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
ExtendedString from TCollection,
Plane from Geom,
TypeOfDist from AIS,
ArrowSide from DsgPrs,
KindOfDimension from AIS,
Drawer from Prs3d,
Edge from TopoDS,
Box from Bnd,
Drawer from AIS,
Vertex from TopoDS
is
Create (aFirstFace : Face from TopoDS;
aSecondFace : Face from TopoDS;
aVal : Real from Standard; -- is defined while first compute, may be any Real
aText : ExtendedString from TCollection)
---Purpose: Constructs a length display object defined by the first
-- face aFShape, the second face aSShape, the dimension aVal, and the text aText.
returns mutable LengthDimension from AIS;
Create (aFirstFace : Face from TopoDS;
aSecondFace : Face from TopoDS;
aVal : Real from Standard; -- is defined while first compute, may be any Real
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
anArrowSize : Real from Standard = 0.0)
---Purpose: Constructs a length display object defined by the first
-- face aFShape, the second face aSShape, the
-- dimension aVal, the position aPosition, the arrow
-- aSymbolPrs with the size anArrowSize and the text aText.
returns mutable LengthDimension from AIS;
Create (Face : Face from TopoDS;
Edge : Edge from TopoDS;
Val : Real from Standard;
Text : ExtendedString from TCollection)
---Purpose: Constructs a length display object defined by the first
-- edge or vertex aFShape, the second edge or vertex
-- aSShape, the dimension aVal,and the plane aPlane.
returns mutable LengthDimension from AIS;
Create (aFShape : Shape from TopoDS;
aSShape : Shape from TopoDS;
aPlane : Plane from Geom;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
---Purpose: -- Constructs a length display object defined by the first
-- edge or vertex aFShape, the second edge or vertex
-- aSShape, the dimension aVal,and the plane aPlane.
returns mutable LengthDimension from AIS;
Create (aFShape : Shape from TopoDS;
aSShape : Shape from TopoDS;
aPlane : Plane from Geom;
aVal : Real from Standard;
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
aTypeDist : TypeOfDist from AIS;
anArrowSize : Real from Standard = 0.0)
---Purpose: Constructs a length display object defined by the first
-- edge or vertex aFShape, the second edge or vertex
-- aSShape, the dimension aVal, the position aPosition,
-- the type of distance aTypeDist, the type of arrow
-- aSymbolPrs with the size anArrowSize, and the plane aPlane.
returns mutable LengthDimension from AIS;
SetFirstShape( me: mutable; aFShape : Shape from TopoDS )
is redefined static;
SetSecondShape( me: mutable; aSShape : Shape from TopoDS )
is redefined static;
KindOfDimension(me)
returns KindOfDimension from AIS
is redefined;
---Purpose: Indicates that we are concerned with a length.
IsMovable(me) returns Boolean from Standard
is redefined;
---Purpose: Returns true if the length dimension is movable.
TypeOfDist (me)
---C++: inline
--- Purpose:
-- Returns the type of distance of the length primitive.
returns TypeOfDist from AIS
is static;
SetTypeOfDist(me: mutable;aTypeDist: TypeOfDist from AIS)
---C++: inline
--- Purpose:
-- Returns true if the length dimension is movable.
is static;
-- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager : PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aPresentation : mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
-- Computation private methods
ComputeOneFaceLength(me : mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeOneEdgeLength(me : mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeTwoFacesLength(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeEdgeFaceLength (me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeTwoEdgesLength (myclass;
aPresentation : mutable Presentation from Prs3d;
aDrawer : Drawer from AIS;
aText : ExtendedString from TCollection;
ArrowSize : Real from Standard;
FirstEdge : Edge from TopoDS;
SecondEdge : Edge from TopoDS;
Plane : Plane from Geom;
AutomaticPos : Boolean from Standard;
IsSetBndBox : Boolean from Standard;
BndBox : Box from Bnd;
ExtShape : out Integer from Standard;
Val : out Real from Standard;
DirAttach : out Dir from gp;
Position : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
SymbolPrs : out ArrowSide from DsgPrs );
ComputeOneEdgeOneVertexLength(myclass;
aPresentation : mutable Presentation from Prs3d;
aDrawer : Drawer from AIS;
aText : ExtendedString from TCollection;
ArrowSize : Real from Standard;
FirstShape : Shape from TopoDS;
SecondShape : Shape from TopoDS;
Plane : Plane from Geom;
AutomaticPos : Boolean from Standard;
IsSetBndBox : Boolean from Standard;
BndBox : Box from Bnd;
ExtShape : out Integer from Standard;
Val : out Real from Standard;
DirAttach : out Dir from gp;
Position : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
SymbolPrs : out ArrowSide from DsgPrs );
ComputeTwoVerticesLength(myclass;
aPresentation : mutable Presentation from Prs3d;
aDrawer : Drawer from AIS;
aText : ExtendedString from TCollection;
ArrowSize : Real from Standard;
FirstVertex : Vertex from TopoDS;
SecondVertex : Vertex from TopoDS;
Plane : Plane from Geom;
AutomaticPos : Boolean from Standard;
IsSetBndBox : Boolean from Standard;
BndBox : Box from Bnd;
TypeDist : TypeOfDist from AIS;
ExtShape : out Integer from Standard;
Val : out Real from Standard;
DirAttach : out Dir from gp;
Position : out Pnt from gp;
FirstAttach : out Pnt from gp;
SecondAttach : out Pnt from gp;
SymbolPrs : out ArrowSide from DsgPrs );
--
-- Computation Selection private methods
--
ComputeFaceSelection(me : mutable;
aSelection : mutable Selection from SelectMgr)
is private;
ComputeEdgeVertexSelection( me : mutable;
aSelection : mutable Selection from SelectMgr)
is private;
fields
myNbShape : Integer from Standard;
myFAttach : Pnt from gp;
mySAttach : Pnt from gp;
myDirAttach: Dir from gp;
myTypeDist : TypeOfDist from AIS;
end LengthDimension;

1246
src/AIS/AIS_LengthDimension.cxx Executable file

File diff suppressed because it is too large Load Diff

27
src/AIS/AIS_LengthDimension.lxx Executable file
View File

@@ -0,0 +1,27 @@
// File: AIS_LengthDimension.lxx
// Created: Fri Feb 28 10:16:02 1997
// Author: Jean-Pierre COMBE
// <jpr>
#include <AIS.hxx>
#include <TopoDS.hxx>
//=======================================================================
//function : TypeOfDist
//purpose :
//=======================================================================
inline AIS_TypeOfDist AIS_LengthDimension::TypeOfDist() const
{
return myTypeDist;
}
//=======================================================================
//function : SetTypeOfDist
//purpose :
//=======================================================================
inline void AIS_LengthDimension::SetTypeOfDist(const AIS_TypeOfDist aTypeDist)
{
myTypeDist = aTypeDist;
}

150
src/AIS/AIS_Line.cdl Executable file
View File

@@ -0,0 +1,150 @@
-- File: AIS_Line.cdl
-- Created: Tue Jan 21 11:45:01 1997
-- Author: Prestataire Christiane ARMAND
-- <car@chamalox.paris1.matra-dtv.fr>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
-- the restricted NameOfColor.
---Copyright: Matra Datavision 1997
class Line from AIS inherits InteractiveObject from AIS
---Purpose: Constructs line datums to be used in construction of
-- composite shapes.
uses
Line from Geom,
Point from Geom,
Presentation from Prs3d,
PresentationManager3d from PrsMgr,
NameOfColor from Quantity,
Color from Quantity,
Selection from SelectMgr,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Line from AIS,
KindOfInteractive from AIS
is
Create(aLine : Line from Geom)
returns mutable Line from AIS;
---Purpose: Initializes the line aLine.
Create(aStartPoint : Point from Geom;
aEndPoint : Point from Geom)
returns mutable Line from AIS;
---Purpose: Initializes a starting point aStartPoint
-- and a finishing point aEndPoint for the line.
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard = 0)
is redefined static private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)is private;
-- Methods from InteractiveObject
Signature(me) returns Integer from Standard is redefined;
---Purpose: Returns the signature 5.
---C++: inline
Type(me) returns KindOfInteractive from AIS is redefined;
---Purpose: Returns the type Datum.
---C++: inline
Line(me) returns any Line from Geom;
---C++: inline
---C++: return const &
---Purpose: Constructs an infinite line.
Points(me;PStart,PEnd: out Point from Geom);
---Purpose: Returns the starting point PStart and the end point
-- PEnd of the line set by SetPoints.
---C++: inline
SetLine(me:mutable;L : Line from Geom);
---C++: inline
---Purpose: instantiates an infinite line.
SetPoints(me:mutable;P1,P2:Point from Geom);
--- Purpose:
-- Sets the starting point P1 and ending point P2 of the
-- infinite line to create a finite line segment.
---C++: inline
SetColor(me :mutable; aColor : NameOfColor from Quantity)
is redefined static;
---Purpose: Provides a new color setting aColor for the line in the
-- drawing tool, or "Drawer".
SetColor(me :mutable; aColor : Color from Quantity)
is redefined static;
SetWidth(me:mutable; aValue:Real from Standard)
is redefined static;
---Purpose: Provides the new width setting aValue for the line in
-- the drawing tool, or "Drawer".
UnsetColor(me:mutable)
is redefined static;
---Purpose: Removes the color setting and returns the original color.
UnsetWidth(me:mutable)
is redefined static;
---Purpose: Removes the width setting and returns the original width.
ComputeInfiniteLine(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeSegmentLine(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeInfiniteLineSelection(me: mutable;
aSelection : mutable Selection from SelectMgr)
is private;
ComputeSegmentLineSelection(me: mutable;
aSelection : mutable Selection from SelectMgr)
is private;
fields
myComponent : Line from Geom;
myStartPoint : Point from Geom;
myEndPoint : Point from Geom;
myLineIsSegment : Boolean from Standard;
end Line;

334
src/AIS/AIS_Line.cxx Executable file
View File

@@ -0,0 +1,334 @@
// File: AIS_Line.cxx
// Created: Tue Jan 21 11:45:01 1997
// Author: Prestataire Christiane ARMAND
// <car@chamalox.paris1.matra-dtv.fr>
// Copyright: Matra Datavision 1997
#define GER61351 //GG_171199 Enable to set an object RGB color
// instead a restricted object NameOfColor.
#include <AIS_Line.ixx>
#include <Aspect_TypeOfLine.hxx>
#include <Prs3d_Drawer.hxx>
#include <Precision.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_Structure.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <StdPrs_Curve.hxx>
#include <Geom_Line.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <AIS_Drawer.hxx>
#include <GC_MakeSegment.hxx>
#include <Handle_Geom_Line.hxx>
#include <Quantity_Color.hxx>
#include <AIS_GraphicTool.hxx>
#include <UnitsAPI.hxx>
//==================================================================
// function: FindLimits
// purpose:
//==================================================================
//unused
/*#ifdef DEB
static void FindLimits(const Adaptor3d_Curve& aCurve,
const Standard_Real aLimit,
gp_Pnt& P1,
gp_Pnt& P2)
{
Standard_Real First = aCurve.FirstParameter();
Standard_Real Last = aCurve.LastParameter();
Standard_Boolean firstInf = Precision::IsNegativeInfinite(First);
Standard_Boolean lastInf = Precision::IsPositiveInfinite(Last);
if (firstInf || lastInf) {
Standard_Real delta = 1;
if (firstInf && lastInf) {
do {
delta *= 2;
First = - delta;
Last = delta;
aCurve.D0(First,P1);
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
else if (firstInf) {
aCurve.D0(Last,P2);
do {
delta *= 2;
First = Last - delta;
aCurve.D0(First,P1);
} while (P1.Distance(P2) < aLimit);
}
else if (lastInf) {
aCurve.D0(First,P1);
do {
delta *= 2;
Last = First + delta;
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
}
}
#endif
*/
//=======================================================================
//function : AIS_Line
//purpose :
//=======================================================================
AIS_Line::AIS_Line(const Handle(Geom_Line)& aComponent):
myComponent (aComponent),
myLineIsSegment(Standard_False)
{
SetInfiniteState();
}
//=======================================================================
//function : AIS_Line
//purpose :
//=======================================================================
AIS_Line::AIS_Line(const Handle(Geom_Point)& aStartPoint,
const Handle(Geom_Point)& aEndPoint):
myStartPoint(aStartPoint),
myEndPoint(aEndPoint),
myLineIsSegment(Standard_True)
{}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Line::Compute(const Handle(PrsMgr_PresentationManager3d)&,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer)
{
aPresentation->Clear();
aPresentation->SetDisplayPriority(5);
if (!myLineIsSegment) ComputeInfiniteLine(aPresentation);
else ComputeSegmentLine(aPresentation);
}
void AIS_Line::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_Line::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Line::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer)
{
if (!myLineIsSegment) ComputeInfiniteLineSelection(aSelection);
else ComputeSegmentLineSelection(aSelection);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Line::SetColor(const Quantity_NameOfColor aCol)
#ifdef GER61351
{
SetColor(Quantity_Color(aCol));
}
void AIS_Line::SetColor(const Quantity_Color &aCol)
#endif
{
hasOwnColor=Standard_True;
myOwnColor=aCol;
Standard_Real WW = HasWidth()? myOwnWidth:
AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
if (!myDrawer->HasLineAspect ())
myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
else
myDrawer->LineAspect()->SetColor(aCol);
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Line::UnsetColor()
{
hasOwnColor = Standard_False;
Handle(Prs3d_LineAspect) NullAsp;
if (!HasWidth()) myDrawer->SetLineAspect(NullAsp);
else{
#ifdef GER61351
Quantity_Color CC;
if( HasColor() ) CC = myOwnColor;
else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
#else
Quantity_NameOfColor CC =
AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line);
#endif
myDrawer->LineAspect()->SetColor(CC);
myOwnColor = CC;
}
}
//=======================================================================
//function : SetWidth
//purpose :
//=======================================================================
void AIS_Line::SetWidth(const Standard_Real aValue)
{
myOwnWidth=aValue;
#ifndef GER61351
Quantity_NameOfColor CC =
HasColor()? myOwnColor : AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line);
#endif
if (!myDrawer->HasLineAspect ()) {
#ifdef GER61351
Quantity_Color CC;
if( HasColor() ) CC = myOwnColor;
else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
#endif
myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue));
} else
myDrawer->LineAspect()->SetWidth(aValue);
}
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
void AIS_Line::UnsetWidth()
{
Handle(Prs3d_LineAspect) NullAsp;
if (!HasColor()) myDrawer->SetLineAspect(NullAsp);
else{
Standard_Real WW = AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
myDrawer->LineAspect()->SetWidth(WW);
myOwnWidth = WW;
}
}
//=======================================================================
//function : ComputeInfiniteLine
//purpose :
//=======================================================================
void AIS_Line::ComputeInfiniteLine( const Handle(Prs3d_Presentation)& aPresentation)
{
GeomAdaptor_Curve curv(myComponent);
Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable();
StdPrs_Curve::Add(aPresentation,curv,myDrawer);
if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable();
//pas de prise en compte lors du FITALL
aPresentation->SetInfiniteState (Standard_True);
}
//=======================================================================
//function : ComputeSegmentLine
//purpose :
//=======================================================================
void AIS_Line::ComputeSegmentLine( const Handle(Prs3d_Presentation)& aPresentation)
{
gp_Pnt P1 = myStartPoint->Pnt();
gp_Pnt P2 = myEndPoint->Pnt();
myComponent = new Geom_Line(P1,gp_Dir(P2.XYZ()-P1.XYZ()));
Standard_Real dist = P1.Distance(P2);
GeomAdaptor_Curve curv(myComponent,0.,dist);
Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable();
StdPrs_Curve::Add(aPresentation,curv,myDrawer);
if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable();
}
//=======================================================================
//function : ComputeInfiniteLineSelection
//purpose :
//=======================================================================
void AIS_Line::ComputeInfiniteLineSelection(const Handle(SelectMgr_Selection)& aSelection)
{
/* // on calcule les points min max a partir desquels on cree un segment sensible...
GeomAdaptor_Curve curv(myComponent);
gp_Pnt P1,P2;
FindLimits(curv,myDrawer->MaximalParameterValue(),P1,P2);
*/
const gp_Dir& thedir = myComponent->Position().Direction();
const gp_Pnt& loc = myComponent->Position().Location();
const gp_XYZ& dir_xyz = thedir.XYZ();
const gp_XYZ& loc_xyz = loc.XYZ();
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
Standard_Real aLength = UnitsAPI::AnyToLS (250000. ,"mm");
gp_Pnt P1 = loc_xyz + aLength*dir_xyz;
gp_Pnt P2 = loc_xyz - aLength*dir_xyz;
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,5);
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown,P1,P2);
aSelection->Add(seg);
}
//=======================================================================
//function : ComputeSegmentLineSelection
//purpose :
//=======================================================================
void AIS_Line::ComputeSegmentLineSelection(const Handle(SelectMgr_Selection)& aSelection)
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,5);
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown,
myStartPoint->Pnt(),
myEndPoint->Pnt());
aSelection->Add(seg);
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Line::Compute(const Handle(PrsMgr_PresentationManager2d)&,
const Handle(Graphic2d_GraphicObject)&,
const Standard_Integer)
{
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Line::Compute(const Handle(Prs3d_Projector)&,
const Handle(Prs3d_Presentation)&)
{
}

25
src/AIS/AIS_Line.lxx Executable file
View File

@@ -0,0 +1,25 @@
// File: AIS_Line.lxx
// Created: Thu Mar 6 14:26:11 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
inline AIS_KindOfInteractive AIS_Line::Type() const
{return AIS_KOI_Datum;}
inline Standard_Integer AIS_Line::Signature() const
{return 5;}
inline const Handle(Geom_Line)& AIS_Line::Line() const
{return myComponent;}
inline void AIS_Line::Points( Handle(Geom_Point)& PStart,
Handle(Geom_Point)& PEnd) const
{ PStart = myStartPoint; PEnd = myEndPoint;}
inline void AIS_Line::SetLine(const Handle(Geom_Line)& L)
{myComponent =L;myLineIsSegment=Standard_False;}
inline void AIS_Line::SetPoints(const Handle(Geom_Point)& PStart,
const Handle(Geom_Point)& PEnd)
{
myStartPoint=PStart;
myEndPoint = PEnd;
myLineIsSegment=Standard_True;
}

593
src/AIS/AIS_LocalContext.cdl Executable file
View File

@@ -0,0 +1,593 @@
-- File: AIS_LocalContext.cdl
-- Created: Wed Sep 4 16:13:24 1996
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
--
-- Modified May 20th 98 :
-- Modification in Management of selected entities
-- Now we store the selected entity Owner in AIS_Selection.
-- (no more links with Session...)
-- Modifications in Management of hilight of detected entities
-- VTN 23/11/99 BUC60614 Avoid to crash because
-- myStdFilters array is too short.
-- GG : BUC60688 25/05/00 Add SetSensitivity() methods
-- GG : IMP150501 Remove oboslete method DragTo
-- (See AIS_InteractiveContext)
-- ZSV : IMP160701 Add InitDetected(),MoreDetected(),NextDetected(),
-- DetectedCurrentShape(),DetectedCurrentObject()
-- methods
--
---Copyright: Matra Datavision 1996
private class LocalContext from AIS inherits TShared from MMgt
---Purpose: Defines a specific context for selection.
-- It becomes possible to:
-- + Load InteractiveObjects with a mode to be
-- activated + associate InteractiveObjects with a
-- set of temporary selectable Objects.... + +
-- activate StandardMode of selection for Entities
-- inheriting BasicShape from AIS (Selection Of
-- vertices, edges, wires,faces... + Add Filters
-- acting on detected owners of sensitive primitives
--
--
-- - automatically highlight shapes and
-- InteractiveObjects (highlight of detected shape +
-- highlight of detected selectable...
--
uses
AsciiString from TCollection,
ListOfInteger from TColStd,
SequenceOfInteger from TColStd,
MapOfTransient from TColStd,
Array1OfPnt2d from TColgp,
NameOfColor from Quantity,
ShapeEnum from TopAbs,
Shape from TopoDS,
View from V3d,
PresentationManager3d from PrsMgr,
Projector from Select3D,
IndexedMapOfOwner from SelectMgr,
EntityOwner from SelectMgr,
OrFilter from SelectMgr,
Filter from SelectMgr,
SelectionManager from SelectMgr,
SelectableObject from SelectMgr ,
ListOfFilter from SelectMgr,
BRepOwner from StdSelect,
ViewerSelector3d from StdSelect,
InteractiveContext from AIS,
ClearMode from AIS,
InteractiveObject from AIS,
Shape from AIS,
DataMapOfSelStat from AIS,
LocalStatus from AIS,
StatusOfPick from AIS,
StatusOfDetection from AIS,
SequenceOfInteractive from AIS
is
Create returns mutable LocalContext from AIS;
Create (aCtx : InteractiveContext from AIS;
anIndex : Integer from Standard;
LoadDisplayed : Boolean from Standard=Standard_True;
AcceptStandardModes : Boolean from Standard=Standard_True;
AcceptErase : Boolean from Standard= Standard_False;
UseBothViewers : Boolean from Standard= Standard_False)
returns mutable LocalContext from AIS;
---Purpose: Constructor By Default, the displayed objects are
-- automatically loaded.
AcceptErase(me:mutable;aStatus : Boolean from Standard);
---C++: inline
---Purpose: authorize or not others contexts to erase
-- temporary displayed objects here;
AcceptErase(me) returns Boolean from Standard;
---C++: inline
SetContext(me:mutable;aCtx:InteractiveContext from AIS);
SelectionName(me) returns AsciiString from TCollection;
---C++: inline
---C++: return const&
Terminate(me: mutable; updateviewer : Boolean from Standard = Standard_True);
HasSameProjector(me;aPrj:Projector from Select3D)
returns Boolean from Standard;
---Purpose: compares the current projector of the localContext
-- with <aPrj>
-- returns True if the projectors are identical.
-- (no need to update projection of selection primitives
-- when closing the local context)....
Reactivate(me:mutable);
---Purpose: to be called when a upper local context was closed...
-- useful to put pack the right projector...
---Category: LOAD AND PREPARE
-- - INTERACTIVE OBJECTS...
-- - FILTERS
-- - STANDARD MODES OF ACTIVATION
Display(me : mutable;
anInteractive : InteractiveObject from AIS;
DisplayMode : Integer from Standard = 0;
AllowShapeDecomposition: Boolean from Standard = Standard_True;
ActivationMode : Integer from Standard = 0)
returns Boolean from Standard;
---Purpose: returns true if done...
Load(me : mutable;
anInteractive : InteractiveObject from AIS;
AllowShapeDecomposition: Boolean from Standard = Standard_True;
ActivationMode : Integer from Standard = 0)
returns Boolean from Standard;
---Purpose: loads <anInteractive> with nodisplay...
-- returns true if done
Erase(me: mutable;
anInteractive : InteractiveObject from AIS)
returns Boolean from Standard;
---Purpose: returns true if done...
Remove(me : mutable;
aSelectable : InteractiveObject from AIS)
returns Boolean from Standard;
ClearPrs (me : mutable;
anInteractive : InteractiveObject from AIS;
aMode : Integer from Standard)
returns Boolean from Standard;
SetShapeDecomposition(me : mutable;
aStoredObject : InteractiveObject from AIS;
aStatus : Boolean from Standard);
---Purpose: allows or forbids the shape decomposition into
-- Activated Standard Mode for <aStoredObject>
-- does nothing if the object doesn't inherits
-- BasicShape from AIS
Clear(me:mutable;atype: ClearMode from AIS = AIS_CM_All);
---Purpose: according to <atype> , clears the different parts of
-- the selector (filters, modeof activation, objects...)
ActivateMode (me : mutable;
aSelectable: InteractiveObject from AIS;
aMode : Integer from Standard );
---Purpose: optional : activation of a mode which is not 0 for a selectable...
DeactivateMode(me : mutable;
aSelectable: InteractiveObject from AIS;
aMode : Integer from Standard );
Deactivate(me : mutable;
aSelectable: InteractiveObject from AIS);
ActivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
---Purpose: decomposition of shapes into <aType>
DeactivateStandardMode(me:mutable;aType:ShapeEnum from TopAbs);
StandardModes(me) returns ListOfInteger from TColStd;
---C++: return const &
---C++: inline
AddFilter(me:mutable;aFilter:Filter from SelectMgr);
RemoveFilter(me:mutable;aFilter: Filter from SelectMgr);
ListOfFilter(me) returns ListOfFilter from SelectMgr;
---C++: return const &
---C++: inline
Filter(me) returns any OrFilter from SelectMgr;
---C++: return const &
---C++: inline
SetAutomaticHilight(me:mutable ; aStatus:Boolean) ;
---Purpose: if <aStatus> = True , the shapes or subshapes detected
-- by the selector will be automatically hilighted in the
-- main viewer.
-- Else the user has to manage the detected shape outside the
-- Shape Selector....
---C++: inline
AutomaticHilight(me) returns Boolean;
---C++: inline
---Category: THE SELECTION PROCESS
MoveTo(me:mutable;Xpix,Ypix : Integer from Standard;
aview : View from V3d)
returns StatusOfDetection from AIS;
HasNextDetected(me) returns Boolean from Standard;
---C++: inline
---Purpose: returns True if more than one entity
-- was detected at the last Mouse position.
HilightNextDetected(me:mutable;aView:View from V3d)
returns Integer from Standard;
---Purpose: returns True if last detected. the next detected will
-- be first one (endless loop)
HilightPreviousDetected(me:mutable;aView:View from V3d)
returns Integer from Standard;
UnhilightLastDetected(me:mutable;aView:View from V3d) returns Boolean from Standard;
---Purpose: returns True if something was done...
Select(me: mutable;updateviewer : Boolean from Standard = Standard_True)
returns StatusOfPick from AIS;
---Purpose: returns the number of selected
ShiftSelect(me: mutable;updateviewer : Boolean from Standard = Standard_True)
returns StatusOfPick from AIS;
Select(me : mutable;
XPMin,YPMin,XPMax,YPMax : Integer from Standard;
aView : View from V3d;
updateviewer : Boolean from Standard = Standard_True)
returns StatusOfPick from AIS;
ShiftSelect(me : mutable;
XPMin,YPMin,XPMax,YPMax : Integer from Standard;
aView : View from V3d;
updateviewer : Boolean from Standard = Standard_True)
returns StatusOfPick from AIS;
Select(me : mutable;
Polyline : Array1OfPnt2d from TColgp;
aView : View from V3d;
updateviewer : Boolean from Standard = Standard_True)
returns StatusOfPick from AIS;
ShiftSelect(me : mutable;
Polyline : Array1OfPnt2d from TColgp;
aView : View from V3d;
updateviewer : Boolean from Standard = Standard_True)
returns StatusOfPick from AIS;
HilightPicked(me:mutable;updateviewer:Boolean from Standard =Standard_True) ;
UnhilightPicked(me:mutable;updateviewer:Boolean from Standard = Standard_True) ;
UpdateSelected (me : mutable;
updateviewer : Boolean from Standard = Standard_True);
UpdateSelected (me : mutable;
anobj : InteractiveObject from AIS;
updateviewer : Boolean from Standard = Standard_True);
---Purpose: Part of advanced selection highlighting mechanism.
-- If no owners belonging to anobj are selected, calls anobj->ClearSelected(),
-- otherwise calls anobj->HilightSelected(). This method can be used to avoid
-- redrawing the whole selection belonging to several Selectable Objects.
SetSelected(me : mutable;
anobj : InteractiveObject from AIS;
updateviewer : Boolean from Standard=Standard_True);
---Purpose: useful to update selection with objects coming from
-- Collector or stack
AddOrRemoveSelected(me : mutable;
anobj : InteractiveObject from AIS;
updateviewer : Boolean from Standard=Standard_True);
---Purpose: useful to update selection with objects coming from
-- Collector or stack
AddOrRemoveSelected(me : mutable;
aShape : Shape from TopoDS;
updateviewer : Boolean from Standard=Standard_True);
AddOrRemoveSelected(me : mutable;
Ownr : EntityOwner from SelectMgr;
updateviewer : Boolean from Standard=Standard_True);
ClearSelected(me:mutable;updateviewer : Boolean from Standard=Standard_True);
---Purpose:
---Category: GET THE DETECTED
HasDetected (me) returns Boolean from Standard;
---C++: inline
InitDetected(me: mutable);
MoreDetected(me) returns Boolean from Standard;
NextDetected(me: mutable);
DetectedCurrentShape(me) returns Shape from TopoDS;
---C++: return const &
DetectedCurrentObject(me) returns InteractiveObject from AIS;
HasDetectedShape(me) returns Boolean from Standard;
DetectedShape (me) returns Shape from TopoDS;
---C++: return const &
DetectedInteractive(me) returns InteractiveObject from AIS;
DetectedOwner (me) returns EntityOwner from SelectMgr;
---Category: GET THE SELECTED
InitSelected (me: mutable);
MoreSelected(me) returns Boolean from Standard;
NextSelected(me:mutable);
HasShape(me) returns Boolean from Standard;
---Purpose: returns TRUE if the detected entity is a shape
-- coming from a Decomposition of an element.
SelectedShape(me) returns Shape from TopoDS;
---C++: return const &
SelectedOwner(me) returns EntityOwner from SelectMgr;
IsSelected(me;aniobj: InteractiveObject from AIS) returns Boolean from Standard;
IsSelected(me;anOwner: EntityOwner from SelectMgr) returns Boolean from Standard;
SelectedInteractive(me) returns InteractiveObject from AIS;
HasApplicative (me) returns Boolean from Standard;
---Purpose: returns TRUE if an interactive element
-- was associated with the current picked entity.
SelectedApplicative(me) returns any Transient from Standard;
---C++: return const &
---Category: Management Of Temporary Attributes
SetDisplayPriority(me : mutable;
anObject: InteractiveObject from AIS;
Prior : Integer from Standard);
DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
returns Integer from Standard;
IsIn(me;anObject : InteractiveObject from AIS)
returns Boolean from Standard;
IsDisplayed(me;anObject : InteractiveObject from AIS)
returns Boolean from Standard;
IsDisplayed(me;anObject : InteractiveObject from AIS;
aMode : Integer from Standard)
returns Boolean from Standard;
SelectionModes(me;anObject:InteractiveObject from AIS)
returns ListOfInteger from TColStd;
---C++: return const &
SubIntensityOn(me:mutable; anObject : InteractiveObject from AIS );
SubIntensityOff(me:mutable; anObject : InteractiveObject from AIS );
Hilight(me: mutable; anObject : InteractiveObject from AIS);
Hilight(me:mutable; anObject : InteractiveObject from AIS;aCol:NameOfColor from Quantity);
Unhilight(me:mutable; anObject : InteractiveObject from AIS);
IsHilighted(me;anObject : InteractiveObject from AIS)
returns Boolean from Standard;
IsHilighted(me;
anObject : InteractiveObject from AIS;
WithColor : out Boolean from Standard;
HiCol : out NameOfColor from Quantity)
returns Boolean from Standard;
SetSensitivity(me:mutable;
aPrecision: Real from Standard);
---Level: Public
---Purpose: Define the current selection sensitivity for
-- this local context according to the view size.
SetSensitivity(me:mutable;
aPrecision: Integer from Standard = 2);
---Level: Public
---Purpose: Define the current selection sensitivity for
-- this local context according to the view size.
---Category: IMMEDIATE MODE
BeginImmediateDraw (me:mutable) returns Boolean from Standard;
---Purpose: initializes the list of presentations to be displayed
-- returns False if No Local COnte
ImmediateAdd (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0)
returns Boolean from Standard;
---Purpose: returns True if <anIObj> has been stored in the list.
ImmediateRemove (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0)
returns Boolean from Standard;
---Purpose: returns True if <anIObj> has been removed from the list.
EndImmediateDraw(me:mutable;aView : View from V3d;DoubleBuf:Boolean from Standard=Standard_False)
returns Boolean from Standard;
---Purpose: returns True if the immediate display has been done.
IsImmediateModeOn(me) returns Boolean from Standard;
---Category: INTERNAL METHODS;
UpdateConversion(me:mutable);
UpdateSort(me:mutable);
Status(me) returns AsciiString from TCollection is private;
Status(me;anObject : InteractiveObject from AIS)
returns any LocalStatus from AIS is private;
---C++: return const&
LoadContextObjects(me:mutable);
UnloadContextObjects(me:mutable);
Process(me : mutable;
anObject : SelectableObject from SelectMgr;
WithProj: Boolean from Standard = Standard_True) is static private;
Process(me:mutable;
WithProj: Boolean from Standard = Standard_True) is static private;
ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr;
WithProj: Boolean from Standard = Standard_True) is static private;
ManageDetected(me:mutable;
aPickOwner : EntityOwner from SelectMgr;
aview : View from V3d) is static private;
DetectedIndex(me:mutable) returns Integer from Standard is static private;
---C++: inline
---Purpose: returns 0 if the detected entity was Not FilterOK...
Hilight(me:mutable;Own:EntityOwner from SelectMgr;aview: View from V3d) is static private;
Unhilight(me:mutable;Ownr:EntityOwner from SelectMgr;aview: View from V3d) is static private;
ClearObjects(me:mutable) is static private;
ClearDetected(me:mutable) is static private;
IsDecompositionOn(me) returns Boolean from Standard is static private;
IsShape(me;anIndex:Integer from Standard) returns Boolean from Standard is static private;
IsValidForSelection(me;anIObj:InteractiveObject from AIS) returns Boolean from Standard is static private;
IsValidIndex(me;anIndex:Integer from Standard)
returns Boolean from Standard is static private;
---C++: inline
ComesFromDecomposition(me; aPickedIndex : Integer from Standard)
returns Boolean from Standard is static private;
DisplayAreas(me:mutable;aviou:View from V3d);
ClearAreas (me:mutable;
aView: View from V3d) is static;
---Level: Internal
HasFilters(me;aType:ShapeEnum from TopAbs)
returns Boolean from Standard is private;
DisplaySensitive(me:mutable;aView : View from V3d) is static;
ClearSensitive(me:mutable;aView:View from V3d) is static;
MainSelector(me) returns any ViewerSelector3d from StdSelect;
---C++: inline
---C++: return const&
HilightTriangle(me:mutable;Rank:Integer from Standard;aViou:View from V3d) is static private;
---Level: Internal
FindSelectedOwnerFromIO(me;anIObj:InteractiveObject from AIS)
returns EntityOwner from SelectMgr is private;
FindSelectedOwnerFromShape(me;aShape : Shape from TopoDS)
returns EntityOwner from SelectMgr is private;
fields
myCTX : InteractiveContext from AIS;
myLoadDisplayed,myAcceptStdMode : Boolean from Standard;
myAcceptErase : Boolean from Standard;
mySM : SelectionManager from SelectMgr;
myMainVS : ViewerSelector3d from StdSelect;
myMainPM : PresentationManager3d from PrsMgr;
mySelName : AsciiString from TCollection;
myCollVS : ViewerSelector3d from StdSelect;
-- The Objects and their attributes...
myActiveObjects : DataMapOfSelStat from AIS;
-- The Filters...
myFilters : OrFilter from SelectMgr;
myListOfStandardMode : ListOfInteger from TColStd;
-- VTN myStdFilters : Filter from SelectMgr [7]; --internal mgt
myStdFilters : Filter from SelectMgr [9]; --internal mgt
-- Selection Process
myAutoHilight : Boolean from Standard;
myMapOfOwner : IndexedMapOfOwner from SelectMgr;
mylastindex : Integer from Standard;
mylastgood : Integer from Standard;
myCurrentOwner : Integer from Standard;
myDetectedSeq : SequenceOfInteger from TColStd;
myCurDetected : Integer from Standard;
-- the detected objects.
myAISDetectedSeq : SequenceOfInteractive from AIS;
myAISCurDetected : Integer from Standard;
-- This variables is used by following functions:
-- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject().
friends
KeepTemporary from InteractiveContext from AIS(me:mutable;anIObj:InteractiveObject from AIS;WhichMode : Integer from Standard = -1)
end LocalContext;

1221
src/AIS/AIS_LocalContext.cxx Executable file

File diff suppressed because it is too large Load Diff

53
src/AIS/AIS_LocalContext.lxx Executable file
View File

@@ -0,0 +1,53 @@
// File: AIS_LocalContext.lxx
// Created: Fri Jan 17 13:34:31 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
#include <SelectMgr_AndFilter.hxx>
#include <SelectMgr_OrFilter.hxx>
inline const TCollection_AsciiString& AIS_LocalContext::
SelectionName() const
{return mySelName;}
inline void AIS_LocalContext::SetAutomaticHilight(const Standard_Boolean aStatus)
{myAutoHilight = aStatus;}
inline Standard_Boolean AIS_LocalContext::AutomaticHilight() const
{return myAutoHilight;}
inline const TColStd_ListOfInteger&
AIS_LocalContext::StandardModes() const
{return myListOfStandardMode;}
inline const SelectMgr_ListOfFilter& AIS_LocalContext::ListOfFilter() const
{return myFilters->StoredFilters();}
inline const Handle(SelectMgr_OrFilter)& AIS_LocalContext::Filter() const
{return myFilters;}
inline void AIS_LocalContext::AcceptErase(const Standard_Boolean aStatus)
{myAcceptErase = aStatus;}
inline Standard_Boolean AIS_LocalContext::AcceptErase() const
{return myAcceptErase;}
inline const Handle(StdSelect_ViewerSelector3d)&
AIS_LocalContext::MainSelector() const
{return myMainVS;}
inline Standard_Boolean AIS_LocalContext::HasDetected() const
{return mylastindex!=0;}
inline Standard_Integer AIS_LocalContext::DetectedIndex()
{
return mylastindex;
}
inline Standard_Boolean AIS_LocalContext::HasNextDetected() const
{return myCurDetected<myDetectedSeq.Length();}
inline Standard_Boolean AIS_LocalContext::IsValidIndex(const Standard_Integer indx) const
{ return (indx>0 && indx<=myMapOfOwner.Extent());}

1620
src/AIS/AIS_LocalContext_1.cxx Executable file

File diff suppressed because it is too large Load Diff

96
src/AIS/AIS_LocalStatus.cdl Executable file
View File

@@ -0,0 +1,96 @@
-- File: AIS_LocalStatus.cdl
-- Created: Mon Jan 20 15:35:55 1997
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
private class LocalStatus from AIS inherits TShared from MMgt
---Purpose: Stored Info about temporary objects.
uses
ListOfInteger from TColStd,
NameOfColor from Quantity
is
Create(IsTemporary : Boolean from Standard = Standard_True;
Decompose : Boolean from Standard = Standard_False;
DisplayMode : Integer from Standard = -1;
SelectionMode : Integer from Standard = -1;
HilightMode : Integer from Standard = 0;
SubIntensity : Boolean from Standard = 0;
TheHiCol : NameOfColor from Quantity = Quantity_NOC_WHITE)
returns mutable LocalStatus from AIS;
---Category: Read
Decomposed(me) returns Boolean from Standard;
---C++: inline
IsTemporary(me) returns Boolean from Standard;
---C++: inline
DisplayMode(me) returns Integer from Standard;
---C++: inline
SelectionModes(me) returns ListOfInteger from TColStd;
---C++: return const&
---C++: inline
IsActivated(me; aSelMode :Integer from Standard)
returns Boolean from Standard;
HilightMode(me) returns Integer from Standard;
---C++: inline
IsSubIntensityOn(me) returns Boolean from Standard;
---C++: inline
HilightColor(me) returns NameOfColor from Quantity;
---C++: inline
SetDecomposition (me:mutable; astatus : Boolean from Standard);
---C++: inline
SetTemporary (me:mutable; astatus : Boolean from Standard);
---C++: inline
SetDisplayMode (me:mutable; aMode : Integer from Standard);
---C++: inline
SetFirstDisplay (me:mutable; aStatus : Boolean from Standard) ;
---C++: inline
IsFirstDisplay(me) returns Boolean from Standard;
---C++: inline
AddSelectionMode (me:mutable; aMode : Integer from Standard);
RemoveSelectionMode(me:mutable; aMode : Integer from Standard);
ClearSelectionModes(me:mutable);
IsSelModeIn(me;aMode:Integer from Standard)
returns Boolean from Standard;
SetHilightMode (me:mutable; aMode : Integer from Standard);
---C++: inline
SetHilightColor (me:mutable;aHiCol:NameOfColor from Quantity);
---C++: inline
SubIntensityOn (me:mutable);
---C++: inline
SubIntensityOff (me:mutable);
---C++: inline
SetPreviousState(me:mutable;aStatus : Transient from Standard);
---C++: inline
PreviousState(me) returns any Transient from Standard;
---C++: inline
---C++: return const &
fields
myDecomposition : Boolean from Standard;
myIsTemporary : Boolean from Standard;
myDMode : Integer from Standard;
myFirstDisplay : Boolean from Standard;
myHMode : Integer from Standard;
mySModes : ListOfInteger from TColStd;
mySubIntensity : Boolean from Standard;
myHiCol : NameOfColor from Quantity;
myPreviousState : Transient from Standard;
end LocalStatus;

93
src/AIS/AIS_LocalStatus.cxx Executable file
View File

@@ -0,0 +1,93 @@
#include <AIS_LocalStatus.ixx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
AIS_LocalStatus::AIS_LocalStatus(const Standard_Boolean IsTemp,
const Standard_Boolean Decomp,
const Standard_Integer DMode,
const Standard_Integer SMode,
const Standard_Integer HMode,
const Standard_Boolean SubIntensity,
const Quantity_NameOfColor HiCol):
myDecomposition(Decomp),
myIsTemporary(IsTemp),
myDMode(DMode),
myFirstDisplay(Standard_False),
myHMode(HMode),
mySubIntensity(SubIntensity),
myHiCol(HiCol)
{
if(SMode!=-1) mySModes.Append(SMode);
}
//=======================================================================
//function : IsActivated
//purpose :
//=======================================================================
Standard_Boolean AIS_LocalStatus::
IsActivated(const Standard_Integer aSelMode) const
{
TColStd_ListIteratorOfListOfInteger It(mySModes);
for(;It.More();It.Next())
if(It.Value()==aSelMode)
return Standard_True;
return Standard_False;
}
//=======================================================================
//function : RemoveSelectionMode
//purpose :
//=======================================================================
void AIS_LocalStatus::RemoveSelectionMode(const Standard_Integer aMode)
{
TColStd_ListIteratorOfListOfInteger It(mySModes);
for(;It.More();It.Next())
{
if(It.Value()==aMode) {
mySModes.Remove(It);
return;
}
}
}
//=======================================================================
//function : ClearSelectionModes
//purpose :
//=======================================================================
void AIS_LocalStatus::ClearSelectionModes()
{mySModes.Clear();}
//=======================================================================
//function : AddSelectionMode
//purpose :
//=======================================================================
void AIS_LocalStatus::AddSelectionMode(const Standard_Integer aMode)
{
if(IsSelModeIn(aMode)) return;
if(aMode!=-1)
mySModes.Append(aMode);
else
mySModes.Clear();
}
//=======================================================================
//function : IsSelModeIn
//purpose :
//=======================================================================
Standard_Boolean AIS_LocalStatus::IsSelModeIn(const Standard_Integer aMode) const
{
for(TColStd_ListIteratorOfListOfInteger It(mySModes);
It.More();
It.Next()){
if(It.Value()==aMode)
return Standard_True;
}
return Standard_False;
}

57
src/AIS/AIS_LocalStatus.lxx Executable file
View File

@@ -0,0 +1,57 @@
inline Standard_Boolean AIS_LocalStatus::Decomposed() const
{return myDecomposition;}
inline Standard_Boolean AIS_LocalStatus::IsTemporary() const
{return myIsTemporary;}
inline Standard_Integer AIS_LocalStatus::DisplayMode() const
{return myDMode;}
inline const TColStd_ListOfInteger& AIS_LocalStatus::
SelectionModes() const
{return mySModes;}
inline Standard_Boolean AIS_LocalStatus::IsSubIntensityOn() const
{return mySubIntensity;}
inline void AIS_LocalStatus::SetDecomposition(const Standard_Boolean astatus)
{myDecomposition=astatus;}
inline void AIS_LocalStatus::SetTemporary(const Standard_Boolean astatus)
{myIsTemporary = astatus;}
inline void AIS_LocalStatus::SubIntensityOn()
{mySubIntensity = Standard_True;}
inline void AIS_LocalStatus::SubIntensityOff()
{mySubIntensity = Standard_False;}
inline void AIS_LocalStatus::
SetDisplayMode(const Standard_Integer aMode)
{myDMode = aMode;}
inline void AIS_LocalStatus::SetHilightMode(const Standard_Integer aMode)
{myHMode=aMode;}
inline Standard_Integer AIS_LocalStatus::HilightMode() const
{return myHMode;}
inline void AIS_LocalStatus::SetPreviousState(const Handle(Standard_Transient)& stat)
{ myPreviousState = stat;}
inline const Handle(Standard_Transient)&
AIS_LocalStatus::PreviousState() const
{return myPreviousState;}
inline void AIS_LocalStatus::SetFirstDisplay(const Standard_Boolean aStat)
{myFirstDisplay = aStat;}
inline Standard_Boolean AIS_LocalStatus::IsFirstDisplay() const
{return myFirstDisplay;}
inline void AIS_LocalStatus::SetHilightColor(const Quantity_NameOfColor aCol)
{myHiCol = aCol;}
inline Quantity_NameOfColor AIS_LocalStatus::HilightColor() const
{return myHiCol;}

View File

@@ -0,0 +1,119 @@
-- File: AIS_MaxRadiusDimension.cdl
-- Created: Thu Jan 22 08:58:19 1998
-- Author: Sergey ZARITCHNY
-- <szy@androx.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class MaxRadiusDimension from AIS inherits EllipseRadiusDimension from AIS
---Purpose:
-- Ellipse Max radius dimension of a Shape which can be Edge
-- or Face (planar or cylindrical(surface of extrusion or
-- surface of offset))
uses
Shape from TopoDS,
Elips from gp,
Pnt from gp,
Pln from gp,
Ellipse from Geom,
OffsetCurve from Geom,
Plane from Geom,
Surface from Geom,
Presentation from Prs3d,
PresentationManager3d from PrsMgr,
Selection from SelectMgr,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
ExtendedString from TCollection,
ArrowSide from DsgPrs,
KindOfSurface from AIS,
KindOfDimension from AIS
raises ConstructionError from Standard
is
Create (aShape : Shape from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
---Purpose: Max Ellipse radius dimension
-- Shape can be edge , planar face or cylindrical face
--
returns mutable MaxRadiusDimension from AIS;
Create (aShape : Shape from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
anArrowSize : Real from Standard = 0.0)
---Purpose: Max Ellipse radius dimension with position
-- Shape can be edge , planar face or cylindrical face
--
returns mutable MaxRadiusDimension from AIS;
-- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
--
-- Computation private methods
--
ComputeEllipse(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeArcOfEllipse(me: mutable;
aPresentation : mutable Presentation from Prs3d )
is private;
fields
myApexP : Pnt from gp;
myApexN : Pnt from gp;
myEndOfArrow : Pnt from gp;
end MaxRadiusDimension;

View File

@@ -0,0 +1,370 @@
// File: AIS_MaxRadiusDimension.cxx
// Created: Fri Jan 23 12:46:52 1998
// Author: Sergey ZARITCHNY
// <szy@androx.nnov.matra-dtv.fr>
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
// if any in all dimensions.
#include <Standard_NotImplemented.hxx>
#include <AIS_MaxRadiusDimension.ixx>
#include <AIS_EllipseRadiusDimension.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Prs3d_LengthAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_Text.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <TopoDS.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
#include <Precision.hxx>
#include <DsgPrs_EllipseRadiusPresentation.hxx>
//=======================================================================
//function : AIS_MaxRadiusDimension
//purpose :
//=======================================================================
AIS_MaxRadiusDimension::AIS_MaxRadiusDimension(const TopoDS_Shape& aShape,
const Standard_Real aVal,
const TCollection_ExtendedString& aText)
:AIS_EllipseRadiusDimension(aShape, aText)
{
myVal = aVal;
mySymbolPrs = DsgPrs_AS_LASTAR;
myAutomaticPosition = Standard_True;
myArrowSize = myVal / 100.;
}
//=======================================================================
//function : AIS_MaxRadiusDimension
//purpose :
//=======================================================================
AIS_MaxRadiusDimension::AIS_MaxRadiusDimension(const TopoDS_Shape& aShape,
const Standard_Real aVal,
const TCollection_ExtendedString& aText,
const gp_Pnt& aPosition,
const DsgPrs_ArrowSide aSymbolPrs,
const Standard_Real anArrowSize)
:AIS_EllipseRadiusDimension(aShape, aText)
{
myVal = aVal;
mySymbolPrs = aSymbolPrs;
myPosition = aPosition;
myAutomaticPosition = Standard_False;
#ifdef BUC60915
SetArrowSize( anArrowSize );
#else
myArrowSize = anArrowSize;
#endif
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MaxRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer /*aMode*/)
{
aPresentation->Clear();
// if( myAutomaticPosition )
{//ota : recompute in any case
ComputeGeometry();
myEllipse.SetMajorRadius(myVal);
gp_Vec v1(myEllipse.XAxis().Direction());
v1 *=myVal;
myApexP = myEllipse.Location().Translated(v1);
myApexN = myEllipse.Location().Translated(-v1);
}
if(myIsAnArc) ComputeArcOfEllipse(aPresentation);
else
ComputeEllipse(aPresentation);
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_MaxRadiusDimension::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_MaxRadiusDimension::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation)");
PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_MaxRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager,
const Handle(Graphic2d_GraphicObject)& aPresentation,
const Standard_Integer aMode)
{
// Standard_NotImplemented::Raise("AIS_MaxRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, const Handle(Graphic2d_GraphicObject)& aPresentation, const Standard_Integer aMode)");
PrsMgr_PresentableObject::Compute( aPresentationManager ,aPresentation,aMode) ;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MaxRadiusDimension::Compute(const Handle_Prs3d_Projector& aProjector,
const Handle_Geom_Transformation& aTransformation,
const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_MaxRadiusDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeEllipse
//purpose :
//=======================================================================
void AIS_MaxRadiusDimension::ComputeEllipse(const Handle(Prs3d_Presentation)& aPresentation)
{
Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
// size
#ifdef BUC60915
if( !myArrowSizeIsDefined ) {
myArrowSize = Min(myArrowSize,myVal / 5.);
}
arr->SetLength(myArrowSize);
#else
if (myVal / 5. > myArrowSize) {
arr->SetLength(myArrowSize);
}
else {
arr->SetLength(myVal / 5.);
}
#endif
Standard_Real U;//,V;
gp_Pnt curPos, Center;
Center = myEllipse.Location();
if( myAutomaticPosition )
{
myPosition = Center;
myEndOfArrow = myApexP;
myAutomaticPosition = Standard_True;
if ( myIsSetBndBox )
myPosition = AIS::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
myBndBox );
curPos = myPosition;
}
else //!AutomaticPosition
{
curPos = myPosition;
gp_Lin L1(myEllipse.XAxis());
U = ElCLib::Parameter ( L1, curPos );
curPos = ElCLib::Value (U, L1);
if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
myEndOfArrow = myApexP ;
else
myEndOfArrow = myApexN ;
}
// Presenatation
DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, curPos,
myEndOfArrow, Center, Standard_True, mySymbolPrs);
}
//=======================================================================
//function : ComputeArcOfEllipse
//purpose :
//=======================================================================
void AIS_MaxRadiusDimension::ComputeArcOfEllipse(const Handle(Prs3d_Presentation)& aPresentation)
{
Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
// size
#ifdef BUC60915
if( !myArrowSizeIsDefined ) {
myArrowSize = Min(myArrowSize,myVal / 5.);
}
arr->SetLength(myArrowSize);
#else
if (myVal / 5. > myArrowSize) {
arr->SetLength(myArrowSize);
}
else {
arr->SetLength(myVal / 5.);
}
#endif
Standard_Real par;
gp_Pnt curPos, Center;
Center = myEllipse.Location();
Standard_Boolean IsInDomain = Standard_True;
if( myAutomaticPosition )
{
myEndOfArrow = AIS::NearestApex(myEllipse, myApexP, myApexN,
myFirstPar, myLastPar, IsInDomain);
myPosition = Center;
myAutomaticPosition = Standard_True;
if ( myIsSetBndBox )
myPosition = AIS::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
myBndBox );
curPos = myPosition;
}
else //!AutomaticPosition
{
curPos = myPosition;
// ElSLib::Parameters ( myPlane->Pln(), curPos, U, V );
// curPos = ElSLib::Value (U, V, myPlane->Pln());
gp_Lin L1(myEllipse.XAxis());
par = ElCLib::Parameter ( L1, curPos );
curPos = ElCLib::Value (par, L1);
if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
myEndOfArrow = myApexP ;
else
myEndOfArrow = myApexN ;
par = ElCLib::Parameter ( myEllipse, myEndOfArrow );
IsInDomain = AIS::InDomain( myFirstPar, myLastPar, par );
myPosition = curPos;
}
// Standard_Real parEnd = ElCLib::Parameter ( myEllipse, myEndOfArrow );
Standard_Real parStart = 0.;
if( !IsInDomain )
{
if(AIS::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
AIS::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
parStart = myFirstPar;
else
parStart = myLastPar;
}
if(!myIsOffset)
DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myEllipse,
curPos, myEndOfArrow, Center, parStart, IsInDomain,
Standard_True, mySymbolPrs);
else
DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myOffsetCurve,
curPos, myEndOfArrow, Center, parStart, IsInDomain,
Standard_True, mySymbolPrs);
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_MaxRadiusDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer /*aMode*/)
{
gp_Pnt center = myEllipse.Location();
gp_Pnt AttachmentPoint = myPosition;
Standard_Real dist = center.Distance(AttachmentPoint);
Standard_Real aRadius = myVal;
//Standard_Real inside = Standard_False;
gp_Pnt pt1;
if (dist > aRadius) pt1 = AttachmentPoint;
else
pt1 = myEndOfArrow;
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
Handle(Select3D_SensitiveSegment)
seg = new Select3D_SensitiveSegment(own, center , pt1);
aSelection->Add(seg);
// Text
Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
AttachmentPoint.X(),
AttachmentPoint.Y(),
AttachmentPoint.Z(),
AttachmentPoint.X()+size,
AttachmentPoint.Y()+size,
AttachmentPoint.Z()+size);
aSelection->Add(box);
// Arc of Ellipse
if(myIsAnArc)
{
Standard_Real parEnd = ElCLib::Parameter ( myEllipse, myEndOfArrow );
if(!AIS::InDomain(myFirstPar, myLastPar, parEnd))
{
Standard_Real parStart, par;
if(AIS::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
AIS::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
par = myFirstPar;
else
par = myLastPar;
gp_Vec Vapex(center, ElCLib::Value( parEnd, myEllipse )) ;
gp_Vec Vpnt (center, ElCLib::Value( par, myEllipse )) ;
gp_Dir dir(Vpnt ^ Vapex);
if(myEllipse.Position().Direction().IsOpposite( dir, Precision::Angular())) {
parStart = parEnd;
parEnd = par;
}
else
parStart = par;
Handle(Geom_TrimmedCurve)TrimCurve;
if(myIsOffset)
{
Handle(Geom_Curve) aCurve = myOffsetCurve;
TrimCurve = new Geom_TrimmedCurve( aCurve, parStart, parEnd );
}
else
{
Handle(Geom_Ellipse) Ellipse = new Geom_Ellipse( myEllipse );
TrimCurve = new Geom_TrimmedCurve( Ellipse, parStart, parEnd );
}
Handle( Select3D_SensitiveCurve ) SensArc;
SensArc = new Select3D_SensitiveCurve( own, TrimCurve );
aSelection->Add( SensArc );
}
}
}

133
src/AIS/AIS_MidPointRelation.cdl Executable file
View File

@@ -0,0 +1,133 @@
-- File: AIS_MidPointRelation.cdl
-- Created: Fri Oct 20 15:57:32 2000
-- Author: Julia DOROVSKIKH
-- <jfa@androx.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
class MidPointRelation from AIS inherits Relation from AIS
---Purpose: presentation of equal distance to point myMidPoint
uses
ExtendedString from TCollection,
Projector from Prs3d,
Presentation from Prs3d,
PresentationManager2d from PrsMgr,
PresentationManager3d from PrsMgr,
Selection from SelectMgr,
GraphicObject from Graphic2d,
Dir from gp,
Pnt from gp,
Lin from gp,
Circ from gp,
Elips from gp,
Plane from Geom,
Transformation from Geom,
Shape from TopoDS
is
Create(aSymmTool : Shape from TopoDS;
FirstShape : Shape from TopoDS;
SecondShape : Shape from TopoDS;
aPlane : Plane from Geom)
returns mutable MidPointRelation from AIS;
IsMovable(me) returns Boolean from Standard
---C++: inline
is redefined;
SetTool(me: mutable; aMidPointTool : Shape from TopoDS);
---C++: inline
GetTool(me)
---C++: inline
---C++: return const &
returns Shape from TopoDS;
-- Methods from PresentableObject
Compute(me: mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined static private;
Compute(me: mutable;
aProjector : Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me: mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation : mutable GraphicObject from Graphic2d;
aMode : Integer from Standard = 0)
is redefined static private;
Compute(me: mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: Computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)is private;
-- Computation private methods
ComputeFaceFromPnt(me: mutable; aprs : mutable Presentation from Prs3d; first : Boolean from Standard)
is private;
ComputeEdgeFromPnt(me: mutable; aprs : mutable Presentation from Prs3d; first : Boolean from Standard)
is private;
ComputeVertexFromPnt(me: mutable; aprs : mutable Presentation from Prs3d; first : Boolean from Standard)
is private;
ComputePointsOnLine(me: mutable; aLin : Lin from gp;
first : Boolean from Standard)
is private;
ComputePointsOnLine(me: mutable; pnt1,pnt2 : Pnt from gp;
first : Boolean from Standard)
is private;
ComputePointsOnCirc(me: mutable; aCirc : Circ from gp; pnt1,pnt2 : Pnt from gp;
first : Boolean from Standard)
is private;
ComputePointsOnElips(me: mutable; anEll : Elips from gp; pnt1,pnt2 : Pnt from gp;
first : Boolean from Standard)
is private;
---Purpose: ComputePointsOn... methods set myFAttach, myFirstPnt and myLastPnt
-- from the following initial data: curve, end points, myMidPoint.
-- End points (pnt1 & pnt2) and curve define the trimmed curve.
-- If end points are equal, curve is not trimmed (line - special case).
--
-- .------. pnt2
-- / \
-- . circle . myLastPnt
-- | |
-- . pnt1 . myFAttach
-- \ arc / . myMidPoint
-- .______. myFirstPnt
fields
myTool : Shape from TopoDS;
myMidPoint : Pnt from gp; -- point of symmetry
myFAttach : Pnt from gp; -- position on myFShape to be connected with myMidPoint by segment
myFirstPnt1 : Pnt from gp; -- points on myFShape,
myFirstPnt2 : Pnt from gp; -- defining a segment of it to be drawn
mySAttach : Pnt from gp; -- position on mySShape to be connected with myMidPoint by segment
mySecondPnt1 : Pnt from gp; -- points on mySShape,
mySecondPnt2 : Pnt from gp; -- defining a segment of it to be drawn
end MidPointRelation;

719
src/AIS/AIS_MidPointRelation.cxx Executable file
View File

@@ -0,0 +1,719 @@
// File: AIS_MidPointRelation.cxx
// Created: Fri Oct 20 16:00:58 2000
// Author: Julia DOROVSKIKH
// <jfa@androx.nnov.matra-dtv.fr>
#include <AIS_MidPointRelation.ixx>
#include <Standard_NotImplemented.hxx>
#include <Precision.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
#include <gce_MakeLin.hxx>
#include <ElCLib.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pln.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveCurve.hxx>
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LengthAspect.hxx>
#include <DsgPrs_MidPointPresentation.hxx>
#include <TopoDS_Vertex.hxx>
//=======================================================================
//function : AIS_MidPointRelation
//purpose :
//=======================================================================
AIS_MidPointRelation::AIS_MidPointRelation(const TopoDS_Shape& aMidPointTool,
const TopoDS_Shape& FirstShape,
const TopoDS_Shape& SecondShape,
const Handle(Geom_Plane)& aPlane)
:AIS_Relation(),
myTool(aMidPointTool)
{
SetFirstShape(FirstShape);
SetSecondShape(SecondShape);
SetPlane(aPlane);
myPosition = aPlane->Pln().Location();
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MidPointRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&,
const Handle(Prs3d_Presentation)& aprs,
const Standard_Integer)
{
aprs->Clear();
if (myTool.ShapeType() == TopAbs_VERTEX)
{
gp_Pnt pp;
Standard_Boolean isonplane;
if ( AIS::ComputeGeometry(TopoDS::Vertex(myTool),pp,myPlane,isonplane) )
{
if ( !isonplane ) ComputeProjVertexPresentation(aprs,TopoDS::Vertex(myTool),pp);
}
myMidPoint = pp;
}
else return;
if ( myAutomaticPosition ) myPosition = myMidPoint;
switch (myFShape.ShapeType())
{
case TopAbs_FACE :
{
ComputeFaceFromPnt(aprs, Standard_True);
}
break;
case TopAbs_EDGE :
{
ComputeEdgeFromPnt(aprs, Standard_True);
}
break;
case TopAbs_VERTEX :
{
ComputeVertexFromPnt(aprs, Standard_True);
}
break;
default:
break;
}
switch (mySShape.ShapeType())
{
case TopAbs_FACE :
{
ComputeFaceFromPnt(aprs, Standard_False);
}
break;
case TopAbs_EDGE :
{
ComputeEdgeFromPnt(aprs, Standard_False);
}
break;
case TopAbs_VERTEX :
{
ComputeVertexFromPnt(aprs, Standard_False);
}
break;
default:
break;
}
}
//=======================================================================
//function : Compute
//purpose : to avoid warning at compilation (SUN)
//=======================================================================
void AIS_MidPointRelation::Compute(const Handle(Prs3d_Projector)& /*aProjector*/,
const Handle(Prs3d_Presentation)& /*aPresentation*/)
{
// Standard_NotImplemented::Raise("AIS_MidPointRelation::Compute(const Handle(Prs3d_Projector)&,const Handle(Prs3d_Presentation)&)");
// PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
//=======================================================================
//function : Compute
//purpose : to avoid warning at compilation (SUN)
//=======================================================================
void AIS_MidPointRelation::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager2d*/,
const Handle(Graphic2d_GraphicObject)& /*aGraphicObject*/,
const Standard_Integer /*anInteger*/)
{
// Standard_NotImplemented::Raise("AIS_MidPointRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)");
// PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
void AIS_MidPointRelation::Compute(const Handle_Prs3d_Projector& aProjector,
const Handle_Geom_Transformation& aTransformation,
const Handle_Prs3d_Presentation& aPresentation)
{
Standard_NotImplemented::Raise("AIS_MidPointRelation::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_MidPointRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
const Standard_Integer)
{
Handle(Select3D_SensitiveSegment) seg;
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
if ( !myMidPoint.IsEqual(myFAttach,Precision::Confusion()) )
{
// segment from mid point to the first geometry
seg = new Select3D_SensitiveSegment(own,myFAttach,myMidPoint);
aSel->Add(seg);
// segment from mid point to the second geometry
seg = new Select3D_SensitiveSegment(own,mySAttach,myMidPoint);
aSel->Add(seg);
}
if ( !myMidPoint.IsEqual(myPosition,Precision::Confusion()) )
{
// segment from mid point to the text position
seg = new Select3D_SensitiveSegment(own,myMidPoint,myPosition);
aSel->Add(seg);
}
// center of the symmetry - circle around the MidPoint
gp_Ax2 ax = myPlane->Pln().Position().Ax2();
ax.SetLocation(myMidPoint);
Standard_Real rad = myFAttach.Distance(myMidPoint)/20.0;
gp_Circ aCircleM (ax,rad);
Handle(Geom_Circle) thecir = new Geom_Circle(aCircleM);
Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own, thecir);
aSel->Add(scurv);
Handle(Geom_Curve) curv;
gp_Pnt firstp,lastp;
Standard_Boolean isInfinite,isOnPlane;
Handle(Geom_Curve) extCurv;
// segment on first curve
if ( myFShape.ShapeType() == TopAbs_EDGE )
{
TopoDS_Edge E = TopoDS::Edge(myFShape);
if ( !AIS::ComputeGeometry(E,curv,firstp,lastp,extCurv,isInfinite,isOnPlane,myPlane) ) return;
if ( curv->IsInstance(STANDARD_TYPE(Geom_Line)) ) // case of line
{
// segment on line
seg = new Select3D_SensitiveSegment(own,myFirstPnt1,myFirstPnt2);
aSel->Add(seg);
}
else if ( curv->IsInstance(STANDARD_TYPE(Geom_Circle)) ) // case of circle
{
// segment on circle
Handle(Geom_Circle) thecirc = (Handle(Geom_Circle)&) curv;
Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),myFirstPnt1);
Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),myFirstPnt2);
Handle(Geom_TrimmedCurve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
scurv = new Select3D_SensitiveCurve(own, thecu);
aSel->Add(scurv);
}
else if ( curv->IsInstance(STANDARD_TYPE(Geom_Ellipse)) ) // case of ellipse
{
// segment on ellipse
Handle(Geom_Ellipse) theEll = (Handle(Geom_Ellipse)&) curv;
Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),myFirstPnt1);
Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),myFirstPnt2);
Handle(Geom_TrimmedCurve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
scurv = new Select3D_SensitiveCurve(own, thecu);
aSel->Add(scurv);
}
}
// segment on second curve
if ( mySShape.ShapeType() == TopAbs_EDGE )
{
TopoDS_Edge E = TopoDS::Edge(mySShape);
if ( !AIS::ComputeGeometry(E,curv,firstp,lastp,extCurv,isInfinite,isOnPlane,myPlane) ) return;
if ( curv->IsInstance(STANDARD_TYPE(Geom_Line)) ) // case of line
{
// segment on line
seg = new Select3D_SensitiveSegment(own,mySecondPnt1,mySecondPnt2);
aSel->Add(seg);
}
else if ( curv->IsInstance(STANDARD_TYPE(Geom_Circle)) ) // case of circle
{
// segment on circle
Handle(Geom_Circle) thecirc = (Handle(Geom_Circle)&) curv;
Standard_Real udeb = ElCLib::Parameter(thecirc->Circ(),mySecondPnt1);
Standard_Real ufin = ElCLib::Parameter(thecirc->Circ(),mySecondPnt2);
Handle(Geom_TrimmedCurve) thecu = new Geom_TrimmedCurve(thecirc,udeb,ufin);
scurv = new Select3D_SensitiveCurve(own, thecu);
aSel->Add(scurv);
}
else if ( curv->IsInstance(STANDARD_TYPE(Geom_Ellipse)) ) // case of ellipse
{
// segment on ellipse
Handle(Geom_Ellipse) theEll = (Handle(Geom_Ellipse)&) curv;
Standard_Real udeb = ElCLib::Parameter(theEll->Elips(),mySecondPnt1);
Standard_Real ufin = ElCLib::Parameter(theEll->Elips(),mySecondPnt2);
Handle(Geom_TrimmedCurve) thecu = new Geom_TrimmedCurve(theEll,udeb,ufin);
scurv = new Select3D_SensitiveCurve(own, thecu);
aSel->Add(scurv);
}
}
}
//=======================================================================
//function : ComputeFaceFromPnt
//purpose :
//=======================================================================
void AIS_MidPointRelation::ComputeFaceFromPnt(const Handle(Prs3d_Presentation)&,
const Standard_Boolean /*first*/)
{
}
//=======================================================================
//function : ComputeEdgeFromPnt
//purpose :
//=======================================================================
void AIS_MidPointRelation::ComputeEdgeFromPnt(const Handle(Prs3d_Presentation)& aprs,
const Standard_Boolean first)
{
TopoDS_Edge E;
if ( first ) E = TopoDS::Edge(myFShape);
else E = TopoDS::Edge(mySShape);
Handle(Geom_Curve) geom;
gp_Pnt ptat1,ptat2;
Handle(Geom_Curve) extCurv;
Standard_Boolean isInfinite,isOnPlane;
if ( !AIS::ComputeGeometry(E, geom, ptat1, ptat2, extCurv, isInfinite, isOnPlane, myPlane) ) return;
gp_Ax2 ax = myPlane->Pln().Position().Ax2();
if ( geom->IsInstance(STANDARD_TYPE(Geom_Line)) )
{
if ( !isInfinite ) ComputePointsOnLine(ptat1,ptat2,first);
else
{
const gp_Lin& line = ((Handle(Geom_Line)&) geom)->Lin();
ComputePointsOnLine(line,first);
}
if ( first ) DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,
myFAttach,myFirstPnt1,myFirstPnt2,first);
else DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,
mySAttach,mySecondPnt1,mySecondPnt2,first);
}
else if ( geom->IsInstance(STANDARD_TYPE(Geom_Circle)) )
{
const Handle(Geom_Circle)& geom_cir = (Handle(Geom_Circle)&) geom;
gp_Circ circ (geom_cir->Circ());
ComputePointsOnCirc(circ,ptat1,ptat2,first);
if ( first ) DsgPrs_MidPointPresentation::Add(aprs,myDrawer,circ,myMidPoint,myPosition,
myFAttach,myFirstPnt1,myFirstPnt2,first);
else DsgPrs_MidPointPresentation::Add(aprs,myDrawer,circ,myMidPoint,myPosition,
mySAttach,mySecondPnt1,mySecondPnt2,first);
}
else if ( geom->IsInstance(STANDARD_TYPE(Geom_Ellipse)) )
{
const Handle(Geom_Ellipse)& geom_ell = (Handle(Geom_Ellipse)&) geom;
gp_Elips elips (geom_ell->Elips());
ComputePointsOnElips(elips,ptat1,ptat2,first);
if ( first ) DsgPrs_MidPointPresentation::Add(aprs,myDrawer,elips,myMidPoint,myPosition,
myFAttach,myFirstPnt1,myFirstPnt2,first);
else DsgPrs_MidPointPresentation::Add(aprs,myDrawer,elips,myMidPoint,myPosition,
mySAttach,mySecondPnt1,mySecondPnt2,first);
}
else return;
// projection on myPlane
if ( !isOnPlane ) ComputeProjEdgePresentation(aprs,E,geom,ptat1,ptat2);
}
//=======================================================================
//function : ComputeVertexFromPnt
//purpose :
//=======================================================================
void AIS_MidPointRelation::ComputeVertexFromPnt(const Handle(Prs3d_Presentation)& aprs,
const Standard_Boolean first)
{
gp_Ax2 ax = myPlane->Pln().Position().Ax2();
if ( first )
{
Standard_Boolean isOnPlane;
TopoDS_Vertex V = TopoDS::Vertex(myFShape);
AIS::ComputeGeometry(V, myFAttach, myPlane, isOnPlane);
DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,myFAttach,first);
if ( !isOnPlane ) ComputeProjVertexPresentation(aprs,V,myFAttach);
}
else
{
Standard_Boolean isOnPlane;
TopoDS_Vertex V = TopoDS::Vertex(mySShape);
AIS::ComputeGeometry(V, mySAttach, myPlane, isOnPlane);
DsgPrs_MidPointPresentation::Add(aprs,myDrawer,ax,myMidPoint,myPosition,mySAttach,first);
if ( !isOnPlane ) ComputeProjVertexPresentation(aprs,V,mySAttach);
}
}
//=======================================================================
//function : ComputePointsOnLine
//purpose :
//=======================================================================
void AIS_MidPointRelation::ComputePointsOnLine(const gp_Lin& aLin,
const Standard_Boolean first)
{
Standard_Real ppar = ElCLib::Parameter(aLin,myMidPoint);
gp_Pnt anAttach = ElCLib::Value(ppar,aLin);
Standard_Real dist = anAttach.Distance(myMidPoint)/10.0;
if ( dist < Precision::Confusion() ) dist = 10.0;
Standard_Real fpar = ppar + dist;
Standard_Real spar = ppar - dist;
gp_Pnt aPnt1 = ElCLib::Value(fpar,aLin);
gp_Pnt aPnt2 = ElCLib::Value(spar,aLin);
if ( first )
{
myFAttach = anAttach;
myFirstPnt1 = aPnt1;
myFirstPnt2 = aPnt2;
}
else
{
mySAttach = anAttach;
mySecondPnt1 = aPnt1;
mySecondPnt2 = aPnt2;
}
}
//=======================================================================
//function : ComputePointsOnLine
//purpose :
//=======================================================================
void AIS_MidPointRelation::ComputePointsOnLine(const gp_Pnt& pnt1, const gp_Pnt& pnt2,
const Standard_Boolean first)
{
gp_Vec aVec (pnt1,pnt2);
gp_Lin aLin (pnt1,gp_Dir(aVec));
Standard_Real fpar = ElCLib::Parameter(aLin,pnt1);
Standard_Real spar = ElCLib::Parameter(aLin,pnt2);
Standard_Real ppar = ElCLib::Parameter(aLin,myMidPoint);
gp_Pnt aProjPnt = ElCLib::Value(ppar,aLin);
Standard_Real dist = myMidPoint.Distance(aProjPnt);
Standard_Real ll = pnt1.Distance(pnt2);
Standard_Real segm = Min(dist,ll)*0.75;
if ( dist < Precision::Confusion() ) segm = ll*0.75;
gp_Pnt anAttach,aPnt1,aPnt2;
anAttach = aProjPnt;
gp_Vec aVecTr;
if ( ppar <= fpar )
{
aPnt2 = pnt1;
aVecTr = gp_Vec(pnt2,pnt1);
aVecTr.Normalize();
aPnt1 = aProjPnt.Translated(aVecTr*segm);
}
else if ( ppar >= spar )
{
aPnt1 = pnt2;
aVecTr = gp_Vec(pnt1,pnt2);
aVecTr.Normalize();
aPnt2 = aProjPnt.Translated(aVecTr*segm);
}
else
{
Standard_Real dp1 = aProjPnt.Distance(pnt1);
Standard_Real dp2 = aProjPnt.Distance(pnt2);
segm = Min(dist,dp1)*0.75;
aVecTr = gp_Vec(aProjPnt,pnt1);
aVecTr.Normalize();
aPnt1 = aProjPnt.Translated(aVecTr*segm);
segm = Min(dist,dp2)*0.75;
aVecTr = gp_Vec(aProjPnt,pnt2);
aVecTr.Normalize();
aPnt2 = aProjPnt.Translated(aVecTr*segm);
}
if ( first )
{
myFAttach = anAttach;
myFirstPnt1 = aPnt1;
myFirstPnt2 = aPnt2;
}
else
{
mySAttach = anAttach;
mySecondPnt1 = aPnt1;
mySecondPnt2 = aPnt2;
}
}
//=======================================================================
//function : ComputePointsOnCirc
//purpose :
//=======================================================================
void AIS_MidPointRelation::ComputePointsOnCirc(const gp_Circ& aCirc,
const gp_Pnt& pnt1, const gp_Pnt& pnt2,
const Standard_Boolean first)
{
gp_Pnt curpos = myMidPoint;
// Case of confusion between the current position and the center
// of the circle -> we move the current position
Standard_Real confusion (Precision::Confusion());
gp_Pnt aCenter = aCirc.Location();
if ( aCenter.Distance(curpos) <= confusion )
{
gp_Vec vprec(aCenter, pnt1);
vprec.Normalize();
curpos.Translate(vprec*1e-5);
}
Standard_Real pcurpos = ElCLib::Parameter(aCirc,curpos);
Standard_Real rad = Standard_PI/5.0;
Standard_Real segm;
Standard_Real pFPnt;
Standard_Real pSPnt;
if ( pnt1.IsEqual(pnt2,confusion) ) // full circle
{
pFPnt = pcurpos - rad;
pSPnt = pcurpos + rad;
}
else
{
Standard_Real pFAttach = ElCLib::Parameter(aCirc,pnt1);
Standard_Real pSAttach = ElCLib::Parameter(aCirc,pnt2);
Standard_Real pSAttachM = pSAttach;
Standard_Real deltap = pSAttachM - pFAttach;
if ( deltap < 0 )
{
deltap += 2*Standard_PI;
pSAttachM += 2*Standard_PI;
}
pSAttachM -= pFAttach;
Standard_Real pmiddleout = pSAttachM/2.0 + Standard_PI;
Standard_Real pcurpos1 = pcurpos;
// define where curpos lays
if ( pcurpos1 < pFAttach )
{
pcurpos1 = pcurpos1 + 2*Standard_PI - pFAttach;
if ( pcurpos1 > pSAttachM ) // out
{
segm = Min(rad,deltap*0.75);
if ( pcurpos1 > pmiddleout )
{
pcurpos = pFAttach;
pFPnt = pFAttach;
pSPnt = pFAttach + segm;
}
else
{
pcurpos = pSAttach;
pFPnt = pSAttach - segm;
pSPnt = pSAttach;
}
}
else // on arc
{
Standard_Real dp1 = pcurpos1 - pFAttach;
Standard_Real dp2 = pSAttachM - pcurpos1;
segm = Min(rad,dp1*0.75);
pFPnt = pcurpos - segm;
segm = Min(rad,dp2*0.75);
pSPnt = pcurpos + segm;
}
}
else if ( pcurpos1 > (pFAttach + deltap) ) // out
{
pcurpos1 -= pFAttach;
segm = Min(rad,deltap*0.75);
if ( pcurpos1 > pmiddleout )
{
pcurpos = pFAttach;
pFPnt = pFAttach;
pSPnt = pFAttach + segm;
}
else
{
pcurpos = pSAttach;
pFPnt = pSAttach - segm;
pSPnt = pSAttach;
}
}
else // on arc
{
Standard_Real dp1 = pcurpos1 - pFAttach;
Standard_Real dp2 = pSAttach - pcurpos1;
segm = Min(rad,dp1*0.75);
pFPnt = pcurpos - segm;
segm = Min(rad,dp2*0.75);
pSPnt = pcurpos + segm;
}
}
if ( first )
{
myFAttach = ElCLib::Value(pcurpos,aCirc);
myFirstPnt1 = ElCLib::Value(pFPnt,aCirc);
myFirstPnt2 = ElCLib::Value(pSPnt,aCirc);
}
else
{
mySAttach = ElCLib::Value(pcurpos,aCirc);
mySecondPnt1 = ElCLib::Value(pFPnt,aCirc);
mySecondPnt2 = ElCLib::Value(pSPnt,aCirc);
}
}
//=======================================================================
//function : ComputePointsOnElips
//purpose :
//=======================================================================
void AIS_MidPointRelation::ComputePointsOnElips(const gp_Elips& anEll,
const gp_Pnt& pnt1, const gp_Pnt& pnt2,
const Standard_Boolean first)
{
gp_Pnt curpos = myMidPoint;
// Case of confusion between the current position and the center
// of the circle -> we move the current position
Standard_Real confusion (Precision::Confusion());
gp_Pnt aCenter = anEll.Location();
if ( aCenter.Distance(curpos) <= confusion )
{
gp_Vec vprec(aCenter, pnt1);
vprec.Normalize();
curpos.Translate(vprec*1e-5);
}
Standard_Real pcurpos = ElCLib::Parameter(anEll,curpos);
Standard_Real rad = Standard_PI/5.0;
Standard_Real segm;
Standard_Real pFPnt;
Standard_Real pSPnt;
if ( pnt1.IsEqual(pnt2,confusion) ) // full circle
{
pFPnt = pcurpos - rad;
pSPnt = pcurpos + rad;
}
else
{
Standard_Real pFAttach = ElCLib::Parameter(anEll,pnt1);
Standard_Real pSAttach = ElCLib::Parameter(anEll,pnt2);
Standard_Real pSAttachM = pSAttach;
Standard_Real deltap = pSAttachM - pFAttach;
if ( deltap < 0 )
{
deltap += 2*Standard_PI;
pSAttachM += 2*Standard_PI;
}
pSAttachM -= pFAttach;
Standard_Real pmiddleout = pSAttachM/2.0 + Standard_PI;
Standard_Real pcurpos1 = pcurpos;
// define where curpos lays
if ( pcurpos1 < pFAttach )
{
pcurpos1 = pcurpos1 + 2*Standard_PI - pFAttach;
if ( pcurpos1 > pSAttachM ) // out
{
segm = Min(rad,deltap*0.75);
if ( pcurpos1 > pmiddleout )
{
pcurpos = pFAttach;
pFPnt = pFAttach;
pSPnt = pFAttach + segm;
}
else
{
pcurpos = pSAttach;
pFPnt = pSAttach - segm;
pSPnt = pSAttach;
}
}
else // on arc
{
Standard_Real dp1 = pcurpos1 - pFAttach;
Standard_Real dp2 = pSAttachM - pcurpos1;
segm = Min(rad,dp1*0.75);
pFPnt = pcurpos - segm;
segm = Min(rad,dp2*0.75);
pSPnt = pcurpos + segm;
}
}
else if ( pcurpos1 > (pFAttach + deltap) ) // out
{
pcurpos1 -= pFAttach;
segm = Min(rad,deltap*0.75);
if ( pcurpos1 > pmiddleout )
{
pcurpos = pFAttach;
pFPnt = pFAttach;
pSPnt = pFAttach + segm;
}
else
{
pcurpos = pSAttach;
pFPnt = pSAttach - segm;
pSPnt = pSAttach;
}
}
else // on arc
{
Standard_Real dp1 = pcurpos1 - pFAttach;
Standard_Real dp2 = pSAttach - pcurpos1;
segm = Min(rad,dp1*0.75);
pFPnt = pcurpos - segm;
segm = Min(rad,dp2*0.75);
pSPnt = pcurpos + segm;
}
}
if ( first )
{
myFAttach = ElCLib::Value(pcurpos,anEll);
myFirstPnt1 = ElCLib::Value(pFPnt,anEll);
myFirstPnt2 = ElCLib::Value(pSPnt,anEll);
}
else
{
mySAttach = ElCLib::Value(pcurpos,anEll);
mySecondPnt1 = ElCLib::Value(pFPnt,anEll);
mySecondPnt2 = ElCLib::Value(pSPnt,anEll);
}
}

View File

@@ -0,0 +1,32 @@
// File: AIS_MidPointRelation.lxx
// Created: Fri Oct 20 16:00:58 2000
// Author: Julia DOROVSKIKH
// <jfa@androx.nnov.matra-dtv.fr>
//=======================================================================
//function : SetTool
//purpose :
//=======================================================================
inline void AIS_MidPointRelation::SetTool(const TopoDS_Shape& aMidPointTool)
{
myTool = aMidPointTool;
}
//=======================================================================
//function : GetTool
//purpose :
//=======================================================================
inline const TopoDS_Shape& AIS_MidPointRelation::GetTool() const
{
return myTool;
}
//=======================================================================
//function : IsMovable
//purpose :
//=======================================================================
inline Standard_Boolean AIS_MidPointRelation::IsMovable() const
{
return Standard_True;
}

View File

@@ -0,0 +1,120 @@
-- File: AIS_MinRadiusDimension.cdl
-- Created: Thu Jan 22 08:58:42 1998
-- Author: Sergey ZARITCHNY
-- <szy@androx.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class MinRadiusDimension from AIS inherits EllipseRadiusDimension from AIS
---Purpose:-- Ellipse Min radius dimension of a Shape which
-- can be Edge or Face (planar or cylindrical(surface of
-- extrusion or surface of offset))
uses
Shape from TopoDS,
Elips from gp,
Pnt from gp,
Pln from gp,
Ellipse from Geom,
Plane from Geom,
Surface from Geom,
Presentation from Prs3d,
PresentationManager3d from PrsMgr,
Selection from SelectMgr,
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
ExtendedString from TCollection,
ArrowSide from DsgPrs,
KindOfSurface from AIS,
KindOfDimension from AIS
raises ConstructionError from Standard
is
Create (aShape : Shape from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
---Purpose: Max Ellipse radius dimension
-- Shape can be edge , planar face or cylindrical face
--
returns mutable MinRadiusDimension from AIS;
Create (aShape : Shape from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection;
aPosition : Pnt from gp;
aSymbolPrs : ArrowSide from DsgPrs;
anArrowSize : Real from Standard = 0.0)
---Purpose: Max Ellipse radius dimension with position
-- Shape can be edge , planar face or cylindrical face
--
returns mutable MinRadiusDimension from AIS;
-- Methods from PresentableObject
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
--
-- Computation private methods
--
ComputeEllipse(me: mutable;
aPresentation : mutable Presentation from Prs3d)
is private;
ComputeArcOfEllipse(me: mutable;
aPresentation : mutable Presentation from Prs3d )
is private;
fields
myApexP : Pnt from gp;
myApexN : Pnt from gp;
myEndOfArrow : Pnt from gp;
end MinRadiusDimension;

View File

@@ -0,0 +1,372 @@
// File: AIS_MinRadiusDimension.cxx
// Created: Tue Jan 27 11:17:01 1998
// Author: Sergey ZARITCHNY
// <szy@androx.nnov.matra-dtv.fr>
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
// if any in all dimensions.
#include <Standard_NotImplemented.hxx>
#include <AIS_MinRadiusDimension.ixx>
#include <AIS_EllipseRadiusDimension.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Prs3d_LengthAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_Text.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <TopoDS.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
#include <Precision.hxx>
#include <DsgPrs_EllipseRadiusPresentation.hxx>
//=======================================================================
//function : AIS_MinRadiusDimension
//purpose :
//=======================================================================
AIS_MinRadiusDimension::AIS_MinRadiusDimension(const TopoDS_Shape& aShape,
const Standard_Real aVal,
const TCollection_ExtendedString& aText)
:AIS_EllipseRadiusDimension(aShape, aText)
{
myVal = aVal;
mySymbolPrs = DsgPrs_AS_LASTAR;
myAutomaticPosition = Standard_True;
myArrowSize = myVal / 100.;
}
//=======================================================================
//function : AIS_MinRadiusDimension
//purpose :
//=======================================================================
AIS_MinRadiusDimension::AIS_MinRadiusDimension(const TopoDS_Shape& aShape,
const Standard_Real aVal,
const TCollection_ExtendedString& aText,
const gp_Pnt& aPosition,
const DsgPrs_ArrowSide aSymbolPrs,
const Standard_Real anArrowSize)
:AIS_EllipseRadiusDimension(aShape, aText)
{
myVal = aVal;
mySymbolPrs = aSymbolPrs;
myPosition = aPosition;
myAutomaticPosition = Standard_False;
#ifdef BUC60915
SetArrowSize( anArrowSize );
#else
myArrowSize = anArrowSize;
#endif
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MinRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer /*aMode*/)
{
aPresentation->Clear();
// if( myAutomaticPosition )
//{ //ota : recompute ellipse always
ComputeGeometry();
myEllipse.SetMinorRadius(myVal);
gp_Vec v1(myEllipse.YAxis().Direction());
v1 *=myVal;
myApexP = myEllipse.Location().Translated(v1);
myApexN = myEllipse.Location().Translated(-v1);
// }
if(myIsAnArc) ComputeArcOfEllipse(aPresentation);
else
ComputeEllipse(aPresentation);
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_MinRadiusDimension::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_MinRadiusDimension::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation)");
PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_MinRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager,
const Handle(Graphic2d_GraphicObject)& aPresentation,
const Standard_Integer aMode)
{
// Standard_NotImplemented::Raise("AIS_MinRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, const Handle(Graphic2d_GraphicObject)& aPresentation, const Standard_Integer aMode)");
PrsMgr_PresentableObject::Compute( aPresentationManager ,aPresentation,aMode) ;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MinRadiusDimension::Compute(const Handle_Prs3d_Projector& aProjector,
const Handle_Geom_Transformation& aTransformation,
const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_MinRadiusDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeEllipse
//purpose :
//=======================================================================
void AIS_MinRadiusDimension::ComputeEllipse(const Handle(Prs3d_Presentation)& aPresentation)
{
Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
// size
#ifdef BUC60915
if( !myArrowSizeIsDefined ) {
myArrowSize = Min(myArrowSize,myVal/5.);
}
arr->SetLength(myArrowSize);
#else
if (myVal/5. > myArrowSize) {
arr->SetLength(myArrowSize);
}
else {
arr->SetLength(myVal/5.);
}
#endif
Standard_Real U;//,V;
gp_Pnt curPos, Center;
Center = myEllipse.Location();
if( myAutomaticPosition )
{
myPosition = Center;
myEndOfArrow = myApexP;
myAutomaticPosition = Standard_True;
if ( myIsSetBndBox )
myPosition = AIS::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
myBndBox );
curPos = myPosition;
}
else //!AutomaticPosition
{
curPos = myPosition;
gp_Lin L1(myEllipse.YAxis());
U = ElCLib::Parameter ( L1, curPos );
curPos = ElCLib::Value (U, L1);
if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
myEndOfArrow = myApexP ;
else
myEndOfArrow = myApexN ;
myPosition = curPos;
}
// Presenatation
DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, curPos,
myEndOfArrow, Center, Standard_False, mySymbolPrs);
}
//=======================================================================
//function : ComputeArcOfEllipse
//purpose :
//=======================================================================
void AIS_MinRadiusDimension::ComputeArcOfEllipse(const Handle(Prs3d_Presentation)& aPresentation)
{
Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
// size
#ifdef BUC60915
if( !myArrowSizeIsDefined ) {
myArrowSize = Min(myArrowSize,myVal/5.);
}
arr->SetLength(myArrowSize);
#else
if (myVal/5. > myArrowSize) {
arr->SetLength(myArrowSize);
}
else {
arr->SetLength(myVal/5.);
}
#endif
Standard_Real par;
gp_Pnt curPos, Center;
Center = myEllipse.Location();
Standard_Boolean IsInDomain = Standard_True;
if( myAutomaticPosition )
{
myEndOfArrow = AIS::NearestApex(myEllipse, myApexP, myApexN,
myFirstPar, myLastPar, IsInDomain);
myPosition = Center;
myAutomaticPosition = Standard_True;
if ( myIsSetBndBox )
myPosition = AIS::TranslatePointToBound(myPosition, gp_Dir(gp_Vec( Center, myPosition )),
myBndBox );
curPos = myPosition;
}
else //!AutomaticPosition
{
curPos = myPosition;
gp_Lin L1(myEllipse.YAxis());
par = ElCLib::Parameter ( L1, curPos );
curPos = ElCLib::Value (par, L1);
if (curPos.Distance(myApexP) < curPos.Distance(myApexN))
myEndOfArrow = myApexP ;
else
myEndOfArrow = myApexN ;
par = ElCLib::Parameter ( myEllipse, myEndOfArrow );
IsInDomain = AIS::InDomain(myFirstPar, myLastPar, par);
myPosition = curPos;
}
Standard_Real parStart =0.;
if( !IsInDomain )
{
if(AIS::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
AIS::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
parStart = myFirstPar;
else
parStart = myLastPar;
}
if(!myIsOffset)
DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myEllipse,
curPos, myEndOfArrow, Center, parStart, IsInDomain,
Standard_True, mySymbolPrs);
else
DsgPrs_EllipseRadiusPresentation::Add(aPresentation, myDrawer, myVal, myText, myOffsetCurve,
curPos, myEndOfArrow, Center, parStart, IsInDomain,
Standard_True, mySymbolPrs);
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_MinRadiusDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer /*aMode*/)
{
gp_Pnt center = myEllipse.Location();
gp_Pnt AttachmentPoint = myPosition;
Standard_Real dist = center.Distance(AttachmentPoint);
Standard_Real aRadius = myVal;
//Standard_Real inside = Standard_False;
gp_Pnt pt1;
if (dist > aRadius) pt1 = AttachmentPoint;
else
pt1 = myEndOfArrow;
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
Handle(Select3D_SensitiveSegment)
seg = new Select3D_SensitiveSegment(own, center , pt1);
aSelection->Add(seg);
// Text
Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
AttachmentPoint.X(),
AttachmentPoint.Y(),
AttachmentPoint.Z(),
AttachmentPoint.X()+size,
AttachmentPoint.Y()+size,
AttachmentPoint.Z()+size);
aSelection->Add(box);
// Arc of Ellipse
if(myIsAnArc)
{
Standard_Real parEnd = ElCLib::Parameter ( myEllipse, myEndOfArrow );
if(!AIS::InDomain(myFirstPar, myLastPar, parEnd))
{
Standard_Real parStart, par;
if(AIS::DistanceFromApex (myEllipse, myEndOfArrow, myFirstPar) <
AIS::DistanceFromApex (myEllipse, myEndOfArrow, myLastPar))
par = myFirstPar;
else
par = myLastPar;
gp_Vec Vapex(center, ElCLib::Value( parEnd, myEllipse )) ;
gp_Vec Vpnt (center, ElCLib::Value( par, myEllipse )) ;
gp_Dir dir(Vpnt ^ Vapex);
if(myEllipse.Position().Direction().IsOpposite( dir, Precision::Angular())) {
parStart = parEnd;
parEnd = par;
}
else
parStart = par;
Handle(Geom_TrimmedCurve)TrimCurve;
if(myIsOffset)
{
Handle(Geom_Curve) aCurve = myOffsetCurve;
TrimCurve = new Geom_TrimmedCurve( aCurve, parStart, parEnd );
}
else
{
Handle(Geom_Ellipse) Ellipse = new Geom_Ellipse( myEllipse );
TrimCurve = new Geom_TrimmedCurve( Ellipse, parStart, parEnd );
}
Handle( Select3D_SensitiveCurve ) SensArc;
SensArc = new Select3D_SensitiveCurve( own, TrimCurve );
aSelection->Add( SensArc );
}
}
}

View File

@@ -0,0 +1,120 @@
-- File: AIS_MultipleConnectedInteractive.cdl
-- Created: Tue Apr 22 17:04:42 1997
-- Author: Guest Design
-- <g_design@hankox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class MultipleConnectedInteractive from AIS inherits InteractiveObject from AIS
---Purpose: Defines an Interactive Object by gathering together
-- several object presentations. This is done through a
-- list of interactive objects. These can also be
-- Connected objects. That way memory-costly
-- calculations of presentation are avoided.
uses
TypeOfPresentation3d from PrsMgr,
InteractiveObject from AIS,
Boolean from Standard,
SequenceOfInteractive from AIS,
KindOfInteractive from AIS,
PresentationManager3d from PrsMgr,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Presentation from Prs3d,
Projector from Prs3d,
Transformation from Geom,
Integer from Standard,
Selection from SelectMgr
is
Create (aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView)
returns mutable MultipleConnectedInteractive from AIS;
---Purpose: Initializes the Interactive Object with multiple
-- presentation connections. If aTypeOfPresentation3d
-- does not have the affectation PrsMgr_TOP_AllView,
-- it is projector dependent.
Connect(me : mutable;
anotherIObj : InteractiveObject from AIS);
---Purpose: Add anotherIObj in the presentation of me
Type(me) returns KindOfInteractive from AIS
is redefined virtual;
Signature(me) returns Integer from Standard
is redefined virtual;
HasConnection(me) returns Boolean from Standard;
---Purpose: Returns true if the object is connected to others.
ConnectedTo(me) returns SequenceOfInteractive from AIS;
---Purpose:
-- Returns the connection references of the previous
-- Interactive Objects in view.
---C++: inline
---C++: return const&
Disconnect(me:mutable;
anotherIObj : InteractiveObject from AIS);
---Purpose: Removes the connection anotherIObj to an entity.
DisconnectAll(me:mutable);
---Purpose: Clears all the connections to objects.
Compute(me:mutable;
aPresentationManager : PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard = 0)
---Level: Internal
---Purpose: this method is redefined virtual;
-- when the instance is connected to another
-- InteractiveObject,this method doesn't
-- compute anything, but just uses the
-- presentation of this last object, with
-- a transformation if there's one stored.
is redefined virtual private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined ;
ComputeSelection(me:mutable; aSelection :mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined virtual private;
fields
myReferences : SequenceOfInteractive from AIS;
myPreviousReferences : SequenceOfInteractive from AIS;
end MultipleConnectedInteractive;

View File

@@ -0,0 +1,187 @@
// File: AIS_MultipleConnectedInteractive.cxx
// Created: Tue Apr 22 17:15:05 1997
// Author: Guest Design
// <g_design>
#include <Standard_NotImplemented.hxx>
#include <AIS_MultipleConnectedInteractive.ixx>
#include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_Presentation3d.hxx>
static Standard_Boolean IsInSeq (const AIS_SequenceOfInteractive& theSeq,
const Handle(AIS_InteractiveObject)& theItem)
{
Standard_Integer I = theSeq.Length();
while ( I>0 && theSeq.Value(I) != theItem) {
I--;
}
return (I>0);
}
static Standard_Integer RangeInSeq (const AIS_SequenceOfInteractive& theSeq ,
const Handle(AIS_InteractiveObject)& theItem)
{
Standard_Integer I = theSeq.Length();
while ( I>0 && theSeq.Value(I) != theItem) {
I--;
}
return I;
}
//=======================================================================
//function : AIS_MultipleConnectedInteractive
//purpose :
//=======================================================================
AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive
(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
AIS_InteractiveObject(aTypeOfPresentation3d)
{
SetHilightMode(0);
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const
{return AIS_KOI_Object;}
//=======================================================================
//function : Signature
//purpose :
//=======================================================================
Standard_Integer AIS_MultipleConnectedInteractive::Signature() const
{return 1;}
//=======================================================================
//function : Connect
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::Connect(const Handle(AIS_InteractiveObject)& anotherIObj)
{
if (!IsInSeq (myReferences, anotherIObj)) {
myReferences.Append(anotherIObj);
}
}
//=======================================================================
//function : HasConnection
//purpose :
//=======================================================================
Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
{
return (!myReferences.Length()==0);
}
//=======================================================================
//function : Disconnect
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj)
{
Standard_Integer I = RangeInSeq (myReferences, anotherIObj);
if (I != 0) {
myReferences.Remove(I);
}
}
//=======================================================================
//function : DisconnectAll
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::DisconnectAll ()
{
/* for(Standard_Integer i =1;i<=myPresentations.Length();i++)
{
Handle(PrsMgr_Presentation3d) P = Handle(PrsMgr_Presentation3d)::DownCast(myPresentations(i).Presentation());
if(!P.IsNull()) {
P->Presentation()->DisconnectAll(Graphic3d_TOC_DESCENDANT);
}
}*/
myPreviousReferences = myReferences; // pour garder les poignees au chaud!!!!
myReferences.Clear();
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::Compute
(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer aMode)
{
//cout<<"AIS_MultipleConnectedInteractive::Compute"<<endl;
aPresentation->Clear(Standard_False);
aPresentation->RemoveAll();
if(HasConnection()) {
for (Standard_Integer I=1 ; I<= myReferences.Length(); I++) {
const Handle (AIS_InteractiveObject)& aReference = myReferences.Value (I);
aPresentationManager->Connect( this, aReference, aMode, aMode);
if(aPresentationManager->Presentation(aReference,aMode)->MustBeUpdated())
aPresentationManager->Update(aReference,aMode);
}
}
aPresentation->ReCompute();
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector,
const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d,
const Handle_Graphic2d_GraphicObject& aGraphicObject,
const int anInteger)
{
// Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)");
PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector,
const Handle_Geom_Transformation& aTransformation,
const Handle_Prs3d_Presentation& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSel*/,
const Standard_Integer /*aMode*/)
{
}

View File

@@ -0,0 +1,13 @@
// File: AIS_MultipleConnectedInteractive.lxx
// Created: Wed Apr 23 14:34:14 1997
// Author: Guest Design
// <g_design>
//=======================================================================
//function : ConnectedTo
//purpose :
//=======================================================================
inline const AIS_SequenceOfInteractive& AIS_MultipleConnectedInteractive::ConnectedTo() const
{
return myReferences;
}

View File

@@ -0,0 +1,111 @@
-- File: AIS_MultipleConnectedShape.cdl
-- Created: Tue Apr 22 17:40:03 1997
-- Author: Guest Design
-- <g_design@hankox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class MultipleConnectedShape from AIS inherits MultipleConnectedInteractive from AIS
---Purpose: Constructs an Interactive Object connected to a list of
-- Interactive Objects having a Shape. These include
-- AIS_Shape, and AIS_ConnectedShape.
-- Presentation of Hidden parts is calculated automatically.
-- You define the Interactive Object by gathering
-- together several other object presentations as in
-- AIS_MultipleConnectedInteractive.
uses
PresentationManager3d from PrsMgr,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Shape from TopoDS,
Projector from Prs3d,
Presentation from Prs3d,
Selection from SelectMgr,
Integer from Standard,
Transformation from Geom,
KindOfInteractive from AIS
raises
NotImplemented from Standard
is
Create (aShape : Shape from TopoDS)
returns mutable MultipleConnectedShape from AIS;
---Purpose: Initializes the shape aShape, a multiple connected
-- Interactive Object grouping different
-- projector-dependent representations of an entity.
Type(me) returns KindOfInteractive from AIS
is redefined virtual;
Signature(me) returns Integer from Standard
is redefined virtual;
AcceptShapeDecomposition(me)
returns Boolean from Standard is redefined virtual;
---Purpose: Returns true is shape decomposition is accepted.
Set(me:mutable;ashap : Shape from TopoDS) is static;
---Purpose: Constructs the reference shape ashap.
---C++: inline
Shape(me) returns Shape from TopoDS ;
---Purpose: Returns the shape which is constructed in Set.
---C++: inline
---C++: return const&
Compute(me:mutable;
aProjector : Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined virtual protected;
Compute(me:mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation: mutable Presentation from Prs3d)
is redefined virtual protected;
ComputeSelection(me:mutable; aSelection :mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined virtual protected;
Compute(me:mutable;
aProjector : Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d;
aShape : Shape from TopoDS)
is private;
Compute(me:mutable;
aPresentationManager : PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard = 0)
---Level: Internal
---Purpose: this method is redefined virtual;
-- when the instance is connected to another
-- InteractiveObject,this method doesn't
-- compute anything, but just uses the
-- presentation of this last object, with
-- a transformation if there's one stored.
is redefined virtual private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
---Level: Internal
---Purpose: this method should fill the presentation according to the
-- enumerated mode of the application and to the display parameter
-- of the application.
raises NotImplemented from Standard
is redefined;
fields
myShape : Shape from TopoDS; -- celle qui sert au compute Hidden lines et selection
end MultipleConnectedShape;

View File

@@ -0,0 +1,232 @@
// File: AIS_MultipleConnectedShape.cxx
// Created: Tue Apr 22 17:43:42 1997
// Author: Guest Design
// <g_design>
#include <Standard_NotImplemented.hxx>
#include <AIS_MultipleConnectedShape.ixx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Drawer.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <StdPrs_WFDeflectionShape.hxx>
#include <StdPrs_HLRPolyShape.hxx>
#include <Prs3d_Drawer.hxx>
#include <Aspect_TypeOfDeflection.hxx>
#include <Bnd_Box.hxx>
#include <BRepTools.hxx>
#include <BRepBndLib.hxx>
#include <OSD_Timer.hxx>
#include <StdSelect_BRepSelectionTool.hxx>
#include <StdSelect.hxx>
#include <Precision.hxx>
//=======================================================================
//function : AIS_ConnectedShape
//purpose :
//=======================================================================
AIS_MultipleConnectedShape::AIS_MultipleConnectedShape (const TopoDS_Shape& aShape):
AIS_MultipleConnectedInteractive(PrsMgr_TOP_ProjectorDependant),
myShape(aShape)
{
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
AIS_KindOfInteractive AIS_MultipleConnectedShape::Type() const
{return AIS_KOI_Shape;}
//=======================================================================
//function : Signature
//purpose :
//=======================================================================
Standard_Integer AIS_MultipleConnectedShape::Signature() const
{return 2;}
//=======================================================================
//function : AcceptShapeDecomposition
//purpose :
//=======================================================================
Standard_Boolean AIS_MultipleConnectedShape::AcceptShapeDecomposition() const
{return Standard_True;}
//=======================================================================
//function : Compute Hidden Lines
//purpose :
//=======================================================================
void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation)
{
Compute(aProjector,aPresentation,myShape);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Geom_Transformation)& aTrsf,
const Handle(Prs3d_Presentation)& aPresentation)
{
aPresentation->Clear();
const TopLoc_Location& loc = myShape.Location();
TopoDS_Shape shbis = myShape.Located(TopLoc_Location(aTrsf->Trsf())*loc);
Compute(aProjector,aPresentation,shbis);
}
void AIS_MultipleConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation,
const TopoDS_Shape& SH)
{
//Standard_Boolean recompute = Standard_False;
//Standard_Boolean myFirstCompute = Standard_True;
switch (SH.ShapeType()){
case TopAbs_VERTEX:
case TopAbs_EDGE:
case TopAbs_WIRE:
{
aPresentation->SetDisplayPriority(4);
StdPrs_WFDeflectionShape::Add(aPresentation,SH,myDrawer);
break;
}
default:
{
Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
if (defdrawer->DrawHiddenLine())
{myDrawer->EnableDrawHiddenLine();}
else {myDrawer->DisableDrawHiddenLine();}
Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
// traitement HLRAngle et HLRDeviationCoefficient()
Standard_Real prevangl = myDrawer->HLRAngle();
Standard_Real newangl = defdrawer->HLRAngle();
if (Abs(newangl- prevangl) > Precision::Angular()) {
#ifdef DEB
cout << "AIS_MultipleConnectedShape : compute"<<endl;
cout << "newangl : " << newangl << " # de " << "prevangl : " << prevangl << endl;
#endif
BRepTools::Clean(SH);
}
myDrawer->SetHLRAngle(newangl);
myDrawer->SetHLRDeviationCoefficient(defdrawer->HLRDeviationCoefficient());
StdPrs_HLRPolyShape::Add(aPresentation,SH,myDrawer,aProjector);
defdrawer->SetTypeOfDeflection (prevdef);
}
}
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager3d& /*aPresentationManager3d*/,
const Handle_Prs3d_Presentation& /*aPresentation*/,
const int /*anint*/)
{
Standard_NotImplemented::Raise("AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager3d&, const Handle_Prs3d_Presentation&, const int)");
// AIS_MultipleConnectedInteractive::Compute( aPresentationManager3d , aPresentation , anint ) ; Not accessible
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d,
const Handle_Graphic2d_GraphicObject& aGraphicObject,
const int anInteger)
{
// Standard_NotImplemented::Raise("AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)");
PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_MultipleConnectedShape::ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
{
//cout<<"AIS_MultipleConnectedShape::ComputeSelection"<<endl;
Standard_Real aDeviationAngle = myDrawer->DeviationAngle();
Standard_Real aDeflection = myDrawer->MaximalChordialDeviation();
if (myDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
{
// On calcule la fleche en fonction des min max globaux de la piece:
Bnd_Box aBndBox; //= BoundingBox(); ?
BRepBndLib::Add (myShape, aBndBox);
if (!aBndBox.IsVoid())
{
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
aDeflection = Max (aXmax - aXmin, Max (aYmax - aYmin, aZmax - aZmin)) * myDrawer->DeviationCoefficient();
}
}
switch(aMode){
case 1:
StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_VERTEX, aDeflection, aDeviationAngle);
break;
case 2:
StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_EDGE, aDeflection, aDeviationAngle);
break;
case 3:
StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_WIRE, aDeflection, aDeviationAngle);
break;
case 4:
StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_FACE, aDeflection, aDeviationAngle);
break;
case 5:
StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SHELL, aDeflection, aDeviationAngle);
break;
case 6:
StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SOLID, aDeflection, aDeviationAngle);
break;
case 7:
StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_COMPOUND, aDeflection, aDeviationAngle);
break;
case 8:
StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_COMPSOLID, aDeflection, aDeviationAngle);
break;
default:
StdSelect_BRepSelectionTool::Load(aSelection,this,myShape,TopAbs_SHAPE, aDeflection, aDeviationAngle);
break;
}
// insert the drawer in the BrepOwners for hilight...
StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
}

View File

@@ -0,0 +1,16 @@
// File: AIS_MultipleConnectedShape.lxx
// Created: Tue Apr 22 17:46:40 1997
// Author: Guest Design
// <g_design>
inline void AIS_MultipleConnectedShape::Set(const TopoDS_Shape& ashap)
{
myShape = ashap;
}
inline const TopoDS_Shape&
AIS_MultipleConnectedShape::Shape() const
{
return myShape;
}

View File

@@ -0,0 +1,24 @@
// File: AIS_NDataMapOfTransientIteratorOfListTransient.hxx
// Created: Sun May 04 17:51:26 2003
// Author: Alexander Grigoriev (a-grigoriev@opencascade.com)
#ifndef _AIS_NDataMapOfTransientIteratorOfListTransient_HeaderFile
#define _AIS_NDataMapOfTransientIteratorOfListTransient_HeaderFile
#include <AIS_NListIteratorOfListTransient.hxx>
#include <NCollection_DefineDataMap.hxx>
inline Standard_Boolean IsEqual (const Handle_Standard_Transient& theH1,
const Handle_Standard_Transient& theH2)
{
return (theH1 == theH2);
}
DEFINE_BASECOLLECTION(AIS_BaseCollItListTransient,
AIS_NListIteratorOfListTransient)
DEFINE_DATAMAP (AIS_NDataMapOfTransientIteratorOfListTransient,
AIS_BaseCollItListTransient,
Handle(Standard_Transient),
AIS_NListIteratorOfListTransient)
#endif

View File

@@ -0,0 +1,12 @@
// File: AIS_NListIteratorOfListTransient.hxx
// Created: Sun May 04 18:17:58 2003
// Author: Alexander Grigoriev (a-grigoriev@opencascade.com)
#ifndef _AIS_NListIteratorOfListTransient_HeaderFile
#define _AIS_NListIteratorOfListTransient_HeaderFile
#include <AIS_NListTransient.hxx>
typedef AIS_NListTransient::Iterator AIS_NListIteratorOfListTransient;
#endif

16
src/AIS/AIS_NListTransient.hxx Executable file
View File

@@ -0,0 +1,16 @@
// File: AIS_NListTransient.hxx
// Created: Sun May 04 18:13:54 2003
// Author: Alexander Grigoriev (a-grigoriev@opencascade.com)
#ifndef _AIS_NListTransient_HeaderFile
#define _AIS_NListTransient_HeaderFile
#include <Standard_Transient.hxx>
#include <NCollection_StdBase.hxx>
#include <NCollection_DefineList.hxx>
DEFINE_LIST (AIS_NListTransient,
NCollection_BaseCollTransient,
Handle(Standard_Transient))
#endif

118
src/AIS/AIS_OffsetDimension.cdl Executable file
View File

@@ -0,0 +1,118 @@
-- File: AIS_OffsetDimension.cdl
-- Created: Tue Mar 4 09:33:10 1997
-- Author: Jean-Pierre COMBE
-- <jpr@chariox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class OffsetDimension from AIS inherits Relation from AIS
---Purpose: A framework to display dimensions of offsets.
-- The relation between the offset and the basis shape
-- is indicated. This relation is displayed with arrows and
-- text. The text gives the dsitance between the offset
-- and the basis shape.
uses
Shape from TopoDS,
Presentation from Prs3d,
Projector from Prs3d,
Transformation from Geom,
PresentationManager3d from PrsMgr,
PresentationManager2d from PrsMgr,
Selection from SelectMgr,
GraphicObject from Graphic2d,
Dir from gp,
Pnt from gp,
Trsf from gp,
KindOfDimension from AIS,
ExtendedString from TCollection
is
Create (FistShape, SecondShape : Shape from TopoDS;
aVal : Real from Standard;
aText : ExtendedString from TCollection)
returns mutable OffsetDimension from AIS;
---Purpose: Constructs the offset display object defined by the
-- first shape aFShape, the second shape aSShape, the
-- dimension aVal, and the text aText.
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation : mutable Presentation from Prs3d;
aMode : Integer from Standard= 0)
is redefined private;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
-- Methods from SelectableObject
ComputeSelection(me : mutable;
aSelection : mutable Selection from SelectMgr;
aMode : Integer from Standard)
is redefined private;
KindOfDimension(me)
---Purpose:
-- Indicates that the dimension we are concerned with is an offset.
---C++: inline
returns KindOfDimension from AIS
is redefined;
IsMovable(me)
---C++: inline
---Purpose: Returns true if the offset datum is movable.
returns Boolean from Standard
is redefined;
SetRelativePos (me:mutable; aTrsf: Trsf from gp);
---C++: inline
---Purpose: Sets a transformation aTrsf for presentation and
-- selection to a relative position.
ComputeTwoFacesOffset(me: mutable;
aPresentation : mutable Presentation from Prs3d;
aTrsf : Trsf from gp)
is private;
ComputeTwoAxesOffset(me: mutable;
aPresentation : mutable Presentation from Prs3d;
aTrsf : Trsf from gp)
is private;
ComputeAxeFaceOffset(me: mutable;
aPresentation : mutable Presentation from Prs3d;
aTrsf : Trsf from gp)
is private;
fields
myFAttach : Pnt from gp;
mySAttach : Pnt from gp;
myDirAttach : Dir from gp;
myDirAttach2 : Dir from gp;
myRelativePos : Trsf from gp;
end OffsetDimension;

Some files were not shown because too many files have changed in this diff Show More