- export font properties to the property tree again
- don't keep oodles of class member variables public (eek!) - use ::hasValue() instead of ::getType() != SGPropertyNode::NONE - consistency fixes and cosmetics
This commit is contained in:
parent
4b245467c7
commit
47b9da740b
2 changed files with 78 additions and 71 deletions
|
@ -75,16 +75,17 @@ typedef radar_list_type::const_iterator radar_list_const_iterator;
|
|||
static const float UNIT = 1.0f / 8.0f; // 8 symbols in a row/column in the texture
|
||||
static const char *DEFAULT_FONT = "typewriter.txf";
|
||||
|
||||
|
||||
wxRadarBg::wxRadarBg(SGPropertyNode *node) :
|
||||
_name(node->getStringValue("name", "radar")),
|
||||
_num(node->getIntValue("number", 0)),
|
||||
_interval(node->getDoubleValue("update-interval-sec", 1.0)),
|
||||
_time(0.0),
|
||||
_last_switchKnob("off"),
|
||||
_sim_init_done(false),
|
||||
_odg(0),
|
||||
_last_switchKnob("off"),
|
||||
_resultTexture(0),
|
||||
_wxEcho(0),
|
||||
_odg(0)
|
||||
_wxEcho(0)
|
||||
{
|
||||
string branch;
|
||||
branch = "/instrumentation/" + _name;
|
||||
|
@ -95,6 +96,16 @@ wxRadarBg::wxRadarBg(SGPropertyNode *node) :
|
|||
|
||||
_font_node = _Instrument->getNode("font", true);
|
||||
_font_node->addChangeListener(this, true);
|
||||
|
||||
#define INITFONT(p, val, type) if (!_font_node->hasValue(p)) _font_node->set##type##Value(p, val)
|
||||
INITFONT("name", DEFAULT_FONT, String);
|
||||
INITFONT("size", 8, Float);
|
||||
INITFONT("line-spacing", 0.25, Float);
|
||||
INITFONT("color/red", 0, Float);
|
||||
INITFONT("color/green", 0.8, Float);
|
||||
INITFONT("color/blue", 0, Float);
|
||||
INITFONT("color/alpha", 1, Float);
|
||||
#undef INITFONT
|
||||
}
|
||||
|
||||
|
||||
|
@ -171,11 +182,11 @@ wxRadarBg::init ()
|
|||
_radar_rotate_node = n->getNode("rotate", true);
|
||||
|
||||
_radar_centre_node->setBoolValue(false);
|
||||
if (_radar_coverage_node->getType() == SGPropertyNode::NONE)
|
||||
if (!_radar_coverage_node->hasValue())
|
||||
_radar_coverage_node->setFloatValue(120);
|
||||
if (_radar_ref_rng_node->getType() == SGPropertyNode::NONE)
|
||||
if (!_radar_ref_rng_node->hasValue())
|
||||
_radar_ref_rng_node->setDoubleValue(35);
|
||||
if (_radar_hdg_marker_node->getType() == SGPropertyNode::NONE)
|
||||
if (!_radar_hdg_marker_node->hasValue())
|
||||
_radar_hdg_marker_node->setBoolValue(true);
|
||||
|
||||
_x_offset = 0;
|
||||
|
@ -427,8 +438,7 @@ wxRadarBg::update (double delta_time_sec)
|
|||
for (int i = 0; i < 3 * 4; i++)
|
||||
_texCoords->push_back(whiteSpot);
|
||||
|
||||
trimaskPSet->set(osg::PrimitiveSet::TRIANGLES, firstQuadVert + 4,
|
||||
3 * 4);
|
||||
trimaskPSet->set(osg::PrimitiveSet::TRIANGLES, firstQuadVert + 4, 3 * 4);
|
||||
|
||||
} else {
|
||||
maskPSet->set(osg::PrimitiveSet::QUADS, 0, 0);
|
||||
|
@ -858,14 +868,14 @@ wxRadarBg::calcRelBearing(float bearing, float heading)
|
|||
void
|
||||
wxRadarBg::updateFont()
|
||||
{
|
||||
float red = _font_node->getFloatValue("color/red", 0);
|
||||
float green = _font_node->getFloatValue("color/green", 0.8);
|
||||
float blue = _font_node->getFloatValue("color/blue", 0);
|
||||
float alpha = _font_node->getFloatValue("color/alpha", 1);
|
||||
float red = _font_node->getFloatValue("color/red");
|
||||
float green = _font_node->getFloatValue("color/green");
|
||||
float blue = _font_node->getFloatValue("color/blue");
|
||||
float alpha = _font_node->getFloatValue("color/alpha");
|
||||
_font_color.set(red, green, blue, alpha);
|
||||
|
||||
_font_size = _font_node->getFloatValue("size", 8);
|
||||
_font_spacing = _font_size * _font_node->getFloatValue("line-spacing", 1.5);
|
||||
_font_size = _font_node->getFloatValue("size");
|
||||
_font_spacing = _font_size * _font_node->getFloatValue("line-spacing");
|
||||
string path = _font_node->getStringValue("name", DEFAULT_FONT);
|
||||
|
||||
SGPath tpath;
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
// 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 _INST_WXRADAR_HXX
|
||||
#define _INST_WXRADAR_HXX
|
||||
|
@ -42,7 +40,6 @@ SG_USING_STD(vector);
|
|||
SG_USING_STD(string);
|
||||
|
||||
class FGAIBase;
|
||||
|
||||
class FGODGauge;
|
||||
|
||||
class wxRadarBg : public SGSubsystem, public SGPropertyChangeListener {
|
||||
|
@ -56,11 +53,12 @@ public:
|
|||
virtual void update(double dt);
|
||||
virtual void valueChanged(SGPropertyNode *);
|
||||
|
||||
protected:
|
||||
string _name;
|
||||
int _num;
|
||||
double _interval;
|
||||
double _time;
|
||||
bool _sim_init_done;
|
||||
string _name;
|
||||
int _num;
|
||||
|
||||
SGPropertyNode_ptr _serviceable_node;
|
||||
SGPropertyNode_ptr _Instrument;
|
||||
|
@ -160,7 +158,7 @@ template<> inline
|
|||
SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, bool value)
|
||||
{
|
||||
SGPropertyNode *result = _Instrument->getNode(name, true);
|
||||
if (result->getType() == SGPropertyNode::NONE)
|
||||
if (!result->hasValue())
|
||||
result->setBoolValue(value);
|
||||
return result;
|
||||
}
|
||||
|
@ -170,18 +168,17 @@ template<> inline
|
|||
SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, double value)
|
||||
{
|
||||
SGPropertyNode *result = _Instrument->getNode(name, true);
|
||||
if (result->getType() == SGPropertyNode::NONE)
|
||||
if (!result->hasValue())
|
||||
result->setDoubleValue(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template<> inline
|
||||
SGPropertyNode* wxRadarBg::getInstrumentNode(const char* name,
|
||||
const char* value)
|
||||
SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, const char *value)
|
||||
{
|
||||
SGPropertyNode *result = _Instrument->getNode(name, true);
|
||||
if (result->getType() == SGPropertyNode::NONE)
|
||||
if (result->hasValue())
|
||||
result->setStringValue(value);
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue