26 #include "moc_qgraphpainter.cpp" 30 QWidget(parent, name, f|WRepaintNoErase|WResizeNoErase){
86 if (te->timerId()==
timer)
91 timer=startTimer(period);
101 for (
unsigned int i=0; i<(
unsigned int)width() && i<
values.size(); i++){
111 painter.setPen(Qt::black);
112 painter.drawRect(0, 0, width(), height());
113 const int boundary=2;
115 double scale=((double)height()-2*boundary-2)/(_max-_min);
118 painter.setPen(Qt::green);
119 painter.drawLine(xoffset+boundary/2, height()-(
int)(scale*(
reference-_min)),
120 width()-boundary/2, height()-(
int)(scale*(
reference-_min)));
122 painter.setPen(Qt::blue);
123 unsigned int start=0;
124 if (
values.size()>(
unsigned int)width()-2*boundary-xoffset)
125 start=
values.size()-width()+2*boundary+xoffset;
127 if ((
unsigned int)width()-2*boundary-xoffset>1 &&
values.size()>1)
128 oldv = (
int)(scale*(
values[1+
start]-_min)) + boundary;
130 for (
unsigned int i=1; i<(
unsigned int)width()-2*boundary-xoffset && i<
values.size(); i++){
131 int v=(int)(scale*(
values[i+start]-_min)) + boundary;
132 painter.drawLine(i-1+boundary+xoffset, height()-boundary-oldv,
133 xoffset+i+boundary, height()-boundary-v);
136 painter.setPen(Qt::black);
137 painter.drawText( 3, height()/2,
title);
138 QFont sansFont(
"Helvetica [Cronyx]", 6);
139 painter.setFont(sansFont);
void setRange(double min, double max)
virtual void timerEvent(QTimerEvent *te)
void setYReference(double y)
virtual void resizeEvent(QResizeEvent *)
void setAutoscale(bool a)
void setTitle(const char *title)
QGraphPainter(QWidget *parent=0, const char *name=0, Qt::WindowFlags f=0)
bool getAutoscale() const
virtual void paintEvent(QPaintEvent *paintevent)