diff --git a/demo/viewer/forms/layer_info.ui b/demo/viewer/forms/layer_info.ui
new file mode 100644
index 000000000..ea9aaf740
--- /dev/null
+++ b/demo/viewer/forms/layer_info.ui
@@ -0,0 +1,101 @@
+
+ Artem Pavlenko
+ LayerInfoDialog
+
+
+
+ 0
+ 0
+
+
+
+ Layer Info
+
+
+ false
+
+
+ -
+
+
-
+
+
-
+
+
+ Name:
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ Styles:
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ LayerInfoDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ LayerInfoDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/demo/viewer/layer_info_dialog.cpp b/demo/viewer/layer_info_dialog.cpp
new file mode 100644
index 000000000..082bad24d
--- /dev/null
+++ b/demo/viewer/layer_info_dialog.cpp
@@ -0,0 +1,45 @@
+/* This file is part of Mapnik (c++ mapping toolkit)
+ * Copyright (C) 2007 Artem Pavlenko
+ *
+ * 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
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+//$Id$
+
+#include "layer_info_dialog.hpp"
+
+layer_info_dialog::layer_info_dialog(QVector > const& info, QWidget *parent)
+ : QDialog(parent)
+{
+ ui.setupUi(this);
+ //ui.tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Name"));
+ //ui.tableWidget->setHorizontalHeaderItem(1,new QTableWidgetItem("Value"));
+
+ ui.tableWidget->setRowCount(info.size());
+ ui.tableWidget->setColumnCount(2);
+ for (int i=0;isetItem(i,0,keyItem);
+ ui.tableWidget->setItem(i,1,valueItem);
+ }
+}
+
+Ui::LayerInfoDialog& layer_info_dialog::getUI()
+{
+ return ui;
+}
+
diff --git a/demo/viewer/layer_info_dialog.hpp b/demo/viewer/layer_info_dialog.hpp
new file mode 100644
index 000000000..ab9175e76
--- /dev/null
+++ b/demo/viewer/layer_info_dialog.hpp
@@ -0,0 +1,39 @@
+/* This file is part of Mapnik (c++ mapping toolkit)
+ * Copyright (C) 2007 Artem Pavlenko
+ *
+ * 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
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+//$Id$
+
+
+#ifndef LAYER_INFO_DIALOG_HPP
+#define LAYER_INFO_DIALOG_HPP
+
+#include "ui_layer_info.h"
+#include
+
+class layer_info_dialog : public QDialog
+{
+ Q_OBJECT
+ public:
+ layer_info_dialog(QVector > const& params,QWidget * parent = 0);
+ Ui::LayerInfoDialog& getUI();
+ private:
+ Ui::LayerInfoDialog ui;
+};
+
+
+#endif //LAYER_INFO_DIALOG_HPP
diff --git a/demo/viewer/layerlistmodel.cpp b/demo/viewer/layerlistmodel.cpp
index b021652b8..70559a26a 100644
--- a/demo/viewer/layerlistmodel.cpp
+++ b/demo/viewer/layerlistmodel.cpp
@@ -107,6 +107,17 @@ Qt::ItemFlags LayerListModel::flags(QModelIndex const& index) const
return flags;
}
+boost::optional LayerListModel::map_layer(int i)
+{
+ if (map_)
+ {
+ std::vector & layers = const_cast& >(map_->layers());
+ if (i < layers.size())
+ return boost::optional(layers[i]);
+ }
+ return boost::optional();
+}
+
diff --git a/demo/viewer/layerlistmodel.hpp b/demo/viewer/layerlistmodel.hpp
index 8a66f19bc..6a6644859 100644
--- a/demo/viewer/layerlistmodel.hpp
+++ b/demo/viewer/layerlistmodel.hpp
@@ -26,8 +26,7 @@
#include
#include
#include
-
-//using namespace mapnik;
+#include
class LayerListModel : public QAbstractListModel
{
@@ -41,6 +40,7 @@ class LayerListModel : public QAbstractListModel
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole);
Qt::ItemFlags flags(QModelIndex const& index) const;
+ boost::optional map_layer(int i);
private:
boost::shared_ptr map_;
diff --git a/demo/viewer/layerwidget.cpp b/demo/viewer/layerwidget.cpp
index 7f711d3ec..e4003f527 100644
--- a/demo/viewer/layerwidget.cpp
+++ b/demo/viewer/layerwidget.cpp
@@ -30,6 +30,8 @@
#include
#include
#include
+#include "layerlistmodel.hpp"
+#include "layer_info_dialog.hpp"
using namespace std;
@@ -50,6 +52,64 @@ void LayerTab::dataChanged(const QModelIndex &topLeft,
emit update_mapwidget();
}
+void LayerTab::layerInfo()
+{
+ qDebug("Layer info");
+ QModelIndexList indexes = selectedIndexes();
+ if (indexes.size() > 0)
+ {
+ qDebug("id = %d",indexes[0].row());
+
+ }
+}
+
+void LayerTab::layerInfo2(QModelIndex const& index)
+{
+ qDebug("LayerInfo id = %d",index.row());
+ QVector > params;
+ unsigned i = index.row();
+ LayerListModel * model = static_cast(this->model());
+ boost::optional layer = model->map_layer(i);
+
+ if (layer)
+ {
+ mapnik::datasource_ptr ds = (*layer).datasource();
+ if (ds)
+ {
+ mapnik::parameters ps = ds->params();
+
+ //mapnik::parameters::extract_iterator_type itr = ps.extract_begin();
+ //mapnik::parameters::extract_iterator_type end = ps.extract_end();
+
+ //for (;itr != end;++itr)
+ //{
+ //if (itr->second)
+ // {
+ /// params.push_back(QPair(itr->first.c_str(),itr->first.c_str()));
+ // }
+ //}
+
+
+ mapnik::parameters::const_iterator pos;
+
+ for (pos = ps.begin();pos != ps.end();++pos)
+ {
+ boost::optional result;
+ boost::apply_visitor(mapnik::value_extractor_visitor(result),pos->second);
+ if (result)
+ {
+ params.push_back(QPair(pos->first.c_str(),(*result).c_str()));
+ }
+ }
+ }
+ layer_info_dialog dlg(params,this);
+ dlg.getUI().layerNameEdit->setText(QString((*layer).name().c_str()));
+
+
+ dlg.exec();
+ }
+}
+
StyleTab::StyleTab(QWidget*)
{
diff --git a/demo/viewer/layerwidget.hpp b/demo/viewer/layerwidget.hpp
index afe407dac..766c314aa 100644
--- a/demo/viewer/layerwidget.hpp
+++ b/demo/viewer/layerwidget.hpp
@@ -32,7 +32,10 @@ class LayerTab : public QListView
LayerTab(QWidget* parent=0);
void paintEvent(QPaintEvent *e);
signals:
- void update_mapwidget();
+ void update_mapwidget();
+ public slots:
+ void layerInfo();
+ void layerInfo2(QModelIndex const&);
protected slots:
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
};
diff --git a/demo/viewer/mainwindow.cpp b/demo/viewer/mainwindow.cpp
index d43430e80..c64e18ddb 100644
--- a/demo/viewer/mainwindow.cpp
+++ b/demo/viewer/mainwindow.cpp
@@ -109,6 +109,7 @@ void MainWindow::createContextMenu()
{
layerTab_->setContextMenuPolicy(Qt::ActionsContextMenu);
layerTab_->addAction(openAct);
+ layerTab_->addAction(layerInfo);
}
void MainWindow::open(QString const& path)
@@ -299,6 +300,9 @@ void MainWindow::createActions()
reloadAct = new QAction(QIcon(":/images/reload.png"),tr("Reload"),this);
connect(reloadAct, SIGNAL(triggered()), this, SLOT(reload()));
+ layerInfo = new QAction(QIcon(":/images/info.png"),tr("&Layer info"),layerTab_);
+ connect(layerInfo, SIGNAL(triggered()), layerTab_,SLOT(layerInfo()));
+ connect(layerTab_, SIGNAL(doubleClicked(QModelIndex const&)), layerTab_,SLOT(layerInfo2(QModelIndex const&)));
foreach (QByteArray format, QImageWriter::supportedImageFormats())
{
QString text = tr("%1...").arg(QString(format).toUpper());
diff --git a/demo/viewer/mainwindow.hpp b/demo/viewer/mainwindow.hpp
index 078f35e4f..5b2df4ca4 100644
--- a/demo/viewer/mainwindow.hpp
+++ b/demo/viewer/mainwindow.hpp
@@ -97,6 +97,7 @@ public slots:
QAction *panUpAct;
QAction *panDownAct;
QAction *reloadAct;
+ QAction *layerInfo;
//toolbars
QToolBar *fileToolBar;
QToolBar *editToolBar;
diff --git a/demo/viewer/styles_model.cpp b/demo/viewer/styles_model.cpp
index b5c197d32..f39dc9e6a 100644
--- a/demo/viewer/styles_model.cpp
+++ b/demo/viewer/styles_model.cpp
@@ -23,6 +23,8 @@
#include
#include
#include
+#include
+#include
class node : private boost::noncopyable
{
@@ -110,6 +112,7 @@ class node : private boost::noncopyable
node * parent_;
};
+
struct symbolizer_info : public boost::static_visitor
{
QString operator() (mapnik::point_symbolizer const& sym) const
@@ -154,6 +157,37 @@ struct symbolizer_info : public boost::static_visitor
}
};
+struct symbolizer_icon : public boost::static_visitor
+{
+ QIcon operator() (mapnik::polygon_symbolizer const& sym) const
+ {
+ QPixmap pix(16,16);
+ QPainter painter(&pix);
+ mapnik::Color fill = sym.get_fill();
+ QBrush brush(QColor(fill.red(),fill.green(),fill.blue(),fill.alpha()));
+ painter.fillRect(0, 0, 16, 16, brush);
+ return QIcon(pix);
+ }
+
+ QIcon operator() (mapnik::point_symbolizer const& sym) const
+ {
+ boost::shared_ptr symbol = sym.get_data();
+ if (symbol)
+ {
+ QImage image(symbol->getBytes(),symbol->width(),symbol->height(),QImage::Format_ARGB32);
+ QPixmap pix = QPixmap::fromImage(image.rgbSwapped());
+ return QIcon(pix);
+ }
+ return QIcon();
+ }
+
+ template
+ QIcon operator() (T const& ) const
+ {
+ return QIcon (":/images/filter.png");
+ }
+};
+
class symbolizer_node
{
public:
@@ -169,7 +203,7 @@ class symbolizer_node
QIcon icon() const
{
- return QIcon(":/images/filter.png");
+ return boost::apply_visitor(symbolizer_icon(),sym_);//QIcon(":/images/filter.png");
}
mapnik::symbolizer const& sym_;
};
diff --git a/demo/viewer/viewer.pro b/demo/viewer/viewer.pro
index 170960589..635331bad 100644
--- a/demo/viewer/viewer.pro
+++ b/demo/viewer/viewer.pro
@@ -16,7 +16,9 @@ unix:LIBS = -L/usr/local/lib -lmapnik -lfreetype
# Input
CONFIG += qt debug_and_release
-FORMS += forms/about.ui forms/info.ui
+FORMS += forms/about.ui \
+ forms/info.ui \
+ forms/layer_info.ui
HEADERS += mainwindow.hpp \
mapwidget.hpp \
@@ -26,7 +28,8 @@ HEADERS += mainwindow.hpp \
styles_model.hpp
HEADERS += about_dialog.hpp \
- info_dialog.hpp
+ info_dialog.hpp \
+ layer_info_dialog.hpp
SOURCES += main.cpp \
mainwindow.cpp \
@@ -37,6 +40,7 @@ SOURCES += main.cpp \
styles_model.cpp
SOURCES += about_dialog.cpp \
- info_dialog.cpp
+ info_dialog.cpp \
+ layer_info_dialog.cpp
RESOURCES += mapnik_viewer.qrc