0031456: Visualization - move out Dimensions and Relations from package AIS to PrsDims
[occt.git] / src / PrsDim / PrsDim_Relation.hxx
CommitLineData
42cf5bc1 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
787ff240 17#ifndef _PrsDim_Relation_HeaderFile
18#define _PrsDim_Relation_HeaderFile
42cf5bc1 19
87432b82 20#include <AIS_KindOfInteractive.hxx>
42cf5bc1 21#include <AIS_InteractiveObject.hxx>
42cf5bc1 22#include <Aspect_TypeOfLine.hxx>
23#include <Aspect_TypeOfMarker.hxx>
87432b82 24#include <Bnd_Box.hxx>
25#include <DsgPrs_ArrowSide.hxx>
26#include <gp_Pln.hxx>
27#include <gp_Pnt.hxx>
787ff240 28#include <PrsDim_KindOfDimension.hxx>
29#include <PrsDim_KindOfSurface.hxx>
87432b82 30#include <TCollection_ExtendedString.hxx>
31#include <TopoDS_Shape.hxx>
32
33class Geom_Curve;
42cf5bc1 34class Geom_Plane;
35class Geom_Surface;
42cf5bc1 36class TopoDS_Edge;
42cf5bc1 37class TopoDS_Vertex;
38
42cf5bc1 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.
787ff240 48class PrsDim_Relation : public AIS_InteractiveObject
42cf5bc1 49{
787ff240 50 DEFINE_STANDARD_RTTIEXT(PrsDim_Relation, AIS_InteractiveObject)
42cf5bc1 51public:
52
87432b82 53 //! Allows you to provide settings for the color theColor
42cf5bc1 54 //! of the lines representing the relation between the two shapes.
87432b82 55 Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
56
42cf5bc1 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;
87432b82 60
61 virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Relation; }
787ff240 62
42cf5bc1 63 //! Indicates that the type of dimension is unknown.
787ff240 64 virtual PrsDim_KindOfDimension KindOfDimension() const { return PrsDim_KOD_NONE; }
65
42cf5bc1 66 //! Returns true if the interactive object is movable.
787ff240 67 virtual Standard_Boolean IsMovable() const { return Standard_False; }
87432b82 68
69 const TopoDS_Shape& FirstShape() const { return myFShape; }
70
787ff240 71 virtual void SetFirstShape (const TopoDS_Shape& aFShape) { myFShape = aFShape; }
87432b82 72
42cf5bc1 73 //! Returns the second shape.
87432b82 74 const TopoDS_Shape& SecondShape() const { return mySShape; }
75
42cf5bc1 76 //! Allows you to identify the second shape aSShape
77 //! relative to the first.
787ff240 78 virtual void SetSecondShape (const TopoDS_Shape& aSShape) { mySShape = aSShape; }
87432b82 79
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
87 void UnsetBndBox() { myIsSetBndBox = Standard_False; }
88
42cf5bc1 89 //! Returns the plane.
87432b82 90 const Handle(Geom_Plane)& Plane() const { return myPlane; }
42cf5bc1 91
87432b82 92 //! Allows you to set the plane thePlane. This is used to
42cf5bc1 93 //! define relations and dimensions in several daughter classes.
87432b82 94 void SetPlane (const Handle(Geom_Plane)& thePlane) { myPlane = thePlane; }
95
42cf5bc1 96 //! Returns the value of each object in the relation.
87432b82 97 Standard_Real Value() const { return myVal; }
98
99 //! Allows you to provide settings for the value theVal for each object in the relation.
100 void SetValue (const Standard_Real theVal) { myVal = theVal; }
101
42cf5bc1 102 //! Returns the position set using SetPosition.
87432b82 103 const gp_Pnt& Position() const { return myPosition; }
42cf5bc1 104
105 //! Allows you to provide the objects in the relation with
106 //! settings for a non-default position.
87432b82 107 void SetPosition (const gp_Pnt& thePosition)
108 {
109 myPosition = thePosition;
110 myAutomaticPosition = Standard_False;
111 }
112
42cf5bc1 113 //! Returns settings for text aspect.
87432b82 114 const TCollection_ExtendedString& Text() const { return myText; }
115
116 //! Allows you to provide the settings theText for text aspect.
117 void SetText (const TCollection_ExtendedString& theText) { myText = theText; }
42cf5bc1 118
119 //! Returns the value for the size of the arrow identifying
120 //! the relation between the two shapes.
87432b82 121 Standard_Real ArrowSize() const { return myArrowSize; }
42cf5bc1 122
123 //! Allows you to provide settings for the size of the
87432b82 124 //! arrow theArrowSize identifying the relation between the two shapes.
125 void SetArrowSize (const Standard_Real theArrowSize)
126 {
127 myArrowSize = theArrowSize;
128 myArrowSizeIsDefined = Standard_True;
129 }
42cf5bc1 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
87432b82 141 DsgPrs_ArrowSide SymbolPrs() const { return mySymbolPrs; }
42cf5bc1 142
143 //! Allows you to provide settings for the symbol presentation.
87432b82 144 void SetSymbolPrs (const DsgPrs_ArrowSide theSymbolPrs) { mySymbolPrs = theSymbolPrs; }
42cf5bc1 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.
87432b82 152 void SetExtShape (const Standard_Integer theIndex) { myExtShape = theIndex; }
42cf5bc1 153
154 //! Returns the status index of the extension shape.
87432b82 155 Standard_Integer ExtShape() const { return myExtShape; }
42cf5bc1 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)
787ff240 171 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
42cf5bc1 172
87432b82 173 void SetAutomaticPosition (const Standard_Boolean theStatus) { myAutomaticPosition = theStatus; }
42cf5bc1 174
87432b82 175 Standard_Boolean AutomaticPosition() const { return myAutomaticPosition; }
42cf5bc1 176
177protected:
178
787ff240 179 Standard_EXPORT PrsDim_Relation (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
87432b82 180
42cf5bc1 181 //! Calculates the presentation aPres of the 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;
87432b82 187
42cf5bc1 188 //! Calculates the presentation aPres of the 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
87432b82 194protected:
195
42cf5bc1 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;
787ff240 210 PrsDim_KindOfSurface myFirstSurfType;
211 PrsDim_KindOfSurface mySecondSurfType;
42cf5bc1 212 Standard_Real myFirstOffset;
213 Standard_Real mySecondOffset;
214 Bnd_Box myBndBox;
215 Standard_Boolean myIsSetBndBox;
216 Standard_Boolean myArrowSizeIsDefined;
217
42cf5bc1 218};
219
787ff240 220DEFINE_STANDARD_HANDLE(PrsDim_Relation, AIS_InteractiveObject)
42cf5bc1 221
222#endif // _AIS_Relation_HeaderFile