1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/***************************************************************************
copyright : (C) 2004, 2005 by Carsten Niehaus
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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 <tqpainter.h>
PlotWidget::PlotWidget( double x1,
double x2,
double y1,
double y2,
TQWidget *parent,
const char* name)
: KPlotWidget( x1, x2, y1, y2, parent, name )
{
m_connectPoints = false;
}
void PlotWidget::drawObjects( TQPainter *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
TQPoint 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( TQColor( po->color() ) );
p->setBrush( TQColor( po->color() ) );
for ( DPoint *dp = po->points()->first(); dp; dp = po->points()->next() )
{
TQPoint 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( TQt::NoBrush );
}
}
|