Merge branch 'master' of github.com:mapnik/mapnik
This commit is contained in:
commit
5a968959b5
4 changed files with 46 additions and 25 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
|
|
||||||
|
@ -97,12 +98,15 @@ MainWindow::MainWindow()
|
||||||
//connect mapview to layerlist
|
//connect mapview to layerlist
|
||||||
connect(mapWidget_, SIGNAL(mapViewChanged()),layerTab_, SLOT(update()));
|
connect(mapWidget_, SIGNAL(mapViewChanged()),layerTab_, SLOT(update()));
|
||||||
// slider
|
// slider
|
||||||
connect(slider_,SIGNAL(valueChanged(int)),mapWidget_,SLOT(zoomToLevel(int)));
|
connect(slider_,SIGNAL(valueChanged(int)),mapWidget_,SLOT(zoomToLevel(int)));
|
||||||
// renderer selector
|
// renderer selector
|
||||||
connect(renderer_selector_,SIGNAL(currentIndexChanged(QString const&)),
|
connect(renderer_selector_,SIGNAL(currentIndexChanged(QString const&)),
|
||||||
mapWidget_, SLOT(updateRenderer(QString const&)));
|
mapWidget_, SLOT(updateRenderer(QString const&)));
|
||||||
|
|
||||||
//
|
// scale factor
|
||||||
|
connect(scale_factor_,SIGNAL(valueChanged(double)),
|
||||||
|
mapWidget_, SLOT(updateScaleFactor(double)));
|
||||||
|
//
|
||||||
connect(layerTab_,SIGNAL(update_mapwidget()),mapWidget_,SLOT(updateMap()));
|
connect(layerTab_,SIGNAL(update_mapwidget()),mapWidget_,SLOT(updateMap()));
|
||||||
connect(layerTab_,SIGNAL(layerSelected(int)),
|
connect(layerTab_,SIGNAL(layerSelected(int)),
|
||||||
mapWidget_,SLOT(layerSelected(int)));
|
mapWidget_,SLOT(layerSelected(int)));
|
||||||
|
@ -373,16 +377,23 @@ void MainWindow::createToolBars()
|
||||||
fileToolBar->addAction(infoAct);
|
fileToolBar->addAction(infoAct);
|
||||||
fileToolBar->addAction(reloadAct);
|
fileToolBar->addAction(reloadAct);
|
||||||
fileToolBar->addAction(printAct);
|
fileToolBar->addAction(printAct);
|
||||||
|
|
||||||
renderer_selector_ = new QComboBox(fileToolBar);
|
renderer_selector_ = new QComboBox(fileToolBar);
|
||||||
renderer_selector_->setFocusPolicy(Qt::NoFocus);
|
renderer_selector_->setFocusPolicy(Qt::NoFocus);
|
||||||
renderer_selector_->addItem("AGG");
|
renderer_selector_->addItem("AGG");
|
||||||
#ifdef HAVE_CAIRO
|
#ifdef HAVE_CAIRO
|
||||||
renderer_selector_->addItem("Cairo");
|
renderer_selector_->addItem("Cairo");
|
||||||
#endif
|
#endif
|
||||||
renderer_selector_->addItem("Grid");
|
renderer_selector_->addItem("Grid");
|
||||||
fileToolBar->addWidget(renderer_selector_);
|
fileToolBar->addWidget(renderer_selector_);
|
||||||
|
|
||||||
|
scale_factor_ = new QDoubleSpinBox(fileToolBar);
|
||||||
|
scale_factor_->setMinimum(0.1);
|
||||||
|
scale_factor_->setMaximum(5.0);
|
||||||
|
scale_factor_->setSingleStep(0.1);
|
||||||
|
scale_factor_->setValue(1.0);
|
||||||
|
|
||||||
|
fileToolBar->addWidget(scale_factor_);
|
||||||
slider_ = new QSlider(Qt::Horizontal,fileToolBar);
|
slider_ = new QSlider(Qt::Horizontal,fileToolBar);
|
||||||
slider_->setRange(1,18);
|
slider_->setRange(1,18);
|
||||||
slider_->setTickPosition(QSlider::TicksBelow);
|
slider_->setTickPosition(QSlider::TicksBelow);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
|
|
||||||
#include "mapwidget.hpp"
|
#include "mapwidget.hpp"
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ class LayerTab;
|
||||||
class StyleTab;
|
class StyleTab;
|
||||||
class QSlider;
|
class QSlider;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
class QDoubleSpinBox;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -108,6 +110,7 @@ private:
|
||||||
QStatusBar *status;
|
QStatusBar *status;
|
||||||
QSlider * slider_;
|
QSlider * slider_;
|
||||||
QComboBox * renderer_selector_;
|
QComboBox * renderer_selector_;
|
||||||
|
QDoubleSpinBox * scale_factor_;
|
||||||
mapnik::box2d<double> default_extent_;
|
mapnik::box2d<double> default_extent_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -184,16 +184,16 @@ void MapWidget::mousePressEvent(QMouseEvent* e)
|
||||||
feature_ptr feat = fs->next();
|
feature_ptr feat = fs->next();
|
||||||
if (feat)
|
if (feat)
|
||||||
{
|
{
|
||||||
|
|
||||||
feature_kv_iterator itr(*feat,true);
|
feature_kv_iterator itr(*feat,true);
|
||||||
feature_kv_iterator end(*feat);
|
feature_kv_iterator end(*feat);
|
||||||
|
|
||||||
for ( ;itr!=end; ++itr)
|
for ( ;itr!=end; ++itr)
|
||||||
{
|
{
|
||||||
info.push_back(QPair<QString,QString>(QString(boost::get<0>(*itr).c_str()),
|
info.push_back(QPair<QString,QString>(QString(boost::get<0>(*itr).c_str()),
|
||||||
boost::get<1>(*itr).to_string().c_str()));
|
boost::get<1>(*itr).to_string().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef mapnik::coord_transform<mapnik::CoordTransform,mapnik::geometry_type> path_type;
|
typedef mapnik::coord_transform<mapnik::CoordTransform,mapnik::geometry_type> path_type;
|
||||||
|
|
||||||
for (unsigned i=0; i<feat->num_geometries();++i)
|
for (unsigned i=0; i<feat->num_geometries();++i)
|
||||||
|
@ -498,12 +498,12 @@ void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
||||||
{
|
{
|
||||||
unsigned width=map.width();
|
unsigned width=map.width();
|
||||||
unsigned height=map.height();
|
unsigned height=map.height();
|
||||||
|
|
||||||
image_32 buf(width,height);
|
image_32 buf(width,height);
|
||||||
mapnik::agg_renderer<image_32> ren(map,buf,scaling_factor);
|
mapnik::agg_renderer<image_32> ren(map,buf,scaling_factor);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ren.apply();
|
ren.apply();
|
||||||
QImage image((uchar*)buf.raw_data(),width,height,QImage::Format_ARGB32);
|
QImage image((uchar*)buf.raw_data(),width,height,QImage::Format_ARGB32);
|
||||||
pix = QPixmap::fromImage(image.rgbSwapped());
|
pix = QPixmap::fromImage(image.rgbSwapped());
|
||||||
|
@ -527,23 +527,23 @@ void render_grid(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
||||||
{
|
{
|
||||||
unsigned width=map.width();
|
unsigned width=map.width();
|
||||||
unsigned height=map.height();
|
unsigned height=map.height();
|
||||||
|
|
||||||
mapnik::grid buf(width,height,"F_CODE", 1);
|
mapnik::grid buf(width,height,"F_CODE", 1);
|
||||||
mapnik::grid_renderer<mapnik::grid> ren(map,buf,scaling_factor);
|
mapnik::grid_renderer<mapnik::grid> ren(map,buf,scaling_factor);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ren.apply();
|
ren.apply();
|
||||||
int * imdata = static_cast<int*>(buf.raw_data());
|
int * imdata = static_cast<int*>(buf.raw_data());
|
||||||
|
|
||||||
QImage image(width,height,QImage::Format_RGB32);
|
QImage image(width,height,QImage::Format_RGB32);
|
||||||
for (unsigned i = 0 ; i < height ; ++i)
|
for (unsigned i = 0 ; i < height ; ++i)
|
||||||
{
|
{
|
||||||
for (unsigned j = 0 ; j < width ; ++j)
|
for (unsigned j = 0 ; j < width ; ++j)
|
||||||
{
|
{
|
||||||
image.setPixel(j,i,qRgb((uint8_t)(imdata[i*width+j]>>8),
|
image.setPixel(j,i,qRgb((uint8_t)(imdata[i*width+j]>>8),
|
||||||
(uint8_t)(imdata[i*width+j+1]>>8),
|
(uint8_t)(imdata[i*width+j+1]>>8),
|
||||||
(uint8_t)(imdata[i*width+j+2]>>8)));
|
(uint8_t)(imdata[i*width+j+2]>>8)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pix = QPixmap::fromImage(image);
|
pix = QPixmap::fromImage(image);
|
||||||
|
@ -567,12 +567,12 @@ void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef HAVE_CAIRO
|
#ifdef HAVE_CAIRO
|
||||||
Cairo::RefPtr<Cairo::ImageSurface> image_surface =
|
Cairo::RefPtr<Cairo::ImageSurface> image_surface =
|
||||||
Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, map.width(),map.height());
|
Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, map.width(),map.height());
|
||||||
|
|
||||||
mapnik::cairo_renderer<Cairo::Surface> png_render(map, image_surface, scaling_factor);
|
mapnik::cairo_renderer<Cairo::Surface> png_render(map, image_surface, scaling_factor);
|
||||||
png_render.apply();
|
png_render.apply();
|
||||||
|
|
||||||
image_32 buf(image_surface);
|
image_32 buf(image_surface);
|
||||||
QImage image((uchar*)buf.raw_data(),buf.width(),buf.height(),QImage::Format_ARGB32);
|
QImage image((uchar*)buf.raw_data(),buf.width(),buf.height(),QImage::Format_ARGB32);
|
||||||
pix = QPixmap::fromImage(image.rgbSwapped());
|
pix = QPixmap::fromImage(image.rgbSwapped());
|
||||||
|
@ -588,6 +588,12 @@ void MapWidget::updateRenderer(QString const& txt)
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapWidget::updateScaleFactor(double scale_factor)
|
||||||
|
{
|
||||||
|
set_scaling_factor(scale_factor);
|
||||||
|
updateMap();
|
||||||
|
}
|
||||||
|
|
||||||
void MapWidget::updateMap()
|
void MapWidget::updateMap()
|
||||||
{
|
{
|
||||||
if (map_)
|
if (map_)
|
||||||
|
@ -611,7 +617,7 @@ void MapWidget::updateMap()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
projection prj(map_->srs()); // map projection
|
projection prj(map_->srs()); // map projection
|
||||||
box2d<double> ext = map_->get_current_extent();
|
box2d<double> ext = map_->get_current_extent();
|
||||||
double x0 = ext.minx();
|
double x0 = ext.minx();
|
||||||
double y0 = ext.miny();
|
double y0 = ext.miny();
|
||||||
|
@ -623,7 +629,7 @@ void MapWidget::updateMap()
|
||||||
update();
|
update();
|
||||||
// emit signal to interested widgets
|
// emit signal to interested widgets
|
||||||
emit mapViewChanged();
|
emit mapViewChanged();
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cerr << "Unknown exception caught!\n";
|
std::cerr << "Unknown exception caught!\n";
|
||||||
|
|
|
@ -53,8 +53,8 @@ public:
|
||||||
AGG,
|
AGG,
|
||||||
Cairo,
|
Cairo,
|
||||||
Grid
|
Grid
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::shared_ptr<mapnik::Map> map_;
|
boost::shared_ptr<mapnik::Map> map_;
|
||||||
int selected_;
|
int selected_;
|
||||||
|
@ -91,6 +91,7 @@ public slots:
|
||||||
void updateMap();
|
void updateMap();
|
||||||
void layerSelected(int);
|
void layerSelected(int);
|
||||||
void updateRenderer(QString const& txt);
|
void updateRenderer(QString const& txt);
|
||||||
|
void updateScaleFactor(double scale_factor);
|
||||||
signals:
|
signals:
|
||||||
void mapViewChanged();
|
void mapViewChanged();
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in a new issue