[5419] | 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 |
|
---|
| 31 | using namespace std;
|
---|
| 32 | using namespace GnssCenter;
|
---|
| 33 |
|
---|
| 34 | // Constructor
|
---|
| 35 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 36 | t_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 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 58 | t_worldPlot::~t_worldPlot() {
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | //
|
---|
| 62 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 63 | void 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);
|
---|
[5423] | 85 |
|
---|
| 86 | replot();
|
---|
[5419] | 87 | }
|
---|
| 88 |
|
---|
| 89 | // Print the widget
|
---|
| 90 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 91 | void 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 |
|
---|