Scale color using Qwt::
Brought to you by:
rathmann
From: <qw...@ds...> - 2004-03-13 23:16:07
|
The program I am working on needs to be able to draw a QwtPlot subclass widget onto a QPixmap to be able to double-buffer and draw things onto the graph. I have about 252 of these plots to draw and use. I determined that the following code placed in this plotter class would print onto a QPainter: print (painter, plotRect); (I did read in the mailing list of the Qpixmap::grabWidget() way of doing this, but it turned out to be really slow.) The problem I faced with this approach (print method) is that the background I chose is black and the routine printScales() that print() calls also paints the scales in black by default with this code (qwt_plot_print.cpp): #if 1 painter->setPen(Qt::black); // acisColor ???? #endif Thats from 4.2rc1. So I checked the CVS and the only change was in the comment. It would be nice if we had control over the color that the scales are printed somehow. I imagine this would not be terribly difficult to implement as part of the QwtScale class, using a call similar to setTitleColor(), maybe setScaleColor() or setPen() -- this, in my mind, includes the tick marks, and major tick labels). What do you think? In the mean time I changed the #if 1 to #if 0 (in qwt_plot_print.cpp) and set the pen [color] outside of printScales(). I replaced the simple print() call to this code, for simplicity, and efficiency: // prepare for plotting updateAxes(); updateLayout(); // draw the canvas area: grids, curves, markers - that stuff painter->translate (plotLayout()->canvasRect().x(), plotLayout()->canvasRect().y()); drawCanvas (painter); painter->resetXForm(); // draw scales painter->setPen (white); drawScale (painter, xBottom); drawScale (painter, yLeft); return plotLayout()->canvasRect(); where drawScale() is: // from qwt_plot_print.cpp ... print() int startDist, endDist; axis (axisKey)->minBorderDist (startDist, endDist); int baseDist = axis (axisKey)->baseLineDist(); printScale (painter, axisKey, startDist, endDist, baseDist, plotLayout()->scaleRect (axisKey)); Thank you, Randy Evered |