Re: scale customization
Brought to you by:
rathmann
From: Gerard V. <ger...@gr...> - 2004-11-19 17:56:50
|
On Fri, 19 Nov 2004 18:36:32 +0100 ver...@c-... wrote: > is there a possibility to add text in scale? > with the code you can see, I replace value by a text but how can I add > ticks to default ticks builded > > Idea should be to addmark values in x axis scale so that > in CdScaleDraw:: label(double v) I could indentify some values to be > replaced by a text. > but I don't see in different classes (qwplot, QwtScale, QwtScaleDiv....) > I read if it's possible > > class CdScaleDraw: public QwtScaleDraw > { > public: > CdScaleDraw() > { > } > virtual QString label(double v) const > { > if > (v EQ 5000) > { > return QString("monwaypoint"); > } > return QwtScaleDraw::label(v); > } > private: > }; > class CdScaleDraw: public QwtScaleDraw { public: ... void draw(Painter *p) const { QwtScaleDraw::draw(p); // (1) assume that pairs of (extra tickValues, extra labels) are in a private container // (2) draw your extra ticks and text, see QwtScaleDraw::draw() for how to do this // (2a) use protected QwtScaleDraw::drawTick() to draw your extra ticks // (2b) use something like protected QwtScaleDraw::drawLabel() to draw your extra labels // you probably want to make CdScaleDraw::drawExtraLabel(); or you have to play // tricks with label(); } void addTicksAndText(double tickValue, QString text) { // put this in a container (std_vector of std_pair?) } private: containerType container; // container of extra pairs }; Gerard |