Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:55

0001 // Created on: 1995-10-09
0002 // Created by: Arnaud BOUZY/Odile Olivier
0003 // Copyright (c) 1995-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 _AIS_Trihedron_HeaderFile
0018 #define _AIS_Trihedron_HeaderFile
0019 
0020 #include <AIS_InteractiveObject.hxx>
0021 #include <AIS_KindOfInteractive.hxx>
0022 #include <Graphic3d_ArrayOfTriangles.hxx>
0023 #include <PrsMgr_PresentationManager.hxx>
0024 #include <Prs3d_DatumAspect.hxx>
0025 #include <Prs3d_DatumMode.hxx>
0026 #include <Prs3d_DatumParts.hxx>
0027 #include <Prs3d_LineAspect.hxx>
0028 #include <SelectMgr_Selection.hxx>
0029 #include <Quantity_Color.hxx>
0030 
0031 class Geom_Axis2Placement;
0032 
0033 //! Create a selectable trihedron
0034 //! The trihedron includes 1 origin, 3 axes and 3 labels.
0035 //! Default text of labels are "X", "Y", "Z".
0036 //! Color of origin and any axis, color of arrows and labels may be changed.
0037 //! Visual presentation might be shown in two, shaded and wireframe modes, wireframe by default).
0038 //! There are 4 modes of selection:
0039 //! - AIS_TrihedronSelectionMode_EntireObject to select trihedron,  priority = 1
0040 //! - AIS_TrihedronSelectionMode_Origin       to select its origin, priority = 5
0041 //! - AIS_TrihedronSelectionMode_Axes         to select its axis,   priority = 3
0042 //! - AIS_TrihedronSelectionMode_MainPlanes   to select its planes, priority = 2
0043 //!
0044 //! Warning!
0045 //! For the presentation of trihedron, the default unit of length is the millimetre,
0046 //! and the default value for the representation of the axes is 100.
0047 //! If you modify these dimensions, you must temporarily recover the Drawer.
0048 //! From inside it, you take the aspect in which the values for length are stocked.
0049 //! For trihedron, this is Prs3d_Drawer_LineAspect.
0050 //! You change the values inside this Aspect and recalculate the presentation.
0051 class AIS_Trihedron : public AIS_InteractiveObject
0052 {
0053   DEFINE_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject)
0054 public:
0055 
0056   //! Initializes a trihedron entity.
0057   Standard_EXPORT AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent);
0058 
0059   //! Returns datum display mode.
0060   Prs3d_DatumMode DatumDisplayMode() const { return myTrihDispMode; }
0061 
0062   //! Sets Shading or Wireframe display mode, triangle or segment graphic group is used relatively.
0063   void SetDatumDisplayMode (Prs3d_DatumMode theMode) { myTrihDispMode = theMode; }
0064 
0065   //! Returns the right-handed coordinate system set in SetComponent.
0066   const Handle(Geom_Axis2Placement)& Component() const { return myComponent; }
0067 
0068   //! Constructs the right-handed coordinate system aComponent.
0069   Standard_EXPORT void SetComponent (const Handle(Geom_Axis2Placement)& theComponent);
0070 
0071   //! Returns true if the trihedron object has a size other
0072   //! than the default size of 100 mm. along each axis.
0073   Standard_Boolean HasOwnSize() const { return myHasOwnSize; }
0074 
0075   //! Returns the size of trihedron object; 100.0 by DEFAULT.
0076   Standard_EXPORT Standard_Real Size() const;
0077 
0078   //! Sets the size of trihedron object.
0079   Standard_EXPORT void SetSize (const Standard_Real theValue);
0080 
0081   //! Removes any non-default settings for size of this trihedron object.
0082   //! If the object has 1 color, the default size of the
0083   //! drawer is reproduced, otherwise DatumAspect becomes null.
0084   Standard_EXPORT void UnsetSize();
0085 
0086   //! Returns true if trihedron has own text color
0087   Standard_Boolean HasTextColor() const { return myHasOwnTextColor; }
0088 
0089   //! Returns trihedron text color
0090   Standard_EXPORT Quantity_Color TextColor() const;
0091 
0092   //! Sets color of label of trihedron axes.
0093   Standard_EXPORT void SetTextColor (const Quantity_Color& theColor);
0094 
0095   //! Sets color of label of trihedron axis.
0096   Standard_EXPORT void SetTextColor (const Prs3d_DatumParts thePart,
0097                                      const Quantity_Color& theColor);
0098 
0099   //! Returns true if trihedron has own arrow color
0100   Standard_Boolean HasArrowColor() const { return myHasOwnArrowColor; }
0101 
0102   //! Returns trihedron arrow color
0103   Standard_EXPORT Quantity_Color ArrowColor() const;
0104 
0105   //! Sets color of arrow of trihedron axes.
0106   Standard_EXPORT void SetArrowColor (const Quantity_Color& theColor);
0107 
0108   //! Sets color of arrow of trihedron axes.
0109   Standard_EXPORT void SetArrowColor (const Prs3d_DatumParts thePart,
0110                                       const Quantity_Color& theColor);
0111 
0112   //! Returns color of datum part: origin or some of trihedron axes.
0113   Standard_EXPORT Quantity_Color DatumPartColor (Prs3d_DatumParts thePart);
0114 
0115   //! Sets color of datum part: origin or some of trihedron axes.
0116   //! If presentation is shading mode, this color is set for both sides of facing model
0117   Standard_EXPORT void SetDatumPartColor (const Prs3d_DatumParts thePart,
0118                                           const Quantity_Color&  theColor);
0119   //! Sets color of origin.
0120   //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
0121   Standard_EXPORT void SetOriginColor (const Quantity_Color& theColor);
0122 
0123   //! Sets color of x-axis.
0124   //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
0125   Standard_EXPORT void SetXAxisColor (const Quantity_Color& theColor);
0126 
0127   //! Sets color of y-axis.
0128   //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
0129   Standard_EXPORT void SetYAxisColor (const Quantity_Color& theColor);
0130 
0131   //! Sets color of z-axis.
0132   //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
0133   Standard_EXPORT void SetAxisColor (const Quantity_Color& theColor);
0134 
0135   //! Returns true if arrows are to be drawn
0136   Standard_EXPORT Standard_Boolean ToDrawArrows() const;
0137 
0138   //! Sets whether to draw the arrows in visualization
0139   Standard_EXPORT void SetDrawArrows (const Standard_Boolean theToDraw);
0140 
0141   //! Returns priority of selection for owner of the given type
0142   Standard_Integer SelectionPriority (Prs3d_DatumParts thePart) { return mySelectionPriority[thePart]; }
0143 
0144   //! Sets priority of selection for owner of the given type
0145   void SetSelectionPriority (Prs3d_DatumParts thePart,
0146                              Standard_Integer thePriority)
0147   {
0148     mySelectionPriority[thePart] = thePriority;
0149   }
0150 
0151   //! Returns text of axis. Parameter thePart should be XAxis, YAxis or ZAxis
0152   const TCollection_ExtendedString& Label (Prs3d_DatumParts thePart) { return myLabels[thePart]; }
0153 
0154   //! Sets text label for trihedron axis. Parameter thePart should be XAxis, YAxis or ZAxis
0155   void SetLabel (const Prs3d_DatumParts thePart,
0156                  const TCollection_ExtendedString& theName)
0157   {
0158     myLabels[thePart] = theName;
0159   }
0160 
0161 public:
0162 
0163   //! Sets the color theColor for this trihedron object, it changes color of axes.
0164   Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
0165 
0166   //! Returns true if the display mode selected, aMode, is valid for trihedron datums.
0167   virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE
0168   {
0169     return theMode == 0;
0170   }
0171 
0172   //! Returns index 3, selection of the planes XOY, YOZ, XOZ.
0173   virtual Standard_Integer Signature() const Standard_OVERRIDE { return 3; }
0174 
0175   //! Indicates that the type of Interactive Object is datum.
0176   virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
0177 
0178   //! Removes the settings for color.
0179   Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
0180 
0181 public:
0182 
0183   //! Method which clear all selected owners belonging
0184   //! to this selectable object ( for fast presentation draw ).
0185   Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
0186 
0187   //! Method which draws selected owners ( for fast presentation draw ).
0188   Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager)& thePM,
0189                                                 const SelectMgr_SequenceOfOwner& theOwners) Standard_OVERRIDE;
0190 
0191   //! Method which hilight an owner belonging to
0192   //! this selectable object  ( for fast presentation draw ).
0193   Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
0194                                                       const Handle(Prs3d_Drawer)& theStyle,
0195                                                       const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
0196 
0197 protected:
0198 
0199   //! Compute trihedron presentation.
0200   Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
0201                                 const Handle(Prs3d_Presentation)& thePrs,
0202                                 const Standard_Integer theMode) Standard_OVERRIDE;
0203 
0204   //! Compute selection.
0205   Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
0206                                                  const Standard_Integer theMode) Standard_OVERRIDE;
0207 
0208   //! Dumps the content of me into the stream
0209   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0210 
0211 protected:
0212 
0213   //! Creates a sensitive entity for the datum part that will be used in selection owner creation.
0214   Standard_EXPORT Handle(Select3D_SensitiveEntity) createSensitiveEntity (const Prs3d_DatumParts thePart,
0215                                                      const Handle(SelectMgr_EntityOwner)& theOwner) const;
0216 
0217   //! Computes presentation for display mode equal 1.
0218   Standard_EXPORT void computePresentation (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
0219                                             const Handle(Prs3d_Presentation)& thePrs);
0220 
0221   //! Returns own datum aspect of trihedron, create this aspect if it was not created yet.
0222   Standard_EXPORT void setOwnDatumAspect();
0223 
0224   //! Returns primitives.
0225   const Handle(Graphic3d_ArrayOfPrimitives)& arrayOfPrimitives (Prs3d_DatumParts thePart) const { return myPrimitives[thePart]; }
0226 
0227   //! Updates graphic groups for the current datum mode
0228   //! Parameters of datum position and orientation
0229   Standard_EXPORT void updatePrimitives (const Handle(Prs3d_DatumAspect)& theAspect,
0230                                          Prs3d_DatumMode theMode,
0231                                          const gp_Pnt& theOrigin,
0232                                          const gp_Dir& theXDir,
0233                                          const gp_Dir& theYDir,
0234                                          const gp_Dir& theZDir);
0235 
0236 protected:
0237   Handle(Geom_Axis2Placement) myComponent;
0238   Prs3d_DatumMode  myTrihDispMode;
0239   Standard_Boolean myHasOwnSize;
0240   Standard_Boolean myHasOwnTextColor;
0241   Standard_Boolean myHasOwnArrowColor;
0242 
0243   TCollection_ExtendedString myLabels[Prs3d_DatumParts_NB];
0244   Standard_Integer mySelectionPriority[Prs3d_DatumParts_NB];
0245 
0246   Handle(Graphic3d_Group) myPartToGroup[Prs3d_DatumParts_NB];
0247   NCollection_List<Prs3d_DatumParts> mySelectedParts;
0248   Handle(Graphic3d_AspectLine3d) myHiddenLineAspect;
0249 
0250   Handle(Graphic3d_ArrayOfPrimitives) myPrimitives[Prs3d_DatumParts_NB];
0251 };
0252 
0253 DEFINE_STANDARD_HANDLE(AIS_Trihedron, AIS_InteractiveObject)
0254 
0255 #endif // _AIS_Trihedron_HeaderFile