00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _STELMAINGRAPHICSVIEW_HPP_
00021 #define _STELMAINGRAPHICSVIEW_HPP_
00022
00023 #include <QGraphicsView>
00024 #include <QCoreApplication>
00025 #include <QEventLoop>
00026
00027 class QGLWidget;
00028 class QResizeEvent;
00029 class StelGuiBase;
00030 class StelMainScriptAPIProxy;
00031 class StelScriptMgr;
00032 class StelQGLWidget;
00033
00037 class StelMainGraphicsView : public QGraphicsView
00038 {
00039 Q_OBJECT
00040 public:
00041 StelMainGraphicsView(QWidget* parent);
00042 virtual ~StelMainGraphicsView();
00043
00045 void init(class QSettings* conf);
00046
00048 static StelMainGraphicsView& getInstance() {Q_ASSERT(singleton); return *singleton;}
00049
00051 void deinitGL();
00052
00055 class StelAppGraphicsWidget* getStelAppGraphicsWidget() {return mainSkyItem;}
00056
00059 QGraphicsWidget* getTopLevelGraphicsWidget() {return backItem;}
00060
00061 #ifndef DISABLE_SCRIPTING
00062
00063 StelMainScriptAPIProxy* getMainScriptAPIProxy() {return scriptAPIProxy;}
00065 StelScriptMgr& getScriptMgr() {return *scriptMgr;}
00066 #endif
00067
00068 public slots:
00069
00071
00078 void saveScreenShot(const QString& filePrefix="stellarium-", const QString& saveDir="");
00079
00081 bool getFlagInvertScreenShotColors() const {return flagInvertScreenShotColors;}
00083 void setFlagInvertScreenShotColors(bool b) {flagInvertScreenShotColors=b;}
00084
00086 bool getFlagCursorTimeout() {return flagCursorTimeout;}
00088 float getCursorTimeout() const {return cursorTimeout;}
00090 void setFlagCursorTimeout(bool b) {flagCursorTimeout=b;}
00092 void setCursorTimeout(float t) {cursorTimeout=t;}
00093
00098 void setMinFps(float m) {minfps=m; minFpsChanged();}
00100 float getMinFps() {return minfps;}
00103 void setMaxFps(float m) {maxfps = m;}
00105 float getMaxFps() {return maxfps;}
00106
00108 void updateScene() {
00109
00110 #ifdef QT_MAC_USE_COCOA
00111
00112
00113
00114 QCoreApplication::processEvents(QEventLoop::AllEvents);
00115 #endif
00116 scene()->update();
00117 }
00118
00119 protected:
00120 virtual void resizeEvent(QResizeEvent* event);
00121 virtual void mouseMoveEvent(QMouseEvent* event);
00122 virtual void mousePressEvent(QMouseEvent* event);
00123 virtual void mouseReleaseEvent(QMouseEvent* event);
00124 virtual void keyPressEvent(QKeyEvent* event);
00125 virtual void keyReleaseEvent(QKeyEvent* event);
00126 virtual void wheelEvent(QWheelEvent* wheelEvent);
00127
00130 virtual void drawBackground(QPainter* painter, const QRectF &rect);
00131
00132 signals:
00136 void screenshotRequested(void);
00137
00138 private slots:
00139
00140 void doScreenshot(void);
00141
00142 void minFpsChanged();
00143
00144 private:
00146 void startMainLoop();
00147
00149 static StelMainGraphicsView* singleton;
00150 QGraphicsWidget* backItem;
00151 class StelAppGraphicsWidget* mainSkyItem;
00152
00154 StelQGLWidget* glWidget;
00155 class QGLContext* glContext;
00156
00157 StelGuiBase* gui;
00158
00159 #ifndef DISABLE_SCRIPTING
00160
00161 StelMainScriptAPIProxy* scriptAPIProxy;
00162
00163
00164 StelScriptMgr* scriptMgr;
00165 #endif
00166
00167 bool wasDeinit;
00168
00169 bool flagInvertScreenShotColors;
00170
00171 QString screenShotPrefix;
00172 QString screenShotDir;
00173
00174
00175 float cursorTimeout;
00176 bool flagCursorTimeout;
00177
00180 void thereWasAnEvent();
00181
00182 double lastEventTimeSec;
00183
00184 QTimer* minFpsTimer;
00186 float minfps;
00188 float maxfps;
00189 };
00190
00191
00192 #endif // _STELMAINGRAPHICSVIEW_HPP_