[4836] | 1 |
|
---|
| 2 | /* -------------------------------------------------------------------------
|
---|
| 3 | * RTNet GUI
|
---|
| 4 | * -------------------------------------------------------------------------
|
---|
| 5 | *
|
---|
[5406] | 6 | * Class: t_map_stations
|
---|
[4836] | 7 | *
|
---|
| 8 | * Purpose: Plot map of stations/satellites
|
---|
| 9 | *
|
---|
| 10 | * Author: L. Mervart
|
---|
| 11 | *
|
---|
| 12 | * Created: 05-Jan-2013
|
---|
| 13 | *
|
---|
| 14 | * Changes:
|
---|
| 15 | *
|
---|
| 16 | * -----------------------------------------------------------------------*/
|
---|
| 17 |
|
---|
[5418] | 18 | #include <iostream>
|
---|
[4836] | 19 | #include <QtSvg>
|
---|
| 20 |
|
---|
| 21 | #include <qwt_symbol.h>
|
---|
| 22 | #include <qwt_plot.h>
|
---|
| 23 | #include <qwt_plot_svgitem.h>
|
---|
| 24 | #include <qwt_plot_curve.h>
|
---|
| 25 | #include <qwt_plot_marker.h>
|
---|
| 26 | #include <qwt_plot_canvas.h>
|
---|
| 27 | #include <qwt_plot_zoomer.h>
|
---|
| 28 | #include <qwt_plot_renderer.h>
|
---|
| 29 |
|
---|
[5406] | 30 | #include "map_stations.h"
|
---|
[5420] | 31 | #include "worldplot.h"
|
---|
[5416] | 32 | #include "thriftclient.h"
|
---|
[4836] | 33 |
|
---|
[4858] | 34 | using namespace std;
|
---|
[5001] | 35 | using namespace GnssCenter;
|
---|
[4858] | 36 |
|
---|
[5406] | 37 | Q_EXPORT_PLUGIN2(gnsscenter_map_stations, GnssCenter::t_map_stationsFactory)
|
---|
[5018] | 38 |
|
---|
[4836] | 39 | // Constructor
|
---|
| 40 | /////////////////////////////////////////////////////////////////////////////
|
---|
[5420] | 41 | t_map_stations::t_map_stations() : QMainWindow() {
|
---|
[4836] | 42 |
|
---|
[5420] | 43 | // World Plot
|
---|
| 44 | // ----------
|
---|
| 45 | _plot = new t_worldPlot();
|
---|
| 46 | setCentralWidget(_plot);
|
---|
[4836] | 47 |
|
---|
[5422] | 48 | // Tool Bar
|
---|
| 49 | // --------
|
---|
| 50 | QToolBar* toolBar = new QToolBar("t_map_stations_ToolBar");
|
---|
| 51 | addToolBar(Qt::BottomToolBarArea, toolBar);
|
---|
[5430] | 52 |
|
---|
[5422] | 53 | QAction* actStartThrift = new QAction("Start Thrift", 0);
|
---|
| 54 | toolBar->addAction(actStartThrift);
|
---|
| 55 | connect(actStartThrift, SIGNAL(triggered()), this, SLOT(slotStartThrift()));
|
---|
| 56 |
|
---|
[5430] | 57 | QAction* actStopThrift = new QAction("Stop Thrift", 0);
|
---|
| 58 | toolBar->addAction(actStopThrift);
|
---|
| 59 | connect(actStopThrift, SIGNAL(triggered()), this, SLOT(slotStopThrift()));
|
---|
| 60 |
|
---|
[5410] | 61 | // Thrift Client;
|
---|
[5415] | 62 | // --------------
|
---|
[5422] | 63 | _thriftClient = 0;
|
---|
[5427] | 64 | _results = 0;
|
---|
[4836] | 65 | }
|
---|
| 66 |
|
---|
| 67 | // Destructor
|
---|
| 68 | /////////////////////////////////////////////////////////////////////////////
|
---|
[5422] | 69 | t_map_stations::~t_map_stations() {
|
---|
[5431] | 70 | slotStopThrift();
|
---|
[5428] | 71 | if (_results) {
|
---|
| 72 | while (!_results->empty()) {
|
---|
| 73 | delete _results->back();
|
---|
| 74 | _results->pop_back();
|
---|
| 75 | }
|
---|
| 76 | delete _results;
|
---|
| 77 | }
|
---|
[4836] | 78 | }
|
---|
| 79 |
|
---|
[5422] | 80 | //
|
---|
| 81 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 82 | void t_map_stations::slotStartThrift() {
|
---|
| 83 | if (!_thriftClient) {
|
---|
| 84 | _thriftClient = new t_thriftClient(this);
|
---|
[5431] | 85 | connect(_thriftClient, SIGNAL(finished()), this, SLOT(slotThriftFinished()));
|
---|
[5422] | 86 | _thriftClient->start();
|
---|
[5429] | 87 | slotPlotResults();
|
---|
[5422] | 88 | }
|
---|
| 89 | }
|
---|
[4836] | 90 |
|
---|
[5415] | 91 | //
|
---|
| 92 | /////////////////////////////////////////////////////////////////////////////
|
---|
[5430] | 93 | void t_map_stations::slotStopThrift() {
|
---|
[5431] | 94 | if (_thriftClient) {
|
---|
| 95 | _thriftClient->stop();
|
---|
[5430] | 96 | _thriftClient = 0;
|
---|
| 97 | }
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | //
|
---|
| 101 | /////////////////////////////////////////////////////////////////////////////
|
---|
[5431] | 102 | void t_map_stations::slotThriftFinished() {
|
---|
| 103 | sender()->deleteLater();
|
---|
| 104 | _thriftClient = 0;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | //
|
---|
| 108 | /////////////////////////////////////////////////////////////////////////////
|
---|
[5427] | 109 | void t_map_stations::putThriftResults(std::vector<t_thriftResult*>* results) {
|
---|
[5429] | 110 | QMutexLocker locker(&_mutex);
|
---|
[5427] | 111 | if (_results) {
|
---|
| 112 | while (!_results->empty()) {
|
---|
| 113 | delete _results->back();
|
---|
| 114 | _results->pop_back();
|
---|
| 115 | }
|
---|
| 116 | delete _results;
|
---|
| 117 | }
|
---|
| 118 | _results = results;
|
---|
[5429] | 119 | }
|
---|
| 120 |
|
---|
| 121 | //
|
---|
| 122 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 123 | void t_map_stations::slotPlotResults() {
|
---|
| 124 | QMutexLocker locker(&_mutex);
|
---|
[5427] | 125 | // beg test
|
---|
[5429] | 126 | if (_results) {
|
---|
| 127 | for (unsigned ii = 0; ii < _results->size(); ii++) {
|
---|
| 128 | const t_thriftResult* result = _results->at(ii);
|
---|
| 129 | cout << result->_name << ' '
|
---|
| 130 | << result->_nGPS << ' ' << result->_nGLO << ' '
|
---|
| 131 | << result->_x << ' ' << result->_y << ' ' << result->_z << endl;
|
---|
| 132 | }
|
---|
[5427] | 133 | }
|
---|
[5433] | 134 | _plot->slotNewPoint("AAAA", 50.0, 15.0);
|
---|
[5427] | 135 | // end test
|
---|
[5430] | 136 | if (_thriftClient) {
|
---|
| 137 | QTimer::singleShot(1000, this, SLOT(slotPlotResults()));
|
---|
| 138 | }
|
---|
[5415] | 139 | }
|
---|