Krita Source Code Documentation
Loading...
Searching...
No Matches
KoPathTool.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2006-2012 Jan Hambrecht <jaham@gmx.net>
3 * SPDX-FileCopyrightText: 2006, 2007 Thorsten Zachmann <zachmann@kde.org>
4 * SPDX-FileCopyrightText: 2007, 2010 Thomas Zander <zander@kde.org>
5 * SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org>
6 *
7 * SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9
10#include "KoPathTool.h"
11#include "KoCanvasBase.h"
14#include "KoParameterShape.h"
15#include "KoPathPoint.h"
18#include "KoPathShape_p.h"
19#include "KoPathToolHandle.h"
20#include "KoPointerEvent.h"
22#include "KoSelection.h"
23#include "KoShapeController.h"
24#include "KoShapeGroup.h"
25#include "KoShapeManager.h"
26#include "KoSnapGuide.h"
27#include "KoToolBase_p.h"
28#include "KoToolManager.h"
29#include "KoViewConverter.h"
39#include "kis_action_registry.h"
40#include "kis_command_utils.h"
41#include "kis_pointer_utils.h"
43#include <KoShapeStrokeModel.h>
49#include <text/KoSvgTextShape.h>
50
51#include <KoIcon.h>
52
53#include <QMenu>
54#include <QAction>
55#include <FlakeDebug.h>
56#include <klocalizedstring.h>
57#include <QPainter>
58#include <QPainterPath>
59#include <QBitmap>
60#include <QTabWidget>
61
62#include <math.h>
63
64// helper function to calculate the squared distance between two points
65qreal squaredDistance(const QPointF& p1, const QPointF &p2)
66{
67 qreal dx = p1.x()-p2.x();
68 qreal dy = p1.y()-p2.y();
69 return dx*dx + dy*dy;
70}
71
74 : path(0), segmentStart(0), positionOnSegment(0)
75 {
76 }
77
78 bool isValid() {
79 return path && segmentStart;
80 }
81
85};
86
88 : KoToolBase(canvas)
89 , m_pointSelection(this)
90 , m_textOutlineHelper(new KoSvgTextShapeOutlineHelper(canvas))
91{
92 m_actionPathPointCorner = action("pathpoint-corner");
93 m_actionPathPointSmooth = action("pathpoint-smooth");
94 m_actionPathPointSymmetric = action("pathpoint-symmetric");
95 m_actionCurvePoint = action("pathpoint-curve");
96 m_actionLinePoint = action("pathpoint-line");
97 m_actionLineSegment = action("pathsegment-line");
98 m_actionCurveSegment = action("pathsegment-curve");
99 m_actionAddPoint = action("pathpoint-insert");
100 m_actionRemovePoint = action("pathpoint-remove");
101 m_actionBreakPoint = action("path-break-point");
102 m_actionBreakSegment = action("path-break-segment");
103 m_actionBreakSelection = action("path-break-selection");
104 m_actionJoinSegment = action("pathpoint-join");
105 m_actionMergePoints = action("pathpoint-merge");
106 m_actionConvertToPath = action("convert-to-path");
107
108 m_contextMenu.reset(new QMenu());
109 m_textOutlineHelper->setDrawBoundingRect(true);
110 m_textOutlineHelper->setDrawShapeOutlines(false);
111
112 m_selectCursor = QCursor(QIcon(":/cursor-needle.svg").pixmap(32), 0, 0);
113 m_moveCursor = QCursor(QIcon(":/cursor-needle-move.svg").pixmap(32), 0, 0);
114
115 connect(&m_pointSelection, SIGNAL(selectionChanged()), SLOT(repaintDecorations()));
116}
117
121
123{
125
126 PathToolOptionWidget * toolOptions = new PathToolOptionWidget(this);
127 connect(this, SIGNAL(typeChanged(int)), toolOptions, SLOT(setSelectionType(int)));
128 connect(this, SIGNAL(singleShapeChanged(KoPathShape*)), toolOptions, SLOT(setCurrentShape(KoPathShape*)));
129 connect(toolOptions, SIGNAL(sigRequestUpdateActions()), this, SLOT(updateActions()));
131 toolOptions->setWindowTitle(i18n("Edit Shape"));
132 list.append(toolOptions);
133
134 return list;
135}
136
146
148{
149 Q_D(KoToolBase);
152
153 KUndo2Command *initialConversionCommand = createPointToCurveCommand(selectedPoints);
154
155 // conversion should happen before the c-tor
156 // of KoPathPointTypeCommand is executed!
157 if (initialConversionCommand) {
158 initialConversionCommand->redo();
159 }
160
161 KUndo2Command *command =
162 new KoPathPointTypeCommand(selectedPoints, type);
163
164 if (initialConversionCommand) {
165 using namespace KisCommandUtils;
166 CompositeCommand *parent = new CompositeCommand();
167 parent->setText(command->text());
168 parent->addCommand(new SkipFirstRedoWrapper(initialConversionCommand));
169 parent->addCommand(command);
170 command = parent;
171 }
172
173 d->canvas->addCommand(command);
174 }
175}
176
178{
179 Q_D(KoToolBase);
181 if (segments.size() == 1) {
182 qreal positionInSegment = 0.5;
183 if (m_activeSegment && m_activeSegment->isValid()) {
184 positionInSegment = m_activeSegment->positionOnSegment;
185 }
186
187 KoPathPointInsertCommand *cmd = new KoPathPointInsertCommand(segments, positionInSegment);
188 d->canvas->addCommand(cmd);
189
190 // TODO: this construction is dangerous. The canvas can remove the command right after
191 // it has been added to it!
193 foreach (KoPathPoint * p, cmd->insertedPoints()) {
194 m_pointSelection.add(p, false);
195 }
196 }
197}
198
200{
201 Q_D(KoToolBase);
202 if (m_pointSelection.size() > 0) {
204 PointHandle *pointHandle = dynamic_cast<PointHandle*>(m_activeHandle.data());
205 if (pointHandle && m_pointSelection.contains(pointHandle->activePoint())) {
206 m_activeHandle.reset();
207 }
209 d->canvas->addCommand(cmd);
210 }
211}
212
214{
215 Q_D(KoToolBase);
218 QList<KoPathPointData> pointToChange;
219
220 QList<KoPathPointData>::const_iterator it(selectedPoints.constBegin());
221 for (; it != selectedPoints.constEnd(); ++it) {
222 KoPathPoint *point = it->pathShape->pointByIndex(it->pointIndex);
223 if (point && (point->activeControlPoint1() || point->activeControlPoint2()))
224 pointToChange.append(*it);
225 }
226
227 if (! pointToChange.isEmpty()) {
228 d->canvas->addCommand(new KoPathPointTypeCommand(pointToChange, KoPathPointTypeCommand::Line));
229 }
230 }
231}
232
234{
235 Q_D(KoToolBase);
238
239 KUndo2Command *command = createPointToCurveCommand(selectedPoints);
240
241 if (command) {
242 d->canvas->addCommand(command);
243 }
244 }
245}
246
248{
249 KUndo2Command *command = 0;
250 QList<KoPathPointData> pointToChange;
251
252 QList<KoPathPointData>::const_iterator it(points.constBegin());
253 for (; it != points.constEnd(); ++it) {
254 KoPathPoint *point = it->pathShape->pointByIndex(it->pointIndex);
255 if (point && (! point->activeControlPoint1() || ! point->activeControlPoint2()))
256 pointToChange.append(*it);
257 }
258
259 if (!pointToChange.isEmpty()) {
260 command = new KoPathPointTypeCommand(pointToChange, KoPathPointTypeCommand::Curve);
261 }
262
263 return command;
264}
265
267{
268 Q_D(KoToolBase);
269 if (m_pointSelection.size() > 1) {
271 if (segments.size() > 0) {
272 d->canvas->addCommand(new KoPathSegmentTypeCommand(segments, KoPathSegmentTypeCommand::Line));
273 }
274 }
275}
276
278{
279 Q_D(KoToolBase);
280 if (m_pointSelection.size() > 1) {
282 if (segments.size() > 0) {
283 d->canvas->addCommand(new KoPathSegmentTypeCommand(segments, KoPathSegmentTypeCommand::Curve));
284 }
285 }
286}
287
289{
290 Q_D(KoToolBase);
291
293
294 QList<KoParameterShape*> parameterShapes;
295
296 Q_FOREACH (KoShape *shape, m_pointSelection.selectedShapes()) {
297 KoParameterShape * parametric = dynamic_cast<KoParameterShape*>(shape);
298 if (parametric && parametric->isParametricShape()) {
299 parameterShapes.append(parametric);
300 }
301 }
302
303 if (!parameterShapes.isEmpty()) {
304 d->canvas->addCommand(new KoParameterToPathCommand(parameterShapes));
305 }
306
307 QList<KoSvgTextShape*> textShapes;
308 Q_FOREACH (KoShape *shape, selection->selectedEditableShapes()) {
309 if (KoSvgTextShape *text = dynamic_cast<KoSvgTextShape*>(shape)) {
310 textShapes.append(text);
311 }
312 }
313
314 if (!textShapes.isEmpty()) {
315 KUndo2Command *cmd = new KUndo2Command(kundo2_i18n("Convert to Path")); // TODO: reuse the text from KoParameterToPathCommand
316 const QList<KoShape*> oldSelectedShapes = implicitCastList<KoShape*>(textShapes);
317
318
319 new KoKeepShapesSelectedCommand(oldSelectedShapes, {}, canvas()->selectedShapesProxy(),
321
322 QList<KoShape*> newSelectedShapes;
323 Q_FOREACH (KoSvgTextShape *shape, textShapes) {
324 KoShape *outlineShape = shape->textOutline();
325
326 KoShapeContainer *parent = shape->parent();
327 canvas()->shapeController()->addShapeDirect(outlineShape, parent, cmd);
328
329 newSelectedShapes << outlineShape;
330 }
331
332 canvas()->shapeController()->removeShapes(oldSelectedShapes, cmd);
333
334 new KoKeepShapesSelectedCommand({}, newSelectedShapes, canvas()->selectedShapesProxy(),
336
337 canvas()->addCommand(cmd);
338 }
339
341}
342
343namespace {
344bool checkCanJoinToPoints(const KoPathPointData & pd1, const KoPathPointData & pd2)
345{
346 const KoPathPointIndex & index1 = pd1.pointIndex;
347 const KoPathPointIndex & index2 = pd2.pointIndex;
348
349 KoPathShape *path1 = pd1.pathShape;
350 KoPathShape *path2 = pd2.pathShape;
351
352 // check if subpaths are already closed
353 if (path1->isClosedSubpath(index1.first) || path2->isClosedSubpath(index2.first))
354 return false;
355
356 // check if first point is an endpoint
357 if (index1.second != 0 && index1.second != path1->subpathPointCount(index1.first)-1)
358 return false;
359
360 // check if second point is an endpoint
361 if (index2.second != 0 && index2.second != path2->subpathPointCount(index2.first)-1)
362 return false;
363
364 return true;
365}
366}
367
369{
370 Q_D(KoToolBase);
371
372 if (m_pointSelection.size() != 2)
373 return;
374
376 if (pointData.size() != 2) return;
377
378 const KoPathPointData & pd1 = pointData.at(0);
379 const KoPathPointData & pd2 = pointData.at(1);
380
381 if (!checkCanJoinToPoints(pd1, pd2)) {
382 return;
383 }
384
386
387 KUndo2Command *cmd = 0;
388
389 if (doJoin) {
390 cmd = new KoMultiPathPointJoinCommand(pd1, pd2, d->canvas->shapeController()->documentBase(), d->canvas->shapeManager()->selection());
391 } else {
392 cmd = new KoMultiPathPointMergeCommand(pd1, pd2, d->canvas->shapeController()->documentBase(), d->canvas->shapeManager()->selection());
393 }
394 d->canvas->addCommand(cmd);
395}
396
398{
399 mergePointsImpl(true);
400}
401
403{
404 mergePointsImpl(false);
405}
406
408{
409 Q_D(KoToolBase);
412 }
413}
414
416{
417 Q_D(KoToolBase);
418
419 if (m_pointSelection.objectCount() == 1 && m_pointSelection.size() == 2) {
421 if (segments.size() == 1) {
422 d->canvas->addCommand(new KoPathSegmentBreakCommand(segments.at(0)));
423 }
424 } else if (m_pointSelection.hasSelection()) {
426 }
427}
428
430{
431 Q_D(KoToolBase);
432 // only try to break a segment when 2 points of the same object are selected
433 if (m_pointSelection.objectCount() == 1 && m_pointSelection.size() == 2) {
435 if (segments.size() == 1) {
436 d->canvas->addCommand(new KoPathSegmentBreakCommand(segments.at(0)));
437 }
438 }
439}
440
441void KoPathTool::paint(QPainter &painter, const KoViewConverter &converter)
442{
443 Q_D(KoToolBase);
444 m_textOutlineHelper->setDecorationThickness(decorationThickness());
445 m_textOutlineHelper->setHandleRadius(handleRadius());
446 m_textOutlineHelper->paint(&painter, converter);
447
449
450 Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
454
455 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
456 if (parameterShape && parameterShape->isParametricShape()) {
457 parameterShape->paintHandles(helper);
458 } else {
459 shape->paintPoints(helper);
460 }
461
462 if (!shape->stroke() || !shape->stroke()->isVisible()) {
464 helper.drawPath(shape->outline());
465 }
466 }
467
468 if (m_currentStrategy) {
469 painter.save();
470 m_currentStrategy->paint(painter, converter, canvas()->displayRendererInterface());
471 painter.restore();
472 }
473
475
476 if (m_activeHandle) {
479 } else {
480 m_activeHandle.reset();
481 }
482 } else if (m_activeSegment && m_activeSegment->isValid()) {
483
484 KoPathShape *shape = m_activeSegment->path;
485
486 // if the stroke is invisible, then we already painted the outline of the shape!
487 if (shape->stroke() && shape->stroke()->isVisible()) {
488 KoPathPointIndex index = shape->pathPointIndex(m_activeSegment->segmentStart);
489 KoPathSegment segment = shape->segmentByIndex(index).toCubic();
490
492
496
497 QPainterPath path;
498 path.moveTo(segment.first()->point());
499 path.cubicTo(segment.first()->controlPoint2(),
500 segment.second()->controlPoint1(),
501 segment.second()->point());
502
503 helper.drawPath(path);
504 }
505 }
506
507
508
509 if (m_currentStrategy) {
510 painter.save();
511 painter.setTransform(converter.documentToView(), true);
512 d->canvas->snapGuide()->paint(painter, converter, canvas()->displayRendererInterface());
513 painter.restore();
514 }
515}
516
518{
519 const_cast<KoPathToolSelection&>(m_pointSelection).update();
520
521 QRectF newDecorationsRect;
522
523 Q_FOREACH (KoShape *shape, m_pointSelection.selectedShapes()) {
524 newDecorationsRect |= kisGrowRect(shape->boundingRect(), handleDocRadius());
525 }
526
527 Q_FOREACH(const KoPathPoint *point, m_pointSelection.selectedPoints()) {
528 newDecorationsRect |= kisGrowRect(point->boundingRect(false), handleDocRadius());
529 }
530
531 if (m_activeHandle) {
532 newDecorationsRect |= kisGrowRect(m_activeHandle->boundingRect(), handleDocRadius());
533 }
534
535 if (m_activeSegment) {
536 KoPathPointIndex index = m_activeSegment->path->pathPointIndex(m_activeSegment->segmentStart);
537 KoPathSegment segment = m_activeSegment->path->segmentByIndex(index);
538
539 QRectF rect = segment.boundingRect();
540 rect = m_activeSegment->path->shapeToDocument(rect);
541
542 newDecorationsRect |= kisGrowRect(rect, handleDocRadius());
543 }
544
545 newDecorationsRect |= m_textOutlineHelper->decorationRect();
546
547 return newDecorationsRect;
548}
549
555
557{
558 // When using touch drawing, we only ever receive move events after the
559 // finger has pressed down. We have to issue an artificial move here so that
560 // the tool's state is updated properly to handle the press.
561 if (event->isTouchEvent()) {
562 mouseMoveEvent(event);
563 }
564
565 if (KoSvgTextShape *shape = m_textOutlineHelper->contourModeButtonHovered(event->point)) {
566 m_textOutlineHelper->toggleTextContourMode(shape);
567 event->accept();
568 }
569 // we are moving if we hit a point and use the left mouse button
570 if (m_activeHandle) {
571 m_currentStrategy.reset(m_activeHandle->handleMousePress(event));
572 } else {
573
574 if (event->button() & Qt::LeftButton) {
575
576 bool shift_pressed = (event->modifiers() & Qt::ShiftModifier);
577
578 // check if we hit a path segment
579 if (m_activeSegment && m_activeSegment->isValid()) {
580
581 KoPathShape *shape = m_activeSegment->path;
582 KoPathPointIndex index = shape->pathPointIndex(m_activeSegment->segmentStart);
583 KoPathSegment segment = shape->segmentByIndex(index);
584
585 // The segment is selected so now need to deselect it
587 && shift_pressed) {
588 m_pointSelection.remove(segment.first());
589 m_pointSelection.remove(segment.second());
590 } else {
591 m_pointSelection.add(segment.first(), !shift_pressed);
592 m_pointSelection.add(segment.second(), false);
593 }
594
595 KoPathPointData data(shape, index);
596 m_currentStrategy.reset(new KoPathSegmentChangeStrategy(this, event->point, data, m_activeSegment->positionOnSegment));
597 } else {
598
599 KoShapeManager *shapeManager = canvas()->shapeManager();
600 KoSelection *selection = shapeManager->selection();
601 KoShape *shape = shapeManager->shapeAt(event->point, KoFlake::ShapeOnTop);
602
603 if (shape && !selection->isSelected(shape)) {
604
605 if (!shift_pressed) {
606 selection->deselectAll();
607 }
608
609 selection->select(shape);
610 } else {
613 }
614 }
615 }
616 }
617}
618
620{
621 if (event->button() & Qt::RightButton)
622 return;
623
624 if (m_currentStrategy) {
625 m_lastPoint = event->point;
626 m_currentStrategy->handleMouseMove(event->point, event->modifiers());
627
629
630 return;
631 }
632
633 if (m_activeSegment) {
634 m_activeSegment.reset();
636 }
637
638 Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
639 QRectF roi = shape->documentToShape(handleGrabRect(event->point));
640 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
641 if (parameterShape && parameterShape->isParametricShape()) {
642 int handleId = parameterShape->handleIdAt(roi);
643 if (handleId != -1) {
645 Q_EMIT statusTextChanged(i18n("Drag to move handle."));
646
647 m_activeHandle.reset(new ParameterHandle(this, parameterShape, handleId));
649 return;
650 }
651 } else {
652 QList<KoPathPoint*> points = shape->pointsAt(roi, true);
653 if (! points.empty()) {
654 // find the nearest control point from all points within the roi
655 KoPathPoint * bestPoint = 0;
657 qreal minDistance = HUGE_VAL;
658 Q_FOREACH (KoPathPoint *p, points) {
659 // the node point must be hit if the point is not selected yet
660 if (! m_pointSelection.contains(p) && ! roi.contains(p->point()))
661 continue;
662
663 // check for the control points first as otherwise it is no longer
664 // possible to change the control points when they are the same as the point
665 if (p->activeControlPoint1() && roi.contains(p->controlPoint1())) {
666 qreal dist = squaredDistance(roi.center(), p->controlPoint1());
667 if (dist < minDistance) {
668 bestPoint = p;
669 bestPointType = KoPathPoint::ControlPoint1;
670 minDistance = dist;
671 }
672 }
673
674 if (p->activeControlPoint2() && roi.contains(p->controlPoint2())) {
675 qreal dist = squaredDistance(roi.center(), p->controlPoint2());
676 if (dist < minDistance) {
677 bestPoint = p;
678 bestPointType = KoPathPoint::ControlPoint2;
679 minDistance = dist;
680 }
681 }
682
683 // check the node point at last
684 qreal dist = squaredDistance(roi.center(), p->point());
685 if (dist < minDistance) {
686 bestPoint = p;
687 bestPointType = KoPathPoint::Node;
688 minDistance = dist;
689 }
690 }
691
692 if (! bestPoint) {
694 return;
695 }
696
698 if (bestPointType == KoPathPoint::Node)
699 Q_EMIT statusTextChanged(i18n("Drag to move point. Shift click to change point type."));
700 else
701 Q_EMIT statusTextChanged(i18n("Drag to move control point."));
702
703 PointHandle *prev = dynamic_cast<PointHandle*>(m_activeHandle.data());
704 if (prev && prev->activePoint() == bestPoint && prev->activePointType() == bestPointType)
705 return; // no change;
706
707 m_activeHandle.reset(new PointHandle(this, bestPoint, bestPointType));
709 return;
710 }
711 }
712 }
713
715
716 if (m_activeHandle) {
717 m_activeHandle.reset();
719 }
720
721 PathSegment *hoveredSegment = segmentAtPoint(event->point);
722 if(hoveredSegment) {
723 useCursor(Qt::PointingHandCursor);
724 Q_EMIT statusTextChanged(i18n("Drag to change curve directly. Double click to insert new path point."));
725 m_activeSegment.reset(hoveredSegment);
727 } else {
728 uint selectedPointCount = m_pointSelection.size();
729 if (selectedPointCount == 0)
730 Q_EMIT statusTextChanged(QString());
731 else {
732 if (!m_actionBreakSelection->shortcut().isEmpty()) {
733 if (selectedPointCount == 1)
734 Q_EMIT statusTextChanged(i18nc("%1 is a shortcut to be pressed", "Press %1 to break path at selected point.", m_actionBreakSelection->shortcut().toString()));
735 else
736 Q_EMIT statusTextChanged(i18nc("%1 is a shortcut to be pressed", "Press %1 to break path at selected segments.", m_actionBreakSelection->shortcut().toString()));
737 } else {
738 Q_EMIT statusTextChanged(QString());
739 }
740 }
741 }
742}
743
745{
746 Q_D(KoToolBase);
747 if (m_currentStrategy) {
748 const bool hadNoSelection = !m_pointSelection.hasSelection();
749 m_currentStrategy->finishInteraction(event->modifiers());
750 KUndo2Command *command = m_currentStrategy->createCommand();
751 if (command)
752 d->canvas->addCommand(command);
753 if (hadNoSelection && dynamic_cast<KoPathPointRubberSelectStrategy*>(m_currentStrategy.data())
755 // the click didn't do anything at all. Allow it to be used by others.
756 event->ignore();
757 }
758 m_currentStrategy.reset();
760 }
761}
762
763void KoPathTool::keyPressEvent(QKeyEvent *event)
764{
765 if (m_currentStrategy) {
766 switch (event->key()) {
767 case Qt::Key_Control:
768 case Qt::Key_Alt:
769 case Qt::Key_Shift:
770 case Qt::Key_Meta:
771 if (! event->isAutoRepeat()) {
772 m_currentStrategy->handleMouseMove(m_lastPoint, event->modifiers());
773 }
774 break;
775 case Qt::Key_Escape:
776 m_currentStrategy->cancelInteraction();
777 m_currentStrategy.reset();
778 break;
779 default:
780 event->ignore();
781 return;
782 }
783 } else {
784 switch (event->key()) {
785#ifndef NDEBUG
786// case Qt::Key_D:
787// if (m_pointSelection.objectCount() == 1) {
788// QList<KoPathPointData> selectedPoints = m_pointSelection.selectedPointsData();
789// KoPathShapePrivate *p = static_cast<KoPathShapePrivate*>(selectedPoints[0].pathShape->priv());
790// p->debugPath();
791// }
792// break;
793#endif
794 default:
795 event->ignore();
796 return;
797 }
798 }
799 event->accept();
800}
801
802void KoPathTool::keyReleaseEvent(QKeyEvent *event)
803{
804 if (m_currentStrategy) {
805 switch (event->key()) {
806 case Qt::Key_Control:
807 case Qt::Key_Alt:
808 case Qt::Key_Shift:
809 case Qt::Key_Meta:
810 if (! event->isAutoRepeat()) {
811 m_currentStrategy->handleMouseMove(m_lastPoint, Qt::NoModifier);
812 }
813 break;
814 default:
815 break;
816 }
817 }
818 event->accept();
819}
820
822{
823 Q_D(KoToolBase);
824 // check if we are doing something else at the moment
825 if (m_currentStrategy) return;
826
827 if (!m_activeHandle && m_activeSegment && m_activeSegment->isValid()) {
828 QList<KoPathPointData> segments;
829 segments.append(
831 m_activeSegment->path->pathPointIndex(m_activeSegment->segmentStart)));
832
833 KoPathPointInsertCommand *cmd = new KoPathPointInsertCommand(segments, m_activeSegment->positionOnSegment);
834 d->canvas->addCommand(cmd);
835
837 foreach (KoPathPoint * p, cmd->insertedPoints()) {
838 m_pointSelection.add(p, false);
839 }
841
842 // Call a mouse move event to update the cursor and allow the user to drag the new point immediately
843 mouseMoveEvent(event);
844 } else if (!m_activeHandle && !m_activeSegment) {
846 }
847}
848
850{
851 // the max allowed distance from a segment
852 const QRectF grabRoi = handleGrabRect(point);
853 std::unique_ptr<PathSegment> segment(new PathSegment);
854
855 Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
856 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
857 if (parameterShape && parameterShape->isParametricShape())
858 continue;
859
860 const KoPathSegment s = shape->segmentAtPoint(point, grabRoi);
861 if (s.isValid()) {
862 segment->path = shape;
863 segment->segmentStart = s.first();
864 segment->positionOnSegment = s.nearestPoint(shape->documentToShape(point));
865 }
866 }
867
868 if (!segment->isValid()) {
869 segment.reset();
870 }
871
872 return segment.release();
873}
874
875void KoPathTool::activate(const QSet<KoShape*> &shapes)
876{
877 KoToolBase::activate(shapes);
878
879 Q_D(KoToolBase);
880
881 d->canvas->snapGuide()->reset();
882
884 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()));
885 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionContentChanged()), this, SLOT(updateActions()));
886
887 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(repaintDecorations()));
888 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionContentChanged()), this, SLOT(repaintDecorations()));
890 initializeWithShapes(QList<KoShape*>(shapes.begin(), shapes.end()));
891 connect(m_actionCurvePoint, SIGNAL(triggered()), this, SLOT(pointToCurve()), Qt::UniqueConnection);
892 connect(m_actionLinePoint, SIGNAL(triggered()), this, SLOT(pointToLine()), Qt::UniqueConnection);
893 connect(m_actionLineSegment, SIGNAL(triggered()), this, SLOT(segmentToLine()), Qt::UniqueConnection);
894 connect(m_actionCurveSegment, SIGNAL(triggered()), this, SLOT(segmentToCurve()), Qt::UniqueConnection);
895 connect(m_actionAddPoint, SIGNAL(triggered()), this, SLOT(insertPoints()), Qt::UniqueConnection);
896 connect(m_actionRemovePoint, SIGNAL(triggered()), this, SLOT(removePoints()), Qt::UniqueConnection);
897 connect(m_actionBreakPoint, SIGNAL(triggered()), this, SLOT(breakAtPoint()), Qt::UniqueConnection);
898 connect(m_actionBreakSegment, SIGNAL(triggered()), this, SLOT(breakAtSegment()), Qt::UniqueConnection);
899 connect(m_actionBreakSelection, SIGNAL(triggered()), this, SLOT(breakAtSelection()), Qt::UniqueConnection);
900 connect(m_actionJoinSegment, SIGNAL(triggered()), this, SLOT(joinPoints()), Qt::UniqueConnection);
901 connect(m_actionMergePoints, SIGNAL(triggered()), this, SLOT(mergePoints()), Qt::UniqueConnection);
902 connect(m_actionConvertToPath, SIGNAL(triggered()), this, SLOT(convertToPath()), Qt::UniqueConnection);
903 connect(m_actionPathPointCorner, SIGNAL(triggered()), this, SLOT(pointTypeChangedCorner()), Qt::UniqueConnection);
904 connect(m_actionPathPointSmooth, SIGNAL(triggered()), this, SLOT(pointTypeChangedSmooth()), Qt::UniqueConnection);
905 connect(m_actionPathPointSymmetric, SIGNAL(triggered()), this, SLOT(pointTypeChangedSymmetric()), Qt::UniqueConnection);
906 connect(&m_pointSelection, SIGNAL(selectionChanged()), this, SLOT(pointSelectionChanged()), Qt::UniqueConnection);
907
908}
909
911{
912 Q_D(KoToolBase);
913 QList<KoShape*> shapes =
914 d->canvas->selectedShapesProxy()->selection()->selectedEditableShapesAndDelegates();
915
916 initializeWithShapes(shapes);
917}
918
920{
921 Q_UNUSED(shape);
922
923 // active handle and selection might have already become invalid, so just
924 // delete them without dereferencing anything...
925
926 m_activeHandle.reset();
927 m_activeSegment.reset();
928}
929
936
938{
939 QList<KoPathShape*> selectedShapes;
940 Q_FOREACH (KoShape *shape, shapes) {
941 KoPathShape *pathShape = dynamic_cast<KoPathShape*>(shape);
942
943 if (pathShape && pathShape->isShapeEditable()) {
944 selectedShapes.append(pathShape);
945 }
946 }
947
948 if (selectedShapes != m_pointSelection.selectedShapes()) {
950 m_pointSelection.setSelectedShapes(selectedShapes);
952 }
953
956}
957
959{
960 PathToolOptionWidget::Types type;
962 Q_FOREACH (KoPathShape *shape, selectedShapes) {
963 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
964 type |= parameterShape && parameterShape->isParametricShape() ?
966 }
967
968 Q_EMIT singleShapeChanged(selectedShapes.size() == 1 ? selectedShapes.first() : 0);
969 Q_EMIT typeChanged(type);
970}
971
973{
975
976 bool canBreakAtPoint = false;
977
978 bool hasNonSmoothPoints = false;
979 bool hasNonSymmetricPoints = false;
980 bool hasNonSplitPoints = false;
981
982 bool hasNonLinePoints = false;
983 bool hasNonCurvePoints = false;
984
985 bool canJoinSubpaths = false;
986
987 if (!pointData.isEmpty()) {
988 Q_FOREACH (const KoPathPointData &pd, pointData) {
989 const int subpathIndex = pd.pointIndex.first;
990 const int pointIndex = pd.pointIndex.second;
991
992 canBreakAtPoint |= pd.pathShape->isClosedSubpath(subpathIndex) ||
993 (pointIndex > 0 && pointIndex < pd.pathShape->subpathPointCount(subpathIndex) - 1);
994
996
997 hasNonSmoothPoints |= !(point->properties() & KoPathPoint::IsSmooth);
998 hasNonSymmetricPoints |= !(point->properties() & KoPathPoint::IsSymmetric);
999 hasNonSplitPoints |=
1002
1003 hasNonLinePoints |= point->activeControlPoint1() || point->activeControlPoint2();
1004 hasNonCurvePoints |= !point->activeControlPoint1() && !point->activeControlPoint2();
1005 }
1006
1007 if (pointData.size() == 2) {
1008 const KoPathPointData & pd1 = pointData.at(0);
1009 const KoPathPointData & pd2 = pointData.at(1);
1010
1011 canJoinSubpaths = checkCanJoinToPoints(pd1, pd2);
1012 }
1013 }
1014
1015 m_actionPathPointCorner->setEnabled(hasNonSplitPoints);
1016 m_actionPathPointSmooth->setEnabled(hasNonSmoothPoints);
1017 m_actionPathPointSymmetric->setEnabled(hasNonSymmetricPoints);
1018
1019 m_actionRemovePoint->setEnabled(!pointData.isEmpty());
1020
1021 m_actionBreakPoint->setEnabled(canBreakAtPoint);
1022
1023 m_actionCurvePoint->setEnabled(hasNonCurvePoints);
1024 m_actionLinePoint->setEnabled(hasNonLinePoints);
1025
1026 m_actionJoinSegment->setEnabled(canJoinSubpaths);
1027 m_actionMergePoints->setEnabled(canJoinSubpaths);
1028
1030
1031
1032 bool canSplitAtSegment = false;
1033 bool canConvertSegmentToLine = false;
1034 bool canConvertSegmentToCurve= false;
1035
1036 if (!segments.isEmpty()) {
1037
1038 canSplitAtSegment = segments.size() == 1;
1039
1040 bool hasLines = false;
1041 bool hasCurves = false;
1042
1043 Q_FOREACH (const KoPathPointData &pd, segments) {
1045 hasLines |= segment.degree() == 1;
1046 hasCurves |= segment.degree() > 1;
1047 }
1048
1049 canConvertSegmentToLine = !segments.isEmpty() && hasCurves;
1050 canConvertSegmentToCurve= !segments.isEmpty() && hasLines;
1051 }
1052
1053 m_actionAddPoint->setEnabled(canSplitAtSegment);
1054
1055 m_actionLineSegment->setEnabled(canConvertSegmentToLine);
1056 m_actionCurveSegment->setEnabled(canConvertSegmentToCurve);
1057
1058 m_actionBreakSegment->setEnabled(canSplitAtSegment);
1059 m_actionBreakSelection->setEnabled(canSplitAtSegment | canBreakAtPoint);
1060
1062 bool haveConvertibleShapes = false;
1063 Q_FOREACH (KoShape *shape, selection->selectedEditableShapes()) {
1064 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
1065 KoSvgTextShape *textShape = dynamic_cast<KoSvgTextShape*>(shape);
1066 if (textShape ||
1067 (parameterShape && parameterShape->isParametricShape())) {
1068
1069 haveConvertibleShapes = true;
1070 break;
1071 }
1072 }
1073 m_actionConvertToPath->setEnabled(haveConvertibleShapes);
1074}
1075
1077{
1078 Q_D(KoToolBase);
1079
1084 m_activeHandle.reset();
1085 m_activeSegment.reset();
1086 m_currentStrategy.reset();
1087 d->canvas->snapGuide()->reset();
1088
1089 disconnect(m_actionCurvePoint, 0, this, 0);
1090 disconnect(m_actionLinePoint, 0, this, 0);
1091 disconnect(m_actionLineSegment, 0, this, 0);
1092 disconnect(m_actionCurveSegment, 0, this, 0);
1093 disconnect(m_actionAddPoint, 0, this, 0);
1094 disconnect(m_actionRemovePoint, 0, this, 0);
1095 disconnect(m_actionBreakPoint, 0, this, 0);
1096 disconnect(m_actionBreakSegment, 0, this, 0);
1097 disconnect(m_actionBreakSelection, 0, this, 0);
1098 disconnect(m_actionJoinSegment, 0, this, 0);
1099 disconnect(m_actionMergePoints, 0, this, 0);
1100 disconnect(m_actionConvertToPath, 0, this, 0);
1101 disconnect(m_actionPathPointCorner, 0, this, 0);
1102 disconnect(m_actionPathPointSmooth, 0, this, 0);
1103 disconnect(m_actionPathPointSymmetric, 0, this, 0);
1104 disconnect(&m_pointSelection, 0, this, 0);
1105
1107}
1108
1109void KoPathTool::canvasResourceChanged(int key, const QVariant & /*res*/)
1110{
1113 }
1114}
1115
1117{
1118 Q_D(KoToolBase);
1119 updateActions();
1120 d->canvas->snapGuide()->setIgnoredPathPoints(QList<KoPathPoint*>(m_pointSelection.selectedPoints().begin(), m_pointSelection.selectedPoints().end()));
1122}
1123
1124namespace {
1125void addActionsGroupIfEnabled(QMenu *menu, QAction *a1, QAction *a2)
1126{
1127 if (a1->isEnabled() || a2->isEnabled()) {
1128 menu->addAction(a1);
1129 menu->addAction(a2);
1130 menu->addSeparator();
1131 }
1132}
1133
1134void addActionsGroupIfEnabled(QMenu *menu, QAction *a1, QAction *a2, QAction *a3)
1135{
1136 if (a1->isEnabled() || a2->isEnabled()) {
1137 menu->addAction(a1);
1138 menu->addAction(a2);
1139 menu->addAction(a3);
1140 menu->addSeparator();
1141 }
1142}
1143}
1144
1146{
1147 if (m_activeHandle) {
1148 m_activeHandle->trySelectHandle();
1149 }
1150
1151 if (m_activeSegment && m_activeSegment->isValid()) {
1152 KoPathShape *shape = m_activeSegment->path;
1153 KoPathSegment segment = shape->segmentByIndex(shape->pathPointIndex(m_activeSegment->segmentStart));
1154
1155 m_pointSelection.add(segment.first(), true);
1156 m_pointSelection.add(segment.second(), false);
1157 }
1158
1159 if (m_contextMenu) {
1160 m_contextMenu->clear();
1161
1162 addActionsGroupIfEnabled(m_contextMenu.data(),
1166
1167 addActionsGroupIfEnabled(m_contextMenu.data(),
1170
1171 addActionsGroupIfEnabled(m_contextMenu.data(),
1174
1175 addActionsGroupIfEnabled(m_contextMenu.data(),
1178
1179 addActionsGroupIfEnabled(m_contextMenu.data(),
1182
1183 addActionsGroupIfEnabled(m_contextMenu.data(),
1186
1188
1189 m_contextMenu->addSeparator();
1190 }
1191
1192 return m_contextMenu.data();
1193}
1194
1199
1204
1206{
1207 // noop!
1208}
1209
1214
1216{
1217 // noop!
1218}
1219
1224
1226{
1229 return true;
1230}
1231
const Params2D p
QPointF p2
QPointF p1
unsigned int uint
QPair< int, int > KoPathPointIndex
Definition KoPathShape.h:28
qreal squaredDistance(const QPointF &p1, const QPointF &p2)
KUndo2MagicString text() const
virtual void redo()
The KisHandlePainterHelper class is a special helper for painting handles around objects....
void drawPath(const QPainterPath &path)
void setHandleStyle(const KisHandleStyle &style)
static KisHandleStyle & secondarySelection(KisHandlePalette palette=KisHandlePalette())
static KisHandleStyle & primarySelection(KisHandlePalette palette=KisHandlePalette())
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
QPointer< KoShapeController > shapeController
virtual KoShapeManager * shapeManager() const =0
virtual KoColorDisplayRendererInterface * displayRendererInterface() const
displayRendererInterface The display renderer interface has a number of color conversion functions wh...
virtual void addCommand(KUndo2Command *command)=0
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
virtual KisHandlePalette handlePaletteForDisplayColorSpace() const =0
handlePaletteForDisplayColorSpace
void paintHandles(KisHandlePainterHelper &handlesHelper)
Paint the handles.
bool isParametricShape() const
Check if object is a parametric shape.
int handleIdAt(const QRectF &rect) const
Get the id of the handle within the given rect.
The undo / redo command for changing a KoParameterShape into a KoPathShape.
Command to break a subpath at points.
Describe a KoPathPoint by a KoPathShape and its indices.
KoPathPointIndex pointIndex
position of the point in the path shape
KoPathShape * pathShape
path shape the path point belongs too
The undo / redo command for inserting path points.
QList< KoPathPoint * > insertedPoints() const
Returns list of inserted points.
static KUndo2Command * createCommand(const QList< KoPathPointData > &pointDataList, KoShapeController *shapeController, KUndo2Command *parent=0)
Create command for removing points from path shapes.
Strategy to rubber select points of a path shape.
The undo / redo command for changing the path point type.
PointType
The type of the point.
A KoPathPoint represents a point in a path.
PointProperties properties
QRectF boundingRect(bool active=true) const
Get the bounding rect of the point.
QPointF point
QPointF controlPoint1
@ IsSmooth
it is smooth, both control points on a line through the point
Definition KoPathPoint.h:41
@ IsSymmetric
it is symmetric, like smooth but control points have same distance to point
Definition KoPathPoint.h:42
PointType
the type for identifying part of a KoPathPoint
Definition KoPathPoint.h:47
@ ControlPoint2
the second control point
Definition KoPathPoint.h:51
@ ControlPoint1
the first control point
Definition KoPathPoint.h:50
@ Node
the node point
Definition KoPathPoint.h:49
bool activeControlPoint1
bool activeControlPoint2
QPointF controlPoint2
The undo / redo command for breaking a subpath by removing the segment.
Strategy for deforming a segment of a path shape.
The undo / redo command for changing segments to curves/lines.
A KoPathSegment consist of two neighboring KoPathPoints.
KoPathPoint * first
int degree() const
Returns the degree of the segment: 1 = line, 2 = quadratic, 3 = cubic, -1 = invalid.
qreal nearestPoint(const QPointF &point) const
KoPathPoint * second
bool isValid() const
Returns if segment is valid, e.g. has two valid points.
QRectF boundingRect() const
Returns the axis aligned tight bounding rect.
KoPathSegment toCubic() const
Returns cubic bezier curve segment of this segment.
The position of a path point within a path shape.
Definition KoPathShape.h:63
int subpathPointCount(int subpathIndex) const
Returns the number of points in a subpath.
bool isClosedSubpath(int subpathIndex) const
Checks if a subpath is closed.
KoPathSegment segmentAtPoint(const QPointF &point, const QRectF &grabRoi) const
QList< KoPathPoint * > pointsAt(const QRectF &rect, const bool useControlPoints=false) const
Returns the path points within the given rectangle.
QPainterPath outline() const override
reimplemented
KoPathSegment segmentByIndex(const KoPathPointIndex &pointIndex) const
Returns the segment specified by a path point index.
virtual void paintPoints(KisHandlePainterHelper &handlesHelper)
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.
Handle the selection of points.
int objectCount() const
Get the number of path objects in the selection.
const QSet< KoPathPoint * > & selectedPoints() const
Get all selected points.
bool contains(KoPathPoint *point)
Check if a point is in the selection.
bool hasSelection() override
reimplemented from KoToolSelection
int size() const
Get the number of path points in the selection.
QList< KoPathPointData > selectedPointsData() const
Get the point data of all selected points.
void clear()
Clear the selection.
void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, KoColorDisplayRendererInterface *renderInterface)
Draw the selected points.
QList< KoPathShape * > selectedShapes() const
Returns list of selected shapes.
void add(KoPathPoint *point, bool clear)
Add a point to the selection.
void setSelectedShapes(const QList< KoPathShape * > shapes)
Sets list of selected shapes.
void remove(KoPathPoint *point)
Remove a point form the selection.
QList< KoPathPointData > selectedSegmentsData() const
Get the point data of all selected segments.
void canvasResourceChanged(int key, const QVariant &res) override
void mousePressEvent(KoPointerEvent *event) override
QAction * m_actionJoinSegment
Definition KoPathTool.h:139
QScopedPointer< KoInteractionStrategy > m_currentStrategy
the rubber selection strategy
Definition KoPathTool.h:125
void updateActions()
void mouseMoveEvent(KoPointerEvent *event) override
QCursor m_selectCursor
Definition KoPathTool.h:115
QAction * m_actionCurvePoint
Definition KoPathTool.h:130
void pointTypeChangedSmooth()
QAction * m_actionLinePoint
Definition KoPathTool.h:131
void activate(const QSet< KoShape * > &shapes) override
QAction * m_actionRemovePoint
Definition KoPathTool.h:135
KoPathToolSelection m_pointSelection
the point selection
Definition KoPathTool.h:114
void updateOptionsWidget()
QAction * m_actionLineSegment
Definition KoPathTool.h:132
void breakAtSelection()
QRectF decorationsRect() const override
QScopedPointer< QMenu > m_contextMenu
Definition KoPathTool.h:143
QMenu * popupActionsMenu() override
void requestStrokeCancellation() override
void requestStrokeEnd() override
void segmentToCurve()
void keyPressEvent(QKeyEvent *event) override
QAction * m_actionPathPointSymmetric
Definition KoPathTool.h:129
QScopedPointer< PathSegment > m_activeSegment
Definition KoPathTool.h:120
QScopedPointer< KoSvgTextShapeOutlineHelper > m_textOutlineHelper
Definition KoPathTool.h:144
QAction * m_actionBreakSegment
Definition KoPathTool.h:137
void breakAtPoint()
~KoPathTool() override
void pointToLine()
void convertToPath()
void deselect() override
deselect the tool should clear the selection if it has one.
QAction * m_actionAddPoint
Definition KoPathTool.h:134
void joinPoints()
void singleShapeChanged(KoPathShape *path)
KUndo2Command * createPointToCurveCommand(const QList< KoPathPointData > &points)
PathSegment * segmentAtPoint(const QPointF &point)
KisSignalAutoConnectionsStore m_canvasConnections
Definition KoPathTool.h:145
bool selectAll() override
selectAll select all data the tool can select.
QAction * m_actionPathPointSmooth
Definition KoPathTool.h:128
void pointSelectionChanged()
void segmentToLine()
void pointToCurve()
QPointF m_lastPoint
needed for interaction strategy
Definition KoPathTool.h:119
QAction * m_actionCurveSegment
Definition KoPathTool.h:133
void pointTypeChangedCorner()
void slotSelectionChanged()
void mouseDoubleClickEvent(KoPointerEvent *event) override
QCursor m_moveCursor
Definition KoPathTool.h:142
void mouseReleaseEvent(KoPointerEvent *event) override
void breakAtSegment()
KoToolSelection * selection() override
QList< QPointer< QWidget > > createOptionWidgets() override
reimplemented
void clearActivePointSelectionReferences()
void explicitUserStrokeEndRequest() override
explicitUserStrokeEndRequest is called by the input manager when the user presses Enter key or any eq...
KoPathTool(KoCanvasBase *canvas)
void pointTypeChangedSymmetric()
void deactivate() override
void mergePointsImpl(bool doJoin)
void removePoints()
void initializeWithShapes(const QList< KoShape * > shapes)
void pointTypeChanged(KoPathPointTypeCommand::PointType type)
QAction * m_actionMergePoints
Definition KoPathTool.h:140
QScopedPointer< KoPathToolHandle > m_activeHandle
the currently active handle
Definition KoPathTool.h:118
void keyReleaseEvent(QKeyEvent *event) override
void deleteSelection() override
void mergePoints()
KoShapeFillResourceConnector m_shapeFillResourceConnector
Definition KoPathTool.h:146
void notifyPathPointsChanged(KoPathShape *shape)
void requestUndoDuringStroke() override
void paint(QPainter &painter, const KoViewConverter &converter) override
QAction * m_actionBreakPoint
Definition KoPathTool.h:136
QAction * m_actionConvertToPath
Definition KoPathTool.h:141
void repaintDecorations() override
QAction * m_actionPathPointCorner
Definition KoPathTool.h:127
void insertPoints()
void typeChanged(int types)
QAction * m_actionBreakSelection
Definition KoPathTool.h:138
Qt::MouseButton button() const
return button pressed (see QMouseEvent::button());
bool isTouchEvent() const
Qt::KeyboardModifiers modifiers() const
QPointF point
The point in document coordinates.
virtual KoSelection * selection()=0
KoShape * shapeAt(const QPointF &position, KoFlake::ShapeSelection selection=KoFlake::ShapeOnTop, bool omitHiddenShapes=true)
KoSelection * selection
virtual bool isShapeEditable(bool recursive=true) const
checks recursively if the shape or one of its parents is not visible or locked
Definition KoShape.cpp:965
virtual KoShapeStrokeModelSP stroke() const
Definition KoShape.cpp:885
QPointF documentToShape(const QPointF &point) const
Transforms point from document coordinates to shape coordinates.
Definition KoShape.cpp:1011
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:300
KoShapeContainer * parent() const
Definition KoShape.cpp:857
static KisHandlePainterHelper createHandlePainterHelperView(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
Definition KoShape.cpp:977
The KoSvgTextShapeOutlineHelper class helper class that draws the text outlines and contour mode butt...
KoShape * textOutline() const
textOutline This turns the text object into non-text KoShape(s) to the best of its abilities.
qreal handleDocRadius() const
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
void selectionChanged(bool hasSelection)
void statusTextChanged(const QString &statusText)
virtual void repaintDecorations()
int handleRadius() const
Convenience function to get the current handle radius.
void useCursor(const QCursor &cursor)
virtual void activate(const QSet< KoShape * > &shapes)
QRectF handleGrabRect(const QPointF &position) const
virtual void deactivate()
QAction * action(const QString &name) const
int decorationThickness() const
decorationThickness The minimum thickness for tool decoration lines, this is derived from the screen ...
void switchToolRequested(const QString &id)
static KoToolManager * instance()
Return the toolmanager singleton.
virtual QPointF documentToView(const QPointF &documentPoint) const
KoPathPoint * activePoint() const
KoPathPoint::PointType activePointType() const
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
T kisGrowRect(const T &rect, U offset)
Definition kis_global.h:186
KUndo2MagicString kundo2_i18n(const char *text)
@ DecorationThickness
Integer, the thickness of single px decorations, will be adjusted by HiDPI settings....
@ HandleRadius
The handle radius used for drawing handles of any kind.
@ ShapeOnTop
return the shape highest z-ordering, regardless of selection.
Definition KoFlake.h:74
KoPathPoint * segmentStart