ScreenImageMgr.hpp   ScreenImageMgr.hpp 
/* /*
* Stellarium * Stellarium
* This file Copyright (C) 2008 Matthew Gates * This file Copyright (C) 2008 Matthew Gates
* Parts copyright (C) 2016 Georg Zotti (added size transitions)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* 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.
skipping to change at line 50 skipping to change at line 51
Q_OBJECT Q_OBJECT
public: public:
//! Load an image //! Load an image
//! @param filename the partial path of the file to load. This will be searched for in the //! @param filename the partial path of the file to load. This will be searched for in the
//! scripts directory using StelFileMgr. //! scripts directory using StelFileMgr.
//! @param x the screen x-position for the texture (in pixels), meas ured from the left side of the screen. //! @param x the screen x-position for the texture (in pixels), meas ured from the left side of the screen.
//! @param y the screen x-position for the texture (in pixels), meas ured from the bottom of the screen. //! @param y the screen x-position for the texture (in pixels), meas ured from the bottom of the screen.
//! @param show the initial displayed status of the image (false == hidden). //! @param show the initial displayed status of the image (false == hidden).
//! @param scale scale factor for the image. 1 = original size, 0.5 = 50% size etc. //! @param scale scale factor for the image. 1 = original size, 0.5 = 50% size etc.
//! Note that this also controls the final resolution of the
image! Scale smaller that 1 leads to reduced resolution,
//! larger than 1 of course creates upsampling artifacts. The
scaling that happens after loading is a simple stretch of this loaded pixm
ap.
//! In order to get a small image on screen which you might w
ant to grow later, load with this scale=1 and setScale() later.
//! @param fadeDuration the time it takes for screen images to fade in/out/change alpha in seconds. //! @param fadeDuration the time it takes for screen images to fade in/out/change alpha in seconds.
ScreenImage(const QString& filename, float x, float y, bool show=fal se, float scale=1., float alpha=1., float fadeDuration=1.); ScreenImage(const QString& filename, float x, float y, bool show=fal se, float scale=1., float alpha=1., float fadeDuration=1.);
virtual ~ScreenImage(); virtual ~ScreenImage();
//! Draw the image. //! Draw the image.
//! @param core the StelCore object //! @param core the StelCore object
virtual bool draw(const StelCore* core); virtual bool draw(const StelCore* core);
//! update fade for on/off action //! Empty dummy. The various animations are updated by other means.
virtual void update(double deltaTime); virtual void update(double deltaTime);
//! Set the duration used for the fade in / fade out of the image //! Set the duration used for the fade in / fade out of the image
virtual void setFadeDuration(float duration); virtual void setFadeDuration(float duration);
//! Show or hide the image (it will fade in/out) //! Show or hide the image (it will fade in/out)
//! @param b if true, the image will be shown, else it will be hidde n //! @param b if true, the image will be shown, else it will be hidde n
virtual void setFlagShow(bool b); virtual void setFlagShow(bool b);
//! Get the displayed status of the image //! Get the displayed status of the image
virtual bool getFlagShow(void); virtual bool getFlagShow(void);
//! Set the image alpha for when it is in full "on" (after fade in). //! Set the image alpha for when it is in full "on" (after fade in).
//! @param a the new alpha (transparency) for the image. 1.0 = tota lly transparent, 0.0 = fully opaque. //! @param a the new alpha (transparency) for the image. 1.0 = tota lly transparent, 0.0 = fully opaque.
//! @param duration the time for the change in alpha to take effect. //! @param duration the time for the change in alpha to take effect.
virtual void setAlpha(float a); virtual void setAlpha(float a);
//! Set the x, y position of the image. //! Set the x, y position of the image.
//! @param x new x position //! @param x new x position
//! @param y new y position //! @param y new y position
//! @param duration how long for the movement to take in seconds //! @param duration how long for the movement to take in seconds
virtual void setXY(float x, float y, float duration=0.); virtual void setXY(float x, float y, float duration=0.);
//! Set the x, y position of the image relative to the current posit ion //! Set the x, y position of the image relative to the current posit ion
//! @param x the offset in the x-axis //! @param x the offset in the x-axis
//! @param y the offset in the y-axis //! @param y the offset in the y-axis
//! @param duration how long for the movement to take in seconds //! @param duration how long for the movement to take in seconds
virtual void addXY(float x, float y, float duration=0.); virtual void addXY(float x, float y, float duration=0.);
virtual int imageHeight(void); virtual int imageHeight(void);
virtual int imageWidth(void); virtual int imageWidth(void);
//! Set the image scale relative to the size originally loaded.
//! @param scaleX new (target) horizontal scale factor. Native size=
1.
//! @param scaleY new (target) vertical scale factor. Native size=1.
//! @param duration how long for the resize to take in seconds
virtual void setScale(float scaleX, float scaleY, float duration=0.)
;
virtual float imageScaleX(void);
virtual float imageScaleY(void);
protected: protected:
QGraphicsPixmapItem* tex; QGraphicsPixmapItem* tex;
QTimeLine* moveTimer; QTimeLine* moveTimer; // for position changes
QTimeLine* fadeTimer; QTimeLine* fadeTimer; // for transparency
QTimeLine* scaleTimer; // for grow/shrink
QGraphicsItemAnimation* anim; QGraphicsItemAnimation* anim;
QGraphicsItemAnimation* scaleAnim;
private slots: private slots:
void setOpacity(qreal alpha); void setOpacity(qreal alpha);
private: private:
float maxAlpha; float maxAlpha;
}; };
//! @class ScreenImageMgr //! @class ScreenImageMgr
skipping to change at line 124 skipping to change at line 141
virtual void init(); virtual void init();
virtual void draw(StelCore* core); virtual void draw(StelCore* core);
//! Update time-dependent parts of the module. //! Update time-dependent parts of the module.
virtual void update(double deltaTime); virtual void update(double deltaTime);
//! Defines the order in which the various modules are drawn. //! Defines the order in which the various modules are drawn.
virtual double getCallOrder(StelModuleActionName actionName) const; virtual double getCallOrder(StelModuleActionName actionName) const;
public slots: public slots:
//! Create an image from a file and display on the screen at x,y coo rdinates. //! Create an image from a file and display on the screen at x,y coo rdinates.
//! @param id the ID to use when referring to this image (an arbitra ry string). //! @param id the ID to use when referring to this image (an arbitra ry string).
//! If an image with this id exists already, it will be delet ed first.
//! @param filename the partial path of the file to load. This will be searched //! @param filename the partial path of the file to load. This will be searched
//! for using StelFileMgr, with "scripts/" prefixed to the filename. //! for using StelFileMgr, with "scripts/" prefixed to the fi lename.
//! @param x The x-coordinate for the image (0 = left of screen) //! @param x The x-coordinate for the image (0 = left of screen)
//! @param y The y-coordinate for the image (0 = bottom of screen) //! @param y The y-coordinate for the image (0 = bottom of screen)
//! @param scale scale factor for the image. 1 = original size, 0.5 = 50% size etc.
//! @param visible The initial visible state of the image //! @param visible The initial visible state of the image
//! @param alpha The initial alpha (transparancy) value for the imag e (range 0.0 to 1.0) //! @param alpha The initial alpha (opacity) value for the image (ra nge 0.0=transparent to 1.0=opaque)
//! @param fadeDuration the time it takes for screen images to fade in/out/change alpha in seconds. //! @param fadeDuration the time it takes for screen images to fade in/out/change alpha in seconds.
void createScreenImage(const QString& id, void createScreenImage(const QString& id,
const QString& filename, const QString& filename,
float x, float x,
float y, float y,
float scale=1., float scale=1.,
bool visible=true, bool visible=true,
float alpha=1., float alpha=1.,
float fadeDuration=1.); float fadeDuration=1.);
//! Find out if an image is currently visible. //! Find out if an image is currently visible.
//! @param id the ID for the desired image. //! @param id the ID for the desired image.
//! @return true if visible, false if not visible or not loaded.
bool getShowImage(const QString& id); bool getShowImage(const QString& id);
//! Set an image's visible status. //! Set an image's visible status.
//! @param id the ID for the desired image. //! @param id the ID for the desired image.
//! @param show the new visible state to set. //! @param show the new visible state to set.
void showImage(const QString& id, bool show);
//! @param id the ID for the desired image.
//! @return width (unscaled!) in pixels.
int getImageWidth(const QString& id); int getImageWidth(const QString& id);
//! @param id the ID for the desired image.
//! @return height (unscaled!) in pixels.
int getImageHeight(const QString& id); int getImageHeight(const QString& id);
void showImage(const QString& id, bool show);
//! Set the x and y scale for the specified image, relative to size
given at load time.
//! @param id the ID for the desired image.
//! @param scaleX The new x-scale for the image.
//! @param scaleY The new y-scale for the image.
//! @param duration The time for the change to take place, in second
s.
void setImageScale(const QString& id, float scaleX, float scaleY, fl
oat duration=0.);
//! @param id the ID for the desired image.
//! @return current X scaling factor, relative to loaded size.
float getImageScaleX(const QString& id);
//! @param id the ID for the desired image.
//! @return current Y scaling factor, relative to loaded size.
float getImageScaleY(const QString& id);
//! Set an image's alpha value when visible //! Set an image's alpha value when visible
//! @param id the ID for the desired image. //! @param id the ID for the desired image.
//! @param alpha the new alpha value to set. //! @param alpha the new alpha value to set.
void setImageAlpha(const QString& id, float alpha); void setImageAlpha(const QString& id, float alpha);
//! Set the x and y coordinates for the specified image //! Set the x and y coordinates for the specified image
//! @param id the ID for the desired image. //! @param id the ID for the desired image.
//! @param x The new x-coordinate for the image. //! @param x The new x-coordinate for the image, pixels.
//! @param y The new y-coordinate for the image. //! @param y The new y-coordinate for the image, pixels.
//! @param duration The time for the change to take place, in second s. //! @param duration The time for the change to take place, in second s.
void setImageXY(const QString& id, float x, float y, float duration= 0.); void setImageXY(const QString& id, float x, float y, float duration= 0.);
//! Add x and y coordinate offsets to the specified image
//! @param id the ID for the desired image.
//! @param x The x-coordinate shift for the image, pixels.
//! @param y The y-coordinate shift for the image, pixels.
//! @param duration The time for the change to take place, in second
s.
void addImageXY(const QString& id, float x, float y, float duration=
0.);
//! Delete an image. //! Delete an image.
//! @param id the ID for the desired image. //! @param id the ID for the desired image.
void deleteImage(const QString& id); void deleteImage(const QString& id);
//! Delete all images currently managed by ScreenImageMgr. //! Delete all images currently managed by ScreenImageMgr.
void deleteAllImages(void); void deleteAllImages(void);
//! Get a list of currently loaded image IDs. //! Get a list of currently loaded image IDs.
QStringList getAllImageIDs(void); QStringList getAllImageIDs(void);
private: private:
QMap<QString, ScreenImage*> allScreenImages; QMap<QString, ScreenImage*> allScreenImages;
 End of changes. 19 change blocks. 
8 lines changed or deleted 62 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/