本文整理汇总了C++中QwtPlotCurve::attach方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotCurve::attach方法的具体用法?C++ QwtPlotCurve::attach怎么用?C++ QwtPlotCurve::attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotCurve
的用法示例。
在下文中一共展示了QwtPlotCurve::attach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timeWindowEnabled
EventViewer::EventViewer(unsigned eventId, const QString& eventName, unsigned eventVariablesCount, MainWindow::EventViewers* eventsViewers) :
eventId(eventId),
eventsViewers(eventsViewers),
values(eventVariablesCount),
startingTime(QTime::currentTime())
{
QSettings settings;
// create plot
plot = new QwtPlot;
plot->setCanvasBackground(Qt::white);
plot->setAxisTitle(plot->xBottom, tr("Time (seconds)"));
plot->setAxisTitle(plot->yLeft, tr("Values"));
QwtLegend *legend = new QwtLegend;
//legend->setItemMode(QwtLegend::CheckableItem);
plot->insertLegend(legend, QwtPlot::BottomLegend);
for (size_t i = 0; i < values.size(); i++)
{
QwtPlotCurve *curve = new QwtPlotCurve(QString("%0").arg(i));
#if QWT_VERSION >= 0x060000
curve->setData(new EventDataWrapper(timeStamps, values[i]));
#else
curve->setData(EventDataWrapper(timeStamps, values[i]));
#endif
curve->attach(plot);
curve->setPen(QPen(QColor::fromHsv((i * 360) / values.size(), 255, 100), 2));
}
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(plot);
// add control
QHBoxLayout *controlLayout = new QHBoxLayout;
status = new QLabel(tr("Recording..."));
controlLayout->addWidget(status);
pauseRunButton = new QPushButton(QPixmap(QString(":/images/pause.png")), tr("&Pause"));
connect(pauseRunButton, SIGNAL(clicked()), SLOT(pauseRunCapture()));
controlLayout->addWidget(pauseRunButton);
QPushButton *clearButton = new QPushButton(QPixmap(QString(":/images/reset.png")), tr("&Clear"));
connect(clearButton, SIGNAL(clicked()), SLOT(clearPlot()));
controlLayout->addWidget(clearButton);
const bool timeWindowEnabled(settings.value("EventViewer/timeWindowEnabled", false).toBool());
timeWindowCheckBox = new QCheckBox(tr("time &window:"));
controlLayout->addWidget(timeWindowCheckBox);
timeWindowCheckBox->setChecked(timeWindowEnabled);
timeWindowLength = new QDoubleSpinBox;
timeWindowLength->setSuffix("s");
connect(timeWindowCheckBox, SIGNAL(toggled(bool)), timeWindowLength, SLOT(setEnabled(bool)));
timeWindowLength->setValue(settings.value("EventViewer/timeWindowLength", 10.).toDouble());
timeWindowLength->setEnabled(timeWindowEnabled);
controlLayout->addWidget(timeWindowLength);
controlLayout->addStretch();
QPushButton *saveToFileButton = new QPushButton(QPixmap(QString(":/images/filesaveas.png")), tr("Save &As..."));
connect(saveToFileButton, SIGNAL(clicked()), SLOT(saveToFile()));
controlLayout->addWidget(saveToFileButton);
layout->addLayout(controlLayout);
// receive events
eventsViewers->insert(eventId, this);
isCapturing = true;
}
示例2: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
string videoName = "static";
//
//*** Pixel variation error
// original video pixel variation (RMSE) reading
tic();
vector<double> RMSEO,framesO;
double avrRMSEO;
if(readPixelRMSE("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+".avi",RMSEO,framesO,avrRMSEO)>0) return -1;
toc();
// fusion stabilized video pixel variation (RMSE) reading
tic();
vector<double> RMSEF,framesF;
double avrRMSEF;
if(readPixelRMSE("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable_F.avi",RMSEF,framesF,avrRMSEF)>0) return -1;
toc();
// video processing stabilized video pixel variation (RMSE) reading
tic();
vector<double> RMSEV,framesV;
double avrRMSEV;
if(readPixelRMSE("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable_VP.avi",RMSEV,framesV,avrRMSEV)>0) return -1;
toc();
// second round fusion stabilized video pixel variation (RMSE) reading
tic();
vector<double> RMSEF2,framesF2;
double avrRMSEF2;
if(readPixelRMSE("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable2_F.avi",RMSEF2,framesF2,avrRMSEF2)>0) return -1;
toc();
// second round video processing stabilized video pixel variation (RMSE) reading
tic();
vector<double> RMSEV2,framesV2;
double avrRMSEV2;
if(readPixelRMSE("/home/maelle/Desktop/Samples/Static/"+videoName+"/"+videoName+"_stable2_VP.avi",RMSEV2,framesV2,avrRMSEV2)>0) return -1;
toc();
// plot first round
QwtPlot plotRMSE;
plotRMSE.setTitle("Root Mean Squared pixel variation per frame");
plotRMSE.setCanvasBackground(Qt::white);
plotRMSE.insertLegend(new QwtLegend());
plotRMSE.setAxisTitle(QwtPlot::yLeft,"RMSE (px)");
plotRMSE.setAxisTitle(QwtPlot::xBottom,"Frame");
QwtPlotMarker *mAO=new QwtPlotMarker();
mAO->setLinePen(QPen(Qt::darkBlue));
mAO->setLineStyle(QwtPlotMarker::HLine);
mAO->setValue(0,avrRMSEO);
mAO->attach(&plotRMSE);
QwtPlotMarker *mAF=new QwtPlotMarker();
mAF->setLinePen(QPen(Qt::darkRed));
mAF->setLineStyle(QwtPlotMarker::HLine);
mAF->setValue(0,avrRMSEF);
mAF->attach(&plotRMSE);
QwtPlotMarker *mAV=new QwtPlotMarker();
mAV->setLinePen(QPen(Qt::darkGreen));
mAV->setLineStyle(QwtPlotMarker::HLine);
mAV->setValue(0,avrRMSEV);
mAV->attach(&plotRMSE);
QwtPlotCurve *curveRMSEO = new QwtPlotCurve();
curveRMSEO->setTitle("Original");
curveRMSEO->setPen(Qt::blue,2);
curveRMSEO->setRenderHint(QwtPlotItem::RenderAntialiased,true);
curveRMSEO->setRawSamples(framesO.data(),RMSEO.data(),framesO.size());
curveRMSEO->attach(&plotRMSE);
QwtPlotCurve *curveRMSEF = new QwtPlotCurve();
curveRMSEF->setTitle("Fusion stabilized");
curveRMSEF->setPen(Qt::red,2);
curveRMSEF->setRenderHint(QwtPlotItem::RenderAntialiased,true);
curveRMSEF->setRawSamples(framesF.data(),RMSEF.data(),framesF.size());
curveRMSEF->attach(&plotRMSE);
QwtPlotCurve *curveRMSEV = new QwtPlotCurve();
curveRMSEV->setTitle("Video Processing stabilized");
curveRMSEV->setPen(Qt::green,2);
curveRMSEV->setRenderHint(QwtPlotItem::RenderAntialiased,true);
curveRMSEV->setRawSamples(framesV.data(),RMSEV.data(),framesV.size());
curveRMSEV->attach(&plotRMSE);
plotRMSE.resize(600,400);
plotRMSE.show();
// plot second round
QwtPlot plotRMSE2;
plotRMSE2.setTitle("Root Mean Squared pixel variation per frame (second round)");
plotRMSE2.setCanvasBackground(Qt::white);
plotRMSE2.insertLegend(new QwtLegend());
plotRMSE2.setAxisTitle(QwtPlot::yLeft,"RMSE (px)");
plotRMSE2.setAxisTitle(QwtPlot::xBottom,"Frame");
QwtPlotMarker *mAO2=new QwtPlotMarker();
mAO2->setLinePen(QPen(Qt::darkBlue));
mAO2->setLineStyle(QwtPlotMarker::HLine);
mAO2->setValue(0,avrRMSEO);
mAO2->attach(&plotRMSE2);
QwtPlotMarker *mAOF=new QwtPlotMarker();
mAOF->setLinePen(QPen(Qt::darkCyan));
mAOF->setLineStyle(QwtPlotMarker::HLine);
//.........这里部分代码省略.........
示例3: main
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QwtPlot plot;
plot.setTitle( "Plot Demo" );
plot.setCanvasBackground( Qt::white );
plot.setAxisScale( QwtPlot::xBottom, -1.0, 6.0 );
QwtLegend *legend = new QwtLegend();
legend->setDefaultItemMode( QwtLegendData::Checkable );
plot.insertLegend( legend );
for ( int i = 0; i < 4; i++ )
{
QwtPlotCurve *curve = new QwtPlotCurve();
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
curve->setPen( Qt::blue );
QBrush brush;
QwtSymbol::Style style = QwtSymbol::NoSymbol;
QString title;
if ( i == 0 )
{
brush = Qt::magenta;
style = QwtSymbol::Path;
title = "Path";
}
else if ( i == 2 )
{
brush = Qt::red;
style = QwtSymbol::Graphic;
title = "Graphic";
}
else if ( i == 1 )
{
brush = Qt::yellow;
style = QwtSymbol::SvgDocument;
title = "Svg";
}
else if ( i == 3 )
{
brush = Qt::cyan;
style = QwtSymbol::Pixmap;
title = "Pixmap";
}
MySymbol *symbol = new MySymbol( style, brush );
curve->setSymbol( symbol );
curve->setTitle( title );
curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true );
curve->setLegendIconSize( QSize( 15, 18 ) );
QPolygonF points;
points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 )
<< QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 )
<< QPointF( 4.0, 7.9 ) << QPointF( 5.0, 7.1 );
points.translate( 0.0, i * 2.0 );
curve->setSamples( points );
curve->attach( &plot );
}
plot.resize( 600, 400 );
plot.show();
return a.exec();
}
示例4: i
void
PfPvPlot::refreshZoneItems()
{
// clear out any zone curves which are presently defined
if (zoneCurves.size()) {
QListIterator<QwtPlotCurve *> i(zoneCurves);
while (i.hasNext()) {
QwtPlotCurve *curve = i.next();
curve->detach();
delete curve;
}
}
zoneCurves.clear();
// delete any existing power zone labels
if (zoneLabels.size()) {
QListIterator<PfPvPlotZoneLabel *> i(zoneLabels);
while (i.hasNext()) {
PfPvPlotZoneLabel *label = i.next();
label->detach();
delete label;
}
}
zoneLabels.clear();
// give up for a null ride
if (! rideItem) return;
const Zones *zones = rideItem->zones;
int zone_range = rideItem->zoneRange();
if (zone_range >= 0) {
setCP(zones->getCP(zone_range));
// populate the zone curves
QList <int> zone_power = zones->getZoneLows(zone_range);
QList <QString> zone_name = zones->getZoneNames(zone_range);
int num_zones = zone_power.size();
assert(zone_name.size() == num_zones);
if (num_zones > 0) {
QPen *pen = new QPen();
pen->setStyle(Qt::NoPen);
QwtArray<double> yvalues;
// generate x values
for (int z = 0; z < num_zones; z ++) {
QwtPlotCurve *curve = new QwtPlotCurve(zone_name[z]);
curve->setPen(*pen);
QColor brush_color = zoneColor(z, num_zones);
brush_color.setHsv(brush_color.hue(), brush_color.saturation() / 4, brush_color.value());
curve->setBrush(brush_color); // fill below the line
curve->setZ(1 - 1e-6 * zone_power[z]);
// generate data for curve
if (z < num_zones - 1) {
QwtArray <double> contour_yvalues;
int watts = zone_power[z + 1];
int dwatts = (double) watts;
for (int i = 0; i < contour_xvalues.size(); i ++) {
contour_yvalues.append( (1e6 * contour_xvalues[i] < watts) ? 1e6 : dwatts / contour_xvalues[i]);
}
curve->setData(contour_xvalues, contour_yvalues);
} else {
// top zone has a curve at "infinite" power
QwtArray <double> contour_x;
QwtArray <double> contour_y;
contour_x.append(contour_xvalues[0]);
contour_x.append(contour_xvalues[contour_xvalues.size() - 1]);
contour_y.append(1e6);
contour_y.append(1e6);
curve->setData(contour_x, contour_y);
}
curve->setVisible(shade_zones);
curve->attach(this);
zoneCurves.append(curve);
}
delete pen;
// generate labels for existing zones
for (int z = 0; z < num_zones; z ++) {
PfPvPlotZoneLabel *label = new PfPvPlotZoneLabel(this, z);
label->setVisible(shade_zones);
label->attach(this);
zoneLabels.append(label);
}
}
}
}
示例5: QwtPlot
//
// Initialize main window
//
DataPlot::DataPlot(QWidget *parent):
QwtPlot(parent),
d_interval(0),
d_timerId(-1)
{
// Disable polygon clipping
QwtPainter::setDeviceClipping(false);
// We don't need the cache here
canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
#if QT_VERSION >= 0x040000
#ifdef Q_WS_X11
/*
Qt::WA_PaintOnScreen is only supported for X11, but leads
to substantial bugs with Qt 4.2.x/Windows
*/
canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif
#endif
alignScales();
// Initialize data
for (int i = 0; i< PLOT_SIZE; i++)
{
d_x[i] = 0.5 * i; // time axis
d_y[i] = 0;
d_z[i] = 0;
}
// Assign a title
setTitle("A Test for High Refresh Rates");
insertLegend(new QwtLegend(), QwtPlot::BottomLegend);
// Insert new curves
QwtPlotCurve *cRight = new QwtPlotCurve("Data Moving Right");
cRight->attach(this);
QwtPlotCurve *cLeft = new QwtPlotCurve("Data Moving Left");
cLeft->attach(this);
// Set curve styles
cRight->setPen(QPen(Qt::red));
cLeft->setPen(QPen(Qt::blue));
// Attach (don't copy) data. Both curves use the same x array.
cRight->setRawData(d_x, d_y, PLOT_SIZE);
cLeft->setRawData(d_x, d_z, PLOT_SIZE);
#if 0
// Insert zero line at y = 0
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->setLineStyle(QwtPlotMarker::HLine);
mY->setYValue(0.0);
mY->attach(this);
#endif
// Axis
setAxisTitle(QwtPlot::xBottom, "Time/seconds");
setAxisScale(QwtPlot::xBottom, 0, 100);
setAxisTitle(QwtPlot::yLeft, "Values");
setAxisScale(QwtPlot::yLeft, -1.5, 1.5);
setTimerInterval(0.0);
}
示例6: insertNewCurve
void Curves::insertNewCurve(int i)
{
QwtPlotCurve* curve = createCurve(i);
curves[i] = curve;
curve->attach(ownerOuts);
}
示例7: pen
void
CpintPlot::plot_allCurve(CpintPlot *thisPlot,
int n_values,
const double *power_values)
{
clear_CP_Curves();
QVector<double> energyBests(n_values);
QVector<double> time_values(n_values);
// generate an array of time values
for (int t = 0; t < n_values; t++) {
time_values[t] = (t + 1) / 60.0;
energyBests[t] = power_values[t] * time_values[t] * 60.0 / 1000.0;
}
// generate zones from derived CP value
if (cp > 0) {
QList <int> power_zone;
int n_zones = zones->lowsFromCP(&power_zone, (int) int(cp));
int high = n_values - 1;
int zone = 0;
while (zone < n_zones && high > 0) {
int low = high - 1;
int nextZone = zone + 1;
if (nextZone >= power_zone.size())
low = 0;
else {
while ((low > 0) && (power_values[low] < power_zone[nextZone]))
--low;
}
QColor color = zoneColor(zone, n_zones);
QString name = zones->getDefaultZoneName(zone);
QwtPlotCurve *curve = new QwtPlotCurve(name);
if (appsettings->value(this, GC_ANTIALIAS, false).toBool() == true)
curve->setRenderHint(QwtPlotItem::RenderAntialiased);
QPen pen(color.darker(200));
pen.setWidth(appsettings->value(this, GC_LINEWIDTH, 2.0).toDouble());
curve->setPen(pen);
curve->attach(thisPlot);
color.setAlpha(64);
curve->setBrush(color); // brush fills below the line
if (series == RideFile::none) { // this is Energy mode
curve->setData(time_values.data() + low,
energyBests.data() + low, high - low + 1);
} else {
curve->setData(time_values.data() + low,
power_values + low, high - low + 1);
}
allCurves.append(curve);
if (series != RideFile::none || energyBests[high] > 100.0) {
QwtText text(name);
text.setFont(QFont("Helvetica", 20, QFont::Bold));
color.setAlpha(255);
text.setColor(color);
QwtPlotMarker *label_mark = new QwtPlotMarker();
// place the text in the geometric mean in time, at a decent power
double x, y;
if (series == RideFile::none) {
x = (time_values[low] + time_values[high]) / 2;
y = (energyBests[low] + energyBests[high]) / 5;
}
else {
x = sqrt(time_values[low] * time_values[high]);
y = (power_values[low] + power_values[high]) / 5;
}
label_mark->setValue(x, y);
label_mark->setLabel(text);
label_mark->attach(thisPlot);
allZoneLabels.append(label_mark);
}
high = low;
++zone;
}
}
// no zones available: just plot the curve without zones
else {
QwtPlotCurve *curve = new QwtPlotCurve(tr("maximal power"));
if (appsettings->value(this, GC_ANTIALIAS, false).toBool() == true)
curve->setRenderHint(QwtPlotItem::RenderAntialiased);
QPen pen(GColor(CCP));
pen.setWidth(appsettings->value(this, GC_LINEWIDTH, 2.0).toDouble());
curve->setPen(pen);
QColor brush_color = GColor(CCP);
brush_color.setAlpha(200);
curve->setBrush(brush_color); // brush fills below the line
if (series == RideFile::none)
curve->setData(time_values.data(), energyBests.data(), n_values);
else
curve->setData(time_values.data(), power_values, n_values);
curve->attach(thisPlot);
allCurves.append(curve);
}
// Energy mode is really only interesting in the range where energy is
// linear in interval duration--up to about 1 hour.
double xmax = (series == RideFile::none) ? 60.0 : time_values[n_values - 1];
//.........这里部分代码省略.........
示例8: timerEvent
// Generate new values
void DataPlot::timerEvent(QTimerEvent *)
{
for (int k = 0; k < numberOfInputPorts; k++)
{
int timeout = 0;
int maxTimeout = 2;
Bottle *b = NULL;
while(b==NULL && timeout < maxTimeout)
{
b = inputPorts[k].read(false);
Time::delay(0.005);
timeout++;
}
if (timeout==maxTimeout)
{
if(VERBOSE) fprintf(stderr, "MESSAGE: Couldn't receive data. Going to put a zero! \n");
for(int i = 0; i < numberOfPlots[k]; i++)
{
d_y[k][i][PLOT_SIZE - 1] = 0;
for ( int j = 0; j < PLOT_SIZE - 1; j++ )
{
d_y[k][i][j] = d_y[k][i][j+1];
}
}
}
else
{
for(int i = 0; i < numberOfPlots[k]; i++)
{
Stamp stmp;
inputPorts[k].getEnvelope(stmp);
#ifdef ENABLE_REALTIME
if (stmp.isValid())
d_x_real_time[PLOT_SIZE - 1] = (stmp.getTime() - initialTime);
for ( int j = 0; j < PLOT_SIZE - 1; j++ )
{
if(realTime)
d_x_real_time[j] = d_x_real_time[j+1];
}
#endif
if (b==NULL)
d_y[k][i][PLOT_SIZE - 1] = 0;
else
if (b->size()-1 >= index[k][i])
{
d_y[k][i][PLOT_SIZE - 1] = b->get(index[k][i]).asDouble();
//if(VERBOSE) fprintf(stderr, "MESSAGE: Getting from port %d the index %d\n", k, index[k][i]);
}
// y moves from left to right:
// Shift y array right and assign new value to y[0].
for ( int j = 0; j < PLOT_SIZE - 1; j++ )
{
d_y[k][i][j] = d_y[k][i][j+1];
}
// update the display
//setAxisScale(QwtPlot::yLeft, min, max);
#ifdef ENABLE_REALTIME
if(numberAcquiredData==PLOT_SIZE && realTime)
{
if(VERBOSE) fprintf(stderr, "MESSAGE: switching to real time\n");
QwtPlotCurve *timeBasedCurve = new QwtPlotCurve("Data");
timeBasedCurve->attach(this);
timeBasedCurve->setRawData(d_x_real_time, d_y[k][i], PLOT_SIZE);
timeBasedCurve->setPen(coloredPens[k%NUMBER_OF_LIN][i%NUMBER_OF_COL]);
nonTimeBasedCurve[k][i].attach(NULL);
//Set title
char cTitle[256];
sprintf(cTitle, "Data(%d)", index[k][i]);
QwtText curveTitle(cTitle, QwtText::PlainText);
curveTitle.setFont(plotFont);
timeBasedCurve->setTitle(curveTitle);
}
#endif
}
}
}
if (acquire)
replot();
numberAcquiredData++;
//if(VERBOSE) fprintf(stderr, "Number of acquired data is %d\n", numberAcquiredData);
//QSize plotSize= this->sizeHint();
//if(VERBOSE) fprintf(stderr, "Hint is: hInt=%d, vInt=%d\n", plotSize.height(), plotSize.width());
static double before = Time::now();
double now = Time::now();
static double meanEffectiveTime = 0;
double currentEffectiveTime = (now - before)*1000.0;
if (numberAcquiredData >= 2)
meanEffectiveTime = (meanEffectiveTime*(numberAcquiredData-2) + currentEffectiveTime)/(numberAcquiredData-1);
//if(VERBOSE) fprintf(stderr, "Iteration %d: Current time is %f and mean is %f\n", numberAcquiredData, currentEffectiveTime, meanEffectiveTime);
//.........这里部分代码省略.........
示例9: QwtPlot
//---------------------------------------------------------------------------
Plot::Plot( size_t streamPos, size_t Type, size_t Group, QWidget *parent ) :
QwtPlot( parent ),
m_streamPos( streamPos ),
m_type( Type ),
m_group( Group )
{
setAutoReplot( false );
QwtPlotCanvas* canvas = dynamic_cast<QwtPlotCanvas*>( this->canvas() );
if ( canvas )
{
canvas->setFrameStyle( QFrame::Plain | QFrame::Panel );
canvas->setLineWidth( 1 );
#if 1
canvas->setPalette( QColor("Cornsilk") );
#endif
}
setAxisMaxMajor( QwtPlot::yLeft, 0 );
setAxisMaxMinor( QwtPlot::yLeft, 0 );
setAxisScaleDraw( QwtPlot::yLeft, new PlotScaleDrawY() );
enableAxis( QwtPlot::xBottom, false );
// something invalid
setAxisScale( QwtPlot::xBottom, -1, 0 );
setAxisScale( QwtPlot::yLeft, -1, 0 );
// Plot grid
QwtPlotGrid *grid = new QwtPlotGrid();
grid->enableXMin( true );
grid->enableYMin( true );
grid->setMajorPen( Qt::darkGray, 0, Qt::DotLine );
grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
grid->attach( this );
m_cursor = new PlotCursor( canvas );
m_cursor->setPosition( 0 );
// curves
for( unsigned j = 0; j < PerStreamType[m_type].PerGroup[m_group].Count; ++j )
{
QwtPlotCurve* curve = new QwtPlotCurve( PerStreamType[m_type].PerItem[PerStreamType[m_type].PerGroup[m_group].Start + j].Name );
switch (m_group)
{
case Group_IDET_S :
case Group_IDET_M :
case Group_IDET_R :
curve->setPen( curveColor( j ), 2 );
break;
default :
curve->setPen( curveColor( j ) );
}
curve->setRenderHint( QwtPlotItem::RenderAntialiased );
curve->setZ( curve->z() - j ); //Invert data order (e.g. MAX before MIN)
curve->attach( this );
m_curves += curve;
}
// visual helpers
if ( m_type == Type_Video )
switch (m_group)
{
case Group_Y :
Plot_AddHLine( this, 16, 61, 89, 171);
Plot_AddHLine( this, 235, 220, 20, 60);
break;
case Group_U :
case Group_V :
Plot_AddHLine( this, 16, 61, 89, 171);
Plot_AddHLine( this, 240, 220, 20, 60);
break;
case Group_Sat :
Plot_AddHLine( this, 88, 255, 0, 255);
Plot_AddHLine( this, 118, 220, 20, 60);
break;
default : ;
}
PlotPicker* picker = new PlotPicker( canvas, &PerStreamType[m_type], m_group, &m_curves );
connect( picker, SIGNAL( moved( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );
connect( picker, SIGNAL( selected( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );
connect( axisWidget( QwtPlot::xBottom ), SIGNAL( scaleDivChanged() ), SLOT( onXScaleChanged() ) );
// legend
m_legend = new PlotLegend();
connect( this, SIGNAL( legendDataChanged( const QVariant &, const QList<QwtLegendData> & ) ),
m_legend, SLOT( updateLegend( const QVariant &, const QList<QwtLegendData> & ) ) );
updateLegend();
}
示例10: if
/**
* @brief Scatterplot2dScopeConfig::loadConfiguration loads the plot configuration into the scope gadget widget
* @param scopeGadgetWidget
*/
void Scatterplot2dScopeConfig::loadConfiguration(ScopeGadgetWidget *scopeGadgetWidget)
{
preparePlot(scopeGadgetWidget);
scopeGadgetWidget->setScope(this);
scopeGadgetWidget->startTimer(m_refreshInterval);
// Configure each data source
foreach (Plot2dCurveConfiguration* plotCurveConfig, m_scatterplotSourceConfigs)
{
QString uavObjectName = plotCurveConfig->uavObjectName;
QString uavFieldName = plotCurveConfig->uavFieldName;
QRgb color = plotCurveConfig->color;
ScatterplotData* scatterplotData;
switch(scatterplot2dType){
case SERIES2D:
scatterplotData = new SeriesPlotData(uavObjectName, uavFieldName);
break;
case TIMESERIES2D:
scatterplotData = new TimeSeriesPlotData(uavObjectName, uavFieldName);
break;
}
scatterplotData->setXWindowSize(timeHorizon);
scatterplotData->setScalePower(plotCurveConfig->yScalePower);
scatterplotData->setMeanSamples(plotCurveConfig->yMeanSamples);
scatterplotData->setMathFunction(plotCurveConfig->mathFunction);
//Generate the curve name
QString curveName = (scatterplotData->getUavoName()) + "." + (scatterplotData->getUavoFieldName());
if(scatterplotData->getHaveSubFieldFlag())
curveName = curveName.append("." + scatterplotData->getUavoSubFieldName());
//Get the uav object
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject((scatterplotData->getUavoName())));
if(!obj) {
qDebug() << "Object " << scatterplotData->getUavoName() << " is missing";
return;
}
//Get the units
QString units = getUavObjectFieldUnits(scatterplotData->getUavoName(), scatterplotData->getUavoFieldName());
//Generate name with scaling factor appeneded
QString curveNameScaled;
if(plotCurveConfig->yScalePower == 0)
curveNameScaled = curveName + "(" + units + ")";
else
curveNameScaled = curveName + "(x10^" + QString::number(plotCurveConfig->yScalePower) + " " + units + ")";
QString curveNameScaledMath;
if (plotCurveConfig->mathFunction == "None")
curveNameScaledMath = curveNameScaled;
else if (plotCurveConfig->mathFunction == "Boxcar average"){
curveNameScaledMath = curveNameScaled + " (avg)";
}
else if (plotCurveConfig->mathFunction == "Standard deviation"){
curveNameScaledMath = curveNameScaled + " (std)";
}
else
{
//Shouldn't be able to get here. Perhaps a new math function was added without
// updating this list?
Q_ASSERT(0);
}
while(scopeGadgetWidget->getDataSources().keys().contains(curveNameScaledMath))
curveNameScaledMath=curveNameScaledMath+"*";
//Create the curve plot
QwtPlotCurve* plotCurve = new QwtPlotCurve(curveNameScaledMath);
plotCurve->setPen(QPen(QBrush(QColor(color), Qt::SolidPattern), (qreal)1, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
plotCurve->setSamples(*(scatterplotData->getXData()), *(scatterplotData->getYData()));
plotCurve->attach(scopeGadgetWidget);
scatterplotData->setCurve(plotCurve);
//Keep the curve details for later
scopeGadgetWidget->insertDataSources(curveNameScaledMath, scatterplotData);
// Connect the UAVO
scopeGadgetWidget->connectUAVO(obj);
}
示例11: plotCurves
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotWidget::plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, double pointMarkerYValue, QString pointMarkerLabel, QString plotTitle, QString yAxisTitle)
{
m_qwtPlot->detachItems(QwtPlotItem::Rtti_PlotCurve);
m_qwtPlot->detachItems(QwtPlotItem::Rtti_PlotMarker);
m_qwtCurveArr.clear();
m_pvtCurveArr.clear();
m_trackerPlotMarker = nullptr;
// Construct an auxiliary curve that connects the first point in all the input curves as a visual aid
// This should only be shown when the phase being plotted is oil
// Will not be added to our array of qwt curves since we do not expect the user to interact with it
{
std::vector<double> xVals;
std::vector<double> yVals;
for (size_t i = 0; i < curveArr.size(); i++)
{
const RigFlowDiagSolverInterface::PvtCurve& curve = curveArr[i];
if (curve.phase == RigFlowDiagSolverInterface::PvtCurve::OIL && curve.pressureVals.size() > 0 && curve.yVals.size() > 0)
{
xVals.push_back(curve.pressureVals[0]);
yVals.push_back(curve.yVals[0]);
}
}
if (xVals.size() > 1)
{
QwtPlotCurve* qwtCurve = new QwtPlotCurve();
qwtCurve->setSamples(xVals.data(), yVals.data(), static_cast<int>(xVals.size()));
qwtCurve->setStyle(QwtPlotCurve::Lines);
qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
QColor curveClr = Qt::darkGreen;
const QPen curvePen(curveClr);
qwtCurve->setPen(curvePen);
qwtCurve->attach(m_qwtPlot);
}
}
// Add the primary curves
for (size_t i = 0; i < curveArr.size(); i++)
{
const RigFlowDiagSolverInterface::PvtCurve& curve = curveArr[i];
QwtPlotCurve* qwtCurve = new QwtPlotCurve();
CVF_ASSERT(curve.pressureVals.size() == curve.yVals.size());
qwtCurve->setSamples(curve.pressureVals.data(), curve.yVals.data(), static_cast<int>(curve.pressureVals.size()));
qwtCurve->setStyle(QwtPlotCurve::Lines);
QColor curveClr = Qt::magenta;
if (curve.phase == RigFlowDiagSolverInterface::PvtCurve::GAS) curveClr = QColor(Qt::red);
else if (curve.phase == RigFlowDiagSolverInterface::PvtCurve::OIL) curveClr = QColor(Qt::green);
const QPen curvePen(curveClr);
qwtCurve->setPen(curvePen);
qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
QwtSymbol* curveSymbol = new QwtSymbol(QwtSymbol::Ellipse);
curveSymbol->setSize(6, 6);
curveSymbol->setPen(curvePen);
curveSymbol->setBrush(Qt::NoBrush);
qwtCurve->setSymbol(curveSymbol);
qwtCurve->attach(m_qwtPlot);
m_qwtCurveArr.push_back(qwtCurve);
}
m_pvtCurveArr = curveArr;
CVF_ASSERT(m_pvtCurveArr.size() == m_qwtCurveArr.size());
// Add vertical marker line to indicate cell pressure
if (pressure != HUGE_VAL)
{
QwtPlotMarker* lineMarker = new QwtPlotMarker;
lineMarker->setXValue(pressure);
lineMarker->setLineStyle(QwtPlotMarker::VLine);
lineMarker->setLinePen(QPen(QColor(128, 128, 255), 1, Qt::DashLine));
lineMarker->setLabel(QString("PRESSURE"));
lineMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignRight);
lineMarker->setLabelOrientation(Qt::Vertical);
lineMarker->attach(m_qwtPlot);
}
// Then point marker
if (pressure != HUGE_VAL && pointMarkerYValue != HUGE_VAL)
{
QwtPlotMarker* pointMarker = new QwtPlotMarker;
pointMarker->setValue(pressure, pointMarkerYValue);
QColor markerClr(128, 0, 255);
QwtSymbol* symbol = new QwtSymbol(QwtSymbol::Ellipse);
//.........这里部分代码省略.........
示例12: setData
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
//.........这里部分代码省略.........
示例13: TimeScaleDraw
QwtGrapher::QwtGrapher(QWidget* parent):
QwtPlot(parent) {
m_values = new TwoDArray<double>(3,100);
plotLayout()->setAlignCanvasToScales(true);
QwtLegend *legend = new QwtLegend;
legend->setItemMode(QwtLegend::CheckableItem);
insertLegend(legend, QwtPlot::RightLegend);
setAxisTitle(QwtPlot::xBottom, " FitnessCases");
/*setAxisScaleDraw(QwtPlot::xBottom,
new TimeScaleDraw(cpuStat.upTime()));
setAxisScale(QwtPlot::xBottom, 0, HISTORY);
setAxisLabelRotation(QwtPlot::xBottom, -50.0);
setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
*/
/*
In situations, when there is a label at the most right position of the
scale, additional space is needed to display the overlapping part
of the label would be taken by reducing the width of scale and canvas.
To avoid this "jumping canvas" effect, we add a permanent margin.
We don't need to do the same for the left border, because there
is enough space for the overlapping label below the left scale.
*/
QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom);
const int fmh = QFontMetrics(scaleWidget->font()).height();
scaleWidget->setMinBorderDist(0, fmh / 2);
setAxisTitle(QwtPlot::yLeft, "Ouput") ;
//setAxisScale(QwtPlot::yLeft, 0, 100);
// Background *bg = new Background();
//bg->attach(this);
/*CpuPieMarker *pie = new CpuPieMarker();
pie->attach(this);
*/
QwtPlotCurve *curve;
curve = new QwtPlotCurve("Best");
curve->setPen(QColor(Qt::green));
curve->attach(this);
m_curves[0] = curve;
curve = new QwtPlotCurve("Average");
curve->setPen(QColor(Qt::blue));
curve->setZ(curve->z() - 1);
curve->attach(this);
m_curves[1] = curve;
curve = new QwtPlotCurve("Worst");
curve->setPen(QColor(Qt::black));
curve->setZ(curve->z() - 2);
curve->attach(this);
m_curves[2] = curve;
showCurve(m_curves[0], true);
showCurve(m_curves[1], true);
showCurve(m_curves[2], true);
connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)),
SLOT(showCurve(QwtPlotItem *, bool)));
}
示例14: setScalingEnabled
void StochasticProcessWidget::setScalingEnabled(
bool isEnabled) {
if (infCurves.size() <= 0) {
return;
}
imatrix distributionMatrix =
process->getDistributions();
int ubDistMatrix = Ub(distributionMatrix, 1);
int lbDistMatrix = Lb(distributionMatrix, 1);
unsigned int distCount = ubDistMatrix -lbDistMatrix
+ 1;
for (unsigned int i = 0; i < distCount; i++) {
if (i >= infCurves.size()) {
return;
}
if (infCurves[i]) {
infCurves[i]->detach();
delete infCurves[i];
}
if (supCurves[i]) {
supCurves[i]->detach();
delete supCurves[i];
}
}
infCurves.clear();
supCurves.clear();
rvector statProbabilities =
process->getStationaryProbabilities();
for (int i = lbDistMatrix; i <= ubDistMatrix; i++) {
ivector values = distributionMatrix[i];
if (isEnabled) {
values *= statProbabilities[i];
}
rvector inf = Inf(values);
rvector sup = Sup(values);
////////////////////////////////////////////
// Update distribution graph
////////////////////////////////////////////
QwtPlotCurve
*infCurve =
PlotUtil::constructCurveFromRVector(inf);
QwtPlotCurve
*supCurve =
PlotUtil::constructCurveFromRVector(sup);
infCurve->attach(distGraph);
supCurve->attach(distGraph);
infCurves.push_back(infCurve);
supCurves.push_back(supCurve);
}
updateColors();
}
示例15: addIntervalDistributionToGraph
bool StochasticProcessWidget::addIntervalDistributionToGraph(
QString title, ivector values) {
rvector inf = Inf(values);
rvector sup = Sup(values);
intervalDists.push_back(values);
////////////////////////////////////////////
// Update distribution graph
////////////////////////////////////////////
QwtPlotCurve *infCurve =
PlotUtil::constructCurveFromRVector(inf);
QwtPlotCurve *supCurve =
PlotUtil::constructCurveFromRVector(sup);
infCurve->attach(distGraph);
supCurve->attach(distGraph);
infCurves.push_back(infCurve);
supCurves.push_back(supCurve);
int columnIndex = distGraphTable->columnCount() - 1;
distGraphTable->setColumnCount(columnIndex + 2);
for (int i = 0; i <= 5; i++) {
distGraphTable->setItem(
i,
columnIndex + 1,
distGraphTable->takeItem(i, columnIndex));
}
QTableWidgetItem *valueItem = new QTableWidgetItem(QString("%1").arg(columnIndex+1));
valueItem->setFlags(Qt::ItemIsUserCheckable
| Qt::ItemIsEnabled);
valueItem->setCheckState(Qt::Checked);
valueItem->setTextAlignment(Qt::AlignCenter);
distGraphTable->setItem(0, columnIndex, valueItem);
double
average =
_double(CompUtil::getExpectationValue(values));
QwtPlotMarker *avgMarker = new QwtPlotMarker();
avgMarker->setLineStyle(QwtPlotMarker::VLine);
avgMarker->setXValue(average);
avgMarker->attach(distGraph);
avgMarkers.push_back(avgMarker);
QTableWidgetItem *avgItem = new QTableWidgetItem(QString("%1").arg(average));
avgItem->setFlags(Qt::ItemIsUserCheckable
| Qt::ItemIsEnabled);
avgItem->setCheckState(Qt::Checked);
avgItem->setTextAlignment(Qt::AlignCenter);
distGraphTable->setItem(1, columnIndex, avgItem);
distGraphTable->resizeRowsToContents();
double
stdDev =
_double(CompUtil::getDistributionStandardDeviation(values));
QwtPlotMarker *lowerStdDevMarker =
new QwtPlotMarker();
lowerStdDevMarker->setLineStyle(QwtPlotMarker::VLine);
lowerStdDevMarker->setXValue(average - stdDev);
lowerStdDevMarker->attach(distGraph);
QwtPlotMarker *upperStdDevMarker =
new QwtPlotMarker();
upperStdDevMarker->setLineStyle(QwtPlotMarker::VLine);
upperStdDevMarker->setXValue(average + stdDev);
upperStdDevMarker->attach(distGraph);
stdDevMarkers.push_back(PlotMarkerPair(
lowerStdDevMarker, upperStdDevMarker));
QTableWidgetItem *stdDevItem =
new QTableWidgetItem(QString("%1").arg(stdDev));
stdDevItem->setFlags(Qt::ItemIsUserCheckable
| Qt::ItemIsEnabled);
stdDevItem->setCheckState(Qt::Checked);
stdDevItem->setTextAlignment(Qt::AlignCenter);
distGraphTable->setItem(2, columnIndex, stdDevItem);
QTableWidgetItem
*statProbItem =
new QTableWidgetItem(QString("%1").arg(_double(statProbs[columnIndex + Lb(statProbs)])));
statProbItem->setTextAlignment(Qt::AlignCenter);
distGraphTable->setItem(3, columnIndex,
statProbItem);
QTableWidgetItem *rangeItem = new QTableWidgetItem(QString("%1 - %2").arg(Lb(values)).arg(Ub(values)));
rangeItem->setTextAlignment(Qt::AlignCenter);
distGraphTable->setItem(4, columnIndex, rangeItem);
QTableWidgetItem *selectAllItem =
new QTableWidgetItem(tr("Show All"));
selectAllItem->setFlags(Qt::ItemIsUserCheckable
| Qt::ItemIsEnabled);
selectAllItem->setCheckState(Qt::Checked);
//.........这里部分代码省略.........