1
0
Fork 0

Sep. 22, 2000 panel updates from David Megginson to make the new config file

panel be the default (sp_panel.* RIP).
This commit is contained in:
curt 2000-09-22 17:20:56 +00:00
parent bf14bb1151
commit e7df2d5dc8
10 changed files with 222 additions and 1164 deletions

View file

@ -10,7 +10,6 @@ libCockpit_a_SOURCES = \
panel.cxx panel.hxx \
panel_io.cxx panel_io.hxx \
radiostack.cxx radiostack.hxx \
sp_panel.cxx sp_panel.hxx \
steam.cxx steam.hxx
INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -68,6 +68,44 @@ FGTextureManager::createTexture (const string &relativePath)
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGCropped Texture.
////////////////////////////////////////////////////////////////////////
FGCroppedTexture::FGCroppedTexture ()
: _path(""), _texture(0),
_minX(0.0), _minY(0.0), _maxX(1.0), _maxY(1.0)
{
}
FGCroppedTexture::FGCroppedTexture (const string &path,
float minX, float minY,
float maxX, float maxY)
: _path(path), _texture(0),
_minX(minX), _minY(minY), _maxX(maxX), _maxY(maxY)
{
}
FGCroppedTexture::~FGCroppedTexture ()
{
}
ssgTexture *
FGCroppedTexture::getTexture ()
{
if (_texture == 0) {
_texture = FGTextureManager::createTexture(_path);
}
return _texture;
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGPanel.
@ -473,7 +511,7 @@ FGLayeredInstrument::addLayer (FGInstrumentLayer *layer)
}
int
FGLayeredInstrument::addLayer (CroppedTexture &texture,
FGLayeredInstrument::addLayer (FGCroppedTexture &texture,
int w, int h)
{
return addLayer(new FGTexturedLayer(texture, w, h));
@ -551,7 +589,7 @@ FGInstrumentLayer::addTransformation (FGPanelTransformation * transformation)
////////////////////////////////////////////////////////////////////////
FGTexturedLayer::FGTexturedLayer (const CroppedTexture &texture, int w, int h)
FGTexturedLayer::FGTexturedLayer (const FGCroppedTexture &texture, int w, int h)
: FGInstrumentLayer(w, h)
{
setTexture(texture);
@ -570,17 +608,22 @@ FGTexturedLayer::draw ()
int h2 = _h / 2;
transform();
glBindTexture(GL_TEXTURE_2D, _texture.texture->getHandle());
glBindTexture(GL_TEXTURE_2D, _texture.getTexture()->getHandle());
glBegin(GL_POLYGON);
// From Curt: turn on the panel
// lights after sundown.
if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
glColor4fv( cur_light_params.scene_diffuse );
} else {
glColor4f(0.7, 0.2, 0.2, 1.0);
}
glTexCoord2f(_texture.minX, _texture.minY); glVertex2f(-w2, -h2);
glTexCoord2f(_texture.maxX, _texture.minY); glVertex2f(w2, -h2);
glTexCoord2f(_texture.maxX, _texture.maxY); glVertex2f(w2, h2);
glTexCoord2f(_texture.minX, _texture.maxY); glVertex2f(-w2, h2);
glTexCoord2f(_texture.getMinX(), _texture.getMinY()); glVertex2f(-w2, -h2);
glTexCoord2f(_texture.getMaxX(), _texture.getMinY()); glVertex2f(w2, -h2);
glTexCoord2f(_texture.getMaxX(), _texture.getMaxY()); glVertex2f(w2, h2);
glTexCoord2f(_texture.getMinX(), _texture.getMaxY()); glVertex2f(-w2, h2);
glEnd();
}
@ -595,7 +638,7 @@ FGWindowLayer::FGWindowLayer (int w, int h)
{
}
FGWindowLayer::FGWindowLayer (const CroppedTexture &texture, int w, int h)
FGWindowLayer::FGWindowLayer (const FGCroppedTexture &texture, int w, int h)
: FGTexturedLayer(texture, w, h)
{
}

View file

@ -30,6 +30,8 @@
# include <config.h>
#endif
#include <simgear/compiler.h>
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
@ -72,17 +74,36 @@ private:
// This structure wraps an SSG texture with cropping information.
////////////////////////////////////////////////////////////////////////
struct CroppedTexture
class FGCroppedTexture
{
CroppedTexture () {}
CroppedTexture (const string &path,
float _minX = 0.0, float _minY = 0.0,
float _maxX = 1.0, float _maxY = 1.0)
: texture(FGTextureManager::createTexture(path)),
minX(_minX), minY(_minY), maxX(_maxX), maxY(_maxY) {}
public:
ssgTexture * texture;
float minX, minY, maxX, maxY;
FGCroppedTexture ();
FGCroppedTexture (const string &path,
float _minX = 0.0, float _minY = 0.0,
float _maxX = 1.0, float _maxY = 1.0);
virtual ~FGCroppedTexture ();
virtual void setPath (const string &path) { _path = path; }
virtual const string &getPath () const { return _path; }
virtual ssgTexture * getTexture ();
virtual void setCrop (float minX, float minY, float maxX, float maxY) {
_minX = minX; _minY = minY; _maxX = maxX; _maxY = maxY;
}
virtual float getMinX () const { return _minX; }
virtual float getMinY () const { return _minY; }
virtual float getMaxX () const { return _maxX; }
virtual float getMaxY () const { return _maxY; }
private:
string _path;
ssgTexture * _texture;
float _minX, _minY, _maxX, _maxY;
};
@ -400,7 +421,7 @@ public:
// Transfer pointer ownership!!
virtual int addLayer (FGInstrumentLayer *layer);
virtual int addLayer (CroppedTexture &texture, int w = -1, int h = -1);
virtual int addLayer (FGCroppedTexture &texture, int w = -1, int h = -1);
// Transfer pointer ownership!!
virtual void addTransformation (FGPanelTransformation * transformation);
@ -423,19 +444,19 @@ class FGTexturedLayer : public FGInstrumentLayer
{
public:
FGTexturedLayer (int w = -1, int h = -1) : FGInstrumentLayer(w, h) {}
FGTexturedLayer (const CroppedTexture &texture, int w = -1, int h = -1);
FGTexturedLayer (const FGCroppedTexture &texture, int w = -1, int h = -1);
virtual ~FGTexturedLayer ();
virtual void draw ();
virtual void setTexture (const CroppedTexture &texture) {
virtual void setTexture (const FGCroppedTexture &texture) {
_texture = texture;
}
virtual CroppedTexture &getTexture () { return _texture; }
virtual const CroppedTexture &getTexture () const { return _texture; }
virtual FGCroppedTexture &getTexture () { return _texture; }
virtual const FGCroppedTexture &getTexture () const { return _texture; }
private:
mutable CroppedTexture _texture;
mutable FGCroppedTexture _texture;
};
@ -451,7 +472,7 @@ class FGWindowLayer : public FGTexturedLayer
{
public:
FGWindowLayer (int w = -1, int h = -1);
FGWindowLayer (const CroppedTexture &texture, int w = -1, int h = -1);
FGWindowLayer (const FGCroppedTexture &texture, int w = -1, int h = -1);
virtual ~FGWindowLayer ();
virtual void draw ();

View file

@ -41,9 +41,9 @@
#include "steam.hxx"
#include "panel_io.hxx"
using std::istream;
using std::ifstream;
using std::string;
FG_USING_STD(istream);
FG_USING_STD(ifstream);
FG_USING_STD(string);
@ -66,7 +66,7 @@ public:
FGMagRibbon::FGMagRibbon (int w, int h)
: FGTexturedLayer(w, h)
{
CroppedTexture texture("Instruments/Default/Textures/compass-ribbon.rgb");
FGCroppedTexture texture("Instruments/Default/Textures/compass-ribbon.rgb");
setTexture(texture);
}
@ -103,11 +103,8 @@ FGMagRibbon::draw ()
// Adjust to put the number in the centre
xoffset -= 0.25;
CroppedTexture &t = getTexture();
t.minX = xoffset;
t.minY = yoffset;
t.maxX = xoffset + 0.5;
t.maxY = yoffset + 0.25;
FGCroppedTexture &t = getTexture();
t.setCrop(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25);
FGTexturedLayer::draw();
}
@ -167,10 +164,10 @@ FGMagRibbon::draw ()
* ending position. For example, to use the bottom-left quarter of a
* texture, x1=0.0, y1=0.0, x2=0.5, y2=0.5.
*/
static CroppedTexture
static FGCroppedTexture
readTexture (SGPropertyNode node)
{
CroppedTexture texture(node.getStringValue("path"),
FGCroppedTexture texture(node.getStringValue("path"),
node.getFloatValue("x1"),
node.getFloatValue("y1"),
node.getFloatValue("x2", 1.0),
@ -440,7 +437,7 @@ readTextChunk (SGPropertyNode node)
static FGInstrumentLayer *
readLayer (SGPropertyNode node, float hscale, float vscale)
{
FGInstrumentLayer * layer;
FGInstrumentLayer * layer = NULL;
string name = node.getStringValue("name");
string type = node.getStringValue("type");
int w = node.getIntValue("w", -1);
@ -461,7 +458,7 @@ readLayer (SGPropertyNode node, float hscale, float vscale)
// A textured instrument layer.
if (type == "texture") {
CroppedTexture texture = readTexture(node.getSubNode("texture"));
FGCroppedTexture texture = readTexture(node.getSubNode("texture"));
layer = new FGTexturedLayer(texture, w, h);
}
@ -499,7 +496,7 @@ readLayer (SGPropertyNode node, float hscale, float vscale)
// A switch instrument layer.
else if (type == "switch") {
SGValue * value =
current_properties.getValue(node.getStringValue("property"));
current_properties.getValue(node.getStringValue("property"), true);
FGInstrumentLayer * layer1 =
readLayer(node.getSubNode("layer1"), hscale, vscale);
FGInstrumentLayer * layer2 =

File diff suppressed because it is too large Load diff

View file

@ -1,35 +0,0 @@
// sp_panel.hxx - default, 2D single-engine prop instrument panel
//
// Written by David Megginson, started January 2000.
//
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#include "panel.hxx"
extern FGPanel * fgCreateSmallSinglePropPanel (int x, int y,
int finx, int finy);
// end of sp_panel.hxx

View file

@ -96,6 +96,8 @@ FGBFI::init ()
// current_properties.tieString("/sim/aircraft",
// getAircraft, setAircraft);
// TODO: timeGMT
current_properties.tieString("/sim/time/gmt-string",
getGMTString, 0);
current_properties.tieBool("/sim/hud/visibility",
getHUDVisible, setHUDVisible);
current_properties.tieBool("/sim/panel/visibility",
@ -190,6 +192,10 @@ FGBFI::init ()
getNAV1SelRadial, setNAV1SelRadial);
current_properties.tieDouble("/radios/nav1/dme/distance",
getNAV1DistDME, 0);
current_properties.tieBool("/radios/nav1/to-flag",
getNAV1TO, 0);
current_properties.tieBool("/radios/nav1/from-flag",
getNAV1FROM, 0);
current_properties.tieBool("/radios/nav1/in-range",
getNAV1InRange, 0);
current_properties.tieBool("/radios/nav1/dme/in-range",
@ -205,6 +211,10 @@ FGBFI::init ()
getNAV2SelRadial, setNAV2SelRadial);
current_properties.tieDouble("/radios/nav2/dme/distance",
getNAV2DistDME, 0);
current_properties.tieBool("/radios/nav2/to-flag",
getNAV2TO, 0);
current_properties.tieBool("/radios/nav2/from-flag",
getNAV2FROM, 0);
current_properties.tieBool("/radios/nav2/in-range",
getNAV2InRange, 0);
current_properties.tieBool("/radios/nav2/dme/in-range",
@ -416,6 +426,22 @@ FGBFI::setTimeGMT (time_t time)
}
/**
* Return the GMT as a string.
*/
const string &
FGBFI::getGMTString ()
{
static string out; // FIXME: not thread-safe
char buf[16];
struct tm * t = globals->get_time_params()->getGmt();
sprintf(buf, " %.2d:%.2d:%.2d",
t->tm_hour, t->tm_min, t->tm_sec);
out = buf;
return out;
}
/**
* Return true if the HUD is visible.
*/
@ -1147,6 +1173,46 @@ FGBFI::getNAV1DistDME ()
return current_radiostack->get_nav1_dme_dist();
}
bool
FGBFI::getNAV1TO ()
{
if (current_radiostack->get_nav1_inrange()) {
double heading = current_radiostack->get_nav1_heading();
double radial = current_radiostack->get_nav1_radial();
double var = FGBFI::getMagVar();
if (current_radiostack->get_nav1_loc()) {
double offset = fabs(heading - radial);
return (offset<= 8.0 || offset >= 352.0);
} else {
double offset =
fabs(heading - var - radial);
return (offset <= 20.0 || offset >= 340.0);
}
} else {
return false;
}
}
bool
FGBFI::getNAV1FROM ()
{
if (current_radiostack->get_nav1_inrange()) {
double heading = current_radiostack->get_nav1_heading();
double radial = current_radiostack->get_nav1_radial();
double var = FGBFI::getMagVar();
if (current_radiostack->get_nav1_loc()) {
double offset = fabs(heading - radial);
return (offset >= 172.0 && offset<= 188.0);
} else {
double offset =
fabs(heading - var - radial);
return (offset >= 160.0 && offset <= 200.0);
}
} else {
return false;
}
}
bool
FGBFI::getNAV1InRange ()
{
@ -1190,6 +1256,47 @@ FGBFI::getNAV2DistDME ()
return current_radiostack->get_nav2_dme_dist();
}
bool
FGBFI::getNAV2TO ()
{
if (current_radiostack->get_nav2_inrange()) {
double heading = current_radiostack->get_nav2_heading();
double radial = current_radiostack->get_nav2_radial();
double var = FGBFI::getMagVar();
if (current_radiostack->get_nav2_loc()) {
double offset = fabs(heading - radial);
return (offset<= 8.0 || offset >= 352.0);
} else {
double offset =
fabs(heading - var - radial);
return (offset <= 20.0 || offset >= 340.0);
}
} else {
return false;
}
}
bool
FGBFI::getNAV2FROM ()
{
if (current_radiostack->get_nav2_inrange()) {
double heading = current_radiostack->get_nav2_heading();
double radial = current_radiostack->get_nav2_radial();
double var = FGBFI::getMagVar();
if (current_radiostack->get_nav2_loc()) {
double offset = fabs(heading - radial);
return (offset >= 172.0 && offset<= 188.0);
} else {
double offset =
fabs(heading - var - radial);
return (offset >= 160.0 && offset <= 200.0);
}
} else {
return false;
}
}
bool
FGBFI::getNAV2InRange ()
{

View file

@ -57,6 +57,7 @@ public:
static const string getAircraft ();
static const string getAircraftDir ();
static time_t getTimeGMT ();
static const string &getGMTString ();
static bool getHUDVisible ();
static bool getPanelVisible ();
@ -149,6 +150,8 @@ public:
static double getNAV1Radial ();
static double getNAV1SelRadial ();
static double getNAV1DistDME ();
static bool getNAV1TO ();
static bool getNAV1FROM ();
static bool getNAV1InRange ();
static bool getNAV1DMEInRange ();
@ -157,6 +160,8 @@ public:
static double getNAV2Radial ();
static double getNAV2SelRadial ();
static double getNAV2DistDME ();
static bool getNAV2TO ();
static bool getNAV2FROM ();
static bool getNAV2InRange ();
static bool getNAV2DMEInRange ();

View file

@ -63,7 +63,7 @@
#include <Cockpit/cockpit.hxx>
#include <Cockpit/radiostack.hxx>
#include <Cockpit/panel.hxx>
#include <Cockpit/sp_panel.hxx>
#include <Cockpit/panel_io.hxx>
#include <FDM/Balloon.h>
#include <FDM/External.hxx>
#include <FDM/JSBSim.hxx>
@ -700,7 +700,16 @@ bool fgInitSubsystems( void ) {
#endif
// Initialize the 2D panel.
current_panel = fgCreateSmallSinglePropPanel(0, 0, 1024, 768);
string panel_path =
current_properties.getStringValue("/sim/panel",
"Panels/Default/default.xml");
current_panel = fgReadPanel(panel_path);
if (current_panel == 0) {
FG_LOG(FG_INPUT, FG_ALERT,
"Error reading new panel from " << panel_path);
}
FG_LOG(FG_INPUT, FG_INFO, "Loaded new panel from " << panel_path);
// current_panel = fgCreateSmallSinglePropPanel(0, 0, 1024, 768);
// Initialize the BFI
FGBFI::init();

View file

@ -55,7 +55,6 @@
#include <Cockpit/hud.hxx>
#include <Cockpit/panel.hxx>
#include <Cockpit/panel_io.hxx>
#include <Cockpit/sp_panel.hxx>
#include <GUI/gui.h>
#include <Scenery/tilemgr.hxx>
#include <Objects/matlib.hxx>