00001 /* Copyright (C) 2009 Väinö Lappi <djap84@gmail.com> 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00016 00017 */ 00018 #ifndef ITISSNOWING_H 00019 #define ITISSNOWING_H 00020 // 00021 #include <QThread> 00022 #include <QMutex> 00023 #include <QGraphicsScene> 00024 #include <QPixmap> 00025 #include <QGraphicsPixmapItem> 00026 #include "AnimationEngineAPI.h" 00027 00032 #define SNOW_AMMOUNT 40 00033 00038 #ifndef PI 00039 #define PI 3.14 00040 #endif 00041 00047 class ItIsSnowing : public QThread, public AnimationEngineAPI 00048 { 00049 Q_OBJECT 00050 public: 00051 ItIsSnowing(); 00052 virtual ~ItIsSnowing(); 00053 00062 void startAnimation(QGraphicsScene *targetGraphicsScene); 00063 00072 void startAnimationPreview(QGraphicsScene *targetGraphicsScene); 00073 00080 void stopAndCleanUp(); 00081 00082 QString getAnimationName(); 00083 QString getAnimationBg(); 00084 protected: 00091 void run(); 00092 private: 00097 QPixmap* iSnowFlakePixmap; 00098 00103 QGraphicsPixmapItem* iSnowFlake[SNOW_AMMOUNT]; 00104 00109 float iSnowflakeXOffsets[SNOW_AMMOUNT]; 00110 00115 float iSnowflakeFallSpeeds[SNOW_AMMOUNT]; 00116 00121 float iSnowflakeYLocations[SNOW_AMMOUNT]; 00122 00127 float iSnowflakeXLocations[SNOW_AMMOUNT]; 00128 00133 QGraphicsScene* iTargetScene; 00134 00139 QMutex iRunningMux; 00140 00145 QMutex iSnowflakeLocationMux; 00146 private slots: 00147 /* 00148 * Routing graphics updates through Qts signaling queue so they will be handled by the GUI thread 00149 */ 00157 void updateGraphics(); 00158 signals: 00166 void sigUpdateGraphics(); 00167 }; 00168 #endif