如何在两个鼻窦之间绘制表面

问题描述 投票:0回答:1

我很想在à两条窦曲线之间绘制表面。两条窦曲线的时间基准相同,这意味着两条窦的第一个点的x相同,第二个点也相同。...

所以我该怎么做?我的想法是在2个窦性点之间绘制一束线,但是我没有在qwt中找到一个函数让我在具有相同x和y的两个点之间绘制线。

[如果您有更好的主意,我很乐意听,如果有人已经做到了,那么拥有一个主意将是完美的]

您可以在下面找到我想做的事的例子。

灰色部分正是我想要的。谢谢大家的帮助

enter image description here

c++ qt qwt
1个回答
0
投票

您可以使用QwtPlotIntervalCurve

QwtPlotIntervalCurve

#include <QtWidgets> #include <qwt_plot.h> #include <qwt_plot_curve.h> #include <qwt_plot_intervalcurve.h> #include <cmath> static double f(double x, double A, double W, double B){ return A * std::sin(W * x) + B; } int main(int argc, char *argv[]) { QApplication a(argc, argv); const double deltax = .1; const int size = 100; QVector<QwtIntervalSample> rangeData(size); QVector<QPointF> lowData(size); QVector<QPointF> upperData(size); for(int i=0; i <size; ++i){ double x = deltax * i; double ylow = f(x, 1, 4, -10); double yupper = f(x, 1, 2, 10); lowData[i] = QPointF(x, ylow); upperData[i] = QPointF(x, yupper); rangeData[i] = QwtIntervalSample(x, QwtInterval(ylow, yupper)); } QwtPlot plot; QColor bg(Qt::gray); bg.setAlpha(150); QwtPlotCurve lowcurve; lowcurve.setRenderHint( QwtPlotItem::RenderAntialiased ); lowcurve.setPen(QPen(Qt::gray, 5)); lowcurve.setSamples(lowData); lowcurve.attach(&plot); QwtPlotCurve uppercurve; uppercurve.setRenderHint( QwtPlotItem::RenderAntialiased ); uppercurve.setPen(QPen(Qt::gray, 5)); uppercurve.setSamples(upperData); uppercurve.attach(&plot); QwtPlotIntervalCurve curve; curve.setRenderHint( QwtPlotItem::RenderAntialiased ); curve.setPen(Qt::white); curve.setBrush(bg); curve.setStyle(QwtPlotIntervalCurve::Tube); curve.setSamples( rangeData ); curve.attach(&plot); plot.resize(640, 480); plot.show(); return a.exec(); }

© www.soinside.com 2019 - 2024. All rights reserved.