+ add resolution to mapwidget
+ add resolution command option
This commit is contained in:
parent
e645338237
commit
3e2a82ed16
5 changed files with 76 additions and 58 deletions
|
@ -62,7 +62,7 @@ int main( int argc, char **argv )
|
|||
MainWindow window;
|
||||
window.show();
|
||||
if (argc > 1) window.open(argv[1]);
|
||||
if (argc == 3)
|
||||
if (argc >= 3)
|
||||
{
|
||||
QStringList list = QString(argv[2]).split(",");
|
||||
if (list.size()==4)
|
||||
|
@ -78,6 +78,12 @@ int main( int argc, char **argv )
|
|||
else
|
||||
{
|
||||
window.zoom_all();
|
||||
}
|
||||
}
|
||||
if (argc == 4)
|
||||
{
|
||||
bool ok;
|
||||
double scaling_factor = QString(argv[3]).toDouble(&ok);
|
||||
if (ok) window.set_scaling_factor(scaling_factor);
|
||||
}
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -387,6 +387,11 @@ void MainWindow::set_default_extent(double x0,double y0, double x1, double y1)
|
|||
catch (...) {}
|
||||
}
|
||||
|
||||
void MainWindow::set_scaling_factor(double scaling_factor)
|
||||
{
|
||||
mapWidget_->set_scaling_factor(scaling_factor);
|
||||
}
|
||||
|
||||
void MainWindow::zoom_all()
|
||||
{
|
||||
boost::shared_ptr<mapnik::Map> map_ptr = mapWidget_->getMap();
|
||||
|
|
|
@ -43,6 +43,7 @@ class MainWindow : public QMainWindow
|
|||
MainWindow();
|
||||
virtual ~MainWindow();
|
||||
void set_default_extent(double x0,double y0,double x1, double y1);
|
||||
void set_scaling_factor(double scaling_factor);
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
public slots:
|
||||
|
@ -104,7 +105,6 @@ private:
|
|||
//status bar
|
||||
QStatusBar *status;
|
||||
QSlider * slider_;
|
||||
|
||||
mapnik::box2d<double> default_extent_;
|
||||
};
|
||||
|
||||
|
|
|
@ -74,7 +74,8 @@ MapWidget::MapWidget(QWidget *parent)
|
|||
drag_(false),
|
||||
first_(true),
|
||||
pen_(QColor(0,0,255,96)),
|
||||
selectedLayer_(-1)
|
||||
selectedLayer_(-1),
|
||||
scaling_factor_(1.0)
|
||||
{
|
||||
pen_.setWidth(3);
|
||||
pen_.setCapStyle(Qt::RoundCap);
|
||||
|
@ -444,6 +445,10 @@ void MapWidget::export_to_file(unsigned ,unsigned ,std::string const&,std::strin
|
|||
//image.saveToFile(filename,type);
|
||||
}
|
||||
|
||||
void MapWidget::set_scaling_factor(double scaling_factor)
|
||||
{
|
||||
scaling_factor_ = scaling_factor;
|
||||
}
|
||||
|
||||
void MapWidget::updateMap()
|
||||
{
|
||||
|
@ -456,7 +461,7 @@ void MapWidget::updateMap()
|
|||
|
||||
try
|
||||
{
|
||||
mapnik::agg_renderer<image_32> ren(*map_,buf);
|
||||
mapnik::agg_renderer<image_32> ren(*map_,buf,scaling_factor_);
|
||||
ren.apply();
|
||||
|
||||
QImage image((uchar*)buf.raw_data(),width,height,QImage::Format_ARGB32);
|
||||
|
|
|
@ -34,61 +34,63 @@
|
|||
|
||||
class MapWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum eTool
|
||||
{
|
||||
ZoomToBox = 1,
|
||||
Pan,
|
||||
Info,
|
||||
};
|
||||
public:
|
||||
enum eTool
|
||||
{
|
||||
ZoomToBox = 1,
|
||||
Pan,
|
||||
Info,
|
||||
};
|
||||
|
||||
private:
|
||||
boost::shared_ptr<mapnik::Map> map_;
|
||||
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_;
|
||||
public:
|
||||
MapWidget(QWidget *parent=0);
|
||||
void setTool(eTool tool);
|
||||
boost::shared_ptr<mapnik::Map> getMap();
|
||||
inline QPixmap const& pixmap() const { return pix_;}
|
||||
void setMap(boost::shared_ptr<mapnik::Map> map);
|
||||
void defaultView();
|
||||
void zoomToBox(mapnik::box2d<double> const& box);
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void panLeft();
|
||||
void panRight();
|
||||
void panUp();
|
||||
void panDown();
|
||||
public slots:
|
||||
void zoomToLevel(int level);
|
||||
void updateMap();
|
||||
void layerSelected(int);
|
||||
signals:
|
||||
void mapViewChanged();
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* ev);
|
||||
void resizeEvent(QResizeEvent* ev);
|
||||
void mousePressEvent(QMouseEvent* e);
|
||||
void mouseMoveEvent(QMouseEvent* e);
|
||||
void mouseReleaseEvent(QMouseEvent* e);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void export_to_file(unsigned width,
|
||||
unsigned height,
|
||||
std::string const& filename,
|
||||
std::string const& type);
|
||||
private:
|
||||
boost::shared_ptr<mapnik::Map> map_;
|
||||
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_;
|
||||
public:
|
||||
MapWidget(QWidget *parent=0);
|
||||
void setTool(eTool tool);
|
||||
boost::shared_ptr<mapnik::Map> getMap();
|
||||
inline QPixmap const& pixmap() const { return pix_;}
|
||||
void setMap(boost::shared_ptr<mapnik::Map> map);
|
||||
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);
|
||||
signals:
|
||||
void mapViewChanged();
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* ev);
|
||||
void resizeEvent(QResizeEvent* ev);
|
||||
void mousePressEvent(QMouseEvent* e);
|
||||
void mouseMoveEvent(QMouseEvent* e);
|
||||
void mouseReleaseEvent(QMouseEvent* e);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void export_to_file(unsigned width,
|
||||
unsigned height,
|
||||
std::string const& filename,
|
||||
std::string const& type);
|
||||
};
|
||||
|
||||
#endif // MAP_WIDGET_HPP
|
||||
|
|
Loading…
Reference in a new issue