1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/*
* kis_tool_transform.h - part of Chalk
*
* Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_TOOL_TRANSFORM_H_
#define KIS_TOOL_TRANSFORM_H_
#include <tqpoint.h>
#include <kis_tool_non_paint.h>
#include <kis_tool_factory.h>
#include <kis_undo_adapter.h>
#include <kis_layer.h>
class KisTransaction;
class WdgToolTransform;
class KisID;
class KisFilterStrategy;
/**
* Transform tool
*
*/
class KisToolTransform : public KisToolNonPaint, KisCommandHistoryListener {
typedef KisToolNonPaint super;
TQ_OBJECT
public:
KisToolTransform();
virtual ~KisToolTransform();
virtual TQWidget* createOptionWidget(TQWidget* parent);
virtual TQWidget* optionWidget();
virtual void setup(TDEActionCollection *collection);
virtual enumToolType toolType() { return TOOL_TRANSFORM; }
virtual TQ_UINT32 priority() { return 3; }
virtual void paint(KisCanvasPainter& gc);
virtual void paint(KisCanvasPainter& gc, const TQRect& rc);
virtual void buttonPress(KisButtonPressEvent *e);
virtual void move(KisMoveEvent *e);
virtual void buttonRelease(KisButtonReleaseEvent *e);
void setScaleX(double sx) { m_scaleX = sx; }
void setScaleY(double sy) { m_scaleY = sy; }
void setTranslateX(double tx) { m_translateX = tx; }
void setTranslateY(double ty) { m_translateY = ty; }
void setAngle(double a) { m_a = a; }
void paintOutline();
public:
void notifyCommandAdded(KCommand *);
void notifyCommandExecuted(KCommand *);
public:
virtual void deactivate();
private:
void paintOutline(KisCanvasPainter& gc, const TQRect& rc);
void transform();
void recalcOutline();
double rotX(double x, double y) { return m_cosa*x - m_sina*y;};
double rotY(double x, double y) { return m_sina*x + m_cosa*y;};
double invrotX(double x, double y) { return m_cosa*x + m_sina*y;};
double invrotY(double x, double y) { return -m_sina*x + m_cosa*y;};
int det(TQPoint v,TQPoint w);
int distsq(TQPoint v,TQPoint w);
void setFunctionalCursor();
void initHandles();
private slots:
void slotLayerActivated(KisLayerSP);
void slotSetFilter(const KisID &);
void setStartX(int x) { m_startPos.setX(x); }
void setStartY(int y) { m_startPos.setY(y); }
void setEndX(int x) { m_endPos.setX(x); }
void setEndY(int y) { m_endPos.setY(y); }
protected slots:
virtual void activate();
private:
enum function {ROTATE,MOVE,TOPLEFTSCALE,TOPSCALE,TOPRIGHTSCALE,RIGHTSCALE,
BOTTOMRIGHTSCALE, BOTTOMSCALE,BOTTOMLEFTSCALE, LEFTSCALE};
TQCursor m_sizeCursors[8];
function m_function;
TQPoint m_startPos;
TQPoint m_endPos;
bool m_selecting;
bool m_actualyMoveWhileSelected;
TQPoint m_topleft;
TQPoint m_topright;
TQPoint m_bottomleft;
TQPoint m_bottomright;
double m_scaleX;
double m_scaleY;
double m_translateX;
double m_translateY;
TQPoint m_clickoffset;
double m_org_cenX;
double m_org_cenY;
double m_cosa;
double m_sina;
double m_a;
double m_clickangle;
KisFilterStrategy *m_filter;
WdgToolTransform *m_optWidget;
KisPaintDeviceSP m_origDevice;
KisSelectionSP m_origSelection;
bool m_wasPressed;
};
class KisToolTransformFactory : public KisToolFactory {
typedef KisToolFactory super;
public:
KisToolTransformFactory() : super() {};
virtual ~KisToolTransformFactory(){};
virtual KisTool * createTool(TDEActionCollection * ac) {
KisTool * t = new KisToolTransform();
TQ_CHECK_PTR(t);
t->setup(ac); return t;
}
virtual KisID id() { return KisID("transform", i18n("Transform Tool")); }
};
#endif // KIS_TOOL_TRANSFORM_H_
|