bool MgCmdDrawFreeLines::touchEnded(const MgMotion* sender) { MgBaseLines* lines = (MgBaseLines*)dynshape()->shape(); float closelen = sender->displayMmToModel(5.f); 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, true)) lines->removePoint(m_step); } dynshape()->shape()->update(); if (m_step > 1) { addShape(sender); } else { click(sender); // add a point } delayClear(sender); return MgCommandDraw::touchEnded(sender); }
bool MgCmdDrawLine::touchEnded(const MgMotion* sender) { dynshape()->shape()->setPoint(1, snapPoint(sender)); dynshape()->shape()->update(); if ( ((MgLine*)dynshape()->shape())->length() > sender->displayMmToModel(2.f)) { addShape(sender); } delayClear(sender); return MgCommandDraw::touchEnded(sender); }
bool MgCmdDrawTriangle::touchEnded(const MgMotion* sender) { Point2d pnt(snapPoint(sender)); float distmin = sender->displayMmToModel(2.f); dynshape()->shape()->setPoint(m_step, pnt); dynshape()->shape()->update(); if (pnt.distanceTo(dynshape()->shape()->getPoint(m_step - 1)) > distmin) { m_step++; if (3 == m_step) { addShape(sender); delayClear(); m_step = 0; } } return MgCommandDraw::touchEnded(sender); }
bool MgCommandDraw::touchEndedStep(const MgMotion* sender) { Point2d pnt(snapPoint(sender)); Tol tol(sender->displayMmToModel(2.f)); setStepPoint(m_step, pnt); dynshape()->shape()->update(); if (!pnt.isEqualTo(dynshape()->shape()->getPoint(m_step - 1), tol)) { m_step++; if (m_step >= getMaxStep()) { if (!dynshape()->shape()->getExtent().isEmpty(tol, false)) { addShape(sender); delayClear(); } m_step = 0; } } return MgCommandDraw::touchEnded(sender); }
void MgCmdDrawRect::addRectShape(const MgMotion* sender) { addShape(sender); delayClear(sender); }