PDA

View Full Version : Want to Create a Fixed Grid Size when Printed?



roltman
9th July 2010, 19:30
I'm an engineer using Qwt to plot data (1,000's plots). I have a requirement that when printed on paper it have following grid design

- A major division every 2cm with a solid line.
- A sub division every 1 cm with same grid line type as the major.
- A sub division every 0.5cm with a densely dotted line type.
- A sub division every mm with a loosely dotted line type.

I'm using a QPrinter with a specific setPaperSize (which varies based on the plot) exporting the plots as PDFs.

First is there a "simple" way to get this grid? I'm guessing not, but it wouldn't be the first I've started to reinvent the wheel.

Assuming no, is there a way to "print preview" the plot without sending it to the PDF file? i.e. Try to gather the rendered canvas size, based on the paper dimensions from the Qwt::print command.

Also, is there going to be some limitation that will prevent me from creating these 4 grid levels? Or should I look at setting the canvas image to this fixed pattern?

Regards,
Ryan

Uwe
19th July 2010, 07:21
The layout engine of the plot widget always distributes a given rectangle to scales/title/legend and the rest goes to the canvas. But what you need is a layout system, that takes the size for the canvas and calculates the other sizes from it ( what is exactly vice versa ). Unfortunately it doesn't exist.

I would try to use Qwt from SVN trunk, because its render engine is double based now. Then paint to a scalable vector format ( PDF or SVG ). When you overload some of the methods of QwtPlotRenderer ( f.e. renderScale ) it should be possible to find the scaling factor, that is needed to scale your document having a grid of 2 cm.

Uwe