示例#1
0
void Nmr::plotSelectionChanged(bool tf)
{
   QCPGraph* graph(qobject_cast<QCPGraph*>(sender()));
   if (!graph) return;
   //qDebug() << "Plot selection changed called for" << graph->name();

   if (tf) {
      graph->setPen(m_selectPen);
      graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc));
   }else {
      graph->setPen(m_pen);
      graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle));
      return;
   }

   if (!tf) return;
   if (!m_ui->impulseButton->isChecked()) return;

   bool ok;
   int sig(graph->name().toInt(&ok));
   if (!ok) return;

   QList<int> rows(m_graphToRows.value(sig));

   QTableWidget* table(m_ui->shieldingsTable);
   QItemSelectionModel *selectionModel(table->selectionModel());
   selectionModel->clearSelection();
   QItemSelection itemSelection;

   for (int i = 0; i < rows.size(); ++i) {
       table->selectRow(rows[i]);
       itemSelection.merge(selectionModel->selection(), QItemSelectionModel::Select);
   }
   selectionModel->select(itemSelection, QItemSelectionModel::Select);
}
示例#2
0
Plotter::Plotter(QWidget *parent) 
    : QCustomPlot(parent)
{
    //    this->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
    
    this->mMarkerSize = 5;
    
    this->setLocale(QLocale(QLocale::English, QLocale::UnitedStates));
    
    // Graph for Lineplots
    this->addGraph();
    this->graph(0)->setPen(QColor(6, 48, 200, 255));
    
    // Graph to visualize current Position i.e. Timepoint as Line
    this->addGraph(this->xAxis, this->yAxis);
    this->graph(1)->setPen(QColor(255, 0, 51, 255));
    
    // Graph for Marker
    this->addGraph(this->xAxis, this->yAxis);
    this->graph(2)->setPen(QColor(6, 48, 200, 255));
    this->graph(2)->setLineStyle(QCPGraph::lsNone);
    this->graph(2)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, this->mMarkerSize));
    
    // Graph to visualize current Position in Markerplot
    this->addGraph(this->xAxis, this->yAxis);
    this->graph(3)->setPen(QColor(255, 0, 51, 255));
    this->graph(3)->setLineStyle(QCPGraph::lsNone);
    this->graph(3)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, this->mMarkerSize));
}
void Frequencies::plotSelectionChanged(bool tf)
{
//qDebug() << "Plot selection changed called";
   QCPGraph* graph(qobject_cast<QCPGraph*>(sender()));
   if (!graph) return;

   if (tf) {
      graph->setPen(m_selectPen);
      graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc));
   }else {
      graph->setPen(m_pen);
      graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle));
      return;
   }

   if (!tf) return;
   if (!m_configurator.impulseButton->isChecked()) return;

   bool ok;
   int mode(graph->name().toInt(&ok));
   if (!ok) return;

   QTableWidget* table(m_configurator.frequencyTable);
   table->setCurrentCell(mode, 0, QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect);
   table->scrollToItem(table->item(mode,0));
   on_frequencyTable_itemSelectionChanged();
}
void ExcitedStates::plotSelectionChanged(bool tf)
{      
   QCPGraph* graph(qobject_cast<QCPGraph*>(sender()));
   if (!graph) return;
       
   if (tf) {
      graph->setPen(m_selectedPen);
      graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc));
   }else {
      graph->setPen(m_pen);
      graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle));
      return;
   }

   if (!tf) return;
   if (!m_configurator.impulseButton->isChecked()) return;

   bool ok;
   int row(graph->name().toInt(&ok));
   if (!ok) return;

   QTableWidget* table(m_configurator.energyTable);
   table->setCurrentCell(row, 0, 
      QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect);
   table->scrollToItem(table->item(row,0));
   updateMoPlot(row);
}
void CustomPlotRegression::setupQuadraticDemo(double * kernely,
                                              int size_kernely,
                                              double * kernelx,
                                              int size_kernelx  )
{
    QCustomPlot* customPlot=m_CustomPlot;
    // make top right axes clones of bottom left axes:

    // generate some data:
    QVector<double> x1( 0 ), y1( 0 );   // initialize with entries 0..100
    customPlot->addGraph();
    customPlot->graph( 0 )->setPen( QPen( Qt::red ) );
    //customPlot->graph( 0 )->setSelectedPen( QPen( Qt::blue, 2 ) );
    //    customPlot->graph( 0 )->setData( x1, y1 );
    QVector<double> x;
    QVector<double> y;
    //std::cout << "****************************************************************+++" <<endl;
    double maxx= DBL_MIN;
    double maxy= DBL_MIN;
    for (int i = 0; i < size_kernelx; i++) {
        //        std::cout << kernel[i] << endl;
        x.push_back(kernelx[i]);
        y.push_back(kernely[i]);
        if(kernelx[i] > maxx){
            maxx=kernelx[i];
        }
        if(kernely[i] > maxy){
            maxy=kernely[i];
        }
    }
    m_CustomPlot->graph( 0 )->setData( x, y);
    //    std::cout << "ok" << endl;
    customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 10));

    customPlot->addGraph();
    customPlot->graph( 1 )->setPen( QPen( Qt::green ) );
    //customPlot->graph( 1 )->setSelectedPen( QPen( Qt::blue, 2 ) );
    //    customPlot->graph( 1 )->setData( x1, y1 );
    customPlot->graph(1)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 10));

    // give the axes some labels:
    customPlot->xAxis->setLabel( "Generation" );
    customPlot->yAxis->setLabel( "Fitness" );
    // set axes ranges, so we see all data:

    customPlot->xAxis->setRange( 0, maxx );
    customPlot->yAxis->setRange( 0, maxy);

    customPlot ->setInteractions( QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables );
    connect( customPlot, SIGNAL( plottableClick( QCPAbstractPlottable*, QMouseEvent* ) ), this, SLOT( graphClicked( QCPAbstractPlottable* ) ) );
    for (int i = 0; i < number_of_function; ++i) {
            customPlot->addGraph();
    }


}
示例#6
0
void MainWindow::makePlot()
{
//    demoName = "Scatter Style Demo";
    ui->customPlot->legend->setVisible(false);
    ui->customPlot->legend->setFont(QFont("Helvetica", 9));
    ui->customPlot->legend->setRowSpacing(-2);
    QVector<QCPScatterStyle::ScatterShape> shapes;

    shapes << QCPScatterStyle::ssDisc;

    QPen pen;
    // add graphs with different scatter styles:
    for (int i=0; i<shapes.size(); ++i)
    {
        ui->customPlot->addGraph();
        pen.setColor(QColor(Qt::blue));
        // generate data:
        QVector<double> x(10), y(10);
        for (int k=0; k<10; ++k)
        {
            x[k] = k/10.0 * 4*3.14 + 0.01;
            y[k] = 7*qSin(x[k])/x[k] + (shapes.size()-i)*5;
        }
        ui->customPlot->graph()->setData(x, y);
        ui->customPlot->graph()->rescaleAxes(true);
        ui->customPlot->graph()->setPen(pen);
        ui->customPlot->graph()->setName(QCPScatterStyle::staticMetaObject.enumerator(QCPScatterStyle::staticMetaObject.indexOfEnumerator("ScatterShape")).valueToKey(shapes.at(i)));
//      ui->customPlot->graph()->setLineStyle(QCPGraph::lsLine);
        // set scatter style:
        if (shapes.at(i) != QCPScatterStyle::ssCustom)
        {
            ui->customPlot->graph()->setScatterStyle(QCPScatterStyle(shapes.at(i), 10));
        }
        else
        {
            QPainterPath customScatterPath;
            for (int i=0; i<3; ++i)
                customScatterPath.cubicTo(qCos(2*M_PI*i/3.0)*9, qSin(2*M_PI*i/3.0)*9, qCos(2*M_PI*(i+0.9)/3.0)*9, qSin(2*M_PI*(i+0.9)/3.0)*9, 0, 0);
            ui->customPlot->graph()->setScatterStyle(QCPScatterStyle(customScatterPath, QPen(Qt::red, 0), QColor(40, 70, 255, 50), 10));
        }
   }
    // set blank axis lines:
    ui->customPlot->rescaleAxes();
    ui->customPlot->xAxis->setTicks(true);
    ui->customPlot->yAxis->setTicks(true);
    ui->customPlot->xAxis->setTickLabels(true);
    ui->customPlot->yAxis->setTickLabels(true);
    // make top right axes clones of bottom left axes:
    ui->customPlot->axisRect()->setupFullAxesBox();
}
void Frequencies::plotImpulse(double const scaleFactor)
{
   QVector<double> x(1), y(1);
   double maxIntensity;

   if (m_configurator.ramanCheckbox->isChecked()) {
      maxIntensity = (m_frequencies.maxRamanIntensity());
   } else {
      maxIntensity = (m_frequencies.maxIntensity());
   }

   for (int mode = 0; mode < m_rawData.size(); ++mode) {
       x[0] = scaleFactor * m_rawData[mode].first;
       y[0] = m_rawData[mode].second;

       QCPGraph* graph(m_customPlot->addGraph());
       graph->setData(x, y);
       graph->setName(QString::number(mode));
       graph->setLineStyle(QCPGraph::lsImpulse);
       graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle));
       graph->setPen(m_pen);
       graph->setSelectedPen(m_selectPen);
       connect(graph, SIGNAL(selectionChanged(bool)), this, SLOT(plotSelectionChanged(bool)));
   }

   m_customPlot->xAxis->setRange(0, 4000);
   m_customPlot->yAxis->setRange(-0.00*maxIntensity, 1.05*maxIntensity);
   m_customPlot->yAxis->setAutoTickStep(true);
}
void CCvProject::initPlot()
{
    // give the axes some labels:
    customPlot->xAxis->setLabel("U [V]");
    customPlot->yAxis->setLabel("I [A]");

    // create Curve and assign data to it:
    customCurve = new QCPCurve(customPlot->xAxis, customPlot->yAxis);
    customPlot->addPlottable(customCurve);
    customCurve->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle));
    customCurve->setName("CV measure");

    /*customPlot->addGraph();
    customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle));
    customPlot->graph(0)->setName("CV measure");*/

    m_upperXRange = 2; // voltage
    m_lowerXRange = -2;
    m_upperYRange = 0.01; // current
    m_lowerYRange = -0.01;

    m_tickStepX = 0.15;
    m_tickStepY = 0.0001;

    customPlot->xAxis->setTickStep(m_tickStepX);
    customPlot->yAxis->setTickStep(m_tickStepY);
    customPlot->xAxis->setRange(m_lowerXRange, m_upperXRange);
    customPlot->yAxis->setRange(m_lowerYRange, m_upperYRange);

    customPlot->replot();
}
示例#9
0
void MainWindow::genScatterStyles()
{
  resetPlot();
  // Different scatter styles in separate images:
  customPlot->xAxis->setRange(-1, 1);
  customPlot->yAxis->setRange(-1, 1);
  customPlot->addGraph();
  customPlot->graph()->addData(0, 0);
  customPlot->graph()->setPen(QPen(Qt::black));
  customPlot->setBackground(Qt::transparent);
  QMap<QCPScatterStyle::ScatterShape, QString> scatterShapes;
  scatterShapes.insert(QCPScatterStyle::ssDot, "ssDot");
  scatterShapes.insert(QCPScatterStyle::ssCross, "ssCross");
  scatterShapes.insert(QCPScatterStyle::ssPlus, "ssPlus");
  scatterShapes.insert(QCPScatterStyle::ssCircle, "ssCircle");
  scatterShapes.insert(QCPScatterStyle::ssDisc, "ssDisc");
  scatterShapes.insert(QCPScatterStyle::ssSquare, "ssSquare");
  scatterShapes.insert(QCPScatterStyle::ssDiamond, "ssDiamond");
  scatterShapes.insert(QCPScatterStyle::ssStar, "ssStar");
  scatterShapes.insert(QCPScatterStyle::ssTriangle, "ssTriangle");
  scatterShapes.insert(QCPScatterStyle::ssTriangleInverted, "ssTriangleInverted");
  scatterShapes.insert(QCPScatterStyle::ssCrossSquare, "ssCrossSquare");
  scatterShapes.insert(QCPScatterStyle::ssPlusSquare, "ssPlusSquare");
  scatterShapes.insert(QCPScatterStyle::ssCrossCircle, "ssCrossCircle");
  scatterShapes.insert(QCPScatterStyle::ssPlusCircle, "ssPlusCircle");
  scatterShapes.insert(QCPScatterStyle::ssPeace, "ssPeace");
  QMapIterator<QCPScatterStyle::ScatterShape, QString> scatterIt(scatterShapes);
  while (scatterIt.hasNext())
  {
    scatterIt.next();
    customPlot->graph()->setScatterStyle(QCPScatterStyle(scatterIt.key(), 8.5));
    QPixmap pm = customPlot->toPixmap(16, 16);
    pm.save(dir.filePath(scatterIt.value()+".png"));
  }
}
示例#10
0
void LeastSquare::PlotQuadr(QCustomPlot *customPlot)
{
    QString label1 = ui->XLabel->text();
    QString label2 = ui->YLabel->text();
    QString size_point = ui->size_point->text();
    if (size_point.isEmpty())
    {
        size_point = "8";
    }

    customPlot->addGraph();
    customPlot->graph(0)->setPen(QPen(Qt::black));
    customPlot->graph(0)->setLineStyle(QCPGraph::lsNone);
    customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, size_point.toInt()));
    customPlot->graph(0)->setData(x_values, y_values);

    customPlot->addGraph();
    customPlot->graph(1)->setPen(QPen(Qt::cyan));
    customPlot->graph(1)->setLineStyle(QCPGraph::lsLine);
    customPlot->graph(1)->setData(x_values, y_apprx);

    customPlot->xAxis2->setVisible(true);
    customPlot->xAxis2->setTickLabels(false);
    customPlot->yAxis2->setVisible(true);
    customPlot->yAxis2->setTickLabels(false);
    connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis2, SLOT(setRange(QCPRange)));
    connect(customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->yAxis2, SLOT(setRange(QCPRange)));
    customPlot->xAxis->setLabel(label1);
    customPlot->yAxis->setLabel(label2);
    customPlot->graph(0)->rescaleAxes();
    customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
}
CustomView::CustomView(QWidget *parent) :
    QCustomPlot(parent)
{    
    this->addGraph();
    this->graph(0)->setPen(QColor(50, 50, 50, 255));
    this->graph(0)->setLineStyle(QCPGraph::lsNone);
    this->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 4));


    ellipse = new QCPItemEllipse(this);
    ellipse->setPen(QColor(255, 0, 0, 255));
    ellipse->setBrush(QBrush(QColor(255, 0, 0, 32)));
    this->addItem(ellipse);

    ellipseLM = new QCPItemEllipse(this);
    ellipseLM->setPen(QColor(255, 0, 0, 255));
    ellipseLM->setBrush(QBrush(QColor(0, 255, 0, 64)));
    this->addItem(ellipseLM);

    xAxisType = SPEED;
    yAxisType = VELOCITY;
    colorization = NONE;

    updateDiagram();
}
示例#12
0
DialogColor::DialogColor(QWidget *parent) :
    QDialog(parent),
    ui_color(new Ui::DialogColor)
{
    ui_color->setupUi(this);
    connect(ui_color->backgroundColor, SIGNAL(clicked()),this, SLOT(setBackgroundColor()));
    connect(ui_color->lineColor, SIGNAL(clicked()),this, SLOT(setLineColor()));
    connect(ui_color->set, SIGNAL(clicked()),this, SLOT(dialogColorSet()));
    connect(ui_color->cancel, SIGNAL(clicked()),this,SLOT(dialogColorCancel()));
    conf = new QSettings(QSettings::NativeFormat, QSettings::UserScope, "AE_analysis", "CMiR");
    _backgroundColor = conf->value("color/backgroundColor").value<QColor>();
    _lineColor = conf->value("color/lineColor").value<QColor>();
    ui_color->widget->setBackground(_backgroundColor);
    ui_color->widget->xAxis->setVisible(false);
    ui_color->widget->yAxis->setVisible(false);
    ui_color->widget->axisRect()->setAutoMargins(QCP::msNone);
    ui_color->widget->axisRect()->setMargins(QMargins(0,0,0,0));
    QVector <double> x(100), y(100);
    for (int i=0; i<100; i++)
    {
        x[i]=rand()%100;
        y[i]=rand()%100;
    }
    ui_color->widget->addGraph();
    ui_color->widget->graph(0)->setLineStyle(QCPGraph::lsNone);
    ui_color->widget->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2));
    ui_color->widget->graph(0)->setData(x,y);
    ui_color->widget->graph(0)->setPen(_lineColor);
    ui_color->widget->xAxis->setRange(0, 100);
    ui_color->widget->yAxis->setRange(0, 100);
    ui_color->widget->replot();
}
示例#13
0
// -------------------------------------------------------------------------------------------------------------------
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    wiiThread = new WiiThread();

    mesures = new QVector<QPointF>();

    connect(wiiThread, &WiiThread::connected,    this, &MainWindow::connected);
    connect(wiiThread, &WiiThread::disconnected, this, &MainWindow::disconnected);
    connect(wiiThread, &WiiThread::gotEvent, this, &MainWindow::gotEvent);

    xmin=100.0;
    xmax=-100.0;

    ymin=100.0;
    ymax=-100.0;

    ui->XY->xAxis->setRange(-25.0,  25.0);
    ui->XY->yAxis->setRange(-25.0,  25.0);
    ui->XY->addGraph();
    ui->XY->graph(0)->setLineStyle(QCPGraph::lsNone);
    ui->XY->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 4));

    ui->XY->addGraph();
    ui->XY->graph(1)->setPen(QPen(Qt::red));
    ui->XY->graph(1)->setLineStyle(QCPGraph::lsNone);
    ui->XY->graph(1)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 10));

    circle = new QCPCurve(ui->XY->xAxis, ui->XY->yAxis);
    circle->setPen(QPen(Qt::black));
    ui->XY->addPlottable(circle);

    QTimer *timer0 = new QTimer(this);
    connect(timer0, SIGNAL(timeout()), this, SLOT(displayRate()));

    nb_evt = 0;
    before = new QDateTime(QDateTime::currentDateTime());

    timer0->start(1000);

}
示例#14
0
void dialog_inputs::setupPlot()
{
    ui->plot_hydro->addGraph();
    ui->plot_hydro->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));
    ui->plot_hydro->graph(0)->setLineStyle(QCPGraph::lsLine);
    ui->plot_hydro->graph(0)->setPen(QPen(Qt::blue));

    ui->plot_hydro->yAxis->setLabel("Discarge (cms)");
    ui->plot_hydro->xAxis->setLabel("Date");
}
示例#15
0
void ScatterWidget::setData(const std::vector<PointD> &data, string legend)
{
    QCPGraph *graph = NULL;
    int nG = ui->scatter->graphCount();
    for(int i=0; i<nG; i++)
    {
        if(ui->scatter->graph(i)->name() == QString::fromStdString(legend))
        {
            graph = ui->scatter->graph(i);
            break;
        }
    }

    if(!graph)
    {
        graph = ui->scatter->addGraph();
        // ----------------------- Scatter Configuration ---------------------------
        graph->setName(QString::fromStdString(legend));
        QColor color_ = colorManager.getNewDifferentColor();
        graph->setPen(QPen(color_));
        graph->setLineStyle(QCPGraph::lsNone);
        graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssPlusCircle, 4));
        ui->scatter->legend->setVisible(true);
    }

    double min_x =  INFINITY, min_y =  INFINITY;
    double max_x = -INFINITY, max_y = -INFINITY;

    QVector<QCPGraphData> q_data(data.size());
    for(unsigned int i=0; i<data.size(); i++)
    {
        q_data[i] = QCPGraphData(data[i].x, data[i].y);

        if(ui->recButton->isChecked())
        {
            vector<double> vec2_double(2);
            vec2_double[0] = data[i].x;
            vec2_double[1] = data[i].y;
            vector<string> vec2_string(2);
            vec2_string[0] = legend + "_x";
            vec2_string[1] = legend + "_y";
            logger.addLogCsv(graph->dataCount(), vec2_string, vec2_double);
        }

        max_x = qMax(data[i].x, ui->scatter->xAxis->range().upper);
        min_x = qMin(data[i].x, ui->scatter->xAxis->range().lower);
        max_y = qMax(data[i].y, ui->scatter->yAxis->range().upper);
        min_y = qMin(data[i].y, ui->scatter->yAxis->range().lower);
    }

    graph->data()->set(q_data);
    ui->scatter->xAxis->setRange(min_x, max_x);
    ui->scatter->yAxis->setRange(min_y, max_y);
    ui->scatter->replot();
}
示例#16
0
void GraphLegend::plot(QCPScatterStyle::ScatterShape style, QColor couleur, int size, int epaisseur, bool antiAliased)
{
    this->graph(0)->setScatterStyle(QCPScatterStyle(style, size));
    this->graph(0)->setAntialiasedScatters(antiAliased);
    QPen pen;
    pen.setColor(couleur);
    pen.setWidth(epaisseur);
    this->graph(0)->setPen(pen);

    this->replot();
}
示例#17
0
void MainWindow::addCurve(QCustomPlot *customPlot,int i){

        QColor color;
        color.setRgb(rand()%255, rand()%255, rand()%255);
        customPlot->addGraph();
        customPlot->graph(i)->setPen(QPen(color));
        customPlot->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));
        QString name = QString("DeviceID: %1").arg(dev_id[i]);
        customPlot->graph(i)->setName(name);

}
示例#18
0
void ScatterWidget::addPacket(const ScatterPacket &packet)
{
    QCPGraph *graph = NULL;
    int nG = ui->scatter->graphCount();
    for(int i=0; i<nG; i++)
    {
        if(ui->scatter->graph(i)->name() == QString::fromStdString(packet.legend))
        {
            graph = ui->scatter->graph(i);
            break;
        }
    }

    if(!graph)
    {
        graph = ui->scatter->addGraph();
        // ----------------------- Scatter Configuration ---------------------------
        graph->setName(QString::fromStdString(packet.legend));
        QColor color_ = colorManager.getNewDifferentColor();
        graph->setPen(QPen(color_));
        graph->setLineStyle(QCPGraph::lsNone);
        graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssPlusCircle, 4));
        ui->scatter->legend->setVisible(true);
    }

    graph->addData(packet.point.x, packet.point.y);
    //if(packet.point.x > ui->scatter->xAxis->max)

    double max_x = qMax(packet.point.x, ui->scatter->xAxis->range().upper);
    double min_x = qMin(packet.point.x, ui->scatter->xAxis->range().lower);
    double max_y = qMax(packet.point.y, ui->scatter->yAxis->range().upper);
    double min_y = qMin(packet.point.y, ui->scatter->yAxis->range().lower);

    ui->scatter->xAxis->setRange(min_x, max_x);
    ui->scatter->yAxis->setRange(min_y, max_y);

    if(realTimePlot)
        ui->scatter->replot();
    else
        ui->scatter->replot(QCustomPlot::rpQueuedReplot);

    if(ui->recButton->isChecked())
    {
        vector<double> vec2_double(2);
        vec2_double[0] = packet.point.x;
        vec2_double[1] = packet.point.y;
        vector<string> vec2_string(2);
        vec2_string[0] = packet.legend + "_x";
        vec2_string[1] = packet.legend + "_y";
        logger.addLogCsv(graph->dataCount(), vec2_string, vec2_double);
    }
}
示例#19
0
	QCPGraph* SensorDashboard::createGraph(const QString& name, const QColor& color)
	{
		QPen pen;
		pen.setBrush(color);

		QCPGraph *graph = mPlot->addGraph();
		graph->setName(name);
		graph->setLineStyle(QCPGraph::lsLine);
		graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone));
		graph->setPen(pen);

		return graph;
	}
示例#20
0
void MainWindow::grafica(QVector<double> x,QVector<double> y){

    // create graph and assign data to it:
    ui->grafico1->addGraph();
    ui->grafico1->graph(0)->setData(x,y);
    ui->grafico1->setInteractions(QCP::iRangeDrag|QCP::iRangeZoom);
    ui->grafico1->graph(0)->setLineStyle(QCPGraph::lsImpulse);
    ui->grafico1->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle,Qt::blue,Qt::white,3));
    // give the axes some labels:
    //ui->grafico1->xAxis->setLabel("tiempo");
    //ui->grafico1->yAxis->setLabel("amplitud");
    ui->grafico1->graph(0)->rescaleAxes();
    ui->grafico1->replot();

}
示例#21
0
void TCPStreamDialog::fillTcptrace()
{
    QString dlg_title = QString(tr("Sequence Numbers (tcptrace)")) + streamDescription();
    setWindowTitle(dlg_title);
    title_->setText(dlg_title);

    QCustomPlot *sp = ui->streamPlot;
    sp->yAxis->setLabel(sequence_number_label_);

    base_graph_->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDot));

    seg_graph_->setVisible(true);
    ack_graph_->setVisible(true);
    rwin_graph_->setVisible(true);

    QVector<double> seq_time, seq, sb_time, sb_center, sb_span, ackrwin_time, ack, rwin;
    for (struct segment *seg = graph_.segments; seg != NULL; seg = seg->next) {
        double ts = (seg->rel_secs + seg->rel_usecs / 1000000.0) - ts_offset_;
        if (compareHeaders(seg)) {
            // Forward direction: seq + data
            seq_time.append(ts);
            seq.append(seg->th_seq - seq_offset_);

            // QCP doesn't have a segment graph type. For now, fake
            // it with error bars.
            if (seg->th_seglen > 0) {
                double half = seg->th_seglen / 2.0;
                sb_time.append(ts);
                sb_center.append(seg->th_seq - seq_offset_ + half);
                sb_span.append(half);
            }
        } else {
            // Reverse direction: ACK + RWIN
            if (! (seg->th_flags & TH_ACK)) {
                // SYNs and RSTs do not necessarily have ACKs
                continue;
            }
            double ackno = seg->th_ack - seq_offset_;
            ackrwin_time.append(ts);
            ack.append(ackno);
            rwin.append(ackno + seg->th_win);
        }
    }
    base_graph_->setData(seq_time, seq);
    seg_graph_->setDataValueError(sb_time, sb_center, sb_span);
    ack_graph_->setData(ackrwin_time, ack);
    rwin_graph_->setData(ackrwin_time, rwin);
}
示例#22
0
/*!
  Constructs a curve which uses \a keyAxis as its key axis ("x") and \a valueAxis as its value
  axis ("y"). \a keyAxis and \a valueAxis must reside in the same QCustomPlot instance and not have
  the same orientation. If either of these restrictions is violated, a corresponding message is
  printed to the debug output (qDebug), the construction is not aborted, though.
  
  The constructed QCPCurve can be added to the plot with QCustomPlot::addPlottable, QCustomPlot
  then takes ownership of the graph.
*/
QCPCurve::QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis) :
  QCPAbstractPlottable(keyAxis, valueAxis)
{
  mData = new QCPCurveDataMap;
  mPen.setColor(Qt::blue);
  mPen.setStyle(Qt::SolidLine);
  mBrush.setColor(Qt::blue);
  mBrush.setStyle(Qt::NoBrush);
  mSelectedPen = mPen;
  mSelectedPen.setWidthF(2.5);
  mSelectedPen.setColor(QColor(80, 80, 255)); // lighter than Qt::blue of mPen
  mSelectedBrush = mBrush;
  
  setScatterStyle(QCPScatterStyle());
  setLineStyle(lsLine);
}
示例#23
0
void MainWindow::DrawInterpolationLines()
{
    ui->customplot->addGraph();
    ui->customplot->graph(1)->setName("inter. f(x) #1");
    ui->customplot->graph(1)->setPen(QPen(Qt::red));
    ui->customplot->graph(1)->setData(inter.calculated_datasets[0].x,
            inter.calculated_datasets[0].y);
    ui->customplot->addGraph();
    ui->customplot->graph(2)->setPen(QPen(Qt::red));
    ui->customplot->graph(2)->setData(inter.source_datasets[0].x,
            inter.source_datasets[0].y);
    ui->customplot->graph(2)->setLineStyle(QCPGraph::LineStyle::lsNone);
    ui->customplot->graph(2)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 5));

    this->viewLegend();
}
MissionElevationDisplay::MissionElevationDisplay(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MissionElevationDisplay),
    m_uasInterface(NULL),
    m_uasWaypointMgr(NULL),
    m_totalDistance(0),
    m_elevationData(NULL),
    m_useHomeAltOffset(false),
    m_homeAltOffset(0.0),
    m_elevationShown(false)
{
    ui->setupUi(this);

    ui->sampleSpinBox->setEnabled(false);

    QCustomPlot* customPlot = ui->customPlot;
    customPlot->addGraph(); // Mission Elevation Graph (ElevationGraphMissionId)
    customPlot->graph(ElevationGraphMissionId)->setPen(QPen(Qt::blue)); // line color blue for mission data
    customPlot->graph(ElevationGraphMissionId)->setBrush(QBrush(QColor(0, 0, 255, 20))); // first graph will be filled with translucent blue

    customPlot->addGraph(); // Google Elevation Graph (ElevationGraphElevationId)
    customPlot->graph(ElevationGraphElevationId)->setPen(QPen(Qt::red)); // line color red for elevation data
    customPlot->graph(ElevationGraphElevationId)->setBrush(QBrush(QColor(255, 0, 0, 20))); // first graph will be filled with translucent blue
    customPlot->graph(ElevationGraphElevationId)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDiamond, 10));
    customPlot->xAxis->setLabel("distance (m)");
    customPlot->yAxis->setLabel("altitude (m)");
    // set default ranges for Alt and distance
    customPlot->xAxis->setRange(0,ElevationDefaultDistanceMax); //m
    customPlot->yAxis->setRange(ElevationDefaultAltMin,ElevationDefaultAltMax); //m

    QFont legendFont = font();
    legendFont.setPointSize(9);
    customPlot->legend->setFont(legendFont);

    // set a more compact font size for bottom and left axis tick labels:
    customPlot->xAxis->setTickLabelFont(QFont(QFont().family(), 9));
    customPlot->xAxis->setLabelFont(QFont(QFont().family(), 9));
    customPlot->yAxis->setTickLabelFont(QFont(QFont().family(), 9));
    customPlot->yAxis->setLabelFont(QFont(QFont().family(), 9));

    customPlot->replot();

    connect(UASManager::instance(),SIGNAL(activeUASSet(UASInterface*)),this,SLOT(activeUASSet(UASInterface*)));
    activeUASSet(UASManager::instance()->getActiveUAS());

    connect(ui->infoButton, SIGNAL(clicked()), this, SLOT(showInfoBox()));
}
示例#25
0
void MathPlot::setupScatterPixmapDemo(QCustomPlot *customPlot)
{

  customPlot->axisRect()->setBackground(QPixmap("./solarpanels.jpg"));
  customPlot->addGraph();
  customPlot->graph()->setLineStyle(QCPGraph::lsLine);
  QPen pen;
  pen.setColor(QColor(255, 200, 20, 200));
  pen.setStyle(Qt::DashLine);
  pen.setWidthF(2.5);
  customPlot->graph()->setPen(pen);
  customPlot->graph()->setBrush(QBrush(QColor(255,200,20,70)));
  customPlot->graph()->setScatterStyle(QCPScatterStyle(QPixmap("./sun.png")));
  // set graph name, will show up in legend next to icon:
  customPlot->graph()->setName("Data from Photovoltaic\nenergy barometer 2011");
  // set data:
  QVector<double> year, value;
  year  << 2005 << 2006 << 2007 << 2008  << 2009  << 2010;
  value << 2.17 << 3.42 << 4.94 << 10.38 << 15.86 << 29.33;
  customPlot->graph()->setData(year, value);

  // set title of plot:
  customPlot->plotLayout()->insertRow(0);
  customPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(customPlot, "Regenerative Energies"));
  // set a fixed tick-step to one tick per year value:
  customPlot->xAxis->setAutoTickStep(false);
  customPlot->xAxis->setTickStep(1);
  customPlot->xAxis->setSubTickCount(3);
  // other axis configurations:
  customPlot->xAxis->setLabel("Year");
  customPlot->yAxis->setLabel("Installed Gigawatts of\nphotovoltaic in the European Union");
  customPlot->xAxis2->setVisible(true);
  customPlot->yAxis2->setVisible(true);
  customPlot->xAxis2->setTickLabels(false);
  customPlot->yAxis2->setTickLabels(false);
  customPlot->xAxis2->setTicks(false);
  customPlot->yAxis2->setTicks(false);
  customPlot->xAxis2->setSubTickCount(0);
  customPlot->yAxis2->setSubTickCount(0);
  customPlot->xAxis->setRange(2004.5, 2010.5);
  customPlot->yAxis->setRange(0, 30);
  // setup legend:
  customPlot->legend->setFont(QFont(font().family(), 7));
  customPlot->legend->setIconSize(50, 20);
  customPlot->legend->setVisible(true);
}
示例#26
0
/**
 * @brief WidgetCompLineChart::drawYear2 draw year for the second measure
 * @param sel the index of the year to draw
 * @param offset the offset in the list of graphs
 */
void WidgetCompLineChart::drawYear2(const int &sel,const int &offset)
{
    QList<QListWidgetItem*> tempList = ui->listLineChartMunicipality_4->selectedItems();
    int i = 0;
    for(QList<QListWidgetItem*>::Iterator it = tempList.begin(); it != tempList.end(); ++it) {
        QListWidgetItem *tempItem = *it;
        Municipality tempMuni = _meas2->findMuni(tempItem->text());
        try {
            ui->widgetCompLineChart_2->graph(i+offset)->addData(_ylist->at(sel).toInt(),tempMuni.getYear(_meas2->yearRange().at(sel)).value());
            ui->widgetCompLineChart_2->graph(i+offset)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle) );
        } catch(std::string s) {
        }
        ui->widgetCompLineChart_2->graph(i+offset)->setName(tempMuni.name()+ ":" + _meas2->id());
        ++i;
    }

}
示例#27
0
MagCal::MagCal(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MagCal)
{
    ui->setupUi(this);
    layout()->setContentsMargins(0, 0, 0, 0);

    ui->magSampXyPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
    ui->magSampXzPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
    ui->magSampYzPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);

    ui->magSampXyPlot->yAxis->setLabel("XY");
    ui->magSampXyPlot->addGraph();
    ui->magSampXyPlot->graph()->setPen(QPen(Qt::red));
    ui->magSampXyPlot->graph()->setName("Uncompensated");
    ui->magSampXyPlot->graph()->setLineStyle(QCPGraph::lsNone);
    ui->magSampXyPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCross, 4));
    ui->magSampXyPlot->addGraph();
    ui->magSampXyPlot->graph()->setPen(QPen(Qt::blue));
    ui->magSampXyPlot->graph()->setName("Compensated");
    ui->magSampXyPlot->graph()->setLineStyle(QCPGraph::lsNone);
    ui->magSampXyPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCross, 4));

    ui->magSampXzPlot->yAxis->setLabel("XZ");
    ui->magSampXzPlot->addGraph();
    ui->magSampXzPlot->graph()->setPen(QPen(Qt::red));
    ui->magSampXzPlot->graph()->setName("Uncompensated");
    ui->magSampXzPlot->graph()->setLineStyle(QCPGraph::lsNone);
    ui->magSampXzPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCross, 4));
    ui->magSampXzPlot->addGraph();
    ui->magSampXzPlot->graph()->setPen(QPen(Qt::blue));
    ui->magSampXzPlot->graph()->setName("Compensated");
    ui->magSampXzPlot->graph()->setLineStyle(QCPGraph::lsNone);
    ui->magSampXzPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCross, 4));

    ui->magSampYzPlot->yAxis->setLabel("YZ");
    ui->magSampYzPlot->addGraph();
    ui->magSampYzPlot->graph()->setPen(QPen(Qt::red));
    ui->magSampYzPlot->graph()->setName("Uncompensated");
    ui->magSampYzPlot->graph()->setLineStyle(QCPGraph::lsNone);
    ui->magSampYzPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCross, 4));
    ui->magSampYzPlot->addGraph();
    ui->magSampYzPlot->graph()->setPen(QPen(Qt::blue));
    ui->magSampYzPlot->graph()->setName("Compensated");
    ui->magSampYzPlot->graph()->setLineStyle(QCPGraph::lsNone);
    ui->magSampYzPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCross, 4));

    mTimer = new QTimer(this);
    mTimer->start(20);
    mMagReplot = false;

    connect(mTimer, SIGNAL(timeout()), this, SLOT(timerSlot()));
}
示例#28
0
void Nmr::plotImpulse(QList<double> const& data, QPair<double, double> const& domain)
{
   // Signals that are within the resolution are considered to be the same.
   double width(m_ui->widthSlider->value()/20000.0);
   double resolution(width*(domain.second-domain.first));

   m_graphToRows.clear();

   for (int i = 0; i < data.size(); ++i) {
       double shift(data[i]);
       if (shift < NO_SHIFT-1) {
          int x(shift/resolution);
           //qDebug() << " incrementing " << x << "because of" << shift;
           m_graphToRows[x].append(i);
       }
   }

   //qDebug() << "Signals map with resolution" << resolution << width;
   //qDebug() << m_graphToRows;

   int range(1);
   QVector<double> x(1), y(1);
   QMap<int, QList<int> >::iterator iter;

   for (iter = m_graphToRows.begin(); iter != m_graphToRows.end(); ++iter) {
       x[0] = resolution*iter.key();
       y[0] = iter.value().size();
       range = std::max(range, iter.value().size());

       QCPGraph* graph(m_plot->addGraph());
       graph->setData(x, y);
       graph->setName(QString::number(iter.key()));
       graph->setLineStyle(QCPGraph::lsImpulse);
       graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle));
       graph->setPen(m_pen);
       graph->setSelectedPen(m_selectPen);
       connect(graph, SIGNAL(selectionChanged(bool)), this, SLOT(plotSelectionChanged(bool)));
   }

   m_plot->yAxis->setRange(-0.00, 1.05*range);
   m_plot->yAxis->setAutoTickStep(false);
   m_plot->yAxis->setTickStep(1);
   m_plot->yAxis->setTickLabels(true);
   m_plot->yAxis->setLabel("Count");
}
示例#29
0
void Plot1D::clickedGraph(QMouseEvent *event)
{
  // function for mouse interaction

  // ontain the mouse position when click on the plot and transfer the pixel
  // position to the coord position
  xPosition = ui->customPlot->xAxis->pixelToCoord(event->pos().x());
  yPosition = ui->customPlot->yAxis->pixelToCoord(event->pos().y());

  // get the closest solution point w.r.t. the mouse clicked coord position
  int i = 0;
  while (xPosition > x_hist[i])
  {
    i = i+1;
  }

  xPosition_dis = x_hist[i];
  yPosition_dis = y_hist[i];
  yPosition_ex_dis = y_ex_hist[i];
  double error_dis = yPosition_dis - yPosition_ex_dis;

  // update the status bar message
  ui->statusBar->showMessage(QString("r: %1;  Phi(num.): %2;  "
                                     "Phi(exa.): %3;  Error: %4")
                             .arg(xPosition_dis)
                             .arg(yPosition_dis)
                             .arg(yPosition_ex_dis)
                             .arg(error_dis)
                             , 0);

  QVector<double> x(2), y(2);
  x[0] = xPosition_dis;
  x[1] = xPosition_dis;
  y[0] = yPosition_dis;
  y[1] = yPosition_ex_dis;

  // plot the clicked data points
  ui->customPlot->addGraph();
  ui->customPlot->graph(2)->setData(x, y);
  ui->customPlot->graph(2)->setName("Point track");
  ui->customPlot->graph(2)->setLineStyle(QCPGraph::lsNone);
  ui->customPlot->graph(2)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssSquare, QPen(Qt::red), QBrush(Qt::white), 10));
}
示例#30
0
void ConvertProfile(TProfile* prof, QCPGraph &graph){
  //how we put the profile histogram in Qt.
  //passing the graph to alter is just easier :)
  QVector<double> xvals,yvals,xerrs, yerrs;
  int nbins = prof->GetNbinsX();
  //get the values
  for(int i=0; i<nbins;++i){
    xvals.push_back(prof->GetBinCenter(i+1));
    yvals.push_back(prof->GetBinContent(i+1));
    xerrs.push_back(prof->GetBinWidth(i+1)/2.);
    yerrs.push_back(prof->GetBinError(i+1));
  }
  
  graph.setData(xvals, yvals);
  graph.setDataValueError(xvals, yvals, yerrs);//symmetric errors, only in y.
  graph.setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::black, 1.5), QBrush(Qt::white), 9));
  graph.setPen(QPen(QColor(120, 120, 120), 2));
  graph.setLineStyle(QCPGraph::LineStyle::lsNone);
  return;
}