Home · All Namespaces · All Classes · Functions · Coding Style · Plugins · File Structure

modules/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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _SCREENIMAGEMGR_HPP_
00021 #define _SCREENIMAGEMGR_HPP_
00022 
00023 
00024 #include "StelFader.hpp"
00025 #include "StelModule.hpp"
00026 #include "StelTextureTypes.hpp"
00027 #include "VecMath.hpp"
00028 
00029 #include <QMap>
00030 #include <QString>
00031 #include <QStringList>
00032 
00033 class StelCore;
00034 class QGraphicsPixmapItem;
00035 class QTimeLine;
00036 class QGraphicsItemAnimation;
00037 
00038 // base class for different image types
00039 class ScreenImage
00040 {
00041 public:
00049     ScreenImage(const QString& filename, float x, float y, bool show=false, float scale=1.);
00050     virtual ~ScreenImage();
00051 
00054     virtual bool draw(const StelCore* core);
00056     virtual void update(double deltaTime);
00058     virtual void setFadeDuration(float duration);
00061     virtual void setFlagShow(bool b);
00063     virtual bool getFlagShow(void);
00067     virtual void setAlpha(float a, float duration=0.);
00072     virtual void setXY(float x, float y, float duration=0.);
00073 
00074 protected:
00075     LinearFader imageFader;
00076     QGraphicsPixmapItem* tex;
00077     QTimeLine* moveTimer;
00078     QTimeLine* fadeTimer;
00079     QGraphicsItemAnimation* anim;
00080 
00081 };
00082 
00089 class ScreenImageMgr : public StelModule
00090 {
00091     Q_OBJECT
00092 
00093 public:
00095     ScreenImageMgr(); 
00096     virtual ~ScreenImageMgr();
00097  
00099     // Methods defined in the StelModule class
00100     virtual void init();
00101     virtual void draw(StelCore* core);
00103     virtual void update(double deltaTime);
00105     virtual double getCallOrder(StelModuleActionName actionName) const;
00106 
00107 public slots:
00116     void createScreenImage(const QString& id,
00117                           const QString& filename,
00118                           float x,
00119                           float y,
00120                           float scale=1.,
00121                           bool visible=true,
00122                           float alpha=1.0);
00123 
00126     bool getShowImage(const QString& id); 
00130     void showImage(const QString& id, bool show); 
00135     void setImageXY(const QString& id, float x, float y, float duration=0.);
00138     void deleteImage(const QString& id);
00140     void deleteAllImages(void);
00142     QStringList getAllImageIDs(void);
00143 
00144 signals:
00145     void requestCreateScreenImage(const QString& id,
00146                                       const QString& filename,
00147                                   float x,
00148                                   float y,
00149                                   float scale,
00150                                   bool visible,
00151                                   float alpha);
00152 
00153     void requestSetImageShow(const QString& id, bool b);
00154 
00155     void requestSetImageXY(const QString& id, float x, float y, float duration);
00156 
00157     void requestDeleteImage(const QString& id);
00158 
00159     void requestDeleteAllImages(void);
00160 
00161 private slots:
00162     // Main thread implemention of functions which modify the state of the class.
00163     void doCreateScreenImage(const QString& id,
00164                                  const QString& filename,
00165                              float x,
00166                              float y,
00167                              float scale,
00168                              bool visible,
00169                              float alpha);
00170 
00171     void doSetImageShow(const QString& id, bool b);
00172 
00173     void doSetImageXY(const QString& id, float x, float y, float duration);
00174 
00175     void doDeleteImage(const QString& id);
00176 
00177     void doDeleteAllImages(void);
00178 
00179 private:
00180     QMap<QString, ScreenImage*> allScreenImages;
00181 };
00182 
00183 #endif // _SCREENIMAGEMGR_HPP_

Generated on Mon Feb 2 17:23:47 2009 for Stellarium by  doxygen 1.5.5