Eneboo - Documentación para desarrolladores
src/qwt/src/qwt_layout_metrics.h
Ir a la documentación de este archivo.
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  * 
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 #ifndef QWT_LAYOUT_METRICS_H
00011 #define QWT_LAYOUT_METRICS_H
00012 
00013 #include <qsize.h>
00014 #include <qrect.h>
00015 #include "qwt_polygon.h"
00016 #include "qwt_global.h"
00017 
00018 class QPainter;
00019 class QString;
00020 class QFontMetrics;
00021 #if QT_VERSION < 0x040000
00022 class QWMatrix;
00023 #else
00024 class QMatrix;
00025 #endif
00026 class QPaintDevice;
00027 
00031 class QWT_EXPORT QwtMetricsMap
00032 {
00033 public:
00034     QwtMetricsMap();
00035 
00036     bool isIdentity() const;
00037 
00038     void setMetrics(const QPaintDevice *layoutMetrics,
00039         const QPaintDevice *deviceMetrics);
00040 
00041     int layoutToDeviceX(int x) const;
00042     int deviceToLayoutX(int x) const;
00043     int screenToLayoutX(int x) const;
00044     int layoutToScreenX(int x) const;
00045 
00046     int layoutToDeviceY(int y) const;
00047     int deviceToLayoutY(int y) const;
00048     int screenToLayoutY(int y) const;
00049     int layoutToScreenY(int y) const;
00050 
00051     QPoint layoutToDevice(const QPoint &, const QPainter * = NULL) const;
00052     QPoint deviceToLayout(const QPoint &, const QPainter * = NULL) const;
00053     QPoint screenToLayout(const QPoint &) const;
00054     QPoint layoutToScreen(const QPoint &point) const;
00055 
00056 
00057     QSize layoutToDevice(const QSize &) const;
00058     QSize deviceToLayout(const QSize &) const;
00059     QSize screenToLayout(const QSize &) const;
00060     QSize layoutToScreen(const QSize &) const;
00061 
00062     QRect layoutToDevice(const QRect &, const QPainter * = NULL) const;
00063     QRect deviceToLayout(const QRect &, const QPainter * = NULL) const;
00064     QRect screenToLayout(const QRect &) const;
00065     QRect layoutToScreen(const QRect &) const;
00066 
00067     QwtPolygon layoutToDevice(const QwtPolygon &, 
00068         const QPainter * = NULL) const;
00069     QwtPolygon deviceToLayout(const QwtPolygon &, 
00070         const QPainter * = NULL) const;
00071 
00072 #if QT_VERSION < 0x040000
00073     static QwtPolygon translate(const QWMatrix &, const QwtPolygon &);
00074     static QRect translate(const QWMatrix &, const QRect &);
00075 #else
00076     static QwtPolygon translate(const QMatrix &, const QwtPolygon &);
00077     static QRect translate(const QMatrix &, const QRect &);
00078 #endif
00079 
00080 private:
00081     double d_screenToLayoutX;
00082     double d_screenToLayoutY;
00083 
00084     double d_deviceToLayoutX;
00085     double d_deviceToLayoutY;
00086 };
00087 
00088 inline bool QwtMetricsMap::isIdentity() const
00089 {
00090     return d_deviceToLayoutX == 1.0 && d_deviceToLayoutY == 1.0;
00091 }
00092 
00093 inline int QwtMetricsMap::layoutToDeviceX(int x) const
00094 {
00095     return qRound(x / d_deviceToLayoutX);
00096 }
00097 
00098 inline int QwtMetricsMap::deviceToLayoutX(int x) const
00099 {
00100     return qRound(x * d_deviceToLayoutX);
00101 }
00102 
00103 inline int QwtMetricsMap::screenToLayoutX(int x) const
00104 {
00105     return qRound(x * d_screenToLayoutX);
00106 }
00107 
00108 inline int QwtMetricsMap::layoutToScreenX(int x) const
00109 {
00110     return qRound(x / d_screenToLayoutX);
00111 }
00112 
00113 inline int QwtMetricsMap::layoutToDeviceY(int y) const
00114 {
00115     return qRound(y / d_deviceToLayoutY);
00116 }
00117 
00118 inline int QwtMetricsMap::deviceToLayoutY(int y) const
00119 {
00120     return qRound(y * d_deviceToLayoutY);
00121 }
00122 
00123 inline int QwtMetricsMap::screenToLayoutY(int y) const
00124 {
00125     return qRound(y * d_screenToLayoutY);
00126 }
00127 
00128 inline int QwtMetricsMap::layoutToScreenY(int y) const
00129 {
00130     return qRound(y / d_screenToLayoutY);
00131 }
00132 
00133 inline QSize QwtMetricsMap::layoutToDevice(const QSize &size) const
00134 {
00135     return QSize(layoutToDeviceX(size.width()), 
00136         layoutToDeviceY(size.height()));
00137 }
00138 
00139 inline QSize QwtMetricsMap::deviceToLayout(const QSize &size) const
00140 {
00141     return QSize(deviceToLayoutX(size.width()), 
00142         deviceToLayoutY(size.height()));
00143 }
00144 
00145 inline QSize QwtMetricsMap::screenToLayout(const QSize &size) const
00146 {
00147     return QSize(screenToLayoutX(size.width()), 
00148         screenToLayoutY(size.height()));
00149 }
00150 
00151 inline QSize QwtMetricsMap::layoutToScreen(const QSize &size) const
00152 {
00153     return QSize(layoutToScreenX(size.width()), 
00154         layoutToScreenY(size.height()));
00155 }
00156 
00157 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'