summaryrefslogtreecommitdiffstats
path: root/libtdeedu/tdeeduplot/kplotobject.h
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-16 16:06:06 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-16 16:06:06 -0600
commit34784ccef6ac9dd33b4460560c68e5422a73560a (patch)
treea206e2a4050c2861ce0706a8fd3542ff29e234e1 /libtdeedu/tdeeduplot/kplotobject.h
parent89354dfc31a795bae9415f79bb07b32be643e4f4 (diff)
downloadtdeedu-34784ccef6ac9dd33b4460560c68e5422a73560a.tar.gz
tdeedu-34784ccef6ac9dd33b4460560c68e5422a73560a.zip
Finish rename from prior commit
Diffstat (limited to 'libtdeedu/tdeeduplot/kplotobject.h')
-rw-r--r--libtdeedu/tdeeduplot/kplotobject.h205
1 files changed, 205 insertions, 0 deletions
diff --git a/libtdeedu/tdeeduplot/kplotobject.h b/libtdeedu/tdeeduplot/kplotobject.h
new file mode 100644
index 00000000..f1074cb6
--- /dev/null
+++ b/libtdeedu/tdeeduplot/kplotobject.h
@@ -0,0 +1,205 @@
+/***************************************************************************
+ kplotobject.h - A list of points to be plotted
+ -------------------
+ begin : Sun 18 May 2003
+ copyright : (C) 2003 by Jason Harris
+ email : kstars@30doradus.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KPLOTOBJECT_H
+#define KPLOTOBJECT_H
+
+
+class TQString;
+class TQPainter;
+
+#include <kdemacros.h>
+
+/**class DRect
+ *@short equivalent of TQRect 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 ); }
+ DRect( double x, double y, double w, double h ) { X = x; Y = y; W = w; H = h; }
+ ~DRect() {}
+
+ double x() const { return X; }
+ double y() const { return Y; }
+ double x2() const { return X + W; }
+ double y2() const { return Y + H; }
+ double width() const { return W; }
+ double height() const { return H; }
+
+ void setX( double x ) { X = x; }
+ void setY( double y ) { Y = y; }
+ void setWidth( double w ) { W = w; }
+ void setHeight( double h ) { H = h; }
+
+private:
+ double X,Y,W,H;
+};
+
+/**class DPoint
+ *@short equivalent of TQPoint with double x,y coordinates
+ *@author Jason Harris
+ *@version 1.0
+ */
+class KDE_EXPORT DPoint {
+public:
+ DPoint() { DPoint( 0.0, 0.0 ); }
+ DPoint( double x, double y ) { setX( x ); setY( y ); }
+ ~DPoint() {}
+
+ double x() const { return X; }
+ double y() const { return Y; }
+
+ TQPoint qpoint( TQRect pb, DRect db ) {
+ int px = pb.left() + int( pb.width()*( x() - db.x() )/db.width() );
+ int py = pb.top() + int( pb.height()*( db.y2() - y() )/db.height() );
+ return TQPoint( px, py );
+ }
+
+ void setX( double x ) { X = x; }
+ void setY( double y ) { Y = y; }
+
+private:
+ 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 TQPoints, an object type, a color, a size,
+ *and a TQString 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 TQPainter.
+ */
+class KDE_EXPORT KPlotObject{
+public:
+/**@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 { DOT=0, CIRCLE=1, SQUARE=2, LETTER=3, UNKNOWN_POINT };
+
+/**@enum CPARAM
+ *Parameter specifying the kind of line. These are numerically equal to
+ *the TQt::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.
+ */
+ KPlotObject();
+
+/**Constructor. Create a KPlotObject according to the arguments.
+ */
+ KPlotObject( const TQString &name, const TQString &color, PTYPE otype, unsigned int size=2, unsigned int param=0 );
+
+/**Destructor (empty)
+ */
+ ~KPlotObject();
+
+/**@return the KPlotObject's Name
+ */
+ TQString name() const { return Name; }
+
+/**@short set the KPlotObject's Name
+ *@param n the new name
+ */
+ void setName( const TQString &n ) { Name = n; }
+
+/**@return the KPlotObject's Color
+ */
+ TQString color() const { return Color; }
+
+/**@short set the KPlotObject's Color
+ *@param c the new color
+ */
+ void setColor( const TQString &c ) { Color = c; }
+
+/**@return the KPlotObject's Type
+ */
+ PTYPE type() const { return Type; }
+
+/**@short set the KPlotObject's Type
+ *@param t the new type
+ */
+ void setType( PTYPE t ) { Type = t; }
+
+/**@return the KPlotObject's Size
+ */
+ unsigned int size() const { return Size; }
+
+/**@short 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.
+ */
+ 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.
+ */
+ void setParam( unsigned int p ) { Parameter = p; }
+
+/**@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); }
+
+ TQPtrList<DPoint>* points() { return &pList; }
+
+/**@short 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.
+ */
+ void addPoint( DPoint *p ) { pList.append( p ); }
+
+/**@short remove the TQPoint at position index from the list of points
+ *@param index the index of the point to be removed.
+ */
+ void removePoint( unsigned int index );
+
+/**@return the number of TQPoints currently in the list
+ */
+ unsigned int count() const { return pList.count(); }
+
+/**@short clear the Object's points list
+ */
+ void clearPoints() { pList.clear(); }
+
+private:
+ TQPtrList<DPoint> pList;
+ PTYPE Type;
+ unsigned int Size, Parameter;
+ TQString Color, Name;
+};
+
+#endif