1 // Created on: 1995-08-09 2 // Created by: Arnaud BOUZY/Odile Olivier 3 // Copyright (c) 1995-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 _AIS_Axis_HeaderFile 18 #define _AIS_Axis_HeaderFile 19 20 #include <AIS_InteractiveObject.hxx> 21 #include <AIS_TypeOfAxis.hxx> 22 #include <gp_Dir.hxx> 23 #include <gp_Pnt.hxx> 24 #include <SelectMgr_Selection.hxx> 25 26 class Geom_Line; 27 class Geom_Axis1Placement; 28 class Geom_Axis2Placement; 29 class Prs3d_LineAspect; 30 31 //! Locates the x, y and z axes in an Interactive Object. 32 //! These are used to orient it correctly in presentations 33 //! from different viewpoints, or to construct a revolved 34 //! shape, for example, from one of the axes. Conversely, 35 //! an axis can be created to build a revolved shape and 36 //! then situated relative to one of the axes of the view. 37 class AIS_Axis : public AIS_InteractiveObject 38 { 39 DEFINE_STANDARD_RTTIEXT(AIS_Axis, AIS_InteractiveObject) 40 public: 41 42 //! Initializes the line aComponent 43 Standard_EXPORT AIS_Axis(const Handle(Geom_Line)& aComponent); 44 45 //! initializes the axis2 position 46 //! aComponent. The coordinate system used is right-handed. 47 Standard_EXPORT AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType); 48 49 //! Initializes the axis1 position anAxis. 50 Standard_EXPORT AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis); 51 52 //! Initializes the ray as axis with start point and direction 53 //! @param[in] theAxis Start point and direction of the ray 54 //! @param[in] theLength Optional length of the ray (ray is infinite by default). 55 Standard_EXPORT AIS_Axis (const gp_Ax1& theAxis, const Standard_Real theLength = -1); 56 57 //! Returns the axis entity aComponent and identifies it 58 //! as a component of a shape. Handle(Geom_Line)59 const Handle(Geom_Line)& Component() const { return myComponent; } 60 61 //! Sets the coordinates of the lin aComponent. 62 Standard_EXPORT void SetComponent (const Handle(Geom_Line)& aComponent); 63 64 //! Returns the position of axis2 and positions it by 65 //! identifying it as the x, y, or z axis and giving its 66 //! direction in 3D space. The coordinate system used is right-handed. Handle(Geom_Axis2Placement)67 const Handle(Geom_Axis2Placement)& Axis2Placement() const { return myAx2; } 68 69 //! Allows you to provide settings for aComponent:the 70 //! position and direction of an axis in 3D space. The 71 //! coordinate system used is right-handed. 72 Standard_EXPORT void SetAxis2Placement (const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType); 73 74 //! Constructs a new line to serve as the axis anAxis in 3D space. 75 Standard_EXPORT void SetAxis1Placement (const Handle(Geom_Axis1Placement)& anAxis); 76 77 //! Returns the type of axis. TypeOfAxis() const78 AIS_TypeOfAxis TypeOfAxis() const { return myTypeOfAxis; } 79 80 //! Constructs the entity theTypeAxis to stock information 81 //! concerning type of axis. SetTypeOfAxis(const AIS_TypeOfAxis theTypeAxis)82 void SetTypeOfAxis (const AIS_TypeOfAxis theTypeAxis) { myTypeOfAxis = theTypeAxis; } 83 84 //! Returns a signature of 2 for axis datums. When you 85 //! activate mode 2 by a signature, you pick AIS objects 86 //! of type AIS_Axis. IsXYZAxis() const87 Standard_Boolean IsXYZAxis() const { return myIsXYZAxis; } 88 89 //! Returns true if the interactive object accepts the display mode aMode. 90 Standard_EXPORT Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE; 91 Signature() const92 virtual Standard_Integer Signature() const Standard_OVERRIDE { return 2; } 93 Type() const94 virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; } 95 96 Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE; 97 98 Standard_EXPORT void SetWidth (const Standard_Real aValue) Standard_OVERRIDE; 99 100 //! Set required visualization parameters. 101 Standard_EXPORT void SetDisplayAspect (const Handle(Prs3d_LineAspect)& theNewDatumAspect); 102 103 Standard_EXPORT void UnsetColor() Standard_OVERRIDE; 104 105 Standard_EXPORT void UnsetWidth() Standard_OVERRIDE; 106 107 private: 108 109 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, 110 const Handle(Prs3d_Presentation)& thePrs, 111 const Standard_Integer theMode) Standard_OVERRIDE; 112 113 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel, 114 const Standard_Integer theMode) Standard_OVERRIDE; 115 116 Standard_EXPORT void ComputeFields(); 117 118 private: 119 120 Handle(Geom_Line) myComponent; 121 Handle(Geom_Axis2Placement) myAx2; 122 gp_Pnt myPfirst; 123 gp_Pnt myPlast; 124 AIS_TypeOfAxis myTypeOfAxis; 125 Standard_Boolean myIsXYZAxis; 126 gp_Dir myDir; 127 Standard_Real myVal; 128 Standard_CString myText; 129 Handle(Prs3d_LineAspect) myLineAspect; 130 131 }; 132 133 DEFINE_STANDARD_HANDLE(AIS_Axis, AIS_InteractiveObject) 134 135 #endif // _AIS_Axis_HeaderFile 136