Stellarium 0.13.3
ScreenImageMgr.hpp
1 /*
2  * Stellarium
3  * This file Copyright (C) 2008 Matthew Gates
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _SCREENIMAGEMGR_HPP_
21 #define _SCREENIMAGEMGR_HPP_
22 
23 
24 #include "StelModule.hpp"
25 #include "StelTextureTypes.hpp"
26 #include "VecMath.hpp"
27 
28 #include <QMap>
29 #include <QString>
30 #include <QStringList>
31 #include <QSize>
32 
33 class StelCore;
34 class QGraphicsPixmapItem;
35 class QTimeLine;
36 class QGraphicsItemAnimation;
37 
38 // base class for different image types
39 class ScreenImage : public QObject
40 {
41  Q_OBJECT
42 
43 public:
52  ScreenImage(const QString& filename, float x, float y, bool show=false, float scale=1., float alpha=1., float fadeDuration=1.);
53  virtual ~ScreenImage();
54 
57  virtual bool draw(const StelCore* core);
59  virtual void update(double deltaTime);
61  virtual void setFadeDuration(float duration);
64  virtual void setFlagShow(bool b);
66  virtual bool getFlagShow(void);
70  virtual void setAlpha(float a);
75  virtual void setXY(float x, float y, float duration=0.);
80  virtual void addXY(float x, float y, float duration=0.);
81  virtual int imageHeight(void);
82  virtual int imageWidth(void);
83 
84 protected:
85  QGraphicsPixmapItem* tex;
86  QTimeLine* moveTimer;
87  QTimeLine* fadeTimer;
88  QGraphicsItemAnimation* anim;
89 
90 private slots:
91  void setOpacity(qreal alpha);
92 
93 private:
94  float maxAlpha;
95 
96 };
97 
105 {
106  Q_OBJECT
107 
108 public:
110  ScreenImageMgr();
111  virtual ~ScreenImageMgr();
112 
114  // Methods defined in the StelModule class
115  virtual void init();
116  virtual void draw(StelCore* core);
118  virtual void update(double deltaTime);
120  virtual double getCallOrder(StelModuleActionName actionName) const;
121 
122 public slots:
132  void createScreenImage(const QString& id,
133  const QString& filename,
134  float x,
135  float y,
136  float scale=1.,
137  bool visible=true,
138  float alpha=1.,
139  float fadeDuration=1.);
140 
143  bool getShowImage(const QString& id);
147  int getImageWidth(const QString& id);
148  int getImageHeight(const QString& id);
149  void showImage(const QString& id, bool show);
153  void setImageAlpha(const QString& id, float alpha);
159  void setImageXY(const QString& id, float x, float y, float duration=0.);
162  void deleteImage(const QString& id);
164  void deleteAllImages(void);
166  QStringList getAllImageIDs(void);
167 
168 private:
169  QMap<QString, ScreenImage*> allScreenImages;
170 };
171 
172 #endif // _SCREENIMAGEMGR_HPP_
QStringList getAllImageIDs(void)
Get a list of currently loaded image IDs.
void deleteAllImages(void)
Delete all images currently managed by ScreenImageMgr.
virtual bool getFlagShow(void)
Get the displayed status of the image.
void deleteImage(const QString &id)
Delete an image.
Module for managing images for scripting.
virtual bool draw(const StelCore *core)
Draw the image.
Define the StelTextureSP type.
virtual void setFadeDuration(float duration)
Set the duration used for the fade in / fade out of the image.
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
virtual void setXY(float x, float y, float duration=0.)
Set the x, y position of the image.
virtual void setFlagShow(bool b)
Show or hide the image (it will fade in/out)
virtual void addXY(float x, float y, float duration=0.)
Set the x, y position of the image relative to the current position.
virtual double getCallOrder(StelModuleActionName actionName) const
Defines the order in which the various modules are drawn.
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
virtual void setAlpha(float a)
Set the image alpha for when it is in full "on" (after fade in).
virtual void init()
Initialize itself.
void setImageXY(const QString &id, float x, float y, float duration=0.)
Set the x and y coordinates for the specified image.
void setImageAlpha(const QString &id, float alpha)
Set an image's alpha value when visible.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:117
void createScreenImage(const QString &id, const QString &filename, float x, float y, float scale=1., bool visible=true, float alpha=1., float fadeDuration=1.)
Create an image from a file and display on the screen at x,y coordinates.
bool getShowImage(const QString &id)
Find out if an image is currently visible.
ScreenImageMgr()
Construct a LabelMgr object.
virtual void update(double deltaTime)
Update time-dependent parts of the module.
int getImageWidth(const QString &id)
Set an image's visible status.
ScreenImage(const QString &filename, float x, float y, bool show=false, float scale=1., float alpha=1., float fadeDuration=1.)
Load an image.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49
virtual void update(double deltaTime)
update fade for on/off action