mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Added support for vector maps projection setting
Removed obsolete "Always show the map" setting
This commit is contained in:
parent
f0d71d667b
commit
37c971a720
@ -177,7 +177,8 @@ HEADERS += src/common/config.h \
|
|||||||
src/map/IMG/subdiv.h \
|
src/map/IMG/subdiv.h \
|
||||||
src/map/IMG/units.h \
|
src/map/IMG/units.h \
|
||||||
src/map/IMG/style.h \
|
src/map/IMG/style.h \
|
||||||
src/map/IMG/netfile.h
|
src/map/IMG/netfile.h \
|
||||||
|
src/GUI/limitedcombobox.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/common/coordinates.cpp \
|
src/common/coordinates.cpp \
|
||||||
src/common/rectc.cpp \
|
src/common/rectc.cpp \
|
||||||
|
@ -103,7 +103,6 @@ GUI::GUI()
|
|||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
updateGraphTabs();
|
updateGraphTabs();
|
||||||
updateMapView();
|
|
||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,7 +804,7 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
|
|
||||||
for (int i = 0; i < _tabs.count(); i++)
|
for (int i = 0; i < _tabs.count(); i++)
|
||||||
graphs.append(_tabs.at(i)->loadData(data));
|
graphs.append(_tabs.at(i)->loadData(data));
|
||||||
if (updateGraphTabs() | updateMapView())
|
if (updateGraphTabs())
|
||||||
_splitter->refresh();
|
_splitter->refresh();
|
||||||
paths = _mapView->loadData(data);
|
paths = _mapView->loadData(data);
|
||||||
|
|
||||||
@ -828,7 +827,6 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
updateGraphTabs();
|
updateGraphTabs();
|
||||||
updateMapView();
|
|
||||||
|
|
||||||
QString error = tr("Error loading data file:") + "\n\n"
|
QString error = tr("Error loading data file:") + "\n\n"
|
||||||
+ fileName + "\n\n" + data.errorString();
|
+ fileName + "\n\n" + data.errorString();
|
||||||
@ -930,6 +928,7 @@ void GUI::openOptions()
|
|||||||
SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
|
SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
|
||||||
SET_VIEW_OPTION(useOpenGL, useOpenGL);
|
SET_VIEW_OPTION(useOpenGL, useOpenGL);
|
||||||
SET_VIEW_OPTION(sliderColor, setMarkerColor);
|
SET_VIEW_OPTION(sliderColor, setMarkerColor);
|
||||||
|
SET_VIEW_OPTION(projection, setProjection);
|
||||||
|
|
||||||
SET_TAB_OPTION(palette, setPalette);
|
SET_TAB_OPTION(palette, setPalette);
|
||||||
SET_TAB_OPTION(graphWidth, setGraphWidth);
|
SET_TAB_OPTION(graphWidth, setGraphWidth);
|
||||||
@ -974,8 +973,6 @@ void GUI::openOptions()
|
|||||||
reloadFile();
|
reloadFile();
|
||||||
|
|
||||||
_options = options;
|
_options = options;
|
||||||
|
|
||||||
updateMapView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::printFile()
|
void GUI::printFile()
|
||||||
@ -1230,7 +1227,6 @@ void GUI::closeAll()
|
|||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
updateGraphTabs();
|
updateGraphTabs();
|
||||||
updateMapView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::showGraphs(bool show)
|
void GUI::showGraphs(bool show)
|
||||||
@ -1473,19 +1469,6 @@ bool GUI::updateGraphTabs()
|
|||||||
return (hidden != _graphTabWidget->isHidden());
|
return (hidden != _graphTabWidget->isHidden());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GUI::updateMapView()
|
|
||||||
{
|
|
||||||
bool hidden = _mapView->isHidden();
|
|
||||||
|
|
||||||
if (_options.alwaysShowMap)
|
|
||||||
_mapView->setHidden(false);
|
|
||||||
else
|
|
||||||
_mapView->setHidden(!(_trackCount + _routeCount + _waypointCount
|
|
||||||
+ _areaCount));
|
|
||||||
|
|
||||||
return (hidden != _mapView->isHidden());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::setTimeType(TimeType type)
|
void GUI::setTimeType(TimeType type)
|
||||||
{
|
{
|
||||||
for (int i = 0; i <_tabs.count(); i++)
|
for (int i = 0; i <_tabs.count(); i++)
|
||||||
@ -1847,8 +1830,8 @@ void GUI::writeSettings()
|
|||||||
_options.separateGraphPage);
|
_options.separateGraphPage);
|
||||||
if (_options.sliderColor != SLIDER_COLOR_DEFAULT)
|
if (_options.sliderColor != SLIDER_COLOR_DEFAULT)
|
||||||
settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor);
|
settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor);
|
||||||
if (_options.alwaysShowMap != ALWAYS_SHOW_MAP_DEFAULT)
|
if (_options.projection != PROJECTION_DEFAULT)
|
||||||
settings.setValue(ALWAYS_SHOW_MAP_SETTING, _options.alwaysShowMap);
|
settings.setValue(PROJECTION_SETTING, _options.projection);
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
if (_options.hidpiMap != HIDPI_MAP_DEFAULT)
|
if (_options.hidpiMap != HIDPI_MAP_DEFAULT)
|
||||||
settings.setValue(HIDPI_MAP_SETTING, _options.hidpiMap);
|
settings.setValue(HIDPI_MAP_SETTING, _options.hidpiMap);
|
||||||
@ -2110,8 +2093,8 @@ void GUI::readSettings()
|
|||||||
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
|
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
|
||||||
_options.sliderColor = settings.value(SLIDER_COLOR_SETTING,
|
_options.sliderColor = settings.value(SLIDER_COLOR_SETTING,
|
||||||
SLIDER_COLOR_DEFAULT).value<QColor>();
|
SLIDER_COLOR_DEFAULT).value<QColor>();
|
||||||
_options.alwaysShowMap = settings.value(ALWAYS_SHOW_MAP_SETTING,
|
_options.projection = settings.value(PROJECTION_SETTING, PROJECTION_DEFAULT)
|
||||||
ALWAYS_SHOW_MAP_DEFAULT).toBool();
|
.toInt();
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_options.hidpiMap = settings.value(HIDPI_MAP_SETTING, HIDPI_MAP_SETTING)
|
_options.hidpiMap = settings.value(HIDPI_MAP_SETTING, HIDPI_MAP_SETTING)
|
||||||
.toBool();
|
.toBool();
|
||||||
@ -2139,6 +2122,7 @@ void GUI::readSettings()
|
|||||||
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
||||||
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
_mapView->setProjection(_options.projection);
|
||||||
|
|
||||||
for (int i = 0; i < _tabs.count(); i++) {
|
for (int i = 0; i < _tabs.count(); i++) {
|
||||||
_tabs.at(i)->setPalette(_options.palette);
|
_tabs.at(i)->setPalette(_options.palette);
|
||||||
|
@ -116,7 +116,6 @@ private:
|
|||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
void updateNavigationActions();
|
void updateNavigationActions();
|
||||||
bool updateGraphTabs();
|
bool updateGraphTabs();
|
||||||
bool updateMapView();
|
|
||||||
|
|
||||||
TimeType timeType() const;
|
TimeType timeType() const;
|
||||||
Units units() const;
|
Units units() const;
|
||||||
|
38
src/GUI/limitedcombobox.h
Normal file
38
src/GUI/limitedcombobox.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#ifndef LIMITEDCOMBOBOX_H
|
||||||
|
#define LIMITEDCOMBOBOX_H
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QEvent>
|
||||||
|
|
||||||
|
class LimitedComboBox : public QComboBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LimitedComboBox(int limit, QWidget *parent = 0)
|
||||||
|
: QComboBox(parent), _limit(limit)
|
||||||
|
{
|
||||||
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(qMin(_limit, QComboBox::sizeHint().width()),
|
||||||
|
QComboBox::sizeHint().height());
|
||||||
|
}
|
||||||
|
QSize minimumSizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(qMin(_limit, QComboBox::minimumSizeHint().width()),
|
||||||
|
QComboBox::minimumSizeHint().height());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool event(QEvent *e)
|
||||||
|
{
|
||||||
|
if (e->type() == QEvent::Polish)
|
||||||
|
view()->setMinimumWidth(QComboBox::sizeHint().width());
|
||||||
|
return QComboBox::event(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _limit;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LIMITEDCOMBOBOX_H
|
@ -7,6 +7,7 @@
|
|||||||
#include "data/poi.h"
|
#include "data/poi.h"
|
||||||
#include "data/data.h"
|
#include "data/data.h"
|
||||||
#include "map/map.h"
|
#include "map/map.h"
|
||||||
|
#include "map/pcs.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "trackitem.h"
|
#include "trackitem.h"
|
||||||
#include "routeitem.h"
|
#include "routeitem.h"
|
||||||
@ -48,8 +49,10 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
|||||||
_coordinates->setVisible(false);
|
_coordinates->setVisible(false);
|
||||||
_scene->addItem(_coordinates);
|
_scene->addItem(_coordinates);
|
||||||
|
|
||||||
|
_projection = PCS::pcs(3857);
|
||||||
_map = map;
|
_map = map;
|
||||||
_map->load();
|
_map->load();
|
||||||
|
_map->setProjection(_projection);
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||||
|
|
||||||
_poi = poi;
|
_poi = poi;
|
||||||
@ -312,6 +315,7 @@ void MapView::setMap(Map *map)
|
|||||||
|
|
||||||
_map = map;
|
_map = map;
|
||||||
_map->load();
|
_map->load();
|
||||||
|
_map->setProjection(_projection);
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
|
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
@ -1012,3 +1016,17 @@ void MapView::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
|||||||
Q_UNUSED(mapRatio);
|
Q_UNUSED(mapRatio);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::setProjection(int id)
|
||||||
|
{
|
||||||
|
Projection projection(PCS::pcs(id));
|
||||||
|
if (!projection.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
_projection = projection;
|
||||||
|
|
||||||
|
Coordinates center = _map->xy2ll(mapToScene(viewport()->rect().center()));
|
||||||
|
_map->setProjection(_projection);
|
||||||
|
rescale();
|
||||||
|
centerOn(_map->ll2xy(center));
|
||||||
|
}
|
||||||
|
@ -8,11 +8,13 @@
|
|||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "data/waypoint.h"
|
#include "data/waypoint.h"
|
||||||
|
#include "data/polygon.h"
|
||||||
|
#include "map/projection.h"
|
||||||
#include "searchpointer.h"
|
#include "searchpointer.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "data/polygon.h"
|
|
||||||
|
|
||||||
class Data;
|
class Data;
|
||||||
class POI;
|
class POI;
|
||||||
@ -80,6 +82,7 @@ public slots:
|
|||||||
void clearMapCache();
|
void clearMapCache();
|
||||||
void setCoordinatesFormat(CoordinatesFormat format);
|
void setCoordinatesFormat(CoordinatesFormat format);
|
||||||
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||||
|
void setProjection(int id);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatePOI();
|
void updatePOI();
|
||||||
@ -132,6 +135,7 @@ private:
|
|||||||
Units _units;
|
Units _units;
|
||||||
CoordinatesFormat _coordinatesFormat;
|
CoordinatesFormat _coordinatesFormat;
|
||||||
qreal _mapOpacity;
|
qreal _mapOpacity;
|
||||||
|
Projection _projection;
|
||||||
|
|
||||||
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
||||||
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
||||||
|
@ -12,11 +12,14 @@
|
|||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include "map/pcs.h"
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
#include "colorbox.h"
|
#include "colorbox.h"
|
||||||
#include "stylecombobox.h"
|
#include "stylecombobox.h"
|
||||||
#include "oddspinbox.h"
|
#include "oddspinbox.h"
|
||||||
#include "percentslider.h"
|
#include "percentslider.h"
|
||||||
|
#include "limitedcombobox.h"
|
||||||
#include "optionsdialog.h"
|
#include "optionsdialog.h"
|
||||||
|
|
||||||
|
|
||||||
@ -36,10 +39,15 @@ static QFrame *line()
|
|||||||
|
|
||||||
QWidget *OptionsDialog::createMapPage()
|
QWidget *OptionsDialog::createMapPage()
|
||||||
{
|
{
|
||||||
_alwaysShowMap = new QCheckBox(tr("Always show the map"));
|
_projection = new LimitedComboBox(200);
|
||||||
_alwaysShowMap->setChecked(_options->alwaysShowMap);
|
QList<PCS::Info> projections(PCS::pcsList());
|
||||||
_alwaysShowMap->setToolTip("<p>" +
|
qSort(projections);
|
||||||
tr("Show the map even when no files are loaded.") + "</p>");
|
for (int i = 0; i < projections.size(); i++) {
|
||||||
|
QString text = QString::number(projections.at(i).id()) + " - "
|
||||||
|
+ projections.at(i).name();
|
||||||
|
_projection->addItem(text, QVariant(projections.at(i).id()));
|
||||||
|
}
|
||||||
|
_projection->setCurrentIndex(_projection->findData(_options->projection));
|
||||||
|
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_hidpi = new QRadioButton(tr("High-resolution"));
|
_hidpi = new QRadioButton(tr("High-resolution"));
|
||||||
@ -60,14 +68,14 @@ QWidget *OptionsDialog::createMapPage()
|
|||||||
llo->setFont(f);
|
llo->setFont(f);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
|
||||||
QFormLayout *showMapLayout = new QFormLayout();
|
QFormLayout *vectorLayout = new QFormLayout();
|
||||||
showMapLayout->addWidget(_alwaysShowMap);
|
vectorLayout->addRow(tr("Projection:"), _projection);
|
||||||
|
|
||||||
QWidget *mapTab = new QWidget();
|
QWidget *vectorMapsTab = new QWidget();
|
||||||
QVBoxLayout *mapTabLayout = new QVBoxLayout();
|
QVBoxLayout *vectorMapsTabLayout = new QVBoxLayout();
|
||||||
mapTabLayout->addLayout(showMapLayout);
|
vectorMapsTabLayout->addLayout(vectorLayout);
|
||||||
mapTabLayout->addStretch();
|
vectorMapsTabLayout->addStretch();
|
||||||
mapTab->setLayout(mapTabLayout);
|
vectorMapsTab->setLayout(vectorMapsTabLayout);
|
||||||
|
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
QVBoxLayout *hidpiTabLayout = new QVBoxLayout();
|
QVBoxLayout *hidpiTabLayout = new QVBoxLayout();
|
||||||
@ -83,7 +91,7 @@ QWidget *OptionsDialog::createMapPage()
|
|||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
|
||||||
QTabWidget *mapPage = new QTabWidget();
|
QTabWidget *mapPage = new QTabWidget();
|
||||||
mapPage->addTab(mapTab, tr("General"));
|
mapPage->addTab(vectorMapsTab, tr("Vector maps"));
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
mapPage->addTab(hidpiTab, tr("HiDPI display mode"));
|
mapPage->addTab(hidpiTab, tr("HiDPI display mode"));
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
@ -261,6 +269,7 @@ QWidget *OptionsDialog::createAppearancePage()
|
|||||||
_backgroundColor = new ColorBox();
|
_backgroundColor = new ColorBox();
|
||||||
_backgroundColor->setColor(_options->backgroundColor);
|
_backgroundColor->setColor(_options->backgroundColor);
|
||||||
_backgroundColor->enableAlphaChannel(false);
|
_backgroundColor->enableAlphaChannel(false);
|
||||||
|
|
||||||
QFormLayout *mapLayout = new QFormLayout();
|
QFormLayout *mapLayout = new QFormLayout();
|
||||||
mapLayout->addRow(tr("Background color:"), _backgroundColor);
|
mapLayout->addRow(tr("Background color:"), _backgroundColor);
|
||||||
mapLayout->addRow(tr("Map opacity:"), _mapOpacity);
|
mapLayout->addRow(tr("Map opacity:"), _mapOpacity);
|
||||||
@ -656,7 +665,7 @@ void OptionsDialog::accept()
|
|||||||
_options->sliderColor = _sliderColor->color();
|
_options->sliderColor = _sliderColor->color();
|
||||||
_options->graphAntiAliasing = _graphAA->isChecked();
|
_options->graphAntiAliasing = _graphAA->isChecked();
|
||||||
|
|
||||||
_options->alwaysShowMap = _alwaysShowMap->isChecked();
|
_options->projection = _projection->currentData().toInt();
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_options->hidpiMap = _hidpi->isChecked();
|
_options->hidpiMap = _hidpi->isChecked();
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
@ -15,6 +15,7 @@ class QComboBox;
|
|||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QRadioButton;
|
class QRadioButton;
|
||||||
class PercentSlider;
|
class PercentSlider;
|
||||||
|
class LimitedComboBox;
|
||||||
|
|
||||||
struct Options {
|
struct Options {
|
||||||
// Appearance
|
// Appearance
|
||||||
@ -37,7 +38,7 @@ struct Options {
|
|||||||
int mapOpacity;
|
int mapOpacity;
|
||||||
QColor backgroundColor;
|
QColor backgroundColor;
|
||||||
// Map
|
// Map
|
||||||
bool alwaysShowMap;
|
int projection;
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
bool hidpiMap;
|
bool hidpiMap;
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
@ -79,11 +80,14 @@ class OptionsDialog : public QDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void accept();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OptionsDialog(Options *options, QWidget *parent = 0);
|
OptionsDialog(Options *options, QWidget *parent = 0);
|
||||||
|
|
||||||
public slots:
|
//private slots:
|
||||||
void accept();
|
// void projectionChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *createMapPage();
|
QWidget *createMapPage();
|
||||||
@ -116,7 +120,7 @@ private:
|
|||||||
ColorBox *_sliderColor;
|
ColorBox *_sliderColor;
|
||||||
QCheckBox *_graphAA;
|
QCheckBox *_graphAA;
|
||||||
// Map
|
// Map
|
||||||
QCheckBox *_alwaysShowMap;
|
LimitedComboBox *_projection;
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
QRadioButton *_hidpi;
|
QRadioButton *_hidpi;
|
||||||
QRadioButton *_lodpi;
|
QRadioButton *_lodpi;
|
||||||
|
@ -171,8 +171,8 @@
|
|||||||
#define SEPARATE_GRAPH_PAGE_DEFAULT false
|
#define SEPARATE_GRAPH_PAGE_DEFAULT false
|
||||||
#define SLIDER_COLOR_SETTING "sliderColor"
|
#define SLIDER_COLOR_SETTING "sliderColor"
|
||||||
#define SLIDER_COLOR_DEFAULT QColor(Qt::red)
|
#define SLIDER_COLOR_DEFAULT QColor(Qt::red)
|
||||||
#define ALWAYS_SHOW_MAP_SETTING "alwaysShowMap"
|
#define PROJECTION_SETTING "projection"
|
||||||
#define ALWAYS_SHOW_MAP_DEFAULT true
|
#define PROJECTION_DEFAULT 3857
|
||||||
#define HIDPI_MAP_SETTING "HiDPIMap"
|
#define HIDPI_MAP_SETTING "HiDPIMap"
|
||||||
#define HIDPI_MAP_DEFAULT true
|
#define HIDPI_MAP_DEFAULT true
|
||||||
|
|
||||||
|
@ -369,3 +369,10 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
painter->drawPixmap(mt.xy(), pm);
|
painter->drawPixmap(mt.xy(), pm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IMGMap::setProjection(const Projection &projection)
|
||||||
|
{
|
||||||
|
_projection = projection;
|
||||||
|
updateTransform();
|
||||||
|
QPixmapCache::clear();
|
||||||
|
}
|
||||||
|
@ -31,6 +31,8 @@ public:
|
|||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||||
|
|
||||||
|
void setProjection(const Projection &projection);
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <QLineF>
|
#include <QLineF>
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
#include "pcs.h"
|
||||||
|
|
||||||
qreal Map::resolution(const QRectF &rect)
|
qreal Map::resolution(const QRectF &rect)
|
||||||
{
|
{
|
||||||
|
@ -7,8 +7,10 @@
|
|||||||
#include <QFlags>
|
#include <QFlags>
|
||||||
#include "common/coordinates.h"
|
#include "common/coordinates.h"
|
||||||
|
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class RectC;
|
class RectC;
|
||||||
|
class Projection;
|
||||||
|
|
||||||
class Map : public QObject
|
class Map : public QObject
|
||||||
{
|
{
|
||||||
@ -45,6 +47,7 @@ public:
|
|||||||
virtual void load() {}
|
virtual void load() {}
|
||||||
virtual void unload() {}
|
virtual void unload() {}
|
||||||
virtual void setDevicePixelRatio(qreal, qreal) {}
|
virtual void setDevicePixelRatio(qreal, qreal) {}
|
||||||
|
virtual void setProjection(const Projection &) {}
|
||||||
|
|
||||||
virtual bool isValid() const {return true;}
|
virtual bool isValid() const {return true;}
|
||||||
virtual QString errorString() const {return QString();}
|
virtual QString errorString() const {return QString();}
|
||||||
|
@ -5,13 +5,16 @@
|
|||||||
|
|
||||||
class PCS::Entry {
|
class PCS::Entry {
|
||||||
public:
|
public:
|
||||||
Entry(int id, int proj, const PCS &pcs) : _id(id), _proj(proj), _pcs(pcs) {}
|
Entry(const QString &name, int id, int proj, const PCS &pcs)
|
||||||
|
: _name(name), _id(id), _proj(proj), _pcs(pcs) {}
|
||||||
|
|
||||||
|
const QString &name() const {return _name;}
|
||||||
int id() const {return _id;}
|
int id() const {return _id;}
|
||||||
int proj() const {return _proj;}
|
int proj() const {return _proj;}
|
||||||
const PCS &pcs() const {return _pcs;}
|
const PCS &pcs() const {return _pcs;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString _name;
|
||||||
int _id, _proj;
|
int _id, _proj;
|
||||||
PCS _pcs;
|
PCS _pcs;
|
||||||
};
|
};
|
||||||
@ -21,8 +24,9 @@ QList<PCS::Entry> PCS::_pcss = defaults();
|
|||||||
QList<PCS::Entry> PCS::defaults()
|
QList<PCS::Entry> PCS::defaults()
|
||||||
{
|
{
|
||||||
QList<PCS::Entry> list;
|
QList<PCS::Entry> list;
|
||||||
list.append(PCS::Entry(3857, 3856, PCS(&GCS::WGS84(), 1024,
|
list.append(PCS::Entry("WGS 84 / Pseudo-Mercator", 3857, 3856,
|
||||||
Projection::Setup(0, 0, NAN, 0, 0, NAN, NAN), 9001, 4499)));
|
PCS(&GCS::WGS84(), 1024, Projection::Setup(0, 0, NAN, 0, 0, NAN, NAN),
|
||||||
|
9001, 4499)));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,27 +158,28 @@ void PCS::loadList(const QString &path)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = list[1].trimmed().toInt(&res);
|
QString name(list.at(0).trimmed());
|
||||||
|
int id = list.at(1).trimmed().toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid PCS code", qPrintable(path), ln);
|
qWarning("%s:%d: Invalid PCS code", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int gcsid = list[2].trimmed().toInt(&res);
|
int gcsid = list.at(2).trimmed().toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid GCS code", qPrintable(path), ln);
|
qWarning("%s:%d: Invalid GCS code", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int proj = list[3].trimmed().toInt(&res);
|
int proj = list.at(3).trimmed().toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid projection code", qPrintable(path), ln);
|
qWarning("%s:%d: Invalid projection code", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int units = list[4].trimmed().toInt(&res);
|
int units = list.at(4).trimmed().toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid linear units code", qPrintable(path), ln);
|
qWarning("%s:%d: Invalid linear units code", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int transform = list[5].trimmed().toInt(&res);
|
int transform = list.at(5).trimmed().toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid coordinate transformation code",
|
qWarning("%s:%d: Invalid coordinate transformation code",
|
||||||
qPrintable(path), ln);
|
qPrintable(path), ln);
|
||||||
@ -214,10 +219,20 @@ void PCS::loadList(const QString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PCS pcs(gcs, transform, setup, units, cs);
|
PCS pcs(gcs, transform, setup, units, cs);
|
||||||
_pcss.append(Entry(id, proj, pcs));
|
_pcss.append(Entry(name, id, proj, pcs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<PCS::Info> PCS::pcsList()
|
||||||
|
{
|
||||||
|
QList<Info> list;
|
||||||
|
|
||||||
|
for (int i = 0; i < _pcss.size(); i++)
|
||||||
|
list.append(Info(_pcss.at(i).id(), _pcss.at(i).name()));
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
QDebug operator<<(QDebug dbg, const PCS &pcs)
|
QDebug operator<<(QDebug dbg, const PCS &pcs)
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,20 @@
|
|||||||
class PCS
|
class PCS
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
class Info {
|
||||||
|
public:
|
||||||
|
Info(int id, const QString &name) : _id(id), _name(name) {}
|
||||||
|
|
||||||
|
int id() const {return _id;}
|
||||||
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
|
bool operator<(const Info &other) const {return _id < other._id;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _id;
|
||||||
|
QString _name;
|
||||||
|
};
|
||||||
|
|
||||||
PCS() : _gcs(0) {}
|
PCS() : _gcs(0) {}
|
||||||
PCS(const GCS *gcs, const Projection::Method &method,
|
PCS(const GCS *gcs, const Projection::Method &method,
|
||||||
const Projection::Setup &setup, const LinearUnits &units,
|
const Projection::Setup &setup, const LinearUnits &units,
|
||||||
@ -34,11 +48,12 @@ public:
|
|||||||
static void loadList(const QString &path);
|
static void loadList(const QString &path);
|
||||||
static const PCS *pcs(int id);
|
static const PCS *pcs(int id);
|
||||||
static const PCS *pcs(const GCS *gcs, int proj);
|
static const PCS *pcs(const GCS *gcs, int proj);
|
||||||
|
static QList<Info> pcsList();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Entry;
|
class Entry;
|
||||||
|
|
||||||
static QList<PCS::Entry> defaults();
|
static QList<Entry> defaults();
|
||||||
|
|
||||||
const GCS *_gcs;
|
const GCS *_gcs;
|
||||||
Projection::Method _method;
|
Projection::Method _method;
|
||||||
|
Loading…
Reference in New Issue
Block a user