1 // HUD_misc.cxx -- HUD miscellaneous elements
3 // Written by Melchior FRANZ, started September 2006.
5 // Copyright (C) 2006 Melchior FRANZ [mfranz#aon:at]
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.
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.
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.
25 #include <simgear/props/condition.hxx>
29 // MIL-STD-1787B aiming reticle
31 HUD::AimingReticle::AimingReticle(HUD *hud, const SGPropertyNode *n, float x, float y) :
34 _diameter(n->getNode("diameter-input", false)),
35 _bullet_size(_w / 6.0),
36 _inner_radius(_w / 2.0)
38 const SGPropertyNode *node = n->getNode("active-condition");
40 _active_condition = sgReadCondition(globals->get_props(), node);
44 void HUD::AimingReticle::draw(void)
46 bool active = _active_condition ? _active_condition->test() : true;
47 float diameter = _diameter.isValid() ? _diameter.getFloatValue() : 2.0f; // outer circle
52 if (active) { // stadiametric (4.2.4.4)
53 draw_bullet(x, y, _bullet_size);
54 draw_circle(x, y, _inner_radius);
55 draw_circle(x, y, diameter * _inner_radius);
57 } else { // standby (4.2.4.5)