huseyinkozan
19th March 2009, 19:59
Hi,
This is the code in the constructor :
PlotWidget::PlotWidget(QWidget * parent, double * _ySession,
QString name, int rate, int numVis, int numSess)
: QwtPlot(parent) {
// data stuff....
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);
setAxisScaleDiv(QwtPlot::xBottom, scdiv);
// for inside margin (I think)
axisScaleEngine(QwtPlot::xBottom)->setAttributes(QwtScaleEngine::Floating);
axisScaleEngine(QwtPlot::xTop)->setAttributes(QwtScaleEngine::Floating);
axisScaleEngine(QwtPlot::yLeft)->setAttributes(QwtScaleEngine::Floating);
axisScaleEngine(QwtPlot::yRight)->setAttributes(QwtScaleEngine::Floating);
curve = new QwtPlotCurve(name);
//curve->setRenderHint(QwtPlotItem::RenderAntialiased);
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);
}
And the code in the derived print filter :
QColor MyQwtPlotPrintFilter::color(const QColor &c, Item item) const {
switch(item){
case MajorGrid:
return Qt::blue;
case MinorGrid:
return Qt::green;
default:;
}
return c;
}
I got the exported pdf as attached "export.pdf". But I want to get "expected.png".
I added the colors to see the major and minor grids.
Now, the problem is :
1) I cannot see the minor grids at x axis.
2) I dont want a gap between the starting data and plot edge.
For 2'nd I found :
axisScaleEngine(QwtPlot::xBottom)->setAttributes(QwtScaleEngine::Floating);
but I couldn't realize what the QwtScaleEngine::Floating means (and other Attribute's)
Thanks for help.
Hüseyin
This is the code in the constructor :
PlotWidget::PlotWidget(QWidget * parent, double * _ySession,
QString name, int rate, int numVis, int numSess)
: QwtPlot(parent) {
// data stuff....
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);
setAxisScaleDiv(QwtPlot::xBottom, scdiv);
// for inside margin (I think)
axisScaleEngine(QwtPlot::xBottom)->setAttributes(QwtScaleEngine::Floating);
axisScaleEngine(QwtPlot::xTop)->setAttributes(QwtScaleEngine::Floating);
axisScaleEngine(QwtPlot::yLeft)->setAttributes(QwtScaleEngine::Floating);
axisScaleEngine(QwtPlot::yRight)->setAttributes(QwtScaleEngine::Floating);
curve = new QwtPlotCurve(name);
//curve->setRenderHint(QwtPlotItem::RenderAntialiased);
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);
}
And the code in the derived print filter :
QColor MyQwtPlotPrintFilter::color(const QColor &c, Item item) const {
switch(item){
case MajorGrid:
return Qt::blue;
case MinorGrid:
return Qt::green;
default:;
}
return c;
}
I got the exported pdf as attached "export.pdf". But I want to get "expected.png".
I added the colors to see the major and minor grids.
Now, the problem is :
1) I cannot see the minor grids at x axis.
2) I dont want a gap between the starting data and plot edge.
For 2'nd I found :
axisScaleEngine(QwtPlot::xBottom)->setAttributes(QwtScaleEngine::Floating);
but I couldn't realize what the QwtScaleEngine::Floating means (and other Attribute's)
Thanks for help.
Hüseyin