source: ntrip/trunk/GnssCenter/map_stations/worldplot.cpp@ 5431

Last change on this file since 5431 was 5423, checked in by mervart, 9 years ago
File size: 2.7 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::slotNewPoint(const QString& name, double latDeg, double lonDeg) {
64
65 if (lonDeg > 180.0) lonDeg -= 360.0;
66
67 QColor red(220,20,60);
68 QwtSymbol* symbol = new QwtSymbol(QwtSymbol::Rect, QBrush(red),
69 QPen(red), QSize(2,2));
70 QwtPlotMarker* marker = new QwtPlotMarker();
71 marker->setValue(lonDeg, latDeg);
72 if (lonDeg > 170.0) {
73 marker->setLabelAlignment(Qt::AlignLeft);
74 }
75 else {
76 marker->setLabelAlignment(Qt::AlignRight);
77 }
78 QwtText text(name.left(4));
79 QFont font = text.font();
80 font.setPointSize(font.pointSize()*0.8);
81 text.setFont(font);
82 marker->setLabel(text);
83 marker->setSymbol(symbol);
84 marker->attach(this);
85
86 replot();
87}
88
89// Print the widget
90////////////////////////////////////////////////////////////////////////////
91void t_worldPlot::slotPrint() {
92
93 QPrinter printer;
94 QPrintDialog* dialog = new QPrintDialog(&printer, this);
95 dialog->setWindowTitle(tr("Print Map"));
96 if (dialog->exec() != QDialog::Accepted) {
97 return;
98 }
99 else {
100 QwtPlotRenderer renderer;
101 renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false);
102 renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames, true);
103 renderer.renderTo(this, printer);
104 }
105}
106
107
Note: See TracBrowser for help on using the repository browser.