source: ntrip/trunk/BNC/src/rinex/availplot.cpp@ 4589

Last change on this file since 4589 was 4589, checked in by mervart, 10 years ago
File size: 2.6 KB
Line 
1
2#include <qwt_symbol.h>
3#include <qwt_plot_curve.h>
4#include <qwt_scale_draw.h>
5#include <qwt_text.h>
6
7#include "availplot.h"
8#include "reqcanalyze.h"
9
10//
11//////////////////////////////////////////////////////////////////////////////
12class t_scaleDrawTime : public QwtScaleDraw {
13 public:
14 t_scaleDrawTime() {}
15 virtual QwtText label(double mjd) const {
16 bncTime epoTime; epoTime.setmjd(mjd);
17 return QwtText(epoTime.timestr(0,':').c_str());
18 }
19};
20
21//
22//////////////////////////////////////////////////////////////////////////////
23class t_scaleDrawPrn : public QwtScaleDraw {
24 public:
25 t_scaleDrawPrn() {}
26 virtual QwtText label(double iPrn) const {
27 return _yLabels[iPrn];
28 }
29 QMap<int, QString> _yLabels;
30};
31
32// Constructor
33//////////////////////////////////////////////////////////////////////////////
34t_availPlot::t_availPlot(QWidget* parent,
35 QMap<QString, t_availData>* availDataMap)
36: QwtPlot(parent) {
37
38 setCanvasBackground(QColor(Qt::white));
39
40 // Axes
41 // ----
42 setAxisScaleDraw(QwtPlot::xBottom, new t_scaleDrawTime());
43 setAxisLabelRotation(QwtPlot::xBottom, -10.0);
44 setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
45
46 t_scaleDrawPrn* scaleDrawPrn = new t_scaleDrawPrn();
47 setAxisScaleDraw(QwtPlot::yLeft, scaleDrawPrn);
48
49 // Curves
50 // ------
51 int iC = 0;
52 QMapIterator<QString, t_availData > it(*availDataMap);
53 while (it.hasNext()) {
54 it.next();
55 ++iC;
56 const QString& prn = it.key();
57 const t_availData& availData = it.value();
58 const QVector<double>& epochs = availData._epoL1;
59
60 scaleDrawPrn->_yLabels[iC] = prn;
61
62 double xData[epochs.size()];
63 double yData[epochs.size()];
64 for (int ii = 0; ii < epochs.size(); ii++) {
65 xData[ii] = epochs[ii];
66 yData[ii] = iC;
67 }
68
69 QwtSymbol* symbol = new QwtSymbol( QwtSymbol::XCross );
70 symbol->setSize( 4 );
71
72 QwtPlotCurve* curve = new QwtPlotCurve(prn);
73 curve->setSymbol( symbol );
74 curve->setStyle( QwtPlotCurve::NoCurve );
75 curve->setXAxis(QwtPlot::xBottom);
76 curve->setYAxis(QwtPlot::yLeft);
77 curve->setSamples(xData, yData, epochs.size());
78 curve->attach(this);
79 }
80
81 QList<double> ticks[QwtScaleDiv::NTickTypes];
82 QList<double> &majorTicks = ticks[QwtScaleDiv::MajorTick];
83 QMapIterator<int, QString> itT(scaleDrawPrn->_yLabels);
84 while (itT.hasNext()) {
85 itT.next();
86 majorTicks << double(itT.key());
87 }
88 QwtScaleDiv yScaleDiv(majorTicks.first()-0.5, majorTicks.last()+0.5, ticks );
89 setAxisScaleDiv(QwtPlot::yLeft, yScaleDiv);
90
91 // Important !!!
92 // -------------
93 replot();
94}
95
Note: See TracBrowser for help on using the repository browser.