Newer
Older
/* -*- 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"
QwtScaleMap offers transformations from the coordinate system
of a scale into the linear coordinate system of a paint device
and vice versa.
*/
class QWT_EXPORT QwtScaleMap
{
public:
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;
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 & );
double d_s1, d_s2; // scale interval boundaries
double d_p1, d_p2; // paint device interval boundaries
double d_cnv; // conversion factor
};
/*!
\return First border of the scale interval
*/
inline double QwtScaleMap::s1() const
{
return d_s1;
}
/*!
\return Second border of the scale interval
*/
inline double QwtScaleMap::s2() const
{
return d_s2;
}
/*!
\return First border of the paint interval
*/
inline double QwtScaleMap::p1() const
{
return d_p1;
}
/*!
\return Second border of the paint interval
*/
inline double QwtScaleMap::p2() const
Transform a point related to the scale interval into an point
\param s Value relative to the coordinates of the scale
\return Transformed value
\sa invTransform()
*/
inline double QwtScaleMap::transform( double s ) const
{
if ( d_transform )
s = d_transform->transform( s );
Transform an paint device value into a value in the
interval of the scale.
\param p Value relative to the coordinates of the paint device
\return Transformed value
\sa transform()
double s = d_ts1 + ( p - d_p1 ) / d_cnv;
if ( d_transform )
s = d_transform->invTransform( s );
//! \return True, when ( p1() < p2() ) != ( s1() < s2() )
inline bool QwtScaleMap::isInverting() const
#ifndef QT_NO_DEBUG_STREAM
QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleMap & );
#endif