LandscapeMgr.cpp   LandscapeMgr.cpp 
skipping to change at line 144 skipping to change at line 144
{ {
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getAppStelTranslator(); const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getAppStelTranslator();
sNorth = trans.qtranslate("N"); sNorth = trans.qtranslate("N");
sSouth = trans.qtranslate("S"); sSouth = trans.qtranslate("S");
sEast = trans.qtranslate("E"); sEast = trans.qtranslate("E");
sWest = trans.qtranslate("W"); sWest = trans.qtranslate("W");
} }
LandscapeMgr::LandscapeMgr() LandscapeMgr::LandscapeMgr()
: StelModule() : StelModule()
, atmosphere(NULL) , atmosphere(Q_NULLPTR)
, cardinalsPoints(NULL) , cardinalsPoints(Q_NULLPTR)
, landscape(NULL) , landscape(Q_NULLPTR)
, oldLandscape(NULL) , oldLandscape(Q_NULLPTR)
, flagLandscapeSetsLocation(false) , flagLandscapeSetsLocation(false)
, flagLandscapeAutoSelection(false) , flagLandscapeAutoSelection(false)
, flagLightPollutionFromDatabase(false) , flagLightPollutionFromDatabase(false)
, flagLandscapeUseMinimalBrightness(false) , flagLandscapeUseMinimalBrightness(false)
, defaultMinimalBrightness(0.01) , defaultMinimalBrightness(0.01)
, flagLandscapeSetsMinimalBrightness(false) , flagLandscapeSetsMinimalBrightness(false)
, flagAtmosphereAutoEnabling(false) , flagAtmosphereAutoEnabling(false)
{ {
setObjectName("LandscapeMgr"); // should be done by StelModule's con structor. setObjectName("LandscapeMgr"); // should be done by StelModule's con structor.
skipping to change at line 177 skipping to change at line 177
landscapeCache.clear(); landscapeCache.clear();
} }
LandscapeMgr::~LandscapeMgr() LandscapeMgr::~LandscapeMgr()
{ {
delete atmosphere; delete atmosphere;
delete cardinalsPoints; delete cardinalsPoints;
if (oldLandscape) if (oldLandscape)
{ {
delete oldLandscape; delete oldLandscape;
oldLandscape=NULL; oldLandscape=Q_NULLPTR;
} }
delete landscape; delete landscape;
landscape = NULL; landscape = Q_NULLPTR;
qDebug() << "LandscapeMgr: Clearing cache of" << landscapeCache.size () << "landscapes totalling about " << landscapeCache.totalCost() << "MB."; qDebug() << "LandscapeMgr: Clearing cache of" << landscapeCache.size () << "landscapes totalling about " << landscapeCache.totalCost() << "MB.";
landscapeCache.clear(); // deletes all objects within. landscapeCache.clear(); // deletes all objects within.
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double LandscapeMgr::getCallOrder(StelModuleActionName actionName) const double LandscapeMgr::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
skipping to change at line 218 skipping to change at line 218
if (getIsLandscapeFullyVisible()) if (getIsLandscapeFullyVisible())
{ {
oldLandscape->setFlagShow(false); oldLandscape->setFlagShow(false);
if (oldLandscape->getEffectiveLandFadeValue()< 0.01f ) if (oldLandscape->getEffectiveLandFadeValue()< 0.01f )
{ {
// new logic: try to put old landscape to ca che. // new logic: try to put old landscape to ca che.
//qDebug() << "LandscapeMgr::update: moving oldLandscape " << oldLandscape->getId() << "to Cache. Cost:" << oldLandscap e->getMemorySize()/(1024*1024)+1; //qDebug() << "LandscapeMgr::update: moving oldLandscape " << oldLandscape->getId() << "to Cache. Cost:" << oldLandscap e->getMemorySize()/(1024*1024)+1;
landscapeCache.insert(oldLandscape->getId(), oldLandscape, oldLandscape->getMemorySize()/(1024*1024)+1); landscapeCache.insert(oldLandscape->getId(), oldLandscape, oldLandscape->getMemorySize()/(1024*1024)+1);
//qDebug() << "--> LandscapeMgr::update(): c ache now contains " << landscapeCache.size() << "landscapes totalling about " << landscapeCache.totalCost() << "MB."; //qDebug() << "--> LandscapeMgr::update(): c ache now contains " << landscapeCache.size() << "landscapes totalling about " << landscapeCache.totalCost() << "MB.";
oldLandscape=NULL; oldLandscape=Q_NULLPTR;
} }
} }
} }
landscape->update(deltaTime); landscape->update(deltaTime);
cardinalsPoints->update(deltaTime); cardinalsPoints->update(deltaTime);
// Compute the atmosphere color and intensity // Compute the atmosphere color and intensity
// Compute the sun position in local coordinate // Compute the sun position in local coordinate
SolarSystem* ssystem = (SolarSystem*)StelApp::getInstance().getModul eMgr().getModule("SolarSystem"); SolarSystem* ssystem = (SolarSystem*)StelApp::getInstance().getModul eMgr().getModule("SolarSystem");
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
Vec3d sunPos = ssystem->getSun()->getAltAzPosAuto(core); Vec3d sunPos = ssystem->getSun()->getAltAzPosAuto(core);
// Compute the moon position in local coordinate // Compute the moon position in local coordinate
Vec3d moonPos = ssystem->getMoon()->getAltAzPosAuto(core); Vec3d moonPos = ssystem->getMoon()->getAltAzPosAuto(core);
float lunarPhaseAngle=ssystem->getMoon()->getPhaseAngle(ssystem->get Earth()->getHeliocentricEclipticPos()); float lunarPhaseAngle=ssystem->getMoon()->getPhaseAngle(ssystem->get Earth()->getHeliocentricEclipticPos());
float lunarMagnitude=ssystem->getMoon()->getVMagnitudeWithExtinction (core);
// LP:1673283 no lunar brightening if not on Earth! // LP:1673283 no lunar brightening if not on Earth!
if (core->getCurrentLocation().planetName != "Earth") if (core->getCurrentLocation().planetName != "Earth")
{ {
moonPos=sunPos; moonPos=sunPos;
lunarPhaseAngle=0.0f; lunarPhaseAngle=0.0f;
} }
// GZ: First parameter in next call is used for particularly earth-b ound computations in Schaefer's sky brightness model. Difference DeltaT mak es no difference here. // GZ: First parameter in next call is used for particularly earth-b ound computations in Schaefer's sky brightness model. Difference DeltaT mak es no difference here.
atmosphere->computeColor(core->getJDE(), sunPos, moonPos, lunarPhase Angle, atmosphere->computeColor(core->getJDE(), sunPos, moonPos, lunarPhase Angle, lunarMagnitude,
core, core->getCurrentLocation().latitude, core->getCurrentL ocation().altitude, core, core->getCurrentLocation().latitude, core->getCurrentL ocation().altitude,
15.f, 40.f); // Temperature = 15c, relative humidity = 40 % 15.f, 40.f); // Temperature = 15c, relative humidity = 40 %
core->getSkyDrawer()->reportLuminanceInFov(3.75+atmosphere->getAvera geLuminance()*3.5, true); core->getSkyDrawer()->reportLuminanceInFov(3.75+atmosphere->getAvera geLuminance()*3.5, true);
// NOTE: Simple workaround for brightness of landscape when observin g from the Sun. // NOTE: Simple workaround for brightness of landscape when observin g from the Sun.
if (core->getCurrentLocation().planetName == "Sun") if (core->getCurrentLocation().planetName == "Sun")
{ {
landscape->setBrightness(1.0f, 1.0f); landscape->setBrightness(1.0f, 1.0f);
return; return;
skipping to change at line 308 skipping to change at line 309
float sinSunAngle = 0.0f; float sinSunAngle = 0.0f;
if(atmosphere->getFlagShow()) if(atmosphere->getFlagShow())
{ {
sinSunAngle=sin(qMin(M_PI_2, asin(sunPos[2])+8.*M_PI/180.)); sinSunAngle=sin(qMin(M_PI_2, asin(sunPos[2])+8.*M_PI/180.));
if(sinSunAngle > -0.1/1.5 ) if(sinSunAngle > -0.1/1.5 )
landscapeBrightness += 1.5*(sinSunAngle+0.1/1.5); landscapeBrightness += 1.5*(sinSunAngle+0.1/1.5);
} }
else else
{ {
// In case we have exceptionally deep horizons ("Little Prin ce planet"), the sun will rise somehow over that line and demand light on t he landscape. // In case we have exceptionally deep horizons ("Little Prin ce planet"), the sun will rise somehow over that line and demand light on t he landscape.
sinSunAngle=sin(qMin(M_PI_2, asin(qMax(-1.0, qMin(1.0, sunPo s[2]-landscape->getSinMinAltitudeLimit()))) + (0.25f *M_PI/180.))); sinSunAngle=sin(qMin(M_PI_2, asin(qBound(-1.0, sunPos[2]-lan dscape->getSinMinAltitudeLimit(), 1.0) ) + (0.25f *M_PI/180.)));
if(sinSunAngle > 0.0f) if(sinSunAngle > 0.0f)
landscapeBrightness += (1.0f-landscape->getOpacity( sunPos))*sinSunAngle; landscapeBrightness += (1.0f-landscape->getOpacity( sunPos))*sinSunAngle;
} }
// GZ: 2013-09-25 Take light pollution into account! // GZ: 2013-09-25 Take light pollution into account!
StelSkyDrawer* drawer=StelApp::getInstance().getCore()->getSkyDrawer (); StelSkyDrawer* drawer=StelApp::getInstance().getCore()->getSkyDrawer ();
float pollutionAddonBrightness=(drawer->getBortleScaleIndex()-1.0f)* 0.025f; // 0..8, so we assume empirical linear brightening 0..0.02 float pollutionAddonBrightness=(drawer->getBortleScaleIndex()-1.0f)* 0.025f; // 0..8, so we assume empirical linear brightening 0..0.02
float lunarAddonBrightness=0.f; float lunarAddonBrightness=0.f;
if (moonPos[2] > -0.1/1.5) if (moonPos[2] > -0.1/1.5)
skipping to change at line 925 skipping to change at line 926
QSettings landscapeIni(landscapeFile, StelIniFormat); QSettings landscapeIni(landscapeFile, StelIniFormat);
QString s; QString s;
if (landscapeIni.status() != QSettings::NoError) if (landscapeIni.status() != QSettings::NoError)
{ {
qWarning() << "ERROR parsing landscape.ini file: " << QDir:: toNativeSeparators(landscapeFile); qWarning() << "ERROR parsing landscape.ini file: " << QDir:: toNativeSeparators(landscapeFile);
s = ""; s = "";
} }
else else
s = landscapeIni.value("landscape/type").toString(); s = landscapeIni.value("landscape/type").toString();
Landscape* ldscp = NULL; Landscape* landscape = Q_NULLPTR;
if (s=="old_style") if (s=="old_style")
ldscp = new LandscapeOldStyle(); landscape = new LandscapeOldStyle();
else if (s=="spherical") else if (s=="spherical")
ldscp = new LandscapeSpherical(); landscape = new LandscapeSpherical();
else if (s=="fisheye") else if (s=="fisheye")
ldscp = new LandscapeFisheye(); landscape = new LandscapeFisheye();
else if (s=="polygonal") else if (s=="polygonal")
ldscp = new LandscapePolygonal(); landscape = new LandscapePolygonal();
else else
{ {
qDebug() << "Unknown landscape type: \"" << s << "\""; qDebug() << "Unknown landscape type: \"" << s << "\"";
// to avoid making this a fatal error, will load as a fishey e // to avoid making this a fatal error, will load as a fishey e
// if this fails, it just won't draw // if this fails, it just won't draw
ldscp = new LandscapeFisheye(); landscape = new LandscapeFisheye();
} }
ldscp->load(landscapeIni, landscapeId); landscape->load(landscapeIni, landscapeId);
QSettings *conf=StelApp::getInstance().getSettings(); QSettings *conf=StelApp::getInstance().getSettings();
ldscp->setLabelFontSize(conf->value("landscape/label_font_size", 15) landscape->setLabelFontSize(conf->value("landscape/label_font_size",
.toInt()); 15).toInt());
return ldscp; return landscape;
} }
QString LandscapeMgr::nameToID(const QString& name) const QString LandscapeMgr::nameToID(const QString& name) const
{ {
QMap<QString,QString> nameToDirMap = getNameToDirMap(); QMap<QString,QString> nameToDirMap = getNameToDirMap();
if (nameToDirMap.find(name)!=nameToDirMap.end()) if (nameToDirMap.find(name)!=nameToDirMap.end())
{ {
Q_ASSERT(0); Q_ASSERT(0);
return "error"; return "error";
 End of changes. 15 change blocks. 
19 lines changed or deleted 20 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/