本文整理汇总了C++中LineBuffer::y_coord方法的典型用法代码示例。如果您正苦于以下问题:C++ LineBuffer::y_coord方法的具体用法?C++ LineBuffer::y_coord怎么用?C++ LineBuffer::y_coord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LineBuffer
的用法示例。
在下文中一共展示了LineBuffer::y_coord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessArea
///////////////////////////////////////////////////////////////////////////////
// Called when applying an area style on a feature geometry. Area styles can
// can only be applied to polygon feature geometry types.
void SE_Renderer::ProcessArea(SE_ApplyContext* ctx, SE_RenderAreaStyle* style)
{
// the feature geometry we're applying the style on...
LineBuffer* featGeom = ctx->geometry;
// can't apply an area style to point and linestring geometry types
switch (featGeom->geom_type())
{
case GeometryType_Point:
case GeometryType_MultiPoint:
case GeometryType_LineString:
case GeometryType_MultiLineString:
case GeometryType_CurveString:
case GeometryType_MultiCurveString:
return;
}
SE_Matrix w2s;
GetWorldToScreenTransform(w2s);
//--------------------------------------------------------------
// special code to handle simple solid fill styles
//--------------------------------------------------------------
if (style->solidFill)
{
// just draw it and bail out of the layout function
SE_RenderPolygon* rp = (SE_RenderPolygon*)style->symbol[0];
if (m_bSelectionMode)
DrawScreenPolygon(featGeom, &w2s, m_selFillColor);
else
DrawScreenPolygon(featGeom, &w2s, rp->fill);
return;
}
// transform the feature geometry to rendering space
LineBuffer* xfgeom = LineBufferPool::NewLineBuffer(m_pPool, featGeom->point_count());
std::auto_ptr<LineBuffer> spLB(xfgeom);
*xfgeom = *featGeom;
int size = featGeom->point_count();
for (int i=0; i<size; ++i)
w2s.transform(xfgeom->x_coord(i), xfgeom->y_coord(i));
// recompute the bounds
RS_Bounds& bounds = const_cast<RS_Bounds&>(xfgeom->bounds());
bounds.minx = bounds.miny = bounds.minz = +DBL_MAX;
bounds.maxx = bounds.maxy = bounds.maxz = -DBL_MAX;
xfgeom->ComputeBounds(bounds);
// account for any viewport rotation
SE_AreaPositioning ap(xfgeom, style, GetWorldToScreenRotation());
double baserot = ap.PatternRotation();
SE_Matrix xform;
SE_Matrix xformbase = *ctx->xform;
xformbase.rotate(baserot);
for (const Point2D* pos = ap.NextLocation(); pos != NULL; pos = ap.NextLocation())
{
xform = xformbase;
xform.translate(pos->x, pos->y);
DrawSymbol(style->symbol, xform, baserot, style->addToExclusionRegion);
}
LineBufferPool::FreeLineBuffer(m_pPool, spLB.release());
}
示例2: MultipleHighwaysShields
void SE_PositioningAlgorithms::MultipleHighwaysShields(SE_ApplyContext* applyCtx,
SE_RenderStyle* rstyle,
double mm2su,
RS_FeatureReader* featureReader,
SE_SymbolManager* symbolManager)
{
if (featureReader == NULL)
return;
SE_Renderer* se_renderer = applyCtx->renderer;
LineBuffer* geometry = applyCtx->geometry;
// this placement algorithm only applies to line styles
if (rstyle->type != SE_RenderStyle_Line)
return;
SE_RenderLineStyle* rlStyle = (SE_RenderLineStyle*)rstyle;
// ... and the units control must be absolute
if (rlStyle->unitsControl != SE_UnitsControl_Absolute)
return;
// highway info format: countryCode|type1|num1|type2|num2|type3|num3|...
// example: US|2|101|3|1
StringOfTokens highwayInfo(featureReader->GetString(L"Url"), L"|");
int shieldCount = (highwayInfo.getTokenCount() - 1) / 2;
if (shieldCount < 1)
return;
double startOffset = rlStyle->startOffset;
double increment = rlStyle->repeat;
// the endOffset is used in this context as the increment between multiple shields in one group
// double incrementS = 10.0 * mm2su;
double incrementS = rlStyle->endOffset;
// calc the overall length of this geometry
double totalLen = 0.0;
for (int i=0; i<geometry->cntr_count(); ++i)
{
int pt = geometry->contour_start_point(i);
int last = geometry->contour_end_point(i);
while (pt < last)
{
// transform the point to screen space
double cx1, cy1, cx2, cy2;
se_renderer->WorldToScreenPoint(geometry->x_coord(pt), geometry->y_coord(pt), cx1, cy1);
pt++;
se_renderer->WorldToScreenPoint(geometry->x_coord(pt), geometry->y_coord(pt), cx2, cy2);
// calc length
double dx = cx2 - cx1;
double dy = cy2 - cy1;
totalLen += sqrt(dx*dx + dy*dy);
}
}
if (startOffset >= 0.0)
{
// calc optimal start offset (with rlStyle->startOffset taken as a minimum)
// to co-locate shield groups placed on two-line highways where the two
// parallel lines are processed from opposit ends.
// this avoids a problem with perceived irregular placement when overposting
// removes just some of the duplicate shields
double shieldGroupLen = (shieldCount - 1) * incrementS;
// length in excess of the required length to place one group with startOffset on each side
double availLen = totalLen - (shieldGroupLen + 2.0 * startOffset);
if (availLen < 0.0)
{
// there is no room to 'properly' place even one group, nothing to do but cry about it
return;
}
int numAdditionalGroups = (int) (availLen / (shieldGroupLen + increment));
double additionalOffset = (availLen - numAdditionalGroups * (shieldGroupLen + increment)) / 2;
startOffset += additionalOffset;
}
else
{
// negative startOffset value disables the optimization
// use absolute value as the offset
startOffset = -startOffset;
}
SE_RenderPrimitiveList* symbolVectors = new SE_RenderPrimitiveList[shieldCount];
std::wstring countryCode = highwayInfo.getFirstToken();
int shieldIndex;
for (shieldIndex=0; shieldIndex<shieldCount; ++shieldIndex)
{
std::wstring shieldType = highwayInfo.getNextToken();
std::wstring highwayNum = highwayInfo.getNextToken();
//.........这里部分代码省略.........