void QmitkIVIMWidget::SetParameters( IVIMFilterType::IVIMSnapshot snap ) { this->Clear(); if (snap.bvalues.empty()) return; QString s("f=%1, D=%2, D*=%3"); s = s.arg(snap.currentF,4); s = s.arg(snap.currentD,4); s = s.arg(snap.currentDStar,4); int curveId = this->InsertCurve( s.toAscii() ); this->SetCurvePen( curveId, QPen( Qt::NoPen ) ); curveId = this->InsertCurve( "ignored measurement points" ); this->SetCurveData( curveId, vec(snap.bvalues), vec(snap.allmeas) ); this->SetCurvePen( curveId, QPen(Qt::NoPen) ); QwtSymbol* whiteSymbol = new QwtSymbol(QwtSymbol::Diamond, QColor(Qt::white), QColor(Qt::black), QSize(10,10)); this->SetCurveSymbol(curveId, whiteSymbol); if(snap.currentDStar != 0) { curveId = this->InsertCurve( "additional points second fit" ); this->SetCurveData( curveId, vec(snap.bvals2), vec(snap.meas2) ); this->SetCurvePen( curveId, QPen( Qt::NoPen ) ); QwtSymbol* blackSymbol = new QwtSymbol(QwtSymbol::Diamond, QColor(Qt::black), QColor(Qt::black), QSize(10,10)); this->SetCurveSymbol(curveId, blackSymbol); } curveId = this->InsertCurve( "points first fit" ); this->SetCurveData( curveId, vec(snap.bvals1), vec(snap.meas1) ); this->SetCurvePen( curveId, QPen( Qt::NoPen ) ); QwtSymbol* redSymbol = new QwtSymbol(QwtSymbol::Diamond, QColor(Qt::red), QColor(Qt::red), QSize(10,10)); this->SetCurveSymbol(curveId, redSymbol); QPen pen; pen.setColor( QColor(Qt::red) ); pen.setWidth(2); double maxb = snap.bvalues.max_value(); vnl_vector<double> xvals(2); vnl_vector<double> yvals(2); xvals[0] = 0; xvals[1] = maxb; yvals[0] = 1-snap.currentFunceiled; yvals[1] = yvals[0]*exp(-maxb * snap.currentD); curveId = this->InsertCurve( "contribution of D to the signal" ); this->SetCurveData( curveId, vec(xvals), vec(yvals) ); this->SetCurvePen( curveId, pen ); if(snap.currentDStar != 0) { pen.setColor(Qt::black); int nsampling = 50; xvals.set_size(nsampling); yvals.set_size(nsampling); double f = 1-snap.currentFunceiled; for(int i=0; i<nsampling; i++) { xvals[i] = (((1.0)*i)/(1.0*nsampling))*maxb; yvals[i] = f*exp(- xvals[i] * snap.currentD) + (1-f)*exp(- xvals[i] * (snap.currentD+snap.currentDStar)); } curveId = this->InsertCurve( "resulting fit of the model" ); this->SetCurveData( curveId, vec(xvals), vec(yvals) ); this->SetCurvePen( curveId, pen ); } // QMargins margins; // margins.setBottom(0); // margins.setLeft(0); // margins.setRight(0); // margins.setTop(0); QwtLegend* legend = new QwtLegend(); // legend->setContentsMargins(margins); m_Plot->insertLegend(legend, QwtPlot::BottomLegend); this->Replot(); }
void ScatterPlot::setData (ScatterSettings *settings) { // get application settings cranklength = appsettings->value(this, GC_CRANKLENGTH, 0.0).toDouble() / 1000.0; // if there are no settings or incomplete settings // create a null data plot if (settings == NULL || settings->ride == NULL || settings->ride->ride() == NULL || settings->x == 0 || settings->y == 0 ) { return; } // if its not setup or no settings exist default to 175mm cranks if (cranklength == 0.0) cranklength = 0.175; // // Create Main Plot dataset - used to frame intervals // int points=0; x.clear(); y.clear(); x.resize(settings->ride->ride()->dataPoints().count()); y.resize(settings->ride->ride()->dataPoints().count()); double maxY = maxX = -65535; double minY = minX = 65535; foreach(const RideFilePoint *point, settings->ride->ride()->dataPoints()) { double xv = x[points] = pointType(point, settings->x, context->athlete->useMetricUnits, cranklength); double yv = y[points] = pointType(point, settings->y, context->athlete->useMetricUnits, cranklength); // skip zeroes? if (!(settings->ignore && (x[points] == 0 || y[points] == 0))) { points++; if (yv > maxY) maxY = yv; if (yv < minY) minY = yv; if (xv > maxX) maxX = xv; if (xv < minX) minX = xv; } } QwtSymbol sym; sym.setStyle(QwtSymbol::Ellipse); sym.setSize(6); sym.setPen(GCColor::invert(GColor(CPLOTBACKGROUND))); sym.setBrush(QBrush(Qt::NoBrush)); QPen p; p.setColor(GColor(CPLOTSYMBOL)); sym.setPen(p); // wipe away existing if (all) { all->detach(); delete all; } // setup the framing curve if (settings->frame) { all = new QwtPlotCurve(); all->setSymbol(new QwtSymbol(sym)); all->setStyle(QwtPlotCurve::Dots); all->setRenderHint(QwtPlotItem::RenderAntialiased); all->setData(x.constData(), y.constData(), points); all->attach(this); } else { all = NULL; } QPen gridPen(GColor(CPLOTGRID)); gridPen.setStyle(Qt::DotLine); if (grid) { grid->detach(); delete grid; } if (settings->gridlines) { grid = new QwtPlotGrid(); grid->setPen(gridPen); grid->enableX(true); grid->enableY(true); grid->attach(this); } else { grid = NULL; } setAxisTitle(yLeft, describeType(settings->y, true, useMetricUnits)); setAxisTitle(xBottom, describeType(settings->x, true, useMetricUnits)); // truncate PfPv values to make easier to read if (settings->y == MODEL_AEPF) setAxisScale(yLeft, 0, 600); else setAxisScale(yLeft, minY, maxY); if (settings->x == MODEL_CPV) setAxisScale(xBottom, 0, 3); else setAxisScale(xBottom, minX, maxX); // // Create Interval Plot dataset - used to frame intervals // // clear out any interval curves which are presently defined if (intervalCurves.size()) { QListIterator<QwtPlotCurve *> i(intervalCurves); while (i.hasNext()) { QwtPlotCurve *curve = i.next(); curve->detach(); delete curve; } } intervalCurves.clear(); // which ones are highlighted then? QVector<int> intervals; QMap<int,int> displaySequence; for (int child=0; child<context->athlete->allIntervalItems()->childCount(); child++) { IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(child)); if ((current != NULL) && current->isSelected()) { intervals.append(child); displaySequence.insert(current->displaySequence, intervals.count()-1); } } if (intervals.count() > 0) { // interval data in here QVector<QVector<double> > xvals(intervals.count()); // array of curve x arrays QVector<QVector<double> > yvals(intervals.count()); // array of curve x arrays QVector<int> points(intervals.count()); // points in eac curve // extract interval data foreach(const RideFilePoint *point, settings->ride->ride()->dataPoints()) { double x = pointType(point, settings->x, useMetricUnits, cranklength); double y = pointType(point, settings->y, useMetricUnits, cranklength); if (!(settings->ignore && (x == 0 && y ==0))) { // which interval is it in? for (int idx=0; idx<intervals.count(); idx++) { IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(intervals[idx])); if (point->secs+settings->ride->ride()->recIntSecs() > current->start && point->secs< current->stop) { xvals[idx].append(x); yvals[idx].append(y); points[idx]++; } } } } // now we have the interval data lets create the curves QMapIterator<int, int> order(displaySequence); while (order.hasNext()) { order.next(); int idx = order.value(); QPen pen; QColor intervalColor; intervalColor.setHsv((255/context->athlete->allIntervalItems()->childCount()) * (intervals[idx]), 255,255); pen.setColor(intervalColor); sym.setPen(pen); QwtPlotCurve *curve = new QwtPlotCurve(); curve->setSymbol(new QwtSymbol(sym)); curve->setStyle(QwtPlotCurve::Dots); curve->setRenderHint(QwtPlotItem::RenderAntialiased); curve->setData(xvals[idx].constData(), yvals[idx].constData(), points[idx]); curve->attach(this); intervalCurves.append(curve); } }