0022819: Redesign of OpenGl driver
[occt.git] / src / OpenGl / OpenGl_AspectText.cxx
CommitLineData
2166f0fa
SK
1// File: OpenGl_AspectText.cxx
2// Created: 13 July 2011
3// Author: Sergey ZERCHANINOV
4// Copyright: OPEN CASCADE 2011
5
6#include <OpenGl_AspectText.hxx>
7
8static const TEL_COLOUR myDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }};
9
10/*----------------------------------------------------------------------*/
11
12OpenGl_AspectText::OpenGl_AspectText ()
13 : myZoomable(0),
14 myAngle(0.0F),
15 myFontAspect(OSD_FA_Regular),
16 myFont(NULL),
17 //mySpace(0.3F),
18 //myExpan(1.0F),
19 myColor(myDefaultColor),
20 myStyleType(Aspect_TOST_NORMAL),
21 myDisplayType(Aspect_TODT_NORMAL),
22 mySubtitleColor(myDefaultColor)
23{
24 SetFontName( (const char *) "Courier" );
25}
26
27/*----------------------------------------------------------------------*/
28
29OpenGl_AspectText::~OpenGl_AspectText ()
30{
31 if (myFont)
32 delete[] myFont;
33}
34
35/*----------------------------------------------------------------------*/
36
37void OpenGl_AspectText::SetContext (const CALL_DEF_CONTEXTTEXT &AContext)
38{
39 myZoomable = (int) AContext.TextZoomable;
40 myAngle = (float) AContext.TextAngle;
41 myFontAspect = (OSD_FontAspect) AContext.TextFontAspect;
42 //mySpace = (float) AContext.Space;
43 //myExpan = (float) AContext.Expan;
44 myColor.rgb[0] = (float) AContext.Color.r;
45 myColor.rgb[1] = (float) AContext.Color.g;
46 myColor.rgb[2] = (float) AContext.Color.b;
47 myColor.rgb[3] = 1.0f;
48 myStyleType = (Aspect_TypeOfStyleText) AContext.Style;
49 myDisplayType = (Aspect_TypeOfDisplayText) AContext.DisplayType;
50 mySubtitleColor.rgb[0] = (float) AContext.ColorSubTitle.r;
51 mySubtitleColor.rgb[1] = (float) AContext.ColorSubTitle.g;
52 mySubtitleColor.rgb[2] = (float) AContext.ColorSubTitle.b;
53 mySubtitleColor.rgb[3] = 1.0f;
54
55 SetFontName( (const char *) AContext.Font );
56}
57
58/*----------------------------------------------------------------------*/
59
60void OpenGl_AspectText::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
61{
62 AWorkspace->SetAspectText(this);
63}
64
65/*----------------------------------------------------------------------*/
66
67void OpenGl_AspectText::SetFontName (const char *AFont)
68{
69 if (myFont)
70 delete[] myFont;
71 char *fontname = new char[ strlen( AFont ) + 1 ];
72 strcpy( fontname, AFont );
73 myFont = fontname;
74}
75
76/*----------------------------------------------------------------------*/