29#include <klocalizedstring.h>
35const qreal
M_PI = 3.1415927;
60 painter.setRenderHints(QPainter::Antialiasing,
false);
61 painter.setPen(Qt::red);
65 painter.drawRect(QRectF(
p1,
p2));
120 if (selectedShape != 0) {
198 if (event->
xTilt() != 0 ||
event->yTilt() != 0) {
203 if (event->
xTilt() == 0 &&
event->yTilt() == 0) {
206 if (event->
x() == 0) {
212 m_angle = std::atan(
static_cast<double>(-event->
yTilt()) /
static_cast<double>(event->
xTilt())) +
M_PI / 2.0;
222 QPointF dSpeed = force /
m_mass;
231 qreal step = QLineF(QPointF(0, 0), sp).length();
250 qreal speed = std::sqrt(pow(
m_speed.x(), 2) + pow(
m_speed.y(), 2));
251 qreal thinning =
m_thinning * (speed + 1) / 10.0;
261 qreal strokeWidth =
m_strokeWidth * pressure * (1 - thinning);
263 const qreal MINIMUM_STROKE_WIDTH = 1.0;
264 if (strokeWidth < MINIMUM_STROKE_WIDTH) {
265 strokeWidth = MINIMUM_STROKE_WIDTH;
274 qreal oldLength = QLineF(QPointF(0, 0), oldSpeed).length();
275 qreal newLength = QLineF(QPointF(0, 0), newSpeed).length();
277 oldSpeed / oldLength : QPointF(0, 0);
279 newSpeed / newLength : QPointF(0, 0);
280 QPointF speed = oldSpeedNorm + newSpeedNorm;
283 qreal speedAngle = 0;
284 if (speed.x() != 0) {
285 speedAngle = std::atan(speed.y() / speed.x());
286 }
else if (speed.y() > 0) {
288 speedAngle =
M_PI / 2;
289 }
else if (speed.y() < 0) {
291 speedAngle = -
M_PI / 2;
298 speedAngle +=
M_PI / 2;
302 qreal diff = fixedAngle - speedAngle;
303 while (diff >=
M_PI) {
306 while (diff < -
M_PI) {
310 if (std::abs(diff) >
M_PI / 2) {
314 qreal dAngle = speedAngle - fixedAngle;
317 while (dAngle >=
M_PI / 2) {
320 while (dAngle < -
M_PI / 2) {
324 qreal angle = fixedAngle + dAngle * (1.0 -
m_fixation);
337 QAction *a =
action(
"calligraphy_increase_width");
338 connect(a, SIGNAL(triggered()),
m_widget, SLOT(increaseWidth()), Qt::UniqueConnection);
340 a =
action(
"calligraphy_decrease_width");
341 connect(a, SIGNAL(triggered()),
m_widget, SLOT(decreaseWidth()), Qt::UniqueConnection);
343 a =
action(
"calligraphy_increase_angle");
344 connect(a, SIGNAL(triggered()),
m_widget, SLOT(increaseAngle()), Qt::UniqueConnection);
346 a =
action(
"calligraphy_decrease_angle");
347 connect(a, SIGNAL(triggered()),
m_widget, SLOT(decreaseAngle()), Qt::UniqueConnection);
355 QAction *a =
action(
"calligraphy_increase_width");
356 disconnect(a, 0,
this, 0);
358 a =
action(
"calligraphy_decrease_width");
359 disconnect(a, 0,
this, 0);
361 a =
action(
"calligraphy_increase_angle");
362 disconnect(a, 0,
this, 0);
364 a =
action(
"calligraphy_decrease_angle");
365 disconnect(a, 0,
this, 0);
411 m_widget, SLOT(setUsePathEnabled(
bool)));
415 m_widget->setObjectName(i18nc(
"Object name of Calligraphy",
"Calligraphy"));
416 m_widget->setWindowTitle(i18nc(
"Tool Option title of Calligraphy",
"Calligraphy"));
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void appendPoint(const QPointF &p1, qreal angle, qreal width)
const QRectF lastPieceBoundingRect()
QPointer< KoShapeController > shapeController
virtual KoShapeManager * shapeManager() const =0
virtual void updateCanvas(const QRectF &rc)=0
virtual void addCommand(KUndo2Command *command)=0
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
A simple solid color shape background.
The position of a path point within a path shape.
void paint(QPainter &painter) const override
reimplemented
QPainterPath outline() const override
reimplemented
QRectF boundingRect() const override
reimplemented
int subpathCount() const
Returns the number of subpaths in the path.
QPointF point
The point in document coordinates.
void deselectAll()
clear the selections list
void select(KoShape *shape)
KoShape * shapeAt(const QPointF &position, KoFlake::ShapeSelection selection=KoFlake::ShapeOnTop, bool omitHiddenShapes=true)
QTransform absoluteTransformation() const
virtual void setBackground(QSharedPointer< KoShapeBackground > background)
virtual QPointF documentToView(const QPointF &documentPoint) const
static bool qFuzzyCompare(half p1, half p2)