summaryrefslogtreecommitdiffstats
path: root/kalzium/src/plotwidget.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 (patch)
treed3bb9f5d25a2dc09ca81adecf39621d871534297 /kalzium/src/plotwidget.cpp
downloadtdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.tar.gz
tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.zip
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
Diffstat (limited to 'kalzium/src/plotwidget.cpp')
-rw-r--r--kalzium/src/plotwidget.cpp69
1 files changed, 69 insertions, 0 deletions
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 <kdebug.h>
+
+//QT-Includes
+#include <qpainter.h>
+
+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 );
+ }
+}
+