{
Q_OBJECT
public:
......
private:
....
}
class my2dPlot : public QWidget
{
Q_OBJECT
public:
my2dPlot(QWidget *parent = 0);
......
private:
QwtPlot *myPlot;
QwtPlotGrid *grid;
QwtPlotCurve *mainCurve;
QwtPlotMarker *mainCurveMarker;
QwtPlotZoomer *m_zoomer;
QwtPlotPicker *d_picker;//<-----
QwtPlotPanner *d_panner;
....
}
To copy to clipboard, switch view to plain text mode
{
public:
{
setRubberBandPen
(QColor(Qt
::green));
//d_picker->setRubberBand(QwtPicker::PolygonRubberBand);
//setTrackerPen(QColor(Qt::yellow));
//setTrackerFont(f);
}
private:
QwtText trackerText
(const QwtDoublePoint
& pos
) const;
};
QwtText PlotPicker
::trackerText (const QwtDoublePoint
& pos
) const {
bgColor.setAlpha(160);
text.
setBackgroundBrush(QBrush(bgColor
));
return text;
}
//i have created my own zoomer, copying the "bode" example
{
public:
{
// RightButton: zoom out by 1
// Ctrl+RightButton: zoom out to full size
Qt::RightButton, Qt::ControlModifier);
Qt::RightButton);
}
};
my2dPlot
::my2dPlot(QWidget *parent
){
.....
m_zoomer
= new Zoomer
( QwtPlot::xBottom,
QwtPlot::yLeft,myPlot
->canvas
());
myPlot->canvas());
.....
}
class PlotPicker : public QwtPlotPicker
{
public:
PlotPicker(QwtPlot::Axis xAxis, QwtPlot::Axis yAxis, QwtPicker::RubberBand rb, QwtPicker::DisplayMode dm, QwtPlotCanvas* canvas):
QwtPlotPicker( xAxis, yAxis, rb , dm , canvas)
{
setStateMachine(new QwtPickerPolygonMachine());
setRubberBandPen(QColor(Qt::green));
//d_picker->setRubberBand(QwtPicker::PolygonRubberBand);
//setTrackerPen(QColor(Qt::yellow));
//setTrackerFont(f);
}
private:
QwtText trackerText (const QwtDoublePoint & pos) const;
};
QwtText PlotPicker::trackerText (const QwtDoublePoint & pos) const
{
QwtText text("(" + QString::number(pos.x()) + "...," + QString::number(pos.y()) + ") " );
QColor bgColor(Qt::blue);
bgColor.setAlpha(160);
text.setBackgroundBrush(QBrush(bgColor));
return text;
}
//i have created my own zoomer, copying the "bode" example
class Zoomer: public QwtPlotZoomer
{
public:
Zoomer(int xAxis, int yAxis, QwtPlotCanvas *canvas):
QwtPlotZoomer(xAxis, yAxis, canvas)
{
setTrackerMode(QwtPicker::AlwaysOff);
setRubberBand(QwtPicker::NoRubberBand);
// RightButton: zoom out by 1
// Ctrl+RightButton: zoom out to full size
setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
}
};
my2dPlot::my2dPlot(QWidget *parent)
: QWidget(parent)
{
.....
myPlot = new QwtPlot;
m_zoomer = new Zoomer( QwtPlot::xBottom, QwtPlot::yLeft,myPlot->canvas());
d_picker = new PlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
QwtPlotPicker::PolygonRubberBand, QwtPicker::AlwaysOn,
myPlot->canvas());
.....
}
To copy to clipboard, switch view to plain text mode
Bookmarks