Changeset 5420 in ntrip


Ignore:
Timestamp:
Sep 12, 2013, 4:05:11 PM (11 years ago)
Author:
mervart
Message:
 
Location:
trunk/GnssCenter/map_stations
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GnssCenter/map_stations/map_stations.cpp

    r5418 r5420  
    2929
    3030#include "map_stations.h"
     31#include "worldplot.h"
    3132#include "thriftclient.h"
    3233
     
    3839// Constructor
    3940/////////////////////////////////////////////////////////////////////////////
    40 t_map_stations::t_map_stations() : QDialog() {
     41t_map_stations::t_map_stations() : QMainWindow() {
    4142
    42   // Map in Scalable Vector Graphics (svg) Format
    43   // --------------------------------------------
    44   _mapPlot = new QwtPlot();
    45 
    46   _mapPlot->setAxisScale(QwtPlot::xBottom, -180.0, 180.0);
    47   _mapPlot->setAxisScale(QwtPlot::yLeft,    -90.0,  90.0);
    48 
    49   _mapPlotZoomer = new QwtPlotZoomer(_mapPlot->canvas());
    50 
    51   _mapPlot->canvas()->setFocusPolicy(Qt::WheelFocus);
    52 
    53   QwtPlotSvgItem* mapItem = new QwtPlotSvgItem();
    54   mapItem->loadFile(QRectF(-180.0, -90.0, 360.0, 180.0), ":world.svg");
    55   mapItem->attach(_mapPlot);
    56 
    57   // Buttons
    58   // -------
    59   int ww = QFontMetrics(font()).width('w');
    60 
    61   _buttonClose = new QPushButton(tr("Close"), this);
    62   _buttonClose->setMaximumWidth(10*ww);
    63   connect(_buttonClose, SIGNAL(clicked()), this, SLOT(slotClose()));
    64 
    65   _buttonPrint = new QPushButton(tr("Print"), this);
    66   _buttonPrint->setMaximumWidth(10*ww);
    67   connect(_buttonPrint, SIGNAL(clicked()), this, SLOT(slotPrint()));
    68 
    69   _buttonWhatsThis = new QPushButton(tr("Help=Shift+F1"), this);
    70   _buttonWhatsThis->setMaximumWidth(10*ww);
    71   connect(_buttonWhatsThis, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
    72 
    73   // Layout
    74   // ------
    75   QHBoxLayout* buttonLayout = new QHBoxLayout;
    76   buttonLayout->addWidget(_buttonClose);
    77   buttonLayout->addWidget(_buttonPrint);
    78   buttonLayout->addWidget(_buttonWhatsThis);
    79 
    80   QVBoxLayout* mainLayout = new QVBoxLayout(this);
    81   mainLayout->addWidget(_mapPlot);
    82   mainLayout->addLayout(buttonLayout);
    83 
    84   // WhatsThis
    85   // ---------
    86   _buttonClose->setWhatsThis(tr("<p>Close window.</p>"));
    87   _buttonPrint->setWhatsThis(tr("<p>Print stream distribution map.</p>"));
    88 
    89   // Minimal and Maximal Coordinates
    90   // -------------------------------
    91   _minPointLat = 0.0;
    92   _maxPointLat = 0.0;
    93   _minPointLon = 0.0;
    94   _maxPointLon = 0.0;
    95 
    96   // Important
    97   // ---------
    98   _mapPlot->replot();
     43  // World Plot
     44  // ----------
     45  _plot = new t_worldPlot();
     46  setCentralWidget(_plot);
    9947
    10048  // Thrift Client;
     
    10755/////////////////////////////////////////////////////////////////////////////
    10856t_map_stations::~t_map_stations() {
    109   delete _mapPlot;
    110   delete _buttonWhatsThis;
    11157  _thriftClient->stop();
    11258}
    11359
    114 //
    115 /////////////////////////////////////////////////////////////////////////////
    116 void t_map_stations::slotNewPoint(const QString& name, double latDeg, double lonDeg) {
    117 
    118   if (lonDeg > 180.0) lonDeg -= 360.0;
    119 
    120   QColor red(220,20,60);
    121   QwtSymbol* symbol = new QwtSymbol(QwtSymbol::Rect, QBrush(red),
    122                                     QPen(red), QSize(2,2));
    123   QwtPlotMarker* marker = new QwtPlotMarker();
    124   marker->setValue(lonDeg, latDeg);
    125   if (lonDeg > 170.0) {
    126     marker->setLabelAlignment(Qt::AlignLeft);
    127   }
    128   else {
    129     marker->setLabelAlignment(Qt::AlignRight);
    130   }
    131   QwtText text(name.left(4));
    132   QFont   font = text.font();
    133   font.setPointSize(font.pointSize()*0.8);
    134   text.setFont(font);
    135   marker->setLabel(text);
    136   marker->setSymbol(symbol);
    137   marker->attach(_mapPlot);
    138 
    139   // Remeber minimal and maximal coordinates
    140   // ---------------------------------------
    141   if (_minPointLat == 0.0 && _maxPointLat == 0.0 &&
    142       _minPointLon == 0.0 && _maxPointLon == 0.0) {
    143     _minPointLat = latDeg;
    144     _maxPointLat = latDeg;
    145     _minPointLon = lonDeg;
    146     _maxPointLon = lonDeg;
    147   }
    148   else {
    149     if      (_maxPointLat < latDeg) {
    150       _maxPointLat = latDeg;
    151     }
    152     else if (_minPointLat > latDeg) {
    153       _minPointLat = latDeg;
    154     }
    155     if      (_maxPointLon < lonDeg) {
    156       _maxPointLon = lonDeg;
    157     }
    158     else if (_minPointLon > lonDeg) {
    159       _minPointLon = lonDeg;
    160     }
    161   }
    162 }
    16360
    16461//
     
    16966       << result->_x << ' ' << result->_y << ' ' << result->_z << endl;
    17067}
    171 
    172 // Close
    173 ////////////////////////////////////////////////////////////////////////////
    174 void t_map_stations::slotClose() {
    175   done(0);
    176 }
    177 
    178 // Close Dialog gracefully
    179 ////////////////////////////////////////////////////////////////////////////
    180 void t_map_stations::closeEvent(QCloseEvent* event) {
    181   QDialog::closeEvent(event);
    182 }
    183 
    184 //
    185 ////////////////////////////////////////////////////////////////////////////
    186 void t_map_stations::showEvent(QShowEvent* event) {
    187   double width  = _maxPointLon - _minPointLon;
    188   double height = _maxPointLat - _minPointLat;
    189   if (width > 0 && height > 0) {
    190 
    191     // Extend plot area by 10 percent
    192     // ------------------------------
    193     double eps = 0.1;
    194     double epsLon    = eps * (_maxPointLon - _minPointLon);
    195     double epsLat    = eps * (_maxPointLat - _minPointLat);
    196     double widthExt  = width  + 2 * epsLon;
    197     double heightExt = height + 2 * epsLat;
    198     double minLon    = _minPointLon - epsLon;
    199     double minLat    = _minPointLat - epsLat;
    200 
    201     // Keep lat/lon relations
    202     // ----------------------
    203     double widthBorder = widthExt;
    204     double heightBorder = heightExt;
    205     double scale = widthExt/heightExt/2.;
    206     if ( scale < 1.) {
    207       widthBorder = widthExt / scale;
    208       minLon = minLon - (widthBorder - widthExt)/2.;
    209     }
    210     else {
    211       heightBorder = heightExt * scale;
    212       minLat = minLat - (heightBorder - heightExt)/2.;
    213     }
    214 
    215     // Borders shall not exceed min or max values
    216     // ------------------------------------------
    217     if (minLon < -180.) minLon = -180.;
    218     if (minLat <  -90.) minLat =  -90.;
    219     double maxLat = minLat + heightBorder;
    220     if ( maxLat >  90) minLat = minLat - (maxLat -  90.);
    221     double maxLon = minLon + widthBorder;
    222     if ( maxLon > 180) minLon = minLon - (maxLon - 180.);
    223 
    224     // Area large enough to justify world map
    225     // --------------------------------------
    226     if (widthBorder < 270.0 && heightBorder < 135.0) {
    227       QRectF rect(minLon, minLat, widthBorder, heightBorder);
    228       _mapPlotZoomer->zoom(rect);
    229     }
    230   }
    231   QDialog::showEvent(event);
    232 }
    233 
    234 // Print the widget
    235 ////////////////////////////////////////////////////////////////////////////
    236 void t_map_stations::slotPrint() {
    237 
    238   QPrinter printer;
    239   QPrintDialog* dialog = new QPrintDialog(&printer, this);
    240   dialog->setWindowTitle(tr("Print Map"));
    241   if (dialog->exec() != QDialog::Accepted) {
    242     return;
    243   }
    244   else {
    245     QwtPlotRenderer renderer;
    246     renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false);
    247     renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames, true);
    248     renderer.renderTo(_mapPlot, printer);
    249   }
    250 }
    251 
    252 // Whats This Help
    253 ////////////////////////////////////////////////////////////////////////////
    254 void t_map_stations::slotWhatsThis() {
    255   QWhatsThis::enterWhatsThisMode();
    256 }
    257 
  • trunk/GnssCenter/map_stations/map_stations.h

    r5416 r5420  
    66#include "plugininterface.h"
    77
    8 class QwtPlot;
    9 class QwtPlotZoomer;
     8namespace GnssCenter {
     9class t_worldPlot;
     10}
     11
    1012class t_thriftClient;
    1113class t_thriftResult;
     
    1315namespace GnssCenter {
    1416
    15 class t_map_stations : public QDialog {
     17class t_map_stations : public QMainWindow {
    1618 Q_OBJECT
    1719 public:
     
    2022
    2123 public slots:
    22   void slotNewPoint(const QString& name, double latDeg, double lonDeg);
    2324  void slotNewThriftResult(t_thriftResult*);
    2425
    25  private slots:
    26   void slotClose();
    27   void slotPrint();
    28   void slotWhatsThis();
    29 
    30  protected:
    31   virtual void closeEvent(QCloseEvent *);
    32   virtual void showEvent(QShowEvent *);
    33 
    3426 private:
    35   QwtPlot*        _mapPlot;
    36   QwtPlotZoomer*  _mapPlotZoomer;
    37   QPushButton*    _buttonClose;
    38   QPushButton*    _buttonPrint;
    39   QPushButton*    _buttonWhatsThis;
    40   double          _minPointLat;
    41   double          _maxPointLat;
    42   double          _minPointLon;
    43   double          _maxPointLon;
    44 
     27  t_worldPlot*    _plot;
    4528  t_thriftClient* _thriftClient;
    4629};
  • trunk/GnssCenter/map_stations/map_stations.pro

    r5413 r5420  
    2525
    2626HEADERS   = map_stations.h \
     27            worldplot.h    \
    2728            thriftclient.h
    2829
    2930SOURCES   = map_stations.cpp \
     31            worldplot.cpp    \
    3032            thriftclient.cpp \
    3133            gen-cpp/RtnetData.cpp \
Note: See TracChangeset for help on using the changeset viewer.