void CanvasMode_EditArc::activate(bool fromGesture) { VectorDialog = new ArcVectorDialog(m_ScMW); m_canvas->m_viewMode.m_MouseButtonPressed = false; m_canvas->resetRenderMode(); m_doc->DragP = false; m_doc->leaveDrag = false; m_canvas->m_viewMode.operItemMoving = false; m_canvas->m_viewMode.operItemResizing = false; m_view->MidButt = false; Mxp = Myp = -1; PageItem *currItem = m_doc->m_Selection->itemAt(0); PageItem_Arc* item = currItem->asArc(); centerPoint = currItem->PoLine.pointQF(0); startPoint = currItem->PoLine.pointQF(3); endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 4); widthPoint = QPointF(centerPoint.x() - item->arcWidth / 2.0, centerPoint.y()); heightPoint = QPointF(centerPoint.x(), centerPoint.y() - item->arcHeight / 2.0); startAngle = item->arcStartAngle; endAngle = startAngle + item->arcSweepAngle; QLineF res = QLineF(centerPoint, startPoint); QLineF swe = QLineF(centerPoint, endPoint); VectorDialog->setValues(res.angle(), swe.angle(), item->arcHeight, item->arcWidth); VectorDialog->show(); setModeCursor(); if (fromGesture) { m_view->update(); } connect(VectorDialog, SIGNAL(NewVectors(double, double, double, double)), this, SLOT(applyValues(double, double, double, double))); connect(VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing())); connect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool))); connect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem())); }
void CanvasMode_EditSpiral::activate(bool fromGesture) { m_VectorDialog = new SpiralVectorDialog(m_ScMW); m_canvas->m_viewMode.m_MouseButtonPressed = false; m_canvas->resetRenderMode(); m_doc->DragP = false; m_doc->leaveDrag = false; m_canvas->m_viewMode.operItemMoving = false; m_canvas->m_viewMode.operItemResizing = false; m_view->MidButt = false; m_Mxp = m_Myp = -1; PageItem *currItem = m_doc->m_Selection->itemAt(0); PageItem_Spiral* item = currItem->asSpiral(); m_startPoint = currItem->PoLine.pointQF(0); m_endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2); m_startAngle = item->spiralStartAngle; m_endAngle = item->spiralEndAngle; m_VectorDialog->setValues(computeRealAngle(m_startAngle, false), computeRealAngle(m_endAngle, false), item->spiralFactor); m_VectorDialog->show(); setModeCursor(); if (fromGesture) { m_view->update(); } connect(m_VectorDialog, SIGNAL(NewVectors(double, double, double)), this, SLOT(applyValues(double, double, double))); connect(m_VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing())); connect(m_VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool))); connect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem())); }
void CanvasMode_EditArc::deactivate(bool forGesture) { disconnect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool))); VectorDialog->close(); delete VectorDialog; m_view->redrawMarker->hide(); m_arcPoint = noPointDefined; disconnect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem())); }
void CanvasMode_EditPolygon::deactivate(bool forGesture) { disconnect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool))); VectorDialog->close(); VectorDialog->deleteLater(); m_view->setRedrawMarkerShown(false); m_polygonPoint = noPointDefined; disconnect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem())); }
void CanvasMode_EditPolygon::applyValues(int polyC, double polyF, bool polyUseCF, double polyR, double polyCur, double polyIRot, double polyOCur) { PageItem *currItem = m_doc->m_Selection->itemAt(0); PageItem_RegularPolygon* item = currItem->asRegularPolygon(); QRectF oldRect = item->getBoundingRect(); polyCorners = polyC; polyFactor = polyF; polyRotation = polyR; polyCurvature = polyCur; polyInnerRot = polyIRot; polyOuterCurvature = polyOCur; if (UndoManager::undoEnabled()) { SimpleState *ss = new SimpleState(Um::EditPolygon,"",Um::IPolygon); ss->set("POLYGON","polygon"); ss->set("NEW_CORNER",polyC); ss->set("NEW_USEFACTOR",polyUseCF); ss->set("NEW_FACTOR",polyFactor); ss->set("NEW_ROTATION",polyRotation); ss->set("NEW_CURV",polyCurvature); ss->set("NEW_INNER",polyInnerRot); ss->set("NEW_OUTER",polyOuterCurvature); ss->set("OLD_CORNER",item->polyCorners); ss->set("OLD_USEFACTOR",item->polyUseFactor); ss->set("OLD_FACTOR",item->polyFactor); ss->set("OLD_ROTATION",item->polyRotation); ss->set("OLD_CURV",item->polyCurvature); ss->set("OLD_INNER",item->polyInnerRot); ss->set("OLD_OUTER",item->polyOuterCurvature); undoManager->action(currItem,ss); } item->polyCorners = polyC; item->polyUseFactor = polyUseCF; item->polyFactor = polyFactor; item->polyRotation = polyRotation; item->polyCurvature = polyCurvature; item->polyInnerRot = polyInnerRot; item->polyOuterCurvature = polyOuterCurvature; item->recalcPath(); updateFromItem(); QTransform itemMatrix = currItem->getTransform(); QPainterPath path = itemMatrix.map(RegularPolygonPath(item->width(), item->height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature)); QRectF updateRect = oldRect.united(path.boundingRect()); m_doc->regionsChanged()->update(updateRect.adjusted(-5, -5, 10, 10)); }
void CanvasMode_EditPolygon::activate(bool fromGesture) { m_polygonPoint = noPointDefined; m_canvas->m_viewMode.m_MouseButtonPressed = false; m_canvas->resetRenderMode(); m_doc->DragP = false; m_doc->leaveDrag = false; m_canvas->m_viewMode.operItemMoving = false; m_canvas->m_viewMode.operItemResizing = false; m_view->MidButt = false; Mxp = Myp = -1; PageItem *currItem = m_doc->m_Selection->itemAt(0); PageItem_RegularPolygon* item = currItem->asRegularPolygon(); centerPoint = QPointF(currItem->width() / 2.0, currItem->height() / 2.0); startPoint = currItem->PoLine.pointQF(0); endPoint = currItem->PoLine.pointQF(2); polyCorners = item->polyCorners; polyUseFactor = item->polyUseFactor; polyFactor = item->polyFactor; polyRotation = item->polyRotation; polyCurvature = item->polyCurvature; polyInnerRot = item->polyInnerRot; polyOuterCurvature = item->polyOuterCurvature; VectorDialog = new PolyVectorDialog(m_ScMW, polyCorners, polyFactor, polyUseFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature); VectorDialog->show(); uint cx = polyUseFactor ? polyCorners * 2 : polyCorners; double seg = 360.0 / cx; double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (item->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (item->height() / 2.0) + (item->height()/2.0) - item->height(), 2)); QLineF innerLine = QLineF(endPoint, centerPoint); innerLine.setAngle(innerLine.angle() + 90); innerLine.setLength(trueLength * polyCurvature); innerCPoint = innerLine.p2(); QLineF outerLine = QLineF(startPoint, currItem->PoLine.pointQF(6)); outerLine.setLength(outerLine.length() * polyOuterCurvature); outerCPoint = outerLine.p2(); setModeCursor(); if (fromGesture) m_view->update(); connect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem())); connect(VectorDialog, SIGNAL(NewVectors(int, double, bool, double, double, double, double)), this, SLOT(applyValues(int, double, bool, double, double, double, double))); connect(VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing())); connect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool))); }