Skip to content
Snippets Groups Projects
Select Git revision
  • c9b61fcefac2e621e385003fd36856fd33d3f388
  • master default protected
  • fix_Makefile.mingw#2
  • update_Makefile.mingw
  • fix_Makefile.mingw
  • fix_API_for_C_apps
  • fix_procinfo_mac
  • boinccmd_gpu_mode_always_until_sigterm
  • fgrp_osx_hotfix
  • fix_boinc_master@f8250782
  • eah_wrapper_improvements
  • diagnostics_win-hotfix
  • diagnostics_win-hotfix-old
  • current_fgrp_apps
  • testing_gw_apps
  • gw_app_darwin_15
  • current_brp_apps
  • current_brp_apps_android10
  • current_gfx_apps
  • current_server
  • current_gw_apps
  • previous_fgrp_apps
  • previous_gw_apps
  • testing_brp_apps
  • apps_FGRP3_1.07
  • apps_FGRP3_1.08
26 results

bmplib.h

Blame
  • 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);
        }
    }