1
0
Fork 0

Merge branch 'next' of gitorious.org:fg/flightgear into next

This commit is contained in:
Dave Luff 2010-12-09 23:38:18 +00:00
commit 3d4d621a3b
11 changed files with 190 additions and 52 deletions

View file

@ -156,7 +156,9 @@ FGEnvironmentMgr::bind ()
&FGEnvironmentMgr::get_cloud_layer_visibility_m,
&FGEnvironmentMgr::set_cloud_layer_visibility_m);
_tiedProperties.Tie( layerNode->getNode( "alpha",true), this, i,
&FGEnvironmentMgr::get_cloud_layer_maxalpha,
&FGEnvironmentMgr::set_cloud_layer_maxalpha);
}
_tiedProperties.setRoot( fgGetNode("/sim/rendering", true ) );
@ -332,6 +334,19 @@ FGEnvironmentMgr::set_cloud_layer_visibility_m (int index, double visibility_m)
thesky->get_cloud_layer(index)->setVisibility_m(visibility_m);
}
double
FGEnvironmentMgr::get_cloud_layer_maxalpha (int index ) const
{
return thesky->get_cloud_layer(index)->getMaxAlpha();
}
void
FGEnvironmentMgr::set_cloud_layer_maxalpha (int index, double maxalpha)
{
thesky->get_cloud_layer(index)->setMaxAlpha(maxalpha);
}
void

View file

@ -89,6 +89,8 @@ private:
void set_cloud_layer_coverage_type (int index, int type );
double get_cloud_layer_visibility_m (int index) const;
void set_cloud_layer_visibility_m (int index, double visibility_m);
double get_cloud_layer_maxalpha (int index ) const;
void set_cloud_layer_maxalpha (int index, double maxalpha);
FGEnvironment * _environment; // always the same, for now
FGClouds *fgClouds;

View file

@ -239,26 +239,46 @@ void MetarProperties::set_metar( const char * metar )
unsigned layerOffset = 0; // Oh, this is ugly!
bool setGroundCloudLayer = _rootNode->getBoolValue("set-ground-cloud-layer", false );
if( setGroundCloudLayer && isFG ) {
// make sure fog actually starts at ground and set it's bottom at a constant
if( setGroundCloudLayer ) {
// create a cloud layer #0 starting at the ground if its fog, mist or haze
// make sure layer actually starts at ground and set it's bottom at a constant
// value below the station's elevation
const double LAYER_BOTTOM_BELOW_STATION_ELEVATION=200;
// fog - create a cloud layer #0 starting at the ground
SGMetarCloud::Coverage coverage = SGMetarCloud::COVERAGE_NIL;
double thickness = 0;
double alpha = 1.0;
if( isFG ) { // fog
coverage = isBC ? SGMetarCloud::COVERAGE_SCATTERED : SGMetarCloud::COVERAGE_BROKEN;
thickness = isMI ?
30 + LAYER_BOTTOM_BELOW_STATION_ELEVATION : // shallow fog, 10m/30ft
500 + LAYER_BOTTOM_BELOW_STATION_ELEVATION; // fog, 150m/500ft
alpha = 1.0;
} else if( isBR ) { // mist
coverage = SGMetarCloud::COVERAGE_OVERCAST;
thickness = 2000 + LAYER_BOTTOM_BELOW_STATION_ELEVATION;
alpha = 0.8;
} else if( isHZ ) { // hase
coverage = SGMetarCloud::COVERAGE_OVERCAST;
thickness = 2000 + LAYER_BOTTOM_BELOW_STATION_ELEVATION;
alpha = 0.6;
}
// fog is "overcast" by default of "broken" for patches of fog
SGPropertyNode_ptr layerNode = cloudsNode->getChild(LAYER, 0, true );
SGMetarCloud::Coverage coverage = isBC ? SGMetarCloud::COVERAGE_SCATTERED : SGMetarCloud::COVERAGE_BROKEN;
layerNode->setDoubleValue( "coverage-type", SGCloudLayer::getCoverageType(coverage_string[coverage]) );
layerNode->setStringValue( "coverage", coverage_string[coverage] );
layerNode->setDoubleValue( "elevation-ft", _station_elevation - LAYER_BOTTOM_BELOW_STATION_ELEVATION );
layerNode->setDoubleValue( "thickness-ft", isMI ?
30 + LAYER_BOTTOM_BELOW_STATION_ELEVATION : // shallow fog, 10m/30ft
500 + LAYER_BOTTOM_BELOW_STATION_ELEVATION ); // fog, 150m/500ft
layerNode->setDoubleValue( "visibility-m", _min_visibility );
_min_visibility = _max_visibility = 20000.0; // assume good visibility above the fog
layerOffset = 1; // shudder
} else if( setGroundCloudLayer && isHZ ) {
}
if( coverage != SGMetarCloud::COVERAGE_NIL ) {
SGPropertyNode_ptr layerNode = cloudsNode->getChild(LAYER, 0, true );
layerNode->setDoubleValue( "coverage-type", SGCloudLayer::getCoverageType(coverage_string[coverage]) );
layerNode->setStringValue( "coverage", coverage_string[coverage] );
layerNode->setDoubleValue( "elevation-ft", _station_elevation - LAYER_BOTTOM_BELOW_STATION_ELEVATION );
layerNode->setDoubleValue( "thickness-ft", thickness );
layerNode->setDoubleValue( "visibility-m", _min_visibility );
layerNode->setDoubleValue( "alpha", alpha );
_min_visibility = _max_visibility = 20000.0; // assume good visibility above the fog
layerOffset = 1; // shudder
}
}
for( unsigned i = 0; i < 5-layerOffset; i++ ) {
SGPropertyNode_ptr layerNode = cloudsNode->getChild(LAYER, i+layerOffset, true );

View file

@ -818,6 +818,7 @@ void ScrolledWaypointList::setScrollPercent(float v)
void ScrolledWaypointList::setSize(int w, int h)
{
updateWantsScroll(w, h);
puGroup::setSize(w, h);
}
void ScrolledWaypointList::updateWantsScroll(int w, int h)

View file

@ -1376,4 +1376,36 @@ int fgComboBox::checkHit(int b, int up, int x, int y)
return r;
}
void fgComboBox::setSize(int w, int h)
{
puaComboBox::setSize(w, h);
recalc_bbox();
}
void fgComboBox::recalc_bbox()
{
// bug-fix for issue #192
// http://code.google.com/p/flightgear-bugs/issues/detail?id=192
// puaComboBox is including the height of its popupMenu in the height
// computation, which breaks layout computations.
// this implementation skips popup-menus
puBox contents;
contents.empty();
for (puObject *bo = dlist; bo != NULL; bo = bo -> getNextObject()) {
if (bo->getType() & PUCLASS_POPUPMENU) {
continue;
}
contents.extend (bo -> getBBox()) ;
}
abox.max[0] = abox.min[0] + contents.max[0] ;
abox.max[1] = abox.min[1] + contents.max[1] ;
puObject::recalc_bbox () ;
}
// end of dialog.cxx

View file

@ -266,8 +266,11 @@ public:
void update();
virtual void setSize(int w, int h);
virtual int checkHit(int b, int up, int x, int y);
virtual void recalc_bbox();
private:
bool _inHit;
};

View file

@ -80,7 +80,7 @@ void LayoutWidget::calcPrefSize(int* w, int* h)
if(getBool("vertical")) *w = 4*UNIT;
else *h = 4*UNIT;
} else if (isType("list") || isType("airport-list")
|| isType("property-list") || isType("dial")) {
|| isType("property-list") || isType("dial") || isType("waypointlist")) {
*w = *h = 12*UNIT;
} else if (isType("hrule")) {
*h = 1;

View file

@ -1256,6 +1256,30 @@ fgOptFgviewer(const char* arg)
return FG_OPTIONS_OK;
}
static int
fgOptCallSign(const char * arg)
{
int i;
char callsign[11];
strncpy(callsign,arg,10);
callsign[10]=0;
for (i=0;callsign[i];i++)
{
switch (callsign[i])
{
case 'A'...'Z':break;
case 'a'...'z':break;
case '0'...'9':break;
case '_':case '-':break;
default:
// convert any other illegal characters
callsign[i]='-';
break;
}
}
fgSetString("sim/multiplay/callsign", callsign );
return FG_OPTIONS_OK;
}
static map<string,size_t> fgOptionMap;
@ -1440,7 +1464,7 @@ struct OptionDesc {
{"joyclient", true, OPTION_CHANNEL, "", false, "", 0 },
{"jsclient", true, OPTION_CHANNEL, "", false, "", 0 },
{"proxy", true, OPTION_FUNC, "", false, "", fgSetupProxy },
{"callsign", true, OPTION_STRING, "sim/multiplay/callsign", false, "", 0 },
{"callsign", true, OPTION_FUNC, "", false, "", fgOptCallSign},
{"multiplay", true, OPTION_CHANNEL, "", false, "", 0 },
{"trace-read", true, OPTION_FUNC, "", false, "", fgOptTraceRead },
{"trace-write", true, OPTION_FUNC, "", false, "", fgOptTraceWrite },

View file

@ -34,6 +34,7 @@
#include <simgear/misc/sg_path.hxx>
#include <simgear/structure/exception.hxx>
#include <simgear/misc/sgstream.hxx>
#include <simgear/props/props_io.hxx>
#include "navrecord.hxx"
#include "navlist.hxx"
@ -41,9 +42,16 @@
#include <Main/globals.hxx>
#include <Navaids/markerbeacon.hxx>
#include <Airports/simple.hxx>
#include <Airports/runways.hxx>
#include <Airports/xmlloader.hxx>
#include <Main/fg_props.hxx>
using std::string;
typedef std::map<FGAirport*, SGPropertyNode_ptr> AirportPropertyMap;
static AirportPropertyMap static_airportIlsData;
static FGPositioned::Type
mapRobinTypeToFGPType(int aTy)
{
@ -223,9 +231,62 @@ bool fgNavDBInit( FGNavList *navlist, FGNavList *loclist, FGNavList *gslist,
// end ReadChanFile
// flush all the parsed ils.xml data, we don't need it anymore,
// since it's been meregd into the FGNavRecords
static_airportIlsData.clear();
return true;
}
SGPropertyNode* ilsDataForRunwayAndNavaid(FGRunway* aRunway, const std::string& aNavIdent)
{
if (!fgGetBool("/sim/paths/use-custom-scenery-data")) {
return NULL;
}
if (!aRunway) {
return NULL;
}
FGAirport* apt = aRunway->airport();
// find (or load) the airprot ILS data
AirportPropertyMap::iterator it = static_airportIlsData.find(apt);
if (it == static_airportIlsData.end()) {
SGPath path;
if (!XMLLoader::findAirportData(apt->ident(), "ils", path)) {
// no ils.xml file for this airpot, insert a NULL entry so we don't
// check again
static_airportIlsData.insert(it, std::make_pair(apt, SGPropertyNode_ptr()));
return NULL;
}
SGPropertyNode_ptr rootNode = new SGPropertyNode;
readProperties(path.str(), rootNode);
it = static_airportIlsData.insert(it, std::make_pair(apt, rootNode));
} // of ils.xml file not loaded
if (!it->second) {
return NULL;
}
// find the entry matching the runway
SGPropertyNode* runwayNode, *ilsNode;
for (int i=0; (runwayNode = it->second->getChild("runway", i)) != NULL; ++i) {
for (int j=0; (ilsNode = runwayNode->getChild("ils", j)) != NULL; ++j) {
// must match on both nav-ident and runway ident, to support the following:
// - runways with multiple distinct ILS installations (KEWD, for example)
// - runways where both ends share the same nav ident (LFAT, for example)
if ((ilsNode->getStringValue("nav-id") == aNavIdent) &&
(ilsNode->getStringValue("rwy") == aRunway->ident()))
{
return ilsNode;
}
} // of ILS iteration
} // of runway iteration
return NULL;
}
FGRunway* getRunwayFromName(const std::string& aName)
{
vector<string> parts = simgear::strutils::split(aName);

View file

@ -37,6 +37,13 @@ bool fgNavDBInit( FGNavList *navlist, FGNavList *loclist, FGNavList *gslist,
FGTACANList *channellist );
/**
* Return the property node corresponding to the runway ILS installation,
* from the Airports/I/C/A/ICAO.ils.xml file (loading it if necessary)
* returns NULL is no ILS data is defined for the runway.
*/
SGPropertyNode* ilsDataForRunwayAndNavaid(FGRunway* aRunway, const std::string& aNavIdent);
/**
* Helper to map a nav.data name (eg 'KBWI 33R GS') into a FGRunway reference.
* returns NULL, and complains loudly, if the airport/runway is not found.

View file

@ -32,7 +32,7 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/sg_inlines.h>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include <Navaids/navrecord.hxx>
#include <Navaids/navdb.hxx>
@ -97,7 +97,10 @@ void FGNavRecord::initAirportRelation()
}
if (type() != GS) {
readAirportSceneryData();
SGPropertyNode* ilsData = ilsDataForRunwayAndNavaid(mRunway, ident());
if (ilsData) {
processSceneryILS(ilsData);
}
}
// fudge elevation to the runway elevation if it's not specified
@ -121,36 +124,6 @@ void FGNavRecord::initAirportRelation()
}
}
void FGNavRecord::readAirportSceneryData()
{
// allow users to disable the scenery data in the short-term
// longer term, this option can probably disappear
if (!fgGetBool("/sim/use-scenery-airport-data")) {
return;
}
SGPath path;
SGPropertyNode_ptr rootNode = new SGPropertyNode;
if (!XMLLoader::findAirportData(mRunway->airport()->ident(), "ils", path)) {
return;
}
readProperties(path.str(), rootNode);
SGPropertyNode* runwayNode, *ilsNode;
for (int i=0; (runwayNode = rootNode->getChild("runway", i)) != NULL; ++i) {
for (int j=0; (ilsNode = runwayNode->getChild("ils", j)) != NULL; ++j) {
// must match on both nav-ident and runway ident, to support the following:
// - runways with multiple distinct ILS installations (KEWD, for example)
// - runways where both ends share the same nav ident (LFAT, for example)
if ((ilsNode->getStringValue("nav-id") == ident()) &&
(ilsNode->getStringValue("rwy") == mRunway->ident())) {
processSceneryILS(ilsNode);
return;
}
} // of ILS iteration
} // of runway iteration
}
void FGNavRecord::processSceneryILS(SGPropertyNode* aILSNode)
{
double hdgDeg = aILSNode->getDoubleValue("hdg-deg"),