Qwtplotitem (2)

Source: Internet
Author: User

The qwt framework provides several standard implementation elements. Such as grid (qwtplotgrid class), label (qwtplotmarker class), ruler (qwtplotscaleitem class), element displaying SVG format graphics file (qwtplotsvgitem class), spectrum graph (qwtplotspectrogram class) qwtplotcurve, qwtplothistogram, qwtplotintervalcurve, and qwtplotspectrocurve. You can inherit from qwtplotitem to implement elements that meet your needs.

1. qwtplotcurve class: Curve Elements. This class is the most commonly used class, which represents a series of point data. Qwtplotcurve inherits from the qwtplotseriesitem <t> class template, where T is qpointf.

1) attributes:

Class qwtplotcurve: privatedata {public: privatedata (): style (qwtplotcurve: lines), baseline (0.0), symbol (null), attributes (0), paintattributes (qwtplotcurve :: clippolygons), legendattributes (0) {pen = qpen (QT: Black); curvefitter = new qwtsplinecurvefitter ;}~ Privatedata () {Delete symbol; Delete curvefitter;} qwtplotcurve: curvestyle style; // curve style: Double baseline; // baseline, the baseline const qwtsymbol * symbol when filling; // node symbol qwtcurvefitter * curvefitter; // Curve Fitting qpen pen; qbrush brush; // fill brush attributes: curveattributes attributes; qwtplotcurve: paintattributes; attributes :: legendattributes ;};

By setting the curve property value, you can get a variety of curve appearances and representations.

2) data setting interface:

void setSamples( const QVector<QPointF> & );

Almost every qwtplotitem subclass (representator) has an interface function to set data. However, because different qwtplotitem subclasses require different data, this function is not defined as a virtual function.
3) find the nearest vertex:

 int closestPoint( const QPoint &pos, double *dist = NULL ) const;

This is a well-defined interface Example. The return value int indicates the index of the closest point in the curve data; Dist indicates the distance from the closest point to the specified POS.

4) set the node Symbol Representation (pointer transmission ):

    void setSymbol( const QwtSymbol *s );    const QwtSymbol *symbol() const;

The implementation is as follows:

/*! Assign a symbol \ Param symbol \ SA symbol () */void qwtplotcurve: setsymbol (const qwtsymbol * symbol) {If (symbol! = D_data-> symbol) // first judge whether it is the same object value {Delete d_data-> symbol; // Delete the old node symbol object d_data-> symbol = symbol; // value itemchanged (); // update legend and refresh plot }}/*! \ Return current symbol or null, when no symbol has been assigned \ SA setsymbol () */const qwtsymbol * qwtplotcurve: Symbol () const {return d_data-> symbol ;}

2. qwtplotintervalcurve class: draws the interval between two curves. It is often used to display error bars or regions. Inherited from the qwtplotseriesitem class template, where T is qwtintervalsample. [Y1, y2] = f (x)

3. qwtplothistogram class: bar chart. Inherited from the qwtplotseriesitem class template, where T is qwtintervalsample. Note the differences between qwtplothistogram and qwtplotintervalcurve.

Understand the definition of qwtintervalsample: a sample of the types (x1-x2, Y) or (x, y1-y2 ).

4. qwtplotspectrocurve class: Three-dimensional scatter chart, which uses color to represent the Z axis. Inherited from the qwtplotseriesitem <t> class template, where T is qwtpoint3d.

5. qwtplotgrid class: Draw a coordinate grid.

This class provides a variety of attribute setting interfaces. By setting different attribute values, you can get a very beautiful gridded map.

6. qwtplotmarker class: Drawing labels. There are three line styles: horizontal, vertical, and cross.

    void setXValue( double );    void setYValue( double );    void setValue( double, double );    void setValue( const QPointF & );

Double xvalue;
Double yvalue;

What is the meaning (attribute )?

Alignment between labels and cables:

    void setLabelAlignment( Qt::Alignment );    Qt::Alignment labelAlignment() const;

Label (layout) Direction:

    void setLabelOrientation( Qt::Orientation );    Qt::Orientation labelOrientation() const;

7. qwtplotscaleitem class: class used to draw a ruler in the canvas.

A class which draws a scale inside the plot canvas.

Qwtplotscaleitem can
Be used to draw an axis inside the plot canvas. It might by synchronized to one of the axis of the plot, but can also display its own ticks and labels.

It is allowed to synchronize the scale item with a disabled axis. In plots with vertical and horizontal scale items, it might be necessary to remove ticks
The intersections, by overloading updatescalediv ().

The scale might be at a specific position (f.e 0.0) or it might be aligned to a canvas border.

Pass

Void setxaxis (INT axis); // horizontal direction
Void setyaxis (INT axis); // vertical direction

You can specify which axis to bind to qwtplotscaleitem.

Pass

Void setscalediv (const qwtscalediv &);

You can set qwtplotscaleitem to display its own independent scale.

8. qwtplotsvgitem: displays the elements of image data in SVG format.

The example svgmap demonstrates the use of the qwtplotsvgitem class. Imports an image in SVG format.

9. qwtplotrasteritem: displays raster data.

A class, which displays raster data.

Raster Data is a grid of pixel values, that can be represented as a qimage. It is used for your types of information like Spectrograms, cartograms, geographical maps...

Often a plot has several types of raster data organized in layers. (F. e a geographical map, with weather statistics). Using setalpha () raster
Items can be stacked easily.

Qwtplotrasteritem is
Only implemented for images of the following formats: qimage: format_indexed8, qimage: format_argb32.

Qwtplotrasteritem is an abstract class that defines a pure virtual function that renders data into qimage.

    /*!      \brief Render an image       An implementation of render() might iterate over all      pixels of imageRect. Each pixel has to be translated into       the corresponding position in scale coordinates using the maps.      This position can be used to look up a value in a implementation      specific way and to map it into a color.      \param xMap X-Scale Map      \param yMap Y-Scale Map      \param area Requested area for the image in scale coordinates      \param imageSize Requested size of the image     */    virtual QImage renderImage( const QwtScaleMap &xMap,        const QwtScaleMap &yMap, const QRectF &area,        const QSize &imageSize ) const = 0;

10. qwtplotspectrogram class: spectrum graph elements inherited from the qwtplotrasteritem class.


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.