Stellarium 0.11.4
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

scripting/ScreenImageMgr.hpp

00001 /*
00002  * Stellarium
00003  * This file Copyright (C) 2008 Matthew Gates
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
00018  */
00019 
00020 #ifndef _SCREENIMAGEMGR_HPP_
00021 #define _SCREENIMAGEMGR_HPP_
00022 
00023 
00024 #include "StelModule.hpp"
00025 #include "StelTextureTypes.hpp"
00026 #include "VecMath.hpp"
00027 
00028 #include <QMap>
00029 #include <QString>
00030 #include <QStringList>
00031 #include <QSize>
00032 
00033 class StelCore;
00034 class QGraphicsPixmapItem;
00035 class QTimeLine;
00036 class QGraphicsItemAnimation;
00037 
00038 // base class for different image types
00039 class ScreenImage : public QObject
00040 {
00041     Q_OBJECT
00042 
00043 public:
00052     ScreenImage(const QString& filename, float x, float y, bool show=false, float scale=1., float alpha=1., float fadeDuration=1.);
00053     virtual ~ScreenImage();
00054 
00057     virtual bool draw(const StelCore* core);
00059     virtual void update(double deltaTime);
00061     virtual void setFadeDuration(float duration);
00064     virtual void setFlagShow(bool b);
00066     virtual bool getFlagShow(void);
00070     virtual void setAlpha(float a);
00075     virtual void setXY(float x, float y, float duration=0.);
00080     virtual void addXY(float x, float y, float duration=0.);
00081     virtual int imageHeight(void);
00082     virtual int imageWidth(void);
00083 
00084 protected:
00085     QGraphicsPixmapItem* tex;
00086     QTimeLine* moveTimer;
00087     QTimeLine* fadeTimer;
00088     QGraphicsItemAnimation* anim;
00089 
00090 private slots:
00091     void setOpacity(qreal alpha);
00092 
00093 private:
00094     float maxAlpha;
00095 
00096 };
00097 
00104 class ScreenImageMgr : public StelModule
00105 {
00106     Q_OBJECT
00107 
00108 public:
00110     ScreenImageMgr(); 
00111     virtual ~ScreenImageMgr();
00112  
00114     // Methods defined in the StelModule class
00115     virtual void init();
00116     virtual void draw(StelCore* core);
00118     virtual void update(double deltaTime);
00120     virtual double getCallOrder(StelModuleActionName actionName) const;
00121 
00122 public slots:
00132     void createScreenImage(const QString& id,
00133                                const QString& filename,
00134                            float x,
00135                            float y,
00136                            float scale=1.,
00137                            bool visible=true,
00138                            float alpha=1.,
00139                            float fadeDuration=1.);
00140 
00143     bool getShowImage(const QString& id); 
00147     int getImageWidth(const QString& id);
00148     int getImageHeight(const QString& id);
00149     void showImage(const QString& id, bool show); 
00153     void setImageAlpha(const QString& id, float alpha); 
00159     void setImageXY(const QString& id, float x, float y, float duration=0.);
00162     void deleteImage(const QString& id);
00164     void deleteAllImages(void);
00166     QStringList getAllImageIDs(void);
00167 
00168 private:
00169     QMap<QString, ScreenImage*> allScreenImages;
00170 };
00171 
00172 #endif // _SCREENIMAGEMGR_HPP_
Generated on Sat Aug 25 22:13:30 2012 for Stellarium by  doxygen 1.6.3