[mapguide-commits] r1207 - trunk/MgDev/Common/Stylization
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Mar 13 10:06:09 EDT 2007
Author: waltweltonlair
Date: 2007-03-13 10:06:09 -0400 (Tue, 13 Mar 2007)
New Revision: 1207
Modified:
trunk/MgDev/Common/Stylization/DWFRenderer.cpp
trunk/MgDev/Common/Stylization/GDRenderer.cpp
trunk/MgDev/Common/Stylization/GDW2DRewriter.cpp
trunk/MgDev/Common/Stylization/GeometryAdapter.cpp
trunk/MgDev/Common/Stylization/LabelRenderer.cpp
trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp
trunk/MgDev/Common/Stylization/PointAdapter.cpp
trunk/MgDev/Common/Stylization/RS_FontEngine.cpp
trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp
trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp
trunk/MgDev/Common/Stylization/SE_Renderer.cpp
trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp
trunk/MgDev/Common/Stylization/SLDSymbols.h
trunk/MgDev/Common/Stylization/StylizationEngine.cpp
trunk/MgDev/Common/Stylization/stdafx.h
Log:
- Added a #define for M_PI / 180.0 and updated stylization code to use this
- Removed unnecessary includes of <math.h> and <float.h>
- Removed unnecessary #defines of _USE_MATH_DEFINES
Modified: trunk/MgDev/Common/Stylization/DWFRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/DWFRenderer.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/DWFRenderer.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -769,7 +769,7 @@
}
//default symbol
- double angle = mdef.rotation() * M_PI / 180.0;
+ double angle = mdef.rotation() * M_PI180;
//default bounds of symbol data in W2D
//for symbols created by MapGuide Studio
@@ -1428,7 +1428,7 @@
WT_Integer32 line_hgt_y = (WT_Integer32)line_hgt;
if (tdef.rotation() != 0.0)
{
- double angle = tdef.rotation() * M_PI / 180.0;
+ double angle = tdef.rotation() * M_PI180;
line_hgt_x = (WT_Integer32)(-line_hgt * sin(angle));
line_hgt_y = (WT_Integer32)( line_hgt * cos(angle));
}
Modified: trunk/MgDev/Common/Stylization/GDRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/GDRenderer.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/GDRenderer.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -603,7 +603,7 @@
double refY = mdef.insy();
//rotation angle
- double angle = mdef.rotation() * M_PI / 180.0;
+ double angle = mdef.rotation() * M_PI180;
if (!symbol && is_font_symbol)
{
Modified: trunk/MgDev/Common/Stylization/GDW2DRewriter.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/GDW2DRewriter.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/GDW2DRewriter.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -371,7 +371,7 @@
0, 0, //srcX, srcY
resized ? resized->sx : src->sx,
resized ? resized->sx : src->sy, //srcW, srcH
- (int)(-angle * 180.0 / M_PI)
+ (int)(-angle / M_PI180)
);
if (resized)
@@ -711,7 +711,7 @@
0, 0, //srcX, srcY
resized ? resized->sx : src->sx,
resized ? resized->sx : src->sy, //srcW, srcH
- (int)(-angle * 180.0 / M_PI)
+ (int)(-angle / M_PI180)
);
if (resized)
@@ -824,7 +824,7 @@
//rescale font height
double hgt = 0.75 * rewriter->ScaleW2DNumber(file, font.height().height());
- double rot = (double)font.rotation().rotation() * 2 * M_PI / 65536.;
+ double rot = (double)font.rotation().rotation() * 2.0 * M_PI / 65536.0;
//match the font
int style = RS_FontStyle_Regular;
Modified: trunk/MgDev/Common/Stylization/GeometryAdapter.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/GeometryAdapter.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/GeometryAdapter.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -22,10 +22,7 @@
#include "SymbolVisitor.h"
#include "SLDSymbols.h"
-#define _USE_MATH_DEFINES //for M_PI
-#include <math.h>
-
GeometryAdapter::GeometryAdapter(LineBufferPool* lbp)
{
m_exec = NULL;
@@ -653,7 +650,7 @@
ConvertTextDef(text, def);
if (useSlope)
- def.rotation() = atan(slope) * 180.0 / M_PI;
+ def.rotation() = atan(slope) / M_PI180;
std::wstring txt;
/*bool const1 =*/ EvalString(text->GetText(), txt);
Modified: trunk/MgDev/Common/Stylization/LabelRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRenderer.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/LabelRenderer.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -26,7 +26,6 @@
#include "SE_Renderer.h"
#include "RS_FontEngine.h"
-#define M_PI 3.14159265358979323846
#define ROUND(x) (int)((x) + 0.5)
//#define DEBUG_LABELS
@@ -394,7 +393,7 @@
fe->GetTextMetrics(info.m_text, info.m_tdef, tm, false);
//radian CCW rotation
- double rotation = info.m_tdef.rotation() * M_PI / 180.0;
+ double rotation = info.m_tdef.rotation() * M_PI180;
double cos_a = cos(rotation);
double sin_a = sin(rotation);
Modified: trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -23,7 +23,6 @@
#include "Centroid.h"
#include "RS_Font.h"
-#define M_PI 3.14159265358979323846
#define ROUND(x) (int)((x) + 0.5)
//#define DEBUG_LABELS
@@ -753,7 +752,7 @@
return false;
//radian CCW rotation
- double rotation = info.m_tdef.rotation() * M_PI / 180.0;
+ double rotation = info.m_tdef.rotation() * M_PI180;
double cos_a = cos(rotation);
double sin_a = sin(rotation);
Modified: trunk/MgDev/Common/Stylization/PointAdapter.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/PointAdapter.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/PointAdapter.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -223,7 +223,7 @@
//due to the rotation
if (mdefRot != 0.0)
{
- double rotRad = mdefRot * M_PI / 180.0;
+ double rotRad = mdefRot * M_PI180;
double cs = cos(rotRad);
double sn = sin(rotRad);
Modified: trunk/MgDev/Common/Stylization/RS_FontEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/RS_FontEngine.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/RS_FontEngine.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -486,7 +486,7 @@
void RS_FontEngine::DrawBlockText(RS_TextMetrics& tm, RS_TextDef& tdef, double insx, double insy)
{
//radian CCW rotation
- double rotation = tdef.rotation() * M_PI / 180.0;
+ double rotation = tdef.rotation() * M_PI180;
double cos_a = cos(rotation);
double sin_a = sin(rotation);
Modified: trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -15,14 +15,11 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
+#include "stdafx.h"
#include "SE_LineBuffer.h"
#include "SE_ConvexHull.h"
#include "SE_Bounds.h"
-#define _USE_MATH_DEFINES
-#include <math.h>
-#include <float.h>
-
#define GROWTH_FACTOR 1.5
#define ENSURE_POINT_BUFFER(points) \
Modified: trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -33,7 +33,7 @@
RS_F_Point fpts[4];
//radian CCW rotation
- double rotation = txt->tdef.rotation() * M_PI / 180.0;
+ double rotation = txt->tdef.rotation() * M_PI180;
double cos_a = cos(rotation);
double sin_a = sin(rotation);
@@ -143,7 +143,7 @@
double symbol_width = fpts[1].x - fpts[0].x; //symbol width in meters
double symbol_height = fpts[2].y - fpts[1].y; //symbol height in meters
- double symbol_rot_deg = box_angle_rad * (180.0 / M_PI);
+ double symbol_rot_deg = box_angle_rad / M_PI180;
double op_pts[16];
@@ -175,7 +175,7 @@
//due to the rotation
if (symbol_rot_deg != 0.0)
{
- double rotRad = symbol_rot_deg * (M_PI/180.); //symbol_rot assumed to be in radians
+ double rotRad = symbol_rot_deg * M_PI180; //symbol_rot assumed to be in radians
double cs = cos(rotRad);
double sn = sin(rotRad);
Modified: trunk/MgDev/Common/Stylization/SE_Renderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_Renderer.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/SE_Renderer.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -209,13 +209,13 @@
tdef.color() = m_textForeColor;
tdef.bgcolor() = m_textBackColor;
if (anglerad != 0)
- tdef.rotation() = anglerad * (180 / M_PI);
+ tdef.rotation() = anglerad / M_PI180;
DrawScreenText(tp->text, tdef, x, y, NULL, 0, 0.0);
}
else if (anglerad != 0.0)
{
RS_TextDef tdef = tp->tdef;
- tdef.rotation() = anglerad * (180.0 / M_PI);
+ tdef.rotation() = anglerad / M_PI180;
DrawScreenText(tp->text, tdef, x, y, NULL, 0, 0.0);
}
else
@@ -230,7 +230,7 @@
double x, y;
posxform.transform(rp->position[0], rp->position[1], x, y);
- DrawScreenRaster(rp->pngPtr, rp->pngSize, RS_ImageFormat_PNG, -1, -1, x, y, rp->extent[0], rp->extent[1], anglerad * (180 / M_PI));
+ 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/SE_StyleVisitor.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -21,8 +21,6 @@
#include "SE_SymbolManager.h"
#include "SE_LineBuffer.h"
-#define _USE_MATH_DEFINES
-#include <math.h>
#include <wctype.h>
using namespace MDFMODEL_NAMESPACE;
@@ -211,7 +209,7 @@
ly = y;
}
- if (rx == 0 || ry == 0)
+ if (rx == 0.0 || ry == 0.0)
{
lb->LineTo(lx, ly);
break;
@@ -256,7 +254,7 @@
if (def.rotation != 0.0)
{
- rotrad = def.rotation*M_PI/180.0;
+ rotrad = def.rotation * M_PI180;
/* Derotate the points, so we can handle only the axis-oriented case */
double sine = sin(-rotrad);
double cosine = cos(-rotrad);
@@ -285,7 +283,7 @@
(x1 - cx)^2/a^2 + (y1 - cy)^2/b^2 = 1}
verified with Mathematica. */
- double a = 2*(ry2*dx2 + rx2*dy2);
+ double a = 2.0*(ry2*dx2 + rx2*dy2);
double ay = rx2*a;
double ax = ry2*dx*a;
double sq = sqrt(rxy2*dx2*(-ry4*dx2*dx2 + 2*rxy2*dx2*(2*ry2 - dy2) - rx2*rx2*dy2*(-4*ry2 + dy2)));
@@ -296,7 +294,7 @@
double cx0, cx1, cy0, cy1;
- if (ax == 0)
+ if (ax == 0.0)
{
//x0 equal to x1 -- vertical chord
cx0 = x0;
@@ -308,7 +306,7 @@
cx1 = (mbx - sqx)/ax;
}
- if (ay == 0)
+ if (ay == 0.0)
{
//this means that y0 and y1 were equal so chord is horizontal
cy0 = y0;
@@ -321,11 +319,11 @@
}
double sAng = atan2(y0-cy0, x0-cx0);
- if (sAng < 0)
- sAng += 2*M_PI;
+ if (sAng < 0.0)
+ sAng += 2.0*M_PI;
double eAng = atan2(y1-cy0, x1-cx0);
- if (eAng < 0)
- eAng += 2*M_PI;
+ if (eAng < 0.0)
+ eAng += 2.0*M_PI;
/* TODO: scale radii until properly specified instead of failing */
if (!_finite(cx0) || _isnan(cx0) ||
@@ -341,11 +339,11 @@
{
cx = cx1, cy = cy1;
sAng = atan2(y0-cy0, x0-cx1);
- if (sAng < 0)
- sAng += 2*M_PI;
+ if (sAng < 0.0)
+ sAng += 2.0*M_PI;
eAng = atan2(y1-cy1, x1-cx1);
- if (eAng < 0)
- eAng += 2*M_PI;
+ if (eAng < 0.0)
+ eAng += 2.0*M_PI;
}
if (def.clockwise)
@@ -356,9 +354,9 @@
}
if (eAng < sAng)
- eAng += 2*M_PI;
+ eAng += 2.0*M_PI;
- if (def.rotation != 0)
+ if (def.rotation != 0.0)
{
/* Rerotate the center */
double tcx = cx, tcy = cy;
Modified: trunk/MgDev/Common/Stylization/SLDSymbols.h
===================================================================
--- trunk/MgDev/Common/Stylization/SLDSymbols.h 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/SLDSymbols.h 2007-03-13 14:06:09 UTC (rev 1207)
@@ -46,22 +46,22 @@
//////////////////////////////////////////////
-static const double sq34 = 0.5 - 0.25 * sqrt(3.);
+static const double sq34 = 0.5 - 0.25 * sqrt(3.0);
//equilateral triangle
static const double SLD_TRIANGLE[] = {
- 0., sq34,
- 1., sq34,
- 0.5, 1. - sq34,
- 0., sq34
+ 0.0, sq34,
+ 1.0, sq34,
+ 0.5, 1.0 - sq34,
+ 0.0, sq34
};
//////////////////////////////////////////////
-static const double cos36 = cos(36. * M_PI / 180.);
-static const double cos18 = cos(18. * M_PI / 180.);
-static const double sin36 = sin(36. * M_PI / 180.);
-static const double plen = 1. - 0.5 / cos36; //length of the side of star point edge
+static const double cos36 = cos(36.0 * M_PI / 180.0);
+static const double cos18 = cos(18.0 * M_PI / 180.0);
+static const double sin36 = sin(36.0 * M_PI / 180.0);
+static const double plen = 1.0 - 0.5 / cos36; //length of the side of star point edge
//star (pentagonal)
// CCW list order
@@ -73,66 +73,68 @@
// 0 2
static const double SLD_STAR[] = {
- 1. - cos36, 0.5 - 0.5 * cos18,
- 1. - cos36 + plen * cos36, 0.5 - 0.5 * cos18 + plen * sin36,
+ 1.0 - cos36, 0.5 - 0.5 * cos18,
+ 1.0 - cos36 + plen * cos36, 0.5 - 0.5 * cos18 + plen * sin36,
cos36, 0.5 - 0.5 * cos18,
- 1. - plen * cos36, sin36 - plen * sin36,
- 1., sin36,
- 1. - plen, sin36,
+ 1.0 - plen * cos36, sin36 - plen * sin36,
+ 1.0, sin36,
+ 1.0 - plen, sin36,
0.5, 0.5 + 0.5 * cos18,
plen, sin36,
- 0., sin36,
+ 0.0, sin36,
plen * cos36, sin36 - plen * sin36,
- 1. - cos36, 0.5 - 0.5 * cos18
+ 1.0 - cos36, 0.5 - 0.5 * cos18
};
+
//////////////////////////////////////////////
//constant to derive a thickness for the plus
static const double phi = 1.6180339887498948482045868343656; //Golden ratio
-static const double t = 0.5 / (2. * (phi + 1.));
+static const double t = 0.5 / (2.0 * (phi + 1.0));
//cross (looks like plus sign)
static const double SLD_CROSS[] = {
- 0.5 - t, 0.,
- 0.5 + t, 0.,
+ 0.5 - t, 0.0,
+ 0.5 + t, 0.0,
0.5 + t, 0.5 - t,
- 1., 0.5 - t,
- 1., 0.5 + t,
+ 1.0, 0.5 - t,
+ 1.0, 0.5 + t,
0.5 + t, 0.5 + t,
- 0.5 + t, 1.,
- 0.5 - t, 1.,
+ 0.5 + t, 1.0,
+ 0.5 - t, 1.0,
0.5 - t, 0.5 + t,
- 0., 0.5 + t,
- 0., 0.5 - t,
+ 0.0, 0.5 + t,
+ 0.0, 0.5 - t,
0.5 - t, 0.5 - t,
- 0.5 - t, 0.
+ 0.5 - t, 0.0
};
//////////////////////////////////////////////
-static const double t2 = 2. * t / sqrt(2.);
+static const double t2 = 2.0 * t / sqrt(2.0);
static const double SLD_X[] = {
- t2, 0.,
+ t2, 0.0,
0.5, 0.5 - t2,
- 1. - t2, 0.,
- 1., t2,
+ 1.0 - t2, 0.0,
+ 1.0, t2,
0.5 + t2, 0.5,
- 1., 1. - t2,
- 1. - t2, 1.,
+ 1.0, 1.0 - t2,
+ 1.0 - t2, 1.0,
0.5, 0.5 + t2,
- t2, 1.,
- 0., 1. - t2,
+ t2, 1.0,
+ 0.0, 1.0 - t2,
0.5 - t2, 0.5,
- 0., t2,
- t2, 0.
+ 0.0, t2,
+ t2, 0.0
};
+
//////////////////////////////////////////////
-static const double incr = M_PI / 10.;
+static const double incr = M_PI / 10.0;
#define circpt(x) 0.5 + 0.5 * cos(x * incr), 0.5 + 0.5 * sin(x * incr)
//circle, approximated by 20-gon
@@ -148,17 +150,17 @@
//////////////////////////////////////////////
-//simle x symbol for use in error conditions
+//simple x symbol for use in error conditions
static const double SLD_ERROR[] = {
- 0., 0.,
- 1., 0.,
- 1., 1.,
- 0., 0.,
- 0., 1.,
- 1., 1.,
- 1., 0.,
- 0., 1.
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 0.0, 0.0,
+ 0.0, 1.0,
+ 1.0, 1.0,
+ 1.0, 0.0,
+ 0.0, 1.0
};
#endif
Modified: trunk/MgDev/Common/Stylization/StylizationEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/StylizationEngine.cpp 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/StylizationEngine.cpp 2007-03-13 14:06:09 UTC (rev 1207)
@@ -107,7 +107,6 @@
}
SE_Rule* rule = NULL;
-
for (int i = 0; i < nRules; i++)
{
bool match = (rules[i].filter == NULL);
@@ -229,7 +228,6 @@
SE_RenderPointStyle* render = new SE_RenderPointStyle();
LineBuffer::GeomOperationType type;
-
switch(geometry->xf_buffer()->geom_type())
{
case FdoGeometryType_LineString:
@@ -249,7 +247,7 @@
break;
}
- double rotation = 0.0;
+ double angle = 0.0;
const wchar_t* angleControl = style->angleControl.evaluate(m_exec);
if (wcscmp(L"FromGeometry", angleControl) == 0)
{
@@ -257,22 +255,18 @@
{
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.0)
- rotation += 2.0*M_PI;
+ angle = atan2(y1 - y0, x1 - x0);
}
- else
- rotation = 0.0;
}
else
- rotation = style->angle.evaluate(m_exec)*M_PI/180.0;
+ angle = style->angle.evaluate(m_exec) * M_PI180;
double originOffsetX = style->originOffset[0].evaluate(m_exec)*mm2px;
double originOffsetY = style->originOffset[1].evaluate(m_exec)*mm2px;
SE_Matrix sxform;
sxform.translate(originOffsetX, originOffsetY);
- sxform.rotate(rotation);
+ sxform.rotate(m_renderer->GetFontEngine()->_Yup()? angle : -angle);
sxform.premultiply(xform);
xform = sxform;
@@ -283,12 +277,12 @@
{
SE_RenderLineStyle* render = new SE_RenderLineStyle();
- double angle = style->angle.evaluate(m_exec)*(M_PI/180.0);
+ 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_PI/180.0);
+ render->vertexAngleLimit = style->vertexAngleLimit.evaluate(m_exec) * M_PI180;
render->angleControl = style->angleControl.evaluate(m_exec);
render->unitsControl = style->unitsControl.evaluate(m_exec);
@@ -302,7 +296,7 @@
{
SE_RenderAreaStyle* render = new SE_RenderAreaStyle();
- double angle = style->angle.evaluate(m_exec)*(M_PI/180.0);
+ double angle = style->angle.evaluate(m_exec) * M_PI180;
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);
@@ -348,6 +342,7 @@
case SE_PolygonPrimitive:
rsym = new SE_RenderPolygon();
((SE_RenderPolygon*)rsym)->fill = ((SE_Polygon*)sym)->fill.evaluate(m_exec);
+
case SE_PolylinePrimitive:
{
if (!rsym) rsym = new SE_RenderPolyline();
@@ -366,6 +361,7 @@
rp->bounds = NULL;
}
break;
+
case SE_TextPrimitive:
{
rsym = new SE_RenderText();
@@ -373,23 +369,21 @@
SE_RenderText* rt = (SE_RenderText*)rsym;
rt->text = t->textExpr.evaluate(m_exec);
rt->position[0] = t->position[0].evaluate(m_exec)*mm2px;
- rt->position[1] = t->position[1].evaluate(m_exec)*mm2px;//TODO: take into account y-up or y-down!
+ rt->position[1] = t->position[1].evaluate(m_exec)*mm2px;
xform.transform(rt->position[0], rt->position[1]);
- 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();
+ double angle = t->angle.evaluate(m_exec);
+ rt->tdef.rotation() = m_renderer->GetFontEngine()->_Yup()? angle : -angle;
int style = RS_FontStyle_Regular;
-
if (t->underlined.evaluate(m_exec)) style |= (int)RS_FontStyle_Underline;
if (t->italic.evaluate(m_exec)) style |= (int)RS_FontStyle_Italic;
if (t->bold.evaluate(m_exec)) style |= (int)RS_FontStyle_Bold;
rt->tdef.font().style() = (RS_FontStyle_Mask)style;
+ 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.color() = RS_Color::FromARGB(t->textColor.evaluate(m_exec));
rt->tdef.bgcolor() = RS_Color::FromARGB(t->ghostColor.evaluate(m_exec));
@@ -423,7 +417,7 @@
RS_TextMetrics tm;
SE_Matrix txf;
m_renderer->GetFontEngine()->GetTextMetrics(rt->text, rt->tdef, tm, false);
- txf.rotate(rt->tdef.rotation()*M_PI/180.0);
+ txf.rotate(rt->tdef.rotation() * M_PI180);
txf.translate(rt->position[0], rt->position[1]);
double* buffer = (double*)alloca(tm.line_pos.size()*sizeof(double)*8);
@@ -445,6 +439,7 @@
(int)tm.line_pos.size()*4, m_pool);
}
break;
+
case SE_RasterPrimitive:
{
rsym = new SE_RenderRaster();
@@ -466,29 +461,31 @@
xform.transform(rr->position[0], rr->position[1]);
rr->extent[0] = r->extent[0].evaluate(m_exec)*xform.x0;
rr->extent[1] = r->extent[1].evaluate(m_exec)*xform.y1;
- rr->angle = r->angle.evaluate(m_exec)*(M_PI/180.0);
+ rr->angle = r->angle.evaluate(m_exec) * M_PI180;
rr->bounds = m_pool->NewBounds(5);
SE_Matrix rxf;
rxf.rotate(rr->angle);
rxf.translate(rr->position[0], rr->position[1]);
- double w = rr->extent[0]/2.0;
- double h = rr->extent[1]/2.0;
+ double w = 0.5 * rr->extent[0];
+ double h = 0.5 * rr->extent[1];
double sx, sy, x, y;
rxf.transform(w, h, sx, sy); // upper right
rr->bounds->Add(sx, sy);
- rxf.transform(w, -h, x, y); // lower right
+ rxf.transform(w, -h, x, y); // lower right
rr->bounds->Add(x, y);
rxf.transform(-w, -h, x, y); // lower left
rr->bounds->Add(x, y);
- rxf.transform(-w, h, x, y); // upper left
+ rxf.transform(-w, h, x, y); // upper left
rr->bounds->Add(x, y);
- rr->bounds->Add(sx, sy); // upper right
+ rr->bounds->Add(sx, sy); // upper right
}
break;
- default: break;
+
+ default:
+ break;
}
if (rsym)
@@ -521,9 +518,11 @@
case ResizeBox::GrowInX:
growy = 0.0;
break;
+
case ResizeBox::GrowInY:
growx = 0.0;
break;
+
case ResizeBox::GrowInXYMaintainAspect:
if (growy > growx)
growx = growy;
@@ -595,15 +594,12 @@
}
//else if (style->positioningAlgorithm == MultipleHighwayShields)
//{
-
//}
-
}
//clears cached filters/styles/etc
void StylizationEngine::ClearCache()
{
-
std::map<CompositeTypeStyle*, SE_Rule*>::iterator iter = m_rules.begin();
for (; iter != m_rules.end(); iter++)
Modified: trunk/MgDev/Common/Stylization/stdafx.h
===================================================================
--- trunk/MgDev/Common/Stylization/stdafx.h 2007-03-13 13:10:38 UTC (rev 1206)
+++ trunk/MgDev/Common/Stylization/stdafx.h 2007-03-13 14:06:09 UTC (rev 1207)
@@ -45,6 +45,8 @@
#include <math.h>
#include <limits>
+#define M_PI180 0.0174532925199432957692
+
// Stylization DLL export headers
#include "Stylization.h"
More information about the mapguide-commits
mailing list