$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r68855 - trunk/libs/geometry/example/with_external_libs
From: barend.gehrels_at_[hidden]
Date: 2011-02-13 16:55:41
Author: barendgehrels
Date: 2011-02-13 16:55:40 EST (Sun, 13 Feb 2011)
New Revision: 68855
URL: http://svn.boost.org/trac/boost/changeset/68855
Log:
Added Qt World Mapper Example conform the WxWidget one (but yet missing highlighing)
Added:
   trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper.cpp   (contents, props changed)
   trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper.sln   (contents, props changed)
   trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper.vcproj   (contents, props changed)
   trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper_readme.txt   (contents, props changed)
Added: trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper.cpp	2011-02-13 16:55:40 EST (Sun, 13 Feb 2011)
@@ -0,0 +1,161 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// Qt World Mapper Example
+
+// Qt is a well-known and often used platform independent windows library
+
+// To build and run this example:
+// 1) download (from http://qt.nokia.com), configure and make QT
+// 2) if necessary, adapt Qt clause in include path (note there is a Qt property sheet)
+
+#include <sstream>
+#include <fstream>
+
+#include <QtGui>
+#include <QWidget>
+#include <QObject>
+#include <QPainter>
+
+#include <boost/foreach.hpp>
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/geometries/register/point.hpp>
+#include <boost/geometry/geometries/register/ring.hpp>
+
+#include <boost/geometry/multi/multi.hpp>
+#include <boost/geometry/extensions/algorithms/selected.hpp>
+#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
+
+
+#include "qt_mapper.hpp"
+
+
+// Adapt a QPointF such that it can be handled by Boost.Geometry
+BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(QPointF, double, cs::cartesian, x, y, setX, setY)
+
+// Adapt a QPolygonF as well.
+// A QPolygonF has no holes (interiors) so it is similar to a Boost.Geometry ring
+BOOST_GEOMETRY_REGISTER_RING(QPolygonF)
+
+
+typedef boost::geometry::model::d2::point_xy<double> point_2d;
+typedef boost::geometry::model::multi_polygon
+    <
+        boost::geometry::model::polygon<point_2d>
+    > country_type;
+
+
+class WorldMapper : public QWidget
+{
+ public:
+    WorldMapper(std::vector<country_type> const& countries, boost::geometry::model::box<point_2d> const& box, QWidget *parent = 0)
+        : m_countries(countries)
+        , m_box(box)
+    {
+        setPalette(QPalette(QColor(200, 250, 250)));
+        setAutoFillBackground(true);
+    }
+
+ protected:
+    void paintEvent(QPaintEvent *event)
+    {
+        map_transformer_type transformer(m_box, this->width(), this->height());
+
+        QPainter painter(this);
+        painter.setBrush(Qt::green);
+
+        BOOST_FOREACH(country_type const& country, m_countries)
+        {
+            typedef boost::range_value<country_type>::type polygon_type;
+            BOOST_FOREACH(polygon_type const& polygon, country)
+            {
+                typedef boost::geometry::ring_type<polygon_type>::type ring_type;
+                ring_type const& ring = boost::geometry::exterior_ring(polygon);
+
+                // This is the essention:
+                // Directly transform from a multi_polygon (ring-type) to a QPolygonF
+                QPolygonF qring;
+                boost::geometry::transform(ring, qring, transformer);
+
+                painter.drawPolygon(qring);
+            }
+        }
+    }
+
+ private:
+    typedef boost::geometry::strategy::transform::map_transformer
+        <
+            point_2d, QPointF,
+            true, true
+        > map_transformer_type;
+
+     std::vector<country_type> const& m_countries;
+     boost::geometry::model::box<point_2d> const& m_box;
+ };
+
+
+class MapperWidget : public QWidget
+{
+ public:
+     MapperWidget(std::vector<country_type> const& countries, boost::geometry::model::box<point_2d> const& box, QWidget *parent = 0)
+         : QWidget(parent)
+     {
+         WorldMapper* mapper = new WorldMapper(countries, box);
+
+         QPushButton *quit = new QPushButton(tr("Quit"));
+         quit->setFont(QFont("Times", 18, QFont::Bold));
+         connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
+
+         QVBoxLayout *layout = new QVBoxLayout;
+         layout->addWidget(mapper);
+         layout->addWidget(quit);
+         setLayout(layout);
+     }
+
+};
+
+
+// ----------------------------------------------------------------------------
+// Read an ASCII file containing WKT's
+// ----------------------------------------------------------------------------
+template <typename Geometry, typename Box>
+inline void read_wkt(std::string const& filename, std::vector<Geometry>& geometries, Box& box)
+{
+    std::ifstream cpp_file(filename.c_str());
+    if (cpp_file.is_open())
+    {
+        while (! cpp_file.eof() )
+        {
+            std::string line;
+            std::getline(cpp_file, line);
+            if (! line.empty())
+            {
+                Geometry geometry;
+                boost::geometry::read_wkt(line, geometry);
+                geometries.push_back(geometry);
+                boost::geometry::combine(box, boost::geometry::make_envelope<Box>(geometry));
+            }
+        }
+    }
+}
+
+
+int main(int argc, char *argv[])
+{
+    std::vector<country_type> countries;
+    boost::geometry::model::box<point_2d> box;
+    boost::geometry::assign_inverse(box);
+    read_wkt("../data/world.wkt", countries, box);
+
+    QApplication app(argc, argv);
+    MapperWidget widget(countries, box);
+    widget.setWindowTitle("Boost.Geometry for Qt - Hello World!");
+    widget.setGeometry(50, 50, 800, 500);
+    widget.show();
+    return app.exec();
+}
Added: trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper.sln
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper.sln	2011-02-13 16:55:40 EST (Sun, 13 Feb 2011)
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x06_qt_world_mapper", "x06_qt_world_mapper.vcproj", "{242C6ADC-3A10-4B69-81F7-5669E0582A8B}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Debug|Win32.ActiveCfg = Debug|Win32
+		{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Debug|Win32.Build.0 = Debug|Win32
+		{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Release|Win32.ActiveCfg = Release|Win32
+		{242C6ADC-3A10-4B69-81F7-5669E0582A8B}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Added: trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper.vcproj	2011-02-13 16:55:40 EST (Sun, 13 Feb 2011)
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="x06_qt_world_mapper"
+	ProjectGUID="{242C6ADC-3A10-4B69-81F7-5669E0582A8B}"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)\x06_qt_world_mapper"
+			ConfigurationType="1"
+			InheritedPropertySheets="..\boost.vsprops;.\qt.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="../../../.."
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				DebugInformationFormat="1"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalLibraryDirectories=""
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)\x06_qt_world_mapper"
+			ConfigurationType="1"
+			InheritedPropertySheets="..\boost.vsprops;.\qt.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="../../../.."
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalLibraryDirectories=""
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\x06_qt_world_mapper.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\x06_qt_world_mapper_readme.txt"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Added: trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper_readme.txt
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/example/with_external_libs/x06_qt_world_mapper_readme.txt	2011-02-13 16:55:40 EST (Sun, 13 Feb 2011)
@@ -0,0 +1,28 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2011, Geodan, Amsterdam, the Netherlands
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+
+Qt World Mapper example
+
+It will show a basic Qt Widget, displaying world countries
+
+
+To compile this program:
+
+Install Qt (if not done before)
+Install Boost (if not done before)
+
+Using MSVC: 
+   - edit the file qt.vsprops 
+   - set the UserMacro QT to point to your Qt distribution
+   - edit the file boost.vsprops
+   - set the UserMacro BOOST_ROOT to point to your Boost distribution
+   - alternatively you can include Boost and/or Qt in your standard include path
+   
+Using Linux/gcc
+