00001 //# Copyright (C) 2005 00002 //# Associated Universities, Inc. Washington DC, USA. 00003 //# 00004 //# This library is free software; you can redistribute it and/or modify it 00005 //# under the terms of the GNU Library General Public License as published by 00006 //# the Free Software Foundation; either version 2 of the License, or (at your 00007 //# option) any later version. 00008 //# 00009 //# This library is distributed in the hope that it will be useful, but WITHOUT 00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 //# License for more details. 00013 //# 00014 //# You should have received a copy of the GNU Library General Public License 00015 //# along with this library; if not, write to the Free Software Foundation, 00016 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00017 //# 00018 //# Correspondence concerning AIPS++ should be addressed as follows: 00019 //# Internet email: aips2-request@nrao.edu. 00020 //# Postal address: AIPS++ Project Office 00021 //# National Radio Astronomy Observatory 00022 //# 520 Edgemont Road 00023 //# Charlottesville, VA 22903-2475 USA 00024 //# 00025 00026 #ifndef CASAQT_EXTERNALAXIS_WIDGET_H_ 00027 #define CASAQT_EXTERNALAXIS_WIDGET_H_ 00028 #include <casaqt/QwtPlotter/QPOptions.h> 00029 #include <casa/BasicSL/String.h> 00030 #include <QWidget> 00031 #include <qwt_plot.h> 00032 00033 00034 namespace casa { 00035 00036 class QPScaleDraw; 00037 00043 class ExternalAxisWidget : public QWidget { 00044 public: 00045 ExternalAxisWidget(QWidget* parent, QwtPlot* plot, 00046 bool leftAxisInternal, bool bottomAxisInternal, 00047 bool rightAxisInternal ); 00048 void setAxisLabel( const QString& label ); 00049 QString getAxisLabel() const; 00050 00051 virtual void paintEvent( QPaintEvent* event ); 00052 void print( QPainter* painter, QRect imageRect ); 00053 00054 //Date formats 00055 void setDateFormat(const String& newFormat); 00056 void setRelativeDateFormat(const String& newFormat); 00057 00058 //Axis scale 00059 void setAxisScale(PlotAxisScale scale); 00060 void setReferenceValue(bool on, double value); 00061 00062 //Axis font 00063 void setAxisFont(const QFont& font); 00064 00065 virtual ~ExternalAxisWidget(); 00066 00067 protected: 00068 virtual void drawTicks( QPainter* painter, int tickLength ) = 0; 00069 virtual void defineAxis( QLine& axisLine ) = 0; 00070 virtual void drawAxisLabel( QPainter* painter ) = 0; 00071 virtual int getAxisLength() const = 0; 00072 virtual int getCanvasHeight() const; 00073 virtual int getCanvasWidth() const; 00074 virtual int getStartY() const; 00075 virtual int getStartX() const; 00076 virtual int getEndY() const; 00077 00078 int getTickIncrement( int tickCount ) const; 00079 double getTickStartPixel( QwtPlot::Axis axis ); 00080 double getTickDistance( QwtPlot::Axis axis ); 00081 double getTickIncrement( double tickDistance, QwtPlot::Axis axis ); 00082 00083 QString formatLabel( double value ) const; 00084 00085 QwtPlot* plot; 00086 QPScaleDraw* scaleDraw; 00087 QString axisLabel; 00088 QwtPlot::Axis plotAxis; 00089 00090 //Which axis are internal (drawn by the Qwt plot) 00091 bool leftAxisInternal; 00092 bool bottomAxisInternal; 00093 bool rightAxisInternal; 00094 00095 const int AXIS_SMALL_SIDE; 00096 const int TICK_LENGTH; 00097 const int MARGIN; 00098 const int MIN_START_Y; 00099 00100 private: 00101 void drawBackBone( QPainter* painter ); 00102 void drawTicks( QPainter* painter ); 00103 void drawLabel( QPainter* painter ); 00104 QFont axisFont; 00105 00106 }; 00107 00108 } /* namespace casa */ 00109 #endif /* EXTERNALAXIS_WIDGET_H_ */