StelCore.cpp   StelCore.cpp 
skipping to change at line 31 skipping to change at line 31
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelProjectorClasses.hpp" #include "StelProjectorClasses.hpp"
#include "StelToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelGeodesicGrid.hpp" #include "StelGeodesicGrid.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelPainter.hpp"
#include "StelLocationMgr.hpp" #include "StelLocationMgr.hpp"
#include "StelObserver.hpp" #include "StelObserver.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "renderer/GenericVertexTypes.hpp"
#include "renderer/StelRenderer.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include <QtOpenGL>
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QMetaEnum> #include <QMetaEnum>
// Init statics transfo matrices // Init statics transfo matrices
// See vsop87.doc: // See vsop87.doc:
const Mat4d StelCore::matJ2000ToVsop87(Mat4d::xrotation(-23.439280305555555 5556*(M_PI/180)) * Mat4d::zrotation(0.0000275*(M_PI/180))); const Mat4d StelCore::matJ2000ToVsop87(Mat4d::xrotation(-23.439280305555555 5556*(M_PI/180)) * Mat4d::zrotation(0.0000275*(M_PI/180)));
const Mat4d StelCore::matVsop87ToJ2000(matJ2000ToVsop87.transpose()); const Mat4d StelCore::matVsop87ToJ2000(matJ2000ToVsop87.transpose());
const Mat4d StelCore::matJ2000ToGalactic(-0.054875539726, 0.494109453312, - 0.867666135858, 0, -0.873437108010, -0.444829589425, -0.198076386122, 0, -0 .483834985808, 0.746982251810, 0.455983795705, 0, 0, 0, 0, 1); const Mat4d StelCore::matJ2000ToGalactic(-0.054875539726, 0.494109453312, - 0.867666135858, 0, -0.873437108010, -0.444829589425, -0.198076386122, 0, -0 .483834985808, 0.746982251810, 0.455983795705, 0, 0, 0, 0, 1);
const Mat4d StelCore::matGalacticToJ2000(matJ2000ToGalactic.transpose()); const Mat4d StelCore::matGalacticToJ2000(matJ2000ToGalactic.transpose());
skipping to change at line 91 skipping to change at line 91
{ {
delete toneConverter; toneConverter=NULL; delete toneConverter; toneConverter=NULL;
delete geodesicGrid; geodesicGrid=NULL; delete geodesicGrid; geodesicGrid=NULL;
delete skyDrawer; skyDrawer=NULL; delete skyDrawer; skyDrawer=NULL;
delete position; position=NULL; delete position; position=NULL;
} }
/************************************************************************* /*************************************************************************
Load core data and initialize with default values Load core data and initialize with default values
*************************************************************************/ *************************************************************************/
void StelCore::init() void StelCore::init(class StelRenderer* renderer)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
defaultLocationID = conf->value("init_location/location","error").to String(); defaultLocationID = conf->value("init_location/location","error").to String();
bool ok; bool ok;
StelLocation location = StelApp::getInstance().getLocationMgr().loca tionForString(defaultLocationID, &ok); StelLocation location = StelApp::getInstance().getLocationMgr().loca tionForString(defaultLocationID, &ok);
if (!ok) if (!ok)
{ {
qWarning() << "Warning: location" << defaultLocationID << "i s unknown."; qWarning() << "Warning: location" << defaultLocationID << "i s unknown.";
} }
skipping to change at line 135 skipping to change at line 135
setTodayTime(getInitTodayTime()); setTodayTime(getInitTodayTime());
// Compute transform matrices between coordinates systems // Compute transform matrices between coordinates systems
updateTransformMatrices(); updateTransformMatrices();
movementMgr = new StelMovementMgr(this); movementMgr = new StelMovementMgr(this);
movementMgr->init(); movementMgr->init();
currentProjectorParams.fov = movementMgr->getInitFov(); currentProjectorParams.fov = movementMgr->getInitFov();
StelApp::getInstance().getModuleMgr().registerModule(movementMgr); StelApp::getInstance().getModuleMgr().registerModule(movementMgr);
skyDrawer = new StelSkyDrawer(this); skyDrawer = new StelSkyDrawer(this, renderer);
skyDrawer->init(); skyDrawer->init();
QString tmpstr = conf->value("projection/type", "stereographic").toS tring(); QString tmpstr = conf->value("projection/type", "ProjectionStereogra phic").toString();
setCurrentProjectionTypeKey(tmpstr); setCurrentProjectionTypeKey(tmpstr);
} }
// Get the shared instance of StelGeodesicGrid. // Get the shared instance of StelGeodesicGrid.
// The returned instance is garanteed to allow for at least maxLevel levels // The returned instance is garanteed to allow for at least maxLevel levels
const StelGeodesicGrid* StelCore::getGeodesicGrid(int maxLevel) const const StelGeodesicGrid* StelCore::getGeodesicGrid(int maxLevel) const
{ {
if (geodesicGrid==NULL) if (geodesicGrid==NULL)
{ {
geodesicGrid = new StelGeodesicGrid(maxLevel); geodesicGrid = new StelGeodesicGrid(maxLevel);
skipping to change at line 304 skipping to change at line 304
currentProjectorParams.fov = movementMgr->getCurrentFov(); currentProjectorParams.fov = movementMgr->getCurrentFov();
skyDrawer->update(deltaTime); skyDrawer->update(deltaTime);
} }
/************************************************************************* /*************************************************************************
Execute all the pre-drawing functions Execute all the pre-drawing functions
*************************************************************************/ *************************************************************************/
void StelCore::preDraw() void StelCore::preDraw()
{ {
// Init openGL viewing with fov, screen size and clip planes
currentProjectorParams.zNear = 0.000001; currentProjectorParams.zNear = 0.000001;
currentProjectorParams.zFar = 50.; currentProjectorParams.zFar = 50.;
skyDrawer->preDraw(); skyDrawer->preDraw();
}
//! Fill with black around viewport disc shape.
static void drawViewportShape(StelRenderer* renderer, StelProjectorP projec
tor)
{
if (projector->getMaskType() != StelProjector::MaskDisk)
{
return;
}
renderer->setBlendMode(BlendMode_None);
renderer->setGlobalColor(0.0f, 0.0f, 0.0f);
const float innerRadius = 0.5 * projector->getViewportFovDiameter();
const float outerRadius = projector->getViewportWidth() + projector-
>getViewportHeight();
Q_ASSERT_X(innerRadius >= 0.0f && outerRadius > innerRadius,
Q_FUNC_INFO, "Inner radius must be at least zero and oute
r radius must be greater");
const float sweepAngle = 360.0f;
static const int resolution = 192;
float sinCache[resolution];
float cosCache[resolution];
// Clear areas not redrawn by main viewport (i.e. fisheye square vie const float deltaRadius = outerRadius - innerRadius;
wport) const int slices = resolution - 1;
StelPainter sPainter(getProjection2d()); // Cache is the vertex locations cache
glClearColor(0,0,0,0); for (int s = 0; s <= slices; s++)
glClear(GL_COLOR_BUFFER_BIT); {
const float angle = (M_PI * sweepAngle) / 180.0f * s / slice
s;
sinCache[s] = std::sin(angle);
cosCache[s] = std::cos(angle);
}
sinCache[slices] = sinCache[0];
cosCache[slices] = cosCache[0];
const float radiusHigh = outerRadius - deltaRadius;
StelVertexBuffer<VertexP2>* vertices =
renderer->createVertexBuffer<VertexP2>(PrimitiveType_Triangl
eStrip);
const Vec2f center = projector->getViewportCenterAbsolute();
for (int i = 0; i <= slices; i++)
{
vertices->addVertex(VertexP2(center[0] + outerRadius * sinCa
che[i],
center[1] + outerRadius * cosCa
che[i]));
vertices->addVertex(VertexP2(center[0] + radiusHigh * sinCac
he[i],
center[1] + radiusHigh * cosCac
he[i]));
}
vertices->lock();
renderer->setCulledFaces(CullFace_None);
renderer->drawVertexBuffer(vertices);
delete vertices;
} }
/************************************************************************* /*************************************************************************
Update core state after drawing modules Update core state after drawing modules
*************************************************************************/ *************************************************************************/
void StelCore::postDraw() void StelCore::postDraw(StelRenderer* renderer)
{ {
StelPainter sPainter(getProjection(StelCore::FrameJ2000)); drawViewportShape(renderer, getProjection(StelCore::FrameJ2000));
sPainter.drawViewportShape();
} }
void StelCore::setCurrentProjectionType(ProjectionType type) void StelCore::setCurrentProjectionType(ProjectionType type)
{ {
currentProjectionType=type; currentProjectionType=type;
const double savedFov = currentProjectorParams.fov; const double savedFov = currentProjectorParams.fov;
currentProjectorParams.fov = 0.0001; // Avoid crash currentProjectorParams.fov = 0.0001; // Avoid crash
double newMaxFov = getProjection(StelProjector::ModelViewTranformP(n ew StelProjector::Mat4dTransform(Mat4d::identity())))->getMaxFov(); double newMaxFov = getProjection(StelProjector::ModelViewTranformP(n ew StelProjector::Mat4dTransform(Mat4d::identity())))->getMaxFov();
movementMgr->setMaxFov(newMaxFov); movementMgr->setMaxFov(newMaxFov);
currentProjectorParams.fov = qMin(newMaxFov, savedFov); currentProjectorParams.fov = qMin(newMaxFov, savedFov);
skipping to change at line 731 skipping to change at line 778
Q_ASSERT(objmgr); Q_ASSERT(objmgr);
if (objmgr->getWasSelected()) if (objmgr->getWasSelected())
{ {
Planet* pl = dynamic_cast<Planet*>(objmgr->getSelectedObject ()[0].data()); Planet* pl = dynamic_cast<Planet*>(objmgr->getSelectedObject ()[0].data());
if (pl) if (pl)
{ {
// We need to move to the selected planet. Try to ge nerate a location from the current one // We need to move to the selected planet. Try to ge nerate a location from the current one
StelLocation loc = getCurrentLocation(); StelLocation loc = getCurrentLocation();
if (loc.planetName != pl->getEnglishName()) if (loc.planetName != pl->getEnglishName())
{ {
loc.planetName = pl->getEnglishName(); loc.planetName = pl->getEnglishName();
loc.name = "-"; loc.name = "-";
loc.state = ""; loc.state = "";
moveObserverTo(loc); moveObserverTo(loc);
LandscapeMgr* landscapeMgr = GETSTELMODULE(L
andscapeMgr);
if (pl->getEnglishName() == "Solar System Ob
server")
{
landscapeMgr->setFlagAtmosphere(fals
e);
landscapeMgr->setFlagFog(false);
landscapeMgr->setFlagLandscape(false
);
}
else
{
landscapeMgr->setFlagAtmosphere(pl->
hasAtmosphere());
landscapeMgr->setFlagFog(pl->hasAtmo
sphere());
landscapeMgr->setFlagLandscape(true)
;
}
} }
} }
} }
StelMovementMgr* mmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* mmgr = GETSTELMODULE(StelMovementMgr);
Q_ASSERT(mmgr); Q_ASSERT(mmgr);
mmgr->setFlagTracking(false); mmgr->setFlagTracking(false);
} }
// Get the informations on the current location // Get the informations on the current location
const StelLocation& StelCore::getCurrentLocation() const const StelLocation& StelCore::getCurrentLocation() const
{ {
return position->getCurrentLocation(); return position->getCurrentLocation();
} }
const QSharedPointer<Planet> StelCore::getCurrentPlanet() const
{
return position->getHomePlanet();
}
// Smoothly move the observer to the given location // Smoothly move the observer to the given location
void StelCore::moveObserverTo(const StelLocation& target, double duration, double durationIfPlanetChange) void StelCore::moveObserverTo(const StelLocation& target, double duration, double durationIfPlanetChange)
{ {
emit(locationChanged(target)); emit(locationChanged(target));
double d = (getCurrentLocation().planetName==target.planetName) ? du ration : durationIfPlanetChange; double d = (getCurrentLocation().planetName==target.planetName) ? du ration : durationIfPlanetChange;
if (d>0.) if (d>0.)
{ {
StelLocation curLoc = getCurrentLocation(); StelLocation curLoc = getCurrentLocation();
if (position->isTraveling()) if (position->isTraveling())
{ {
skipping to change at line 852 skipping to change at line 918
addSiderealDays(1.0); addSiderealDays(1.0);
} }
void StelCore::addSiderealWeek() void StelCore::addSiderealWeek()
{ {
addSiderealDays(7.0); addSiderealDays(7.0);
} }
void StelCore::addSiderealMonth() void StelCore::addSiderealMonth()
{ {
addSiderealDays(27.321661); double days = 27.321661;
const PlanetP& home = position->getHomePlanet();
if ((home->getEnglishName() != "Solar System Observer") && (home->ge
tSiderealPeriod()>0))
days = home->getSiderealPeriod()/12;
addSolarDays(days);
} }
void StelCore::addSiderealYear() void StelCore::addSiderealYear()
{ {
addSolarDays(365.256363004); double days = 365.256363004;
const PlanetP& home = position->getHomePlanet();
if ((home->getEnglishName() != "Solar System Observer") && (home->ge
tSiderealPeriod()>0))
days = home->getSiderealPeriod();
addSolarDays(days);
}
void StelCore::addSiderealCentury()
{
double days = 36525.6363004;
const PlanetP& home = position->getHomePlanet();
if ((home->getEnglishName() != "Solar System Observer") && (home->ge
tSiderealPeriod()>0))
days = home->getSiderealPeriod()*100;
addSolarDays(days);
}
void StelCore::addSynodicMonth()
{
addSolarDays(29.530588853);
}
void StelCore::addDraconicMonth()
{
addSolarDays(27.212220817);
}
void StelCore::addTropicalMonth()
{
addSolarDays(27.321582241);
}
void StelCore::addAnomalisticMonth()
{
addSolarDays(27.554549878);
}
void StelCore::addDraconicYear()
{
addSolarDays(346.620075883);
}
void StelCore::addTropicalYear()
{
addSolarDays(365.2421897);
}
void StelCore::addTropicalCentury()
{
addSolarDays(36524.21897);
} }
void StelCore::subtractHour() void StelCore::subtractHour()
{ {
addSolarDays(-JD_HOUR); addSolarDays(-JD_HOUR);
} }
void StelCore::subtractDay() void StelCore::subtractDay()
{ {
addSolarDays(-1.0); addSolarDays(-1.0);
skipping to change at line 887 skipping to change at line 1008
addSiderealDays(-1.0); addSiderealDays(-1.0);
} }
void StelCore::subtractSiderealWeek() void StelCore::subtractSiderealWeek()
{ {
addSiderealDays(-7.0); addSiderealDays(-7.0);
} }
void StelCore::subtractSiderealMonth() void StelCore::subtractSiderealMonth()
{ {
addSiderealDays(-27.321661); double days = -27.321661;
const PlanetP& home = position->getHomePlanet();
if ((home->getEnglishName() != "Solar System Observer") && (home->ge
tSiderealPeriod()>0))
days = -1*(home->getSiderealPeriod()/12);
addSolarDays(days);
} }
void StelCore::subtractSiderealYear() void StelCore::subtractSiderealYear()
{ {
addSolarDays(-365.256363004); double days = 365.256363004;
const PlanetP& home = position->getHomePlanet();
if ((home->getEnglishName() != "Solar System Observer") && (home->ge
tSiderealPeriod()>0))
days = home->getSiderealPeriod();
addSolarDays(-days);
}
void StelCore::subtractSiderealCentury()
{
double days = 36525.6363004;
const PlanetP& home = position->getHomePlanet();
if ((home->getEnglishName() != "Solar System Observer") && (home->ge
tSiderealPeriod()>0))
days = home->getSiderealPeriod()*100;
addSolarDays(-days);
}
void StelCore::subtractSynodicMonth()
{
addSolarDays(-29.530588853);
}
void StelCore::subtractDraconicMonth()
{
addSolarDays(-27.212220817);
}
void StelCore::subtractTropicalMonth()
{
addSolarDays(-27.321582241);
}
void StelCore::subtractAnomalisticMonth()
{
addSolarDays(-27.554549878);
}
void StelCore::subtractDraconicYear()
{
addSolarDays(-346.620075883);
}
void StelCore::subtractTropicalYear()
{
addSolarDays(-365.2421897);
}
void StelCore::subtractTropicalCentury()
{
addSolarDays(-36524.21897);
} }
void StelCore::addSolarDays(double d) void StelCore::addSolarDays(double d)
{ {
const PlanetP& home = position->getHomePlanet();
if (home->getEnglishName() != "Solar System Observer")
{
double sp = home->getSiderealPeriod();
double dsol = home->getSiderealDay();
bool fwdDir = true;
if ((home->getEnglishName() == "Venus") || (home->getEnglish
Name() == "Uranus"))
fwdDir = false;
d *= StelUtils::calculateSolarDay(sp, dsol, fwdDir);
}
setJDay(getJDay() + d); setJDay(getJDay() + d);
} }
void StelCore::addSiderealDays(double d) void StelCore::addSiderealDays(double d)
{ {
const PlanetP& home = position->getHomePlanet(); const PlanetP& home = position->getHomePlanet();
if (home->getEnglishName() != "Solar System StelObserver") if (home->getEnglishName() != "Solar System Observer")
d *= home->getSiderealDay(); d *= home->getSiderealDay();
setJDay(getJDay() + d); setJDay(getJDay() + d);
} }
// Get the sideral time shifted by the observer longitude // Get the sideral time shifted by the observer longitude
double StelCore::getLocalSideralTime() const double StelCore::getLocalSideralTime() const
{ {
return (position->getHomePlanet()->getSiderealTime(JDay)+position->g etCurrentLocation().longitude)*M_PI/180.; return (position->getHomePlanet()->getSiderealTime(JDay)+position->g etCurrentLocation().longitude)*M_PI/180.;
} }
 End of changes. 20 change blocks. 
24 lines changed or deleted 235 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/