]> git.mxchange.org Git - flightgear.git/commitdiff
Make HUD items private to the subsystem.
authorJames Turner <zakalawe@mac.com>
Wed, 26 Sep 2012 16:02:11 +0000 (17:02 +0100)
committerJames Turner <zakalawe@mac.com>
Wed, 26 Sep 2012 16:02:11 +0000 (17:02 +0100)
Make the HUD independent of the instrument manager, and push most of the declarations from the header into a private header.

21 files changed:
src/Instrumentation/CMakeLists.txt
src/Instrumentation/HUD/HUD.cxx
src/Instrumentation/HUD/HUD.hxx
src/Instrumentation/HUD/HUD_dial.cxx
src/Instrumentation/HUD/HUD_gauge.cxx
src/Instrumentation/HUD/HUD_instrument.cxx
src/Instrumentation/HUD/HUD_label.cxx
src/Instrumentation/HUD/HUD_ladder.cxx
src/Instrumentation/HUD/HUD_misc.cxx
src/Instrumentation/HUD/HUD_private.hxx [new file with mode: 0644]
src/Instrumentation/HUD/HUD_runway.cxx
src/Instrumentation/HUD/HUD_scale.cxx
src/Instrumentation/HUD/HUD_tape.cxx
src/Instrumentation/HUD/HUD_tbi.cxx
src/Instrumentation/adf.cxx
src/Instrumentation/adf.hxx
src/Instrumentation/airspeed_indicator.hxx
src/Instrumentation/dme.hxx
src/Instrumentation/instrument_mgr.cxx
src/Main/fg_init.cxx
src/Viewer/renderer.cxx

index 7ae7cf3436769ef94907e08f53856f73e71988dc..4060b83b9d17f8b71d060e3a194d1c8c63c5b335 100644 (file)
@@ -106,6 +106,7 @@ set(HEADERS
     wxradar.hxx
     NavDisplay.hxx
     HUD/HUD.hxx
+    HUD/HUD_private.hxx
     KLN89/kln89.hxx
     KLN89/kln89_page.hxx
     KLN89/kln89_page_act.hxx
index 2b5d75aae7f2cb67000cb3f33028a3778ade19a7..d0f257cc45ac7cf5922fb168c0ef7f1e2d167743 100644 (file)
 #include <plib/fnt.h>
 
 #include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 #include <Viewer/viewmgr.hxx>
 #include <Viewer/viewer.hxx>
 #include <GUI/FGFontCache.hxx>
+#include <GUI/gui.h> // for guiErrorMessage
 
 #include "HUD.hxx"
+#include "HUD_private.hxx"
 
 using std::endl;
 using std::ifstream;
 using std::string;
+using std::deque;
+using std::vector;
 
 static float clamp(float f)
 {
     return f < 0.0f ? 0.0f : f > 1.0f ? 1.0f : f;
 }
 
+HUD::Input::Input(const SGPropertyNode *n, float factor, float offset,
+      float min, float max) :
+  _valid(false),
+  _property(0),
+  _damped(SGLimitsf::max())
+{
+  if (!n)
+    return;
+  _factor = n->getFloatValue("factor", factor);
+  _offset = n->getFloatValue("offset", offset);
+  _min = n->getFloatValue("min", min);
+  _max = n->getFloatValue("max", max);
+  _coeff = 1.0 - 1.0 / powf(10, fabs(n->getFloatValue("damp", 0.0)));
+  SGPropertyNode *p = ((SGPropertyNode *)n)->getNode("property", false);
+  if (p) {
+    const char *path = p->getStringValue();
+    if (path && path[0]) {
+      _property = fgGetNode(path, true);
+      _valid = true;
+    }
+  }
+}
 
 HUD::HUD() :
     _currentPath(fgGetNode("/sim/hud/current-path", true)),
index ade3d88dbe4af3fa877ef905648b198e648a822b..22d27d847f0c5fbbffaa679618f8a2b977c05c4a 100644 (file)
 #define _HUD_HXX
 
 #include <simgear/compiler.h>
-#include <simgear/props/condition.hxx>
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
 
 #include <vector>
 #include <deque>
-#include <fstream>
-
-using std::deque;
-using std::vector;
 
 #include <osg/State>
 
 #include <simgear/math/SGLimits.hxx>
 #include <simgear/constants.h>
 #include <simgear/structure/subsystem_mgr.hxx>
+#include <simgear/props/props.hxx>
 
-#include <Airports/runways.hxx>     // FGRunway
-#include <GUI/gui.h>                // fntRenderer ?   guiErrorMessage()
-#include <GUI/new_gui.hxx>          // FGFontCache, FGColor
-#include <Main/fg_props.hxx>
-
-
+class FGFontCache;
+class fntRenderer;
+class fntTexFont;
 class FGViewer;
-
-
-class ClipBox {
-public:
-    ClipBox(const SGPropertyNode *, float xoffset = 0, float yoffset = 0);
-    void set();
-    void unset();
-
-private:
-    bool _active;
-    float _xoffs, _yoffs;
-    SGConstPropertyNode_ptr _top_node;
-    SGConstPropertyNode_ptr _bot_node;
-    SGConstPropertyNode_ptr _left_node;
-    SGConstPropertyNode_ptr _right_node;
-    GLdouble _top[4];
-    GLdouble _bot[4];
-    GLdouble _left[4];
-    GLdouble _right[4];
-};
-
-
+class ClipBox;
 
 class LineSegment {
 public:
@@ -95,14 +63,14 @@ public:
     inline unsigned int size() const { return _list.size(); }
     void draw() {
         glBegin(GL_LINES);
-        vector<LineSegment>::const_iterator it, end = _list.end();
+        std::vector<LineSegment>::const_iterator it, end = _list.end();
         for (it = _list.begin(); it != end; ++it)
             it->draw();
         glEnd();
     }
 
 private:
-    vector<LineSegment> _list;
+  std::vector<LineSegment> _list;
 };
 
 
@@ -137,14 +105,11 @@ public:
 
 private:
     fntRenderer *_font;
-    vector<HUDText> _list;
+    std::vector<HUDText> _list;
 };
 
 
 
-
-
-
 class HUD : public SGSubsystem, public SGPropertyChangeListener {
 public:
     HUD();
@@ -215,8 +180,8 @@ private:
     class Runway;
     class AimingReticle;
 
-    deque<Item *> _items;
-    deque<Item *> _ladders;
+    std::deque<Item *> _items;
+    std::deque<Item *> _ladders;
 
     SGPropertyNode_ptr _currentPath;
     SGPropertyNode_ptr _currentColor;
@@ -253,389 +218,4 @@ private:
     LineList _stipple_line_list;
 };
 
-
-
-class HUD::Input {
-public:
-    Input(const SGPropertyNode *n, float factor = 1.0, float offset = 0.0,
-            float min = -SGLimitsf::max(), float max = SGLimitsf::max()) :
-        _valid(false),
-        _property(0),
-        _damped(SGLimitsf::max())
-    {
-        if (!n)
-            return;
-        _factor = n->getFloatValue("factor", factor);
-        _offset = n->getFloatValue("offset", offset);
-        _min = n->getFloatValue("min", min);
-        _max = n->getFloatValue("max", max);
-        _coeff = 1.0 - 1.0 / powf(10, fabs(n->getFloatValue("damp", 0.0)));
-        SGPropertyNode *p = ((SGPropertyNode *)n)->getNode("property", false);
-        if (p) {
-            const char *path = p->getStringValue();
-            if (path && path[0]) {
-                _property = fgGetNode(path, true);
-                _valid = true;
-            }
-        }
-    }
-
-    bool getBoolValue() const {
-        assert(_property);
-        return _property->getBoolValue();
-    }
-
-    const char *getStringValue() const {
-        assert(_property);
-        return _property->getStringValue();
-    }
-
-    float getFloatValue() {
-        assert(_property);
-        float f = _property->getFloatValue() * _factor + _offset;
-        if (_damped == SGLimitsf::max())
-            _damped = f;
-        if (_coeff > 0.0f)
-            f = _damped = f * (1.0f - _coeff) + _damped * _coeff;
-        return clamp(f);
-    }
-
-    inline float isValid() const { return _valid; }
-    inline float min() const { return _min; }
-    inline float max() const { return _max; }
-    inline float factor() const { return _factor; }
-    float clamp(float v) const { return v < _min ? _min : v > _max ? _max : v; }
-
-    void set_min(float m, bool force = true) {
-        if (force || _min == -SGLimitsf::max())
-            _min = m;
-    }
-    void set_max(float m, bool force = true) {
-        if (force || _max == SGLimitsf::max())
-            _max = m;
-    }
-
-private:
-    bool _valid;
-    SGConstPropertyNode_ptr _property;
-    float _factor;
-    float _offset;
-    float _min;
-    float _max;
-    float _coeff;
-    float _damped;
-};
-
-
-
-class HUD::Item {
-public:
-    Item(HUD *parent, const SGPropertyNode *, float x = 0.0f, float y = 0.0f);
-    virtual ~Item () {}
-    virtual void draw() = 0;
-    virtual bool isEnabled();
-
-protected:
-    enum Format {
-        INVALID,
-        NONE,
-        INT,
-        LONG,
-        FLOAT,
-        DOUBLE,
-        STRING,
-    };
-
-    Format  check_format(const char *) const;
-    inline float get_span()       const { return _scr_span; }
-    inline int   get_digits()     const { return _digits; }
-
-    inline bool option_vert()    const { return (_options & VERTICAL) == VERTICAL; }
-    inline bool option_left()    const { return (_options & LEFT) == LEFT; }
-    inline bool option_right()   const { return (_options & RIGHT) == RIGHT; }
-    inline bool option_both()    const { return (_options & BOTH) == BOTH; }
-    inline bool option_noticks() const { return (_options & NOTICKS) == NOTICKS; }
-    inline bool option_notext()  const { return (_options & NOTEXT) == NOTEXT; }
-    inline bool option_top()     const { return (_options & TOP) == TOP; }
-    inline bool option_bottom()  const { return (_options & BOTTOM) == BOTTOM; }
-
-    void draw_line(float x1, float y1, float x2, float y2);
-    void draw_stipple_line(float x1, float y1, float x2, float y2);
-    void draw_text(float x, float y, const char *msg, int align = 0, int digit = 0);
-    void draw_circle(float x1, float y1, float r) const;
-    void draw_arc(float x1, float y1, float t0, float t1, float r) const;
-    void draw_bullet(float, float, float);
-
-    HUD         *_hud;
-    std::string      _name;
-    int         _options;
-    float       _x, _y, _w, _h;
-    float       _center_x, _center_y;
-
-private:
-    SGSharedPtr<SGCondition> _condition;
-    float       _disp_factor;   // Multiply by to get numbers shown on scale.
-    float       _scr_span;      // Working values for draw;
-    int         _digits;
-};
-
-
-
-class HUD::Label : public Item {
-public:
-    Label(HUD *parent, const SGPropertyNode *, float x, float y);
-    virtual void draw();
-
-private:
-    bool    blink();
-
-    Input   _input;
-    Format  _mode;
-    std::string  _format;
-    int     _halign;    // HUDText alignment
-    int     _blink;
-    bool    _box;
-    float   _text_y;
-    float   _pointer_width;
-    float   _pointer_length;
-
-    SGSharedPtr<SGCondition> _blink_condition;
-    double  _blink_interval;
-    double  _blink_target;  // time for next blink state change
-    bool    _blink_state;
-};
-
-
-
-// abstract base class for both moving scale and moving needle (fixed scale)
-// indicators.
-//
-class HUD::Scale : public Item {
-public:
-    Scale(HUD *parent, const SGPropertyNode *, float x, float y);
-    virtual void draw    ( void ) {}  // No-op here. Defined in derived classes.
-
-protected:
-    inline float factor() const { return _display_factor; }
-    inline float range_to_show() const { return _range_shown; }
-
-    Input _input;
-    float _major_divs;      // major division marker units
-    float _minor_divs;      // minor division marker units
-    unsigned int _modulo;   // Roll over point
-
-private:
-    float _range_shown;     // Width Units.
-    float _display_factor;  // factor => screen units/range values.
-};
-
-
-class HUD::Gauge : public Scale {
-public:
-    Gauge(HUD *parent, const SGPropertyNode *, float x, float y);
-    virtual void draw();
-};
-
-
-
-// displays the indicated quantity on a scale that moves past the
-// pointer. It may be horizontal or vertical.
-//
-class HUD::Tape : public Scale {
-public:
-    Tape(HUD *parent, const SGPropertyNode *, float x, float y);
-    virtual void draw();
-
-protected:
-    void draw_vertical(float);
-    void draw_horizontal(float);
-    void draw_fixed_pointer(float, float, float, float, float, float);
-    char *format_value(float);
-
-private:
-    float  _val_span;
-    float  _half_width_units;
-    bool   _draw_tick_bottom;
-    bool   _draw_tick_top;
-    bool   _draw_tick_right;
-    bool   _draw_tick_left;
-    bool   _draw_cap_bottom;
-    bool   _draw_cap_top;
-    bool   _draw_cap_right;
-    bool   _draw_cap_left;
-    float  _marker_offset;
-    float  _label_offset;
-    float  _label_gap;
-    bool   _pointer;
-    Format _label_fmt;
-    std::string _format;
-    int    _div_ratio;          // _major_divs/_minor_divs
-    bool   _odd_type;           // whether to put numbers at 0/2/4 or 1/3/5
-
-    enum { BUFSIZE = 64 };
-    char   _buf[BUFSIZE];
-
-    enum PointerType { FIXED, MOVING } _pointer_type;
-    enum TickType { LINE, CIRCLE } _tick_type;
-    enum TickLength { VARIABLE, CONSTANT } _tick_length;
-};
-
-
-
-class HUD::Dial : public Scale {
-public:
-    Dial(HUD *parent, const SGPropertyNode *, float x, float y);
-    virtual void draw();
-
-private:
-    float  _radius;
-    int    _divisions;
-};
-
-
-
-class HUD::TurnBankIndicator : public Item {
-public:
-    TurnBankIndicator(HUD *parent, const SGPropertyNode *, float x, float y);
-    virtual void draw();
-
-private:
-    void draw_scale();
-    void draw_tee();
-    void draw_line(float, float, float, float);
-    void draw_tick(float angle, float r1, float r2, int side);
-
-    Input _bank;
-    Input _sideslip;
-
-    float _gap_width;
-    bool  _bank_scale;
-};
-
-
-
-class HUD::Ladder : public Item {
-public:
-    Ladder(HUD *parent, const SGPropertyNode *, float x, float y);
-    ~Ladder();
-    virtual void draw();
-
-private:
-    void draw_zenith(float, float);
-    void draw_nadir(float, float);
-
-    void draw_text(float x, float y, const char *s, int align = 0) {
-        _locTextList.add(x, y, s, align, 0);
-    }
-
-    void draw_line(float x1, float y1, float x2, float y2, bool stipple = false) {
-        if (stipple)
-            _locStippleLineList.add(LineSegment(x1, y1, x2, y2));
-        else
-            _locLineList.add(LineSegment(x1, y1, x2, y2));
-    }
-
-    enum   Type { PITCH, CLIMB_DIVE } _type;
-    Input  _pitch;
-    Input  _roll;
-    float  _width_units;
-    int    _div_units;
-    float  _scr_hole;
-    float  _zero_bar_overlength;
-    bool   _dive_bar_angle;
-    float  _tick_length;
-    float  _vmax;
-    float  _vmin;
-    float  _compression;
-    bool   _dynamic_origin;
-    bool   _frl;               // fuselage reference line
-    bool   _target_spot;
-    bool   _target_markers;
-    bool   _velocity_vector;
-    bool   _drift_marker;
-    bool   _alpha_bracket;
-    bool   _energy_marker;
-    bool   _climb_dive_marker;
-    bool   _glide_slope_marker;
-    float  _glide_slope;
-    bool   _energy_worm;
-    bool   _waypoint_marker;
-    bool   _zenith;
-    bool   _nadir;
-    bool   _hat;
-
-    ClipBox *_clip_box;
-    // The Ladder has its own temporary display lists
-    TextList _locTextList;
-    LineList _locLineList;
-    LineList _locStippleLineList;
-};
-
-
-
-// responsible for rendering the active runway in the hud (if visible).
-//
-class HUD::Runway : public Item {
-public:
-    Runway(HUD *parent, const SGPropertyNode *, float x, float y);
-    virtual void draw();
-
-private:
-    void boundPoint(const sgdVec3& v, sgdVec3& m);
-    bool boundOutsidePoints(sgdVec3& v, sgdVec3& m);
-    bool drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& p1, const sgdVec3& p2);
-    void drawArrow();
-    FGRunway* get_active_runway();
-    void get_rwy_points(sgdVec3 *points);
-    void setLineWidth();
-
-    SGPropertyNode_ptr _agl;
-    sgdVec3 _points3d[6], _points2d[6];
-    double _mm[16];
-    double _pm[16];
-    double _arrow_scale;  // scales of runway indication arrow
-    double _arrow_radius;
-    double _line_scale;   // maximum line scale
-    double _scale_dist;   // distance where to start scaling the lines
-    double _default_pitch;
-    double _default_heading;
-    GLint  _view[4];
-    FGRunway* _runway;
-    unsigned short _stipple_out;    // stipple pattern of the outline of the runway
-    unsigned short _stipple_center; // stipple pattern of the center line of the runway
-    bool   _draw_arrow;             // draw arrow when runway is not visible in HUD
-    bool   _draw_arrow_always;      // always draws arrow
-    float  _left, _right, _top, _bottom;
-};
-
-
-class HUD::AimingReticle : public Item {
-public:
-    AimingReticle(HUD *parent, const SGPropertyNode *, float x, float y);
-    virtual void draw();
-
-private:
-    SGSharedPtr<SGCondition> _active_condition;  // stadiametric (true) or standby (false)
-    SGSharedPtr<SGCondition> _tachy_condition;  // tachymetric (true) or standby (false)
-    SGSharedPtr<SGCondition> _align_condition;  // tachymetric (true) or standby (false)
-
-    Input   _diameter;               // inner/outer radius relation
-    Input  _pitch;
-    Input  _yaw;
-    Input  _speed;
-    Input  _range;
-    Input  _t0;
-    Input  _t1;
-    Input  _offset_x;
-    Input  _offset_y;
-
-    float   _bullet_size;
-    float   _inner_radius;
-    float   _compression;
-    float  _limit_x;
-    float  _limit_y;
-
-};
-
-
 #endif // _HUD_HXX
index d641dca9b5a4243d94117a998d6a49821c44e733..8fba91ab865ffa5c9da14bb0977528bd3be3bfd5 100644 (file)
@@ -20,7 +20,7 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include "HUD.hxx"
-
+#include "HUD_private.hxx"
 
 HUD::Dial::Dial(HUD *hud, const SGPropertyNode *n, float x, float y) :
     Scale(hud, n, x, y),
index e60bca0e4469653469b75f1cd1d2f9be3951d3ea..b1fe5362f0ef86d99de28193721294b6c820e49e 100644 (file)
@@ -20,7 +20,7 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include "HUD.hxx"
-
+#include "HUD_private.hxx"
 
 HUD::Gauge::Gauge(HUD *hud, const SGPropertyNode *n, float x, float y) :
     Scale(hud, n, x, y)
index 630837581e7771a37fabac9a414cdb53f45157d4..69fb3309cbf817b97ddd8b8e5d6a3a33f65fe994 100644 (file)
 #endif
 
 #include <simgear/math/SGLimits.hxx>
+#include <simgear/props/condition.hxx>
+
 #include "HUD.hxx"
+#include "HUD_private.hxx"
+
+#include <Main/globals.hxx>
 
+using std::vector;
 
 HUD::Item::Item(HUD *hud, const SGPropertyNode *n, float x, float y) :
     _hud(hud),
index 030e246b00933b3ffb95890ebcf5fee6c9be4eee..5414cf02fdd05a307858087ecd187c8cda7a246d 100644 (file)
@@ -24,7 +24,9 @@
 #endif
 
 #include "HUD.hxx"
+#include "HUD_private.hxx"
 
+#include <Main/globals.hxx>
 
 HUD::Label::Label(HUD *hud, const SGPropertyNode *n, float x, float y) :
     Item(hud, n, x, y),
index 0b7784a27f91642728e1ce1b7f20066d7860db84..5cf33fec48b8342a20d2b9bbcb0e45480fc101ec 100644 (file)
 #include <sstream>
 #include <simgear/math/SGGeometry.hxx>
 #include <Viewer/viewer.hxx>
+
 #include "HUD.hxx"
+#include "HUD_private.hxx"
+
+#include <Main/fg_props.hxx>
 
 using std::string;
 
index 891101713ca65553614c79c6818f83b701a24e32..17e33b4892359a721b0bdfaf7fe416347c1ece2f 100644 (file)
@@ -23,6 +23,9 @@
 #endif
 
 #include "HUD.hxx"
+#include "HUD_private.hxx"
+
+#include <Main/globals.hxx>
 
 // MIL-STD-1787B aiming reticle
 
diff --git a/src/Instrumentation/HUD/HUD_private.hxx b/src/Instrumentation/HUD/HUD_private.hxx
new file mode 100644 (file)
index 0000000..ee787b6
--- /dev/null
@@ -0,0 +1,429 @@
+// HUD_private.hxx -- Intenral delcerations for the HUD
+//
+// Written by Michele America, started September 1997.
+//
+// Copyright (C) 1997  Michele F. America  [micheleamerica#geocities:com]
+// Copyright (C) 2006  Melchior FRANZ  [mfranz#aon:at]
+//
+// 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.
+
+#ifndef _HUD_PRIVATE_HXX
+#define _HUD_PRIVATE_HXX
+
+#include <simgear/compiler.h>
+#include <simgear/props/condition.hxx>
+
+#include <vector>
+#include <deque>
+#include <cassert>
+
+#include <osg/State>
+
+#include <simgear/math/SGLimits.hxx>
+#include <simgear/constants.h>
+#include <simgear/props/props.hxx>
+
+#include <plib/sg.h> // for lingering sgdVec3 usage below
+
+class FGFontCache;
+class fntRenderer;
+class fntTexFont;
+class FGViewer;
+class FGRunway;
+
+class ClipBox {
+public:
+  ClipBox(const SGPropertyNode *, float xoffset = 0, float yoffset = 0);
+  void set();
+  void unset();
+  
+private:
+  bool _active;
+  float _xoffs, _yoffs;
+  SGConstPropertyNode_ptr _top_node;
+  SGConstPropertyNode_ptr _bot_node;
+  SGConstPropertyNode_ptr _left_node;
+  SGConstPropertyNode_ptr _right_node;
+  GLdouble _top[4];
+  GLdouble _bot[4];
+  GLdouble _left[4];
+  GLdouble _right[4];
+};
+
+
+class HUD::Input {
+public:
+    Input(const SGPropertyNode *n, float factor = 1.0, float offset = 0.0,
+          float min = -SGLimitsf::max(), float max = SGLimitsf::max());
+  
+    bool getBoolValue() const {
+        assert(_property);
+        return _property->getBoolValue();
+    }
+
+    const char *getStringValue() const {
+        assert(_property);
+        return _property->getStringValue();
+    }
+
+    float getFloatValue() {
+        assert(_property);
+        float f = _property->getFloatValue() * _factor + _offset;
+        if (_damped == SGLimitsf::max())
+            _damped = f;
+        if (_coeff > 0.0f)
+            f = _damped = f * (1.0f - _coeff) + _damped * _coeff;
+        return clamp(f);
+    }
+
+    inline float isValid() const { return _valid; }
+    inline float min() const { return _min; }
+    inline float max() const { return _max; }
+    inline float factor() const { return _factor; }
+    float clamp(float v) const { return v < _min ? _min : v > _max ? _max : v; }
+
+    void set_min(float m, bool force = true) {
+        if (force || _min == -SGLimitsf::max())
+            _min = m;
+    }
+    void set_max(float m, bool force = true) {
+        if (force || _max == SGLimitsf::max())
+            _max = m;
+    }
+
+private:
+    bool _valid;
+    SGConstPropertyNode_ptr _property;
+    float _factor;
+    float _offset;
+    float _min;
+    float _max;
+    float _coeff;
+    float _damped;
+};
+
+
+
+class HUD::Item {
+public:
+    Item(HUD *parent, const SGPropertyNode *, float x = 0.0f, float y = 0.0f);
+    virtual ~Item () {}
+    virtual void draw() = 0;
+    virtual bool isEnabled();
+
+protected:
+    enum Format {
+        INVALID,
+        NONE,
+        INT,
+        LONG,
+        FLOAT,
+        DOUBLE,
+        STRING,
+    };
+
+    Format  check_format(const char *) const;
+    inline float get_span()       const { return _scr_span; }
+    inline int   get_digits()     const { return _digits; }
+
+    inline bool option_vert()    const { return (_options & VERTICAL) == VERTICAL; }
+    inline bool option_left()    const { return (_options & LEFT) == LEFT; }
+    inline bool option_right()   const { return (_options & RIGHT) == RIGHT; }
+    inline bool option_both()    const { return (_options & BOTH) == BOTH; }
+    inline bool option_noticks() const { return (_options & NOTICKS) == NOTICKS; }
+    inline bool option_notext()  const { return (_options & NOTEXT) == NOTEXT; }
+    inline bool option_top()     const { return (_options & TOP) == TOP; }
+    inline bool option_bottom()  const { return (_options & BOTTOM) == BOTTOM; }
+
+    void draw_line(float x1, float y1, float x2, float y2);
+    void draw_stipple_line(float x1, float y1, float x2, float y2);
+    void draw_text(float x, float y, const char *msg, int align = 0, int digit = 0);
+    void draw_circle(float x1, float y1, float r) const;
+    void draw_arc(float x1, float y1, float t0, float t1, float r) const;
+    void draw_bullet(float, float, float);
+
+    HUD         *_hud;
+    std::string      _name;
+    int         _options;
+    float       _x, _y, _w, _h;
+    float       _center_x, _center_y;
+
+private:
+    SGSharedPtr<SGCondition> _condition;
+    float       _disp_factor;   // Multiply by to get numbers shown on scale.
+    float       _scr_span;      // Working values for draw;
+    int         _digits;
+};
+
+
+
+class HUD::Label : public Item {
+public:
+    Label(HUD *parent, const SGPropertyNode *, float x, float y);
+    virtual void draw();
+
+private:
+    bool    blink();
+
+    Input   _input;
+    Format  _mode;
+    std::string  _format;
+    int     _halign;    // HUDText alignment
+    int     _blink;
+    bool    _box;
+    float   _text_y;
+    float   _pointer_width;
+    float   _pointer_length;
+
+    SGSharedPtr<SGCondition> _blink_condition;
+    double  _blink_interval;
+    double  _blink_target;  // time for next blink state change
+    bool    _blink_state;
+};
+
+
+
+// abstract base class for both moving scale and moving needle (fixed scale)
+// indicators.
+//
+class HUD::Scale : public Item {
+public:
+    Scale(HUD *parent, const SGPropertyNode *, float x, float y);
+    virtual void draw    ( void ) {}  // No-op here. Defined in derived classes.
+
+protected:
+    inline float factor() const { return _display_factor; }
+    inline float range_to_show() const { return _range_shown; }
+
+    Input _input;
+    float _major_divs;      // major division marker units
+    float _minor_divs;      // minor division marker units
+    unsigned int _modulo;   // Roll over point
+
+private:
+    float _range_shown;     // Width Units.
+    float _display_factor;  // factor => screen units/range values.
+};
+
+
+class HUD::Gauge : public Scale {
+public:
+    Gauge(HUD *parent, const SGPropertyNode *, float x, float y);
+    virtual void draw();
+};
+
+
+
+// displays the indicated quantity on a scale that moves past the
+// pointer. It may be horizontal or vertical.
+//
+class HUD::Tape : public Scale {
+public:
+    Tape(HUD *parent, const SGPropertyNode *, float x, float y);
+    virtual void draw();
+
+protected:
+    void draw_vertical(float);
+    void draw_horizontal(float);
+    void draw_fixed_pointer(float, float, float, float, float, float);
+    char *format_value(float);
+
+private:
+    float  _val_span;
+    float  _half_width_units;
+    bool   _draw_tick_bottom;
+    bool   _draw_tick_top;
+    bool   _draw_tick_right;
+    bool   _draw_tick_left;
+    bool   _draw_cap_bottom;
+    bool   _draw_cap_top;
+    bool   _draw_cap_right;
+    bool   _draw_cap_left;
+    float  _marker_offset;
+    float  _label_offset;
+    float  _label_gap;
+    bool   _pointer;
+    Format _label_fmt;
+    std::string _format;
+    int    _div_ratio;          // _major_divs/_minor_divs
+    bool   _odd_type;           // whether to put numbers at 0/2/4 or 1/3/5
+
+    enum { BUFSIZE = 64 };
+    char   _buf[BUFSIZE];
+
+    enum PointerType { FIXED, MOVING } _pointer_type;
+    enum TickType { LINE, CIRCLE } _tick_type;
+    enum TickLength { VARIABLE, CONSTANT } _tick_length;
+};
+
+
+
+class HUD::Dial : public Scale {
+public:
+    Dial(HUD *parent, const SGPropertyNode *, float x, float y);
+    virtual void draw();
+
+private:
+    float  _radius;
+    int    _divisions;
+};
+
+
+
+class HUD::TurnBankIndicator : public Item {
+public:
+    TurnBankIndicator(HUD *parent, const SGPropertyNode *, float x, float y);
+    virtual void draw();
+
+private:
+    void draw_scale();
+    void draw_tee();
+    void draw_line(float, float, float, float);
+    void draw_tick(float angle, float r1, float r2, int side);
+
+    Input _bank;
+    Input _sideslip;
+
+    float _gap_width;
+    bool  _bank_scale;
+};
+
+
+
+class HUD::Ladder : public Item {
+public:
+    Ladder(HUD *parent, const SGPropertyNode *, float x, float y);
+    ~Ladder();
+    virtual void draw();
+
+private:
+    void draw_zenith(float, float);
+    void draw_nadir(float, float);
+
+    void draw_text(float x, float y, const char *s, int align = 0) {
+        _locTextList.add(x, y, s, align, 0);
+    }
+
+    void draw_line(float x1, float y1, float x2, float y2, bool stipple = false) {
+        if (stipple)
+            _locStippleLineList.add(LineSegment(x1, y1, x2, y2));
+        else
+            _locLineList.add(LineSegment(x1, y1, x2, y2));
+    }
+
+    enum   Type { PITCH, CLIMB_DIVE } _type;
+    Input  _pitch;
+    Input  _roll;
+    float  _width_units;
+    int    _div_units;
+    float  _scr_hole;
+    float  _zero_bar_overlength;
+    bool   _dive_bar_angle;
+    float  _tick_length;
+    float  _vmax;
+    float  _vmin;
+    float  _compression;
+    bool   _dynamic_origin;
+    bool   _frl;               // fuselage reference line
+    bool   _target_spot;
+    bool   _target_markers;
+    bool   _velocity_vector;
+    bool   _drift_marker;
+    bool   _alpha_bracket;
+    bool   _energy_marker;
+    bool   _climb_dive_marker;
+    bool   _glide_slope_marker;
+    float  _glide_slope;
+    bool   _energy_worm;
+    bool   _waypoint_marker;
+    bool   _zenith;
+    bool   _nadir;
+    bool   _hat;
+
+    ClipBox *_clip_box;
+    // The Ladder has its own temporary display lists
+    TextList _locTextList;
+    LineList _locLineList;
+    LineList _locStippleLineList;
+};
+
+
+
+// responsible for rendering the active runway in the hud (if visible).
+//
+class HUD::Runway : public Item {
+public:
+    Runway(HUD *parent, const SGPropertyNode *, float x, float y);
+    virtual void draw();
+
+private:
+    void boundPoint(const sgdVec3& v, sgdVec3& m);
+    bool boundOutsidePoints(sgdVec3& v, sgdVec3& m);
+    bool drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& p1, const sgdVec3& p2);
+    void drawArrow();
+    FGRunway* get_active_runway();
+    void get_rwy_points(sgdVec3 *points);
+    void setLineWidth();
+
+    SGPropertyNode_ptr _agl;
+    sgdVec3 _points3d[6], _points2d[6];
+    double _mm[16];
+    double _pm[16];
+    double _arrow_scale;  // scales of runway indication arrow
+    double _arrow_radius;
+    double _line_scale;   // maximum line scale
+    double _scale_dist;   // distance where to start scaling the lines
+    double _default_pitch;
+    double _default_heading;
+    GLint  _view[4];
+    FGRunway* _runway;
+    unsigned short _stipple_out;    // stipple pattern of the outline of the runway
+    unsigned short _stipple_center; // stipple pattern of the center line of the runway
+    bool   _draw_arrow;             // draw arrow when runway is not visible in HUD
+    bool   _draw_arrow_always;      // always draws arrow
+    float  _left, _right, _top, _bottom;
+};
+
+
+class HUD::AimingReticle : public Item {
+public:
+    AimingReticle(HUD *parent, const SGPropertyNode *, float x, float y);
+    virtual void draw();
+
+private:
+    SGSharedPtr<SGCondition> _active_condition;  // stadiametric (true) or standby (false)
+    SGSharedPtr<SGCondition> _tachy_condition;  // tachymetric (true) or standby (false)
+    SGSharedPtr<SGCondition> _align_condition;  // tachymetric (true) or standby (false)
+
+    Input   _diameter;               // inner/outer radius relation
+    Input  _pitch;
+    Input  _yaw;
+    Input  _speed;
+    Input  _range;
+    Input  _t0;
+    Input  _t1;
+    Input  _offset_x;
+    Input  _offset_y;
+
+    float   _bullet_size;
+    float   _inner_radius;
+    float   _compression;
+    float  _limit_x;
+    float  _limit_y;
+
+};
+
+
+#endif // _HUD_HXX
index f44a6d3a588e8eaaef82da263cade86f73f2401a..5ad4592a1d6141bf6ba53d9e2dd95ad92423ea6a 100644 (file)
@@ -28,6 +28,7 @@
 #include <simgear/scene/util/project.hxx>
 
 #include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 #include <Scenery/scenery.hxx>
 #include <Aircraft/controls.hxx>
 #include <FDM/flight.hxx>
@@ -38,7 +39,7 @@
 #include <ATCDCL/ATCutils.hxx>
 
 #include "HUD.hxx"
-
+#include "HUD_private.hxx"
 
 HUD::Runway::Runway(HUD *hud, const SGPropertyNode *node, float x, float y) :
     Item(hud, node, x, y),
index 0ce10c4b6328ef33828da7282fd460dcd78dc814..44c5427c4e459815276461a11e23e3ec10a68808 100644 (file)
@@ -20,7 +20,7 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include "HUD.hxx"
-
+#include "HUD_private.hxx"
 
 HUD::Scale::Scale( HUD *hud, const SGPropertyNode *n, float x, float y) :
     Item(hud, n, x, y),
index 4897a7e4a29cd8b79d2f642fdd39fe7934006b62..56b5b60713eb35e4e70e32d86e388a085ff91d70 100644 (file)
@@ -20,6 +20,7 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include "HUD.hxx"
+#include "HUD_private.hxx"
 
 static const float TICK_OFFSET = 2.f;
 
index 7ec4c2639163cfca18b65735c1f8b58dd3cdddc0..9e6707ad32142e70452a7c156f257941a9c0b66b 100644 (file)
@@ -20,7 +20,7 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include "HUD.hxx"
-
+#include "HUD_private.hxx"
 
 HUD::TurnBankIndicator::TurnBankIndicator(HUD *hud, const SGPropertyNode *n, float x, float y) :
     Item(hud, n, x, y),
index 8e7de862675c75ad741013342949dd73ffb82bf7..f3a3a486af915e20cfdebd784e26903c0d5a56d0 100644 (file)
@@ -24,6 +24,7 @@
 #include <string>
 #include <sstream>
 
+using std::string;
 
 // Use a bigger number to be more responsive, or a smaller number
 // to be more sluggish.
index 3831e0ca9bbeb2cf2ab2e427b8baf294eea479b2..2ac32fa9d10effff6a818382c77806c225e7e854 100644 (file)
@@ -16,9 +16,7 @@
 #include <simgear/props/props.hxx>
 
 #include <simgear/structure/subsystem_mgr.hxx>
-
-using std::string;
-
+#include <simgear/math/SGMath.hxx>
 
 class SGSampleGroup;
 
@@ -84,7 +82,7 @@ private:
 
     int _last_frequency_khz;
     bool _transmitter_valid;
-    string _last_ident;
+    std::string _last_ident;
     SGGeod _transmitter_pos;
     SGVec3d _transmitter_cart;
     double _transmitter_range_nm;
@@ -92,7 +90,7 @@ private:
     int _ident_count;
     time_t _last_ident_time;
     float _last_volume;
-    string _adf_ident;
+    std::string _adf_ident;
 
     SGSharedPtr<SGSampleGroup> _sgr;
 };
index 1222b492feaf321531048aff6c21cec01a377366..e85a8ffbd28f94c699fe709b53932415b74c1f8e 100644 (file)
@@ -48,10 +48,10 @@ private:
 
     std::string _name;
     unsigned int _num;
-    string _total_pressure;
-    string _static_pressure;
+    std::string _total_pressure;
+    std::string _static_pressure;
     bool _has_overspeed;
-    string _pressure_alt_source;
+    std::string _pressure_alt_source;
     double _ias_limit;
     double _mach_limit;
     double _alt_threshold;
index 376e1ce9ca767f960501c2b083312c62ffa4667e..96bbdd5ae9e0ccbe190f7c34b13751755bd0a7d6 100644 (file)
@@ -10,6 +10,9 @@
 #include <simgear/props/props.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
 
+// forward decls
+class FGNavRecord;
+
 /**
  * Model a DME radio.
  *
index e1ca12775f9727a0efd4b9f13e9df1af8d873bf2..86b09e13e9351d391fd6c99e705c62e681f96c97 100644 (file)
@@ -19,7 +19,6 @@
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
 #include <Main/util.hxx>
-#include <Instrumentation/HUD/HUD.hxx>
 
 #include "instrument_mgr.hxx"
 #include "adf.hxx"
@@ -56,7 +55,6 @@
 FGInstrumentMgr::FGInstrumentMgr () :
   _explicitGps(false)
 {    
-    globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY);
 }
 
 FGInstrumentMgr::~FGInstrumentMgr ()
index ad8701e2732eee4a2db3d6b2803a78bcbdb0b247..3c3955c92529e525718c9f4861c7c160400f0c0e 100644 (file)
@@ -98,6 +98,7 @@
 #include <Viewer/renderer.hxx>
 #include <Viewer/viewmgr.hxx>
 #include <Navaids/NavDataCache.hxx>
+#include <Instrumentation/HUD/HUD.hxx>
 
 #include "fg_init.hxx"
 #include "fg_io.hxx"
@@ -600,7 +601,8 @@ void fgCreateSubsystems() {
 
     globals->add_subsystem("systems", new FGSystemMgr, SGSubsystemMgr::FDM);
     globals->add_subsystem("instrumentation", new FGInstrumentMgr, SGSubsystemMgr::FDM);
-
+    globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY);
+  
     ////////////////////////////////////////////////////////////////////
     // Initialize the XML Autopilot subsystem.
     ////////////////////////////////////////////////////////////////////
index fea0d42c8c7b38a6da362cf0e3aa19984e044091..62c1cbd55a4a21171ba9eeafdaea7a641bf44a84 100644 (file)
 #include "CameraGroup.hxx"
 #include "FGEventHandler.hxx"
 
+#include <plib/pu.h>
+
 using namespace osg;
 using namespace simgear;
 using namespace flightgear;