StelMainView.hpp   StelMainView.hpp 
skipping to change at line 27 skipping to change at line 27
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _STELMAINGRAPHICSVIEW_HPP_ #ifndef _STELMAINGRAPHICSVIEW_HPP_
#define _STELMAINGRAPHICSVIEW_HPP_ #define _STELMAINGRAPHICSVIEW_HPP_
#include <QCoreApplication> #include <QCoreApplication>
#include <QGraphicsView> #include <QGraphicsView>
#include <QEventLoop> #include <QEventLoop>
#include <QOpenGLContext> #include <QOpenGLContext>
#include <QTimer>
// This define (only used here and in StelMainView.cpp) is temporarily used #ifdef OPENGL_DEBUG_LOGGING
// to allow uncompromised compiling while the migration to the new QOpenGL. #include <QOpenGLDebugMessage>
.. classes
// has not been done. As soon as Qt5.4 is out, we should finish this migrat
ion process!
#define STEL_USE_NEW_OPENGL_WIDGETS 0
#if STEL_USE_NEW_OPENGL_WIDGETS
class QOpenGLWidget;
class StelQOpenGLWidget;
#else
class QGLWidget;
class StelQGLWidget;
#endif #endif
class StelGLWidget;
class StelGraphicsScene;
class QMoveEvent; class QMoveEvent;
class QResizeEvent; class QResizeEvent;
class StelGuiBase; class StelGuiBase;
class QMoveEvent; class QMoveEvent;
class QSettings; class QSettings;
//! @class StelMainView //! @class StelMainView
//! Reimplement a QGraphicsView for Stellarium. //! Reimplement a QGraphicsView for Stellarium.
//! It is the class creating the singleton GL Widget, the main StelApp inst ance as well as the main GUI. //! It is the class creating the singleton GL Widget, the main StelApp inst ance as well as the main GUI.
class StelMainView : public QGraphicsView class StelMainView : public QGraphicsView
{ {
friend class StelGuiItem; friend class StelGuiItem;
friend class StelSkyItem; friend class StelRootItem;
friend class StelGraphicsScene;
friend class NightModeGraphicsEffect;
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOT IFY fullScreenChanged) Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOT IFY fullScreenChanged)
public: public:
StelMainView(QWidget* parent = NULL); //! Contains some basic info about the OpenGL context used
struct GLInfo
{
QString vendor;
QString renderer;
QOpenGLContext* mainContext;
QOpenGLFunctions* functions;
};
StelMainView(QSettings* settings);
virtual ~StelMainView(); virtual ~StelMainView();
//! Start the main initialization of Stellarium //! Start the main initialization of Stellarium
void init(class QSettings* conf); void init();
void deinit(); void deinit();
//! Set the application title for the current language. //! Set the application title for the current language.
//! This is useful for e.g. chinese. //! This is useful for e.g. chinese.
void initTitleI18n(); void initTitleI18n();
//! Get the StelMainView singleton instance. //! Get the StelMainView singleton instance.
static StelMainView& getInstance() {Q_ASSERT(singleton); return *sin gleton;} static StelMainView& getInstance() {Q_ASSERT(singleton); return *sin gleton;}
//! Delete openGL textures (to call before the GLContext disappears) //! Delete openGL textures (to call before the GLContext disappears)
void deinitGL(); void deinitGL();
//! Return focus to the sky item. To be used when we close a dialog
.
void focusSky();
//! Return the parent gui widget, this should be used as parent to a ll //! Return the parent gui widget, this should be used as parent to a ll
//! the StelDialog instances. //! the StelDialog instances.
QGraphicsWidget* getGuiWidget() const {return guiItem;} QGraphicsWidget* getGuiWidget() const {return guiItem;}
//! Return mouse position coordinates //! Return mouse position coordinates
QPoint getMousePos(); QPoint getMousePos();
//! Returns the main application OpenGL context,
//! which should be used for all drawing Stellarium does
//! @sa glContextMakeCurrent()
//! @sa glContextDoneCurrent()
QOpenGLContext* glContext() const;
//! Make the main GL context (the one returned from glContext()) cur
rent
//! on the main view surface
void glContextMakeCurrent();
//! Releases the main GL context
void glContextDoneCurrent();
//! Returns the information about the GL context, this does not requ
ire the context to be active.
GLInfo getGLInformation() const { return glInfo; }
public slots: public slots:
//! Set whether fullscreen is activated or not //! Set whether fullscreen is activated or not
void setFullScreen(bool); void setFullScreen(bool);
//! Set focus on the sky //! Return focus to the sky item. To be used when we close a dialog
void setFocusOnSky(); .
void focusSky();
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Specific methods // Specific methods
//! Save a screen shot. //! Save a screen shot.
//! The format of the file, and hence the filename extension //! The format of the file, and hence the filename extension
//! depends on the architecture and build type. //! depends on the architecture and build type.
//! @arg filePrefix changes the beginning of the file name //! @arg filePrefix changes the beginning of the file name
//! @arg saveDir changes the directory where the screenshot is saved //! @arg saveDir changes the directory where the screenshot is saved
//! If saveDir is "" then StelFileMgr::getScreenshotDir() will be us ed //! If saveDir is "" then StelFileMgr::getScreenshotDir() will be us ed
//! @arg overwrite if true, @arg filePrefix is used as filename, and existing file will be overwritten. //! @arg overwrite if true, @arg filePrefix is used as filename, and existing file will be overwritten.
skipping to change at line 122 skipping to change at line 140
float getCursorTimeout() const {return cursorTimeout;} float getCursorTimeout() const {return cursorTimeout;}
//! Get the state of the mouse cursor timeout flag //! Get the state of the mouse cursor timeout flag
void setFlagCursorTimeout(bool b) {flagCursorTimeout=b;} void setFlagCursorTimeout(bool b) {flagCursorTimeout=b;}
//! Set the mouse cursor timeout in seconds //! Set the mouse cursor timeout in seconds
void setCursorTimeout(float t) {cursorTimeout=t;} void setCursorTimeout(float t) {cursorTimeout=t;}
//! Set the minimum frames per second. Usually this minimum will be switched to after there are no //! Set the minimum frames per second. Usually this minimum will be switched to after there are no
//! user events for some seconds to save power. However, if can be u seful to set this to a high //! user events for some seconds to save power. However, if can be u seful to set this to a high
//! value to improve playing smoothness in scripts. //! value to improve playing smoothness in scripts.
//! @param m the new minimum fps setting. //! @param m the new minimum fps setting.
void setMinFps(float m) {minfps=m; minFpsChanged();} void setMinFps(float m) {minfps=m; minFpsTimer->setInterval(1000/min fps);}
//! Get the current minimum frames per second. //! Get the current minimum frames per second.
float getMinFps() {return minfps;} float getMinFps() {return minfps;}
//! Set the maximum frames per second. //! Set the maximum frames per second.
//! @param m the new maximum fps setting. //! @param m the new maximum fps setting.
//! @todo this setting currently does nothing
void setMaxFps(float m) {maxfps = m;} void setMaxFps(float m) {maxfps = m;}
//! Get the current maximum frames per second. //! Get the current maximum frames per second.
float getMaxFps() {return maxfps;} float getMaxFps() {return maxfps;}
void maxFpsSceneUpdate();
//! Updates the scene and process all events
void updateScene();
//! Notify that an event was handled by the program and therefore th e //! Notify that an event was handled by the program and therefore th e
//! FPS should be maximized for a couple of seconds. //! FPS should be maximized for a couple of seconds.
void thereWasAnEvent(); void thereWasAnEvent();
protected: //! Determines if we should render as fast as possible,
virtual void mouseMoveEvent(QMouseEvent* event); //! or limit the FPS. This depends on the time the last user event
virtual void mousePressEvent(QMouseEvent* event); //! happened.
virtual void mouseReleaseEvent(QMouseEvent* event); bool needsMaxFPS() const;
virtual void keyPressEvent(QKeyEvent* event);
virtual void keyReleaseEvent(QKeyEvent* event);
virtual void wheelEvent(QWheelEvent* wheelEvent);
virtual void moveEvent(QMoveEvent* event);
virtual void closeEvent(QCloseEvent* event);
virtual void resizeEvent(QResizeEvent* event);
//! Update the mouse pointer state and schedule next redraw.
//! This method is called automatically by Qt.
virtual void drawBackground(QPainter* painter, const QRectF &rect);
protected:
//! Hack to determine current monitor pixel ratio
//! @todo Find a better way to handle this
virtual void moveEvent(QMoveEvent* event) Q_DECL_OVERRIDE;
//! Handle window closed event, calling StelApp::quit()
virtual void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
//! Handle window resized events, and change the size of the underly
ing
//! QGraphicsScene to be the same
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
signals: signals:
//! emitted when saveScreenShot is requested with saveScreenShot(). //! emitted when saveScreenShot is requested with saveScreenShot().
//! doScreenshot() does the actual work (it has to do it in the main //! doScreenshot() does the actual work (it has to do it in the main
//! thread, where as saveScreenShot() might get called from another one. //! thread, where as saveScreenShot() might get called from another one.
//!
//! @remark FS: is threaded access here even a possibility anymore,
or a remnant of older code?
void screenshotRequested(void); void screenshotRequested(void);
void fullScreenChanged(bool b); void fullScreenChanged(bool b);
private slots: private slots:
// Do the actual screenshot generation in the main thread with this method. // Do the actual screenshot generation in the main thread with this method.
void doScreenshot(void); void doScreenshot(void);
void minFpsChanged(); void minFPSUpdate();
#ifdef OPENGL_DEBUG_LOGGING
void logGLMessage(const QOpenGLDebugMessage& debugMessage);
void contextDestroyed();
#endif
void updateNightModeProperty(bool b); void updateNightModeProperty(bool b);
private: private:
//! Start the display loop //! The graphics scene notifies us when a draw finished, so that we
void startMainLoop(); can queue the next one
void drawEnded();
//! Returns the desired OpenGL format settings,
//! on desktop this corresponds to a GL 2.1 context,
//! with 32bit RGBA buffer and 24/8 depth/stencil buffer
QSurfaceFormat getDesiredGLFormat() const;
//! provide extended OpenGL diagnostics in logfile. //! provide extended OpenGL diagnostics in logfile.
void dumpOpenGLdiagnostics() const; void dumpOpenGLdiagnostics() const;
//! Startup diagnostics, providing test for various circumstances of bad OS/OpenGL driver combinations //! Startup diagnostics, providing test for various circumstances of bad OS/OpenGL driver combinations
//! to provide feedback to the user about bad OpenGL drivers. //! to provide feedback to the user about bad OpenGL drivers.
#if STEL_USE_NEW_OPENGL_WIDGETS void processOpenGLdiagnosticsAndWarnings(QSettings *conf, QOpenGLCon
void processOpenGLdiagnosticsAndWarnings(QSettings *conf, StelQOpenG text* context) const;
LWidget* glWidget) const;
#else
void processOpenGLdiagnosticsAndWarnings(QSettings *conf, StelQGLWid
get* glWidget) const;
#endif
//! The StelMainView singleton //! The StelMainView singleton
static StelMainView* singleton; static StelMainView* singleton;
QGraphicsWidget* rootItem; GLInfo glInfo;
QGraphicsWidget* skyItem;
QSettings* configuration;
class StelRootItem* rootItem;
QGraphicsWidget* guiItem; QGraphicsWidget* guiItem;
QGraphicsEffect* nightModeEffect; QGraphicsEffect* nightModeEffect;
//! The openGL window //! The openGL viewport of the graphics scene
#if STEL_USE_NEW_OPENGL_WIDGETS //! Responsible for main GL setup, rendering is done in the scene ba
StelQOpenGLWidget* glWidget; ckground
#else StelGLWidget* glWidget;
StelQGLWidget* glWidget; //! Custom QGraphicsScene, this renders our scene background
#endif StelGraphicsScene* stelScene;
StelGuiBase* gui; StelGuiBase* gui;
class StelApp* stelApp; class StelApp* stelApp;
bool updateQueued;
bool flagInvertScreenShotColors; bool flagInvertScreenShotColors;
bool flagOverwriteScreenshots; //! if set to true, screenshot is nam ed exactly screenShotPrefix.png and overwrites existing file bool flagOverwriteScreenshots; //! if set to true, screenshot is nam ed exactly screenShotPrefix.png and overwrites existing file
QString screenShotPrefix; QString screenShotPrefix;
QString screenShotDir; QString screenShotDir;
// Number of second before the mouse cursor disappears // Number of second before the mouse cursor disappears
float cursorTimeout; float cursorTimeout;
bool flagCursorTimeout; bool flagCursorTimeout;
double lastEventTimeSec; double lastEventTimeSec;
QTimer* minFpsTimer;
bool flagMaxFpsUpdatePending;
//! The minimum desired frame rate in frame per second. //! The minimum desired frame rate in frame per second.
float minfps; float minfps;
//! The maximum desired frame rate in frame per second. //! The maximum desired frame rate in frame per second.
float maxfps; float maxfps;
QTimer* minFpsTimer;
#ifdef OPENGL_DEBUG_LOGGING
QOpenGLDebugLogger* glLogger;
#endif
}; };
#endif // _STELMAINGRAPHICSVIEW_HPP_ #endif // _STELMAINGRAPHICSVIEW_HPP_
 End of changes. 23 change blocks. 
63 lines changed or deleted 91 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/