32 : axesCalcModeY( CartesianCoordinatePlane::Linear ),
33 axesCalcModeX( CartesianCoordinatePlane::Linear ),
38 CartesianCoordinatePlane::AxesCalcMode axesCalcModeY;
39 CartesianCoordinatePlane::AxesCalcMode axesCalcModeX;
49 qreal logTransform( qreal value,
bool isPositiveRange )
const
51 if ( isPositiveRange ) {
52 return log10( value );
54 return -log10( -value );
58 qreal logTransformBack( qreal value,
bool wasPositive )
const
61 return pow( 10.0, value );
63 return -pow( 10.0, -value );
67 void updateTransform(
const QRectF& constDataRect,
const QRectF& screenRect )
69 QRectF dataRect = constDataRect;
70 if ( axesCalcModeX == CartesianCoordinatePlane::Logarithmic ) {
72 isPositiveX = dataRect.
left() >= 0.0;
73 dataRect.
setLeft( logTransform( dataRect.
left(), isPositiveX ) );
74 dataRect.
setRight( logTransform( dataRect.
right(), isPositiveX ) );
76 if ( axesCalcModeY == CartesianCoordinatePlane::Logarithmic ) {
77 isPositiveY = dataRect.
top() >= 0.0;
78 dataRect.
setTop( logTransform( dataRect.
top(), isPositiveY ) );
84 transform.translate( screenRect.
left(), screenRect.
bottom() );
85 transform.scale( screenRect.
width(), screenRect.
height() );
90 transform.translate( 0.5, -0.5 );
91 transform.scale( zoom.xFactor, zoom.yFactor );
92 transform.translate( -zoom.xCenter, 1.0 - zoom.yCenter );
94 transform.scale( 1.0 / dataRect.
width(), 1.0 / dataRect.
height() );
95 transform.translate( -dataRect.
left(), -dataRect.
bottom() );
98 backTransform = transform.inverted();
105 if ( axesCalcModeX == CartesianCoordinatePlane::Logarithmic ) {
106 data.
setX( logTransform( data.
x(), isPositiveX ) );
108 if ( axesCalcModeY == CartesianCoordinatePlane::Logarithmic ) {
109 data.
setY( logTransform( data.
y(), isPositiveY ) );
112 return transform.map( data );
116 inline const QPointF translateBack(
const QPointF& screenPoint )
const
118 QPointF ret = backTransform.
map( screenPoint );
119 if ( axesCalcModeX == CartesianCoordinatePlane::Logarithmic ) {
120 ret.
setX( logTransformBack( ret.
x(), isPositiveX ) );
122 if ( axesCalcModeY == CartesianCoordinatePlane::Logarithmic ) {
123 ret.
setY( logTransformBack( ret.
y(), isPositiveY ) );