[mapguide-commits] r1294 - in trunk/MgDev: Common/Stylization
Server/src/Services/Mapping
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Mar 19 20:06:47 EDT 2007
Author: waltweltonlair
Date: 2007-03-19 20:06:47 -0400 (Mon, 19 Mar 2007)
New Revision: 1294
Modified:
trunk/MgDev/Common/Stylization/DWFRenderer.cpp
trunk/MgDev/Common/Stylization/DWFRenderer.h
trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.cpp
Log:
Initial set up of DWFRenderer for new symbolization.
DWFRenderer now extends SE_Renderer so it can participate in the new
symbology. For the purpose of SE_Renderer, we define "screen space"
to be "W2D space". The virtual SE_Renderer methods which define the
transforms have been implemented, but not yet any of the Draw calls.
This will happen in a subsequent submission.
Modified: trunk/MgDev/Common/Stylization/DWFRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/DWFRenderer.cpp 2007-03-19 20:25:03 UTC (rev 1293)
+++ trunk/MgDev/Common/Stylization/DWFRenderer.cpp 2007-03-20 00:06:47 UTC (rev 1294)
@@ -67,10 +67,11 @@
//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
//------------------------------Utilities--------------------------------------
//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
WT_Color Util_ConvertColor(RS_Color & color)
{
WT_Color ret(color.red(), color.green(), color.blue(), color.alpha());
@@ -191,11 +192,13 @@
return WT_Result::Unknown_File_Read_Error;
}
+
//-----------------------------------------------------------------------------
//--------------------------DWFRenderer----------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+
DWFRenderer::DWFRenderer()
: m_w2dFile(NULL),
m_mapInfo(NULL),
@@ -249,6 +252,7 @@
delete m_attributes;
}
+
//-----------------------------------------------------------------------------
//
// Initializes map generation with required map properties.
@@ -259,8 +263,7 @@
double mapScale,
double dpi,
double metersPerUnit,
- CSysTransformer* xformToLL
- )
+ CSysTransformer* xformToLL)
{
if (dpi == 0.0)
m_dpi = 96.0; // default -- 96 is usually true for Windows
@@ -302,6 +305,7 @@
m_mapInfo = mapInfo;
}
+
//-----------------------------------------------------------------------------
//
// Tells the Renderer we are done with map generation. It should be overloaded
@@ -349,6 +353,7 @@
m_mapInfo = NULL;
}
+
//-----------------------------------------------------------------------------
//
// Indicates beginning of a map layer. This function creates a W2D for feature
@@ -357,10 +362,7 @@
// are labels.
//
//-----------------------------------------------------------------------------
-
-void DWFRenderer::StartLayer(RS_LayerUIInfo* legendInfo,
- RS_FeatureClassInfo* classInfo
- )
+void DWFRenderer::StartLayer(RS_LayerUIInfo* legendInfo, RS_FeatureClassInfo* classInfo)
{
if (classInfo && legendInfo &&
(legendInfo->selectable() || legendInfo->hastooltips() || legendInfo->hashyperlinks()))
@@ -455,6 +457,7 @@
m_layerInfo = legendInfo;
}
+
//-----------------------------------------------------------------------------
//
// Cleans up W2D files after processing for a layer is done. Should be
@@ -512,6 +515,7 @@
m_layerInfo = NULL;
}
+
//----------------------------------------------------------------------------
// All subsequent drawables will be considered as part of a single feature
// identifier by the given feature reader, until the next call to StartFeature()
@@ -523,7 +527,6 @@
double /*zOffset*/,
double /*zExtrusion*/,
RS_ElevationType /*zOffsetType*/)
-
{
//attributes and selection support
StoreAttributes(feature, tooltip, url);
@@ -536,8 +539,7 @@
// holes etc.
//
//-----------------------------------------------------------------------------
-void DWFRenderer::ProcessPolygon ( LineBuffer* srclb,
- RS_FillStyle& fill)
+void DWFRenderer::ProcessPolygon(LineBuffer* srclb, RS_FillStyle& fill)
{
LineBuffer* workbuffer = srclb->Optimize(m_drawingScale, &m_lbPool);
@@ -620,8 +622,7 @@
// Polyline features. Transformation to W2D space is done here.
//
//-----------------------------------------------------------------------------
-void DWFRenderer::ProcessPolyline(LineBuffer* srclb,
- RS_LineStroke& lsym)
+void DWFRenderer::ProcessPolyline(LineBuffer* srclb, RS_LineStroke& lsym)
{
if (srclb->point_count() == 0)
return;
@@ -663,17 +664,18 @@
m_lbPool.FreeLineBuffer(workbuffer);
}
+
//-----------------------------------------------------------------------------
//
// Raster serialization.
//
//-----------------------------------------------------------------------------
-void DWFRenderer::ProcessRaster(unsigned char* data,
- int length,
- RS_ImageFormat format,
- int width,
- int height,
- RS_Bounds extents)
+void DWFRenderer::ProcessRaster(unsigned char* data,
+ int length,
+ RS_ImageFormat format,
+ int width,
+ int height,
+ RS_Bounds extents)
{
if (format != RS_ImageFormat_RGBA && format != RS_ImageFormat_PNG)
{
@@ -733,10 +735,7 @@
// Marker Symbols
//
//-----------------------------------------------------------------------------
-void DWFRenderer::ProcessMarker(LineBuffer* srclb,
- RS_MarkerDef& mdef,
- bool allowOverpost,
- RS_Bounds* bounds)
+void DWFRenderer::ProcessMarker(LineBuffer* srclb, RS_MarkerDef& mdef, bool allowOverpost, RS_Bounds* bounds)
{
for (int i=0; i<srclb->point_count(); i++)
{
@@ -763,9 +762,7 @@
// symbol library resource. This is hardcoded right now.
// If it ever changes, we will need to update it
//
-
- symbol = (RS_InputStream*)m_symbolManager->GetSymbolData(mdef.library().c_str(),
- L"symbols.dwf"); //NOXLATE
+ symbol = (RS_InputStream*)m_symbolManager->GetSymbolData(mdef.library().c_str(), L"symbols.dwf"); //NOXLATE
}
//default symbol
@@ -796,7 +793,6 @@
double aspect = (mdef.width() == 0.0) ? DBL_MAX : mdef.height() / mdef.width();
RS_Bounds dst;
-
if (aspect <= 1.0)
dst = RS_Bounds(0, 0, SYMBOL_MAX, aspect * SYMBOL_MAX);
else
@@ -1076,27 +1072,25 @@
m_obsMesh->ProcessPoint(x, y);
}
+
//-----------------------------------------------------------------------------
//
// Text labels
//
//-----------------------------------------------------------------------------
-void DWFRenderer::ProcessLabel(double x,
- double y,
- const RS_String& text,
- RS_TextDef& tdef)
+void DWFRenderer::ProcessLabel(double x, double y, const RS_String& text, RS_TextDef& tdef)
{
RS_LabelInfo info(x, y, 0.0, 0.0, tdef.font().units(), tdef, false);
ProcessLabelGroup(&info, 1, text, RS_OverpostType_All, false, NULL);
}
-void DWFRenderer::ProcessLabelGroup( RS_LabelInfo* labels,
- int nlabels,
- const RS_String& text,
- RS_OverpostType type,
- bool exclude,
- LineBuffer* /*path*/)
+void DWFRenderer::ProcessLabelGroup(RS_LabelInfo* labels,
+ int nlabels,
+ const RS_String& text,
+ RS_OverpostType type,
+ bool exclude,
+ LineBuffer* /*path*/)
{
if (nlabels == 0)
return;
@@ -1548,6 +1542,7 @@
}
}
+
//-----------------------------------------------------------------------------
//
// Writes multi-polyline geometry to W2D. Input is a LineBuffer
@@ -1594,6 +1589,7 @@
m_w2dFile->desired_rendition().line_weight() = WT_Line_Weight(line_weight);
}
+
//-----------------------------------------------------------------------------
//
// Serializes a polygon fill style
@@ -1646,6 +1642,7 @@
}
}
+
//-----------------------------------------------------------------------------
//
// Serializes font and text alignement and rendering settings
@@ -1719,6 +1716,7 @@
}
}
+
//-----------------------------------------------------------------------------
//scale an input number in meters to a mapping
//space number given a device or mapping space unit.
@@ -1749,6 +1747,7 @@
return (double)pixels * (0.0254 / renderer->GetDpi()) * renderer->GetMapScale() / renderer->GetMetersPerUnit();
}
+
//-----------------------------------------------------------------------------
//scale an input number in meters to a mapping
//space number given a device or mapping space unit.
@@ -1808,14 +1807,14 @@
file->desired_rendition().drawing_info().units().serialize(*file);
}
+
//-----------------------------------------------------------------------------
//
// Helper function to start a new W2D object node and write out the attributes
// of the current feature into a DWF object definition instance
//
//-----------------------------------------------------------------------------
-void DWFRenderer::StoreAttributes(RS_FeatureReader* feature, const RS_String* tooltip,
- const RS_String* url)
+void DWFRenderer::StoreAttributes(RS_FeatureReader* feature, const RS_String* tooltip, const RS_String* url)
{
if (m_featureClass && m_featureClassInfo)
{
@@ -1906,6 +1905,12 @@
}
+void DWFRenderer::SetSymbolManager(RS_SymbolManager* manager)
+{
+ m_symbolManager = manager;
+}
+
+
RS_MapUIInfo* DWFRenderer::GetMapInfo()
{
return m_mapInfo;
@@ -1929,6 +1934,11 @@
return m_mapScale;
}
+double DWFRenderer::GetMetersPerUnit()
+{
+ return m_metersPerUnit;
+}
+
RS_Bounds& DWFRenderer::GetBounds()
{
return m_extents;
@@ -1939,9 +1949,9 @@
return m_dpi;
}
-double DWFRenderer::GetMetersPerUnit()
+bool DWFRenderer::RequiresClipping()
{
- return m_metersPerUnit;
+ return true;
}
double DWFRenderer::GetMapToW2DScale()
@@ -1949,10 +1959,6 @@
return m_scale;
}
-bool DWFRenderer::RequiresClipping()
-{
- return true;
-}
void DWFRenderer::EnsureBufferSize(int len)
{
@@ -1970,11 +1976,6 @@
}
-void DWFRenderer::SetSymbolManager(RS_SymbolManager* manager)
-{
- m_symbolManager = manager;
-}
-
void DWFRenderer::StartLayout(RS_Bounds& extents)
{
// Reset m_mapScale and m_metersPerUnit
@@ -2010,6 +2011,7 @@
m_imgID = 0;
}
+
void DWFRenderer::EndLayout()
{
m_extents = m_mapExtents;
@@ -2039,6 +2041,7 @@
}
}
+
void DWFRenderer::Init(RS_Bounds& extents)
{
m_mapExtents = m_extents;
@@ -2059,6 +2062,109 @@
m_offsetY = 0;
}
+
+//-----------------------------------------------------------------------------
+//
+// SE Renderer
+//
+//-----------------------------------------------------------------------------
+
+void DWFRenderer::DrawScreenPolyline(LineBuffer* geom, const SE_Matrix* xform, unsigned int color, double weight)
+{
+ // TODO
+}
+
+
+void DWFRenderer::DrawScreenPolygon(LineBuffer* geom, const SE_Matrix* xform, unsigned int fill)
+{
+ // TODO
+}
+
+
+void DWFRenderer::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)
+{
+ // TODO
+}
+
+
+void DWFRenderer::DrawScreenText(const RS_String& txt, RS_TextDef& tdef, double insx, double insy, double* path, int npts, double param_position)
+{
+ // TODO
+}
+
+
+void DWFRenderer::GetWorldToScreenTransform(SE_Matrix& xform)
+{
+ // "screen space" in DWF is W2D space
+ xform.x0 = m_scale;
+ xform.x1 = 0.0;
+ xform.x2 = - m_offsetX * m_scale;
+ xform.y0 = 0.0;
+ xform.y1 = m_scale;
+ xform.y2 = - m_offsetY * m_scale;
+}
+
+
+void DWFRenderer::WorldToScreenPoint(double& inx, double& iny, double& ox, double& oy)
+{
+ // "screen space" in DWF is W2D space
+ ox = (inx - m_offsetX) * m_scale;
+ oy = (iny - m_offsetY) * m_scale;
+}
+
+
+void DWFRenderer::ScreenToWorldPoint(double& inx, double& iny, double& ox, double& oy)
+{
+ // "screen space" in DWF is W2D space
+ ox = inx / m_scale + m_offsetX;
+ oy = iny / m_scale + m_offsetY;
+}
+
+
+// returns number of W2D units per millimeter screen
+double DWFRenderer::GetPixelsPerMillimeterScreen()
+{
+ // [ W2D ] [ W2D ] [ World ] meter-world mm-world
+ // --------- = --------- * ----------- * ------------- * ---------
+ // mm-screen [ World ] meter-world 1000 mm-world mm-screen
+ return m_scale / m_metersPerUnit / 1000.0 * m_mapScale;
+}
+
+
+// returns number of W2D units per millimeter world
+double DWFRenderer::GetPixelsPerMillimeterWorld()
+{
+ // [ W2D ] [ W2D ] [ World ] meter-world
+ // -------- = --------- * ----------- * -------------
+ // mm-world [ World ] meter-world 1000 mm-world
+ return m_scale / m_metersPerUnit / 1000.0;
+}
+
+
+RS_FontEngine* DWFRenderer::GetFontEngine()
+{
+ // TODO
+ return NULL;
+}
+
+
+void DWFRenderer::ProcessLabelGroup(SE_LabelInfo* labels,
+ int nlabels,
+ RS_OverpostType type,
+ bool exclude,
+ LineBuffer* path)
+{
+ // TODO
+}
+
+
+void DWFRenderer::AddExclusionRegion(RS_F_Point* fpts, int npts)
+{
+ // TODO
+}
+
+
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
////
Modified: trunk/MgDev/Common/Stylization/DWFRenderer.h
===================================================================
--- trunk/MgDev/Common/Stylization/DWFRenderer.h 2007-03-19 20:25:03 UTC (rev 1293)
+++ trunk/MgDev/Common/Stylization/DWFRenderer.h 2007-03-20 00:06:47 UTC (rev 1294)
@@ -28,6 +28,8 @@
#include "LineBuffer.h"
#include "KeyEncode.h"
+#include "SE_Renderer.h"
+
//forward declare
class WT_File;
class WT_Viewport;
@@ -61,61 +63,58 @@
///<summary>
/// Implementation of Renderer for DWF-W2D output
///</summary>
-class DWFRenderer : public Renderer
+class DWFRenderer : public Renderer, public SE_Renderer
{
public:
STYLIZATION_API DWFRenderer();
STYLIZATION_API virtual ~DWFRenderer();
- STYLIZATION_API virtual void StartMap (RS_MapUIInfo* mapInfo,
- RS_Bounds& extents,
- double mapScale,
- double dpi,
- double metersPerUnit,
- CSysTransformer* xformToLL);
+ ///////////////////////////////////
+ // Renderer implementation
+ //
+ STYLIZATION_API virtual void StartMap(RS_MapUIInfo* mapInfo,
+ RS_Bounds& extents,
+ double mapScale,
+ double dpi,
+ double metersPerUnit,
+ CSysTransformer* xformToLL);
- STYLIZATION_API virtual void EndMap ();
+ STYLIZATION_API virtual void EndMap();
- STYLIZATION_API virtual void StartLayer (RS_LayerUIInfo* legendInfo,
- RS_FeatureClassInfo* classInfo);
+ STYLIZATION_API virtual void StartLayer(RS_LayerUIInfo* legendInfo,
+ RS_FeatureClassInfo* classInfo);
- STYLIZATION_API virtual void EndLayer ();
+ STYLIZATION_API virtual void EndLayer();
- STYLIZATION_API virtual void StartFeature (RS_FeatureReader* feature,
- const RS_String* tooltip = NULL,
- const RS_String* url = NULL,
- const RS_String* theme = NULL,
- double zOffset = 0,
- double zExtrusion = 0,
- RS_ElevationType zOffsetType = RS_ElevationType_RelativeToGround);
+ STYLIZATION_API virtual void StartFeature(RS_FeatureReader* feature,
+ const RS_String* tooltip = NULL,
+ const RS_String* url = NULL,
+ const RS_String* theme = NULL,
+ double zOffset = 0,
+ double zExtrusion = 0,
+ RS_ElevationType zOffsetType = RS_ElevationType_RelativeToGround);
- STYLIZATION_API virtual void ProcessPolygon (LineBuffer* lb,
- RS_FillStyle& fill);
+ STYLIZATION_API virtual void ProcessPolygon(LineBuffer* lb, RS_FillStyle& fill);
- STYLIZATION_API virtual void ProcessPolyline(LineBuffer* lb,
- RS_LineStroke& lsym);
+ STYLIZATION_API virtual void ProcessPolyline(LineBuffer* lb, RS_LineStroke& lsym);
- STYLIZATION_API virtual void ProcessRaster (unsigned char* data,
- int length,
- RS_ImageFormat format,
- int width,
- int height,
- RS_Bounds extents);
+ STYLIZATION_API virtual void ProcessRaster(unsigned char* data,
+ int length,
+ RS_ImageFormat format,
+ int width,
+ int height,
+ RS_Bounds extents);
- STYLIZATION_API virtual void ProcessMarker(LineBuffer* lb,
- RS_MarkerDef& mdef,
- bool allowOverpost,
- RS_Bounds* bounds = NULL);
+ STYLIZATION_API virtual void ProcessMarker(LineBuffer* lb, RS_MarkerDef& mdef, bool allowOverpost, RS_Bounds* bounds = NULL);
- STYLIZATION_API virtual void ProcessLabel(double x, double y,
- const RS_String& text, RS_TextDef& tdef);
+ STYLIZATION_API virtual void ProcessLabel(double x, double y, const RS_String& text, RS_TextDef& tdef);
- STYLIZATION_API virtual void ProcessLabelGroup( RS_LabelInfo* labels,
- int nlabels,
- const RS_String& text,
- RS_OverpostType type,
- bool exclude,
- LineBuffer* path);
+ STYLIZATION_API virtual void ProcessLabelGroup(RS_LabelInfo* labels,
+ int nlabels,
+ const RS_String& text,
+ RS_OverpostType type,
+ bool exclude,
+ LineBuffer* path);
STYLIZATION_API virtual void AddDWFContent(RS_InputStream* in,
CSysTransformer* xformer,
@@ -133,20 +132,49 @@
STYLIZATION_API virtual double GetMapScale();
+ STYLIZATION_API virtual double GetMetersPerUnit();
+
STYLIZATION_API virtual RS_Bounds& GetBounds();
STYLIZATION_API virtual double GetDpi();
- STYLIZATION_API virtual double GetMetersPerUnit();
+ STYLIZATION_API virtual bool RequiresClipping();
- STYLIZATION_API virtual double GetMapToW2DScale();
+ /////////////////////////////////////////////
+ // DWFRenderer specific
+ //
+ STYLIZATION_API double GetMapToW2DScale();
- STYLIZATION_API virtual bool RequiresClipping();
-
STYLIZATION_API void StartLayout(RS_Bounds& extents);
STYLIZATION_API void EndLayout();
+ ////////////////////////////////////////////////
+ // SE_Renderer
+ //
+ virtual void DrawScreenPolyline(LineBuffer* geom, const SE_Matrix* xform, unsigned int color, double weight); // px
+ virtual void DrawScreenPolygon(LineBuffer* geom, const SE_Matrix* xform, unsigned int fill);
+ 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);
+ virtual void DrawScreenText(const RS_String& txt, RS_TextDef& tdef, double insx, double insy, double* path, int npts, double param_position);
+
+ virtual void GetWorldToScreenTransform(SE_Matrix& xform);
+ virtual void WorldToScreenPoint(double& inx, double& iny, double& ox, double& oy);
+ virtual void ScreenToWorldPoint(double& inx, double& iny, double& ox, double& oy);
+
+ virtual double GetPixelsPerMillimeterScreen();
+ virtual double GetPixelsPerMillimeterWorld();
+
+ virtual RS_FontEngine* GetFontEngine();
+
+ virtual void ProcessLabelGroup(SE_LabelInfo* labels,
+ int nlabels,
+ RS_OverpostType type,
+ bool exclude,
+ LineBuffer* path = NULL);
+
+ virtual void AddExclusionRegion(RS_F_Point* fpts, int npts);
+
protected:
//list of layer w2d streams
WT_File* m_w2dFile;
Modified: trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.cpp 2007-03-19 20:25:03 UTC (rev 1293)
+++ trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.cpp 2007-03-20 00:06:47 UTC (rev 1294)
@@ -16,7 +16,6 @@
//
#include "ServerMappingServiceDefs.h"
-
#include "ServerMappingService.h"
#include "Stylization.h"
@@ -34,6 +33,7 @@
#include "FeatureTypeStyleVisitor.h"
#include "RSMgSymbolManager.h"
+#include "SEMgSymbolManager.h"
#include "LegendPlotUtil.h"
@@ -422,7 +422,8 @@
RSMgSymbolManager mgr(m_svcResource);
dr.SetSymbolManager(&mgr);
- DefaultStylizer ds(NULL);
+ SEMgSymbolManager semgr(m_svcResource);
+ DefaultStylizer ds(&semgr);
RS_MapUIInfo mapInfo(sessionId, map->GetName(), map->GetObjectId(), srs, units, bgcolor);
More information about the mapguide-commits
mailing list