source: ntrip/trunk/GnssCenter/monitor/worldplot.cpp@ 5443

Last change on this file since 5443 was 5435, checked in by mervart, 11 years ago
File size: 3.2 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * RTNet GUI
4 * -------------------------------------------------------------------------
5 *
6 * Class: t_worldPlot
7 *
8 * Purpose: Plot map of stations/satellites
9 *
10 * Author: L. Mervart
11 *
12 * Created: 12-Sep-2013
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iostream>
19#include <QtSvg>
20
21#include <qwt_symbol.h>
22#include <qwt_plot_svgitem.h>
23#include <qwt_plot_curve.h>
24#include <qwt_plot_marker.h>
25#include <qwt_plot_canvas.h>
26#include <qwt_plot_zoomer.h>
27#include <qwt_plot_renderer.h>
28
29#include "worldplot.h"
30
31using namespace std;
32using namespace GnssCenter;
33
34// Constructor
35/////////////////////////////////////////////////////////////////////////////
36t_worldPlot::t_worldPlot() : QwtPlot() {
37
38 // Map in Scalable Vector Graphics (svg) Format
39 // --------------------------------------------
40 this->setAxisScale(QwtPlot::xBottom, -180.0, 180.0);
41 this->setAxisScale(QwtPlot::yLeft, -90.0, 90.0);
42
43 _zoomer = new QwtPlotZoomer(this->canvas());
44
45 this->canvas()->setFocusPolicy(Qt::WheelFocus);
46
47 QwtPlotSvgItem* mapItem = new QwtPlotSvgItem();
48 mapItem->loadFile(QRectF(-180.0, -90.0, 360.0, 180.0), ":world.svg");
49 mapItem->attach(this);
50
51 // Important
52 // ---------
53 this->replot();
54}
55
56// Destructor
57/////////////////////////////////////////////////////////////////////////////
58t_worldPlot::~t_worldPlot() {
59}
60
61//
62/////////////////////////////////////////////////////////////////////////////
63void t_worldPlot::slotNewPoints(const QList<t_point*>& points) {
64
65 // Remove old markers
66 // ------------------
67 QListIterator<QwtPlotMarker*> im(_markers);
68 while (im.hasNext()) {
69 QwtPlotMarker* marker = im.next();
70 marker->detach();
71 delete marker;
72 }
73 _markers.clear();
74
75 QColor red(220,20,60);
76
77 QListIterator<t_point*> ip(points);
78 while (ip.hasNext()) {
79 t_point* point = ip.next();
80
81 if (point->_lonDeg > 180.0) point->_lonDeg -= 360.0;
82
83 QwtSymbol* symbol = new QwtSymbol(QwtSymbol::Rect, QBrush(red),
84 QPen(red), QSize(2,2));
85 QwtPlotMarker* marker = new QwtPlotMarker();
86 marker->setValue(point->_lonDeg, point->_latDeg);
87 if (point->_lonDeg > 170.0) {
88 marker->setLabelAlignment(Qt::AlignLeft);
89 }
90 else {
91 marker->setLabelAlignment(Qt::AlignRight);
92 }
93 QwtText text(point->_name.left(4));
94 QFont font = text.font();
95 font.setPointSize(font.pointSize()*0.8);
96 text.setFont(font);
97 marker->setLabel(text);
98 marker->setSymbol(symbol);
99 marker->attach(this);
100 _markers.append(marker);
101 }
102
103 replot();
104}
105
106// Print the widget
107////////////////////////////////////////////////////////////////////////////
108void t_worldPlot::slotPrint() {
109
110 QPrinter printer;
111 QPrintDialog* dialog = new QPrintDialog(&printer, this);
112 dialog->setWindowTitle(tr("Print Map"));
113 if (dialog->exec() != QDialog::Accepted) {
114 return;
115 }
116 else {
117 QwtPlotRenderer renderer;
118 renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false);
119 renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames, true);
120 renderer.renderTo(this, printer);
121 }
122}
123
124
Note: See TracBrowser for help on using the repository browser.