/* ------------------------------------------------------------------------- * RTNet GUI * ------------------------------------------------------------------------- * * Class: t_map_stations * * Purpose: Plot map of stations/satellites * * Author: L. Mervart * * Created: 05-Jan-2013 * * Changes: * * -----------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include #include #include #include "map_stations.h" #include "utils.h" #include "worldplot.h" #include "thriftclient.h" using namespace std; using namespace GnssCenter; Q_EXPORT_PLUGIN2(gnsscenter_map_stations, GnssCenter::t_map_stationsFactory) // Constructor ///////////////////////////////////////////////////////////////////////////// t_map_stations::t_map_stations() : QMainWindow() { // World Plot // ---------- _plot = new t_worldPlot(); setCentralWidget(_plot); // Tool Bar // -------- QToolBar* toolBar = new QToolBar("t_map_stations_ToolBar"); addToolBar(Qt::BottomToolBarArea, toolBar); QAction* actStartThrift = new QAction("Start Thrift", 0); toolBar->addAction(actStartThrift); connect(actStartThrift, SIGNAL(triggered()), this, SLOT(slotStartThrift())); QAction* actStopThrift = new QAction("Stop Thrift", 0); toolBar->addAction(actStopThrift); connect(actStopThrift, SIGNAL(triggered()), this, SLOT(slotStopThrift())); // Thrift Client; // -------------- _thriftClient = 0; _results = 0; } // Destructor ///////////////////////////////////////////////////////////////////////////// t_map_stations::~t_map_stations() { slotStopThrift(); if (_results) { while (!_results->empty()) { delete _results->back(); _results->pop_back(); } delete _results; } } // ///////////////////////////////////////////////////////////////////////////// void t_map_stations::slotStartThrift() { if (!_thriftClient) { _thriftClient = new t_thriftClient(this); connect(_thriftClient, SIGNAL(finished()), this, SLOT(slotThriftFinished())); _thriftClient->start(); slotPlotResults(); } } // ///////////////////////////////////////////////////////////////////////////// void t_map_stations::slotStopThrift() { if (_thriftClient) { _thriftClient->stop(); _thriftClient = 0; } } // ///////////////////////////////////////////////////////////////////////////// void t_map_stations::slotThriftFinished() { sender()->deleteLater(); _thriftClient = 0; } // ///////////////////////////////////////////////////////////////////////////// void t_map_stations::putThriftResults(std::vector* results) { QMutexLocker locker(&_mutex); if (_results) { while (!_results->empty()) { delete _results->back(); _results->pop_back(); } delete _results; } _results = results; } // ///////////////////////////////////////////////////////////////////////////// void t_map_stations::slotPlotResults() { QMutexLocker locker(&_mutex); if (_results) { QList points; for (unsigned ii = 0; ii < _results->size(); ii++) { const t_thriftResult* result = _results->at(ii); double xyz[3]; xyz[0] = result->_x; xyz[1] = result->_y; xyz[2] = result->_z; double ell[3]; if (xyz2ell(xyz, ell) == success) { double latDeg = ell[0] * 180.0 / M_PI; double lonDeg = ell[1] * 180.0 / M_PI; QString str = QString().sprintf("%d/%d", result->_nGPS, result->_nGLO); t_worldPlot::t_point* point = new t_worldPlot::t_point(str, latDeg, lonDeg); points.append(point); } } _plot->slotNewPoints(points); QListIterator it(points); while (it.hasNext()) { delete it.next(); } } if (_thriftClient) { QTimer::singleShot(1000, this, SLOT(slotPlotResults())); } }