StelAppGraphicsWidget.cpp   StelAppGraphicsWidget.cpp 
skipping to change at line 20 skipping to change at line 20
* 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.
*/ */
#include <config.h>
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelAppGraphicsWidget.hpp" #include "StelAppGraphicsWidget.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelGuiBase.hpp" #include "StelGuiBase.hpp"
#include "StelViewportEffect.hpp" #include "StelViewportEffect.hpp"
#include <QPainter> #include <QPainter>
#include <QPaintEngine> #include <QPaintEngine>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGLFramebufferObject> #include <QGLFramebufferObject>
#include <QSettings> #include <QSettings>
StelAppGraphicsWidget::StelAppGraphicsWidget() StelAppGraphicsWidget::StelAppGraphicsWidget()
: paintState(0), useBuffers(false), backgroundBuffer(0), foregroundB uffer(0), viewportEffect(NULL) : paintState(0), useBuffers(false), backgroundBuffer(NULL), foregrou ndBuffer(NULL), viewportEffect(NULL)
{ {
previousPaintTime = StelApp::getTotalRunTime(); previousPaintTime = StelApp::getTotalRunTime();
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
stelApp = new StelApp(); stelApp = new StelApp();
} }
StelAppGraphicsWidget::~StelAppGraphicsWidget() StelAppGraphicsWidget::~StelAppGraphicsWidget()
{ {
delete stelApp; delete stelApp;
if (backgroundBuffer) stelApp = NULL;
delete backgroundBuffer; if (backgroundBuffer) delete backgroundBuffer;
if (foregroundBuffer) backgroundBuffer = NULL;
delete foregroundBuffer; if (foregroundBuffer) delete foregroundBuffer;
if (viewportEffect) foregroundBuffer = NULL;
delete viewportEffect; if (viewportEffect) delete viewportEffect;
viewportEffect = NULL;
StelApp::deinitStatic();
} }
void StelAppGraphicsWidget::init(QSettings* conf) void StelAppGraphicsWidget::init(QSettings* conf)
{ {
Q_ASSERT(viewportEffect==NULL); Q_ASSERT(viewportEffect==NULL);
setViewportEffect(conf->value("video/viewport_effect", "none").toStr ing()); setViewportEffect(conf->value("video/viewport_effect", "none").toStr ing());
stelApp->init(conf); stelApp->init(conf);
//previousPaintTime needs to be updated after the time zone is set
//in StelLocaleMgr::init(), otherwise this causes an invalid value o
f
//deltaT the first time it is calculated in paintPartial(), which in
//turn causes Stellarium to start with a wrong time.
previousPaintTime = StelApp::getTotalRunTime();
} }
void StelAppGraphicsWidget::setViewportEffect(const QString& name) void StelAppGraphicsWidget::setViewportEffect(const QString& name)
{ {
if (viewportEffect) if (viewportEffect)
{ {
if (viewportEffect->getName()==name) if (viewportEffect->getName()==name)
return; return;
delete viewportEffect; delete viewportEffect;
viewportEffect=NULL; viewportEffect=NULL;
skipping to change at line 149 skipping to change at line 156
if (stelApp->drawPartial()) if (stelApp->drawPartial())
return true; return true;
paintState = 0; paintState = 0;
return false; return false;
} }
Q_ASSERT(false); Q_ASSERT(false);
return false; return false;
} }
void StelAppGraphicsWidget::paint(QPainter* painter, const QStyleOptionGrap hicsItem* option, QWidget* widget) void StelAppGraphicsWidget::paint(QPainter* painter, const QStyleOptionGrap hicsItem*, QWidget*)
{ {
// Don't even try to draw if we don't have a core yet (fix a bug dur ing splash screen) // Don't even try to draw if we don't have a core yet (fix a bug dur ing splash screen)
if (!stelApp || !stelApp->getCore()) if (!stelApp || !stelApp->getCore())
return; return;
if (painter->paintEngine()->type() != QPaintEngine::OpenGL && painte
r->paintEngine()->type() != QPaintEngine::OpenGL2)
{
qWarning("StelAppGraphicsWidget: paint needs a QGLWidget to
be set as viewport on the graphics view");
return;
}
StelPainter::setQPainter(painter); StelPainter::setQPainter(painter);
if (useBuffers) if (useBuffers)
{ {
stelApp->makeMainGLContextCurrent(); StelPainter::makeMainGLContextCurrent();
initBuffers(); initBuffers();
backgroundBuffer->bind(); backgroundBuffer->bind();
QPainter* pa = new QPainter(backgroundBuffer); QPainter* pa = new QPainter(backgroundBuffer);
StelPainter::setQPainter(pa); StelPainter::setQPainter(pa);
// If we are using the gui, then we try to have the best rea ctivity, even if we need to lower the fps for that. // If we are using the gui, then we try to have the best rea ctivity, even if we need to lower the fps for that.
int minFps = StelApp::getInstance().getGui()->isCurrentlyUse d() ? 16 : 2; int minFps = StelApp::getInstance().getGui()->isCurrentlyUse d() ? 16 : 2;
while (true) while (true)
{ {
bool keep = paintPartial(); bool keep = paintPartial();
 End of changes. 7 change blocks. 
19 lines changed or deleted 19 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/