GridLinesMgr.cpp   GridLinesMgr.cpp 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include <set> #include <set>
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include "GridLinesMgr.hpp" #include "GridLinesMgr.hpp"
#include "StelMovementMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "Navigator.hpp" #include "StelNavigator.hpp"
#include "Translator.hpp" #include "StelTranslator.hpp"
#include "Projector.hpp" #include "StelProjector.hpp"
#include "LoadingBar.hpp" #include "StelLoadingBar.hpp"
#include "Fader.hpp" #include "StelFader.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "StelFontMgr.hpp" #include "StelFontMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "SFont.hpp" #include "StelFont.hpp"
#include "StelStyle.hpp" #include "StelStyle.hpp"
#include "StelPainter.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: this class suffers a number of problems: //! TODO needs support for DMS/DMS labelling, not only HMS/DMS
//! 1- the algorithm used to find the points where the lines cross the edge
of the screen
//! is slow and very buggy at high latitudes
//! 2- 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(Projector::FrameType frame); SkyGrid(StelCore::FrameType frame);
virtual ~SkyGrid(); virtual ~SkyGrid();
void draw(const Projector* prj) const; void draw(const StelCore* prj) const;
void setFontSize(double newFontSize); void setFontSize(double newFontSize);
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 set_fade_duration(float duration) {fader.setDuration((int)(dura tion*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;}
bool getFlagshow(void) const {return fader;} bool getFlagshow(void) const {return fader;}
void set_top_transparancy(bool b) { transparent_top= b; }
private: private:
bool transparent_top;
Vec3f color; Vec3f color;
Projector::FrameType frameType; StelCore::FrameType frameType;
double fontSize; double fontSize;
SFont& font; StelFont& font;
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,
ECLIPTIC, ECLIPTIC,
LOCAL,
MERIDIAN MERIDIAN
}; };
// 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(Projector *prj,const Navigator *nav) 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 set_fade_duration(float duration) {fader.setDuration((int)(dura tion*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;}
bool getFlagshow(void) const {return fader;} bool getFlagshow(void) const {return fader;}
void setFontSize(double newSize); void setFontSize(double newSize);
private: private:
SKY_LINE_TYPE line_type; SKY_LINE_TYPE line_type;
Vec3f color; Vec3f color;
Projector::FrameType frameType; StelCore::FrameType frameType;
LinearFader fader; LinearFader fader;
double fontSize; double fontSize;
SFont& font; StelFont& font;
QString label;
}; };
// rms added color as parameter // rms added color as parameter
SkyGrid::SkyGrid(Projector::FrameType frame) : color(0.2,0.2,0.2), frameTyp e(frame), fontSize(12), SkyGrid::SkyGrid(StelCore::FrameType frame) : color(0.2,0.2,0.2), frameType (frame), fontSize(12),
font(StelApp::getInstance().getFontManager().getStandardFont(StelApp ::getInstance().getLocaleMgr().getAppLanguage(), fontSize)) font(StelApp::getInstance().getFontManager().getStandardFont(StelApp ::getInstance().getLocaleMgr().getAppLanguage(), fontSize))
{ {
transparent_top = true;
} }
SkyGrid::~SkyGrid() SkyGrid::~SkyGrid()
{ {
} }
void SkyGrid::setFontSize(double newFontSize) void SkyGrid::setFontSize(double newFontSize)
{ {
fontSize = newFontSize; fontSize = newFontSize;
font = StelApp::getInstance().getFontManager().getStandardFont(StelA pp::getInstance().getLocaleMgr().getAppLanguage(), fontSize); font = StelApp::getInstance().getFontManager().getStandardFont(StelA pp::getInstance().getLocaleMgr().getAppLanguage(), fontSize);
} }
// Conversion into mas = milli arcsecond // Conversion into mas = milli arcsecond
static const double RADIAN_MAS = 180./M_PI*1000.*60.*60.; static const double RADIAN_MAS = 180./M_PI*1000.*60.*60.;
static const double DEGREE_MAS = 1000.*60.*60.; static const double DEGREE_MAS = 1000.*60.*60.;
//! Return the standard longitude in radian [-pi;+pi] for a position given
in the viewport
static double getLonFrom2dPos(const Projector* prj, const Vec2d& p)
{
Vec3d v;
prj->unProject(p[0], p[1], v);
return std::atan2(v[1],v[0]);
}
//! Return the standard latitude in radian [-pi/2;+pi/2] for a position giv
en in the viewport
static double getLatFrom2dPos(const Projector* prj, const Vec2d& p)
{
Vec3d v;
prj->unProject(p[0], p[1], v);
return std::asin(v[2]);
}
//! Return a "longitude" between 0 and pi and "latitude" between 0 and 2*pi
//! This is used to get rid of the longitude discontinuity in lon=0
void rectToSpheType2(double& lon, double& lat, const Vec3d& v)
{
StelUtils::rectToSphe(&lon, &lat, v);
// lon is now between -pi and pi, we want it between 0 and pi, like
a latitude
// lat is now between -pi/2 and pi/2, we want it between 0 and 2*pi
like a longitude
lat += M_PI/2;
if (lon<0.)
{
lat = 2.*M_PI-lat;
lon = -lon;
}
assert(lat>=0. && lat<=2.*M_PI);
assert(lon>=0. && lon<=M_PI);
}
//! Create a vector from a "longitude" between 0 and pi and "latitude" betw
een 0 and 2*pi
//! This is used to get rid of the longitude discontinuity in lon=0
void spheToRectType2(double lon, double lat, Vec3d& v)
{
assert(lat>=0. && lat<=2.*M_PI);
assert(lon>=0. && lon<=M_PI);
if (lat>M_PI)
{
lat = 2.*M_PI-lat;
lon = -lon;
}
lat -= M_PI/2;
StelUtils::spheToRect(lon, lat, v);
}
void spheToRectLat1802(double lon, double lat, Vec3d& v)
{
assert(lat>=0. && lat<=2.*M_PI);
assert(lon>=0. && lon<=M_PI);
if (lat>M_PI)
{
lat = 2.*M_PI-lat;
lon += M_PI;
}
lat -= M_PI/2;
StelUtils::spheToRect(lon, lat, v);
}
//! Return a special latitude in radian [0;2*pi] for a position given in th
e viewport
static double getLatFrom2dPosType2(const Projector* prj, const Vec2d& p)
{
Vec3d v;
prj->unProject(p[0], p[1], v);
double lon, lat;
rectToSpheType2(lon, lat, v);
return lat;
}
//! Return a special longitude in radian [0;pi] for a position given in the
viewport
static double getLonFrom2dPosType2(const Projector* prj, const Vec2d& p)
{
Vec3d v;
prj->unProject(p[0], p[1], v);
double lon, lat;
rectToSpheType2(lon, lat, v);
return lon;
}
//! Return the 2D position in the viewport from a longitude and latitude in
radian
static Vec3d get2dPosFromSpherical(const Projector* prj, double lon, double
lat)
{
Vec3d v;
Vec3d win;
StelUtils::spheToRect(lon, lat, v);
prj->project(v, win);
return win;
}
//! Return the 2D position in the viewport from special longitude and latit
ude in radian
static Vec3d get2dPosFromSpherical1802(const Projector* prj, double lon, do
uble lat)
{
Vec3d v;
Vec3d win;
spheToRectLat1802(lon, lat, v);
prj->project(v, win);
return win;
}
//! Check if the given point from the viewport side is the beginning of a p
arallel or not
//! Beginning means that the direction of increasing longitude goes inside
the viewport
static bool isParallelEntering(const Projector* prj, double lon, double lat
)
{
return prj->checkInViewport(get2dPosFromSpherical(prj, lon+0.0001*pr
j->getFov(), lat));
}
//! Check if the given point from the viewport side is the beginning of a m
eridian or not
//! Beginning means that the direction of increasing latitude goes inside t
he viewport
//! @param lon180 Modified longitude in radian
static bool isMeridianEnteringLat180(const Projector* prj, double lon1802,
double lat1802)
{
assert(lat1802>=0. && lat1802<=2.*M_PI);
assert(lon1802>=0. && lon1802<=M_PI);
double lat2 = lat1802+0.001*prj->getFov();
if (lat2>2.*M_PI)
lat2-=2.*M_PI;
return prj->checkInViewport(get2dPosFromSpherical1802(prj, lon1802,
lat2));
}
//! Return all the points p on the segment [p0 p1] for which the value of f
unc(p) == k*step
//! For each value of k*step, the result is then sorted ordered according t
o the value of func2(p)
//! @return a map associating all the values of k*step and their associated
func2(p)
static void getPslow(std::map<int, std::set<double> > & result, const Proje
ctor* prj,
const Vec2d& p0, const Vec2d& p1, double step,
double (*func)(const Projector* prj, const Vec2d& p),
double (*func2)(const Projector* prj, const Vec2d& p))
{
double precision = 0.1;
const Vec2d deltaP(p1-p0);
Vec2d p = p0;
const double umax = deltaP.length();
const Vec2d dPix1 = deltaP/umax; // 1 pixel step
double funcp, funcpDpix;
funcp = func(prj, p);
funcpDpix = func(prj, p+dPix1*precision);
double u=0.;
bool lastLoop=false;
bool stop;
do
{
stop = lastLoop;
if (funcp<funcpDpix) // func(p) increases over the segment [
p p+dPix]
{
// If targets are included inside the range, add the
m
double v = step*(std::ceil(funcp/step));
while (v<=funcpDpix)
{
result[(int)(v*RADIAN_MAS)].insert(func2(prj
, p-dPix1*precision*(funcpDpix-v)/(funcpDpix-funcp)));
v+=step;
}
}
else // func(p) descreases over the segment [p p+dPix]
{
// If targets are included inside the range, add the
m
double v = step*(std::floor(funcp/step));
while(v>=funcpDpix)
{
result[(int)(v*RADIAN_MAS)].insert(func2(prj
, p-dPix1*precision*(v-funcpDpix)/(funcp-funcpDpix)));
v-=step;
}
}
precision = step/(std::fabs(funcpDpix-funcp)/precision);
if (precision>2 || funcpDpix-funcp==0.)
precision = 2.;
else if (precision<0.5)
precision = 0.5;
u+=precision;
if (u>umax)
{
precision-=u-umax;
u=umax;
lastLoop = true;
}
p+=dPix1*precision;
funcp = funcpDpix;
funcpDpix = func(prj,p);
}
while(stop==false);
}
// Step sizes in arcsec // Step sizes in arcsec
static const double STEP_SIZES_DMS[] = {1., 5., 10., 60., 300., 600., 1200. static const double STEP_SIZES_DMS[] = {0.05, 0.2, 1., 5., 10., 60., 300.,
, 3600., 3600.*5., 3600.*10.}; 600., 1200., 3600., 3600.*5., 3600.*10.};
static const double STEP_SIZES_HMS[] = {1.5, 7.5, 15., 15.*5., 15.*10., 15. static const double STEP_SIZES_HMS[] = {0.05, 0.2, 1.5, 7.5, 15., 15.*5., 1
*60., 15.*60.*5., 15.*60*10., 15.*60*60}; 5.*10., 15.*60., 15.*60.*5., 15.*60*10., 15.*60*60};
//! Return the angular grid step in degree which best fits the given scale //! Return the angular grid step in degree which best fits the given scale
static double getClosestResolutionDMS(double pixelPerRad) static double getClosestResolutionDMS(double pixelPerRad)
{ {
double minResolution = 80.; double minResolution = 80.;
double minSizeArcsec = minResolution/pixelPerRad*180./M_PI*3600; double minSizeArcsec = minResolution/pixelPerRad*180./M_PI*3600;
for (unsigned int i=0;i<10;++i) for (unsigned int i=0;i<12;++i)
if (STEP_SIZES_DMS[i]>minSizeArcsec) if (STEP_SIZES_DMS[i]>minSizeArcsec)
{ {
return STEP_SIZES_DMS[i]/3600.; return STEP_SIZES_DMS[i]/3600.;
} }
return 10.; return 10.;
} }
//! Return the angular grid step in degree which best fits the given scale //! Return the angular grid step in degree which best fits the given scale
static double getClosestResolutionHMS(double pixelPerRad) static double getClosestResolutionHMS(double pixelPerRad)
{ {
double minResolution = 80.; double minResolution = 80.;
double minSizeArcsec = minResolution/pixelPerRad*180./M_PI*3600; double minSizeArcsec = minResolution/pixelPerRad*180./M_PI*3600;
for (unsigned int i=0;i<9;++i) for (unsigned int i=0;i<11;++i)
if (STEP_SIZES_HMS[i]>minSizeArcsec) if (STEP_SIZES_HMS[i]>minSizeArcsec)
{ {
return STEP_SIZES_HMS[i]/3600.; return STEP_SIZES_HMS[i]/3600.;
} }
return 15.; return 15.;
} }
//! Draw the sky grid in the current frame struct ViewportEdgeIntersectCallbackData
//! This method look for each point of the viewport's contour intersecting
with a meridian/parallel
//! The the intersecting points are matched 2 by 2 to find out where to dra
w the arc of meridian/parallel
void SkyGrid::draw(const Projector* prj) const
{ {
if (!fader.getInterstate()) return; ViewportEdgeIntersectCallbackData(const StelPainter& p) : sPainter(p
glDisable(GL_TEXTURE_2D); ) {;}
glEnable(GL_BLEND); const StelPainter& sPainter;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa StelFont* font;
rency mode Vec4f textColor;
Vec4f textColor(color[0], color[1], color[2], 0); QString text; // Label to display at the intersection of t
float red; he lines and screen side
double raAngle; // Used for meridians
StelCore::FrameType frameType;
};
if (StelApp::getInstance().getVisionModeNight()) // Callback which draws the label of the grid
{ void viewportEdgeIntersectCallback(const Vec3d& screenPos, const Vec3d& dir
// instead of a filter which just zeros G&B, set the red ection, const void* userData)
// value to the mean brightness of RGB. {
red = (color[0] + color[1] + color[2]) / 3.0; const ViewportEdgeIntersectCallbackData* d = static_cast<const Viewp
textColor[0] = red; ortEdgeIntersectCallbackData*>(userData);
textColor[1] = 0.; textColor[2] = 0.; Vec3d direc(direction);
glColor4f(red, 0, 0, fader.getInterstate()); direc.normalize();
GLfloat tmpColor[4];
glGetFloatv(GL_CURRENT_COLOR, tmpColor);
glColor4fv(d->textColor);
QString text;
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)
Vec3d tmpV;
d->sPainter.getProjector()->unProject(screenPos, tmpV);
double lon, lat;
StelUtils::rectToSphe(&lon, &lat, tmpV);
if (d->frameType==StelCore::FrameAltAz)
{
double raAngle = M_PI-d->raAngle;
lon = M_PI-lon;
if (raAngle<0)
raAngle=+2.*M_PI;
if (lon<0)
lon=+2.*M_PI;
if (std::fabs(2.*M_PI-lon)<0.01)
{
// We are at meridian 0
lon = 0.;
}
if (std::fabs(lon-raAngle) < 0.01)
text = StelUtils::radToDmsStrAdapt(raAngle);
else
{
const double delta = raAngle<M_PI ? M_PI : -
M_PI;
text = StelUtils::radToDmsStrAdapt(raAngle+d
elta);
}
}
else
{
if (std::fabs(2.*M_PI-lon)<0.01)
{
// We are at meridian 0
lon = 0.;
}
if (std::fabs(lon-d->raAngle) < 0.01)
text = StelUtils::radToHmsStrAdapt(d->raAngl
e);
else
{
const double delta = d->raAngle<M_PI ? M_PI
: -M_PI;
text = StelUtils::radToHmsStrAdapt(d->raAngl
e+delta);
}
}
} }
else else
text = d->text;
double angleDeg = std::atan2(-direc[1], -direc[0])*180./M_PI;
float xshift=6.f;
if (angleDeg>90. || angleDeg<-90.)
{ {
glColor4f(color[0],color[1],color[2], fader.getInterstate()) angleDeg+=180.;
; xshift=-d->font->getStrLen(text)-6.f;
} }
textColor*=2; d->sPainter.drawText(d->font, screenPos[0], screenPos[1], text, angl
textColor[3]=fader.getInterstate(); eDeg, xshift, 3);
glColor4fv(tmpColor);
}
prj->setCurrentFrame(frameType); // set 2D coordinate //! Draw the sky grid in the current frame
void SkyGrid::draw(const StelCore* core) const
{
const StelProjectorP prj = core->getProjection(frameType);
if (!fader.getInterstate())
return;
// 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;
Vec3d win; Vec3d win;
if (prj->project(Vec3d(0,0,1), win) && prj->checkInViewport(win)) if (prj->project(Vec3d(0,0,1), win) && prj->checkInViewport(win))
northPoleInViewport = true; northPoleInViewport = true;
if (prj->project(Vec3d(0,0,-1), win) && prj->checkInViewport(win)) if (prj->project(Vec3d(0,0,-1), win) && prj->checkInViewport(win))
southPoleInViewport = true; southPoleInViewport = true;
// Get the longitude and latitude resolution at the center of the vi ewport // Get the longitude and latitude resolution at the center of the vi ewport
Vec3d centerV; Vec3d centerV;
double lon0, lat0, lon1, lat1, lon2, lat2;
prj->unProject(prj->getViewportPosX()+prj->getViewportWidth()/2, prj
->getViewportPosY()+prj->getViewportHeight()/2, centerV);
StelUtils::rectToSphe(&lon0, &lat0, centerV);
prj->unProject(prj->getViewportPosX()+prj->getViewportWidth()/2+1, p
rj->getViewportPosY()+prj->getViewportHeight()/2, centerV);
StelUtils::rectToSphe(&lon1, &lat1, centerV);
prj->unProject(prj->getViewportPosX()+prj->getViewportWidth()/2, prj ->getViewportPosY()+prj->getViewportHeight()/2+1, centerV); prj->unProject(prj->getViewportPosX()+prj->getViewportWidth()/2, prj ->getViewportPosY()+prj->getViewportHeight()/2+1, centerV);
double lon2, lat2;
StelUtils::rectToSphe(&lon2, &lat2, centerV); StelUtils::rectToSphe(&lon2, &lat2, centerV);
const double gridStepParallelRad = M_PI/180.*getClosestResolutionDMS const double gridStepParallelRad = M_PI/180.*getClosestResolutionDMS
(1./std::sqrt((lat1-lat0)*(lat1-lat0)+(lat2-lat0)*(lat2-lat0))); (prj->getPixelPerRadAtCenter());
double gridStepMeridianRad;
if (northPoleInViewport || southPoleInViewport)
gridStepMeridianRad = M_PI/180.* 15.;
else
{
const double closetResLon = (frameType==StelCore::FrameAltAz
) ? getClosestResolutionDMS(prj->getPixelPerRadAtCenter()*std::cos(lat2)) :
getClosestResolutionHMS(prj->getPixelPerRadAtCenter()*std::cos(lat2));
gridStepMeridianRad = M_PI/180.* ((northPoleInViewport || so
uthPoleInViewport) ? 15. : closetResLon);
}
// Get the bounding halfspace
const StelGeom::HalfSpace viewPortHalfSpace = prj->getBoundingHalfSp
ace();
// Compute the first grid starting point. This point is close to the
center of the screen
// and lays at the intersection of a meridien and a parallel
lon2 = gridStepMeridianRad*((int)(lon2/gridStepMeridianRad));
lat2 = gridStepParallelRad*((int)(lat2/gridStepParallelRad));
Vec3d firstPoint;
StelUtils::spheToRect(lon2, lat2, firstPoint);
firstPoint.normalize();
const double closetResLon = (frameType==Projector::FrameLocal) ? get Q_ASSERT(viewPortHalfSpace.contains(firstPoint));
ClosestResolutionDMS(1./std::sqrt((lon1-lon0)*(lon1-lon0)+(lon2-lon0)*(lon2
-lon0))) : getClosestResolutionHMS(1./std::sqrt((lon1-lon0)*(lon1-lon0)+(lo
n2-lon0)*(lon2-lon0)));
const double gridStepMeridianRad = M_PI/180.* ((northPoleInViewport
|| southPoleInViewport) ? 15. : closetResLon);
std::map<int, std::set<double> > resultsParallels; // Initialize a painter and set openGL state
std::map<int, std::set<double> > resultsMeridians; StelPainter sPainter(prj);
const QList<Vec2d> viewportVertices = prj->getViewportVertices2d(); glEnable(GL_LINE_SMOOTH);
for (int i=0;i<viewportVertices.size();++i) glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa
rency mode
Vec4f textColor(color[0], color[1], color[2], 0);
if (StelApp::getInstance().getVisionModeNight())
{ {
// The segment of the viewport is between v0 and v1 // instead of a filter which just zeros G&B, set the red
Vec2d vertex0 = viewportVertices[i]; // value to the mean brightness of RGB.
Vec2d vertex1 = viewportVertices[(i+1)%viewportVertices.size float red = (color[0] + color[1] + color[2]) / 3.0;
()]; textColor[0] = red;
getPslow(resultsParallels, prj, vertex0, vertex1, gridStepPa textColor[1] = 0.; textColor[2] = 0.;
rallelRad, getLatFrom2dPos, getLonFrom2dPos); glColor4f(red, 0, 0, fader.getInterstate());
getPslow(resultsMeridians, prj, vertex0, vertex1, gridStepMe
ridianRad, getLonFrom2dPosType2, getLatFrom2dPosType2);
} }
else
// Draw the parallels
for (std::map<int, std::set<double> >::const_iterator iter=resultsPa
rallels.begin(); iter!=resultsParallels.end(); ++iter)
{ {
if (iter->second.size()%2!=0) glColor4f(color[0],color[1],color[2], fader.getInterstate())
{ ;
qWarning() << "ERROR drawing skygrid - parallel "<< }
(double)iter->first/DEGREE_MAS << iter->second.size();
}
else
{
std::set<double>::const_iterator ii = iter->second.b
egin();
if (!isParallelEntering(prj, *iter->second.begin(),
(double)iter->first/RADIAN_MAS))
{
++ii;
}
Vec3d vv; textColor*=2;
double size; textColor[3]=fader.getInterstate();
for (unsigned int i=0;i<iter->second.size()/2;++i)
ViewportEdgeIntersectCallbackData userData(sPainter);
userData.font = &font;
userData.textColor = textColor;
userData.frameType = frameType;
/////////////////////////////////////////////////
// Draw all the meridians (great circles)
StelGeom::HalfSpace meridianHalfSpace(Vec3d(1,0,0), 0);
Mat4d rotLon = Mat4d::zrotation(gridStepMeridianRad);
Vec3d fpt = firstPoint;
Vec3d p1, p2;
int maxNbIter = (int)(M_PI/gridStepMeridianRad);
int i;
for (i=0; i<maxNbIter; ++i)
{
StelUtils::rectToSphe(&lon2, &lat2, fpt);
userData.raAngle = lon2;
meridianHalfSpace.n = fpt^Vec3d(0,0,1);
meridianHalfSpace.n.normalize();
if (!planeIntersect2(viewPortHalfSpace, meridianHalfSpace, p
1, p2))
{
if (viewPortHalfSpace.d<meridianHalfSpace.d && viewP
ortHalfSpace.contains(meridianHalfSpace.n))
{ {
double lon = *ii; // The meridian is fully included in the vie
StelUtils::spheToRect(lon, (double)iter->fir wport, draw it in 3 sub-arcs to avoid length > 180.
st/RADIAN_MAS, vv); Mat4d rotLon120 = Mat4d::rotation(meridianHa
++ii; lfSpace.n, 120.*M_PI/180.);
if (ii==iter->second.end()) Vec3d rotFpt=fpt;
size = *iter->second.begin() - lon; rotFpt.transfo4d(rotLon120);
else Vec3d rotFpt2=rotFpt;
size = *ii - lon; rotFpt2.transfo4d(rotLon120);
if (size<0) size+=2.*M_PI; sPainter.drawSmallCircleArc(fpt, rotFpt, Vec
prj->drawParallel(vv, size, true, &font, &te 3d(0,0,0), viewportEdgeIntersectCallback, &userData);
xtColor); sPainter.drawSmallCircleArc(rotFpt, rotFpt2,
++ii; Vec3d(0,0,0), viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(rotFpt2, fpt, Ve
c3d(0,0,0), viewportEdgeIntersectCallback, &userData);
fpt.transfo4d(rotLon);
continue;
} }
else
break;
} }
Vec3d middlePoint = p1+p2;
middlePoint.normalize();
if (!viewPortHalfSpace.contains(middlePoint))
middlePoint*=-1.;
// Draw the arc in 2 sub-arcs to avoid lengths > 180 deg
sPainter.drawSmallCircleArc(p1, middlePoint, Vec3d(0), viewp
ortEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(p2, middlePoint, Vec3d(0), viewp
ortEdgeIntersectCallback, &userData);
fpt.transfo4d(rotLon);
} }
// Draw the parallels which didn't intersect the viewport but are in if (i!=maxNbIter)
the screen
// This can only happen for parallels around the poles fully include
d in the viewport (At least I hope!)
if (northPoleInViewport && !resultsParallels.empty())
{ {
const double lastLat = (double)(--resultsParallels.end())->f rotLon = Mat4d::rotation(Vec3d(0,0,1), -gridStepMeridianRad)
irst/RADIAN_MAS; ;
for (double lat=lastLat+gridStepParallelRad;lat<M_PI/2-0.000 fpt = firstPoint;
01;lat+=gridStepParallelRad) fpt.transfo4d(rotLon);
for (int j=0; j<maxNbIter-i; ++j)
{ {
Vec3d vv(std::cos(lat), 0, std::sin(lat)); StelUtils::rectToSphe(&lon2, &lat2, fpt);
prj->drawParallel(vv, 2.*M_PI); userData.raAngle = lon2;
meridianHalfSpace.n = fpt^Vec3d(0,0,1);
meridianHalfSpace.n.normalize();
if (!planeIntersect2(viewPortHalfSpace, meridianHalf
Space, p1, p2))
break;
Vec3d middlePoint = p1+p2;
middlePoint.normalize();
if (!viewPortHalfSpace.contains(middlePoint))
middlePoint*=-1;
sPainter.drawSmallCircleArc(p1, middlePoint, Vec3d(0
), viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(p2, middlePoint, Vec3d(0
), viewportEdgeIntersectCallback, &userData);
fpt.transfo4d(rotLon);
} }
} }
if (southPoleInViewport && !resultsParallels.empty())
/////////////////////////////////////////////////
// Draw all the parallels (small circles)
StelGeom::HalfSpace parallelHalfSpace(Vec3d(0,0,1), 0);
rotLon = Mat4d::rotation(firstPoint^Vec3d(0,0,1), gridStepParallelRa
d);
fpt = firstPoint;
maxNbIter = (int)(M_PI/gridStepParallelRad)-1;
for (i=0; i<maxNbIter; ++i)
{ {
const double lastLat = (double)resultsParallels.begin()->fir StelUtils::rectToSphe(&lon2, &lat2, fpt);
st/RADIAN_MAS; userData.text = StelUtils::radToDmsStrAdapt(lat2);
for (double lat=lastLat-gridStepParallelRad;lat>-M_PI/2+0.00
001;lat-=gridStepParallelRad)
{
Vec3d vv(std::cos(lat), 0, std::sin(lat));
prj->drawParallel(vv, 2.*M_PI);
}
}
// Draw meridians parallelHalfSpace.d = fpt[2];
if (parallelHalfSpace.d>0.9999999)
break;
// Discriminate meridian categories, if latitude is > pi, the real l const Vec3d rotCenter(0,0,parallelHalfSpace.d);
ongitude180 is -longitude+pi if (!planeIntersect2(viewPortHalfSpace, parallelHalfSpace, p
std::map<int, std::set<double> > resultsMeridiansOrdered; 1, p2))
for (std::map<int, std::set<double> >::const_iterator iter=resultsMe
ridians.begin(); iter!=resultsMeridians.end(); ++iter)
{
for (std::set<double>::const_iterator k=iter->second.begin()
;k!=iter->second.end();++k)
{ {
assert(*k>=0. && *k<=2.*M_PI); if ((viewPortHalfSpace.d<parallelHalfSpace.d && view
assert((double)iter->first/RADIAN_MAS>=0. && (double PortHalfSpace.contains(parallelHalfSpace.n))
)iter->first/RADIAN_MAS<=M_PI); || (viewPortHalfSpace.d<-parallelHalfSpace.d
if (*k>M_PI) && viewPortHalfSpace.contains(-parallelHalfSpace.n)))
resultsMeridiansOrdered[(int)(10*std::floor( {
(M_PI*RADIAN_MAS-iter->first+5.0)/10.0))].insert(*k); // The parallel is fully included in the vie
wport, draw it in 3 sub-arcs to avoid lengths >= 180 deg
Mat4d rotLon120 = Mat4d::rotation(Vec3d(0,0,
1), 120.*M_PI/180.);
Vec3d rotFpt=fpt;
rotFpt.transfo4d(rotLon120);
Vec3d rotFpt2=rotFpt;
rotFpt2.transfo4d(rotLon120);
sPainter.drawSmallCircleArc(fpt, rotFpt, rot
Center, viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(rotFpt, rotFpt2,
rotCenter, viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(rotFpt2, fpt, ro
tCenter, viewportEdgeIntersectCallback, &userData);
fpt.transfo4d(rotLon);
continue;
}
else else
resultsMeridiansOrdered[(int)(10*std::floor( (iter->first+5.0)/10.0))].insert(*k); break;
} }
}
for (std::map<int, std::set<double> >::const_iterator iter=resultsMe // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg
ridiansOrdered.begin(); iter!=resultsMeridiansOrdered.end(); ++iter) Vec3d middlePoint = p1-rotCenter+p2-rotCenter;
{ middlePoint.normalize();
// qDebug() << "------- lon1802=" << iter->first << "--------"; middlePoint*=(p1-rotCenter).length();
// for (map<double, Vec2d>::const_iterator k = iter->second.beg middlePoint+=rotCenter;
in();k!=iter->second.end();++k) if (!viewPortHalfSpace.contains(middlePoint))
// {
// Vec3d v;
// prj->unProject(k->second[0], k->second[1], v);
// double llon, llat;
// rectToSpheType2(llon, llat, v);
// qDebug() << k->second << " lat=" << k->first*180./M_
PI << " Llon="<< llon*180./M_PI << " Llat=" << llat*180./M_PI << (isMeridia
nEnteringLat180(prj, (double)iter->first/RADIAN_MAS, k->first) ?" *":"");
// }
if (iter->second.size()%2!=0)
{ {
//qDebug() << "Error meridian " << (double)iter->fir middlePoint-=rotCenter;
st/DEGREE_MAS << " " << iter->second.size(); middlePoint*=-1.;
middlePoint+=rotCenter;
} }
else
sPainter.drawSmallCircleArc(p1, middlePoint, rotCenter, view
portEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(p2, middlePoint, rotCenter, view
portEdgeIntersectCallback, &userData);
fpt.transfo4d(rotLon);
}
if (i!=maxNbIter)
{
rotLon = Mat4d::rotation(firstPoint^Vec3d(0,0,1), -gridStepP
arallelRad);
fpt = firstPoint;
fpt.transfo4d(rotLon);
for (int j=0; j<maxNbIter-i; ++j)
{ {
// The content of the set iter->second is supposed t StelUtils::rectToSphe(&lon2, &lat2, fpt);
o be the sorted list of the latitudeType2 userData.text = StelUtils::radToDmsStrAdapt(lat2);
// at which the meridian of longitude iter->first cr
osses the viewport
std::set<double>::const_iterator k = iter->second.be
gin();
if (!isMeridianEnteringLat180(prj, (double)iter->fir
st/RADIAN_MAS, *k))
{
++k;
}
Vec3d vv; parallelHalfSpace.d = fpt[2];
double size; const Vec3d rotCenter(0,0,parallelHalfSpace.d);
for (unsigned int i=0;i<iter->second.size()/2;++i) if (!planeIntersect2(viewPortHalfSpace, parallelHalf
Space, p1, p2))
{ {
double lat180 = *k; if ((viewPortHalfSpace.d<parallelHalfSpace.d
spheToRectLat1802((double)iter->first/RADIAN && viewPortHalfSpace.contains(parallelHalfSpace.n))
_MAS, lat180, vv); || (viewPortHalfSpace.d<-parallelHa
++k; lfSpace.d && viewPortHalfSpace.contains(-parallelHalfSpace.n)))
if (k==iter->second.end()) {
size = *iter->second.begin() - lat18 // The parallel is fully included in
0; the viewport, draw it in 3 sub-arcs to avoid lengths >= 180 deg
Mat4d rotLon120 = Mat4d::rotation(Ve
c3d(0,0,1), 120.*M_PI/180.);
Vec3d rotFpt=fpt;
rotFpt.transfo4d(rotLon120);
Vec3d rotFpt2=rotFpt;
rotFpt2.transfo4d(rotLon120);
sPainter.drawSmallCircleArc(fpt, rot
Fpt, rotCenter, viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(rotFpt,
rotFpt2, rotCenter, viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(rotFpt2,
fpt, rotCenter, viewportEdgeIntersectCallback, &userData);
fpt.transfo4d(rotLon);
continue;
}
else else
size = *k - lat180; break;
if (size<0.) size+=2.*M_PI;
prj->drawMeridian(vv, size, true, &font, &te
xtColor, -1, frameType==Projector::FrameLocal);
++k;
} }
}
// // Debug, draw a cross for all the points // Draw the arc in 2 sub-arcs to avoid lengths > 180
// for (set<double>::const_iterator k=iter->second.begin();k!=i deg
ter->second.end();++k) Vec3d middlePoint = p1-rotCenter+p2-rotCenter;
// { middlePoint.normalize();
// //const double lon180 = k->first>M_PI? (double)iter- middlePoint*=(p1-rotCenter).length();
>first/RADIAN_MAS-M_PI : (double)iter->first/RADIAN_MAS; middlePoint+=rotCenter;
// if (isMeridianEnteringLat180(prj, (double)iter->firs if (!viewPortHalfSpace.contains(middlePoint))
t/RADIAN_MAS, *k))
// {
// glColor3f(1,1,0);
// }
// else
// {
// glColor3f(0,0,1);
// }
// Vec3d vv, win;
// spheToRectLat1802((double)iter->first/RADIAN_MAS, *k
, vv);
// prj->project(vv, win);
// glBegin(GL_LINES);
// glVertex2f(win[0]-30,win[1]);
// glVertex2f(win[0]+30,win[1]);
// glVertex2f(win[0],win[1]-30);
// glVertex2f(win[0],win[1]+30);
// glEnd();
// }
}
// Draw meridian zero which can't be found by the normal algo..
const Vec3d vv(1,0,0);
prj->drawMeridian(vv, 2.*M_PI, false, &font, NULL, -1, frameType==Pr
ojector::FrameLocal);
// Draw the meridians which are totally included in the viewport (an
d thus don't intersect with the edge of the screen)
if (northPoleInViewport && southPoleInViewport)
{
int nbMeridian = (int)(2.*M_PI/gridStepMeridianRad);
int dLatMas = 360*60*60*1000/nbMeridian;
// qDebug() << resultsMeridiansOrdered.size()+1 << "/" << nb
Meridian/2 << " dLatMas=" << dLatMas/1000/60/60;
for (int latMas=0;latMas<360*60*60*1000/2;latMas+=dLatMas)
{
if (resultsMeridiansOrdered.find(latMas)==resultsMer
idiansOrdered.end() && latMas!=0)
{ {
Vec3d vvv; middlePoint-=rotCenter;
spheToRectLat1802((double)latMas/RADIAN_MAS, middlePoint*=-1.;
0, vvv); middlePoint+=rotCenter;
prj->drawMeridian(vvv, 2.*M_PI, false, &font
, &textColor, -1, frameType==Projector::FrameLocal);
} }
sPainter.drawSmallCircleArc(p1, middlePoint, rotCent
er, viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(p2, middlePoint, rotCent
er, viewportEdgeIntersectCallback, &userData);
fpt.transfo4d(rotLon);
} }
} }
} }
SkyLine::SkyLine(SKY_LINE_TYPE _line_type) : color(0.f, 0.f, 1.f), fontSize (1.), SkyLine::SkyLine(SKY_LINE_TYPE _line_type) : color(0.f, 0.f, 1.f), fontSize (14.),
font(StelApp::getInstance().getFontManager().getStandardFont(StelApp::getIn stance().getLocaleMgr().getAppLanguage(), fontSize)) font(StelApp::getInstance().getFontManager().getStandardFont(StelApp::getIn stance().getLocaleMgr().getAppLanguage(), fontSize))
{ {
line_type = _line_type; line_type = _line_type;
switch (line_type) switch (line_type)
{ {
case LOCAL : frameType = Projector::FrameLocal; break; case MERIDIAN:
case MERIDIAN : frameType = Projector::FrameLocal; break; frameType = StelCore::FrameAltAz;
case ECLIPTIC : frameType = Projector::FrameHelio; break; label = q_("Meridian");
case EQUATOR : frameType = Projector::FrameEarthEqu; break; break;
default : frameType = Projector::FrameEarthEqu; case ECLIPTIC:
frameType = StelCore::FrameObservercentricEcliptic;
label = q_("Ecliptic");
break;
case EQUATOR:
frameType = StelCore::FrameEquinoxEqu;
label = q_("Equator");
break;
} }
} }
SkyLine::~SkyLine() SkyLine::~SkyLine()
{ {
} }
void SkyLine::setFontSize(double newFontSize) void SkyLine::setFontSize(double newFontSize)
{ {
fontSize = newFontSize; fontSize = newFontSize;
font = StelApp::getInstance().getFontManager().getStandardFont(StelA pp::getInstance().getLocaleMgr().getAppLanguage(), fontSize); font = StelApp::getInstance().getFontManager().getStandardFont(StelA pp::getInstance().getLocaleMgr().getAppLanguage(), fontSize);
} }
void SkyLine::draw(Projector *prj,const Navigator *nav) const void SkyLine::draw(StelCore *core) const
{ {
if (!fader.getInterstate()) return; if (!fader.getInterstate())
return;
StelProjectorP prj = core->getProjection(frameType);
// Get the bounding halfspace
const StelGeom::HalfSpace viewPortHalfSpace = prj->getBoundingHalfSp
ace();
// Initialize a painter and set openGL state
StelPainter sPainter(prj);
glColor4f(color[0], color[1], color[2], fader.getInterstate()); glColor4f(color[0], color[1], color[2], fader.getInterstate());
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
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
glEnable(GL_LINE_SMOOTH);
prj->setCurrentFrame(frameType); Vec4f textColor(color[0], color[1], color[2], 0);
textColor*=2;
textColor[3]=fader.getInterstate();
// Johannes: use a big radius as a dirty workaround for the bug that ViewportEdgeIntersectCallbackData userData(sPainter);
the userData.font = &font;
// ecliptic line is not drawn around the observer, but around the su userData.textColor = textColor;
n: userData.text = label;
const Vec3d vv(1000000,0,0);
/////////////////////////////////////////////////
// Draw the line
StelGeom::HalfSpace meridianHalfSpace(Vec3d(0,0,1), 0);
Vec3d fpt(1,0,0);
if (line_type==MERIDIAN) if (line_type==MERIDIAN)
prj->drawMeridian(vv, 2.*M_PI, false, &font); {
else meridianHalfSpace.n.set(0,1,0);
prj->drawParallel(vv, 2.*M_PI, false, &font); }
Vec3d p1, p2;
if (!planeIntersect2(viewPortHalfSpace, meridianHalfSpace, p1, p2))
{
if ((viewPortHalfSpace.d<meridianHalfSpace.d && viewPortHalf
Space.contains(meridianHalfSpace.n))
|| (viewPortHalfSpace.d<-meridianHalfSpace.d && viewPort
HalfSpace.contains(-meridianHalfSpace.n)))
{
// The meridian is fully included in the viewport, d
raw it in 3 sub-arcs to avoid length > 180.
Mat4d rotLon120 = Mat4d::rotation(meridianHalfSpace.
n, 120.*M_PI/180.);
Vec3d rotFpt=fpt;
rotFpt.transfo4d(rotLon120);
Vec3d rotFpt2=rotFpt;
rotFpt2.transfo4d(rotLon120);
sPainter.drawSmallCircleArc(fpt, rotFpt, Vec3d(0,0,0
), viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(rotFpt, rotFpt2, Vec3d(0
,0,0), viewportEdgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(rotFpt2, fpt, Vec3d(0,0,
0), viewportEdgeIntersectCallback, &userData);
return;
}
else
return;
}
Vec3d middlePoint = p1+p2;
middlePoint.normalize();
if (!viewPortHalfSpace.contains(middlePoint))
middlePoint*=-1.;
// Draw the arc in 2 sub-arcs to avoid lengths > 180 deg
sPainter.drawSmallCircleArc(p1, middlePoint, Vec3d(0,0,0), viewportE
dgeIntersectCallback, &userData);
sPainter.drawSmallCircleArc(p2, middlePoint, Vec3d(0,0,0), viewportE
dgeIntersectCallback, &userData);
// // 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:
// const Vec3d vv(1000000,0,0);
} }
GridLinesMgr::GridLinesMgr() GridLinesMgr::GridLinesMgr()
{ {
setObjectName("GridLinesMgr"); setObjectName("GridLinesMgr");
equGrid = new SkyGrid(Projector::FrameEarthEqu); equGrid = new SkyGrid(StelCore::FrameEquinoxEqu);
equJ2000Grid = new SkyGrid(Projector::FrameJ2000); equJ2000Grid = new SkyGrid(StelCore::FrameJ2000);
aziGrid = new SkyGrid(Projector::FrameLocal); 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);
} }
GridLinesMgr::~GridLinesMgr() GridLinesMgr::~GridLinesMgr()
{ {
delete equGrid; delete equGrid;
delete equJ2000Grid; delete equJ2000Grid;
delete aziGrid; delete aziGrid;
skipping to change at line 644 skipping to change at line 624
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;
} }
void GridLinesMgr::init() void GridLinesMgr::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
assert(conf); Q_ASSERT(conf);
setFlagAzimutalGrid(conf->value("viewing/flag_azimutal_grid").toBool ()); 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());
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 ());
} }
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);
aziGrid->update(deltaTime); aziGrid->update(deltaTime);
equatorLine->update(deltaTime); equatorLine->update(deltaTime);
eclipticLine->update(deltaTime); eclipticLine->update(deltaTime);
meridianLine->update(deltaTime); meridianLine->update(deltaTime);
} }
void GridLinesMgr::draw(StelCore* core) void GridLinesMgr::draw(StelCore* core)
{ {
Navigator* nav = core->getNavigation();
Projector* prj = core->getProjection();
glEnable(GL_LINE_SMOOTH);
// Draw the equatorial grid // Draw the equatorial grid
equGrid->draw(prj); equGrid->draw(core);
// Draw the equatorial grid // Draw the equatorial grid
equJ2000Grid->draw(prj); equJ2000Grid->draw(core);
// Draw the altazimutal grid // Draw the altazimuthal grid
aziGrid->draw(prj); aziGrid->draw(core);
// Draw the celestial equator line // Draw the celestial equator line
equatorLine->draw(prj,nav); equatorLine->draw(core);
// Draw the ecliptic line // Draw the ecliptic line
eclipticLine->draw(prj,nav); eclipticLine->draw(core);
// Draw the meridian line // Draw the meridian line
meridianLine->draw(prj,nav); meridianLine->draw(core);
glDisable(GL_LINE_SMOOTH);
} }
void GridLinesMgr::setStelStyle(const StelStyle& style) void GridLinesMgr::setStelStyle(const StelStyle& style)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
QString section = style.confSectionName; QString section = style.confSectionName;
// 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()));
setColorAzimutalGrid(StelUtils::strToVec3f(conf->value(section+"/azi muthal_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()));
} }
//! Set flag for displaying Azimutal Grid //! Set flag for displaying Azimuthal Grid
void GridLinesMgr::setFlagAzimutalGrid(bool b) {aziGrid->setFlagshow(b);} void GridLinesMgr::setFlagAzimuthalGrid(bool b) {aziGrid->setFlagshow(b);}
//! Get flag for displaying Azimutal Grid //! Get flag for displaying Azimuthal Grid
bool GridLinesMgr::getFlagAzimutalGrid(void) const {return aziGrid->getFlag bool GridLinesMgr::getFlagAzimuthalGrid(void) const {return aziGrid->getFla
show();} gshow();}
Vec3f GridLinesMgr::getColorAzimutalGrid(void) const {return aziGrid->getCo Vec3f GridLinesMgr::getColorAzimuthalGrid(void) const {return aziGrid->getC
lor();} 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);}
//! Get flag for displaying Equatorial Grid //! Get flag for displaying Equatorial Grid
bool GridLinesMgr::getFlagEquatorGrid(void) const {return equGrid->getFlags how();} bool GridLinesMgr::getFlagEquatorGrid(void) const {return equGrid->getFlags how();}
Vec3f GridLinesMgr::getColorEquatorGrid(void) const {return equGrid->getCol or();} Vec3f GridLinesMgr::getColorEquatorGrid(void) const {return equGrid->getCol or();}
//! Set flag for displaying Equatorial J2000 Grid //! Set flag for displaying Equatorial J2000 Grid
void GridLinesMgr::setFlagEquatorJ2000Grid(bool b) {equJ2000Grid->setFlagsh ow(b);} void GridLinesMgr::setFlagEquatorJ2000Grid(bool b) {equJ2000Grid->setFlagsh ow(b);}
//! Get flag for displaying Equatorial J2000 Grid //! Get flag for displaying Equatorial J2000 Grid
skipping to change at line 739 skipping to change at line 712
//! 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();}
void GridLinesMgr::setColorAzimutalGrid(const Vec3f& v) { aziGrid->setColor (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::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);}
 End of changes. 86 change blocks. 
512 lines changed or deleted 468 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/