GridLinesMgr.cpp   GridLinesMgr.cpp 
skipping to change at line 28 skipping to change at line 28
*/ */
#include <set> #include <set>
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QFontMetrics> #include <QFontMetrics>
#include <QtOpenGL> #include <QtOpenGL>
#include "GridLinesMgr.hpp" #include "GridLinesMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelNavigator.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"
//! @class SkyGrid //! @class SkyGrid
//! Class which manages a grid to display in the sky. //! Class which manages a grid to display in the sky.
//! TODO needs support for DMS/DMS labelling, not only HMS/DMS //! TODO needs support for DMS/DMS labelling, not only HMS/DMS
class SkyGrid class SkyGrid
{ {
public: public:
// Create and precompute positions of a SkyGrid // Create and precompute positions of a SkyGrid
SkyGrid(StelCore::FrameType frame); SkyGrid(StelCore::FrameType frame);
virtual ~SkyGrid(); virtual ~SkyGrid();
skipping to change at line 71 skipping to change at line 72
//! @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,
ECLIPTIC, ECLIPTIC,
MERIDIAN MERIDIAN,
HORIZON
}; };
// 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);
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 setFlagshow(bool b){fader = b;} void setFlagshow(bool b){fader = b;}
skipping to change at line 190 skipping to change at line 192
if (std::fabs(2.*M_PI-lon)<0.01) if (std::fabs(2.*M_PI-lon)<0.01)
{ {
// We are at meridian 0 // We are at meridian 0
lon = 0.; lon = 0.;
} }
if (std::fabs(lon-raAngle) < 0.01) if (std::fabs(lon-raAngle) < 0.01)
text = StelUtils::radToDmsStrAdapt(r aAngle); text = StelUtils::radToDmsStrAdapt(r aAngle);
else else
{ {
const double delta = raAngle<M_PI ? M_PI : -M_PI; const double delta = raAngle<M_PI ? M_PI : -M_PI;
text = StelUtils::radToDmsStrAdapt(r if (raAngle==2*M_PI && delta==-M_PI)
aAngle+delta); {
text = StelUtils::radToDmsSt
rAdapt(0);
}
else
{
text = StelUtils::radToDmsSt
rAdapt(raAngle+delta);
}
} }
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;
if (raAngle<0) if (raAngle<0)
raAngle=+2.*M_PI; raAngle=+2.*M_PI;
if (lon<0) if (lon<0)
skipping to change at line 254 skipping to change at line 263
d->sPainter->drawText(screenPos[0], screenPos[1], text, angleDeg, xs hift, 3); d->sPainter->drawText(screenPos[0], screenPos[1], text, angleDeg, xs hift, 3);
d->sPainter->setColor(tmpColor[0], tmpColor[1], tmpColor[2], tmpColo r[3]); d->sPainter->setColor(tmpColor[0], tmpColor[1], tmpColor[2], tmpColo r[3]);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
} }
//! Draw the sky grid in the current frame //! Draw the sky grid in the current frame
void SkyGrid::draw(const StelCore* core) const void SkyGrid::draw(const StelCore* core) const
{ {
const StelProjectorP prj = core->getProjection(frameType); const StelProjectorP prj = core->getProjection(frameType, frameType! =StelCore::FrameAltAz ? StelCore::RefractionAuto : StelCore::RefractionOff) ;
if (!fader.getInterstate()) if (!fader.getInterstate())
return; return;
// Look for all meridians and parallels intersecting with the disk b ounding the viewport // Look for all meridians and parallels intersecting with the disk b ounding the viewport
// Check whether the pole are in the viewport // Check whether the pole are in the viewport
bool northPoleInViewport = false; bool northPoleInViewport = false;
bool southPoleInViewport = false; bool southPoleInViewport = false;
Vec3f win; Vec3f win;
if (prj->project(Vec3f(0,0,1), win) && prj->checkInViewport(win)) if (prj->project(Vec3f(0,0,1), win) && prj->checkInViewport(win))
northPoleInViewport = true; northPoleInViewport = true;
skipping to change at line 524 skipping to change at line 533
label = q_("Meridian"); label = q_("Meridian");
break; break;
case ECLIPTIC: case ECLIPTIC:
frameType = StelCore::FrameObservercentricEcliptic; frameType = StelCore::FrameObservercentricEcliptic;
label = q_("Ecliptic"); label = q_("Ecliptic");
break; break;
case EQUATOR: case EQUATOR:
frameType = StelCore::FrameEquinoxEqu; frameType = StelCore::FrameEquinoxEqu;
label = q_("Equator"); label = q_("Equator");
break; break;
case HORIZON:
frameType = StelCore::FrameAltAz;
label = q_("Horizon");
break;
} }
} }
SkyLine::~SkyLine() SkyLine::~SkyLine()
{ {
} }
void SkyLine::setFontSize(double newFontSize) void SkyLine::setFontSize(double newFontSize)
{ {
font.setPixelSize(newFontSize); font.setPixelSize(newFontSize);
} }
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); 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
Vec4f textColor(color[0], color[1], color[2], 0); Vec4f textColor(color[0], color[1], color[2], 0);
textColor*=2; textColor*=2;
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
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);
} }
Vec3d p1, p2; Vec3d p1, p2;
skipping to change at line 616 skipping to change at line 628
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);
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);
eclipticLine = new SkyLine(SkyLine::ECLIPTIC); eclipticLine = new SkyLine(SkyLine::ECLIPTIC);
meridianLine = new SkyLine(SkyLine::MERIDIAN); meridianLine = new SkyLine(SkyLine::MERIDIAN);
horizonLine = new SkyLine(SkyLine::HORIZON);
} }
GridLinesMgr::~GridLinesMgr() GridLinesMgr::~GridLinesMgr()
{ {
delete equGrid; delete equGrid;
delete equJ2000Grid; delete equJ2000Grid;
delete galacticGrid; delete galacticGrid;
delete aziGrid; delete aziGrid;
delete equatorLine; delete equatorLine;
delete eclipticLine; delete eclipticLine;
delete meridianLine; delete meridianLine;
delete horizonLine;
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double GridLinesMgr::getCallOrder(StelModuleActionName actionName) const double GridLinesMgr::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Nebu laMgr")->getCallOrder(actionName)+10; return StelApp::getInstance().getModuleMgr().getModule("Nebu laMgr")->getCallOrder(actionName)+10;
return 0; return 0;
skipping to change at line 651 skipping to change at line 665
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());
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() );
setFlagEclipticLine(conf->value("viewing/flag_ecliptic_line").toBool ()); setFlagEclipticLine(conf->value("viewing/flag_ecliptic_line").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()
);
connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QSt
ring&)), this, SLOT(setStelStyle(const QString&)));
} }
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);
galacticGrid->update(deltaTime); galacticGrid->update(deltaTime);
aziGrid->update(deltaTime); aziGrid->update(deltaTime);
equatorLine->update(deltaTime); equatorLine->update(deltaTime);
eclipticLine->update(deltaTime); eclipticLine->update(deltaTime);
meridianLine->update(deltaTime); meridianLine->update(deltaTime);
horizonLine->update(deltaTime);
} }
void GridLinesMgr::draw(StelCore* core) void GridLinesMgr::draw(StelCore* core)
{ {
equGrid->draw(core); equGrid->draw(core);
galacticGrid->draw(core); galacticGrid->draw(core);
equJ2000Grid->draw(core); equJ2000Grid->draw(core);
aziGrid->draw(core); aziGrid->draw(core);
equatorLine->draw(core); equatorLine->draw(core);
eclipticLine->draw(core); eclipticLine->draw(core);
meridianLine->draw(core); meridianLine->draw(core);
horizonLine->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()));
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()));
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()));
} }
//! Set flag for displaying Azimuthal Grid //! Set flag for displaying Azimuthal Grid
void GridLinesMgr::setFlagAzimuthalGrid(bool b) {aziGrid->setFlagshow(b);} void GridLinesMgr::setFlagAzimuthalGrid(bool b) {aziGrid->setFlagshow(b);}
//! Get flag for displaying Azimuthal Grid //! Get flag for displaying Azimuthal Grid
bool GridLinesMgr::getFlagAzimuthalGrid(void) const {return aziGrid->getFla gshow();} bool GridLinesMgr::getFlagAzimuthalGrid(void) const {return aziGrid->getFla gshow();}
Vec3f GridLinesMgr::getColorAzimuthalGrid(void) const {return aziGrid->getC olor();} Vec3f GridLinesMgr::getColorAzimuthalGrid(void) const {return aziGrid->getC olor();}
//! Set flag for displaying Equatorial Grid //! Set flag for displaying Equatorial Grid
void GridLinesMgr::setFlagEquatorGrid(bool b) {equGrid->setFlagshow(b);} void GridLinesMgr::setFlagEquatorGrid(bool b) {equGrid->setFlagshow(b);}
skipping to change at line 733 skipping to change at line 752
//! Get flag for displaying Ecliptic Line //! Get flag for displaying Ecliptic Line
bool GridLinesMgr::getFlagEclipticLine(void) const {return eclipticLine->ge tFlagshow();} bool GridLinesMgr::getFlagEclipticLine(void) const {return eclipticLine->ge tFlagshow();}
Vec3f GridLinesMgr::getColorEclipticLine(void) const {return eclipticLine-> getColor();} Vec3f GridLinesMgr::getColorEclipticLine(void) const {return eclipticLine-> getColor();}
//! Set flag for displaying Meridian Line //! Set flag for displaying Meridian Line
void GridLinesMgr::setFlagMeridianLine(bool b) {meridianLine->setFlagshow(b );} void GridLinesMgr::setFlagMeridianLine(bool b) {meridianLine->setFlagshow(b );}
//! Get flag for displaying Meridian Line //! Get flag for displaying Meridian Line
bool GridLinesMgr::getFlagMeridianLine(void) const {return meridianLine->ge tFlagshow();} bool GridLinesMgr::getFlagMeridianLine(void) const {return meridianLine->ge tFlagshow();}
Vec3f GridLinesMgr::getColorMeridianLine(void) const {return meridianLine-> getColor();} Vec3f GridLinesMgr::getColorMeridianLine(void) const {return meridianLine-> getColor();}
//! Set flag for displaying Horizon Line
void GridLinesMgr::setFlagHorizonLine(bool b) {horizonLine->setFlagshow(b);
}
//! Get flag for displaying Horizon Line
bool GridLinesMgr::getFlagHorizonLine(void) const {return horizonLine->getF
lagshow();}
Vec3f GridLinesMgr::getColorHorizonLine(void) const {return horizonLine->ge
tColor();}
void GridLinesMgr::setColorAzimuthalGrid(const Vec3f& v) { aziGrid->setColo r(v);} void GridLinesMgr::setColorAzimuthalGrid(const Vec3f& v) { aziGrid->setColo r(v);}
void GridLinesMgr::setColorEquatorGrid(const Vec3f& v) { equGrid->setColor( v);} void GridLinesMgr::setColorEquatorGrid(const Vec3f& v) { equGrid->setColor( v);}
void GridLinesMgr::setColorEquatorJ2000Grid(const Vec3f& v) { equJ2000Grid- >setColor(v);} void GridLinesMgr::setColorEquatorJ2000Grid(const Vec3f& v) { equJ2000Grid- >setColor(v);}
void GridLinesMgr::setColorGalacticGrid(const Vec3f& v) { galacticGrid->set Color(v);} void GridLinesMgr::setColorGalacticGrid(const Vec3f& v) { galacticGrid->set Color(v);}
void GridLinesMgr::setColorEquatorLine(const Vec3f& v) { equatorLine->setCo lor(v);} void GridLinesMgr::setColorEquatorLine(const Vec3f& v) { equatorLine->setCo lor(v);}
void GridLinesMgr::setColorEclipticLine(const Vec3f& v) { eclipticLine->set Color(v);} void GridLinesMgr::setColorEclipticLine(const Vec3f& v) { eclipticLine->set Color(v);}
void GridLinesMgr::setColorMeridianLine(const Vec3f& v) { meridianLine->set Color(v);} void GridLinesMgr::setColorMeridianLine(const Vec3f& v) { meridianLine->set Color(v);}
void GridLinesMgr::setColorHorizonLine(const Vec3f& v) { horizonLine->setCo lor(v);}
 End of changes. 16 change blocks. 
7 lines changed or deleted 38 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/