26#include <klocalizedstring.h>
28#include <QDoubleSpinBox>
30#include <QStackedWidget>
87 if (!
m_shape && stroke && stroke->isVisible()) {
93 QPointF point =
event->point;
104 if (event->
buttons() & Qt::LeftButton)
126 QPointF point =
event->point;
189 useCursor((stroke && stroke->isVisible()) ? Qt::ArrowCursor : Qt::ForbiddenCursor);
212 qreal angle = atan2(
p2.y() -
p1.y(),
p2.x() -
p1.x());
216 return angle * 180.0 /
M_PI;
234 combineAngle = 0.50f;
241 float lastAngle =
lineAngle(complete[0], complete[1]);
244 for (
uint i = 2; i < pointCount; ++i) {
246 if (qAbs(angle - lastAngle) < combineAngle)
247 complete.removeLast();
264 uint pointCount = points->count();
265 path->moveTo(points->at(0));
266 for (
uint i = 1; i < pointCount; ++i)
267 path->lineTo(points->at(i));
289 QWidget *optionWidget =
new QWidget();
290 QVBoxLayout * layout =
new QVBoxLayout(optionWidget);
292 QHBoxLayout *modeLayout =
new QHBoxLayout;
293 modeLayout->setSpacing(3);
294 QLabel *modeLabel =
new QLabel(i18n(
"Precision:"), optionWidget);
295 QComboBox * modeBox =
new QComboBox(optionWidget);
296 modeBox->addItem(i18nc(
"The raw line data",
"Raw"));
297 modeBox->addItem(i18n(
"Curve"));
298 modeBox->addItem(i18n(
"Straight"));
299 modeLayout->addWidget(modeLabel);
300 modeLayout->addWidget(modeBox, 1);
301 layout->addLayout(modeLayout);
303 QStackedWidget * stackedWidget =
new QStackedWidget(optionWidget);
305 QWidget * rawBox =
new QWidget(stackedWidget);
306 QVBoxLayout * rawLayout =
new QVBoxLayout(rawBox);
307 QCheckBox * optimizeRaw =
new QCheckBox(i18n(
"Optimize"), rawBox);
309 rawLayout->addWidget(optimizeRaw);
310 rawLayout->setContentsMargins(0, 0, 0, 0);
312 QWidget * curveBox =
new QWidget(stackedWidget);
313 QHBoxLayout * curveLayout =
new QHBoxLayout(curveBox);
314 QCheckBox * optimizeCurve =
new QCheckBox(i18n(
"Optimize"), curveBox);
317 fittingError->setSingleStep(0.50);
318 fittingError->setMaximum(400.0);
319 fittingError->setMinimum(0.0);
321 fittingError->setToolTip(i18n(
"Exactness:"));
322 curveLayout->addWidget(optimizeCurve);
323 curveLayout->addWidget(fittingError);
324 curveLayout->setContentsMargins(0, 0, 0, 0);
326 QWidget *straightBox =
new QWidget(stackedWidget);
327 QVBoxLayout *straightLayout =
new QVBoxLayout(straightBox);
329 combineAngle->setSingleStep(0.50);
330 combineAngle->setMaximum(360.0);
331 combineAngle->setMinimum(0.0);
333 combineAngle->setSuffix(
" deg");
336 straightLayout->addWidget(combineAngle);
337 straightLayout->setContentsMargins(0, 0, 0, 0);
339 stackedWidget->addWidget(rawBox);
340 stackedWidget->addWidget(curveBox);
341 stackedWidget->addWidget(straightBox);
342 layout->addWidget(stackedWidget);
343 layout->addStretch(1);
345 connect(modeBox, SIGNAL(activated(
int)), stackedWidget, SLOT(setCurrentIndex(
int)));
349 connect(fittingError, SIGNAL(valueChanged(
double)),
this, SLOT(
setDelta(
double)));
350 connect(combineAngle, SIGNAL(valueChanged(
double)),
this, SLOT(
setDelta(
double)));
352 modeBox->setCurrentIndex(
m_mode);
353 stackedWidget->setCurrentIndex(
m_mode);
354 optionWidget->setObjectName(i18n(
"Pencil"));
355 optionWidget->setWindowTitle(i18n(
"Pencil"));
356 widgets.append(optionWidget);
395 if (endShape && startShape != endShape)
455 qreal minDistance = HUGE_VAL;
458 Q_FOREACH(
KoShape * shape, shapes) {
467 uint subpathCount = path->subpathCount();
468 for (
uint i = 0; i < subpathCount; ++i) {
469 if (path->isClosedSubpath(i))
474 if (d < minDistance && d < maxDistance) {
481 if (d < minDistance && d < maxDistance) {
494 if (!pointAtStart && !pointAtEnd)
497 if (pointAtStart == pointAtEnd)
518 pathShape->
combine(startShape);
525 if (endShape != startShape) {
531 bool connectToSingleSubpath = (startShape == endShape && startIndex.first == endIndex.first);
533 if (startIndex.second == 0 && !connectToSingleSubpath) {
537 if (endIndex.second > 0 && !connectToSingleSubpath) {
554 if (existingStartPoint) {
561 if (existingEndPoint) {
KoPathShape * bezierFit(const QList< QPointF > &points, float error)
QPair< int, int > KoPathPointIndex
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.
The KisHandlePainterHelper class is a special helper for painting handles around objects....
void setHandleStyle(const KisHandleStyle &style)
static KisHandleStyle & primarySelection()
QPointer< KoShapeController > shapeController
virtual KoShapeManager * shapeManager() const =0
virtual const KoViewConverter * viewConverter() const =0
virtual void updateCanvas(const QRectF &rc)=0
virtual void addCommand(KUndo2Command *command)=0
bool isParametricShape() const
Check if object is a parametric shape.
Describe a KoPathPoint by a KoPathShape and its indices.
The undo / redo command for merging two subpath end points.
void redo() override
redo the command
A KoPathPoint represents a point in a path.
KoPathShape * parent() const
Get the path shape the point belongs to.
void paint(KisHandlePainterHelper &handlesHelper, PointTypes types, bool active=true)
The position of a path point within a path shape.
int subpathPointCount(int subpathIndex) const
Returns the number of points in a subpath.
bool reverseSubpath(int subpathIndex)
Reverse subpath.
KoPathPoint * lineTo(const QPointF &p)
Adds a new line segment.
KoPathPoint * moveTo(const QPointF &p)
Starts a new Subpath.
bool moveSubpath(int oldSubpathIndex, int newSubpathIndex)
Moves the position of a subpath within a path.
void paint(QPainter &painter) const override
reimplemented
QRectF boundingRect() const override
reimplemented
int subpathCount() const
Returns the number of subpaths in the path.
KoPathPointIndex pathPointIndex(const KoPathPoint *point) const
Returns the path point index of a given path point.
KoPathPoint * pointByIndex(const KoPathPointIndex &pointIndex) const
Returns the path point specified by a path point index.
int combine(KoPathShape *path)
Combines two path shapes by appending the data of the specified path.
Qt::MouseButtons buttons() const
return buttons pressed (see QMouseEvent::buttons());
Qt::KeyboardModifiers modifiers() const
QPointF point
The point in document coordinates.
QList< KoShape * > shapesAt(const QRectF &rect, bool omitHiddenShapes=true, bool containedMode=false)
QPointF shapeToDocument(const QPointF &point) const
Transforms point from shape coordinates to document coordinates.
virtual KoShapeStrokeModelSP stroke() const
virtual void setStroke(KoShapeStrokeModelSP stroke)
QTransform absoluteTransformation() const
static KisHandlePainterHelper createHandlePainterHelperView(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
void setShapeId(const QString &id)
virtual qreal viewToDocumentX(qreal viewX) const
virtual QPointF documentToView(const QPointF &documentPoint) const