00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00088 class StelViewportDistorter *distorter;
00089
00090
00091 static StelAppGraphicsScene* singleton;
00092
00093
00094 float cursorTimeout;
00095 bool flagCursorTimeout;
00096
00097 QTimer* minFpsTimer;
00098 };
00099
00100 #endif // _STELAPPGRAPHICSSCENE_HPP_
00101