当前位置: 首页>>代码示例>>C++>>正文


C++ LineBuffer::geom_type方法代码示例

本文整理汇总了C++中LineBuffer::geom_type方法的典型用法代码示例。如果您正苦于以下问题:C++ LineBuffer::geom_type方法的具体用法?C++ LineBuffer::geom_type怎么用?C++ LineBuffer::geom_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LineBuffer的用法示例。


在下文中一共展示了LineBuffer::geom_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PathLabels

void SE_PositioningAlgorithms::PathLabels(SE_ApplyContext* applyCtx,
                                          SE_RenderStyle*  rstyle)
{
    SE_Renderer* se_renderer = applyCtx->renderer;
    LineBuffer* geometry = applyCtx->geometry;

    // path labeling only applies to linestring feature geometry
    switch (geometry->geom_type())
    {
        case GeometryType_LineString:
        case GeometryType_MultiLineString:
        case GeometryType_CurveString:
        case GeometryType_MultiCurveString:
            break;

        default:
            return;
    }

    // in the case of a point style, just use the default placement algorithm
    if (rstyle->type == SE_RenderStyle_Point)
        return SE_PositioningAlgorithms::Default(applyCtx, rstyle);

    // path labeling using an area style is not supported
    if (rstyle->type == SE_RenderStyle_Area)
        return;

    // the style needs to contain at least one primitive
    SE_RenderPrimitiveList& prims = rstyle->symbol;
    if (prims.size() == 0)
        return;

    // If the symbol contains just a single text element then add the
    // text as a regular path label (non-symbol).  Use 0.5 as the
    // default value for the scale limit.
    if (prims.size() == 1 && prims[0]->type == SE_RenderPrimitive_Text)
    {
        SE_RenderText* rt = (SE_RenderText*)prims[0];

        RS_LabelInfo info(0.0, 0.0, 0.0, 0.0, RS_Units_Device, rt->tdef);
        RS_OverpostType overpostType = rstyle->checkExclusionRegion? RS_OverpostType_AllFit : RS_OverpostType_All;
        return se_renderer->ProcessLabelGroup(&info, 1, rt->content, overpostType, rstyle->addToExclusionRegion, geometry, 0.5);
    }

    se_renderer->ProcessLineLabels(geometry, (SE_RenderLineStyle*)rstyle);
}
开发者ID:jumpinjackie,项目名称:mg-playground,代码行数:46,代码来源:SE_PositioningAlgorithms.cpp

示例2: 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());
}
开发者ID:jumpinjackie,项目名称:mg-playground,代码行数:71,代码来源:SE_Renderer.cpp

示例3: ProcessLine

///////////////////////////////////////////////////////////////////////////////
// Called when applying a line style on a feature geometry.  Line styles can
// only be applied to linestring and polygon feature geometry types.
void SE_Renderer::ProcessLine(SE_ApplyContext* ctx, SE_RenderLineStyle* style)
{
    // the feature geometry we're applying the style on...
    LineBuffer* featGeom = ctx->geometry;

    // can't apply a line style to point geometry types
    switch (featGeom->geom_type())
    {
        case GeometryType_Point:
        case GeometryType_MultiPoint:
            return;
    }

    //--------------------------------------------------------------
    // special code to handle simple straight solid line styles
    //--------------------------------------------------------------

    if (style->solidLine)
    {
        // just draw it and bail out of the layout function
        SE_RenderPolyline* rp = (SE_RenderPolyline*)style->symbol[0];

        SE_Matrix w2s;
        GetWorldToScreenTransform(w2s);
        if (m_bSelectionMode)
        {
            m_selLineStroke.cap        = rp->lineStroke.cap;
            m_selLineStroke.join       = rp->lineStroke.join;
            m_selLineStroke.miterLimit = rp->lineStroke.miterLimit;
            DrawScreenPolyline(featGeom, &w2s, m_selLineStroke);
        }
        else
            DrawScreenPolyline(featGeom, &w2s, rp->lineStroke);
        return;
    }

    //--------------------------------------------------------------
    // handle the case repeat <= 0 - here we ignore vertex control
    //--------------------------------------------------------------

    if (style->repeat <= 0.0)
    {
        // this can be handled using the overlap direct algorithm with:
        // - repeat set to larger than each contour length
        // - vertex angle limit set to >180 degrees
        double old_val = style->vertexAngleLimit;
        double old_rep = style->repeat;
        style->vertexAngleLimit = M_PI + 1.0;   // any value greater than M_PI
        style->repeat = DBL_MAX;

        ProcessLineOverlapDirect(featGeom, style);

        style->vertexAngleLimit = old_val;
        style->repeat = old_rep;
        return;
    }

    //--------------------------------------------------------------
    // check the vertex control type and call the appropriate helper
    //--------------------------------------------------------------

    if (style->vertexControl == SE_VertexControl_OverlapNone)
        ProcessLineOverlapNone(featGeom, style);
    else if (style->vertexControl == SE_VertexControl_OverlapDirect)
        ProcessLineOverlapDirect(featGeom, style);
    else
        ProcessLineOverlapWrap(featGeom, style);
}
开发者ID:jumpinjackie,项目名称:mg-playground,代码行数:71,代码来源:SE_Renderer.cpp

示例4: ProcessPoint

///////////////////////////////////////////////////////////////////////////////
// Called when applying a point style on a feature geometry.  Point styles can
// be applied to all feature geometry types.
void SE_Renderer::ProcessPoint(SE_ApplyContext* ctx, SE_RenderPointStyle* style, RS_Bounds* bounds)
{
    // the feature geometry we're applying the style on...
    LineBuffer* featGeom = ctx->geometry;

    double angleRad = 0.0;
    if (style->angleControl == SE_AngleControl_FromGeometry)
    {
        switch (featGeom->geom_type())
        {
            case GeometryType_LineString:
            case GeometryType_MultiLineString:
            case GeometryType_Polygon:
            case GeometryType_MultiPolygon:
            {
                double x0, y0;
                featGeom->Centroid(LineBuffer::ctLine, &x0, &y0, &angleRad);
                break;
            }
        }
    }

    angleRad += style->angleRad;

    // also account for any viewport rotation
    angleRad += GetWorldToScreenRotation();

    SE_Matrix xform;
    bool yUp = YPointsUp();

    // see StylizationEngine::Stylize for a detailed explanation of these transforms
    SE_Matrix xformbase;
    xformbase.translate(style->offset[0], style->offset[1]);
    xformbase.rotate(yUp? angleRad : -angleRad);
    xformbase.premultiply(*ctx->xform);

    // render the points
    for (int i=0; i<featGeom->point_count(); ++i)
    {
        double x, y;
        featGeom->get_point(i, x, y);

        // transform to screen space - feature geometry is in [the original] mapping space
        WorldToScreenPoint(x, y, x, y);

        xform = xformbase;
        xform.translate(x, y);

        if (style->drawLast)
            AddLabel(featGeom, style, xform, angleRad);
        else
            DrawSymbol(style->symbol, xform, angleRad, style->addToExclusionRegion);
    }

    if (bounds)
    {
        // get the symbol bounds after applying the transforms
        bounds->minx = bounds->miny = +DBL_MAX;
        bounds->maxx = bounds->maxy = -DBL_MAX;
        for (int i=0; i<4; ++i)
        {
            RS_F_Point xfpt;
            xformbase.transform(style->bounds[i].x, style->bounds[i].y, xfpt.x, xfpt.y);
            bounds->add_point(xfpt);
        }
    }
}
开发者ID:jumpinjackie,项目名称:mg-playground,代码行数:70,代码来源:SE_Renderer.cpp

示例5: EightSurrounding

void SE_PositioningAlgorithms::EightSurrounding(SE_ApplyContext* applyCtx,
                                                SE_RenderStyle*  rstyle,
                                                double           mm2su)
{
    SE_Renderer* se_renderer = applyCtx->renderer;
    LineBuffer* geometry = applyCtx->geometry;

    // eight surrounding labeling only applies to point feature geometry
    switch (geometry->geom_type())
    {
        case GeometryType_Point:
        case GeometryType_MultiPoint:
            break;

        default:
            return;
    }

    // eight surrounding labeling only works with point styles
    if (rstyle->type != SE_RenderStyle_Point)
        return;

    // the style needs to contain at least one primitive
    SE_RenderPrimitiveList& prims = rstyle->symbol;
    if (prims.size() == 0)
        return;

    SE_RenderPointStyle* rpstyle = (SE_RenderPointStyle*)rstyle;

    // get actual feature point and transform to screen space
    // TODO: in the case of a multi-point feature we get the average of all the points;
    //       generating candidate labels around this point doesn't make a whole lot of
    //       sense
    double cx = 0.0;
    double cy = 0.0;
    geometry->Centroid(LineBuffer::ctPoint, &cx, &cy, NULL);

    // don't add a label if we can't compute the centroid
    if (_isnan(cx) || _isnan(cy))
        return;

    se_renderer->WorldToScreenPoint(cx, cy, cx, cy);

    // Get the extent of the last drawn point symbol so that we know how much to offset
    // the label.  This call assumes the symbol draws right before the label.
    // TODO: remove this assumption
    const RS_F_Point* cfpts = se_renderer->GetLastSymbolExtent();
    RS_F_Point fpts[4];
    if(cfpts[0].x == 0 && cfpts[0].y == 0 &&
        cfpts[1].x == 0 && cfpts[1].y == 0 &&
        cfpts[2].x == 0 && cfpts[2].y == 0 &&
        cfpts[3].x == 0 && cfpts[3].y == 0)
    {
        for (int i=0; i<4; ++i)
        {
            fpts[i].x = cx;
            fpts[i].y = cy;
        }
    }
    else
        memcpy(fpts, cfpts, 4*sizeof(RS_F_Point));

    double dx = fpts[1].x - fpts[0].x;
    double dy = fpts[1].y - fpts[0].y;
    double symbol_rot_rad = atan2(dy, dx);

    // factor out position and rotation
    SE_Matrix ixform;
    ixform.translate(-cx, -cy);     // factor out point position
    ixform.rotate(-symbol_rot_rad); // factor out rotation
    for (int i=0; i<4; ++i)
        ixform.transform(fpts[i].x, fpts[i].y);

    bool yUp = se_renderer->YPointsUp();
    if (!yUp)
        symbol_rot_rad = -symbol_rot_rad;

    // unrotated bounds
    RS_Bounds symbol_bounds(fpts[0].x, fpts[0].y, fpts[2].x, fpts[2].y);
    double symbol_width  = symbol_bounds.width();   // symbol width in screen units
    double symbol_height = symbol_bounds.height();  // symbol height in screen units

    // offset the label from the symbol's edge
    double offset = POINT_LABEL_OFFSET_MM * mm2su;  // offset in screen units

    // make sure we have at least one pixel's worth of offset
    double screenUnitsPerPixel = MILLIMETERS_PER_INCH * se_renderer->GetScreenUnitsPerMillimeterDevice() / se_renderer->GetDpi();
    if (offset < screenUnitsPerPixel)
        offset = screenUnitsPerPixel;

    // compute how far label needs to be offset from center point of symbol
    double w2 = 0.5 * symbol_width;
    double h2 = 0.5 * symbol_height;
    double ch = 0.0;    // vertical center point
    double cw = 0.0;    // horizontal center point

    w2 += offset;
    h2 += offset;

    bool useBounds = symbol_bounds.IsValid();
//.........这里部分代码省略.........
开发者ID:jumpinjackie,项目名称:mg-playground,代码行数:101,代码来源:SE_PositioningAlgorithms.cpp


注:本文中的LineBuffer::geom_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。