本文整理汇总了C++中QwtPlotCurve::setStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotCurve::setStyle方法的具体用法?C++ QwtPlotCurve::setStyle怎么用?C++ QwtPlotCurve::setStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotCurve
的用法示例。
在下文中一共展示了QwtPlotCurve::setStyle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
void Plot::add() {
Q_ASSERT(plotWidget && x && y && x->size()==y->size());
setIntervals();
for (int i = 0; i < intervals.size(); ++i) {
QwtPlotCurve *curve = new QwtPlotCurve(yLegend);
curve->setItemAttribute(QwtPlotItem::Legend, showLegend && i==0);
plotWidget->addCurve(curve);
if (type == Trace::Symbols) {
curve->setStyle(QwtPlotCurve::NoCurve);
}
if (type == Trace::Symbols || type == Trace::Both) {
Q_ASSERT(symbol);
curve->setSymbol(symbol);
}
if (type == Trace::Line || type == Trace::Both) {
curve->setPen(pen);
}
Interval iv = intervals[i];
int numPoints = iv.second - iv.first + 1;
if (numPoints <=0 )
Q_ASSERT(numPoints > 0);
curve->setSamples(x->data() + iv.first, y->data() + iv.first, numPoints);
}
}
示例2: drawDots
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();
}
示例3: startNewCurve
void IncrementalPlot::startNewCurve()
{
if (!curves.empty())
curCurveOffset += curves.back()->dataSize();
QwtPlotCurve *newCurve = new QwtPlotCurve("Line");
newCurve->setStyle(QwtPlotCurve::Lines);
newCurve->setPaintAttribute(QwtPlotCurve::PaintFiltered);
newCurve->setPen(QColor(Qt::white));
const QColor &c = Qt::white;
newCurve->setSymbol(QwtSymbol(QwtSymbol::NoSymbol, QBrush(c), QPen(c), QSize(6, 6)));
curves.push_back(newCurve);
newCurve->attach(this);
}
示例4: createCurve
QwtPlotCurve* PowerBarHistoryPlot::createCurve(const QwtText& title, const QPen& pen, ArraySeriesData* data)
{
QwtPlotCurve* curve = new QwtPlotCurve(title);
curve->setStyle(QwtPlotCurve::Lines);
curve->setPen(pen);
curve->setRenderHint(QwtPlotItem::RenderAntialiased, false);
curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, true);
curve->setData(data);
curve->attach(m_plot);
return curve;
}
示例5: updateRDFPlot
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatsGenRDFWidget::updateRDFPlot(QVector<float>& freqs)
{
// These are the output vectors
QwtArray<double> xD(static_cast<int>(freqs.size()));
QwtArray<double> yD(static_cast<int>(freqs.size()));
QLocale loc = QLocale::system();
bool ok = false;
float minDist = loc.toFloat(minDistLE->text(), &ok);
float maxDist = loc.toFloat(maxDistLE->text(), &ok);
const int numValues = freqs.size();
float increment = (maxDist - minDist) / numValues;
double pos = minDist;
for (qint32 i = 0; i < numValues; ++i)
{
xD[i] = pos;
yD[i] = static_cast<double>(freqs.at(i));
pos = pos + increment;
}
// This will actually plot the XY data in the Qwt plot widget
QwtPlotCurve* curve = m_PlotCurve;
#if QWT_VERSION >= 0x060000
curve->setSamples(xD, yD);
#else
curve->setData(xD, yD);
#endif
curve->setStyle(QwtPlotCurve::Lines);
//Use Antialiasing to improve plot render quality
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
QPen pen;
pen.setColor(Qt::white);
pen.setWidth(2);
curve->setPen(pen);//Set colour and thickness for drawing the curve
curve->attach(m_RDFPlot);
m_RDFPlot->replot();
}
示例6: updateMDFPlot
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatsGenMDFWidget::updateMDFPlot(QVector<float>& odf)
{
int err = 0;
int size = 100000;
// These are the input vectors
QVector<float> angles;
QVector<float> axes;
QVector<float> weights;
angles = m_MDFTableModel->getData(SGMDFTableModel::Angle);
weights = m_MDFTableModel->getData(SGMDFTableModel::Weight);
axes = m_MDFTableModel->getData(SGMDFTableModel::Axis);
// These are the output vectors
QVector<float> x;
QVector<float> y;
if ( Ebsd::CrystalStructure::Cubic_High == m_CrystalStructure )
{
// Allocate a new vector to hold the mdf data
QVector<float> mdf(CubicOps::k_MdfSize);
// Calculate the MDF Data using the ODF data and the rows from the MDF Table model
Texture::CalculateMDFData<float, CubicOps>(angles.data(), axes.data(), weights.data(), odf.data(), mdf.data(), static_cast<size_t>(angles.size()));
// Now generate the actual XY point data that gets plotted.
int npoints = 13;
x.resize(npoints);
y.resize(npoints);
err = StatsGen::GenCubicMDFPlotData(mdf.data(), x.data(), y.data(), npoints, size);
if (err < 0)
{
return;
}
}
else if ( Ebsd::CrystalStructure::Hexagonal_High == m_CrystalStructure )
{
// Allocate a new vector to hold the mdf data
QVector<float> mdf(HexagonalOps::k_MdfSize);
// Calculate the MDF Data using the ODF data and the rows from the MDF Table model
Texture::CalculateMDFData<float, HexagonalOps>(angles.data(), axes.data(), weights.data(), odf.data(), mdf.data(), static_cast<size_t>(angles.size()));
// Now generate the actual XY point data that gets plotted.
int npoints = 20;
x.resize(npoints);
y.resize(npoints);
err = StatsGen::GenHexMDFPlotData(mdf.data(), x.data(), y.data(), npoints, size);
if (err < 0) { return; }
}
QwtArray<double> xD(static_cast<int>(x.size()));
QwtArray<double> yD(static_cast<int>(x.size()));
for (qint32 i = 0; i < x.size(); ++i)
{
xD[i] = static_cast<double>(x.at(i));
yD[i] = static_cast<double>(y.at(i));
}
// This will actually plot the XY data in the Qwt plot widget
QwtPlotCurve* curve = m_PlotCurve;
#if QWT_VERSION >= 0x060000
curve->setSamples(xD, yD);
#else
curve->setData(xD, yD);
#endif
QColor color = QColor("DodgerBlue");
curve->setPen(color, 2);
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
curve->setStyle(QwtPlotCurve::Lines);
QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
QBrush( Qt::white ), QPen( color, 2 ), QSize( 8, 8 ) );
curve->setSymbol( symbol );
curve->attach(m_MDFPlot);
m_MDFPlot->replot();
}
示例7: 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
//.........这里部分代码省略.........
示例8: 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);
//.........这里部分代码省略.........
示例9: main
int main(int argc, char *argv[])
{
// QGuiApplication a(argc, argv);
QApplication a(argc, argv);
QwtPlot *plot = new QwtPlot();
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setBorderRadius(10);
plot->setCanvas(canvas);
plot->setCanvasBackground(QColor("LIGHTGRAY"));
plot->enableAxis(QwtPlot::yRight);
plot->enableAxis(QwtPlot::xTop);
plot->setAxisTitle(QwtPlot::xBottom, "Xline");
plot->setAxisTitle(QwtPlot::xTop, "Xline");
plot->setAxisTitle(QwtPlot::yLeft, "Inline");
plot->setAxisTitle(QwtPlot::yRight, "Inline");
// float minx = srv->getStations().first().x();
// float maxx = srv->getStations().last().x();
plot->setAxisScale( QwtPlot::xBottom,3500,300);
// plot->setAxisScale( QwtPlot::xTop,minx,maxx );
// QwtScaleDraw *sd = axisScaleDraw( QwtPlot::yLeft );
// sd->setMinimumExtent( sd->extent( axisWidget( QwtPlot::yLeft )->font() ) );
plot->plotLayout()->setAlignCanvasToScales( true );
QFileDialog custDialog;
QStringList names = custDialog.getOpenFileNames(NULL, ("Open Files..."),QString(), ("UKOOA Files (*.p190 *.p90);;All Files (*)"));
// handle if the dialog was "Cancelled"
if(names.isEmpty())
{
return 0;
}
qSort(names.begin(), names.end());
QVector <QwtPlotCurve *> curves;
foreach (QString name, names)
{
QwtPlotCurve *vCurve = new QwtPlotCurve;
if(name.contains(QString( "NS1763")) || name.contains(QString("NS2029")))
{
QColor c = Qt::red;
vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::red,c , QSize( 2, 2 ) ) );
}
else
{
QColor c = Qt::green;
vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::green,c , QSize( 2, 2 ) ) );
}
vCurve->setStyle( QwtPlotCurve::NoCurve );
vCurve->setPen( Qt::gray );
cout << name.toStdString() << endl;
QVector<QPointF> curveData;
// m_nameLineLable->setText(m_names.at(0));
QFile *ukFile = new QFile(QString(name));
bool rt = ukFile->open(QIODevice::ReadOnly);
cout << "return " << rt << endl;
qint64 icount = 0;
qint64 fileSize = ukFile->size();
char *data = new char[fileSize];
ukFile->read(data,fileSize);
QString sData = data;
QString shot = "SNS";
while (true)
{
ukFile->seek(icount);
ukFile->read(data,fileSize);
sData = data;;
if(icount>=fileSize)
{
break;
}
auto sPos = sData.indexOf(shot,0,Qt::CaseInsensitive);
QString cr = sData.mid(sPos,19);
if(cr.contains("\n"))
{
sPos +=2;
}
// auto shotNo = sData.mid(sPos+20,sPos+5);
QString shotNo = sData.mid(sPos+19,6);
int shotNos;
if(shotNo.contains("\n") || shotNo.contains("\r"))
{
shotNo = sData.mid(sPos+19,8);
int shift1 = shotNo.indexOf("\r");
int shift = shotNo.indexOf("\n");
// cout << shift1 << " " << shift << endl;
QString tmp = shotNo.mid(0,shift1);
tmp.append(shotNo.mid(shift+1,3));
shotNos = tmp.toInt();
}
else
//.........这里部分代码省略.........