1
0
Fork 0

Fixed some warnings, updated whitespace.

This commit is contained in:
curt 2001-06-12 23:37:29 +00:00
parent 3d0ed99651
commit d0126ec533
5 changed files with 515 additions and 524 deletions

View file

@ -714,7 +714,7 @@ void fgCockpitUpdate( void ) {
int iwidth = xsize_node->getIntValue();
int iheight = ysize_node->getIntValue();
float width = iwidth;
float height = iheight;
// float height = iheight;
// FIXME: inefficient
if ( hud_visibility_node->getBoolValue() ) {

View file

@ -831,131 +831,132 @@ static puSlider *HUDalphaHS0;
static char SliderText[2][ 8 ];
static void alpha_adj( puObject *hs ) {
float val ;
float val ;
hs-> getValue ( &val ) ;
fgAP_CLAMP ( val, 0.1, 1.0 ) ;
// printf ( "maxroll_adj( %p ) %f %f\n", hs, val, MaxRollAdjust * val ) ;
hud_trans_alpha = val;
sprintf( SliderText[ 0 ], "%05.2f", hud_trans_alpha );
HUDalphaText -> setLabel ( SliderText[ 0 ] ) ;
hs-> getValue ( &val ) ;
fgAP_CLAMP ( val, 0.1, 1.0 ) ;
// printf ( "maxroll_adj( %p ) %f %f\n", hs, val, MaxRollAdjust * val ) ;
hud_trans_alpha = val;
sprintf( SliderText[ 0 ], "%05.2f", hud_trans_alpha );
HUDalphaText -> setLabel ( SliderText[ 0 ] ) ;
}
void fgHUDalphaAdjust( puObject * ) {
fgSetBool("/sim/hud/antialiased", true);
FG_PUSH_PUI_DIALOG( HUDalphaDialog );
fgSetBool("/sim/hud/antialiased", true);
FG_PUSH_PUI_DIALOG( HUDalphaDialog );
}
static void goAwayHUDalphaAdjust (puObject *)
{
FG_POP_PUI_DIALOG( HUDalphaDialog );
FG_POP_PUI_DIALOG( HUDalphaDialog );
}
static void cancelHUDalphaAdjust (puObject *)
{
fgSetBool("/sim/hud/antialiased", false);
FG_POP_PUI_DIALOG( HUDalphaDialog );
fgSetBool("/sim/hud/antialiased", false);
FG_POP_PUI_DIALOG( HUDalphaDialog );
}
// Done once at system initialization
void fgHUDalphaInit( void ) {
// printf("fgHUDalphaInit\n");
// printf("fgHUDalphaInit\n");
#define HORIZONTAL FALSE
int DialogX = 40;
int DialogY = 100;
int DialogWidth = 240;
int DialogX = 40;
int DialogY = 100;
int DialogWidth = 240;
char Label[] = "HUD Adjuster";
char *s;
char Label[] = "HUD Adjuster";
char *s;
int labelX = (DialogWidth / 2) -
(puGetStringWidth( puGetDefaultLabelFont(), Label ) / 2);
int labelX = (DialogWidth / 2) -
(puGetStringWidth( puGetDefaultLabelFont(), Label ) / 2);
int nSliders = 1;
int slider_x = 10;
int slider_y = 55;
int slider_width = 220;
int slider_title_x = 15;
int slider_value_x = 160;
float slider_delta = 0.05f;
int nSliders = 1;
int slider_x = 10;
int slider_y = 55;
int slider_width = 220;
int slider_title_x = 15;
int slider_value_x = 160;
float slider_delta = 0.05f;
puFont HUDalphaLegendFont;
puFont HUDalphaLabelFont;
puGetDefaultFonts ( &HUDalphaLegendFont, &HUDalphaLabelFont );
puFont HUDalphaLegendFont;
puFont HUDalphaLabelFont;
puGetDefaultFonts ( &HUDalphaLegendFont, &HUDalphaLabelFont );
HUDalphaDialog = new puDialogBox ( DialogX, DialogY ); {
int horiz_slider_height = puGetStringHeight (HUDalphaLabelFont) +
puGetStringDescender (HUDalphaLabelFont) +
PUSTR_TGAP + PUSTR_BGAP + 5;
HUDalphaDialog = new puDialogBox ( DialogX, DialogY ); {
int horiz_slider_height = puGetStringHeight (HUDalphaLabelFont) +
puGetStringDescender (HUDalphaLabelFont) +
PUSTR_TGAP + PUSTR_BGAP + 5;
puFrame *
HUDalphaFrame = new puFrame ( 0, 0,
DialogWidth,
85 + nSliders * horiz_slider_height );
/* puFrame *
HUDalphaFrame = new puFrame ( 0, 0, DialogWidth,
85 + nSliders
* horiz_slider_height ); */
puText *
HUDalphaDialogMessage = new puText ( labelX,
52 + nSliders
* horiz_slider_height );
HUDalphaDialogMessage -> setDefaultValue ( Label );
HUDalphaDialogMessage -> getDefaultValue ( &s );
HUDalphaDialogMessage -> setLabel ( s );
HUDalphaHS0 = new puSlider ( slider_x, slider_y,
slider_width, HORIZONTAL ) ;
HUDalphaHS0-> setDelta ( slider_delta ) ;
HUDalphaHS0-> setValue ( hud_trans_alpha ) ;
HUDalphaHS0-> setCBMode ( PUSLIDER_DELTA ) ;
HUDalphaHS0-> setCallback ( alpha_adj ) ;
puText *
HUDalphaTitle = new puText ( slider_title_x, slider_y ) ;
HUDalphaTitle-> setDefaultValue ( "Alpha" ) ;
HUDalphaTitle-> getDefaultValue ( &s ) ;
HUDalphaTitle-> setLabel ( s ) ;
puText *
HUDalphaDialogMessage = new puText ( labelX,
52 + nSliders
* horiz_slider_height );
HUDalphaDialogMessage -> setDefaultValue ( Label );
HUDalphaDialogMessage -> getDefaultValue ( &s );
HUDalphaDialogMessage -> setLabel ( s );
HUDalphaText = new puText ( slider_value_x, slider_y ) ;
sprintf( SliderText[ 0 ], "%05.2f", hud_trans_alpha );
HUDalphaText-> setLabel ( SliderText[ 0 ] ) ;
HUDalphaHS0 = new puSlider ( slider_x, slider_y,
slider_width, HORIZONTAL ) ;
HUDalphaHS0-> setDelta ( slider_delta ) ;
HUDalphaHS0-> setValue ( hud_trans_alpha ) ;
HUDalphaHS0-> setCBMode ( PUSLIDER_DELTA ) ;
HUDalphaHS0-> setCallback ( alpha_adj ) ;
puOneShot *
HUDalphaOkButton = new puOneShot ( 10, 10, 60, 45 );
HUDalphaOkButton-> setLegend ( gui_msg_OK );
HUDalphaOkButton-> makeReturnDefault ( TRUE );
HUDalphaOkButton-> setCallback ( goAwayHUDalphaAdjust );
puText *
HUDalphaTitle = new puText ( slider_title_x, slider_y ) ;
HUDalphaTitle-> setDefaultValue ( "Alpha" ) ;
HUDalphaTitle-> getDefaultValue ( &s ) ;
HUDalphaTitle-> setLabel ( s ) ;
HUDalphaText = new puText ( slider_value_x, slider_y ) ;
sprintf( SliderText[ 0 ], "%05.2f", hud_trans_alpha );
HUDalphaText-> setLabel ( SliderText[ 0 ] ) ;
puOneShot *
HUDalphaOkButton = new puOneShot ( 10, 10, 60, 45 );
HUDalphaOkButton-> setLegend ( gui_msg_OK );
HUDalphaOkButton-> makeReturnDefault ( TRUE );
HUDalphaOkButton-> setCallback ( goAwayHUDalphaAdjust );
puOneShot *
HUDalphaNoButton = new puOneShot ( 160, 10, 230, 45 );
HUDalphaNoButton-> setLegend ( gui_msg_CANCEL );
HUDalphaNoButton-> setCallback ( cancelHUDalphaAdjust );
}
FG_FINALIZE_PUI_DIALOG( HUDalphaDialog );
puOneShot *
HUDalphaNoButton = new puOneShot ( 160, 10, 230, 45 );
HUDalphaNoButton-> setLegend ( gui_msg_CANCEL );
HUDalphaNoButton-> setCallback ( cancelHUDalphaAdjust );
}
FG_FINALIZE_PUI_DIALOG( HUDalphaDialog );
#undef HORIZONTAL
}
void fgHUDReshape(void) {
if ( HUDtext )
delete HUDtext;
HUD_TextSize = fgGetInt("/sim/startup/xsize") / 60;
HUD_TextSize = 10;
HUDtext = new fntRenderer();
HUDtext -> setFont ( guiFntHandle ) ;
HUDtext -> setPointSize ( HUD_TextSize ) ;
HUD_TextList.setFont( HUDtext );
void fgHUDReshape(void) {
if ( HUDtext )
delete HUDtext;
HUD_TextSize = fgGetInt("/sim/startup/xsize") / 60;
HUD_TextSize = 10;
HUDtext = new fntRenderer();
HUDtext -> setFont ( guiFntHandle ) ;
HUDtext -> setPointSize ( HUD_TextSize ) ;
HUD_TextList.setFont( HUDtext );
}
static void set_hud_color(float r, float g, float b) {
fgGetBool("/sim/hud/antialiased") ?
glColor4f(r,g,b,hud_trans_alpha) :
glColor3f(r,g,b);
fgGetBool("/sim/hud/antialiased") ?
glColor4f(r,g,b,hud_trans_alpha) :
glColor3f(r,g,b);
}
// fgUpdateHUD
//
// Performs a once around the list of calls to instruments installed in

View file

@ -74,21 +74,21 @@ hud_card ::
hud_card ::
hud_card( const hud_card & image):
instr_scale( (const instr_scale & ) image),
val_span( image.val_span),
half_width_units (image.half_width_units),
draw_tick_bottom (image.draw_tick_bottom),
draw_tick_top (image.draw_tick_top),
draw_tick_right (image.draw_tick_right),
draw_tick_left (image.draw_tick_left),
draw_cap_bottom (image.draw_cap_bottom),
draw_cap_top (image.draw_cap_top),
draw_cap_right (image.draw_cap_right),
draw_cap_left (image.draw_cap_left),
marker_offset (image.marker_offset),
type(image.type),
pointer (image.pointer),
pointer_type (image.pointer_type)
instr_scale( (const instr_scale & ) image),
val_span( image.val_span),
type(image.type),
half_width_units (image.half_width_units),
draw_tick_bottom (image.draw_tick_bottom),
draw_tick_top (image.draw_tick_top),
draw_tick_right (image.draw_tick_right),
draw_tick_left (image.draw_tick_left),
draw_cap_bottom (image.draw_cap_bottom),
draw_cap_top (image.draw_cap_top),
draw_cap_right (image.draw_cap_right),
draw_cap_left (image.draw_cap_left),
marker_offset (image.marker_offset),
pointer (image.pointer),
pointer_type (image.pointer_type)
{
// UINT options = get_options();
@ -104,10 +104,10 @@ hud_card( const hud_card & image):
hud_card & hud_card ::
operator = (const hud_card & rhs )
{
if( !( this == &rhs)){
instr_scale::operator = (rhs);
val_span = rhs.val_span;
half_width_units = rhs.half_width_units;
if( !( this == &rhs)){
instr_scale::operator = (rhs);
val_span = rhs.val_span;
half_width_units = rhs.half_width_units;
draw_tick_bottom = rhs.draw_tick_bottom;
draw_tick_top = rhs.draw_tick_top;
draw_tick_right = rhs.draw_tick_right;
@ -120,79 +120,75 @@ operator = (const hud_card & rhs )
type = rhs.type;
pointer = rhs.pointer;
pointer_type = rhs.pointer_type;
}
}
return *this;
return *this;
}
void hud_card ::
draw( void ) // (HUD_scale * pscale )
{
float vmin, vmax;
int marker_xs;
int marker_xe;
int marker_ys;
int marker_ye;
int text_x, text_y;
int lenstr;
int height, width;
int i, last;
char TextScale[80];
bool condition;
int disp_val = 0;
float vmin = 0.0, vmax = 0.0;
int marker_xs;
int marker_xe;
int marker_ys;
int marker_ye;
int text_x = 0, text_y = 0;
int lenstr;
int height, width;
int i, last;
char TextScale[80];
bool condition;
int disp_val = 0;
POINT mid_scr = get_centroid();
float cur_value = get_value();
RECT scrn_rect = get_location();
UINT options = get_options();
POINT mid_scr = get_centroid();
float cur_value = get_value();
RECT scrn_rect = get_location();
UINT options = get_options();
height = scrn_rect.top + scrn_rect.bottom;
width = scrn_rect.left + scrn_rect.right;
height = scrn_rect.top + scrn_rect.bottom;
width = scrn_rect.left + scrn_rect.right;
if(type=="guage") {
if(type=="guage") {
vmin = min_val();
vmax = max_val();
text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
text_x = marker_xs;
}
else
if(type=="tape") {
vmin = min_val();
vmax = max_val();
text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
text_x = marker_xs;
} else {
if(type=="tape") {
vmin = cur_value - half_width_units; // width units == needle travel
vmax = cur_value + half_width_units; // or picture unit span.
text_x = mid_scr.x;
text_y = mid_scr.y;
}
vmin = cur_value - half_width_units; // width units == needle travel
vmax = cur_value + half_width_units; // or picture unit span.
text_x = mid_scr.x;
text_y = mid_scr.y;
}
}
// Draw the basic markings for the scale...
// Draw the basic markings for the scale...
if( huds_vert(options) ) { // Vertical scale
if (draw_tick_bottom) {
drawOneLine( scrn_rect.left, // Bottom tick bar
scrn_rect.top,
width,
scrn_rect.top);
} // endif draw_tick_bottom
if (draw_tick_top) {
drawOneLine( scrn_rect.left, // Top tick bar
height,
width,
height );
} // endif draw_tick_top
if( huds_vert(options) ) { // Vertical scale
if (draw_tick_bottom) {
drawOneLine( scrn_rect.left, // Bottom tick bar
scrn_rect.top,
width,
scrn_rect.top);
} // endif draw_tick_bottom
if (draw_tick_top) {
drawOneLine( scrn_rect.left, // Top tick bar
height,
width,
height );
} // endif draw_tick_top
marker_xs = scrn_rect.left; // x start
marker_xe = width; // x extent
marker_ye = height;
marker_xs = scrn_rect.left; // x start
marker_xe = width; // x extent
marker_ye = height;
// glBegin(GL_LINES);
// Bottom tick bar
// Bottom tick bar
// glVertex2f( marker_xs, scrn_rect.top);
// glVertex2f( marker_xe, scrn_rect.top);
@ -202,212 +198,208 @@ draw( void ) // (HUD_scale * pscale )
// glEnd();
// We do not use else in the following so that combining the two
// options produces a "caged" display with double carrots. The
// same is done for horizontal card indicators.
// We do not use else in the following so that combining the
// two options produces a "caged" display with double
// carrots. The same is done for horizontal card indicators.
if( huds_left(options) ) { // Calculate x marker offset
if( huds_left(options) ) { // Calculate x marker offset
if (draw_cap_right) {
if (draw_cap_right) {
drawOneLine( marker_xe, scrn_rect.top,
marker_xe, marker_ye); // Cap right side
} //endif cap_right
drawOneLine( marker_xe, scrn_rect.top,
marker_xe, marker_ye); // Cap right side
} //endif cap_right
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
// drawOneLine( marker_xs, mid_scr.y,
// marker_xe, mid_scr.y + scrn_rect.right / 6);
// drawOneLine( marker_xs, mid_scr.y,
// marker_xe, mid_scr.y - scrn_rect.right / 6);
// drawOneLine( marker_xs, mid_scr.y,
// marker_xe, mid_scr.y + scrn_rect.right / 6);
// drawOneLine( marker_xs, mid_scr.y,
// marker_xe, mid_scr.y - scrn_rect.right / 6);
// draw pointer
if(pointer) {
if(pointer_type=="fixed") {
glBegin(GL_LINE_STRIP);
glVertex2f( marker_offset+marker_xe, text_y + scrn_rect.right / 6);
glVertex2f( marker_offset+marker_xs, text_y);
glVertex2f( marker_offset+marker_xe, text_y - scrn_rect.right / 6);
glEnd();
}
else
if(pointer_type=="moving") {
//Code for Moving Type Pointer to be included.
}
}
// draw pointer
if(pointer) {
if(pointer_type=="fixed") {
glBegin(GL_LINE_STRIP);
glVertex2f( marker_offset+marker_xe, text_y + scrn_rect.right / 6);
glVertex2f( marker_offset+marker_xs, text_y);
glVertex2f( marker_offset+marker_xe, text_y - scrn_rect.right / 6);
glEnd();
} else {
if(pointer_type=="moving") {
//Code for Moving Type Pointer to be included.
}
}
}
}
}
if( huds_right(options) ) { // We'll default this for now.
if (draw_cap_left) {
drawOneLine( scrn_rect.left, scrn_rect.top,
scrn_rect.left, marker_ye ); // Cap left side
} //endif cap_left
if( huds_right(options) ) { // We'll default this for now.
if (draw_cap_left) {
drawOneLine( scrn_rect.left, scrn_rect.top,
scrn_rect.left, marker_ye ); // Cap left side
} //endif cap_left
marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
// Indicator carrot
// drawOneLine( scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
// marker_xe, mid_scr.y );
// drawOneLine( scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
// marker_xe, mid_scr.y);
marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
// Indicator carrot
// drawOneLine( scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
// marker_xe, mid_scr.y );
// drawOneLine( scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
// marker_xe, mid_scr.y);
// draw pointer
if(pointer) {
if(pointer_type=="fixed") {
glBegin(GL_LINE_STRIP);
glVertex2f( -marker_offset+scrn_rect.left, text_y + scrn_rect.right / 6);
glVertex2f( -marker_offset+marker_xe, text_y );
glVertex2f( -marker_offset+scrn_rect.left, text_y - scrn_rect.right / 6);
glEnd();
}
else
if(pointer_type=="moving") {
// Code for Moving Type Pointer to be included.
}
}
}
// draw pointer
if(pointer) {
if(pointer_type=="fixed") {
glBegin(GL_LINE_STRIP);
glVertex2f( -marker_offset+scrn_rect.left, text_y + scrn_rect.right / 6);
glVertex2f( -marker_offset+marker_xe, text_y );
glVertex2f( -marker_offset+scrn_rect.left, text_y - scrn_rect.right / 6);
glEnd();
}
else {
if(pointer_type=="moving") {
// Code for Moving Type Pointer to be included.
}
}
}
}
// At this point marker x_start and x_end values are transposed.
// To keep this from confusing things they are now interchanged.
if(huds_both(options)) {
marker_ye = marker_xs;
marker_xs = marker_xe;
marker_xe = marker_ye;
}
// At this point marker x_start and x_end values are transposed.
// To keep this from confusing things they are now interchanged.
if(huds_both(options)) {
marker_ye = marker_xs;
marker_xs = marker_xe;
marker_xe = marker_ye;
}
// Work through from bottom to top of scale. Calculating where to put
// minor and major ticks.
// Work through from bottom to top of scale. Calculating where to put
// minor and major ticks.
// draw scale or tape
// draw scale or tape
// last = FloatToInt(vmax)+1;
// i = FloatToInt(vmin);
last = (int)vmax + 1;
i = (int)vmin;
for( ; i <last ; i++ )
{
condition = true;
if( !modulo()) {
if( i < min_val()) {
condition = false;
}
}
last = (int)vmax + 1;
i = (int)vmin;
for( ; i <last ; i++ ) {
condition = true;
if( !modulo()) {
if( i < min_val()) {
condition = false;
}
}
if( condition ) { // Show a tick if necessary
// Calculate the location of this tick
marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
// marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
// Block calculation artifact from drawing ticks below min coordinate.
// Calculation here accounts for text height.
if( condition ) { // Show a tick if necessary
// Calculate the location of this tick
marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
// marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
// Block calculation artifact from drawing ticks below min coordinate.
// Calculation here accounts for text height.
if(( marker_ys < (scrn_rect.top + 4)) |
( marker_ys > (height - 4))) {
// Magic numbers!!!
continue;
}
if( div_min()) {
// if( (i%div_min()) == 0) {
if( !(i%(int)div_min())) {
if((( marker_ys - 5) > scrn_rect.top ) &&
(( marker_ys + 5) < (height))){
if( huds_both(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs, marker_ys );
drawOneLine( marker_xe, marker_ys,
width, marker_ys );
// glBegin(GL_LINES);
// glVertex2f( scrn_rect.left, marker_ys );
// glVertex2f( marker_xs, marker_ys );
// glVertex2f( marker_xe, marker_ys);
// glVertex2f( scrn_rect.left + scrn_rect.right, marker_ys );
// glEnd();
}
else {
if( huds_left(options) ) {
drawOneLine( marker_xs + 4, marker_ys,
marker_xe, marker_ys );
}
else {
drawOneLine( marker_xs, marker_ys,
marker_xe - 4, marker_ys );
}
}
}
}
}
if( div_max() ) {
if( !(i%(int)div_max()) )
{
if(modulo()) {
if( disp_val < 0) {
while(disp_val < 0)
disp_val += modulo();
// } else {
// disp_val = i % (int)modulo();
}
disp_val = i % (int) modulo(); // ?????????
} else {
disp_val = i;
}
if(( marker_ys < (scrn_rect.top + 4)) |
( marker_ys > (height - 4)))
{
// Magic numbers!!!
continue;
}
if( div_min()) {
// if( (i%div_min()) == 0) {
if( !(i%(int)div_min())) {
if((( marker_ys - 5) > scrn_rect.top ) &&
(( marker_ys + 5) < (height))){
if( huds_both(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs, marker_ys );
drawOneLine( marker_xe, marker_ys,
width, marker_ys );
// glBegin(GL_LINES);
// glVertex2f( scrn_rect.left, marker_ys );
// glVertex2f( marker_xs, marker_ys );
// glVertex2f( marker_xe, marker_ys);
// glVertex2f( scrn_rect.left + scrn_rect.right, marker_ys );
// glEnd();
} else {
if( huds_left(options) ) {
drawOneLine( marker_xs + 4, marker_ys,
marker_xe, marker_ys );
} else {
drawOneLine( marker_xs, marker_ys,
marker_xe - 4, marker_ys );
}
}
}
}
}
lenstr = sprintf( TextScale, "%d",
FloatToInt(disp_val * data_scaling()/*+.5*/));
// (int)(disp_val * data_scaling() +.5));
if(( (marker_ys - 8 ) > scrn_rect.top ) &&
( (marker_ys + 8) < (height))){
if( huds_both(options) ) {
// drawOneLine( scrn_rect.left, marker_ys,
// marker_xs, marker_ys);
// drawOneLine( marker_xs, marker_ys,
// scrn_rect.left + scrn_rect.right,
// marker_ys);
glBegin(GL_LINE_STRIP);
glVertex2f( scrn_rect.left, marker_ys );
glVertex2f( marker_xs, marker_ys);
glVertex2f( width, marker_ys);
glEnd();
if( !huds_notext(options)) {
textString ( marker_xs + 2, marker_ys,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
else {
drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
if( !huds_notext(options) ) {
if( huds_left(options) ) {
textString( marker_xs - 8 * lenstr - 2,
marker_ys - 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
else {
textString( marker_xe + 3 * lenstr,
marker_ys - 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
}
} // Else read oriented right
} // End if modulo division by major interval is zero
} // End if major interval divisor non-zero
} // End if condition
} // End for range of i from vmin to vmax
} // End if VERTICAL SCALE TYPE
else { // Horizontal scale by default
// left tick bar
if( div_max() ) {
if( !(i%(int)div_max()) ) {
if(modulo()) {
if( disp_val < 0) {
while(disp_val < 0)
disp_val += modulo();
// } else {
// disp_val = i % (int)modulo();
}
disp_val = i % (int) modulo(); // ?????????
} else {
disp_val = i;
}
lenstr = sprintf( TextScale, "%d",
FloatToInt(disp_val * data_scaling()/*+.5*/));
// (int)(disp_val * data_scaling() +.5));
if(( (marker_ys - 8 ) > scrn_rect.top ) &&
( (marker_ys + 8) < (height))){
if( huds_both(options) ) {
// drawOneLine( scrn_rect.left, marker_ys,
// marker_xs, marker_ys);
// drawOneLine( marker_xs, marker_ys,
// scrn_rect.left + scrn_rect.right,
// marker_ys);
glBegin(GL_LINE_STRIP);
glVertex2f( scrn_rect.left, marker_ys );
glVertex2f( marker_xs, marker_ys);
glVertex2f( width, marker_ys);
glEnd();
if( !huds_notext(options)) {
textString ( marker_xs + 2, marker_ys,
TextScale, GLUT_BITMAP_8_BY_13 );
}
} else {
drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
if( !huds_notext(options) ) {
if( huds_left(options) ) {
textString( marker_xs - 8 * lenstr - 2,
marker_ys - 4,
TextScale, GLUT_BITMAP_8_BY_13 );
} else {
textString( marker_xe + 3 * lenstr,
marker_ys - 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
}
} // Else read oriented right
} // End if modulo division by major interval is zero
} // End if major interval divisor non-zero
} // End if condition
} // End for range of i from vmin to vmax
} // End if VERTICAL SCALE TYPE
else { // Horizontal scale by default
// left tick bar
if (draw_tick_left) {
drawOneLine( scrn_rect.left, scrn_rect.top,
scrn_rect.left, height);
drawOneLine( scrn_rect.left, scrn_rect.top,
scrn_rect.left, height);
} // endif draw_tick_left
// right tick bar
// right tick bar
if (draw_tick_right) {
drawOneLine( width, scrn_rect.top,
width,
height );
drawOneLine( width, scrn_rect.top,
width,
height );
} // endif draw_tick_right
marker_ys = scrn_rect.top; // Starting point for
marker_ye = height; // tick y location calcs
marker_xe = width;
marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
marker_ys = scrn_rect.top; // Starting point for
marker_ye = height; // tick y location calcs
marker_xe = width;
marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
// glBegin(GL_LINES);
@ -421,69 +413,68 @@ draw( void ) // (HUD_scale * pscale )
// glEnd();
if( huds_top(options) ) {
if (draw_cap_bottom) {
// Bottom box line
drawOneLine( scrn_rect.left,
scrn_rect.top,
width,
scrn_rect.top);
} //endif cap_bottom
// Tick point adjust
marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
// Bottom arrow
// drawOneLine( mid_scr.x, marker_ye,
// mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
// drawOneLine( mid_scr.x, marker_ye,
// mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
// draw pointer
if(pointer) {
if(pointer_type=="fixed") {
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs - scrn_rect.bottom / 4, scrn_rect.top);
glVertex2f( marker_xs, marker_ye);
glVertex2f( marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
glEnd();
}
else
if(pointer_type=="moving") {
// Code for Moving type Pointer to be included.
}
}
if (draw_cap_bottom) {
// Bottom box line
drawOneLine( scrn_rect.left,
scrn_rect.top,
width,
scrn_rect.top);
} //endif cap_bottom
// Tick point adjust
marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
// Bottom arrow
// drawOneLine( mid_scr.x, marker_ye,
// mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
// drawOneLine( mid_scr.x, marker_ye,
// mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
// draw pointer
if(pointer) {
if(pointer_type=="fixed") {
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs - scrn_rect.bottom / 4, scrn_rect.top);
glVertex2f( marker_xs, marker_ye);
glVertex2f( marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
glEnd();
} else {
if(pointer_type=="moving") {
// Code for Moving type Pointer to be included.
}
}
}
}
if( huds_bottom(options) ) {
// Top box line
if (draw_cap_top) {
drawOneLine( scrn_rect.left, height,
width, height);
} //endif cap_top
// Tick point adjust
marker_ys = height - scrn_rect.bottom / 2;
// Top arrow
// drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
// scrn_rect.top + scrn_rect.bottom,
// mid_scr.x, marker_ys );
// drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
// scrn_rect.top + scrn_rect.bottom,
// mid_scr.x , marker_ys );
// draw pointer
if(pointer) {
if(pointer_type=="fixed") {
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs + scrn_rect.bottom / 4, height);
glVertex2f( marker_xs, marker_ys );
glVertex2f( marker_xs - scrn_rect.bottom / 4, height);
glEnd();
}
else
if(pointer_type=="moving") {
// Code for Moving Type Pointer to be included.
}
}//if pointer
// Top box line
if (draw_cap_top) {
drawOneLine( scrn_rect.left, height,
width, height);
} //endif cap_top
// Tick point adjust
marker_ys = height - scrn_rect.bottom / 2;
// Top arrow
// drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
// scrn_rect.top + scrn_rect.bottom,
// mid_scr.x, marker_ys );
// drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
// scrn_rect.top + scrn_rect.bottom,
// mid_scr.x , marker_ys );
// draw pointer
if(pointer) {
if(pointer_type=="fixed") {
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs + scrn_rect.bottom / 4, height);
glVertex2f( marker_xs, marker_ys );
glVertex2f( marker_xs - scrn_rect.bottom / 4, height);
glEnd();
} else {
if(pointer_type=="moving") {
// Code for Moving Type Pointer to be included.
}
}
}//if pointer
}
@ -497,113 +488,109 @@ draw( void ) // (HUD_scale * pscale )
// last = FloatToInt(vmax)+1;
// i = FloatToInt(vmin);
last = (int)vmax + 1;
i = (int)vmin;
for(; i <last ; i++ ) {
// for( i = (int)vmin; i <= (int)vmax; i++ ) {
// printf("<*> i = %d\n", i);
condition = true;
if( !modulo()) {
if( i < min_val()) {
condition = false;
}
}
// printf("<**> i = %d\n", i);
if( condition ) {
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
if( div_min()){
// if( (i%(int)div_min()) == 0 ) {
if( !(i%(int)div_min() )) {
// draw in ticks only if they aren't too close to the edge.
if((( marker_xs - 5) > scrn_rect.left ) &&
(( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys - 4);
drawOneLine( marker_xs, marker_ye + 4,
marker_xs, height);
// glBegin(GL_LINES);
// glVertex2f( marker_xs, scrn_rect.top);
// glVertex2f( marker_xs, marker_ys - 4);
// glVertex2f( marker_xs, marker_ye + 4);
// glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
// glEnd();
}
else {
if( huds_top(options)) {
// draw minor ticks
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye - 4);
}
else {
drawOneLine( marker_xs, marker_ys + 4,
marker_xs, marker_ye);
}
}
}
}
}
last = (int)vmax + 1;
i = (int)vmin;
for(; i <last ; i++ ) {
// for( i = (int)vmin; i <= (int)vmax; i++ ) {
// printf("<*> i = %d\n", i);
condition = true;
if( !modulo()) {
if( i < min_val()) {
condition = false;
}
}
// printf("<**> i = %d\n", i);
if( condition ) {
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
if( div_min()){
// if( (i%(int)div_min()) == 0 ) {
if( !(i%(int)div_min() )) {
// draw in ticks only if they aren't too close to the edge.
if((( marker_xs - 5) > scrn_rect.left ) &&
(( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys - 4);
drawOneLine( marker_xs, marker_ye + 4,
marker_xs, height);
// glBegin(GL_LINES);
// glVertex2f( marker_xs, scrn_rect.top);
// glVertex2f( marker_xs, marker_ys - 4);
// glVertex2f( marker_xs, marker_ye + 4);
// glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
// glEnd();
} else {
if( huds_top(options)) {
// draw minor ticks
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye - 4);
} else {
drawOneLine( marker_xs, marker_ys + 4,
marker_xs, marker_ye);
}
}
}
}
}
// printf("<***> i = %d\n", i);
if( div_max()) {
// printf("i = %d\n", i);
// if( (i%(int)div_max())==0 ) {
if( !(i%(int)div_max()) ) {
if(modulo()) {
if( disp_val < 0) {
while(disp_val<0)
disp_val += modulo();
}
disp_val = i % (int) modulo(); // ?????????
} else {
disp_val = i;
}
if( div_max()) {
// printf("i = %d\n", i);
// if( (i%(int)div_max())==0 ) {
if( !(i%(int)div_max()) ) {
if(modulo()) {
if( disp_val < 0) {
while(disp_val<0)
disp_val += modulo();
}
disp_val = i % (int) modulo(); // ?????????
} else {
disp_val = i;
}
// printf("disp_val = %d\n", disp_val);
// printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
lenstr = sprintf( TextScale, "%d",
// (int)(disp_val * data_scaling() +.5));
FloatToInt(disp_val * data_scaling()/*+.5*/));
// Draw major ticks and text only if far enough from the edge.
if(( (marker_xs - 10)> scrn_rect.left ) &&
( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
if( huds_both(options) ) {
// drawOneLine( marker_xs, scrn_rect.top,
// marker_xs, marker_ys);
// drawOneLine( marker_xs, marker_ye,
// marker_xs, scrn_rect.top + scrn_rect.bottom);
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs, scrn_rect.top);
glVertex2f( marker_xs, marker_ye);
glVertex2f( marker_xs, height);
glEnd();
if( !huds_notext(options) ) {
textString ( marker_xs - 4 * lenstr,
marker_ys + 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
else {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye );
if( !huds_notext(options)) {
if( huds_top(options) ) {
textString ( marker_xs - 4 * lenstr,
height - 10,
TextScale, GLUT_BITMAP_8_BY_13 );
}
else {
textString( marker_xs - 4 * lenstr,
scrn_rect.top,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
}
}
}
}
lenstr = sprintf( TextScale, "%d",
// (int)(disp_val * data_scaling() +.5));
FloatToInt(disp_val * data_scaling()/*+.5*/));
// Draw major ticks and text only if far enough from the edge.
if(( (marker_xs - 10)> scrn_rect.left ) &&
( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
if( huds_both(options) ) {
// drawOneLine( marker_xs, scrn_rect.top,
// marker_xs, marker_ys);
// drawOneLine( marker_xs, marker_ye,
// marker_xs, scrn_rect.top + scrn_rect.bottom);
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs, scrn_rect.top);
glVertex2f( marker_xs, marker_ye);
glVertex2f( marker_xs, height);
glEnd();
if( !huds_notext(options) ) {
textString ( marker_xs - 4 * lenstr,
marker_ys + 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
} else {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye );
if( !huds_notext(options)) {
if( huds_top(options) ) {
textString ( marker_xs - 4 * lenstr,
height - 10,
TextScale, GLUT_BITMAP_8_BY_13 );
} else {
textString( marker_xs - 4 * lenstr,
scrn_rect.top,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
}
}
}
}
// printf("<****> i = %d\n", i);
}
}
}
}
}
}
} //draw

View file

@ -45,12 +45,12 @@ HudLadder :: HudLadder( string name,
factor ( factr ),
hudladder_type ( name ),
frl ( frl_spot ),
target_spot ( target ),
velocity_vector ( vel_vec ),
drift_marker ( drift ),
alpha_bracket ( alpha ),
energy_marker ( energy ),
climb_dive_marker ( climb ),
target_spot ( target ),
glide_slope_marker ( glide ),
glide_slope ( glide_slope_val),
energy_worm ( worm_energy),
@ -79,12 +79,12 @@ HudLadder( const HudLadder & image ) :
factor ( image.factor ),
hudladder_type ( image.hudladder_type),
frl ( image.frl),
target_spot ( image.target_spot),
velocity_vector ( image.velocity_vector),
drift_marker ( image.drift_marker),
alpha_bracket ( image.alpha_bracket),
energy_marker ( image.energy_marker),
climb_dive_marker ( image.climb_dive_marker),
target_spot ( image.target_spot),
glide_slope_marker ( image.glide_slope_marker),
glide_slope ( image.glide_slope),
energy_worm ( image.energy_worm),
@ -127,15 +127,17 @@ void HudLadder :: draw( void )
float x_ini,x_ini2;
float x_end,x_end2;
float y;
float y = 0;
int count;
float cosine, sine,xvvr,yvvr,Vxx,Vyy,Vzz,up_vel,ground_vel,actslope;
float Axx,Ayy,Azz,total_vel,pot_slope,t1,t2,psi,alpha,pla;
float vel_x,vel_y,drift;
char Textaux[8] ;
bool pitch_ladder;
bool climb_dive_ladder;
bool clip_plane;
float cosine, sine, xvvr, yvvr, Vxx = 0.0, Vyy = 0.0, Vzz = 0.0,
up_vel, ground_vel, actslope = 0.0;
float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1,
t2 = 0.0, psi = 0.0, alpha,pla;
float vel_x = 0.0, vel_y = 0.0, drift;
// char Textaux[8] ;
bool pitch_ladder = false;
bool climb_dive_ladder = false;
bool clip_plane = false;
GLdouble eqn_top[4] = {0.0,-1.0,0.0,0.0};
GLdouble eqn_left[4] = {-1.0,0.0,0.0,100.0};
@ -473,13 +475,15 @@ void HudLadder :: draw( void )
float bot ;
float top ;
float text_offset = 4.0f ;
float zero_offset;
float zero_offset = 0.0;
if(climb_dive_ladder)
if ( climb_dive_ladder ) {
zero_offset = 50.0f ;
else
if(pitch_ladder)
} else {
if ( pitch_ladder ) {
zero_offset = 10.0f ;
}
}
fntFont *font = HUDtext->getFont();
float pointsize = HUDtext->getPointSize();

View file

@ -482,7 +482,6 @@ double FGSteam::get_HackOBS2_deg () {
double FGSteam::get_HackADF_deg () {
static double last_r = 0;
double r;
if ( current_radiostack->get_adf_inrange() ) {
double r = current_radiostack->get_adf_heading()