[mapguide-commits] r1247 - trunk/MgDev/Common/Stylization
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Thu Mar 15 20:10:53 EDT 2007
Author: waltweltonlair
Date: 2007-03-15 20:10:53 -0400 (Thu, 15 Mar 2007)
New Revision: 1247
Modified:
trunk/MgDev/Common/Stylization/DefaultStylizer.cpp
trunk/MgDev/Common/Stylization/StylizationEngine.cpp
trunk/MgDev/Common/Stylization/StylizationEngine.h
Log:
Move composite stylization code in DefaultStylizer to StylizationEngine. DefaultStylizer
now checks for the presence of at least one CompositeTypeStyle. If it finds one it calls
a new StylizeVectorLayer on StylizationEngine, otherwise DefaultStylizer works the way
it originally did. This separation is in preparation for adding rendering pass support
for compound symbols.
Modified: trunk/MgDev/Common/Stylization/DefaultStylizer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/DefaultStylizer.cpp 2007-03-15 19:57:54 UTC (rev 1246)
+++ trunk/MgDev/Common/Stylization/DefaultStylizer.cpp 2007-03-16 00:10:53 UTC (rev 1247)
@@ -26,9 +26,8 @@
#include "Renderer.h"
#include "LineBuffer.h"
#include "ElevationSettings.h"
-#include "StylizationEngine.h"
#include "FeatureTypeStyleVisitor.h"
-#include "SE_Renderer.h"
+#include "StylizationEngine.h"
const RS_String s_Empty(L"");
@@ -75,19 +74,18 @@
// no range -- do not stylize
if (NULL == range) return;
- // we have a valid scale range... we can now go over the features and
- // apply the feature styles in that range
-
- //Sidenote: as of now (8/10/04) it is not clear whether FeatureTypeStyle
- //is matched to features via geometry type or via name of the
- //feature class. For now, we match by geometry.
-
+ // get the geometry column name
const wchar_t* gpName = features->GetGeomPropName();
+ if (NULL == gpName)
+ return;
- //no geometry -- do not stylize
- if (NULL == gpName) return;
+ // we have a valid scale range and geometry... we can now go over the
+ // features and apply the feature styles in that range
+ MdfModel::FeatureTypeStyleCollection* ftsc = range->GetFeatureTypeStyles();
- RS_FilterExecutor* exec = RS_FilterExecutor::Create(features);
+ //Sidenote: as of now (8/10/04) it is not clear whether FeatureTypeStyle
+ //is matched to features via geometry type or via name of the feature
+ //class. For now, we match by geometry.
// configure the filter with the current map/layer info
RS_MapUIInfo* mapInfo = renderer->GetMapInfo();
@@ -98,103 +96,97 @@
const RS_String& mapName = (mapInfo != NULL)? mapInfo->name() : s_Empty;
const RS_String& layerId = (layerInfo != NULL)? layerInfo->guid() : s_Empty;
const RS_String& featCls = (featInfo != NULL)? featInfo->name() : s_Empty;
+
+ RS_FilterExecutor* exec = RS_FilterExecutor::Create(features);
exec->SetMapLayerInfo(session, mapName, layerId, featCls);
- // find the FeatureTypeStyle
- MdfModel::FeatureTypeStyleCollection* ftsc = range->GetFeatureTypeStyles();
-
- //TODO: //HACK: temporary code to detect whether we are using a new style
- //composite symbolizations
- bool use_style_engine = false;
- SE_Renderer* se_renderer = NULL;
- if (FeatureTypeStyleVisitor::DetermineFeatureTypeStyle(ftsc->GetAt(0)) == FeatureTypeStyleVisitor::ftsComposite)
+ // check if we have any composite type styles - if we find at least
+ // one then we'll use it and ignore any other non-composite type styles
+ // TODO: confirm this is the behavior we want
+ bool foundComposite = false;
+ for (int i=0; i<ftsc->GetCount(); i++)
{
- use_style_engine = true;
- se_renderer = dynamic_cast<SE_Renderer*>(renderer);
+ MdfModel::FeatureTypeStyle* fts = ftsc->GetAt(i);
+ if (FeatureTypeStyleVisitor::DetermineFeatureTypeStyle(fts) == FeatureTypeStyleVisitor::ftsComposite)
+ {
+ foundComposite = true;
+ break;
+ }
}
- //extract hyperlink and tooltip info
- //this is invariant, so do outside of feature iterator loop
- const MdfModel::MdfString& mdfTip = fl->GetToolTip();
- const MdfModel::MdfString& mdfUrl = fl->GetUrl();
- const MdfModel::MdfString* lrTip = mdfTip.empty()? NULL : &mdfTip;
- const MdfModel::MdfString* lrUrl = mdfUrl.empty()? NULL : &mdfUrl;
-
- SE_String seTip;
- SE_String seUrl;
- if (use_style_engine)
+ // composite type styles are handled by the new style engine
+ if (foundComposite)
{
- m_styleEngine->ParseStringExpression(mdfTip, seTip);
- m_styleEngine->ParseStringExpression(mdfUrl, seUrl);
+ this->m_styleEngine->StylizeVectorLayer(fl, range, renderer, features, exec, xformer, cancel, userData);
}
+ else
+ {
+ //extract hyperlink and tooltip info
+ //this is invariant, so do outside of feature iterator loop
+ const MdfModel::MdfString& mdfTip = fl->GetToolTip();
+ const MdfModel::MdfString& mdfUrl = fl->GetUrl();
+ const MdfModel::MdfString* lrTip = mdfTip.empty()? NULL : &mdfTip;
+ const MdfModel::MdfString* lrUrl = mdfUrl.empty()? NULL : &mdfUrl;
- //TODO:
- //*****************************************
- //* THIS CALL IS REALLY REALLY REALLY SLOW!!!
- //*****************************************
- //It needs to be done per feature if there is inheritance of feature classes
- //but is so horribly slow that in all other cases it needs to be optimized away
- //FdoPtr<FdoClassDefinition> concreteClass = features->GetClassDefinition();
+ //TODO:
+ //*****************************************
+ //* THIS CALL IS REALLY REALLY REALLY SLOW!!!
+ //*****************************************
+ //It needs to be done per feature if there is inheritance of feature classes
+ //but is so horribly slow that in all other cases it needs to be optimized away
+ //FdoPtr<FdoClassDefinition> concreteClass = features->GetClassDefinition();
- bool bClip = renderer->RequiresClipping();
+ bool bClip = renderer->RequiresClipping();
- #ifdef _DEBUG
- int nFeatures = 0;
- #endif
-
- //main loop over feature data
- while (features->ReadNext())
- {
#ifdef _DEBUG
- nFeatures++;
+ int nFeatures = 0;
#endif
- LineBuffer* lb = NULL;
+ //main loop over feature data
+ while (features->ReadNext())
+ {
+ #ifdef _DEBUG
+ nFeatures++;
+ #endif
- //get the geometry just once
- //all types of geometry
- lb = m_lbPool->NewLineBuffer(8);
- features->GetGeometry(gpName, lb, xformer);
+ LineBuffer* lb = NULL;
- if (lb && bClip)
- {
- //clip geometry to given map request extents
- //TODO: is this the right place to do so?
- LineBuffer* lbc = lb->Clip(renderer->GetBounds(), LineBuffer::ctAGF, m_lbPool);
+ //get the geometry just once
+ //all types of geometry
+ lb = m_lbPool->NewLineBuffer(8);
+ features->GetGeometry(gpName, lb, xformer);
- //did geom require clipping?
- //free original line buffer
- //note original geometry is still accessible to the
- //user from the RS_FeatureReader::GetGeometry
- if (lbc != lb)
+ if (lb && bClip)
{
- m_lbPool->FreeLineBuffer(lb);
- lb = lbc;
+ //clip geometry to given map request extents
+ //TODO: is this the right place to do so?
+ LineBuffer* lbc = lb->Clip(renderer->GetBounds(), LineBuffer::ctAGF, m_lbPool);
+
+ //did geom require clipping?
+ //free original line buffer
+ //note original geometry is still accessible to the
+ //user from the RS_FeatureReader::GetGeometry
+ if (lbc != lb)
+ {
+ m_lbPool->FreeLineBuffer(lb);
+ lb = lbc;
+ }
}
- }
- if (!lb) continue;
+ if (!lb) continue;
- //need to clear out the filter execution engine cache
- //some feature attributes may be cached while executing theming
- //expressions and this call flushes that
- exec->Reset();
+ //need to clear out the filter execution engine cache
+ //some feature attributes may be cached while executing theming
+ //expressions and this call flushes that
+ exec->Reset();
- // we need to stylize once for each FeatureTypeStyle that matches
- // the geometry type (Note: this may have to change to match
- // feature classes)
- for (int i=0; i<ftsc->GetCount(); i++)
- {
- MdfModel::FeatureTypeStyle* fts = ftsc->GetAt(i);
-
- if (use_style_engine)
+ // we need to stylize once for each FeatureTypeStyle that matches
+ // the geometry type (Note: this may have to change to match
+ // feature classes)
+ for (int i=0; i<ftsc->GetCount(); i++)
{
- //we are hoping that the renderer is nice enough to be an SE_Renderer
- if (se_renderer)
- m_styleEngine->Stylize(se_renderer, features, exec, lb, (CompositeTypeStyle*)fts, &seTip, &seUrl, NULL);
- }
- else
- {
+ MdfModel::FeatureTypeStyle* fts = ftsc->GetAt(i);
+
//TODO: future enhancement:
//If we have a stylizer that works on a specific feature class
//we should invoke it here, instead of invoking the
@@ -234,18 +226,18 @@
elevSettings = NULL;
}
}
- }
- if (lb)
- m_lbPool->FreeLineBuffer(lb); // free geometry when done stylizing
+ if (lb)
+ m_lbPool->FreeLineBuffer(lb); // free geometry when done stylizing
- if (cancel && cancel(userData)) break;
+ if (cancel && cancel(userData)) break;
+ }
+
+ #ifdef _DEBUG
+ printf(" DefaultStylizer::StylizeVectorLayer() Layer: %S Features: %d\n", layer->GetFeatureName().c_str(), nFeatures);
+ #endif
}
- #ifdef _DEBUG
- printf(" DefaultStylizer::StylizeVectorLayer() Layer: %S Features: %d\n", layer->GetFeatureName().c_str(), nFeatures);
- #endif
-
//need the cast due to multiple inheritance resulting in two Disposables
//in the vtable of FilterExecutor
((FdoIExpressionProcessor*)exec)->Release();
Modified: trunk/MgDev/Common/Stylization/StylizationEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/StylizationEngine.cpp 2007-03-15 19:57:54 UTC (rev 1246)
+++ trunk/MgDev/Common/Stylization/StylizationEngine.cpp 2007-03-16 00:10:53 UTC (rev 1247)
@@ -25,7 +25,8 @@
#include "SE_SymbolManager.h"
#include "SE_PositioningAlgorithms.h"
#include "RS_FontEngine.h"
-
+#include "FeatureTypeStyleVisitor.h"
+#include "LineBuffer.h"
#include "Renderer.h"
#include <algorithm>
@@ -36,11 +37,10 @@
StylizationEngine::StylizationEngine(SE_SymbolManager* resources) :
m_resources(resources),
- m_renderer(NULL),
- m_exec(NULL),
- m_reader(NULL)
+ m_serenderer(NULL)
{
m_pool = new SE_LineBufferPool;
+ m_lbPool = new LineBufferPool;
m_visitor = new SE_StyleVisitor(resources, m_pool);
}
@@ -48,32 +48,124 @@
{
ClearCache();
delete m_pool;
+ delete m_lbPool;
delete m_visitor;
}
-void StylizationEngine::Stylize( SE_Renderer* renderer,
- RS_FeatureReader* feature,
- RS_FilterExecutor* executor,
- LineBuffer* geometry,
- CompositeTypeStyle* style,
- SE_String* seTip,
- SE_String* seUrl,
- RS_ElevationSettings* /*elevSettings*/)
+
+/* TODO: Stylize one CompoundSymbol feature and label per run; investigate caching
+ * possiblities to avoid filter execution on subsequent passes */
+void StylizationEngine::StylizeVectorLayer(MdfModel::VectorLayerDefinition* layer,
+ MdfModel::VectorScaleRange* range,
+ Renderer* renderer,
+ RS_FeatureReader* reader,
+ RS_FilterExecutor* executor,
+ CSysTransformer* xformer,
+ CancelStylization cancel,
+ void* userData)
{
- if (renderer == NULL || feature == NULL || executor == NULL)
+ if (reader == NULL || executor == NULL)
return;
- m_renderer = renderer;
- m_reader = feature;
- m_exec = executor;
+ // make sure we have an SE renderer
+ // TODO: eliminate the need to do dynamic casts on these renderers. We should
+ // probably ultimately have just one renderer interface class...
+ m_serenderer = dynamic_cast<SE_Renderer*>(renderer);
+ if (m_serenderer == NULL)
+ return;
- SE_Matrix w2s;
- m_renderer->GetWorldToScreenTransform(w2s);
- m_renderer->SetLineBufferPool(m_pool);
+ // get the geometry column name
+ const wchar_t* gpName = reader->GetGeomPropName();
+ if (NULL == gpName)
+ return;
- double mm2pxs = m_renderer->GetPixelsPerMillimeterScreen();
- double mm2pxw = m_renderer->GetPixelsPerMillimeterWorld();
+ m_serenderer->SetLineBufferPool(m_pool);
+ // get tooltip and url for the layer
+ SE_String seTip;
+ SE_String seUrl;
+ m_visitor->ParseStringExpression(layer->GetToolTip(), seTip);
+ m_visitor->ParseStringExpression(layer->GetUrl(), seUrl);
+
+ MdfModel::FeatureTypeStyleCollection* ftsc = range->GetFeatureTypeStyles();
+
+ bool bClip = renderer->RequiresClipping();
+
+ #ifdef _DEBUG
+ int nFeatures = 0;
+ #endif
+
+ //main loop over feature data
+ while (reader->ReadNext())
+ {
+ #ifdef _DEBUG
+ nFeatures++;
+ #endif
+
+ LineBuffer* lb = NULL;
+
+ //get the geometry just once
+ //all types of geometry
+ lb = m_lbPool->NewLineBuffer(8);
+ reader->GetGeometry(gpName, lb, xformer);
+
+ if (lb && bClip)
+ {
+ //clip geometry to given map request extents
+ //TODO: is this the right place to do so?
+ LineBuffer* lbc = lb->Clip(renderer->GetBounds(), LineBuffer::ctAGF, m_lbPool);
+
+ //did geom require clipping?
+ //free original line buffer
+ //note original geometry is still accessible to the
+ //user from the RS_FeatureReader::GetGeometry
+ if (lbc != lb)
+ {
+ m_lbPool->FreeLineBuffer(lb);
+ lb = lbc;
+ }
+ }
+
+ if (!lb) continue;
+
+ //need to clear out the filter execution engine cache
+ //some feature attributes may be cached while executing theming
+ //expressions and this call flushes that
+ executor->Reset();
+
+ // we need to stylize once for each FeatureTypeStyle that matches
+ // the geometry type (Note: this may have to change to match
+ // feature classes)
+ for (int i=0; i<ftsc->GetCount(); i++)
+ {
+ MdfModel::FeatureTypeStyle* fts = ftsc->GetAt(i);
+ if (FeatureTypeStyleVisitor::DetermineFeatureTypeStyle(fts) == FeatureTypeStyleVisitor::ftsComposite)
+ Stylize(reader, executor, lb, (CompositeTypeStyle*)fts, &seTip, &seUrl, NULL);
+ }
+
+ if (lb)
+ m_lbPool->FreeLineBuffer(lb); // free geometry when done stylizing
+
+ if (cancel && cancel(userData)) break;
+ }
+
+ #ifdef _DEBUG
+ printf(" StylizationEngine::StylizeVectorLayer() Layer: %S Features: %d\n", layer->GetFeatureName().c_str(), nFeatures);
+ #endif
+}
+
+
+void StylizationEngine::Stylize(RS_FeatureReader* reader,
+ RS_FilterExecutor* executor,
+ LineBuffer* geometry,
+ CompositeTypeStyle* style,
+ SE_String* seTip,
+ SE_String* seUrl,
+ RS_ElevationSettings* /*elevSettings*/)
+{
+ double mm2pxs = m_serenderer->GetPixelsPerMillimeterScreen();
+ double mm2pxw = m_serenderer->GetPixelsPerMillimeterWorld();
+
SE_Rule*& rules = m_rules[style];
RuleCollection* rulecoll = style->GetRules();
int nRules = rulecoll->GetCount();
@@ -131,16 +223,16 @@
// TODO: eliminate the need to do dynamic casts on these renderers. We should
// probably ultimately have just one renderer interface class...
- Renderer* baseRenderer = dynamic_cast<Renderer*>(m_renderer);
- if (baseRenderer != NULL)
+ Renderer* renderer = dynamic_cast<Renderer*>(m_serenderer);
+ if (renderer)
{
- const wchar_t* strTip = seTip->evaluate(m_exec);
- const wchar_t* strUrl = seUrl->evaluate(m_exec);
+ const wchar_t* strTip = seTip->evaluate(executor);
+ const wchar_t* strUrl = seUrl->evaluate(executor);
RS_String rs_tip = strTip? strTip : L"";
RS_String rs_url = strUrl? strUrl : L"";
RS_String& rs_thm = rule->legendLabel;
- baseRenderer->StartFeature(feature, rs_tip.empty()? NULL : &rs_tip, rs_url.empty()? NULL : &rs_url, rs_thm.empty()? NULL : &rs_thm);
+ renderer->StartFeature(reader, rs_tip.empty()? NULL : &rs_tip, rs_url.empty()? NULL : &rs_url, rs_thm.empty()? NULL : &rs_thm);
}
/* TODO: Obey the indices--Get rid of the indices altogther--single pass! */
@@ -149,12 +241,12 @@
{
SE_Symbolization* sym = *iter;
- double mm2px = (sym->context == MappingUnits ? mm2pxw : mm2pxs);
+ double mm2px = (sym->context == MappingUnits)? mm2pxw : mm2pxs;
SE_Matrix xform;
- xform.setTransform( sym->scale[0].evaluate(m_exec),
- sym->scale[1].evaluate(m_exec),
- sym->absOffset[0].evaluate(m_exec)*mm2px,
- sym->absOffset[1].evaluate(m_exec)*mm2px );
+ xform.setTransform( sym->scale[0].evaluate(executor),
+ sym->scale[1].evaluate(executor),
+ sym->absOffset[0].evaluate(executor)*mm2px,
+ sym->absOffset[1].evaluate(executor)*mm2px );
xform.scale(mm2px, mm2px);
for (std::vector<SE_Style*>::const_iterator siter = sym->styles.begin(); siter != sym->styles.end(); siter++)
@@ -171,24 +263,24 @@
{
case SE_PointStyleType:
//this call may modify xform to apply the necessary rotation
- rstyle = EvaluatePointStyle(geometry, tmpxform, (SE_PointStyle*)style, mm2px);
+ rstyle = EvaluatePointStyle(executor, geometry, tmpxform, (SE_PointStyle*)style, mm2px);
break;
case SE_LineStyleType:
- rstyle = EvaluateLineStyle(tmpxform, (SE_LineStyle*)style);
+ rstyle = EvaluateLineStyle(executor, tmpxform, (SE_LineStyle*)style);
break;
case SE_AreaStyleType:
- rstyle = EvaluateAreaStyle(tmpxform, (SE_AreaStyle*)style);
+ rstyle = EvaluateAreaStyle(executor, tmpxform, (SE_AreaStyle*)style);
break;
}
//evaluate values that are common to all styles
- rstyle->renderPass = style->renderPass.evaluate(m_exec);
- rstyle->addToExclusionRegions = sym->addToExclusionRegions.evaluate(m_exec);
- rstyle->checkExclusionRegions = sym->checkExclusionRegions.evaluate(m_exec);
- rstyle->drawLast = sym->drawLast.evaluate(m_exec);
+ rstyle->renderPass = style->renderPass.evaluate(executor);
+ rstyle->addToExclusionRegions = sym->addToExclusionRegions.evaluate(executor);
+ rstyle->checkExclusionRegions = sym->checkExclusionRegions.evaluate(executor);
+ rstyle->drawLast = sym->drawLast.evaluate(executor);
//evaluate the graphic elements
- EvaluateSymbols(tmpxform, style, rstyle, mm2px);
+ EvaluateSymbols(executor, tmpxform, style, rstyle, mm2px);
if (!sym->positioningAlgorithm.empty() && sym->positioningAlgorithm != L"Default")
{
@@ -199,13 +291,13 @@
switch(style->type)
{
case SE_PointStyleType:
- m_renderer->ProcessPoint(geometry, (SE_RenderPointStyle*)rstyle);
+ m_serenderer->ProcessPoint(geometry, (SE_RenderPointStyle*)rstyle);
break;
case SE_LineStyleType:
- m_renderer->ProcessLine(geometry, (SE_RenderLineStyle*)rstyle);
+ m_serenderer->ProcessLine(geometry, (SE_RenderLineStyle*)rstyle);
break;
case SE_AreaStyleType:
- m_renderer->ProcessArea(geometry, (SE_RenderAreaStyle*)rstyle);
+ m_serenderer->ProcessArea(geometry, (SE_RenderAreaStyle*)rstyle);
break;
}
}
@@ -217,7 +309,12 @@
}
}
-SE_RenderPointStyle* StylizationEngine::EvaluatePointStyle(LineBuffer* geometry, SE_Matrix& xform, SE_PointStyle* style, double mm2px)
+
+SE_RenderPointStyle* StylizationEngine::EvaluatePointStyle(RS_FilterExecutor* executor,
+ LineBuffer* geometry,
+ SE_Matrix& xform,
+ SE_PointStyle* style,
+ double mm2px)
{
SE_RenderPointStyle* render = new SE_RenderPointStyle();
@@ -242,7 +339,7 @@
}
double angle = 0.0;
- const wchar_t* angleControl = style->angleControl.evaluate(m_exec);
+ const wchar_t* angleControl = style->angleControl.evaluate(executor);
if (wcscmp(L"FromGeometry", angleControl) == 0)
{
if (type == LineBuffer::ctLine || type == LineBuffer::ctArea)
@@ -259,10 +356,10 @@
}
}
else
- angle = style->angle.evaluate(m_exec) * M_PI180;
+ angle = style->angle.evaluate(executor) * M_PI180;
- double originOffsetX = style->originOffset[0].evaluate(m_exec)*mm2px;
- double originOffsetY = style->originOffset[1].evaluate(m_exec)*mm2px;
+ double originOffsetX = style->originOffset[0].evaluate(executor)*mm2px;
+ double originOffsetY = style->originOffset[1].evaluate(executor)*mm2px;
SE_Matrix sxform;
sxform.translate(originOffsetX, originOffsetY);
@@ -273,54 +370,56 @@
return render;
}
-SE_RenderLineStyle* StylizationEngine::EvaluateLineStyle(SE_Matrix& xform, SE_LineStyle* style)
+
+SE_RenderLineStyle* StylizationEngine::EvaluateLineStyle(RS_FilterExecutor* executor, SE_Matrix& xform, SE_LineStyle* style)
{
SE_RenderLineStyle* render = new SE_RenderLineStyle();
- render->angleControl = style->angleControl.evaluate(m_exec);
- render->unitsControl = style->unitsControl.evaluate(m_exec);
- render->vertexControl = style->vertexControl.evaluate(m_exec);
+ render->angleControl = style->angleControl.evaluate(executor);
+ render->unitsControl = style->unitsControl.evaluate(executor);
+ render->vertexControl = style->vertexControl.evaluate(executor);
// 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;
+ render->angle = style->angle.evaluate(executor) * M_PI180;
+ render->startOffset = style->startOffset.evaluate(executor)*xform.x0; // x0 is x scale * mm2px
+ render->endOffset = style->endOffset.evaluate(executor)*xform.x0;
+ render->repeat = style->repeat.evaluate(executor)*xform.x0;
+ render->vertexAngleLimit = style->vertexAngleLimit.evaluate(executor) * M_PI180;
return render;
}
-SE_RenderAreaStyle* StylizationEngine::EvaluateAreaStyle(SE_Matrix& /*xform*/, SE_AreaStyle* style)
+
+SE_RenderAreaStyle* StylizationEngine::EvaluateAreaStyle(RS_FilterExecutor* executor, SE_Matrix& /*xform*/, SE_AreaStyle* style)
{
SE_RenderAreaStyle* render = new SE_RenderAreaStyle();
- render->angleControl = style->angleControl.evaluate(m_exec);
- render->originControl = style->originControl.evaluate(m_exec);
- render->clippingControl = style->clippingControl.evaluate(m_exec);
+ render->angleControl = style->angleControl.evaluate(executor);
+ render->originControl = style->originControl.evaluate(executor);
+ render->clippingControl = style->clippingControl.evaluate(executor);
- 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->angle = style->angle.evaluate(executor) * M_PI180;
+ render->origin[0] = style->origin[0].evaluate(executor);
+ render->origin[1] = style->origin[1].evaluate(executor);
+ render->repeat[0] = style->repeat[0].evaluate(executor);
+ render->repeat[1] = style->repeat[1].evaluate(executor);
+ render->bufferWidth = style->bufferWidth.evaluate(executor);
return render;
}
-void StylizationEngine::EvaluateSymbols(SE_Matrix& xform, SE_Style* style, SE_RenderStyle* renderStyle, double mm2px)
+void StylizationEngine::EvaluateSymbols(RS_FilterExecutor* executor, SE_Matrix& xform, SE_Style* style, SE_RenderStyle* renderStyle, double mm2px)
{
double dx, dy, sx, sy;
double minx, maxx, miny, maxy;
double growx, growy;
if (style->useBox)
{
- dx = style->resizePosition[0].evaluate(m_exec);
- dy = style->resizePosition[1].evaluate(m_exec);
- sx = style->resizeSize[0].evaluate(m_exec)/2.0;
- sy = style->resizeSize[1].evaluate(m_exec)/2.0;
+ dx = style->resizePosition[0].evaluate(executor);
+ dy = style->resizePosition[1].evaluate(executor);
+ sx = style->resizeSize[0].evaluate(executor)/2.0;
+ sy = style->resizeSize[1].evaluate(executor)/2.0;
xform.transform(dx - sx, dy - sy, minx, miny);
xform.transform(dx + sx, dy + sy, maxx, maxy);
@@ -330,6 +429,9 @@
growy = 0.0;
}
+ double mm2pxs = m_serenderer->GetPixelsPerMillimeterScreen();
+ double mm2pxw = m_serenderer->GetPixelsPerMillimeterWorld();
+
for (SE_PrimitiveList::const_iterator src = style->symbol.begin(); src != style->symbol.end(); src++)
{
SE_Primitive* sym = *src;
@@ -339,19 +441,17 @@
{
case SE_PolygonPrimitive:
rsym = new SE_RenderPolygon();
- ((SE_RenderPolygon*)rsym)->fill = ((SE_Polygon*)sym)->fill.evaluate(m_exec);
+ ((SE_RenderPolygon*)rsym)->fill = ((SE_Polygon*)sym)->fill.evaluate(executor);
case SE_PolylinePrimitive:
{
if (!rsym) rsym = new SE_RenderPolyline();
- SE_Polyline* p = (SE_Polyline*) sym;
+ SE_Polyline* p = (SE_Polyline*)sym;
SE_RenderPolyline* rp = (SE_RenderPolyline*)rsym;
- double wx = p->weightScalable.evaluate(m_exec) ?
- m_renderer->GetPixelsPerMillimeterWorld() :
- m_renderer->GetPixelsPerMillimeterScreen();
- rp->weight = p->weight.evaluate(m_exec)*wx;
+ double wx = p->weightScalable.evaluate(executor)? mm2pxw : mm2pxs;
+ rp->weight = p->weight.evaluate(executor) * wx;
rp->geometry = p->geometry->Clone();
- rp->color = p->color.evaluate(m_exec);
+ rp->color = p->color.evaluate(executor);
/* Defer transformation */
if (sym->resize != GraphicElement::AdjustToResizeBox)
{
@@ -368,27 +468,27 @@
rsym = new SE_RenderText();
SE_Text* t = (SE_Text*)sym;
SE_RenderText* rt = (SE_RenderText*)rsym;
- rt->text = t->textExpr.evaluate(m_exec);
- rt->position[0] = t->position[0].evaluate(m_exec);
- rt->position[1] = t->position[1].evaluate(m_exec);
+ rt->text = t->textExpr.evaluate(executor);
+ rt->position[0] = t->position[0].evaluate(executor);
+ rt->position[1] = t->position[1].evaluate(executor);
xform.transform(rt->position[0], rt->position[1]);
- rt->tdef.rotation() = t->angle.evaluate(m_exec);;
+ rt->tdef.rotation() = t->angle.evaluate(executor);;
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;
+ if (t->underlined.evaluate(executor)) style |= (int)RS_FontStyle_Underline;
+ if (t->italic.evaluate(executor)) style |= (int)RS_FontStyle_Italic;
+ if (t->bold.evaluate(executor)) 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.font().name() = t->fontExpr.evaluate(executor);
+ rt->tdef.font().height() = t->size.evaluate(executor)*0.001*xform.y1/mm2px; //convert mm to meters which is what RS_TextDef expects
+ rt->tdef.linespace() = t->lineSpacing.evaluate(executor);
- rt->tdef.color() = RS_Color::FromARGB(t->textColor.evaluate(m_exec));
- rt->tdef.bgcolor() = RS_Color::FromARGB(t->ghostColor.evaluate(m_exec));
+ rt->tdef.color() = RS_Color::FromARGB(t->textColor.evaluate(executor));
+ rt->tdef.bgcolor() = RS_Color::FromARGB(t->ghostColor.evaluate(executor));
- const wchar_t* hAlign = t->hAlignment.evaluate(m_exec);
+ const wchar_t* hAlign = t->hAlignment.evaluate(executor);
if (hAlign)
{
if (wcscmp(hAlign, L"Left") == 0)
@@ -399,7 +499,7 @@
rt->tdef.halign() = RS_HAlignment_Right;
}
- const wchar_t* vAlign = t->vAlignment.evaluate(m_exec);
+ const wchar_t* vAlign = t->vAlignment.evaluate(executor);
if (vAlign)
{
if (wcscmp(vAlign, L"Bottom") == 0)
@@ -416,7 +516,7 @@
RS_TextMetrics tm;
SE_Matrix txf;
- m_renderer->GetFontEngine()->GetTextMetrics(rt->text, rt->tdef, tm, false);
+ m_serenderer->GetFontEngine()->GetTextMetrics(rt->text, rt->tdef, tm, false);
txf.rotate(rt->tdef.rotation() * M_PI180);
txf.translate(rt->position[0], rt->position[1]);
@@ -448,7 +548,7 @@
if (!r->pngPtr)
{
- rr->pngPtr = m_resources->GetImageData(r->pngPath.evaluate(m_exec), rr->pngSize);
+ rr->pngPtr = m_resources->GetImageData(r->pngPath.evaluate(executor), rr->pngSize);
}
else
{
@@ -456,12 +556,12 @@
rr->pngSize = r->pngSize;
}
- rr->position[0] = r->position[0].evaluate(m_exec);
- rr->position[1] = r->position[1].evaluate(m_exec);
+ rr->position[0] = r->position[0].evaluate(executor);
+ rr->position[1] = r->position[1].evaluate(executor);
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_PI180;
+ rr->extent[0] = r->extent[0].evaluate(executor)*xform.x0;
+ rr->extent[1] = r->extent[1].evaluate(executor)*xform.y1;
+ rr->angle = r->angle.evaluate(executor) * M_PI180;
SE_Matrix rxf;
rxf.rotate(rr->angle);
@@ -490,7 +590,7 @@
if (rsym)
{
- rsym->resize = sym->resize == GraphicElement::AdjustToResizeBox;
+ rsym->resize = (sym->resize == GraphicElement::AdjustToResizeBox);
if (!rsym->resize)
{
@@ -590,14 +690,15 @@
//here we decide which one to call based on the name of the positioning algorithm
if (positioningAlgo == L"EightSurrounding")
{
- SE_PositioningAlgorithms::EightSurrounding(m_renderer, geometry, xform, style, rstyle, mm2px);
+ SE_PositioningAlgorithms::EightSurrounding(m_serenderer, geometry, xform, style, rstyle, mm2px);
}
else if (positioningAlgo == L"PathLabels")
{
- SE_PositioningAlgorithms::PathLabels(m_renderer, geometry, xform, style, rstyle, mm2px);
+ SE_PositioningAlgorithms::PathLabels(m_serenderer, geometry, xform, style, rstyle, mm2px);
}
}
+
//clears cached filters/styles/etc
void StylizationEngine::ClearCache()
{
@@ -611,9 +712,3 @@
m_rules.clear();
}
-
-//parses a string expression
-void StylizationEngine::ParseStringExpression(const MdfString& mdf_string, SE_String& se_string)
-{
- m_visitor->ParseStringExpression(mdf_string, se_string);
-}
Modified: trunk/MgDev/Common/Stylization/StylizationEngine.h
===================================================================
--- trunk/MgDev/Common/Stylization/StylizationEngine.h 2007-03-15 19:57:54 UTC (rev 1246)
+++ trunk/MgDev/Common/Stylization/StylizationEngine.h 2007-03-16 00:10:53 UTC (rev 1247)
@@ -18,6 +18,7 @@
#ifndef STYLIZATION_ENGINE_H
#define STYLIZATION_ENGINE_H
+#include "Stylizer.h"
#include "SE_Matrix.h"
#include "SE_Include.h"
@@ -29,6 +30,7 @@
class SE_Renderer;
class SE_StyleVisitor;
class LineBuffer;
+class LineBufferPool;
class RS_ElevationSettings;
namespace MDFMODEL_NAMESPACE
@@ -42,13 +44,20 @@
{
public:
StylizationEngine(SE_SymbolManager* resources);
- /* TODO: don't leak basically everything */
~StylizationEngine();
- /* TODO: add stylize layer to this class, and reset functionality to RS_FeatureReader API & implementations
- * Stylize one CompoundSymbol feature and label per run; investigate caching possiblities to avoid
- * filter execution on subsequent passes */
- void Stylize(SE_Renderer* renderer,
- RS_FeatureReader* feature,
+
+ // Stylizes the supplied layer using all composite type styles in the given scale.
+ void StylizeVectorLayer(MdfModel::VectorLayerDefinition* layer,
+ MdfModel::VectorScaleRange* range,
+ Renderer* renderer,
+ RS_FeatureReader* reader,
+ RS_FilterExecutor* executor,
+ CSysTransformer* xformer,
+ CancelStylization cancel,
+ void* userData);
+
+ // Stylizes the current feature on the reader using the supplied composite type style.
+ void Stylize(RS_FeatureReader* reader,
RS_FilterExecutor* executor,
LineBuffer* geometry,
CompositeTypeStyle* style,
@@ -58,24 +67,21 @@
void ClearCache();
- void ParseStringExpression(const MdfString& mdf_string, SE_String& se_string);
-
private:
- SE_RenderPointStyle* EvaluatePointStyle(LineBuffer* geometry, SE_Matrix& xform, SE_PointStyle* style, double mm2px);
- SE_RenderAreaStyle* EvaluateAreaStyle(SE_Matrix& xform, SE_AreaStyle* style);
- SE_RenderLineStyle* EvaluateLineStyle(SE_Matrix& xform, SE_LineStyle* style);
+ SE_RenderPointStyle* EvaluatePointStyle(RS_FilterExecutor* executor, LineBuffer* geometry, SE_Matrix& xform, SE_PointStyle* style, double mm2px);
+ SE_RenderLineStyle* EvaluateLineStyle(RS_FilterExecutor* executor, SE_Matrix& xform, SE_LineStyle* style);
+ SE_RenderAreaStyle* EvaluateAreaStyle(RS_FilterExecutor* executor, SE_Matrix& xform, SE_AreaStyle* style);
void LayoutCustomLabel(const std::wstring& positioningAlgo, LineBuffer* geometry, SE_Matrix& xform, SE_Style* style, SE_RenderStyle* rstyle, double mm2px);
- void EvaluateSymbols(SE_Matrix& xform, SE_Style* style, SE_RenderStyle* renderStyle, double mm2px);
+ void EvaluateSymbols(RS_FilterExecutor* executor, SE_Matrix& xform, SE_Style* style, SE_RenderStyle* renderStyle, double mm2px);
private:
- SE_Renderer* m_renderer;
- RS_FilterExecutor* m_exec;
- RS_FeatureReader* m_reader;
+ SE_Renderer* m_serenderer;
SE_SymbolManager* m_resources;
SE_LineBufferPool* m_pool;
SE_StyleVisitor* m_visitor;
std::map<CompositeTypeStyle*, SE_Rule*> m_rules;
+ LineBufferPool* m_lbPool;
};
#endif // STYLIZATION_ENGINE_H
More information about the mapguide-commits
mailing list