Changeset 4651 in ntrip for trunk/BNC/src/bncmap_svg.cpp


Ignore:
Timestamp:
Sep 6, 2012, 2:16:38 PM (12 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncmap_svg.cpp

    r4636 r4651  
    4747#include <qwt_plot_marker.h>
    4848#include <qwt_plot_canvas.h>
    49 #include <qwt_plot_panner.h>
    5049#include <qwt_plot_zoomer.h>
    51 #include <qwt_plot_magnifier.h>
    5250#include <qwt_plot_renderer.h>
    5351
     
    6563  _mapPlot->setAxisScale(QwtPlot::yLeft,    -90.0,  90.0);
    6664
    67   //  (void)new QwtPlotPanner(_mapPlot->canvas());
    68   //  (void)new QwtPlotMagnifier(_mapPlot->canvas());
    69   (void)new QwtPlotZoomer(_mapPlot->canvas());
     65  _mapPlotZoomer = new QwtPlotZoomer(_mapPlot->canvas());
    7066
    7167  _mapPlot->canvas()->setFocusPolicy(Qt::WheelFocus);
     
    9793  mainLayout->addLayout(buttonLayout);
    9894
     95  // Minimal and Maximal Coordinates
     96  // -------------------------------
     97  _minPointLat = 0.0;
     98  _maxPointLat = 0.0;
     99  _minPointLon = 0.0;
     100  _maxPointLon = 0.0;
     101
    99102  // Important
    100103  // ---------
     
    123126  marker->setSymbol(symbol);
    124127  marker->attach(_mapPlot);
     128
     129  // Remeber minimal and maximal coordinates
     130  // ---------------------------------------
     131  if (_minPointLat == 0.0 && _maxPointLat == 0.0 &&
     132      _minPointLon == 0.0 && _maxPointLon == 0.0) {
     133    _minPointLat = latDeg;
     134    _maxPointLat = latDeg;
     135    _minPointLon = lonDeg;
     136    _maxPointLon = lonDeg;
     137  }
     138  else {
     139    if      (_maxPointLat < latDeg) {
     140      _maxPointLat = latDeg;
     141    }
     142    else if (_minPointLat > latDeg) {
     143      _minPointLat = latDeg;
     144    }
     145    if      (_maxPointLon < lonDeg) {
     146      _maxPointLon = lonDeg;
     147    }
     148    else if (_minPointLon > lonDeg) {
     149      _minPointLon = lonDeg;
     150    }
     151  }
    125152}
    126153
     
    135162void t_bncMap::closeEvent(QCloseEvent* event) {
    136163  QDialog::closeEvent(event);
     164}
     165
     166//
     167////////////////////////////////////////////////////////////////////////////
     168void t_bncMap::showEvent(QShowEvent* event) {
     169  double width  = _maxPointLon - _minPointLon;
     170  double height = _maxPointLat - _minPointLat;
     171  if (width > 0 && height > 0) {
     172    QRectF rect(_minPointLon, _minPointLat, width, height);
     173    qDebug() << rect;
     174    _mapPlotZoomer->zoom(rect);
     175  }
     176  QDialog::showEvent(event);
    137177}
    138178
Note: See TracChangeset for help on using the changeset viewer.