GridLinesMgr.cpp   GridLinesMgr.cpp 
skipping to change at line 32 skipping to change at line 32
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelFader.hpp" #include "StelFader.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "precession.h"
#include <set> #include <set>
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QFontMetrics> #include <QFontMetrics>
//! @class SkyGrid //! @class SkyGrid
//! Class which manages a grid to display in the sky. //! Class which manages a grid to display in the sky.
class SkyGrid class SkyGrid
{ {
skipping to change at line 68 skipping to change at line 69
LinearFader fader; LinearFader fader;
}; };
//! @class SkyLine //! @class SkyLine
//! Class which manages a line to display around the sky like the ecliptic line. //! Class which manages a line to display around the sky like the ecliptic line.
class SkyLine class SkyLine
{ {
public: public:
enum SKY_LINE_TYPE enum SKY_LINE_TYPE
{ {
EQUATOR, EQUATOR_J2000,
ECLIPTIC, EQUATOR_OF_DATE,
ECLIPTIC_J2000,
ECLIPTIC_OF_DATE,
PRECESSIONCIRCLE_N,
PRECESSIONCIRCLE_S,
MERIDIAN, MERIDIAN,
HORIZON, HORIZON,
GALACTICEQUATOR, GALACTICEQUATOR,
LONGITUDE LONGITUDE
}; };
// Create and precompute positions of a SkyGrid // Create and precompute positions of a SkyGrid
SkyLine(SKY_LINE_TYPE _line_type = EQUATOR); SkyLine(SKY_LINE_TYPE _line_type = EQUATOR_J2000);
virtual ~SkyLine(); virtual ~SkyLine();
void draw(StelCore* core) const; void draw(StelCore* core) const;
void setColor(const Vec3f& c) {color = c;} void setColor(const Vec3f& c) {color = c;}
const Vec3f& getColor() {return color;} const Vec3f& getColor() {return color;}
void update(double deltaTime) {fader.update((int)(deltaTime*1000));} void update(double deltaTime) {fader.update((int)(deltaTime*1000));}
void setFadeDuration(float duration) {fader.setDuration((int)(durati on*1000.f));} void setFadeDuration(float duration) {fader.setDuration((int)(durati on*1000.f));}
void setDisplayed(const bool displayed){fader = displayed;} void setDisplayed(const bool displayed){fader = displayed;}
bool isDisplayed(void) const {return fader;} bool isDisplayed(void) const {return fader;}
void setFontSize(double newSize); void setFontSize(double newSize);
//! Re-translates the label. //! Re-translates the label.
skipping to change at line 168 skipping to change at line 173
}; };
// Callback which draws the label of the grid // Callback which draws the label of the grid
void viewportEdgeIntersectCallback(const Vec3d& screenPos, const Vec3d& dir ection, void* userData) void viewportEdgeIntersectCallback(const Vec3d& screenPos, const Vec3d& dir ection, void* userData)
{ {
ViewportEdgeIntersectCallbackData* d = static_cast<ViewportEdgeInter sectCallbackData*>(userData); ViewportEdgeIntersectCallbackData* d = static_cast<ViewportEdgeInter sectCallbackData*>(userData);
Vec3d direc(direction); Vec3d direc(direction);
direc.normalize(); direc.normalize();
const Vec4f tmpColor = d->sPainter->getColor(); const Vec4f tmpColor = d->sPainter->getColor();
d->sPainter->setColor(d->textColor[0], d->textColor[1], d->textColor [2], d->textColor[3]); d->sPainter->setColor(d->textColor[0], d->textColor[1], d->textColor [2], d->textColor[3]);
bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDe bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDe
grees();; grees();
bool useOldAzimuth = StelApp::getInstance().getFlagOldAzimuthUsage()
;
QString text; QString text;
if (d->text.isEmpty()) if (d->text.isEmpty())
{ {
// We are in the case of meridians, we need to determine whi ch of the 2 labels (3h or 15h to use) // We are in the case of meridians, we need to determine whi ch of the 2 labels (3h or 15h to use)
Vec3d tmpV; Vec3d tmpV;
d->sPainter->getProjector()->unProject(screenPos, tmpV); d->sPainter->getProjector()->unProject(screenPos, tmpV);
double lon, lat, textAngle; double lon, lat, textAngle;
StelUtils::rectToSphe(&lon, &lat, tmpV); StelUtils::rectToSphe(&lon, &lat, tmpV);
switch (d->frameType) switch (d->frameType)
skipping to change at line 197 skipping to change at line 203
const double delta = raAngle<M_PI ? M_PI : - M_PI; const double delta = raAngle<M_PI ? M_PI : - M_PI;
if (std::fabs(lon-raAngle) < 0.01 || (lon==0 . && raAngle!=M_PI)) if (std::fabs(lon-raAngle) < 0.01 || (lon==0 . && raAngle!=M_PI))
textAngle = raAngle; textAngle = raAngle;
else else
textAngle = raAngle+delta; textAngle = raAngle+delta;
if (raAngle==2*M_PI && delta==-M_PI) if (raAngle==2*M_PI && delta==-M_PI)
textAngle = 0; textAngle = 0;
if (useOldAzimuth)
textAngle += M_PI;
if (withDecimalDegree) if (withDecimalDegree)
text = StelUtils::radToDecDegStr(tex tAngle); text = StelUtils::radToDecDegStr(tex tAngle, 4, false, true);
else else
text = StelUtils::radToDmsStrAdapt(t extAngle); text = StelUtils::radToDmsStrAdapt(t extAngle);
break; break;
} }
case StelCore::FrameObservercentricEcliptic: case StelCore::FrameObservercentricEclipticJ2000:
case StelCore::FrameObservercentricEclipticOfDate:
{ {
double raAngle = d->raAngle; double raAngle = d->raAngle;
if (raAngle<0.) if (raAngle<0.)
raAngle += 2.*M_PI; raAngle += 2.*M_PI;
if (lon<0.) if (lon<0.)
lon += 2*M_PI; lon += 2*M_PI;
if (std::fabs(2.*M_PI-lon)<0.001) // We are at meridian 0 if (std::fabs(2.*M_PI-lon)<0.001) // We are at meridian 0
lon = 0.; lon = 0.;
skipping to change at line 226 skipping to change at line 236
const double delta = raAngle<M_PI ? M_PI : - M_PI; const double delta = raAngle<M_PI ? M_PI : - M_PI;
if (std::fabs(lon-raAngle) < 1. || lon==0.) if (std::fabs(lon-raAngle) < 1. || lon==0.)
textAngle = raAngle; textAngle = raAngle;
else else
textAngle = raAngle+delta; textAngle = raAngle+delta;
if (raAngle==2*M_PI && delta==-M_PI) if (raAngle==2*M_PI && delta==-M_PI)
textAngle = 0; textAngle = 0;
if (withDecimalDegree) if (withDecimalDegree)
text = StelUtils::radToDecDegStr(tex tAngle); text = StelUtils::radToDecDegStr(tex tAngle, 4, false, true);
else else
text = StelUtils::radToDmsStrAdapt(t extAngle); text = StelUtils::radToDmsStrAdapt(t extAngle);
break; break;
} }
case StelCore::FrameGalactic: case StelCore::FrameGalactic:
{ {
double raAngle = M_PI-d->raAngle; double raAngle = M_PI-d->raAngle;
lon = M_PI-lon; lon = M_PI-lon;
skipping to change at line 255 skipping to change at line 265
if (std::fabs(lon-raAngle) < 0.01) if (std::fabs(lon-raAngle) < 0.01)
textAngle = -raAngle+M_PI; textAngle = -raAngle+M_PI;
else else
{ {
const double delta = raAngle<M_PI ? M_PI : -M_PI; const double delta = raAngle<M_PI ? M_PI : -M_PI;
textAngle = -raAngle-delta+M_PI; textAngle = -raAngle-delta+M_PI;
} }
if (withDecimalDegree) if (withDecimalDegree)
text = StelUtils::radToDecDegStr(tex tAngle); text = StelUtils::radToDecDegStr(tex tAngle, 4, false, true);
else else
text = StelUtils::radToDmsStrAdapt(t extAngle); text = StelUtils::radToDmsStrAdapt(t extAngle);
break; break;
} }
default: default:
{ {
if (std::fabs(2.*M_PI-lon)<0.001) if (std::fabs(2.*M_PI-lon)<0.001)
{ {
// We are at meridian 0 // We are at meridian 0
lon = 0.; lon = 0.;
skipping to change at line 277 skipping to change at line 287
const double delta = d->raAngle<M_PI ? M_PI : -M_PI; const double delta = d->raAngle<M_PI ? M_PI : -M_PI;
if (std::fabs(lon-d->raAngle) < 1. || lon==0 . || d->raAngle==M_PI) if (std::fabs(lon-d->raAngle) < 1. || lon==0 . || d->raAngle==M_PI)
textAngle = d->raAngle; textAngle = d->raAngle;
else else
textAngle = d->raAngle+delta; textAngle = d->raAngle+delta;
if (d->raAngle+delta==0.) if (d->raAngle+delta==0.)
textAngle = M_PI; textAngle = M_PI;
if (withDecimalDegree) if (withDecimalDegree)
text = StelUtils::radToDecDegStr(tex tAngle); text = StelUtils::radToDecDegStr(tex tAngle, 4, false, true);
else else
text = StelUtils::radToHmsStrAdapt(t extAngle); text = StelUtils::radToHmsStrAdapt(t extAngle);
} }
} }
} }
else else
text = d->text; text = d->text;
double angleDeg = std::atan2(-direc[1], -direc[0])*180./M_PI; double angleDeg = std::atan2(-direc[1], -direc[0])*180./M_PI;
float xshift=6.f; float xshift=6.f;
skipping to change at line 357 skipping to change at line 367
// Initialize a painter and set OpenGL state // Initialize a painter and set OpenGL state
StelPainter sPainter(prj); StelPainter sPainter(prj);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa rency mode glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa rency mode
// OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH
#ifdef GL_LINE_SMOOTH #ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format().renderableType()==QSu rfaceFormat::OpenGL) if (QOpenGLContext::currentContext()->format().renderableType()==QSu rfaceFormat::OpenGL)
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
#endif #endif
Vec4f textColor(color[0], color[1], color[2], 0);
sPainter.setColor(color[0],color[1],color[2], fader.getInterstate())
;
textColor*=2; // make text colors just a bit brighter. (But if >1, QColor::setRgb
textColor[3]=fader.getInterstate(); fails and makes text invisible.)
Vec4f textColor(qMin(1.0f, 1.25f*color[0]), qMin(1.0f, 1.25f*color[1
]), qMin(1.0f, 1.25f*color[2]), fader.getInterstate());
sPainter.setColor(color[0],color[1],color[2], fader.getInterstate())
;
sPainter.setFont(font); sPainter.setFont(font);
ViewportEdgeIntersectCallbackData userData(&sPainter); ViewportEdgeIntersectCallbackData userData(&sPainter);
userData.textColor = textColor; userData.textColor = textColor;
userData.frameType = frameType; userData.frameType = frameType;
///////////////////////////////////////////////// /////////////////////////////////////////////////
// Draw all the meridians (great circles) // Draw all the meridians (great circles)
SphericalCap meridianSphericalCap(Vec3d(1,0,0), 0); SphericalCap meridianSphericalCap(Vec3d(1,0,0), 0);
Mat4d rotLon = Mat4d::zrotation(gridStepMeridianRad); Mat4d rotLon = Mat4d::zrotation(gridStepMeridianRad);
skipping to change at line 587 skipping to change at line 596
} }
void SkyLine::updateLabel() void SkyLine::updateLabel()
{ {
switch (line_type) switch (line_type)
{ {
case MERIDIAN: case MERIDIAN:
frameType = StelCore::FrameAltAz; frameType = StelCore::FrameAltAz;
label = q_("Meridian"); label = q_("Meridian");
break; break;
case ECLIPTIC: case ECLIPTIC_J2000:
frameType = StelCore::FrameObservercentricEcliptic; frameType = StelCore::FrameObservercentricEclipticJ2
label = q_("Ecliptic"); 000;
label = q_("Ecliptic of J2000.0");
break;
case ECLIPTIC_OF_DATE:
frameType = StelCore::FrameObservercentricEclipticOf
Date;
label = q_("Ecliptic of Date");
break; break;
case EQUATOR: case EQUATOR_J2000:
frameType = StelCore::FrameJ2000;
label = q_("Equator of J2000.0");
break;
case EQUATOR_OF_DATE:
frameType = StelCore::FrameEquinoxEqu; frameType = StelCore::FrameEquinoxEqu;
label = q_("Equator"); label = q_("Equator");
break; break;
case PRECESSIONCIRCLE_N:
case PRECESSIONCIRCLE_S:
frameType = StelCore::FrameObservercentricEclipticOf
Date;
label = q_("Precession Circle");
break;
case HORIZON: case HORIZON:
frameType = StelCore::FrameAltAz; frameType = StelCore::FrameAltAz;
label = q_("Horizon"); label = q_("Horizon");
break; break;
case GALACTICEQUATOR: case GALACTICEQUATOR:
frameType = StelCore::FrameGalactic; frameType = StelCore::FrameGalactic;
label = q_("Galactic Equator"); label = q_("Galactic Equator");
break; break;
case LONGITUDE: case LONGITUDE:
frameType = StelCore::FrameObservercentricEcliptic; frameType = StelCore::FrameObservercentricEclipticJ2 000; // TODO: Switch to FrameObservercentriEclipticOfDate
// TRANSLATORS: Full term is "opposition/conjunction longitude" // TRANSLATORS: Full term is "opposition/conjunction longitude"
label = q_("O./C. longitude"); label = q_("O./C. longitude");
break; break;
default:
Q_ASSERT(0);
} }
} }
void SkyLine::draw(StelCore *core) const void SkyLine::draw(StelCore *core) const
{ {
if (!fader.getInterstate()) if (!fader.getInterstate())
return; return;
StelProjectorP prj = core->getProjection(frameType, frameType!=StelC ore::FrameAltAz ? StelCore::RefractionAuto : StelCore::RefractionOff); StelProjectorP prj = core->getProjection(frameType, frameType!=StelC ore::FrameAltAz ? StelCore::RefractionAuto : StelCore::RefractionOff);
// Get the bounding halfspace // Get the bounding halfspace
const SphericalCap& viewPortSphericalCap = prj->getBoundingCap(); const SphericalCap& viewPortSphericalCap = prj->getBoundingCap();
// Initialize a painter and set openGL state // Initialize a painter and set openGL state
StelPainter sPainter(prj); StelPainter sPainter(prj);
sPainter.setColor(color[0], color[1], color[2], fader.getInterstate( )); sPainter.setColor(color[0], color[1], color[2], fader.getInterstate( ));
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa rency mode glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa rency mode
#ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format().renderableType()==QSu
rfaceFormat::OpenGL)
glEnable(GL_LINE_SMOOTH);
#endif
Vec4f textColor(color[0], color[1], color[2], 0); Vec4f textColor(color[0], color[1], color[2], 0);
textColor[3]=fader.getInterstate(); textColor[3]=fader.getInterstate();
ViewportEdgeIntersectCallbackData userData(&sPainter); ViewportEdgeIntersectCallbackData userData(&sPainter);
sPainter.setFont(font); sPainter.setFont(font);
userData.textColor = textColor; userData.textColor = textColor;
userData.text = label; userData.text = label;
///////////////////////////////////////////////// /////////////////////////////////////////////////
// Draw the line // Draw the line
// Precession circles are Small Circles, all others are Great Circle
s.
if (line_type==PRECESSIONCIRCLE_N || line_type==PRECESSIONCIRCLE_S)
{
const double lat=(line_type==PRECESSIONCIRCLE_S ? -1.0 : 1.0
) * (M_PI/2.0-getPrecessionAngleVondrakCurrentEpsilonA());
SphericalCap declinationCap(Vec3d(0,0,1), std::sin(lat));
const Vec3d rotCenter(0,0,declinationCap.d);
Vec3d p1, p2;
if (!SphericalCap::intersectionPoints(viewPortSphericalCap,
declinationCap, p1, p2))
{
if ((viewPortSphericalCap.d<declinationCap.d && view
PortSphericalCap.contains(declinationCap.n))
|| (viewPortSphericalCap.d<-declinationCap.d
&& viewPortSphericalCap.contains(-declinationCap.n)))
{
// The line is fully included in the viewpor
t, draw it in 3 sub-arcs to avoid length > 180.
Vec3d pt1;
Vec3d pt2;
Vec3d pt3;
const double lon1=0.0;
const double lon2=120.0*M_PI/180.0;
const double lon3=240.0*M_PI/180.0;
StelUtils::spheToRect(lon1, lat, pt1); pt1.n
ormalize();
StelUtils::spheToRect(lon2, lat, pt2); pt2.n
ormalize();
StelUtils::spheToRect(lon3, lat, pt3); pt3.n
ormalize();
sPainter.drawSmallCircleArc(pt1, pt2, rotCen
ter, viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(pt2, pt3, rotCen
ter, viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(pt3, pt1, rotCen
ter, viewportEdgeIntersectCallback, &userData);
#ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format
().renderableType()==QSurfaceFormat::OpenGL)
glDisable(GL_LINE_SMOOTH);
#endif
glDisable(GL_BLEND);
return;
}
else
{
#ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format
().renderableType()==QSurfaceFormat::OpenGL)
glDisable(GL_LINE_SMOOTH);
#endif
glDisable(GL_BLEND);
return;
}
}
// Draw the arc in 2 sub-arcs to avoid lengths > 180 deg
Vec3d middlePoint = p1-rotCenter+p2-rotCenter;
middlePoint.normalize();
middlePoint*=(p1-rotCenter).length();
middlePoint+=rotCenter;
if (!viewPortSphericalCap.contains(middlePoint))
{
middlePoint-=rotCenter;
middlePoint*=-1.;
middlePoint+=rotCenter;
}
sPainter.drawSmallCircleArc(p1, middlePoint, rotCenter,viewp
ortEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(p2, middlePoint, rotCenter, view
portEdgeIntersectCallback, &userData);
// OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH
#ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format().renderableTyp
e()==QSurfaceFormat::OpenGL)
glDisable(GL_LINE_SMOOTH);
#endif
glDisable(GL_BLEND);
return;
}
// All the other "lines" are Great Circles
SphericalCap meridianSphericalCap(Vec3d(0,0,1), 0); SphericalCap meridianSphericalCap(Vec3d(0,0,1), 0);
Vec3d fpt(1,0,0); Vec3d fpt(1,0,0);
if (line_type==MERIDIAN) if (line_type==MERIDIAN)
{ {
meridianSphericalCap.n.set(0,1,0); meridianSphericalCap.n.set(0,1,0);
} }
if (line_type==LONGITUDE) if (line_type==LONGITUDE)
{ {
Vec3d coord; Vec3d coord;
skipping to change at line 683 skipping to change at line 782
Vec3d middlePoint = p1+p2; Vec3d middlePoint = p1+p2;
middlePoint.normalize(); middlePoint.normalize();
if (!viewPortSphericalCap.contains(middlePoint)) if (!viewPortSphericalCap.contains(middlePoint))
middlePoint*=-1.; middlePoint*=-1.;
// Draw the arc in 2 sub-arcs to avoid lengths > 180 deg // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg
sPainter.drawGreatCircleArc(p1, middlePoint, NULL, viewportEdgeInter sectCallback, &userData); sPainter.drawGreatCircleArc(p1, middlePoint, NULL, viewportEdgeInter sectCallback, &userData);
sPainter.drawGreatCircleArc(p2, middlePoint, NULL, viewportEdgeInter sectCallback, &userData); sPainter.drawGreatCircleArc(p2, middlePoint, NULL, viewportEdgeInter sectCallback, &userData);
// OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH
#ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format().renderableType()==QSu
rfaceFormat::OpenGL)
glDisable(GL_LINE_SMOOTH);
#endif
glDisable(GL_BLEND);
// // Johannes: use a big radius as a dirty workaround for the bug that the // // Johannes: use a big radius as a dirty workaround for the bug that the
// // ecliptic line is not drawn around the observer, but around the su n: // // ecliptic line is not drawn around the observer, but around the su n:
// const Vec3d vv(1000000,0,0); // const Vec3d vv(1000000,0,0);
} }
GridLinesMgr::GridLinesMgr() GridLinesMgr::GridLinesMgr()
{ {
setObjectName("GridLinesMgr"); setObjectName("GridLinesMgr");
equGrid = new SkyGrid(StelCore::FrameEquinoxEqu); equGrid = new SkyGrid(StelCore::FrameEquinoxEqu);
equJ2000Grid = new SkyGrid(StelCore::FrameJ2000); equJ2000Grid = new SkyGrid(StelCore::FrameJ2000);
eclJ2000Grid = new SkyGrid(StelCore::FrameObservercentricEcliptic); eclJ2000Grid = new SkyGrid(StelCore::FrameObservercentricEclipticJ20
00);
eclGrid = new SkyGrid(StelCore::FrameObservercentricEclipticOfDate);
galacticGrid = new SkyGrid(StelCore::FrameGalactic); galacticGrid = new SkyGrid(StelCore::FrameGalactic);
aziGrid = new SkyGrid(StelCore::FrameAltAz); aziGrid = new SkyGrid(StelCore::FrameAltAz);
equatorLine = new SkyLine(SkyLine::EQUATOR); equatorLine = new SkyLine(SkyLine::EQUATOR_OF_DATE);
eclipticLine = new SkyLine(SkyLine::ECLIPTIC); equatorJ2000Line = new SkyLine(SkyLine::EQUATOR_J2000);
eclipticJ2000Line = new SkyLine(SkyLine::ECLIPTIC_J2000); // previou
s eclipticLine
eclipticLine = new SkyLine(SkyLine::ECLIPTIC_OF_DATE); // GZ NEW
precessionCircleN = new SkyLine(SkyLine::PRECESSIONCIRCLE_N);
precessionCircleS = new SkyLine(SkyLine::PRECESSIONCIRCLE_S);
meridianLine = new SkyLine(SkyLine::MERIDIAN); meridianLine = new SkyLine(SkyLine::MERIDIAN);
horizonLine = new SkyLine(SkyLine::HORIZON); horizonLine = new SkyLine(SkyLine::HORIZON);
galacticEquatorLine = new SkyLine(SkyLine::GALACTICEQUATOR); galacticEquatorLine = new SkyLine(SkyLine::GALACTICEQUATOR);
longitudeLine = new SkyLine(SkyLine::LONGITUDE); longitudeLine = new SkyLine(SkyLine::LONGITUDE);
} }
GridLinesMgr::~GridLinesMgr() GridLinesMgr::~GridLinesMgr()
{ {
delete equGrid; delete equGrid;
delete equJ2000Grid; delete equJ2000Grid;
delete eclJ2000Grid; delete eclJ2000Grid;
delete eclGrid;
delete galacticGrid; delete galacticGrid;
delete aziGrid; delete aziGrid;
delete equatorLine; delete equatorLine;
delete equatorJ2000Line;
delete eclipticLine; delete eclipticLine;
delete eclipticJ2000Line;
delete precessionCircleN;
delete precessionCircleS;
delete meridianLine; delete meridianLine;
delete horizonLine; delete horizonLine;
delete galacticEquatorLine; delete galacticEquatorLine;
delete longitudeLine; delete longitudeLine;
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double GridLinesMgr::getCallOrder(StelModuleActionName actionName) const double GridLinesMgr::getCallOrder(StelModuleActionName actionName) const
skipping to change at line 739 skipping to change at line 856
void GridLinesMgr::init() void GridLinesMgr::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
setFlagAzimuthalGrid(conf->value("viewing/flag_azimuthal_grid").toBo ol()); setFlagAzimuthalGrid(conf->value("viewing/flag_azimuthal_grid").toBo ol());
setFlagEquatorGrid(conf->value("viewing/flag_equatorial_grid").toBoo l()); setFlagEquatorGrid(conf->value("viewing/flag_equatorial_grid").toBoo l());
setFlagEquatorJ2000Grid(conf->value("viewing/flag_equatorial_J2000_g rid").toBool()); setFlagEquatorJ2000Grid(conf->value("viewing/flag_equatorial_J2000_g rid").toBool());
setFlagEclipticJ2000Grid(conf->value("viewing/flag_ecliptic_J2000_gr id").toBool()); setFlagEclipticJ2000Grid(conf->value("viewing/flag_ecliptic_J2000_gr id").toBool());
setFlagEclipticGrid(conf->value("viewing/flag_ecliptic_grid").toBool ());
setFlagGalacticGrid(conf->value("viewing/flag_galactic_grid").toBool ()); setFlagGalacticGrid(conf->value("viewing/flag_galactic_grid").toBool ());
setFlagEquatorLine(conf->value("viewing/flag_equator_line").toBool() ); setFlagEquatorLine(conf->value("viewing/flag_equator_line").toBool() );
setFlagEquatorJ2000Line(conf->value("viewing/flag_equator_J2000_line ").toBool());
setFlagEclipticLine(conf->value("viewing/flag_ecliptic_line").toBool ()); setFlagEclipticLine(conf->value("viewing/flag_ecliptic_line").toBool ());
setFlagEclipticJ2000Line(conf->value("viewing/flag_ecliptic_J2000_li
ne").toBool());
setFlagPrecessionCircles(conf->value("viewing/flag_precession_circle
s").toBool());
setFlagMeridianLine(conf->value("viewing/flag_meridian_line").toBool ()); setFlagMeridianLine(conf->value("viewing/flag_meridian_line").toBool ());
setFlagHorizonLine(conf->value("viewing/flag_horizon_line").toBool() ); setFlagHorizonLine(conf->value("viewing/flag_horizon_line").toBool() );
setFlagGalacticEquatorLine(conf->value("viewing/flag_galactic_equato r_line").toBool()); setFlagGalacticEquatorLine(conf->value("viewing/flag_galactic_equato r_line").toBool());
setFlagLongitudeLine(conf->value("viewing/flag_longitude_line").toBo ol()); setFlagLongitudeLine(conf->value("viewing/flag_longitude_line").toBo ol());
StelApp& app = StelApp::getInstance(); StelApp& app = StelApp::getInstance();
connect(&app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT (setStelStyle(const QString&))); connect(&app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT (setStelStyle(const QString&)));
connect(&app, SIGNAL(languageChanged()), this, SLOT(updateLineLabels ())); connect(&app, SIGNAL(languageChanged()), this, SLOT(updateLineLabels ()));
QString displayGroup = N_("Display Options"); QString displayGroup = N_("Display Options");
addAction("actionShow_Equatorial_Grid", displayGroup, N_("Equatorial grid"), "equatorGridDisplayed", "E"); addAction("actionShow_Equatorial_Grid", displayGroup, N_("Equatorial grid"), "equatorGridDisplayed", "E");
addAction("actionShow_Azimuthal_Grid", displayGroup, N_("Azimuthal g rid"), "azimuthalGridDisplayed", "Z"); addAction("actionShow_Azimuthal_Grid", displayGroup, N_("Azimuthal g rid"), "azimuthalGridDisplayed", "Z");
addAction("actionShow_Ecliptic_Line", displayGroup, N_("Ecliptic lin e"), "eclipticLineDisplayed", ","); addAction("actionShow_Ecliptic_Line", displayGroup, N_("Ecliptic lin e"), "eclipticLineDisplayed", ",");
addAction("actionShow_Ecliptic_J2000_Line", displayGroup, N_("Eclipt ic J2000 line"), "eclipticJ2000LineDisplayed");
addAction("actionShow_Equator_Line", displayGroup, N_("Equator line" ), "equatorLineDisplayed", "."); addAction("actionShow_Equator_Line", displayGroup, N_("Equator line" ), "equatorLineDisplayed", ".");
addAction("actionShow_Equator_J2000_Line", displayGroup, N_("Equator J2000 line"), "equatorJ2000LineDisplayed"); // or with Hotkey??
addAction("actionShow_Meridian_Line", displayGroup, N_("Meridian lin e"), "meridianLineDisplayed", ";"); addAction("actionShow_Meridian_Line", displayGroup, N_("Meridian lin e"), "meridianLineDisplayed", ";");
addAction("actionShow_Horizon_Line", displayGroup, N_("Horizon line" ), "horizonLineDisplayed", "H"); addAction("actionShow_Horizon_Line", displayGroup, N_("Horizon line" ), "horizonLineDisplayed", "H");
addAction("actionShow_Equatorial_J2000_Grid", displayGroup, N_("Equa torial J2000 grid"), "equatorJ2000GridDisplayed"); addAction("actionShow_Equatorial_J2000_Grid", displayGroup, N_("Equa torial J2000 grid"), "equatorJ2000GridDisplayed");
addAction("actionShow_Ecliptic_J2000_Grid", displayGroup, N_("Eclipt ic J2000 grid"), "eclipticJ2000GridDisplayed"); addAction("actionShow_Ecliptic_J2000_Grid", displayGroup, N_("Eclipt ic J2000 grid"), "eclipticJ2000GridDisplayed");
addAction("actionShow_Ecliptic_Grid", displayGroup, N_("Ecliptic gri d"), "eclipticGridDisplayed");
addAction("actionShow_Galactic_Grid", displayGroup, N_("Galactic gri d"), "galacticGridDisplayed"); addAction("actionShow_Galactic_Grid", displayGroup, N_("Galactic gri d"), "galacticGridDisplayed");
addAction("actionShow_Galactic_Equator_Line", displayGroup, N_("Gala ctic equator"), "galacticEquatorLineDisplayed"); addAction("actionShow_Galactic_Equator_Line", displayGroup, N_("Gala ctic equator"), "galacticEquatorLineDisplayed");
addAction("actionShow_Longitude_Line", displayGroup, N_("Opposition/ conjunction longitude line"), "longitudeLineDisplayed"); addAction("actionShow_Longitude_Line", displayGroup, N_("Opposition/ conjunction longitude line"), "longitudeLineDisplayed");
addAction("actionShow_Precession_Circles", displayGroup, N_("Precess ion Circles"), "precessionCirclesDisplayed");
} }
void GridLinesMgr::update(double deltaTime) void GridLinesMgr::update(double deltaTime)
{ {
// Update faders // Update faders
equGrid->update(deltaTime); equGrid->update(deltaTime);
equJ2000Grid->update(deltaTime); equJ2000Grid->update(deltaTime);
eclJ2000Grid->update(deltaTime); eclJ2000Grid->update(deltaTime);
eclGrid->update(deltaTime);
galacticGrid->update(deltaTime); galacticGrid->update(deltaTime);
aziGrid->update(deltaTime); aziGrid->update(deltaTime);
equatorLine->update(deltaTime); equatorLine->update(deltaTime);
equatorJ2000Line->update(deltaTime);
eclipticLine->update(deltaTime); eclipticLine->update(deltaTime);
eclipticJ2000Line->update(deltaTime);
precessionCircleN->update(deltaTime);
precessionCircleS->update(deltaTime);
meridianLine->update(deltaTime); meridianLine->update(deltaTime);
horizonLine->update(deltaTime); horizonLine->update(deltaTime);
galacticEquatorLine->update(deltaTime); galacticEquatorLine->update(deltaTime);
longitudeLine->update(deltaTime); longitudeLine->update(deltaTime);
} }
void GridLinesMgr::draw(StelCore* core) void GridLinesMgr::draw(StelCore* core)
{ {
equGrid->draw(core);
galacticGrid->draw(core); galacticGrid->draw(core);
equJ2000Grid->draw(core);
eclJ2000Grid->draw(core); eclJ2000Grid->draw(core);
// While ecliptic of J2000 may be helpful to get a feeling of the Z=
0 plane of VSOP87,
// ecliptic of date is related to Earth and does not make much sense
for the other planets.
// Of course, orbital plane of respective planet would be better, bu
t is not implemented.
if (core->getCurrentPlanet()->getEnglishName()=="Earth")
eclGrid->draw(core);
equJ2000Grid->draw(core);
equGrid->draw(core);
aziGrid->draw(core); aziGrid->draw(core);
// Lines after grids, to be able to e.g. draw equators in different
color!
galacticEquatorLine->draw(core);
eclipticJ2000Line->draw(core);
if (core->getCurrentPlanet()->getEnglishName()=="Earth")
{
eclipticLine->draw(core);
precessionCircleN->draw(core);
precessionCircleS->draw(core);
}
longitudeLine->draw(core);
equatorJ2000Line->draw(core);
equatorLine->draw(core); equatorLine->draw(core);
eclipticLine->draw(core);
meridianLine->draw(core); meridianLine->draw(core);
horizonLine->draw(core); horizonLine->draw(core);
galacticEquatorLine->draw(core);
longitudeLine->draw(core);
} }
void GridLinesMgr::setStelStyle(const QString& section) void GridLinesMgr::setStelStyle(const QString& section)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
// Load colors from config file // Load colors from config file
QString defaultColor = conf->value(section+"/default_color").toStrin g(); QString defaultColor = conf->value(section+"/default_color").toStrin g();
setColorEquatorGrid(StelUtils::strToVec3f(conf->value(section+"/equa torial_color", defaultColor).toString())); setColorEquatorGrid(StelUtils::strToVec3f(conf->value(section+"/equa torial_color", defaultColor).toString()));
setColorEquatorJ2000Grid(StelUtils::strToVec3f(conf->value(section+" /equatorial_J2000_color", defaultColor).toString())); setColorEquatorJ2000Grid(StelUtils::strToVec3f(conf->value(section+" /equatorial_J2000_color", defaultColor).toString()));
setColorEclipticJ2000Grid(StelUtils::strToVec3f(conf->value(section+ setColorEclipticJ2000Grid(StelUtils::strToVec3f(conf->value(section+
"/ecliptic_J2000_color", defaultColor).toString())); "/ecliptical_J2000_color", defaultColor).toString()));
setColorEclipticGrid(StelUtils::strToVec3f(conf->value(section+"/ecl
iptical_color", defaultColor).toString()));
setColorGalacticGrid(StelUtils::strToVec3f(conf->value(section+"/gal actic_color", defaultColor).toString())); setColorGalacticGrid(StelUtils::strToVec3f(conf->value(section+"/gal actic_color", defaultColor).toString()));
setColorAzimuthalGrid(StelUtils::strToVec3f(conf->value(section+"/az imuthal_color", defaultColor).toString())); setColorAzimuthalGrid(StelUtils::strToVec3f(conf->value(section+"/az imuthal_color", defaultColor).toString()));
setColorEquatorLine(StelUtils::strToVec3f(conf->value(section+"/equa tor_color", defaultColor).toString())); setColorEquatorLine(StelUtils::strToVec3f(conf->value(section+"/equa tor_color", defaultColor).toString()));
setColorEclipticLine(StelUtils::strToVec3f(conf->value(section+"/ecl iptic_color", defaultColor).toString())); setColorEclipticLine(StelUtils::strToVec3f(conf->value(section+"/ecl iptic_color", defaultColor).toString()));
setColorEclipticJ2000Line(StelUtils::strToVec3f(conf->value(section+
"/ecliptic_J2000_color", defaultColor).toString()));
setColorPrecessionCircles(StelUtils::strToVec3f(conf->value(section+
"/precession_circles_color", defaultColor).toString()));
setColorMeridianLine(StelUtils::strToVec3f(conf->value(section+"/mer idian_color", defaultColor).toString())); setColorMeridianLine(StelUtils::strToVec3f(conf->value(section+"/mer idian_color", defaultColor).toString()));
setColorHorizonLine(StelUtils::strToVec3f(conf->value(section+"/hori zon_color", defaultColor).toString())); setColorHorizonLine(StelUtils::strToVec3f(conf->value(section+"/hori zon_color", defaultColor).toString()));
setColorGalacticEquatorLine(StelUtils::strToVec3f(conf->value(sectio n+"/galactic_equator_color", defaultColor).toString())); setColorGalacticEquatorLine(StelUtils::strToVec3f(conf->value(sectio n+"/galactic_equator_color", defaultColor).toString()));
setColorLongitudeLine(StelUtils::strToVec3f(conf->value(section+"/lo ngitude_color", defaultColor).toString())); setColorLongitudeLine(StelUtils::strToVec3f(conf->value(section+"/lo ngitude_color", defaultColor).toString()));
} }
void GridLinesMgr::updateLineLabels() void GridLinesMgr::updateLineLabels()
{ {
equatorJ2000Line->updateLabel();
equatorLine->updateLabel(); equatorLine->updateLabel();
eclipticLine->updateLabel(); eclipticLine->updateLabel();
eclipticJ2000Line->updateLabel();
precessionCircleN->updateLabel();
precessionCircleS->updateLabel();
meridianLine->updateLabel(); meridianLine->updateLabel();
horizonLine->updateLabel(); horizonLine->updateLabel();
galacticEquatorLine->updateLabel(); galacticEquatorLine->updateLabel();
longitudeLine->updateLabel(); longitudeLine->updateLabel();
} }
//! Set flag for displaying Azimuthal Grid //! Set flag for displaying Azimuthal Grid
void GridLinesMgr::setFlagAzimuthalGrid(const bool displayed) void GridLinesMgr::setFlagAzimuthalGrid(const bool displayed)
{ {
if(displayed != aziGrid->isDisplayed()) { if(displayed != aziGrid->isDisplayed()) {
skipping to change at line 925 skipping to change at line 1075
return eclJ2000Grid->getColor(); return eclJ2000Grid->getColor();
} }
void GridLinesMgr::setColorEclipticJ2000Grid(const Vec3f& newColor) void GridLinesMgr::setColorEclipticJ2000Grid(const Vec3f& newColor)
{ {
if(newColor != eclJ2000Grid->getColor()) { if(newColor != eclJ2000Grid->getColor()) {
eclJ2000Grid->setColor(newColor); eclJ2000Grid->setColor(newColor);
emit eclipticJ2000GridColorChanged(newColor); emit eclipticJ2000GridColorChanged(newColor);
} }
} }
//! Set flag for displaying Ecliptic of Date Grid
void GridLinesMgr::setFlagEclipticGrid(const bool displayed)
{
if(displayed != eclGrid->isDisplayed()) {
eclGrid->setDisplayed(displayed);
emit eclipticGridDisplayedChanged(displayed);
}
}
//! Get flag for displaying Ecliptic of Date Grid
bool GridLinesMgr::getFlagEclipticGrid(void) const
{
return eclGrid->isDisplayed();
}
Vec3f GridLinesMgr::getColorEclipticGrid(void) const
{
return eclGrid->getColor();
}
void GridLinesMgr::setColorEclipticGrid(const Vec3f& newColor)
{
if(newColor != eclGrid->getColor()) {
eclGrid->setColor(newColor);
emit eclipticGridColorChanged(newColor);
}
}
//! Set flag for displaying Galactic Grid //! Set flag for displaying Galactic Grid
void GridLinesMgr::setFlagGalacticGrid(const bool displayed) void GridLinesMgr::setFlagGalacticGrid(const bool displayed)
{ {
if(displayed != galacticGrid->isDisplayed()) { if(displayed != galacticGrid->isDisplayed()) {
galacticGrid->setDisplayed(displayed); galacticGrid->setDisplayed(displayed);
emit galacticGridDisplayedChanged(displayed); emit galacticGridDisplayedChanged(displayed);
} }
} }
//! Get flag for displaying Galactic Grid //! Get flag for displaying Galactic Grid
bool GridLinesMgr::getFlagGalacticGrid(void) const bool GridLinesMgr::getFlagGalacticGrid(void) const
skipping to change at line 975 skipping to change at line 1150
return equatorLine->getColor(); return equatorLine->getColor();
} }
void GridLinesMgr::setColorEquatorLine(const Vec3f& newColor) void GridLinesMgr::setColorEquatorLine(const Vec3f& newColor)
{ {
if(newColor != equatorLine->getColor()) { if(newColor != equatorLine->getColor()) {
equatorLine->setColor(newColor); equatorLine->setColor(newColor);
emit equatorLineColorChanged(newColor); emit equatorLineColorChanged(newColor);
} }
} }
//! Set flag for displaying J2000 Equatorial Line
void GridLinesMgr::setFlagEquatorJ2000Line(const bool displayed)
{
if(displayed != equatorJ2000Line->isDisplayed()) {
equatorJ2000Line->setDisplayed(displayed);
emit equatorJ2000LineDisplayedChanged(displayed);
}
}
//! Get flag for displaying J2000 Equatorial Line
bool GridLinesMgr::getFlagEquatorJ2000Line(void) const
{
return equatorJ2000Line->isDisplayed();
}
Vec3f GridLinesMgr::getColorEquatorJ2000Line(void) const
{
return equatorJ2000Line->getColor();
}
void GridLinesMgr::setColorEquatorJ2000Line(const Vec3f& newColor)
{
if(newColor != equatorJ2000Line->getColor()) {
equatorJ2000Line->setColor(newColor);
emit equatorJ2000LineColorChanged(newColor);
}
}
//! Set flag for displaying Ecliptic Line //! Set flag for displaying Ecliptic Line
void GridLinesMgr::setFlagEclipticLine(const bool displayed) void GridLinesMgr::setFlagEclipticLine(const bool displayed)
{ {
if(displayed != eclipticLine->isDisplayed()) { if(displayed != eclipticLine->isDisplayed()) {
eclipticLine->setDisplayed(displayed); eclipticLine->setDisplayed(displayed);
emit eclipticLineDisplayedChanged(displayed); emit eclipticLineDisplayedChanged(displayed);
} }
} }
//! Get flag for displaying Ecliptic Line //! Get flag for displaying Ecliptic Line
bool GridLinesMgr::getFlagEclipticLine(void) const bool GridLinesMgr::getFlagEclipticLine(void) const
skipping to change at line 1000 skipping to change at line 1200
return eclipticLine->getColor(); return eclipticLine->getColor();
} }
void GridLinesMgr::setColorEclipticLine(const Vec3f& newColor) void GridLinesMgr::setColorEclipticLine(const Vec3f& newColor)
{ {
if(newColor != eclipticLine->getColor()) { if(newColor != eclipticLine->getColor()) {
eclipticLine->setColor(newColor); eclipticLine->setColor(newColor);
emit eclipticLineColorChanged(newColor); emit eclipticLineColorChanged(newColor);
} }
} }
//! Set flag for displaying Ecliptic J2000 Line
void GridLinesMgr::setFlagEclipticJ2000Line(const bool displayed)
{
if(displayed != eclipticJ2000Line->isDisplayed()) {
eclipticJ2000Line->setDisplayed(displayed);
emit eclipticJ2000LineDisplayedChanged(displayed);
}
}
//! Get flag for displaying Ecliptic J2000 Line
bool GridLinesMgr::getFlagEclipticJ2000Line(void) const
{
return eclipticJ2000Line->isDisplayed();
}
Vec3f GridLinesMgr::getColorEclipticJ2000Line(void) const
{
return eclipticJ2000Line->getColor();
}
void GridLinesMgr::setColorEclipticJ2000Line(const Vec3f& newColor)
{
if(newColor != eclipticJ2000Line->getColor()) {
eclipticJ2000Line->setColor(newColor);
emit eclipticJ2000LineColorChanged(newColor);
}
}
//! Set flag for displaying Precession Circles
void GridLinesMgr::setFlagPrecessionCircles(const bool displayed)
{
if(displayed != precessionCircleN->isDisplayed()) {
precessionCircleN->setDisplayed(displayed);
precessionCircleS->setDisplayed(displayed);
emit precessionCirclesDisplayedChanged(displayed);
}
}
//! Get flag for displaying Precession Circles
bool GridLinesMgr::getFlagPrecessionCircles(void) const
{
// precessionCircleS is always synchronous, no separate queries.
return precessionCircleN->isDisplayed();
}
Vec3f GridLinesMgr::getColorPrecessionCircles(void) const
{
return precessionCircleN->getColor();
}
void GridLinesMgr::setColorPrecessionCircles(const Vec3f& newColor)
{
if(newColor != precessionCircleN->getColor()) {
precessionCircleN->setColor(newColor);
precessionCircleS->setColor(newColor);
emit precessionCirclesColorChanged(newColor);
}
}
//! Set flag for displaying Meridian Line //! Set flag for displaying Meridian Line
void GridLinesMgr::setFlagMeridianLine(const bool displayed) void GridLinesMgr::setFlagMeridianLine(const bool displayed)
{ {
if(displayed != meridianLine->isDisplayed()) { if(displayed != meridianLine->isDisplayed()) {
meridianLine->setDisplayed(displayed); meridianLine->setDisplayed(displayed);
emit meridianLineDisplayedChanged(displayed); emit meridianLineDisplayedChanged(displayed);
} }
} }
//! Get flag for displaying Meridian Line //! Get flag for displaying Meridian Line
bool GridLinesMgr::getFlagMeridianLine(void) const bool GridLinesMgr::getFlagMeridianLine(void) const
 End of changes. 48 change blocks. 
31 lines changed or deleted 320 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/