1 |
|
---|
2 | /* -------------------------------------------------------------------------
|
---|
3 | * RTNet GUI
|
---|
4 | * -------------------------------------------------------------------------
|
---|
5 | *
|
---|
6 | * Class: t_map_stations
|
---|
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 |
|
---|
18 | #include <iostream>
|
---|
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 |
|
---|
30 | #include "map_stations.h"
|
---|
31 | #include "worldplot.h"
|
---|
32 | #include "thriftclient.h"
|
---|
33 |
|
---|
34 | using namespace std;
|
---|
35 | using namespace GnssCenter;
|
---|
36 |
|
---|
37 | Q_EXPORT_PLUGIN2(gnsscenter_map_stations, GnssCenter::t_map_stationsFactory)
|
---|
38 |
|
---|
39 | // Constructor
|
---|
40 | /////////////////////////////////////////////////////////////////////////////
|
---|
41 | t_map_stations::t_map_stations() : QMainWindow() {
|
---|
42 |
|
---|
43 | // World Plot
|
---|
44 | // ----------
|
---|
45 | _plot = new t_worldPlot();
|
---|
46 | setCentralWidget(_plot);
|
---|
47 |
|
---|
48 | // Tool Bar
|
---|
49 | // --------
|
---|
50 | QToolBar* toolBar = new QToolBar("t_map_stations_ToolBar");
|
---|
51 | addToolBar(Qt::BottomToolBarArea, toolBar);
|
---|
52 |
|
---|
53 | QAction* actStartThrift = new QAction("Start Thrift", 0);
|
---|
54 | toolBar->addAction(actStartThrift);
|
---|
55 | connect(actStartThrift, SIGNAL(triggered()), this, SLOT(slotStartThrift()));
|
---|
56 |
|
---|
57 | QAction* actStopThrift = new QAction("Stop Thrift", 0);
|
---|
58 | toolBar->addAction(actStopThrift);
|
---|
59 | connect(actStopThrift, SIGNAL(triggered()), this, SLOT(slotStopThrift()));
|
---|
60 |
|
---|
61 | // Thrift Client;
|
---|
62 | // --------------
|
---|
63 | _thriftClient = 0;
|
---|
64 | _results = 0;
|
---|
65 | }
|
---|
66 |
|
---|
67 | // Destructor
|
---|
68 | /////////////////////////////////////////////////////////////////////////////
|
---|
69 | t_map_stations::~t_map_stations() {
|
---|
70 | slotStopThrift();
|
---|
71 | if (_results) {
|
---|
72 | while (!_results->empty()) {
|
---|
73 | delete _results->back();
|
---|
74 | _results->pop_back();
|
---|
75 | }
|
---|
76 | delete _results;
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | //
|
---|
81 | /////////////////////////////////////////////////////////////////////////////
|
---|
82 | void t_map_stations::slotStartThrift() {
|
---|
83 | if (!_thriftClient) {
|
---|
84 | _thriftClient = new t_thriftClient(this);
|
---|
85 | connect(_thriftClient, SIGNAL(finished()), this, SLOT(slotThriftFinished()));
|
---|
86 | _thriftClient->start();
|
---|
87 | slotPlotResults();
|
---|
88 | }
|
---|
89 | //// beg test
|
---|
90 | else {
|
---|
91 | _plot->slotNewPoint("AAAA", 50.0, 15.0);
|
---|
92 | }
|
---|
93 | //// end test
|
---|
94 | }
|
---|
95 |
|
---|
96 | //
|
---|
97 | /////////////////////////////////////////////////////////////////////////////
|
---|
98 | void t_map_stations::slotStopThrift() {
|
---|
99 | qDebug() << "slotStopThrift" << _thriftClient;
|
---|
100 | if (_thriftClient) {
|
---|
101 | _thriftClient->stop();
|
---|
102 | _thriftClient = 0;
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | //
|
---|
107 | /////////////////////////////////////////////////////////////////////////////
|
---|
108 | void t_map_stations::slotThriftFinished() {
|
---|
109 | qDebug() << "slotThriftFinished" << _thriftClient;
|
---|
110 | sender()->deleteLater();
|
---|
111 | _thriftClient = 0;
|
---|
112 | }
|
---|
113 |
|
---|
114 | //
|
---|
115 | /////////////////////////////////////////////////////////////////////////////
|
---|
116 | void t_map_stations::putThriftResults(std::vector<t_thriftResult*>* results) {
|
---|
117 | QMutexLocker locker(&_mutex);
|
---|
118 | if (_results) {
|
---|
119 | while (!_results->empty()) {
|
---|
120 | delete _results->back();
|
---|
121 | _results->pop_back();
|
---|
122 | }
|
---|
123 | delete _results;
|
---|
124 | }
|
---|
125 | _results = results;
|
---|
126 | }
|
---|
127 |
|
---|
128 | //
|
---|
129 | /////////////////////////////////////////////////////////////////////////////
|
---|
130 | void t_map_stations::slotPlotResults() {
|
---|
131 | QMutexLocker locker(&_mutex);
|
---|
132 | // beg test
|
---|
133 | if (_results) {
|
---|
134 | for (unsigned ii = 0; ii < _results->size(); ii++) {
|
---|
135 | const t_thriftResult* result = _results->at(ii);
|
---|
136 | cout << result->_name << ' '
|
---|
137 | << result->_nGPS << ' ' << result->_nGLO << ' '
|
---|
138 | << result->_x << ' ' << result->_y << ' ' << result->_z << endl;
|
---|
139 | }
|
---|
140 | }
|
---|
141 | // end test
|
---|
142 | if (_thriftClient) {
|
---|
143 | QTimer::singleShot(1000, this, SLOT(slotPlotResults()));
|
---|
144 | }
|
---|
145 | }
|
---|