QList<KPlotPoint*> pList;
int type;
- PStyle pointStyle;
+ PointStyle pointStyle;
double size;
QPen pen, linePen, barPen, labelPen;
QBrush brush, barBrush;
{
}
-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
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;
}
}
{
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;
}
}
{
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;
}
}
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;
}
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 );
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() )
break;
}
- case SQUARE:
+ case Square:
painter->drawRect( qr );
break;
- case PENTAGON:
+ case Pentagon:
{
QPolygonF pent;
pent << QPointF( q.x(), q.y() - size() )
break;
}
- case HEXAGON:
+ case Hexagon:
{
QPolygonF hex;
hex << QPointF( q.x(), q.y() + size() )
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() ) );
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() )
* 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
* @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.
* @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.
/**
* @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.
*/
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
*/
{
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 );
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) );
{
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 ) {
{
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" );
{
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 );
{
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 );