void CanvasMode_EditPolygon::updateFromItem() { if (updateFromItemBlocked()) return; 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->polyWidget->blockSignals(true); VectorDialog->setValues(polyCorners, polyFactor, polyUseFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature); VectorDialog->polyWidget->blockSignals(false); 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(); m_view->update(); }
void CanvasMode_EditSpiral::updateFromItem() { if (updateFromItemBlocked()) return; 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_view->update(); }
void CanvasMode_EditArc::updateFromItem() { if (updateFromItemBlocked()) return; 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); m_view->update(); }