qwt_scale_map.h
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#ifndef QWT_SCALE_MAP_H
#define QWT_SCALE_MAP_H
#include "qwt_global.h"
#include "qwt_transform.h"
#include <qrect.h>
#ifndef QT_NO_DEBUG_STREAM
#include <qdebug.h>
#endif
class QRectF;
class QWT_EXPORT QwtScaleMap
{
public:
QwtScaleMap();
QwtScaleMap( const QwtScaleMap& );
~QwtScaleMap();
QwtScaleMap &operator=( const QwtScaleMap & );
void setTransformation( QwtTransform * );
const QwtTransform *transformation() const;
void setPaintInterval( double p1, double p2 );
void setScaleInterval( double s1, double s2 );
double transform( double s ) const;
double invTransform( double p ) const;
double p1() const;
double p2() const;
double s1() const;
double s2() const;
double pDist() const;
double sDist() const;
static QRectF transform( const QwtScaleMap &,
const QwtScaleMap &, const QRectF & );
static QRectF invTransform( const QwtScaleMap &,
const QwtScaleMap &, const QRectF & );
static QPointF transform( const QwtScaleMap &,
const QwtScaleMap &, const QPointF & );
static QPointF invTransform( const QwtScaleMap &,
const QwtScaleMap &, const QPointF & );
bool isInverting() const;
private:
void updateFactor();
double d_s1, d_s2; // scale interval boundaries
double d_p1, d_p2; // paint device interval boundaries
double d_cnv; // conversion factor
double d_ts1;
QwtTransform *d_transform;
};
inline double QwtScaleMap::s1() const
{
return d_s1;
}
inline double QwtScaleMap::s2() const
{
return d_s2;
}
inline double QwtScaleMap::p1() const
{
return d_p1;
}
inline double QwtScaleMap::p2() const
{
return d_p2;
}
inline double QwtScaleMap::pDist() const
{
return qAbs( d_p2 - d_p1 );
}
inline double QwtScaleMap::sDist() const
{
return qAbs( d_s2 - d_s1 );
}
inline double QwtScaleMap::transform( double s ) const
{
if ( d_transform )
s = d_transform->transform( s );
return d_p1 + ( s - d_ts1 ) * d_cnv;
}
inline double QwtScaleMap::invTransform( double p ) const
{
double s = d_ts1 + ( p - d_p1 ) / d_cnv;
if ( d_transform )
s = d_transform->invTransform( s );
return s;
}
inline bool QwtScaleMap::isInverting() const
{
return ( ( d_p1 < d_p2 ) != ( d_s1 < d_s2 ) );
}
#ifndef QT_NO_DEBUG_STREAM
QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleMap & );
#endif
#endif
QwtTransform
A transformation between coordinate systems.
Definition: qwt_transform.h:35
QwtScaleMap::s2
double s2() const
Definition: qwt_scale_map.h:93
QwtScaleMap::pDist
double pDist() const
Definition: qwt_scale_map.h:117
QwtScaleMap
A scale map.
Definition: qwt_scale_map.h:30
QwtScaleMap::s1
double s1() const
Definition: qwt_scale_map.h:85
QwtScaleMap::isInverting
bool isInverting() const
Definition: qwt_scale_map.h:166
QwtScaleMap::p1
double p1() const
Definition: qwt_scale_map.h:101
QwtScaleMap::p2
double p2() const
Definition: qwt_scale_map.h:109
QwtScaleMap::invTransform
double invTransform(double p) const
Definition: qwt_scale_map.h:156
QwtScaleMap::transform
double transform(double s) const
Definition: qwt_scale_map.h:139
QwtScaleMap::sDist
double sDist() const
Definition: qwt_scale_map.h:125