![]() |
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure |
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 _STELMAINGRAPHICSVIEW_HPP_ 00021 #define _STELMAINGRAPHICSVIEW_HPP_ 00022 00023 #include <QGraphicsView> 00024 00025 class QGLWidget; 00026 class QResizeEvent; 00027 class StelGuiBase; 00028 class StelMainScriptAPIProxy; 00029 class StelScriptMgr; 00030 class StelQGLWidget; 00031 00035 class StelMainGraphicsView : public QGraphicsView 00036 { 00037 Q_OBJECT 00038 public: 00039 StelMainGraphicsView(QWidget* parent); 00040 virtual ~StelMainGraphicsView(); 00041 00043 void init(class QSettings* conf); 00044 00046 static StelMainGraphicsView& getInstance() {Q_ASSERT(singleton); return *singleton;} 00047 00050 QGLWidget* getOpenGLWin() {return (QGLWidget*)glWidget;} 00051 00054 void swapBuffer(); 00055 00056 void makeGLContextCurrent(); 00057 00059 void deinitGL(); 00060 00063 class StelAppGraphicsWidget* getStelAppGraphicsWidget() {return mainSkyItem;} 00064 00067 QGraphicsWidget* getTopLevelGraphicsWidget() {return backItem;} 00068 00070 StelMainScriptAPIProxy* getMainScriptAPIProxy() {return scriptAPIProxy;} 00072 StelScriptMgr& getScriptMgr() {return *scriptMgr;} 00073 00074 public slots: 00075 00077 // Specific methods 00084 void saveScreenShot(const QString& filePrefix="stellarium-", const QString& saveDir=""); 00085 00087 bool getFlagInvertScreenShotColors() const {return flagInvertScreenShotColors;} 00089 void setFlagInvertScreenShotColors(bool b) {flagInvertScreenShotColors=b;} 00090 00092 bool getFlagCursorTimeout() {return flagCursorTimeout;} 00094 float getCursorTimeout() const {return cursorTimeout;} 00096 void setFlagCursorTimeout(bool b) {flagCursorTimeout=b;} 00098 void setCursorTimeout(float t) {cursorTimeout=t;} 00099 00104 void setMinFps(float m) {minfps=m; minFpsChanged();} 00106 float getMinFps() {return minfps;} 00109 void setMaxFps(float m) {maxfps = m;} 00111 float getMaxFps() {return maxfps;} 00112 00113 protected: 00114 virtual void resizeEvent(QResizeEvent* event); 00115 virtual void mouseMoveEvent(QMouseEvent* event); 00116 virtual void mousePressEvent(QMouseEvent* event); 00117 virtual void mouseReleaseEvent(QMouseEvent* event); 00118 virtual void keyPressEvent(QKeyEvent* event); 00119 virtual void keyReleaseEvent(QKeyEvent* event); 00120 virtual void wheelEvent(QWheelEvent* wheelEvent); 00121 00124 virtual void drawBackground(QPainter* painter, const QRectF &rect); 00125 virtual void drawForeground(QPainter* painter, const QRectF &rect); 00126 00127 signals: 00131 void screenshotRequested(void); 00132 00133 private slots: 00134 // Do the actual screenshot generation in the main thread with this method. 00135 void doScreenshot(void); 00136 00137 void minFpsChanged(); 00138 00139 private: 00141 void startMainLoop(); 00142 00144 static StelMainGraphicsView* singleton; 00145 QGraphicsWidget* backItem; 00146 class StelAppGraphicsWidget* mainSkyItem; 00147 00149 StelQGLWidget* glWidget; 00150 00151 StelGuiBase* gui; 00152 00153 // The script API proxy object (for bridging threads) 00154 StelMainScriptAPIProxy* scriptAPIProxy; 00155 00156 // The script manager based on Qt script engine 00157 StelScriptMgr* scriptMgr; 00158 00159 bool wasDeinit; 00160 00161 bool flagInvertScreenShotColors; 00162 00163 QString screenShotPrefix; 00164 QString screenShotDir; 00165 00166 // Number of second before the mouse cursor disappears 00167 float cursorTimeout; 00168 bool flagCursorTimeout; 00169 00172 void thereWasAnEvent(); 00173 00174 double lastEventTimeSec; 00175 00176 QTime* qtime; 00177 QTimer* minFpsTimer; 00179 float minfps; 00181 float maxfps; 00182 }; 00183 00184 00185 #endif // _STELMAINGRAPHICSVIEW_HPP_