Exemplo n.º 1
1
QTabWidget* ResultsPage::createDataTabWidget()
{
    QTabWidget *tabWidget = new QTabWidget;

    // Plot
    m_plot = new QwtPlot(tabWidget);
    m_plot->setCanvasBackground(Qt::white);
    m_plot->setContextMenuPolicy(Qt::CustomContextMenu);
    m_plot->setAutoReplot(false);

    connect(m_plot, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(showPlotContextMenu(QPoint)));
    
    // Picker to allow for selection of the closest curve and displays curve
    // coordinates with a cross rubber band.
    QwtPlotPicker *picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                                              QwtPicker::CrossRubberBand, QwtPicker::ActiveOnly,
                                              m_plot->canvas());
    picker->setStateMachine(new QwtPickerDragPointMachine());

    connect(picker, SIGNAL(appended(QPoint)), this, SLOT(pointSelected(QPoint)));

    // Legend
    QwtLegend* legend = new QwtLegend;
    legend->setFrameStyle(QFrame::Box | QFrame::Sunken);
    m_plot->insertLegend(legend, QwtPlot::BottomLegend);
#if QWT_VERSION >= 0x060100
    connect(m_plot,
            SIGNAL(legendDataChanged(QVariant,QList<QwtLegendData>)),
            legend,
            SLOT(updateLegend(QVariant,QList<QwtLegendData>)));
#endif

    // Add the generic curves to the legend
    QList<QPair<QString, Qt::GlobalColor> > pairs;
    pairs << qMakePair(tr("Unselected Realization"), Qt::darkGray)
          << qMakePair(tr("Selected and Enabled Realization"), Qt::darkGreen)
          << qMakePair(tr("Selected and Disabled Realization"), Qt::darkRed);

    QPair<QString, Qt::GlobalColor> pair;
    foreach (pair, pairs) {
        QwtPlotCurve *curve = new QwtPlotCurve(pair.first);

        curve->setLegendIconSize(QSize(32, 8));
        curve->setPen(QPen(QBrush(pair.second), 2));
        curve->setLegendAttribute(QwtPlotCurve::LegendShowLine);
#if QWT_VERSION < 0x060100
        curve->updateLegend(legend);
#else
        m_plot->updateLegend(curve);
#endif
    }
Exemplo n.º 2
0
 void AmplitudePlot::removeSampleSource(PointSampler* src) {
     QwtPlotCurve* curve = _sources.take(src);
     curve->detach();
     src->disconnect(this);
     delete curve;
     updatePlot();
 }
Exemplo n.º 3
0
void Plot::insertCurve(Qt::Orientation o,
    const QColor &c, double base)
{
    QwtPlotCurve *curve = new QwtPlotCurve();

    curve->setPen(c);
    curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,
        Qt::gray, c, QSize(8, 8)));

    double x[10];
    double y[sizeof(x) / sizeof(x[0])];

    for ( uint i = 0; i < sizeof(x) / sizeof(x[0]); i++ )
    {
        double v = 5.0 + i * 10.0;
        if ( o == Qt::Horizontal )
        {
            x[i] = v;
            y[i] = base;
        }
        else
        {
            x[i] = base;
            y[i] = v;
        }
    }
        
    curve->setSamples(x, y, sizeof(x) / sizeof(x[0]));
    curve->attach(this);
}
Exemplo n.º 4
0
unsigned int QmitkPlotWidget::InsertCurve(const char* title)
{
  QwtPlotCurve* curve = new QwtPlotCurve(QwtText(title));
  m_PlotCurveVector.push_back(curve);
  curve->attach(m_Plot);
  return static_cast<unsigned int> (m_PlotCurveVector.size() - 1);
}
Exemplo n.º 5
0
void PlotSettingsDialog::
setAutoScale( const std::vector<QwtPlot*>& plots, QwtPlot::Axis axis ) {
    const double margin = 1.05;

    for( unsigned int i=0 ; i < plots.size() ; i++ ) {
        double max = -9e99;
        double min =  9e99;
        QwtPlotItemList L = plots[i]->itemList();
        for (int id = 0; id < L.size(); ++id) {
            if (L[id]->rtti() != QwtPlotItem::Rtti_PlotCurve)
                continue;

            QwtPlotCurve *curve = dynamic_cast<QwtPlotCurve*>(L[i]);
            if( axis == QwtPlot::xBottom ) {
                max = std::max( max, curve->maxXValue() );
                min = std::min( min, curve->minXValue() );
            }
            else {
                max = std::max( max, curve->maxYValue() );
                min = std::min( min, curve->minYValue() );
            }
        }
        plots[i]->setAxisScale( axis, min*(2-margin), max*margin );
        plots[i]->replot();
    }
}
Exemplo n.º 6
0
void Curves::resamples()
{
    setTitleX();
    foreach(int i, curves.keys()){
        if(i >= file->size()){
            delete curves.take(i);
        }
        else{
            QwtPlotCurve* curve = curves.value(i);
            curve->setSamples(
                file->samples(iX),
                file->samples(i)
            );
        }
    }

    ownerOuts->repaint();

    if(in){
        if(iIn >= file->size()){
            iIn = -1;
            delete in;
            in = NULL;
        }
        else{
            in->setSamples(
                file->samples(iX),
                file->samples(iIn)
            );
        }
        static_cast<InPlot*>(ownerIn)->clearInterval();
    }
}
Exemplo n.º 7
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos)
{
    QwtPlotCurve* closestCurve = NULL;
    double distMin = DBL_MAX;

    const QwtPlotItemList& itmList = itemList();
    for(QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++)
    {
        if((*it)->rtti() == QwtPlotItem::Rtti_PlotCurve)
        {
            QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>(*it);
            double dist = DBL_MAX;
            candidateCurve->closestPoint(pos, &dist);
            if(dist < distMin)
            {
                closestCurve = candidateCurve;
                distMin = dist;
            }
        }
    }

    if(closestCurve && distMin < 20)
    {
        RimSummaryCurve* selectedCurve = m_plotDefinition->findRimCurveFromQwtCurve(closestCurve);
        if(selectedCurve)
        {
            RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(selectedCurve);
        }
    }
}
Exemplo n.º 8
0
void CDataPlot::rebuild(void)
{
	for(int ci = 0; ci < m_portalCurveMap.count(); ++ci)
	{
		if(m_portalCurveMap.values().at(ci))
		{
			m_portalCurveMap.values().at(ci)->detach();
			delete m_portalCurveMap.values().at(ci);
		}
	}
	m_portalCurveMap.clear();

	if(m_algTreeModel)
	{
		QList<CPortal*> portals = m_algTreeModel->checkedPortalList();
		foreach(CPortal *portal, portals)
		{
			if(!portal) continue;
			QwtPlotCurve *curve = new QwtPlotCurve(portal->caption());
			curve->setData(new CCurveData(portal));
			curve->setPen(portal->dataColor(), 3);
			curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
			curve->attach(this);
			m_portalCurveMap[portal] = curve;
		}
	}

	refresh();
}
void Data_analysis_gui::set_y_axis_logscale( bool on ) {
  /*
  if (plot_->axisScaleEngine(QwtPlot::xBottom)->transformation()->type() ==
      QwtScaleTransformation::Log10 && on)
    return;

  if (plot_->axisScaleEngine(QwtPlot::xBottom)->transformation()->type() ==
      QwtScaleTransformation::Linear && (!on))
    return;
  */

  if( on ) {
    // Before allowing to go to log scaling, make sure all values are > 0:
    // if some are < 0, return without doing anything
    QwtPlotItemList L = plot_->itemList();
    for (int i = 0; i < L.size(); ++i) {
      if (L[i]->rtti() == QwtPlotItem::Rtti_PlotCurve) {
	QwtPlotCurve * curve = dynamic_cast<QwtPlotCurve*>(L[i]);
	if (curve->minYValue() <= 0)
	  return;
      }
    }
    plot_->setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);    
  }
  else
    plot_->setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);        

  plot_->replot();
}
Exemplo n.º 10
0
void Plot::drawDots(QVector< QVector<struct numCluster> > data, double n, double k, int index, int size, int number)
{
    int j, l;
    QPolygonF points;
    QwtPlotCurve *curve;

    QwtSymbol *symbol;

    points.clear();
    curve = new QwtPlotCurve();//QString("y = norm%1(x)").arg(index));
    curve->setItemAttribute(QwtPlotItem::Legend, false);
    curve->setStyle( QwtPlotCurve::Dots );
    for (l = 0; l < data.size(); l++){
        if (data[l][number].cluster == index){
            // ПЕРЕДЕЛАТЬ если возможно!!! Нужно, чтобы он печатал сразу для всех кластеров одной л.п.
            if (index == 0 && data[l][number].number < n){
                points << QPointF(data[l][number].number, 1);
            }else if (index == size - 1 && data[l][number].number > n){
                points << QPointF(data[l][number].number, 1);
            }else{
                points << QPointF(data[l][number].number, func_normal(data[l][number].number,n,k));
            }

            //std::cout << index << "data = " << data[l][i].number << std::endl;
        }
    }
    curve->setSamples(points);
    switch (index % 5){
    case 0:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::yellow ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 1:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::green ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 2:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::cyan ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 3:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::magenta ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 4:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::gray ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    default:
        break;
    }
    curve->attach(this);
    this->replot();
}
Exemplo n.º 11
0
int CurvesModel::getSymbolSize(int row) const {
    SolvWidget* solv =  solvers->at(row);
    QwtPlotCurve* curve = solv->curve;
    if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol) {
            return curve->symbol()->size().width();
    }
    return 7;
}
Exemplo n.º 12
0
QColor CurvesModel::getSymbolColor(int row) const { 
    SolvWidget* solv =  solvers->at(row);
    QwtPlotCurve* curve = solv->curve;
    if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol) {
            return curve->symbol()->pen().color();
    }
    return curve->pen().color();
}
Exemplo n.º 13
0
QwtPlotCurve* Curves::createCurve(int i) const
{
    QwtPlotCurve* curve = new QwtPlotCurve(file->header(i));
    curve->setRenderHint(QwtPlotCurve::RenderAntialiased);
    curve->setPen(QPen(QColor(rand() % 255, rand() % 255, rand() % 255), 2));
    curve->setPaintAttribute(QwtPlotCurve::ClipPolygons);
    return curve;
}
Exemplo n.º 14
0
void Plot::drawPoints(){
    QwtPlotCurve *curvePoints;
    curvePoints = new QwtPlotCurve();
    curvePoints->setPen(Qt::green);
    curvePoints->setSamples(pointsArr);
    curvePoints->attach(this);
    this->replot();
}
Exemplo n.º 15
0
void Plot::drawFunc(QVector params, double (*f)(double, QVector)){
    int j;
    QwtPlotCurve *curve = new QwtPlotCurve(QString("m: %1; a: %2").arg(m).arg(a));
    curve->setData(new FuncData(params, f));
    curve->attach(this);

    this->replot();
}
Exemplo n.º 16
0
void MQwt::curve(var iX, var iY, var iTitle)
{
    QwtPlotCurve* curve = new QwtPlotCurve(iTitle.str());
    curve->attach(mPlot);
    curve->setRenderHint(QwtPlotItem::RenderAntialiased);
    curve->setSamples(
        iX.ptr<double>(), iY.ptr<double>(), std::min(iX.size(), iY.size())
    );
}
Exemplo n.º 17
0
void Plot::drawLine(QColor color){
    QwtPlotCurve *curvePoints;
    curvePoints = new QwtPlotCurve();
    curvePoints->setPen(color);
    curvePoints->setSamples(pointsArr);
    curvePoints->attach(this);
    this->replot();
    pointsArr.clear();
}
Exemplo n.º 18
0
void ExpDecayDialog::fit()
{
	QString curve = boxName->currentText();
	QwtPlotCurve *c = graph->curve(curve);
	QStringList curvesList = graph->analysableCurvesList();
	if (!c || !curvesList.contains(curve)){
		QMessageBox::critical(this,tr("QtiPlot - Warning"),
				tr("The curve <b> %1 </b> doesn't exist anymore! Operation aborted!").arg(curve));
		boxName->clear();
		boxName->addItems(curvesList);
		return;
	}

	ApplicationWindow *app = (ApplicationWindow *)this->parent();
	if (!app)
        return;

	if (fitter)
        delete fitter;

	if (slopes == 3){
		double x_init[7] = {1.0, boxFirst->value(), 1.0, boxSecond->value(), 1.0, boxThird->value(), boxYOffset->value()};
		fitter = new ThreeExpFit(app, graph);
		fitter->setInitialGuesses(x_init);
	} else if (slopes == 2) {
		double x_init[5] = {1.0, boxFirst->value(), 1.0, boxSecond->value(), boxYOffset->value()};
		fitter = new TwoExpFit(app, graph);
		fitter->setInitialGuesses(x_init);
	} else if (slopes == 1 || slopes == -1){
		double x_init[3] = {boxAmplitude->value(), slopes*boxFirst->value(), boxYOffset->value()};
		fitter = new ExponentialFit(app, graph, slopes == -1);
		fitter->setInitialGuesses(x_init);
	}

  	if (fitter->setDataFromCurve(boxName->currentText(), boxStart->value(), c->maxXValue())){
		fitter->setColor(boxColor->currentItem());
		fitter->scaleErrors(app->fit_scale_errors);
        fitter->setOutputPrecision(app->fit_output_precision);
		fitter->generateFunction(app->generateUniformFitPoints, app->fitPoints);
		fitter->fit();

		double *results = fitter->results();
		boxFirst->setValue(results[1]);
		if (slopes < 2){
            boxAmplitude->setValue(results[0]);
            boxYOffset->setValue(results[2]);
        } else if (slopes == 2){
            boxSecond->setValue(results[3]);
            boxYOffset->setValue(results[4]);
        } else if (slopes == 3){
            boxSecond->setValue(results[3]);
            boxThird->setValue(results[5]);
            boxYOffset->setValue(results[6]);
        }
	}
}
Exemplo n.º 19
0
void PlotPropertiesGUI::curveWidthValue(int value)
{
    QwtPlotCurve *plotCurve = internalCurves.value(currentCurve)->plotCurve;

    // Changes only the curve width
    QPen pen = plotCurve->pen();
    pen.setWidth(value);
    plotCurve->setPen(pen);
    plotter->replot();
}
Exemplo n.º 20
0
void PlotWidget::RemovePlotData(QString title)
{
	QwtPlotCurve *c = _curves.value(title);
	if(c == NULL)
		return;
	c->detach();
	_curves.remove(title);
	delete c;
	CheckNReplot();
}
Exemplo n.º 21
0
void PlotPropertiesGUI::selectedLine(int value)
{
    QwtPlotCurve *plotCurve = internalCurves.value(currentCurve)->plotCurve;

    // Changes only the curve style
    QPen pen = plotCurve->pen();
    pen.setStyle((Qt::PenStyle) value);
    plotCurve->setPen(pen);
    plotter->replot();
}
Exemplo n.º 22
0
 void AmplitudePlot::updateSeriesVisibility(bool state) {
     QObject* srcObj = QObject::sender();
     PointSampler* src = qobject_cast<PointSampler*>(srcObj);
     if(src) {
         QwtPlotCurve* curve = _sources.value(src);
         if(curve)  {
             qDebug() << "Setting visibility of" << curve << "to" << state;
             curve->setVisible(state);
         }
     }
 }
Exemplo n.º 23
0
 WorkoutPlot()
 {
     workoutCurve = new QwtPlotCurve();
     setTitle("Workout Chart");
     QPen pen = QPen(Qt::blue,1.0);
     workoutCurve->setPen(pen);
     QColor brush_color = QColor(124, 91, 31);
     brush_color.setAlpha(64);
     workoutCurve->setBrush(brush_color);
     workoutCurve->attach(this);
 }
void SmoothCurveDialog::activateCurve(const QString& curveName)
{
    if (smooth_method == SmoothFilter::Average)
	{
	QwtPlotCurve *c = graph->curve(curveName);
	if (!c || c->rtti() != QwtPlotItem::Rtti_PlotCurve)
		return;

	boxPointsLeft->setMaxValue(c->dataSize()/2);
	}
}
Exemplo n.º 25
0
void Plot::setSignalColor(SignalData* signalData, QColor color)
{
  if (!signalData)
  {
    return;
  }

  QwtPlotCurve* curve = mSignals.value(signalData);
  assert(curve);
  curve->setPen(QPen(color));
}
Exemplo n.º 26
0
void RTVTPlotWindow::addCurveWithDataFromChannel(QVector<qreal> frequency, QVector<qreal> amplitude, unsigned int channel)
{
    QwtPlotCurve *curve = new QwtPlotCurve(QString("Channel " + QString::number(channel)));
    curve->setPen(selectPen());
    curve->setSamples(frequency, amplitude);
    curve->setAxes(QwtPlot::xBottom, QwtPlot::yLeft);
    curves << curve;

    channelStringList << curve->title().text();
    channelListStringModel->setStringList(channelStringList);
}
Exemplo n.º 27
0
SagittalZMPPlot::SagittalZMPPlot(QWidget *parent)
   : DataPlot(parent) {
   for (int i = 0; i < PLOT_SIZE; ++i)
      data[i] = 0.0;
   setTitle("Sagittal Plane");

   QwtPlotCurve *curve = new QwtPlotCurve("SagittalZMP");
   curve->attach(this);
   curve->setRawData(t, data, PLOT_SIZE);
   setAxisScale(QwtPlot::xBottom, 0, PLOT_SIZE - 1);
   setAxisScale(QwtPlot::yLeft, -100, 100);
}
Exemplo n.º 28
0
COMyPlot::COMyPlot(QWidget *parent)
   : XYZPlot(parent) {
   for (int i = 0; i < PLOT_SIZE; ++i)
      data[i] = 0.0;
   setTitle("COM relative to foot touching ground y");

   QwtPlotCurve *curve = new QwtPlotCurve("COMy");
   curve->attach(this);
   curve->setRawData(t, data, PLOT_SIZE);
   setAxisScale(QwtPlot::xBottom, 0, PLOT_SIZE - 1);
   setAxisScale(QwtPlot::yLeft, -100, 100);
}
Exemplo n.º 29
0
SurfPlot::SurfPlot(QWidget *parent)
   : DataPlot(parent) {
   for (int i = 0; i < SURF_PLOT_SIZE; ++i)
      data[i] = 0.0;
   setTitle("Surf landmark matching score");

   QwtPlotCurve *curve = new QwtPlotCurve("Surf");
   curve->attach(this);
   curve->setRawData(t, data, SURF_PLOT_SIZE);
   setAxisScale(QwtPlot::xBottom, 0, SURF_PLOT_SIZE - 1);
   setAxisScale(QwtPlot::yLeft, 0, 2000);
}
void polynomFitDialog::changeCurve(int index)
{
QwtPlotCurve *c = graph->curve(index);
while(c->dataSize()<2)
	{
	index++;
	c = graph->curve(index);
	if(!c || index >= graph->curves()) 
		index=0; //Restart from the beginning
	}
boxName->setCurrentItem(index);
activateCurve(index);
}