RiverWare 6.5: Plot Print Preview and Margin Settings
Plot Print Preview: Known Problems
Phil Weinstein, CADSWES, edit: 7-14-2014
As mentioned in the feature notes, the relative curve line thicknesses shown in the plot print preview image will not generally exactly match that of the actual printed page. This is a limitation our current plotting package's support for onscreen and printer-device rendering.
Additionally, there is a more serious problem when printing from the Plot Print Preview Dialog using its "Print" toolbar button:
Printing from the Plot Print Preview dialog lacks the adjustment we otherwise make to curve line thicknesses for printed output (i.e. when instead printing directly from the Plot Dialog). When printing from the Plot Print Preview dialog, curves and markers will generally be too thin to clearly see. |
Both the Print Preview's onscreen preview drawing and its print function (toolbar button) call into the same place in our code for graphical rendering. For single plots, they both call the following method (and a similar method for the full plot page):
Our rendering algorithm (using Qwt 5.2.3) needs to know whether the rendering is for a screen-resolution device or a high-resolution device (PDF output or an actual printer). This is for our workaround for the Gnats 5325 problem (Printed Plot Curve and Marker Thickness) -- we need to explicitly increase the thickness of all drawn curves by a factor of about 12 for high-resolution device printing. As of RiverWare 6.4, the "Print Line Width Factor" is a settable configuration value in the Plot Dialog Settings dialog. See this webpage:
Unfortunately we can't distinguish the two contexts from that method. Apparently, there are no properties in the provided QPrinter object which indicate the difference.
The QPrinter class internally supports a preview mode, used by the QPrintPreviewWidget (in the QPrintPreviewDialog) -- but we can't get our hands on that. See the highlighted lines below.
void QPrintPreviewWidgetPrivate::generatePreview() { //### If QPrinter::setPreviewMode() becomes public, handle the //### case that we have been constructed with a printer that //### _already_ has been preview-painted to, so we should //### initially just show the pages it already contains, and not //### emit paintRequested() until the user changes some parameter Q_Q(QPrintPreviewWidget); printer->d_func()->setPreviewMode(true); emit q->paintRequested(printer); printer->d_func()->setPreviewMode(false); pictures = printer->d_func()->previewPages(); populateScene(); // i.e. setPreviewPrintedPictures() e.l. layoutPages(); curPage = qBound(1, curPage, pages.count()); if (fitting) _q_fit(); emit q->previewChanged(); } |
I also tried getting my hands on the print button action or widget to reimplement its functionality. An inspection of the Qt object names of all of the QPrintPreviewDialog's child widgets (about 100 of them) didn't turn up a named object for this print control. Only 13 of those 100-odd QObjects had been given object names. See this list:
One way to resolve the bigger problem is to port from Qwt 5.2.1 to Qwt 6.x. The Qwt author, Uwe, responded to my question about the general problem on this qtcentre.org post (9-29-2013):
Qwt 6 has a floating point based render engine and is using painter transformations (scaling) for PDF generation. When using non cosmetic pens ( https://qt-project.org/doc/qt-5.1/qt...tml#isCosmetic ) for the curve the lines in the PDF document will appear comparable to screen. Note that when using non cosmetic pens, that the lines will be scaled when zooming in in a PDF viewer too. |
--- (end) ---