Hi,
i have a little problem with QwtWheel and how to update it's values related to a x-Axis that continuously changes.
Subclass MasterWheel from QwtWheel
When scaleDivChanged() signal was triggered, i apply the changes to the MasterWheel.
When valueChanged(double) signal was triggered, i apply the new values from MasterWheel to the axis
The problem:
-> when scaleDivChanged() i apply the new values to the MasterWheel (only if it is not in use)
-> i set also the value to the lowerBound() of the QwtScaleDiv
-> BUT, when the value is changed i got the signal to change the axis
-> if i apply the new value to axis, i trigger the signal scaleDivChanged() and so on...
now i have a circle of signals and slots
How to set the values of a QwtWheel if the xBottom changes continuously?
Thx
Stefan
Here is my code:
connect( pPlotPressure
->axisWidget
( QwtPlot::xBottom ),
SIGNAL(scaleDivChanged
()),
SLOT(setMasterWheelValues
()));
connect( pMasterWheel, SIGNAL(valueChanged(double)), SLOT(setAxisScaleByMasterWheel(double)));
connect( pPlotPressure->axisWidget( QwtPlot::xBottom ), SIGNAL(scaleDivChanged()), SLOT(setMasterWheelValues()));
connect( pMasterWheel, SIGNAL(valueChanged(double)), SLOT(setAxisScaleByMasterWheel(double)));
To copy to clipboard, switch view to plain text mode
void PlotManager::setMasterWheelValues()
{
// wheelPressed() set isActive() to true
// wheelReleased() set isActive() to false
if( !(pMasterWheel->isActive()) )
{
const double minValue = scaleDiv.lowerBound();
const double maxValue = scaleDiv.upperBound();
if( maxValue > pMasterWheel->maximum() )
pMasterWheel->setMaximum( maxValue );
if( minValue < pMasterWheel->minimum() )
pMasterWheel->setMinimum( minValue );
// pMasterWheel->setValue( minValue ); // THIS LINE IS THE PROBLEM
d_data->dxMasterWheel = scaleDiv.range();
}
}
void PlotManager::setAxisScaleByMasterWheel(double value)
{
pPlotPressure
->setAxisScale
( QwtPlot::xBottom, value, value
+ d_data
->dxMasterWheel
);
pPlotPressure->replot();
}
void PlotManager::setMasterWheelValues()
{
// wheelPressed() set isActive() to true
// wheelReleased() set isActive() to false
if( !(pMasterWheel->isActive()) )
{
const QwtScaleDiv scaleDiv = pPlotPressure->axisScaleDiv( QwtPlot::xBottom );
const double minValue = scaleDiv.lowerBound();
const double maxValue = scaleDiv.upperBound();
if( maxValue > pMasterWheel->maximum() )
pMasterWheel->setMaximum( maxValue );
if( minValue < pMasterWheel->minimum() )
pMasterWheel->setMinimum( minValue );
// pMasterWheel->setValue( minValue ); // THIS LINE IS THE PROBLEM
d_data->dxMasterWheel = scaleDiv.range();
}
}
void PlotManager::setAxisScaleByMasterWheel(double value)
{
pPlotPressure->setAxisScale( QwtPlot::xBottom, value, value + d_data->dxMasterWheel );
pPlotPressure->replot();
}
To copy to clipboard, switch view to plain text mode
Bookmarks