[mapguide-commits] r9180 - sandbox/jng/utfgrid/Common/Renderers

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Apr 24 08:14:11 PDT 2017


Author: jng
Date: 2017-04-24 08:14:11 -0700 (Mon, 24 Apr 2017)
New Revision: 9180

Added:
   sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp
   sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.h
Modified:
   sandbox/jng/utfgrid/Common/Renderers/Renderers.vcxproj
   sandbox/jng/utfgrid/Common/Renderers/Renderers.vcxproj.filters
Log:
Add skeleton UTFGridRenderer.

Modified: sandbox/jng/utfgrid/Common/Renderers/Renderers.vcxproj
===================================================================
--- sandbox/jng/utfgrid/Common/Renderers/Renderers.vcxproj	2017-04-24 13:17:11 UTC (rev 9179)
+++ sandbox/jng/utfgrid/Common/Renderers/Renderers.vcxproj	2017-04-24 15:14:11 UTC (rev 9180)
@@ -218,6 +218,7 @@
     <ClCompile Include="SymbolTrans.cpp" />
     <ClCompile Include="DWFRenderer.cpp" />
     <ClCompile Include="EPlotRenderer.cpp" />
+    <ClCompile Include="UTFGridRenderer.cpp" />
     <ClCompile Include="W2DRewriter.cpp" />
     <ClCompile Include="complex_polygon_gd.cpp" />
     <ClCompile Include="GDFillPatterns.cpp" />
@@ -265,6 +266,7 @@
     <ClInclude Include="EPlotRenderer.h" />
     <ClInclude Include="RSDWFInputStream.h" />
     <ClInclude Include="RSDWFOutputStream.h" />
+    <ClInclude Include="UTFGridRenderer.h" />
     <ClInclude Include="W2DRewriter.h" />
     <ClInclude Include="whip_fill_library.h" />
     <ClInclude Include="whip_hatch_library.h" />

Modified: sandbox/jng/utfgrid/Common/Renderers/Renderers.vcxproj.filters
===================================================================
--- sandbox/jng/utfgrid/Common/Renderers/Renderers.vcxproj.filters	2017-04-24 13:17:11 UTC (rev 9179)
+++ sandbox/jng/utfgrid/Common/Renderers/Renderers.vcxproj.filters	2017-04-24 15:14:11 UTC (rev 9180)
@@ -22,6 +22,9 @@
     <Filter Include="AGGRenderer">
       <UniqueIdentifier>{737455e1-014f-4212-b295-d535728637bc}</UniqueIdentifier>
     </Filter>
+    <Filter Include="UTFGridRenderer">
+      <UniqueIdentifier>{139cab4d-e977-4ad2-8526-73e40cb9dde1}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="SymbolTrans.cpp">
@@ -114,6 +117,9 @@
     <ClCompile Include="CriticalSection.cpp" />
     <ClCompile Include="MapQuantization.cpp" />
     <ClCompile Include="RenderUtil.cpp" />
+    <ClCompile Include="UTFGridRenderer.cpp">
+      <Filter>UTFGridRenderer</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="SymbolTrans.h">
@@ -205,6 +211,9 @@
     <ClInclude Include="Renderers.h" />
     <ClInclude Include="RenderUtil.h" />
     <ClInclude Include="stdafx.h" />
+    <ClInclude Include="UTFGridRenderer.h">
+      <Filter>UTFGridRenderer</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="Renderers.rc" />

Added: sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp
===================================================================
--- sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp	                        (rev 0)
+++ sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.cpp	2017-04-24 15:14:11 UTC (rev 9180)
@@ -0,0 +1,242 @@
+#include "UTFGridRenderer.h"
+
+#define UTF_GRID_WIDTH 256
+#define UTF_GRID_HEIGHT 256
+
+UTFGridRenderer::UTFGridRenderer()
+{
+}
+
+
+UTFGridRenderer::~UTFGridRenderer()
+{
+}
+
+void UTFGridRenderer::StartMap(RS_MapUIInfo * mapInfo, RS_Bounds & extents, double mapScale, double dpi, double metersPerUnit, CSysTransformer * xformToLL)
+{
+    m_mapScale = mapScale;
+    m_dpi = dpi;
+    m_metersPerUnit = metersPerUnit;
+    m_extents = extents;
+
+    // find scale used to convert to pixel coordinates
+    // need to take aspect ratios into account
+    double arDisplay = 1.0;
+    double arMap = m_extents.width() / m_extents.height();
+
+    double scale;
+    if (arDisplay > arMap)
+        scale = (double)UTF_GRID_HEIGHT / m_extents.height();
+    else
+        scale = (double)UTF_GRID_WIDTH / m_extents.width();
+
+    m_xform.x0 = scale;
+    m_xform.x1 = 0.0;
+    m_xform.x2 = -scale * m_extents.minx;
+    m_xform.y0 = 0.0;
+    m_xform.y1 = scale;
+    m_xform.y2 = -scale * m_extents.miny;
+
+    m_ixform.x0 = 1.0 / scale;
+    m_ixform.x1 = 0.0;
+    m_ixform.x2 = m_extents.minx;
+    m_ixform.y0 = 0.0;
+    m_ixform.y1 = m_ixform.x0;
+    m_ixform.y2 = m_extents.miny;
+
+    double metersPerPixel = METERS_PER_INCH / m_dpi;
+
+    // compute drawing scale
+    // drawing scale is map scale converted to [mapping units] / [pixels]
+    m_drawingScale = m_mapScale * metersPerPixel / m_metersPerUnit;
+
+    // remember the map info
+    m_mapInfo = mapInfo;
+}
+
+void UTFGridRenderer::EndMap()
+{
+    m_mapInfo = NULL;
+}
+
+void UTFGridRenderer::StartLayer(RS_LayerUIInfo * layerInfo, RS_FeatureClassInfo * classInfo)
+{
+    // remember the layer/feature info
+    m_layerInfo = layerInfo;
+    m_fcInfo = classInfo;
+}
+
+void UTFGridRenderer::EndLayer()
+{
+    // clear the layer/feature info
+    m_layerInfo = NULL;
+    m_fcInfo = NULL;
+}
+
+void UTFGridRenderer::StartFeature(RS_FeatureReader * feature, bool initialPass, const RS_String * tooltip, const RS_String * url, const RS_String * theme, double zOffset, double zExtrusion, RS_ElevationType zOffsetType)
+{
+    m_currentFeature = feature;
+}
+
+void UTFGridRenderer::ProcessPolygon(LineBuffer * lb, RS_FillStyle & fill)
+{
+    DrawScreenPolygon(lb, &m_xform, fill.color().argb());
+}
+
+void UTFGridRenderer::ProcessPolyline(LineBuffer * lb, RS_LineStroke & lsym)
+{
+    DrawScreenPolyline(lb, &m_xform, m_lineStroke);
+}
+
+void UTFGridRenderer::ProcessRaster(unsigned char * data, int length, RS_ImageFormat format, int width, int height, RS_Bounds & extents, TransformMesh * xformMesh)
+{
+    //Not applicable for UTFGrid
+}
+
+void UTFGridRenderer::ProcessMarker(LineBuffer * lb, RS_MarkerDef & mdef, bool allowOverpost, RS_Bounds * bounds)
+{
+
+}
+
+void UTFGridRenderer::ProcessLabelGroup(RS_LabelInfo * labels, int nlabels, const RS_String & text, RS_OverpostType type, bool exclude, LineBuffer * path, double scaleLimit)
+{
+    //Not applicable for UTFGrid
+}
+
+void UTFGridRenderer::AddDWFContent(RS_InputStream * in, CSysTransformer * xformer, const RS_String & section, const RS_String & passwd, const RS_String & w2dfilter)
+{
+    //Not applicable for UTFGrid
+}
+
+void UTFGridRenderer::SetSymbolManager(RS_SymbolManager * manager)
+{
+    //Not applicable for UTFGrid
+}
+
+RS_MapUIInfo * UTFGridRenderer::GetMapInfo()
+{
+    return m_mapInfo;
+}
+
+RS_LayerUIInfo * UTFGridRenderer::GetLayerInfo()
+{
+    return m_layerInfo;
+}
+
+RS_FeatureClassInfo * UTFGridRenderer::GetFeatureClassInfo()
+{
+    return m_fcInfo;
+}
+
+double UTFGridRenderer::GetMapScale()
+{
+    return m_mapScale;
+}
+
+double UTFGridRenderer::GetDrawingScale()
+{
+    return m_drawingScale;
+}
+
+double UTFGridRenderer::GetMetersPerUnit()
+{
+    return m_metersPerUnit;
+}
+
+double UTFGridRenderer::GetDpi()
+{
+    return m_dpi;
+}
+
+RS_Bounds & UTFGridRenderer::GetBounds()
+{
+    return m_extents;
+}
+
+bool UTFGridRenderer::RequiresClipping()
+{
+    return false;
+}
+
+bool UTFGridRenderer::RequiresLabelClipping()
+{
+    return false;
+}
+
+bool UTFGridRenderer::SupportsZ()
+{
+    return false;
+}
+
+void UTFGridRenderer::DrawScreenPolyline(LineBuffer * polyline, const SE_Matrix * xform, const SE_LineStroke & lineStroke)
+{
+}
+
+void UTFGridRenderer::DrawScreenPolygon(LineBuffer * polygon, const SE_Matrix * xform, unsigned int fill)
+{
+}
+
+void UTFGridRenderer::DrawScreenRaster(unsigned char * data, int length, RS_ImageFormat format, int native_width, int native_height, double x, double y, double w, double h, double angleDeg)
+{
+    //Not applicable for UTFGrid
+}
+
+void UTFGridRenderer::DrawScreenRaster(unsigned char * data, int length, RS_ImageFormat format, int native_width, int native_height, double x, double y, double w, double h, double angleDeg, double alpha)
+{
+    //Not applicable for UTFGrid
+}
+
+void UTFGridRenderer::DrawScreenText(const RS_TextMetrics & tm, RS_TextDef & tdef, double insx, double insy, RS_F_Point * path, int npts, double param_position)
+{
+    //Not applicable for UTFGrid
+}
+
+bool UTFGridRenderer::YPointsUp()
+{
+    return false;
+}
+
+void UTFGridRenderer::GetWorldToScreenTransform(SE_Matrix & xform)
+{
+    xform = m_xform;
+}
+
+void UTFGridRenderer::WorldToScreenPoint(double & inx, double & iny, double & ox, double & oy)
+{
+    m_xform.transform(inx, iny, ox, oy);
+}
+
+void UTFGridRenderer::ScreenToWorldPoint(double & inx, double & iny, double & ox, double & oy)
+{
+    m_ixform.transform(inx, iny, ox, oy);
+}
+
+double UTFGridRenderer::GetScreenUnitsPerMillimeterDevice()
+{
+    return m_dpi / MILLIMETERS_PER_INCH;
+}
+
+double UTFGridRenderer::GetScreenUnitsPerMillimeterWorld()
+{
+    return m_dpi / MILLIMETERS_PER_INCH / m_mapScale;
+}
+
+double UTFGridRenderer::GetScreenUnitsPerPixel()
+{
+    return 1.0;
+}
+
+RS_FontEngine * UTFGridRenderer::GetRSFontEngine()
+{
+    return NULL;
+}
+
+void UTFGridRenderer::ProcessSELabelGroup(SE_LabelInfo * labels, int nlabels, RS_OverpostType type, bool exclude, LineBuffer * path)
+{
+    //Not applicable for UTFGrid
+}
+
+void UTFGridRenderer::AddExclusionRegion(RS_F_Point * fpts, int npts)
+{
+    //Not applicable for UTFGrid
+}

Added: sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.h
===================================================================
--- sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.h	                        (rev 0)
+++ sandbox/jng/utfgrid/Common/Renderers/UTFGridRenderer.h	2017-04-24 15:14:11 UTC (rev 9180)
@@ -0,0 +1,91 @@
+//
+//  Copyright (C) 2004-2017 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library 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
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef _UTFGRIDRENDERER_H_
+#define _UTFGRIDRENDERER_H_
+
+#include "Renderers.h"
+#include "SE_Renderer.h"
+
+class UTFGridRenderer : public SE_Renderer
+{
+public:
+    RENDERERS_API UTFGridRenderer();
+    RENDERERS_API virtual ~UTFGridRenderer();
+
+    // Inherited via SE_Renderer
+    RENDERERS_API virtual void StartMap(RS_MapUIInfo * mapInfo, RS_Bounds & extents, double mapScale, double dpi, double metersPerUnit, CSysTransformer * xformToLL);
+    RENDERERS_API virtual void EndMap();
+    RENDERERS_API virtual void StartLayer(RS_LayerUIInfo * layerInfo, RS_FeatureClassInfo * classInfo);
+    RENDERERS_API virtual void EndLayer();
+    RENDERERS_API virtual void StartFeature(RS_FeatureReader * feature, bool initialPass, const RS_String * tooltip = NULL, const RS_String * url = NULL, const RS_String * theme = NULL, double zOffset = 0.0, double zExtrusion = 0.0, RS_ElevationType zOffsetType = RS_ElevationType_RelativeToGround);
+    RENDERERS_API virtual void ProcessPolygon(LineBuffer * lb, RS_FillStyle & fill);
+    RENDERERS_API virtual void ProcessPolyline(LineBuffer * lb, RS_LineStroke & lsym);
+    RENDERERS_API virtual void ProcessRaster(unsigned char * data, int length, RS_ImageFormat format, int width, int height, RS_Bounds & extents, TransformMesh * xformMesh = NULL);
+    RENDERERS_API virtual void ProcessMarker(LineBuffer * lb, RS_MarkerDef & mdef, bool allowOverpost, RS_Bounds * bounds = NULL);
+    RENDERERS_API virtual void ProcessLabelGroup(RS_LabelInfo * labels, int nlabels, const RS_String & text, RS_OverpostType type, bool exclude, LineBuffer * path, double scaleLimit);
+    RENDERERS_API virtual void AddDWFContent(RS_InputStream * in, CSysTransformer * xformer, const RS_String & section, const RS_String & passwd, const RS_String & w2dfilter);
+    RENDERERS_API virtual void SetSymbolManager(RS_SymbolManager * manager);
+    RENDERERS_API virtual RS_MapUIInfo * GetMapInfo();
+    RENDERERS_API virtual RS_LayerUIInfo * GetLayerInfo();
+    RENDERERS_API virtual RS_FeatureClassInfo * GetFeatureClassInfo();
+    RENDERERS_API virtual double GetMapScale();
+    RENDERERS_API virtual double GetDrawingScale();
+    RENDERERS_API virtual double GetMetersPerUnit();
+    RENDERERS_API virtual double GetDpi();
+    RENDERERS_API virtual RS_Bounds & GetBounds();
+    RENDERERS_API virtual bool RequiresClipping();
+    RENDERERS_API virtual bool RequiresLabelClipping();
+    RENDERERS_API virtual bool SupportsZ();
+    RENDERERS_API virtual void DrawScreenPolyline(LineBuffer * polyline, const SE_Matrix * xform, const SE_LineStroke & lineStroke);
+    RENDERERS_API virtual void DrawScreenPolygon(LineBuffer * polygon, const SE_Matrix * xform, unsigned int fill);
+    RENDERERS_API virtual void DrawScreenRaster(unsigned char * data, int length, RS_ImageFormat format, int native_width, int native_height, double x, double y, double w, double h, double angleDeg);
+    RENDERERS_API virtual void DrawScreenRaster(unsigned char * data, int length, RS_ImageFormat format, int native_width, int native_height, double x, double y, double w, double h, double angleDeg, double alpha);
+    RENDERERS_API virtual void DrawScreenText(const RS_TextMetrics & tm, RS_TextDef & tdef, double insx, double insy, RS_F_Point * path, int npts, double param_position);
+    RENDERERS_API virtual bool YPointsUp();
+    RENDERERS_API virtual void GetWorldToScreenTransform(SE_Matrix & xform);
+    RENDERERS_API virtual void WorldToScreenPoint(double & inx, double & iny, double & ox, double & oy);
+    RENDERERS_API virtual void ScreenToWorldPoint(double & inx, double & iny, double & ox, double & oy);
+    RENDERERS_API virtual double GetScreenUnitsPerMillimeterDevice();
+    RENDERERS_API virtual double GetScreenUnitsPerMillimeterWorld();
+    RENDERERS_API virtual double GetScreenUnitsPerPixel();
+    RENDERERS_API virtual RS_FontEngine * GetRSFontEngine();
+    RENDERERS_API virtual void ProcessSELabelGroup(SE_LabelInfo * labels, int nlabels, RS_OverpostType type, bool exclude, LineBuffer * path = NULL);
+    RENDERERS_API virtual void AddExclusionRegion(RS_F_Point * fpts, int npts);
+
+private:
+    RS_Bounds m_extents;
+    double m_drawingScale;
+    double m_metersPerUnit;
+    double m_dpi;
+    double m_mapScale;
+
+    // map/layer/feature info
+    RS_MapUIInfo* m_mapInfo;
+    RS_LayerUIInfo* m_layerInfo;
+    RS_FeatureClassInfo* m_fcInfo;
+
+    RS_FeatureReader* m_currentFeature;
+
+    SE_Matrix m_xform;
+    SE_Matrix m_ixform;
+
+    //Not used, just passed around to satisfy required func signatures
+    SE_LineStroke m_lineStroke;
+};
+
+#endif
\ No newline at end of file



More information about the mapguide-commits mailing list