~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to .pc/kubuntu_01_arm_needs_qreal.diff/krita/image/brushengine/kis_paint_information.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (c) 2007,2010 Cyrille Berger <cberger@cberger.net>
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; either version 2 of the License, or
 
7
 *  (at your option) any later version.
 
8
 *
 
9
 *  This program is distributed in the hope that it will be useful,
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *  GNU General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; if not, write to the Free Software
 
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
 */
 
18
 
 
19
#include "kis_paint_information.h"
 
20
#include <QDomElement>
 
21
 
 
22
struct KisPaintInformation::Private {
 
23
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW
 
24
 
 
25
    QPointF pos;
 
26
    double pressure;
 
27
    double xTilt;
 
28
    double yTilt;
 
29
    KisVector2D movement;
 
30
    double angle;
 
31
    double rotation;
 
32
    double tangentialPressure;
 
33
    int time;
 
34
};
 
35
 
 
36
KisPaintInformation::KisPaintInformation(const QPointF & pos_, double pressure_,
 
37
        double xTilt_, double yTilt_,
 
38
        const KisVector2D& movement_,
 
39
        double rotation_,
 
40
        double tangentialPressure_,
 
41
        int time)
 
42
        : d(new Private)
 
43
{
 
44
    d->pos = pos_;
 
45
    d->pressure = pressure_;
 
46
    d->xTilt = xTilt_;
 
47
    d->yTilt = yTilt_;
 
48
    d->movement = movement_;
 
49
    d->rotation = rotation_;
 
50
    d->tangentialPressure = tangentialPressure_;
 
51
    d->angle = atan2(movement_.y(), movement_.x());
 
52
    d->time = time;
 
53
}
 
54
 
 
55
KisPaintInformation::KisPaintInformation(const KisPaintInformation& rhs) : d(new Private(*rhs.d))
 
56
{
 
57
}
 
58
 
 
59
void KisPaintInformation::operator=(const KisPaintInformation & rhs)
 
60
{
 
61
    *d = *rhs.d;
 
62
}
 
63
 
 
64
KisPaintInformation::~KisPaintInformation()
 
65
{
 
66
    delete d;
 
67
}
 
68
 
 
69
 
 
70
void KisPaintInformation::toXML(QDomDocument&, QDomElement& e) const
 
71
{
 
72
    e.setAttribute("pointX", QString::number(pos().x(), 'g', 15));
 
73
    e.setAttribute("pointY", QString::number(pos().y(), 'g', 15));
 
74
    e.setAttribute("pressure", QString::number(pressure(), 'g', 15));
 
75
    e.setAttribute("xTilt", QString::number(xTilt(), 'g', 15));
 
76
    e.setAttribute("yTilt", QString::number(yTilt(), 'g', 15));
 
77
    e.setAttribute("movementX", QString::number(movement().x(), 'g', 15));
 
78
    e.setAttribute("movementY", QString::number(movement().y(), 'g', 15));
 
79
    e.setAttribute("rotation", QString::number(rotation(), 'g', 15));
 
80
    e.setAttribute("tangentialPressure", QString::number(tangentialPressure(), 'g', 15));
 
81
    e.setAttribute("time", d->time);
 
82
}
 
83
 
 
84
KisPaintInformation KisPaintInformation::fromXML(const QDomElement& e)
 
85
{
 
86
    double pointX = e.attribute("pointX", "0.0").toDouble();
 
87
    double pointY = e.attribute("pointY", "0.0").toDouble();
 
88
    double pressure = e.attribute("pressure", "0.0").toDouble();
 
89
    double rotation = e.attribute("rotation", "0.0").toDouble();
 
90
    double tangentialPressure = e.attribute("tangentialPressure", "0.0").toDouble();
 
91
    double xTilt = e.attribute("xTilt", "0.0").toDouble();
 
92
    double yTilt = e.attribute("yTilt", "0.0").toDouble();
 
93
    double movementX = e.attribute("movementX", "0.0").toDouble();
 
94
    double movementY = e.attribute("movementY", "0.0").toDouble();
 
95
    int time = e.attribute("time", "0").toInt();
 
96
 
 
97
    return KisPaintInformation(QPointF(pointX, pointY), pressure, xTilt, yTilt, KisVector2D(movementX, movementY),
 
98
                               rotation, tangentialPressure, time);
 
99
}
 
100
 
 
101
const QPointF& KisPaintInformation::pos() const
 
102
{
 
103
    return d->pos;
 
104
}
 
105
 
 
106
void KisPaintInformation::setPos(const QPointF& p)
 
107
{
 
108
    d->pos = p;
 
109
}
 
110
 
 
111
double KisPaintInformation::pressure() const
 
112
{
 
113
    return d->pressure;
 
114
}
 
115
 
 
116
void KisPaintInformation::setPressure(double p)
 
117
{
 
118
    d->pressure = p;
 
119
}
 
120
 
 
121
double KisPaintInformation::xTilt() const
 
122
{
 
123
    return d->xTilt;
 
124
}
 
125
 
 
126
double KisPaintInformation::yTilt() const
 
127
{
 
128
    return d->yTilt;
 
129
}
 
130
 
 
131
KisVector2D KisPaintInformation::movement() const
 
132
{
 
133
    return d->movement;
 
134
}
 
135
 
 
136
double KisPaintInformation::angle() const
 
137
{
 
138
    return d->angle;
 
139
}
 
140
 
 
141
double KisPaintInformation::rotation() const
 
142
{
 
143
    return d->rotation;
 
144
}
 
145
 
 
146
double KisPaintInformation::tangentialPressure() const
 
147
{
 
148
    return d->tangentialPressure;
 
149
}
 
150
 
 
151
int KisPaintInformation::currentTime() const
 
152
{
 
153
    return d->time;
 
154
}
 
155
 
 
156
QDebug operator<<(QDebug dbg, const KisPaintInformation &info)
 
157
{
 
158
#ifdef NDEBUG
 
159
    Q_UNUSED(info);
 
160
#else
 
161
    dbg.nospace() << "Position: " << info.pos();
 
162
    dbg.nospace() << ", Pressure: " << info.pressure();
 
163
    dbg.nospace() << ", X Tilt: " << info.xTilt();
 
164
    dbg.nospace() << ", Y Tilt: " << info.yTilt();
 
165
    dbg.nospace() << ", Movement: " << toQPointF(info.movement());
 
166
    dbg.nospace() << ", Rotation: " << info.rotation();
 
167
    dbg.nospace() << ", Tangential Pressure: " << info.tangentialPressure();
 
168
    dbg.nospace() << ", Angle: " << info.angle();
 
169
    dbg.nospace() << ", Time: " << info.currentTime();
 
170
#endif
 
171
    return dbg.space();
 
172
}
 
173
 
 
174
KisPaintInformation KisPaintInformation::mix(const QPointF& p, double t, const KisPaintInformation& pi1, const KisPaintInformation& pi2, const KisVector2D& movement)
 
175
{
 
176
    double pressure = (1 - t) * pi1.pressure() + t * pi2.pressure();
 
177
    double xTilt = (1 - t) * pi1.xTilt() + t * pi2.xTilt();
 
178
    double yTilt = (1 - t) * pi1.yTilt() + t * pi2.yTilt();
 
179
    double rotation = (1 - t) * pi1.rotation() + t * pi2.rotation();
 
180
    double tangentialPressure = (1 - t) * pi1.tangentialPressure() + t * pi2.tangentialPressure();
 
181
    int time = (1 - t) * pi1.currentTime() + t * pi2.currentTime();
 
182
    return KisPaintInformation(p, pressure, xTilt, yTilt, movement, rotation, tangentialPressure, time);
 
183
}