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

Last change on this file since 7905 was 5494, 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 QListIterator<t_point*> ip(points);
76 while (ip.hasNext()) {
77 t_point* point = ip.next();
78
79 if (point->_lonDeg > 180.0) point->_lonDeg -= 360.0;
80
81 QwtSymbol* symbol = new QwtSymbol(QwtSymbol::Rect, QBrush(point->_color),
82 QPen(point->_color), QSize(2,2));
83 QwtPlotMarker* marker = new QwtPlotMarker();
84 marker->setValue(point->_lonDeg, point->_latDeg);
85 if (point->_lonDeg > 170.0) {
86 marker->setLabelAlignment(Qt::AlignLeft);
87 }
88 else {
89 marker->setLabelAlignment(Qt::AlignRight);
90 }
91 QwtText text(point->_name);
92 QFont font = text.font();
93 font.setPointSize(font.pointSize()*0.8);
94 text.setFont(font);
95 text.setColor(point->_color);
96 marker->setLabel(text);
97 marker->setSymbol(symbol);
98 marker->attach(this);
99 _markers.append(marker);
100 }
101
102 replot();
103}
104
105// Print the widget
106////////////////////////////////////////////////////////////////////////////
107void t_worldPlot::slotPrint() {
108
109 QPrinter printer;
110 QPrintDialog* dialog = new QPrintDialog(&printer, this);
111 dialog->setWindowTitle(tr("Print Map"));
112 if (dialog->exec() != QDialog::Accepted) {
113 return;
114 }
115 else {
116 QwtPlotRenderer renderer;
117 renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false);
118 renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames, true);
119 renderer.renderTo(this, printer);
120 }
121}
122
123
Note: See TracBrowser for help on using the repository browser.