diff --git a/src/AIS/AIS_TextLabel.cxx b/src/AIS/AIS_TextLabel.cxx index 170cf5ada3..5b364f0965 100644 --- a/src/AIS/AIS_TextLabel.cxx +++ b/src/AIS/AIS_TextLabel.cxx @@ -30,7 +30,6 @@ #include - IMPLEMENT_STANDARD_RTTIEXT(AIS_TextLabel,AIS_InteractiveObject) //======================================================================= @@ -61,12 +60,20 @@ void AIS_TextLabel::SetColor (const Quantity_Color& theColor) } //======================================================================= -//function : SetColor +//function : SetTransparency //purpose : //======================================================================= -void AIS_TextLabel::SetColor (const Quantity_NameOfColor theColor) +void AIS_TextLabel::SetTransparency (const Standard_Real theValue) { - SetColor (Quantity_Color (theColor)); + Quantity_ColorRGBA aTextColor (myDrawer->TextAspect()->Aspect()->Color()); + aTextColor.SetAlpha (Standard_ShortReal(1.0 - theValue)); + + Quantity_ColorRGBA aSubColor (myDrawer->TextAspect()->Aspect()->ColorSubTitle()); + aSubColor.SetAlpha (aTextColor.Alpha()); + + myDrawer->TextAspect()->Aspect()->SetColor (aTextColor); + myDrawer->TextAspect()->Aspect()->SetColorSubTitle (aSubColor); + myDrawer->SetTransparency (Standard_ShortReal(theValue)); } //======================================================================= @@ -233,7 +240,6 @@ void AIS_TextLabel::SetColorSubTitle (const Quantity_Color& theColor) myDrawer->TextAspect()->Aspect()->SetColorSubTitle(theColor); } -#include //======================================================================= //function : Compute //purpose : diff --git a/src/AIS/AIS_TextLabel.hxx b/src/AIS/AIS_TextLabel.hxx index 4f88154684..3b3562bb5b 100644 --- a/src/AIS/AIS_TextLabel.hxx +++ b/src/AIS/AIS_TextLabel.hxx @@ -36,7 +36,13 @@ public: Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; //! Setup color of entire text. - Standard_EXPORT virtual void SetColor (const Quantity_NameOfColor theColor) Standard_OVERRIDE; + virtual void SetColor (const Quantity_NameOfColor theColor) Standard_OVERRIDE { SetColor (Quantity_Color (theColor)); } + + //! Setup transparency within [0, 1] range. + Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE; + + //! Removes the transparency setting. + virtual void UnsetTransparency() Standard_OVERRIDE { SetTransparency (0.0); } //! Material has no effect for text label. virtual void SetMaterial (const Graphic3d_NameOfMaterial ) Standard_OVERRIDE {} diff --git a/src/Graphic3d/Graphic3d_AspectText3d.hxx b/src/Graphic3d/Graphic3d_AspectText3d.hxx index e2f243b15c..827f87e3a9 100644 --- a/src/Graphic3d/Graphic3d_AspectText3d.hxx +++ b/src/Graphic3d/Graphic3d_AspectText3d.hxx @@ -77,6 +77,9 @@ public: //! Modifies the color. void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); } + //! Modifies the color. + void SetColor (const Quantity_ColorRGBA& theColor) { myColor = theColor; } + //! Modifies the expansion factor (height/width ratio) //! If the factor is less than 1, the characters will //! be higher than they are wide. @@ -144,6 +147,10 @@ public: //! and the color of background for the TODT_DEKALE TextDisplayType. void SetColorSubTitle (const Quantity_Color& theColor) { myColorSubTitle.SetRGB (theColor); } + //! Modifies the color of the subtitle for the TODT_SUBTITLE TextDisplayType + //! and the color of background for the TODT_DEKALE TextDisplayType. + void SetColorSubTitle (const Quantity_ColorRGBA& theColor) { myColorSubTitle = theColor; } + //! Returns TRUE when the Text Zoomable is on. bool GetTextZoomable() const { return myTextZoomable; }