[mapguide-commits] r1223 - trunk/MgDev/Common/Stylization
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Mar 14 14:00:44 EDT 2007
Author: waltweltonlair
Date: 2007-03-14 14:00:44 -0400 (Wed, 14 Mar 2007)
New Revision: 1223
Modified:
trunk/MgDev/Common/Stylization/GDUtils.cpp
trunk/MgDev/Common/Stylization/LabelRenderer.cpp
trunk/MgDev/Common/Stylization/LabelRenderer.h
trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp
trunk/MgDev/Common/Stylization/LabelRendererLocal.h
trunk/MgDev/Common/Stylization/LineBuffer.cpp
trunk/MgDev/Common/Stylization/LineBuffer.h
trunk/MgDev/Common/Stylization/RSBufferOutputStream.h
trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp
trunk/MgDev/Common/Stylization/SE_LineBuffer.h
trunk/MgDev/Common/Stylization/stdafx.h
Log:
Updated LabelRendererLocal to support the new symbolization.
Modified: trunk/MgDev/Common/Stylization/GDUtils.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/GDUtils.cpp 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/GDUtils.cpp 2007-03-14 18:00:44 UTC (rev 1223)
@@ -74,7 +74,7 @@
//so the alpha is computed as 255 / line_weight * 2
RS_Color falpha = color;
falpha.alpha() = falpha.alpha() / line_weight * 2 + 1;
- falpha.alpha() = rs_min(255, falpha.alpha());
+ falpha.alpha() = (falpha.alpha() < 255)? falpha.alpha() : 255;
//outer transparent circle -- for antialiased effect
rs_gdImageCircleForBrush(brush1, sx/2, sy/2, line_weight / 2, falpha);
Modified: trunk/MgDev/Common/Stylization/LabelRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRenderer.cpp 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/LabelRenderer.cpp 2007-03-14 18:00:44 UTC (rev 1223)
@@ -24,7 +24,6 @@
#include "SE_Include.h"
#include "SE_Bounds.h"
#include "SE_Renderer.h"
-#include "RS_FontEngine.h"
#define ROUND(x) (int)((x) + 0.5)
@@ -321,7 +320,6 @@
//////////////////////////////////////////////////////////////////////////////
void LabelRenderer::AddExclusionRegion(RS_F_Point* pts, int npts)
{
-
#ifdef DEBUG_LABELS
LineBuffer lb(5);
lb.MoveTo(pts[0].x, pts[0].y);
@@ -410,13 +408,13 @@
#ifdef DEBUG_LABELS
// this debugging code draws a box around the label (using its bounds)
- LineBuffer lb(5);
- lb.MoveTo(fpts[0].x, fpts[0].y);
- lb.LineTo(fpts[1].x, fpts[1].y);
- lb.LineTo(fpts[2].x, fpts[2].y);
- lb.LineTo(fpts[3].x, fpts[3].y);
- lb.Close();
- m_serenderer->DrawScreenPolyline(&lb, info.m_tdef.color().argb(), 0.0);
+ LineBuffer lb(5);
+ lb.MoveTo(fpts[0].x, fpts[0].y);
+ lb.LineTo(fpts[1].x, fpts[1].y);
+ lb.LineTo(fpts[2].x, fpts[2].y);
+ lb.LineTo(fpts[3].x, fpts[3].y);
+ lb.Close();
+ m_serenderer->DrawScreenPolyline(&lb, info.m_tdef.color().argb(), 0.0);
#endif
//-------------------------------------------------------
@@ -447,12 +445,12 @@
//This needs to be improved to handle text along a path
//get native symbol bounds (in pixels -- the render style is already scaled to pixels)
- SE_Bounds* b;
- b = info.m_sestyle->bounds;
+ SE_Bounds* b = info.m_sestyle->bounds;
+ if (!b)
+ return false;
- //now we will trnaslate and orient the bounds with the given angle and position of the symbol
+ //now we will translate and orient the bounds with the given angle and position of the symbol
RS_F_Point fpts[4];
-
fpts[0].x = b->min[0];
fpts[0].y = b->min[1];
fpts[1].x = b->max[0];
@@ -582,7 +580,7 @@
RS_F_Point* b = &oriented_bounds[i * 4];
RotatedBounds(tm.char_pos[i].x, tm.char_pos[i].y, advance, tm.text_height, tm.char_pos[i].anglerad, b);
- #ifdef DEBUG_LABELS
+#ifdef DEBUG_LABELS
LineBuffer lb(5);
lb.MoveTo(b[0].x, b[0].y);
lb.LineTo(b[1].x, b[1].y);
@@ -590,7 +588,7 @@
lb.LineTo(b[3].x, b[3].y);
lb.Close();
m_serenderer->DrawScreenPolyline(&lb, info.m_tdef.color().argb(), 0.0);
- #endif
+#endif
}
//-------------------------------------------------------
Modified: trunk/MgDev/Common/Stylization/LabelRenderer.h
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRenderer.h 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/LabelRenderer.h 2007-03-14 18:00:44 UTC (rev 1223)
@@ -20,6 +20,7 @@
#include "LabelRendererBase.h"
#include "SimpleOverpost.h"
+#include "RS_FontEngine.h"
struct SE_RenderStyle;
Modified: trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/LabelRendererLocal.cpp 2007-03-14 18:00:44 UTC (rev 1223)
@@ -292,8 +292,13 @@
}
// remember the feature bounds for the label group
- m_labelGroups.back().m_feature_bounds = path->bounds();
+ RS_Bounds bounds;
+ path->ComputeBounds(bounds);
+ // this is the non-SE case, and so the line buffer bounds are
+ // already in mapping space
+ m_labelGroups.back().m_feature_bounds = bounds;
+
EndOverpostGroup();
}
@@ -306,7 +311,47 @@
bool exclude,
LineBuffer* path)
{
- //TODO
+ BeginOverpostGroup(type, true, exclude);
+
+ //Add a new style SE label to the overpost groups.
+ //Here we are processing the simple case (like labels at given points
+ //rather than labels along a line). The hard case is //TODO
+ m_labelGroups.back().m_algo = laSESymbol;
+ RS_FontEngine* fe = m_serenderer->GetFontEngine();
+
+ for (int i=0; i<nlabels; i++)
+ {
+ SE_LabelInfo* info = &labels[i];
+
+ // label is in device space
+ double offx = fe->MeterToMapSize(info->dunits, info->dx);
+ double offy = fe->MeterToMapSize(info->dunits, info->dy);
+
+ LR_LabelInfoLocal lrinfo(info->x + offx, info->y + offy, info->symbol);
+
+ //TODO: HACK -- well somewhat of a hack -- store the angle in the tdef
+ lrinfo.m_tdef.rotation() = info->anglerad;
+
+ m_labelGroups.back().m_labels.push_back(lrinfo);
+ }
+
+ // remember the feature bounds for the label group
+ RS_Bounds bounds;
+ path->ComputeBounds(bounds);
+
+ // this is the SE case, and so the line buffer bounds are
+ // in screen space - convert them back to mapping space
+ double x0, y0, x1, y1;
+ m_serenderer->ScreenToWorldPoint(bounds.minx, bounds.miny, x0, y0);
+ m_serenderer->ScreenToWorldPoint(bounds.maxx, bounds.maxy, x1, y1);
+ bounds.minx = rs_min(x0, x1);
+ bounds.maxx = rs_max(x0, x1);
+ bounds.miny = rs_min(y0, y1);
+ bounds.maxy = rs_max(y0, y1);
+
+ m_labelGroups.back().m_feature_bounds = bounds;
+
+ EndOverpostGroup();
}
@@ -390,10 +435,13 @@
}
else
{
- success = ComputeSimpleLabelBounds(info);
+ if (info.m_sestyle)
+ success = ComputeSELabelBounds(info);
+ else
+ success = ComputeSimpleLabelBounds(info);
- //simple label --> simply add one instance of it
- //to the repeated infos collection. When we add repeated
+ //simple label or SE Label --> simply add one instance of
+ //it to the repeated infos collection. When we add repeated
//labels for polygons, this code will change.
LR_LabelInfoLocal copy = info;
copy.m_pts = NULL;
@@ -410,7 +458,7 @@
}
}
- //now replace the group's label infos, by the new repeated
+ //now replace the group's label infos by the new repeated
//infos collection -- also free the polyline data stored
//in the m_pts members of the original infos, since we will
//no longer need the geometry data
@@ -796,40 +844,45 @@
static int featIdS = -1;
featIdS++;
- RS_Color clrR(255, 0, 0, 255);
- RS_Color clrG( 0, 255, 0, 255);
- RS_Color clrB( 0, 0, 255, 255);
- RS_Color clrO(255, 128, 0, 255);
-/*
- // this debugging code draws the feature geometry using a thick
- // brush, with the color alternating between blue and orange
- gdImagePtr brush = rs_gdImageThickLineBrush(2, ((featIdS % 2)==0)? clrB : clrO);
- gdImageSetBrush((gdImagePtr)m_renderer->GetImage(), brush);
+ static RS_Color clrR(255, 0, 0, 255);
+ static RS_Color clrG( 0, 255, 0, 255);
+ static RS_Color clrB( 0, 0, 255, 255);
+ static RS_Color clrO(255, 128, 0, 255);
- printf("numPts=%d\n", info.m_numpts);
- for (int j=1; j<info.m_numpts; ++j)
+ GDRenderer* gdRenderer = dynamic_cast<GDRenderer*>(m_renderer);
+ if (gdRenderer)
{
- RS_D_Point dpts[2];
- dpts[0].x = (int)info.m_pts[j-1].x;
- dpts[0].y = (int)info.m_pts[j-1].y;
- dpts[1].x = (int)info.m_pts[j ].x;
- dpts[1].y = (int)info.m_pts[j ].y;
- gdImagePolygon((gdImagePtr)m_renderer->GetImage(), (gdPointPtr)dpts, 2, gdBrushed);
- }
+/*
+ // this debugging code draws the feature geometry using a thick
+ // brush, with the color alternating between blue and orange
+ gdImagePtr brush = rs_gdImageThickLineBrush(2, ((featIdS % 2)==0)? clrB : clrO);
+ gdImageSetBrush((gdImagePtr)gdRenderer->GetImage(), brush);
- gdImageSetBrush((gdImagePtr)m_renderer->GetImage(), NULL);
- gdImageDestroy(brush);
+ printf("numPts=%d\n", info.m_numpts);
+ for (int j=1; j<info.m_numpts; ++j)
+ {
+ RS_D_Point dpts[2];
+ dpts[0].x = (int)info.m_pts[j-1].x;
+ dpts[0].y = (int)info.m_pts[j-1].y;
+ dpts[1].x = (int)info.m_pts[j ].x;
+ dpts[1].y = (int)info.m_pts[j ].y;
+ gdImagePolygon((gdImagePtr)gdRenderer->GetImage(), (gdPointPtr)dpts, 2, gdBrushed);
+ }
+
+ gdImageSetBrush((gdImagePtr)gdRenderer->GetImage(), NULL);
+ gdImageDestroy(brush);
*/
- // this debugging code draws a box around the label (using its bounds),
- // with the color cycling between red, green, and blue
- RS_D_Point dpts[4];
- for (int j=0; j<4; ++j)
- {
- dpts[j].x = (int)info.m_oriented_bounds[j].x;
- dpts[j].y = (int)info.m_oriented_bounds[j].y;
+ // this debugging code draws a box around the label (using its bounds),
+ // with the color cycling between red, green, and blue
+ RS_D_Point dpts[4];
+ for (int j=0; j<4; ++j)
+ {
+ dpts[j].x = (int)info.m_oriented_bounds[j].x;
+ dpts[j].y = (int)info.m_oriented_bounds[j].y;
+ }
+ gdImagePolygon((gdImagePtr)gdRenderer->GetImage(), (gdPointPtr)dpts, 4, ConvertColor((gdImagePtr)gdRenderer->GetImage(), ((featIdS % 3)==0)? clrR : ((featIdS % 3)==1)? clrG : clrB));
+// gdImagePolygon((gdImagePtr)gdRenderer->GetImage(), (gdPointPtr)dpts, 4, ConvertColor((gdImagePtr)gdRenderer->GetImage(), info.m_tdef.color()));
}
- gdImagePolygon((gdImagePtr)m_renderer->GetImage(), (gdPointPtr)dpts, 4, ConvertColor((gdImagePtr)m_renderer->GetImage(), ((featIdS % 3)==0)? clrR : ((featIdS % 3)==1)? clrG : clrB));
-// gdImagePolygon((gdImagePtr)m_renderer->GetImage(), (gdPointPtr)dpts, 4, ConvertColor((gdImagePtr)m_renderer->GetImage(), info.m_tdef.color()));
#endif
return true;
@@ -904,26 +957,29 @@
RS_F_Point* b = ©_info.m_oriented_bounds[i * 4];
RotatedBounds(copy_info.m_tm.char_pos[i].x, copy_info.m_tm.char_pos[i].y, advance, copy_info.m_tm.text_height, copy_info.m_tm.char_pos[i].anglerad, b);
- #ifdef DEBUG_LABELS
+#ifdef DEBUG_LABELS
static int featIdP = -1;
if (i == 0) featIdP++;
- RS_Color clrR(255, 0, 0, 255);
- RS_Color clrG( 0, 255, 0, 255);
- RS_Color clrB( 0, 0, 255, 255);
- RS_Color clrO(255, 128, 0, 255);
+ static RS_Color clrR(255, 0, 0, 255);
+ static RS_Color clrG( 0, 255, 0, 255);
+ static RS_Color clrB( 0, 0, 255, 255);
- // this debugging code draws a box around the label's characters
- // with the color cycling between red, green, and blue
- RS_D_Point dpts[4];
- for (int j=0; j<4; j++)
+ GDRenderer* gdRenderer = dynamic_cast<GDRenderer*>(m_renderer);
+ if (gdRenderer)
{
- dpts[j].x = (int)b[j].x;
- dpts[j].y = (int)b[j].y;
+ // this debugging code draws a box around the label's characters
+ // with the color cycling between red, green, and blue
+ RS_D_Point dpts[4];
+ for (int j=0; j<4; j++)
+ {
+ dpts[j].x = (int)b[j].x;
+ dpts[j].y = (int)b[j].y;
+ }
+ gdImagePolygon((gdImagePtr)gdRenderer->GetImage(), (gdPointPtr)dpts, 4, ConvertColor((gdImagePtr)gdRenderer->GetImage(), ((featIdP % 3)==0)? clrR : ((featIdP % 3)==1)? clrG : clrB));
+// gdImagePolygon((gdImagePtr)gdRenderer->GetImage(), (gdPointPtr)dpts, 4, ConvertColor((gdImagePtr)gdRenderer->GetImage(), info.m_tdef.color()));
}
- gdImagePolygon((gdImagePtr)m_renderer->GetImage(), (gdPointPtr)dpts, 4, ConvertColor((gdImagePtr)m_renderer->GetImage(), ((featIdP % 3)==0)? clrR : ((featIdP % 3)==1)? clrG : clrB));
- // gdImagePolygon((gdImagePtr)m_renderer->GetImage(), (gdPointPtr)dpts, 4, ConvertColor((gdImagePtr)m_renderer->GetImage(), info.m_tdef.color()));
- #endif
+#endif
}
//add current periodic label to the return list
@@ -935,6 +991,116 @@
//////////////////////////////////////////////////////////////////////////////
+bool LabelRendererLocal::ComputeSELabelBounds(LR_LabelInfoLocal& info)
+{
+ //get native symbol bounds (in pixels -- the render style is already scaled to pixels)
+ SE_Bounds* b = info.m_sestyle->bounds;
+ if (!b)
+ return false;
+
+ //now we will translate and orient the bounds with the given angle and position of the symbol
+ RS_F_Point fpts[4];
+ fpts[0].x = b->min[0];
+ fpts[0].y = b->min[1];
+ fpts[1].x = b->max[0];
+ fpts[1].y = b->min[1];
+ fpts[2].x = b->max[0];
+ fpts[2].y = b->max[1];
+ fpts[3].x = b->min[0];
+ fpts[3].y = b->max[1];
+
+ //apply position and rotation to the native bounds of the symbol
+ double angle = m_serenderer->GetFontEngine()->_Yup() ? info.m_tdef.rotation() : -info.m_tdef.rotation();
+ SE_Matrix m;
+ m.setIdentity();
+ m.rotate(angle); //it is already in radians in there
+ m.translate(info.m_x, info.m_y);
+
+ for (int i=0; i<4; i++)
+ m.transform(fpts[i].x, fpts[i].y);
+
+ // compute the overall rotated bounds
+ RS_Bounds rotatedBounds(+DBL_MAX, +DBL_MAX, -DBL_MAX, -DBL_MAX);
+ for (int i=0; i<4; i++)
+ rotatedBounds.add_point(fpts[i]);
+
+ //allocate the data we need
+ info.m_numelems = 1;
+ info.m_oriented_bounds = new RS_F_Point[4];
+
+ //store the oriented bounds with the label
+ rotatedBounds.get_points(info.m_oriented_bounds);
+
+#ifdef DEBUG_LABELS
+ static int featIdS = -1;
+ featIdS++;
+
+ static RS_Color clrR(255, 0, 0, 255);
+ static RS_Color clrG( 0, 255, 0, 255);
+ static RS_Color clrB( 0, 0, 255, 255);
+ static RS_Color clrO(255, 128, 0, 255);
+
+ GDRenderer* gdRenderer = dynamic_cast<GDRenderer*>(m_renderer);
+ if (gdRenderer)
+ {
+/*
+ // this debugging code draws the feature geometry using a thick
+ // brush, with the color alternating between blue and orange
+ gdImagePtr brush = rs_gdImageThickLineBrush(2, ((featIdS % 2)==0)? clrB : clrO);
+ gdImageSetBrush((gdImagePtr)gdRenderer->GetImage(), brush);
+
+ printf("numPts=%d\n", info.m_numpts);
+ for (int j=1; j<info.m_numpts; ++j)
+ {
+ RS_D_Point dpts[2];
+ dpts[0].x = (int)info.m_pts[j-1].x;
+ dpts[0].y = (int)info.m_pts[j-1].y;
+ dpts[1].x = (int)info.m_pts[j ].x;
+ dpts[1].y = (int)info.m_pts[j ].y;
+ gdImagePolygon((gdImagePtr)gdRenderer->GetImage(), (gdPointPtr)dpts, 2, gdBrushed);
+ }
+
+ gdImageSetBrush((gdImagePtr)gdRenderer->GetImage(), NULL);
+ gdImageDestroy(brush);
+*/
+ // this debugging code draws a box around the label (using its bounds),
+ // with the color cycling between red, green, and blue
+ RS_D_Point dpts[4];
+ for (int j=0; j<4; ++j)
+ {
+ dpts[j].x = (int)info.m_oriented_bounds[j].x;
+ dpts[j].y = (int)info.m_oriented_bounds[j].y;
+ }
+ gdImagePolygon((gdImagePtr)gdRenderer->GetImage(), (gdPointPtr)dpts, 4, ConvertColor((gdImagePtr)gdRenderer->GetImage(), ((featIdS % 3)==0)? clrR : ((featIdS % 3)==1)? clrG : clrB));
+// gdImagePolygon((gdImagePtr)gdRenderer->GetImage(), (gdPointPtr)dpts, 4, ConvertColor((gdImagePtr)gdRenderer->GetImage(), info.m_tdef.color()));
+ }
+#endif
+/*
+#ifdef DEBUG_LABELS
+ static int featIdS = -1;
+ featIdS++;
+
+ static unsigned int clrR = 0xffff0000;
+ static unsigned int clrG = 0xff00ff00;
+ static unsigned int clrB = 0xff0000ff;
+
+ // this debugging code draws a box around the label (using its bounds),
+ // with the color cycling between red, green, and blue
+ LineBuffer lb(5);
+ lb.MoveTo(info.m_oriented_bounds[0].x, info.m_oriented_bounds[0].y);
+ lb.LineTo(info.m_oriented_bounds[1].x, info.m_oriented_bounds[1].y);
+ lb.LineTo(info.m_oriented_bounds[2].x, info.m_oriented_bounds[2].y);
+ lb.LineTo(info.m_oriented_bounds[3].x, info.m_oriented_bounds[3].y);
+ lb.Close();
+ unsigned int color = ((featIdS % 3)==0)? clrR : ((featIdS % 3)==1)? clrG : clrB;
+ m_serenderer->DrawScreenPolyline(&lb, color, 0.0);
+#endif
+*/
+ return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
void LabelRendererLocal::ProcessLabelGroupsInternal(SimpleOverpost* pMgr, std::vector<LR_OverpostGroupLocal*>& groups)
{
for (size_t i=0; i<groups.size(); i++)
@@ -998,7 +1164,18 @@
if (render)
{
// call the appropriate routine
- if (info.m_tm.char_pos.size() > 0) //detect whether it's path text or not
+ if (info.m_sestyle)
+ {
+ //apply position and rotation to the native bounds of the symbol
+ double angle = m_serenderer->GetFontEngine()->_Yup() ? info.m_tdef.rotation() : -info.m_tdef.rotation();
+ SE_Matrix m;
+ m.setIdentity();
+ m.rotate(angle); //it is already in radians in there
+ m.translate(info.m_x, info.m_y);
+
+ m_serenderer->DrawSymbol(info.m_sestyle->symbol, m, angle);
+ }
+ else if (info.m_tm.char_pos.size() > 0)
m_serenderer->GetFontEngine()->DrawPathText(info.m_tm, info.m_tdef);
else
m_serenderer->GetFontEngine()->DrawBlockText(info.m_tm, info.m_tdef, info.m_ins_point.x, info.m_ins_point.y);
Modified: trunk/MgDev/Common/Stylization/LabelRendererLocal.h
===================================================================
--- trunk/MgDev/Common/Stylization/LabelRendererLocal.h 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/LabelRendererLocal.h 2007-03-14 18:00:44 UTC (rev 1223)
@@ -22,6 +22,7 @@
#include "SimpleOverpost.h"
#include "RS_FontEngine.h"
+struct SE_RenderStyle;
//////////////////////////////////////////////////////////////////////////////
//used to accumulate labels
@@ -36,10 +37,22 @@
m_pts(NULL),
m_numpts(0),
m_numelems(0),
- m_oriented_bounds(NULL)
+ m_oriented_bounds(NULL),
+ m_sestyle(NULL)
{
}
+ LR_LabelInfoLocal(double x, double y, SE_RenderStyle* style)
+ : m_x(x),
+ m_y(y),
+ m_pts(NULL),
+ m_numpts(0),
+ m_numelems(0),
+ m_oriented_bounds(NULL),
+ m_sestyle(style)
+ {
+ }
+
double m_x;
double m_y;
RS_String m_text;
@@ -64,6 +77,9 @@
// stores matched font, measured text size, kerned char spacings
// layout character positions
RS_TextMetrics m_tm;
+
+ // new SE labels keep the symbol here rather than in the m_tdef/m_text combo
+ SE_RenderStyle* m_sestyle;
};
@@ -123,6 +139,7 @@
bool ComputeSimpleLabelBounds(LR_LabelInfoLocal& info);
bool ComputePathLabelBounds(LR_LabelInfoLocal& info, std::vector<LR_LabelInfoLocal>& repeated_infos);
+ bool ComputeSELabelBounds(LR_LabelInfoLocal& info);
void ProcessLabelGroupsInternal(SimpleOverpost* pMgr, std::vector<LR_OverpostGroupLocal*>& groups);
bool ProcessLabelInternal(SimpleOverpost* pMgr, LR_LabelInfoLocal& info, bool render, bool exclude, bool check);
Modified: trunk/MgDev/Common/Stylization/LineBuffer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/LineBuffer.cpp 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/LineBuffer.cpp 2007-03-14 18:00:44 UTC (rev 1223)
@@ -784,7 +784,6 @@
*pts++ = *xv++;
*pts++ = *yv++;
}
-
}
}
@@ -1029,7 +1028,7 @@
return this;
//check if line buffer is completely outside box
- if (m_bounds.minx > b.maxx
+ if ( m_bounds.minx > b.maxx
|| m_bounds.miny > b.maxy
|| m_bounds.maxx < b.minx
|| m_bounds.maxy < b.miny)
@@ -1836,6 +1835,26 @@
}
+void LineBuffer::ComputeBounds(RS_Bounds& bounds)
+{
+ // update the bounds, if they're not already set
+ if (!m_bounds.IsValid())
+ {
+ for (int i=0; i<m_cur_pts;)
+ {
+ double x = m_pts[i++];
+ double y = m_pts[i++];
+ m_bounds.minx = rs_min(m_bounds.minx, x);
+ m_bounds.maxx = rs_max(m_bounds.maxx, x);
+ m_bounds.miny = rs_min(m_bounds.miny, y);
+ m_bounds.maxy = rs_max(m_bounds.maxy, y);
+ }
+ }
+
+ bounds = m_bounds;
+}
+
+
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
////
Modified: trunk/MgDev/Common/Stylization/LineBuffer.h
===================================================================
--- trunk/MgDev/Common/Stylization/LineBuffer.h 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/LineBuffer.h 2007-03-14 18:00:44 UTC (rev 1223)
@@ -61,7 +61,6 @@
};
public:
-
STYLIZATION_API LineBuffer(int size);
STYLIZATION_API virtual ~LineBuffer();
@@ -90,6 +89,9 @@
STYLIZATION_API void Reset();
STYLIZATION_API void SetGeometryType(int geomType);
+ // computes the bounds of the line buffer's geometry
+ void ComputeBounds(RS_Bounds& bounds);
+
//the inline stuff
inline unsigned char* types() { return m_types; }
inline double* points() { return m_pts; }
Modified: trunk/MgDev/Common/Stylization/RSBufferOutputStream.h
===================================================================
--- trunk/MgDev/Common/Stylization/RSBufferOutputStream.h 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/RSBufferOutputStream.h 2007-03-14 18:00:44 UTC (rev 1223)
@@ -22,9 +22,7 @@
class RSBufferOutputStream : public RS_OutputStream
{
-
public:
-
RSBufferOutputStream(int size)
{
if (size == 0)
@@ -72,13 +70,12 @@
}
protected:
-
void ensure_capacity(size_t sz)
{
if (m_pos + sz <= m_len)
return;
- m_len = rs_max(m_len*2, sz + m_pos);
+ m_len = (m_len*2 > sz + m_pos)? m_len*2 : sz + m_pos;
unsigned char* ndata = new unsigned char[m_len];
memcpy(ndata, m_data, m_pos);
@@ -89,14 +86,12 @@
//
// Default constructor
//
- RSBufferOutputStream() {;}
+ RSBufferOutputStream() {}
private:
-
unsigned char* m_data;
size_t m_pos;
size_t m_len;
-
};
#endif
Modified: trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/SE_LineBuffer.cpp 2007-03-14 18:00:44 UTC (rev 1223)
@@ -43,9 +43,9 @@
void SetToTransform(const SE_Matrix& xform, LineBuffer* src);
};
-SE_LineStorage::SE_LineStorage(int size) :
- LineBuffer(size)
-{
+SE_LineStorage::SE_LineStorage(int size) :
+ LineBuffer(size)
+{
}
void SE_LineStorage::_MoveTo(double x, double y)
@@ -284,7 +284,7 @@
however, appear to be using round joins at the moment. */
m_ch_ptbuf.insert(std::pair<double,double>(x + vx, y + vy));
m_ch_ptbuf.insert(std::pair<double,double>(x - vx, y - vy));
- m_ch_ptbuf.insert(std::pair<double,double>(lx + vx, ly + vy));
+ m_ch_ptbuf.insert(std::pair<double,double>(lx + vx, ly + vy));
m_ch_ptbuf.insert(std::pair<double,double>(lx - vx, ly - vy));
while(cur < last)
@@ -468,7 +468,7 @@
int max_newpts = (int)(GROWTH_FACTOR*max_pts) + 1;
if (max_newpts - max_pts < mininc)
max_newpts += mininc;
-
+
void* newbuf = new char[unitsize*max_newpts];
memcpy(newbuf, *buffer, cur_pts*unitsize);
delete[] *buffer;
@@ -529,11 +529,11 @@
int nsegs = (int)(4.0*fabs(eAng - sAng)/(2*M_PI)) + 1; // eAng - sAng is (0, 2pi), so this is {1,2,3,4}.
double span = (eAng - sAng)/(double)nsegs;
double aspan = fabs(span);
-
+
double sec = 1.0/cos(aspan/2.0);
double alpha = sin(aspan)*(sqrt(1.0 + 3.0/sec/sec) - 1)/3.0;
double rcos = cos(rot), rsin = sin(rot);
-
+
double ex, ey, sx, sy;
double scos, ssin, ecos, esin;
double sa, ea;
@@ -620,7 +620,7 @@
m_xf = xform;
m_xf_tol = 0.0;
m_xf_weight = weight;
-
+
if (m_xf_bounds)
{
m_xf_bounds->Free();
Modified: trunk/MgDev/Common/Stylization/SE_LineBuffer.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_LineBuffer.h 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/SE_LineBuffer.h 2007-03-14 18:00:44 UTC (rev 1223)
@@ -67,6 +67,7 @@
STYLIZATION_API SE_INLINE bool& compute_bounds() { return m_compute_bounds; }
STYLIZATION_API SE_INLINE LineBuffer* xf_buffer() { return (LineBuffer*)m_xf_buf; }
STYLIZATION_API SE_INLINE LineBuffer* inst_buffer() { return (LineBuffer*)m_inst_buf; }
+ STYLIZATION_API SE_INLINE LineBuffer* src_buffer() { return m_src_lb; }
STYLIZATION_API SE_INLINE SE_Bounds* xf_bounds() { return m_xf_bounds; }
STYLIZATION_API SE_INLINE SE_Bounds* inst_bounds() { return m_inst_bounds; }
@@ -90,7 +91,7 @@
double m_start[2];
double m_last[2];
-
+
bool m_compute_bounds;
SE_Matrix m_xf;
@@ -99,7 +100,6 @@
SE_Bounds* m_xf_bounds;
SE_LineStorage* m_xf_buf;
-
SE_Bounds* m_inst_bounds;
SE_LineStorage* m_inst_buf;
Modified: trunk/MgDev/Common/Stylization/stdafx.h
===================================================================
--- trunk/MgDev/Common/Stylization/stdafx.h 2007-03-14 16:50:32 UTC (rev 1222)
+++ trunk/MgDev/Common/Stylization/stdafx.h 2007-03-14 18:00:44 UTC (rev 1223)
@@ -49,7 +49,3 @@
// Stylization DLL export headers
#include "Stylization.h"
-
-
-#define rs_max(a,b) (((a) > (b)) ? (a) : (b))
-#define rs_min(a,b) (((a) < (b)) ? (a) : (b))
More information about the mapguide-commits
mailing list