still label trouble, here is the code:
{
public:
NewScaleDraw()
{
qDebug() << "in newscaledraw ";
invalidateCache();
}
virtual QwtText label
(double value
) const {
qDebug() << "value = " << value;
double freqLabel = (::centerFreq-(value/2000));
return strFreqLabel;
}
};
//In the constructor of the plot class
this
->setAxisScaleDraw
(QwtPlot::xBottom,
new NewScaleDraw
());
/* this same code is called each time the centerFreq value changes */
class NewScaleDraw : public QwtScaleDraw
{
public:
NewScaleDraw()
{
qDebug() << "in newscaledraw ";
invalidateCache();
}
virtual QwtText label(double value) const
{
qDebug() << "value = " << value;
double freqLabel = (::centerFreq-(value/2000));
QString strFreqLabel = QString("%1").arg(freqLabel);
return strFreqLabel;
}
};
//In the constructor of the plot class
this->setAxisScaleDraw(QwtPlot::xBottom, new NewScaleDraw()); /* this same code is called each time the centerFreq value changes */
To copy to clipboard, switch view to plain text mode
When the setAxisScaleDraw line executes from the plot class constructor, the "value" debug statement returns the following:
value = 0
value = 100000
value = 20000
value = 40000
value = 60000
value = 80000
value = 0
value = 95000
value = 5000
value = 10000
value = 15000
value = 20000
value = 25000
value = 30000
value = 35000
value = 40000
value = 45000
value = 50000
value = 55000
value = 60000
value = 65000
value = 70000
value = 75000
value = 80000
value = 85000
value = 90000
Which I don't understand. So the labels are changed but not to the correct values since the "value" in the NewScaleDraw doesn't start with zero and progress linearly up to 90000. Why is this?
Second problem is that the NewScaleDraw line is also executed later in the code whenever the centerFreq value changes.
When that happens, according to the debug output, only the constructor for NewScaleDraw executes, not the QwtText code, so the labels don't change.
I'm really puzzled.
Bookmarks