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 }
void AmplitudePlot::removeSampleSource(PointSampler* src) { QwtPlotCurve* curve = _sources.take(src); curve->detach(); src->disconnect(this); delete curve; updatePlot(); }
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); }
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); }
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(); } }
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(); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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); } } }
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(); }
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(); }
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; }
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(); }
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; }
void Plot::drawPoints(){ QwtPlotCurve *curvePoints; curvePoints = new QwtPlotCurve(); curvePoints->setPen(Qt::green); curvePoints->setSamples(pointsArr); curvePoints->attach(this); this->replot(); }
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(); }
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()) ); }
void Plot::drawLine(QColor color){ QwtPlotCurve *curvePoints; curvePoints = new QwtPlotCurve(); curvePoints->setPen(color); curvePoints->setSamples(pointsArr); curvePoints->attach(this); this->replot(); pointsArr.clear(); }
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]); } } }
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(); }
void PlotWidget::RemovePlotData(QString title) { QwtPlotCurve *c = _curves.value(title); if(c == NULL) return; c->detach(); _curves.remove(title); delete c; CheckNReplot(); }
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(); }
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); } } }
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); } }
void Plot::setSignalColor(SignalData* signalData, QColor color) { if (!signalData) { return; } QwtPlotCurve* curve = mSignals.value(signalData); assert(curve); curve->setPen(QPen(color)); }
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); }
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); }
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); }
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); }