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


C++ Graphic::GetBounds方法代码示例

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


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

示例1: Align

void Viewer::Align (GraphicComp* comp, Alignment a) {
    Graphic* g = comp->GetGraphic();
    float cl, cb, cr, ct;
    g->GetBounds(cl, cb, cr, ct);

    Perspective* p = GetPerspective();
    float mag = GetMagnification();
    float vl = float(p->curx - p->x0) / mag;
    float vb = float(p->cury - p->y0) / mag;
    float vr = float(p->curx - p->x0 + p->curwidth - 1) / mag;
    float vt = float(p->cury - p->y0 + p->curheight - 1) / mag;

    float dx, dy;

    switch (a) {
    case TopLeft:
    case CenterLeft:
    case BottomLeft:
    case Left:
        dx = vl - cl;
        break;

    case TopCenter:
    case Center:
    case BottomCenter:
        dx = (vr + vl - cr - cl) / 2;
        break;

    case TopRight:
    case CenterRight:
    case BottomRight:
    case Right:
        dx = vr - cr;
        break;
    }
    
    switch (a) {
    case TopLeft:
    case TopCenter:
    case TopRight:
    case Top:
        dy = vt - ct;
        break;

    case CenterLeft:
    case Center:
    case CenterRight:
        dy = (vt + vb - ct - cb) / 2;
        break;

    case BottomLeft:
    case BottomCenter:
    case BottomRight:
    case Bottom:
        dy = vb - cb;
        break;
    }
    MoveCmd mvcmd(GetEditor(), dx, dy);
    comp->Interpret(&mvcmd);
}
开发者ID:PNCG,项目名称:neuron,代码行数:60,代码来源:viewer.cpp

示例2: Connect

void PadComp::Connect (Connector* target, CGlue* g) {
    PadGraphic* padgr = GetPad();
    float l, b, r, t;
    padgr->GetBounds(l, b, r, t);
    float h = (r - l)/2;
    float v = (t - b)/2;

    if (target->IsA(PIN_COMP)) {
        CGlue padGlue(0, 0, h*hfil, h*hfil, v*vfil, v*vfil, h, h, v, v);
        padGlue.Interpose(g);
        csolver->Connect(this, target, &padGlue);
        Connector::Connect(target, &padGlue);

    } else if (target->IsA(HSLOT_COMP)) {
        Graphic* peergr = target->GetGraphic();
        peergr->GetBounds(l, b, r, t);
        h += (r - l)/2;
        CGlue slotGlue(0, 0, h*hfil, h*hfil, v*vfil, v*vfil, h, h, v, v);

        slotGlue.Interpose(g);
        csolver->Connect(this, target, &slotGlue);
        Connector::Connect(target, &slotGlue);

    } else if (target->IsA(VSLOT_COMP)) {
        Graphic* peergr = target->GetGraphic();
        peergr->GetBounds(l, b, r, t);
        v += (t - b)/2;
        CGlue slotGlue(0, 0, h*hfil, h*hfil, v*vfil, v*vfil, h, h, v, v);

        slotGlue.Interpose(g);
        csolver->Connect(this, target, &slotGlue);
        Connector::Connect(target, &slotGlue);

    } else if (target->IsA(PAD_COMP)) {
        Graphic* peergr = target->GetGraphic();
        peergr->GetBounds(l, b, r, t);
        h += (r - l)/2;
        v += (t - b)/2;
        CGlue padGlue(0, 0, h*hfil, h*hfil, v*vfil, v*vfil, h, h, v, v);

        padGlue.Interpose(g);
        csolver->Connect(this, target, &padGlue);
        Connector::Connect(target, &padGlue);
    }
}
开发者ID:LambdaCalculus379,项目名称:SLS-1.02,代码行数:45,代码来源:pad.c


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