1 // ATCdisplay.cxx - routines to display ATC output - graphically for now
3 // Written by David Luff, started October 2001.
5 // Copyright (C) 2001 David C Luff - david.luff@nottingham.ac.uk
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <simgear/misc/props.hxx>
27 #include <Include/general.hxx>
28 #include <Main/fg_props.hxx>
31 #include "ATCdisplay.hxx"
34 FGATCDisplay *current_atcdisplay;
38 FGATCDisplay::FGATCDisplay( void ) {
46 FGATCDisplay::~FGATCDisplay( void ) {
49 void FGATCDisplay::init( void ) {
53 // update - this actually draws the visuals and should be called from the main Flightgear rendering loop.
54 void FGATCDisplay::update() {
57 float fps = general.get_frame_rate();
59 //cout << "In FGATC::update()" << endl;
60 SGPropertyNode *xsize_node = fgGetNode("/sim/startup/xsize");
61 SGPropertyNode *ysize_node = fgGetNode("/sim/startup/ysize");
62 int iwidth = xsize_node->getIntValue();
63 int iheight = ysize_node->getIntValue();
65 //TODO - if the string is bigger than the buffer the program exits - we really ought to have a robust check here
67 //float fps = visibility/1600;
68 // sprintf(buf,"%-4.1f %7.0f %7.0f", fps, tris, culled);
69 // sprintf(buf,"%s %-5.1f", "visibility ", visibility);
70 sprintf(buf,"%s", rep_msg_str.c_str());
72 glMatrixMode( GL_PROJECTION );
75 gluOrtho2D( 0, iwidth, 0, iheight );
76 glMatrixMode( GL_MODELVIEW );
80 glDisable( GL_DEPTH_TEST );
81 glDisable( GL_LIGHTING );
83 glColor3f( 0.9, 0.4, 0.2 );
85 // guiFnt.drawString( buf,
86 // int(iwidth - guiFnt.getStringWidth(buf) - 10 - (int)dsp_offset),
88 guiFnt.drawString( buf,
89 int(iwidth - 10 - dsp_offset1),
91 guiFnt.drawString( buf,
92 int(iwidth - 10 - dsp_offset2),
94 glEnable( GL_DEPTH_TEST );
95 glEnable( GL_LIGHTING );
96 glMatrixMode( GL_PROJECTION );
98 glMatrixMode( GL_MODELVIEW );
101 // Try to scroll at a frame rate independent speed
102 // 40 pixels/second looks about right for now
103 if(dsp_offset1 >= dsp_offset2) {
104 dsp_offset1+=(40.0/fps);
105 dsp_offset2 = dsp_offset1 - (rep_msg_str.size() * 10) - 100;
106 if(dsp_offset1 > (iwidth + (rep_msg_str.size() * 10)))
109 dsp_offset2+=(40.0/fps);
110 dsp_offset1 = dsp_offset2 - (rep_msg_str.size() * 10) - 100;
111 if(dsp_offset2 > (iwidth + (rep_msg_str.size() * 10)))
119 void FGATCDisplay::RegisterRepeatingMessage(string msg) {
125 void FGATCDisplay::ChangeRepeatingMessage(string newmsg) {
126 //Not implemented yet
130 void FGATCDisplay::CancelRepeatingMessage() {