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>
12
13#include "kis_command_ids.h"
14
15#include <klocalizedstring.h>
16
25
27 : KUndo2Command(kundo2_i18n("Set marker"), parent),
28 m_d(new Private)
29{
30 m_d->shapes = shapes;
31 m_d->marker = marker;
32 m_d->position = position;
33
34 // save old markers
35 Q_FOREACH (KoPathShape *shape, m_d->shapes) {
36 m_d->oldMarkers.append(QExplicitlySharedDataPointer<KoMarker>(shape->marker(position)));
37 m_d->oldAutoFillMarkers.append(shape->autoFillMarkers());
38 }
39}
40
44
46{
48 Q_FOREACH (KoPathShape *shape, m_d->shapes) {
49 const QRectF oldDirtyRect = shape->boundingRect();
50 shape->setMarker(m_d->marker.data(), m_d->position);
51
52 // we have no GUI for selection auto-filling yet! So just enable it!
53 shape->setAutoFillMarkers(true);
54
55 shape->updateAbsolute(oldDirtyRect | shape->boundingRect());
56 }
57}
58
60{
62 auto markerIt = m_d->oldMarkers.begin();
63 auto autoFillIt = m_d->oldAutoFillMarkers.begin();
64 Q_FOREACH (KoPathShape *shape, m_d->shapes) {
65 const QRectF oldDirtyRect = shape->boundingRect();
66 shape->setMarker((*markerIt).data(), m_d->position);
67 shape->setAutoFillMarkers(*autoFillIt);
68 shape->updateAbsolute(oldDirtyRect | shape->boundingRect());
69 ++markerIt;
70 ++autoFillIt;
71 }
72}
73
78
80{
81 const KoPathShapeMarkerCommand *other = dynamic_cast<const KoPathShapeMarkerCommand*>(command);
82
83 if (!other ||
84 other->m_d->shapes != m_d->shapes ||
85 other->m_d->position != m_d->position) {
86
87 return false;
88 }
89
90 m_d->marker = other->m_d->marker;
91 return true;
92}
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)
QRectF boundingRect() const override
reimplemented
QList< KoShape * > shapes() const
virtual void updateAbsolute(const QRectF &rect) const
Definition KoShape.cpp:616
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