tripletplot.cpp
Go to the documentation of this file.00001
00014 #include <klocale.h>
00015
00016 #include <qpointarray.h>
00017 #include <qpainter.h>
00018
00019 #include "tripletplot.h"
00020 #include "setiloc.h"
00021
00022
00023 TripletPlot::TripletPlot(SetiLoc* loc, QWidget *parent, const char *name )
00024 : SetiGraph(loc, true, false, parent,name)
00025 {
00026 init();
00027 }
00028
00029
00030 TripletPlot::TripletPlot(QWidget *parent, const char *name )
00031 : SetiGraph(0, true, false, parent,name)
00032 {
00033 init();
00034 }
00035
00036
00037 TripletPlot::~TripletPlot()
00038 {
00039 }
00040
00041
00042 void TripletPlot::init()
00043 {
00044
00045 tripletData.resize(512);
00046
00047 if(m_location)
00048 {
00049
00050 connect(m_location, SIGNAL(newTriplet(TripletScore)),
00051 this, SLOT(showNewTripletData(TripletScore)));
00052
00053 QString title;
00054 title = i18n("Location %1: Top Triplet (right-click for options)").arg(m_location->description());
00055 setCaption(title);
00056 }
00057 setBackgroundColor(black);
00058 resize(350, 200);
00059 setMinimumSize(150, 100);
00060
00061
00062 setMargin(0, 0, 20, 0);
00063
00064 dataLoaded = false;
00065
00066
00067 if(m_location)
00068 showNewTripletData(m_location->tripletScore());
00069 }
00070
00071
00072 void TripletPlot::paintWidget(QPaintDevice* pd)
00073 {
00074 QPainter p;
00075
00076 SetiGraph::paintWidget(pd);
00077 p.begin(pd);
00078 p.translate(0, rect().bottom());
00079
00080 if(dataLoaded)
00081 {
00082 if(arraySize() > 0)
00083 {
00084 QBrush bru;
00085 bru.setStyle(SolidPattern);
00086 bru.setColor(Qt::green);
00087 QPen pen;
00088 pen.setColor(Qt::green);
00089 p.setPen(pen);
00090 p.setBrush(bru);
00091
00092 drawPulseMarker(triplet.tpotind0_0, &p);
00093 drawPulseMarker(triplet.tpotind1_0, &p);
00094 drawPulseMarker(triplet.tpotind2_0, &p);
00095 }
00096 }
00097
00098 p.end();
00099 }
00100
00101
00102 void TripletPlot::showNewTripletData(TripletScore score)
00103 {
00104 triplet = score;
00105 tripletData.resize(triplet.data_len);
00106
00107 if(triplet.data_len > 0)
00108 {
00109 for(int i=0;i<triplet.data_len;i++)
00110 tripletData[i] = (double)triplet.data[i];
00111 }
00112 setCurve(tripletData);
00113
00114
00115 QString it;
00116 it.sprintf("power : %f\n"
00117 "mean : %f\n"
00118 "period: %f\n",
00119 triplet.power,
00120 triplet.mean,
00121 triplet.period);
00122 setInfoText(it);
00123
00124 dataLoaded = true;
00125 repaint();
00126 }
00127
00128
00129 void TripletPlot::drawPulseMarker(int index, QPainter* p)
00130 {
00131 int gw = width() - leftMargin() - rightMargin();
00132 int x = (int)((2*index+1.5)*gw)/arraySize();
00133 int y = -(int)(height() - topMargin());
00134 int w = gw/(2*arraySize()) + 1;
00135 int l = 10;
00136
00137 QPointArray a;
00138 a.setPoints(3, x,y, x-w,y-l, x+w,y-l);
00139 p->drawPolygon(a);
00140 }
00141
00142 #include "tripletplot.moc"
This file is part of the documentation for Ksetiwatch API Version 2.6.1.