Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:15:33

0001 // Created on: 2014-11-10
0002 // Copyright (c) 2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _AIS_TextLabel_HeaderFile
0016 #define _AIS_TextLabel_HeaderFile
0017 
0018 #include <AIS_InteractiveObject.hxx>
0019 
0020 #include <gp_Pnt.hxx>
0021 #include <gp_Ax2.hxx>
0022 #include <Graphic3d_VerticalTextAlignment.hxx>
0023 #include <Graphic3d_HorizontalTextAlignment.hxx>
0024 #include <Font_FontAspect.hxx>
0025 #include <TCollection_ExtendedString.hxx>
0026 
0027 class Font_TextFormatter;
0028 
0029 //! Presentation of the text.
0030 class AIS_TextLabel : public AIS_InteractiveObject
0031 {
0032 public:
0033   //! Default constructor
0034   Standard_EXPORT AIS_TextLabel();
0035 
0036   //! Return TRUE for supported display mode.
0037   bool AcceptDisplayMode(const int theMode) const override { return theMode == 0; }
0038 
0039   //! Setup color of entire text.
0040   Standard_EXPORT void SetColor(const Quantity_Color& theColor) override;
0041 
0042   //! Setup transparency within [0, 1] range.
0043   Standard_EXPORT void SetTransparency(const double theValue) override;
0044 
0045   //! Removes the transparency setting.
0046   void UnsetTransparency() override { SetTransparency(0.0); }
0047 
0048   //! Material has no effect for text label.
0049   void SetMaterial(const Graphic3d_MaterialAspect&) override {}
0050 
0051   //! Setup text.
0052   Standard_EXPORT void SetText(const TCollection_ExtendedString& theText);
0053 
0054   //! Setup position.
0055   Standard_EXPORT void SetPosition(const gp_Pnt& thePosition);
0056 
0057   //! Setup horizontal justification.
0058   Standard_EXPORT void SetHJustification(const Graphic3d_HorizontalTextAlignment theHJust);
0059 
0060   //! Setup vertical justification.
0061   Standard_EXPORT void SetVJustification(const Graphic3d_VerticalTextAlignment theVJust);
0062 
0063   //! Setup angle.
0064   Standard_EXPORT void SetAngle(const double theAngle);
0065 
0066   //! Setup zoomable property.
0067   Standard_EXPORT void SetZoomable(const bool theIsZoomable);
0068 
0069   //! Setup height.
0070   Standard_EXPORT void SetHeight(const double theHeight);
0071 
0072   //! Setup font aspect.
0073   Standard_EXPORT void SetFontAspect(const Font_FontAspect theFontAspect);
0074 
0075   //! Setup font.
0076   Standard_EXPORT void SetFont(const char* theFont);
0077 
0078   //! Setup label orientation in the model 3D space.
0079   Standard_EXPORT void SetOrientation3D(const gp_Ax2& theOrientation);
0080 
0081   //! Reset label orientation in the model 3D space.
0082   Standard_EXPORT void UnsetOrientation3D();
0083 
0084   //! Returns position.
0085   Standard_EXPORT const gp_Pnt& Position() const;
0086 
0087   //! Returns the label text.
0088   const TCollection_ExtendedString& Text() const { return myText; }
0089 
0090   //! Returns the font of the label text.
0091   Standard_EXPORT const TCollection_AsciiString& FontName() const;
0092 
0093   //! Returns the font aspect of the label text.
0094   Standard_EXPORT Font_FontAspect FontAspect() const;
0095 
0096   //! Returns label orientation in the model 3D space.
0097   Standard_EXPORT const gp_Ax2& Orientation3D() const;
0098 
0099   //! Returns true if the current text placement mode uses text orientation in the model 3D space.
0100   Standard_EXPORT bool HasOrientation3D() const;
0101 
0102   Standard_EXPORT void SetFlipping(const bool theIsFlipping);
0103 
0104   Standard_EXPORT bool HasFlipping() const;
0105 
0106   //! Returns flag if text uses position as point of attach
0107   bool HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
0108 
0109   //! Set flag if text uses position as point of attach
0110   void SetOwnAnchorPoint(const bool theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; }
0111 
0112   //! Define the display type of the text.
0113   //!
0114   //! TODT_NORMAL     Default display. Text only.
0115   //! TODT_SUBTITLE   There is a subtitle under the text.
0116   //! TODT_DEKALE     The text is displayed with a 3D style.
0117   //! TODT_BLEND      The text is displayed in XOR.
0118   //! TODT_DIMENSION  Dimension line under text will be invisible.
0119   Standard_EXPORT void SetDisplayType(const Aspect_TypeOfDisplayText theDisplayType);
0120 
0121   //! Modifies the colour of the subtitle for the TODT_SUBTITLE TextDisplayType
0122   //! and the colour of backgroubd for the TODT_DEKALE TextDisplayType.
0123   Standard_EXPORT void SetColorSubTitle(const Quantity_Color& theColor);
0124 
0125   //! Returns text presentation formatter; NULL by default, which means standard text formatter will
0126   //! be used.
0127   const occ::handle<Font_TextFormatter>& TextFormatter() const { return myFormatter; }
0128 
0129   //! Setup text formatter for presentation. It's empty by default.
0130   void SetTextFormatter(const occ::handle<Font_TextFormatter>& theFormatter)
0131   {
0132     myFormatter = theFormatter;
0133   }
0134 
0135 protected:
0136   //! Compute
0137   Standard_EXPORT void Compute(const occ::handle<PrsMgr_PresentationManager>& theprsMgr,
0138                                const occ::handle<Prs3d_Presentation>&         thePrs,
0139                                const int                                      theMode) override;
0140 
0141   //! Compute selection
0142   Standard_EXPORT void ComputeSelection(const occ::handle<SelectMgr_Selection>& theSelection,
0143                                         const int                               theMode) override;
0144 
0145   //! Calculate label center, width and height
0146   Standard_EXPORT bool calculateLabelParams(const gp_Pnt& thePosition,
0147                                             gp_Pnt&       theCenterOfLabel,
0148                                             double&       theWidth,
0149                                             double&       theHeight) const;
0150 
0151   //! Calculate label transformation
0152   Standard_EXPORT gp_Trsf calculateLabelTrsf(const gp_Pnt& thePosition,
0153                                              gp_Pnt&       theCenterOfLabel) const;
0154 
0155 protected:
0156   occ::handle<Font_TextFormatter> myFormatter;
0157 
0158   TCollection_ExtendedString myText;
0159   gp_Ax2                     myOrientation3D;
0160   bool                       myHasOrientation3D;
0161   bool                       myHasOwnAnchorPoint;
0162   bool                       myHasFlipping;
0163 
0164 public:
0165   //! CASCADE RTTI
0166   DEFINE_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject)
0167 };
0168 
0169 #endif // _AIS_TextLabel_HeaderFile