Stellarium 0.15.0
1 /*
2  * Stellarium
3  * This file Copyright (C) 2008 Matthew Gates
4  * Parts copyright (C) 2016 Georg Zotti (added size transitions)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
25 #include "StelModule.hpp"
26 #include "StelTextureTypes.hpp"
27 #include "VecMath.hpp"
29 #include <QMap>
30 #include <QString>
31 #include <QStringList>
32 #include <QSize>
34 class StelCore;
35 class QGraphicsPixmapItem;
36 class QTimeLine;
37 class QGraphicsItemAnimation;
39 // base class for different image types
40 class ScreenImage : public QObject
41 {
44 public:
56  ScreenImage(const QString& filename, float x, float y, bool show=false, float scale=1., float alpha=1., float fadeDuration=1.);
57  virtual ~ScreenImage();
61  virtual bool draw(const StelCore* core);
63  virtual void update(double deltaTime);
65  virtual void setFadeDuration(float duration);
68  virtual void setFlagShow(bool b);
70  virtual bool getFlagShow(void);
75  virtual void setAlpha(float a);
81  virtual void setXY(float x, float y, float duration=0.);
87  virtual void addXY(float x, float y, float duration=0.);
88  virtual int imageHeight(void);
89  virtual int imageWidth(void);
95  virtual void setScale(float scaleX, float scaleY, float duration=0.);
96  virtual float imageScaleX(void);
97  virtual float imageScaleY(void);
99 protected:
100  QGraphicsPixmapItem* tex;
101  QTimeLine* moveTimer; // for position changes
102  QTimeLine* fadeTimer; // for transparency
103  QTimeLine* scaleTimer; // for grow/shrink
104  QGraphicsItemAnimation* anim;
105  QGraphicsItemAnimation* scaleAnim;
107 private slots:
108  void setOpacity(qreal alpha);
110 private:
111  float maxAlpha;
113 };
122 {
125 public:
127  ScreenImageMgr();
128  virtual ~ScreenImageMgr();
131  // Methods defined in the StelModule class
132  virtual void init();
133  virtual void draw(StelCore* core);
135  virtual void update(double deltaTime);
137  virtual double getCallOrder(StelModuleActionName actionName) const;
139 public slots:
151  void createScreenImage(const QString& id,
152  const QString& filename,
153  float x,
154  float y,
155  float scale=1.,
156  bool visible=true,
157  float alpha=1.,
158  float fadeDuration=1.);
163  bool getShowImage(const QString& id);
167  void showImage(const QString& id, bool show);
170  int getImageWidth(const QString& id);
173  int getImageHeight(const QString& id);
180  void setImageScale(const QString& id, float scaleX, float scaleY, float duration=0.);
183  float getImageScaleX(const QString& id);
186  float getImageScaleY(const QString& id);
190  void setImageAlpha(const QString& id, float alpha);
196  void setImageXY(const QString& id, float x, float y, float duration=0.);
202  void addImageXY(const QString& id, float x, float y, float duration=0.);
205  void deleteImage(const QString& id);
207  void deleteAllImages(void);
209  QStringList getAllImageIDs(void);
211 private:
212  QMap<QString, ScreenImage*> allScreenImages;
213 };
215 #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.
virtual void setScale(float scaleX, float scaleY, float duration=0.)
Set the image scale relative to the size originally loaded.
Module for managing images for scripting.
virtual bool draw(const StelCore *core)
Draw the image.
float getImageScaleX(const QString &id)
Define the StelTextureSP type.
void addImageXY(const QString &id, float x, float y, float duration=0.)
Add x and y coordinate offsets to the specified image.
void showImage(const QString &id, bool show)
Set an image's visible status.
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:48
void setImageScale(const QString &id, float scaleX, float scaleY, float duration=0.)
Set the x and y scale for the specified image, relative to size given at load time.
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.
float getImageScaleY(const QString &id)
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.
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.
int getImageHeight(const QString &id)
Construct a LabelMgr object.
virtual void update(double deltaTime)
Update time-dependent parts of the module.
int getImageWidth(const QString &id)
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)
Empty dummy. The various animations are updated by other means.