1
0
Fork 0

remove readCard and let the gauge_instr class read its own properties

This commit is contained in:
mfranz 2006-06-14 20:39:10 +00:00
parent b32aa5086a
commit 9e2de090b4
4 changed files with 229 additions and 312 deletions

View file

@ -48,12 +48,11 @@
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/props/props.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <Aircraft/aircraft.hxx> #include <Aircraft/aircraft.hxx>
#include <Autopilot/xmlauto.hxx> #include <Autopilot/xmlauto.hxx>
#include <GUI/new_gui.hxx> #include <GUI/new_gui.hxx> // FGFontCache
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Scenery/scenery.hxx> #include <Scenery/scenery.hxx>
@ -61,7 +60,7 @@
#include "hud.hxx" #include "hud.hxx"
static HUD_Properties *HUD = 0; static HUD_Properties *HUDprop = 0;
static char units[5]; static char units[5];
@ -125,7 +124,7 @@ static FLTFNPTR load_fn;
int readHud( istream &input ); int readHud( istream &input );
int readInstrument ( const SGPropertyNode * node); int readInstrument ( const SGPropertyNode * node);
static instr_item * readCard ( const SGPropertyNode * node); static instr_item * readCardDialTape ( const SGPropertyNode * node);
static void drawHUD(); static void drawHUD();
static void fgUpdateHUDVirtual(); static void fgUpdateHUDVirtual();
@ -159,12 +158,10 @@ locRECT :: locRECT( UINT left, UINT top, UINT right, UINT bottom)
// //
static instr_item * static instr_item *
readCard(const SGPropertyNode * node) readCardDialTape(const SGPropertyNode * node)
{ {
instr_item *p; instr_item *p;
name = node->getStringValue("name");
x = node->getIntValue("x"); x = node->getIntValue("x");
y = node->getIntValue("y"); y = node->getIntValue("y");
width = node->getIntValue("width"); width = node->getIntValue("width");
@ -197,12 +194,8 @@ readCard(const SGPropertyNode * node)
divisions = node->getIntValue("divisions"); divisions = node->getIntValue("divisions");
zoom = node->getIntValue("zoom"); zoom = node->getIntValue("zoom");
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name); SG_LOG(SG_INPUT, SG_INFO, "Done reading dial/tape instrument "
<< node->getStringValue("name", "[none]"));
if (type=="gauge") {
span_units = maxValue - minValue;
}
if (loadfn=="anzg") { if (loadfn=="anzg") {
load_fn = get_anzg; load_fn = get_anzg;
@ -233,55 +226,41 @@ readCard(const SGPropertyNode * node)
} }
if ( (type == "dial") | (type == "tape") ) { // type == "dial") || (type == "tape")
p = (instr_item *) new hud_card( x, p = (instr_item *) new hud_card( x,
y, y,
width, width,
height, height,
load_fn, load_fn,
options, options,
maxValue, minValue, maxValue, minValue,
scaling, scaling,
major_divs, minor_divs, major_divs, minor_divs,
modulator, modulator,
dp_showing, dp_showing,
span_units, span_units,
type, type,
tick_bottom, tick_bottom,
tick_top, tick_top,
tick_right, tick_right,
tick_left, tick_left,
cap_bottom, cap_bottom,
cap_top, cap_top,
cap_right, cap_right,
cap_left, cap_left,
marker_off, marker_off,
enable_pointer, enable_pointer,
type_pointer, type_pointer,
type_tick, type_tick,
length_tick, length_tick,
working, working,
radius, radius,
divisions, divisions,
zoom zoom
); );
} else {
p = (instr_item *) new gauge_instr( x, // x
y, // y
width, // width
height, // height
load_fn, // data source
options,
scaling,
maxValue,minValue,
major_divs, minor_divs,
dp_showing,
modulator,
working);
}
return p; return p;
}// end readCard }
int readInstrument(const SGPropertyNode * node) int readInstrument(const SGPropertyNode * node)
@ -311,7 +290,11 @@ int readInstrument(const SGPropertyNode * node)
if (card_group != 0) { if (card_group != 0) {
int nCards = card_group->nChildren(); int nCards = card_group->nChildren();
for (int j = 0; j < nCards; j++) { for (int j = 0; j < nCards; j++) {
HIptr = readCard(card_group->getChild(j)); const char *type = card_group->getChild(j)->getStringValue("type", "gauge");
if (!strcmp(type, "gauge"))
HIptr = static_cast<instr_item *>(new gauge_instr(card_group->getChild(j)));
else if (!strcmp(type, "dial") || !strcmp(type, "tape"))
HIptr = readCardDialTape(card_group->getChild(j));
HUD_deque.insert(HUD_deque.begin(), HIptr); HUD_deque.insert(HUD_deque.begin(), HIptr);
} }
} }
@ -442,8 +425,8 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
HUDtext->setPointSize(HUD_TextSize); HUDtext->setPointSize(HUD_TextSize);
HUD_TextList.setFont( HUDtext ); HUD_TextList.setFont( HUDtext );
if (!HUD) if (!HUDprop)
HUD = new HUD_Properties; HUDprop = new HUD_Properties;
return 0; // For now. Later we may use this for an error code. return 0; // For now. Later we may use this for an error code.
} }
@ -468,8 +451,8 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
input.close(); input.close();
} }
if (!HUD) if (!HUDprop)
HUD = new HUD_Properties; HUDprop = new HUD_Properties;
return 0; // For now. Later we may use this for an error code. return 0; // For now. Later we may use this for an error code.
} }
@ -621,21 +604,21 @@ void drawHUD()
static char hud_alt_text[256]; static char hud_alt_text[256];
glEnable(GL_BLEND); glEnable(GL_BLEND);
if (HUD->isTransparent()) if (HUDprop->isTransparent())
glBlendFunc(GL_SRC_ALPHA, GL_ONE); glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else else
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (HUD->isAntialiased()) { if (HUDprop->isAntialiased()) {
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
glAlphaFunc(GL_GREATER, HUD->alphaClamp()); glAlphaFunc(GL_GREATER, HUDprop->alphaClamp());
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
//glLineWidth(1.5); //glLineWidth(1.5);
} else { } else {
//glLineWidth(1.0); //glLineWidth(1.0);
} }
HUD->setColor(); HUDprop->setColor();
for_each(HUD_deque.begin(), HUD_deque.end(), HUDdraw()); for_each(HUD_deque.begin(), HUD_deque.end(), HUDdraw());
//HUD_TextList.add( fgText(40, 10, get_formated_gmt_time(), 0) ); //HUD_TextList.add( fgText(40, 10, get_formated_gmt_time(), 0) );
@ -701,7 +684,7 @@ void drawHUD()
// HUD_StippleLineList.draw(); // HUD_StippleLineList.draw();
// glDisable(GL_LINE_STIPPLE); // glDisable(GL_LINE_STIPPLE);
if (HUD->isAntialiased()) { if (HUDprop->isAntialiased()) {
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
glDisable(GL_LINE_SMOOTH); glDisable(GL_LINE_SMOOTH);
//glLineWidth(1.0); //glLineWidth(1.0);
@ -723,14 +706,14 @@ void fgTextList::draw()
glPushAttrib(GL_COLOR_BUFFER_BIT); glPushAttrib(GL_COLOR_BUFFER_BIT);
glEnable(GL_BLEND); glEnable(GL_BLEND);
if (HUD->isTransparent()) if (HUDprop->isTransparent())
glBlendFunc(GL_SRC_ALPHA, GL_ONE); glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else else
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (HUD->isAntialiased()) { if (HUDprop->isAntialiased()) {
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, HUD->alphaClamp()); glAlphaFunc(GL_GREATER, HUDprop->alphaClamp());
} }
Font->begin(); Font->begin();

View file

@ -801,23 +801,7 @@ public:
class gauge_instr : public instr_scale { class gauge_instr : public instr_scale {
public: public:
gauge_instr( int x, gauge_instr(const SGPropertyNode *);
int y,
UINT width,
UINT height,
FLTFNPTR load_fn,
UINT options,
float disp_scaling,
float maxValue,
float minValue,
UINT major_divs,
UINT minor_divs,
int dp_showing,
UINT modulus,
bool working);
~gauge_instr();
gauge_instr( const gauge_instr & image);
virtual void draw( void ); // Required method in base class virtual void draw( void ); // Required method in base class
}; };

View file

@ -1,68 +1,65 @@
#include "hud.hxx" #include "hud.hxx"
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString(x, y, text, digit) TextString(text, x , y ,digit) #define textString(x, y, text, digit) TextString(text, x , y ,digit)
#else #else
#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y) #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif #endif
//============== Top of gauge_instr class member definitions ==============
gauge_instr::gauge_instr( gauge_instr::gauge_instr(const SGPropertyNode *node) :
int x, instr_scale(
int y, node->getIntValue("x"),
UINT width, node->getIntValue("y"),
UINT height, node->getIntValue("width"),
FLTFNPTR load_fn, node->getIntValue("height"),
UINT options, 0 /*load_fn*/,
float disp_scale, node->getIntValue("options"),
float maxValue, node->getFloatValue("maxValue") - node->getFloatValue("minValue"), // Always shows span?
float minValue, node->getFloatValue("maxValue"),
UINT major_divs, node->getFloatValue("minValue"),
UINT minor_divs, node->getFloatValue("disp_scaling"),
int dp_showing, node->getIntValue("major_divs"),
UINT modulus, node->getIntValue("minor_divs"),
bool working) : node->getIntValue("modulator"), // "rollover"
instr_scale( x, y, width, height, 0, /* hud.cxx: static int dp_shoing = 0; */ // FIXME
load_fn, options, node->getBoolValue("working"))
(maxValue - minValue), // Always shows span?
maxValue, minValue,
disp_scale,
major_divs, minor_divs,
modulus, dp_showing,
working)
{ {
// UINT options = get_options(); SG_LOG(SG_INPUT, SG_INFO, "Done reading gauge instrument "
// huds_vert = options & HUDS_VERT; << node->getStringValue("name", "[unnamed]"));
// huds_left = options & HUDS_LEFT;
// huds_right = options & HUDS_RIGHT;
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
// huds_noticks = options & HUDS_NOTICKS;
// huds_notext = options & HUDS_NOTEXT;
// huds_top = options & HUDS_TOP;
// huds_bottom = options & HUDS_BOTTOM;
}
string loadfn = node->getStringValue("loadfn"); // FIXME
float (*load_fn)(void);
if (loadfn=="anzg") {
load_fn = get_anzg;
} else if (loadfn=="heading") {
load_fn = get_heading;
} else if (loadfn=="aoa") {
load_fn = get_aoa;
} else if (loadfn=="climb") {
load_fn = get_climb_rate;
} else if (loadfn=="altitude") {
load_fn = get_altitude;
} else if (loadfn=="agl") {
load_fn = get_agl;
} else if (loadfn=="speed") {
load_fn = get_speed;
} else if (loadfn=="view_direction") {
load_fn = get_view_direction;
} else if (loadfn=="aileronval") {
load_fn = get_aileronval;
} else if (loadfn=="elevatorval") {
load_fn = get_elevatorval;
} else if (loadfn=="elevatortrimval") {
load_fn = get_elev_trimval;
} else if (loadfn=="rudderval") {
load_fn = get_rudderval;
} else if (loadfn=="throttleval") {
load_fn = get_throttleval;
} else
load_fn = 0;
gauge_instr::~gauge_instr() set_data_source(load_fn);
{
}
gauge_instr::gauge_instr( const gauge_instr & image) :
instr_scale( (instr_scale &) image)
{
// UINT options = get_options();
// huds_vert = options & HUDS_VERT;
// huds_left = options & HUDS_LEFT;
// huds_right = options & HUDS_RIGHT;
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
// huds_noticks = options & HUDS_NOTICKS;
// huds_notext = options & HUDS_NOTEXT;
// huds_top = options & HUDS_TOP;
// huds_bottom = options & HUDS_BOTTOM;
} }
@ -72,7 +69,7 @@ gauge_instr::gauge_instr( const gauge_instr & image) :
// This routine should be worked over before using. Current value would be // This routine should be worked over before using. Current value would be
// fetched and not used if not commented out. Clearly that is intollerable. // fetched and not used if not commented out. Clearly that is intollerable.
void gauge_instr::draw (void) void gauge_instr::draw(void)
{ {
float marker_xs, marker_xe; float marker_xs, marker_xe;
float marker_ys, marker_ye; float marker_ys, marker_ye;
@ -83,53 +80,41 @@ void gauge_instr::draw (void)
char TextScale[80]; char TextScale[80];
bool condition; bool condition;
int disp_val = 0; int disp_val = 0;
float vmin = min_val(); float vmin = min_val();
float vmax = max_val(); float vmax = max_val();
POINT mid_scr = get_centroid(); POINT mid_scr = get_centroid();
float cur_value = get_value(); float cur_value = get_value();
RECT scrn_rect = get_location(); RECT scrn_rect = get_location();
UINT options = get_options(); UINT options = get_options();
width = scrn_rect.left + scrn_rect.right; width = scrn_rect.left + scrn_rect.right;
height = scrn_rect.top + scrn_rect.bottom, height = scrn_rect.top + scrn_rect.bottom;
bottom_4 = scrn_rect.bottom / 4; bottom_4 = scrn_rect.bottom / 4;
// Draw the basic markings for the scale... // Draw the basic markings for the scale...
if (huds_vert(options)) { // Vertical scale
// Bottom tick bar
drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
if ( huds_vert(options) ) { // Vertical scale // Top tick bar
drawOneLine( scrn_rect.left, // Bottom tick bar drawOneLine( scrn_rect.left, height, width, height);
scrn_rect.top,
width,
scrn_rect.top);
drawOneLine( scrn_rect.left, // Top tick bar
height,
width,
height );
marker_xs = scrn_rect.left; marker_xs = scrn_rect.left;
marker_xe = width; marker_xe = width;
if ( huds_left(options) ) { // Read left, so line down right side if (huds_left(options)) { // Read left, so line down right side
drawOneLine( width, drawOneLine(width, scrn_rect.top, width, height);
scrn_rect.top, marker_xs = marker_xe - scrn_rect.right / 3.0; // Adjust tick
width,
height);
marker_xs = marker_xe - scrn_rect.right / 3.0; // Adjust tick xs
} }
if ( huds_right(options) ) { // Read right, so down left sides if (huds_right(options)) { // Read right, so down left sides
drawOneLine( scrn_rect.left, drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, height);
scrn_rect.top, marker_xe = scrn_rect.left + scrn_rect.right / 3.0; // Adjust tick
scrn_rect.left,
height);
marker_xe = scrn_rect.left + scrn_rect.right / 3.0; // Adjust tick xe
} }
// At this point marker x_start and x_end values are transposed. // At this point marker x_start and x_end values are transposed.
// To keep this from confusing things they are now interchanged. // To keep this from confusing things they are now interchanged.
if ( huds_both(options) ) { if (huds_both(options)) {
marker_ye = marker_xs; marker_ye = marker_xs;
marker_xs = marker_xe; marker_xs = marker_xe;
marker_xe = marker_ye; marker_xe = marker_ye;
@ -138,34 +123,28 @@ void gauge_instr::draw (void)
// Work through from bottom to top of scale. Calculating where to put // Work through from bottom to top of scale. Calculating where to put
// minor and major ticks. // minor and major ticks.
if ( !huds_noticks(options)) { // If not no ticks...:) if (!huds_noticks(options)) { // If not no ticks...:)
// Calculate x marker offsets // Calculate x marker offsets
int last = (int)vmax + 1; //FloatToInt(vmax)+1; int last = (int)vmax + 1; // FloatToInt(vmax)+1;
i = (int)vmin; //FloatToInt(vmin); i = (int)vmin; //FloatToInt(vmin);
for (; i < last; i++) {
// for ( i = (int)vmin; i <= (int)vmax; i++ ) {
for (; i < last; i++) {
// Calculate the location of this tick // Calculate the location of this tick
marker_ys = scrn_rect.top + (i - vmin) * factor()/* +.5f*/; marker_ys = scrn_rect.top + (i - vmin) * factor()/* +.5f*/;
// We compute marker_ys even though we don't know if we will use // We compute marker_ys even though we don't know if we will use
// either major or minor divisions. Simpler. // either major or minor divisions. Simpler.
if ( div_min()) { // Minor tick marks if (div_min()) { // Minor tick marks
if ( !(i%(int)div_min()) ) { if (!(i % (int)div_min())) {
if ( huds_left(options) && huds_right(options) ) { if (huds_left(options) && huds_right(options)) {
drawOneLine( scrn_rect.left, marker_ys, drawOneLine(scrn_rect.left, marker_ys, marker_xs - 3, marker_ys);
marker_xs - 3, marker_ys ); drawOneLine(marker_xe + 3, marker_ys, width, marker_ys);
drawOneLine( marker_xe + 3, marker_ys,
width, marker_ys ); } else if (huds_left(options)) {
} drawOneLine(marker_xs + 3, marker_ys, marker_xe, marker_ys);
else { } else {
if ( huds_left(options) ) { drawOneLine(marker_xs, marker_ys, marker_xe - 3, marker_ys);
drawOneLine( marker_xs + 3, marker_ys, marker_xe, marker_ys );
}
else {
drawOneLine( marker_xs, marker_ys, marker_xe - 3, marker_ys );
}
} }
} }
} }
@ -174,44 +153,39 @@ void gauge_instr::draw (void)
// and no labels are drawn otherwise, we label inside this if // and no labels are drawn otherwise, we label inside this if
// statement. // statement.
if ( div_max()) { // Major tick mark if (div_max()) { // Major tick mark
if ( !(i%(int)div_max()) ) { if (!(i % (int)div_max())) {
if ( huds_left(options) && huds_right(options) ) { if (huds_left(options) && huds_right(options)) {
drawOneLine( scrn_rect.left, marker_ys, drawOneLine(scrn_rect.left, marker_ys, marker_xs, marker_ys);
marker_xs, marker_ys ); drawOneLine(marker_xe, marker_ys, width, marker_ys);
drawOneLine( marker_xe, marker_ys, } else {
width, marker_ys ); drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
}
else {
drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
} }
if ( !huds_notext(options) ) { if (!huds_notext(options)) {
disp_val = i; disp_val = i;
sprintf( TextScale, "%d", sprintf(TextScale, "%d",
FloatToInt(disp_val * data_scaling()/*+.5*/ )); FloatToInt(disp_val * data_scaling()/*+.5*/));
lenstr = getStringWidth( TextScale ); lenstr = getStringWidth(TextScale);
if ( huds_left(options) && huds_right(options) ) { if (huds_left(options) && huds_right(options)) {
text_x = mid_scr.x - lenstr/2 ; text_x = mid_scr.x - lenstr/2 ;
}
else { } else if (huds_left(options)) {
if ( huds_left(options) ) { text_x = FloatToInt(marker_xs - lenstr);
text_x = FloatToInt(marker_xs - lenstr); } else {
} text_x = FloatToInt(marker_xe - lenstr);
else {
text_x = FloatToInt(marker_xe - lenstr);
}
} }
// Now we know where to put the text. // Now we know where to put the text.
text_y = FloatToInt(marker_ys); text_y = FloatToInt(marker_ys);
textString( text_x, text_y, TextScale, 0 ); textString(text_x, text_y, TextScale, 0);
} }
} }
} // }
} // }
} // }
// Now that the scale is drawn, we draw in the pointer(s). Since labels // 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 // 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 // with the marker start stops to produce a pointer for each side reading
@ -219,147 +193,123 @@ void gauge_instr::draw (void)
text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/); text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
// text_x = marker_xs - scrn_rect.left; // text_x = marker_xs - scrn_rect.left;
if ( huds_right(options) ) { if (huds_right(options)) {
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
glVertex2f( scrn_rect.left, text_y + 5); glVertex2f(scrn_rect.left, text_y + 5);
glVertex2f( FloatToInt(marker_xe), text_y); glVertex2f(FloatToInt(marker_xe), text_y);
glVertex2f( scrn_rect.left, text_y - 5); glVertex2f(scrn_rect.left, text_y - 5);
glEnd(); glEnd();
} }
if ( huds_left(options) ) { if (huds_left(options)) {
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
glVertex2f( width, text_y + 5); glVertex2f(width, text_y + 5);
glVertex2f( FloatToInt(marker_xs), text_y); glVertex2f(FloatToInt(marker_xs), text_y);
glVertex2f( width, text_y - 5); glVertex2f(width, text_y - 5);
glEnd(); glEnd();
} }
// End if VERTICAL SCALE TYPE // End if VERTICAL SCALE TYPE
} else { // Horizontal scale by default } else { // Horizontal scale by default
drawOneLine( scrn_rect.left, // left tick bar // left tick bar
scrn_rect.top, drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, height);
scrn_rect.left,
height);
drawOneLine( width, // right tick bar // right tick bar
scrn_rect.top, drawOneLine(width, scrn_rect.top, width, height );
width,
height );
marker_ys = scrn_rect.top; // Starting point for marker_ys = scrn_rect.top; // Starting point for
marker_ye = height; // tick y location calcs marker_ye = height; // tick y location calcs
marker_xs = scrn_rect.left + (cur_value - vmin) * factor() /*+ .5f*/; marker_xs = scrn_rect.left + (cur_value - vmin) * factor() /*+ .5f*/;
if ( huds_top(options) ) { if (huds_top(options)) {
drawOneLine( scrn_rect.left, // Bottom box line
scrn_rect.top, drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
width,
scrn_rect.top); // Bottom box line
marker_ye = scrn_rect.top + scrn_rect.bottom / 2.0; // Tick point adjust marker_ye = scrn_rect.top + scrn_rect.bottom / 2.0; // Tick point adjust
// Bottom arrow // Bottom arrow
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs - bottom_4, scrn_rect.top); glVertex2f(marker_xs - bottom_4, scrn_rect.top);
glVertex2f( marker_xs, marker_ye); glVertex2f(marker_xs, marker_ye);
glVertex2f( marker_xs + bottom_4, scrn_rect.top); glVertex2f(marker_xs + bottom_4, scrn_rect.top);
glEnd(); glEnd();
} }
if ( huds_bottom(options) ) {
if (huds_bottom(options)) {
// Top box line // Top box line
drawOneLine( scrn_rect.left, height, width, height); drawOneLine(scrn_rect.left, height, width, height);
// Tick point adjust // Tick point adjust
marker_ys = height - scrn_rect.bottom / 2.0; marker_ys = height - scrn_rect.bottom / 2.0;
// Top arrow // Top arrow
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs + bottom_4, height); glVertex2f(marker_xs + bottom_4, height);
glVertex2f( marker_xs, marker_ys ); glVertex2f(marker_xs, marker_ys );
glVertex2f( marker_xs - bottom_4, height); glVertex2f(marker_xs - bottom_4, height);
glEnd(); glEnd();
} }
int last = (int)vmax + 1; //FloatToInt(vmax)+1; int last = (int)vmax + 1; //FloatToInt(vmax)+1;
i = (int)vmin; //FloatToInt(vmin); i = (int)vmin; //FloatToInt(vmin);
for ( ; i <last ; i++ ) { for (; i <last ; i++) {
condition = true; condition = true;
if ( !modulo()) { if (!modulo() && i < min_val())
if ( i < min_val()) {
condition = false; condition = false;
}
} if (condition) {
if ( condition ) {
marker_xs = scrn_rect.left + (i - vmin) * factor()/* +.5f*/; marker_xs = scrn_rect.left + (i - vmin) * factor()/* +.5f*/;
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f); // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f);
if ( div_min()){ if (div_min()) {
if ( !(i%(int)div_min()) ) { if (!(i % (int)div_min())) {
// draw in ticks only if they aren't too close to the edge. // draw in ticks only if they aren't too close to the edge.
if ((( marker_xs + 5) > scrn_rect.left ) || if (((marker_xs + 5) > scrn_rect.left)
(( marker_xs - 5 )< (width))){ || ((marker_xs - 5) < (width))) {
if ( huds_both(options) ) { if (huds_both(options)) {
drawOneLine( marker_xs, scrn_rect.top, drawOneLine(marker_xs, scrn_rect.top, marker_xs, marker_ys - 4);
marker_xs, marker_ys - 4); drawOneLine(marker_xs, marker_ye + 4, marker_xs, height);
drawOneLine( marker_xs, marker_ye + 4,
marker_xs, height); } else if (huds_top(options)) {
} drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye - 4);
else { } else {
if ( huds_top(options) ) { drawOneLine(marker_xs, marker_ys + 4, marker_xs, marker_ye);
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()) ) { if (div_max()) {
if (!(i % (int)div_max())) {
if (modulo()) { if (modulo()) {
if ( disp_val < 0) { if (disp_val < 0) {
while ( disp_val < 0 ) { while (disp_val < 0)
disp_val += modulo(); disp_val += modulo();
}
} }
disp_val = i % (int)modulo(); disp_val = i % (int)modulo();
} else { } else {
disp_val = i; disp_val = i;
} }
sprintf( TextScale, "%d", sprintf(TextScale, "%d",
FloatToInt(disp_val * data_scaling()/* +.5*/ )); FloatToInt(disp_val * data_scaling()/* +.5*/));
lenstr = getStringWidth( TextScale); lenstr = getStringWidth(TextScale);
// Draw major ticks and text only if far enough from the edge. // Draw major ticks and text only if far enough from the edge.
if (( (marker_xs - 10)> scrn_rect.left ) && if (((marker_xs - 10) > scrn_rect.left)
( (marker_xs + 10) < width )){ && ((marker_xs + 10) < width)) {
if ( huds_both(options) ) { if (huds_both(options)) {
drawOneLine( marker_xs, scrn_rect.top, drawOneLine(marker_xs, scrn_rect.top, marker_xs, marker_ys);
marker_xs, marker_ys); drawOneLine(marker_xs, marker_ye, marker_xs, height);
drawOneLine( marker_xs, marker_ye,
marker_xs, height);
if ( !huds_notext(options) ) { if (!huds_notext(options))
textString ( marker_xs - lenstr, marker_ys + 4, textString(marker_xs - lenstr, marker_ys + 4, TextScale, 0);
TextScale ,0);
}
}
else {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye );
if ( !huds_notext(options) ) { } else {
if ( huds_top(options) ) { drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
textString ( marker_xs - lenstr,
height - 10, if (!huds_notext(options)) {
TextScale, 0 ); if (huds_top(options))
} textString(marker_xs - lenstr, height - 10, TextScale, 0);
else { else
textString( marker_xs - lenstr, scrn_rect.top, textString(marker_xs - lenstr, scrn_rect.top, TextScale, 0);
TextScale, 0 );
}
} }
} }
} }

View file

@ -29,7 +29,7 @@ instr_scale::instr_scale(
UINT minor_divs, UINT minor_divs,
UINT rollover, UINT rollover,
int dp_showing, int dp_showing,
bool working ) : bool working) :
instr_item( x, y, width, height, load_fn, disp_scale, options, working), instr_item( x, y, width, height, load_fn, disp_scale, options, working),
range_shown ( show_range ), range_shown ( show_range ),
Maximum_value( maxValue ), Maximum_value( maxValue ),