You can try something like this:
class MyTransform: public QwtTransform
{
public:
MyTransform( double threshold ):
m_threshold( threshold ),
m_offset( threshold - log( threshold ) )
{
}
virtual double transform( double value ) const
{
double v = qAbs( value );
if ( v > m_threshold )
v = m_offset + log( v );
return value < 0.0 ? -v : v;
}
virtual double invTransform( double value ) const
{
double v = qAbs( value );
if ( v > m_offset )
v = qExp( v ) - m_offset;
return value < 0.0 ? -v : v;
}
virtual double bounded( double value ) const
{
return value;
}
virtual QwtTransform *copy() const
{
return new MyTransform( m_threshold );
}
private:
const double m_threshold;
const double m_offset;
};
...
scaleEngine->setTransformation( new MyTransform( 10.0 ) );
plot
->setAxisScaleEngine
( QwtPlot::yLeft, scaleEngine
);
QList<double> majorTicks;
majorTicks << -10000 << -1000 << -100 << -10 << -8 << -6 << -4 << -2 << 0 << 2 << 4 << 6 << 8 << 10 << 100 << 1000 << 10000;
scaleDiv.
setTicks( QwtScaleDiv::MajorTick, majorTicks
);
plot
->setAxisScaleDiv
( QwtPlot::yLeft, scaleDiv
);
class MyTransform: public QwtTransform
{
public:
MyTransform( double threshold ):
m_threshold( threshold ),
m_offset( threshold - log( threshold ) )
{
}
virtual double transform( double value ) const
{
double v = qAbs( value );
if ( v > m_threshold )
v = m_offset + log( v );
return value < 0.0 ? -v : v;
}
virtual double invTransform( double value ) const
{
double v = qAbs( value );
if ( v > m_offset )
v = qExp( v ) - m_offset;
return value < 0.0 ? -v : v;
}
virtual double bounded( double value ) const
{
return value;
}
virtual QwtTransform *copy() const
{
return new MyTransform( m_threshold );
}
private:
const double m_threshold;
const double m_offset;
};
...
QwtLinearScaleEngine *scaleEngine = new QwtLinearScaleEngine();
scaleEngine->setTransformation( new MyTransform( 10.0 ) );
plot->setAxisScaleEngine( QwtPlot::yLeft, scaleEngine );
QwtScaleDiv scaleDiv( -10000.0, 10000.0 );
QList<double> majorTicks;
majorTicks << -10000 << -1000 << -100 << -10 << -8 << -6 << -4 << -2 << 0 << 2 << 4 << 6 << 8 << 10 << 100 << 1000 << 10000;
scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks );
plot->setAxisScaleDiv( QwtPlot::yLeft, scaleDiv );
To copy to clipboard, switch view to plain text mode
If you can't set the ticks manually ( f.e. your application supports zooming ) you also have to implement your own type of QwtScaleEngine.
Uwe
Bookmarks