bool MgCmdDrawFreeLines::touchMoved(const MgMotion* sender) { MgBaseLines* lines = (MgBaseLines*)dynshape()->shape(); float closelen = mgLineHalfWidthModel(dynshape(), sender) + mgDisplayMmToModel(5, sender); float closedist = sender->pointM.distanceTo(dynshape()->shape()->getPoint(0)); bool closed = (m_step > 2 && closedist < closelen && dynshape()->shape()->getExtent().width() > closedist * 1.5f && dynshape()->shape()->getExtent().height() > closedist * 1.5f); if (m_step > 2 && dynshape()->shape()->isClosed() != closed) { lines->setClosed(closed); if (closed) lines->removePoint(m_step); else lines->addPoint(sender->pointM); } if (!closed) { dynshape()->shape()->setPoint(m_step, sender->pointM); if (m_step > 0 && canAddPoint(sender, false)) { m_step++; if (m_step >= dynshape()->shape()->getPointCount()) { ((MgBaseLines*)dynshape()->shape())->addPoint(sender->pointM); } } } dynshape()->shape()->update(); return _touchMoved(sender); }
bool MgCmdDrawTriangle::touchMoved(const MgMotion* sender) { dynshape()->shape()->setPoint(m_step, snapPoint(sender)); dynshape()->shape()->update(); return _touchMoved(sender); }
bool MgCmdParallelogram::touchMoved(const MgMotion* sender) { dynshape()->shape()->setHandlePoint(m_step, snapPoint(sender), 0); dynshape()->shape()->update(); return _touchMoved(sender); }
bool MgCommandDraw::_touchMoved2(const MgMotion* sender) { setStepPoint(m_step, snapPoint(sender)); dynshape()->shape()->update(); return _touchMoved(sender); }
bool MgCmdDrawRect::touchMoved(const MgMotion* sender) { Point2d pt1(m_startPt); Point2d pt2(snapPoint(sender)); MgBaseRect* shape = (MgBaseRect*)dynshape()->shape(); shape->setRect2P(pt1, pt2); dynshape()->shape()->update(); return _touchMoved(sender); }
bool MgCmdDrawGrid::touchMoved(const MgMotion* sender) { if (m_step == 1) { return MgCmdDrawRect::touchMoved(sender); } dynshape()->shape()->setHandlePoint(8, snapPoint(sender), 0); dynshape()->shape()->update(); return _touchMoved(sender); }
//-------------------------------------------------------------- bool GuiControl::_touchUp(int _x, int _y, int button){ if(!enabled) return false; over = hitTest(_x, _y); down = false; if(editing) { _touchMoved (_x, _y, button); } else { if(over) touchUp(_x, _y, button); } editState = EDIT_NONE; return over; }
bool MgCmdDrawSplines::touchMoved(const MgMotion* sender) { MgBaseLines* lines = (MgBaseLines*)dynshape()->shape(); dynshape()->shape()->setPoint(m_step, sender->pointM); if (m_step > 0 && canAddPoint(sender, false)) { m_step++; if (m_step >= dynshape()->shape()->getPointCount()) { lines->addPoint(sender->pointM); } } dynshape()->shape()->update(); return _touchMoved(sender); }
bool MgCmdDrawLines::touchMoved(const MgMotion* sender) { Point2d pnt(snapPoint(sender)); dynshape()->shape()->setPoint(m_step, pnt); if (needCheckClosed()) { float distmin = mgDisplayMmToModel(2.f, sender); bool closed = m_step > 2 && pnt.distanceTo(dynshape()->shape()->getPoint(0)) < distmin; ((MgBaseLines*)dynshape()->shape())->setClosed(closed); } dynshape()->shape()->update(); return _touchMoved(sender); }
bool MgCmdDrawRect::touchMoved(const MgMotion* sender) { Point2d pt1(m_startPt); Point2d pt2(snapPoint(sender)); MgBaseRect* shape = (MgBaseRect*)dynshape()->shape(); if (shape->getFlag(kMgSquare)) { float len = (float)mgMax(fabs(pt2.x - pt1.x), fabs(pt2.y - pt1.y)); Box2d rect(m_startPt, 2.f * len, 0); pt1 = rect.leftTop(); pt2 = rect.rightBottom(); } shape->setRect(pt1, pt2); dynshape()->shape()->update(); return _touchMoved(sender); }
bool MgCmdDrawSplines::touchBegan(const MgMotion* sender) { MgBaseLines* lines = (MgBaseLines*)dynshape()->shape(); if (m_step > 0 && !m_freehand) { m_step++; if (m_step >= dynshape()->shape()->getPointCount()) { lines->addPoint(sender->pointM); dynshape()->shape()->update(); } return _touchMoved(sender); } else { lines->resize(2); m_freehand = !sender->pressDrag; m_step = 1; dynshape()->shape()->setPoint(0, sender->startPointM); dynshape()->shape()->setPoint(1, sender->pointM); dynshape()->shape()->update(); return _touchBegan(sender); } }