#include <string.h>
#ifndef WIN32
-# include <values.h> /* for MAXINT */
-#endif /* not WIN32 */
+# include <values.h> // for MAXINT
+#endif //
#include "hud.h"
#include <Math/mat3.h>
#include <Math/polar.h>
#include <Scenery/scenery.h>
-// #include <Scenery/mesh.h> /* not used any more :-) */
#include <Time/fg_timer.h>
#include <Weather/weather.h>
factor = (pscale->scr_max - pscale->scr_min)/pscale->width_units;
- for( i=vmin; i<=vmax; i+=1 )
+ for( i = vmin; i <= vmax; i++ )
{
- if( pscale->sub_type == LIMIT )
- condition = i>= pscale->minimum_value;
- else
- if( pscale->sub_type == NOLIMIT )
+ if( pscale->sub_type == LIMIT ) {
+ condition = (i >= pscale->minimum_value);
+ }
+ else {
+ if( pscale->sub_type == NOLIMIT ) {
condition = 1;
-
+ }
+ }
if( condition )
{
- marker_y = pscale->scr_min+(i-vmin)*factor;
- if( i%pscale->div_min==0 )
+ marker_y = pscale->scr_min + (i - vmin) * factor;
+ if( !(i%pscale->div_min)) {
if( pscale->orientation == LEFT )
{
- drawOneLine( marker_x+3, marker_y, marker_x+6, marker_y );
+ drawOneLine( marker_x + 3, marker_y, marker_x + 6, marker_y );
}
- else
+ else {
if( pscale->orientation == RIGHT )
{
- drawOneLine( marker_x, marker_y, marker_x+3, marker_y );
+ drawOneLine( marker_x, marker_y, marker_x + 3, marker_y );
}
if( i%pscale->div_max==0 )
{
- drawOneLine( marker_x, marker_y, marker_x+6, marker_y );
+ drawOneLine( marker_x, marker_y, marker_x + 6, marker_y );
sprintf( TextScale, "%d", i );
if( pscale->orientation == LEFT )
{
- textString( marker_x-8*strlen(TextScale)-2, marker_y-4,
+ textString( marker_x - 8 * strlen(TextScale) - 2, marker_y - 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
- else
+ else {
if( pscale->orientation == RIGHT )
{
textString( marker_x+10, marker_y-4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
+ }
}
- }
+ }
+ }
+ }
} // End for range of i from vmin to vmax
}
if( pscale->type == HORIZONTAL ) // Horizontal scale
{
- if( pscale->orientation == TOP )
+ if( pscale->orientation == TOP ) {
marker_y = pscale->scr_pos;
- else
- if( pscale->orientation == BOTTOM )
- marker_y = pscale->scr_pos-6;
+ }
+ else {
+ if( pscale->orientation == BOTTOM ) {
+ marker_y = pscale->scr_pos - 6;
+ }
+ }
drawOneLine( pscale->scr_min,
pscale->scr_pos,
pscale->scr_max,
pscale->scr_pos-6 );
}
- else
+ else {
if( pscale->orientation == BOTTOM )
{
drawOneLine( pscale->scr_min,
mid_scr,
pscale->scr_pos+6 );
}
-
+ }
factor = (pscale->scr_max - pscale->scr_min)/pscale->width_units;
- for( i=vmin; i<=vmax; i+=1 )
+ for( i = vmin; i <= vmax; i++ ) // increment is faster than addition
{
- if( pscale->sub_type == LIMIT )
- condition = i>= pscale->minimum_value;
- else
- if( pscale->sub_type == NOLIMIT )
+ if( pscale->sub_type == LIMIT ) {
+ condition = (i >= pscale->minimum_value);
+ }
+ else {
+ if( pscale->sub_type == NOLIMIT ) {
condition = 1;
-
+ }
+ }
if( condition )
{
marker_x = pscale->scr_min+(i-vmin)*factor;
- if( i%pscale->div_min==0 )
+ if( i%pscale->div_min==0 ) {
if( pscale->orientation == TOP )
{
drawOneLine( marker_x, marker_y, marker_x, marker_y+3 );
}
- else
+ else {
if( pscale->orientation == BOTTOM )
{
drawOneLine( marker_x, marker_y+3, marker_x, marker_y+6 );
}
- if( i%pscale->div_max==0 )
+ }
+ }
+ if( i%pscale->div_max==0 )
+ {
+ sprintf( TextScale, "%d", i );
+ if( pscale->orientation == TOP )
{
- sprintf( TextScale, "%d", i );
- if( pscale->orientation == TOP )
+ drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
+ textString ( marker_x-4*strlen(TextScale), marker_y+14,
+ TextScale, GLUT_BITMAP_8_BY_13 );
+ }
+ else {
+ if( pscale->orientation == BOTTOM )
{
drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
- textString ( marker_x-4*strlen(TextScale), marker_y+14,
+ textString ( marker_x+10, marker_y-4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
- else
- if( pscale->orientation == BOTTOM )
- {
- drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
- textString ( marker_x+10, marker_y-4,
- TextScale, GLUT_BITMAP_8_BY_13 );
- }
}
+ }
}
}
}
}
-/*
-
- Draws a climb ladder in the center of the HUD
-
-*/
+//
+// Draws a climb ladder in the center of the HUD
+//
static void drawladder( HUD_ladder *ladder )
{
vmin = pitch_value - ladder->width_units/2;
vmax = pitch_value + ladder->width_units/2;
-
+
scr_min = ladder->y_pos - (ladder->scr_height/2);
scr_max = scr_min + ladder->scr_height;
sprintf( TextLadder, "%d", i );
if( ladder->scr_hole == 0 )
{
- if( i )
+ if( i ) {
x_ini = ladder->x_pos - ladder->scr_width/2;
- else
+ }
+ else {
x_ini = ladder->x_pos - ladder->scr_width/2 - 10;
+ }
y_ini = marker_y;
x_end = ladder->x_pos + ladder->scr_width/2;
y_end = marker_y;
}
else
{
- if( i != 0 )
+ if( i != 0 ) {
x_ini = ladder->x_pos - ladder->scr_width/2;
- else
+ }
+ else {
x_ini = ladder->x_pos - ladder->scr_width/2 - 10;
+ }
y_ini = marker_y;
x_end = ladder->x_pos - ladder->scr_width/2 + ladder->scr_hole/2;
y_end = marker_y;
x_ini = ladder->x_pos + ladder->scr_width/2 - ladder->scr_hole/2;
y_ini = marker_y;
- if( i != 0 )
+ if( i != 0 ) {
x_end = ladder->x_pos + ladder->scr_width/2;
- else
+ }
+ else {
x_end = ladder->x_pos + ladder->scr_width/2 + 10;
+ }
y_end = marker_y;
new_x_ini = ladder->x_pos + \
(x_ini-ladder->x_pos)*cos(roll_value) -\
horizon->x_pos + x_inc1, horizon->y_pos + y_inc1 );
}
}
-/*
- Draws a representation of the control surfaces in their current state
- anywhere in the HUD
-
- Needs: struct HUD_control_surfaces
+// drawControlSurfaces()
+// Draws a representation of the control surfaces in their current state
+// anywhere in the HUD
+//
-*/
static void drawControlSurfaces( HUD_control_surfaces *ctrl_surf )
{
int x_ini, y_ini;
drawOneLine( x_ini + 35 + (int)(((FG_Rudder + 1.0)/2)*50.0), y_ini + 25, \
x_ini + 35 + (int)(((FG_Rudder + 1.0)/2)*50.0), y_ini + 5 );
}
-
-
+
+
/* Draw throttle diagram */
- textString( x_ini + 90 + 1, y_end-11, "T", GLUT_BITMAP_8_BY_13 );
- textString( x_ini + 90 + 1, y_end-21, "r", GLUT_BITMAP_8_BY_13 );
+ textString( x_ini + 90 + 1, y_end-11, "T", GLUT_BITMAP_8_BY_13 );
+ textString( x_ini + 90 + 1, y_end-21, "r", GLUT_BITMAP_8_BY_13 );
drawOneLine( x_ini + 105, y_ini + 5, x_ini + 105, y_ini + 55 );
drawOneLine( x_ini + 100, y_ini + 5 + (int)(FG_Throttle[0]*50.0), \
x_ini + 110, y_ini + 5 + (int)(FG_Throttle[0]*50.0) );
-
-
+
+
/* Draw elevator trim diagram */
- textString( x_ini + 121, y_end-11, "T", GLUT_BITMAP_8_BY_13 );
- textString( x_ini + 121, y_end-22, "m", GLUT_BITMAP_8_BY_13 );
+ textString( x_ini + 121, y_end-11, "T", GLUT_BITMAP_8_BY_13 );
+ textString( x_ini + 121, y_end-22, "m", GLUT_BITMAP_8_BY_13 );
drawOneLine( x_ini + 135, y_ini + 5, x_ini + 135, y_ini + 55 );
drawOneLine( x_ini + 134, y_ini + 30, x_ini + 136, y_ini + 30 );
if( FG_Elev_Trim <= -0.01 || FG_Elev_Trim >= 0.01 )
drawOneLine( x_ini + 127, y_ini + 5 + (int)(((FG_Elev_Trim + 1.0)/2)*50.0), \
x_ini + 143, y_ini + 5 + (int)(((FG_Elev_Trim + 1.0)/2)*50.0) );
}
-
+
}
//
sprintf( string, buffer, (*label->load_value)() );
-
+#ifdef DEBUGHUD
fgPrintf( FG_COCKPIT, FG_DEBUG, buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, string );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
-
+#endif
lenstr = strlen( string );
if( label->justify == LEFT_JUST ) {
posincr = -lenstr*8;
hud->code = 1;
hud->status = 0;
- // For now lets just hardcode the hud here .
+ // For now lets just hardcode the hud here.
// In the future, hud information has to come from the same place
// aircraft information came from.
RIGHT_JUST, NULL, " m", "%5.0f", get_altitude );
fgHUDAddLadder ( hud, 330, 190, 90, 180, 70, 10,
NONE, 45, get_roll, get_pitch );
- // fgHUDAddControlSurfaces( hud, 10, 10, get_heading );
+ fgHUDAddControlSurfaces( hud, 10, 10, get_heading );
return( hud );
}
return hud;
}
+// fgHUDAddControlSurfaces()
+//
+// Adds the control surface indicators which make up for the lack of seat
+// of the pants feel. Should be unnecessary with joystick and pedals
+// enabled. But that is another improvement. Also, what of flaps? Spoilers?
+// This may need to be expanded or flattened into multiple indicators,
+// vertical and horizontal.
+
+Hptr fgHUDAddControlSurfaces( Hptr hud,
+ int x_pos,
+ int y_pos,
+ double (*load_value)() )
+{
+ HUD_control_surfaces *pctrl_surf;
+ HUD_instr *pinstrument;
+
+ if( !hud ) {
+ return NULL;
+ }
+
+ // Construct shell
+ pinstrument = (HIptr)calloc(sizeof(HUD_instr),1);
+ if( !pinstrument )
+ return NULL;
+
+ pinstrument->type = HUDcontrols;
+
+ // Construct core
+ pctrl_surf = (HUD_control_surfaces *)calloc(sizeof(HUD_control_surfaces),1);
+ if( !(pctrl_surf == NULL) )
+ return( NULL );
+
+ pctrl_surf->x_pos = x_pos;
+ pctrl_surf->y_pos = y_pos;
+ pctrl_surf->load_value = load_value;
+ // Integrate
+ pinstrument->instr = pctrl_surf;
+ // Install
+ add_instrument( hud, pinstrument);
+
+ return hud;
+}
+
+
/*
Hptr fgHUDAddMovingHorizon( Hptr hud, \
int x_pos, \
glLineWidth(1);
glColor3f (0.1, 0.9, 0.1);
- fgPrintf( FG_COCKPIT, FG_DEBUG,
- "HUD Code %d Status %d\n",
- hud->code, hud->status );
+ fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n",
+ hud->code, hud->status );
phud_instr = hud->instruments;
while( phud_instr ) {
case HUDcontrols:
drawControlSurfaces( (pHUDControlSurface) phud_instr->instr );
+ break;
default:; // Ignore anything you don't know about.
}
/* $Log$
-/* Revision 1.13 1998/02/11 02:50:19 curt
-/* Added changes submitted by Michele America.
+/* Revision 1.14 1998/02/12 21:59:41 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
* Revision 1.12 1998/02/09 15:07:48 curt
* Minor tweaks.