]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/HUD/HUD_misc.cxx
add MIL-STD-1787B Aiming Reticle (stadiametric; TODO: standby)
[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 #include <simgear/props/condition.hxx>
22 #include "HUD.hxx"
23
24
25 // MIL-STD-1787B aiming reticle
26
27 HUD::AimingReticle::AimingReticle(HUD *hud, const SGPropertyNode *n, float x, float y) :
28     Item(hud, n, x, y),
29     _active_condition(0),
30     _diameter(n->getNode("diameter-input", false)),
31     _bullet_size(_w / 3.0),
32     _inner_radius(_w)
33 {
34     const SGPropertyNode *node = n->getNode("active-condition");
35     if (node)
36        _active_condition = sgReadCondition(globals->get_props(), node);
37 }
38
39
40 void HUD::AimingReticle::draw(void)
41 {
42     bool active = _active_condition ? _active_condition->test() : true;
43     float diameter = _diameter.isValid() ? _diameter.getFloatValue() : 2.0f; // outer circle
44
45     Point centroid = get_centroid();
46     float x = centroid.x;
47     float y = centroid.y;
48
49     if (active) { // stadiametric (4.2.4.4)
50         draw_bullet(x, y, _bullet_size);
51         draw_circle(x, y, _inner_radius);
52         draw_circle(x, y, diameter * _inner_radius);
53
54     } else { // standby (4.2.4.5)
55         // TODO
56     }
57 }
58
59