Back to home page

EIC code displayed by LXR

 
 

    


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

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 
0034   //! Default constructor
0035   Standard_EXPORT AIS_TextLabel();
0036 
0037   //! Return TRUE for supported display mode.
0038   virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
0039 
0040   //! Setup color of entire text.
0041   Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
0042 
0043   //! Setup transparency within [0, 1] range.
0044   Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE;
0045 
0046   //! Removes the transparency setting.
0047   virtual void UnsetTransparency() Standard_OVERRIDE { SetTransparency (0.0); }
0048 
0049   //! Material has no effect for text label.
0050   virtual void SetMaterial (const Graphic3d_MaterialAspect& ) Standard_OVERRIDE {}
0051 
0052   //! Setup text.
0053   Standard_EXPORT void SetText (const TCollection_ExtendedString& theText);
0054 
0055   //! Setup position.
0056   Standard_EXPORT void SetPosition (const gp_Pnt& thePosition);
0057 
0058   //! Setup horizontal justification.
0059   Standard_EXPORT void SetHJustification (const Graphic3d_HorizontalTextAlignment theHJust);
0060 
0061   //! Setup vertical justification.
0062   Standard_EXPORT void SetVJustification (const Graphic3d_VerticalTextAlignment theVJust);
0063 
0064   //! Setup angle.
0065   Standard_EXPORT void SetAngle (const Standard_Real theAngle);
0066 
0067   //! Setup zoomable property.
0068   Standard_EXPORT void SetZoomable (const Standard_Boolean theIsZoomable);
0069 
0070   //! Setup height.
0071   Standard_EXPORT void SetHeight (const Standard_Real theHeight);
0072 
0073   //! Setup font aspect.
0074   Standard_EXPORT void SetFontAspect (const Font_FontAspect theFontAspect);
0075 
0076   //! Setup font.
0077   Standard_EXPORT void SetFont (Standard_CString theFont);
0078 
0079   //! Setup label orientation in the model 3D space.
0080   Standard_EXPORT void SetOrientation3D (const gp_Ax2& theOrientation);
0081 
0082   //! Reset label orientation in the model 3D space.
0083   Standard_EXPORT void UnsetOrientation3D ();
0084 
0085   //! Returns position.
0086   Standard_EXPORT const gp_Pnt& Position() const;
0087 
0088   //! Returns the label text.
0089   const TCollection_ExtendedString& Text() const { return myText; }
0090 
0091   //! Returns the font of the label text.
0092   Standard_EXPORT const TCollection_AsciiString& FontName() const;
0093 
0094   //! Returns the font aspect of the label text.
0095   Standard_EXPORT Font_FontAspect FontAspect() const;
0096 
0097   //! Returns label orientation in the model 3D space.
0098   Standard_EXPORT const gp_Ax2& Orientation3D() const;
0099 
0100   //! Returns true if the current text placement mode uses text orientation in the model 3D space.
0101   Standard_EXPORT Standard_Boolean HasOrientation3D() const;
0102 
0103   Standard_EXPORT void SetFlipping (const Standard_Boolean theIsFlipping);
0104 
0105   Standard_EXPORT Standard_Boolean HasFlipping() const;
0106 
0107   //! Returns flag if text uses position as point of attach
0108   Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
0109 
0110   //! Set flag if text uses position as point of attach
0111   void SetOwnAnchorPoint (const Standard_Boolean theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; }
0112 
0113   //! Define the display type of the text.
0114   //!
0115   //! TODT_NORMAL     Default display. Text only.
0116   //! TODT_SUBTITLE   There is a subtitle under the text.
0117   //! TODT_DEKALE     The text is displayed with a 3D style.
0118   //! TODT_BLEND      The text is displayed in XOR.
0119   //! TODT_DIMENSION  Dimension line under text will be invisible.
0120   Standard_EXPORT void SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType);
0121 
0122   //! Modifies the colour of the subtitle for the TODT_SUBTITLE TextDisplayType
0123   //! and the colour of backgroubd for the TODT_DEKALE TextDisplayType.
0124   Standard_EXPORT void SetColorSubTitle (const Quantity_Color& theColor);
0125 
0126   //! Returns text presentation formatter; NULL by default, which means standard text formatter will be used.
0127   const Handle(Font_TextFormatter)& TextFormatter() const { return myFormatter; }
0128 
0129   //! Setup text formatter for presentation. It's empty by default.
0130   void SetTextFormatter (const Handle(Font_TextFormatter)& theFormatter) { myFormatter = theFormatter; }
0131 
0132 protected:
0133 
0134   //! Compute
0135   Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& theprsMgr,
0136                                         const Handle(Prs3d_Presentation)& thePrs,
0137                                         const Standard_Integer theMode) Standard_OVERRIDE;
0138 
0139   //! Compute selection
0140   Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
0141                                                  const Standard_Integer             theMode) Standard_OVERRIDE;
0142 
0143   //! Calculate label center, width and height
0144   Standard_EXPORT Standard_Boolean calculateLabelParams (const gp_Pnt& thePosition,
0145                                                          gp_Pnt& theCenterOfLabel,
0146                                                          Standard_Real& theWidth,
0147                                                          Standard_Real& theHeight) const;
0148 
0149   //! Calculate label transformation
0150   Standard_EXPORT gp_Trsf calculateLabelTrsf (const gp_Pnt& thePosition,
0151                                               gp_Pnt& theCenterOfLabel) const;
0152 
0153 protected:
0154 
0155   Handle(Font_TextFormatter) myFormatter;
0156 
0157   TCollection_ExtendedString myText;
0158   gp_Ax2                     myOrientation3D;
0159   Standard_Boolean           myHasOrientation3D;
0160   Standard_Boolean           myHasOwnAnchorPoint;
0161   Standard_Boolean           myHasFlipping;
0162 
0163 public:
0164 
0165   //! CASCADE RTTI
0166   DEFINE_STANDARD_RTTIEXT(AIS_TextLabel,AIS_InteractiveObject)
0167 
0168 };
0169 
0170 DEFINE_STANDARD_HANDLE(AIS_TextLabel, AIS_InteractiveObject)
0171 
0172 #endif // _AIS_TextLabel_HeaderFile