ScreenImageMgr.hpp   ScreenImageMgr.hpp 
skipping to change at line 23 skipping to change at line 23
* 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 _SCREENIMAGEMGR_HPP_ #ifndef _SCREENIMAGEMGR_HPP_
#define _SCREENIMAGEMGR_HPP_ #define _SCREENIMAGEMGR_HPP_
#include "StelFader.hpp"
#include "StelModule.hpp" #include "StelModule.hpp"
#include "StelTextureTypes.hpp" #include "StelTextureTypes.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include <QMap> #include <QMap>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QSize>
class StelCore; class StelCore;
class QGraphicsPixmapItem; class QGraphicsPixmapItem;
class QTimeLine; class QTimeLine;
class QGraphicsItemAnimation; class QGraphicsItemAnimation;
// base class for different image types // base class for different image types
class ScreenImage class ScreenImage : public QObject
{ {
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 top 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.
ScreenImage(const QString& filename, float x, float y, bool show=fal //! @param fadeDuration the time it takes for screen images to fade
se, float scale=1.); 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.);
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 //! update fade for on/off action
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, float duration=0.); 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
//! @param x the offset in the x-axis
//! @param y the offset in the y-axis
//! @param duration how long for the movement to take in seconds
virtual void addXY(float x, float y, float duration=0.);
virtual int imageHeight(void);
virtual int imageWidth(void);
protected: protected:
LinearFader imageFader;
QGraphicsPixmapItem* tex; QGraphicsPixmapItem* tex;
QTimeLine* moveTimer; QTimeLine* moveTimer;
QTimeLine* fadeTimer; QTimeLine* fadeTimer;
QGraphicsItemAnimation* anim; QGraphicsItemAnimation* anim;
private slots:
void setOpacity(qreal alpha);
private:
float maxAlpha;
}; };
//! @class ScreenImageMgr //! @class ScreenImageMgr
//! Module for managing images for scripting. Images are identified by a s tring ID which is //! Module for managing images for scripting. Images are identified by a s tring ID which is
//! passed to ScreenImageMgr members when it is necessary to specify an ima ge to work with. //! passed to ScreenImageMgr members when it is necessary to specify an ima ge to work with.
//! Member functions in this class which modify the state of the class are all mediated //! Member functions in this class which modify the state of the class are all mediated
//! through the signal/slot mechanism to ensure such operations happen in t he main thread //! through the signal/slot mechanism to ensure such operations happen in t he main thread
//! where images are drawn, and not in the script thread. //! where images are drawn, and not in the script thread.
class ScreenImageMgr : public StelModule class ScreenImageMgr : public StelModule
{ {
skipping to change at line 111 skipping to change at line 126
//! 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).
//! @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 filename.
//! @param x The x-coordinate for the image //! @param x The x-coordinate for the image (0 = left of screen)
//! @param y The x-coordinate for the image //! @param y The y-coordinate for the image (0 = bottom of screen)
//! @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 (transparancy) value for the imag e (range 0.0 to 1.0)
//! @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.0); float alpha=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.
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.
int getImageWidth(const QString& id);
int getImageHeight(const QString& id);
void showImage(const QString& id, bool show); void showImage(const QString& id, bool show);
//! Set an image's alpha value when visible
//! @param id the ID for the desired image.
//! @param alpha the new alpha value to set.
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.
//! @param y The new y-coordinate for the image. //! @param y The new y-coordinate for the image.
//! @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.);
//! 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);
signals: signals:
void requestCreateScreenImage(const QString& id, void requestCreateScreenImage(const QString& id,
const QString& filename, const QString& filename,
float x, float x,
float y, float y,
float scale, float scale,
bool visible, bool visible,
float alpha); float alpha,
float fadeDuration);
void requestSetImageShow(const QString& id, bool b); void requestSetImageShow(const QString& id, bool b);
void requestSetImageAlpha(const QString& id, float alpha);
void requestSetImageXY(const QString& id, float x, float y, float du ration); void requestSetImageXY(const QString& id, float x, float y, float du ration);
void requestDeleteImage(const QString& id); void requestDeleteImage(const QString& id);
void requestDeleteAllImages(void); void requestDeleteAllImages(void);
private slots: private slots:
// Main thread implemention of functions which modify the state of t he class. // Main thread implemention of functions which modify the state of t he class.
void doCreateScreenImage(const QString& id, void doCreateScreenImage(const QString& id,
const QString& filename, const QString& filename,
float x, float x,
float y, float y,
float scale, float scale,
bool visible, bool visible,
float alpha); float alpha,
float fadeDuration);
void doSetImageShow(const QString& id, bool b); void doSetImageShow(const QString& id, bool b);
void doSetImageAlpha(const QString& id, float alpha);
void doSetImageXY(const QString& id, float x, float y, float duratio n); void doSetImageXY(const QString& id, float x, float y, float duratio n);
void doDeleteImage(const QString& id); void doDeleteImage(const QString& id);
void doDeleteAllImages(void); void doDeleteAllImages(void);
private: private:
QMap<QString, ScreenImage*> allScreenImages; QMap<QString, ScreenImage*> allScreenImages;
}; };
 End of changes. 20 change blocks. 
17 lines changed or deleted 49 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/