1 // Created on: 1997-02-27
2 // Created by: Odile Olivier
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _AIS_Relation_HeaderFile
18 #define _AIS_Relation_HeaderFile
20 #include <AIS_KindOfDimension.hxx>
21 #include <AIS_KindOfInteractive.hxx>
22 #include <AIS_KindOfSurface.hxx>
23 #include <AIS_InteractiveObject.hxx>
24 #include <Aspect_TypeOfLine.hxx>
25 #include <Aspect_TypeOfMarker.hxx>
26 #include <Bnd_Box.hxx>
27 #include <DsgPrs_ArrowSide.hxx>
30 #include <PrsMgr_TypeOfPresentation3d.hxx>
31 #include <TCollection_ExtendedString.hxx>
32 #include <TopoDS_Shape.hxx>
40 //! One of the four types of interactive object in
41 //! AIS,comprising dimensions and constraints. Serves
42 //! as the abstract class for the seven relation classes as
43 //! well as the seven dimension classes.
44 //! The statuses available for relations between shapes are as follows:
45 //! - 0 - there is no connection to a shape;
46 //! - 1 - there is a connection to the first shape;
47 //! - 2 - there is a connection to the second shape.
48 //! The connection takes the form of an edge between the two shapes.
49 class AIS_Relation : public AIS_InteractiveObject
51 DEFINE_STANDARD_RTTIEXT(AIS_Relation, AIS_InteractiveObject)
54 //! Allows you to provide settings for the color theColor
55 //! of the lines representing the relation between the two shapes.
56 Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
58 //! Allows you to remove settings for the color of the
59 //! lines representing the relation between the two shapes.
60 Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
62 virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Relation; }
64 //! Indicates that the type of dimension is unknown.
65 Standard_EXPORT virtual AIS_KindOfDimension KindOfDimension() const;
67 //! Returns true if the interactive object is movable.
68 Standard_EXPORT virtual Standard_Boolean IsMovable() const;
70 const TopoDS_Shape& FirstShape() const { return myFShape; }
72 Standard_EXPORT virtual void SetFirstShape (const TopoDS_Shape& aFShape);
74 //! Returns the second shape.
75 const TopoDS_Shape& SecondShape() const { return mySShape; }
77 //! Allows you to identify the second shape aSShape
78 //! relative to the first.
79 Standard_EXPORT virtual void SetSecondShape (const TopoDS_Shape& aSShape);
81 void SetBndBox (const Standard_Real theXmin, const Standard_Real theYmin, const Standard_Real theZmin,
82 const Standard_Real theXmax, const Standard_Real theYmax, const Standard_Real theZmax)
84 myBndBox.Update (theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
85 myIsSetBndBox = Standard_True;
88 void UnsetBndBox() { myIsSetBndBox = Standard_False; }
90 //! Returns the plane.
91 const Handle(Geom_Plane)& Plane() const { return myPlane; }
93 //! Allows you to set the plane thePlane. This is used to
94 //! define relations and dimensions in several daughter classes.
95 void SetPlane (const Handle(Geom_Plane)& thePlane) { myPlane = thePlane; }
97 //! Returns the value of each object in the relation.
98 Standard_Real Value() const { return myVal; }
100 //! Allows you to provide settings for the value theVal for each object in the relation.
101 void SetValue (const Standard_Real theVal) { myVal = theVal; }
103 //! Returns the position set using SetPosition.
104 const gp_Pnt& Position() const { return myPosition; }
106 //! Allows you to provide the objects in the relation with
107 //! settings for a non-default position.
108 void SetPosition (const gp_Pnt& thePosition)
110 myPosition = thePosition;
111 myAutomaticPosition = Standard_False;
114 //! Returns settings for text aspect.
115 const TCollection_ExtendedString& Text() const { return myText; }
117 //! Allows you to provide the settings theText for text aspect.
118 void SetText (const TCollection_ExtendedString& theText) { myText = theText; }
120 //! Returns the value for the size of the arrow identifying
121 //! the relation between the two shapes.
122 Standard_Real ArrowSize() const { return myArrowSize; }
124 //! Allows you to provide settings for the size of the
125 //! arrow theArrowSize identifying the relation between the two shapes.
126 void SetArrowSize (const Standard_Real theArrowSize)
128 myArrowSize = theArrowSize;
129 myArrowSizeIsDefined = Standard_True;
132 //! Returns the value of the symbol presentation. This will be one of:
134 //! - AS_FIRSTAR - first arrow
135 //! - AS_LASTAR - last arrow
136 //! - AS_BOTHAR - both arrows
137 //! - AS_FIRSTPT - first point
138 //! - AS_LASTPT - last point
139 //! - AS_BOTHPT - both points
140 //! - AS_FIRSTAR_LASTPT - first arrow, last point
141 //! - AS_FIRSTPT_LASTAR - first point, last arrow
142 DsgPrs_ArrowSide SymbolPrs() const { return mySymbolPrs; }
144 //! Allows you to provide settings for the symbol presentation.
145 void SetSymbolPrs (const DsgPrs_ArrowSide theSymbolPrs) { mySymbolPrs = theSymbolPrs; }
147 //! Allows you to set the status of the extension shape by
148 //! the index aIndex.
149 //! The status will be one of the following:
150 //! - 0 - there is no connection to a shape;
151 //! - 1 - there is a connection to the first shape;
152 //! - 2 - there is a connection to the second shape.
153 void SetExtShape (const Standard_Integer theIndex) { myExtShape = theIndex; }
155 //! Returns the status index of the extension shape.
156 Standard_Integer ExtShape() const { return myExtShape; }
158 //! Returns true if the display mode aMode is accepted
159 //! for the Interactive Objects in the relation.
160 //! ComputeProjPresentation(me;
161 //! aPres : Presentation from Prs3d;
162 //! Curve1 : Curve from Geom;
163 //! Curve2 : Curve from Geom;
164 //! FirstP1 : Pnt from gp;
165 //! LastP1 : Pnt from gp;
166 //! FirstP2 : Pnt from gp;
167 //! LastP2 : Pnt from gp;
168 //! aColor : NameOfColor from Quantity = Quantity_NOC_PURPLE;
169 //! aWidth : Real from Standard = 2;
170 //! aProjTOL : TypeOfLine from Aspect = Aspect_TOL_DASH;
171 //! aCallTOL : TypeOfLine from Aspect = Aspect_TOL_DOT)
172 Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
174 void SetAutomaticPosition (const Standard_Boolean theStatus) { myAutomaticPosition = theStatus; }
176 Standard_Boolean AutomaticPosition() const { return myAutomaticPosition; }
180 Standard_EXPORT AIS_Relation(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
182 //! Calculates the presentation aPres of the the edge
183 //! anEdge and the curve it defines, ProjCurve. The later
184 //! is also specified by the first point FirstP and the last point LastP.
185 //! The presentation includes settings for color aColor,
186 //! type - aProjTOL and aCallTOL - and width of line, aWidth.
187 Standard_EXPORT void ComputeProjEdgePresentation (const Handle(Prs3d_Presentation)& aPres, const TopoDS_Edge& anEdge, const Handle(Geom_Curve)& ProjCurve, const gp_Pnt& FirstP, const gp_Pnt& LastP, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfLine aProjTOL = Aspect_TOL_DASH, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT) const;
189 //! Calculates the presentation aPres of the the vertex
190 //! aVertex and the point it defines, ProjPoint.
191 //! The presentation includes settings for color aColor,
192 //! type - aProjTOM and aCallTOL - and width of line, aWidth.
193 Standard_EXPORT void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT) const;
197 TopoDS_Shape myFShape;
198 TopoDS_Shape mySShape;
199 Handle(Geom_Plane) myPlane;
202 TCollection_ExtendedString myText;
203 Standard_Real myArrowSize;
204 Standard_Boolean myAutomaticPosition;
205 DsgPrs_ArrowSide mySymbolPrs;
206 Standard_Integer myExtShape;
208 gp_Pln mySecondPlane;
209 Handle(Geom_Surface) myFirstBasisSurf;
210 Handle(Geom_Surface) mySecondBasisSurf;
211 AIS_KindOfSurface myFirstSurfType;
212 AIS_KindOfSurface mySecondSurfType;
213 Standard_Real myFirstOffset;
214 Standard_Real mySecondOffset;
216 Standard_Boolean myIsSetBndBox;
217 Standard_Boolean myArrowSizeIsDefined;
221 DEFINE_STANDARD_HANDLE(AIS_Relation, AIS_InteractiveObject)
223 #endif // _AIS_Relation_HeaderFile