Debian Codegraph @

utils/fgpanel/FGTextLayer.hxx

raw symbols SCIP
1 // SPDX-FileCopyrightText: 2000 David Megginson
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <string>
7 #include <simgear/timing/timestamp.hxx>
8
9 #include "FGFontCache.hxx"
10 #include "FGInstrumentLayer.hxx"
11
12
13 /**
14 * A text layer of an instrument.
15 *
16 * This is a layer holding a string of static and/or generated text.
17 * It is useful for instruments that have text displays, such as
18 * a chronometer, GPS, or NavCom radio.
19 */
20
21 class FGTextLayer : public FGInstrumentLayer {
22 public:
23 enum ChunkType {
24 TEXT,
25 TEXT_VALUE,
26 DOUBLE_VALUE
27 };
28
29 class Chunk : public SGConditional {
30 public:
31 Chunk (const std::string &text,
32 const std::string &fmt = "%s");
33 Chunk (const ChunkType type,
34 const SGPropertyNode *node,
35 const std::string &fmt = "",
36 const float mult = 1.0,
37 const float offs = 0.0,
38 const bool truncation = false);
39
40 const char *getValue () const;
41 private:
42 ChunkType m_type;
43 std::string m_text;
44 SGConstPropertyNode_ptr m_node;
45 std::string m_fmt;
46 float m_mult;
47 float m_offs;
48 bool m_trunc;
49 mutable char m_buf[1024];
50
51 };
52
53 static bool Init ();
54
55 FGTextLayer (const int w = -1, const int h = -1);
56 virtual ~FGTextLayer ();
57
58 virtual void draw ();
59
60 // Transfer pointer!!
61 virtual void addChunk (Chunk * const chunk);
62 virtual void setColor (const float r,
63 const float g,
64 const float b);
65 virtual void setPointSize (const float size);
66 virtual void setFontName (const std::string &name);
67
68 private:
69
70 void recalc_value () const;
71
72 typedef std::vector<Chunk *> chunk_list;
73 chunk_list m_chunks;
74 float m_color[4];
75
76 float m_pointSize;
77 static SGPath The_Font_Path;
78 mutable std::string m_font_name;
79 mutable std::string m_value;
80 mutable SGTimeStamp m_then;
81 mutable SGTimeStamp m_now;
82
83 static FGFontCache The_Font_Cache;
84
85 static GLuint Text_Layer_Program_Object;
86 static GLint Text_Layer_Position_Loc;
87 static GLint Text_Layer_Tex_Coord_Loc;
88 static GLint Text_Layer_MVP_Loc;
89 static GLint Text_Layer_Sampler_Loc;
90 static GLint Text_Layer_Color_Loc;
91 };