#include "curve.h"
{
public:
{
setRubberBandPen
(QPen(Qt
::darkGreen,
1.5, Qt
::SolidLine));
}
{
text.
setBackgroundBrush( QBrush( bg
));
return text;
}
virtual void rescale()
{
}
};
{
QFont font
("Arial" ,
12);
plotZoom = new Zoomer(plot->canvas());
//plotTitle
plotTitle.setFont(font);
plotTitle.setText(title);
//plotGrid
plotGrid->enableXMin(true);
plotGrid->enableYMin(true);
plotGrid
->setMajPen
(QPen(Qt
::black,
1,Qt
::SolidLine));
plotGrid
->setMinPen
(QPen(Qt
::darkGray,
0,Qt
::DotLine));
plotGrid->attach(plot);
//Plot
plot->setTitle(plotTitle);
plot->setMaximumSize(800,800);
plot->setMinimumSize(400,400);
plot->setCanvasLineWidth(2);
plot
->setCanvasBackground
(QBrush(QColor(240,
240,
240), Qt
::SolidPattern));
plot->setAxisFont(0, font);
plot->setAxisFont(2, font);
plot->axisWidget(0)->setMargin(0);
plot->axisWidget(2)->setMargin(0);
plot->plotLayout()->setAlignCanvasToScales(true);
plotGridLayout->addWidget(plot);
this->setLayout(plotGridLayout);
}
//plotCurve
void curve
::createCurve(const QVector<QPointF>
&vector,
const QString &title
) {
//Std Color = blue
plotCurve
->setPen
(QPen(Qt
::blue,
1.5));
//Std_style = lines, antialiased
plotCurve
->setRenderHint
(QwtPlotItem::RenderAntialiased);
//Points = vector
plotCurve->setSamples(vector);
//Std_Plot = plot
plotCurve->attach(plot);
}
#include "curve.h"
class Zoomer: public QwtPlotZoomer
{
public:
Zoomer(QwtPlotCanvas *canvas):
QwtPlotZoomer(canvas)
{
setRubberBandPen(QPen(Qt::darkGreen, 1.5, Qt::SolidLine));
}
virtual QwtText trackerTextF(const QPointF &pos) const
{
QColor bg(Qt::white);
QwtText text = QwtPlotZoomer::trackerTextF(pos);
text.setBackgroundBrush( QBrush( bg ));
return text;
}
virtual void rescale()
{
QwtPlotZoomer::rescale();
}
};
curve::curve(QWidget *parent, const QString &title) : QWidget()
{
QFont font("Arial" , 12);
plot = new QwtPlot;
plotGrid = new QwtPlotGrid;
plotGridLayout = new QGridLayout;
plotZoom = new Zoomer(plot->canvas());
//plotTitle
plotTitle.setFont(font);
plotTitle.setText(title);
//plotGrid
plotGrid->enableXMin(true);
plotGrid->enableYMin(true);
plotGrid->setMajPen(QPen(Qt::black,1,Qt::SolidLine));
plotGrid->setMinPen(QPen(Qt::darkGray,0,Qt::DotLine));
plotGrid->attach(plot);
//Plot
plot->setTitle(plotTitle);
plot->setMaximumSize(800,800);
plot->setMinimumSize(400,400);
plot->setCanvasLineWidth(2);
plot->setCanvasBackground(QBrush(QColor(240,240,240), Qt::SolidPattern));
plot->setAxisFont(0, font);
plot->setAxisFont(2, font);
plot->axisWidget(0)->setMargin(0);
plot->axisWidget(2)->setMargin(0);
plot->plotLayout()->setAlignCanvasToScales(true);
plotGridLayout->addWidget(plot);
this->setLayout(plotGridLayout);
}
//plotCurve
void curve::createCurve(const QVector<QPointF> &vector, const QString &title)
{
plotCurve = new QwtPlotCurve(title);
//Std Color = blue
plotCurve->setPen(QPen(Qt::blue, 1.5));
plotCurve->setSymbol(new QwtSymbol(QwtSymbol::XCross, Qt::NoBrush, QPen(Qt::black), QSize(3, 3)));
//Std_style = lines, antialiased
plotCurve->setCurveAttribute(QwtPlotCurve::Fitted);
plotCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
//Points = vector
plotCurve->setSamples(vector);
//Std_Plot = plot
plotCurve->attach(plot);
}
To copy to clipboard, switch view to plain text mode
Bookmarks