StelAppGraphicsScene.hpp   StelAppGraphicsWidget.hpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2007 Fabien Chereau * Copyright (C) 2009 Fabien Chereau
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifndef _STELAPPGRAPHICSSCENE_HPP_ #ifndef _STELAPPGRAPHICSWIDGET_HPP_
#define _STELAPPGRAPHICSSCENE_HPP_ #define _STELAPPGRAPHICSWIDGET_HPP_
#include <QGraphicsScene> #include <QGraphicsWidget>
class QTimer; class StelViewportEffect;
//! A special QGraphicsScene for use in Stellarium. //! @class StelAppGraphicsWidget
//! It manages initialization of the program and redirects users inputs to //! A QGraphicsWidget encapsulating all the Stellarium main sky view and th
the core and GUI e embedded GUI widgets
class StelAppGraphicsScene : public QGraphicsScene //! such as the moving button bars.
//! It manages redirection of users inputs to the core and GUI.
class StelAppGraphicsWidget : public QGraphicsWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
StelAppGraphicsScene(); StelAppGraphicsWidget();
~StelAppGraphicsScene(); ~StelAppGraphicsWidget();
//! Get the StelMainWindow singleton instance. //! Initialize the StelAppGraphicsWidget.
//! @return the StelMainWindow singleton instance void init(class QSettings* conf);
static StelAppGraphicsScene& getInstance() {Q_ASSERT(singleton); ret
urn *singleton;}
//! Initialize the StelAppGraphicsScene
void init();
//! Start the display loop
void startMainLoop();
//! Define the type of viewport distorter to use
//! @param type can be only 'fisheye_to_spheric_mirror' or anything
else for no distorter
void setViewPortDistorterType(const QString& type);
//! Get the type of viewport distorter currently used
QString getViewPortDistorterType() const;
void glWindowHasBeenResized(int w, int h);
//! Get the state of the mouse cursor timeout flag
bool getFlagCursorTimeout() {return flagCursorTimeout;}
//! Get the mouse cursor timeout in seconds
float getCursorTimeout() const {return cursorTimeout;}
//! Get the state of the mouse cursor timeout flag
void setFlagCursorTimeout(bool b) {flagCursorTimeout=b;}
//! Set the mouse cursor timeout in seconds
void setCursorTimeout(float t) {cursorTimeout=t;}
public slots: //! Paint the main sky view and the embedded GUI widgets such as the
void minFpsChanged(); moving button bars.
//! This method is called automatically by the GraphicsView.
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem
* option, QWidget* widget=0);
//! Define the type of viewport effect to use
//! @param effectName must be one of 'none', 'framebufferOnly', 'sph
ericMirrorDistorter'
void setViewportEffect(const QString& effectName);
//! Get the type of viewport effect currently used
QString getViewportEffect() const;
protected: protected:
virtual void keyPressEvent(QKeyEvent* event); virtual void keyPressEvent(QKeyEvent* event);
virtual void keyReleaseEvent(QKeyEvent* event); virtual void keyReleaseEvent(QKeyEvent* event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent * wheelEvent); virtual void wheelEvent(QGraphicsSceneWheelEvent * wheelEvent);
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
//! Paint the whole Core of stellarium.
//! This method is called automatically by the GraphicsView
void drawBackground(QPainter *painter, const QRectF &rect);
private: private:
double previousPaintTime;
//! The time at the last time re refreshed the frame
//! Since paint may decide to stop before we finish to render a comp
lete scene, this is not necessarily the same
//! than `previousPaintTime`.
double previousPaintFrameTime;
//! The main application instance.
class StelApp* stelApp;
//! The state of paintPartial method
int paintState;
//! set to true to use buffers
bool useBuffers;
//! The framebuffer where we are currently drawing the scene
class QGLFramebufferObject* backgroundBuffer;
//! The framebuffer that we use while waiting for the drawing to be
done
class QGLFramebufferObject* foregroundBuffer;
//! Initialize the opengl buffer objects.
void initBuffers();
//! Swap the buffers
//! this should be called after we finish the paint
void swapBuffers();
//! Iterate through the drawing sequence.
bool paintPartial();
//! Notify that an event was handled by the program and therefore th StelViewportEffect* viewportEffect;
e void distortPos(QPointF* pos);
//! FPS should be maximized for a couple of seconds.
void thereWasAnEvent();
double previousTime;
double lastEventTimeSec;
// Main elements of the StelApp
class StelViewportDistorter *distorter;
// The StelAppGraphicsScene singleton
static StelAppGraphicsScene* singleton;
// Number of second before the mouse cursor disappears
float cursorTimeout;
bool flagCursorTimeout;
QTimer* minFpsTimer;
}; };
#endif // _STELAPPGRAPHICSSCENE_HPP_ #endif // _STELAPPGRAPHICSWIDGET_HPP_
 End of changes. 12 change blocks. 
64 lines changed or deleted 56 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/