[mapguide-commits] r1264 - trunk/MgDev/Common/Stylization
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Mar 16 17:27:39 EDT 2007
Author: traianstanev
Date: 2007-03-16 17:27:39 -0400 (Fri, 16 Mar 2007)
New Revision: 1264
Modified:
trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp
trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h
trunk/MgDev/Common/Stylization/StylizationEngine.cpp
Log:
Made styles self applying. Also SE_Styles now hold on to their SE_RenderStyle. This will help once we add code to detect whether a style is constant -- if it is, then evaluation can be a noop after the first time the SE_Style is converter to an SE_RendeerStyle.
Modified: trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp 2007-03-16 20:09:09 UTC (rev 1263)
+++ trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.cpp 2007-03-16 21:27:39 UTC (rev 1264)
@@ -26,6 +26,15 @@
#include <algorithm>
#include <functional>
+SE_Style::~SE_Style()
+{
+ for (SE_PrimitiveList::iterator iter = symbol.begin(); iter != symbol.end(); iter++)
+ delete *iter;
+
+ delete rstyle;
+}
+
+
SE_RenderPrimitive* SE_Polyline::evaluate(SE_EvalContext* cxt)
{
SE_RenderPolyline* ret = new SE_RenderPolyline();
@@ -193,10 +202,10 @@
return ret;
}
-void SE_Style::evaluate_common(SE_EvalContext* cxt, SE_RenderStyle* ret)
+void SE_Style::evaluate(SE_EvalContext* cxt)
{
//evaluate values that are common to all styles
- ret->renderPass = renderPass.evaluate(cxt->exec);
+ rstyle->renderPass = renderPass.evaluate(cxt->exec);
//
//evaluation of all primitives and also resize box stuff
@@ -239,17 +248,17 @@
{
if (!rsym->resize)
{
- if (ret->bounds)
+ if (rstyle->bounds)
{
- SE_Bounds* bounds = ret->bounds;
- ret->bounds = bounds->Union(rsym->bounds);
+ SE_Bounds* bounds = rstyle->bounds;
+ rstyle->bounds = bounds->Union(rsym->bounds);
bounds->Free();
}
else
- ret->bounds = rsym->bounds->Clone();
+ rstyle->bounds = rsym->bounds->Clone();
}
- ret->symbol.push_back(rsym);
+ rstyle->symbol.push_back(rsym);
if (useBox && sym->resize == GraphicElement::AddToResizeBox)
rsym->bounds->Contained(minx, miny, maxx, maxy, growx, growy);
@@ -282,22 +291,22 @@
growxf.translate(dx, dy);
totalxf.premultiply(growxf);
- for (SE_RenderPrimitiveList::iterator rs = ret->symbol.begin(); rs != ret->symbol.end(); rs++)
+ for (SE_RenderPrimitiveList::iterator rs = rstyle->symbol.begin(); rs != rstyle->symbol.end(); rs++)
{
SE_RenderPrimitive* rsym = *rs;
if (rsym->resize)
{
switch(rsym->type)
{
- case SE_PolygonPrimitive:
- case SE_PolylinePrimitive:
+ case SE_RenderPolygonPrimitive:
+ case SE_RenderPolylinePrimitive:
{
SE_RenderPolyline* rp = (SE_RenderPolyline*)rsym;
rp->geometry->Transform(totalxf, rp->weight);
rp->bounds = rp->geometry->xf_bounds()->Clone();
break;
}
- case SE_TextPrimitive:
+ case SE_RenderTextPrimitive:
{
SE_RenderText* rt = (SE_RenderText*)rsym;
growxf.transform(rt->position[0], rt->position[1]);
@@ -305,7 +314,7 @@
rt->bounds->Transform(growxf);
break;
}
- case SE_RasterPrimitive:
+ case SE_RenderRasterPrimitive:
{
SE_RenderRaster* rr = (SE_RenderRaster*)rsym;
growxf.transform(rr->position[0], rr->position[1]);
@@ -316,21 +325,21 @@
}
}
- if (ret->bounds)
+ if (rstyle->bounds)
{
- SE_Bounds* bounds = ret->bounds;
- ret->bounds = bounds->Union(rsym->bounds);
+ SE_Bounds* bounds = rstyle->bounds;
+ rstyle->bounds = bounds->Union(rsym->bounds);
bounds->Free();
}
else
- ret->bounds = rsym->bounds->Clone();
+ rstyle->bounds = rsym->bounds->Clone();
}
}
}
}
-SE_RenderStyle* SE_PointStyle::evaluate(SE_EvalContext* cxt)
+void SE_PointStyle::evaluate(SE_EvalContext* cxt)
{
SE_RenderPointStyle* render = new SE_RenderPointStyle();
@@ -383,13 +392,16 @@
sxform.premultiply(*cxt->xform);
*cxt->xform = sxform; //BAD here we modify the passed in transform -- figure out a way to avoid this
+ //set the cached renderStyle member variable
+ //TODO: cache constant render styles
+ delete rstyle;
+ rstyle = render;
+
//evaluate all the primitives too
- evaluate_common(cxt, render);
-
- return render;
+ SE_Style::evaluate(cxt);
}
-SE_RenderStyle* SE_LineStyle::evaluate(SE_EvalContext* cxt)
+void SE_LineStyle::evaluate(SE_EvalContext* cxt)
{
SE_RenderLineStyle* render = new SE_RenderLineStyle();
@@ -404,13 +416,16 @@
render->repeat = repeat.evaluate(cxt->exec)*cxt->mm2px;
render->vertexAngleLimit = vertexAngleLimit.evaluate(cxt->exec) * M_PI180;
+ //set the cached renderStyle member variable
+ //TODO: cache constant render styles
+ delete rstyle;
+ rstyle = render;
+
//evaluate all the primitives too
- evaluate_common(cxt, render);
-
- return render;
+ SE_Style::evaluate(cxt);
}
-SE_RenderStyle* SE_AreaStyle::evaluate(SE_EvalContext* cxt)
+void SE_AreaStyle::evaluate(SE_EvalContext* cxt)
{
SE_RenderAreaStyle* render = new SE_RenderAreaStyle();
@@ -425,10 +440,26 @@
render->repeat[1] = repeat[1].evaluate(cxt->exec);
render->bufferWidth = bufferWidth.evaluate(cxt->exec);
+ //set the cached renderStyle member variable
+ //TODO: cache constant render styles
+ delete rstyle;
+ rstyle = render;
+
//evaluate all the primitives too
- evaluate_common(cxt, render);
+ SE_Style::evaluate(cxt);
+}
- return render;
+void SE_PointStyle::apply(LineBuffer* geometry, SE_Renderer* renderer)
+{
+ renderer->ProcessPoint(geometry, (SE_RenderPointStyle*)rstyle);
}
+void SE_LineStyle::apply(LineBuffer* geometry, SE_Renderer* renderer)
+{
+ renderer->ProcessLine(geometry, (SE_RenderLineStyle*)rstyle);
+}
+void SE_AreaStyle::apply(LineBuffer* geometry, SE_Renderer* renderer)
+{
+ renderer->ProcessArea(geometry, (SE_RenderAreaStyle*)rstyle);
+}
Modified: trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h
===================================================================
--- trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h 2007-03-16 20:09:09 UTC (rev 1263)
+++ trunk/MgDev/Common/Stylization/SE_SymbolDefProxies.h 2007-03-16 21:27:39 UTC (rev 1264)
@@ -50,6 +50,7 @@
class RS_FilterExecutor;
class RS_FontEngine;
class SE_SymbolManager;
+class SE_Renderer;
class SE_EvalContext
{
@@ -151,6 +152,7 @@
struct SE_Style
{
+ SE_RenderStyle* rstyle; // cached evaluated RenderStyle
SE_StyleType type;
SE_PrimitiveList symbol;
SE_Integer renderPass;
@@ -160,16 +162,12 @@
SE_Double resizeSize[2];
ResizeBox::GrowControl resize;
- SE_INLINE SE_Style(SE_StyleType stype) : type(stype) { }
+ SE_INLINE SE_Style(SE_StyleType stype) : type(stype), rstyle(NULL) { }
- virtual ~SE_Style()
- {
- for (SE_PrimitiveList::iterator iter = symbol.begin(); iter != symbol.end(); iter++)
- delete *iter;
- }
+ virtual ~SE_Style();
- virtual SE_RenderStyle* evaluate(SE_EvalContext*) = 0;
- void evaluate_common(SE_EvalContext* , SE_RenderStyle* );
+ virtual void apply(LineBuffer* geometry, SE_Renderer* renderer) = 0;
+ virtual void evaluate(SE_EvalContext*) = 0;
};
@@ -180,7 +178,8 @@
SE_Double originOffset[2];
SE_INLINE SE_PointStyle() : SE_Style(SE_PointStyleType) { }
- virtual SE_RenderStyle* evaluate(SE_EvalContext*);
+ virtual void apply(LineBuffer* geometry, SE_Renderer* renderer);
+ virtual void evaluate(SE_EvalContext*);
};
@@ -198,7 +197,8 @@
SE_Double vertexAngleLimit;
SE_INLINE SE_LineStyle() : SE_Style(SE_LineStyleType) { }
- virtual SE_RenderStyle* evaluate(SE_EvalContext*);
+ virtual void apply(LineBuffer* geometry, SE_Renderer* renderer);
+ virtual void evaluate(SE_EvalContext*);
};
@@ -214,7 +214,8 @@
SE_Double bufferWidth;
SE_INLINE SE_AreaStyle() : SE_Style(SE_AreaStyleType) { }
- virtual SE_RenderStyle* evaluate(SE_EvalContext*);
+ virtual void apply(LineBuffer* geometry, SE_Renderer* renderer);
+ virtual void evaluate(SE_EvalContext*);
};
Modified: trunk/MgDev/Common/Stylization/StylizationEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/StylizationEngine.cpp 2007-03-16 20:09:09 UTC (rev 1263)
+++ trunk/MgDev/Common/Stylization/StylizationEngine.cpp 2007-03-16 21:27:39 UTC (rev 1264)
@@ -315,36 +315,21 @@
//evaluate the style (all expressions inside it) and convert to a constant screen space
//render style
- SE_RenderStyle* rstyle = style->evaluate(&cxt);
+ style->evaluate(&cxt);
- //why are these in the symbolization?
- rstyle->addToExclusionRegions = sym->addToExclusionRegions.evaluate(executor);
- rstyle->checkExclusionRegions = sym->checkExclusionRegions.evaluate(executor);
- rstyle->drawLast = sym->drawLast.evaluate(executor);
+ //why are these in the symbolization? fix this!
+ style->rstyle->addToExclusionRegions = sym->addToExclusionRegions.evaluate(executor);
+ style->rstyle->checkExclusionRegions = sym->checkExclusionRegions.evaluate(executor);
+ style->rstyle->drawLast = sym->drawLast.evaluate(executor);
if (!sym->positioningAlgorithm.empty() && sym->positioningAlgorithm != L"Default")
{
- LayoutCustomLabel(sym->positioningAlgorithm, geometry, tmpxform, style, rstyle, mm2px);
+ LayoutCustomLabel(sym->positioningAlgorithm, geometry, tmpxform, style, style->rstyle, mm2px);
}
else
{
- switch(style->type)
- {
- case SE_PointStyleType:
- m_serenderer->ProcessPoint(geometry, (SE_RenderPointStyle*)rstyle);
- break;
- case SE_LineStyleType:
- m_serenderer->ProcessLine(geometry, (SE_RenderLineStyle*)rstyle);
- break;
- case SE_AreaStyleType:
- m_serenderer->ProcessArea(geometry, (SE_RenderAreaStyle*)rstyle);
- break;
- }
+ style->apply(geometry, m_serenderer);
}
-
- //Free the render style. If the style was needed for drawing as a label,
- //the renderer would have cloned it and created its own pointer
- delete rstyle;
}
}
}
More information about the mapguide-commits
mailing list