LandscapeMgr.cpp   LandscapeMgr.cpp 
skipping to change at line 30 skipping to change at line 30
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
#include <QString> #include <QString>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QTemporaryFile> #include <QTemporaryFile>
#ifdef USE_OPENGL_ES2
#include "GLES2/gl2.h"
#else
#include <QtOpenGL>
#endif
#include <stdexcept> #include <stdexcept>
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "Landscape.hpp" #include "Landscape.hpp"
#include "Atmosphere.hpp" #include "Atmosphere.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelPainter.hpp" #include "renderer/StelRenderer.hpp"
#include "karchive.h" #include "karchive.h"
#include "kzip.h" #include "kzip.h"
// Class which manages the cardinal points displaying // Class which manages the cardinal points displaying
class Cardinals class Cardinals
{ {
public: public:
Cardinals(float _radius = 1.); Cardinals(float _radius = 1.);
virtual ~Cardinals(); virtual ~Cardinals();
void draw(const StelCore* core, double latitude) const; void draw(const StelCore* core, StelRenderer* renderer, double latit ude) const;
void setColor(const Vec3f& c) {color = c;} void setColor(const Vec3f& c) {color = c;}
Vec3f get_color() {return color;} Vec3f get_color() {return color;}
void updateI18n(); void updateI18n();
void update(double deltaTime) {fader.update((int)(deltaTime*1000));} void update(double deltaTime) {fader.update((int)(deltaTime*1000));}
void set_fade_duration(float duration) {fader.setDuration((int)(dura tion*1000.f));} void set_fade_duration(float duration) {fader.setDuration((int)(dura tion*1000.f));}
void setFlagShow(bool b){fader = b;} void setFlagShow(bool b){fader = b;}
bool getFlagShow() const {return fader;} bool getFlagShow() const {return fader;}
private: private:
float radius; float radius;
QFont font; QFont font;
skipping to change at line 93 skipping to change at line 87
sEast = "E"; sEast = "E";
sWest = "W"; sWest = "W";
} }
Cardinals::~Cardinals() Cardinals::~Cardinals()
{ {
} }
// Draw the cardinals points : N S E W // Draw the cardinals points : N S E W
// handles special cases at poles // handles special cases at poles
void Cardinals::draw(const StelCore* core, double latitude) const void Cardinals::draw(const StelCore* core, StelRenderer* renderer, double l atitude) const
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz, StelCore::RefractionOff); const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz, StelCore::RefractionOff);
StelPainter sPainter(prj); renderer->setFont(font);
sPainter.setFont(font);
if (!fader.getInterstate()) return; if (!fader.getInterstate()) return;
// direction text // direction text
QString d[4]; QString d[4];
d[0] = sNorth; d[0] = sNorth;
d[1] = sSouth; d[1] = sSouth;
d[2] = sEast; d[2] = sEast;
d[3] = sWest; d[3] = sWest;
// fun polar special cases // fun polar special cases
if (latitude == 90.0 ) d[0] = d[1] = d[2] = d[3] = sSouth; if (latitude == 90.0 ) d[0] = d[1] = d[2] = d[3] = sSouth;
if (latitude == -90.0 ) d[0] = d[1] = d[2] = d[3] = sNorth; if (latitude == -90.0 ) d[0] = d[1] = d[2] = d[3] = sNorth;
sPainter.setColor(color[0],color[1],color[2],fader.getInterstate()); renderer->setGlobalColor(color[0], color[1], color[2], fader.getInte
glEnable(GL_BLEND); rstate());
sPainter.enableTexture2d(true); renderer->setBlendMode(BlendMode_Alpha);
// Normal transparency mode
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Vec3f pos; Vec3f pos;
Vec3f xy; Vec3f xy;
float shift = sPainter.getFontMetrics().width(sNorth)/2; float shift = QFontMetrics(font).width(sNorth)/2;
if (core->getProjection(StelCore::FrameJ2000)->getMaskType() == Stel Projector::MaskDisk) if (core->getProjection(StelCore::FrameJ2000)->getMaskType() == Stel Projector::MaskDisk)
shift = 0; shift = 0;
// N for North // N for North
pos.set(-1.f, 0.f, 0.f); pos.set(-1.f, 0.f, 0.f);
if (prj->project(pos,xy)) sPainter.drawText(xy[0], xy[1], d[0], 0., if (prj->project(pos, xy))
-shift, -shift, false); {
renderer->drawText(TextParams(xy[0], xy[1], d[0])
.shift(-shift, -shift).useGravity());
}
// S for South // S for South
pos.set(1.f, 0.f, 0.f); pos.set(1.f, 0.f, 0.f);
if (prj->project(pos,xy)) sPainter.drawText(xy[0], xy[1], d[1], 0., if (prj->project(pos, xy))
-shift, -shift, false); {
renderer->drawText(TextParams(xy[0], xy[1], d[1])
.shift(-shift, -shift).useGravity());
}
// E for East // E for East
pos.set(0.f, 1.f, 0.f); pos.set(0.f, 1.f, 0.f);
if (prj->project(pos,xy)) sPainter.drawText(xy[0], xy[1], d[2], 0., if (prj->project(pos, xy))
-shift, -shift, false); {
renderer->drawText(TextParams(xy[0], xy[1], d[2])
.shift(-shift, -shift).useGravity());
}
// W for West // W for West
pos.set(0.f, -1.f, 0.f); pos.set(0.f, -1.f, 0.f);
if (prj->project(pos,xy)) sPainter.drawText(xy[0], xy[1], d[3], 0., if (prj->project(pos, xy))
-shift, -shift, false); {
renderer->drawText(TextParams(xy[0], xy[1], d[3])
.shift(-shift, -shift).useGravity());
}
} }
// Translate cardinal labels with gettext to current sky language and updat e font for the language // Translate cardinal labels with gettext to current sky language and updat e font for the language
void Cardinals::updateI18n() void Cardinals::updateI18n()
{ {
StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getApp StelTranslator(); StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getApp StelTranslator();
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");
skipping to change at line 198 skipping to change at line 203
// 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()->getAltAzPosApparent(core); Vec3d sunPos = ssystem->getSun()->getAltAzPosApparent(core);
// Compute the moon position in local coordinate // Compute the moon position in local coordinate
Vec3d moonPos = ssystem->getMoon()->getAltAzPosApparent(core); Vec3d moonPos = ssystem->getMoon()->getAltAzPosApparent(core);
atmosphere->computeColor(core->getJDay(), sunPos, moonPos, atmosphere->computeColor(core->getJDay(), sunPos, moonPos,
ssystem->getMoon()->getPhase(ssystem->getEarth()->getHelioce ssystem->getMoon()->getPhaseAngle(ssystem->getEarth()->getHe
ntricEclipticPos()), liocentricEclipticPos()),
core, core->getCurrentLocation().latitude, core->getCurrentL core, ssystem->getEclipseFactor(core), core->getCurrentLocat
ocation().altitude, ion().latitude, core->getCurrentLocation().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);
// Compute the ground luminance based on every planets around // Compute the ground luminance based on every planets around
// float groundLuminance = 0; // float groundLuminance = 0;
// const vector<Planet*>& allPlanets = ssystem->getAllPlanets(); // const vector<Planet*>& allPlanets = ssystem->getAllPlanets();
// for (vector<Planet*>::const_iterator i=allPlanets.begin();i!=allPlan ets.end();++i) // for (vector<Planet*>::const_iterator i=allPlanets.begin();i!=allPlan ets.end();++i)
// { // {
// Vec3d pos = (*i)->getAltAzPos(core); // Vec3d pos = (*i)->getAltAzPos(core);
skipping to change at line 257 skipping to change at line 262
{ {
// If the atmosphere is on, a solar eclipse might darken the sky // If the atmosphere is on, a solar eclipse might darken the sky
// otherwise we just use the sun position calculation above // otherwise we just use the sun position calculation above
landscapeBrightness *= (atmosphere->getRealDisplayIntensityF actor()+0.1); landscapeBrightness *= (atmosphere->getRealDisplayIntensityF actor()+0.1);
} }
// TODO: should calculate dimming with solar eclipse even without at mosphere on // TODO: should calculate dimming with solar eclipse even without at mosphere on
landscape->setBrightness(landscapeBrightness+0.05); landscape->setBrightness(landscapeBrightness+0.05);
} }
void LandscapeMgr::draw(StelCore* core) void LandscapeMgr::draw(StelCore* core, class StelRenderer* renderer)
{ {
// Draw the atmosphere // Draw the atmosphere
atmosphere->draw(core); atmosphere->draw(core, renderer);
// Draw the landscape // Draw the landscape
landscape->draw(core); landscape->draw(core, renderer);
// Draw the cardinal points // Draw the cardinal points
cardinalsPoints->draw(core, StelApp::getInstance().getCore()->getCur rentLocation().latitude); cardinalsPoints->draw(core, renderer, StelApp::getInstance().getCore ()->getCurrentLocation().latitude);
} }
void LandscapeMgr::init() void LandscapeMgr::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
atmosphere = new Atmosphere(); atmosphere = new Atmosphere();
landscape = new LandscapeOldStyle(); landscape = new LandscapeOldStyle();
defaultLandscapeID = conf->value("init_location/landscape_name").toS tring(); defaultLandscapeID = conf->value("init_location/landscape_name").toS tring();
 End of changes. 16 change blocks. 
34 lines changed or deleted 36 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/