casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtDrawCanvas.qo.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 
27 #ifndef TQDRAWCANVAS_H
28 #define TQDRAWCANVAS_H
29 
30 #include <casa/aips.h>
31 #include <casa/BasicSL/String.h>
32 #include <casa/Containers/Record.h>
33 #include <casa/Arrays/Array.h>
34 #include <casa/Arrays/ArrayMath.h>
35 #include <casa/Arrays/Vector.h>
36 #include <casa/Arrays/Matrix.h>
37 #include <casa/Inputs/Input.h>
38 #include <casa/Arrays/IPosition.h>
39 
41 
42 #include <graphics/X11/X_enter.h>
43 #include <QDir>
44 #include <QColor>
45 #include <QHash>
46 #include <QWidget>
47 #include <QMouseEvent>
48 #include <QToolButton>
49 #include <QDialog>
50 #include <QPixmap>
51 #include <QVBoxLayout>
52 #include <QLabel>
53 #include <map>
54 #include <vector>
55 #include <graphics/X11/X_exit.h>
56 
57 namespace casa {
58 
59  typedef std::vector<double> CurveData;
60 
61  class GraphLabel {
62  public:
63  QString text;
64  QString fontName;
65  int fontSize;
66  QColor color;
67  GraphLabel() : text(""), fontName("Helvetica [Cronyx]"),
68  fontSize(12), color(Qt::blue) {}
69  };
70 
71  class QtDrawCanvas : public QWidget {
72  Q_OBJECT
73  public:
74  enum {LINE = 0, POINT, FPOINT, CIRCLE, FCIRCLE,
82  };
83  QtDrawCanvas(QWidget *parent = 0);
84 
85  void setPlotSettings(const QtDrawSettings &settings);
86  void setCurveData(int id, const CurveData data,
87  int tp = 0, int cl = 0);
88  void clearCurve(int id);
89  void setDataRange();
90  void setImageMode(bool);
91  void setPixmap(const QImage&);
92  QPixmap* graph();
93  void drawBackBuffer(QPainter *);
94  void plotPolyLines(QString);
95 
96  //ln = 0, new chart
97  //ln < 0, remove trace
98  //ln > 0, append trace if ln exists, otherwise add trace
99  //tp = 0, continous line
100  //tp > 0, discrete symbols
101  //tp < 0, line and symbols
102  //cl, color value range from 0 up
104  const casacore::Vector<int>&,
105  int ln = 0, int tp = 0, int cl = 0);
107  const casacore::Vector<float> &y,
108  int ln = 0, int tp = 0, int cl = 0);
111  int ln = 0, int tp = 0, int cl = 0);
112 
113  //Each row is a trace
114  //ln = 0, new chart
115  //ln < 0, remove traces
116  //ln > 0, append traces from (ln)th, add if not exists
117  //tp < 0, same shape for all traces
118  //tp = 0, continuous lines
119  //tp > 0, different discrete shape for each trace
120  //cl > 0, different color for each trace
121  //cl <= 0, same color for all traces
122  void plotPolyLine(const casacore::Matrix<int> &verts,
123  int ln = 0, int tp = 0, int cl = 0);
124  void plotPolyLine(const casacore::Matrix<float> &verts,
125  int ln = 0, int tp = 0, int cl = 0);
126  void plotPolyLine(const casacore::Matrix<double> &verts,
127  int ln = 0, int tp = 0, int cl = 0);
128 
129  // template<class T>
132  //void setMarkMode(bool);
133 
134  QColor getLinearColor(double);
135  QSize minimumSizeHint() const;
136  QSize sizeHint() const;
137  ~QtDrawCanvas();
138  void increaseCurZoom();
139  int getCurZoom();
140  int getZoomStackSize();
141  int getCurLine();
142  int getTotalLines();
143 
144  void setTitle(const QString &text,
145  int fontSize = 12, int color = 0,
146  const QString &font = "Helvetica [Cronyx]");
147  void setXLabel(const QString &text,
148  int fontSize = 10, int color = 1,
149  const QString &font = "Helvetica [Cronyx]");
150  void setYLabel(const QString &text,
151  int fontSize = 10, int color = 2,
152  const QString &font = "Helvetica [Cronyx]");
153  void setWelcome(const QString &text, int fontSize = 14,
154  int color = 1,
155  const QString &font = "Helvetica [Cronyx]");
156 
157  public slots:
158  void zoomIn();
159  void zoomOut();
160  void markPrev();
161  void markNext();
162 
163  signals:
164  void zoomChanged();
165  void gotFocus();
166 
167  protected:
168  void paintEvent(QPaintEvent *event);
169  void resizeEvent(QResizeEvent *event);
170  void mousePressEvent(QMouseEvent *event);
171  void mouseMoveEvent(QMouseEvent *event);
172  void mouseReleaseEvent(QMouseEvent *event);
173  void keyPressEvent(QKeyEvent *event);
174  void wheelEvent(QWheelEvent *event);
175  void focusInEvent(QFocusEvent *event);
176 
177  private:
178  void updateRubberBandRegion();
179  void refreshPixmap();
180  void drawGrid(QPainter *painter);
181  void drawTicks(QPainter *painter);
182  void drawLabels(QPainter *painter);
183  void drawWelcome(QPainter *painter);
184  void drawCurves(QPainter *painter);
185  void drawRects(QPainter *painter);
186 
187  enum { Margin = 60 };
188 
193 
194  std::map<int, CurveData> curveMap;
195  std::map<int, int> typeMap;
196  std::map<int, int> colorMap;
197  int curLine;
198 
199  std::vector<QtDrawSettings> zoomStack;
200  int curZoom;
201 
202  std::map<int, CurveData> markerStack;
204 
207 
208  bool imageMode;
209  bool markMode;
210 
211  QPixmap pixmap;
212  QPixmap backBuffer;
214 
215  };
216 
217 }
218 #endif
219 
void drawImage(const casacore::Matrix< casacore::uInt > &data, casacore::Matrix< casacore::uInt > *mask)
template&lt;class T&gt;
void setCurveData(int id, const CurveData data, int tp=0, int cl=0)
void drawWelcome(QPainter *painter)
casacore::Matrix< casacore::uInt > * pMask
void setYLabel(const QString &text, int fontSize=10, int color=2, const QString &font="Helvetica [Cronyx]")
void updateRubberBandRegion()
QString fontName
Definition: QtCanvas.qo.h:74
QPixmap * graph()
void wheelEvent(QWheelEvent *event)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
std::map< int, CurveData > markerStack
void plotPolyLine(const casacore::Vector< int > &, const casacore::Vector< int > &, int ln=0, int tp=0, int cl=0)
ln = 0, new chart ln &lt; 0, remove trace ln &gt; 0, append trace if ln exists, otherwise add trace tp = 0...
void plotPolyLines(QString)
void resizeEvent(QResizeEvent *event)
void mouseMoveEvent(QMouseEvent *event)
void focusInEvent(QFocusEvent *event)
std::map< int, CurveData > curveMap
QtDrawCanvas(QWidget *parent=0)
QSize sizeHint() const
void setWelcome(const QString &text, int fontSize=14, int color=1, const QString &font="Helvetica [Cronyx]")
A 2-D Specialization of the Array class.
void drawGrid(QPainter *painter)
void keyPressEvent(QKeyEvent *event)
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
QColor getLinearColor(double)
void setMarkMode(bool);
void drawLabels(QPainter *painter)
void mouseReleaseEvent(QMouseEvent *event)
void paintEvent(QPaintEvent *event)
void setPixmap(const QImage &)
void drawTicks(QPainter *painter)
void setPlotSettings(const QtDrawSettings &settings)
void drawBackBuffer(QPainter *)
void setTitle(const QString &text, int fontSize=12, int color=0, const QString &font="Helvetica [Cronyx]")
std::vector< QtDrawSettings > zoomStack
void drawRects(QPainter *painter)
void setXLabel(const QString &text, int fontSize=10, int color=1, const QString &font="Helvetica [Cronyx]")
std::map< int, int > colorMap
std::map< int, int > typeMap
void mousePressEvent(QMouseEvent *event)
void clearCurve(int id)
QSize minimumSizeHint() const
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the color(i.e.,"000000"for black) and
std::vector< double > CurveData
void setImageMode(bool)
void drawCurves(QPainter *painter)