Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60450 - sandbox/geometry/libs/geometry/example
From: barend.gehrels_at_[hidden]
Date: 2010-03-10 16:40:10


Author: barendgehrels
Date: 2010-03-10 16:40:09 EST (Wed, 10 Mar 2010)
New Revision: 60450
URL: http://svn.boost.org/trac/boost/changeset/60450

Log:
Added wxWidgets example
Renamed soci_examples.sln solution file
Added:
   sandbox/geometry/libs/geometry/example/x03_soci_examples.sln
      - copied unchanged from r60443, /sandbox/geometry/libs/geometry/example/soci_examples.sln
   sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.cpp (contents, props changed)
   sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.sln (contents, props changed)
   sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.vcproj (contents, props changed)
Removed:
   sandbox/geometry/libs/geometry/example/soci_examples.sln

Deleted: sandbox/geometry/libs/geometry/example/soci_examples.sln
==============================================================================
--- sandbox/geometry/libs/geometry/example/soci_examples.sln 2010-03-10 16:40:09 EST (Wed, 10 Mar 2010)
+++ (empty file)
@@ -1,37 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x03_a_soci_example", "x03_a_soci_example.vcproj", "{C3B3143D-F354-4036-9DA1-5975D8A4F166}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x03_b_soci_example", "x03_b_soci_example.vcproj", "{5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x03_c_soci_example", "x03_c_soci_example.vcproj", "{5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x03_d_soci_example", "x03_d_soci_example.vcproj", "{5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {C3B3143D-F354-4036-9DA1-5975D8A4F166}.Debug|Win32.ActiveCfg = Debug|Win32
- {C3B3143D-F354-4036-9DA1-5975D8A4F166}.Debug|Win32.Build.0 = Debug|Win32
- {C3B3143D-F354-4036-9DA1-5975D8A4F166}.Release|Win32.ActiveCfg = Release|Win32
- {C3B3143D-F354-4036-9DA1-5975D8A4F166}.Release|Win32.Build.0 = Release|Win32
- {5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}.Debug|Win32.ActiveCfg = Debug|Win32
- {5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}.Debug|Win32.Build.0 = Debug|Win32
- {5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}.Release|Win32.ActiveCfg = Release|Win32
- {5EFD08EE-10CB-4D3E-9907-4E9A7F3AB1C1}.Release|Win32.Build.0 = Release|Win32
- {5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}.Debug|Win32.ActiveCfg = Debug|Win32
- {5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}.Debug|Win32.Build.0 = Debug|Win32
- {5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}.Release|Win32.ActiveCfg = Release|Win32
- {5EFD08FE-10CB-4D3E-9907-4E9A2F3AB1C1}.Release|Win32.Build.0 = Release|Win32
- {5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}.Debug|Win32.ActiveCfg = Debug|Win32
- {5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}.Debug|Win32.Build.0 = Debug|Win32
- {5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}.Release|Win32.ActiveCfg = Release|Win32
- {5EFD08FE-10CB-4D3E-9917-4E9A2F3AB1C1}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal

Added: sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.cpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.cpp 2010-03-10 16:40:09 EST (Wed, 10 Mar 2010)
@@ -0,0 +1,225 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2010, 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)
+//
+// wxWidgets World Mapper example
+
+#include <fstream>
+
+#include <boost/foreach.hpp>
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/geometries/register/point.hpp>
+#include <boost/geometry/multi/multi.hpp>
+#include <boost/geometry/geometries/cartesian2d.hpp>
+#include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
+#include <boost/geometry/extensions/gis/io/wkt/read_wkt_multi.hpp>
+
+// wxWidgets, if these headers are NOT found, adapt include path (and lib path)
+#include "wx/wx.h"
+#include "wx/math.h"
+#include "wx/stockitem.h"
+
+
+// Adapt wxWidgets points to Boost.Geometry points such that they can be used
+// in e.g. transformations (see below)
+BOOST_GEOMETRY_REGISTER_POINT_2D(wxPoint, int, cs::cartesian, x, y)
+BOOST_GEOMETRY_REGISTER_POINT_2D(wxRealPoint, double, cs::cartesian, x, y)
+
+
+typedef boost::geometry::multi_polygon<boost::geometry::polygon_2d> multi_type;
+
+
+// ----------------------------------------------------------------------------
+// Read an ASCII file containing WKT's
+// ----------------------------------------------------------------------------
+template <typename Geometry, typename Box>
+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);
+ Geometry geometry;
+ 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));
+ }
+ }
+ }
+}
+
+
+
+// ----------------------------------------------------------------------------
+class HelloWorldApp: public wxApp
+{
+public:
+ bool OnInit();
+};
+
+
+// ----------------------------------------------------------------------------
+class HelloWorldFrame: public wxFrame
+{
+public:
+ HelloWorldFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size);
+
+ void OnCloseWindow(wxCloseEvent& );
+ void OnExit(wxCommandEvent& );
+
+ DECLARE_EVENT_TABLE()
+};
+
+
+// ----------------------------------------------------------------------------
+class HelloWorldCanvas: public wxWindow
+{
+public:
+ HelloWorldCanvas(wxFrame *frame);
+ void DrawCountries(wxDC& dc);
+
+private:
+ void OnPaint(wxPaintEvent& );
+
+ boost::geometry::box_2d box;
+ std::vector<multi_type> countries;
+
+
+DECLARE_EVENT_TABLE()
+};
+
+
+// ----------------------------------------------------------------------------
+bool HelloWorldApp::OnInit()
+{
+ // Create the main frame window
+ HelloWorldFrame *frame = new HelloWorldFrame(NULL, _T("Boost.Geometry for wxWidgets - Hello World!"), wxDefaultPosition, wxSize(640, 480));
+
+ wxMenu *file_menu = new wxMenu;
+ file_menu->Append(wxID_EXIT, wxGetStockLabel(wxID_EXIT));
+ wxMenuBar* menuBar = new wxMenuBar;
+ menuBar->Append(file_menu, _T("&File"));
+ frame->SetMenuBar(menuBar);
+
+ int width, height;
+ frame->GetClientSize(&width, &height);
+
+ (void) new HelloWorldCanvas(frame);
+
+ // Show the frame
+ frame->Show(true);
+
+ return true;
+}
+
+
+// ----------------------------------------------------------------------------
+HelloWorldFrame::HelloWorldFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size):
+ wxFrame(frame, wxID_ANY, title, pos, size, wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE )
+{
+}
+
+
+void HelloWorldFrame::OnExit(wxCommandEvent& )
+{
+ this->Destroy();
+}
+
+void HelloWorldFrame::OnCloseWindow(wxCloseEvent& )
+{
+ static bool destroyed = false;
+ if (! destroyed)
+ {
+ this->Destroy();
+ destroyed = true;
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+HelloWorldCanvas::HelloWorldCanvas(wxFrame *frame)
+ : wxWindow(frame, wxID_ANY)
+{
+ boost::geometry::assign_inverse(box);
+ read_wkt("data/world.wkt", countries, box);
+}
+
+
+void HelloWorldCanvas::OnPaint(wxPaintEvent& )
+{
+ wxPaintDC dc(this);
+ PrepareDC(dc);
+
+ static bool running = false;
+ if (! running)
+ {
+ running = true;
+ DrawCountries(dc);
+ running = false;
+ }
+}
+
+void HelloWorldCanvas::DrawCountries(wxDC& dc)
+{
+ dc.SetBackground(*wxLIGHT_GREY_BRUSH);
+ dc.Clear();
+
+ namespace bg = boost::geometry;
+
+ wxSize sz = GetClientSize();
+ boost::geometry::strategy::transform::map_transformer
+ <
+ bg::point_2d,
+ wxPoint, true, true
+ > matrix(box, sz.x, sz.y);
+
+ BOOST_FOREACH(multi_type const& country, countries)
+ {
+ BOOST_FOREACH(bg::polygon_2d const& poly, country)
+ {
+ bg::linear_ring<wxPoint> wx_ring;
+ // Use only outer, holes are (for the moment) ignored
+ bg::transform(poly.outer(), wx_ring, matrix);
+
+ // Todo: avoid converting (use pointer-compatible container)
+ wxPoint* points = new wxPoint[boost::size(wx_ring)];
+ int n = 0;
+ BOOST_FOREACH(wxPoint const& p, wx_ring)
+ {
+ points[n++] = p;
+ }
+ // end todo
+
+ dc.DrawPolygon(n, points);
+
+ delete[] points;
+ }
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+
+
+BEGIN_EVENT_TABLE(HelloWorldFrame, wxFrame)
+ EVT_CLOSE(HelloWorldFrame::OnCloseWindow)
+ EVT_MENU(wxID_EXIT, HelloWorldFrame::OnExit)
+END_EVENT_TABLE()
+
+
+BEGIN_EVENT_TABLE(HelloWorldCanvas, wxWindow)
+ EVT_PAINT(HelloWorldCanvas::OnPaint)
+END_EVENT_TABLE()
+
+
+IMPLEMENT_APP(HelloWorldApp)

Added: sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.sln
==============================================================================
--- (empty file)
+++ sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.sln 2010-03-10 16:40:09 EST (Wed, 10 Mar 2010)
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x04_wxwidgets_world_mapper", "x04_wxwidgets_world_mapper.vcproj", "{DD1D469B-29A8-4873-A596-9CCCB24F54FA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DD1D469B-29A8-4873-A596-9CCCB24F54FA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DD1D469B-29A8-4873-A596-9CCCB24F54FA}.Debug|Win32.Build.0 = Debug|Win32
+ {DD1D469B-29A8-4873-A596-9CCCB24F54FA}.Release|Win32.ActiveCfg = Release|Win32
+ {DD1D469B-29A8-4873-A596-9CCCB24F54FA}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal

Added: sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.vcproj
==============================================================================
--- (empty file)
+++ sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.vcproj 2010-03-10 16:40:09 EST (Wed, 10 Mar 2010)
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="x04_wxwidgets_world_mapper"
+ ProjectGUID="{DD1D469B-29A8-4873-A596-9CCCB24F54FA}"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)\x04_wxwidgets_world_mapper"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/EHsc "
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;c:\software\libraries\wxWidgets-2.8.10\lib\vc_lib\mswd&quot;;&quot;c:\software\libraries\wxWidgets-2.8.10\include&quot;;..\..\.."
+ PreprocessorDefinitions="WIN32;_DEBUG;__WXMSW__;__WXDEBUG__;_WINDOWS;NOPCH"
+ MinimalRebuild="true"
+ RuntimeLibrary="1"
+ RuntimeTypeInfo="true"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG,__WXMSW__,__WXDEBUG__,_WINDOWS,NOPCH"
+ Culture="1033"
+ AdditionalIncludeDirectories=".\..\..\lib\vc_lib\mswd;.\..\..\include;.;.\..\..\samples"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="wxmsw28d_core.lib wxbase28d.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexd.lib wxexpatd.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib odbc32.lib gdiplus.lib"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ AdditionalLibraryDirectories="c:\software\libraries\wxWidgets-2.8.10\lib\vc_lib"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)\x04_wxwidgets_world_mapper"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/EHsc "
+ Optimization="2"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="&quot;c:\software\libraries\wxWidgets-2.8.10\lib\vc_lib\mswd&quot;;&quot;c:\software\libraries\wxWidgets-2.8.10\include&quot;;..\..\.."
+ PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH"
+ StringPooling="true"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ RuntimeTypeInfo="true"
+ PrecompiledHeaderFile=""
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="__WXMSW__,_WINDOWS,NOPCH"
+ Culture="1033"
+ AdditionalIncludeDirectories=".\..\..\lib\vc_lib\msw;.\..\..\include;.;.\..\..\samples"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib odbc32.lib gdiplus.lib"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ AdditionalLibraryDirectories="c:\software\libraries\wxWidgets-2.8.10\lib\vc_lib"
+ ProgramDatabaseFile=""
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="x04_wxwidgets_world_mapper.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk