PlotWidget
::PlotWidget(QWidget * parent,
double * _ySession,
QString name,
int rate,
int numVis,
int numSess
) {
setAutoReplot(false);
sampRate = rate;
plotName = name;
sizeLoop = numVis;
sizeVisible = numVis;
sizeSession = numSess;
scrollModeOn = false;
clearPlot = false;
indexLoop = 0;
sessionScrollIndex = 0;
pageDiv = 50;
xLoop = new double[sizeLoop];
yLoop = new double[sizeLoop];
ySession = _ySession;
pen
= new QPen(Qt
::black);
penWidth = 1.0;
penWidthDiff = 0.5;
gridMinPenWidth = 1.0;
gridMajPenWidth = 1.0;
for (int i = 0; i < sizeLoop; i++){
xLoop[i] = i;
yLoop[i] = 0.0;
}
//canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
canvas()->setLineWidth(1);
canvas()->setMidLineWidth(0);
setCanvasBackground
(QColor(Qt
::white));
enableAxis
(QwtPlot::xBottom,
false);
setMargin(0);
setAxisScale
(QwtPlot::xBottom,
0.0, sizeLoop
);
setAxisScale
(QwtPlot::yLeft,
1500,
3000,
0 );
setAxisMaxMajor
(QwtPlot::yLeft,
8);
setAxisMaxMinor
(QwtPlot::yLeft,
5);
QwtValueList vlist[3];
for(double i=0;i<sizeLoop; i+=((sizeLoop-0)/13*5))
vlist[0] << i;
for(double i=0;i<sizeLoop; i+=((sizeLoop-0)/13))
vlist[1] << i;
for(double i=0;i<sizeLoop; i+=((sizeLoop-0)/13))
vlist[2] << i;
setAxisScaleDiv
(QwtPlot::xBottom, scdiv
);
// for inside margin
plotLayout()->setAlignCanvasToScales(true);
plotLayout
()->setCanvasMargin
(0,
QwtPlot::xBottom);
plotLayout
()->setCanvasMargin
(0,
QwtPlot::xTop);
plotLayout
()->setCanvasMargin
(0,
QwtPlot::yLeft);
plotLayout
()->setCanvasMargin
(0,
QwtPlot::yRight);
pen->setWidthF(penWidth + penWidthDiff);
curve->setPen(*pen);
curve->attach(this);
curve->setRawData(xLoop, yLoop, sizeLoop);
grid->enableXMin(true);
grid->enableYMin(true);
gridMinPen
= new QPen(QColor(255,
230,
230),
0, Qt
::SolidLine, Qt
::RoundCap, Qt
::RoundJoin);
gridMajPen
= new QPen(QColor(255,
200,
200),
0, Qt
::SolidLine, Qt
::RoundCap, Qt
::RoundJoin);
grid->setMajPen(*gridMajPen);
grid->setMinPen(*gridMinPen);
grid->attach(this);
labelMarker->setValue(QwtDoublePoint(50, 2900));
text.
setColor(QColor(180,
180,
180));
text.setRenderFlags(Qt::AlignLeft);
labelMarker->setLabel(text);
labelMarker->attach(this);
}
PlotWidget::PlotWidget(QWidget * parent, double * _ySession,
QString name, int rate, int numVis, int numSess)
: QwtPlot(parent)
{
setAutoReplot(false);
sampRate = rate;
plotName = name;
sizeLoop = numVis;
sizeVisible = numVis;
sizeSession = numSess;
scrollModeOn = false;
clearPlot = false;
indexLoop = 0;
sessionScrollIndex = 0;
pageDiv = 50;
xLoop = new double[sizeLoop];
yLoop = new double[sizeLoop];
ySession = _ySession;
pen = new QPen(Qt::black);
penWidth = 1.0;
penWidthDiff = 0.5;
gridMinPenWidth = 1.0;
gridMajPenWidth = 1.0;
for (int i = 0; i < sizeLoop; i++){
xLoop[i] = i;
yLoop[i] = 0.0;
}
QwtPainter::setDeviceClipping(false);
canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, true);
canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, true);
//canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
canvas()->setFrameStyle(QFrame::Box | QFrame::Plain);
canvas()->setLineWidth(1);
canvas()->setMidLineWidth(0);
setCanvasBackground(QColor(Qt::white));
enableAxis(QwtPlot::xBottom, false);
enableAxis(QwtPlot::yLeft, false);
setMargin(0);
setAxisScale(QwtPlot::xBottom,0.0, sizeLoop);
setAxisScale(QwtPlot::yLeft,1500, 3000, 0 );
setAxisMaxMajor(QwtPlot::yLeft, 8);
setAxisMaxMinor(QwtPlot::yLeft, 5);
QwtValueList vlist[3];
for(double i=0;i<sizeLoop; i+=((sizeLoop-0)/13*5))
vlist[0] << i;
for(double i=0;i<sizeLoop; i+=((sizeLoop-0)/13))
vlist[1] << i;
for(double i=0;i<sizeLoop; i+=((sizeLoop-0)/13))
vlist[2] << i;
QwtScaleDiv scdiv(0, sizeLoop, vlist);
scdiv.setTicks(QwtScaleDiv::MinorTick, vlist[1]);
setAxisScaleDiv(QwtPlot::xBottom, scdiv);
// for inside margin
plotLayout()->setAlignCanvasToScales(true);
plotLayout()->setCanvasMargin(0,QwtPlot::xBottom);
plotLayout()->setCanvasMargin(0,QwtPlot::xTop);
plotLayout()->setCanvasMargin(0,QwtPlot::yLeft);
plotLayout()->setCanvasMargin(0,QwtPlot::yRight);
curve = new QwtPlotCurve(plotName);
pen->setWidthF(penWidth + penWidthDiff);
curve->setPen(*pen);
curve->attach(this);
curve->setRawData(xLoop, yLoop, sizeLoop);
grid = new QwtPlotGrid;
grid->enableXMin(true);
grid->enableYMin(true);
gridMinPen = new QPen(QColor(255, 230, 230), 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
gridMajPen = new QPen(QColor(255, 200, 200), 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
grid->setMajPen(*gridMajPen);
grid->setMinPen(*gridMinPen);
grid->attach(this);
labelMarker = new QwtPlotMarker;
labelMarker->setValue(QwtDoublePoint(50, 2900));
QwtText text(plotName);
text.setFont(QFont("Verdana", 10, QFont::Bold));
text.setColor(QColor(180,180,180));
text.setRenderFlags(Qt::AlignLeft);
labelMarker->setLabel(text);
labelMarker->attach(this);
}
To copy to clipboard, switch view to plain text mode
Bookmarks