Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:21:04

0001 // Created on: 1997-02-27
0002 // Created by: Odile Olivier
0003 // Copyright (c) 1997-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _PrsDim_Relation_HeaderFile
0018 #define _PrsDim_Relation_HeaderFile
0019 
0020 #include <AIS_InteractiveObject.hxx>
0021 #include <Aspect_TypeOfLine.hxx>
0022 #include <Aspect_TypeOfMarker.hxx>
0023 #include <Bnd_Box.hxx>
0024 #include <DsgPrs_ArrowSide.hxx>
0025 #include <gp_Pln.hxx>
0026 #include <gp_Pnt.hxx>
0027 #include <PrsDim_KindOfDimension.hxx>
0028 #include <PrsDim_KindOfSurface.hxx>
0029 #include <TCollection_ExtendedString.hxx>
0030 #include <TopoDS_Shape.hxx>
0031 
0032 class Geom_Curve;
0033 class Geom_Plane;
0034 class Geom_Surface;
0035 class TopoDS_Edge;
0036 class TopoDS_Vertex;
0037 
0038 //! One of the four types of interactive object in
0039 //! AIS,comprising dimensions and constraints. Serves
0040 //! as the abstract class for the seven relation classes as
0041 //! well as the seven dimension classes.
0042 //! The statuses available for relations between shapes are as follows:
0043 //! -   0 - there is no connection to a shape;
0044 //! -   1 - there is a connection to the first shape;
0045 //! -   2 - there is a connection to the second shape.
0046 //! The connection takes the form of an edge between the two shapes.
0047 class PrsDim_Relation : public AIS_InteractiveObject
0048 {
0049   DEFINE_STANDARD_RTTIEXT(PrsDim_Relation, AIS_InteractiveObject)
0050 public:
0051   //! Allows you to provide settings for the color theColor
0052   //! of the lines representing the relation between the two shapes.
0053   Standard_EXPORT void SetColor(const Quantity_Color& theColor) override;
0054 
0055   //! Allows you to remove settings for the color of the
0056   //! lines representing the relation between the two shapes.
0057   Standard_EXPORT void UnsetColor() override;
0058 
0059   AIS_KindOfInteractive Type() const override { return AIS_KindOfInteractive_Relation; }
0060 
0061   //! Indicates that the type of dimension is unknown.
0062   virtual PrsDim_KindOfDimension KindOfDimension() const { return PrsDim_KOD_NONE; }
0063 
0064   //! Returns true if the interactive object is movable.
0065   virtual bool IsMovable() const { return false; }
0066 
0067   const TopoDS_Shape& FirstShape() const { return myFShape; }
0068 
0069   virtual void SetFirstShape(const TopoDS_Shape& aFShape) { myFShape = aFShape; }
0070 
0071   //! Returns the second shape.
0072   const TopoDS_Shape& SecondShape() const { return mySShape; }
0073 
0074   //! Allows you to identify the second shape aSShape
0075   //! relative to the first.
0076   virtual void SetSecondShape(const TopoDS_Shape& aSShape) { mySShape = aSShape; }
0077 
0078   void SetBndBox(const double theXmin,
0079                  const double theYmin,
0080                  const double theZmin,
0081                  const double theXmax,
0082                  const double theYmax,
0083                  const double theZmax)
0084   {
0085     myBndBox.Update(theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
0086     myIsSetBndBox = true;
0087   }
0088 
0089   void UnsetBndBox() { myIsSetBndBox = false; }
0090 
0091   //! Returns the plane.
0092   const occ::handle<Geom_Plane>& Plane() const { return myPlane; }
0093 
0094   //! Allows you to set the plane thePlane. This is used to
0095   //! define relations and dimensions in several daughter classes.
0096   void SetPlane(const occ::handle<Geom_Plane>& thePlane) { myPlane = thePlane; }
0097 
0098   //! Returns the value of each object in the relation.
0099   double Value() const { return myVal; }
0100 
0101   //! Allows you to provide settings for the value theVal for each object in the relation.
0102   void SetValue(const double theVal) { myVal = theVal; }
0103 
0104   //! Returns the position set using SetPosition.
0105   const gp_Pnt& Position() const { return myPosition; }
0106 
0107   //! Allows you to provide the objects in the relation with
0108   //! settings for a non-default position.
0109   void SetPosition(const gp_Pnt& thePosition)
0110   {
0111     myPosition          = thePosition;
0112     myAutomaticPosition = false;
0113   }
0114 
0115   //! Returns settings for text aspect.
0116   const TCollection_ExtendedString& Text() const { return myText; }
0117 
0118   //! Allows you to provide the settings theText for text aspect.
0119   void SetText(const TCollection_ExtendedString& theText) { myText = theText; }
0120 
0121   //! Returns the value for the size of the arrow identifying
0122   //! the relation between the two shapes.
0123   double ArrowSize() const { return myArrowSize; }
0124 
0125   //! Allows you to provide settings for the size of the
0126   //! arrow theArrowSize identifying the relation between the two shapes.
0127   void SetArrowSize(const double theArrowSize)
0128   {
0129     myArrowSize          = theArrowSize;
0130     myArrowSizeIsDefined = true;
0131   }
0132 
0133   //! Returns the value of the symbol presentation. This will be one of:
0134   //! -   AS_NONE - none
0135   //! -   AS_FIRSTAR - first arrow
0136   //! -   AS_LASTAR - last arrow
0137   //! -   AS_BOTHAR - both arrows
0138   //! -   AS_FIRSTPT - first point
0139   //! -   AS_LASTPT - last point
0140   //! -   AS_BOTHPT - both points
0141   //! -   AS_FIRSTAR_LASTPT - first arrow, last point
0142   //! -   AS_FIRSTPT_LASTAR - first point, last arrow
0143   DsgPrs_ArrowSide SymbolPrs() const { return mySymbolPrs; }
0144 
0145   //! Allows you to provide settings for the symbol presentation.
0146   void SetSymbolPrs(const DsgPrs_ArrowSide theSymbolPrs) { mySymbolPrs = theSymbolPrs; }
0147 
0148   //! Allows you to set the status of the extension shape by
0149   //! the index aIndex.
0150   //! The status will be one of the following:
0151   //! -   0 - there is no connection to a shape;
0152   //! -   1 - there is a connection to the first shape;
0153   //! -   2 - there is a connection to the second shape.
0154   void SetExtShape(const int theIndex) { myExtShape = theIndex; }
0155 
0156   //! Returns the status index of the extension shape.
0157   int ExtShape() const { return myExtShape; }
0158 
0159   //! Returns true if the display mode aMode is accepted
0160   //! for the Interactive Objects in the relation.
0161   //! ComputeProjPresentation(me;
0162   //! aPres    : Presentation from Prs3d;
0163   //! Curve1   : Curve                from Geom;
0164   //! Curve2   : Curve                from Geom;
0165   //! FirstP1  : Pnt                  from gp;
0166   //! LastP1   : Pnt                  from gp;
0167   //! FirstP2  : Pnt                  from gp;
0168   //! LastP2   : Pnt                  from gp;
0169   //! aColor   : NameOfColor          from Quantity = Quantity_NOC_PURPLE;
0170   //! aWidth   : Real                 from Standard = 2;
0171   //! aProjTOL : TypeOfLine           from Aspect   = Aspect_TOL_DASH;
0172   //! aCallTOL : TypeOfLine           from Aspect   = Aspect_TOL_DOT)
0173   bool AcceptDisplayMode(const int theMode) const override { return theMode == 0; }
0174 
0175   void SetAutomaticPosition(const bool theStatus) { myAutomaticPosition = theStatus; }
0176 
0177   bool AutomaticPosition() const { return myAutomaticPosition; }
0178 
0179 protected:
0180   Standard_EXPORT PrsDim_Relation(
0181     const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
0182 
0183   //! Calculates the presentation aPres of the edge
0184   //! anEdge and the curve it defines, ProjCurve. The later
0185   //! is also specified by the first point FirstP and the last point LastP.
0186   //! The presentation includes settings for color aColor,
0187   //! type - aProjTOL and aCallTOL -   and width of line, aWidth.
0188   Standard_EXPORT void ComputeProjEdgePresentation(
0189     const occ::handle<Prs3d_Presentation>& aPres,
0190     const TopoDS_Edge&                     anEdge,
0191     const occ::handle<Geom_Curve>&         ProjCurve,
0192     const gp_Pnt&                          FirstP,
0193     const gp_Pnt&                          LastP,
0194     const Quantity_NameOfColor             aColor   = Quantity_NOC_PURPLE,
0195     const double                           aWidth   = 2,
0196     const Aspect_TypeOfLine                aProjTOL = Aspect_TOL_DASH,
0197     const Aspect_TypeOfLine                aCallTOL = Aspect_TOL_DOT) const;
0198 
0199   //! Calculates the presentation aPres of the vertex
0200   //! aVertex and the point it defines, ProjPoint.
0201   //! The presentation includes settings for color aColor,
0202   //! type - aProjTOM and aCallTOL -   and width of line, aWidth.
0203   Standard_EXPORT void ComputeProjVertexPresentation(
0204     const occ::handle<Prs3d_Presentation>& aPres,
0205     const TopoDS_Vertex&                   aVertex,
0206     const gp_Pnt&                          ProjPoint,
0207     const Quantity_NameOfColor             aColor   = Quantity_NOC_PURPLE,
0208     const double                           aWidth   = 2,
0209     const Aspect_TypeOfMarker              aProjTOM = Aspect_TOM_PLUS,
0210     const Aspect_TypeOfLine                aCallTOL = Aspect_TOL_DOT) const;
0211 
0212 protected:
0213   TopoDS_Shape               myFShape;
0214   TopoDS_Shape               mySShape;
0215   occ::handle<Geom_Plane>    myPlane;
0216   double                     myVal;
0217   gp_Pnt                     myPosition;
0218   TCollection_ExtendedString myText;
0219   double                     myArrowSize;
0220   bool                       myAutomaticPosition;
0221   DsgPrs_ArrowSide           mySymbolPrs;
0222   int                        myExtShape;
0223   gp_Pln                     myFirstPlane;
0224   gp_Pln                     mySecondPlane;
0225   occ::handle<Geom_Surface>  myFirstBasisSurf;
0226   occ::handle<Geom_Surface>  mySecondBasisSurf;
0227   PrsDim_KindOfSurface       myFirstSurfType;
0228   PrsDim_KindOfSurface       mySecondSurfType;
0229   double                     myFirstOffset;
0230   double                     mySecondOffset;
0231   Bnd_Box                    myBndBox;
0232   bool                       myIsSetBndBox;
0233   bool                       myArrowSizeIsDefined;
0234 };
0235 
0236 #endif // _AIS_Relation_HeaderFile