casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExternalAxisWidget.h
Go to the documentation of this file.
1 //# Copyright (C) 2005
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 //#
25 
26 #ifndef CASAQT_EXTERNALAXIS_WIDGET_H_
27 #define CASAQT_EXTERNALAXIS_WIDGET_H_
29 #include <casa/BasicSL/String.h>
30 #include <QWidget>
31 #include <qwt_plot.h>
32 
33 
34 namespace casa {
35 
36 class QPScaleDraw;
37 
43 class ExternalAxisWidget : public QWidget {
44 public:
45  ExternalAxisWidget(QWidget* parent, QwtPlot* plot,
47  bool rightAxisInternal );
48  void setAxisLabel( const QString& label );
49  QString getAxisLabel() const;
50 
51  virtual void paintEvent( QPaintEvent* event );
52  void print( QPainter* painter, QRect imageRect );
53 
54  //Date formats
55  void setDateFormat(const casacore::String& newFormat);
56  void setRelativeDateFormat(const casacore::String& newFormat);
57 
58  //Axis scale
59  void setAxisScale(PlotAxisScale scale, casacore::uInt base=10);
60  void setReferenceValue(bool on, double value);
61 
62  //Axis font
63  void setAxisFont(const QFont& font);
64 
65  virtual ~ExternalAxisWidget();
66 
67 protected:
68  virtual void drawTicks( QPainter* painter, int tickLength ) = 0;
69  virtual void defineAxis( QLine& axisLine ) = 0;
70  virtual void drawAxisLabel( QPainter* painter ) = 0;
71  virtual int getAxisLength() const = 0;
72  virtual int getCanvasHeight() const;
73  virtual int getCanvasWidth() const;
74  virtual int getStartY() const;
75  virtual int getStartX() const;
76  virtual int getEndY() const;
77 
78  int getTickIncrement( int tickCount ) const;
79  double getTickStartPixel( QwtPlot::Axis axis );
80  double getTickDistance( QwtPlot::Axis axis );
81  double getTickIncrement( double tickDistance, QwtPlot::Axis axis );
82 
83  QString formatLabel( double value ) const;
84 
85  QwtPlot* plot;
86  QPScaleDraw* scaleDraw;
87  QString axisLabel;
88  QwtPlot::Axis plotAxis;
89 
90  //Which axis are internal (drawn by the Qwt plot)
94 
95  const int AXIS_SMALL_SIDE;
96  const int TICK_LENGTH;
97  const int MARGIN;
98  const int MIN_START_Y;
99 
100 private:
101  void drawBackBone( QPainter* painter );
102  void drawTicks( QPainter* painter );
103  void drawLabel( QPainter* painter );
104  QFont axisFont;
105 
106 };
107 
108 } /* namespace casa */
109 #endif /* EXTERNALAXIS_WIDGET_H_ */
bool leftAxisInternal
Which axis are internal (drawn by the Qwt plot)
ExternalAxisWidget(QWidget *parent, QwtPlot *plot, bool leftAxisInternal, bool bottomAxisInternal, bool rightAxisInternal)
Base class for classes that use the QwtScaleDiv information to draw their own axis.
virtual void drawAxisLabel(QPainter *painter)=0
virtual int getCanvasWidth() const
void drawBackBone(QPainter *painter)
QString formatLabel(double value) const
virtual int getStartX() const
virtual int getAxisLength() const =0
virtual int getCanvasHeight() const
virtual void defineAxis(QLine &axisLine)=0
void setRelativeDateFormat(const casacore::String &newFormat)
virtual void paintEvent(QPaintEvent *event)
void setDateFormat(const casacore::String &newFormat)
Date formats.
virtual void drawTicks(QPainter *painter, int tickLength)=0
int getTickIncrement(int tickCount) const
void setAxisFont(const QFont &font)
Axis font.
double getTickStartPixel(QwtPlot::Axis axis)
void print(QPainter *painter, QRect imageRect)
QString getAxisLabel() const
void setAxisLabel(const QString &label)
double getTickDistance(QwtPlot::Axis axis)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void setAxisScale(PlotAxisScale scale, casacore::uInt base=10)
Axis scale.
virtual int getEndY() const
void setReferenceValue(bool on, double value)
PlotAxisScale
Enum for possible axis scales.
Definition: PlotOptions.h:78
virtual int getStartY() const
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
void drawLabel(QPainter *painter)
unsigned int uInt
Definition: aipstype.h:51