- move FloatToInt() function to simgear/math/fastmath.hxx, renamed to
float_to_int() for consistency reasons - remove hud_opts.hxx
This commit is contained in:
parent
ef52b23e3a
commit
038e047e8f
7 changed files with 31 additions and 95 deletions
|
@ -2,7 +2,7 @@ noinst_LIBRARIES = libCockpit.a
|
|||
|
||||
libCockpit_a_SOURCES = \
|
||||
cockpit.cxx cockpit.hxx \
|
||||
hud.cxx hud.hxx hud_opts.hxx \
|
||||
hud.cxx hud.hxx \
|
||||
hud_card.cxx hud_dnst.cxx hud_gaug.cxx hud_inst.cxx \
|
||||
hud_labl.cxx hud_ladr.cxx \
|
||||
hud_lat.cxx hud_lon.cxx \
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
// $Id$
|
||||
|
||||
|
||||
#ifndef _HUD_HXX
|
||||
#define _HUD_HXX
|
||||
#ifndef _OLDHUD_HXX
|
||||
#define _OLDHUD_HXX
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
|
@ -50,8 +50,9 @@
|
|||
#include <deque> // STL double ended queue
|
||||
#include STL_FSTREAM
|
||||
|
||||
#include <simgear/math/fastmath.hxx> // float_to_int()
|
||||
#include <simgear/constants.h>
|
||||
//#include <simgear/props/props.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Include/fg_typedefs.h>
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
|
@ -62,7 +63,6 @@
|
|||
#include <Main/viewmgr.hxx>
|
||||
#include <Airports/runways.hxx>
|
||||
|
||||
#include "hud_opts.hxx"
|
||||
#include <plib/sg.h>
|
||||
|
||||
SG_USING_STD(deque);
|
||||
|
@ -287,7 +287,7 @@ public:
|
|||
if ( HUDtext && str ) {
|
||||
float r, l ;
|
||||
HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
|
||||
return FloatToInt( r - l );
|
||||
return float_to_int( r - l );
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ public:
|
|||
if ( HUDtext && strlen( msg )) {
|
||||
float r, l ;
|
||||
HUD_Font->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
|
||||
return FloatToInt( r - l );
|
||||
return float_to_int( r - l );
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ public:
|
|||
|
||||
void Draw()
|
||||
{
|
||||
guiFnt.drawString( msg, FloatToInt(x), FloatToInt(y) );
|
||||
guiFnt.drawString( msg, float_to_int(x), float_to_int(y) );
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -490,7 +490,7 @@ public:
|
|||
if ( HUDtext && str ) {
|
||||
float r, l ;
|
||||
HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
|
||||
return FloatToInt( r - l );
|
||||
return float_to_int( r - l );
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
@ -898,4 +898,4 @@ private:
|
|||
float _r, _g, _b, _a, _cl;
|
||||
};
|
||||
|
||||
#endif // _HUD_H
|
||||
#endif // _OLDHUD_H
|
||||
|
|
|
@ -339,8 +339,8 @@ void hud_card::draw(void) // (HUD_scale * pscale)
|
|||
|
||||
// draw scale or tape
|
||||
|
||||
// last = FloatToInt(vmax)+1;
|
||||
// i = FloatToInt(vmin);
|
||||
// last = float_to_int(vmax)+1;
|
||||
// i = float_to_int(vmin);
|
||||
last = (int)vmax + 1; // N
|
||||
i = (int)vmin; // N
|
||||
|
||||
|
@ -464,7 +464,7 @@ void hud_card::draw(void) // (HUD_scale * pscale)
|
|||
}
|
||||
|
||||
lenstr = sprintf(TextScale, "%d",
|
||||
FloatToInt(disp_val * data_scaling()/*+.5*/));
|
||||
float_to_int(disp_val * data_scaling()/*+.5*/));
|
||||
// (int)(disp_val * data_scaling() +.5));
|
||||
/* if (((marker_ys - 8) > scrn_rect.top) &&
|
||||
((marker_ys + 8) < (height))){ */
|
||||
|
@ -642,8 +642,8 @@ void hud_card::draw(void) // (HUD_scale * pscale)
|
|||
|
||||
// printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
|
||||
|
||||
// last = FloatToInt(vmax)+1;
|
||||
// i = FloatToInt(vmin);
|
||||
// last = float_to_int(vmax)+1;
|
||||
// i = float_to_int(vmin);
|
||||
|
||||
if (zoom == 1) {
|
||||
zoomed_scale((int)vmin,(int)vmax);
|
||||
|
@ -733,7 +733,7 @@ void hud_card::draw(void) // (HUD_scale * pscale)
|
|||
// 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*/));
|
||||
float_to_int(disp_val * data_scaling()/*+.5*/));
|
||||
|
||||
// Draw major ticks and text only if far enough from the edge.
|
||||
if (((marker_xs - 10)> scrn_rect.left)
|
||||
|
|
|
@ -95,8 +95,8 @@ void gauge_instr::draw(void)
|
|||
|
||||
if (!huds_noticks(options)) { // If not no ticks...:)
|
||||
// Calculate x marker offsets
|
||||
int last = (int)vmax + 1; // FloatToInt(vmax)+1;
|
||||
i = (int)vmin; //FloatToInt(vmin);
|
||||
int last = (int)vmax + 1; // float_to_int(vmax)+1;
|
||||
i = (int)vmin; //float_to_int(vmin);
|
||||
|
||||
for (; i < last; i++) {
|
||||
// Calculate the location of this tick
|
||||
|
@ -135,7 +135,7 @@ void gauge_instr::draw(void)
|
|||
if (!huds_notext(options)) {
|
||||
disp_val = i;
|
||||
sprintf(TextScale, "%d",
|
||||
FloatToInt(disp_val * data_scaling()/*+.5*/));
|
||||
float_to_int(disp_val * data_scaling()/*+.5*/));
|
||||
|
||||
lenstr = getStringWidth(TextScale);
|
||||
|
||||
|
@ -143,12 +143,12 @@ void gauge_instr::draw(void)
|
|||
text_x = mid_scr.x - lenstr/2 ;
|
||||
|
||||
} else if (huds_left(options)) {
|
||||
text_x = FloatToInt(marker_xs - lenstr);
|
||||
text_x = float_to_int(marker_xs - lenstr);
|
||||
} else {
|
||||
text_x = FloatToInt(marker_xe - lenstr);
|
||||
text_x = float_to_int(marker_xe - lenstr);
|
||||
}
|
||||
// Now we know where to put the text.
|
||||
text_y = FloatToInt(marker_ys);
|
||||
text_y = float_to_int(marker_ys);
|
||||
textString(text_x, text_y, TextScale, 0);
|
||||
}
|
||||
}
|
||||
|
@ -160,20 +160,20 @@ void gauge_instr::draw(void)
|
|||
// have been drawn, text_x and text_y may be recycled. This is used
|
||||
// with the marker start stops to produce a pointer for each side reading
|
||||
|
||||
text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
|
||||
text_y = scrn_rect.top + float_to_int((cur_value - vmin) * factor() /*+.5f*/);
|
||||
// text_x = marker_xs - scrn_rect.left;
|
||||
|
||||
if (huds_right(options)) {
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(scrn_rect.left, text_y + 5);
|
||||
glVertex2f(FloatToInt(marker_xe), text_y);
|
||||
glVertex2f(float_to_int(marker_xe), text_y);
|
||||
glVertex2f(scrn_rect.left, text_y - 5);
|
||||
glEnd();
|
||||
}
|
||||
if (huds_left(options)) {
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(width, text_y + 5);
|
||||
glVertex2f(FloatToInt(marker_xs), text_y);
|
||||
glVertex2f(float_to_int(marker_xs), text_y);
|
||||
glVertex2f(width, text_y - 5);
|
||||
glEnd();
|
||||
}
|
||||
|
@ -218,8 +218,8 @@ void gauge_instr::draw(void)
|
|||
}
|
||||
|
||||
|
||||
int last = (int)vmax + 1; //FloatToInt(vmax)+1;
|
||||
i = (int)vmin; //FloatToInt(vmin);
|
||||
int last = (int)vmax + 1; //float_to_int(vmax)+1;
|
||||
i = (int)vmin; //float_to_int(vmin);
|
||||
for (; i <last ; i++) {
|
||||
condition = true;
|
||||
if (!modulo() && i < min_val())
|
||||
|
@ -259,7 +259,7 @@ void gauge_instr::draw(void)
|
|||
disp_val = i;
|
||||
}
|
||||
sprintf(TextScale, "%d",
|
||||
FloatToInt(disp_val * data_scaling()/* +.5*/));
|
||||
float_to_int(disp_val * data_scaling()/* +.5*/));
|
||||
lenstr = getStringWidth(TextScale);
|
||||
|
||||
// Draw major ticks and text only if far enough from the edge.
|
||||
|
|
|
@ -448,8 +448,8 @@ void HudLadder::draw(void)
|
|||
LineList.erase();
|
||||
StippleLineList.erase();
|
||||
|
||||
int last = FloatToInt(vmax) + 1;
|
||||
int i = FloatToInt(vmin);
|
||||
int last = float_to_int(vmax) + 1;
|
||||
int i = float_to_int(vmin);
|
||||
|
||||
if (!scr_hole) {
|
||||
x_end = half_span;
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
// hud_opts.hxx -- hud optimization tools
|
||||
//
|
||||
// Probably written by Norman Vine, started sometime in 1998 or 1999.
|
||||
//
|
||||
// Copyright (C) 1999 FlightGear Project
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#ifndef _HUD_OPTS_HXX
|
||||
#define _HUD_OPTS_HXX
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
|
||||
#if defined(i386)
|
||||
#define USE_X86_ASM
|
||||
#endif
|
||||
|
||||
#if defined(USE_X86_ASM)
|
||||
static __inline__ int FloatToInt(float f)
|
||||
{
|
||||
int r;
|
||||
__asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
|
||||
return r;
|
||||
}
|
||||
#elif defined(__MSC__) && defined(__WIN32__)
|
||||
static __inline int FloatToInt(float f)
|
||||
{
|
||||
int r;
|
||||
_asm {
|
||||
fld f
|
||||
fistp r
|
||||
}
|
||||
return r;
|
||||
}
|
||||
#else
|
||||
#define FloatToInt(F) ((int) ((F) < 0.0f ? (F)-0.5f : (F)+0.5f))
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _HUD_OPTS_H
|
|
@ -45,7 +45,7 @@ instr_scale::instr_scale(
|
|||
if (show_range < 0)
|
||||
range_shown = -range_shown;
|
||||
|
||||
temp = FloatToInt(Maximum_value - Minimum_value) / 100;
|
||||
temp = float_to_int(Maximum_value - Minimum_value) / 100;
|
||||
if (range_shown < temp)
|
||||
range_shown = temp;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue