10 #include <Aircraft/aircraft.hxx>
11 #include <Include/fg_constants.h>
12 #include <Math/fg_random.h>
13 #include <Math/mat3.h>
14 #include <Math/polar3d.hxx>
15 #include <Scenery/scenery.hxx>
16 #include <Time/fg_timer.hxx>
21 //======================= Top of instr_label class =========================
28 const char *label_format,
29 const char *pre_label_string,
30 const char *post_label_string,
33 fgLabelJust justification,
37 instr_item( x, y, width, height,
38 data_source, scale_data,options, working ),
39 pformat ( label_format ),
40 pre_str ( pre_label_string ),
41 post_str ( post_label_string ),
42 justify ( justification ),
43 fontSize ( font_size ),
48 // I put this in to make it easy to construct a class member using the current
52 instr_label :: ~instr_label()
57 instr_label :: instr_label( const instr_label & image) :
58 instr_item((const instr_item &)image),
59 pformat ( image.pformat ),
60 pre_str ( image.pre_str ),
61 post_str ( image.post_str ),
66 instr_label & instr_label ::operator = (const instr_label & rhs )
68 if( !(this == &rhs)) {
69 instr_item::operator = (rhs);
70 pformat = rhs.pformat;
71 fontSize = rhs.fontSize;
73 justify = rhs.justify;
74 pre_str = rhs.pre_str;
75 post_str = rhs.post_str;
81 // draw Draws a label anywhere in the HUD
85 draw( void ) // Required method in base class
87 char format_buffer[80];
88 char label_buffer[80];
91 RECT scrn_rect = get_location();
93 if( pre_str != NULL) {
94 if( post_str != NULL ) {
95 sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
98 sprintf( format_buffer, "%s%s", pre_str, pformat );
102 if( post_str != NULL ) {
103 sprintf( format_buffer, "%s%s", pformat, post_str );
105 } // else do nothing if both pre and post strings are nulls. Interesting.
107 if( data_available() ) {
108 sprintf( label_buffer, format_buffer, get_value() );
111 sprintf( label_buffer, format_buffer );
115 fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
116 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
117 fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
118 fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
120 lenstr = strlen( label_buffer );
122 posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8;
124 if( justify == CENTER_JUST ) {
125 posincr = - (lenstr << 2); // -lenstr*4;
128 if( justify == LEFT_JUST ) {
129 posincr = - (lenstr << 8); // 0;
133 if( fontSize == SMALL ) {
134 textString( scrn_rect.left + posincr, scrn_rect.top,
135 label_buffer, GLUT_BITMAP_8_BY_13);
138 if( fontSize == LARGE ) {
139 textString( scrn_rect.left + posincr, scrn_rect.top,
140 label_buffer, GLUT_BITMAP_9_BY_15);