Krita Source Code Documentation
Loading...
Searching...
No Matches
KoPathShapeMarkerCommand.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2010 Jeremy Lugagne <lugagne.jeremy@gmail.com>
3 * SPDX-FileCopyrightText: 2011 Jean-Nicolas Artaud <jeannicolasartaud@gmail.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
9#include "KoMarker.h"
10#include "KoPathShape.h"
11#include <QExplicitlySharedDataPointer>
13#include <kis_pointer_utils.h>
14
15#include "kis_command_ids.h"
16
17#include <klocalizedstring.h>
18
27
29 : KUndo2Command(kundo2_i18n("Set marker"), parent),
30 m_d(new Private)
31{
32 m_d->shapes = shapes;
33 m_d->marker = marker;
34 m_d->position = position;
35
36 // save old markers
37 Q_FOREACH (KoPathShape *shape, m_d->shapes) {
38 m_d->oldMarkers.append(QExplicitlySharedDataPointer<KoMarker>(shape->marker(position)));
39 m_d->oldAutoFillMarkers.append(shape->autoFillMarkers());
40 }
41}
42
46
48{
50
51 KoShapeBulkActionLock lock(implicitCastList<KoShape*>(m_d->shapes));
52
53 Q_FOREACH (KoPathShape *shape, m_d->shapes) {
54 shape->setMarker(m_d->marker.data(), m_d->position);
55
56 // we have no GUI for selection auto-filling yet! So just enable it!
57 shape->setAutoFillMarkers(true);
58 }
59
61}
62
64{
66
67 KoShapeBulkActionLock lock(implicitCastList<KoShape*>(m_d->shapes));
68
69 auto markerIt = m_d->oldMarkers.begin();
70 auto autoFillIt = m_d->oldAutoFillMarkers.begin();
71 Q_FOREACH (KoPathShape *shape, m_d->shapes) {
72 shape->setMarker((*markerIt).data(), m_d->position);
73 shape->setAutoFillMarkers(*autoFillIt);
74 ++markerIt;
75 ++autoFillIt;
76 }
77
79}
80
85
87{
88 const KoPathShapeMarkerCommand *other = dynamic_cast<const KoPathShapeMarkerCommand*>(command);
89
90 if (!other ||
91 other->m_d->shapes != m_d->shapes ||
92 other->m_d->position != m_d->position) {
93
94 return false;
95 }
96
97 m_d->marker = other->m_d->marker;
98 return true;
99}
virtual void undo()
virtual void redo()
The position of a path point within a path shape.
Definition KoPathShape.h:63
bool autoFillMarkers() const
KoMarker * marker(KoFlake::MarkerPosition pos) const
void setAutoFillMarkers(bool value)
void setMarker(KoMarker *marker, KoFlake::MarkerPosition pos)
static void bulkShapesUpdate(const UpdatesList &updates)
KUndo2MagicString kundo2_i18n(const char *text)
MarkerPosition
Definition KoFlake.h:41
The undo / redo command for setting the shape marker.
KoPathShapeMarkerCommand(const QList< KoPathShape * > &shapes, KoMarker *marker, KoFlake::MarkerPosition position, KUndo2Command *parent=0)
QExplicitlySharedDataPointer< KoMarker > marker
the new marker to set
const QScopedPointer< Private > m_d
bool mergeWith(const KUndo2Command *command) override
QList< QExplicitlySharedDataPointer< KoMarker > > oldMarkers
the old markers, one for each shape
QList< KoPathShape * > shapes
the shapes to set marker for