StelSkyPolygon.cpp   StelSkyPolygon.cpp 
skipping to change at line 28 skipping to change at line 28
#include "StelSkyPolygon.hpp" #include "StelSkyPolygon.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include <stdexcept> #include <stdexcept>
#include <QDebug> #include <QDebug>
#include <QtOpenGL>
void StelSkyPolygon::initCtor() void StelSkyPolygon::initCtor()
{ {
minResolution = -1; minResolution = -1;
texFader = NULL; texFader = NULL;
} }
// Constructor // Constructor
StelSkyPolygon::StelSkyPolygon(const QString& url, StelSkyPolygon* parent) : MultiLevelJsonBase(parent) StelSkyPolygon::StelSkyPolygon(const QString& url, StelSkyPolygon* parent) : MultiLevelJsonBase(parent)
{ {
skipping to change at line 54 skipping to change at line 55
{ {
initCtor(); initCtor();
initFromQVariantMap(map); initFromQVariantMap(map);
} }
// Destructor // Destructor
StelSkyPolygon::~StelSkyPolygon() StelSkyPolygon::~StelSkyPolygon()
{ {
} }
void StelSkyPolygon::draw(StelCore* core) void StelSkyPolygon::draw(StelCore* core, StelPainter& sPainter, float opac ity)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
QMultiMap<double, StelSkyPolygon*> result; QMultiMap<double, StelSkyPolygon*> result;
getTilesToDraw(result, core, prj->getViewportConvexPolygon(0, 0), tr ue); getTilesToDraw(result, core, prj->getViewportConvexPolygon(0, 0), tr ue);
// Draw in the good order // Draw in the good order
glDisable(GL_TEXTURE_2D); sPainter.enableTexture2d(false);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
QMap<double, StelSkyPolygon*>::Iterator i = result.end(); QMap<double, StelSkyPolygon*>::Iterator i = result.end();
while (i!=result.begin()) while (i!=result.begin())
{ {
--i; --i;
i.value()->drawTile(core); i.value()->drawTile(core);
} }
deleteUnusedSubTiles(); deleteUnusedSubTiles();
} }
// Return the list of tiles which should be drawn. // Return the list of tiles which should be drawn.
void StelSkyPolygon::getTilesToDraw(QMultiMap<double, StelSkyPolygon*>& res ult, StelCore* core, const StelGeom::ConvexPolygon& viewPortPoly, bool rech eckIntersect) void StelSkyPolygon::getTilesToDraw(QMultiMap<double, StelSkyPolygon*>& res ult, StelCore* core, const SphericalRegionP& viewPortPoly, bool recheckInte rsect)
{ {
// An error occured during loading // An error occured during loading
if (errorOccured) if (errorOccured)
return; return;
// The JSON file is currently being downloaded // The JSON file is currently being downloaded
if (downloading) if (downloading)
return; return;
// Check that we are in the screen // Check that we are in the screen
skipping to change at line 98 skipping to change at line 99
if (recheckIntersect) if (recheckIntersect)
{ {
if (skyConvexPolygons.isEmpty()) if (skyConvexPolygons.isEmpty())
{ {
// If no polygon is defined, we assume that the tile covers the whole sky // If no polygon is defined, we assume that the tile covers the whole sky
fullInScreen=false; fullInScreen=false;
intersectScreen=true; intersectScreen=true;
} }
else else
{ {
foreach (const StelGeom::ConvexPolygon poly, skyConv exPolygons) foreach (const SphericalConvexPolygon poly, skyConve xPolygons)
{ {
if (contains(viewPortPoly, poly)) if (viewPortPoly->contains(poly))
{ {
intersectScreen = true; intersectScreen = true;
} }
else else
{ {
fullInScreen = false; fullInScreen = false;
if (intersect(viewPortPoly, poly)) if (viewPortPoly->intersects(poly))
intersectScreen = true; intersectScreen = true;
} }
} }
} }
} }
// The tile is outside screen // The tile is outside screen
if (fullInScreen==false && intersectScreen==false) if (fullInScreen==false && intersectScreen==false)
{ {
// Schedule a deletion // Schedule a deletion
scheduleChildsDeletion(); scheduleChildsDeletion();
skipping to change at line 171 skipping to change at line 172
bool StelSkyPolygon::drawTile(StelCore* core) bool StelSkyPolygon::drawTile(StelCore* core)
{ {
if (!texFader) if (!texFader)
{ {
texFader = new QTimeLine(1000, this); texFader = new QTimeLine(1000, this);
texFader->start(); texFader->start();
} }
StelPainter sPainter(core->getProjection(StelCore::FrameJ2000)); StelPainter sPainter(core->getProjection(StelCore::FrameJ2000));
foreach (const StelGeom::ConvexPolygon& poly, skyConvexPolygons) foreach (const SphericalConvexPolygon& poly, skyConvexPolygons)
sPainter.drawPolygon(poly); sPainter.drawSphericalRegion(&poly);
return true; return true;
} }
// Load the tile from a valid QVariantMap // Load the tile from a valid QVariantMap
void StelSkyPolygon::loadFromQVariantMap(const QVariantMap& map) void StelSkyPolygon::loadFromQVariantMap(const QVariantMap& map)
{ {
if (map.contains("imageCredits")) if (map.contains("imageCredits"))
{ {
QVariantMap dsCredits = map.value("imageCredits").toMap(); QVariantMap dsCredits = map.value("imageCredits").toMap();
skipping to change at line 199 skipping to change at line 200
QVariantMap sCredits = map.value("serverCredits").toMap(); QVariantMap sCredits = map.value("serverCredits").toMap();
serverCredits.shortCredits = sCredits.value("short").toStrin g(); serverCredits.shortCredits = sCredits.value("short").toStrin g();
serverCredits.fullCredits = sCredits.value("full").toString( ); serverCredits.fullCredits = sCredits.value("full").toString( );
serverCredits.infoURL = sCredits.value("infoUrl").toString() ; serverCredits.infoURL = sCredits.value("infoUrl").toString() ;
} }
shortName = map.value("shortName").toString(); shortName = map.value("shortName").toString();
bool ok=false; bool ok=false;
minResolution = map.value("minResolution").toDouble(&ok); minResolution = map.value("minResolution").toDouble(&ok);
if (!ok) if (!ok)
throw std::runtime_error("minResolution expect a double valu e"); throw std::runtime_error(qPrintable(QString("minResolution e xpect a double value, found: %1").arg(map.value("minResolution").toString() )));
// Load the convex polygons (if any) // Load the convex polygons (if any)
QVariantList polyList = map.value("worldCoords").toList(); QVariantList polyList = map.value("worldCoords").toList();
foreach (const QVariant& polyRaDec, polyList) foreach (const QVariant& polyRaDec, polyList)
{ {
QList<Vec3d> vertices; QList<Vec3d> vertices;
foreach (QVariant vRaDec, polyRaDec.toList()) foreach (QVariant vRaDec, polyRaDec.toList())
{ {
const QVariantList vl = vRaDec.toList(); const QVariantList vl = vRaDec.toList();
Vec3d v; Vec3d v;
StelUtils::spheToRect(vl.at(0).toDouble(&ok)*M_PI/18 0., vl.at(1).toDouble(&ok)*M_PI/180., v); StelUtils::spheToRect(vl.at(0).toDouble(&ok)*M_PI/18 0., vl.at(1).toDouble(&ok)*M_PI/180., v);
if (!ok) if (!ok)
throw std::runtime_error("wrong Ra and Dec, expect a double value"); throw std::runtime_error("wrong Ra and Dec, expect a double value");
vertices.append(v); vertices.append(v);
} }
Q_ASSERT(vertices.size()==4); Q_ASSERT(vertices.size()==4);
skyConvexPolygons.append(StelGeom::ConvexPolygon(vertices[0] , vertices[1], vertices[2], vertices[3])); skyConvexPolygons.append(SphericalConvexPolygon(vertices[0], vertices[1], vertices[2], vertices[3]));
} }
// This is a list of URLs to the child tiles or a list of already lo aded map containing child information // This is a list of URLs to the child tiles or a list of already lo aded map containing child information
// (in this later case, the StelSkyPolygon objects will be created l ater) // (in this later case, the StelSkyPolygon objects will be created l ater)
subTilesUrls = map.value("subTiles").toList(); subTilesUrls = map.value("subTiles").toList();
} }
// Convert the image informations to a map following the JSON structure. // Convert the image informations to a map following the JSON structure.
QVariantMap StelSkyPolygon::toQVariantMap() const QVariantMap StelSkyPolygon::toQVariantMap() const
{ {
 End of changes. 10 change blocks. 
10 lines changed or deleted 11 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/