PDA

View Full Version : QWT legend customization



alexmal
20th May 2011, 00:23
First of all I would like to say hello to everybody (this is my first post ) and thanks to all people who made QWT available.

I need to display a pair of pressure/impulse ( 2 curves ) for a number of points.
Pressure and impulse curves are recognized by line type and have the same color (which depends on the point number).

Plotting curves works fine.
But standard legend requires too much unnecessary information information about curves - each curve label needs point number and color and line type.

It would be much better to split information by category:
... Pressure
__ Impulse
[colored rectangle] point # 1
[colored rectangle] point # 2


Above requires:
a) adding "dummy" curves which would not have any associated data ( no problem )
b) having only 1 label per pair of the curves visible - this is much more difficult to achieve

Problem with b) is that I could not find a way to skip plotting of the curve related data (marker/label) on the legend.
The best I could achieve is to set curve legend attribute to QwtPlotCurve::LegendShowSymbol without providing a valid symbol.
( I was surprised that LegendNoAttribute does not have such meaning )

Problem with such approach is that even if curve has no label text and displays nothing, it still present in the legend.

While it might be OK when LegendItemMode is set to ReadOnlyItem,
it is inappropriate for ClickableItem or CheckableItem.

Any idea how desired effect can be achieved?

Thanks in advance,
Alex


P.S. I am using qwt-6.0.0

Added after 34 minutes:

I found solution - QwtPlotCurve is QwtPlotItem subclass, so following removes curve legend =:
QwtPlotItem::setItemAttribute( QwtPlotItem::Legend, false);

Regards,
Alex

pkj
20th May 2011, 07:27
Markers and curves are plot items and for each item you can configure if it is supposed to appear on the legend or not.


QwtPlotItem::setItemAttribute( QwtPlotItem::Legend, true/false);

...
just saw u got it.. srry should have read till end of post... :)