-//Added by qt3to4:
-#include <Q3PtrList>
/***************************************************************************
kplotobject.h - A list of points to be plotted
-------------------
#ifndef KPLOTOBJECT_H
#define KPLOTOBJECT_H
-
class QString;
class QPainter;
#include <kdemacros.h>
-/**class DRect
- *@short equivalent of QRect with double x,y coordinates
- *@author Jason Harris
- *@version 1.0
- */
+/**
+ * @class DRect
+ * @short Equivalent of QRect with double x,y coordinates
+ * @author Jason Harris
+ * @version 1.0
+ */
class KDE_EXPORT DRect {
public:
DRect() { DRect( 0.0, 0.0, 1.0, 1.0 ); }
double X,Y,W,H;
};
-/**class DPoint
- *@short equivalent of QPoint with double x,y coordinates
- *@author Jason Harris
- *@version 1.0
- */
+/**
+ * @class DPoint
+ * @short equivalent of QPoint with double x,y coordinates
+ * @author Jason Harris
+ * @version 1.0
+ */
class KDE_EXPORT DPoint {
public:
DPoint() { DPoint( 0.0, 0.0 ); }
double X, Y;
};
-/**@class KPlotObject
- *@short Encapsulates an object to be plotted in a KPlotWidget.
- *@author Jason Harris
- *@version 1.0
- *Each KPlotObject consists of a list of QPoints, an object type, a color, a size,
- *and a QString name. An additional integer (param) specifies something further
- *about the object's appearance, depending on its type. There is a draw function
- *for plotting the object on a KPlotWidget's QPainter.
- */
+/**
+ * @class KPlotObject
+ * @short Encapsulates an object to be plotted in a KPlotWidget.
+ * @author Jason Harris
+ * @version 1.0
+ * Each KPlotObject consists of a list of QPoints, an object type, a color, a size,
+ * and a QString name. An additional integer (param) specifies something further
+ * about the object's appearance, depending on its type. There is a draw function
+ * for plotting the object on a KPlotWidget's QPainter.
+ */
class KDE_EXPORT KPlotObject{
public:
-/**@enum PTYPE
- *The Type classification of the KPlotObject
- */
+ /**
+ * @enum PTYPE
+ * The Type classification of the KPlotObject
+ */
enum PTYPE { POINTS=0, CURVE=1, LABEL=2, POLYGON=3, UNKNOWN_TYPE };
-/**@enum PPARAM
- *Parameter specifying the kind of points
- */
+ /**
+ * @enum PPARAM
+ * Parameter specifying the kind of points
+ */
enum PPARAM { DOT=0, CIRCLE=1, SQUARE=2, LETTER=3, UNKNOWN_POINT };
-/**@enum CPARAM
- *Parameter specifying the kind of line. These are numerically equal to
- *the Qt::PenStyle enum values.
+ /**
+ * @enum CPARAM
+ * Parameter specifying the kind of line. These are numerically equal to
+ * the Qt::PenStyle enum values.
*/
enum CPARAM { NO_LINE=0, SOLID=1, DASHED=2, DOTTED=3, DASHDOTTED=4, DASHDOTDOTTED=5, UNKNOWN_CURVE };
-/**Default constructor. Create a POINTS-type object with an empty list of points.
- */
+ /**
+ * Default constructor. Create a POINTS-type object with an empty list of points.
+ */
KPlotObject();
-/**Constructor. Create a KPlotObject according to the arguments.
- */
+ /**
+ * Constructor. Create a KPlotObject according to the arguments.
+ */
KPlotObject( const QString &name, const QString &color, PTYPE otype, unsigned int size=2, unsigned int param=0 );
-/**Destructor (empty)
- */
+ /**
+ * Destructor (empty)
+ */
~KPlotObject();
-/**@return the KPlotObject's Name
- */
+ /**
+ * @return the KPlotObject's Name
+ */
QString name() const { return Name; }
-/**@short set the KPlotObject's Name
- *@param n the new name
- */
+ /**
+ * Set the KPlotObject's Name
+ * @param n the new name
+ */
void setName( const QString &n ) { Name = n; }
-/**@return the KPlotObject's Color
- */
+ /**
+ * @return the KPlotObject's Color
+ */
QString color() const { return Color; }
-/**@short set the KPlotObject's Color
- *@param c the new color
- */
+ /**
+ * Set the KPlotObject's Color
+ * @param c the new color
+ */
void setColor( const QString &c ) { Color = c; }
-/**@return the KPlotObject's Type
- */
+ /**
+ * @return the KPlotObject's Type
+ */
PTYPE type() const { return Type; }
-/**@short set the KPlotObject's Type
- *@param t the new type
- */
+ /**
+ * Set the KPlotObject's Type
+ * @param t the new type
+ */
void setType( PTYPE t ) { Type = t; }
-/**@return the KPlotObject's Size
+ /**
+ * @return the KPlotObject's Size
*/
unsigned int size() const { return Size; }
-/**@short set the KPlotObject's Size
- *@param s the new size
- */
+ /**
+ * Set the KPlotObject's Size
+ * @param s the new size
+ */
void setSize( unsigned int s ) { Size = s; }
-/**@return the KPlotObject's type-specific Parameter
- *Parameter is an unsigned int because it can either be a PPARAM or a CPARAM enum.
- */
+ /**
+ * @return the KPlotObject's type-specific Parameter
+ * Parameter is an unsigned int because it can either be a PPARAM or a CPARAM enum.
+ */
unsigned int param() const { return Parameter; }
-/**@short set the KPlotObject's type-specific Parameter
- *@param p the new parameter
- *Parameter is an unsigned int because it can either be a PPARAM or a CPARAM enum.
- */
+ /**
+ * Set the KPlotObject's type-specific Parameter
+ * @param p the new parameter
+ * Parameter is an unsigned int because it can either be a PPARAM or a CPARAM enum.
+ */
void setParam( unsigned int p ) { Parameter = p; }
-/**@return a pointer to the DPoint at position i
- *@param i the index of the desired point.
- */
+ /**
+ * @return a pointer to the DPoint at position i
+ * @param i the index of the desired point.
+ */
DPoint* point( unsigned int i ) { return pList.at(i); }
- Q3PtrList<DPoint>* points() { return &pList; }
+ QList<DPoint*> *points() { return &pList; }
-/**@short Add a point to the object's list.
- *@param p the DPoint to add.
- */
+ /**
+ * Add a point to the object's list.
+ * @param p the DPoint to add.
+ */
void addPoint( const DPoint &p ) { pList.append( new DPoint( p.x(), p.y() ) ); }
-/**@short Add a point to the object's list. This is an overloaded function,
- *provided for convenience. It behaves essentially like the above function.
- *@param p pointer to the DPoint to add.
- */
+ /**
+ * Add a point to the object's list.
+ * @overload
+ * @param p pointer to the DPoint to add.
+ */
void addPoint( DPoint *p ) { pList.append( p ); }
-/**@short remove the QPoint at position index from the list of points
- *@param index the index of the point to be removed.
- */
- void removePoint( unsigned int index );
+ /**
+ * Remove the QPoint at position index from the list of points
+ * @param index the index of the point to be removed.
+ */
+ void removePoint( int index );
-/**@return the number of QPoints currently in the list
- */
+ /**
+ * @return the number of QPoints currently in the list
+ */
unsigned int count() const { return pList.count(); }
-/**@short clear the Object's points list
- */
+ /**
+ * Clear the Object's points list
+ */
void clearPoints() { pList.clear(); }
private:
- Q3PtrList<DPoint> pList;
+ QList<DPoint*> pList;
PTYPE Type;
unsigned int Size, Parameter;
QString Color, Name;
#define _KPLOTWIDGET_H_
#include <qwidget.h>
-//Added by qt3to4:
-#include <QPixmap>
-#include <QResizeEvent>
-#include <QPaintEvent>
-#include <Q3PtrList>
+#include <qlist.h>
#include "kplotobject.h"
#include "kplotaxis.h"
class QColor;
class QPixmap;
-/**@class KPlotWidget
- *@short Genric data plotting widget.
- *@author Jason Harris
- *@version 1.1
- *Widget for drawing plots. Includes adjustable axes (KPlotAxis) with
- *tickmarks and labels and a list of KPlotObjects to be drawn.
- */
+/**
+ * @class KPlotWidget
+ *
+ * @short Genric data plotting widget.
+ *
+ * Widget for drawing plots. Includes adjustable axes (KPlotAxis) with
+ * tickmarks and labels and a list of KPlotObjects to be drawn.
+ *
+ * @author Jason Harris
+ *
+ * @version 1.1
+ */
class KDE_EXPORT KPlotWidget : public QWidget {
Q_OBJECT
public:
- /**@short Constructor. Sets the primary x and y limits in data units.
- *@param x1 the minimum X value in data units
- *@param x2 the maximum X value in data units
- *@param y1 the minimum Y value in data units
- *@param y2 the maximum Y value in data units
- *@param parent the parent widget
- *@param name name label for the KPlotWidget
- */
+ /**
+ * @short Constructor. Sets the primary x and y limits in data units.
+ * @param x1 the minimum X value in data units
+ * @param x2 the maximum X value in data units
+ * @param y1 the minimum Y value in data units
+ * @param y2 the maximum Y value in data units
+ * @param parent the parent widget
+ * @param name name label for the KPlotWidget
+ */
KPlotWidget( double x1=0.0, double x2=1.0, double y1=0.0, double y2=1.0, QWidget *parent=0, const char* name=0 );
- /**Destructor (empty)
- */
+ /**
+ * Destructor (empty)
+ */
virtual ~KPlotWidget();
- /**@short Determine the placement of major and minor tickmarks,
- *based on the current Limit settings
- */
+ /**
+ * @short Determine the placement of major and minor tickmarks,
+ * Based on the current Limit settings
+ */
virtual void updateTickmarks();
- /**@short Reset the data limits.
- *@param x1 the minimum X value in data units
- *@param x2 the maximum X value in data units
- *@param y1 the minimum Y value in data units
- *@param y2 the maximum Y value in data units
- */
+ /**
+ * @short Reset the data limits.
+ * @param x1 the minimum X value in data units
+ * @param x2 the maximum X value in data units
+ * @param y1 the minimum Y value in data units
+ * @param y2 the maximum Y value in data units
+ */
virtual void setLimits( double x1, double x2, double y1, double y2 );
- /**@return the minimum X value in data units*/
+ /**
+ * @return the minimum X value in data units
+ */
virtual double x() const { return DataRect.x(); }
- /**@return the maximum X value in data units*/
+ /**
+ * @return the maximum X value in data units
+ */
virtual double x2() const { return DataRect.x2(); }
- /**@return the minimum Y value in data units*/
+ /**
+ * @return the minimum Y value in data units
+ */
virtual double y() const { return DataRect.y(); }
- /**@return the maximum Y value in data units*/
+ /**
+ * @return the maximum Y value in data units
+ */
virtual double y2() const { return DataRect.y2(); }
- /**@return the width in data units*/
+ /**
+ * @return the width in data units
+ */
virtual double dataWidth() const { return DataRect.width(); }
- /**@return the height in data units*/
+ /**
+ * @return the height in data units
+ */
virtual double dataHeight() const { return DataRect.height(); }
- /**@short Add an item to the list of KPlotObjects to be plotted.
- *@param o pointer to the KPlotObject to be added
- */
+ /**
+ * Add an item to the list of KPlotObjects to be plotted.
+ * @param o pointer to the KPlotObject to be added
+ */
virtual void addObject( KPlotObject *o ) { ObjectList.append( o ); }
- /**@short Remove all items from the list of KPlotObjects
- */
+ /**
+ * Remove all items from the list of KPlotObjects
+ */
virtual void clearObjectList() { ObjectList.clear(); update(); }
- /**@short replace an item in the KPlotObject list.
- *@param i the index of th item to be replaced
- *@param o pointer to the replacement KPlotObject
- */
+ /**
+ * Replace an item in the KPlotObject list.
+ * @param i the index of th item to be replaced
+ * @param o pointer to the replacement KPlotObject
+ */
virtual void replaceObject( int i, KPlotObject *o ) { ObjectList.replace( i, o ); }
- /**@return the number of KPlotObjects in the list
- */
+ /**
+ * @return the number of KPlotObjects in the list
+ */
virtual int objectCount() const { return ObjectList.count(); }
- /**@return a pointer to a specific KPlotObject in the list
- *@param i the index of the desired KPlotObject
+ /**
+ * @return a pointer to a specific KPlotObject in the list
+ * @param i the index of the desired KPlotObject
*/
virtual KPlotObject *object( int i ) { return ObjectList.at(i); }
- /**@return the background color */
+ /**
+ * @return the background color
+ */
virtual QColor bgColor() const { return cBackground; }
- /**@return the foreground color */
+ /**
+ * @return the foreground color
+ */
virtual QColor fgColor() const { return cForeground; }
- /**@return the grid color */
+ /**
+ * @return the grid color
+ */
virtual QColor gridColor() const { return cGrid; }
- /**@short set the background color
- *@param bg the new background color
- */
+ /**
+ * Set the background color
+ * @param bg the new background color
+ */
virtual void setBGColor( const QColor &bg ) { cBackground = bg; setBackgroundColor( bg ); }
- /**@short set the foreground color
- *@param fg the new foreground color
- */
+ /**
+ * Set the foreground color
+ * @param fg the new foreground color
+ */
virtual void setFGColor( const QColor &fg ) { cForeground = fg; }
- /**@short set the grid color
- *@param gc the new grid color
- */
+ /**
+ * Set the grid color
+ * @param gc the new grid color
+ */
virtual void setGridColor( const QColor &gc ) { cGrid = gc; }
- /**@short toggle whether plot axes are drawn.
- *@param show if true, axes will be drawn.
- *The axes are just a box outline around the plot.
- */
+ /**
+ * Toggle whether plot axes are drawn.
+ * @param show if true, axes will be drawn.
+ * The axes are just a box outline around the plot.
+ */
virtual void setShowAxes( bool show ) { BottomAxis.setVisible(show); LeftAxis.setVisible(show); }
- /**@short toggle whether tick marks are drawn along the axes.
- *@param show if true, tick marks will be drawn.
- */
+ /**
+ * Toggle whether tick marks are drawn along the axes.
+ * @param show if true, tick marks will be drawn.
+ */
virtual void setShowTickMarks( bool show ) { ShowTickMarks = show; }
- /**@short toggle whether tick labels are drawn at major tickmarks.
- *@param show if true, tick labels will be drawn.
- */
+ /**
+ * Toggle whether tick labels are drawn at major tickmarks.
+ * @param show if true, tick labels will be drawn.
+ */
virtual void setShowTickLabels( bool show ) { ShowTickLabels = show; }
- /**@short toggle whether grid lines are drawn at major tickmarks.
- *@param show if true, grid lines will be drawn.
- */
+ /**
+ * Toggle whether grid lines are drawn at major tickmarks.
+ * @param show if true, grid lines will be drawn.
+ */
virtual void setShowGrid( bool show ) { ShowGrid = show; }
- /**@short (Deprecated) Sets the X-axis label
- *@param xlabel a short string describing the data plotted on the x-axis.
- *Set the label to an empty string to omit the axis label.
- *This function is deprecated, set the label property in the BottomAxis directly.
- */
+ /**
+ * Sets the X-axis label.
+ * Set the label to an empty string to omit the axis label.
+ *
+ * This function is deprecated, set the label property in the BottomAxis directly.
+ * @param xlabel a short string describing the data plotted on the x-axis.
+ */
virtual void setXAxisLabel( QString xlabel ) { BottomAxis.setLabel(xlabel); }
- /**@short (Deprecated) Sets the Y-axis label
- *@param ylabel a short string describing the data plotted on the y-axis.
- *Set the label to an empty string to omit the axis label.
- *This function is deprecated, set the label property in the LeftAxis directly.
- */
+ /**
+ * Sets the Y-axis label
+ * Set the label to an empty string to omit the axis label.
+ *
+ * This function is deprecated, set the label property in the LeftAxis directly.
+ * @param ylabel a short string describing the data plotted on the y-axis.
+ */
virtual void setYAxisLabel( QString ylabel ) { LeftAxis.setLabel(ylabel); }
- /**@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 are to be drawn.
- */
- virtual int leftPadding() const;
- /**@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.
- */
- virtual int rightPadding() const;
- /**@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.
- */
- virtual int topPadding() const;
- /**@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.
- */
+ /**
+ * @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 are to be drawn.
+ */
+ virtual int leftPadding() const;
+ /**
+ * @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.
+ */
+ virtual int rightPadding() const;
+ /**
+ * @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.
+ */
+ virtual int topPadding() const;
+ /**
+ * @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.
+ */
virtual int bottomPadding() const;
- /**@short 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 the number of pixels to the left of the plot area.
+ * Set this to -1 to revert to automatic determination of padding values.
+ */
virtual void setLeftPadding( int pad ) { LeftPadding = pad; }
- /**@short set the number of pixels to the right of the plot area.
- *Set this to -1 to revert to automatic determination of padding values.
- */
+ /**
+ * Set the number of pixels to the right of the plot area.
+ * Set this to -1 to revert to automatic determination of padding values.
+ */
virtual void setRightPadding( int pad ) { RightPadding = pad; }
- /**@short set the number of pixels above the plot area.
- *Set this to -1 to revert to automatic determination of padding values.
- */
+ /**
+ * Set the number of pixels above the plot area.
+ * Set this to -1 to revert to automatic determination of padding values.
+ */
virtual void setTopPadding( int pad ) { TopPadding = pad; }
- /**@short set the number of pixels below the plot area.
- *Set this to -1 to revert to automatic determination of padding values.
- */
+ /**
+ * Set the number of pixels below the plot area.
+ * Set this to -1 to revert to automatic determination of padding values.
+ */
virtual void setBottomPadding( int pad ) { BottomPadding = pad; }
- /**@short revert all four padding values to be automatically determined. */
+ /**
+ * Revert all four padding values to be automatically determined.
+ */
virtual void setDefaultPadding() { LeftPadding = -1; RightPadding = -1; TopPadding = -1; BottomPadding = -1; }
- /**@short The bottom X axis. */
- KPlotAxis BottomAxis;
- /**@short The left Y axis. */
- KPlotAxis LeftAxis;
+ /**
+ * The bottom X axis.
+ */
+ KPlotAxis BottomAxis;
+ /**
+ * The left Y axis.
+ */
+ KPlotAxis LeftAxis;
protected:
- /**@short the paint event handler, executed when update() or repaint() is called.
- */
- virtual void paintEvent( QPaintEvent* /* e */ );
-
- /**@short the resize event handler, called when the widget is resized.
- */
- virtual void resizeEvent( QResizeEvent* /* e */ );
-
- /**@short draws all of the objects onto the widget. Internal use only; one should simply call update()
- *to draw the widget with axes and all objects.
- *@param p pointer to the painter on which we are drawing
- */
+ /**
+ * The paint event handler, executed when update() or repaint() is called.
+ */
+ virtual void paintEvent( QPaintEvent* );
+
+ /**
+ * The resize event handler, called when the widget is resized.
+ */
+ virtual void resizeEvent( QResizeEvent* );
+
+ /**
+ * Draws all of the objects onto the widget.
+ * @internal Internal use only; one should simply call update()
+ * to draw the widget with axes and all objects.
+ * @param p pointer to the painter on which we are drawing
+ */
virtual void drawObjects( QPainter *p );
- /**@short draws the plot axes and axis labels. Internal use only; one should simply call update()
- *to draw the widget with axes and all objects.
- *@param p pointer to the painter on which we are drawing
- */
+ /**
+ * 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.
+ * @param p pointer to the painter on which we are drawing
+ */
virtual void drawBox( QPainter *p );
- /**@short modulus function for double variables.
- *For example, dmod( 17.0, 7.0 ) returns 3.0
- *@return the remainder after dividing b into a.
- */
+ /**
+ * Modulus function for double variables.
+ * For example:
+ * @code
+ * double m = dmod( 17.0, 7.0 ); // m == 3.0
+ * @endcode
+ * @return the remainder after dividing @p b into @p a.
+ */
double dmod( double a, double b );
//The distance between major tickmarks in data units
QRect PixRect;
//Limits of the plot area in data units
DRect DataRect;
- //List of KPlotObjects
- Q3PtrList<KPlotObject> ObjectList;
+ /**
+ * List of KPlotObjects
+ */
+ QList<KPlotObject*> ObjectList;
//Colors
QColor cBackground, cForeground, cGrid;