Select Git revision
-
David Anderson authored
svn path=/trunk/boinc/; revision=4800
David Anderson authoredsvn path=/trunk/boinc/; revision=4800
pulsescopewidget.cpp 4.20 KiB
/******************************************************************************
* Copyright (C) 2009 by Oliver Bock *
* oliver.bock[AT]aei.mpg.de *
* *
* This file is part of PulsatingScience. *
* *
* PulsatingScience is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation, version 3 of the License. *
* *
* PulsatingScience is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with PulsatingScience. If not, see <http://www.gnu.org/licenses/>. *
* *
******************************************************************************/
#include "pulsescopewidget.h"
PulseScopeWidget::PulseScopeWidget(QWidget *parent) : QGraphicsView(parent),
m_scene()
{
setViewport(new QGLWidget(QGLFormat(QGL::AlphaChannel | QGL::SampleBuffers)));
QGLWidget *glScope = (QGLWidget*) viewport();
QString msgThis = tr("pulse profile");
if(!glScope->format().directRendering()) {
QString msg = tr("Sorry, no direct rendering support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!glScope->format().doubleBuffer()) {
QString msg = tr("Sorry, no double buffering support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!glScope->format().rgba()) {
QString msg = tr("Sorry, no RGBA support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!glScope->format().alpha()) {
QString msg = tr("Sorry, no alpha channel support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!glScope->format().sampleBuffers()) {
QString msg = tr("Sorry, no multisampling support for %1...");
qWarning() << msg.arg(msgThis);
}
m_scopeSizeH = 360.0 * PERIODS;
m_scopeSizeV = 10.0;
m_pathLHO = NULL;
m_pathLLO = NULL;
m_pathVirgo = NULL;
m_xAxis = m_scene.addLine(0.0, m_scopeSizeV/2.0, m_scopeSizeH, m_scopeSizeV/2.0, QPen(QColor("white")));
m_xAxis->setZValue(1);
m_yAxis = m_scene.addLine(0.0, 0.0, 0.0, m_scopeSizeV);
m_yAxis->setZValue(1);
setScene(&m_scene);
}
PulseScopeWidget::~PulseScopeWidget()
{
m_scene.clear();
}
void PulseScopeWidget::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
fitInView(m_scene.itemsBoundingRect(), Qt::IgnoreAspectRatio);
}
void PulseScopeWidget::plot(const PlotData& data)
{
QPainterPath pulsePathLHO(QPointF(0.0, m_scopeSizeV - data.m_dataLHO.at(0) - m_scopeSizeV/2.0));
QPainterPath pulsePathLLO(QPointF(0.0, m_scopeSizeV - data.m_dataLLO.at(0) - m_scopeSizeV/2.0));
QPainterPath pulsePathVirgo(QPointF(0.0, m_scopeSizeV - data.m_dataVirgo.at(0) - m_scopeSizeV/2.0));
for(int i = 1; i < m_scopeSizeH; ++i) {
pulsePathLHO.lineTo(i, m_scopeSizeV - data.m_dataLHO.at(i) - m_scopeSizeV/2.0);
pulsePathLLO.lineTo(i, m_scopeSizeV - data.m_dataLLO.at(i) - m_scopeSizeV/2.0);
pulsePathVirgo.lineTo(i, m_scopeSizeV - data.m_dataVirgo.at(i) - m_scopeSizeV/2.0);
}
if(m_pathLHO == NULL) {
m_pathLHO = m_scene.addPath(pulsePathLHO, QPen(data.m_colorLHO));
m_pathLLO = m_scene.addPath(pulsePathLLO, QPen(data.m_colorLLO));
m_pathVirgo = m_scene.addPath(pulsePathVirgo, QPen(data.m_colorVirgo));
}
else {
m_pathLHO->setPath(pulsePathLHO);
m_pathLLO->setPath(pulsePathLLO);
m_pathVirgo->setPath(pulsePathVirgo);
}
}