SkyImageTile.hpp   StelSkyImageTile.hpp 
skipping to change at line 19 skipping to change at line 19
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* 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.
*/ */
#ifndef _SKYIMAGETILE_HPP_ #ifndef _STELSKYIMAGETILE_HPP_
#define _SKYIMAGETILE_HPP_ #define _STELSKYIMAGETILE_HPP_
#include "StelTextureTypes.hpp"
#include "StelSphereGeometry.hpp"
#include "MultiLevelJsonBase.hpp"
#include "STextureTypes.hpp"
#include "SphereGeometry.hpp"
#include <QTimeLine> #include <QTimeLine>
#include <QList>
#include <QString>
#include <QStringList>
#include <QVariantMap>
//#define DEBUG_SKYIMAGE_TILE //#define DEBUG_STELSKYIMAGE_TILE
class QIODevice; class QIODevice;
class StelCore; class StelCore;
class StelPainter;
//! Contain all the credits for a given server hosting the data //! Contain all the credits for a given server hosting the data
class ServerCredits class ServerCredits
{ {
public: public:
//! Very short credit to display in the loading bar //! Very short credit to display in the loading bar
QString shortCredits; QString shortCredits;
//! Full credits //! Full credits
QString fullCredits; QString fullCredits;
skipping to change at line 64 skipping to change at line 63
QString shortCredits; QString shortCredits;
//! Full credits //! Full credits
QString fullCredits; QString fullCredits;
//! The URL where to get more info about the data collection //! The URL where to get more info about the data collection
QString infoURL; QString infoURL;
}; };
//! Base class for any astro image with a fixed position //! Base class for any astro image with a fixed position
class SkyImageTile : public QObject class StelSkyImageTile : public MultiLevelJsonBase
{ {
Q_OBJECT; Q_OBJECT
friend class JsonLoadThread; friend class StelSkyImageMgr;
public: public:
//! Default constructor //! Default constructor
SkyImageTile() {initCtor();} StelSkyImageTile() {initCtor();}
//! Constructor //! Constructor
SkyImageTile(const QString& url, SkyImageTile* parent=NULL); StelSkyImageTile(const QString& url, StelSkyImageTile* parent=NULL);
//! Constructor //! Constructor
SkyImageTile(const QVariantMap& map, SkyImageTile* parent); StelSkyImageTile(const QVariantMap& map, StelSkyImageTile* parent);
//! Destructor //! Destructor
~SkyImageTile(); ~StelSkyImageTile();
//! Draw the image on the screen. //! Draw the image on the screen.
void draw(StelCore* core); void draw(StelCore* core, const StelPainter& sPainter);
//! Return the dataset credits to use in the progress bar //! Return the dataset credits to use in the progress bar
DataSetCredits getDataSetCredits() const {return dataSetCredits;} DataSetCredits getDataSetCredits() const {return dataSetCredits;}
//! Return the server credits to use in the progress bar //! Return the server credits to use in the progress bar
ServerCredits getServerCredits() const {return serverCredits;} ServerCredits getServerCredits() const {return serverCredits;}
//! Return the short name for this image to be used in the loading b
ar
QString getShortName() const {return shortName;}
//! Return the absolute path/URL to the image file
QString getAbsoluteImageURI() const {return absoluteImageURI;}
//! Return true if the tile is fully loaded and can be displayed //! Return true if the tile is fully loaded and can be displayed
bool isReadyToDisplay() const; bool isReadyToDisplay() const;
//! Return true if an error occured while loading the data //! Convert the image informations to a map following the JSON struc
bool hasErrorOccured() const {return errorOccured;} ture.
//! It can be saved as JSON using the StelJsonParser methods.
//! Delete the texture from memory. It will be reloaded automaticall QVariantMap toQVariantMap() const;
y if needed
void deleteTexture() {tex.reset();}
signals: //! Return the absolute path/URL to the image file
//! Emitted when loading of data started or stopped QString getAbsoluteImageURI() const {return absoluteImageURI;}
//! @param b true if data loading started, false if finished
void loadingStateChanged(bool b);
//! Emitted when the percentage of loading tiles/tiles to be display
ed changed
//! @param percentage the percentage of loaded data
void percentLoadedChanged(int percentage);
private slots:
//! Called when the download for the JSON file terminated
void downloadFinished();
//! Called when the JSON file is loaded
void JsonLoadFinished();
protected: protected:
//! Minimum resolution of the data of the texture in degree/pixel
float minResolution;
//! The credits of the server where this data come from //! The credits of the server where this data come from
ServerCredits serverCredits; ServerCredits serverCredits;
//! The credits for the data set //! The credits for the data set
DataSetCredits dataSetCredits; DataSetCredits dataSetCredits;
//! The very short name for this image set to be used in loading bar
QString shortName;
//! URL where the image is located //! URL where the image is located
QString absoluteImageURI; QString absoluteImageURI;
//! Base URL to prefix to relative URL
QString baseUrl;
//! Minimum resolution of the data of the texture in degree/pixel
float minResolution;
//! The image luminance in cd/m^2 //! The image luminance in cd/m^2
float luminance; float luminance;
//! Whether the texture must be blended //! Whether the texture must be blended
bool alphaBlend; bool alphaBlend;
//! True if the tile is just a list of other tiles without texture f or itself //! True if the tile is just a list of other tiles without texture f or itself
bool noTexture; bool noTexture;
//! Direction of the vertices of each polygons in ICRS frame //! Direction of the vertices of each polygons in ICRS frame
QList<StelGeom::ConvexPolygon> skyConvexPolygons; QList<StelGeom::ConvexPolygon> skyConvexPolygons;
//! Positions of the vertex of each convex polygons in texture space //! Positions of the vertex of each convex polygons in texture space
QList< QList<Vec2f> > textureCoords; QList< QList<Vec2f> > textureCoords;
//! The list of all the subTiles URL for this tile //! The texture of the tile
QStringList subTilesUrls; StelTextureSP tex;
//! The list of all the created subtiles for this tile
QList<SkyImageTile*> subTiles;
//! Set to true if an error occured with this tile and it should not
be displayed
bool errorOccured;
protected: protected:
//! Load the tile information from a JSON file
static QVariantMap loadFromJSON(QIODevice& input, bool compressed=fa
lse);
//! Load the tile from a valid QVariantMap //! Load the tile from a valid QVariantMap
void loadFromQVariantMap(const QVariantMap& map); virtual void loadFromQVariantMap(const QVariantMap& map);
private: private:
//! init the SkyImageTile //! init the StelSkyImageTile
void initCtor(); void initCtor();
//! Return the list of tiles which should be drawn. //! Return the list of tiles which should be drawn.
//! @param result a map containing resolution, pointer to the tiles //! @param result a map containing resolution, pointer to the tiles
void getTilesToDraw(QMultiMap<double, SkyImageTile*>& result, StelCo re* core, const StelGeom::ConvexPolygon& viewPortPoly, float limitLuminance , bool recheckIntersect=true); void getTilesToDraw(QMultiMap<double, StelSkyImageTile*>& result, St elCore* core, const StelGeom::ConvexPolygon& viewPortPoly, float limitLumin ance, bool recheckIntersect=true);
//! Draw the image on the screen. //! Draw the image on the screen.
//! @return true if the tile was actually displayed //! @return true if the tile was actually displayed
bool drawTile(StelCore* core); bool drawTile(StelCore* core, const StelPainter& sPainter);
//! Delete all the subtiles which were not displayed since more than
lastDrawTrigger seconds
void deleteUnusedTiles(double lastDrawTrigger=2.);
//! Return the last time the tile content was actually drawn
double getLastTimeDraw() const {return lastTimeDraw;}
//! Return the base URL prefixed to relative URL
QString getBaseUrl() const {return baseUrl;}
//! Return the minimum resolution //! Return the minimum resolution
double getMinResolution() const {return minResolution;} double getMinResolution() const {return minResolution;}
// The texture of the tile
STextureSP tex;
// Used to download remote JSON files if needed
class QNetworkReply* httpReply;
// true if the JSON descriptor file is currently downloading
bool downloading;
class JsonLoadThread* loadThread;
// Store the time of the last draw
double lastTimeDraw;
// Used for smooth fade in // Used for smooth fade in
QTimeLine* texFader; QTimeLine* texFader;
// The temporary map filled in a thread #ifdef DEBUG_STELSKYIMAGE_TILE
QVariantMap temporaryResultMap; static class StelFont* debugFont;
void updatePercent(int tot, int numToBeLoaded);
bool loadingState;
int lastPercent;
#ifdef DEBUG_SKYIMAGE_TILE
static class SFont* debugFont;
#endif #endif
}; };
#endif // _SKYIMAGETILE_HPP_ #endif // _STELSKYIMAGETILE_HPP_
 End of changes. 28 change blocks. 
104 lines changed or deleted 33 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/