From ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kalzium/src/plotwidget.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 kalzium/src/plotwidget.cpp (limited to 'kalzium/src/plotwidget.cpp') diff --git a/kalzium/src/plotwidget.cpp b/kalzium/src/plotwidget.cpp new file mode 100644 index 00000000..3a6f8530 --- /dev/null +++ b/kalzium/src/plotwidget.cpp @@ -0,0 +1,69 @@ +/*************************************************************************** + copyright : (C) 2004, 2005 by Carsten Niehaus + email : cniehaus@kde.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. * + * * + ***************************************************************************/ + +#include "plotwidget.h" +#include "plotwidget.moc" + +//KDE-Includes +#include + +//QT-Includes +#include + +PlotWidget::PlotWidget( double x1, + double x2, + double y1, + double y2, + QWidget *parent, + const char* name) + : KPlotWidget( x1, x2, y1, y2, parent, name ) +{ + m_connectPoints = false; +} + +void PlotWidget::drawObjects( QPainter *p ) +{ + // let the KPlotWidget draw the default stuff first + KPlotWidget::drawObjects(p); + // then draw the connecting lines + if (!m_connectPoints) return; // bail out if connect points is not enabled + + QPoint old; // used to remember last coordinates + bool first = true; + for ( KPlotObject *po = ObjectList.first(); po; po = ObjectList.next() ) + { + // skip empty plot objects + if ( po->points()->count() == 0 ) continue; + // skip non-point plot objects + if (po->type() != KPlotObject::POINTS) continue; + + // draw the connecting lines + p->setPen( QColor( po->color() ) ); + p->setBrush( QColor( po->color() ) ); + for ( DPoint *dp = po->points()->first(); dp; dp = po->points()->next() ) + { + QPoint q = dp->qpoint( PixRect, DataRect ); + + if ( first ) + first = false; + else + p->drawLine(old.x(), old.y(), q.x(), q.y()); + + old.setX( q.x() ); + old.setY( q.y() ); + } + p->setBrush( Qt::NoBrush ); + } +} + -- cgit v1.2.1