Qwt source code interpretation-picking operations (2)

Source: Internet
Author: User

Iii. qwtplotpicker class:

Qwtplotpicker provides
Selections on a plot canvas.

Qwtplotpicker is
A qwtpicker tailored for selections on a plot canvas.It
Is set to a X-axis and Y-axis and translates all pixel coordinates into this coodinate system.

1. constructor:

/*!  \brief Create a plot picker  The picker is set to those x- and y-axis of the plot  that are enabled. If both or no x-axis are enabled, the picker  is set to QwtPlot::xBottom. If both or no y-axis are  enabled, it is set to QwtPlot::yLeft.  \param canvas Plot canvas to observe, also the parent object  \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect()*/QwtPlotPicker::QwtPlotPicker( QwtPlotCanvas *canvas ):    QwtPicker( canvas ),    d_xAxis( -1 ),    d_yAxis( -1 ){    if ( !canvas )        return;    // attach axes    int xAxis = QwtPlot::xBottom;    const QwtPlot *plot = QwtPlotPicker::plot();    if ( !plot->axisEnabled( QwtPlot::xBottom ) &&        plot->axisEnabled( QwtPlot::xTop ) )    {        xAxis = QwtPlot::xTop;    }    int yAxis = QwtPlot::yLeft;    if ( !plot->axisEnabled( QwtPlot::yLeft ) &&        plot->axisEnabled( QwtPlot::yRight ) )    {        yAxis = QwtPlot::yRight;    }    setAxis( xAxis, yAxis );}

Note:

1) qwtplotpicker is only attached to two axes (X axis and Y axis), and the attached axis must be available (Enabled); otherwise, qwtplotpicker is attached to qwtplot: xbottom and qwtplot by default:: yleft axis.

2) The C ++ constructor has no return value!

If (! Canvas)
Return;

The above code is astonishing ?!

Iv. qwtplotzoomer class

Qwtplotzoomer providesStacked
Zooming for a plot widget.

Qwtplotzoomer offers
Rubberband selections on the plot canvas, translating the selected rectangles into plot coordinates and adjusting the axes to them. zooming can repeated as often as possible, limited only by maxstackdepth () or limit ().Each
Rectangle is pushed on a stack.

Zoom rectangles can be selected depending on selectionflags () using the mouse or keyboard (qwteventpattern, qwtpickermachine ).
Qwteventpattern: mouseselect3, qwteventpattern: keyundo, or qwteventpattern: mouseselect6, qwteventpattern: keyredo walk up and down the zoom stack. qwteventpattern: mouseselect2 or qwteventpattern: keyhome unzoom to the initial size.

Qwtplotzoomer is
Tailored for plots with one X and Y axis, but it is allowed to attach a second qwtplotzoomer
The other axes.

Note:
The realtime example between des an derived Zoomer class that adds scrollbars to the plot canvas.

The qwtplotzoomer class provides the scaling function for a plot component and saves each scaling state to the stack. Therefore, it can be undone and restored at any time. Qwtplotzoomer can only scale one group of x-y axes. Of course, you can use the second qwtplotzoomer to scale the other group of x-y axes.

1. attribute data:

class QwtPlotZoomer::PrivateData{public:    uint zoomRectIndex;    QStack<QRectF> zoomStack;    int maxStackDepth;};

2. Original (basic) size settings:

    virtual void setZoomBase( bool doReplot = true );    virtual void setZoomBase( const QRectF & );

3. scale to the size of a rectangle or stack index:

Virtual void zoom (const qrectf &); Virtual void zoom (INT offset); // offset indicates the offset from the current index.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.