void CanvasMode_EditWeldPoint::mouseMoveEvent(QMouseEvent *m) { const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos()); m->accept(); FPoint npfN; double nx = mousePointDoc.x(); double ny = mousePointDoc.y(); if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true)) npfN = m_doc->ApplyGridF(FPoint(nx, ny)); else npfN = FPoint(nx, ny); m_currItem = m_doc->m_Selection->itemAt(0); FPoint npf = FPoint(npfN.x(), npfN.y(), m_currItem->xPos(), m_currItem->yPos(), m_currItem->rotation(), 1, 1, true); FPoint npx(m_Mxp - npfN.x(), m_Myp - npfN.y(), 0, 0, m_currItem->rotation(), 1, 1, true); m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y()); if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed()) { if (m_editWeldMode) { if (m_selectedPoint != -1) { m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y()); FPoint mp, mp_orig; mp_orig = m_currItem->weldList[m_selectedPoint].weldPoint; mp = mp_orig - npx; double xx = mp.x(); double yy = mp.y(); snapToEdgePoints(xx, yy); m_currItem->weldList[m_selectedPoint].weldPoint = FPoint(xx, yy); } } else { m_currItem->setXYPos(m_currItem->xPos() - npx.x(), m_currItem->yPos() - npx.y(), true); m_currItem->setRedrawBounding(); m_currItem->OwnPage = m_doc->OnPage(m_currItem); } m_doc->regionsChanged()->update(getUpdateRect()); } m_Mxp = npfN.x(); m_Myp = npfN.y(); }
void CanvasMode_EditMeshGradient::mouseMoveEvent(QMouseEvent *m) { const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos()); m->accept(); if (m_selectedMeshPoints.count() == 0) return; if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed()) { FPoint npfN; double nx = mousePointDoc.x(); double ny = mousePointDoc.y(); if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true)) npfN = m_doc->ApplyGridF(FPoint(nx, ny)); else npfN = FPoint(nx, ny); PageItem *currItem = m_doc->m_Selection->itemAt(0); QTransform pp = currItem->getTransform(); FPoint npf = npfN.transformPoint(pp, true); if (m_view->editStrokeGradient == 6) { if (m_selectedMeshPoints.count() > 0) { QPair<int, int> selP = m_selectedMeshPoints[0]; FPoint cP = currItem->meshGradientArray[selP.first][selP.second].controlColor; FPoint gP = currItem->meshGradientArray[selP.first][selP.second].gridPoint; m_canvas->displayXYHUD(m->globalPos(), cP.x() - gP.x(), cP.y() - gP.y()); } } else m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y()); FPoint npx(m_Mxp - npfN.x(), m_Myp - npfN.y(), 0, 0, currItem->rotation(), 1, 1, true); if (m_selectedMeshPoints.count() > 0) { if (m_view->editStrokeGradient == 5) { for (int mo = 0; mo < m_selectedMeshPoints.count(); mo++) { QPair<int, int> selP = m_selectedMeshPoints[mo]; currItem->meshGradientArray[selP.first][selP.second].moveRel(-npx.x(), -npx.y()); } } else if (m_view->editStrokeGradient == 6) { QPair<int, int> selP = m_selectedMeshPoints[0]; currItem->meshGradientArray[selP.first][selP.second].controlColor -= npx; } else if (m_view->editStrokeGradient == 7) { QPair<int, int> selP = m_selectedMeshPoints[0]; if (m_gradientPoint == useControlT) currItem->meshGradientArray[selP.first][selP.second].controlTop -= npx; else if (m_gradientPoint == useControlB) currItem->meshGradientArray[selP.first][selP.second].controlBottom -= npx; else if (m_gradientPoint == useControlL) currItem->meshGradientArray[selP.first][selP.second].controlLeft -= npx; else if (m_gradientPoint == useControlR) currItem->meshGradientArray[selP.first][selP.second].controlRight -= npx; } currItem->update(); QTransform itemMatrix = currItem->getTransform(); m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height())); } m_Mxp = npfN.x(); m_Myp = npfN.y(); } }