3
$Id: DuplicateCmd.cc,v 1.14 2001/07/18 18:45:56 buis Exp $
5
This file is part of KIllustrator.
6
Copyright (C) 1998-99 Kai-Uwe Sattler (kus@iti.cs.uni-magdeburg.de)
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU Library General Public License as
11
the Free Software Foundation; either version 2 of the License, or
12
(at your option) any later version.
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
19
You should have received a copy of the GNU Library General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
#include <DuplicateCmd.h>
29
#include <GDocument.h>
32
#include <PStateManager.h>
34
bool DuplicateCmd::repeatCmd = false;
35
float DuplicateCmd::repOffX = 0.0;
36
float DuplicateCmd::repOffY = 0.0;
38
DuplicateCmd::DuplicateCmd (GDocument* doc)
39
: Command(i18n("Duplicate"))
42
for (QListIterator<GObject> it(doc->activePage()->getSelection()); it.current(); ++it)
52
DuplicateCmd::~DuplicateCmd () {
54
for (o=objects.first(); o!=0L; o=objects.next())
56
for (o=new_objects.first(); o!=0L; o=new_objects.next())
60
void DuplicateCmd::execute () {
69
xoff = PStateManager::instance ()->duplicateXOffset ();
70
yoff = PStateManager::instance ()->duplicateYOffset ();
73
m.translate (xoff, yoff);
75
document->activePage()->unselectAllObjects ();
76
for (GObject *i=objects.first(); i!=0L;
78
GObject *o = i->copy ();
80
o->transform (m, true);
81
document->activePage()->insertObject (o);
82
document->activePage()->selectObject (o);
83
new_objects.append(o);
87
void DuplicateCmd::unexecute () {
88
document->activePage()->unselectAllObjects ();
90
for (o=new_objects.first(); o!=0L; o=new_objects.next())
91
document->activePage()->deleteObject(o);
92
for (o = objects.first(); o!=0L; o=objects.next())
93
document->activePage()->selectObject(o);
96
void DuplicateCmd::resetRepetition () {
100
void DuplicateCmd::setRepetitionOffset (float dx, float dy) {
101
repOffX = dx + PStateManager::instance ()->duplicateXOffset ();
102
repOffY = dy + PStateManager::instance ()->duplicateYOffset ();