Added Charlie Hotchkiss's HUD updates and improvementes.
This commit is contained in:
parent
a97ebd1f37
commit
3a6278c4e0
11 changed files with 2012 additions and 1614 deletions
|
@ -3,6 +3,8 @@ noinst_LIBRARIES = libCockpit.a
|
|||
libCockpit_a_SOURCES = \
|
||||
cockpit.cxx cockpit.hxx \
|
||||
hud.cxx hud.hxx \
|
||||
hud_card.cxx hud_dnst.cxx hud_guag.cxx hud_inst.cxx \
|
||||
hud_labl.cxx hud_ladr.cxx hud_scal.cxx hud_tbi.cxx \
|
||||
panel.cxx panel.hxx
|
||||
|
||||
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator
|
||||
|
|
1715
Cockpit/hud.cxx
1715
Cockpit/hud.cxx
File diff suppressed because it is too large
Load diff
231
Cockpit/hud.hxx
231
Cockpit/hud.hxx
|
@ -27,35 +27,39 @@
|
|||
#ifndef _HUD_HXX
|
||||
#define _HUD_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef __sun__
|
||||
extern "C" void *memmove(void *, const void *, size_t);
|
||||
extern "C" void *memset(void *, int, size_t);
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_VALUES_H
|
||||
# include <values.h> // for MAXINT
|
||||
#endif
|
||||
|
||||
#include <fg_typedefs.h>
|
||||
#include <fg_constants.h>
|
||||
|
||||
#include <Aircraft/aircraft.h>
|
||||
#include <Flight/flight.h>
|
||||
#include <Controls/controls.h>
|
||||
|
||||
//using namespace std;
|
||||
|
||||
#include <deque> // STL
|
||||
|
||||
#include <deque> // STL
|
||||
#ifdef NEEDNAMESPACESTD
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
typedef struct {
|
||||
int x, y;
|
||||
} POINT;
|
||||
|
@ -63,10 +67,8 @@ extern "C" void *memset(void *, int, size_t);
|
|||
typedef struct {
|
||||
int top, bottom, left, right;
|
||||
} RECT;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// View mode definitions
|
||||
|
||||
enum VIEW_MODES{ HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
|
||||
|
@ -112,6 +114,19 @@ enum fgLabelJust{ LEFT_JUST, CENTER_JUST, RIGHT_JUST } ;
|
|||
#define LABEL_COUNTER 1
|
||||
#define LABEL_WARNING 2
|
||||
|
||||
#define HUDS_AUTOTICKS 0x0001
|
||||
#define HUDS_VERT 0x0002
|
||||
#define HUDS_HORZ 0x0000
|
||||
#define HUDS_TOP 0x0004
|
||||
#define HUDS_BOTTOM 0x0008
|
||||
#define HUDS_LEFT HUDS_TOP
|
||||
#define HUDS_RIGHT HUDS_BOTTOM
|
||||
#define HUDS_BOTH (HUDS_LEFT | HUDS_RIGHT)
|
||||
#define HUDS_NOTICKS 0x0010
|
||||
#define HUDS_ARITHTIC 0x0020
|
||||
#define HUDS_DECITICS 0x0040
|
||||
#define HUDS_NOTEXT 0x0080
|
||||
|
||||
// Ladder orientaion
|
||||
// #define HUD_VERTICAL 1
|
||||
// #define HUD_HORIZONTAL 2
|
||||
|
@ -170,8 +185,6 @@ enum hudinstype{ HUDno_instr,
|
|||
HUDtbi
|
||||
};
|
||||
|
||||
enum ReadOriented{ ReadRIGHT, ReadLEFT, ReadTOP, ReadBOTTOM };
|
||||
|
||||
class instr_item { // An Abstract Base Class (ABC)
|
||||
private:
|
||||
static UINT instances; // More than 64K instruments? Nah!
|
||||
|
@ -179,7 +192,7 @@ class instr_item { // An Abstract Base Class (ABC)
|
|||
RECT scrn_pos; // Framing - affects scale dimensions
|
||||
// and orientation. Vert vs Horz, etc.
|
||||
DBLFNPTR load_value_fn;
|
||||
ReadOriented oriented;
|
||||
UINT opts;
|
||||
bool is_enabled;
|
||||
bool broken;
|
||||
int brightness;
|
||||
|
@ -187,9 +200,12 @@ class instr_item { // An Abstract Base Class (ABC)
|
|||
POINT mid_span; //
|
||||
|
||||
public:
|
||||
instr_item( RECT scrn_pos,
|
||||
instr_item( int x,
|
||||
int y,
|
||||
UINT height,
|
||||
UINT width,
|
||||
DBLFNPTR data_source,
|
||||
ReadOriented orient,
|
||||
UINT options,
|
||||
bool working = true);
|
||||
|
||||
instr_item( const instr_item & image );
|
||||
|
@ -204,7 +220,7 @@ class instr_item { // An Abstract Base Class (ABC)
|
|||
double get_value ( void ) { return load_value_fn();}
|
||||
UINT get_span ( void ) { return scr_span; }
|
||||
POINT get_centroid ( void ) { return mid_span; }
|
||||
ReadOriented get_orientation ( void ) { return oriented; }
|
||||
UINT get_options ( void ) { return opts; }
|
||||
|
||||
virtual void display_enable( bool working ) { is_enabled = !! working;}
|
||||
|
||||
|
@ -212,13 +228,13 @@ class instr_item { // An Abstract Base Class (ABC)
|
|||
virtual void update( void );
|
||||
virtual void break_display ( bool bad );
|
||||
virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
|
||||
void SetPosition ( int x, int y, UINT width, UINT height );
|
||||
UINT get_Handle( void );
|
||||
virtual void draw( void ) = 0; // Required method in derived classes
|
||||
};
|
||||
|
||||
typedef instr_item *HIptr;
|
||||
|
||||
extern deque< instr_item * > HUD_deque;
|
||||
extern deque< instr_item *> HUD_deque;
|
||||
|
||||
// instr_item This class has no other purpose than to maintain
|
||||
// a linked list of instrument and derived class
|
||||
|
@ -235,16 +251,19 @@ class instr_label : public instr_item {
|
|||
int blink;
|
||||
|
||||
public:
|
||||
instr_label( RECT the_box,
|
||||
instr_label( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR data_source,
|
||||
const char *label_format,
|
||||
const char *pre_label_string = 0,
|
||||
const char *post_label_string = 0,
|
||||
ReadOriented orientation = ReadTOP,
|
||||
fgLabelJust justification = CENTER_JUST,
|
||||
int font_size = SMALL,
|
||||
int blinking = NOBLINK,
|
||||
bool working = true);
|
||||
const char *pre_label_string = 0,
|
||||
const char *post_label_string = 0,
|
||||
UINT options = HUDS_TOP,
|
||||
fgLabelJust justification = CENTER_JUST,
|
||||
int font_size = SMALL,
|
||||
int blinking = NOBLINK,
|
||||
bool working = true);
|
||||
|
||||
~instr_label();
|
||||
|
||||
|
@ -264,25 +283,32 @@ typedef instr_label * pInstlabel;
|
|||
|
||||
class instr_scale : public instr_item {
|
||||
private:
|
||||
int range_shown; // Width Units.
|
||||
int Maximum_value; // ceiling.
|
||||
int Minimum_value; // Representation floor.
|
||||
double range_shown; // Width Units.
|
||||
double Maximum_value; // ceiling.
|
||||
double Minimum_value; // Representation floor.
|
||||
double scale_factor; // factor => screen units/range values.
|
||||
UINT Maj_div; // major division marker units
|
||||
UINT Min_div; // minor division marker units
|
||||
double disp_factor; // Multiply by to get numbers shown on scale.
|
||||
UINT Modulo; // Roll over point
|
||||
double scale_factor; // factor => screen units/range values.
|
||||
int signif_digits; // digits to show to the right.
|
||||
|
||||
public:
|
||||
instr_scale( RECT the_box,
|
||||
instr_scale( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR load_fn,
|
||||
ReadOriented orient,
|
||||
int show_range,
|
||||
int max_value,
|
||||
int min_value = 0,
|
||||
UINT major_divs = 10,
|
||||
UINT minor_divs = 5,
|
||||
UINT rollover = 0,
|
||||
bool working = true);
|
||||
UINT options,
|
||||
double show_range,
|
||||
double max_value = 100.0,
|
||||
double min_value = 0.0,
|
||||
double disp_scaling = 1.0,
|
||||
UINT major_divs = 10,
|
||||
UINT minor_divs = 5,
|
||||
UINT rollover = 0,
|
||||
int dp_showing = 2,
|
||||
bool working = true);
|
||||
|
||||
virtual ~instr_scale();
|
||||
instr_scale( const instr_scale & image);
|
||||
|
@ -291,57 +317,67 @@ class instr_scale : public instr_item {
|
|||
virtual void draw ( void ) {}; // No-op here. Defined in derived classes.
|
||||
UINT div_min ( void ) { return Min_div;}
|
||||
UINT div_max ( void ) { return Maj_div;}
|
||||
int min_val ( void ) { return Minimum_value;}
|
||||
int max_val ( void ) { return Maximum_value;}
|
||||
double min_val ( void ) { return Minimum_value;}
|
||||
double max_val ( void ) { return Maximum_value;}
|
||||
UINT modulo ( void ) { return Modulo; }
|
||||
double factor ( void ) { return scale_factor;}
|
||||
double range_to_show( void ) { return range_shown;}
|
||||
};
|
||||
|
||||
// moving_scale_instr This class displays the indicated quantity on
|
||||
// hud_card_ This class displays the indicated quantity on
|
||||
// a scale that moves past the pointer. It may be
|
||||
// horizontal or vertical, read above(left) or below(right) of the base
|
||||
// line.
|
||||
|
||||
class moving_scale : public instr_scale {
|
||||
class hud_card : public instr_scale {
|
||||
private:
|
||||
double val_span;
|
||||
double half_width_units;
|
||||
|
||||
public:
|
||||
moving_scale( RECT box,
|
||||
DBLFNPTR load_fn,
|
||||
ReadOriented readway,
|
||||
int maxValue,
|
||||
int minValue,
|
||||
UINT major_divs,
|
||||
UINT minor_divs,
|
||||
UINT modulator,
|
||||
double value_span,
|
||||
bool working = true);
|
||||
hud_card( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR load_fn,
|
||||
UINT options,
|
||||
double maxValue = 100.0,
|
||||
double minValue = 0.0,
|
||||
double disp_scaling = 1.0,
|
||||
UINT major_divs = 10,
|
||||
UINT minor_divs = 5,
|
||||
UINT modulator = 100,
|
||||
int dp_showing = 2,
|
||||
double value_span = 100.0,
|
||||
bool working = true);
|
||||
|
||||
~moving_scale();
|
||||
moving_scale( const moving_scale & image);
|
||||
moving_scale & operator = (const moving_scale & rhs );
|
||||
~hud_card();
|
||||
hud_card( const hud_card & image);
|
||||
hud_card & operator = (const hud_card & rhs );
|
||||
// virtual void display_enable( bool setting );
|
||||
virtual void draw( void ); // Required method in base class
|
||||
};
|
||||
|
||||
typedef moving_scale * pMoveScale;
|
||||
typedef hud_card * pCardScale;
|
||||
|
||||
class guage_instr : public instr_scale {
|
||||
private:
|
||||
|
||||
public:
|
||||
guage_instr( RECT box,
|
||||
DBLFNPTR load_fn,
|
||||
ReadOriented readway,
|
||||
int maxValue,
|
||||
int minValue,
|
||||
UINT major_divs,
|
||||
UINT minor_divs,
|
||||
UINT modulus,
|
||||
bool working = true);
|
||||
guage_instr( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR load_fn,
|
||||
UINT options,
|
||||
double disp_scaling = 1.0,
|
||||
double maxValue = 100,
|
||||
double minValue = 0,
|
||||
UINT major_divs = 50,
|
||||
UINT minor_divs = 0,
|
||||
int dp_showing = 2,
|
||||
UINT modulus = 0,
|
||||
bool working = true);
|
||||
|
||||
~guage_instr();
|
||||
guage_instr( const guage_instr & image);
|
||||
|
@ -359,11 +395,14 @@ class dual_instr_item : public instr_item {
|
|||
DBLFNPTR alt_data_source;
|
||||
|
||||
public:
|
||||
dual_instr_item ( RECT the_box,
|
||||
DBLFNPTR chn1_source,
|
||||
DBLFNPTR chn2_source,
|
||||
bool working = true,
|
||||
ReadOriented readway = ReadTOP);
|
||||
dual_instr_item ( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR chn1_source,
|
||||
DBLFNPTR chn2_source,
|
||||
bool working = true,
|
||||
UINT options = HUDS_TOP);
|
||||
|
||||
virtual ~dual_instr_item() {};
|
||||
dual_instr_item( const dual_instr_item & image);
|
||||
|
@ -381,12 +420,15 @@ class fgTBI_instr : public dual_instr_item {
|
|||
UINT scr_hole;
|
||||
|
||||
public:
|
||||
fgTBI_instr( RECT the_box,
|
||||
fgTBI_instr( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR chn1_source = get_roll,
|
||||
DBLFNPTR chn2_source = get_sideslip,
|
||||
UINT maxBankAngle = 45,
|
||||
UINT maxSlipAngle = 5,
|
||||
UINT gap_width = 5,
|
||||
double maxBankAngle = 45.0,
|
||||
double maxSlipAngle = 5.0,
|
||||
UINT gap_width = 5.0,
|
||||
bool working = true);
|
||||
|
||||
fgTBI_instr( const fgTBI_instr & image);
|
||||
|
@ -409,19 +451,22 @@ class HudLadder : public dual_instr_item {
|
|||
UINT minor_div;
|
||||
UINT label_pos;
|
||||
UINT scr_hole;
|
||||
int vmax;
|
||||
int vmin;
|
||||
double vmax;
|
||||
double vmin;
|
||||
double factor;
|
||||
|
||||
public:
|
||||
HudLadder( RECT the_box,
|
||||
HudLadder( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR ptch_source = get_roll,
|
||||
DBLFNPTR roll_source = get_pitch,
|
||||
UINT span_units = 45,
|
||||
int division_units = 10,
|
||||
UINT minor_division = 0,
|
||||
UINT screen_hole = 70,
|
||||
UINT lbl_pos = 0,
|
||||
double span_units = 45.0,
|
||||
double division_units = 10.0,
|
||||
double minor_division = 0.0,
|
||||
UINT screen_hole = 70,
|
||||
UINT lbl_pos = 0,
|
||||
bool working = true );
|
||||
|
||||
~HudLadder();
|
||||
|
@ -438,6 +483,17 @@ class HudLadder : public dual_instr_item {
|
|||
extern int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
|
||||
extern void fgUpdateHUD( void );
|
||||
|
||||
extern void drawOneLine ( UINT x1, UINT y1, UINT x2, UINT y2);
|
||||
extern void drawOneLine ( RECT &rect);
|
||||
extern void textString ( int x,
|
||||
int y,
|
||||
char *msg,
|
||||
void *font = GLUT_BITMAP_8_BY_13);
|
||||
extern void strokeString( int x,
|
||||
int y,
|
||||
char *msg,
|
||||
void *font = GLUT_STROKE_ROMAN,
|
||||
float theta = 0);
|
||||
/*
|
||||
bool AddHUDInstrument( instr_item *pBlackBox );
|
||||
void DrawHUD ( void );
|
||||
|
@ -453,9 +509,8 @@ void fgHUDSetTimeMode( Hptr hud, int time_of_day );
|
|||
#endif // _HUD_H
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.7 1998/06/12 00:56:00 curt
|
||||
/* Build only static libraries.
|
||||
/* Declare memmove/memset for Sloaris.
|
||||
/* Revision 1.8 1998/07/03 13:16:29 curt
|
||||
/* Added Charlie Hotchkiss's HUD updates and improvementes.
|
||||
/*
|
||||
* Revision 1.6 1998/06/03 00:43:28 curt
|
||||
* No .h when including stl stuff.
|
||||
|
|
380
Cockpit/hud_card.cxx
Normal file
380
Cockpit/hud_card.cxx
Normal file
|
@ -0,0 +1,380 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <Aircraft/aircraft.h>
|
||||
#include <Debug/fg_debug.h>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Math/fg_random.h>
|
||||
#include <Math/mat3.h>
|
||||
#include <Math/polar3d.h>
|
||||
#include <Scenery/scenery.hxx>
|
||||
#include <Time/fg_timer.hxx>
|
||||
#include <Weather/weather.h>
|
||||
|
||||
|
||||
#include "hud.hxx"
|
||||
//========== Top of hud_card class member definitions =============
|
||||
|
||||
hud_card ::
|
||||
hud_card( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR data_source,
|
||||
UINT options,
|
||||
double max_value,
|
||||
double min_value,
|
||||
double disp_scaling,
|
||||
UINT major_divs,
|
||||
UINT minor_divs,
|
||||
UINT modulus,
|
||||
int dp_showing,
|
||||
double value_span,
|
||||
bool working) :
|
||||
instr_scale( x,y,width,height,
|
||||
data_source, options,
|
||||
value_span,
|
||||
max_value, min_value, disp_scaling,
|
||||
major_divs, minor_divs, modulus,
|
||||
working),
|
||||
val_span ( value_span)
|
||||
{
|
||||
half_width_units = range_to_show() / 2.0;
|
||||
}
|
||||
|
||||
hud_card ::
|
||||
~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)
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void hud_card ::
|
||||
draw( void ) // (HUD_scale * pscale )
|
||||
{
|
||||
double vmin, vmax;
|
||||
int marker_xs;
|
||||
int marker_xe;
|
||||
int marker_ys;
|
||||
int marker_ye;
|
||||
register i;
|
||||
char TextScale[80];
|
||||
bool condition;
|
||||
int disp_val;
|
||||
POINT mid_scr = get_centroid();
|
||||
double cur_value = get_value();
|
||||
RECT scrn_rect = get_location();
|
||||
UINT options = get_options();
|
||||
|
||||
vmin = cur_value - half_width_units; // width units == needle travel
|
||||
vmax = cur_value + half_width_units; // or picture unit span.
|
||||
// Draw the basic markings for the scale...
|
||||
|
||||
if( options & HUDS_VERT ) { // Vertical scale
|
||||
drawOneLine( scrn_rect.left, // Bottom tick bar
|
||||
scrn_rect.top,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top);
|
||||
|
||||
drawOneLine( scrn_rect.left, // Top tick bar
|
||||
scrn_rect.top + scrn_rect.bottom,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top + scrn_rect.bottom );
|
||||
|
||||
marker_xs = scrn_rect.left;
|
||||
marker_xe = scrn_rect.left + scrn_rect.right;
|
||||
|
||||
// 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( options & HUDS_LEFT ) { // Calculate x marker offset
|
||||
drawOneLine( scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top + scrn_rect.bottom); // Cap right side
|
||||
|
||||
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
|
||||
// Indicator carrot
|
||||
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);
|
||||
|
||||
}
|
||||
if( options & HUDS_RIGHT ) { // We'll default this for now.
|
||||
drawOneLine( scrn_rect.left,
|
||||
scrn_rect.top,
|
||||
scrn_rect.left,
|
||||
scrn_rect.top + scrn_rect.bottom); // Cap left side
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// At this point marker x_start and x_end values are transposed.
|
||||
// To keep this from confusing things they are now interchanged.
|
||||
if(( options & HUDS_BOTH) == HUDS_BOTH) {
|
||||
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.
|
||||
|
||||
for( i = (int)vmin; i <= (int)vmax; 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 + (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 > (scrn_rect.top + scrn_rect.bottom - 4))) {
|
||||
// Magic numbers!!!
|
||||
continue;
|
||||
}
|
||||
if( div_min()) {
|
||||
if( (i%div_min()) == 0) {
|
||||
if((( marker_ys + 5) > scrn_rect.top ) ||
|
||||
(( marker_ys - 5) < (scrn_rect.top + scrn_rect.bottom))){
|
||||
if( (options & HUDS_BOTH) == HUDS_BOTH ) {
|
||||
drawOneLine( scrn_rect.left, marker_ys,
|
||||
marker_xs, marker_ys );
|
||||
drawOneLine( marker_xe, marker_ys,
|
||||
scrn_rect.left + scrn_rect.right, marker_ys );
|
||||
}
|
||||
else {
|
||||
if( options & HUDS_LEFT ) {
|
||||
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) {
|
||||
disp_val += modulo();
|
||||
}
|
||||
else {
|
||||
disp_val = i % modulo();
|
||||
}
|
||||
}
|
||||
else {
|
||||
disp_val = i;
|
||||
}
|
||||
sprintf( TextScale, "%d", disp_val );
|
||||
if(( (marker_ys - 5 ) > scrn_rect.top ) ||
|
||||
( (marker_ys + 5) < (scrn_rect.top + scrn_rect.bottom))){
|
||||
if( (options & HUDS_BOTH) == HUDS_BOTH) {
|
||||
drawOneLine( scrn_rect.left, marker_ys,
|
||||
marker_xs, marker_ys);
|
||||
drawOneLine( marker_xs, marker_ys,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
marker_ys);
|
||||
if( !(options & HUDS_NOTEXT)) {
|
||||
textString ( marker_xs + 2, marker_ys,
|
||||
TextScale, GLUT_BITMAP_8_BY_13 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
|
||||
if( !(options & HUDS_NOTEXT)) {
|
||||
if( options & HUDS_LEFT ) {
|
||||
textString( marker_xs - 8 * strlen(TextScale) - 2,
|
||||
marker_ys - 4,
|
||||
TextScale, GLUT_BITMAP_8_BY_13 );
|
||||
}
|
||||
else {
|
||||
textString( marker_xe + 3 * strlen(TextScale),
|
||||
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
|
||||
drawOneLine( scrn_rect.left, // left tick bar
|
||||
scrn_rect.top,
|
||||
scrn_rect.left,
|
||||
scrn_rect.top + scrn_rect.bottom);
|
||||
|
||||
drawOneLine( scrn_rect.left + scrn_rect.right, // right tick bar
|
||||
scrn_rect.top,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top + scrn_rect.bottom );
|
||||
|
||||
marker_ys = scrn_rect.top; // Starting point for
|
||||
marker_ye = scrn_rect.top + scrn_rect.bottom; // tick y location calcs
|
||||
|
||||
if( options & HUDS_TOP ) {
|
||||
drawOneLine( scrn_rect.left,
|
||||
scrn_rect.top,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top); // Bottom box line
|
||||
|
||||
marker_ye = scrn_rect.top + scrn_rect.bottom / 2; // Tick point adjust
|
||||
// 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);
|
||||
}
|
||||
if( options & HUDS_BOTTOM) {
|
||||
drawOneLine( scrn_rect.left,
|
||||
scrn_rect.top + scrn_rect.bottom,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top + scrn_rect.bottom); // Top box line
|
||||
// Tick point adjust
|
||||
marker_ys = scrn_rect.top +
|
||||
scrn_rect.bottom - 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 );
|
||||
}
|
||||
|
||||
// if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
|
||||
// marker_xe = marker_ys;
|
||||
// marker_ys = marker_ye;
|
||||
// marker_ye = marker_xe;
|
||||
// }
|
||||
|
||||
for( i = (int)vmin; i <= (int)vmax; i++ ) {
|
||||
condition = true;
|
||||
if( !modulo()) {
|
||||
if( i < min_val()) {
|
||||
condition = false;
|
||||
}
|
||||
}
|
||||
if( condition ) {
|
||||
marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
|
||||
if( div_min()){
|
||||
if( (i%(int)div_min()) == 0 ) {
|
||||
// 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( (options & HUDS_BOTH) == HUDS_BOTH ) {
|
||||
drawOneLine( marker_xs, scrn_rect.top,
|
||||
marker_xs, marker_ys - 4);
|
||||
drawOneLine( marker_xs, marker_ye + 4,
|
||||
marker_xs, scrn_rect.top + scrn_rect.bottom);
|
||||
}
|
||||
else {
|
||||
if( options & HUDS_TOP) {
|
||||
drawOneLine( marker_xs, marker_ys,
|
||||
marker_xs, marker_ye - 4);
|
||||
}
|
||||
else {
|
||||
drawOneLine( marker_xs, marker_ys + 4,
|
||||
marker_xs, marker_ye);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( div_max()) {
|
||||
if( (i%(int)div_max())==0 ) {
|
||||
if(modulo()) {
|
||||
if( disp_val < 0) {
|
||||
disp_val += modulo();
|
||||
}
|
||||
else {
|
||||
disp_val = i % modulo();
|
||||
}
|
||||
}
|
||||
else {
|
||||
disp_val = i;
|
||||
}
|
||||
sprintf( TextScale, "%d", disp_val );
|
||||
// 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( (options & HUDS_BOTH) == HUDS_BOTH) {
|
||||
drawOneLine( marker_xs, scrn_rect.top,
|
||||
marker_xs, marker_ys);
|
||||
drawOneLine( marker_xs, marker_ye,
|
||||
marker_xs, scrn_rect.top + scrn_rect.bottom);
|
||||
|
||||
if( !(options & HUDS_NOTEXT)) {
|
||||
textString ( marker_xs - 4 * strlen(TextScale),
|
||||
marker_ys + 4,
|
||||
TextScale, GLUT_BITMAP_8_BY_13 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
drawOneLine( marker_xs, marker_ys,
|
||||
marker_xs, marker_ye );
|
||||
if( !(options & HUDS_NOTEXT)) {
|
||||
if( options & HUDS_TOP ) {
|
||||
textString ( marker_xs - 4 * strlen(TextScale),
|
||||
scrn_rect.top + scrn_rect.bottom - 10,
|
||||
TextScale, GLUT_BITMAP_8_BY_13 );
|
||||
}
|
||||
else {
|
||||
textString( marker_xs - 4 * strlen(TextScale),
|
||||
scrn_rect.top,
|
||||
TextScale, GLUT_BITMAP_8_BY_13 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
58
Cockpit/hud_dnst.cxx
Normal file
58
Cockpit/hud_dnst.cxx
Normal file
|
@ -0,0 +1,58 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <Aircraft/aircraft.h>
|
||||
#include <Debug/fg_debug.h>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Math/fg_random.h>
|
||||
#include <Math/mat3.h>
|
||||
#include <Math/polar3d.h>
|
||||
#include <Scenery/scenery.hxx>
|
||||
#include <Time/fg_timer.hxx>
|
||||
#include <Weather/weather.h>
|
||||
|
||||
|
||||
#include "hud.hxx"
|
||||
|
||||
//============ Top of dual_instr_item class member definitions ============
|
||||
|
||||
dual_instr_item ::
|
||||
dual_instr_item ( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR chn1_source,
|
||||
DBLFNPTR chn2_source,
|
||||
bool working,
|
||||
UINT options ):
|
||||
instr_item( x, y, width, height,
|
||||
chn1_source, options, working),
|
||||
alt_data_source( chn2_source )
|
||||
{
|
||||
}
|
||||
|
||||
dual_instr_item ::
|
||||
dual_instr_item( const dual_instr_item & image) :
|
||||
instr_item ((instr_item &) image ),
|
||||
alt_data_source( image.alt_data_source)
|
||||
{
|
||||
}
|
||||
|
||||
dual_instr_item & dual_instr_item ::
|
||||
operator = (const dual_instr_item & rhs )
|
||||
{
|
||||
if( !(this == &rhs)) {
|
||||
instr_item::operator = (rhs);
|
||||
alt_data_source = rhs.alt_data_source;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// End of hud_dnst.cxx
|
||||
|
358
Cockpit/hud_guag.cxx
Normal file
358
Cockpit/hud_guag.cxx
Normal file
|
@ -0,0 +1,358 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <Aircraft/aircraft.h>
|
||||
#include <Debug/fg_debug.h>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Math/fg_random.h>
|
||||
#include <Math/mat3.h>
|
||||
#include <Math/polar3d.h>
|
||||
#include <Scenery/scenery.hxx>
|
||||
#include <Time/fg_timer.hxx>
|
||||
#include <Weather/weather.h>
|
||||
|
||||
|
||||
#include "hud.hxx"
|
||||
//============== Top of guage_instr class member definitions ==============
|
||||
|
||||
guage_instr ::
|
||||
guage_instr( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR load_fn,
|
||||
UINT options,
|
||||
double disp_scale,
|
||||
double maxValue,
|
||||
double minValue,
|
||||
UINT major_divs,
|
||||
UINT minor_divs,
|
||||
int dp_showing,
|
||||
UINT modulus,
|
||||
bool working) :
|
||||
instr_scale( x, y, width, height,
|
||||
load_fn, options,
|
||||
(maxValue - minValue), // Always shows span?
|
||||
maxValue, minValue,
|
||||
disp_scale,
|
||||
major_divs, minor_divs,
|
||||
modulus, dp_showing,
|
||||
working)
|
||||
{
|
||||
}
|
||||
|
||||
guage_instr ::
|
||||
~guage_instr()
|
||||
{
|
||||
}
|
||||
|
||||
guage_instr ::
|
||||
guage_instr( const guage_instr & image):
|
||||
instr_scale( (instr_scale &) image)
|
||||
{
|
||||
}
|
||||
|
||||
guage_instr & guage_instr ::
|
||||
operator = (const guage_instr & rhs )
|
||||
{
|
||||
if( !(this == &rhs)) {
|
||||
instr_scale::operator = (rhs);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// As implemented, draw only correctly draws a horizontal or vertical
|
||||
// scale. It should contain a variation that permits clock type displays.
|
||||
// Now is supports "tickless" displays such as control surface indicators.
|
||||
// This routine should be worked over before using. Current value would be
|
||||
// fetched and not used if not commented out. Clearly that is intollerable.
|
||||
|
||||
void guage_instr :: draw (void)
|
||||
{
|
||||
int marker_xs, marker_xe;
|
||||
int marker_ys, marker_ye;
|
||||
int text_x, text_y;
|
||||
register i;
|
||||
char TextScale[80];
|
||||
bool condition;
|
||||
int disp_val;
|
||||
double vmin = min_val();
|
||||
double vmax = max_val();
|
||||
POINT mid_scr = get_centroid();
|
||||
double cur_value = get_value();
|
||||
RECT scrn_rect = get_location();
|
||||
UINT options = get_options();
|
||||
|
||||
// Draw the basic markings for the scale...
|
||||
|
||||
if( options & HUDS_VERT ) { // Vertical scale
|
||||
drawOneLine( scrn_rect.left, // Bottom tick bar
|
||||
scrn_rect.top,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top);
|
||||
|
||||
drawOneLine( scrn_rect.left, // Top tick bar
|
||||
scrn_rect.top + scrn_rect.bottom,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top + scrn_rect.bottom );
|
||||
|
||||
marker_xs = scrn_rect.left;
|
||||
marker_xe = scrn_rect.left + scrn_rect.right;
|
||||
|
||||
if( options & HUDS_LEFT ) { // Read left, so line down right side
|
||||
drawOneLine( scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top + scrn_rect.bottom);
|
||||
|
||||
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
|
||||
}
|
||||
if( options & HUDS_RIGHT ) { // Read right, so down left sides
|
||||
drawOneLine( scrn_rect.left,
|
||||
scrn_rect.top,
|
||||
scrn_rect.left,
|
||||
scrn_rect.top + scrn_rect.bottom);
|
||||
marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
|
||||
}
|
||||
|
||||
// At this point marker x_start and x_end values are transposed.
|
||||
// To keep this from confusing things they are now interchanged.
|
||||
if(( options & HUDS_BOTH) == HUDS_BOTH) {
|
||||
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.
|
||||
|
||||
if( !(options & HUDS_NOTICKS )) { // If not no ticks...:)
|
||||
// Calculate x marker offsets
|
||||
for( i = (int)vmin; i <= (int)vmax; i++ ) {
|
||||
|
||||
// Calculate the location of this tick
|
||||
marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
|
||||
|
||||
// We compute marker_ys even though we don't know if we will use
|
||||
// either major or minor divisions. Simpler.
|
||||
|
||||
if( div_min()) { // Minor tick marks
|
||||
if( (i%div_min()) == 0) {
|
||||
if((options & HUDS_LEFT) && (options && HUDS_RIGHT)) {
|
||||
drawOneLine( scrn_rect.left, marker_ys,
|
||||
marker_xs - 3, marker_ys );
|
||||
drawOneLine( marker_xe + 3, marker_ys,
|
||||
scrn_rect.left + scrn_rect.right, marker_ys );
|
||||
}
|
||||
else {
|
||||
if( options & HUDS_LEFT) {
|
||||
drawOneLine( marker_xs + 3, marker_ys, marker_xe, marker_ys );
|
||||
}
|
||||
else {
|
||||
drawOneLine( marker_xs, marker_ys, marker_xe - 3, marker_ys );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now we work on the major divisions. Since these are also labeled
|
||||
// and no labels are drawn otherwise, we label inside this if
|
||||
// statement.
|
||||
|
||||
if( div_max()) { // Major tick mark
|
||||
if( (i%div_max()) == 0 ) {
|
||||
if((options & HUDS_LEFT) && (options && HUDS_RIGHT)) {
|
||||
|
||||
drawOneLine( scrn_rect.left, marker_ys,
|
||||
marker_xs, marker_ys );
|
||||
drawOneLine( marker_xe, marker_ys,
|
||||
scrn_rect.left + scrn_rect.right, marker_ys );
|
||||
}
|
||||
else {
|
||||
drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
|
||||
}
|
||||
|
||||
if( !(options & HUDS_NOTEXT)) {
|
||||
disp_val = i;
|
||||
sprintf( TextScale, "%d", disp_val );
|
||||
|
||||
if((options & HUDS_LEFT) && (options && HUDS_RIGHT)) {
|
||||
text_x = mid_scr.x - 2 - ((3 * strlen( TextScale ))>>1);
|
||||
}
|
||||
else {
|
||||
if( options & HUDS_LEFT ) {
|
||||
text_x = marker_xs - 2 - 3 * strlen( TextScale);
|
||||
}
|
||||
else {
|
||||
text_x = marker_xe + 10 - strlen( TextScale );
|
||||
}
|
||||
}
|
||||
// Now we know where to put the text.
|
||||
text_y = marker_ys;
|
||||
textString( text_x, text_y, TextScale, GLUT_BITMAP_8_BY_13 );
|
||||
}
|
||||
}
|
||||
} //
|
||||
} //
|
||||
} //
|
||||
// Now that the scale is drawn, we draw in the pointer(s). Since labels
|
||||
// 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 + (int)((cur_value - vmin) * factor() + .5);
|
||||
// text_x = marker_xs - scrn_rect.left;
|
||||
|
||||
if( options & HUDS_RIGHT ) {
|
||||
drawOneLine(scrn_rect.left, text_y,
|
||||
marker_xe, text_y + 5);
|
||||
drawOneLine(scrn_rect.left, text_y,
|
||||
marker_xe, text_y - 5);
|
||||
}
|
||||
if( options & HUDS_LEFT ) {
|
||||
drawOneLine(scrn_rect.left + scrn_rect.right, text_y,
|
||||
marker_xs, text_y + 5);
|
||||
drawOneLine(scrn_rect.left + scrn_rect.right, text_y,
|
||||
marker_xs, text_y - 5);
|
||||
}
|
||||
} // End if VERTICAL SCALE TYPE
|
||||
else { // Horizontal scale by default
|
||||
drawOneLine( scrn_rect.left, // left tick bar
|
||||
scrn_rect.top,
|
||||
scrn_rect.left,
|
||||
scrn_rect.top + scrn_rect.bottom);
|
||||
|
||||
drawOneLine( scrn_rect.left + scrn_rect.right, // right tick bar
|
||||
scrn_rect.top,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top + scrn_rect.bottom );
|
||||
|
||||
marker_ys = scrn_rect.top; // Starting point for
|
||||
marker_ye = scrn_rect.top + scrn_rect.bottom; // tick y location calcs
|
||||
marker_xs = scrn_rect.left + (int)((cur_value - vmin) * factor() + .5);
|
||||
|
||||
if( options & HUDS_TOP ) {
|
||||
drawOneLine( scrn_rect.left,
|
||||
scrn_rect.top,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top); // Bottom box line
|
||||
|
||||
marker_ye = scrn_rect.top + scrn_rect.bottom / 2; // Tick point adjust
|
||||
// Bottom arrow
|
||||
drawOneLine( marker_xs, marker_ye,
|
||||
marker_xs - scrn_rect.bottom / 4, scrn_rect.top);
|
||||
drawOneLine( marker_xs, marker_ye,
|
||||
marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
|
||||
}
|
||||
if( options & HUDS_BOTTOM) {
|
||||
drawOneLine( scrn_rect.left,
|
||||
scrn_rect.top + scrn_rect.bottom,
|
||||
scrn_rect.left + scrn_rect.right,
|
||||
scrn_rect.top + scrn_rect.bottom); // Top box line
|
||||
// Tick point adjust
|
||||
marker_ys = scrn_rect.top +
|
||||
scrn_rect.bottom - scrn_rect.bottom / 2;
|
||||
// Top arrow
|
||||
drawOneLine( marker_xs + scrn_rect.bottom / 4,
|
||||
scrn_rect.top + scrn_rect.bottom,
|
||||
marker_xs,
|
||||
marker_ys );
|
||||
drawOneLine( marker_xs - scrn_rect.bottom / 4,
|
||||
scrn_rect.top + scrn_rect.bottom,
|
||||
marker_xs ,
|
||||
marker_ys );
|
||||
}
|
||||
|
||||
for( i = (int)vmin; i <= (int)vmax; i++ ) {
|
||||
condition = true;
|
||||
if( !modulo()) {
|
||||
if( i < min_val()) {
|
||||
condition = false;
|
||||
}
|
||||
}
|
||||
if( condition ) {
|
||||
marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
|
||||
if( div_min()){
|
||||
if( (i%(int)div_min()) == 0 ) {
|
||||
// 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( (options & HUDS_BOTH) == HUDS_BOTH ) {
|
||||
drawOneLine( marker_xs, scrn_rect.top,
|
||||
marker_xs, marker_ys - 4);
|
||||
drawOneLine( marker_xs, marker_ye + 4,
|
||||
marker_xs, scrn_rect.top + scrn_rect.bottom);
|
||||
}
|
||||
else {
|
||||
if( options & HUDS_TOP) {
|
||||
drawOneLine( marker_xs, marker_ys,
|
||||
marker_xs, marker_ye - 4);
|
||||
}
|
||||
else {
|
||||
drawOneLine( marker_xs, marker_ys + 4,
|
||||
marker_xs, marker_ye);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( div_max()) {
|
||||
if( (i%(int)div_max())==0 ) {
|
||||
if(modulo()) {
|
||||
if( disp_val < 0) {
|
||||
disp_val += modulo();
|
||||
}
|
||||
else {
|
||||
disp_val = i % modulo();
|
||||
}
|
||||
}
|
||||
else {
|
||||
disp_val = i;
|
||||
}
|
||||
sprintf( TextScale, "%d", disp_val );
|
||||
// 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( (options & HUDS_BOTH) == HUDS_BOTH) {
|
||||
drawOneLine( marker_xs, scrn_rect.top,
|
||||
marker_xs, marker_ys);
|
||||
drawOneLine( marker_xs, marker_ye,
|
||||
marker_xs, scrn_rect.top + scrn_rect.bottom);
|
||||
|
||||
if( !(options & HUDS_NOTEXT)) {
|
||||
textString ( marker_xs - 4 * strlen(TextScale),
|
||||
marker_ys + 4,
|
||||
TextScale, GLUT_BITMAP_8_BY_13 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
drawOneLine( marker_xs, marker_ys,
|
||||
marker_xs, marker_ye );
|
||||
if( !(options & HUDS_NOTEXT)) {
|
||||
if( options & HUDS_TOP ) {
|
||||
textString ( marker_xs - 4 * strlen(TextScale),
|
||||
scrn_rect.top + scrn_rect.bottom - 10,
|
||||
TextScale, GLUT_BITMAP_8_BY_13 );
|
||||
}
|
||||
else {
|
||||
textString( marker_xs - 4 * strlen(TextScale),
|
||||
scrn_rect.top,
|
||||
TextScale, GLUT_BITMAP_8_BY_13 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
142
Cockpit/hud_inst.cxx
Normal file
142
Cockpit/hud_inst.cxx
Normal file
|
@ -0,0 +1,142 @@
|
|||
// Abstract Base Class instr_item
|
||||
//
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <Aircraft/aircraft.h>
|
||||
#include <Debug/fg_debug.h>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Math/fg_random.h>
|
||||
#include <Math/mat3.h>
|
||||
#include <Math/polar3d.h>
|
||||
#include <Scenery/scenery.hxx>
|
||||
#include <Time/fg_timer.hxx>
|
||||
#include <Weather/weather.h>
|
||||
|
||||
|
||||
#include "hud.hxx"
|
||||
|
||||
UINT instr_item :: instances; // Initial value of zero
|
||||
|
||||
// constructor ( No default provided )
|
||||
instr_item ::
|
||||
instr_item( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR data_source,
|
||||
UINT options,
|
||||
bool working) :
|
||||
handle ( ++instances ),
|
||||
load_value_fn ( data_source ),
|
||||
opts ( options ),
|
||||
is_enabled ( working ),
|
||||
broken ( FALSE ),
|
||||
brightness ( BRT_MEDIUM )
|
||||
{
|
||||
scrn_pos.left = x;
|
||||
scrn_pos.top = y;
|
||||
scrn_pos.right = width;
|
||||
scrn_pos.bottom = height;
|
||||
|
||||
// Set up convenience values for centroid of the box and
|
||||
// the span values according to orientation
|
||||
|
||||
if( opts & HUDS_VERT) { // Vertical style
|
||||
// Insure that the midpoint marker will fall exactly at the
|
||||
// middle of the bar.
|
||||
if( !(scrn_pos.bottom % 2)) {
|
||||
scrn_pos.bottom++;
|
||||
}
|
||||
scr_span = scrn_pos.bottom;
|
||||
}
|
||||
else {
|
||||
// Insure that the midpoint marker will fall exactly at the
|
||||
// middle of the bar.
|
||||
if( !(scrn_pos.right % 2)) {
|
||||
scrn_pos.right++;
|
||||
}
|
||||
scr_span = scrn_pos.right;
|
||||
}
|
||||
// Here we work out the centroid for the corrected box.
|
||||
mid_span.x = scrn_pos.left + (scrn_pos.right >> 1);
|
||||
mid_span.y = scrn_pos.top + (scrn_pos.bottom >> 1);
|
||||
}
|
||||
|
||||
|
||||
// copy constructor
|
||||
instr_item ::
|
||||
instr_item ( const instr_item & image ):
|
||||
handle ( ++instances ),
|
||||
scrn_pos ( image.scrn_pos ),
|
||||
load_value_fn( image.load_value_fn),
|
||||
opts ( image.opts ),
|
||||
is_enabled ( image.is_enabled ),
|
||||
broken ( image.broken ),
|
||||
brightness ( image.brightness ),
|
||||
scr_span ( image.scr_span ),
|
||||
mid_span ( image.mid_span )
|
||||
{
|
||||
}
|
||||
|
||||
// assignment operator
|
||||
|
||||
instr_item & instr_item :: operator = ( const instr_item & rhs )
|
||||
{
|
||||
if( !(this == &rhs )) { // Not an identity assignment
|
||||
scrn_pos = rhs.scrn_pos;
|
||||
load_value_fn = rhs.load_value_fn;
|
||||
opts = rhs.opts;
|
||||
is_enabled = rhs.is_enabled;
|
||||
broken = rhs.broken;
|
||||
brightness = rhs.brightness;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// destructor
|
||||
|
||||
instr_item :: ~instr_item ()
|
||||
{
|
||||
if( instances ) {
|
||||
instances--;
|
||||
}
|
||||
}
|
||||
|
||||
void instr_item ::
|
||||
update( void )
|
||||
{
|
||||
}
|
||||
|
||||
// break_display This is emplaced to provide hooks for making
|
||||
// instruments unreliable. The default behavior is
|
||||
// to simply not display, but more sophisticated behavior is available
|
||||
// by over riding the function which is virtual in this class.
|
||||
|
||||
void instr_item ::
|
||||
break_display ( bool bad )
|
||||
{
|
||||
broken = !!bad;
|
||||
is_enabled = FALSE;
|
||||
}
|
||||
|
||||
void instr_item ::
|
||||
SetBrightness ( int level )
|
||||
{
|
||||
brightness = level; // This is all we will do for now. Later the
|
||||
// brightness levels will be sensitive both to
|
||||
// the control knob and the outside light levels
|
||||
// to emulated night vision effects.
|
||||
}
|
||||
|
||||
UINT instr_item :: get_Handle( void )
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
140
Cockpit/hud_labl.cxx
Normal file
140
Cockpit/hud_labl.cxx
Normal file
|
@ -0,0 +1,140 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <Aircraft/aircraft.h>
|
||||
#include <Debug/fg_debug.h>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Math/fg_random.h>
|
||||
#include <Math/mat3.h>
|
||||
#include <Math/polar3d.h>
|
||||
#include <Scenery/scenery.hxx>
|
||||
#include <Time/fg_timer.hxx>
|
||||
#include <Weather/weather.h>
|
||||
|
||||
|
||||
#include "hud.hxx"
|
||||
|
||||
//======================= Top of instr_label class =========================
|
||||
instr_label ::
|
||||
instr_label( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR data_source,
|
||||
const char *label_format,
|
||||
const char *pre_label_string,
|
||||
const char *post_label_string,
|
||||
UINT options,
|
||||
fgLabelJust justification,
|
||||
int font_size,
|
||||
int blinking,
|
||||
bool working ):
|
||||
instr_item( x, y, width, height,
|
||||
data_source, options, working ),
|
||||
pformat ( label_format ),
|
||||
pre_str ( pre_label_string ),
|
||||
post_str ( post_label_string ),
|
||||
justify ( justification ),
|
||||
fontSize ( font_size ),
|
||||
blink ( blinking )
|
||||
{
|
||||
}
|
||||
|
||||
// I put this in to make it easy to construct a class member using the current
|
||||
// C code.
|
||||
|
||||
|
||||
instr_label :: ~instr_label()
|
||||
{
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
instr_label :: instr_label( const instr_label & image) :
|
||||
instr_item((const instr_item &)image),
|
||||
pformat ( image.pformat ),
|
||||
pre_str ( image.pre_str ),
|
||||
post_str ( image.post_str ),
|
||||
blink ( image.blink )
|
||||
{
|
||||
}
|
||||
|
||||
instr_label & instr_label ::operator = (const instr_label & rhs )
|
||||
{
|
||||
if( !(this == &rhs)) {
|
||||
instr_item::operator = (rhs);
|
||||
pformat = rhs.pformat;
|
||||
fontSize = rhs.fontSize;
|
||||
blink = rhs.blink;
|
||||
justify = rhs.justify;
|
||||
pre_str = rhs.pre_str;
|
||||
post_str = rhs.post_str;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// draw Draws a label anywhere in the HUD
|
||||
//
|
||||
//
|
||||
void instr_label ::
|
||||
draw( void ) // Required method in base class
|
||||
{
|
||||
char format_buffer[80];
|
||||
char label_buffer[80];
|
||||
int posincr;
|
||||
int lenstr;
|
||||
RECT scrn_rect = get_location();
|
||||
|
||||
if( pre_str != NULL) {
|
||||
if( post_str != NULL ) {
|
||||
sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
|
||||
}
|
||||
else {
|
||||
sprintf( format_buffer, "%s%s", pre_str, pformat );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( post_str != NULL ) {
|
||||
sprintf( format_buffer, "%s%s", pformat, post_str );
|
||||
}
|
||||
} // else do nothing if both pre and post strings are nulls. Interesting.
|
||||
|
||||
sprintf( label_buffer, format_buffer, get_value() );
|
||||
#ifdef DEBUGHUD
|
||||
fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
|
||||
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
|
||||
fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
|
||||
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
|
||||
#endif
|
||||
lenstr = strlen( label_buffer );
|
||||
|
||||
posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8;
|
||||
|
||||
if( justify == CENTER_JUST ) {
|
||||
posincr = - (lenstr << 2); // -lenstr*4;
|
||||
}
|
||||
else {
|
||||
if( justify == LEFT_JUST ) {
|
||||
posincr = - (lenstr << 8); // 0;
|
||||
}
|
||||
}
|
||||
|
||||
if( fontSize == SMALL ) {
|
||||
textString( scrn_rect.left + posincr, scrn_rect.top,
|
||||
label_buffer, GLUT_BITMAP_8_BY_13);
|
||||
}
|
||||
else {
|
||||
if( fontSize == LARGE ) {
|
||||
textString( scrn_rect.left + posincr, scrn_rect.top,
|
||||
label_buffer, GLUT_BITMAP_9_BY_15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
301
Cockpit/hud_ladr.cxx
Normal file
301
Cockpit/hud_ladr.cxx
Normal file
|
@ -0,0 +1,301 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <Aircraft/aircraft.h>
|
||||
#include <Debug/fg_debug.h>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Math/fg_random.h>
|
||||
#include <Math/mat3.h>
|
||||
#include <Math/polar3d.h>
|
||||
#include <Scenery/scenery.hxx>
|
||||
#include <Time/fg_timer.hxx>
|
||||
#include <Weather/weather.h>
|
||||
|
||||
|
||||
#include "hud.hxx"
|
||||
//====================== Top of HudLadder Class =======================
|
||||
HudLadder ::
|
||||
HudLadder( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR ptch_source,
|
||||
DBLFNPTR roll_source,
|
||||
double span_units,
|
||||
double major_div,
|
||||
double minor_div,
|
||||
UINT screen_hole,
|
||||
UINT lbl_pos,
|
||||
bool working) :
|
||||
dual_instr_item( x, y, width, height,
|
||||
ptch_source,
|
||||
roll_source,
|
||||
working,
|
||||
HUDS_RIGHT),
|
||||
width_units ( span_units ),
|
||||
div_units ( major_div < 0? -major_div: major_div ),
|
||||
minor_div ( minor_div ),
|
||||
label_pos ( lbl_pos ),
|
||||
scr_hole ( screen_hole ),
|
||||
vmax ( span_units/2 ),
|
||||
vmin ( -vmax )
|
||||
{
|
||||
if( !width_units ) {
|
||||
width_units = 45;
|
||||
}
|
||||
factor = (double)get_span() / (double) width_units;
|
||||
}
|
||||
|
||||
HudLadder ::
|
||||
~HudLadder()
|
||||
{
|
||||
}
|
||||
|
||||
HudLadder ::
|
||||
HudLadder( const HudLadder & image ) :
|
||||
dual_instr_item( (dual_instr_item &) image),
|
||||
width_units ( image.width_units ),
|
||||
div_units ( image.div_units ),
|
||||
label_pos ( image.label_pos ),
|
||||
scr_hole ( image.scr_hole ),
|
||||
vmax ( image.vmax ),
|
||||
vmin ( image.vmin ),
|
||||
factor ( image.factor )
|
||||
{
|
||||
}
|
||||
HudLadder & HudLadder ::
|
||||
operator = ( const HudLadder & rhs )
|
||||
{
|
||||
if( !(this == &rhs)) {
|
||||
(dual_instr_item &)(*this) = (dual_instr_item &)rhs;
|
||||
width_units = rhs.width_units;
|
||||
div_units = rhs.div_units;
|
||||
label_pos = rhs.label_pos;
|
||||
scr_hole = rhs.scr_hole;
|
||||
vmax = rhs.vmax;
|
||||
vmin = rhs.vmin;
|
||||
factor = rhs.factor;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// Draws a climb ladder in the center of the HUD
|
||||
//
|
||||
|
||||
void HudLadder :: draw( void )
|
||||
{
|
||||
double roll_value;
|
||||
double pitch_value;
|
||||
int marker_y;
|
||||
int x_ini;
|
||||
int x_end;
|
||||
int y_ini;
|
||||
int y_end;
|
||||
int new_x_ini;
|
||||
int new_x_end;
|
||||
int new_y_ini;
|
||||
int new_y_end;
|
||||
int i;
|
||||
POINT centroid = get_centroid();
|
||||
RECT box = get_location();
|
||||
int scr_min = box.top;
|
||||
int half_span = box.right >> 1;
|
||||
char TextLadder[80];
|
||||
int condition;
|
||||
int label_length;
|
||||
roll_value = current_ch2();
|
||||
GLfloat sinRoll = sin( roll_value );
|
||||
GLfloat cosRoll = cos( roll_value );
|
||||
|
||||
pitch_value = current_ch1() * RAD_TO_DEG;
|
||||
vmin = pitch_value - (double)width_units/2.0;
|
||||
vmax = pitch_value + (double)width_units/2.0;
|
||||
|
||||
// Box the target.
|
||||
drawOneLine( centroid.x - 5, centroid.y, centroid.x, centroid.y + 5);
|
||||
drawOneLine( centroid.x, centroid.y + 5, centroid.x + 5, centroid.y);
|
||||
drawOneLine( centroid.x + 5, centroid.y, centroid.x, centroid.y - 5);
|
||||
drawOneLine( centroid.x, centroid.y - 5, centroid.x - 5, centroid.y);
|
||||
|
||||
for( i=(int)vmin; i<=(int)vmax; i++ ) { // Through integer pitch values...
|
||||
condition = 1;
|
||||
if( condition ) {
|
||||
marker_y = centroid.y + (int)(((double)(i - pitch_value) * factor) + .5);
|
||||
if( div_units ) {
|
||||
if( !(i % div_units )) { // At integral multiple of div
|
||||
sprintf( TextLadder, "%d", i );
|
||||
label_length = strlen( TextLadder );
|
||||
if( scr_hole == 0 ) {
|
||||
if( i ) {
|
||||
x_ini = centroid.x - half_span;
|
||||
}
|
||||
else { // Make zero point wider on left
|
||||
x_ini = centroid.x - half_span - 10;
|
||||
}
|
||||
y_ini = marker_y;
|
||||
x_end = centroid.x + half_span;
|
||||
y_end = marker_y;
|
||||
new_x_ini = centroid.x + (int)(
|
||||
(x_ini - centroid.x) * cosRoll -
|
||||
(y_ini - centroid.y) * sinRoll);
|
||||
new_y_ini = centroid.y + (int)( \
|
||||
(x_ini - centroid.x) * sinRoll + \
|
||||
(y_ini - centroid.y) * cosRoll);
|
||||
new_x_end = centroid.x + (int)( \
|
||||
(x_end - centroid.x) * cosRoll - \
|
||||
(y_end - centroid.y) * sinRoll);
|
||||
new_y_end = centroid.y + (int)( \
|
||||
(x_end - centroid.x) * sinRoll + \
|
||||
(y_end - centroid.y) * cosRoll);
|
||||
|
||||
if( i >= 0 ) { // Above zero draw solid lines
|
||||
drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
|
||||
}
|
||||
else { // Below zero draw dashed lines.
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
glLineStipple( 1, 0x00FF );
|
||||
drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
}
|
||||
// Calculate the position of the left text and write it.
|
||||
new_x_ini = centroid.x + (int)(
|
||||
(x_ini - 8 * label_length- 4 - centroid.x) * cosRoll -
|
||||
(y_ini - 4 ) * sinRoll);
|
||||
new_y_ini = centroid.y + (int)(
|
||||
(x_ini - 8 * label_length- 4 - centroid.x) * sinRoll +
|
||||
(y_ini - 4 - centroid.y) * cosRoll);
|
||||
strokeString( new_x_ini , new_y_ini ,
|
||||
TextLadder, GLUT_STROKE_ROMAN,
|
||||
roll_value );
|
||||
|
||||
// Calculate the position of the right text and write it.
|
||||
new_x_end = centroid.x + (int)( \
|
||||
(x_end + 24 - 8 * label_length - centroid.x) * cosRoll - \
|
||||
(y_end - 4 - centroid.y) * sinRoll);
|
||||
new_y_end = centroid.y + (int)( \
|
||||
(x_end + 24 - 8 * label_length - centroid.x) * sinRoll + \
|
||||
(y_end - 4 - centroid.y) * cosRoll);
|
||||
strokeString( new_x_end, new_y_end,
|
||||
TextLadder, GLUT_STROKE_ROMAN,
|
||||
roll_value );
|
||||
}
|
||||
else { // Draw ladder with space in the middle of the lines
|
||||
// Start by calculating the points and drawing the
|
||||
// left side lines.
|
||||
if( i != 0 ) {
|
||||
x_ini = centroid.x - half_span;
|
||||
}
|
||||
else {
|
||||
x_ini = centroid.x - half_span - 10;
|
||||
}
|
||||
y_ini = marker_y;
|
||||
x_end = centroid.x - half_span + scr_hole/2;
|
||||
y_end = marker_y;
|
||||
|
||||
new_x_end = centroid.x+ (int)( \
|
||||
(x_end - centroid.x) * cosRoll -\
|
||||
(y_end - centroid.y) * sinRoll);
|
||||
new_y_end = centroid.y+ (int)( \
|
||||
(x_end - centroid.x) * sinRoll +\
|
||||
(y_end - centroid.y) * cosRoll);
|
||||
new_x_ini = centroid.x + (int)( \
|
||||
(x_ini - centroid.x) * cosRoll -\
|
||||
(y_ini - centroid.y) * sinRoll);
|
||||
new_y_ini = centroid.y + (int)( \
|
||||
(x_ini - centroid.x) * sinRoll +\
|
||||
(y_ini - centroid.y) * cosRoll);
|
||||
|
||||
if( i >= 0 )
|
||||
{
|
||||
drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
|
||||
}
|
||||
else {
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
glLineStipple( 1, 0x00FF );
|
||||
drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
}
|
||||
// Now calculate the location of the left side label using
|
||||
// the previously calculated start of the left side line.
|
||||
|
||||
x_ini = x_ini - (label_length + 32 + centroid.x);
|
||||
if( i < 0) {
|
||||
x_ini -= 8;
|
||||
}
|
||||
else {
|
||||
if( i == 0 ) {
|
||||
x_ini += 20;
|
||||
}
|
||||
}
|
||||
y_ini = y_ini - ( 4 + centroid.y);
|
||||
|
||||
new_x_ini = centroid.x + (int)(x_ini * cosRoll - y_ini * sinRoll);
|
||||
new_y_ini = centroid.y + (int)(x_ini * sinRoll + y_ini * cosRoll);
|
||||
strokeString( new_x_ini , new_y_ini ,
|
||||
TextLadder, GLUT_STROKE_MONO_ROMAN,
|
||||
roll_value );
|
||||
|
||||
// Now calculate and draw the right side line location
|
||||
x_ini = centroid.x + half_span - scr_hole/2;
|
||||
y_ini = marker_y;
|
||||
if( i != 0 ) {
|
||||
x_end = centroid.x + half_span;
|
||||
}
|
||||
else {
|
||||
x_end = centroid.x + half_span + 10;
|
||||
}
|
||||
y_end = marker_y;
|
||||
|
||||
new_x_ini = centroid.x + (int)( \
|
||||
(x_ini-centroid.x)*cosRoll -\
|
||||
(y_ini-centroid.y)*sinRoll);
|
||||
new_y_ini = centroid.y + (int)( \
|
||||
(x_ini-centroid.x)*sinRoll +\
|
||||
(y_ini-centroid.y)*cosRoll);
|
||||
new_x_end = centroid.x + (int)( \
|
||||
(x_end-centroid.x)*cosRoll -\
|
||||
(y_end-centroid.y)*sinRoll);
|
||||
new_y_end = centroid.y + (int)( \
|
||||
(x_end-centroid.x)*sinRoll +\
|
||||
(y_end-centroid.y)*cosRoll);
|
||||
|
||||
if( i >= 0 )
|
||||
{
|
||||
drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
glLineStipple( 1, 0x00FF );
|
||||
drawOneLine( new_x_ini, new_y_ini, new_x_end, new_y_end );
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
}
|
||||
|
||||
// Calculate the location and draw the right side label
|
||||
// using the end of the line as previously calculated.
|
||||
x_end -= centroid.x + label_length - 24;
|
||||
if( i < 0 ) {
|
||||
x_end -= 8;
|
||||
}
|
||||
y_end = marker_y - ( 4 + centroid.y);
|
||||
new_x_end = centroid.x + (int)( (GLfloat)x_end * cosRoll -
|
||||
(GLfloat)y_end * sinRoll);
|
||||
new_y_end = centroid.y + (int)( (GLfloat)x_end * sinRoll +
|
||||
(GLfloat)y_end * cosRoll);
|
||||
strokeString( new_x_end, new_y_end,
|
||||
TextLadder, GLUT_STROKE_MONO_ROMAN,
|
||||
roll_value );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
103
Cockpit/hud_scal.cxx
Normal file
103
Cockpit/hud_scal.cxx
Normal file
|
@ -0,0 +1,103 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <Aircraft/aircraft.h>
|
||||
#include <Debug/fg_debug.h>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Math/fg_random.h>
|
||||
#include <Math/mat3.h>
|
||||
#include <Math/polar3d.h>
|
||||
#include <Scenery/scenery.hxx>
|
||||
#include <Time/fg_timer.hxx>
|
||||
#include <Weather/weather.h>
|
||||
|
||||
|
||||
#include "hud.hxx"
|
||||
//============== Top of instr_scale class memeber definitions ===============
|
||||
//
|
||||
// Notes:
|
||||
// 1. instr_scales divide the specified location into half and then
|
||||
// the half opposite the read direction in half again. A bar is
|
||||
// then drawn along the second divider. Scale ticks are drawn
|
||||
// between the middle and quarter section lines (minor division
|
||||
// markers) or just over the middle line.
|
||||
//
|
||||
// 2. This class was not intended to be instanciated. See moving_scale
|
||||
// and guage_instr classes.
|
||||
//============================================================================
|
||||
instr_scale ::
|
||||
instr_scale ( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR load_fn,
|
||||
UINT options,
|
||||
double show_range,
|
||||
double maxValue,
|
||||
double minValue,
|
||||
double disp_scale,
|
||||
UINT major_divs,
|
||||
UINT minor_divs,
|
||||
UINT rollover,
|
||||
int dp_showing,
|
||||
bool working ) :
|
||||
instr_item( x, y, width, height, load_fn, options, working),
|
||||
range_shown ( show_range ),
|
||||
Maximum_value( maxValue ),
|
||||
Minimum_value( minValue ),
|
||||
scale_factor ( disp_scale ),
|
||||
Maj_div ( major_divs ),
|
||||
Min_div ( minor_divs ),
|
||||
Modulo ( rollover ),
|
||||
signif_digits( dp_showing )
|
||||
{
|
||||
int temp;
|
||||
|
||||
scale_factor = (double)get_span() / range_shown;
|
||||
if( show_range < 0 ) {
|
||||
range_shown = -range_shown;
|
||||
}
|
||||
temp = (Maximum_value - Minimum_value) / 100;
|
||||
if( range_shown < temp ) {
|
||||
range_shown = temp;
|
||||
}
|
||||
}
|
||||
|
||||
instr_scale ::
|
||||
instr_scale( const instr_scale & image ) :
|
||||
instr_item( (const instr_item &) image),
|
||||
range_shown ( image.range_shown ),
|
||||
Maximum_value( image.Maximum_value ),
|
||||
Minimum_value( image.Minimum_value ),
|
||||
scale_factor ( image.scale_factor ),
|
||||
Maj_div ( image.Maj_div ),
|
||||
Min_div ( image.Min_div ),
|
||||
Modulo ( image.Modulo ),
|
||||
signif_digits( image.signif_digits )
|
||||
{
|
||||
}
|
||||
|
||||
instr_scale & instr_scale :: operator = (const instr_scale & rhs )
|
||||
{
|
||||
if( !(this == &rhs)) {
|
||||
instr_item::operator = (rhs);
|
||||
range_shown = rhs.range_shown;
|
||||
scale_factor = rhs.scale_factor;
|
||||
Maximum_value = rhs.Maximum_value;
|
||||
Minimum_value = rhs.Minimum_value;
|
||||
Maj_div = rhs.Maj_div;
|
||||
Min_div = rhs.Min_div;
|
||||
Modulo = rhs.Modulo;
|
||||
signif_digits = rhs.signif_digits;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
instr_scale :: ~ instr_scale () {}
|
||||
|
192
Cockpit/hud_tbi.cxx
Normal file
192
Cockpit/hud_tbi.cxx
Normal file
|
@ -0,0 +1,192 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <Aircraft/aircraft.h>
|
||||
#include <Debug/fg_debug.h>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Math/fg_random.h>
|
||||
#include <Math/mat3.h>
|
||||
#include <Math/polar3d.h>
|
||||
#include <Scenery/scenery.hxx>
|
||||
#include <Time/fg_timer.hxx>
|
||||
#include <Weather/weather.h>
|
||||
|
||||
|
||||
#include "hud.hxx"
|
||||
//============ Top of fgTBI_instr class member definitions ==============
|
||||
|
||||
fgTBI_instr ::
|
||||
fgTBI_instr( int x,
|
||||
int y,
|
||||
UINT width,
|
||||
UINT height,
|
||||
DBLFNPTR chn1_source,
|
||||
DBLFNPTR chn2_source,
|
||||
double maxBankAngle,
|
||||
double maxSlipAngle,
|
||||
UINT gap_width,
|
||||
bool working ) :
|
||||
dual_instr_item( x, y, width, height,
|
||||
chn1_source,
|
||||
chn2_source,
|
||||
working,
|
||||
HUDS_TOP),
|
||||
BankLimit (maxBankAngle),
|
||||
SlewLimit (maxSlipAngle),
|
||||
scr_hole (gap_width )
|
||||
{
|
||||
}
|
||||
|
||||
fgTBI_instr :: ~fgTBI_instr() {}
|
||||
|
||||
fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
|
||||
dual_instr_item( (const dual_instr_item &) image),
|
||||
BankLimit( image.BankLimit),
|
||||
SlewLimit( image.SlewLimit),
|
||||
scr_hole ( image.scr_hole )
|
||||
{
|
||||
}
|
||||
|
||||
fgTBI_instr & fgTBI_instr ::
|
||||
operator = (const fgTBI_instr & rhs )
|
||||
{
|
||||
if( !(this == &rhs)) {
|
||||
dual_instr_item::operator = (rhs);
|
||||
BankLimit = rhs.BankLimit;
|
||||
SlewLimit = rhs.SlewLimit;
|
||||
scr_hole = rhs.scr_hole;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// Draws a Turn Bank Indicator on the screen
|
||||
//
|
||||
|
||||
void fgTBI_instr :: draw( void )
|
||||
{
|
||||
int x_inc1, y_inc1;
|
||||
int x_inc2, y_inc2;
|
||||
int x_t_inc1, y_t_inc1;
|
||||
|
||||
int d_bottom_x, d_bottom_y;
|
||||
int d_right_x, d_right_y;
|
||||
int d_top_x, d_top_y;
|
||||
int d_left_x, d_left_y;
|
||||
|
||||
int inc_b_x, inc_b_y;
|
||||
int inc_r_x, inc_r_y;
|
||||
int inc_t_x, inc_t_y;
|
||||
int inc_l_x, inc_l_y;
|
||||
RECT My_box = get_location();
|
||||
POINT centroid = get_centroid();
|
||||
int tee_height = My_box.bottom;
|
||||
|
||||
// struct fgFLIGHT *f = ¤t_aircraft.flight;
|
||||
double sin_bank, cos_bank;
|
||||
double bank_angle, sideslip_angle;
|
||||
double ss_const; // sideslip angle pixels per rad
|
||||
|
||||
bank_angle = current_ch2(); // Roll limit +/- 30 degrees
|
||||
if( bank_angle < -FG_PI_2/3 ) {
|
||||
bank_angle = -FG_PI_2/3;
|
||||
}
|
||||
else
|
||||
if( bank_angle > FG_PI_2/3 ) {
|
||||
bank_angle = FG_PI_2/3;
|
||||
}
|
||||
sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
|
||||
if( sideslip_angle < -FG_PI/9 ) {
|
||||
sideslip_angle = -FG_PI/9;
|
||||
}
|
||||
else
|
||||
if( sideslip_angle > FG_PI/9 ) {
|
||||
sideslip_angle = FG_PI/9;
|
||||
}
|
||||
|
||||
// sin_bank = sin( FG_2PI-FG_Phi );
|
||||
// cos_bank = cos( FG_2PI-FG_Phi );
|
||||
sin_bank = sin(FG_2PI-bank_angle);
|
||||
cos_bank = cos(FG_2PI-bank_angle);
|
||||
|
||||
x_inc1 = (int)(get_span() * cos_bank);
|
||||
y_inc1 = (int)(get_span() * sin_bank);
|
||||
x_inc2 = (int)(scr_hole * cos_bank);
|
||||
y_inc2 = (int)(scr_hole * sin_bank);
|
||||
|
||||
x_t_inc1 = (int)(tee_height * sin_bank);
|
||||
y_t_inc1 = (int)(tee_height * cos_bank);
|
||||
|
||||
d_bottom_x = 0;
|
||||
d_bottom_y = (int)(-scr_hole);
|
||||
d_right_x = (int)(scr_hole);
|
||||
d_right_y = 0;
|
||||
d_top_x = 0;
|
||||
d_top_y = (int)(scr_hole);
|
||||
d_left_x = (int)(-scr_hole);
|
||||
d_left_y = 0;
|
||||
|
||||
ss_const = (get_span()*2)/(FG_2PI/9); // width represents 40 degrees
|
||||
|
||||
d_bottom_x += (int)(sideslip_angle*ss_const);
|
||||
d_right_x += (int)(sideslip_angle*ss_const);
|
||||
d_left_x += (int)(sideslip_angle*ss_const);
|
||||
d_top_x += (int)(sideslip_angle*ss_const);
|
||||
|
||||
inc_b_x = (int)(d_bottom_x*cos_bank-d_bottom_y*sin_bank);
|
||||
inc_b_y = (int)(d_bottom_x*sin_bank+d_bottom_y*cos_bank);
|
||||
inc_r_x = (int)(d_right_x*cos_bank-d_right_y*sin_bank);
|
||||
inc_r_y = (int)(d_right_x*sin_bank+d_right_y*cos_bank);
|
||||
inc_t_x = (int)(d_top_x*cos_bank-d_top_y*sin_bank);
|
||||
inc_t_y = (int)(d_top_x*sin_bank+d_top_y*cos_bank);
|
||||
inc_l_x = (int)(d_left_x*cos_bank-d_left_y*sin_bank);
|
||||
inc_l_y = (int)(d_left_x*sin_bank+d_left_y*cos_bank);
|
||||
|
||||
if( scr_hole == 0 )
|
||||
{
|
||||
drawOneLine( centroid.x - x_inc1, centroid.y - y_inc1, \
|
||||
centroid.x + x_inc1, centroid.y + y_inc1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
drawOneLine( centroid.x - x_inc1, centroid.y - y_inc1, \
|
||||
centroid.x - x_inc2, centroid.y - y_inc2 );
|
||||
drawOneLine( centroid.x + x_inc2, centroid.y + y_inc2, \
|
||||
centroid.x + x_inc1, centroid.y + y_inc1 );
|
||||
}
|
||||
|
||||
// draw teemarks
|
||||
drawOneLine( centroid.x + x_inc2, \
|
||||
centroid.y + y_inc2, \
|
||||
centroid.x + x_inc2 + x_t_inc1, \
|
||||
centroid.y + y_inc2 - y_t_inc1 );
|
||||
drawOneLine( centroid.x - x_inc2, \
|
||||
centroid.y - y_inc2, \
|
||||
centroid.x - x_inc2 + x_t_inc1, \
|
||||
centroid.y - y_inc2 - y_t_inc1 );
|
||||
|
||||
// draw sideslip diamond (it is not yet positioned correctly )
|
||||
drawOneLine( centroid.x + inc_b_x, \
|
||||
centroid.y + inc_b_y, \
|
||||
centroid.x + inc_r_x, \
|
||||
centroid.y + inc_r_y );
|
||||
drawOneLine( centroid.x + inc_r_x, \
|
||||
centroid.y + inc_r_y, \
|
||||
centroid.x + inc_t_x, \
|
||||
centroid.y + inc_t_y );
|
||||
drawOneLine( centroid.x + inc_t_x, \
|
||||
centroid.y + inc_t_y, \
|
||||
centroid.x + inc_l_x, \
|
||||
centroid.y + inc_l_y );
|
||||
drawOneLine( centroid.x + inc_l_x, \
|
||||
centroid.y + inc_l_y, \
|
||||
centroid.x + inc_b_x, \
|
||||
centroid.y + inc_b_y );
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue