Hi,
I have a timing diagram like this:
timimng.jpg
I want a constant grid, for example every 10 ns because this represents e.g. a clock.
Compare: http://www.texample.net/media/tikz/e...ng-diagram.png
Any ideas?
Hi,
I have a timing diagram like this:
timimng.jpg
I want a constant grid, for example every 10 ns because this represents e.g. a clock.
Compare: http://www.texample.net/media/tikz/e...ng-diagram.png
Any ideas?
QwtPlotGrid draws major or minor grid lines depending on the ticks it gets from the corresponding scales. So you have the option to modify the scale f.e by setting a step size to 10 - or by modifying the max major, max minor attributes. When you don't need zooming/panning you can even assign the ticks manually ( using QwtPlot::setAxisScaleDiv() ).
The other option is to have the grid lines independent from the scales. For this you can overload QwtPlotGrid::updateScaleDiv(). Simply replace the ticks in the incoming scaleDiv object by something aligned to 10 and keep its boundaries.
HTH,
Uwe
I Set the stepsize to 10...
But, whe I zoom everything changed again![]()
Setting a fixed step size doesn't make too much sense when zooming ( consider a step size of 10 for a range of 5-6 ).
But as I wrote before - simply decouple the grid from the ticks of the scales by overloading QwtPlotGrid::updateScaleDiv().
Qt Code:
{ public: ... virtual void updateScaleDiv( const QwtScaleDiv& xScaleDiv, const QwtScaleDiv& yScaleDiv ) { QwtScaleDiv scaleDiv; scaleDiv.setInterval( xScaleDiv.interval() ); double min = xScaleDiv.interval().lowerBound(); double max = xScaleDiv.interval.upperBound(); if ( min > max ) qSwap( min, max ); const int stepSize = 10.0; min = static_cast<int>( min / stepSize ) * stepSize; QList<double > ticks; for ( double tick = min; tick <= max; tick += stepSize ) ticks += tick; }To copy to clipboard, switch view to plain text mode
Uwe
It works fine!
But I had to change this:
Qt Code:
double min = xScaleDiv.interval().minValue(); double max = xScaleDiv.interval().maxValue();To copy to clipboard, switch view to plain text mode
Tank You Uwe!
Regards
Bookmarks