diff --git a/docs-mini/README.effects b/docs-mini/README.effects
index c46d392c2..0e2814e7c 100644
--- a/docs-mini/README.effects
+++ b/docs-mini/README.effects
@@ -192,6 +192,15 @@ texture-unit - has several child properties:
wrap-s
wrap-t
wrap-r
+ mipmap-control - controls how the mipmap levels are computed.
+ Each color channel can be computed with different functions
+ among average, sum, product, min and max. For example :
+ average
+ min
+ function-r - function for red
+ function-g - function for green
+ function-b - function for blue
+ function-a - function for alpha
The following built-in types are supported:
white - 1 pixel white texture
noise - a 3d noise texture
diff --git a/projects/VC90/FlightGear/FlightGear.vcproj b/projects/VC90/FlightGear/FlightGear.vcproj
index e97cba54f..902954b00 100644
--- a/projects/VC90/FlightGear/FlightGear.vcproj
+++ b/projects/VC90/FlightGear/FlightGear.vcproj
@@ -1923,90 +1923,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -2055,14 +1971,6 @@
RelativePath="..\..\..\src\FDM\JSBSim\FGJSBBase.h"
>
-
-
-
-
diff --git a/src/AIModel/submodel.cxx b/src/AIModel/submodel.cxx
index 29b658603..a25212198 100644
--- a/src/AIModel/submodel.cxx
+++ b/src/AIModel/submodel.cxx
@@ -43,6 +43,11 @@ FGSubmodelMgr::~FGSubmodelMgr()
{
}
+FGAIManager* FGSubmodelMgr::aiManager()
+{
+ return (FGAIManager*)globals->get_subsystem("ai_model");
+}
+
void FGSubmodelMgr::init()
{
index = 0;
@@ -74,8 +79,6 @@ void FGSubmodelMgr::init()
_contrail_trigger = fgGetNode("ai/submodels/contrails", true);
_contrail_trigger->setBoolValue(false);
- ai = (FGAIManager*)globals->get_subsystem("ai_model");
-
load();
}
@@ -116,9 +119,9 @@ void FGSubmodelMgr::update(double dt)
_expiry = false;
// check if the submodel hit an object or terrain
- sm_list = ai->get_ai_list();
- sm_list_iterator sm_list_itr = sm_list.begin();
- sm_list_iterator end = sm_list.end();
+ FGAIManager::ai_list_type sm_list(aiManager()->get_ai_list());
+ FGAIManager::ai_list_iterator sm_list_itr = sm_list.begin(),
+ end = sm_list.end();
for (; sm_list_itr != end; ++sm_list_itr) {
FGAIBase::object_type object_type =(*sm_list_itr)->getType();
@@ -300,7 +303,8 @@ bool FGSubmodelMgr::release(submodel *sm, double dt)
ballist->setParentNodes(_selected_ac);
ballist->setContentsNode(sm->contents_node);
ballist->setWeight(sm->weight);
- ai->attach(ballist);
+
+ aiManager()->attach(ballist);
if (sm->count > 0)
sm->count--;
@@ -383,8 +387,6 @@ void FGSubmodelMgr::transform(submodel *sm)
} else {
// set the data for a submodel tied to an AI Object
//cout << " set the data for a submodel tied to an AI Object " << id << endl;
- sm_list_iterator sm_list_itr = sm_list.begin();
- sm_list_iterator end = sm_list.end();
setParentNode(id);
}
@@ -477,15 +479,15 @@ void FGSubmodelMgr::loadAI()
{
SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: Loading AI submodels ");
- sm_list = ai->get_ai_list();
+ FGAIManager::ai_list_type sm_list(aiManager()->get_ai_list());
if (sm_list.empty()) {
SG_LOG(SG_GENERAL, SG_ALERT, "Submodels: Unable to read AI submodel list");
return;
}
- sm_list_iterator sm_list_itr = sm_list.begin();
- sm_list_iterator end = sm_list.end();
+ FGAIManager::ai_list_iterator sm_list_itr = sm_list.begin(),
+ end = sm_list.end();
while (sm_list_itr != end) {
string path = (*sm_list_itr)->_getSMPath();
diff --git a/src/AIModel/submodel.hxx b/src/AIModel/submodel.hxx
index 2abff45ce..71ba8693d 100644
--- a/src/AIModel/submodel.hxx
+++ b/src/AIModel/submodel.hxx
@@ -13,17 +13,13 @@
#include
#include
-#include
+#include
+
#include
#include
-#include
-
-using std::vector;
-using std::string;
-using std::list;
-
class FGAIBase;
+class FGAIManager;
class FGSubmodelMgr : public SGSubsystem, public SGPropertyChangeListener
{
@@ -37,8 +33,8 @@ public:
SGPropertyNode_ptr submodel_node;
SGPropertyNode_ptr speed_node;
- string name;
- string model;
+ std::string name;
+ std::string model;
double speed;
bool slaved;
bool repeat;
@@ -68,13 +64,13 @@ public:
bool collision;
bool expiry;
bool impact;
- string impact_report;
+ std::string impact_report;
double fuse_range;
- string submodel;
+ std::string submodel;
int sub_id;
bool force_stabilised;
bool ext_force;
- string force_path;
+ std::string force_path;
} submodel;
typedef struct {
@@ -112,7 +108,7 @@ public:
private:
- typedef vector submodel_vector_type;
+ typedef std::vector submodel_vector_type;
typedef submodel_vector_type::iterator submodel_vector_iterator;
submodel_vector_type submodels;
@@ -186,22 +182,17 @@ private:
SGPropertyNode_ptr _path_node;
SGPropertyNode_ptr _selected_ac;
-
- FGAIManager* ai;
IC_struct IC;
-
- // A list of pointers to AI objects
- typedef list > sm_list_type;
- typedef sm_list_type::iterator sm_list_iterator;
- typedef sm_list_type::const_iterator sm_list_const_iterator;
-
- sm_list_type sm_list;
-
-
+
+ /**
+ * Helper to retrieve the AI manager, if it currently exists
+ */
+ FGAIManager* aiManager();
+
void loadAI();
void loadSubmodels();
- void setData(int id, string& path, bool serviceable);
- void setSubData(int id, string& path, bool serviceable);
+ void setData(int id, std::string& path, bool serviceable);
+ void setSubData(int id, std::string& path, bool serviceable);
void valueChanged (SGPropertyNode *);
void transform(submodel *);
void setParentNode(int parent_id);
diff --git a/src/Airports/dynamics.cxx b/src/Airports/dynamics.cxx
index f5ebd05d1..11cb454b9 100644
--- a/src/Airports/dynamics.cxx
+++ b/src/Airports/dynamics.cxx
@@ -26,8 +26,6 @@
#include
-#include
-
#include
#include
#include
diff --git a/src/Cockpit/Makefile.am b/src/Cockpit/Makefile.am
index 9908c36a9..68944b762 100644
--- a/src/Cockpit/Makefile.am
+++ b/src/Cockpit/Makefile.am
@@ -1,14 +1,8 @@
noinst_LIBRARIES = libCockpit.a
libCockpit_a_SOURCES = \
- cockpit.cxx cockpit.hxx \
- hud.cxx hud.hxx \
- hud_card.cxx hud_dnst.cxx hud_gaug.cxx hud_inst.cxx \
- hud_labl.cxx hud_ladr.cxx \
- hud_rwy.cxx \
- hud_scal.cxx hud_tbi.cxx \
panel.cxx panel.hxx \
- panel_io.cxx panel_io.hxx
+ panel_io.cxx panel_io.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
diff --git a/src/Cockpit/cockpit.cxx b/src/Cockpit/cockpit.cxx
deleted file mode 100644
index c8afc29c6..000000000
--- a/src/Cockpit/cockpit.cxx
+++ /dev/null
@@ -1,465 +0,0 @@
-// cockpit.cxx -- routines to draw a cockpit (initial draft)
-//
-// Written by Michele America, started September 1997.
-//
-// Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
-//
-// 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.
-//
-// $Id$
-
-
-#ifdef HAVE_CONFIG_H
-# include
-#endif
-
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "cockpit.hxx"
-#include "hud.hxx"
-
-// The following routines obtain information concerntin the aircraft's
-// current state and return it to calling instrument display routines.
-// They should eventually be member functions of the aircraft.
-//
-
-float get_latitude( void )
-{
- return fgGetDouble("/position/latitude-deg");
-}
-
-float get_lat_min( void )
-{
- double a, d;
-
- a = fgGetDouble("/position/latitude-deg");
- if (a < 0.0) {
- a = -a;
- }
- d = (double) ( (int) a);
- float lat_min = (a - d) * 60.0;
-
- return lat_min;
-}
-
-
-float get_longitude( void )
-{
- return fgGetDouble("/position/longitude-deg");
-}
-
-
-char*
-get_formated_gmt_time( void )
-{
- static char buf[32];
- const struct tm *p = globals->get_time_params()->getGmt();
- sprintf( buf, "%d/%d/%4d %d:%02d:%02d",
- p->tm_mon+1, p->tm_mday, 1900 + p->tm_year,
- p->tm_hour, p->tm_min, p->tm_sec);
-
- return buf;
-}
-
-
-float get_long_min( void )
-{
- double a, d;
- a = fgGetDouble("/position/longitude-deg");
- if (a < 0.0) {
- a = -a;
- }
- d = (double) ( (int) a);
- float lon_min = (a - d) * 60.0;
-
- return lon_min;
-}
-
-float get_throttleval( void )
-{
- // Hack limiting to one engine
- return globals->get_controls()->get_throttle( 0 );
-}
-
-float get_aileronval( void )
-{
- return globals->get_controls()->get_aileron();
-}
-
-float get_elevatorval( void )
-{
- return globals->get_controls()->get_elevator();
-}
-
-float get_elev_trimval( void )
-{
- return globals->get_controls()->get_elevator_trim();
-}
-
-float get_rudderval( void )
-{
- return globals->get_controls()->get_rudder();
-}
-
-float get_speed( void )
-{
- static const SGPropertyNode * speedup_node = fgGetNode("/sim/speed-up");
-
- float speed = fgGetDouble("/velocities/airspeed-kt")
- * speedup_node->getIntValue();
-
- return speed;
-}
-
-float get_mach(void)
-{
- return fgGetDouble("/velocities/mach");
-}
-
-float get_aoa( void )
-{
- return fgGetDouble("/orientation/alpha-deg");
-}
-
-float get_roll( void )
-{
- return fgGetDouble("/orientation/roll-deg") * SG_DEGREES_TO_RADIANS;
-}
-
-float get_pitch( void )
-{
- return fgGetDouble("/orientation/pitch-deg") * SG_DEGREES_TO_RADIANS;
-}
-
-float get_heading( void )
-{
- return fgGetDouble("/orientation/heading-deg");
-}
-
-float get_altitude( void )
-{
- static const SGPropertyNode *startup_units_node
- = fgGetNode("/sim/startup/units");
-
- if ( !strcmp(startup_units_node->getStringValue(), "feet") ) {
- return fgGetDouble("/position/altitude-ft");
- } else {
- return fgGetDouble("/position/altitude-ft") * SG_FEET_TO_METER;
- }
-}
-
-float get_agl( void )
-{
- static const SGPropertyNode *startup_units_node
- = fgGetNode("/sim/startup/units");
-
- if ( !strcmp(startup_units_node->getStringValue(), "feet") ) {
- return fgGetDouble("/position/altitude-agl-ft");
- } else {
- return fgGetDouble("/position/altitude-agl-ft") * SG_FEET_TO_METER;
- }
-}
-
-float get_sideslip( void )
-{
- return fgGetDouble("/orientation/side-slip-rad");
-}
-
-float get_frame_rate( void )
-{
- return fgGetInt("/sim/frame-rate");
-}
-
-float get_fov( void )
-{
- return globals->get_current_view()->get_fov();
-}
-
-float get_vfc_ratio( void )
-{
- // float vfc = current_view.get_vfc_ratio();
- // return (vfc);
- return 0.0;
-}
-
-float get_vfc_tris_drawn ( void )
-{
- // float rendered = current_view.get_tris_rendered();
- // return (rendered);
- return 0.0;
-}
-
-float get_vfc_tris_culled ( void )
-{
- // float culled = current_view.get_tris_culled();
- // return (culled);
- return 0.0;
-}
-
-float get_climb_rate( void )
-{
- static const SGPropertyNode *startup_units_node
- = fgGetNode("/sim/startup/units");
-
- float climb_rate = fgGetDouble("/velocities/vertical-speed-fps", 0.0);
- if ( !strcmp(startup_units_node->getStringValue(), "feet") ) {
- climb_rate *= 60.0;
- } else {
- climb_rate *= SG_FEET_TO_METER * 60.0;
- }
-
- return climb_rate;
-}
-
-
-float get_view_direction( void )
-{
- double view_off = 360.0 - globals->get_current_view()->getHeadingOffset_deg();
- double view = fgGetDouble("/orientation/heading-deg") + view_off;
- SG_NORMALIZE_RANGE(view, 0.0, 360.0);
- return view;
-}
-
-// Added by Markus Hof on 5. Jan 2004
-float get_dme( void )
-{
- static const SGPropertyNode * dme_node =
- fgGetNode("/instrumentation/dme/indicated-distance-nm");
-
- return dme_node->getFloatValue();
-}
-
-float get_Ax ( void )
-{
- return fgGetDouble("/accelerations/ned/north-accel-fps_sec", 0.0);
-}
-
-float get_anzg ( void )
-{
- return fgGetDouble("/accelerations/n-z-cg-fps_sec", 0.0);
-}
-
-#ifdef ENABLE_SP_FDM
-float get_aux1 (void)
-{
- return fgGetDouble("/fdm-ada/ship-lat", 0.0);
-}
-
-float get_aux2 (void)
-{
- return fgGetDouble("/fdm-ada/ship-lon", 0.0);
-}
-
-float get_aux3 (void)
-{
- return fgGetDouble("/fdm-ada/ship-alt", 0.0);
-}
-
-float get_aux4 (void)
-{
- return fgGetDouble("/fdm-ada/skijump-dist", 0.0);
-}
-
-float get_aux5 (void)
-{
- return fgGetDouble("/fdm-ada/aux5", 0.0);
-}
-
-float get_aux6 (void)
-{
- return fgGetDouble("/fdm-ada/aux6", 0.0);
-}
-
-float get_aux7 (void)
-{
- return fgGetDouble("/fdm-ada/aux7", 0.0);
-}
-
-float get_aux8 (void)
-{
- return fgGetDouble("/fdm-ada/aux8", 0.0);}
-
-float get_aux9 (void)
-{
- return fgGetDouble("/fdm-ada/aux9", 0.0);}
-
-float get_aux10 (void)
-{
- return fgGetDouble("/fdm-ada/aux10", 0.0);
-}
-
-float get_aux11 (void)
-{
- return fgGetDouble("/fdm-ada/aux11", 0.0);
-}
-
-float get_aux12 (void)
-{
- return fgGetDouble("/fdm-ada/aux12", 0.0);
-}
-
-float get_aux13 (void)
-{
- return fgGetDouble("/fdm-ada/aux13", 0.0);
-}
-
-float get_aux14 (void)
-{
- return fgGetDouble("/fdm-ada/aux14", 0.0);
-}
-
-float get_aux15 (void)
-{
- return fgGetDouble("/fdm-ada/aux15", 0.0);
-}
-
-float get_aux16 (void)
-{
- return fgGetDouble("/fdm-ada/aux16", 0.0);
-}
-
-float get_aux17 (void)
-{
- return fgGetDouble("/fdm-ada/aux17", 0.0);
-}
-
-float get_aux18 (void)
-{
- return fgGetDouble("/fdm-ada/aux18", 0.0);
-}
-#endif
-
-
-bool fgCockpitInit()
-{
- SG_LOG( SG_COCKPIT, SG_INFO, "Initializing cockpit subsystem" );
-
- // cockpit->code = 1; /* It will be aircraft dependent */
- // cockpit->status = 0;
-
- // If aircraft has HUD specified we will get the specs from its def
- // file. For now we will depend upon hard coding in hud?
-
- // We must insure that the existing instrument link is purged.
- // This is done by deleting the links in the list.
-
- // HI_Head is now a null pointer so we can generate a new list from the
- // current aircraft.
-
- fgHUDInit();
-
- return true;
-}
-
-void fgCockpitUpdate( osg::State* state ) {
-
- static const SGPropertyNode * xsize_node = fgGetNode("/sim/startup/xsize");
- static const SGPropertyNode * ysize_node = fgGetNode("/sim/startup/ysize");
- static const SGPropertyNode * hud_visibility_node
- = fgGetNode("/sim/hud/visibility");
-
- int iwidth = xsize_node->getIntValue();
- int iheight = ysize_node->getIntValue();
-
- // FIXME: inefficient
- if ( hud_visibility_node->getBoolValue() ) {
- // This will check the global hud linked list pointer.
- // If there is anything to draw it will.
- fgUpdateHUD( state );
- }
-
- glViewport( 0, 0, iwidth, iheight );
-}
-
-
-
-
-
-struct FuncTable {
- const char *name;
- FLTFNPTR func;
-} fn_table[] = {
- { "agl", get_agl },
- { "aileronval", get_aileronval },
- { "altitude", get_altitude },
- { "anzg", get_anzg },
- { "aoa", get_aoa },
- { "ax", get_Ax },
- { "climb", get_climb_rate },
- { "elevatortrimval", get_elev_trimval },
- { "elevatorval", get_elevatorval },
- { "fov", get_fov },
- { "framerate", get_frame_rate },
- { "heading", get_heading },
- { "latitude", get_latitude },
- { "longitude", get_longitude },
- { "mach", get_mach },
- { "rudderval", get_rudderval },
- { "speed", get_speed },
- { "throttleval", get_throttleval },
- { "view_direction", get_view_direction },
- { "vfc_tris_culled", get_vfc_tris_culled },
- { "vfc_tris_drawn", get_vfc_tris_drawn },
-#ifdef ENABLE_SP_FDM
- { "aux1", get_aux1 },
- { "aux2", get_aux2 },
- { "aux3", get_aux3 },
- { "aux4", get_aux4 },
- { "aux5", get_aux5 },
- { "aux6", get_aux6 },
- { "aux7", get_aux7 },
- { "aux8", get_aux8 },
- { "aux9", get_aux9 },
- { "aux10", get_aux10 },
- { "aux11", get_aux11 },
- { "aux12", get_aux12 },
- { "aux13", get_aux13 },
- { "aux14", get_aux14 },
- { "aux15", get_aux15 },
- { "aux16", get_aux16 },
- { "aux17", get_aux17 },
- { "aux18", get_aux18 },
-#endif
- { 0, 0 },
-};
-
-
-FLTFNPTR get_func(const char *name)
-{
- for (int i = 0; fn_table[i].name; i++)
- if (!strcmp(fn_table[i].name, name))
- return fn_table[i].func;
-
- return 0;
-}
-
-
diff --git a/src/Cockpit/cockpit.hxx b/src/Cockpit/cockpit.hxx
deleted file mode 100644
index 91c415514..000000000
--- a/src/Cockpit/cockpit.hxx
+++ /dev/null
@@ -1,39 +0,0 @@
-/**************************************************************************
- * cockpit.hxx -- cockpit defines and prototypes (initial draft)
- *
- * Written by Michele America, started September 1997.
- *
- * Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
- *
- * 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.
- *
- * $Id$
- **************************************************************************/
-
-
-#ifndef _COCKPIT_HXX
-#define _COCKPIT_HXX
-
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include
-
-bool fgCockpitInit();
-void fgCockpitUpdate( osg::State* );
-
-#endif /* _COCKPIT_HXX */
diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx
deleted file mode 100644
index c08e67d0e..000000000
--- a/src/Cockpit/hud.cxx
+++ /dev/null
@@ -1,654 +0,0 @@
-// hud.cxx -- hud defines and prototypes
-//
-// Written by Michele America, started September 1997.
-//
-// Copyright (C) 1997 Michele F. America - micheleamerica@geocities.com
-//
-// 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.
-//
-// $Id$
-
-#include
-#include
-
-#include
-#include
-
-#ifdef HAVE_CONFIG_H
-# include
-#endif
-
-#include
-#include
-#include // char related functions
-#include // strcmp()
-
-#include
-#include
-#include
-#include
-
-#include
-
-#include // FGFontCache
-#include
-#include
-#include
-#include
-
-#include "hud.hxx"
-
-
-static HUD_Properties *HUDprop = 0;
-
-static char units[5];
-
-deque > HUD_deque;
-
-fgTextList HUD_TextList;
-fgLineList HUD_LineList;
-fgLineList HUD_StippleLineList;
-
-fntRenderer *HUDtext = 0;
-fntTexFont *HUD_Font = 0;
-float HUD_TextSize = 0;
-int HUD_style = 0;
-
-float HUD_matrix[16];
-
-int readHud( istream &input );
-int readInstrument ( const SGPropertyNode * node);
-
-static void drawHUD(osg::State*);
-static void fgUpdateHUDVirtual(osg::State*);
-
-
-class locRECT {
-public:
- RECT rect;
-
- locRECT( UINT left, UINT top, UINT right, UINT bottom);
- RECT get_rect(void) { return rect; }
-};
-
-locRECT :: locRECT( UINT left, UINT top, UINT right, UINT bottom)
-{
- rect.left = left;
- rect.top = top;
- rect.right = right;
- rect.bottom = bottom;
-
-}
-// #define DEBUG
-
-
-
-
-int readInstrument(const SGPropertyNode * node)
-{
- static const SGPropertyNode *startup_units_node
- = fgGetNode("/sim/startup/units");
-
- instr_item *HIptr;
-
- if ( !strcmp(startup_units_node->getStringValue(), "feet") ) {
- strcpy(units, " ft");
- } else {
- strcpy(units, " m");
- }
-
- const SGPropertyNode * ladder_group = node->getNode("ladders");
-
- if (ladder_group != 0) {
- int nLadders = ladder_group->nChildren();
- for (int j = 0; j < nLadders; j++) {
- HIptr = static_cast(new HudLadder(ladder_group->getChild(j)));
- HUD_deque.insert(HUD_deque.begin(), HIptr);
- }
- }
-
- const SGPropertyNode * card_group = node->getNode("cards");
- if (card_group != 0) {
- int nCards = card_group->nChildren();
- for (int j = 0; j < nCards; j++) {
- const char *type = card_group->getChild(j)->getStringValue("type", "gauge");
-
- if (!strcmp(type, "gauge"))
- HIptr = static_cast(new gauge_instr(card_group->getChild(j)));
- else if (!strcmp(type, "dial") || !strcmp(type, "tape"))
- HIptr = static_cast(new hud_card(card_group->getChild(j)));
- else {
- SG_LOG(SG_INPUT, SG_WARN, "HUD: unknown 'card' type: " << type);
- continue;
- }
- HUD_deque.insert(HUD_deque.begin(), HIptr);
- }
- }
-
- const SGPropertyNode * label_group = node->getNode("labels");
- if (label_group != 0) {
- int nLabels = label_group->nChildren();
- for (int j = 0; j < nLabels; j++) {
- HIptr = static_cast(new instr_label(label_group->getChild(j)));
- HUD_deque.insert(HUD_deque.begin(), HIptr);
- }
- }
-
- const SGPropertyNode * tbi_group = node->getNode("tbis");
- if (tbi_group != 0) {
- int nTbis = tbi_group->nChildren();
- for (int j = 0; j < nTbis; j++) {
- HIptr = static_cast(new fgTBI_instr(tbi_group->getChild(j)));
- HUD_deque.insert(HUD_deque.begin(), HIptr);
- }
- }
-
- const SGPropertyNode * rwy_group = node->getNode("runways");
- if (rwy_group != 0) {
- int nRwy = rwy_group->nChildren();
- for (int j = 0; j < nRwy; j++) {
- HIptr = static_cast(new runway_instr(rwy_group->getChild(j)));
- HUD_deque.insert(HUD_deque.begin(), HIptr);
- }
- }
- return 0;
-} //end readinstrument
-
-
-int readHud( istream &input )
-{
-
- SGPropertyNode root;
-
- try {
- readProperties(input, &root);
- } catch (const sg_exception &e) {
- guiErrorMessage("Error reading HUD: ", e);
- return 0;
- }
-
-
- SG_LOG(SG_INPUT, SG_DEBUG, "Read properties for " <<
- root.getStringValue("name"));
-
- if (!root.getNode("depreciated"))
- SG_LOG(SG_INPUT, SG_ALERT, "WARNING: use of depreciated old HUD");
-
- HUD_deque.erase( HUD_deque.begin(), HUD_deque.end());
-
-
- SG_LOG(SG_INPUT, SG_DEBUG, "Reading Hud instruments");
-
- const SGPropertyNode * instrument_group = root.getChild("instruments");
- int nInstruments = instrument_group->nChildren();
-
- for (int i = 0; i < nInstruments; i++) {
-
- const SGPropertyNode * node = instrument_group->getChild(i);
-
- SGPath path( globals->get_fg_root() );
- path.append(node->getStringValue("path"));
-
- SG_LOG(SG_INPUT, SG_DEBUG, "Reading Instrument "
- << node->getName()
- << " from "
- << path.str());
-
- SGPropertyNode root2;
- try {
- readProperties(path.str(), &root2);
- } catch (const sg_exception &e) {
- guiErrorMessage("Error reading HUD instrument: ", e);
- continue;
- }
- readInstrument(&root2);
- }//for loop(i)
-
- return 0;
-}
-
-
-// fgHUDInit
-//
-// Constructs a HUD object and then adds in instruments. At the present
-// the instruments are hard coded into the routine. Ultimately these need
-// to be defined by the aircraft's instrumentation records so that the
-// display for a Piper Cub doesn't show the speed range of a North American
-// mustange and the engine readouts of a B36!
-//
-int fgHUDInit()
-{
-
- HUD_style = 1;
-
- SG_LOG( SG_COCKPIT, SG_INFO, "Initializing current aircraft HUD" );
-
- string hud_path =
- fgGetString("/sim/hud/path", "Huds/Default/default.xml");
- SGPath path(globals->get_fg_root());
- path.append(hud_path);
-
- ifstream input(path.c_str());
- if (!input.good()) {
- SG_LOG(SG_INPUT, SG_ALERT,
- "Cannot read Hud configuration from " << path.str());
- } else {
- readHud(input);
- input.close();
- }
-
- if ( HUDtext ) {
- // this chunk of code is not necessarily thread safe if the
- // compiler optimizer reorders these statements. Note that
- // "delete ptr" does not set "ptr = NULL". We have to do that
- // ourselves.
- fntRenderer *tmp = HUDtext;
- HUDtext = NULL;
- delete tmp;
- }
-
- FGFontCache *fc = globals->get_fontcache();
- const char* fileName = fgGetString("/sim/hud/font/name", "Helvetica.txf");
- HUD_Font = fc->getTexFont(fileName);
- if (!HUD_Font)
- throw sg_io_exception("/sim/hud/font/name is not a texture font",
- sg_location(fileName));
-
- HUD_TextSize = fgGetFloat("/sim/hud/font/size", 10);
-
- HUDtext = new fntRenderer();
- HUDtext->setFont(HUD_Font);
- HUDtext->setPointSize(HUD_TextSize);
- HUD_TextList.setFont( HUDtext );
-
- if (!HUDprop)
- HUDprop = new HUD_Properties;
- return 0; // For now. Later we may use this for an error code.
-
-}
-
-
-int fgHUDInit2()
-{
-
- HUD_style = 2;
-
- SG_LOG( SG_COCKPIT, SG_INFO, "Initializing current aircraft HUD" );
-
- SGPath path(globals->get_fg_root());
- path.append("Huds/Minimal/default.xml");
-
-
- ifstream input(path.c_str());
- if (!input.good()) {
- SG_LOG(SG_INPUT, SG_ALERT,
- "Cannot read Hud configuration from " << path.str());
- } else {
- readHud(input);
- input.close();
- }
-
- if (!HUDprop)
- HUDprop = new HUD_Properties;
- return 0; // For now. Later we may use this for an error code.
-
-}
-//$$$ End - added, Neetha, 28 Nov 2k
-
-
-// fgUpdateHUD
-//
-// Performs a once around the list of calls to instruments installed in
-// the HUD object with requests for redraw. Kinda. It will when this is
-// all C++.
-//
-void fgUpdateHUD( osg::State* state ) {
-
- static const SGPropertyNode *enable3d_node = fgGetNode("/sim/hud/enable3d");
- if ( HUD_style == 1 && enable3d_node->getBoolValue() ) {
- fgUpdateHUDVirtual(state);
- return;
- }
-
- static const float normal_aspect = float(640) / float(480);
- // note: aspect_ratio is Y/X
- float current_aspect = 1.0f/globals->get_current_view()->get_aspect_ratio();
- if ( current_aspect > normal_aspect ) {
- float aspect_adjust = current_aspect / normal_aspect;
- float adjust = 320.0f*aspect_adjust - 320.0f;
- fgUpdateHUD( state, -adjust, 0.0f, 640.0f+adjust, 480.0f );
- } else {
- float aspect_adjust = normal_aspect / current_aspect;
- float adjust = 240.0f*aspect_adjust - 240.0f;
- fgUpdateHUD( state, 0.0f, -adjust, 640.0f, 480.0f+adjust );
- }
-}
-
-void fgUpdateHUDVirtual(osg::State* state)
-{
- using namespace osg;
- FGViewer* view = globals->get_current_view();
-
- // Standard fgfs projection, with essentially meaningless clip
- // planes (we'll map the whole HUD plane to z=-1)
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- Matrixf proj
- = Matrixf::perspective(view->get_v_fov(), 1/view->get_aspect_ratio(),
- 0.1, 10);
- glLoadMatrix(proj.ptr());
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
-
- // Standard fgfs view direction computation
- Vec3f lookat;
- lookat[0] = -sin(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
- lookat[1] = tan(SG_DEGREES_TO_RADIANS * view->getPitchOffset_deg());
- lookat[2] = -cos(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
- if (fabs(lookat[1]) > 9999)
- lookat[1] = 9999; // FPU sanity
- Matrixf mv = Matrixf::lookAt(Vec3f(0.0, 0.0, 0.0), lookat,
- Vec3f(0.0, 1.0, 0.0));
- glLoadMatrix(mv.ptr());
-
- // Map the -1:1 square to a 55.0x41.25 degree wide patch at z=1.
- // This is the default fgfs field of view, which the HUD files are
- // written to assume.
- float dx = 0.52056705; // tan(55/2)
- float dy = dx * 0.75; // assumes 4:3 aspect ratio
- float m[16];
- m[0] = dx; m[4] = 0; m[ 8] = 0; m[12] = 0;
- m[1] = 0; m[5] = dy; m[ 9] = 0; m[13] = 0;
- m[2] = 0; m[6] = 0; m[10] = 1; m[14] = 0;
- m[3] = 0; m[7] = 0; m[11] = 0; m[15] = 1;
- glMultMatrixf(m);
-
- // Convert the 640x480 "HUD standard" coordinate space to a square
- // about the origin in the range [-1:1] at depth of -1
- glScalef(1./320, 1./240, 1);
- glTranslatef(-320, -240, -1);
-
- // Do the deed
- drawHUD(state);
-
- // Clean up our mess
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-}
-
-
-void fgUpdateHUD( osg::State* state, GLfloat x_start, GLfloat y_start,
- GLfloat x_end, GLfloat y_end )
-{
- using namespace osg;
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- Matrixf proj = Matrixf::ortho2D(x_start, x_end, y_start, y_end);
- glLoadMatrix(proj.ptr());
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- drawHUD(state);
-
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-}
-
-
-void drawHUD(osg::State* state)
-{
- if ( !HUD_deque.size() ) // Trust everyone, but ALWAYS cut the cards!
- return;
-
- HUD_TextList.erase();
- HUD_LineList.erase();
- // HUD_StippleLineList.erase();
-
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
-
- static const SGPropertyNode *heading_enabled
- = fgGetNode("/autopilot/locks/heading", true);
- static const SGPropertyNode *altitude_enabled
- = fgGetNode("/autopilot/locks/altitude", true);
-
- static char hud_hdg_text[256];
- static char hud_gps_text0[256];
- static char hud_gps_text1[256];
- static char hud_gps_text2[256];
- static char hud_alt_text[256];
-
- glEnable(GL_BLEND);
- if (HUDprop->isTransparent())
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- else
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- if (HUDprop->isAntialiased()) {
- glEnable(GL_LINE_SMOOTH);
- glAlphaFunc(GL_GREATER, HUDprop->alphaClamp());
- glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
- //glLineWidth(1.5);
- } else {
- //glLineWidth(1.0);
- }
-
- HUDprop->setColor();
- for_each(HUD_deque.begin(), HUD_deque.end(), HUDdraw());
-
- //HUD_TextList.add( fgText(40, 10, get_formated_gmt_time(), 0) );
-
-
- int apY = 480 - 80;
-
-
- if (strcmp( heading_enabled->getStringValue(), "dg-heading-hold") == 0 ) {
- snprintf( hud_hdg_text, 256, "hdg = %.1f\n",
- fgGetDouble("/autopilot/settings/heading-bug-deg") );
- HUD_TextList.add( fgText( 40, apY, hud_hdg_text ) );
- apY -= 15;
- } else if ( strcmp(heading_enabled->getStringValue(), "true-heading-hold") == 0 ) {
- snprintf( hud_hdg_text, 256, "hdg = %.1f\n",
- fgGetDouble("/autopilot/settings/true-heading-deg") );
- HUD_TextList.add( fgText( 40, apY, hud_hdg_text ) );
- apY -= 15;
- }
-
- // GPS current waypoint information
- SGPropertyNode_ptr gps = fgGetNode("/instrumentation/gps", true);
- SGPropertyNode_ptr curWp = gps->getChild("wp")->getChild("wp",1);
-
- if ((gps->getDoubleValue("raim") > 0.5) && curWp) {
- // GPS is receiving a valid signal
- snprintf(hud_gps_text0, 256, "WPT:%5s BRG:%03.0f %5.1fnm",
- curWp->getStringValue("ID"),
- curWp->getDoubleValue("bearing-mag-deg"),
- curWp->getDoubleValue("distance-nm"));
- HUD_TextList.add( fgText( 40, apY, hud_gps_text0 ) );
- apY -= 15;
-
- // curWp->getStringValue("TTW")
- snprintf(hud_gps_text2, 256, "ETA %s", curWp->getStringValue("TTW"));
- HUD_TextList.add( fgText( 40, apY, hud_gps_text2 ) );
- apY -= 15;
-
- double courseError = curWp->getDoubleValue("course-error-nm");
- if (fabs(courseError) >= 0.01) {
- // generate an arrow indicatinng if the pilot should turn left or right
- char dir = (courseError < 0.0) ? '<' : '>';
- snprintf(hud_gps_text1, 256, "GPS TRK:%03.0f XTRK:%c%4.2fnm",
- gps->getDoubleValue("indicated-track-magnetic-deg"), dir, fabs(courseError));
- } else { // on course, don't bother showing the XTRK error
- snprintf(hud_gps_text1, 256, "GPS TRK:%03.0f",
- gps->getDoubleValue("indicated-track-magnetic-deg"));
- }
-
- HUD_TextList.add( fgText( 40, apY, hud_gps_text1) );
- apY -= 15;
- } // of valid GPS output
-
- ////////////////////
-
- if ( strcmp( altitude_enabled->getStringValue(), "altitude-hold" ) == 0 ) {
- snprintf( hud_alt_text, 256, "alt = %.0f\n",
- fgGetDouble("/autopilot/settings/target-altitude-ft") );
- HUD_TextList.add( fgText( 40, apY, hud_alt_text ) );
- apY -= 15;
- } else if ( strcmp( altitude_enabled->getStringValue(), "agl-hold" ) == 0 ){
- snprintf( hud_alt_text, 256, "agl = %.0f\n",
- fgGetDouble("/autopilot/settings/target-agl-ft") );
- HUD_TextList.add( fgText( 40, apY, hud_alt_text ) );
- apY -= 15;
- }
-
- HUD_TextList.draw();
- HUD_LineList.draw();
-
- // glEnable(GL_LINE_STIPPLE);
- // glLineStipple( 1, 0x00FF );
- // HUD_StippleLineList.draw();
- // glDisable(GL_LINE_STIPPLE);
-
- if (HUDprop->isAntialiased()) {
- glDisable(GL_ALPHA_TEST);
- glDisable(GL_LINE_SMOOTH);
- //glLineWidth(1.0);
- }
-
- if (HUDprop->isTransparent())
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_LIGHTING);
-}
-
-
-void fgTextList::draw()
-{
- if (!Font)
- return;
-
- vector::iterator curString = List.begin();
- vector::iterator lastString = List.end();
-
- glPushAttrib(GL_COLOR_BUFFER_BIT);
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
- if (HUDprop->isTransparent())
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- else
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- if (HUDprop->isAntialiased()) {
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, HUDprop->alphaClamp());
- }
-
- Font->begin();
- for (; curString != lastString; curString++)
- curString->Draw(Font);
- Font->end();
-
- glDisable(GL_TEXTURE_2D);
- glPopAttrib();
-}
-
-
-// HUD property listener class
-//
-HUD_Properties::HUD_Properties() :
- _current(fgGetNode("/sim/hud/current-color", true)),
- _visibility(fgGetNode("/sim/hud/visibility", true)),
- _antialiasing(fgGetNode("/sim/hud/color/antialiased", true)),
- _transparency(fgGetNode("/sim/hud/color/transparent", true)),
- _red(fgGetNode("/sim/hud/color/red", true)),
- _green(fgGetNode("/sim/hud/color/green", true)),
- _blue(fgGetNode("/sim/hud/color/blue", true)),
- _alpha(fgGetNode("/sim/hud/color/alpha", true)),
- _alpha_clamp(fgGetNode("/sim/hud/color/alpha-clamp", true)),
- _brightness(fgGetNode("/sim/hud/color/brightness", true)),
- _visible(false),
- _antialiased(false),
- _transparent(false),
- _a(0.67),
- _cl(0.01)
-{
- _visibility->addChangeListener(this);
- _antialiasing->addChangeListener(this);
- _transparency->addChangeListener(this);
- _red->addChangeListener(this);
- _green->addChangeListener(this);
- _blue->addChangeListener(this);
- _alpha->addChangeListener(this);
- _alpha_clamp->addChangeListener(this);
- _brightness->addChangeListener(this);
- _current->addChangeListener(this, true);
-}
-
-
-void HUD_Properties::valueChanged(SGPropertyNode *node)
-{
- if (!strcmp(node->getName(), "current-color")) {
- int i = node->getIntValue();
- if (i < 0)
- i = 0;
- SGPropertyNode *n = fgGetNode("/sim/hud/palette", true);
- if ((n = n->getChild("color", i, false))) {
- if (n->hasValue("red"))
- _red->setFloatValue(n->getFloatValue("red", 1.0));
- if (n->hasValue("green"))
- _green->setFloatValue(n->getFloatValue("green", 1.0));
- if (n->hasValue("blue"))
- _blue->setFloatValue(n->getFloatValue("blue", 1.0));
- if (n->hasValue("alpha"))
- _alpha->setFloatValue(n->getFloatValue("alpha", 0.67));
- if (n->hasValue("alpha-clamp"))
- _alpha_clamp->setFloatValue(n->getFloatValue("alpha-clamp", 0.01));
- if (n->hasValue("brightness"))
- _brightness->setFloatValue(n->getFloatValue("brightness", 0.75));
- if (n->hasValue("antialiased"))
- _antialiasing->setBoolValue(n->getBoolValue("antialiased", false));
- if (n->hasValue("transparent"))
- _transparency->setBoolValue(n->getBoolValue("transparent", false));
- }
- }
- _visible = _visibility->getBoolValue();
- _transparent = _transparency->getBoolValue();
- _antialiased = _antialiasing->getBoolValue();
- float brt = _brightness->getFloatValue();
- _r = clamp(brt * _red->getFloatValue());
- _g = clamp(brt * _green->getFloatValue());
- _b = clamp(brt * _blue->getFloatValue());
- _a = clamp(_alpha->getFloatValue());
- _cl = clamp(_alpha_clamp->getFloatValue());
-}
-
-
-void HUD_Properties::setColor() const
-{
- if (_antialiased)
- glColor4f(_r, _g, _b, _a);
- else
- glColor3f(_r, _g, _b);
-}
-
-
diff --git a/src/Cockpit/hud.hxx b/src/Cockpit/hud.hxx
deleted file mode 100644
index bec30f553..000000000
--- a/src/Cockpit/hud.hxx
+++ /dev/null
@@ -1,730 +0,0 @@
-// hud.hxx -- hud defines and prototypes (initial draft)
-//
-// Written by Michele America, started September 1997.
-//
-// Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
-//
-// 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.
-//
-// $Id$
-
-
-#ifndef _OLDHUD_HXX
-#define _OLDHUD_HXX
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include
-
-#ifdef HAVE_CONFIG_H
-# include
-#endif
-
-#ifdef __CYGWIN__
-#include
-#endif
-
-#include
-#include
-
-#include // for_each()
-#include // STL vector
-#include // STL double ended queue
-#include
-
-namespace osg {
- class State;
-}
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-class FGRunway;
-
-using std::deque;
-using std::vector;
-
-#define float_to_int(v) SGMiscf::roundToInt(v)
-
-// some of Norman's crazy optimizations. :-)
-
-#ifndef WIN32
-typedef struct {
- int x, y;
-} POINT;
-
-typedef struct {
- int top, bottom, left, right;
-} RECT;
-#endif
-
-// View mode definitions
-
-enum VIEW_MODES{ HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
-
-// Label constants
-#define HUD_FONT_SMALL 1
-#define HUD_FONT_LARGE 2
-
-enum fgLabelJust{ LEFT_JUST, CENTER_JUST, RIGHT_JUST } ;
-
-#define HUDS_AUTOTICKS 0x0001
-#define HUDS_VERT 0x0002
-#define HUDS_HORZ 0x0000
-#define HUDS_TOP 0x0004
-#define HUDS_BOTTOM 0x0008
-#define HUDS_LEFT HUDS_TOP
-#define HUDS_RIGHT HUDS_BOTTOM
-#define HUDS_BOTH (HUDS_LEFT | HUDS_RIGHT)
-#define HUDS_NOTICKS 0x0010
-#define HUDS_ARITHTIC 0x0020
-#define HUDS_DECITICS 0x0040
-#define HUDS_NOTEXT 0x0080
-
-// in cockpit.cxx
-extern float get_throttleval ( void );
-extern float get_aileronval ( void );
-extern float get_elevatorval ( void );
-extern float get_elev_trimval( void );
-extern float get_rudderval ( void );
-extern float get_speed ( void );
-extern float get_aoa ( void );
-extern float get_nlf ( void );
-extern float get_roll ( void );
-extern float get_pitch ( void );
-extern float get_heading ( void );
-extern float get_view_direction( void );
-extern float get_altitude ( void );
-extern float get_agl ( void );
-extern float get_sideslip ( void );
-extern float get_frame_rate ( void );
-extern float get_latitude ( void );
-extern float get_lat_min ( void );
-extern float get_longitude ( void );
-extern float get_long_min ( void );
-extern float get_fov ( void );
-extern float get_vfc_ratio ( void );
-extern float get_vfc_tris_drawn ( void );
-extern float get_vfc_tris_culled ( void );
-extern float get_climb_rate ( void );
-extern float get_mach( void );
-extern char *coord_format_lat(float);
-extern char *coord_format_lon(float);
-
-extern char *get_formated_gmt_time( void );
-
-enum hudinstype{ HUDno_instr,
- HUDscale,
- HUDlabel,
- HUDladder,
- HUDcirc_ladder,
- HUDhorizon,
- HUDgauge,
- HUDdual_inst,
- HUDmoving_scale,
- HUDtbi
-};
-
-typedef struct gltagRGBTRIPLE { // rgbt
- GLfloat Blue;
- GLfloat Green;
- GLfloat Red;
-} glRGBTRIPLE;
-
-class fgLineSeg2D {
-private:
- GLfloat x0, y0, x1, y1;
-
-public:
- fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
- : x0(a), y0(b), x1(c), y1(d) {}
-
- fgLineSeg2D( const fgLineSeg2D & image )
- : x0(image.x0), y0(image.y0), x1(image.x1), y1(image.y1) {}
-
- fgLineSeg2D& operator= ( const fgLineSeg2D & image ) { // seems unused
- x0 = image.x0; y0 = image.y0; x1 = image.x1; y1 = image.y1; return *this;
- }
-
- void draw() const
- {
- glVertex2f(x0, y0);
- glVertex2f(x1, y1);
- }
-};
-
-class DrawLineSeg2D {
- public:
- void operator() (const fgLineSeg2D& elem) const {
- elem.draw();
- }
-};
-
-
-#define USE_HUD_TextList
-extern fntTexFont *HUD_Font;
-extern float HUD_TextSize;
-extern fntRenderer *HUDtext;
-extern float HUD_matrix[16];
-
-class fgText {
-private:
- float x, y;
- string msg;
- bool digit;
- // seems unused
-
-public:
- fgText(float x, float y, const string& c, bool digits=false): x(x), y(y), msg( c), digit( digits) {};
-
- fgText( const fgText & image )
- : x(image.x), y(image.y), msg(image.msg), digit(image.digit) { }
-
- fgText& operator = ( const fgText & image ) {
- x = image.x; y = image.y; msg= image.msg; digit = image.digit;
- return *this;
- }
-
- static int getStringWidth ( const char *str )
- {
- if ( HUDtext && str ) {
- float r, l ;
- HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
- return float_to_int( r - l );
- }
- return 0 ;
- }
-
- int StringWidth ()
- {
- if ( HUDtext && msg != "") {
- float r, l ;
- HUD_Font->getBBox ( msg.c_str(), HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
- return float_to_int( r - l );
- }
- return 0 ;
- }
-
- // this code is changed to display Numbers with big/small digits
- // according to MIL Standards for example Altitude above 10000 ft
- // is shown as 10ooo.
-
- void Draw(fntRenderer *fnt) {
- if (digit) {
- int c=0;
-
- int p=4;
-
- if (msg[0]=='-') {
- //if negative value then increase the c and p values
- //for '-' sign. c++;
- p++;
- }
-
- for (string::size_type i = 0; i < msg.size(); i++) {
- if ((msg[i]>='0') && (msg[i]<='9'))
- c++;
- }
- float orig_size = fnt->getPointSize();
- if (c>p) {
- fnt->setPointSize(HUD_TextSize * 0.8);
- int p2=(c-3)*8; //advance to the last 3 digits
-
- fnt->start2f(x+p2,y);
- fnt->puts(msg.c_str() + c - 3); // display last 3 digits
-
- fnt->setPointSize(HUD_TextSize * 1.2);
-
- fnt->start2f(x,y);
- fnt->puts(msg.substr(0,c-3).c_str());
- } else {
- fnt->setPointSize(HUD_TextSize * 1.2);
- fnt->start2f( x, y );
- fnt->puts(msg.c_str());
- }
- fnt->setPointSize(orig_size);
- } else {
- //if digits not true
- fnt->start2f( x, y );
- fnt->puts( msg.c_str()) ;
- }
- }
-
- void Draw()
- {
- guiFnt.drawString( msg.c_str(), float_to_int(x), float_to_int(y) );
- }
-};
-
-class fgLineList {
- vector < fgLineSeg2D > List;
-public:
- fgLineList( void ) {}
- void add( const fgLineSeg2D& seg ) { List.push_back(seg); }
- void erase( void ) { List.clear();}
- void draw( void ) {
- glBegin(GL_LINES);
- for_each( List.begin(), List.end(), DrawLineSeg2D());
- glEnd();
- }
-};
-
-class fgTextList {
- fntRenderer *Font;
- vector< fgText > List;
-public:
- fgTextList ( void ) { Font = 0; }
-
- void setFont( fntRenderer *Renderer ) { Font = Renderer; }
- void add( const fgText& String ) { List.push_back(String); }
- void erase( void ) { List.clear(); }
- void draw( void );
-};
-
-
-inline void Text( fgTextList &List, float x, float y, char *s)
-{
- List.add( fgText( x, y, s) );
-}
-
-inline void Text( fgTextList &List, const fgText &me)
-{
- List.add(me);
-}
-
-inline void Line( fgLineList &List, float x1, float y1, float x2, float y2)
-{
- List.add(fgLineSeg2D(x1,y1,x2,y2));
-}
-
-
-// Declare our externals
-extern fgTextList HUD_TextList;
-extern fgLineList HUD_LineList;
-extern fgLineList HUD_StippleLineList;
-
-
-class instr_item : public SGReferenced { // An Abstract Base Class (ABC)
-private:
- static UINT instances; // More than 64K instruments? Nah!
- static int brightness;
- static glRGBTRIPLE color;
-
- UINT handle;
- RECT scrn_pos; // Framing - affects scale dimensions
- // and orientation. Vert vs Horz, etc.
- FLTFNPTR load_value_fn;
- float disp_factor; // Multiply by to get numbers shown on scale.
- UINT opts;
- bool is_enabled;
- bool broken;
- UINT scr_span; // Working values for draw;
- POINT mid_span; //
- int digits;
-
-public:
- instr_item( int x,
- int y,
- UINT height,
- UINT width,
- FLTFNPTR data_source,
- float data_scaling,
- UINT options,
- bool working = true,
- int digit = 0);
-
- virtual ~instr_item ();
-
- void set_data_source ( FLTFNPTR fn ) { load_value_fn = fn; }
- int get_brightness ( void ) { return brightness;}
- RECT get_location ( void ) { return scrn_pos; }
- bool is_broken ( void ) { return broken; }
- bool enabled ( void ) { return is_enabled;}
- bool data_available ( void ) { return !!load_value_fn; }
- float get_value ( void ) { return load_value_fn(); }
- float data_scaling ( void ) { return disp_factor; }
- UINT get_span ( void ) { return scr_span; }
- POINT get_centroid ( void ) { return mid_span; }
- UINT get_options ( void ) { return opts; }
- int get_digits ( void ) { return digits; }
- inline int get_x() const { return scrn_pos.left; }
- inline int get_y() const { return scrn_pos.top; }
- inline int get_width() const { return scrn_pos.right; }
- inline int get_height() const { return scrn_pos.bottom; }
-
- UINT huds_vert (UINT options) { return (options & HUDS_VERT); }
- UINT huds_left (UINT options) { return (options & HUDS_LEFT); }
- UINT huds_right (UINT options) { return (options & HUDS_RIGHT); }
- UINT huds_both (UINT options) {
- return ((options & HUDS_BOTH) == HUDS_BOTH);
- }
- UINT huds_noticks (UINT options) { return (options & HUDS_NOTICKS); }
- UINT huds_notext (UINT options) { return (options & HUDS_NOTEXT); }
- UINT huds_top (UINT options) { return (options & HUDS_TOP); }
- UINT huds_bottom (UINT options) { return (options & HUDS_BOTTOM); }
-
- virtual void display_enable( bool working ) { is_enabled = working;}
-
- virtual void break_display ( bool bad );
- virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
- void SetPosition ( int x, int y, UINT width, UINT height );
- UINT get_Handle( void );
- virtual void draw( void ) = 0; // Required method in derived classes
-
- void drawOneLine( float x1, float y1, float x2, float y2)
- {
- HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2));
- }
- void drawOneStippleLine( float x1, float y1, float x2, float y2)
- {
- HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
- }
- void TextString( char *msg, float x, float y, bool digit )
- {
- HUD_TextList.add(fgText(x, y, msg,digit));
- }
- int getStringWidth ( char *str )
- {
- if ( HUDtext && str ) {
- float r, l ;
- HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
- return float_to_int( r - l );
- }
- return 0 ;
- }
-
-
-
-};
-
-typedef instr_item *HIptr;
-
-class HUDdraw {
- public:
- void operator() (HIptr elem) const {
- if ( elem->enabled())
- elem->draw();
- }
-};
-
-
-extern int HUD_style;
-
-// instr_item This class has no other purpose than to maintain
-// a linked list of instrument and derived class
-// object pointers.
-
-
-class instr_label : public instr_item {
-private:
- const char *pformat;
-
- fgLabelJust justify;
- int fontSize;
- int blink;
- string format_buffer;
- bool lat;
- bool lon;
- bool lbox;
- SGPropertyNode_ptr lon_node;
- SGPropertyNode_ptr lat_node;
-
-public:
- instr_label(const SGPropertyNode *);
- virtual void draw(void);
-};
-
-
-//
-// fgRunway_instr This class is responsible for rendering the active runway
-// in the hud (if visible).
-class runway_instr : public instr_item {
-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(void);
-
- sgdVec3 points3d[6], points2d[6];
- double mm[16],pm[16], arrowScale, arrowRad, lnScale;
- double scaleDist, default_pitch, default_heading;
- GLint view[4];
- FGRunway* runway;
- FGViewer* cockpit_view;
- unsigned short stippleOut, stippleCen;
- bool drawIA, drawIAAlways;
- RECT location;
- POINT center;
-
-public:
- runway_instr(const SGPropertyNode *);
-
- virtual void draw( void );
- void setArrowRotationRadius(double radius);
- // Scales the runway indication arrow
- void setArrowScale(double scale);
- // Draws arrow when runway is not visible in HUD if draw=true
- void setDrawArrow(bool draw);
- // Always draws arrow if draw=true;
- void setDrawArrowAlways(bool draw);
- // Sets the maximum line scale
- void setLineScale(double scale);
- // Sets the distance where to start scaling the lines
- void setScaleDist(double dist_nm);
- // Sets the stipple pattern of the outline of the runway
- void setStippleOutline(unsigned short stipple);
- // Sets the stipple patter of the center line of the runway
- void setStippleCenterline(unsigned short stipple);
-};
-
-
-//
-// instr_scale This class is an abstract base class for both moving
-// scale and moving needle (fixed scale) indicators. It
-// does not draw itself, but is not instanciable.
-//
-
-class instr_scale : public instr_item {
-private:
- float range_shown; // Width Units.
- float Maximum_value; // ceiling.
- float Minimum_value; // Representation floor.
- float scale_factor; // factor => screen units/range values.
- UINT Maj_div; // major division marker units
- UINT Min_div; // minor division marker units
- UINT Modulo; // Roll over point
- int signif_digits; // digits to show to the right.
-
-public:
- instr_scale( int x,
- int y,
- UINT width,
- UINT height,
- FLTFNPTR load_fn,
- UINT options,
- float show_range,
- float max_value,
- float min_value,
- float disp_scaling,
- UINT major_divs,
- UINT minor_divs,
- UINT rollover,
- int dp_showing,
- bool working = true);
-
- virtual void draw ( void ) {}; // No-op here. Defined in derived classes.
- UINT div_min ( void ) { return Min_div;}
- UINT div_max ( void ) { return Maj_div;}
- float min_val ( void ) { return Minimum_value;}
- float max_val ( void ) { return Maximum_value;}
- UINT modulo ( void ) { return Modulo; }
- float factor ( void ) { return scale_factor;}
- float range_to_show ( void ) { return range_shown;}
-};
-
-// hud_card This class displays the indicated quantity on
-// a scale that moves past the pointer. It may be
-// horizontal or vertical, read above(left) or below(right) of the base
-// line.
-
-class hud_card : public instr_scale {
-private:
- float val_span;
- string type;
- 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;
- bool pointer;
- string pointer_type;
- string tick_type;
- string tick_length;
- float radius;
- float maxValue;
- float minValue;
- int divisions;
- int zoom;
- UINT Maj_div;
- UINT Min_div;
-
-public:
- hud_card(const SGPropertyNode *);
- // virtual void display_enable( bool setting ); // FIXME
- virtual void draw(void);
- void circles(float, float, float);
- void fixed(float, float, float, float, float, float);
- void zoomed_scale(int, int);
-};
-
-
-class gauge_instr : public instr_scale {
-public:
- gauge_instr(const SGPropertyNode *);
- virtual void draw( void ); // Required method in base class
-};
-
-
-//
-// dual_instr_item This class was created to form the base class
-// for both panel and HUD Turn Bank Indicators.
-
-class dual_instr_item : public instr_item {
-private:
- FLTFNPTR alt_data_source;
-
-public:
- dual_instr_item ( int x,
- int y,
- UINT width,
- UINT height,
- FLTFNPTR chn1_source,
- FLTFNPTR chn2_source,
- bool working,
- UINT options );
-
- float current_ch1( void ) { return (float)alt_data_source(); }
- float current_ch2( void ) { return (float)get_value(); }
- virtual void draw( void ) {}
-};
-
-
-class fgTBI_instr : public dual_instr_item {
-private:
- UINT BankLimit;
- UINT SlewLimit;
- UINT scr_hole;
- bool tsi;
- float rad;
-
-public:
- fgTBI_instr(const SGPropertyNode *);
-
- UINT bank_limit(void) { return BankLimit; }
- UINT slew_limit(void) { return SlewLimit; }
-
- virtual void draw(void);
-};
-
-
-class HudLadder : public dual_instr_item {
-private:
- UINT width_units;
- int div_units;
- UINT minor_div;
- UINT label_pos;
- UINT scr_hole;
- float vmax;
- float vmin;
- float factor;
- string hudladder_type;
- bool frl;
- bool target_spot;
- 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;
- int zenith;
- int nadir;
- int hat;
-
- // The Ladder has it's own temporary display lists
- fgTextList TextList;
- fgLineList LineList;
- fgLineList StippleLineList;
-
-public:
- HudLadder(const SGPropertyNode *);
-
- virtual void draw(void);
- void drawZenith(float, float, float);
- void drawNadir(float, float, float);
-
- void Text(float x, float y, char *s)
- {
- TextList.add(fgText(x, y, s));
- }
-
- void Line(float x1, float y1, float x2, float y2)
- {
- LineList.add(fgLineSeg2D(x1, y1, x2, y2));
- }
-
- void StippleLine(float x1, float y1, float x2, float y2)
- {
- StippleLineList.add(fgLineSeg2D(x1, y1, x2, y2));
- }
-};
-
-
-extern int fgHUDInit();
-extern int fgHUDInit2();
-extern void fgUpdateHUD( osg::State* );
-extern void fgUpdateHUD( osg::State*, GLfloat x_start, GLfloat y_start,
- GLfloat x_end, GLfloat y_end );
-
-
-
-
-class HUD_Properties : public SGPropertyChangeListener {
-public:
- HUD_Properties();
- void valueChanged(SGPropertyNode *n);
- void setColor() const;
- bool isVisible() const { return _visible; }
- bool isAntialiased() const { return _antialiased; }
- bool isTransparent() const { return _transparent; }
- float alphaClamp() const { return _cl; }
-
-private:
- float clamp(float f) { return f < 0.0f ? 0.0f : f > 1.0f ? 1.0f : f; }
- SGPropertyNode_ptr _current;
- SGPropertyNode_ptr _visibility;
- SGPropertyNode_ptr _antialiasing;
- SGPropertyNode_ptr _transparency;
- SGPropertyNode_ptr _red, _green, _blue, _alpha;
- SGPropertyNode_ptr _alpha_clamp;
- SGPropertyNode_ptr _brightness;
- bool _visible;
- bool _antialiased;
- bool _transparent;
- float _r, _g, _b, _a, _cl;
-};
-
-#endif // _OLDHUD_H
diff --git a/src/Cockpit/hud_card.cxx b/src/Cockpit/hud_card.cxx
deleted file mode 100644
index 746e9317a..000000000
--- a/src/Cockpit/hud_card.cxx
+++ /dev/null
@@ -1,1163 +0,0 @@
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include
-#include
-#include
-
-#include "hud.hxx"
-
-#ifdef USE_HUD_TextList
-#define textString(x, y, text, digit) TextString(text, x , y , digit)
-#else
-#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
-#endif
-
-FLTFNPTR get_func(const char *name); // FIXME
-
-hud_card::hud_card(const SGPropertyNode *node) :
- instr_scale(
- node->getIntValue("x"),
- node->getIntValue("y"),
- node->getIntValue("width"),
- node->getIntValue("height"),
- 0 /*data_source*/, // FIXME
- node->getIntValue("options"),
- node->getFloatValue("value_span"),
- node->getFloatValue("maxValue"),
- node->getFloatValue("minValue"),
- node->getFloatValue("disp_scaling"),
- node->getIntValue("major_divs"),
- node->getIntValue("minor_divs"),
- node->getIntValue("modulator"),
- node->getBoolValue("working", true)),
- val_span(node->getFloatValue("value_span")), // FIXME
- type(node->getStringValue("type")),
- draw_tick_bottom(node->getBoolValue("tick_bottom", false)),
- draw_tick_top(node->getBoolValue("tick_top", false)),
- draw_tick_right(node->getBoolValue("tick_right", false)),
- draw_tick_left(node->getBoolValue("tick_left", false)),
- draw_cap_bottom(node->getBoolValue("cap_bottom", false)),
- draw_cap_top(node->getBoolValue("cap_top", false)),
- draw_cap_right(node->getBoolValue("cap_right", false)),
- draw_cap_left(node->getBoolValue("cap_left", false)),
- marker_offset(node->getFloatValue("marker_offset", 0.0)),
- pointer(node->getBoolValue("enable_pointer", true)),
- pointer_type(node->getStringValue("pointer_type")),
- tick_type(node->getStringValue("tick_type")), // 'circle' or 'line'
- tick_length(node->getStringValue("tick_length")), // for variable length
- radius(node->getFloatValue("radius")),
- maxValue(node->getFloatValue("maxValue")), // FIXME dup
- minValue(node->getFloatValue("minValue")), // FIXME dup
- divisions(node->getIntValue("divisions")),
- zoom(node->getIntValue("zoom")),
- Maj_div(node->getIntValue("major_divs")), // FIXME dup
- Min_div(node->getIntValue("minor_divs")) // FIXME dup
-{
- SG_LOG(SG_INPUT, SG_BULK, "Done reading dial/tape instrument "
- << node->getStringValue("name", "[unnamed]"));
-
- set_data_source(get_func(node->getStringValue("loadfn")));
- half_width_units = range_to_show() / 2.0;
-}
-
-
-void hud_card::draw(void) // (HUD_scale * pscale)
-{
- float vmin = 0.0, vmax = 0.0;
- float marker_xs;
- float marker_xe;
- float marker_ys;
- float marker_ye;
- int text_x = 0, text_y = 0;
- int lenstr;
- int height, width;
- int i, last;
- char TextScale[80];
- bool condition;
- int disp_val = 0;
- int oddtype, k; //odd or even values for ticks
-
- POINT mid_scr = get_centroid();
- float cur_value = get_value();
-
- if (!((int)maxValue % 2))
- oddtype = 0; //draw ticks at even values
- else
- oddtype = 1; //draw ticks at odd values
-
- RECT scrn_rect = get_location();
- UINT options = get_options();
-
- height = scrn_rect.top + scrn_rect.bottom;
- width = scrn_rect.left + scrn_rect.right;
-
- // if type=gauge then display dial
- if (type == "gauge") {
- float x, y;
- float i;
- y = (float)(scrn_rect.top);
- x = (float)(scrn_rect.left);
- glEnable(GL_POINT_SMOOTH);
- glPointSize(3.0);
-
- float incr = 360.0 / divisions;
- for (i = 0.0; i < 360.0; i += incr) {
- float i1 = i * SGD_DEGREES_TO_RADIANS;
- float x1 = x + radius * cos(i1);
- float y1 = y + radius * sin(i1);
-
- glBegin(GL_POINTS);
- glVertex2f(x1, y1);
- glEnd();
- }
- glPointSize(1.0);
- glDisable(GL_POINT_SMOOTH);
-
-
- if (data_available()) {
- float offset = 90.0 * SGD_DEGREES_TO_RADIANS;
- float r1 = 10.0; //size of carrot
- float theta = get_value();
-
- float theta1 = -theta * SGD_DEGREES_TO_RADIANS + offset;
- float x1 = x + radius * cos(theta1);
- float y1 = y + radius * sin(theta1);
- float x2 = x1 - r1 * cos(theta1 - 30.0 * SGD_DEGREES_TO_RADIANS);
- float y2 = y1 - r1 * sin(theta1 - 30.0 * SGD_DEGREES_TO_RADIANS);
- float x3 = x1 - r1 * cos(theta1 + 30.0 * SGD_DEGREES_TO_RADIANS);
- float y3 = y1 - r1 * sin(theta1 + 30.0 * SGD_DEGREES_TO_RADIANS);
-
- // draw carrot
- drawOneLine(x1, y1, x2, y2);
- drawOneLine(x1, y1, x3, y3);
- sprintf(TextScale,"%3.1f\n", theta);
-
- // draw value
- int l = abs((int)theta);
- if (l) {
- if (l < 10)
- textString(x, y, TextScale, 0);
- else if (l < 100)
- textString(x - 1.0, y, TextScale, 0);
- else if (l<360)
- textString(x - 2.0, y, TextScale, 0);
- }
- }
- //end type=gauge
-
- } else {
- // if its not explicitly a gauge default to tape
- if (pointer) {
- if (pointer_type == "moving") {
- vmin = minValue;
- vmax = maxValue;
-
- } else {
- // default to fixed
- vmin = cur_value - half_width_units; // width units == needle travel
- vmax = cur_value + half_width_units; // or picture unit span.
- text_x = mid_scr.x;
- text_y = mid_scr.y;
- }
-
- } else {
- vmin = cur_value - half_width_units; // width units == needle travel
- vmax = cur_value + half_width_units; // or picture unit span.
- text_x = mid_scr.x;
- text_y = mid_scr.y;
- }
-
- // Draw the basic markings for the scale...
-
- if (huds_vert(options)) { // Vertical scale
- // Bottom tick bar
- if (draw_tick_bottom)
- drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
-
- // Top tick bar
- if (draw_tick_top)
- drawOneLine(scrn_rect.left, height, width, height);
-
- marker_xs = scrn_rect.left; // x start
- marker_xe = width; // x extent
- marker_ye = height;
-
- // glBegin(GL_LINES);
-
- // Bottom tick bar
- // glVertex2f(marker_xs, scrn_rect.top);
- // glVertex2f(marker_xe, scrn_rect.top);
-
- // Top tick bar
- // glVertex2f(marker_xs, marker_ye);
- // glVertex2f(marker_xe, marker_ye);
- // glEnd();
-
-
- // We do not use else in the following so that combining the
- // two options produces a "caged" display with double
- // carrots. The same is done for horizontal card indicators.
-
- // begin vertical/left
- //First draw capping lines and pointers
- if (huds_left(options)) { // Calculate x marker offset
-
- if (draw_cap_right) {
- // Cap right side
- drawOneLine(marker_xe, scrn_rect.top, marker_xe, marker_ye);
- }
-
- marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
-
- // drawOneLine(marker_xs, mid_scr.y,
- // marker_xe, mid_scr.y + scrn_rect.right / 6);
- // drawOneLine(marker_xs, mid_scr.y,
- // marker_xe, mid_scr.y - scrn_rect.right / 6);
-
- // draw pointer
- if (pointer) {
- if (pointer_type == "moving") {
- if (zoom == 0) {
- //Code for Moving Type Pointer
- float ycentre, ypoint, xpoint;
- int range, wth;
- if (cur_value > maxValue)
- cur_value = maxValue;
- if (cur_value < minValue)
- cur_value = minValue;
-
- if (minValue >= 0.0)
- ycentre = scrn_rect.top;
- else if (maxValue + minValue == 0.0)
- ycentre = mid_scr.y;
- else if (oddtype == 1)
- ycentre = scrn_rect.top + (1.0 - minValue)*scrn_rect.bottom
- / (maxValue - minValue);
- else
- ycentre = scrn_rect.top + minValue * scrn_rect.bottom
- / (maxValue - minValue);
-
- range = scrn_rect.bottom;
- wth = scrn_rect.left + scrn_rect.right;
-
- if (oddtype == 1)
- ypoint = ycentre + ((cur_value - 1.0) * range / val_span);
- else
- ypoint = ycentre + (cur_value * range / val_span);
-
- xpoint = wth + marker_offset;
- drawOneLine(xpoint, ycentre, xpoint, ypoint);
- drawOneLine(xpoint, ypoint, xpoint - marker_offset, ypoint);
- drawOneLine(xpoint - marker_offset, ypoint, xpoint - 5.0, ypoint + 5.0);
- drawOneLine(xpoint - marker_offset, ypoint, xpoint - 5.0, ypoint - 5.0);
- } //zoom=0
-
- } else {
- // default to fixed
- fixed(marker_offset + marker_xe, text_y + scrn_rect.right / 6,
- marker_offset + marker_xs, text_y, marker_offset + marker_xe,
- text_y - scrn_rect.right / 6);
- }//end pointer type
- } //if pointer
- } //end vertical/left
-
- // begin vertical/right
- //First draw capping lines and pointers
- if (huds_right(options)) { // We'll default this for now.
- if (draw_cap_left) {
- // Cap left side
- drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, marker_ye);
- } //endif cap_left
-
- marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
- // Indicator carrot
- // drawOneLine(scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
- // marker_xe, mid_scr.y);
- // drawOneLine(scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
- // marker_xe, mid_scr.y);
-
- // draw pointer
- if (pointer) {
- if (pointer_type == "moving") {
- if (zoom == 0) {
- //type-fixed & zoom=1, behaviour to be defined
- // Code for Moving Type Pointer
- float ycentre, ypoint, xpoint;
- int range;
-
- if (cur_value > maxValue)
- cur_value = maxValue;
- if (cur_value < minValue)
- cur_value = minValue;
-
- if (minValue >= 0.0)
- ycentre = scrn_rect.top;
- else if (maxValue + minValue == 0.0)
- ycentre = mid_scr.y;
- else if (oddtype == 1)
- ycentre = scrn_rect.top + (1.0 - minValue)*scrn_rect.bottom / (maxValue - minValue);
- else
- ycentre = scrn_rect.top + minValue * scrn_rect.bottom / (maxValue - minValue);
-
- range = scrn_rect.bottom;
-
- if (oddtype == 1)
- ypoint = ycentre + ((cur_value - 1.0) * range / val_span);
- else
- ypoint = ycentre + (cur_value * range / val_span);
-
- xpoint = scrn_rect.left - marker_offset;
- drawOneLine(xpoint, ycentre, xpoint, ypoint);
- drawOneLine(xpoint, ypoint, xpoint + marker_offset, ypoint);
- drawOneLine(xpoint + marker_offset, ypoint, xpoint + 5.0, ypoint + 5.0);
- drawOneLine(xpoint + marker_offset, ypoint, xpoint + 5.0, ypoint - 5.0);
- }
-
- } else {
- // default to fixed
- fixed(-marker_offset + scrn_rect.left, text_y + scrn_rect.right / 6,
- -marker_offset + marker_xe, text_y,-marker_offset + scrn_rect.left,
- text_y - scrn_rect.right / 6);
- }
- } //if pointer
- } //end vertical/right
-
- // At this point marker x_start and x_end values are transposed.
- // To keep this from confusing things they are now interchanged.
- if (huds_both(options)) {
- marker_ye = marker_xs;
- marker_xs = marker_xe;
- marker_xe = marker_ye;
- }
-
- // Work through from bottom to top of scale. Calculating where to put
- // minor and major ticks.
-
- // draw scale or tape
-
-// last = float_to_int(vmax)+1;
-// i = float_to_int(vmin);
- last = (int)vmax + 1; // N
- i = (int)vmin; // N
-
- if (zoom == 1) {
- zoomed_scale((int)vmin, (int)vmax);
- } else {
- for (; i < last; i++) {
- condition = true;
- if (!modulo() && i < min_val())
- condition = false;
-
- if (condition) { // Show a tick if necessary
- // Calculate the location of this tick
- marker_ys = scrn_rect.top + ((i - vmin) * factor()/*+.5f*/);
- // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
- // Block calculation artifact from drawing ticks below min coordinate.
- // Calculation here accounts for text height.
-
- if ((marker_ys < (scrn_rect.top + 4))
- || (marker_ys > (height - 4))) {
- // Magic numbers!!!
- continue;
- }
-
- if (oddtype == 1)
- k = i + 1; //enable ticks at odd values
- else
- k = i;
-
- bool major_tick_drawn = false;
-
- // Major ticks
- if (div_max()) {
- if (!(k % (int)div_max())) {
- major_tick_drawn = true;
- if (modulo()) {
- disp_val = i % (int) modulo(); // ?????????
- if (disp_val < 0) {
- while (disp_val < 0)
- disp_val += modulo();
- }
- } else {
- disp_val = i;
- }
-
- lenstr = sprintf(TextScale, "%d",
- float_to_int(disp_val * data_scaling()/*+.5*/));
- // (int)(disp_val * data_scaling() +.5));
- /* if (((marker_ys - 8) > scrn_rect.top) &&
- ((marker_ys + 8) < (height))){ */
- // huds_both
- if (huds_both(options)) {
- // drawOneLine(scrn_rect.left, marker_ys,
- // marker_xs, marker_ys);
- // drawOneLine(marker_xs, marker_ys,
- // scrn_rect.left + scrn_rect.right,
- // marker_ys);
- if (tick_type == "line") {
- glBegin(GL_LINE_STRIP);
- glVertex2f(scrn_rect.left, marker_ys);
- glVertex2f(marker_xs, marker_ys);
- glVertex2f(width, marker_ys);
- glEnd();
-
- } else if (tick_type == "circle") {
- circles(scrn_rect.left, (float)marker_ys, 5.0);
-
- } else {
- glBegin(GL_LINE_STRIP);
- glVertex2f(scrn_rect.left, marker_ys);
- glVertex2f(marker_xs, marker_ys);
- glVertex2f(width, marker_ys);
- glEnd();
- }
-
- if (!huds_notext(options))
- textString (marker_xs + 2, marker_ys, TextScale, 0);
-
- } else {
- /* Changes are made to draw a circle when tick_type="circle" */
- // anything other than huds_both
- if (tick_type == "line")
- drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
- else if (tick_type == "circle")
- circles((float)marker_xs + 4, (float)marker_ys, 5.0);
- else
- drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
-
- if (!huds_notext(options)) {
- if (huds_left(options)) {
- textString(marker_xs - 8 * lenstr - 2,
- marker_ys - 4, TextScale, 0);
- } else {
- textString(marker_xe + 3 * lenstr,
- marker_ys - 4, TextScale, 0);
- } //End if huds_left
- } //End if !huds_notext
- } //End if huds-both
- } // End if draw major ticks
- } // End if major ticks
-
- // Minor ticks
- if (div_min() && !major_tick_drawn) {
- // if ((i % div_min()) == 0) {
- if (!(k % (int)div_min())) {
- if (((marker_ys - 5) > scrn_rect.top)
- && ((marker_ys + 5) < (height))) {
-
- //vertical/left OR vertical/right
- if (huds_both(options)) {
- if (tick_type == "line") {
- if (tick_length == "variable") {
- drawOneLine(scrn_rect.left, marker_ys,
- marker_xs, marker_ys);
- drawOneLine(marker_xe, marker_ys,
- width, marker_ys);
- } else {
- drawOneLine(scrn_rect.left, marker_ys,
- marker_xs, marker_ys);
- drawOneLine(marker_xe, marker_ys,
- width, marker_ys);
- }
-
- } else if (tick_type == "circle") {
- circles(scrn_rect.left,(float)marker_ys, 3.0);
-
- } else {
- // if neither line nor circle draw default as line
- drawOneLine(scrn_rect.left, marker_ys,
- marker_xs, marker_ys);
- drawOneLine(marker_xe, marker_ys,
- width, marker_ys);
- }
- // glBegin(GL_LINES);
- // glVertex2f(scrn_rect.left, marker_ys);
- // glVertex2f(marker_xs, marker_ys);
- // glVertex2f(marker_xe, marker_ys);
- // glVertex2f(scrn_rect.left + scrn_rect.right, marker_ys);
- // glEnd();
- // anything other than huds_both
-
- } else {
- if (huds_left(options)) {
- if (tick_type == "line") {
- if (tick_length == "variable") {
- drawOneLine(marker_xs + 4, marker_ys,
- marker_xe, marker_ys);
- } else {
- drawOneLine(marker_xs, marker_ys,
- marker_xe, marker_ys);
- }
- } else if (tick_type == "circle") {
- circles((float)marker_xs + 4, (float)marker_ys, 3.0);
-
- } else {
- drawOneLine(marker_xs + 4, marker_ys,
- marker_xe, marker_ys);
- }
-
- } else {
- if (tick_type == "line") {
- if (tick_length == "variable") {
- drawOneLine(marker_xs, marker_ys,
- marker_xe - 4, marker_ys);
- } else {
- drawOneLine(marker_xs, marker_ys,
- marker_xe, marker_ys);
- }
-
- } else if (tick_type == "circle") {
- circles((float)marker_xe - 4, (float)marker_ys, 3.0);
- } else {
- drawOneLine(marker_xs, marker_ys,
- marker_xe - 4, marker_ys);
- }
- }
- } //end huds both
- }
- } //end draw minor ticks
- } //end minor ticks
-
- } // End condition
- } // End for
- } //end of zoom
- // End if VERTICAL SCALE TYPE (tape loop yet to be closed)
-
- } else {
- // Horizontal scale by default
- // left tick bar
- if (draw_tick_left)
- drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, height);
-
- // right tick bar
- if (draw_tick_right)
- drawOneLine(width, scrn_rect.top, width, height);
-
- marker_ys = scrn_rect.top; // Starting point for
- marker_ye = height; // tick y location calcs
- marker_xe = width;
- marker_xs = scrn_rect.left + ((cur_value - vmin) * factor() /*+ .5f*/);
-
- // glBegin(GL_LINES);
- // left tick bar
- // glVertex2f(scrn_rect.left, scrn_rect.top);
- // glVertex2f(scrn_rect.left, marker_ye);
-
- // right tick bar
- // glVertex2f(marker_xe, scrn_rect.top);
- // glVertex2f(marker_xe, marker_ye);
- // glEnd();
-
- if (huds_top(options)) {
- // Bottom box line
- if (draw_cap_bottom)
- drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
-
- // Tick point adjust
- marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
- // Bottom arrow
- // drawOneLine(mid_scr.x, marker_ye,
- // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
- // drawOneLine(mid_scr.x, marker_ye,
- // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
- // draw pointer
- if (pointer) {
- if (pointer_type == "moving") {
- if (zoom == 0) {
- //Code for Moving Type Pointer
- // static float xcentre, xpoint, ypoint;
- // static int range;
- if (cur_value > maxValue)
- cur_value = maxValue;
- if (cur_value < minValue)
- cur_value = minValue;
-
- float xcentre = mid_scr.x;
- int range = scrn_rect.right;
- float xpoint = xcentre + (cur_value * range / val_span);
- float ypoint = scrn_rect.top - marker_offset;
- drawOneLine(xcentre, ypoint, xpoint, ypoint);
- drawOneLine(xpoint, ypoint, xpoint, ypoint + marker_offset);
- drawOneLine(xpoint, ypoint + marker_offset, xpoint + 5.0, ypoint + 5.0);
- drawOneLine(xpoint, ypoint + marker_offset, xpoint - 5.0, ypoint + 5.0);
- }
-
- } else {
- //default to fixed
- fixed(marker_xs - scrn_rect.bottom / 4, scrn_rect.top, marker_xs,
- marker_ye, marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
- }
- } //if pointer
- } //End Horizontal scale/top
-
- if (huds_bottom(options)) {
- // Top box line
- if (draw_cap_top)
- drawOneLine(scrn_rect.left, height, width, height);
-
- // Tick point adjust
- marker_ys = height - scrn_rect.bottom / 2;
- // Top arrow
- // drawOneLine(mid_scr.x + scrn_rect.bottom / 4,
- // scrn_rect.top + scrn_rect.bottom,
- // mid_scr.x, marker_ys);
- // drawOneLine(mid_scr.x - scrn_rect.bottom / 4,
- // scrn_rect.top + scrn_rect.bottom,
- // mid_scr.x , marker_ys);
-
- // draw pointer
- if (pointer) {
- if (pointer_type == "moving") {
- if (zoom == 0) {
- //Code for Moving Type Pointer
- // static float xcentre, xpoint, ypoint;
- // static int range, hgt;
- if (cur_value > maxValue)
- cur_value = maxValue;
- if (cur_value < minValue)
- cur_value = minValue;
-
- float xcentre = mid_scr.x ;
- int range = scrn_rect.right;
- int hgt = scrn_rect.top + scrn_rect.bottom;
- float xpoint = xcentre + (cur_value * range / val_span);
- float ypoint = hgt + marker_offset;
- drawOneLine(xcentre, ypoint, xpoint, ypoint);
- drawOneLine(xpoint, ypoint, xpoint, ypoint - marker_offset);
- drawOneLine(xpoint, ypoint - marker_offset, xpoint + 5.0, ypoint - 5.0);
- drawOneLine(xpoint, ypoint - marker_offset, xpoint - 5.0, ypoint - 5.0);
- }
- } else {
- fixed(marker_xs + scrn_rect.bottom / 4, height, marker_xs, marker_ys,
- marker_xs - scrn_rect.bottom / 4, height);
- }
- } //if pointer
- } //end horizontal scale bottom
-
- // if ((options & HUDS_BOTTOM) == HUDS_BOTTOM) {
- // marker_xe = marker_ys;
- // marker_ys = marker_ye;
- // marker_ye = marker_xe;
- // }
-
- // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
-
- // last = float_to_int(vmax)+1;
- // i = float_to_int(vmin);
-
- if (zoom == 1) {
- zoomed_scale((int)vmin,(int)vmax);
- } else {
- //default to zoom=0
- last = (int)vmax + 1;
- i = (int)vmin;
- for (; i < last; i++) {
- // for (i = (int)vmin; i <= (int)vmax; i++) {
- // printf("<*> i = %d\n", i);
- condition = true;
- if (!modulo() && i < min_val())
- condition = false;
-
- // printf("<**> i = %d\n", i);
- if (condition) {
- // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
- marker_xs = scrn_rect.left + (((i - vmin) * factor()/*+ .5f*/));
-
- if (oddtype == 1)
- k = i + 1; //enable ticks at odd values
- else
- k = i;
-
- bool major_tick_drawn = false;
-
- //major ticks
- if (div_max()) {
- // printf("i = %d\n", i);
- // if ((i % (int)div_max())==0) {
- // draw major ticks
-
- if (!(k % (int)div_max())) {
- major_tick_drawn = true;
- if (modulo()) {
- disp_val = i % (int) modulo(); // ?????????
- if (disp_val < 0) {
- while (disp_val<0)
- disp_val += modulo();
- }
- } else {
- disp_val = i;
- }
- // printf("disp_val = %d\n", disp_val);
- // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
- lenstr = sprintf(TextScale, "%d",
- // (int)(disp_val * data_scaling() +.5));
- float_to_int(disp_val * data_scaling()/*+.5*/));
-
- // Draw major ticks and text only if far enough from the edge.
- if (((marker_xs - 10)> scrn_rect.left)
- && ((marker_xs + 10) < (scrn_rect.left + scrn_rect.right))) {
- if (huds_both(options)) {
- // drawOneLine(marker_xs, scrn_rect.top,
- // marker_xs, marker_ys);
- // drawOneLine(marker_xs, marker_ye,
- // marker_xs, scrn_rect.top + scrn_rect.bottom);
- glBegin(GL_LINE_STRIP);
- glVertex2f(marker_xs, scrn_rect.top);
- glVertex2f(marker_xs, marker_ye);
- glVertex2f(marker_xs, height);
- glEnd();
-
- if (!huds_notext(options)) {
- textString(marker_xs - 4 * lenstr,
- marker_ys + 4, TextScale, 0);
- }
- } else {
- drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
-
- if (!huds_notext(options)) {
- if (huds_top(options)) {
- textString(marker_xs - 4 * lenstr,
- height - 10, TextScale, 0);
-
- } else {
- textString(marker_xs - 4 * lenstr,
- scrn_rect.top, TextScale, 0);
- }
- }
- }
- }
- } //end draw major ticks
- } //endif major ticks
-
- if (div_min() && !major_tick_drawn) {
- // if ((i % (int)div_min()) == 0) {
- //draw minor ticks
- if (!(k % (int)div_min())) {
- // draw in ticks only if they aren't too close to the edge.
- if (((marker_xs - 5) > scrn_rect.left)
- && ((marker_xs + 5)< (scrn_rect.left + scrn_rect.right))) {
-
- if (huds_both(options)) {
- if (tick_length == "variable") {
- drawOneLine(marker_xs, scrn_rect.top,
- marker_xs, marker_ys - 4);
- drawOneLine(marker_xs, marker_ye + 4,
- marker_xs, height);
- } else {
- drawOneLine(marker_xs, scrn_rect.top,
- marker_xs, marker_ys);
- drawOneLine(marker_xs, marker_ye,
- marker_xs, height);
- }
- // glBegin(GL_LINES);
- // glVertex2f(marker_xs, scrn_rect.top);
- // glVertex2f(marker_xs, marker_ys - 4);
- // glVertex2f(marker_xs, marker_ye + 4);
- // glVertex2f(marker_xs, scrn_rect.top + scrn_rect.bottom);
- // glEnd();
-
- } else {
- if (huds_top(options)) {
- //draw minor ticks
- if (tick_length == "variable")
- drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye - 4);
- else
- drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
-
- } else if (tick_length == "variable") {
- drawOneLine(marker_xs, marker_ys + 4, marker_xs, marker_ye);
- } else {
- drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
- }
- }
- }
- } //end draw minor ticks
- } //end minor ticks
-
- } //end condition
- } //end for
- } //end zoom
- } //end horizontal/vertical scale
- } // end of type tape
-} //draw
-
-
-
-void hud_card::circles(float x, float y, float size)
-{
- glEnable(GL_POINT_SMOOTH);
- glPointSize(size);
-
- glBegin(GL_POINTS);
- glVertex2f(x, y);
- glEnd();
-
- glPointSize(1.0);
- glDisable(GL_POINT_SMOOTH);
-}
-
-
-void hud_card::fixed(float x1, float y1, float x2, float y2, float x3, float y3)
-{
- glBegin(GL_LINE_STRIP);
- glVertex2f(x1, y1);
- glVertex2f(x2, y2);
- glVertex2f(x3, y3);
- glEnd();
-}
-
-
-void hud_card::zoomed_scale(int first, int last)
-{
- POINT mid_scr = get_centroid();
- RECT scrn_rect = get_location();
- UINT options = get_options();
- char TextScale[80];
- int data[80];
-
- float x, y, w, h, bottom;
- float cur_value = get_value();
- if (cur_value > maxValue)
- cur_value = maxValue;
- if (cur_value < minValue)
- cur_value = minValue;
-
- int a = 0;
-
- while (first <= last) {
- if ((first % (int)Maj_div) == 0) {
- data[a] = first;
- a++ ;
- }
- first++;
- }
- int centre = a / 2;
-
- if (huds_vert(options)) {
- x = scrn_rect.left;
- y = scrn_rect.top;
- w = scrn_rect.left + scrn_rect.right;
- h = scrn_rect.top + scrn_rect.bottom;
- bottom = scrn_rect.bottom;
-
- float xstart, yfirst, ycentre, ysecond;
-
- float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
- yfirst = mid_scr.y - hgt;
- ycentre = mid_scr.y;
- ysecond = mid_scr.y + hgt;
- float range = hgt * 2;
-
- int i;
- float factor = range / 10.0;
-
- float hgt1 = bottom * 30.0 / 100.0;
- int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
- int incr = incrs / 2;
- float factors = hgt1 / incr;
-
- // begin
- //this is for moving type pointer
- static float ycent, ypoint, xpoint;
- static int wth;
-
- ycent = mid_scr.y;
- wth = scrn_rect.left + scrn_rect.right;
-
- if (cur_value <= data[centre + 1])
- if (cur_value > data[centre]) {
- ypoint = ycent + ((cur_value - data[centre]) * hgt / Maj_div);
- }
-
- if (cur_value >= data[centre - 1])
- if (cur_value <= data[centre]) {
- ypoint = ycent - ((data[centre]-cur_value) * hgt / Maj_div);
- }
-
- if (cur_value < data[centre - 1])
- if (cur_value >= minValue) {
- float diff = minValue - data[centre - 1];
- float diff1 = cur_value - data[centre - 1];
- float val = (diff1 * hgt1) / diff;
-
- ypoint = ycent - hgt - val;
- }
-
- if (cur_value > data[centre + 1])
- if (cur_value <= maxValue) {
- float diff = maxValue - data[centre + 1];
- float diff1 = cur_value - data[centre + 1];
- float val = (diff1 * hgt1) / diff;
-
- ypoint = ycent + hgt + val;
- }
-
- if (huds_left(options)) {
- xstart = w;
-
- drawOneLine(xstart, ycentre, xstart - 5.0, ycentre); //centre tick
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
-
- if (!huds_notext(options))
- textString(x, ycentre, TextScale, 0);
-
- for (i = 1; i < 5; i++) {
- yfirst += factor;
- ycentre += factor;
- circles(xstart - 2.5, yfirst, 3.0);
- circles(xstart - 2.5, ycentre, 3.0);
- }
-
- yfirst = mid_scr.y - hgt;
-
- for (i = 0; i <= incr; i++) {
- drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
- drawOneLine(xstart, ysecond, xstart - 5.0, ysecond);
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
-
- if (!huds_notext(options))
- textString (x, yfirst, TextScale, 0);
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
-
- if (!huds_notext(options))
- textString (x, ysecond, TextScale, 0);
-
- yfirst -= factors;
- ysecond += factors;
-
- }
-
- //to draw moving type pointer for left option
- //begin
- xpoint = wth + 10.0;
-
- if (pointer_type == "moving") {
- drawOneLine(xpoint, ycent, xpoint, ypoint);
- drawOneLine(xpoint, ypoint, xpoint - 10.0, ypoint);
- drawOneLine(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint + 5.0);
- drawOneLine(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint - 5.0);
- }
- //end
-
- } else {
- //huds_right
- xstart = (x + w) / 2;
-
- drawOneLine(xstart, ycentre, xstart + 5.0, ycentre); //centre tick
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
-
- if (!huds_notext(options))
- textString(w, ycentre, TextScale, 0);
-
- for (i = 1; i < 5; i++) {
- yfirst += factor;
- ycentre += factor;
- circles(xstart + 2.5, yfirst, 3.0);
- circles(xstart + 2.5, ycentre, 3.0);
- }
-
- yfirst = mid_scr.y - hgt;
-
- for (i = 0; i <= incr; i++) {
- drawOneLine(xstart, yfirst, xstart + 5.0, yfirst);
- drawOneLine(xstart, ysecond, xstart + 5.0, ysecond);
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
-
- if (!huds_notext(options))
- textString(w, yfirst, TextScale, 0);
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
-
- if (!huds_notext(options))
- textString(w, ysecond, TextScale, 0);
-
- yfirst -= factors;
- ysecond += factors;
-
- }
-
- // to draw moving type pointer for right option
- //begin
- xpoint = scrn_rect.left;
-
- if (pointer_type == "moving") {
- drawOneLine(xpoint, ycent, xpoint, ypoint);
- drawOneLine(xpoint, ypoint, xpoint + 10.0, ypoint);
- drawOneLine(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint + 5.0);
- drawOneLine(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint - 5.0);
- }
- //end
- }//end huds_right /left
- //end of vertical scale
-
- } else {
- //horizontal scale
- x = scrn_rect.left;
- y = scrn_rect.top;
- w = scrn_rect.left + scrn_rect.right;
- h = scrn_rect.top + scrn_rect.bottom;
- bottom = scrn_rect.right;
-
- float ystart, xfirst, xcentre, xsecond;
-
- float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
- xfirst = mid_scr.x - hgt;
- xcentre = mid_scr.x;
- xsecond = mid_scr.x + hgt;
- float range = hgt * 2;
-
- int i;
- float factor = range / 10.0;
-
- float hgt1 = bottom * 30.0 / 100.0;
- int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
- int incr = incrs / 2;
- float factors = hgt1 / incr;
-
-
- //Code for Moving Type Pointer
- //begin
- static float xcent, xpoint, ypoint;
-
- xcent = mid_scr.x;
-
- if (cur_value <= data[centre + 1])
- if (cur_value > data[centre]) {
- xpoint = xcent + ((cur_value - data[centre]) * hgt / Maj_div);
- }
-
- if (cur_value >= data[centre - 1])
- if (cur_value <= data[centre]) {
- xpoint = xcent - ((data[centre]-cur_value) * hgt / Maj_div);
- }
-
- if (cur_value < data[centre - 1])
- if (cur_value >= minValue) {
- float diff = minValue - data[centre - 1];
- float diff1 = cur_value - data[centre - 1];
- float val = (diff1 * hgt1) / diff;
-
- xpoint = xcent - hgt - val;
- }
-
-
- if (cur_value > data[centre + 1])
- if (cur_value <= maxValue) {
- float diff = maxValue - data[centre + 1];
- float diff1 = cur_value - data[centre + 1];
- float val = (diff1 * hgt1) / diff;
-
- xpoint = xcent + hgt + val;
- }
-
- //end
- if (huds_top(options)) {
- ystart = h;
- drawOneLine(xcentre, ystart, xcentre, ystart - 5.0); //centre tick
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
-
- if (!huds_notext(options))
- textString (xcentre - 10.0, y, TextScale, 0);
-
- for (i = 1; i < 5; i++) {
- xfirst += factor;
- xcentre += factor;
- circles(xfirst, ystart - 2.5, 3.0);
- circles(xcentre, ystart - 2.5, 3.0);
- }
-
- xfirst = mid_scr.x - hgt;
-
- for (i = 0; i <= incr; i++) {
- drawOneLine(xfirst, ystart, xfirst, ystart - 5.0);
- drawOneLine(xsecond, ystart, xsecond, ystart - 5.0);
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
-
- if (!huds_notext(options))
- textString (xfirst - 10.0, y, TextScale, 0);
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
-
- if (!huds_notext(options))
- textString (xsecond - 10.0, y, TextScale, 0);
-
-
- xfirst -= factors;
- xsecond += factors;
- }
- //this is for moving pointer for top option
- //begin
-
- ypoint = scrn_rect.top + scrn_rect.bottom + 10.0;
-
- if (pointer_type == "moving") {
- drawOneLine(xcent, ypoint, xpoint, ypoint);
- drawOneLine(xpoint, ypoint, xpoint, ypoint - 10.0);
- drawOneLine(xpoint, ypoint - 10.0, xpoint + 5.0, ypoint - 5.0);
- drawOneLine(xpoint, ypoint - 10.0, xpoint - 5.0, ypoint - 5.0);
- }
- //end of top option
-
- } else {
- //else huds_bottom
- ystart = (y + h) / 2;
-
- //drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
- drawOneLine(xcentre, ystart, xcentre, ystart + 5.0); //centre tick
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
-
- if (!huds_notext(options))
- textString (xcentre - 10.0, h, TextScale, 0);
-
- for (i = 1; i < 5; i++) {
- xfirst += factor;
- xcentre += factor;
- circles(xfirst, ystart + 2.5, 3.0);
- circles(xcentre, ystart + 2.5, 3.0);
- }
-
- xfirst = mid_scr.x - hgt;
-
- for (i = 0; i <= incr; i++) {
- drawOneLine(xfirst, ystart, xfirst, ystart + 5.0);
- drawOneLine(xsecond, ystart, xsecond, ystart + 5.0);
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
-
- if (!huds_notext(options))
- textString (xfirst - 10.0, h, TextScale, 0);
-
- sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
-
- if (!huds_notext(options))
- textString (xsecond - 10.0, h, TextScale, 0);
-
- xfirst -= factors;
- xsecond += factors;
- }
- //this is for movimg pointer for bottom option
- //begin
-
- ypoint = scrn_rect.top - 10.0;
- if (pointer_type == "moving") {
- drawOneLine(xcent, ypoint, xpoint, ypoint);
- drawOneLine(xpoint, ypoint, xpoint, ypoint + 10.0);
- drawOneLine(xpoint, ypoint + 10.0, xpoint + 5.0, ypoint + 5.0);
- drawOneLine(xpoint, ypoint + 10.0, xpoint - 5.0, ypoint + 5.0);
- }
- }//end hud_top or hud_bottom
- } //end of horizontal/vertical scales
-}//end draw
-
-
diff --git a/src/Cockpit/hud_dnst.cxx b/src/Cockpit/hud_dnst.cxx
deleted file mode 100644
index 9dbb190f4..000000000
--- a/src/Cockpit/hud_dnst.cxx
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "hud.hxx"
-
-
-dual_instr_item::dual_instr_item(
- int x,
- int y,
- UINT width,
- UINT height,
- FLTFNPTR chn1_source,
- FLTFNPTR chn2_source,
- bool working,
- UINT options) :
- instr_item(x, y, width, height,
- chn1_source, 1, options, working),
- alt_data_source(chn2_source)
-{
-}
-
-
diff --git a/src/Cockpit/hud_gaug.cxx b/src/Cockpit/hud_gaug.cxx
deleted file mode 100644
index 7a4d5ce6f..000000000
--- a/src/Cockpit/hud_gaug.cxx
+++ /dev/null
@@ -1,293 +0,0 @@
-#include "hud.hxx"
-
-#ifdef USE_HUD_TextList
-#define textString(x, y, text, digit) TextString(text, x , y ,digit)
-#else
-#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
-#endif
-
-FLTFNPTR get_func(const char *name); // FIXME
-
-gauge_instr::gauge_instr(const SGPropertyNode *node) :
- instr_scale(
- node->getIntValue("x"),
- node->getIntValue("y"),
- node->getIntValue("width"),
- node->getIntValue("height"),
- 0 /*load_fn*/,
- node->getIntValue("options"),
- node->getFloatValue("maxValue") - node->getFloatValue("minValue"), // Always shows span?
- node->getFloatValue("maxValue"),
- node->getFloatValue("minValue"),
- node->getFloatValue("disp_scaling"),
- node->getIntValue("major_divs"),
- node->getIntValue("minor_divs"),
- node->getIntValue("modulator"), // "rollover"
- 0, /* hud.cxx: static int dp_shoing = 0; */ // FIXME
- node->getBoolValue("working", true))
-{
- SG_LOG(SG_INPUT, SG_BULK, "Done reading gauge instrument "
- << node->getStringValue("name", "[unnamed]"));
-
- set_data_source(get_func(node->getStringValue("loadfn")));
-}
-
-
-// As implemented, draw only correctly draws a horizontal or vertical
-// scale. It should contain a variation that permits clock type displays.
-// Now is supports "tickless" displays such as control surface indicators.
-// This routine should be worked over before using. Current value would be
-// fetched and not used if not commented out. Clearly that is intollerable.
-
-void gauge_instr::draw(void)
-{
- float marker_xs, marker_xe;
- float marker_ys, marker_ye;
- int text_x, text_y;
- int width, height, bottom_4;
- int lenstr;
- int i;
- char TextScale[80];
- bool condition;
- int disp_val = 0;
- float vmin = min_val();
- float vmax = max_val();
- POINT mid_scr = get_centroid();
- float cur_value = get_value();
- RECT scrn_rect = get_location();
- UINT options = get_options();
-
- width = scrn_rect.left + scrn_rect.right;
- height = scrn_rect.top + scrn_rect.bottom;
- bottom_4 = scrn_rect.bottom / 4;
-
- // Draw the basic markings for the scale...
- if (huds_vert(options)) { // Vertical scale
- // Bottom tick bar
- drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
-
- // Top tick bar
- drawOneLine( scrn_rect.left, height, width, height);
-
- marker_xs = scrn_rect.left;
- marker_xe = width;
-
- if (huds_left(options)) { // Read left, so line down right side
- drawOneLine(width, scrn_rect.top, width, height);
- marker_xs = marker_xe - scrn_rect.right / 3.0; // Adjust tick
- }
-
- if (huds_right(options)) { // Read right, so down left sides
- drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, height);
- marker_xe = scrn_rect.left + scrn_rect.right / 3.0; // Adjust tick
- }
-
- // At this point marker x_start and x_end values are transposed.
- // To keep this from confusing things they are now interchanged.
- if (huds_both(options)) {
- marker_ye = marker_xs;
- marker_xs = marker_xe;
- marker_xe = marker_ye;
- }
-
- // Work through from bottom to top of scale. Calculating where to put
- // minor and major ticks.
-
- if (!huds_noticks(options)) { // If not no ticks...:)
- // Calculate x marker offsets
- int last = (int)vmax + 1; // float_to_int(vmax)+1;
- i = (int)vmin; //float_to_int(vmin);
-
- for (; i < last; i++) {
- // Calculate the location of this tick
- marker_ys = scrn_rect.top + (i - vmin) * factor()/* +.5f*/;
-
- // We compute marker_ys even though we don't know if we will use
- // either major or minor divisions. Simpler.
-
- if (div_min()) { // Minor tick marks
- if (!(i % (int)div_min())) {
- if (huds_left(options) && huds_right(options)) {
- drawOneLine(scrn_rect.left, marker_ys, marker_xs - 3, marker_ys);
- drawOneLine(marker_xe + 3, marker_ys, width, marker_ys);
-
- } else if (huds_left(options)) {
- drawOneLine(marker_xs + 3, marker_ys, marker_xe, marker_ys);
- } else {
- drawOneLine(marker_xs, marker_ys, marker_xe - 3, marker_ys);
- }
- }
- }
-
- // Now we work on the major divisions. Since these are also labeled
- // and no labels are drawn otherwise, we label inside this if
- // statement.
-
- if (div_max()) { // Major tick mark
- if (!(i % (int)div_max())) {
- if (huds_left(options) && huds_right(options)) {
- drawOneLine(scrn_rect.left, marker_ys, marker_xs, marker_ys);
- drawOneLine(marker_xe, marker_ys, width, marker_ys);
- } else {
- drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
- }
-
- if (!huds_notext(options)) {
- disp_val = i;
- sprintf(TextScale, "%d",
- float_to_int(disp_val * data_scaling()/*+.5*/));
-
- lenstr = getStringWidth(TextScale);
-
- if (huds_left(options) && huds_right(options)) {
- text_x = mid_scr.x - lenstr/2 ;
-
- } else if (huds_left(options)) {
- text_x = float_to_int(marker_xs - lenstr);
- } else {
- text_x = float_to_int(marker_xe - lenstr);
- }
- // Now we know where to put the text.
- text_y = float_to_int(marker_ys);
- textString(text_x, text_y, TextScale, 0);
- }
- }
- }
- }
- }
-
- // Now that the scale is drawn, we draw in the pointer(s). Since labels
- // have been drawn, text_x and text_y may be recycled. This is used
- // with the marker start stops to produce a pointer for each side reading
-
- text_y = scrn_rect.top + float_to_int((cur_value - vmin) * factor() /*+.5f*/);
- // text_x = marker_xs - scrn_rect.left;
-
- if (huds_right(options)) {
- glBegin(GL_LINE_STRIP);
- glVertex2f(scrn_rect.left, text_y + 5);
- glVertex2f(float_to_int(marker_xe), text_y);
- glVertex2f(scrn_rect.left, text_y - 5);
- glEnd();
- }
- if (huds_left(options)) {
- glBegin(GL_LINE_STRIP);
- glVertex2f(width, text_y + 5);
- glVertex2f(float_to_int(marker_xs), text_y);
- glVertex2f(width, text_y - 5);
- glEnd();
- }
- // End if VERTICAL SCALE TYPE
-
- } else { // Horizontal scale by default
- // left tick bar
- drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, height);
-
- // right tick bar
- drawOneLine(width, scrn_rect.top, width, height );
-
- marker_ys = scrn_rect.top; // Starting point for
- marker_ye = height; // tick y location calcs
- marker_xs = scrn_rect.left + (cur_value - vmin) * factor() /*+ .5f*/;
-
- if (huds_top(options)) {
- // Bottom box line
- drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
-
- marker_ye = scrn_rect.top + scrn_rect.bottom / 2.0; // Tick point adjust
- // Bottom arrow
- glBegin(GL_LINE_STRIP);
- glVertex2f(marker_xs - bottom_4, scrn_rect.top);
- glVertex2f(marker_xs, marker_ye);
- glVertex2f(marker_xs + bottom_4, scrn_rect.top);
- glEnd();
- }
-
- if (huds_bottom(options)) {
- // Top box line
- drawOneLine(scrn_rect.left, height, width, height);
- // Tick point adjust
- marker_ys = height - scrn_rect.bottom / 2.0;
-
- // Top arrow
- glBegin(GL_LINE_STRIP);
- glVertex2f(marker_xs + bottom_4, height);
- glVertex2f(marker_xs, marker_ys );
- glVertex2f(marker_xs - bottom_4, height);
- glEnd();
- }
-
-
- int last = (int)vmax + 1; //float_to_int(vmax)+1;
- i = (int)vmin; //float_to_int(vmin);
- for (; i scrn_rect.left)
- || ((marker_xs - 5) < (width))) {
-
- if (huds_both(options)) {
- drawOneLine(marker_xs, scrn_rect.top, marker_xs, marker_ys - 4);
- drawOneLine(marker_xs, marker_ye + 4, marker_xs, height);
-
- } else if (huds_top(options)) {
- drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye - 4);
- } else {
- drawOneLine(marker_xs, marker_ys + 4, marker_xs, marker_ye);
- }
- }
- }
- }
-
- if (div_max()) {
- if (!(i % (int)div_max())) {
- if (modulo()) {
- if (disp_val < 0) {
- while (disp_val < 0)
- disp_val += modulo();
- }
- disp_val = i % (int)modulo();
- } else {
- disp_val = i;
- }
- sprintf(TextScale, "%d",
- float_to_int(disp_val * data_scaling()/* +.5*/));
- lenstr = getStringWidth(TextScale);
-
- // Draw major ticks and text only if far enough from the edge.
- if (((marker_xs - 10) > scrn_rect.left)
- && ((marker_xs + 10) < width)) {
- if (huds_both(options)) {
- drawOneLine(marker_xs, scrn_rect.top, marker_xs, marker_ys);
- drawOneLine(marker_xs, marker_ye, marker_xs, height);
-
- if (!huds_notext(options))
- textString(marker_xs - lenstr, marker_ys + 4, TextScale, 0);
-
- } else {
- drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
-
- if (!huds_notext(options)) {
- if (huds_top(options))
- textString(marker_xs - lenstr, height - 10, TextScale, 0);
- else
- textString(marker_xs - lenstr, scrn_rect.top, TextScale, 0);
- }
- }
- }
- }
- }
- }
- }
- }
-}
-
-
diff --git a/src/Cockpit/hud_inst.cxx b/src/Cockpit/hud_inst.cxx
deleted file mode 100644
index 8f897b594..000000000
--- a/src/Cockpit/hud_inst.cxx
+++ /dev/null
@@ -1,93 +0,0 @@
-
-#include "hud.hxx"
-
-
-UINT instr_item :: instances = 0; // Initial value of zero
-int instr_item :: brightness = 5;/*HUD_BRT_MEDIUM*/
-//glRGBTRIPLE instr_item :: color = {0.1, 0.7, 0.0};
-glRGBTRIPLE instr_item :: color = {0.0, 1.0, 0.0};
-
-// constructor ( No default provided )
-instr_item::instr_item(
- int x,
- int y,
- UINT width,
- UINT height,
- FLTFNPTR data_source,
- float data_scaling,
- UINT options,
- bool working,
- int digit) :
- handle ( ++instances ),
- load_value_fn ( data_source ),
- disp_factor ( data_scaling ),
- opts ( options ),
- is_enabled ( working ),
- broken ( FALSE ),
- digits ( digit )
-{
- scrn_pos.left = x;
- scrn_pos.top = y;
- scrn_pos.right = width;
- scrn_pos.bottom = height;
-
- // Set up convenience values for centroid of the box and
- // the span values according to orientation
-
- if (opts & HUDS_VERT) { // Vertical style
- // Insure that the midpoint marker will fall exactly at the
- // middle of the bar.
- if (!(scrn_pos.bottom % 2))
- scrn_pos.bottom++;
-
- scr_span = scrn_pos.bottom;
-
- } else {
- // Insure that the midpoint marker will fall exactly at the
- // middle of the bar.
- if (!(scrn_pos.right % 2))
- scrn_pos.right++;
-
- scr_span = scrn_pos.right;
- }
-
- // Here we work out the centroid for the corrected box.
- mid_span.x = scrn_pos.left + (scrn_pos.right >> 1);
- mid_span.y = scrn_pos.top + (scrn_pos.bottom >> 1);
-}
-
-
-instr_item::~instr_item ()
-{
- if (instances)
- instances--;
-}
-
-
-// break_display This is emplaced to provide hooks for making
-// instruments unreliable. The default behavior is
-// to simply not display, but more sophisticated behavior is available
-// by over riding the function which is virtual in this class.
-
-void instr_item::break_display ( bool bad )
-{
- broken = !!bad;
- is_enabled = FALSE;
-}
-
-
-void instr_item::SetBrightness ( int level )
-{
- brightness = level; // This is all we will do for now. Later the
- // brightness levels will be sensitive both to
- // the control knob and the outside light levels
- // to emulated night vision effects.
-}
-
-
-UINT instr_item::get_Handle( void )
-{
- return handle;
-}
-
-
diff --git a/src/Cockpit/hud_labl.cxx b/src/Cockpit/hud_labl.cxx
deleted file mode 100644
index 8927b113e..000000000
--- a/src/Cockpit/hud_labl.cxx
+++ /dev/null
@@ -1,145 +0,0 @@
-
-#ifdef HAVE_CONFIG_H
-# include
-#endif
-
-#include "hud.hxx"
-
-#ifdef USE_HUD_TextList
-#define textString(x, y, text, digit) TextString(text, x , y ,digit)
-#else
-#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
-#endif
-
-FLTFNPTR get_func(const char *name); // FIXME
-
-instr_label::instr_label(const SGPropertyNode *node) :
- instr_item(
- node->getIntValue("x"),
- node->getIntValue("y"),
- node->getIntValue("width"),
- node->getIntValue("height"),
- NULL /* node->getStringValue("data_source") */, // FIXME
- node->getFloatValue("scale_data"),
- node->getIntValue("options"),
- node->getBoolValue("working", true),
- node->getIntValue("digits")),
- pformat(node->getStringValue("label_format")),
- fontSize(fgGetInt("/sim/startup/xsize") > 1000 ? HUD_FONT_LARGE : HUD_FONT_SMALL), // FIXME
- blink(node->getIntValue("blinking")),
- lat(node->getBoolValue("latitude", false)),
- lon(node->getBoolValue("longitude", false)),
- lbox(node->getBoolValue("label_box", false)),
- lon_node(fgGetNode("/position/longitude-string", true)),
- lat_node(fgGetNode("/position/latitude-string", true))
-{
- SG_LOG(SG_INPUT, SG_BULK, "Done reading instr_label instrument "
- << node->getStringValue("name", "[unnamed]"));
-
- set_data_source(get_func(node->getStringValue("data_source")));
-
- int just = node->getIntValue("justification");
- if (just == 0)
- justify = LEFT_JUST;
- else if (just == 1)
- justify = CENTER_JUST;
- else if (just == 2)
- justify = RIGHT_JUST;
-
- string pre_str(node->getStringValue("pre_label_string"));
- if (pre_str== "NULL")
- pre_str.clear();
- else if (pre_str == "blank")
- pre_str = " ";
-
- const char *units = strcmp(fgGetString("/sim/startup/units"), "feet") ? " m" : " ft"; // FIXME
-
- string post_str(node->getStringValue("post_label_string"));
- if (post_str== "NULL")
- post_str.clear();
- else if (post_str == "blank")
- post_str = " ";
- else if (post_str == "units")
- post_str = units;
-
- format_buffer = pre_str + pformat;
- format_buffer += post_str;
-}
-
-
-void instr_label::draw(void)
-{
- char label_buffer[80];
- int posincr;
- int lenstr;
- RECT scrn_rect = get_location();
-
- memset( label_buffer, 0, sizeof( label_buffer));
- if (data_available()) {
- if (lat)
- snprintf(label_buffer, sizeof( label_buffer)-1, format_buffer.c_str(), lat_node->getStringValue());
- else if (lon)
- snprintf(label_buffer, sizeof( label_buffer)-1, format_buffer.c_str(), lon_node->getStringValue());
- else {
- if (lbox) {// Box for label
- float x = scrn_rect.left;
- float y = scrn_rect.top;
- float w = scrn_rect.right;
- float h = HUD_TextSize;
-
- glPushMatrix();
- glLoadIdentity();
-
- glBegin(GL_LINES);
- glVertex2f(x - 2.0, y - 2.0);
- glVertex2f(x + w + 2.0, y - 2.0);
- glVertex2f(x + w + 2.0, y + h + 2.0);
- glVertex2f(x - 2.0, y + h + 2.0);
- glEnd();
-
- glEnable(GL_LINE_STIPPLE);
- glLineStipple(1, 0xAAAA);
-
- glBegin(GL_LINES);
- glVertex2f(x + w + 2.0, y - 2.0);
- glVertex2f(x + w + 2.0, y + h + 2.0);
- glVertex2f(x - 2.0, y + h + 2.0);
- glVertex2f(x - 2.0, y - 2.0);
- glEnd();
-
- glDisable(GL_LINE_STIPPLE);
- glPopMatrix();
- }
- snprintf(label_buffer, sizeof(label_buffer)-1, format_buffer.c_str(), get_value() * data_scaling());
- }
-
- } else {
- snprintf(label_buffer, sizeof( label_buffer)-1, format_buffer.c_str(), 0);
- }
-
- lenstr = getStringWidth(label_buffer);
-
-#ifdef DEBUGHUD
- fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer);
- fgPrintf( SG_COCKPIT, SG_DEBUG, "\n");
- fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer);
- fgPrintf( SG_COCKPIT, SG_DEBUG, "\n");
-#endif
- lenstr = strlen(label_buffer);
-
- if (justify == RIGHT_JUST)
- posincr = scrn_rect.right - lenstr;
- else if (justify == CENTER_JUST)
- posincr = get_span() - (lenstr / 2); // -lenstr*4;
- else // justify == LEFT_JUST
- posincr = 0;
-
- if (fontSize == HUD_FONT_SMALL) {
- textString(scrn_rect.left + posincr, scrn_rect.top,
- label_buffer, get_digits());
-
- } else if (fontSize == HUD_FONT_LARGE) {
- textString(scrn_rect.left + posincr, scrn_rect.top,
- label_buffer, get_digits());
- }
-}
diff --git a/src/Cockpit/hud_ladr.cxx b/src/Cockpit/hud_ladr.cxx
deleted file mode 100644
index d56315b06..000000000
--- a/src/Cockpit/hud_ladr.cxx
+++ /dev/null
@@ -1,785 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include
-
-#include "hud.hxx"
-#include "panel.hxx"
-#include
-
-// FIXME
-extern float get_roll(void);
-extern float get_pitch(void);
-
-
-HudLadder::HudLadder(const SGPropertyNode *node) :
- dual_instr_item(
- node->getIntValue("x"),
- node->getIntValue("y"),
- node->getIntValue("width"),
- node->getIntValue("height"),
- get_roll,
- get_pitch, // FIXME getter functions from cockpit.cxx
- node->getBoolValue("working", true),
- HUDS_RIGHT),
- width_units(int(node->getFloatValue("span_units"))),
- div_units(int(fabs(node->getFloatValue("division_units")))),
- minor_div(0 /* hud.cxx: static float minor_division = 0 */),
- label_pos(node->getIntValue("lbl_pos")),
- scr_hole(node->getIntValue("screen_hole")),
- factor(node->getFloatValue("compression_factor")),
- hudladder_type(node->getStringValue("name")),
- frl(node->getBoolValue("enable_frl", false)),
- target_spot(node->getBoolValue("enable_target_spot", false)),
- velocity_vector(node->getBoolValue("enable_velocity_vector", false)),
- drift_marker(node->getBoolValue("enable_drift_marker", false)),
- alpha_bracket(node->getBoolValue("enable_alpha_bracket", false)),
- energy_marker(node->getBoolValue("enable_energy_marker", false)),
- climb_dive_marker(node->getBoolValue("enable_climb_dive_marker", false)),
- glide_slope_marker(node->getBoolValue("enable_glide_slope_marker",false)),
- glide_slope(node->getFloatValue("glide_slope", -4.0)),
- energy_worm(node->getBoolValue("enable_energy_marker", false)),
- waypoint_marker(node->getBoolValue("enable_waypoint_marker", false)),
- zenith(node->getIntValue("zenith")),
- nadir(node->getIntValue("nadir")),
- hat(node->getIntValue("hat"))
-{
- // The factor assumes a base of 55 degrees per 640 pixels.
- // Invert to convert the "compression" factor to a
- // pixels-per-degree number.
- if (fgGetBool("/sim/hud/enable3d", true) && HUD_style == 1)
- factor = 640.0 / 55.0;
-
- SG_LOG(SG_INPUT, SG_BULK, "Done reading HudLadder instrument"
- << node->getStringValue("name", "[unnamed]"));
-
- if (!width_units)
- width_units = 45;
-
- vmax = width_units / 2;
- vmin = -vmax;
-}
-
-
-//
-// Draws a climb ladder in the center of the HUD
-//
-
-void HudLadder::draw(void)
-{
-
- float x_ini, x_ini2;
- float x_end, x_end2;
- float y = 0;
- int count;
- float cosine, sine, xvvr, yvvr, Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
- float up_vel, ground_vel, actslope = 0.0;
- float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1;
- float t2 = 0.0, psi = 0.0, alpha, pla;
- float vel_x = 0.0, vel_y = 0.0, drift;
- bool pitch_ladder = false;
- bool climb_dive_ladder = false;
- bool clip_plane = false;
-
- GLdouble eqn_top[4] = {0.0, -1.0, 0.0, 0.0};
- GLdouble eqn_left[4] = {-1.0, 0.0, 0.0, 100.0};
- GLdouble eqn_right[4] = {1.0, 0.0, 0.0, 100.0};
-
- POINT centroid = get_centroid();
- RECT box = get_location();
-
- float half_span = box.right / 2.0;
- float roll_value = current_ch2();
- alpha = get_aoa();
- pla = get_throttleval();
-
-#ifdef ENABLE_SP_FDM
- int lgear, wown, wowm, ilcanclaw, ihook;
- ilcanclaw = fgGetInt("/fdm-ada/iaux2", 0);
- lgear = fgGetInt("/fdm-ada/iaux3", 0);
- wown = fgGetInt("/fdm-ada/iaux4", 0);
- wowm = fgGetInt("/fdm-ada/iaux5", 0);;
- ihook = fgGetInt("/fdm-ada/iaux6", 0);
-#endif
- float pitch_value = current_ch1() * SGD_RADIANS_TO_DEGREES;
-
- if (hudladder_type == "Climb/Dive Ladder") {
- pitch_ladder = false;
- climb_dive_ladder = true;
- clip_plane = true;
-
- } else { // hudladder_type == "Pitch Ladder"
- pitch_ladder = true;
- climb_dive_ladder = false;
- clip_plane = false;
- }
-
- //**************************************************************
- glPushMatrix();
- // define (0, 0) as center of screen
- glTranslatef(centroid.x, centroid.y, 0);
-
- // OBJECT STATIC RETICLE
- // TYPE FRL
- // ATTRIB - ALWAYS
- // Draw the FRL spot and line
- if (frl) {
-#define FRL_DIAMOND_SIZE 2.0
- glBegin(GL_LINE_LOOP);
- glVertex2f(-FRL_DIAMOND_SIZE, 0.0);
- glVertex2f(0.0, FRL_DIAMOND_SIZE);
- glVertex2f(FRL_DIAMOND_SIZE, 0.0);
- glVertex2f(0.0, -FRL_DIAMOND_SIZE);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex2f(0, FRL_DIAMOND_SIZE);
- glVertex2f(0, 8.0);
- glEnd();
-#undef FRL_DIAMOND_SIZE
- }
- // TYPE WATERLINE_MARK (W shaped _ _ )
- // \/\/
-
- //****************************************************************
- // TYPE TARGET_SPOT
- // Draw the target spot.
- if (target_spot) {
-#define CENTER_DIAMOND_SIZE 6.0
- glBegin(GL_LINE_LOOP);
- glVertex2f(-CENTER_DIAMOND_SIZE, 0.0);
- glVertex2f(0.0, CENTER_DIAMOND_SIZE);
- glVertex2f(CENTER_DIAMOND_SIZE, 0.0);
- glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
- glEnd();
-#undef CENTER_DIAMOND_SIZE
- }
-
- //****************************************************************
- //velocity vector reticle - computations
- if (velocity_vector) {
- Vxx = fgGetDouble("/velocities/north-relground-fps", 0.0);
- Vyy = fgGetDouble("/velocities/east-relground-fps", 0.0);
- Vzz = fgGetDouble("/velocities/down-relground-fps", 0.0);
- Axx = fgGetDouble("/accelerations/ned/north-accel-fps_sec", 0.0);
- Ayy = fgGetDouble("/accelerations/ned/east-accel-fps_sec", 0.0);
- Azz = fgGetDouble("/accelerations/ned/down-accel-fps_sec", 0.0);
- psi = get_heading();
-
- if (psi > 180.0)
- psi = psi - 360;
-
- total_vel = sqrt(Vxx * Vxx + Vyy * Vyy + Vzz * Vzz);
- ground_vel = sqrt(Vxx * Vxx + Vyy * Vyy);
- up_vel = Vzz;
-
- if (ground_vel < 2.0) {
- if (fabs(up_vel) < 2.0)
- actslope = 0.0;
- else
- actslope = (up_vel / fabs(up_vel)) * 90.0;
-
- } else {
- actslope = atan(up_vel / ground_vel) * SGD_RADIANS_TO_DEGREES;
- }
-
- xvvr = (((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi)
- * (factor / globals->get_current_view()->get_aspect_ratio()));
- drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
- yvvr = ((actslope - pitch_value) * factor);
- vel_y = ((actslope - pitch_value) * cos(roll_value) + drift * sin(roll_value)) * factor;
- vel_x = (-(actslope - pitch_value) * sin(roll_value) + drift * cos(roll_value))
- * (factor/globals->get_current_view()->get_aspect_ratio());
- // printf("%f %f %f %f\n",vel_x, vel_y, drift, psi);
-
- //****************************************************************
- // OBJECT MOVING RETICLE
- // TYPE - DRIFT MARKER
- // ATTRIB - ALWAYS
- // drift marker
- if (drift_marker) {
- glBegin(GL_LINE_STRIP);
- glVertex2f((xvvr * 25 / 120) - 6, -4);
- glVertex2f(xvvr * 25 / 120, 8);
- glVertex2f((xvvr * 25 / 120) + 6, -4);
- glEnd();
- }
-
- //****************************************************************
- // Clipping coordinates for ladder to be input from xml file
- // Clip hud ladder
- if (clip_plane) {
- glClipPlane(GL_CLIP_PLANE0, eqn_top);
- glEnable(GL_CLIP_PLANE0);
- glClipPlane(GL_CLIP_PLANE1, eqn_left);
- glEnable(GL_CLIP_PLANE1);
- glClipPlane(GL_CLIP_PLANE2, eqn_right);
- glEnable(GL_CLIP_PLANE2);
- // glScissor(-100,-240, 200, 240);
- // glEnable(GL_SCISSOR_TEST);
- }
-
- //****************************************************************
- // OBJECT MOVING RETICLE
- // TYPE VELOCITY VECTOR
- // ATTRIB - ALWAYS
- // velocity vector
- glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle
- for (count = 0; count < 50; count++) {
- cosine = 6 * cos(count * SGD_2PI / 50.0);
- sine = 6 * sin(count * SGD_2PI / 50.0);
- glVertex2f(cosine + vel_x, sine + vel_y);
- }
- glEnd();
-
- //velocity vector reticle orientation lines
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x - 12, vel_y);
- glVertex2f(vel_x - 6, vel_y);
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x + 12, vel_y);
- glVertex2f(vel_x + 6, vel_y);
- glEnd();
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x, vel_y + 12);
- glVertex2f(vel_x, vel_y + 6);
- glEnd();
-
-#ifdef ENABLE_SP_FDM
- // OBJECT MOVING RETICLE
- // TYPE LINE
- // ATTRIB - ON CONDITION
- if (lgear == 1) {
- // undercarriage status
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x + 8, vel_y);
- glVertex2f(vel_x + 8, vel_y - 4);
- glEnd();
-
- // OBJECT MOVING RETICLE
- // TYPE LINE
- // ATTRIB - ON CONDITION
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x - 8, vel_y);
- glVertex2f(vel_x - 8, vel_y - 4);
- glEnd();
-
- // OBJECT MOVING RETICLE
- // TYPE LINE
- // ATTRIB - ON CONDITION
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x, vel_y - 6);
- glVertex2f(vel_x, vel_y - 10);
- glEnd();
- }
-
- // OBJECT MOVING RETICLE
- // TYPE V
- // ATTRIB - ON CONDITION
- if (ihook == 1) {
- // arrestor hook status
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x - 4, vel_y - 8);
- glVertex2f(vel_x, vel_y - 10);
- glVertex2f(vel_x + 4, vel_y - 8);
- glEnd();
- }
-#endif
- } // if velocity_vector
-
-
- //***************************************************************
- // OBJECT MOVING RETICLE
- // TYPE - SQUARE_BRACKET
- // ATTRIB - ON CONDITION
- // alpha bracket
-#ifdef ENABLE_SP_FDM
- if (alpha_bracket && ihook == 1) {
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x - 20 , vel_y - (16 - alpha) * factor);
- glVertex2f(vel_x - 17, vel_y - (16 - alpha) * factor);
- glVertex2f(vel_x - 17, vel_y - (14 - alpha) * factor);
- glVertex2f(vel_x - 20, vel_y - (14 - alpha) * factor);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x + 20 , vel_y - (16 - alpha) * factor);
- glVertex2f(vel_x + 17, vel_y - (16 - alpha) * factor);
- glVertex2f(vel_x + 17, vel_y - (14 - alpha) * factor);
- glVertex2f(vel_x + 20, vel_y - (14 - alpha) * factor);
- glEnd();
- }
-#endif
- //printf("xvr=%f, yvr=%f, Vx=%f, Vy=%f, Vz=%f\n",xvvr, yvvr, Vx, Vy, Vz);
- //printf("Ax=%f, Ay=%f, Az=%f\n",Ax, Ay, Az);
-
- //****************************************************************
- // OBJECT MOVING RETICLE
- // TYPE ENERGY_MARKERS
- // ATTRIB - ALWAYS
- //energy markers - compute potential slope
- if (energy_marker) {
- if (total_vel < 5.0) {
- t1 = 0;
- t2 = 0;
- } else {
- t1 = up_vel / total_vel;
- t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
- }
- pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * factor + vel_y;
- // if (pot_slope < (vel_y - 45)) pot_slope = vel_y - 45;
- // if (pot_slope > (vel_y + 45)) pot_slope = vel_y + 45;
-
- //energy markers
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x - 20, pot_slope - 5);
- glVertex2f(vel_x - 15, pot_slope);
- glVertex2f(vel_x - 20, pot_slope + 5);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x + 20, pot_slope - 5);
- glVertex2f(vel_x + 15, pot_slope);
- glVertex2f(vel_x + 20, pot_slope + 5);
- glEnd();
-
- if (pla > (105.0 / 131.0)) {
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x - 24, pot_slope - 5);
- glVertex2f(vel_x - 19, pot_slope);
- glVertex2f(vel_x - 24, pot_slope + 5);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x + 24, pot_slope - 5);
- glVertex2f(vel_x + 19, pot_slope);
- glVertex2f(vel_x + 24, pot_slope + 5);
- glEnd();
- }
- }
-
- //**********************************************************
- // ramp reticle
- // OBJECT STATIC RETICLE
- // TYPE LINE
- // ATTRIB - ON CONDITION
-#ifdef ENABLE_SP_FDM
- if (energy_worm && ilcanclaw == 1) {
- glBegin(GL_LINE_STRIP);
- glVertex2f(-15, -134);
- glVertex2f(15, -134);
- glEnd();
-
- // OBJECT MOVING RETICLE
- // TYPE BOX
- // ATTRIB - ON CONDITION
- glBegin(GL_LINE_STRIP);
- glVertex2f(-6, -134);
- glVertex2f(-6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
- glVertex2f(+6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
- glVertex2f(6, -134);
- glEnd();
-
- // OBJECT MOVING RETICLE
- // TYPE DIAMOND
- // ATTRIB - ON CONDITION
- glBegin(GL_LINE_LOOP);
- glVertex2f(-6, actslope * 4.0 - 134);
- glVertex2f(0, actslope * 4.0 -134 + 3);
- glVertex2f(6, actslope * 4.0 - 134);
- glVertex2f(0, actslope * 4.0 -134 -3);
- glEnd();
- }
-#endif
-
- //*************************************************************
- // OBJECT MOVING RETICLE
- // TYPE DIAMOND
- // ATTRIB - ALWAYS
- // Draw the locked velocity vector.
- if (climb_dive_marker) {
- glBegin(GL_LINE_LOOP);
- glVertex2f(-3.0, 0.0 + vel_y);
- glVertex2f(0.0, 6.0 + vel_y);
- glVertex2f(3.0, 0.0 + vel_y);
- glVertex2f(0.0, -6.0 + vel_y);
- glEnd();
- }
-
- //****************************************************************
-
- if (climb_dive_ladder) { // CONFORMAL_HUD
- vmin = pitch_value - (float)width_units;
- vmax = pitch_value + (float)width_units;
- glTranslatef(vel_x, vel_y, 0);
-
- } else { // pitch_ladder - Default Hud
- vmin = pitch_value - (float)width_units * 0.5f;
- vmax = pitch_value + (float)width_units * 0.5f;
- }
-
- glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
- // FRL marker not rotated - this line shifted below
-
- if (div_units) {
- char TextLadder[8];
- float label_length;
- float label_height;
- float left;
- float right;
- float bot;
- float top;
- float text_offset = 4.0f;
- float zero_offset = 0.0;
-
- if (climb_dive_ladder)
- zero_offset = 50.0f; // horizon line is wider by this much (hard coded ??)
- else
- zero_offset = 10.0f;
-
- fntFont *font = HUDtext->getFont(); // FIXME
- float pointsize = HUDtext->getPointSize();
- float italic = HUDtext->getSlant();
-
- TextList.setFont(HUDtext);
- TextList.erase();
- LineList.erase();
- StippleLineList.erase();
-
- int last = float_to_int(vmax) + 1;
- int i = float_to_int(vmin);
-
- if (!scr_hole) {
- x_end = half_span;
-
- for (; igetBBox(TextLadder, pointsize, italic,
- &left, &right, &bot, &top);
- label_length = right - left;
- label_length += text_offset;
- label_height = (top - bot) / 2.0f;
-
- x_ini = -half_span;
-
- if (i >= 0) {
- // Make zero point wider on left
- if (i == 0)
- x_ini -= zero_offset;
-
- // Zero or above draw solid lines
- Line(x_ini, y, x_end, y);
-
- if (i == 90 && zenith == 1)
- drawZenith(x_ini, x_end, y);
- } else {
- // Below zero draw dashed lines.
- StippleLine(x_ini, y, x_end, y);
-
- if (i == -90 && nadir ==1)
- drawNadir(x_ini, x_end, y);
- }
-
- // Calculate the position of the left text and write it.
- Text(x_ini-label_length, y-label_height, TextLadder);
- Text(x_end+text_offset, y-label_height, TextLadder);
- }
- }
-
- } else { // if (scr_hole)
- // Draw ladder with space in the middle of the lines
- float hole = (float)((scr_hole) / 2.0f);
-
- x_end = -half_span + hole;
- x_ini2 = half_span - hole;
-
- for (; i < last; i++) {
- if (hudladder_type == "Pitch Ladder")
- y = (((float)(i - pitch_value) * factor) + .5);
- else if (hudladder_type == "Climb/Dive Ladder")
- y = (((float)(i - actslope) * factor) + .5);
-
- if (!(i % div_units)) { // At integral multiple of div
- sprintf(TextLadder, "%d", i);
- font->getBBox(TextLadder, pointsize, italic,
- &left, &right, &bot, &top);
- label_length = right - left;
- label_length += text_offset;
- label_height = (top - bot) / 2.0f;
- // printf("l %f r %f b %f t %f\n",left, right, bot, top);
-
- // Start by calculating the points and drawing the
- // left side lines.
- x_ini = -half_span;
- x_end2 = half_span;
-
- if (i >= 0) {
- // Make zero point wider on left
- if (i == 0) {
- x_ini -= zero_offset;
- x_end2 += zero_offset;
- }
- //draw climb bar vertical lines
- if (climb_dive_ladder) {
- // Zero or above draw solid lines
- Line(x_end, y - 5.0, x_end, y);
- Line(x_ini2, y - 5.0, x_ini2, y);
- }
- // draw pitch / climb bar
- Line(x_ini, y, x_end, y);
- Line(x_ini2, y, x_end2, y);
-
- if (i == 90 && zenith == 1)
- drawZenith(x_ini2, x_end, y);
-
- } else { // i < 0
- // draw dive bar vertical lines
- if (climb_dive_ladder) {
- Line(x_end, y + 5.0, x_end, y);
- Line(x_ini2, y + 5.0, x_ini2, y);
- }
-
- // draw pitch / dive bars
- StippleLine(x_ini, y, x_end, y);
- StippleLine(x_ini2, y, x_end2, y);
-
- if (i == -90 && nadir == 1)
- drawNadir(x_ini2, x_end, y);
- }
-
- // Now calculate the location of the left side label using
- Text(x_ini-label_length, y - label_height, TextLadder);
- Text(x_end2+text_offset, y - label_height, TextLadder);
- }
- }
-
- // OBJECT LADDER MARK
- // TYPE LINE
- // ATTRIB - ON CONDITION
- // draw appraoch glide slope marker
-#ifdef ENABLE_SP_FDM
- if (glide_slope_marker && ihook) {
- Line(-half_span + 15, (glide_slope-actslope) * factor,
- -half_span + hole, (glide_slope - actslope) * factor);
- Line(half_span - 15, (glide_slope-actslope) * factor,
- half_span - hole, (glide_slope - actslope) * factor);
- }
-#endif
- }
- TextList.draw();
-
- glLineWidth(0.2);
-
- LineList.draw();
-
- glEnable(GL_LINE_STIPPLE);
- glLineStipple(1, 0x00FF);
- StippleLineList.draw();
- glDisable(GL_LINE_STIPPLE);
- }
- glDisable(GL_CLIP_PLANE0);
- glDisable(GL_CLIP_PLANE1);
- glDisable(GL_CLIP_PLANE2);
- // glDisable(GL_SCISSOR_TEST);
- glPopMatrix();
- //*************************************************************
-
- //*************************************************************
-#ifdef ENABLE_SP_FDM
- if (waypoint_marker) {
- //waypoint marker computation
- float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
-
- fromwp_lon = get_longitude() * SGD_DEGREES_TO_RADIANS;
- fromwp_lat = get_latitude() * SGD_DEGREES_TO_RADIANS;
- towp_lon = fgGetDouble("/fdm-ada/ship-lon", 0.0) * SGD_DEGREES_TO_RADIANS;
- towp_lat = fgGetDouble("/fdm-ada/ship-lat", 0.0) * SGD_DEGREES_TO_RADIANS;
-
- dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
- * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));
- delx= towp_lat - fromwp_lat;
- dely = towp_lon - fromwp_lon;
- hyp = sqrt(pow(delx, 2) + pow(dely, 2));
-
- if (hyp != 0)
- theta = asin(dely / hyp);
- else
- theta = 0.0;
-
- brg = theta * SGD_RADIANS_TO_DEGREES;
- if (brg > 360.0)
- brg = 0.0;
- if (delx < 0)
- brg = 180 - brg;
-
- // {Brg = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
- // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
-
- dist *= SGD_RADIANS_TO_DEGREES * 60.0 * 1852.0; //rad->deg->nm->m
- // end waypoint marker computation
-
- //*********************************************************
- // OBJECT MOVING RETICLE
- // TYPE ARROW
- // waypoint marker
- if (fabs(brg-psi) > 10.0) {
- glPushMatrix();
- glTranslatef(centroid.x, centroid.y, 0);
- glTranslatef(vel_x, vel_y, 0);
- glRotatef(brg - psi, 0.0, 0.0, -1.0);
- glBegin(GL_LINE_LOOP);
- glVertex2f(-2.5, 20.0);
- glVertex2f(-2.5, 30.0);
- glVertex2f(-5.0, 30.0);
- glVertex2f(0.0, 35.0);
- glVertex2f(5.0, 30.0);
- glVertex2f(2.5, 30.0);
- glVertex2f(2.5, 20.0);
- glEnd();
- glPopMatrix();
- }
-
- // waypoint marker on heading scale
- if (fabs(brg-psi) < 12.0) {
- if (hat == 0) {
- glBegin(GL_LINE_LOOP);
- glVertex2f(((brg - psi) * 60 / 25) + 320, 240.0);
- glVertex2f(((brg - psi) * 60 / 25) + 326, 240.0 - 4);
- glVertex2f(((brg - psi) * 60 / 25) + 323, 240.0 - 4);
- glVertex2f(((brg - psi) * 60 / 25) + 323, 240.0 - 8);
- glVertex2f(((brg - psi) * 60 / 25) + 317, 240.0 - 8);
- glVertex2f(((brg - psi) * 60 / 25) + 317, 240.0 - 4);
- glVertex2f(((brg - psi) * 60 / 25) + 314, 240.0 - 4);
- glEnd();
-
- } else { //if hat=0
- float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
- float x1, y1;
-
- glEnable(GL_POINT_SMOOTH);
- glBegin(GL_POINTS);
-
- for (int count = 0; count <= 200; count++) {
- float temp = count * 3.142 * 3 / (200.0 * 2.0);
- float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
- x1 = x + r * cos(temp1);
- y1 = y + r * sin(temp1);
- glVertex2f(x1, y1);
- }
-
- glEnd();
- glDisable(GL_POINT_SMOOTH);
- } //hat=0
-
- } //brg<12
- } // if waypoint_marker
-#endif
-}//draw
-
-
-/******************************************************************/
-// draws the zenith symbol for highest possible climb angle (i.e. 90 degree climb angle)
-//
-void HudLadder::drawZenith(float xfirst, float xlast, float yvalue)
-{
- float xcentre = (xfirst + xlast) / 2.0;
- float ycentre = yvalue;
-
- Line(xcentre - 9.0, ycentre, xcentre - 3.0, ycentre + 1.3);
- Line(xcentre - 9.0, ycentre, xcentre - 3.0, ycentre - 1.3);
-
- Line(xcentre + 9.0, ycentre, xcentre + 3.0, ycentre + 1.3);
- Line(xcentre + 9.0, ycentre, xcentre + 3.0, ycentre - 1.3);
-
- Line(xcentre, ycentre + 9.0, xcentre - 1.3, ycentre + 3.0);
- Line(xcentre, ycentre + 9.0, xcentre + 1.3, ycentre + 3.0);
-
- Line(xcentre - 3.9, ycentre + 3.9, xcentre - 3.0, ycentre + 1.3);
- Line(xcentre - 3.9, ycentre + 3.9, xcentre - 1.3, ycentre + 3.0);
-
- Line(xcentre + 3.9, ycentre + 3.9, xcentre + 1.3, ycentre+3.0);
- Line(xcentre + 3.9, ycentre + 3.9, xcentre + 3.0, ycentre+1.3);
-
- Line(xcentre - 3.9, ycentre - 3.9, xcentre - 3.0, ycentre-1.3);
- Line(xcentre - 3.9, ycentre - 3.9, xcentre - 1.3, ycentre-2.6);
-
- Line(xcentre + 3.9, ycentre - 3.9, xcentre + 3.0, ycentre-1.3);
- Line(xcentre + 3.9, ycentre - 3.9, xcentre + 1.3, ycentre-2.6);
-
- Line(xcentre - 1.3, ycentre - 2.6, xcentre, ycentre - 27.0);
- Line(xcentre + 1.3, ycentre - 2.6, xcentre, ycentre - 27.0);
-}
-
-
-// draws the nadir symbol for lowest possible dive angle (i.e. 90 degree dive angle)
-//
-void HudLadder::drawNadir(float xfirst, float xlast, float yvalue)
-{
- float xcentre = (xfirst + xlast) / 2.0;
- float ycentre = yvalue;
-
- float r = 7.5;
- float x1, y1, x2, y2;
-
- // to draw a circle
- float xcent1, xcent2, ycent1, ycent2;
- xcent1 = xcentre + r;
- ycent1 = ycentre;
-
- for (int count = 1; count <= 400; count++) {
- float temp = count * 2 * 3.142 / 400.0;
- xcent2 = xcentre + r * cos(temp);
- ycent2 = ycentre + r * sin(temp);
-
- Line(xcent1, ycent1, xcent2, ycent2);
-
- xcent1 = xcent2;
- ycent1 = ycent2;
- }
-
- xcent2 = xcentre + r;
- ycent2 = ycentre;
-
- drawOneLine(xcent1, ycent1, xcent2, ycent2); //to connect last point to first point
- //end circle
-
- //to draw a line above the circle
- Line(xcentre, ycentre + 7.5, xcentre, ycentre + 22.5);
-
- //line in the middle of circle
- Line(xcentre - 7.5, ycentre, xcentre + 7.5, ycentre);
-
- float theta = asin (2.5 / 7.5);
- float theta1 = asin(5.0 / 7.5);
-
- x1 = xcentre + r * cos(theta);
- y1 = ycentre + 2.5;
- x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
- y2 = ycentre + 2.5;
- Line(x1, y1, x2, y2);
-
- x1 = xcentre + r * cos(theta1);
- y1 = ycentre + 5.0;
- x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
- y2 = ycentre + 5.0;
- Line(x1, y1, x2, y2);
-
- x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
- y1 = ycentre - 2.5;
- x2 = xcentre + r * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
- y2 = ycentre - 2.5;
- Line(x1, y1, x2, y2);
-
- x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
- y1 = ycentre - 5.0;
- x2 = xcentre + r * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
- y2 = ycentre - 5.0;
- Line(x1, y1, x2, y2);
-}
-
-
diff --git a/src/Cockpit/hud_rwy.cxx b/src/Cockpit/hud_rwy.cxx
deleted file mode 100644
index 222975fdb..000000000
--- a/src/Cockpit/hud_rwy.cxx
+++ /dev/null
@@ -1,437 +0,0 @@
-// hud_rwy.cxx -- An instrument that renders a virtual runway on the HUD
-//
-// Written by Aaron Wilson & Phillip Merritt, Nov 2004.
-//
-// Copyright (C) 2004 Aaron Wilson, Aaron.I.Wilson@nasa.gov
-// Copyright (C) 2004 Phillip Merritt, Phillip.M.Merritt@nasa.gov
-//
-// 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.
-//
-
-#include
-
-#include "hud.hxx"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-// int x, int y, int width, int height, float scale_data, bool working)
-
-runway_instr::runway_instr(const SGPropertyNode *node) :
- instr_item(
- node->getIntValue("x"),
- node->getIntValue("y"),
- node->getIntValue("width"),
- node->getIntValue("height"),
- NULL,
- node->getDoubleValue("scale"),
- 0,
- node->getBoolValue("working", true)),
- arrowScale(node->getDoubleValue("arrow_scale", 1.0)),
- arrowRad(node->getDoubleValue("arrow_radius")),
- lnScale(node->getDoubleValue("line_scale", 1.0)),
- scaleDist(node->getDoubleValue("scale_dist_nm")),
- default_pitch(fgGetDouble("/sim/view[0]/config/pitch-pitch-deg", 0.0)),
- default_heading(fgGetDouble("/sim/view[0]/config/pitch-heading-deg", 0.0)),
- cockpit_view(globals->get_viewmgr()->get_view(0)),
- stippleOut(node->getIntValue("outer_stipple", 0xFFFF)),
- stippleCen(node->getIntValue("center_stipple", 0xFFFF)),
- drawIA(arrowScale > 0 ? true : false),
- drawIAAlways(arrowScale > 0 ? node->getBoolValue("arrow_always") : false)
-{
- SG_LOG(SG_INPUT, SG_BULK, "Done reading runway instrument "
- << node->getStringValue("name", "[unnamed]"));
-
- view[0] = 0;
- view[1] = 0;
- view[2] = 640;
- view[3] = 480;
-
- center.x = view[2] >> 1;
- center.y = view[3] >> 1;
-
- location.left = center.x - (get_width() >> 1) + get_x();
- location.right = center.x + (get_width() >>1) + get_x();
- location.bottom = center.y - (get_height() >>1) + get_y();
- location.top = center.y + (get_height() >> 1) + get_y();
-}
-
-
-
-void runway_instr::draw()
-{
- if (!is_broken() && (runway = get_active_runway())) {
- glPushAttrib(GL_LINE_STIPPLE | GL_LINE_STIPPLE_PATTERN | GL_LINE_WIDTH);
- float modelView[4][4], projMat[4][4];
- bool anyLines;
- //Get the current view
- FGViewer* curr_view = globals->get_viewmgr()->get_current_view();
- int curr_view_id = globals->get_viewmgr()->get_current();
- double gpo = curr_view->getGoalPitchOffset_deg();
- double gho = curr_view->getGoalHeadingOffset_deg();
- double po = curr_view->getPitchOffset_deg();
- double ho = curr_view->getHeadingOffset_deg();
-
- double yaw = -(cockpit_view->getHeadingOffset_deg() - default_heading) * SG_DEGREES_TO_RADIANS;
- double pitch = (cockpit_view->getPitchOffset_deg() - default_pitch) * SG_DEGREES_TO_RADIANS;
- //double roll = fgGetDouble("/sim/view[0]/config/roll-offset-deg",0.0) //TODO: adjust for default roll offset
- double sPitch = sin(pitch), cPitch = cos(pitch),
- sYaw = sin(yaw), cYaw = cos(yaw);
-
- //Set the camera to the cockpit view to get the view of the runway from the cockpit
- // OSGFIXME
-// ssgSetCamera((sgVec4 *)cockpit_view->get_VIEW());
- get_rwy_points(points3d);
- //Get the current project matrix
- // OSGFIXME
-// ssgGetProjectionMatrix(projMat);
-// const sgVec4 *viewMat = globals->get_current_view()->get_VIEW();
- //Get the current model view matrix (cockpit view)
- // OSGFIXME
-// ssgGetModelviewMatrix(modelView);
- //Create a rotation matrix to correct for any offsets (other than default offsets) to the model view matrix
- sgMat4 xy; //rotation about the Rxy, negate the sin's on Ry
- xy[0][0] = cYaw; xy[1][0] = 0.0f; xy[2][0] = -sYaw; xy[3][0] = 0.0f;
- xy[0][1] = sPitch*-sYaw; xy[1][1] = cPitch; xy[2][1] = -sPitch*cYaw; xy[3][1] = 0.0f;
- xy[0][2] = cPitch*sYaw; xy[1][2] = sPitch; xy[2][2] = cPitch*cYaw; xy[3][2] = 0.0f;
- xy[0][3] = 0.0f; xy[1][3] = 0.0f; xy[2][3] = 0.0f; xy[3][3] = 1.0f;
- //Re-center the model view
- sgPostMultMat4(modelView,xy);
- //copy float matrices to double
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 4; j++) {
- int idx = (i * 4) + j;
- mm[idx] = (double)modelView[i][j];
- pm[idx] = (double)projMat[i][j];
- }
- }
-
- //Calculate the 2D points via gluProject
- int result = GL_TRUE;
- for (int i = 0; i < 6; i++) {
- result = simgear::project(points3d[i][0], points3d[i][1], points3d[i][2],
- mm, pm, view,
- &points2d[i][0], &points2d[i][1], &points2d[i][2]);
- }
- //set the line width based on our distance from the runway
- setLineWidth();
- //Draw the runway lines on the HUD
- glEnable(GL_LINE_STIPPLE);
- glLineStipple(1, stippleOut);
- anyLines =
- drawLine(points3d[0], points3d[1], points2d[0], points2d[1]) | //draw top
- drawLine(points3d[2], points3d[1], points2d[2], points2d[1]) | //draw right
- drawLine(points3d[2], points3d[3], points2d[2], points2d[3]) | //draw bottom
- drawLine(points3d[3], points3d[0], points2d[3], points2d[0]); //draw left
-
- glLineStipple(1, stippleCen);
- anyLines |= drawLine(points3d[5], points3d[4], points2d[5], points2d[4]); //draw center
-
- //Check to see if arrow needs drawn
- if ((!anyLines && drawIA) || drawIAAlways) {
- drawArrow(); //draw indication arrow
- }
-
- //Set the camera back to the current view
- // OSGFIXME
-// ssgSetCamera((sgVec4 *)curr_view);
- glPopAttrib();
- }//if not broken
-}
-
-
-FGRunway* runway_instr::get_active_runway()
-{
- const FGAirport* apt = fgFindAirportID(fgGetString("/sim/presets/airport-id"));
- if (!apt) return NULL;
-
- return apt->getActiveRunwayForUsage();
-}
-
-
-void runway_instr::get_rwy_points(sgdVec3 *points3d)
-{
- double alt = runway->geod().getElevationM();
- double length = runway->lengthM() * 0.5;
- double width = runway->widthM() * 0.5;
- double frontLat = 0.0, frontLon = 0.0, backLat = 0.0, backLon = 0.0, az = 0.0, tempLat = 0.0, tempLon = 0.0;
- double runwayLon = runway->geod().getLongitudeDeg(),
- runwayLat = runway->geod().getLatitudeDeg();
- double heading = runway->headingDeg();
-
- geo_direct_wgs_84(alt, runwayLat, runwayLon, heading, length, &backLat, &backLon, &az);
- sgGeodToCart(backLat * SG_DEGREES_TO_RADIANS, backLon * SG_DEGREES_TO_RADIANS, alt, points3d[4]);
-
- geo_direct_wgs_84(alt, runwayLat, runwayLon, heading + 180, length, &frontLat, &frontLon, &az);
- sgGeodToCart(frontLat * SG_DEGREES_TO_RADIANS, frontLon * SG_DEGREES_TO_RADIANS, alt, points3d[5]);
-
- geo_direct_wgs_84(alt, backLat, backLon, heading + 90, width, &tempLat, &tempLon, &az);
- sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[0]);
-
- geo_direct_wgs_84(alt, backLat, backLon, heading - 90, width, &tempLat, &tempLon, &az);
- sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[1]);
-
- geo_direct_wgs_84(alt, frontLat, frontLon, heading - 90, width, &tempLat, &tempLon, &az);
- sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[2]);
-
- geo_direct_wgs_84(alt, frontLat, frontLon, heading + 90, width, &tempLat, &tempLon, &az);
- sgGeodToCart(tempLat * SG_DEGREES_TO_RADIANS, tempLon * SG_DEGREES_TO_RADIANS, alt, points3d[3]);
-}
-
-
-bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& point1, const sgdVec3& point2)
-{
- sgdVec3 p1, p2;
- sgdCopyVec3(p1, point1);
- sgdCopyVec3(p2, point2);
- bool p1Inside = (p1[0] >= location.left && p1[0] <= location.right
- && p1[1] >= location.bottom && p1[1] <= location.top);
- bool p1Insight = (p1[2] >= 0.0 && p1[2] < 1.0);
- bool p1Valid = p1Insight && p1Inside;
- bool p2Inside = (p2[0] >= location.left && p2[0] <= location.right
- && p2[1] >= location.bottom && p2[1] <= location.top);
- bool p2Insight = (p2[2] >= 0.0 && p2[2] < 1.0);
- bool p2Valid = p2Insight && p2Inside;
-
- if (p1Valid && p2Valid) { //Both project points are valid, draw the line
- glBegin(GL_LINES);
- glVertex2d(p1[0],p1[1]);
- glVertex2d(p2[0],p2[1]);
- glEnd();
-
- } else if (p1Valid) { //p1 is valid and p2 is not, calculate a new valid point
- sgdVec3 vec = {a2[0] - a1[0], a2[1] - a1[1], a2[2] - a1[2]};
- //create the unit vector
- sgdScaleVec3(vec, 1.0 / sgdLengthVec3(vec));
- sgdVec3 newPt;
- sgdCopyVec3(newPt, a1);
- sgdAddVec3(newPt, vec);
- if (simgear::project(newPt[0], newPt[1], newPt[2], mm, pm, view,
- &p2[0], &p2[1], &p2[2])
- && (p2[2] > 0 && p2[2] < 1.0)) {
- boundPoint(p1, p2);
- glBegin(GL_LINES);
- glVertex2d(p1[0], p1[1]);
- glVertex2d(p2[0], p2[1]);
- glEnd();
- }
-
- } else if (p2Valid) { //p2 is valid and p1 is not, calculate a new valid point
- sgdVec3 vec = {a1[0] - a2[0], a1[1] - a2[1], a1[2] - a2[2]};
- //create the unit vector
- sgdScaleVec3(vec, 1.0 / sgdLengthVec3(vec));
- sgdVec3 newPt;
- sgdCopyVec3(newPt, a2);
- sgdAddVec3(newPt, vec);
- if (simgear::project(newPt[0], newPt[1], newPt[2], mm, pm, view,
- &p1[0], &p1[1], &p1[2])
- && (p1[2] > 0 && p1[2] < 1.0)) {
- boundPoint(p2, p1);
- glBegin(GL_LINES);
- glVertex2d(p2[0], p2[1]);
- glVertex2d(p1[0], p1[1]);
- glEnd();
- }
-
- } else if (p1Insight && p2Insight) { //both points are insight, but not inside
- bool v = boundOutsidePoints(p1, p2);
- if (v) {
- glBegin(GL_LINES);
- glVertex2d(p1[0], p1[1]);
- glVertex2d(p2[0], p2[1]);
- glEnd();
- }
- return v;
- }
- //else both points are not insight, don't draw anything
- return (p1Valid && p2Valid);
-}
-
-
-void runway_instr::boundPoint(const sgdVec3& v, sgdVec3& m)
-{
- double y = v[1];
- if (m[1] < v[1])
- y = location.bottom;
- else if (m[1] > v[1])
- y = location.top;
-
- if (m[0] == v[0]) {
- m[1] = y;
- return; //prevent divide by zero
- }
-
- double slope = (m[1] - v[1]) / (m[0] - v[0]);
- m[0] = (y - v[1]) / slope + v[0];
- m[1] = y;
-
- if (m[0] < location.left) {
- m[0] = location.left;
- m[1] = slope * (location.left - v[0]) + v[1];
-
- } else if (m[0] > location.right) {
- m[0] = location.right;
- m[1] = slope * (location.right - v[0]) + v[1];
- }
-}
-
-
-bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m)
-{
- bool pointsInvalid = (v[1] > location.top && m[1] > location.top) ||
- (v[1] < location.bottom && m[1] < location.bottom) ||
- (v[0] > location.right && m[0] > location.right) ||
- (v[0] < location.left && m[0] < location.left);
- if (pointsInvalid)
- return false;
-
- if (m[0] == v[0]) {//x's are equal, vertical line
- if (m[1] > v[1]) {
- m[1] = location.top;
- v[1] = location.bottom;
- } else {
- v[1] = location.top;
- m[1] = location.bottom;
- }
- return true;
- }
-
- if (m[1] == v[1]) { //y's are equal, horizontal line
- if (m[0] > v[0]) {
- m[0] = location.right;
- v[0] = location.left;
- } else {
- v[0] = location.right;
- m[0] = location.left;
- }
- return true;
- }
-
- double slope = (m[1] - v[1]) / (m[0] - v[0]);
- double b = v[1] - (slope * v[0]);
- double y1 = slope * location.left + b;
- double y2 = slope * location.right + b;
- double x1 = (location.bottom - b) / slope;
- double x2 = (location.top - b) / slope;
- int counter = 0;
-
- if (y1 >= location.bottom && y1 <= location.top) {
- v[0] = location.left;
- v[1] = y1;
- counter++;
- }
-
- if (y2 >= location.bottom && y2 <= location.top) {
- if (counter > 0) {
- m[0] = location.right;
- m[1] = y2;
- } else {
- v[0] = location.right;
- v[1] = y2;
- }
- counter++;
- }
-
- if (x1 >= location.left && x1 <= location.right) {
- if (counter > 0) {
- m[0] = x1;
- m[1] = location.bottom;
- } else {
- v[0] = x1;
- v[1] = location.bottom;
- }
- counter++;
- }
-
- if (x2 >= location.left && x2 <= location.right) {
- m[0] = x1;
- m[1] = location.bottom;
- counter++;
- }
- return (counter == 2);
-}
-
-void runway_instr::drawArrow()
-{
- SGGeod acPos(SGGeod::fromDeg(
- fgGetDouble("/position/longitude-deg"),
- fgGetDouble("/position/latitude-deg")));
- float theta = SGGeodesy::courseDeg(acPos, runway->geod());
- theta -= fgGetDouble("/orientation/heading-deg");
- theta = -theta;
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glTranslated((location.right + location.left) / 2.0,(location.top + location.bottom) / 2.0, 0.0);
- glRotated(theta, 0.0, 0.0, 1.0);
- glTranslated(0.0, arrowRad, 0.0);
- glScaled(arrowScale, arrowScale, 0.0);
-
- glBegin(GL_TRIANGLES);
- glVertex2d(-5.0, 12.5);
- glVertex2d(0.0, 25.0);
- glVertex2d(5.0, 12.5);
- glEnd();
-
- glBegin(GL_QUADS);
- glVertex2d(-2.5, 0.0);
- glVertex2d(-2.5, 12.5);
- glVertex2d(2.5, 12.5);
- glVertex2d(2.5, 0.0);
- glEnd();
- glPopMatrix();
-}
-
-void runway_instr::setLineWidth()
-{
- //Calculate the distance from the runway, A
- SGGeod acPos(SGGeod::fromDeg(
- fgGetDouble("/position/longitude-deg"),
- fgGetDouble("/position/latitude-deg")));
- double distance = SGGeodesy::distanceNm(acPos, runway->geod());
-
- //Get altitude above runway, B
- double alt_nm = get_agl();
- static const SGPropertyNode *startup_units_node = fgGetNode("/sim/startup/units");
-
- if (!strcmp(startup_units_node->getStringValue(), "feet"))
- alt_nm *= SG_FEET_TO_METER*SG_METER_TO_NM;
- else
- alt_nm *= SG_METER_TO_NM;
-
- //Calculate distance away from runway, C = v(A≤+B≤)
- distance = sqrt(alt_nm * alt_nm + distance*distance);
- if (distance < scaleDist)
- glLineWidth(1.0 + ((lnScale - 1) * ((scaleDist - distance) / scaleDist)));
- else
- glLineWidth(1.0);
-
-}
-
-void runway_instr::setArrowRotationRadius(double radius) { arrowRad = radius; }
-void runway_instr::setArrowScale(double scale) { arrowScale = scale; }
-void runway_instr::setDrawArrow(bool draw) {drawIA = draw;}
-void runway_instr::setDrawArrowAlways(bool draw) {drawIAAlways = draw;}
-void runway_instr::setLineScale(double scale) {lnScale = scale;}
-void runway_instr::setScaleDist(double dist_m) {scaleDist = dist_m;}
-void runway_instr::setStippleOutline(unsigned short stipple) {stippleOut = stipple;}
-void runway_instr::setStippleCenterline(unsigned short stipple){stippleCen = stipple;}
-
diff --git a/src/Cockpit/hud_scal.cxx b/src/Cockpit/hud_scal.cxx
deleted file mode 100644
index 694a0ea3a..000000000
--- a/src/Cockpit/hud_scal.cxx
+++ /dev/null
@@ -1,53 +0,0 @@
-
-#include "hud.hxx"
-
-
-//============== Top of instr_scale class memeber definitions ===============
-//
-// Notes:
-// 1. instr_scales divide the specified location into half and then
-// the half opposite the read direction in half again. A bar is
-// then drawn along the second divider. Scale ticks are drawn
-// between the middle and quarter section lines (minor division
-// markers) or just over the middle line.
-//
-// 2. This class was not intended to be instanciated. See moving_scale
-// and gauge_instr classes.
-//============================================================================
-instr_scale::instr_scale(
- int x,
- int y,
- UINT width,
- UINT height,
- FLTFNPTR load_fn,
- UINT options,
- float show_range,
- float maxValue,
- float minValue,
- float disp_scale,
- UINT major_divs,
- UINT minor_divs,
- UINT rollover,
- int dp_showing,
- bool working) :
- instr_item( x, y, width, height, load_fn, disp_scale, options, working),
- range_shown ( show_range ),
- Maximum_value( maxValue ),
- Minimum_value( minValue ),
- Maj_div ( major_divs ),
- Min_div ( minor_divs ),
- Modulo ( rollover ),
- signif_digits( dp_showing )
-{
- int temp;
-
- scale_factor = (float)get_span() / range_shown;
- if (show_range < 0)
- range_shown = -range_shown;
-
- temp = float_to_int(Maximum_value - Minimum_value) / 100;
- if (range_shown < temp)
- range_shown = temp;
-}
-
-
diff --git a/src/Cockpit/hud_tbi.cxx b/src/Cockpit/hud_tbi.cxx
deleted file mode 100644
index c5fd670c6..000000000
--- a/src/Cockpit/hud_tbi.cxx
+++ /dev/null
@@ -1,241 +0,0 @@
-//
-// Turn Bank Indicator
-//
-
-#include
-#include "hud.hxx"
-
-// FIXME
-extern float get_roll(void);
-extern float get_sideslip(void);
-
-// x, y, width, height, get_roll, get_sideslip, maxBankAngle, maxSlipAngle, gap_width, working, tsi, rad
-
-// int x, int y, UINT width, UINT height, FLTFNPTR chn1_source, FLTFNPTR chn2_source, float maxBankAngle,
-// float maxSlipAngle, UINT gap_width, bool working, bool tsivalue, float radius) :
-
-
-fgTBI_instr::fgTBI_instr(const SGPropertyNode *node) :
- dual_instr_item(
- node->getIntValue("x"),
- node->getIntValue("y"),
- node->getIntValue("width"),
- node->getIntValue("height"),
- get_roll, // FIXME
- get_sideslip,
- node->getBoolValue("working", true),
- HUDS_TOP),
- BankLimit(int(node->getFloatValue("maxBankAngle"))),
- SlewLimit(int(node->getFloatValue("maxSlipAngle"))),
- scr_hole(node->getIntValue("gap_width")),
- tsi(node->getBoolValue("tsi")),
- rad(node->getFloatValue("rad"))
-
-{
- SG_LOG(SG_INPUT, SG_BULK, "Done reading TBI instrument"
- << node->getStringValue("name", "[unnamed]"));
-}
-
-
-void fgTBI_instr::draw(void)
-{
- float bank_angle, sideslip_angle;
- float ss_const; // sideslip angle pixels per rad
- float cen_x, cen_y, bank, fspan, tee, hole;
-
- int span = get_span();
- float zero = 0.0;
-
- RECT My_box = get_location();
- POINT centroid = get_centroid();
- int tee_height = My_box.bottom;
-
- bank_angle = current_ch2(); // Roll limit +/- 30 degrees
-
- if (bank_angle < -SGD_PI_2 / 3)
- bank_angle = -SGD_PI_2 / 3;
- else if (bank_angle > SGD_PI_2 / 3)
- bank_angle = SGD_PI_2 / 3;
-
-
- sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
-
- if (sideslip_angle < -SGD_PI / 9)
- sideslip_angle = -SGD_PI / 9;
- else if ( sideslip_angle > SGD_PI / 9 )
- sideslip_angle = SGD_PI / 9;
-
- cen_x = centroid.x;
- cen_y = centroid.y;
-
- bank = bank_angle * SGD_RADIANS_TO_DEGREES;
- tee = -tee_height;
- fspan = span;
- hole = scr_hole;
- ss_const = 2 * sideslip_angle * fspan / (SGD_2PI / 9); // width represents 40 degrees
-
-// printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan);
-// printf("ss_const: %f hole: %f\n", ss_const, hole);
-
- glPushMatrix();
- glTranslatef(cen_x, cen_y, zero);
- glRotatef(-bank, zero, zero, 1.0);
-
- if (!tsi) {
- glBegin(GL_LINES);
-
- if (!scr_hole) {
- glVertex2f(-fspan, zero);
- glVertex2f(fspan, zero);
-
- } else {
- glVertex2f(-fspan, zero);
- glVertex2f(-hole, zero);
- glVertex2f(hole, zero);
- glVertex2f(fspan, zero);
- }
-
- // draw teemarks
- glVertex2f(hole, zero);
- glVertex2f(hole, tee);
- glVertex2f(-hole, zero);
- glVertex2f(-hole, tee);
- glEnd();
-
- glBegin(GL_LINE_LOOP);
- glVertex2f(ss_const, -hole);
- glVertex2f(ss_const + hole, zero);
- glVertex2f(ss_const, hole);
- glVertex2f(ss_const - hole, zero);
- glEnd();
-
- } else { //if tsi enabled
- drawOneLine(cen_x-1.0, My_box.top, cen_x + 1.0, My_box.top);
- drawOneLine(cen_x-1.0, My_box.top, cen_x - 1.0, My_box.top + 10.0);
- drawOneLine(cen_x+1.0, My_box.top, cen_x + 1.0, My_box.top + 10.0);
- drawOneLine(cen_x-1.0, My_box.top + 10.0, cen_x + 1.0, My_box.top + 10.0);
-
- float x1, y1, x2, y2, x3, y3, x4, y4, x5, y5;
- float xc, yc, r = rad, r1 = rad - 10.0, r2 = rad - 5.0;
-
- xc = My_box.left + My_box.right / 2.0 ;
- yc = My_box.top + r;
-
- // first n last lines
- x1 = xc + r * cos(255.0 * SGD_DEGREES_TO_RADIANS);
- y1 = yc + r * sin(255.0 * SGD_DEGREES_TO_RADIANS);
-
- x2 = xc + r1 * cos(255.0 * SGD_DEGREES_TO_RADIANS);
- y2 = yc + r1 * sin(255.0 * SGD_DEGREES_TO_RADIANS);
- drawOneLine(x1,y1,x2,y2);
-
- x1 = xc + r * cos(285.0 * SGD_DEGREES_TO_RADIANS);
- y1 = yc + r * sin(285.0 * SGD_DEGREES_TO_RADIANS);
-
- x2 = xc + r1 * cos(285.0 * SGD_DEGREES_TO_RADIANS);
- y2 = yc + r1 * sin(285.0 * SGD_DEGREES_TO_RADIANS);
- drawOneLine(x1, y1, x2, y2);
-
- // second n fifth lines
- x1 = xc + r * cos(260.0 * SGD_DEGREES_TO_RADIANS);
- y1 = yc + r * sin(260.0 * SGD_DEGREES_TO_RADIANS);
-
- x2 = xc + r2 * cos(260.0 * SGD_DEGREES_TO_RADIANS);
- y2 = yc + r2 * sin(260.0 * SGD_DEGREES_TO_RADIANS);
- drawOneLine(x1, y1, x2, y2);
-
- x1 = xc + r * cos(280.0 * SGD_DEGREES_TO_RADIANS);
- y1 = yc + r * sin(280.0 * SGD_DEGREES_TO_RADIANS);
-
- x2 = xc + r2 * cos(280.0 * SGD_DEGREES_TO_RADIANS);
- y2 = yc + r2 * sin(280.0 * SGD_DEGREES_TO_RADIANS);
- drawOneLine(x1, y1, x2, y2);
-
- // third n fourth lines
- x1 = xc + r * cos(265.0 * SGD_DEGREES_TO_RADIANS);
- y1 = yc + r * sin(265.0 * SGD_DEGREES_TO_RADIANS);
-
-
- x2 = xc + r2 * cos(265.0 * SGD_DEGREES_TO_RADIANS);
- y2 = yc + r2 * sin(265.0 * SGD_DEGREES_TO_RADIANS);
- drawOneLine(x1, y1, x2, y2);
-
- x1 = xc + r * cos(275.0 * SGD_DEGREES_TO_RADIANS);
- y1 = yc + r * sin(275.0 * SGD_DEGREES_TO_RADIANS);
-
- x2 = xc + r2 * cos(275.0 * SGD_DEGREES_TO_RADIANS);
- y2 = yc + r2 * sin(275.0 * SGD_DEGREES_TO_RADIANS);
- drawOneLine(x1,y1,x2,y2);
-
- // draw marker
- float valbank, valsideslip, sideslip;
-
- r = rad + 5.0; // add gap
-
- // upper polygon
- bank_angle = current_ch2();
-
- bank = bank_angle * SGD_RADIANS_TO_DEGREES; // Roll limit +/- 30 degrees
- if (bank > BankLimit)
- bank = BankLimit;
- if (bank < -1.0*BankLimit)
- bank = -1.0*BankLimit;
-
- valbank = bank * 15.0 / BankLimit; // total span of TSI is 30 degrees
-
- sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
- sideslip = sideslip_angle * SGD_RADIANS_TO_DEGREES;
- if (sideslip > SlewLimit)
- sideslip = SlewLimit;
- if (sideslip < -1.0 * SlewLimit)
- sideslip = -1.0 * SlewLimit;
- valsideslip = sideslip * 15.0 / SlewLimit;
-
- // values 270, 225 and 315 are angles in degrees...
- x1 = xc + r * cos((valbank + 270.0) * SGD_DEGREES_TO_RADIANS);
- y1 = yc + r * sin((valbank + 270.0) * SGD_DEGREES_TO_RADIANS);
-
- x2 = x1 + 6.0 * cos(225 * SGD_DEGREES_TO_RADIANS);
- y2 = y1 + 6.0 * sin(225 * SGD_DEGREES_TO_RADIANS);
-
- x3 = x1 + 6.0 * cos(315 * SGD_DEGREES_TO_RADIANS);
- y3 = y1 + 6.0 * sin(315 * SGD_DEGREES_TO_RADIANS);
-
- drawOneLine(x1, y1, x2, y2);
- drawOneLine(x2, y2, x3, y3);
- drawOneLine(x3, y3, x1, y1);
-
- // lower polygon
- x1 = xc + r * cos((valbank + 270.0) * SGD_DEGREES_TO_RADIANS);
- y1 = yc + r * sin((valbank + 270.0) * SGD_DEGREES_TO_RADIANS);
-
- x2 = x1 + 6.0 * cos(225 * SGD_DEGREES_TO_RADIANS);
- y2 = y1 + 6.0 * sin(225 * SGD_DEGREES_TO_RADIANS);
-
- x3 = x1 + 6.0 * cos(315 * SGD_DEGREES_TO_RADIANS);
- y3 = y1 + 6.0 * sin(315 * SGD_DEGREES_TO_RADIANS);
-
- x4 = x1 + 10.0 * cos(225 * SGD_DEGREES_TO_RADIANS);
- y4 = y1 + 10.0 * sin(225 * SGD_DEGREES_TO_RADIANS);
-
- x5 = x1 + 10.0 * cos(315 * SGD_DEGREES_TO_RADIANS);
- y5 = y1 + 10.0 * sin(315 * SGD_DEGREES_TO_RADIANS);
-
- x2 = x2 + cos(valsideslip * SGD_DEGREES_TO_RADIANS);
- y2 = y2 + sin(valsideslip * SGD_DEGREES_TO_RADIANS);
- x3 = x3 + cos(valsideslip * SGD_DEGREES_TO_RADIANS);
- y3 = y3 + sin(valsideslip * SGD_DEGREES_TO_RADIANS);
- x4 = x4 + cos(valsideslip * SGD_DEGREES_TO_RADIANS);
- y4 = y4 + sin(valsideslip * SGD_DEGREES_TO_RADIANS);
- x5 = x5 + cos(valsideslip * SGD_DEGREES_TO_RADIANS);
- y5 = y5 + sin(valsideslip * SGD_DEGREES_TO_RADIANS);
-
- drawOneLine(x2, y2, x3, y3);
- drawOneLine(x3, y3, x5, y5);
- drawOneLine(x5, y5, x4, y4);
- drawOneLine(x4, y4, x2, y2);
- }
- glPopMatrix();
-}
-
-
diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx
index 8cc268788..7c7dd810c 100644
--- a/src/Cockpit/panel.cxx
+++ b/src/Cockpit/panel.cxx
@@ -61,9 +61,6 @@
#include
#include
-#include "hud.hxx"
-
-
#define WIN_X 0
#define WIN_Y 0
#define WIN_W 1024
diff --git a/src/FDM/ExternalNet/ExternalNet.cxx b/src/FDM/ExternalNet/ExternalNet.cxx
index 741bb3b78..9d2f3e7b2 100644
--- a/src/FDM/ExternalNet/ExternalNet.cxx
+++ b/src/FDM/ExternalNet/ExternalNet.cxx
@@ -24,8 +24,11 @@
# include
#endif
+#include
+
#include
#include // endian tests
+#include
#include
#include
@@ -34,6 +37,49 @@
#include "ExternalNet.hxx"
+class HTTPClient : public simgear::NetBufferChannel
+{
+
+ bool done;
+ SGTimeStamp start;
+
+public:
+
+ HTTPClient ( const char* host, int port, const char* path ) :
+ done( false )
+ {
+ open ();
+ connect (host, port);
+
+ char buffer[256];
+ ::snprintf (buffer, 256, "GET %s HTTP/1.0\r\n\r\n", path );
+ bufferSend(buffer, strlen(buffer) ) ;
+
+ start.stamp();
+ }
+
+ virtual void handleBufferRead (simgear::NetBuffer& buffer)
+ {
+ const char* s = buffer.getData();
+ while (*s)
+ fputc(*s++,stdout);
+
+ printf("done\n");
+ buffer.remove();
+ printf("after buffer.remove()\n");
+ done = true;
+ }
+
+ bool isDone() const { return done; }
+ bool isDone( long usec ) const {
+ if ( start + SGTimeStamp::fromUSec(usec) < SGTimeStamp::now() ) {
+ return true;
+ } else {
+ return done;
+ }
+ }
+};
+
FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
{
// set_delta_t( dt );
diff --git a/src/FDM/ExternalNet/ExternalNet.hxx b/src/FDM/ExternalNet/ExternalNet.hxx
index 92d76a322..a3f80891a 100644
--- a/src/FDM/ExternalNet/ExternalNet.hxx
+++ b/src/FDM/ExternalNet/ExternalNet.hxx
@@ -23,59 +23,14 @@
#ifndef _EXTERNAL_NET_HXX
#define _EXTERNAL_NET_HXX
-#include
-#include
-
#include // fine grained timing measurements
+#include
#include
#include
#include
-class HTTPClient : public netBufferChannel
-{
-
- bool done;
- SGTimeStamp start;
-
-public:
-
- HTTPClient ( const char* host, int port, const char* path ) :
- done( false )
- {
- open ();
- connect (host, port);
-
- const char* s = netFormat ( "GET %s HTTP/1.0\r\n\r\n", path );
- bufferSend( s, strlen(s) ) ;
-
- start.stamp();
- }
-
- virtual void handleBufferRead (netBuffer& buffer)
- {
- const char* s = buffer.getData();
- while (*s)
- fputc(*s++,stdout);
-
- printf("done\n");
- buffer.remove();
- printf("after buffer.remove()\n");
- done = true;
- }
-
- bool isDone() const { return done; }
- bool isDone( long usec ) const {
- if ( start + SGTimeStamp::fromUSec(usec) < SGTimeStamp::now() ) {
- return true;
- } else {
- return done;
- }
- }
-};
-
-
class FGExternalNet: public FGInterface {
private:
@@ -85,8 +40,8 @@ private:
int cmd_port;
string fdm_host;
- netSocket data_client;
- netSocket data_server;
+ simgear::Socket data_client;
+ simgear::Socket data_server;
bool valid;
diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp
index 4cba2d0f9..f02d23e64 100644
--- a/src/FDM/JSBSim/FGFDMExec.cpp
+++ b/src/FDM/JSBSim/FGFDMExec.cpp
@@ -71,16 +71,9 @@ using namespace std;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.80 2010/08/21 22:56:10 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.82 2010/10/07 03:17:29 jberndt Exp $";
static const char *IdHdr = ID_FDMEXEC;
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-GLOBAL DECLARATIONS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-unsigned int FGFDMExec::FDMctr = 0;
-FGPropertyManager* FGFDMExec::master=0;
-
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -102,11 +95,21 @@ void checkTied ( FGPropertyManager *node )
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// Constructor
-
-FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root)
+// Constructors
+FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root), delete_root(false)
{
+ FDMctr = new unsigned int;
+ *FDMctr = 0;
+ Initialize();
+}
+FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), delete_root(false), FDMctr(fdmctr)
+{
+ Initialize();
+}
+
+void FGFDMExec::Initialize()
+{
Frame = 0;
Error = 0;
GroundCallback = 0;
@@ -138,22 +141,27 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root)
dT = 1.0/120.0; // a default timestep size. This is needed for when JSBSim is
// run in standalone mode with no initialization file.
- IdFDM = FDMctr; // The main (parent) JSBSim instance is always the "zeroth"
- FDMctr++; // instance. "child" instances are loaded last.
-
try {
char* num = getenv("JSBSIM_DEBUG");
if (num) debug_lvl = atoi(num); // set debug level
- } catch (...) { // if error set to 1
+ } catch (...) { // if error set to 1
debug_lvl = 1;
}
- if (Root == 0) {
- if (master == 0)
- master = new FGPropertyManager;
- Root = master;
+ if (Root == 0) { // Then this is the root FDM
+ Root = new FGPropertyManager; // Create the property manager
+ delete_root = true;
+
+ FDMctr = new unsigned int; // Create and initialize the child FDM counter
+ (*FDMctr) = 0;
}
+ // Store this FDM's ID
+ IdFDM = (*FDMctr); // The main (parent) JSBSim instance is always the "zeroth"
+
+ // Prepare FDMctr for the next child FDM id
+ (*FDMctr)++; // instance. "child" instances are loaded last.
+
instance = Root->GetNode("/fdm/jsbsim",IdFDM,true);
Debug(0);
// this is to catch errors in binding member functions to the property tree.
@@ -186,7 +194,18 @@ FGFDMExec::~FGFDMExec()
try {
checkTied( instance );
DeAllocate();
- if (Root == 0) delete master;
+
+ if (IdFDM == 0) { // Meaning this is no child FDM
+ if(Root != 0) {
+ if (delete_root)
+ delete Root;
+ Root = 0;
+ }
+ if(FDMctr != 0) {
+ delete FDMctr;
+ FDMctr = 0;
+ }
+ }
} catch ( string msg ) {
cout << "Caught error: " << msg << endl;
}
@@ -439,7 +458,7 @@ vector FGFDMExec::EnumerateFDMs(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGFDMExec::LoadScript(string script, double deltaT)
+bool FGFDMExec::LoadScript(const string& script, double deltaT)
{
bool result;
@@ -451,8 +470,8 @@ bool FGFDMExec::LoadScript(string script, double deltaT)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string SystemsPath,
- string model, bool addModelToPath)
+bool FGFDMExec::LoadModel(const string& AircraftPath, const string& EnginePath, const string& SystemsPath,
+ const string& model, bool addModelToPath)
{
FGFDMExec::AircraftPath = RootDir + AircraftPath;
FGFDMExec::EnginePath = RootDir + EnginePath;
@@ -463,7 +482,7 @@ bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string Systems
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGFDMExec::LoadModel(string model, bool addModelToPath)
+bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
{
string token;
string aircraftCfgFileName;
@@ -730,7 +749,7 @@ void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGFDMExec::QueryPropertyCatalog(string in)
+string FGFDMExec::QueryPropertyCatalog(const string& in)
{
string results="";
for (unsigned i=0; iexec = new FGFDMExec();
+ child->exec = new FGFDMExec(Root, FDMctr);
child->exec->SetChild(true);
string childAircraft = el->GetAttributeValue("name");
@@ -922,7 +941,7 @@ void FGFDMExec::EnableOutput(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGFDMExec::SetOutputDirectives(string fname)
+bool FGFDMExec::SetOutputDirectives(const string& fname)
{
bool result;
diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h
index 8c91cb2c9..331097182 100644
--- a/src/FDM/JSBSim/FGFDMExec.h
+++ b/src/FDM/JSBSim/FGFDMExec.h
@@ -60,7 +60,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.52 2010/07/04 13:50:21 jberndt Exp $"
+#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.54 2010/10/07 03:17:29 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@@ -169,7 +169,7 @@ CLASS DOCUMENTATION
property actually maps toa function call of DoTrim().
@author Jon S. Berndt
- @version $Revision: 1.52 $
+ @version $Revision: 1.54 $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -206,8 +206,9 @@ class FGFDMExec : public FGJSBBase, public FGXMLFileRead
public:
- /// Default constructor
+ /// Default constructors
FGFDMExec(FGPropertyManager* root = 0);
+ FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr);
/// Default destructor
~FGFDMExec();
@@ -252,8 +253,8 @@ public:
@param addModelToPath set to true to add the model name to the
AircraftPath, defaults to true
@return true if successful */
- bool LoadModel(string AircraftPath, string EnginePath, string SystemsPath,
- string model, bool addModelToPath = true);
+ bool LoadModel(const string& AircraftPath, const string& EnginePath, const string& SystemsPath,
+ const string& model, bool addModelToPath = true);
/** Loads an aircraft model. The paths to the aircraft and engine
config file directories must be set prior to calling this. See
@@ -265,28 +266,28 @@ public:
@param addModelToPath set to true to add the model name to the
AircraftPath, defaults to true
@return true if successful*/
- bool LoadModel(string model, bool addModelToPath = true);
+ bool LoadModel(const string& model, bool addModelToPath = true);
/** Loads a script
@param Script the full path name and file name for the script to be loaded.
@return true if successfully loadsd; false otherwise. */
- bool LoadScript(string Script, double deltaT);
+ bool LoadScript(const string& Script, double deltaT);
/** Sets the path to the engine config file directories.
@param path path to the directory under which engine config
files are kept, for instance "engine" */
- bool SetEnginePath(string path) { EnginePath = RootDir + path; return true; }
+ bool SetEnginePath(const string& path) { EnginePath = RootDir + path; return true; }
/** Sets the path to the aircraft config file directories.
@param path path to the aircraft directory. For instance:
"aircraft". Under aircraft, then, would be directories for various
modeled aircraft such as C172/, x15/, etc. */
- bool SetAircraftPath(string path) { AircraftPath = RootDir + path; return true; }
+ bool SetAircraftPath(const string& path) { AircraftPath = RootDir + path; return true; }
/** Sets the path to the systems config file directories.
@param path path to the directory under which systems config
files are kept, for instance "systems" */
- bool SetSystemsPath(string path) { SystemsPath = RootDir + path; return true; }
+ bool SetSystemsPath(const string& path) { SystemsPath = RootDir + path; return true; }
/// @name Top-level executive State and Model retrieval mechanism
//@{
@@ -327,28 +328,28 @@ public:
//@}
/// Retrieves the engine path.
- inline string GetEnginePath(void) {return EnginePath;}
+ inline const string& GetEnginePath(void) {return EnginePath;}
/// Retrieves the aircraft path.
- inline string GetAircraftPath(void) {return AircraftPath;}
+ inline const string& GetAircraftPath(void) {return AircraftPath;}
/// Retrieves the systems path.
- inline string GetSystemsPath(void) {return SystemsPath;}
+ inline const string& GetSystemsPath(void) {return SystemsPath;}
/// Retrieves the full aircraft path name.
- inline string GetFullAircraftPath(void) {return FullAircraftPath;}
+ inline const string& GetFullAircraftPath(void) {return FullAircraftPath;}
/** Retrieves the value of a property.
@param property the name of the property
@result the value of the specified property */
- inline double GetPropertyValue(string property) {return instance->GetDouble(property);}
+ inline double GetPropertyValue(const string& property) {return instance->GetDouble(property);}
/** Sets a property value.
@param property the property to be set
@param value the value to set the property to */
- inline void SetPropertyValue(string property, double value) {
+ inline void SetPropertyValue(const string& property, double value) {
instance->SetDouble(property, value);
}
/// Returns the model name.
- string GetModelName(void) { return modelName; }
+ const string& GetModelName(void) { return modelName; }
/*
/// Returns the current time.
double GetSimTime(void);
@@ -382,12 +383,12 @@ public:
be logged.
@param fname the filename of an output directives file.
*/
- bool SetOutputDirectives(string fname);
+ bool SetOutputDirectives(const string& fname);
/** Sets (or overrides) the output filename
@param fname the name of the file to output data to
@return true if successful, false if there is no output specified for the flight model */
- bool SetOutputFileName(string fname) {
+ bool SetOutputFileName(const string& fname) {
if (Outputs.size() > 0) Outputs[0]->SetOutputFileName(fname);
else return false;
return true;
@@ -447,7 +448,7 @@ public:
* @param check The string to search for in the property catalog.
* @return the carriage-return-delimited string containing all matching strings
* in the catalog. */
- string QueryPropertyCatalog(string check);
+ string QueryPropertyCatalog(const string& check);
// Print the contents of the property catalog for the loaded aircraft.
void PrintPropertyCatalog(void);
@@ -495,11 +496,11 @@ public:
/** Sets the root directory where JSBSim starts looking for its system directories.
@param rootDir the string containing the root directory. */
- void SetRootDir(string rootDir) {RootDir = rootDir;}
+ void SetRootDir(const string& rootDir) {RootDir = rootDir;}
/** Retrieves teh Root Directory.
@return the string representing the root (base) JSBSim directory. */
- string GetRootDir(void) const {return RootDir;}
+ const string& GetRootDir(void) const {return RootDir;}
/** Increments the simulation time.
@return the new simulation time. */
@@ -512,7 +513,6 @@ public:
int GetDebugLevel(void) const {return debug_lvl;};
private:
- static unsigned int FDMctr;
int Error;
unsigned int Frame;
unsigned int IdFDM;
@@ -536,8 +536,6 @@ private:
bool trim_status;
int ta_mode;
- static FGPropertyManager *master;
-
FGGroundCallback* GroundCallback;
FGAtmosphere* Atmosphere;
FGFCS* FCS;
@@ -557,13 +555,18 @@ private:
FGTrim* Trim;
FGPropertyManager* Root;
+ bool delete_root;
FGPropertyManager* instance;
+
+ // The FDM counter is used to give each child FDM an unique ID. The root FDM has the ID 0
+ unsigned int* FDMctr;
vector PropertyCatalog;
vector Outputs;
vector ChildFDMList;
vector Models;
+ void Initialize();
bool ReadFileHeader(Element*);
bool ReadChild(Element*);
bool ReadPrologue(Element*);
diff --git a/src/FDM/JSBSim/FGState.cpp b/src/FDM/JSBSim/FGState.cpp
deleted file mode 100644
index 08e38a690..000000000
--- a/src/FDM/JSBSim/FGState.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- Module: FGState.cpp
- Author: Jon Berndt
- Date started: 11/17/98
- Called by: FGFDMExec and accessed by all models.
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more
- details.
-
- You should have received a copy of the GNU Lesser General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU Lesser General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-See header file.
-
-HISTORY
---------------------------------------------------------------------------------
-11/17/98 JSB Created
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-INCLUDES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#include
-#include
-
-#include "FGState.h"
-
-using namespace std;
-
-namespace JSBSim {
-
-static const char *IdSrc = "$Id: FGState.cpp,v 1.15 2009/10/24 22:59:30 jberndt Exp $";
-static const char *IdHdr = ID_STATE;
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-MACROS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-CLASS IMPLEMENTATION
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-FGState::FGState(FGFDMExec* fdex)
-{
- FDMExec = fdex;
-
- sim_time = 0.0;
- dt = 1.0/120.0; // a default timestep size. This is needed for when JSBSim is
- // run in standalone mode with no initialization file.
-
- Aircraft = FDMExec->GetAircraft();
- Propagate = FDMExec->GetPropagate();
- Auxiliary = FDMExec->GetAuxiliary();
- FCS = FDMExec->GetFCS();
- Atmosphere = FDMExec->GetAtmosphere();
- Aerodynamics = FDMExec->GetAerodynamics();
- GroundReactions = FDMExec->GetGroundReactions();
- Propulsion = FDMExec->GetPropulsion();
- PropertyManager = FDMExec->GetPropertyManager();
-
- bind();
-
- Debug(0);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGState::~FGState()
-{
- Debug(1);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGState::Initialize(FGInitialCondition *FGIC)
-{
- sim_time = 0.0;
-
- Propagate->SetInitialState( FGIC );
-
- Atmosphere->Run();
- Atmosphere->SetWindNED( FGIC->GetWindNFpsIC(),
- FGIC->GetWindEFpsIC(),
- FGIC->GetWindDFpsIC() );
-
- FGColumnVector3 vAeroUVW;
- vAeroUVW = Propagate->GetUVW() + Propagate->GetTl2b()*Atmosphere->GetTotalWindNED();
-
- double alpha, beta;
- if (vAeroUVW(eW) != 0.0)
- alpha = vAeroUVW(eU)*vAeroUVW(eU) > 0.0 ? atan2(vAeroUVW(eW), vAeroUVW(eU)) : 0.0;
- else
- alpha = 0.0;
- if (vAeroUVW(eV) != 0.0)
- beta = vAeroUVW(eU)*vAeroUVW(eU)+vAeroUVW(eW)*vAeroUVW(eW) > 0.0 ? atan2(vAeroUVW(eV), (fabs(vAeroUVW(eU))/vAeroUVW(eU))*sqrt(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW))) : 0.0;
- else
- beta = 0.0;
-
- Auxiliary->SetAB(alpha, beta);
-
- double Vt = vAeroUVW.Magnitude();
- Auxiliary->SetVt(Vt);
-
- Auxiliary->SetMach(Vt/Atmosphere->GetSoundSpeed());
-
- double qbar = 0.5*Vt*Vt*Atmosphere->GetDensity();
- Auxiliary->Setqbar(qbar);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGState::bind(void)
-{
- PropertyManager->Tie("sim-time-sec", this, &FGState::Getsim_time);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// The bitmasked value choices are as follows:
-// unset: In this case (the default) JSBSim would only print
-// out the normally expected messages, essentially echoing
-// the config files as they are read. If the environment
-// variable is not set, debug_lvl is set to 1 internally
-// 0: This requests JSBSim not to output any messages
-// whatsoever.
-// 1: This value explicity requests the normal JSBSim
-// startup messages
-// 2: This value asks for a message to be printed out when
-// a class is instantiated
-// 4: When this value is set, a message is displayed when a
-// FGModel object executes its Run() method
-// 8: When this value is set, various runtime state variables
-// are printed out periodically
-// 16: When set various parameters are sanity checked and
-// a message is printed out when they go out of bounds
-
-void FGState::Debug(int from)
-{
- if (debug_lvl <= 0) return;
-
- if (debug_lvl & 1) { // Standard console startup message output
- if (from == 0) { // Constructor
-
- }
- }
- if (debug_lvl & 2 ) { // Instantiation/Destruction notification
- if (from == 0) cout << "Instantiated: FGState" << endl;
- if (from == 1) cout << "Destroyed: FGState" << endl;
- }
- if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
- }
- if (debug_lvl & 8 ) { // Runtime state variables
- }
- if (debug_lvl & 16) { // Sanity checking
- }
- if (debug_lvl & 64) {
- if (from == 0) { // Constructor
- cout << IdSrc << endl;
- cout << IdHdr << endl;
- }
- }
-}
-}
diff --git a/src/FDM/JSBSim/FGState.h b/src/FDM/JSBSim/FGState.h
deleted file mode 100644
index 220f042fd..000000000
--- a/src/FDM/JSBSim/FGState.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- Header: FGState.h
- Author: Jon S. Berndt
- Date started: 11/17/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser 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 Lesser General Public License for more
- details.
-
- You should have received a copy of the GNU Lesser General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU Lesser General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-
-HISTORY
---------------------------------------------------------------------------------
-11/17/98 JSB Created
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-SENTRY
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#ifndef FGSTATE_H
-#define FGSTATE_H
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-INCLUDES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#include
-#include
-#include