Exemplo n.º 1
0
bool MgDiamond::_draw(GiGraphics& gs, const GiContext& ctx) const
{
    Point2d pts[] = { _getHandlePoint(0), _getHandlePoint(1),
        _getHandlePoint(2), _getHandlePoint(3) };
    bool ret = gs.drawPolygon(&ctx, 4, pts);
    return __super::_draw(gs, ctx) || ret;
}
Exemplo n.º 2
0
float MgDiamond::_hitTest(const Point2d& pt, float tol, 
                          Point2d& nearpt, Int32& segment) const
{
    Point2d pts[] = { _getHandlePoint(0), _getHandlePoint(1),
        _getHandlePoint(2), _getHandlePoint(3) };
    return mgLinesHit(4, pts, true, pt, tol, nearpt, segment);
}
Exemplo n.º 3
0
void MgDiamond::_update()
{
    __super::_update();
    Point2d pts[] = { _getHandlePoint(0), _getHandlePoint(1),
        _getHandlePoint(2), _getHandlePoint(3) };
    _extent.set(4, pts);
}
Exemplo n.º 4
0
bool MgDiamond::_hitTestBox(const Box2d& rect) const
{
    if (!__super::_hitTestBox(rect))
        return false;
    
    for (int i = 0; i < 3; i++) {
        if (Box2d(_getHandlePoint(i), _getHandlePoint(i + 1)).isIntersect(rect))
            return true;
    }
    
    return false;
}
Exemplo n.º 5
0
bool MgBaseRect::_setHandlePoint(int index, const Point2d& pt, float)
{
    if (getFlag(kMgSquare)) {
        if (isCurve() && !isEmpty(_MGZERO)) {
            float olddist = _getHandlePoint(index).distanceTo(getCenter());
            transform(Matrix2d::scaling(pt.distanceTo(getCenter()) / olddist, getCenter()));
        }
        else {
            Matrix2d mat(Matrix2d::rotation(-getAngle(), getCenter()));
            Point2d pt2(pt * mat);
            Box2d rect(getRect());
            mgnear::moveRectHandle(rect, index, pt2);
            
            if (4 == index || 6 == index) {
                rect = Box2d(rect.center(), rect.height(), rect.height());
            }
            else {
                rect = Box2d(rect.center(), rect.width(), rect.width());
            }
            setRectWithAngle(rect.leftTop(), rect.rightBottom(), getAngle(), 
                             rect.center() * mat.inverse());
        }
    }
    else {
        int index2 = index / 4 * 4 + (index % 4 + 2) % 4;
        Point2d corner(_getHandlePoint(index2));
        Matrix2d mat(Matrix2d::rotation(-getAngle(), corner));
        
        Box2d rect(_getHandlePoint(0) * mat, _getHandlePoint(2) * mat);
        Point2d pt2(pt * mat);
        
        mgnear::moveRectHandle(rect, index, pt2);
        setRectWithAngle(rect.leftTop(), rect.rightBottom(), getAngle(), corner);
    }
    update();
    return true;
}
Exemplo n.º 6
0
Point2d MgBaseShape::getHandlePoint(int index) const {
    return _getHandlePoint(index);
}
Exemplo n.º 7
0
bool MgComposite::_setHandlePoint(int index, const Point2d& pt, float)
{
    return _offset(pt - _getHandlePoint(index), -1);
}