]> Git trees. - libqmvoc.git/commitdiff
API changes:
authorPino Toscano <pino@kde.org>
Sat, 17 Feb 2007 13:39:33 +0000 (13:39 +0000)
committerPino Toscano <pino@kde.org>
Sat, 17 Feb 2007 13:39:33 +0000 (13:39 +0000)
- remove point(int) and count(), just use points()
- rename PStyle to PointStyle
- CamelCasing the enums

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=634514

kdeeduplot/kplotobject.cpp
kdeeduplot/kplotobject.h
kdeeduplot/tests/testplot_widget.cpp

index 54d73ec06d5f10bbd8a856c4c80e5e222c8d905e..c395254b202caaf8dddff5e586d3eb17c2ec11ee 100644 (file)
@@ -40,7 +40,7 @@ class KPlotObject::Private
 
         QList<KPlotPoint*> pList;
         int type;
-        PStyle pointStyle;
+        PointStyle pointStyle;
         double size;
         QPen pen, linePen, barPen, labelPen;
         QBrush brush, barBrush;
@@ -66,7 +66,7 @@ KPlotPoint::~KPlotPoint()
 {
 }
 
-KPlotObject::KPlotObject( const QColor &c, PlotType t, double size, PStyle ps )
+KPlotObject::KPlotObject( const QColor &c, PlotType t, double size, PointStyle ps )
     : d( new Private( this ) )
 {
        //By default, all pens and brushes are set to the given color
@@ -105,28 +105,28 @@ void KPlotObject::setLabel( int i, const QString &n )
 
 bool KPlotObject::showPoints() const
 {
-    return d->type & KPlotObject::POINTS;
+    return d->type & KPlotObject::Points;
 }
 
 bool KPlotObject::showLines() const
 {
-    return d->type & KPlotObject::LINES;
+    return d->type & KPlotObject::Lines;
 }
 
 bool KPlotObject::showBars() const
 {
-    return d->type & KPlotObject::BARS;
+    return d->type & KPlotObject::Bars;
 }
 
 void KPlotObject::setShowPoints( bool b )
 {
     if ( b )
     {
-        d->type = d->type | KPlotObject::POINTS;
+        d->type = d->type | KPlotObject::Points;
     }
     else
     {
-        d->type = d->type & ~KPlotObject::POINTS;
+        d->type = d->type & ~KPlotObject::Points;
     }
 }
 
@@ -134,11 +134,11 @@ void KPlotObject::setShowLines( bool b )
 {
     if ( b )
     {
-        d->type = d->type | KPlotObject::LINES;
+        d->type = d->type | KPlotObject::Lines;
     }
     else
     {
-        d->type = d->type & ~KPlotObject::LINES;
+        d->type = d->type & ~KPlotObject::Lines;
     }
 }
 
@@ -146,11 +146,11 @@ void KPlotObject::setShowBars( bool b )
 {
     if ( b )
     {
-        d->type = d->type | KPlotObject::BARS;
+        d->type = d->type | KPlotObject::Bars;
     }
     else
     {
-        d->type = d->type & ~KPlotObject::BARS;
+        d->type = d->type & ~KPlotObject::Bars;
     }
 }
 
@@ -164,12 +164,12 @@ void KPlotObject::setSize( double s )
     d->size = s;
 }
 
-unsigned int KPlotObject::pointStyle() const
+KPlotObject::PointStyle KPlotObject::pointStyle() const
 {
     return d->pointStyle;
 }
 
-void KPlotObject::setPointStyle( PStyle p )
+void KPlotObject::setPointStyle( PointStyle p )
 {
     d->pointStyle = p;
 }
@@ -267,16 +267,6 @@ void KPlotObject::removePoint( int index ) {
        d->pList.removeAt( index );
 }
 
-KPlotPoint* KPlotObject::point( int index )
-{
-    return d->pList[index];
-}
-
-int KPlotObject::count() const
-{
-    return d->pList.count();
-}
-
 void KPlotObject::clearPoints()
 {
     qDeleteAll( d->pList );
@@ -351,15 +341,15 @@ void KPlotObject::draw( QPainter *painter, KPlotWidget *pw ) {
                                painter->setBrush( brush() );
        
                                switch ( pointStyle() ) {
-                               case CIRCLE:
+                               case Circle:
                                        painter->drawEllipse( qr );
                                        break;
        
-                               case LETTER:
+                               case Letter:
                                        painter->drawText( qr, Qt::AlignCenter, pp->label().left(1) );
                                        break;
        
-                               case TRIANGLE:
+                               case Triangle:
                                        {
                                                QPolygonF tri;
                                                tri << QPointF( q.x() - size(), q.y() + size() ) 
@@ -369,11 +359,11 @@ void KPlotObject::draw( QPainter *painter, KPlotWidget *pw ) {
                                                break;
                                        }
        
-                               case SQUARE:
+                               case Square:
                                        painter->drawRect( qr );
                                        break;
        
-                               case PENTAGON:
+                               case Pentagon:
                                        {
                                                QPolygonF pent;
                                                pent << QPointF( q.x(), q.y() - size() ) 
@@ -385,7 +375,7 @@ void KPlotObject::draw( QPainter *painter, KPlotWidget *pw ) {
                                                break;
                                        }
        
-                               case HEXAGON:
+                               case Hexagon:
                                        {
                                                QPolygonF hex;
                                                hex << QPointF( q.x(), q.y() + size() ) 
@@ -398,7 +388,7 @@ void KPlotObject::draw( QPainter *painter, KPlotWidget *pw ) {
                                                break;
                                        }
        
-                               case ASTERISK:
+                               case Asterisk:
                                        painter->drawLine( q, QPointF( q.x(), q.y() + size() ) );
                                        painter->drawLine( q, QPointF( q.x() + size(), q.y() + 0.5*size() ) );
                                        painter->drawLine( q, QPointF( q.x() + size(), q.y() - 0.5*size() ) );
@@ -407,7 +397,7 @@ void KPlotObject::draw( QPainter *painter, KPlotWidget *pw ) {
                                        painter->drawLine( q, QPointF( q.x() - size(), q.y() - 0.5*size() ) );
                                        break;
        
-                               case STAR:
+                               case Star:
                                        {
                                                QPolygonF star;
                                                star << QPointF( q.x(), q.y() - size() ) 
index 728bcff7f4968d645182dfe7ff94d1bf7db87dc3..d8334d87dd5c350ed7de6c0d40ac26a3e79a2aa2 100644 (file)
@@ -150,7 +150,13 @@ public:
         * These are bitmask values that can be OR'd together, so that a set 
         * of points can be represented in the plot in multiple ways.
         */
-       enum PlotType { POINTS=1, LINES=2, BARS=4, UNKNOWN_TYPE };
+        enum PlotType
+        {
+            UnknownType = 0,
+            Points = 1,
+            Lines = 2,
+            Bars = 4
+        };
 
        /**
         * @enum PStyle
@@ -164,7 +170,19 @@ public:
         * @li ASTERISK
         * @li STAR
         */
-       enum PStyle { NOPOINTS=0, CIRCLE=1, LETTER=2, TRIANGLE=3, SQUARE=4, PENTAGON=5, HEXAGON=6, ASTERISK=7, STAR=8, UNKNOWN_POINT };
+        enum PointStyle
+        {
+            NoPoints = 0,
+            Circle = 1,
+            Letter = 2,
+            Triangle = 3,
+            Square = 4,
+            Pentagon = 5,
+            Hexagon = 6,
+            Asterisk = 7,
+            Star = 8,
+            UnknwonPoint
+        };
 
        /**
         * Constructor. Create a KPlotObject according to the arguments.
@@ -175,7 +193,7 @@ public:
         * @param size the size to use for the drawn points, in pixels
         * @param ps The PStyle describing the shape for the drawn points
         */
-        explicit KPlotObject( const QColor &color = Qt::white, PlotType otype = POINTS, double size = 2, PStyle ps = CIRCLE );
+        explicit KPlotObject( const QColor &color = Qt::white, PlotType otype = Points, double size = 2, PointStyle ps = Circle );
 
        /**
         * Destructor.
@@ -240,13 +258,13 @@ public:
        /**
         * @return the KPlotObject's PointStyle value
         */
-        unsigned int pointStyle() const;
+        PointStyle pointStyle() const;
 
        /**
         * Set the KPlotObject's type-specific Parameter
         * @param p the new parameter
         */
-        void setPointStyle( PStyle p );
+        void setPointStyle( PointStyle p );
 
        /**
         * @return the default pen for this Object.
@@ -346,17 +364,6 @@ public:
         */
        void removePoint( int index );
 
-       /**
-        * @return a pointer to the KPlotPoint at the given position in the list
-        * @param index the index of the point in the list
-        */
-        KPlotPoint* point( int index );
-
-       /**
-        * @return the number of QPoints currently in the list
-        */
-        int count() const;
-
        /**
         * Clear the Object's points list
         */
index c63733846f6472a34fb6a15e40f1c20bc8eebb88..df3d5cdc886d947d08d228bd4e9969c7d3d7fb60 100644 (file)
@@ -58,8 +58,8 @@ void TestPlot::slotSelectPlot( int n ) {
                {
                        plot->setLimits( -6.0, 11.0, -10.0, 110.0 );
                        
-                       po1 = new KPlotObject( Qt::white, KPlotObject::POINTS, 4, KPlotObject::ASTERISK );
-                       po2 = new KPlotObject( Qt::green, KPlotObject::POINTS, 4, KPlotObject::TRIANGLE );
+                       po1 = new KPlotObject( Qt::white, KPlotObject::Points, 4, KPlotObject::Asterisk );
+                       po2 = new KPlotObject( Qt::green, KPlotObject::Points, 4, KPlotObject::Triangle );
 
                        for ( float x=-5.0; x<=10.0; x+=1.0 ) {
                                po1->addPoint( x, x*x );
@@ -81,8 +81,8 @@ void TestPlot::slotSelectPlot( int n ) {
                        plot->axis(KPlotWidget::BottomAxis)->setLabel("Angle [radians]");
                        plot->axis(KPlotWidget::TopAxis)->setLabel("Angle [degrees]");
 
-                       po1 = new KPlotObject( Qt::red,  KPlotObject::LINES, 2 );
-                       po2 = new KPlotObject( Qt::cyan, KPlotObject::LINES, 2 );
+                       po1 = new KPlotObject( Qt::red,  KPlotObject::Lines, 2 );
+                       po2 = new KPlotObject( Qt::cyan, KPlotObject::Lines, 2 );
 
                        for ( float t=0.0; t<=6.28; t+=0.04 ) {
                                po1->addPoint( t, sin(t) );
@@ -100,7 +100,7 @@ void TestPlot::slotSelectPlot( int n ) {
                {
                        plot->setLimits( -7.0, 7.0, -5.0, 105.0 );
 
-                       po1 = new KPlotObject( Qt::white, KPlotObject::BARS, 2 );
+                       po1 = new KPlotObject( Qt::white, KPlotObject::Bars, 2 );
                        po1->setBarBrush( QBrush(Qt::green, Qt::Dense4Pattern) );
 
                        for ( float x=-6.5; x<=6.5; x+=0.5 ) {
@@ -117,7 +117,7 @@ void TestPlot::slotSelectPlot( int n ) {
                {
                        plot->setLimits( -1.1, 1.1, -1.1, 1.1 );
 
-                       po1 = new KPlotObject( Qt::yellow, KPlotObject::POINTS, 10, KPlotObject::STAR );
+                       po1 = new KPlotObject( Qt::yellow, KPlotObject::Points, 10, KPlotObject::Star );
                        po1->setLabelPen( QPen(Qt::green) );
 
                        po1->addPoint(  0.0,  0.8, "North" );
@@ -139,7 +139,7 @@ void TestPlot::slotSelectPlot( int n ) {
                {
                        plot->setLimits( -2.1, 2.1, -0.1, 4.1 );
 
-                       po1 = new KPlotObject( Qt::white, KPlotObject::POINTS, 10, KPlotObject::PENTAGON );
+                       po1 = new KPlotObject( Qt::white, KPlotObject::Points, 10, KPlotObject::Pentagon );
 
                        po1->setShowLines( true );
                        po1->setShowBars( true );
@@ -166,7 +166,7 @@ void TestPlot::slotSelectPlot( int n ) {
                {
                        plot->setLimits( -2.1, 2.1, -0.1, 4.1 );
 
-                       po1 = new KPlotObject( Qt::white, KPlotObject::POINTS, 10, KPlotObject::PENTAGON );
+                       po1 = new KPlotObject( Qt::white, KPlotObject::Points, 10, KPlotObject::Pentagon );
 
                        po1->setShowLines( true );
                        po1->setShowBars( true );