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

Last change on this file since 4588 was 4588, checked in by mervart, 12 years ago
File size: 2.5 KB
RevLine 
[4578]1
2#include <qwt_symbol.h>
3#include <qwt_plot_curve.h>
[4586]4#include <qwt_scale_draw.h>
5#include <qwt_text.h>
[4578]6
7#include "availplot.h"
[4584]8#include "reqcanalyze.h"
[4578]9
[4586]10//
11//////////////////////////////////////////////////////////////////////////////
[4587]12class t_scaleDrawTime : public QwtScaleDraw {
[4586]13 public:
[4587]14 t_scaleDrawTime() {}
[4586]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//////////////////////////////////////////////////////////////////////////////
[4587]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//////////////////////////////////////////////////////////////////////////////
[4578]34t_availPlot::t_availPlot(QWidget* parent,
[4584]35 QMap<QString, t_availData>* availDataMap)
[4578]36: QwtPlot(parent) {
37
[4579]38 setCanvasBackground(QColor(Qt::white));
39
[4578]40 // Axes
41 // ----
[4587]42 setAxisScaleDraw(QwtPlot::xBottom, new t_scaleDrawTime());
[4586]43 setAxisLabelRotation(QwtPlot::xBottom, -50.0);
44 setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
45
[4587]46 t_scaleDrawPrn* scaleDrawPrn = new t_scaleDrawPrn();
47 setAxisScaleDraw(QwtPlot::yLeft, scaleDrawPrn);
[4578]48
49 // Curves
50 // ------
51 int iC = 0;
[4584]52 QMapIterator<QString, t_availData > it(*availDataMap);
[4578]53 while (it.hasNext()) {
54 it.next();
55 ++iC;
[4584]56 const QString& prn = it.key();
57 const t_availData& availData = it.value();
58 const QVector<double>& epochs = availData._epoL1;
[4578]59
[4587]60 scaleDrawPrn->_yLabels[iC] = prn;
61
[4578]62 double xData[epochs.size()];
63 double yData[epochs.size()];
64 for (int ii = 0; ii < epochs.size(); ii++) {
[4579]65 xData[ii] = epochs[ii];
[4578]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 );
[4579]74 curve->setStyle( QwtPlotCurve::NoCurve );
[4578]75 curve->setXAxis(QwtPlot::xBottom);
76 curve->setYAxis(QwtPlot::yLeft);
77 curve->setSamples(xData, yData, epochs.size());
78 curve->attach(this);
79 }
[4588]80
81 QList<double> ticks[QwtScaleDiv::NTickTypes];
82 QList<double> &majorTicks = ticks[QwtScaleDiv::MajorTick];
83 for (int iPrn = 1; iPrn <= 32; iPrn++) {
84 majorTicks << iPrn;
85 }
86 QwtScaleDiv yScaleDiv(majorTicks.first()-0.5, majorTicks.last()+0.5, ticks );
87 setAxisScaleDiv(QwtPlot::yLeft, yScaleDiv);
[4581]88
[4582]89 // Important !!!
90 // -------------
[4581]91 replot();
[4578]92}
93
Note: See TracBrowser for help on using the repository browser.