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

core/StelAppGraphicsScene.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2007 Fabien Chereau
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 _STELAPPGRAPHICSSCENE_HPP_
00021 #define _STELAPPGRAPHICSSCENE_HPP_
00022 
00023 #include <QGraphicsScene>
00024 
00025 class QTimer;
00026 
00029 class StelAppGraphicsScene : public QGraphicsScene
00030 {
00031     Q_OBJECT
00032 public:
00033     StelAppGraphicsScene();
00034     ~StelAppGraphicsScene();
00035 
00038     static StelAppGraphicsScene& getInstance() {Q_ASSERT(singleton); return *singleton;}
00039     
00041     void init();
00042 
00044     void startMainLoop();
00045             
00048     void setViewPortDistorterType(const QString& type);
00050     QString getViewPortDistorterType() const;
00051     
00052     void glWindowHasBeenResized(int w, int h);
00053     
00055     bool getFlagCursorTimeout() {return flagCursorTimeout;}
00057     float getCursorTimeout() const {return cursorTimeout;}
00059     void setFlagCursorTimeout(bool b) {flagCursorTimeout=b;}
00061     void setCursorTimeout(float t) {cursorTimeout=t;}
00062 
00063 public slots:
00064     void minFpsChanged();
00065 
00066 protected:
00067     virtual void keyPressEvent(QKeyEvent* event);
00068     virtual void keyReleaseEvent(QKeyEvent* event);
00069     virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
00070     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00071     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00072     virtual void wheelEvent(QGraphicsSceneWheelEvent * wheelEvent);
00073     
00076     void drawBackground(QPainter *painter, const QRectF &rect);
00077     
00078 private:
00079     
00082     void thereWasAnEvent();
00083     
00084     double previousTime;
00085     double lastEventTimeSec;
00086     
00087     // Main elements of the StelApp
00088     class StelViewportDistorter *distorter;
00089     
00090     // The StelAppGraphicsScene singleton
00091     static StelAppGraphicsScene* singleton;
00092     
00093     // Number of second before the mouse cursor disappears
00094     float cursorTimeout;
00095     bool flagCursorTimeout;
00096 
00097     QTimer* minFpsTimer;
00098 };
00099 
00100 #endif // _STELAPPGRAPHICSSCENE_HPP_
00101 

Generated on Mon Mar 9 16:16:15 2009 for Stellarium by  doxygen 1.5.5