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

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Mar 13 17:10:16 EDT 2007


Author: waltweltonlair
Date: 2007-03-13 17:10:16 -0400 (Tue, 13 Mar 2007)
New Revision: 1213

Modified:
   trunk/MgDev/Common/Stylization/RS_FontEngine.cpp
   trunk/MgDev/Common/Stylization/SE_Renderer.cpp
   trunk/MgDev/Common/Stylization/StylizationEngine.cpp
Log:
Removed calls in StylizationEngine which check for y up/down.  These checks
should happen further down.


Modified: trunk/MgDev/Common/Stylization/RS_FontEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/RS_FontEngine.cpp	2007-03-13 20:05:53 UTC (rev 1212)
+++ trunk/MgDev/Common/Stylization/RS_FontEngine.cpp	2007-03-13 21:10:16 UTC (rev 1213)
@@ -87,7 +87,7 @@
         float* spacing = (float*)alloca(len * 2 * sizeof(float));
         MeasureString(s, hgt, font, 0.0, fpts, spacing);
         ret.char_advances.reserve(len);
-        for (int i=0; i<len; i++)
+        for (size_t i=0; i<len; i++)
             ret.char_advances.push_back(spacing[i]);
         ret.text_width = fabs(fpts[1].x - fpts[0].x);
         ret.text_height = fabs(fpts[2].y - fpts[0].y);
@@ -116,7 +116,7 @@
         if (num_lines > 1)
         {
             ret.line_breaks.reserve(num_lines);
-            for (int i=0; i<num_lines; i++)
+            for (size_t i=0; i<num_lines; i++)
                 ret.line_breaks.push_back(line_breaks[i]);
         }
 
@@ -450,7 +450,6 @@
 
         //and now find a lower left insertion point
         //based on the midpoint anchor and the angle
-        CharPos pos;
         tm.char_pos[i].x = positions[2*i+1].x - cos(anglerad) * char_width_2;
         tm.char_pos[i].y = positions[2*i+1].y + sin(anglerad) * char_width_2; //y down means + sin
         tm.char_pos[i].anglerad = anglerad;
@@ -469,7 +468,7 @@
 
     //apply vertical alignment to character position
     //horizontal alignment is ignored in this case
-    for (size_t i=0; i<numchars; i++)
+    for (int i=0; i<numchars; i++)
     {
         // add in the rotated vertical alignment contribution
         double angle = tm.char_pos[i].anglerad;
@@ -485,19 +484,18 @@
 //////////////////////////////////////////////////////////////////////////////
 void RS_FontEngine::DrawBlockText(RS_TextMetrics& tm, RS_TextDef& tdef, double insx, double insy)
 {
-    //radian CCW rotation
+    // positive rotation in the RS_TextDef is assumed to always be a radian CCW rotation...
     double rotation = tdef.rotation() * M_PI180;
 
     double cos_a = cos(rotation);
     double sin_a = sin(rotation);
-
     if (m_bYup)
         sin_a = -sin_a;
 
     // get the overall unrotated bounds
     RS_Bounds b(DBL_MAX, DBL_MAX, -DBL_MAX, -DBL_MAX);
 
-    for (int i=0; i<tm.line_pos.size(); i++)
+    for (size_t i=0; i<tm.line_pos.size(); i++)
     {
         b.add_point(tm.line_pos[i].ext[0]);
         b.add_point(tm.line_pos[i].ext[2]);
@@ -595,7 +593,7 @@
 //array, which were previously computed by LayoutPathText
 void RS_FontEngine::DrawPathText(RS_TextMetrics& tm, RS_TextDef& tdef)
 {
-    int numchars = tm.text.length();
+    size_t numchars = tm.text.length();
 
     //draw the characters, each in its computed position
     RS_String c;

Modified: trunk/MgDev/Common/Stylization/SE_Renderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2007-03-13 20:05:53 UTC (rev 1212)
+++ trunk/MgDev/Common/Stylization/SE_Renderer.cpp	2007-03-13 21:10:16 UTC (rev 1213)
@@ -89,6 +89,8 @@
     //convert increment to pixels
     double increment = style->repeat; //TODO: is this already scaled by the mm to pixel scale?
 
+    bool fromAngle = (wcscmp(L"FromAngle", style->angleControl) == 0);
+
     for (int j=0; j<geometry->cntr_count(); j++)
     {
         //current polyline
@@ -121,17 +123,15 @@
                 //compute linear deltas for x and y directions
                 // -- we will use these to quickly move along the line
                 //without having to do too much math
-                double dx_incr, dy_incr;
-                double slope;
+                double slope = atan2(dy, dx);
+                double dx_incr = cos(slope);
+                double dy_incr = sin(slope);
 
-                slope = atan2(dy, dx);
-                dx_incr = cos(slope);
-                dy_incr = sin(slope);
+                double symrot = fromAngle? style->angle : slope;
+                double tx = seg[0] + dx_incr * drawpos;
+                double ty = seg[1] + dy_incr * drawpos;
 
-                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;
                 symxf.translate(tx, ty);
                 dx_incr *= increment;
                 dy_incr *= increment;
@@ -232,7 +232,7 @@
 
             DrawScreenRaster(rp->pngPtr, rp->pngSize, RS_ImageFormat_PNG, -1, -1, x, y, rp->extent[0], rp->extent[1], anglerad / M_PI180);
         }
-     }
+    }
 }
 
 

Modified: trunk/MgDev/Common/Stylization/StylizationEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/StylizationEngine.cpp	2007-03-13 20:05:53 UTC (rev 1212)
+++ trunk/MgDev/Common/Stylization/StylizationEngine.cpp	2007-03-13 21:10:16 UTC (rev 1213)
@@ -166,7 +166,7 @@
         {
             SE_Style* style = *siter;
 
-            SE_Matrix tmpxform(xform); //TODO: this is lame, but necessary since the xform can be modified
+            SE_Matrix tmpxform(xform);  //TODO: this is lame, but necessary since the xform can be modified
                                         //when we evalute the style, in the case of point style set on a
                                         //non-point geometry
 
@@ -266,7 +266,7 @@
 
     SE_Matrix sxform;
     sxform.translate(originOffsetX, originOffsetY);
-    sxform.rotate(m_renderer->GetFontEngine()->_Yup()? angle : -angle);
+    sxform.rotate(angle);
     sxform.premultiply(xform);
     xform = sxform;
 
@@ -277,18 +277,17 @@
 {
     SE_RenderLineStyle* render = new SE_RenderLineStyle();
 
-    double angle = style->angle.evaluate(m_exec) * M_PI180;
-    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->vertexAngleLimit = style->vertexAngleLimit.evaluate(m_exec) * M_PI180;
-
     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);
 
+    render->angle = style->angle.evaluate(m_exec) * M_PI180;
+    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->vertexAngleLimit = style->vertexAngleLimit.evaluate(m_exec) * M_PI180;
+
     return render;
 }
 
@@ -296,18 +295,17 @@
 {
     SE_RenderAreaStyle* render = new SE_RenderAreaStyle();
 
-    double angle = style->angle.evaluate(m_exec) * M_PI180;
-    render->angle = m_renderer->GetFontEngine()->_Yup()? angle : -angle;
+    render->angleControl = style->angleControl.evaluate(m_exec);
+    render->originControl = style->originControl.evaluate(m_exec);
+    render->clippingControl = style->clippingControl.evaluate(m_exec);
+
+    render->angle = style->angle.evaluate(m_exec) * M_PI180;
     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;
 }
 
@@ -375,8 +373,7 @@
                 rt->position[1] = t->position[1].evaluate(m_exec)*mm2px;
                 xform.transform(rt->position[0], rt->position[1]);
 
-                double angle = t->angle.evaluate(m_exec);
-                rt->tdef.rotation() = m_renderer->GetFontEngine()->_Yup()? angle : -angle;
+                rt->tdef.rotation() = t->angle.evaluate(m_exec);;
 
                 int style = RS_FontStyle_Regular;
                 if (t->underlined.evaluate(m_exec)) style |= (int)RS_FontStyle_Underline;



More information about the mapguide-commits mailing list