[mapguide-commits] r1206 - trunk/MgDev/Common/Stylization

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Mar 13 09:10:38 EDT 2007


Author: waltweltonlair
Date: 2007-03-13 09:10:38 -0400 (Tue, 13 Mar 2007)
New Revision: 1206

Modified:
   trunk/MgDev/Common/Stylization/GDRenderer.cpp
   trunk/MgDev/Common/Stylization/LabelRenderer.cpp
   trunk/MgDev/Common/Stylization/LabelRenderer.h
   trunk/MgDev/Common/Stylization/LabelRendererBase.cpp
   trunk/MgDev/Common/Stylization/LabelRendererBase.h
   trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp
   trunk/MgDev/Common/Stylization/LabelRendererLocal.h
   trunk/MgDev/Common/Stylization/SE_Include.h
   trunk/MgDev/Common/Stylization/SE_Renderer.cpp
   trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp
   trunk/MgDev/Common/Stylization/StylizationEngine.cpp
Log:
- Got rid of LabelRenderer constructors taking 2 renderers as input.  It
  now does a dynamic cast in the constructor to get the SE_Renderer from
  the Renderer.  Still something we will eventually clean up.

- Made the SE_Style and SE_RenderStyle variable names match the schema
  and MdfModel.  It was quite confusing in many cases to figure out which
  properties matchde up:
      orientation <=> angleControl
      units       <=> unitsControl
      overlap     <=> vertexControl
      clipping    <=> clippingControl
      radius      <=> bufferWidth
      offset      <=> originOffset


Modified: trunk/MgDev/Common/Stylization/GDRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/GDRenderer.cpp	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/GDRenderer.cpp	2007-03-13 13:10:38 UTC (rev 1206)
@@ -156,9 +156,9 @@
         gdImageColorTransparent(img, bgc);
 
     if (!m_bLocalOverposting)
-        m_labeler = new LabelRenderer(this, this);
+        m_labeler = new LabelRenderer(this);
     else
-        m_labeler = new LabelRendererLocal(this, this, tileExtentOffset);
+        m_labeler = new LabelRendererLocal(this, tileExtentOffset);
 
     m_polyrasterizer = new complex_polygon_gd();
 }

Modified: trunk/MgDev/Common/Stylization/LabelRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRenderer.cpp	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/LabelRenderer.cpp	2007-03-13 13:10:38 UTC (rev 1206)
@@ -35,10 +35,9 @@
 
 
 //////////////////////////////////////////////////////////////////////////////
-//TODO: this needs to be cleaned up -- all three arguments are the same object
-LabelRenderer::LabelRenderer(Renderer* renderer, SE_Renderer* serenderer)
-: LabelRendererBase(renderer, serenderer),
-  m_bOverpostGroupOpen(false)
+LabelRenderer::LabelRenderer(Renderer* renderer)
+: LabelRendererBase(renderer)
+, m_bOverpostGroupOpen(false)
 {
 }
 
@@ -578,7 +577,7 @@
     int numreps = (int)(seglens[info.m_numpts-1] / (200.0 + tm.text_width));
     if (!numreps) numreps = 1;
 
-    int numchars = info.m_text.length();
+    int numchars = (int)info.m_text.length();
     int labels_drawn = 0; //counter for how many of the repeated label were accepted
 
     for (int i=0; i<numreps; i++)
@@ -597,7 +596,7 @@
         float* spacing = (float*)&tm.char_advances.front(); //bold assumption
 
         double total_advance = 0.0;
-        for (size_t i=0; i<numchars; i++)
+        for (int i=0; i<numchars; i++)
         {
             //width of character - not really exact width since
             //it takes kerning into account, but should be good enough
@@ -628,7 +627,7 @@
         //we need to check each character
         if (check)
         {
-            for (size_t i=0; i<numchars; i++)
+            for (int i=0; i<numchars; i++)
             {
                 if (OverlapsStuff(&oriented_bounds[i*4], 4))
                     goto cont_loop; //skip past label draw, but keep looping through outer loop
@@ -639,7 +638,7 @@
         //once again, do this per character to get tighter bounds around the label
         if (exclude)
         {
-            for (size_t i=0; i<numchars; i++)
+            for (int i=0; i<numchars; i++)
             {
                 AddExclusionRegion(&oriented_bounds[i*4], 4);
             }

Modified: trunk/MgDev/Common/Stylization/LabelRenderer.h
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRenderer.h	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/LabelRenderer.h	2007-03-13 13:10:38 UTC (rev 1206)
@@ -85,7 +85,7 @@
 class LabelRenderer : public LabelRendererBase
 {
 public:
-    LabelRenderer(Renderer* renderer, SE_Renderer* serenderer); //TODO: clean this up -- they point to the same class
+    LabelRenderer(Renderer* renderer);
     virtual ~LabelRenderer();
 
     virtual void StartLabels();

Modified: trunk/MgDev/Common/Stylization/LabelRendererBase.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRendererBase.cpp	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/LabelRendererBase.cpp	2007-03-13 13:10:38 UTC (rev 1206)
@@ -24,12 +24,11 @@
 
 
 //////////////////////////////////////////////////////////////////////////////
-//TODO: clearly the arguments to this need cleanup
-LabelRendererBase::LabelRendererBase(Renderer* renderer, SE_Renderer* serenderer)
-:
-m_renderer(renderer),
-m_serenderer(serenderer)
+LabelRendererBase::LabelRendererBase(Renderer* renderer)
+: m_renderer(renderer)
 {
+    //TODO: this needs cleanup
+    m_serenderer = dynamic_cast<SE_Renderer*>(renderer);
 }
 
 
@@ -41,24 +40,24 @@
 {
     if (m_serenderer->GetFontEngine()->_Yup())
     {
+        //y goes up case
         double sina = sin(-angle_cw_rad);
         double cosa = cos(-angle_cw_rad);
 
         //apply rotation
-        //taking into account that y goes down (so subtract instead of adding for y)
+        //taking into account that y goes up (so add instead of subtracting for y)
         b[0].x = x;
         b[0].y = y;
-        b[1].x = b[0].x +  width * cosa;
-        b[1].y = b[0].y + (width * sina);
-        b[2].x = b[0].x +  width * cosa - height * sina;
-        b[2].y = b[0].y + (width * sina + height * cosa);
-        b[3].x = b[0].x                 - height * sina;
-        b[3].y = b[0].y + (               height * cosa);
+        b[1].x = x +  width * cosa;
+        b[1].y = y + (width * sina);
+        b[2].x = x +  width * cosa - height * sina;
+        b[2].y = y + (width * sina + height * cosa);
+        b[3].x = x                 - height * sina;
+        b[3].y = y + (               height * cosa);
     }
     else
     {
         //y goes down case
-
         double sina = sin(angle_cw_rad);
         double cosa = cos(angle_cw_rad);
 
@@ -66,12 +65,12 @@
         //taking into account that y goes down (so subtract instead of adding for y)
         b[0].x = x;
         b[0].y = y;
-        b[1].x = b[0].x +  width * cosa;
-        b[1].y = b[0].y - (width * sina);
-        b[2].x = b[0].x +  width * cosa - height * sina;
-        b[2].y = b[0].y - (width * sina + height * cosa);
-        b[3].x = b[0].x                 - height * sina;
-        b[3].y = b[0].y - (               height * cosa);
+        b[1].x = x +  width * cosa;
+        b[1].y = y - (width * sina);
+        b[2].x = x +  width * cosa - height * sina;
+        b[2].y = y - (width * sina + height * cosa);
+        b[3].x = x                 - height * sina;
+        b[3].y = y - (               height * cosa);
     }
 }
 

Modified: trunk/MgDev/Common/Stylization/LabelRendererBase.h
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRendererBase.h	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/LabelRendererBase.h	2007-03-13 13:10:38 UTC (rev 1206)
@@ -33,7 +33,7 @@
 class LabelRendererBase
 {
 public:
-    LabelRendererBase(Renderer* renderer, SE_Renderer* serenderer);
+    LabelRendererBase(Renderer* renderer);
 
     virtual ~LabelRendererBase() {};
 

Modified: trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp	2007-03-13 13:10:38 UTC (rev 1206)
@@ -31,10 +31,10 @@
 
 
 //////////////////////////////////////////////////////////////////////////////
-LabelRendererLocal::LabelRendererLocal(Renderer* renderer, SE_Renderer* serenderer, double tileExtentOffset)
-: LabelRendererBase(renderer, serenderer),
-  m_bOverpostGroupOpen(false),
-  m_tileExtentOffset(tileExtentOffset)
+LabelRendererLocal::LabelRendererLocal(Renderer* renderer, double tileExtentOffset)
+: LabelRendererBase(renderer)
+, m_bOverpostGroupOpen(false)
+, m_tileExtentOffset(tileExtentOffset)
 {
 }
 

Modified: trunk/MgDev/Common/Stylization/LabelRendererLocal.h
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRendererLocal.h	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/LabelRendererLocal.h	2007-03-13 13:10:38 UTC (rev 1206)
@@ -91,7 +91,7 @@
 class LabelRendererLocal : public LabelRendererBase
 {
 public:
-    LabelRendererLocal(Renderer* renderer, SE_Renderer* serenderer, double tileExtentOffset);
+    LabelRendererLocal(Renderer* renderer, double tileExtentOffset);
     virtual ~LabelRendererLocal();
 
     virtual void StartLabels();

Modified: trunk/MgDev/Common/Stylization/SE_Include.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Include.h	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/SE_Include.h	2007-03-13 13:10:38 UTC (rev 1206)
@@ -413,38 +413,38 @@
 {
     SE_INLINE SE_PointStyle() : SE_Style(SE_PointStyleType) { }
 
-    SE_String orientation;
+    SE_String angleControl;
     SE_Double angle;
-    SE_Double offset[2];
+    SE_Double originOffset[2];
 };
 
 struct SE_LineStyle : public SE_Style
 {
     SE_INLINE SE_LineStyle() : SE_Style(SE_LineStyleType) { }
 
-    SE_String orientation;
-    SE_String units;
-    SE_String overlap;
-    SE_String join;
+    SE_String angleControl;
+    SE_String unitsControl;
+    SE_String vertexControl;
+//  SE_String join;
 
+    SE_Double angle;
     SE_Double startOffset;
     SE_Double endOffset;
     SE_Double repeat;
-    SE_Double angleLimit;
-    SE_Double angle;
+    SE_Double vertexAngleLimit;
 };
 
 struct SE_AreaStyle : public SE_Style
 {
     SE_INLINE SE_AreaStyle() : SE_Style(SE_AreaStyleType) { }
 
-    SE_String orientation;
-    SE_String origincontrol;
-    SE_String clipping;
+    SE_String angleControl;
+    SE_String originControl;
+    SE_String clippingControl;
 
+    SE_Double angle;
     SE_Double origin[2];
     SE_Double repeat[2];
-    SE_Double angle;
     SE_Double bufferWidth;
 };
 
@@ -492,31 +492,30 @@
 {
     SE_INLINE SE_RenderLineStyle() : SE_RenderStyle(SE_LineStyleType) { }
 
-    const wchar_t* orientation;
-    const wchar_t* units;
-    const wchar_t* overlap;
-    const wchar_t* join;
+    const wchar_t* angleControl;
+    const wchar_t* unitsControl;
+    const wchar_t* vertexControl;
+//  const wchar_t* join;
 
+    double angle;
     double startOffset;
     double endOffset;
     double repeat;
-    double angleLimit;
-    double angle;
+    double vertexAngleLimit;
 };
 
 struct SE_RenderAreaStyle : public SE_RenderStyle
 {
     SE_INLINE SE_RenderAreaStyle() : SE_RenderStyle(SE_AreaStyleType) { }
 
-    const wchar_t* origincontrol;
-    const wchar_t* orientation;
-    const wchar_t* clipping;
+    const wchar_t* angleControl;
+    const wchar_t* originControl;
+    const wchar_t* clippingControl;
 
-    unsigned int background;
+    double angle;
     double origin[2];
     double repeat[2];
-    double angle;
-    double radius;
+    double bufferWidth;
 };
 
 

Modified: trunk/MgDev/Common/Stylization/SE_Renderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2007-03-13 13:10:38 UTC (rev 1206)
@@ -128,7 +128,7 @@
                 dx_incr = cos(slope);
                 dy_incr = sin(slope);
 
-                double symrot = wcscmp(L"FromAngle", style->orientation) == 0 ? style->angle : slope;
+                double symrot = wcscmp(L"FromAngle", style->angleControl) == 0 ? style->angle : slope;
                 symxf.rotate(symrot);
                 double tx = seg[0] + dx_incr * drawpos;
                 double ty = seg[1] + dy_incr * drawpos;

Modified: trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp	2007-03-13 13:10:38 UTC (rev 1206)
@@ -58,39 +58,39 @@
 {
     SE_PointStyle* style = new SE_PointStyle();
     ParseDoubleExpression(pointUsage.GetAngle(), style->angle);
-    ParseDoubleExpression(pointUsage.GetOriginOffsetX(), style->offset[0]);
-    ParseDoubleExpression(pointUsage.GetOriginOffsetY(), style->offset[1]);
-    ParseStringExpression(pointUsage.GetAngleControl(), style->orientation);
+    ParseDoubleExpression(pointUsage.GetOriginOffsetX(), style->originOffset[0]);
+    ParseDoubleExpression(pointUsage.GetOriginOffsetY(), style->originOffset[1]);
+    ParseStringExpression(pointUsage.GetAngleControl(), style->angleControl);
     return style;
 }
 
 SE_LineStyle* SE_StyleVisitor::ProcessLineUsage(LineUsage& lineUsage)
 {
     SE_LineStyle* style = new SE_LineStyle();
+    ParseStringExpression(lineUsage.GetAngleControl(), style->angleControl);
+    ParseStringExpression(lineUsage.GetUnitsControl(), style->unitsControl);
+    ParseStringExpression(lineUsage.GetVertexControl(), style->vertexControl);
+//  ParseStringExpression(lineUsage.GetLineJoin(), style->join);
+    ParseDoubleExpression(lineUsage.GetAngle(), style->angle);
     ParseDoubleExpression(lineUsage.GetStartOffset(), style->startOffset);
     ParseDoubleExpression(lineUsage.GetEndOffset(), style->endOffset);
     ParseDoubleExpression(lineUsage.GetRepeat(), style->repeat);
-    ParseDoubleExpression(lineUsage.GetAngle(), style->angle);
-    ParseDoubleExpression(lineUsage.GetVertexAngleLimit(), style->angleLimit);
-    ParseStringExpression(lineUsage.GetUnitsControl(), style->units);
-    ParseStringExpression(lineUsage.GetAngleControl(), style->orientation);
-    ParseStringExpression(lineUsage.GetVertexControl(), style->overlap);
-    //ParseStringExpression(lineUsage.GetLineJoin(), style->join);
+    ParseDoubleExpression(lineUsage.GetVertexAngleLimit(), style->vertexAngleLimit);
     return style;
 }
 
 SE_AreaStyle* SE_StyleVisitor::ProcessAreaUsage(AreaUsage& areaUsage)
 {
     SE_AreaStyle* style = new SE_AreaStyle();
+    ParseStringExpression(areaUsage.GetAngleControl(), style->angleControl);
+    ParseStringExpression(areaUsage.GetOriginControl(), style->originControl);
+    ParseStringExpression(areaUsage.GetClippingControl(), style->clippingControl);
     ParseDoubleExpression(areaUsage.GetAngle(), style->angle);
     ParseDoubleExpression(areaUsage.GetOriginX(), style->origin[0]);
     ParseDoubleExpression(areaUsage.GetOriginY(), style->origin[1]);
     ParseDoubleExpression(areaUsage.GetRepeatX(), style->repeat[0]);
     ParseDoubleExpression(areaUsage.GetRepeatY(), style->repeat[1]);
     ParseDoubleExpression(areaUsage.GetBufferWidth(), style->bufferWidth);
-    ParseStringExpression(areaUsage.GetAngleControl(), style->orientation);
-    ParseStringExpression(areaUsage.GetClippingControl(), style->clipping);
-    ParseStringExpression(areaUsage.GetOriginControl(), style->origincontrol);
     return style;
 }
 

Modified: trunk/MgDev/Common/Stylization/StylizationEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/StylizationEngine.cpp	2007-03-13 11:40:39 UTC (rev 1205)
+++ trunk/MgDev/Common/Stylization/StylizationEngine.cpp	2007-03-13 13:10:38 UTC (rev 1206)
@@ -228,9 +228,6 @@
 {
     SE_RenderPointStyle* render = new SE_RenderPointStyle();
 
-    double offsetX = 0, offsetY = 0;
-    double rotation = 0;
-
     LineBuffer::GeomOperationType type;
 
     switch(geometry->xf_buffer()->geom_type())
@@ -252,16 +249,17 @@
         break;
     }
 
-    const wchar_t* orientation = style->orientation.evaluate(m_exec);
-    if (wcscmp(L"FromGeometry", orientation) == 0)
+    double rotation = 0.0;
+    const wchar_t* angleControl = style->angleControl.evaluate(m_exec);
+    if (wcscmp(L"FromGeometry", angleControl) == 0)
     {
         if (type == LineBuffer::ctLine || type == LineBuffer::ctArea)
         {
             double x0, x1, y0, y1;
             geometry->LongestEdge(geometry->xf_buffer(), x0, y0, x1, y1);
             rotation = atan2(y1 - y0, x1 - x0); //TODO: this is probably affected by which way y goes in the renderer (yUp or yDown)
-            if (rotation < 0)
-                rotation += 2*M_PI;
+            if (rotation < 0.0)
+                rotation += 2.0*M_PI;
         }
         else
             rotation = 0.0;
@@ -269,11 +267,11 @@
     else
         rotation = style->angle.evaluate(m_exec)*M_PI/180.0;
 
+    double originOffsetX = style->originOffset[0].evaluate(m_exec)*mm2px;
+    double originOffsetY = style->originOffset[1].evaluate(m_exec)*mm2px;
+
     SE_Matrix sxform;
-
-    offsetX = style->offset[0].evaluate(m_exec)*mm2px;
-    offsetY = style->offset[1].evaluate(m_exec)*mm2px;
-    sxform.translate(offsetX, offsetY);
+    sxform.translate(originOffsetX, originOffsetY);
     sxform.rotate(rotation);
     sxform.premultiply(xform);
     xform = sxform;
@@ -285,15 +283,17 @@
 {
     SE_RenderLineStyle* render = new SE_RenderLineStyle();
 
-    render->angle = style->angle.evaluate(m_exec)*(M_PI/180.0);
-    render->angleLimit = style->angleLimit.evaluate(m_exec)*(M_PI/180.0);
-    render->endOffset = style->endOffset.evaluate(m_exec)*xform.x0; // x0 is x scale * mm2px
+    double angle = style->angle.evaluate(m_exec)*(M_PI/180.0);
+    render->angle = m_renderer->GetFontEngine()->_Yup()? angle : -angle;
+    render->startOffset = style->startOffset.evaluate(m_exec)*xform.x0; // x0 is x scale * mm2px
+    render->endOffset = style->endOffset.evaluate(m_exec)*xform.x0;
     render->repeat = style->repeat.evaluate(m_exec)*xform.x0;
-    render->startOffset = style->startOffset.evaluate(m_exec)*xform.x0;
+    render->vertexAngleLimit = style->vertexAngleLimit.evaluate(m_exec)*(M_PI/180.0);
 
-    render->units = style->units.evaluate(m_exec);
-    render->orientation = style->orientation.evaluate(m_exec);
-    render->overlap = style->overlap.evaluate(m_exec);
+    render->angleControl = style->angleControl.evaluate(m_exec);
+    render->unitsControl = style->unitsControl.evaluate(m_exec);
+    render->vertexControl = style->vertexControl.evaluate(m_exec);
+//  render->join = style->join.evaluate(m_exec);
 
     return render;
 }
@@ -302,10 +302,18 @@
 {
     SE_RenderAreaStyle* render = new SE_RenderAreaStyle();
 
-    render->orientation = style->orientation.evaluate(m_exec);
-    render->clipping = style->clipping.evaluate(m_exec);
-    render->origincontrol = style->origincontrol.evaluate(m_exec);
+    double angle = style->angle.evaluate(m_exec)*(M_PI/180.0);
+    render->angle = m_renderer->GetFontEngine()->_Yup()? angle : -angle;
+    render->origin[0] = style->origin[0].evaluate(m_exec);
+    render->origin[1] = style->origin[1].evaluate(m_exec);
+    render->repeat[0] = style->repeat[0].evaluate(m_exec);
+    render->repeat[1] = style->repeat[1].evaluate(m_exec);
+    render->bufferWidth = style->bufferWidth.evaluate(m_exec);
 
+    render->angleControl = style->angleControl.evaluate(m_exec);
+    render->originControl = style->originControl.evaluate(m_exec);
+    render->clippingControl = style->clippingControl.evaluate(m_exec);
+
     return render;
 }
 
@@ -368,10 +376,12 @@
                 rt->position[1] = t->position[1].evaluate(m_exec)*mm2px;//TODO: take into account y-up or y-down!
                 xform.transform(rt->position[0], rt->position[1]);
 
-                rt->tdef.font().name() =  t->fontExpr.evaluate(m_exec);
+                rt->tdef.font().name() = t->fontExpr.evaluate(m_exec);
                 rt->tdef.font().height() = t->size.evaluate(m_exec)*0.001*xform.y1/mm2px; //convert mm to meters which is what RS_TextDef expects
                 rt->tdef.linespace() = t->lineSpacing.evaluate(m_exec);
                 rt->tdef.rotation() = t->angle.evaluate(m_exec);
+                if (!m_renderer->GetFontEngine()->_Yup())
+                    rt->tdef.rotation() = -rt->tdef.rotation();
 
                 int style = RS_FontStyle_Regular;
 



More information about the mapguide-commits mailing list