class KPlotWidget |
|
KPlotWidget
Generic data plotting widget. Widget for drawing plots. The basic idea behind KPlotWidget is that you don't have to worry about any transformation from your data's natural units to screen pixel coordinates; this is handled internally by the widget. Data to be plotted are represented by one or more instances of KPlotObject. KPlotObject contains a list of QPointFs to be plotted (again, in the data's natural units), as well as information about how the data are to be rendered in the plot (i.e., as separate points or connected by lines? With what color and point style? etc). See KPlotObject for more information. KPlotWidget automatically adds axis labels with tickmarks and tick labels. These are encapsulated in the KPlotAxis class. All you have to do is set the limits of the plotting area in data units, and KPlotWidget wil figure out the optimal positions and labels for the tickmarks on the axes. Example of usage:
KPlotWidget *kpw = new KPlotWidget( parent ); // setting our limits for the plot kpw->setLimits( 1.0, 5.0, 1.0, 25.0 ); KPlotWidget will take care of the objects added to it, so when clearing the objects list (eg with removeAllPlotObjects()) any previous reference to a KPlotObject already added to a KPlotWidget will be invalid. Author Jason Harris Version: 1.1 |
|
Constructor.
parent - the parent widget |
|
|
Add an item to the list of KPlotObjects to be plotted.
do not use this multiple time if many objects have to be added,
addPlotObjects() is strongly suggested in this case
object - the KPlotObject to be added |
|
Add more than one KPlotObject at one time.
objects - the list of KPlotObjects to be added |
|
Returns whether the antialiasing is active Antialiasing is not active by default. |
|
Returns the axis of the specified type, or 0 if no axis has been set.
See also Axis |
|
Returns the axis of the specified type, or 0 if no axis has been set.
See also Axis |
|
Returns the background color of the plot.
The default color is black. |
|
Returns the number of pixels below the plot area. Padding values are set to -1 by default; if unchanged, this function will try to guess a good value, based on whether ticklabels and/or axis labels are to be drawn. |
|
Unset the secondary limits, so the top and right axes show the same tickmarks as the bottom and left axes (no tickmark labels will be drawn for the top and right axes in this case) |
|
Returns the rectangle representing the boundaries of the current plot,
in natural data units.
See also setLimits() |
|
Draws the plot axes and axis labels.
Internal Internal use only; one should simply call update()
to draw the widget with axes and all objects.
p - pointer to the painter on which we are drawing |
|
Generic event handler. |
|
Returns the foreground color, used for axes, tickmarks and associated
labels.
The default color is white. |
|
Returns the grid color.
The default color is gray. |
|
Returns whether the grid lines are shown Grid lines are not shown by default. |
|
Returns whether the tooltip for the point objects is shown. Tooltips are enabled by default. |
|
Returns the number of pixels to the left of the plot area.
Padding values are set to -1 by default; if unchanged, this function will try to guess a good value, based on whether ticklabels and/or axis labels need to be drawn. |
|
Map a coordinate
p - from the data rect to the physical
pixel rect.
Used mainly when drawing.
p - the point to be converted, in natural data units Returns the coordinate in the pixel coordinate system |
|
Indicate that object labels should try to avoid the line
joining the two given points (in pixel coordinates).
You should not normally call this function directly. It is called by KPlotObject when lines are drawn in the plot. p1 - the starting point for the line p2 - the ending point for the line value - Allows you to determine how strongly the line should be avoided. Larger values are avoided more strongly. |
|
Indicate that object labels should try to avoid the given
rectangle in the plot. The rectangle is in pixel coordinates.
You should not normally call this function directly. It is called by KPlotObject when points, bars and labels are drawn. r - the rectangle defining the region in the plot that text labels should avoid (in pixel coordinates) value - Allows you to determine how strongly the rectangle should be avoided. Larger values are avoided more strongly. |
|
Returns suggested minimum size for the plot widget |
|
The paint event handler, executed when update() or repaint() is called. |
|
Returns the rectangle representing the boundaries of the current plot, in screen pixel units. |
|
Place an object label optimally in the plot. This function will
attempt to place the label as close as it can to the point to which
the label belongs, while avoiding overlap with regions of the plot
that have been masked.
You should not normally call this function directly. It is called internally in KPlotObject.draw(). painter - Pointer to the painter on which to draw the label pp - pointer to the KPlotPoint whose label is to be drawn. |
|
Returns the current list of plot objects |
|
Returns a list of points in the plot which are within 4 pixels
of the screen position given as an argument.
p - The screen position from which to check for plot points. |
|
Remove and delete all items from the list of KPlotObjects |
|
Replace an item in the KPlotObject list.
i - the index of the item to be replaced o - pointer to the replacement KPlotObject |
|
Clear the object list, reset the data limits, and remove axis labels |
|
Reset the mask used for non-overlapping labels so that all regions of the plot area are considered empty. |
|
The resize event handler, called when the widget is resized. |
|
Returns the number of pixels to the right of the plot area. Padding values are set to -1 by default; if unchanged, this function will try to guess a good value, based on whether ticklabels and/or axis labels are to be drawn. |
|
Returns the rectangle representing the boundaries of the secondary
data limits, if they have been set. Otherwise, this function
behaves the same as dataRect().
See also setSecondaryLimits() |
|
Toggle antialiased drawing.
b - if true, the plot graphics will be antialiased. |
|
Set the background color
bg - the new background color |
|
Set the number of pixels below the plot area. Set this to -1 to revert to automatic determination of padding values. |
|
Revert all four padding values to -1, so that they will be automatically determined. |
|
Set the foreground color
fg - the new foreground color |
|
Set the grid color
gc - the new grid color |
|
Set the number of pixels to the left of the plot area. Set this to -1 to revert to automatic determination of padding values. |
|
Set new data limits for the plot.
x1 - the minimum X value in data units x2 - the maximum X value in data units y1 - the minimum Y value in data units y2 - the maximum Y value in data units |
|
Toggle the display of a tooltip for point objects.
show - whether show the tooltip. See also isObjectToolTipShown() |
|
Synchronize the PixRect with the current widget size and padding settings. |
|
Set the number of pixels to the right of the plot area. Set this to -1 to revert to automatic determination of padding values. |
|
Reset the secondary data limits, which control the
values displayed along the top and right axes.
All data points are *plotted* using the coordinates defined by setLimits(), so this function is only useful for showing alternate tickmark labels along the top and right edges. For example, if you were plotting temperature on the X-axis, you could use Centigrade units for the primary (bottom) axis, using setLimits( 0.0, 100.0, 0.0, 1.0 ). If you also wanted to show Farenheit units along the secondary (top) axis, you would additionally use setSecondaryLimits( 32.0, 212.0, 0.0, 1.0 ). The data added to the plot would have x-coordinates in Centigrade degrees. x1 - the minimum X value in secondary data units x2 - the maximum X value in secondary data units y1 - the minimum Y value in secondary data units y2 - the maximum Y value in secondary data units See also setLimits() |
|
Toggle whether grid lines are drawn at major tickmarks.
show - if true, grid lines will be drawn. See also isGridShown() |
|
Set the number of pixels above the plot area. Set this to -1 to revert to automatic determination of padding values. |
|
Returns suggested size for the plot widget |
|
Returns the number of pixels above the plot area. Padding values are set to -1 by default; if unchanged, this function will try to guess a good value, based on whether ticklabels and/or axis labels are to be drawn. |
The four types of plot axes.
LeftAxis | - 0 | - | ||
BottomAxis | - | - | ||
RightAxis | - | - | ||
TopAxis | - | - |