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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 #ifndef _PrsDim_Relation_HeaderFile
18 #define _PrsDim_Relation_HeaderFile
19 
20 #include <AIS_KindOfInteractive.hxx>
21 #include <AIS_InteractiveObject.hxx>
22 #include <Aspect_TypeOfLine.hxx>
23 #include <Aspect_TypeOfMarker.hxx>
24 #include <Bnd_Box.hxx>
25 #include <DsgPrs_ArrowSide.hxx>
26 #include <gp_Pln.hxx>
27 #include <gp_Pnt.hxx>
28 #include <PrsDim_KindOfDimension.hxx>
29 #include <PrsDim_KindOfSurface.hxx>
30 #include <TCollection_ExtendedString.hxx>
31 #include <TopoDS_Shape.hxx>
32 
33 class Geom_Curve;
34 class Geom_Plane;
35 class Geom_Surface;
36 class TopoDS_Edge;
37 class TopoDS_Vertex;
38 
39 //! One of the four types of interactive object in
40 //! AIS,comprising dimensions and constraints. Serves
41 //! as the abstract class for the seven relation classes as
42 //! well as the seven dimension classes.
43 //! The statuses available for relations between shapes are as follows:
44 //! -   0 - there is no connection to a shape;
45 //! -   1 - there is a connection to the first shape;
46 //! -   2 - there is a connection to the second shape.
47 //! The connection takes the form of an edge between the two shapes.
48 class PrsDim_Relation : public AIS_InteractiveObject
49 {
50   DEFINE_STANDARD_RTTIEXT(PrsDim_Relation, AIS_InteractiveObject)
51 public:
52 
53   //! Allows you to provide settings for the color theColor
54   //! of the lines representing the relation between the two shapes.
55   Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
56 
57   //! Allows you to remove settings for the color of the
58   //! lines representing the relation between the two shapes.
59   Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
60 
Type() const61   virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Relation; }
62 
63   //! Indicates that the type of dimension is unknown.
KindOfDimension() const64   virtual PrsDim_KindOfDimension KindOfDimension() const { return PrsDim_KOD_NONE; }
65 
66   //! Returns true if the interactive object is movable.
IsMovable() const67   virtual Standard_Boolean IsMovable() const { return Standard_False; }
68 
FirstShape() const69   const TopoDS_Shape& FirstShape() const { return myFShape; }
70 
SetFirstShape(const TopoDS_Shape & aFShape)71   virtual void SetFirstShape (const TopoDS_Shape& aFShape) { myFShape = aFShape; }
72 
73   //! Returns the second shape.
SecondShape() const74   const TopoDS_Shape& SecondShape() const { return mySShape; }
75 
76   //! Allows you to identify the second shape aSShape
77   //! relative to the first.
SetSecondShape(const TopoDS_Shape & aSShape)78   virtual void SetSecondShape (const TopoDS_Shape& aSShape) { mySShape = aSShape; }
79 
SetBndBox(const Standard_Real theXmin,const Standard_Real theYmin,const Standard_Real theZmin,const Standard_Real theXmax,const Standard_Real theYmax,const Standard_Real theZmax)80   void SetBndBox (const Standard_Real theXmin, const Standard_Real theYmin, const Standard_Real theZmin,
81                   const Standard_Real theXmax, const Standard_Real theYmax, const Standard_Real theZmax)
82   {
83     myBndBox.Update (theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
84     myIsSetBndBox = Standard_True;
85   }
86 
UnsetBndBox()87   void UnsetBndBox() { myIsSetBndBox = Standard_False; }
88 
89   //! Returns the plane.
Handle(Geom_Plane)90   const Handle(Geom_Plane)& Plane() const { return myPlane; }
91 
92   //! Allows you to set the plane thePlane. This is used to
93   //! define relations and dimensions in several daughter classes.
SetPlane(const Handle (Geom_Plane)& thePlane)94   void SetPlane (const Handle(Geom_Plane)& thePlane) { myPlane = thePlane; }
95 
96   //! Returns the value of each object in the relation.
Value() const97   Standard_Real Value() const { return myVal; }
98 
99   //! Allows you to provide settings for the value theVal for each object in the relation.
SetValue(const Standard_Real theVal)100   void SetValue (const Standard_Real theVal) { myVal = theVal; }
101 
102   //! Returns the position set using SetPosition.
Position() const103   const gp_Pnt& Position() const { return myPosition; }
104 
105   //! Allows you to provide the objects in the relation with
106   //! settings for a non-default position.
SetPosition(const gp_Pnt & thePosition)107   void SetPosition (const gp_Pnt& thePosition)
108   {
109     myPosition = thePosition;
110     myAutomaticPosition = Standard_False;
111   }
112 
113   //! Returns settings for text aspect.
Text() const114   const TCollection_ExtendedString& Text() const { return myText; }
115 
116   //! Allows you to provide the settings theText for text aspect.
SetText(const TCollection_ExtendedString & theText)117   void SetText (const TCollection_ExtendedString& theText) { myText = theText; }
118 
119   //! Returns the value for the size of the arrow identifying
120   //! the relation between the two shapes.
ArrowSize() const121   Standard_Real ArrowSize() const { return myArrowSize; }
122 
123   //! Allows you to provide settings for the size of the
124   //! arrow theArrowSize identifying the relation between the two shapes.
SetArrowSize(const Standard_Real theArrowSize)125   void SetArrowSize (const Standard_Real theArrowSize)
126   {
127     myArrowSize = theArrowSize;
128     myArrowSizeIsDefined = Standard_True;
129   }
130 
131   //! Returns the value of the symbol presentation. This will be one of:
132   //! -   AS_NONE - none
133   //! -   AS_FIRSTAR - first arrow
134   //! -   AS_LASTAR - last arrow
135   //! -   AS_BOTHAR - both arrows
136   //! -   AS_FIRSTPT - first point
137   //! -   AS_LASTPT - last point
138   //! -   AS_BOTHPT - both points
139   //! -   AS_FIRSTAR_LASTPT - first arrow, last point
140   //! -   AS_FIRSTPT_LASTAR - first point, last arrow
SymbolPrs() const141   DsgPrs_ArrowSide SymbolPrs() const { return mySymbolPrs; }
142 
143   //! Allows you to provide settings for the symbol presentation.
SetSymbolPrs(const DsgPrs_ArrowSide theSymbolPrs)144   void SetSymbolPrs (const DsgPrs_ArrowSide theSymbolPrs) { mySymbolPrs = theSymbolPrs; }
145 
146   //! Allows you to set the status of the extension shape by
147   //! the index aIndex.
148   //! The status will be one of the following:
149   //! -   0 - there is no connection to a shape;
150   //! -   1 - there is a connection to the first shape;
151   //! -   2 - there is a connection to the second shape.
SetExtShape(const Standard_Integer theIndex)152   void SetExtShape (const Standard_Integer theIndex) { myExtShape = theIndex; }
153 
154   //! Returns the status index of the extension shape.
ExtShape() const155   Standard_Integer ExtShape() const { return myExtShape; }
156 
157   //! Returns true if the display mode aMode is accepted
158   //! for the Interactive Objects in the relation.
159   //! ComputeProjPresentation(me;
160   //! aPres    : Presentation from Prs3d;
161   //! Curve1   : Curve                from Geom;
162   //! Curve2   : Curve                from Geom;
163   //! FirstP1  : Pnt                  from gp;
164   //! LastP1   : Pnt                  from gp;
165   //! FirstP2  : Pnt                  from gp;
166   //! LastP2   : Pnt                  from gp;
167   //! aColor   : NameOfColor          from Quantity = Quantity_NOC_PURPLE;
168   //! aWidth   : Real                 from Standard = 2;
169   //! aProjTOL : TypeOfLine           from Aspect   = Aspect_TOL_DASH;
170   //! aCallTOL : TypeOfLine           from Aspect   = Aspect_TOL_DOT)
AcceptDisplayMode(const Standard_Integer theMode) const171   virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
172 
SetAutomaticPosition(const Standard_Boolean theStatus)173   void SetAutomaticPosition (const Standard_Boolean theStatus) { myAutomaticPosition = theStatus; }
174 
AutomaticPosition() const175   Standard_Boolean AutomaticPosition() const { return myAutomaticPosition; }
176 
177 protected:
178 
179   Standard_EXPORT PrsDim_Relation (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
180 
181   //! Calculates the presentation aPres of the edge
182   //! anEdge and the curve it defines, ProjCurve. The later
183   //! is also specified by the first point FirstP and the last point LastP.
184   //! The presentation includes settings for color aColor,
185   //! type - aProjTOL and aCallTOL -   and width of line, aWidth.
186   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;
187 
188   //! Calculates the presentation aPres of the vertex
189   //! aVertex and the point it defines, ProjPoint.
190   //! The presentation includes settings for color aColor,
191   //! type - aProjTOM and aCallTOL -   and width of line, aWidth.
192   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;
193 
194 protected:
195 
196   TopoDS_Shape myFShape;
197   TopoDS_Shape mySShape;
198   Handle(Geom_Plane) myPlane;
199   Standard_Real myVal;
200   gp_Pnt myPosition;
201   TCollection_ExtendedString myText;
202   Standard_Real myArrowSize;
203   Standard_Boolean myAutomaticPosition;
204   DsgPrs_ArrowSide mySymbolPrs;
205   Standard_Integer myExtShape;
206   gp_Pln myFirstPlane;
207   gp_Pln mySecondPlane;
208   Handle(Geom_Surface) myFirstBasisSurf;
209   Handle(Geom_Surface) mySecondBasisSurf;
210   PrsDim_KindOfSurface myFirstSurfType;
211   PrsDim_KindOfSurface mySecondSurfType;
212   Standard_Real myFirstOffset;
213   Standard_Real mySecondOffset;
214   Bnd_Box myBndBox;
215   Standard_Boolean myIsSetBndBox;
216   Standard_Boolean myArrowSizeIsDefined;
217 
218 };
219 
220 DEFINE_STANDARD_HANDLE(PrsDim_Relation, AIS_InteractiveObject)
221 
222 #endif // _AIS_Relation_HeaderFile
223