Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61587 - sandbox/geometry/libs/geometry/example
From: barend.gehrels_at_[hidden]
Date: 2010-04-26 16:51:14


Author: barendgehrels
Date: 2010-04-26 16:51:13 EDT (Mon, 26 Apr 2010)
New Revision: 61587
URL: http://svn.boost.org/trac/boost/changeset/61587

Log:
Updated wxWidgets project with pointer to wxPoint* and back_insert_iterator
Fixed Qt example vcproj, adding stylestheet

Added:
   sandbox/geometry/libs/geometry/example/qt.vsprops (contents, props changed)
Text files modified:
   sandbox/geometry/libs/geometry/example/x01_qt_example.sln | 4 +-
   sandbox/geometry/libs/geometry/example/x01_qt_example.vcproj | 38 ++++++++----------
   sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.cpp | 78 ++++++++++++++++++++++++++++++++-------
   3 files changed, 83 insertions(+), 37 deletions(-)

Added: sandbox/geometry/libs/geometry/example/qt.vsprops
==============================================================================
--- (empty file)
+++ sandbox/geometry/libs/geometry/example/qt.vsprops 2010-04-26 16:51:13 EDT (Mon, 26 Apr 2010)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="wxwidgets"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="$(QT)\include;$(QT)\include\QtGui"
+ PreprocessorDefinitions="QT_NO_DEBUG;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalLibraryDirectories="$(QT)\lib"
+ />
+ <UserMacro
+ Name="QT"
+ Value="c:\software\libraries\Qt\4.6.2"
+ />
+</VisualStudioPropertySheet>

Modified: sandbox/geometry/libs/geometry/example/x01_qt_example.sln
==============================================================================
--- sandbox/geometry/libs/geometry/example/x01_qt_example.sln (original)
+++ sandbox/geometry/libs/geometry/example/x01_qt_example.sln 2010-04-26 16:51:13 EDT (Mon, 26 Apr 2010)
@@ -1,5 +1,5 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C++ Express 2005
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x01_qt_example", "x01_qt_example.vcproj", "{242C6ADC-3A10-4B69-81F7-5669E0582A8B}"
 EndProject
 Global

Modified: sandbox/geometry/libs/geometry/example/x01_qt_example.vcproj
==============================================================================
--- sandbox/geometry/libs/geometry/example/x01_qt_example.vcproj (original)
+++ sandbox/geometry/libs/geometry/example/x01_qt_example.vcproj 2010-04-26 16:51:13 EDT (Mon, 26 Apr 2010)
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
         ProjectType="Visual C++"
- Version="8.00"
+ Version="9.00"
         Name="x01_qt_example"
         ProjectGUID="{242C6ADC-3A10-4B69-81F7-5669E0582A8B}"
         Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
>
         <Platforms>
                 <Platform
@@ -19,7 +20,7 @@
                         OutputDirectory="$(SolutionDir)$(ConfigurationName)"
                         IntermediateDirectory="$(ConfigurationName)\x01_qt_example"
                         ConfigurationType="1"
- InheritedPropertySheets=".\boost.vsprops"
+ InheritedPropertySheets=".\boost.vsprops;.\qt.vsprops"
                         CharacterSet="1"
>
                         <Tool
@@ -40,11 +41,10 @@
                         <Tool
                                 Name="VCCLCompilerTool"
                                 Optimization="0"
- AdditionalIncludeDirectories="c:\Qt\2009.03\qt\include;c:\Qt\2009.03\qt\include\QtGui"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;QT_NO_DEBUG;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT"
-
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
                                 BasicRuntimeChecks="3"
-
+ RuntimeLibrary="1"
                                 UsePrecompiledHeader="0"
                                 WarningLevel="3"
                                 Detect64BitPortabilityProblems="true"
@@ -62,10 +62,12 @@
                         <Tool
                                 Name="VCLinkerTool"
                                 AdditionalDependencies="qtmain.lib QtGui4.lib QtCore4.lib"
-
- AdditionalLibraryDirectories="c:\Qt\2009.03\qt\lib "
+ AdditionalLibraryDirectories=""
+ IgnoreDefaultLibraryNames="msvcrt.lib"
                                 GenerateDebugInformation="true"
                                 SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
                                 TargetMachine="1"
                         />
                         <Tool
@@ -87,9 +89,6 @@
                                 Name="VCAppVerifierTool"
                         />
                         <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
                                 Name="VCPostBuildEventTool"
                         />
                 </Configuration>
@@ -98,7 +97,7 @@
                         OutputDirectory="$(SolutionDir)$(ConfigurationName)"
                         IntermediateDirectory="$(ConfigurationName)\x01_qt_example"
                         ConfigurationType="1"
- InheritedPropertySheets=".\boost.vsprops"
+ InheritedPropertySheets=".\boost.vsprops;.\qt.vsprops"
                         CharacterSet="1"
                         WholeProgramOptimization="1"
>
@@ -119,13 +118,11 @@
                         />
                         <Tool
                                 Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="c:\Qt\2009.03\qt\include;c:\Qt\2009.03\qt\include\QtGui"
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;QT_NO_DEBUG;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT"
-
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
                                 UsePrecompiledHeader="0"
                                 WarningLevel="3"
                                 Detect64BitPortabilityProblems="true"
-
                         />
                         <Tool
                                 Name="VCManagedResourceCompilerTool"
@@ -139,12 +136,14 @@
                         <Tool
                                 Name="VCLinkerTool"
                                 AdditionalDependencies="qtmain.lib QtGui4.lib QtCore4.lib"
- \
- AdditionalLibraryDirectories="c:\Qt\2009.03\qt\lib "
+ AdditionalLibraryDirectories=""
+ IgnoreDefaultLibraryNames="msvcrt.lib"
                                 GenerateDebugInformation="true"
                                 SubSystem="2"
                                 OptimizeReferences="2"
                                 EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
                                 TargetMachine="1"
                         />
                         <Tool
@@ -166,9 +165,6 @@
                                 Name="VCAppVerifierTool"
                         />
                         <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
                                 Name="VCPostBuildEventTool"
                         />
                 </Configuration>

Modified: sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.cpp (original)
+++ sandbox/geometry/libs/geometry/example/x04_wxwidgets_world_mapper.cpp 2010-04-26 16:51:13 EDT (Mon, 26 Apr 2010)
@@ -18,9 +18,11 @@
 
 #include <boost/foreach.hpp>
 #include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.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/geometries/cartesian2d.hpp>
 #include <boost/geometry/extensions/algorithms/selected.hpp>
@@ -39,12 +41,64 @@
 #include "wx/graphics.h"
 #endif
 
+// wxWidgets draws using wxPoint*
+// So we have to make a wxPoint* array compatible with Boost.Range
+// and with std::back_inserter
+// So we define an iterator pair:
+typedef std::pair<wxPoint*,wxPoint*> wxPointPointerPair;
 
 // 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)
 
+BOOST_GEOMETRY_REGISTER_RING(wxPointPointerPair);
+
+
+
+// Implement a draft back_insert_iterator for such a pair of pointers
+// It might exist somewhere in Boost yet.
+namespace std
+{
+
+template <>
+class back_insert_iterator<wxPointPointerPair>
+{
+public:
+ explicit back_insert_iterator(wxPointPointerPair& x)
+ : current(boost::begin(x))
+ , end(boost::end(x))
+ {}
+
+ back_insert_iterator<wxPointPointerPair>&
+ operator=(const wxPoint& value)
+ {
+ // Check if not passed beyond
+ if (current != end)
+ {
+ *current++ = value;
+ }
+ return *this;
+ }
+
+ // Boiler-plate
+ back_insert_iterator<wxPointPointerPair>& operator*() { return *this; }
+ back_insert_iterator<wxPointPointerPair>& operator++() { return *this; }
+ back_insert_iterator<wxPointPointerPair>& operator++(int) { return *this; }
+
+ typedef wxPointPointerPair container_type;
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+ typedef void difference_type;
+ typedef void pointer;
+ typedef void reference;
+
+protected:
+ boost::range_iterator<wxPointPointerPair>::type current, end;
+};
+
+}
+
 
 typedef boost::geometry::multi_polygon<boost::geometry::polygon_2d> country_type;
 
@@ -304,22 +358,18 @@
 
     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, *m_map_transformer);
-
- // 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
+ // Use only outer, holes are (for the moment) ignored. This would need
+ // a holey-polygon compatible wx object
+
+ std::size_t n = boost::size(poly.outer());
+
+ boost::scoped_ptr<wxPoint> points(new wxPoint[n]);
 
- dc.DrawPolygon(n, points);
+ bg::transform(poly.outer(),
+ std::make_pair(points.get(), points.get() + n),
+ *m_map_transformer);
 
- delete[] points;
+ dc.DrawPolygon(n, points.get());
     }
 }
 


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