2 Attachment(s)
Grid Minor Major and gap before the data
Hi,
This is the code in the constructor :
Code:
PlotWidget
::PlotWidget(QWidget * parent,
double * _ySession,
QString name,
int rate,
int numVis,
int numSess
) // data stuff....
//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 (I think)
//curve->setRenderHint(QwtPlotItem::RenderAntialiased);
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);
}
And the code in the derived print filter :
Code:
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
Re: Grid Minor Major and gap before the data
Quote:
Originally Posted by
huseyinkozan
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.
1) Are there any minor ticks in your bottom scale ?
2) plot->plotLayout()->setAlignCanvasToScales(true);
Uwe
Re: Grid Minor Major and gap before the data
Quote:
Originally Posted by
Uwe
1) Are there any minor ticks in your bottom scale ?
2) plot->plotLayout()->setAlignCanvasToScales(true);
Uwe
1) I found the QwtValueList model here : http://thread.gmane.org/gmane.comp.g...t.general/1425
Does this not assign the minor, medium and major ticks ?
2) I have added the code and plotLayout()->setCanvasMargin(...) it works.
Thanks.
Hüseyin
Note: I am using 5.1.2-svn, Qt 4.5 with msvc addin. And the code is here:
Code:
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);
}
Re: Grid Minor Major and gap before the data
Hi,
I don't want any spacing between the scale backbone and the canvas (plotting area). Thus, the backbones of the left and bottom axes should be "connected". I tried the following without success (there is a 1 or 2 pixels gap):
Code:
plotLayout()->setAlignCanvasToScales(true);
plotLayout
()->setCanvasMargin
(0,
QwtPlot::xBottom);
plotLayout
()->setCanvasMargin
(0,
QwtPlot::xTop);
plotLayout
()->setCanvasMargin
(0,
QwtPlot::yLeft);
plotLayout
()->setCanvasMargin
(0,
QwtPlot::yRight);
plotLayout()->setSpacing(0);
plotLayout()->setMargin(0);
Any hints?