]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/HUD/HUD_misc.cxx
MSVC9 fix
[flightgear.git] / src / Instrumentation / HUD / HUD_misc.cxx
1 // HUD_misc.cxx -- HUD miscellaneous elements
2 //
3 // Written by Melchior FRANZ, started September 2006.
4 //
5 // Copyright (C) 2006  Melchior FRANZ  [mfranz#aon:at]
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21 #ifdef HAVE_CONFIG_H
22 #  include <config.h>
23 #endif
24
25 #include "HUD.hxx"
26
27
28 // MIL-STD-1787B aiming reticle
29
30 HUD::AimingReticle::AimingReticle(HUD *hud, const SGPropertyNode *n, float x, float y) :
31     Item(hud, n, x, y),
32     _active_condition(0),
33     _diameter(n->getNode("diameter-input", false)),
34     _bullet_size(_w / 6.0),
35     _inner_radius(_w / 2.0)
36 {
37     const SGPropertyNode *node = n->getNode("active-condition");
38     if (node)
39        _active_condition = sgReadCondition(globals->get_props(), node);
40 }
41
42
43 void HUD::AimingReticle::draw(void)
44 {
45     bool active = _active_condition ? _active_condition->test() : true;
46     float diameter = _diameter.isValid() ? _diameter.getFloatValue() : 2.0f; // outer circle
47
48     float x = _center_x;
49     float y = _center_y;
50
51     if (active) { // stadiametric (4.2.4.4)
52         draw_bullet(x, y, _bullet_size);
53         draw_circle(x, y, _inner_radius);
54         draw_circle(x, y, diameter * _inner_radius);
55
56     } else { // standby (4.2.4.5)
57         // TODO
58     }
59 }
60
61