Classes | Functions

qwt_dial.cpp File Reference

#include <math.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qevent.h>
#include "qwt_math.h"
#include "qwt_scale_engine.h"
#include "qwt_scale_map.h"
#include "qwt_paint_buffer.h"
#include "qwt_painter.h"
#include "qwt_dial_needle.h"
#include "qwt_dial.h"

Go to the source code of this file.

Classes

class  QwtDial::PrivateData

Functions

static double line2Radians (const QPoint &p1, const QPoint &p2)

Function Documentation

static double line2Radians ( const QPoint &  p1,
const QPoint &  p2 
) [static]

Definition at line 1059 of file qwt_dial.cpp.

References M_PI, and M_PI_2.

Referenced by QwtDial::getValue().

{
    const QPoint p = p2 - p1;

    double angle;
    if ( p.x() == 0 )
        angle = ( p.y() <= 0 ) ? M_PI_2 : 3 * M_PI_2;
    else
    {
        angle = atan(double(-p.y()) / double(p.x()));
        if ( p.x() < 0 )
            angle += M_PI;
        if ( angle < 0.0 )
            angle += 2 * M_PI;
    }
    return 360.0 - angle * 180.0 / M_PI;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines