本文整理汇总了C++中QwtPlotMarker::setXValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotMarker::setXValue方法的具体用法?C++ QwtPlotMarker::setXValue怎么用?C++ QwtPlotMarker::setXValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotMarker
的用法示例。
在下文中一共展示了QwtPlotMarker::setXValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawLapMarkers
void PlotWindow::drawLapMarkers()
{
if (_data_log->numLaps() > 1)
{
for (int i=0; i < _data_log->numLaps(); ++i)
{
QwtPlotMarker* marker = new QwtPlotMarker;
marker->setLineStyle(QwtPlotMarker::VLine);
marker->setLinePen(QPen(Qt::DotLine));
if (_x_axis_measurement->currentIndex() == 0) // time
{
const double time = _data_log->time(_data_log->lap(i).second);
marker->setXValue(time);
}
else // distance
{
const double dist = _data_log->dist(_data_log->lap(i).second);
marker->setXValue(dist);
}
marker->attach(_plot);
marker->show();
_lap_markers.push_back(marker);
}
}
}
示例2: clear
void Plot::clear()
{
this->detachItems();
pointsArr.clear();
// ...a horizontal line at y = 1...
QwtPlotMarker *mY1 = new QwtPlotMarker();
mY1->setLabel( QString::fromLatin1( "y = 1" ) );
mY1->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
mY1->setLineStyle( QwtPlotMarker::HLine );
mY1->setYValue( 1.0 );
mY1->setLinePen(Qt::black, 1, Qt::DashLine);
mY1->attach( this );
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel( QString::fromLatin1( "y = 0" ) );
mY->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
mY->setLineStyle( QwtPlotMarker::HLine );
mY->setYValue( 0.0 );
mY->attach( this );
// ...a vertical line at x = 0
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel( QString::fromLatin1( "x = 0" ) );
mX->setLabelAlignment( Qt::AlignLeft | Qt::AlignBottom );
mX->setLabelOrientation( Qt::Vertical );
mX->setLineStyle( QwtPlotMarker::VLine );
mX->setLinePen( Qt::black, 0, Qt::DashDotLine );
mX->setXValue( 0 );
mX->attach( this );
}
示例3: QDialog
SimDialog::SimDialog( QWidget * parent, Qt::WFlags f)
: QDialog(parent, f)
{
setupUi(this);
// setup the plot ...
m_plot->setTitle("Comparing Similarity Measures");
m_plot->insertLegend(new QwtLegend(), QwtPlot::BottomLegend);
// set up the axes ...
m_plot->setAxisTitle(QwtPlot::xBottom, "Variations");
m_plot->setAxisScale(QwtPlot::xBottom, -10, 10);
m_plot->setAxisTitle(QwtPlot::yLeft, "Similarity");
m_plot->setAxisScale(QwtPlot::yLeft, -1.5, 1.5);
// enable grid ...
QwtPlotGrid *grid = new QwtPlotGrid;
grid->enableXMin(true);
grid->enableYMin(true);
grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
grid->attach(m_plot);
// 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(m_plot);
// Insert zero line at x = 0
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mX->setLineStyle(QwtPlotMarker::VLine);
mX->setXValue(0.0);
mX->attach(m_plot);
// Insert new curves
cReg = new QwtPlotCurve("Regular Similarity Measure");
cReg->attach(m_plot);
cOct = new QwtPlotCurve("Octree based Similarity Measure");
cOct->attach(m_plot);
// Set curve styles
cReg->setPen(QPen(Qt::red, 2));
cOct->setPen(QPen(Qt::blue, 2));
// Populate the volume combos ...
MainWindow* _win = (MainWindow *)this->parent();
viewer3d * _view = (viewer3d *) _win->getViewer();
QList<Volume*> _vols = _view->getVolumes();
// append Volume names to combo boxes ...
// Need to modify Volume class so that it stored patient name ...
// More importantly modify PatientBrowser so that the data can be directly
// loaded.
}
示例4: createVerticalPlotMarker
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtPlotMarker* RicGridStatisticsDialog::createVerticalPlotMarker(const QColor& color, double xValue)
{
QwtPlotMarker* marker = new QwtPlotMarker();
marker->setXValue(xValue);
marker->setLineStyle(QwtPlotMarker::VLine);
marker->setLinePen(color, 2, Qt::SolidLine);
return marker;
}
示例5: setMarkerXPos
/*!
\brief Specify the X position of a marker
\param key Marker key
\param val X position of the marker
\return \c TRUE if the specified marker exists
*/
bool QwtPlot::setMarkerXPos(long key, double val)
{
int rv = FALSE;
QwtPlotMarker *m;
if ((m = d_markers->find(key)))
{
m->setXValue(val);
rv = TRUE;
}
return rv;
}
示例6: addText
void caStripPlot::addText(double x, double y, char* text, QColor c, int fontsize)
{
QwtPlotMarker *mY = new QwtPlotMarker();
QwtText txt;
txt.setText(text);
txt.setFont(QFont("Helvetica",fontsize, QFont::Bold));
txt.setColor(c);
mY->setLabel(txt);
mY->setLabelAlignment(Qt::AlignRight | Qt::AlignTop);
mY->setXValue(x);
mY->setYValue(y);
mY->attach(this);
replot();
}
示例7: setTitle
Plot::Plot()
{
setTitle("A Simple QwtPlot Demonstration");
insertLegend(new QwtLegend(), QwtPlot::RightLegend);
// Set axis titles
setAxisTitle(xBottom, "x -->");
setAxisTitle(yLeft, "y -->");
// Insert new curves
QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
#if QT_VERSION >= 0x040000
cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cSin->setPen(QPen(Qt::red));
cSin->attach(this);
QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)");
#if QT_VERSION >= 0x040000
cCos->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cCos->setPen(QPen(Qt::blue));
cCos->attach(this);
// Create sin and cos data
const int nPoints = 100;
cSin->setData(SimpleData(::sin, nPoints));
cCos->setData(SimpleData(::cos, nPoints));
// Insert markers
// ...a horizontal line at y = 0...
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel(QString::fromLatin1("y = 0"));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->setLineStyle(QwtPlotMarker::HLine);
mY->setYValue(0.0);
mY->attach(this);
// ...a vertical line at x = 2 * pi
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel(QString::fromLatin1("x = 2 pi"));
mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
mX->setLabelOrientation(Qt::Vertical);
mX->setLineStyle(QwtPlotMarker::VLine);
mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine));
mX->setXValue(2.0 * M_PI);
mX->attach(this);
}
示例8: setInitialTimeDisplay
void MainWindow::setInitialTimeDisplay(int start)
{
std::size_t ncols = _vm["file.ncols"].as<int>();
std::size_t nrows = _vm["file.nrows"].as<int>();
//TODO: move plotting to appropiate method
std::size_t numofplottedsamples = _vm["plot.num.samples"].as<int>();
_gridPlot->p->detachItems();
_gridPlot->setoffset(start);
double interrowoffset = _vm["inter.row.offset"].as<double>();
for (std::size_t row=0; row<nrows; ++row){
// for (std::size_t row=0; row<1; ++row){
std::vector<double> xs(numofplottedsamples);
std::vector<double> ys(numofplottedsamples);
std::stringstream strst;
std::string strTitle = "Row";
strst << strTitle << "-" << row;
strTitle = strst.str();
QwtPlotCurve *tscurve = new QwtPlotCurve((char *)strTitle.c_str());
for (std::size_t x = 0; x < numofplottedsamples; ++x)
{
if (x+start<ncols){
xs[x] = (x+start)/_gridPlot->gridXpixelsperunit; //position in seconds
if (_bf!=NULL) {
ys[x] = row*interrowoffset + (*_bf)(row,x+start)/_gridPlot->gridYpixelsperunit; //y value of that sample
} else if (_bfsi!=NULL) {
ys[x] = row*interrowoffset + (*_bfsi)(row,x+start)/_gridPlot->gridYpixelsperunit; //y value of that sample
}
}
}
tscurve->setSamples(&xs[0],&ys[0],xs.size());
tscurve->setPen(QPen(Qt::black));
QwtPlotMarker *rowNameText = new QwtPlotMarker();
rowNameText->setLabel(QString(strTitle.c_str()));
rowNameText->setXValue(xs[0]+0.25);
rowNameText->setYValue(row*interrowoffset-0.5);
rowNameText->attach(_gridPlot->p);
tscurve->attach(_gridPlot->p);
}
_gridPlot->resetzoom();
}
示例9: drawBar
void QmitkTbssRoiAnalysisWidget::drawBar(int x)
{
m_Plot->detachItems(QwtPlotItem::Rtti_PlotMarker, true);
QwtPlotMarker *mX = new QwtPlotMarker();
//mX->setLabel(QString::fromLatin1("selected point"));
mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
mX->setLabelOrientation(Qt::Vertical);
mX->setLineStyle(QwtPlotMarker::VLine);
mX->setLinePen(QPen(Qt::black, 0, Qt::SolidLine));
mX->setXValue(x);
mX->attach(m_Plot);
this->Replot();
}
示例10: populate
void Plot::populate()
{
// Insert new curves
QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
cSin->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
cSin->setPen(QPen(Qt::red));
cSin->attach(this);
QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)");
cCos->setRenderHint(QwtPlotItem::RenderAntialiased);
cCos->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
cCos->setPen(QPen(Qt::blue));
cCos->attach(this);
// Create sin and cos data
cSin->setData(new FunctionData(::sin));
cCos->setData(new FunctionData(::cos));
// Insert markers
// ...a horizontal line at y = 0...
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel(QString::fromLatin1("y = 0"));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->setLineStyle(QwtPlotMarker::HLine);
mY->setYValue(0.0);
mY->attach(this);
// ...a vertical line at x = 2 * pi
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel(QString::fromLatin1("x = 2 pi"));
mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
mX->setLabelOrientation(Qt::Vertical);
mX->setLineStyle(QwtPlotMarker::VLine);
mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine));
mX->setXValue(2.0 * M_PI);
mX->attach(this);
}
示例11: canvasPalette
Plot::Plot(QWidget *parent):
QwtPlot( parent )
{
setAutoFillBackground( true );
setPalette( QPalette( QColor( 165, 193, 228 ) ) );
updateGradient();
setTitle( "График аппроксимации" );
insertLegend( new QwtLegend(), QwtPlot::RightLegend );
// axes
setAxisTitle( xBottom, "" );
setAxisScale( xBottom, 0.0, 10.0 );
setAxisTitle( yLeft, "Функция принадлежности -->" );
setAxisScale( yLeft, 0, 2 );
// canvas
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setLineWidth( 1 );
canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
canvas->setBorderRadius( 15 );
QPalette canvasPalette( Qt::white );
canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
canvas->setPalette( canvasPalette );
setCanvas( canvas );
// panning with the left mouse button
( void ) new QwtPlotPanner( canvas );
// zoom in/out with the wheel
( void ) new QwtPlotMagnifier( canvas );
// ...a horizontal line at y = 0...
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel( QString::fromLatin1( "y = 0" ) );
mY->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
mY->setLineStyle( QwtPlotMarker::HLine );
mY->setYValue( 0.0 );
mY->attach( this );
// ...a horizontal line at y = 1...
QwtPlotMarker *mY1 = new QwtPlotMarker();
mY1->setLabel( QString::fromLatin1( "y = 1" ) );
mY1->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
mY1->setLineStyle( QwtPlotMarker::HLine );
mY1->setYValue( 1.0 );
mY1->setLinePen(Qt::black, 1, Qt::DashLine);
mY1->attach( this );
// ...a vertical line at x = 0
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel( QString::fromLatin1( "x = 0" ) );
mX->setLabelAlignment( Qt::AlignLeft | Qt::AlignBottom );
mX->setLabelOrientation( Qt::Vertical );
mX->setLineStyle( QwtPlotMarker::VLine );
mX->setLinePen( Qt::black, 0, Qt::DashDotLine );
mX->setXValue( 0 );
mX->attach( this );
// curvePoints = new QwtPlotCurve();
// curvePoints->setStyle( QwtPlotCurve::Dots );
// curvePoints->attach( this );
}
示例12: drawHistogram
//.........这里部分代码省略.........
grid->setPen( mGridPen );
grid->attach( mpPlot );
// make colors list
mHistoColors.clear();
foreach ( QgsRendererRangeV2 range, mRanges )
{
mHistoColors << ( range.symbol() ? range.symbol()->color() : Qt::black );
}
//draw histogram
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
QwtPlotHistogram * plotHistogram = 0;
plotHistogram = createPlotHistogram( mRanges.count() > 0 ? mRanges.at( 0 ).label() : QString(),
mRanges.count() > 0 ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
mRanges.count() > 0 ? Qt::NoPen : mPen );
#else
HistogramItem *plotHistogramItem = 0;
plotHistogramItem = createHistoItem( mRanges.count() > 0 ? mRanges.at( 0 ).label() : QString(),
mRanges.count() > 0 ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
mRanges.count() > 0 ? Qt::NoPen : mPen );
#endif
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
QVector<QwtIntervalSample> dataHisto;
#else
// we safely assume that QT>=4.0 (min version is 4.7), therefore QwtArray is a QVector, so don't set size here
QwtArray<QwtDoubleInterval> intervalsHisto;
QwtArray<double> valuesHisto;
#endif
int bins = mBinsSpinBox->value();
QList<double> edges = mHistogram.binEdges( bins );
QList<int> counts = mHistogram.counts( bins );
int rangeIndex = 0;
int lastValue = 0;
for ( int bin = 0; bin < bins; ++bin )
{
int binValue = counts.at( bin );
//current bin crosses two graduated ranges, so we split between
//two histogram items
if ( rangeIndex < mRanges.count() - 1 && edges.at( bin ) > mRanges.at( rangeIndex ).upperValue() )
{
rangeIndex++;
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
plotHistogram->setSamples( dataHisto );
plotHistogram->attach( mpPlot );
plotHistogram = createPlotHistogram( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
dataHisto.clear();
dataHisto << QwtIntervalSample( lastValue, mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) );
#else
plotHistogramItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
plotHistogramItem->attach( mpPlot );
plotHistogramItem = createHistoItem( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
intervalsHisto.clear();
valuesHisto.clear();
intervalsHisto.append( QwtDoubleInterval( mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) ) );
valuesHisto.append( lastValue );
#endif
}
double upperEdge = mRanges.count() > 0 ? qMin( edges.at( bin + 1 ), mRanges.at( rangeIndex ).upperValue() )
: edges.at( bin + 1 );
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
dataHisto << QwtIntervalSample( binValue, edges.at( bin ), upperEdge );
#else
intervalsHisto.append( QwtDoubleInterval( edges.at( bin ), upperEdge ) );
valuesHisto.append( double( binValue ) );
#endif
lastValue = binValue;
}
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
plotHistogram->setSamples( dataHisto );
plotHistogram->attach( mpPlot );
#else
plotHistogramItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
plotHistogramItem->attach( mpPlot );
#endif
mRangeMarkers.clear();
foreach ( QgsRendererRangeV2 range, mRanges )
{
QwtPlotMarker* rangeMarker = new QwtPlotMarker();
rangeMarker->attach( mpPlot );
rangeMarker->setLineStyle( QwtPlotMarker::VLine );
rangeMarker->setXValue( range.upperValue() );
rangeMarker->setLabel( QString::number( range.upperValue() ) );
rangeMarker->setLabelOrientation( Qt::Vertical );
rangeMarker->setLabelAlignment( Qt::AlignLeft | Qt::AlignTop );
rangeMarker->show();
mRangeMarkers << rangeMarker;
}
示例13: MakePlotItems
void Nullcline::MakePlotItems()
{
#ifdef DEBUG_FUNC
ScopeTracker st("Nullcline::MakePlotItems", std::this_thread::get_id());
#endif
std::unique_lock<std::mutex> lock( Mutex() );
if (_packets.empty()) return;
while (_packets.size()>1)
{
delete _packets.front();
_packets.pop_front();
}
Record* record = _packets.front();
_packets.pop_front();
if (!record) return;
lock.unlock();
ClearPlotItems();
const size_t xidx = Spec_toi("xidx"),
yidx = Spec_toi("yidx"),
resolution2 = NumParserMgrs(),
resolution = (int)sqrt(resolution2);
const std::vector< std::pair<int,int> >& xcross_h = record->xcross_h,
& xcross_v = record->xcross_v,
& ycross_h = record->ycross_h,
& ycross_v = record->ycross_v;
const double* x = record->x,
* y = record->y;
const double xinc = record->xinc,
yinc = record->yinc;
const size_t xnum_pts_h = xcross_h.size(),
xnum_pts_v = xcross_v.size(),
ynum_pts_h = ycross_h.size(),
ynum_pts_v = ycross_v.size();
ReservePlotItems(xnum_pts_h + xnum_pts_v + ynum_pts_h + ynum_pts_v);
const QColor& xcolor = _colors.at(xidx+1);
for (size_t i=0; i<xnum_pts_h; ++i)
{
QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
QBrush(xcolor), QPen(xcolor, 2), QSize(5, 5) );
QwtPlotMarker* marker = new QwtPlotMarker();
marker->setSymbol(symbol);
const int idx = xcross_h.at(i).first*resolution + xcross_h.at(i).second;
marker->setXValue(x[idx] + xinc/2.0);
marker->setYValue(y[idx]);
marker->setZ(-1);
AddPlotItem(marker);
}
for (size_t i=0; i<xnum_pts_v; ++i)
{
QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
QBrush(xcolor), QPen(xcolor, 2), QSize(5, 5) );
QwtPlotMarker* marker = new QwtPlotMarker();
marker->setSymbol(symbol);
const int idx = xcross_v.at(i).first*resolution + xcross_v.at(i).second;
marker->setXValue(x[idx]);
marker->setYValue(y[idx] + yinc/2.0);
marker->setZ(-1);
AddPlotItem(marker);
}
QColor ycolor = _colors.at(yidx+1);
for (size_t i=0; i<ynum_pts_h; ++i)
{
QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
QBrush(ycolor), QPen(ycolor, 2), QSize(5, 5) );
QwtPlotMarker* marker = new QwtPlotMarker();
marker->setSymbol(symbol);
const int idx = ycross_h.at(i).first*resolution + ycross_h.at(i).second;
marker->setXValue(x[idx] + xinc/2.0);
marker->setYValue(y[idx]);
marker->setZ(-1);
AddPlotItem(marker);
}
for (size_t i=0; i<ynum_pts_v; ++i)
{
QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
QBrush(ycolor), QPen(ycolor, 2), QSize(5, 5) );
QwtPlotMarker* marker = new QwtPlotMarker();
marker->setSymbol(symbol);
const int idx = ycross_v.at(i).first*resolution + ycross_v.at(i).second;
marker->setXValue(x[idx]);
marker->setYValue(y[idx] + yinc/2.0);
marker->setZ(-1);
AddPlotItem(marker);
}
DrawBase::Initialize(); //Have to wait on this, since we don't know how many objects there
//are until the analysis is complete
delete record;
}
示例14: 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);
//.........这里部分代码省略.........
示例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);
//.........这里部分代码省略.........