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 "KoCanvasController.h"
29#include "KoToolManager.h"
30#include "KoViewConverter.h"
40#include "kis_action_registry.h"
41#include "kis_command_utils.h"
42#include "kis_pointer_utils.h"
44#include <KoShapeStrokeModel.h>
50#include <text/KoSvgTextShape.h>
51
52#include <KoIcon.h>
53
54#include <QMenu>
55#include <QAction>
56#include <FlakeDebug.h>
57#include <klocalizedstring.h>
58#include <QPainter>
59#include <QPainterPath>
60#include <QBitmap>
61#include <QTabWidget>
62
63#include <math.h>
64
65// helper function to calculate the squared distance between two points
66qreal squaredDistance(const QPointF& p1, const QPointF &p2)
67{
68 qreal dx = p1.x()-p2.x();
69 qreal dy = p1.y()-p2.y();
70 return dx*dx + dy*dy;
71}
72
75 : path(0), segmentStart(0), positionOnSegment(0)
76 {
77 }
78
79 bool isValid() {
80 return path && segmentStart;
81 }
82
86};
87
89 : KoToolBase(canvas)
90 , m_pointSelection(this)
91 , m_textOutlineHelper(new KoSvgTextShapeOutlineHelper(canvas))
92{
93 m_actionPathPointCorner = action("pathpoint-corner");
94 m_actionPathPointSmooth = action("pathpoint-smooth");
95 m_actionPathPointSymmetric = action("pathpoint-symmetric");
96 m_actionCurvePoint = action("pathpoint-curve");
97 m_actionLinePoint = action("pathpoint-line");
98 m_actionLineSegment = action("pathsegment-line");
99 m_actionCurveSegment = action("pathsegment-curve");
100 m_actionAddPoint = action("pathpoint-insert");
101 m_actionRemovePoint = action("pathpoint-remove");
102 m_actionBreakPoint = action("path-break-point");
103 m_actionBreakSegment = action("path-break-segment");
104 m_actionBreakSelection = action("path-break-selection");
105 m_actionJoinSegment = action("pathpoint-join");
106 m_actionMergePoints = action("pathpoint-merge");
107 m_actionConvertToPath = action("convert-to-path");
108
109 m_contextMenu.reset(new QMenu());
110 m_textOutlineHelper->setDrawBoundingRect(true);
111 m_textOutlineHelper->setDrawShapeOutlines(false);
112
113 m_selectCursor = QCursor(QIcon(":/cursor-needle.svg").pixmap(32), 0, 0);
114 m_moveCursor = QCursor(QIcon(":/cursor-needle-move.svg").pixmap(32), 0, 0);
115
116 connect(&m_pointSelection, SIGNAL(selectionChanged()), SLOT(repaintDecorations()));
117}
118
122
124{
126
127 PathToolOptionWidget * toolOptions = new PathToolOptionWidget(this);
128 connect(this, SIGNAL(typeChanged(int)), toolOptions, SLOT(setSelectionType(int)));
129 connect(this, SIGNAL(singleShapeChanged(KoPathShape*)), toolOptions, SLOT(setCurrentShape(KoPathShape*)));
130 connect(toolOptions, SIGNAL(sigRequestUpdateActions()), this, SLOT(updateActions()));
132 toolOptions->setWindowTitle(i18n("Edit Shape"));
133 list.append(toolOptions);
134
135 return list;
136}
137
147
149{
150 Q_D(KoToolBase);
153
154 KUndo2Command *initialConversionCommand = createPointToCurveCommand(selectedPoints);
155
156 // conversion should happen before the c-tor
157 // of KoPathPointTypeCommand is executed!
158 if (initialConversionCommand) {
159 initialConversionCommand->redo();
160 }
161
162 KUndo2Command *command =
163 new KoPathPointTypeCommand(selectedPoints, type);
164
165 if (initialConversionCommand) {
166 using namespace KisCommandUtils;
167 CompositeCommand *parent = new CompositeCommand();
168 parent->setText(command->text());
169 parent->addCommand(new SkipFirstRedoWrapper(initialConversionCommand));
170 parent->addCommand(command);
171 command = parent;
172 }
173
174 d->canvas->addCommand(command);
175 }
176}
177
179{
180 Q_D(KoToolBase);
182 if (segments.size() == 1) {
183 qreal positionInSegment = 0.5;
184 if (m_activeSegment && m_activeSegment->isValid()) {
185 positionInSegment = m_activeSegment->positionOnSegment;
186 }
187
188 KoPathPointInsertCommand *cmd = new KoPathPointInsertCommand(segments, positionInSegment);
189 d->canvas->addCommand(cmd);
190
191 // TODO: this construction is dangerous. The canvas can remove the command right after
192 // it has been added to it!
194 foreach (KoPathPoint * p, cmd->insertedPoints()) {
195 m_pointSelection.add(p, false);
196 }
197 }
198}
199
201{
202 Q_D(KoToolBase);
203 if (m_pointSelection.size() > 0) {
205 PointHandle *pointHandle = dynamic_cast<PointHandle*>(m_activeHandle.data());
206 if (pointHandle && m_pointSelection.contains(pointHandle->activePoint())) {
207 m_activeHandle.reset();
208 }
210 d->canvas->addCommand(cmd);
211 }
212}
213
215{
216 Q_D(KoToolBase);
219 QList<KoPathPointData> pointToChange;
220
221 QList<KoPathPointData>::const_iterator it(selectedPoints.constBegin());
222 for (; it != selectedPoints.constEnd(); ++it) {
223 KoPathPoint *point = it->pathShape->pointByIndex(it->pointIndex);
224 if (point && (point->activeControlPoint1() || point->activeControlPoint2()))
225 pointToChange.append(*it);
226 }
227
228 if (! pointToChange.isEmpty()) {
229 d->canvas->addCommand(new KoPathPointTypeCommand(pointToChange, KoPathPointTypeCommand::Line));
230 }
231 }
232}
233
235{
236 Q_D(KoToolBase);
239
240 KUndo2Command *command = createPointToCurveCommand(selectedPoints);
241
242 if (command) {
243 d->canvas->addCommand(command);
244 }
245 }
246}
247
249{
250 KUndo2Command *command = 0;
251 QList<KoPathPointData> pointToChange;
252
253 QList<KoPathPointData>::const_iterator it(points.constBegin());
254 for (; it != points.constEnd(); ++it) {
255 KoPathPoint *point = it->pathShape->pointByIndex(it->pointIndex);
256 if (point && (! point->activeControlPoint1() || ! point->activeControlPoint2()))
257 pointToChange.append(*it);
258 }
259
260 if (!pointToChange.isEmpty()) {
261 command = new KoPathPointTypeCommand(pointToChange, KoPathPointTypeCommand::Curve);
262 }
263
264 return command;
265}
266
268{
269 Q_D(KoToolBase);
270 if (m_pointSelection.size() > 1) {
272 if (segments.size() > 0) {
273 d->canvas->addCommand(new KoPathSegmentTypeCommand(segments, KoPathSegmentTypeCommand::Line));
274 }
275 }
276}
277
279{
280 Q_D(KoToolBase);
281 if (m_pointSelection.size() > 1) {
283 if (segments.size() > 0) {
284 d->canvas->addCommand(new KoPathSegmentTypeCommand(segments, KoPathSegmentTypeCommand::Curve));
285 }
286 }
287}
288
290{
291 Q_D(KoToolBase);
292
294
295 QList<KoParameterShape*> parameterShapes;
296
297 Q_FOREACH (KoShape *shape, m_pointSelection.selectedShapes()) {
298 KoParameterShape * parametric = dynamic_cast<KoParameterShape*>(shape);
299 if (parametric && parametric->isParametricShape()) {
300 parameterShapes.append(parametric);
301 }
302 }
303
304 if (!parameterShapes.isEmpty()) {
305 d->canvas->addCommand(new KoParameterToPathCommand(parameterShapes));
306 }
307
308 QList<KoSvgTextShape*> textShapes;
309 Q_FOREACH (KoShape *shape, selection->selectedEditableShapes()) {
310 if (KoSvgTextShape *text = dynamic_cast<KoSvgTextShape*>(shape)) {
311 textShapes.append(text);
312 }
313 }
314
315 if (!textShapes.isEmpty()) {
316 KUndo2Command *cmd = new KUndo2Command(kundo2_i18n("Convert to Path")); // TODO: reuse the text from KoParameterToPathCommand
317 const QList<KoShape*> oldSelectedShapes = implicitCastList<KoShape*>(textShapes);
318
319
320 new KoKeepShapesSelectedCommand(oldSelectedShapes, {}, canvas()->selectedShapesProxy(),
322
323 QList<KoShape*> newSelectedShapes;
324 Q_FOREACH (KoSvgTextShape *shape, textShapes) {
325 KoShape *outlineShape = shape->textOutline();
326
327 KoShapeContainer *parent = shape->parent();
328 canvas()->shapeController()->addShapeDirect(outlineShape, parent, cmd);
329
330 newSelectedShapes << outlineShape;
331 }
332
333 canvas()->shapeController()->removeShapes(oldSelectedShapes, cmd);
334
335 new KoKeepShapesSelectedCommand({}, newSelectedShapes, canvas()->selectedShapesProxy(),
337
338 canvas()->addCommand(cmd);
339 }
340
342}
343
344namespace {
345bool checkCanJoinToPoints(const KoPathPointData & pd1, const KoPathPointData & pd2)
346{
347 const KoPathPointIndex & index1 = pd1.pointIndex;
348 const KoPathPointIndex & index2 = pd2.pointIndex;
349
350 KoPathShape *path1 = pd1.pathShape;
351 KoPathShape *path2 = pd2.pathShape;
352
353 // check if subpaths are already closed
354 if (path1->isClosedSubpath(index1.first) || path2->isClosedSubpath(index2.first))
355 return false;
356
357 // check if first point is an endpoint
358 if (index1.second != 0 && index1.second != path1->subpathPointCount(index1.first)-1)
359 return false;
360
361 // check if second point is an endpoint
362 if (index2.second != 0 && index2.second != path2->subpathPointCount(index2.first)-1)
363 return false;
364
365 return true;
366}
367}
368
370{
371 Q_D(KoToolBase);
372
373 if (m_pointSelection.size() != 2)
374 return;
375
377 if (pointData.size() != 2) return;
378
379 const KoPathPointData & pd1 = pointData.at(0);
380 const KoPathPointData & pd2 = pointData.at(1);
381
382 if (!checkCanJoinToPoints(pd1, pd2)) {
383 return;
384 }
385
387
388 KUndo2Command *cmd = 0;
389
390 if (doJoin) {
391 cmd = new KoMultiPathPointJoinCommand(pd1, pd2, d->canvas->shapeController()->documentBase(), d->canvas->shapeManager()->selection());
392 } else {
393 cmd = new KoMultiPathPointMergeCommand(pd1, pd2, d->canvas->shapeController()->documentBase(), d->canvas->shapeManager()->selection());
394 }
395 d->canvas->addCommand(cmd);
396}
397
399{
400 mergePointsImpl(true);
401}
402
404{
405 mergePointsImpl(false);
406}
407
409{
410 Q_D(KoToolBase);
413 }
414}
415
417{
418 Q_D(KoToolBase);
419
420 if (m_pointSelection.objectCount() == 1 && m_pointSelection.size() == 2) {
422 if (segments.size() == 1) {
423 d->canvas->addCommand(new KoPathSegmentBreakCommand(segments.at(0)));
424 }
425 } else if (m_pointSelection.hasSelection()) {
427 }
428}
429
431{
432 Q_D(KoToolBase);
433 // only try to break a segment when 2 points of the same object are selected
434 if (m_pointSelection.objectCount() == 1 && m_pointSelection.size() == 2) {
436 if (segments.size() == 1) {
437 d->canvas->addCommand(new KoPathSegmentBreakCommand(segments.at(0)));
438 }
439 }
440}
441
442void KoPathTool::paint(QPainter &painter, const KoViewConverter &converter)
443{
444 Q_D(KoToolBase);
445 m_textOutlineHelper->setDecorationThickness(decorationThickness());
446 m_textOutlineHelper->setHandleRadius(handleRadius());
447 m_textOutlineHelper->paint(&painter, converter);
448
450
451 Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
455
456 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
457 if (parameterShape && parameterShape->isParametricShape()) {
458 parameterShape->paintHandles(helper);
459 } else {
460 shape->paintPoints(helper);
461 }
462
463 if (!shape->stroke() || !shape->stroke()->isVisible()) {
465 helper.drawPath(shape->outline());
466 }
467 }
468
469 if (m_currentStrategy) {
470 painter.save();
471 m_currentStrategy->paint(painter, converter, canvas()->displayRendererInterface());
472 painter.restore();
473 }
474
476
477 if (m_activeHandle) {
480 } else {
481 m_activeHandle.reset();
482 }
483 } else if (m_activeSegment && m_activeSegment->isValid()) {
484
485 KoPathShape *shape = m_activeSegment->path;
486
487 // if the stroke is invisible, then we already painted the outline of the shape!
488 if (shape->stroke() && shape->stroke()->isVisible()) {
489 KoPathPointIndex index = shape->pathPointIndex(m_activeSegment->segmentStart);
490 KoPathSegment segment = shape->segmentByIndex(index).toCubic();
491
493
497
498 QPainterPath path;
499 path.moveTo(segment.first()->point());
500 path.cubicTo(segment.first()->controlPoint2(),
501 segment.second()->controlPoint1(),
502 segment.second()->point());
503
504 helper.drawPath(path);
505 }
506 }
507
508
509
510 if (m_currentStrategy) {
511 painter.save();
512 painter.setTransform(converter.documentToView(), true);
513 d->canvas->snapGuide()->paint(painter, converter, canvas()->displayRendererInterface());
514 painter.restore();
515 }
516}
517
519{
520 const_cast<KoPathToolSelection&>(m_pointSelection).update();
521
522 QRectF newDecorationsRect;
523
524 Q_FOREACH (KoShape *shape, m_pointSelection.selectedShapes()) {
525 newDecorationsRect |= kisGrowRect(shape->boundingRect(), handleDocRadius());
526 }
527
528 Q_FOREACH(const KoPathPoint *point, m_pointSelection.selectedPoints()) {
529 newDecorationsRect |= kisGrowRect(point->boundingRect(false), handleDocRadius());
530 }
531
532 if (m_activeHandle) {
533 newDecorationsRect |= kisGrowRect(m_activeHandle->boundingRect(), handleDocRadius());
534 }
535
536 if (m_activeSegment) {
537 KoPathPointIndex index = m_activeSegment->path->pathPointIndex(m_activeSegment->segmentStart);
538 KoPathSegment segment = m_activeSegment->path->segmentByIndex(index);
539
540 QRectF rect = segment.boundingRect();
541 rect = m_activeSegment->path->shapeToDocument(rect);
542
543 newDecorationsRect |= kisGrowRect(rect, handleDocRadius());
544 }
545
546 newDecorationsRect |= m_textOutlineHelper->decorationRect();
547
548 return newDecorationsRect;
549}
550
556
558{
559 // When using touch drawing, we only ever receive move events after the
560 // finger has pressed down. We have to issue an artificial move here so that
561 // the tool's state is updated properly to handle the press.
562 if (event->isTouchEvent()) {
563 mouseMoveEvent(event);
564 }
565
566 if (KoSvgTextShape *shape = m_textOutlineHelper->contourModeButtonHovered(event->point)) {
567 m_textOutlineHelper->toggleTextContourMode(shape);
568 event->accept();
569 }
570 // we are moving if we hit a point and use the left mouse button
571 if (m_activeHandle) {
572 m_currentStrategy.reset(m_activeHandle->handleMousePress(event));
573 } else {
574
575 if (event->button() & Qt::LeftButton) {
576
577 bool shift_pressed = (event->modifiers() & Qt::ShiftModifier);
578
579 // check if we hit a path segment
580 if (m_activeSegment && m_activeSegment->isValid()) {
581
582 KoPathShape *shape = m_activeSegment->path;
583 KoPathPointIndex index = shape->pathPointIndex(m_activeSegment->segmentStart);
584 KoPathSegment segment = shape->segmentByIndex(index);
585
586 // The segment is selected so now need to deselect it
588 && shift_pressed) {
589 m_pointSelection.remove(segment.first());
590 m_pointSelection.remove(segment.second());
591 } else {
592 m_pointSelection.add(segment.first(), !shift_pressed);
593 m_pointSelection.add(segment.second(), false);
594 }
595
596 KoPathPointData data(shape, index);
597 m_currentStrategy.reset(new KoPathSegmentChangeStrategy(this, event->point, data, m_activeSegment->positionOnSegment));
598 } else {
599
600 KoShapeManager *shapeManager = canvas()->shapeManager();
601 KoSelection *selection = shapeManager->selection();
602 KoShape *shape = shapeManager->shapeAt(event->point, KoFlake::ShapeOnTop);
603
604 if (shape && !selection->isSelected(shape)) {
605
606 if (!shift_pressed) {
607 selection->deselectAll();
608 }
609
610 selection->select(shape);
611 } else {
614 }
615 }
616 }
617 }
618}
619
621{
622 if (event->button() & Qt::RightButton)
623 return;
624
625 if (m_currentStrategy) {
626 m_lastPoint = event->point;
627 m_currentStrategy->handleMouseMove(event->point, event->modifiers());
628
630
631 return;
632 }
633
634 if (m_activeSegment) {
635 m_activeSegment.reset();
637 }
638
639 Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
640 QRectF roi = shape->documentToShape(handleGrabRect(event->point));
641 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
642 if (parameterShape && parameterShape->isParametricShape()) {
643 int handleId = parameterShape->handleIdAt(roi);
644 if (handleId != -1) {
646 Q_EMIT statusTextChanged(i18n("Drag to move handle."));
647
648 m_activeHandle.reset(new ParameterHandle(this, parameterShape, handleId));
650 return;
651 }
652 } else {
653 QList<KoPathPoint*> points = shape->pointsAt(roi, true);
654 if (! points.empty()) {
655 // find the nearest control point from all points within the roi
656 KoPathPoint * bestPoint = 0;
658 qreal minDistance = HUGE_VAL;
659 Q_FOREACH (KoPathPoint *p, points) {
660 // the node point must be hit if the point is not selected yet
661 if (! m_pointSelection.contains(p) && ! roi.contains(p->point()))
662 continue;
663
664 // check for the control points first as otherwise it is no longer
665 // possible to change the control points when they are the same as the point
666 if (p->activeControlPoint1() && roi.contains(p->controlPoint1())) {
667 qreal dist = squaredDistance(roi.center(), p->controlPoint1());
668 if (dist < minDistance) {
669 bestPoint = p;
670 bestPointType = KoPathPoint::ControlPoint1;
671 minDistance = dist;
672 }
673 }
674
675 if (p->activeControlPoint2() && roi.contains(p->controlPoint2())) {
676 qreal dist = squaredDistance(roi.center(), p->controlPoint2());
677 if (dist < minDistance) {
678 bestPoint = p;
679 bestPointType = KoPathPoint::ControlPoint2;
680 minDistance = dist;
681 }
682 }
683
684 // check the node point at last
685 qreal dist = squaredDistance(roi.center(), p->point());
686 if (dist < minDistance) {
687 bestPoint = p;
688 bestPointType = KoPathPoint::Node;
689 minDistance = dist;
690 }
691 }
692
693 if (! bestPoint) {
695 return;
696 }
697
699 if (bestPointType == KoPathPoint::Node)
700 Q_EMIT statusTextChanged(i18n("Drag to move point. Shift click to change point type."));
701 else
702 Q_EMIT statusTextChanged(i18n("Drag to move control point."));
703
704 PointHandle *prev = dynamic_cast<PointHandle*>(m_activeHandle.data());
705 if (prev && prev->activePoint() == bestPoint && prev->activePointType() == bestPointType)
706 return; // no change;
707
708 m_activeHandle.reset(new PointHandle(this, bestPoint, bestPointType));
710 return;
711 }
712 }
713 }
714
716
717 if (m_activeHandle) {
718 m_activeHandle.reset();
720 }
721
722 PathSegment *hoveredSegment = segmentAtPoint(event->point);
723 if(hoveredSegment) {
724 useCursor(Qt::PointingHandCursor);
725 Q_EMIT statusTextChanged(i18n("Drag to change curve directly. Double click to insert new path point."));
726 m_activeSegment.reset(hoveredSegment);
728 } else {
729 uint selectedPointCount = m_pointSelection.size();
730 if (selectedPointCount == 0)
731 Q_EMIT statusTextChanged(QString());
732 else {
733 if (!m_actionBreakSelection->shortcut().isEmpty()) {
734 if (selectedPointCount == 1)
735 Q_EMIT statusTextChanged(i18nc("%1 is a shortcut to be pressed", "Press %1 to break path at selected point.", m_actionBreakSelection->shortcut().toString()));
736 else
737 Q_EMIT statusTextChanged(i18nc("%1 is a shortcut to be pressed", "Press %1 to break path at selected segments.", m_actionBreakSelection->shortcut().toString()));
738 } else {
739 Q_EMIT statusTextChanged(QString());
740 }
741 }
742 }
743}
744
746{
747 Q_D(KoToolBase);
748 if (m_currentStrategy) {
749 const bool hadNoSelection = !m_pointSelection.hasSelection();
750 m_currentStrategy->finishInteraction(event->modifiers());
751 KUndo2Command *command = m_currentStrategy->createCommand();
752 if (command)
753 d->canvas->addCommand(command);
754 if (hadNoSelection && dynamic_cast<KoPathPointRubberSelectStrategy*>(m_currentStrategy.data())
756 // the click didn't do anything at all. Allow it to be used by others.
757 event->ignore();
758 }
759 m_currentStrategy.reset();
761 }
762}
763
764void KoPathTool::keyPressEvent(QKeyEvent *event)
765{
766 if (m_currentStrategy) {
767 switch (event->key()) {
768 case Qt::Key_Control:
769 case Qt::Key_Alt:
770 case Qt::Key_Shift:
771 case Qt::Key_Meta:
772 if (! event->isAutoRepeat()) {
773 m_currentStrategy->handleMouseMove(m_lastPoint, event->modifiers());
774 }
775 break;
776 case Qt::Key_Escape:
777 m_currentStrategy->cancelInteraction();
778 m_currentStrategy.reset();
779 break;
780 default:
781 event->ignore();
782 return;
783 }
784 } else {
785 switch (event->key()) {
786#ifndef NDEBUG
787// case Qt::Key_D:
788// if (m_pointSelection.objectCount() == 1) {
789// QList<KoPathPointData> selectedPoints = m_pointSelection.selectedPointsData();
790// KoPathShapePrivate *p = static_cast<KoPathShapePrivate*>(selectedPoints[0].pathShape->priv());
791// p->debugPath();
792// }
793// break;
794#endif
795 default:
796 event->ignore();
797 return;
798 }
799 }
800 event->accept();
801}
802
803void KoPathTool::keyReleaseEvent(QKeyEvent *event)
804{
805 if (m_currentStrategy) {
806 switch (event->key()) {
807 case Qt::Key_Control:
808 case Qt::Key_Alt:
809 case Qt::Key_Shift:
810 case Qt::Key_Meta:
811 if (! event->isAutoRepeat()) {
812 m_currentStrategy->handleMouseMove(m_lastPoint, Qt::NoModifier);
813 }
814 break;
815 default:
816 break;
817 }
818 }
819 event->accept();
820}
821
823{
824 Q_D(KoToolBase);
825 // check if we are doing something else at the moment
826 if (m_currentStrategy) return;
827
828 if (!m_activeHandle && m_activeSegment && m_activeSegment->isValid()) {
829 QList<KoPathPointData> segments;
830 segments.append(
832 m_activeSegment->path->pathPointIndex(m_activeSegment->segmentStart)));
833
834 KoPathPointInsertCommand *cmd = new KoPathPointInsertCommand(segments, m_activeSegment->positionOnSegment);
835 d->canvas->addCommand(cmd);
836
838 foreach (KoPathPoint * p, cmd->insertedPoints()) {
839 m_pointSelection.add(p, false);
840 }
842
843 // Call a mouse move event to update the cursor and allow the user to drag the new point immediately
844 mouseMoveEvent(event);
845 } else if (!m_activeHandle && !m_activeSegment) {
847 }
848}
849
851{
852 // the max allowed distance from a segment
853 const QRectF grabRoi = handleGrabRect(point);
854 std::unique_ptr<PathSegment> segment(new PathSegment);
855
856 Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
857 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
858 if (parameterShape && parameterShape->isParametricShape())
859 continue;
860
861 const KoPathSegment s = shape->segmentAtPoint(point, grabRoi);
862 if (s.isValid()) {
863 segment->path = shape;
864 segment->segmentStart = s.first();
865 segment->positionOnSegment = s.nearestPoint(shape->documentToShape(point));
866 }
867 }
868
869 if (!segment->isValid()) {
870 segment.reset();
871 }
872
873 return segment.release();
874}
875
876void KoPathTool::activate(const QSet<KoShape*> &shapes)
877{
878 KoToolBase::activate(shapes);
879
880 Q_D(KoToolBase);
881
882 d->canvas->snapGuide()->reset();
883
885 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()));
886 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionContentChanged()), this, SLOT(updateActions()));
887
888 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(repaintDecorations()));
889 m_canvasConnections.addConnection(d->canvas->selectedShapesProxy(), SIGNAL(selectionContentChanged()), this, SLOT(repaintDecorations()));
891 initializeWithShapes(QList<KoShape*>(shapes.begin(), shapes.end()));
892 connect(m_actionCurvePoint, SIGNAL(triggered()), this, SLOT(pointToCurve()), Qt::UniqueConnection);
893 connect(m_actionLinePoint, SIGNAL(triggered()), this, SLOT(pointToLine()), Qt::UniqueConnection);
894 connect(m_actionLineSegment, SIGNAL(triggered()), this, SLOT(segmentToLine()), Qt::UniqueConnection);
895 connect(m_actionCurveSegment, SIGNAL(triggered()), this, SLOT(segmentToCurve()), Qt::UniqueConnection);
896 connect(m_actionAddPoint, SIGNAL(triggered()), this, SLOT(insertPoints()), Qt::UniqueConnection);
897 connect(m_actionRemovePoint, SIGNAL(triggered()), this, SLOT(removePoints()), Qt::UniqueConnection);
898 connect(m_actionBreakPoint, SIGNAL(triggered()), this, SLOT(breakAtPoint()), Qt::UniqueConnection);
899 connect(m_actionBreakSegment, SIGNAL(triggered()), this, SLOT(breakAtSegment()), Qt::UniqueConnection);
900 connect(m_actionBreakSelection, SIGNAL(triggered()), this, SLOT(breakAtSelection()), Qt::UniqueConnection);
901 connect(m_actionJoinSegment, SIGNAL(triggered()), this, SLOT(joinPoints()), Qt::UniqueConnection);
902 connect(m_actionMergePoints, SIGNAL(triggered()), this, SLOT(mergePoints()), Qt::UniqueConnection);
903 connect(m_actionConvertToPath, SIGNAL(triggered()), this, SLOT(convertToPath()), Qt::UniqueConnection);
904 connect(m_actionPathPointCorner, SIGNAL(triggered()), this, SLOT(pointTypeChangedCorner()), Qt::UniqueConnection);
905 connect(m_actionPathPointSmooth, SIGNAL(triggered()), this, SLOT(pointTypeChangedSmooth()), Qt::UniqueConnection);
906 connect(m_actionPathPointSymmetric, SIGNAL(triggered()), this, SLOT(pointTypeChangedSymmetric()), Qt::UniqueConnection);
907 connect(&m_pointSelection, SIGNAL(selectionChanged()), this, SLOT(pointSelectionChanged()), Qt::UniqueConnection);
908
909}
910
912{
913 Q_D(KoToolBase);
914 QList<KoShape*> shapes =
915 d->canvas->selectedShapesProxy()->selection()->selectedEditableShapesAndDelegates();
916
917 initializeWithShapes(shapes);
918}
919
921{
922 Q_UNUSED(shape);
923
924 // active handle and selection might have already become invalid, so just
925 // delete them without dereferencing anything...
926
927 m_activeHandle.reset();
928 m_activeSegment.reset();
929}
930
937
939{
940 QList<KoPathShape*> selectedShapes;
941 Q_FOREACH (KoShape *shape, shapes) {
942 KoPathShape *pathShape = dynamic_cast<KoPathShape*>(shape);
943
944 if (pathShape && pathShape->isShapeEditable()) {
945 selectedShapes.append(pathShape);
946 }
947 }
948
949 if (selectedShapes != m_pointSelection.selectedShapes()) {
951 m_pointSelection.setSelectedShapes(selectedShapes);
953 }
954
957}
958
960{
961 PathToolOptionWidget::Types type;
963 Q_FOREACH (KoPathShape *shape, selectedShapes) {
964 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
965 type |= parameterShape && parameterShape->isParametricShape() ?
967 }
968
969 Q_EMIT singleShapeChanged(selectedShapes.size() == 1 ? selectedShapes.first() : 0);
970 Q_EMIT typeChanged(type);
971}
972
974{
976
977 bool canBreakAtPoint = false;
978
979 bool hasNonSmoothPoints = false;
980 bool hasNonSymmetricPoints = false;
981 bool hasNonSplitPoints = false;
982
983 bool hasNonLinePoints = false;
984 bool hasNonCurvePoints = false;
985
986 bool canJoinSubpaths = false;
987
988 if (!pointData.isEmpty()) {
989 Q_FOREACH (const KoPathPointData &pd, pointData) {
990 const int subpathIndex = pd.pointIndex.first;
991 const int pointIndex = pd.pointIndex.second;
992
993 canBreakAtPoint |= pd.pathShape->isClosedSubpath(subpathIndex) ||
994 (pointIndex > 0 && pointIndex < pd.pathShape->subpathPointCount(subpathIndex) - 1);
995
997
998 hasNonSmoothPoints |= !(point->properties() & KoPathPoint::IsSmooth);
999 hasNonSymmetricPoints |= !(point->properties() & KoPathPoint::IsSymmetric);
1000 hasNonSplitPoints |=
1003
1004 hasNonLinePoints |= point->activeControlPoint1() || point->activeControlPoint2();
1005 hasNonCurvePoints |= !point->activeControlPoint1() && !point->activeControlPoint2();
1006 }
1007
1008 if (pointData.size() == 2) {
1009 const KoPathPointData & pd1 = pointData.at(0);
1010 const KoPathPointData & pd2 = pointData.at(1);
1011
1012 canJoinSubpaths = checkCanJoinToPoints(pd1, pd2);
1013 }
1014 }
1015
1016 m_actionPathPointCorner->setEnabled(hasNonSplitPoints);
1017 m_actionPathPointSmooth->setEnabled(hasNonSmoothPoints);
1018 m_actionPathPointSymmetric->setEnabled(hasNonSymmetricPoints);
1019
1020 m_actionRemovePoint->setEnabled(!pointData.isEmpty());
1021
1022 m_actionBreakPoint->setEnabled(canBreakAtPoint);
1023
1024 m_actionCurvePoint->setEnabled(hasNonCurvePoints);
1025 m_actionLinePoint->setEnabled(hasNonLinePoints);
1026
1027 m_actionJoinSegment->setEnabled(canJoinSubpaths);
1028 m_actionMergePoints->setEnabled(canJoinSubpaths);
1029
1031
1032
1033 bool canSplitAtSegment = false;
1034 bool canConvertSegmentToLine = false;
1035 bool canConvertSegmentToCurve= false;
1036
1037 if (!segments.isEmpty()) {
1038
1039 canSplitAtSegment = segments.size() == 1;
1040
1041 bool hasLines = false;
1042 bool hasCurves = false;
1043
1044 Q_FOREACH (const KoPathPointData &pd, segments) {
1046 hasLines |= segment.degree() == 1;
1047 hasCurves |= segment.degree() > 1;
1048 }
1049
1050 canConvertSegmentToLine = !segments.isEmpty() && hasCurves;
1051 canConvertSegmentToCurve= !segments.isEmpty() && hasLines;
1052 }
1053
1054 m_actionAddPoint->setEnabled(canSplitAtSegment);
1055
1056 m_actionLineSegment->setEnabled(canConvertSegmentToLine);
1057 m_actionCurveSegment->setEnabled(canConvertSegmentToCurve);
1058
1059 m_actionBreakSegment->setEnabled(canSplitAtSegment);
1060 m_actionBreakSelection->setEnabled(canSplitAtSegment | canBreakAtPoint);
1061
1063 bool haveConvertibleShapes = false;
1064 Q_FOREACH (KoShape *shape, selection->selectedEditableShapes()) {
1065 KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
1066 KoSvgTextShape *textShape = dynamic_cast<KoSvgTextShape*>(shape);
1067 if (textShape ||
1068 (parameterShape && parameterShape->isParametricShape())) {
1069
1070 haveConvertibleShapes = true;
1071 break;
1072 }
1073 }
1074 m_actionConvertToPath->setEnabled(haveConvertibleShapes);
1075}
1076
1078{
1079 Q_D(KoToolBase);
1080
1085 m_activeHandle.reset();
1086 m_activeSegment.reset();
1087 m_currentStrategy.reset();
1088 d->canvas->snapGuide()->reset();
1089
1090 disconnect(m_actionCurvePoint, 0, this, 0);
1091 disconnect(m_actionLinePoint, 0, this, 0);
1092 disconnect(m_actionLineSegment, 0, this, 0);
1093 disconnect(m_actionCurveSegment, 0, this, 0);
1094 disconnect(m_actionAddPoint, 0, this, 0);
1095 disconnect(m_actionRemovePoint, 0, this, 0);
1096 disconnect(m_actionBreakPoint, 0, this, 0);
1097 disconnect(m_actionBreakSegment, 0, this, 0);
1098 disconnect(m_actionBreakSelection, 0, this, 0);
1099 disconnect(m_actionJoinSegment, 0, this, 0);
1100 disconnect(m_actionMergePoints, 0, this, 0);
1101 disconnect(m_actionConvertToPath, 0, this, 0);
1102 disconnect(m_actionPathPointCorner, 0, this, 0);
1103 disconnect(m_actionPathPointSmooth, 0, this, 0);
1104 disconnect(m_actionPathPointSymmetric, 0, this, 0);
1105 disconnect(&m_pointSelection, 0, this, 0);
1106
1108}
1109
1110void KoPathTool::canvasResourceChanged(int key, const QVariant & /*res*/)
1111{
1114 }
1115}
1116
1118{
1119 Q_D(KoToolBase);
1120 updateActions();
1121 d->canvas->snapGuide()->setIgnoredPathPoints(QList<KoPathPoint*>(m_pointSelection.selectedPoints().begin(), m_pointSelection.selectedPoints().end()));
1123}
1124
1125namespace {
1126void addActionsGroupIfEnabled(QMenu *menu, QAction *a1, QAction *a2)
1127{
1128 if (a1->isEnabled() || a2->isEnabled()) {
1129 menu->addAction(a1);
1130 menu->addAction(a2);
1131 menu->addSeparator();
1132 }
1133}
1134
1135void addActionsGroupIfEnabled(QMenu *menu, QAction *a1, QAction *a2, QAction *a3)
1136{
1137 if (a1->isEnabled() || a2->isEnabled()) {
1138 menu->addAction(a1);
1139 menu->addAction(a2);
1140 menu->addAction(a3);
1141 menu->addSeparator();
1142 }
1143}
1144}
1145
1147{
1148 if (m_activeHandle) {
1149 m_activeHandle->trySelectHandle();
1150 }
1151
1152 if (m_activeSegment && m_activeSegment->isValid()) {
1153 KoPathShape *shape = m_activeSegment->path;
1154 KoPathSegment segment = shape->segmentByIndex(shape->pathPointIndex(m_activeSegment->segmentStart));
1155
1156 m_pointSelection.add(segment.first(), true);
1157 m_pointSelection.add(segment.second(), false);
1158 }
1159
1160 if (m_contextMenu) {
1161 m_contextMenu->clear();
1162
1163 addActionsGroupIfEnabled(m_contextMenu.data(),
1167
1168 addActionsGroupIfEnabled(m_contextMenu.data(),
1171
1172 addActionsGroupIfEnabled(m_contextMenu.data(),
1175
1176 addActionsGroupIfEnabled(m_contextMenu.data(),
1179
1180 addActionsGroupIfEnabled(m_contextMenu.data(),
1183
1184 addActionsGroupIfEnabled(m_contextMenu.data(),
1187
1189
1190 m_contextMenu->addSeparator();
1191 }
1192
1193 return m_contextMenu.data();
1194}
1195
1200
1205
1207{
1208 // noop!
1209}
1210
1215
1217{
1218 // noop!
1219}
1220
1222{
1223 canvas()->canvasController()->toolManager()->switchToolRequested("InteractionTool");
1224}
1225
1227{
1230 return true;
1231}
1232
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
KoCanvasController * canvasController() const
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
QPointer< KoToolManager > toolManager
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 the Enter key or an...
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:968
virtual KoShapeStrokeModelSP stroke() const
Definition KoShape.cpp:888
QPointF documentToShape(const QPointF &point) const
Transforms point from document coordinates to shape coordinates.
Definition KoShape.cpp:1014
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:300
KoShapeContainer * parent() const
Definition KoShape.cpp:860
static KisHandlePainterHelper createHandlePainterHelperView(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
Definition KoShape.cpp:980
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 ...
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