+ avoid rendering map twice when bbox is specified
This commit is contained in:
parent
dc85719853
commit
1d0ccd689b
3 changed files with 78 additions and 75 deletions
|
@ -75,6 +75,9 @@ int main( int argc, char **argv )
|
|||
if (ok) window.set_default_extent(x0,y0,x1,y1);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
window.zoom_all();
|
||||
}
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -132,7 +132,6 @@ void MainWindow::open(QString const& path)
|
|||
if (!filename_.isEmpty())
|
||||
{
|
||||
load_map_file(filename_);
|
||||
//zoom_all();
|
||||
setWindowTitle(tr("%1 - Mapnik Viewer").arg(filename_));
|
||||
}
|
||||
|
||||
|
@ -179,18 +178,10 @@ void MainWindow::load_map_file(QString const& filename)
|
|||
{
|
||||
std::cout << ex.what() << "\n";
|
||||
}
|
||||
//map->zoom_all();
|
||||
//mapnik::box2d<double> const& ext = map->getCurrentExtent();
|
||||
//mapWidget_->zoomToBox(ext);
|
||||
layerTab_->setModel(new LayerListModel(map,this));
|
||||
styleTab_->setModel(new StyleModel(map,this));
|
||||
}
|
||||
|
||||
void MainWindow::zoom_all()
|
||||
{
|
||||
mapWidget_->defaultView();
|
||||
}
|
||||
|
||||
void MainWindow::zoom_to_box()
|
||||
{
|
||||
mapWidget_->setTool(MapWidget::ZoomToBox);
|
||||
|
@ -394,6 +385,15 @@ void MainWindow::set_default_extent(double x0,double y0, double x1, double y1)
|
|||
}
|
||||
}
|
||||
catch (...) {}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::zoom_all()
|
||||
{
|
||||
boost::shared_ptr<mapnik::Map> map_ptr = mapWidget_->getMap();
|
||||
if (map_ptr)
|
||||
{
|
||||
map_ptr->zoom_all();
|
||||
mapnik::box2d<double> const& ext = map_ptr->getCurrentExtent();
|
||||
mapWidget_->zoomToBox(ext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,74 +38,74 @@ class QSlider;
|
|||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow();
|
||||
virtual ~MainWindow();
|
||||
void set_default_extent(double x0,double y0,double x1, double y1);
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow();
|
||||
virtual ~MainWindow();
|
||||
void set_default_extent(double x0,double y0,double x1, double y1);
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
public slots:
|
||||
void zoom_all();
|
||||
void zoom_to_box();
|
||||
void pan();
|
||||
void info();
|
||||
void export_as();
|
||||
void open(QString const& path = QString());
|
||||
void reload();
|
||||
void save();
|
||||
void print();
|
||||
void about();
|
||||
void pan_left();
|
||||
void pan_right();
|
||||
void pan_up();
|
||||
void pan_down();
|
||||
private:
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createToolBars();
|
||||
void createContextMenu();
|
||||
void load_map_file(QString const& filename);
|
||||
void zoom_all();
|
||||
void zoom_to_box();
|
||||
void pan();
|
||||
void info();
|
||||
void export_as();
|
||||
void open(QString const& path = QString());
|
||||
void reload();
|
||||
void save();
|
||||
void print();
|
||||
void about();
|
||||
void pan_left();
|
||||
void pan_right();
|
||||
void pan_up();
|
||||
void pan_down();
|
||||
private:
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createToolBars();
|
||||
void createContextMenu();
|
||||
void load_map_file(QString const& filename);
|
||||
|
||||
|
||||
QString currentPath;
|
||||
QString filename_;
|
||||
QAbstractItemModel *model;
|
||||
LayerTab *layerTab_;
|
||||
StyleTab * styleTab_;
|
||||
MapWidget * mapWidget_;
|
||||
QPrinter printer;
|
||||
//actions
|
||||
QList<QAction *> exportAsActs;
|
||||
QActionGroup *toolsGroup;
|
||||
QString currentPath;
|
||||
QString filename_;
|
||||
QAbstractItemModel *model;
|
||||
LayerTab *layerTab_;
|
||||
StyleTab * styleTab_;
|
||||
MapWidget * mapWidget_;
|
||||
QPrinter printer;
|
||||
//actions
|
||||
QList<QAction *> exportAsActs;
|
||||
QActionGroup *toolsGroup;
|
||||
|
||||
QAction *zoomAllAct;
|
||||
QAction *zoomBoxAct;
|
||||
QAction *panAct;
|
||||
QAction *infoAct;
|
||||
QAction *openAct;
|
||||
QAction *saveAct;
|
||||
QAction *printAct;
|
||||
QAction *exitAct;
|
||||
QAction *aboutAct;
|
||||
QAction *panLeftAct;
|
||||
QAction *panRightAct;
|
||||
QAction *panUpAct;
|
||||
QAction *panDownAct;
|
||||
QAction *reloadAct;
|
||||
QAction *layerInfo;
|
||||
//toolbars
|
||||
QToolBar *fileToolBar;
|
||||
QToolBar *editToolBar;
|
||||
//menus
|
||||
QMenu *exportMenu;
|
||||
QMenu *fileMenu;
|
||||
QMenu *helpMenu;
|
||||
//status bar
|
||||
QStatusBar *status;
|
||||
QSlider * slider_;
|
||||
QAction *zoomAllAct;
|
||||
QAction *zoomBoxAct;
|
||||
QAction *panAct;
|
||||
QAction *infoAct;
|
||||
QAction *openAct;
|
||||
QAction *saveAct;
|
||||
QAction *printAct;
|
||||
QAction *exitAct;
|
||||
QAction *aboutAct;
|
||||
QAction *panLeftAct;
|
||||
QAction *panRightAct;
|
||||
QAction *panUpAct;
|
||||
QAction *panDownAct;
|
||||
QAction *reloadAct;
|
||||
QAction *layerInfo;
|
||||
//toolbars
|
||||
QToolBar *fileToolBar;
|
||||
QToolBar *editToolBar;
|
||||
//menus
|
||||
QMenu *exportMenu;
|
||||
QMenu *fileMenu;
|
||||
QMenu *helpMenu;
|
||||
//status bar
|
||||
QStatusBar *status;
|
||||
QSlider * slider_;
|
||||
|
||||
mapnik::box2d<double> default_extent_;
|
||||
mapnik::box2d<double> default_extent_;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue