Qwt User's Guide
|
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_ABSTRACT_SCALE_DRAW_H 00011 #define QWT_ABSTRACT_SCALE_DRAW_H 00012 00013 #include "qwt_global.h" 00014 #include "qwt_scale_div.h" 00015 #include "qwt_text.h" 00016 00017 class QPalette; 00018 class QPainter; 00019 class QFont; 00020 class QwtTransform; 00021 class QwtScaleMap; 00022 00031 class QWT_EXPORT QwtAbstractScaleDraw 00032 { 00033 public: 00034 00039 enum ScaleComponent 00040 { 00042 Backbone = 0x01, 00043 00045 Ticks = 0x02, 00046 00048 Labels = 0x04 00049 }; 00050 00052 typedef QFlags<ScaleComponent> ScaleComponents; 00053 00054 QwtAbstractScaleDraw(); 00055 virtual ~QwtAbstractScaleDraw(); 00056 00057 void setScaleDiv( const QwtScaleDiv &s ); 00058 const QwtScaleDiv& scaleDiv() const; 00059 00060 void setTransformation( QwtTransform * ); 00061 const QwtScaleMap &scaleMap() const; 00062 QwtScaleMap &scaleMap(); 00063 00064 void enableComponent( ScaleComponent, bool enable = true ); 00065 bool hasComponent( ScaleComponent ) const; 00066 00067 void setTickLength( QwtScaleDiv::TickType, double length ); 00068 double tickLength( QwtScaleDiv::TickType ) const; 00069 double maxTickLength() const; 00070 00071 void setSpacing( double margin ); 00072 double spacing() const; 00073 00074 void setPenWidth( int width ); 00075 int penWidth() const; 00076 00077 virtual void draw( QPainter *, const QPalette & ) const; 00078 00079 virtual QwtText label( double ) const; 00080 00093 virtual double extent( const QFont &font ) const = 0; 00094 00095 void setMinimumExtent( double ); 00096 double minimumExtent() const; 00097 00098 protected: 00108 virtual void drawTick( QPainter *painter, double value, double len ) const = 0; 00109 00116 virtual void drawBackbone( QPainter *painter ) const = 0; 00117 00126 virtual void drawLabel( QPainter *painter, double value ) const = 0; 00127 00128 void invalidateCache(); 00129 const QwtText &tickLabel( const QFont &, double value ) const; 00130 00131 private: 00132 QwtAbstractScaleDraw( const QwtAbstractScaleDraw & ); 00133 QwtAbstractScaleDraw &operator=( const QwtAbstractScaleDraw & ); 00134 00135 class PrivateData; 00136 PrivateData *d_data; 00137 }; 00138 00139 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtAbstractScaleDraw::ScaleComponents ) 00140 00141 #endif