2007-08-07 17:09:41 +02:00
|
|
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
2011-10-23 16:09:12 +02:00
|
|
|
*
|
2021-01-05 12:59:41 +01:00
|
|
|
* Copyright (C) 2021 Artem Pavlenko
|
2007-08-07 17:09:41 +02:00
|
|
|
*
|
|
|
|
* Mapnik is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2016-01-26 10:54:42 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-08-07 17:09:41 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MAP_WIDGET_HPP
|
|
|
|
#define MAP_WIDGET_HPP
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QPen>
|
2007-10-05 13:27:00 +02:00
|
|
|
#include <QItemSelection>
|
2007-08-07 17:09:41 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
2013-09-20 15:13:23 +02:00
|
|
|
#include <memory>
|
2013-09-20 15:22:58 +02:00
|
|
|
|
2012-04-18 13:15:50 +02:00
|
|
|
|
|
|
|
#ifndef Q_MOC_RUN
|
2007-08-07 17:09:41 +02:00
|
|
|
#include <mapnik/map.hpp>
|
2012-04-18 13:15:50 +02:00
|
|
|
#endif
|
2007-08-07 17:09:41 +02:00
|
|
|
|
2011-10-23 16:09:12 +02:00
|
|
|
class MapWidget : public QWidget
|
2007-08-07 17:09:41 +02:00
|
|
|
{
|
2010-06-17 10:26:08 +02:00
|
|
|
Q_OBJECT
|
2011-10-23 16:09:12 +02:00
|
|
|
|
2012-05-03 16:21:17 +02:00
|
|
|
public:
|
2011-10-23 16:09:12 +02:00
|
|
|
enum eTool
|
2010-06-17 10:26:08 +02:00
|
|
|
{
|
|
|
|
ZoomToBox = 1,
|
|
|
|
Pan,
|
|
|
|
Info,
|
|
|
|
};
|
2011-10-23 16:09:12 +02:00
|
|
|
|
2012-05-03 16:21:17 +02:00
|
|
|
enum eRenderer
|
|
|
|
{
|
|
|
|
AGG,
|
|
|
|
Cairo,
|
|
|
|
Grid
|
2012-07-10 17:58:43 +02:00
|
|
|
};
|
|
|
|
|
2011-10-23 16:09:12 +02:00
|
|
|
private:
|
2013-09-20 15:00:11 +02:00
|
|
|
std::shared_ptr<mapnik::Map> map_;
|
2010-06-17 10:26:08 +02:00
|
|
|
int selected_;
|
|
|
|
QPixmap pix_;
|
|
|
|
mapnik::box2d<double> extent_;
|
|
|
|
eTool cur_tool_;
|
|
|
|
int start_x_;
|
|
|
|
int start_y_;
|
|
|
|
int end_x_;
|
|
|
|
int end_y_;
|
|
|
|
bool drag_;
|
|
|
|
bool first_;
|
|
|
|
QPen pen_;
|
|
|
|
int selectedLayer_;
|
|
|
|
double scaling_factor_;
|
2012-05-03 16:21:17 +02:00
|
|
|
eRenderer cur_renderer_;
|
2010-06-17 10:26:08 +02:00
|
|
|
public:
|
|
|
|
MapWidget(QWidget *parent=0);
|
|
|
|
void setTool(eTool tool);
|
2013-09-20 15:00:11 +02:00
|
|
|
std::shared_ptr<mapnik::Map> getMap();
|
2010-06-17 10:26:08 +02:00
|
|
|
inline QPixmap const& pixmap() const { return pix_;}
|
2013-09-20 15:00:11 +02:00
|
|
|
void setMap(std::shared_ptr<mapnik::Map> map);
|
2010-06-17 10:26:08 +02:00
|
|
|
void defaultView();
|
|
|
|
void zoomToBox(mapnik::box2d<double> const& box);
|
|
|
|
void zoomIn();
|
|
|
|
void zoomOut();
|
|
|
|
void panLeft();
|
|
|
|
void panRight();
|
|
|
|
void panUp();
|
|
|
|
void panDown();
|
|
|
|
void set_scaling_factor(double);
|
|
|
|
public slots:
|
|
|
|
void zoomToLevel(int level);
|
|
|
|
void updateMap();
|
|
|
|
void layerSelected(int);
|
2012-05-03 16:21:17 +02:00
|
|
|
void updateRenderer(QString const& txt);
|
2012-07-10 17:58:43 +02:00
|
|
|
void updateScaleFactor(double scale_factor);
|
2010-06-17 10:26:08 +02:00
|
|
|
signals:
|
|
|
|
void mapViewChanged();
|
2011-10-23 16:09:12 +02:00
|
|
|
protected:
|
2010-06-17 10:26:08 +02:00
|
|
|
void paintEvent(QPaintEvent* ev);
|
|
|
|
void resizeEvent(QResizeEvent* ev);
|
|
|
|
void mousePressEvent(QMouseEvent* e);
|
|
|
|
void mouseMoveEvent(QMouseEvent* e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* e);
|
2012-06-01 01:16:19 +02:00
|
|
|
void wheelEvent(QWheelEvent* e);
|
2010-06-17 10:26:08 +02:00
|
|
|
void keyPressEvent(QKeyEvent *e);
|
|
|
|
void export_to_file(unsigned width,
|
|
|
|
unsigned height,
|
2011-10-23 16:09:12 +02:00
|
|
|
std::string const& filename,
|
|
|
|
std::string const& type);
|
2007-08-07 17:09:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAP_WIDGET_HPP
|