Krita Source Code Documentation
Loading...
Searching...
No Matches
KoFlake Namespace Reference

Enumerations

enum  AnchorPosition {
  TopLeft , Top , TopRight , Left ,
  Center , Right , BottomLeft , Bottom ,
  BottomRight , NoAnchor , NumAnchorPositions
}
 
enum  CanvasResource { HotPosition = 1410100299 }
 
enum  CoordinateSystem { UserSpaceOnUse , ObjectBoundingBox }
 
enum  FillType {
  None , Solid , Gradient , Pattern ,
  MeshGradient
}
 
enum  FillVariant { Fill , StrokeFill }
 
enum  MarkerPosition { StartMarker , MidMarker , EndMarker }
 
enum  SelectionHandle {
  TopMiddleHandle , TopRightHandle , RightMiddleHandle , BottomRightHandle ,
  BottomMiddleHandle , BottomLeftHandle , LeftMiddleHandle , TopLeftHandle ,
  NoHandle
}
 Enum determining which handle is meant, used in KoInteractionTool. More...
 
enum  SelectionType { FullSelection , StrippedSelection , TopLevelSelection }
 the selection type for KoSelection::selectedObjects() More...
 
enum  ShapeSelection { Selected , Unselected , NextUnselected , ShapeOnTop }
 
enum  StyleType { Background , Foreground }
 

Functions

KRITAFLAKE_EXPORT QPointF anchorToPoint (AnchorPosition anchor, const QRectF rect, bool *valid=0)
 
KRITAFLAKE_EXPORT QGradient * cloneGradient (const QGradient *gradient)
 clones the given gradient
 
template<class Policy >
bool compareShapePropertiesEqual (const QList< KoShape * > shapes)
 
template<class Policy >
bool compareShapePropertiesEqual (const QList< KoShape * > shapes, const Policy &policy)
 
CoordinateSystem coordinatesFromString (const QString &value, CoordinateSystem defaultValue)
 
QString coordinateToString (CoordinateSystem value)
 
KRITAFLAKE_EXPORT QGradient * mergeGradient (const QGradient *coordsSource, const QGradient *fillSource)
 
template<typename ModifyFunction >
auto modifyShapesStrokes (QList< KoShape * > shapes, ModifyFunction modifyFunction) -> decltype(modifyFunction(KoShapeStrokeSP()),(KUndo2Command *)(0))
 
KRITAFLAKE_EXPORT void resizeShape (KoShape *shape, qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint, bool useGlobalMode)
 
KRITAFLAKE_EXPORT void resizeShapeCommon (KoShape *shape, qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint, bool useGlobalMode, bool usePostScaling, const QTransform &postScalingCoveringTransform)
 
KRITAFLAKE_EXPORT void scaleShape (KoShape *shape, qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint, const QTransform &postScalingCoveringTransform)
 
KRITAFLAKE_EXPORT void scaleShapeGlobal (KoShape *shape, qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint)
 
KRITAFLAKE_EXPORT Qt::Orientation significantScaleOrientation (qreal scaleX, qreal scaleY)
 
KRITAFLAKE_EXPORT QPointF toAbsolute (const QPointF &relative, const QSizeF &size)
 
KRITAFLAKE_EXPORT QPointF toRelative (const QPointF &absolute, const QSizeF &size)
 

Detailed Description

Flake reference

Enumeration Type Documentation

◆ AnchorPosition

Enumerator
TopLeft 
Top 
TopRight 
Left 
Center 
Right 
BottomLeft 
Bottom 
BottomRight 
NoAnchor 
NumAnchorPositions 

Definition at line 85 of file KoFlake.h.

85 {
86 TopLeft,
87 Top,
89 Left,
90 Center,
91 Right,
93 Bottom,
97 };
@ Left
Definition KoFlake.h:89
@ Right
Definition KoFlake.h:91
@ Bottom
Definition KoFlake.h:93
@ BottomRight
Definition KoFlake.h:94
@ Top
Definition KoFlake.h:87
@ TopRight
Definition KoFlake.h:88
@ NoAnchor
Definition KoFlake.h:95
@ TopLeft
Definition KoFlake.h:86
@ BottomLeft
Definition KoFlake.h:92
@ NumAnchorPositions
Definition KoFlake.h:96

◆ CanvasResource

Enumerator
HotPosition 

Definition at line 101 of file KoFlake.h.

101 {
102 HotPosition = 1410100299
103 };
@ HotPosition
Definition KoFlake.h:102

◆ CoordinateSystem

Enumerator
UserSpaceOnUse 
ObjectBoundingBox 

Definition at line 14 of file KoFlakeCoordinateSystem.h.

◆ FillType

Enumerator
None 
Solid 
Gradient 
Pattern 
MeshGradient 

Definition at line 33 of file KoFlake.h.

33 {
34 None,
35 Solid,
37 Pattern,
39 };
@ Solid
Definition KoFlake.h:35
@ MeshGradient
Definition KoFlake.h:38
@ Gradient
Definition KoFlake.h:36

◆ FillVariant

Enumerator
Fill 
StrokeFill 

Definition at line 28 of file KoFlake.h.

28 {
29 Fill,
31 };
@ StrokeFill
Definition KoFlake.h:30
@ Fill
Definition KoFlake.h:29

◆ MarkerPosition

Enumerator
StartMarker 
MidMarker 
EndMarker 

Definition at line 41 of file KoFlake.h.

41 {
45 };
@ EndMarker
Definition KoFlake.h:44
@ StartMarker
Definition KoFlake.h:42
@ MidMarker
Definition KoFlake.h:43

◆ SelectionHandle

Enum determining which handle is meant, used in KoInteractionTool.

Enumerator
TopMiddleHandle 

The handle that is at the top - center of a selection.

TopRightHandle 

The handle that is at the top - right of a selection.

RightMiddleHandle 

The handle that is at the right - center of a selection.

BottomRightHandle 

The handle that is at the bottom right of a selection.

BottomMiddleHandle 

The handle that is at the bottom center of a selection.

BottomLeftHandle 

The handle that is at the bottom left of a selection.

LeftMiddleHandle 

The handle that is at the left center of a selection.

TopLeftHandle 

The handle that is at the top left of a selection.

NoHandle 

Value to indicate no handle.

Definition at line 55 of file KoFlake.h.

55 {
65 };
@ BottomRightHandle
The handle that is at the bottom right of a selection.
Definition KoFlake.h:59
@ BottomLeftHandle
The handle that is at the bottom left of a selection.
Definition KoFlake.h:61
@ RightMiddleHandle
The handle that is at the right - center of a selection.
Definition KoFlake.h:58
@ TopRightHandle
The handle that is at the top - right of a selection.
Definition KoFlake.h:57
@ TopLeftHandle
The handle that is at the top left of a selection.
Definition KoFlake.h:63
@ LeftMiddleHandle
The handle that is at the left center of a selection.
Definition KoFlake.h:62
@ TopMiddleHandle
The handle that is at the top - center of a selection.
Definition KoFlake.h:56
@ BottomMiddleHandle
The handle that is at the bottom center of a selection.
Definition KoFlake.h:60

◆ SelectionType

the selection type for KoSelection::selectedObjects()

Enumerator
FullSelection 

Create a list of all user-shapes in the selection. This excludes KoShapeGroup grouping objects that may be selected.

StrippedSelection 

Create a stripped list, without children if the container is also in the list.

TopLevelSelection 

Create a list, much like the StrippedSelection, but have the KoShapeGroup instead of all of its children if one is selected.

Definition at line 48 of file KoFlake.h.

48 {
52 };
@ TopLevelSelection
Create a list, much like the StrippedSelection, but have the KoShapeGroup instead of all of its child...
Definition KoFlake.h:51
@ StrippedSelection
Create a stripped list, without children if the container is also in the list.
Definition KoFlake.h:50
@ FullSelection
Create a list of all user-shapes in the selection. This excludes KoShapeGroup grouping objects that m...
Definition KoFlake.h:49

◆ ShapeSelection

Used to change the behavior of KoShapeManager::shapeAt()

Enumerator
Selected 

return the first selected with the highest z-ordering (i.e. on top).

Unselected 

return the first unselected on top.

NextUnselected 

return the first unselected directly under a selected shape, or the top most one if nothing is selected.

ShapeOnTop 

return the shape highest z-ordering, regardless of selection.

Definition at line 70 of file KoFlake.h.

70 {
71 Selected,
75 };
@ Unselected
return the first unselected on top.
Definition KoFlake.h:72
@ Selected
return the first selected with the highest z-ordering (i.e. on top).
Definition KoFlake.h:71
@ ShapeOnTop
return the shape highest z-ordering, regardless of selection.
Definition KoFlake.h:74
@ NextUnselected
return the first unselected directly under a selected shape, or the top most one if nothing is select...
Definition KoFlake.h:73

◆ StyleType

Used to see which style type is active

Enumerator
Background 

the background / fill style is active

Foreground 

the foreground / stroke style is active

Definition at line 80 of file KoFlake.h.

80 {
83 };
@ Background
the background / fill style is active
Definition KoFlake.h:81
@ Foreground
the foreground / stroke style is active
Definition KoFlake.h:82

Function Documentation

◆ anchorToPoint()

QPointF KoFlake::anchorToPoint ( AnchorPosition anchor,
const QRectF rect,
bool * valid = 0 )

Definition at line 329 of file KoFlake.cpp.

330{
331 static QVector<QPointF> anchorTable;
332
333 if (anchorTable.isEmpty()) {
334 anchorTable << QPointF(0.0,0.0);
335 anchorTable << QPointF(0.5,0.0);
336 anchorTable << QPointF(1.0,0.0);
337
338 anchorTable << QPointF(0.0,0.5);
339 anchorTable << QPointF(0.5,0.5);
340 anchorTable << QPointF(1.0,0.5);
341
342 anchorTable << QPointF(0.0,1.0);
343 anchorTable << QPointF(0.5,1.0);
344 anchorTable << QPointF(1.0,1.0);
345 }
346
347 if (valid)
348 *valid = false;
349
350 switch(anchor)
351 {
352 case AnchorPosition::TopLeft:
353 case AnchorPosition::Top:
354 case AnchorPosition::TopRight:
355 case AnchorPosition::Left:
356 case AnchorPosition::Center:
357 case AnchorPosition::Right:
358 case AnchorPosition::BottomLeft:
359 case AnchorPosition::Bottom:
360 case AnchorPosition::BottomRight:
361 if (valid)
362 *valid = true;
363 return KisAlgebra2D::relativeToAbsolute(anchorTable[int(anchor)], rect);
364 default:
365 KIS_SAFE_ASSERT_RECOVER_NOOP(anchor >= AnchorPosition::TopLeft && anchor < AnchorPosition::NumAnchorPositions);
366 return rect.topLeft();
367 }
368}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
QPointF relativeToAbsolute(const QPointF &pt, const QRectF &rc)

References KIS_SAFE_ASSERT_RECOVER_NOOP, and KisAlgebra2D::relativeToAbsolute().

◆ cloneGradient()

QGradient * KoFlake::cloneGradient ( const QGradient * gradient)

clones the given gradient

Definition at line 17 of file KoFlake.cpp.

18{
19 if (! gradient)
20 return 0;
21
22 QGradient *clone = 0;
23
24 switch (gradient->type()) {
25 case QGradient::LinearGradient:
26 {
27 const QLinearGradient *lg = static_cast<const QLinearGradient*>(gradient);
28 clone = new QLinearGradient(lg->start(), lg->finalStop());
29 break;
30 }
31 case QGradient::RadialGradient:
32 {
33 const QRadialGradient *rg = static_cast<const QRadialGradient*>(gradient);
34 clone = new QRadialGradient(rg->center(), rg->radius(), rg->focalPoint());
35 break;
36 }
37 case QGradient::ConicalGradient:
38 {
39 const QConicalGradient *cg = static_cast<const QConicalGradient*>(gradient);
40 clone = new QConicalGradient(cg->center(), cg->angle());
41 break;
42 }
43 default:
44 return 0;
45 }
46
47 clone->setCoordinateMode(gradient->coordinateMode());
48 clone->setSpread(gradient->spread());
49 clone->setStops(gradient->stops());
50
51 return clone;
52}

◆ compareShapePropertiesEqual() [1/2]

template<class Policy >
bool KoFlake::compareShapePropertiesEqual ( const QList< KoShape * > shapes)

Definition at line 71 of file KoFlakeUtils.h.

72{
73 return compareShapePropertiesEqual<Policy>(shapes, Policy());
74}

◆ compareShapePropertiesEqual() [2/2]

template<class Policy >
bool KoFlake::compareShapePropertiesEqual ( const QList< KoShape * > shapes,
const Policy & policy )

Definition at line 47 of file KoFlakeUtils.h.

48{
49 if (shapes.size() == 1) return true;
50
51 typename Policy::PointerType bg =
52 policy.getProperty(shapes.first());
53
54 Q_FOREACH (KoShape *shape, shapes) {
55 typename Policy::PointerType otherBg = policy.getProperty(shape);
56
57 if (
58 !(
59 (!bg && !otherBg) ||
60 (bg && otherBg && policy.compareTo(bg, otherBg))
61 )) {
62
63 return false;
64 }
65 }
66
67 return true;
68}

◆ coordinatesFromString()

CoordinateSystem KoFlake::coordinatesFromString ( const QString & value,
CoordinateSystem defaultValue )
inline

Definition at line 19 of file KoFlakeCoordinateSystem.h.

20{
21 CoordinateSystem result = defaultValue;
22
23 if (value == "userSpaceOnUse") {
24 result = UserSpaceOnUse;
25 } else if (value == "objectBoundingBox") {
26 result = ObjectBoundingBox;
27 }
28
29 return result;
30}
float value(const T *src, size_t ch)

References ObjectBoundingBox, UserSpaceOnUse, and value().

◆ coordinateToString()

QString KoFlake::coordinateToString ( CoordinateSystem value)
inline

Definition at line 32 of file KoFlakeCoordinateSystem.h.

33{
34 return
36 "objectBoundingBox" :
37 "userSpaceOnUse";
38}

References ObjectBoundingBox, and value().

◆ mergeGradient()

QGradient * KoFlake::mergeGradient ( const QGradient * coordsSource,
const QGradient * fillSource )

Definition at line 54 of file KoFlake.cpp.

55{
56 QPointF start;
57 QPointF end;
58 QPointF focalPoint;
59
60 switch (coordsSource->type()) {
61 case QGradient::LinearGradient: {
62 const QLinearGradient *lg = static_cast<const QLinearGradient*>(coordsSource);
63 start = lg->start();
64 focalPoint = start;
65 end = lg->finalStop();
66 break;
67 }
68 case QGradient::RadialGradient: {
69 const QRadialGradient *rg = static_cast<const QRadialGradient*>(coordsSource);
70 start = rg->center();
71 end = start + QPointF(rg->radius(), 0);
72 focalPoint = rg->focalPoint();
73 break;
74 }
75 case QGradient::ConicalGradient: {
76 const QConicalGradient *cg = static_cast<const QConicalGradient*>(coordsSource);
77
78 start = cg->center();
79 focalPoint = start;
80
81 QLineF l (start, start + QPointF(1.0, 0));
82 l.setAngle(cg->angle());
83 end = l.p2();
84 break;
85 }
86 default:
87 return 0;
88 }
89
90 QGradient *clone = 0;
91
92 switch (fillSource->type()) {
93 case QGradient::LinearGradient:
94 clone = new QLinearGradient(start, end);
95 break;
96 case QGradient::RadialGradient:
97 clone = new QRadialGradient(start, kisDistance(start, end), focalPoint);
98 break;
99 case QGradient::ConicalGradient: {
100 QLineF l(start, end);
101 clone = new QConicalGradient(l.p1(), l.angle());
102 break;
103 }
104 default:
105 return 0;
106 }
107
108 clone->setCoordinateMode(fillSource->coordinateMode());
109 clone->setSpread(fillSource->spread());
110 clone->setStops(fillSource->stops());
111
112 return clone;
113}
qreal kisDistance(const QPointF &pt1, const QPointF &pt2)
Definition kis_global.h:190

References kisDistance().

◆ modifyShapesStrokes()

template<typename ModifyFunction >
auto KoFlake::modifyShapesStrokes ( QList< KoShape * > shapes,
ModifyFunction modifyFunction ) -> decltype(modifyFunction(KoShapeStrokeSP()), (KUndo2Command*)(0))

Definition at line 21 of file KoFlakeUtils.h.

23 {
24 if (shapes.isEmpty()) return 0;
25
27
28 Q_FOREACH(KoShape *shape, shapes) {
29 KoShapeStrokeSP shapeStroke = shape->stroke() ?
30 qSharedPointerDynamicCast<KoShapeStroke>(shape->stroke()) :
32
33 KoShapeStrokeSP newStroke =
34 toQShared(shapeStroke ?
35 new KoShapeStroke(*shapeStroke) :
36 new KoShapeStroke());
37
38 modifyFunction(newStroke);
39
40 newStrokes << newStroke;
41 }
42
43 return new KoShapeStrokeCommand(shapes, newStrokes);
44}
The undo / redo command for setting the shape stroke.
virtual KoShapeStrokeModelSP stroke() const
Definition KoShape.cpp:1067
QSharedPointer< T > toQShared(T *ptr)

References KoShape::stroke(), and toQShared().

◆ resizeShape()

void KoFlake::resizeShape ( KoShape * shape,
qreal scaleX,
qreal scaleY,
const QPointF & absoluteStillPoint,
bool useGlobalMode )

The basic idea of such global scaling:

1) We choose two the most distant points of the original outline rect 2) Calculate their expected position if transformed using uniformGlobalTransform 3) NOTE1: we do not transform the entire shape using uniformGlobalTransform, because it will cause massive shearing. We transform only two points and adjust other points using dumb scaling. 4) NOTE2: given that scale transform is much more simpler than uniformGlobalTransform, we cannot guarantee equivalent changes on both globalScaleX and globalScaleY at the same time. We can guarantee only one of them. Therefore we select the most "important" axis and guarantee scale along it. The scale along the other direction is not controlled. 5) After we have the two most distant points, we can just calculate the scale by dividing difference between their expected and original positions. This formula can be derived from equation:

localPoint_i * ScaleMatrix = localPoint_i * UniformGlobalTransform = expectedPoint_i

NOTE: when resizing a shape we expect top-left corner in parent's coordinates to keep it's position.

Definition at line 209 of file KoFlake.cpp.

212{
213 using namespace KisAlgebra2D;
214
215 if (useGlobalMode) {
216 const QTransform scale = QTransform::fromScale(scaleX, scaleY);
217 const QTransform uniformGlobalTransform =
218 shape->absoluteTransformation() *
219 scale *
220 shape->absoluteTransformation().inverted();
221
222 const QRectF rect = shape->outlineRect();
223
245 // choose the most significant scale direction
246 Qt::Orientation significantOrientation = significantScaleOrientation(scaleX, scaleY);
247
248 std::function<qreal(const QPointF&)> dimension;
249
250 if (significantOrientation == Qt::Horizontal) {
251 dimension = [] (const QPointF &pt) {
252 return pt.x();
253 };
254
255 } else {
256 dimension = [] (const QPointF &pt) {
257 return pt.y();
258 };
259 }
260
261 // find min and max points (in absolute coordinates),
262 // by default use top-left and bottom-right
263 QPolygonF localPoints(rect);
264 QPolygonF globalPoints = shape->absoluteTransformation().map(localPoints);
265
266 int minPointIndex = 0;
267 int maxPointIndex = 2;
268
269 findMinMaxPoints(globalPoints, &minPointIndex, &maxPointIndex, dimension);
270
271 // calculate the scale using the extremum points
272 const QPointF minPoint = localPoints[minPointIndex];
273 const QPointF maxPoint = localPoints[maxPointIndex];
274
275 const QPointF minPointExpected = uniformGlobalTransform.map(minPoint);
276 const QPointF maxPointExpected = uniformGlobalTransform.map(maxPoint);
277
278 scaleX = getScaleByPointsPair(minPoint.x(), maxPoint.x(),
279 minPointExpected.x(), maxPointExpected.x());
280 scaleY = getScaleByPointsPair(minPoint.y(), maxPoint.y(),
281 minPointExpected.y(), maxPointExpected.y());
282 }
283
284 const QSizeF oldSize(shape->size());
285 const QSizeF newSize(oldSize.width() * qAbs(scaleX), oldSize.height() * qAbs(scaleY));
286
287 const QTransform mirrorTransform = QTransform::fromScale(signPZ(scaleX), signPZ(scaleY));
288
294 shape->setSize(newSize);
295
296 QPointF localStillPoint = shape->absoluteTransformation().inverted().map(absoluteStillPoint);
297 const QTransform localStillPointOffset = QTransform::fromTranslate(-localStillPoint.x(), -localStillPoint.y());
298 const QSizeF realNewSize = shape->size();
299
300 const QTransform realResizeTransform =
301 QTransform::fromScale(oldSize.width() > 0 ? realNewSize.width() / oldSize.width() : 1.0,
302 oldSize.height() > 0 ? realNewSize.height() / oldSize.height() : 1.0);
303
304 shape->setTransformation(realResizeTransform.inverted() *
305 localStillPointOffset *
306 realResizeTransform *
307 mirrorTransform *
308 localStillPointOffset.inverted() *
309 shape->transformation()
310 );
311}
virtual QSizeF size() const
Get the size of the shape in pt.
Definition KoShape.cpp:820
virtual QRectF outlineRect() const
Definition KoShape.cpp:637
QTransform absoluteTransformation() const
Definition KoShape.cpp:382
void setTransformation(const QTransform &matrix)
Definition KoShape.cpp:417
QTransform transformation() const
Returns the shapes local transformation matrix.
Definition KoShape.cpp:424
virtual void setSize(const QSizeF &size)
Resize the shape.
Definition KoShape.cpp:276
KRITAFLAKE_EXPORT Qt::Orientation significantScaleOrientation(qreal scaleX, qreal scaleY)
Definition KoFlake.cpp:168

References KoShape::absoluteTransformation(), KoShape::outlineRect(), KoShape::setSize(), KoShape::setTransformation(), significantScaleOrientation(), KoShape::size(), and KoShape::transformation().

◆ resizeShapeCommon()

void KoFlake::resizeShapeCommon ( KoShape * shape,
qreal scaleX,
qreal scaleY,
const QPointF & absoluteStillPoint,
bool useGlobalMode,
bool usePostScaling,
const QTransform & postScalingCoveringTransform )

Definition at line 313 of file KoFlake.cpp.

317{
318 if (usePostScaling) {
319 if (!useGlobalMode) {
320 scaleShape(shape, scaleX, scaleY, absoluteStillPoint, postScalingCoveringTransform);
321 } else {
322 scaleShapeGlobal(shape, scaleX, scaleY, absoluteStillPoint);
323 }
324 } else {
325 resizeShape(shape, scaleX, scaleY, absoluteStillPoint, useGlobalMode);
326 }
327}
KRITAFLAKE_EXPORT void resizeShape(KoShape *shape, qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint, bool useGlobalMode)
Definition KoFlake.cpp:209
KRITAFLAKE_EXPORT void scaleShape(KoShape *shape, qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint, const QTransform &postScalingCoveringTransform)
Definition KoFlake.cpp:176

References resizeShape(), scaleShape(), and scaleShapeGlobal().

◆ scaleShape()

void KoFlake::scaleShape ( KoShape * shape,
qreal scaleX,
qreal scaleY,
const QPointF & absoluteStillPoint,
const QTransform & postScalingCoveringTransform )

Definition at line 176 of file KoFlake.cpp.

179{
180 const QTransform scale = QTransform::fromScale(scaleX, scaleY);
181 QPointF localStillPoint = postScalingCoveringTransform.inverted().map(absoluteStillPoint);
182 const QTransform localStillPointOffset = QTransform::fromTranslate(-localStillPoint.x(), -localStillPoint.y());
183
184 shape->setTransformation( shape->transformation() *
185 postScalingCoveringTransform.inverted() *
186 localStillPointOffset *
187 scale *
188 localStillPointOffset.inverted() *
189 postScalingCoveringTransform);
190}

References KoShape::setTransformation(), and KoShape::transformation().

◆ scaleShapeGlobal()

void KoFlake::scaleShapeGlobal ( KoShape * shape,
qreal scaleX,
qreal scaleY,
const QPointF & absoluteStillPoint )

Definition at line 192 of file KoFlake.cpp.

194{
195 const QTransform scale = QTransform::fromScale(scaleX, scaleY);
196 const QTransform absoluteStillPointOffset = QTransform::fromTranslate(-absoluteStillPoint.x(), -absoluteStillPoint.y());
197
198 const QTransform uniformGlobalTransform =
199 shape->absoluteTransformation() *
200 absoluteStillPointOffset *
201 scale *
202 absoluteStillPointOffset.inverted() *
203 shape->absoluteTransformation().inverted() *
204 shape->transformation();
205
206 shape->setTransformation(uniformGlobalTransform);
207}

References KoShape::absoluteTransformation(), KoShape::setTransformation(), and KoShape::transformation().

◆ significantScaleOrientation()

Qt::Orientation KoFlake::significantScaleOrientation ( qreal scaleX,
qreal scaleY )

Definition at line 168 of file KoFlake.cpp.

169{
170 const qreal scaleXDeviation = qAbs(1.0 - scaleX);
171 const qreal scaleYDeviation = qAbs(1.0 - scaleY);
172
173 return scaleXDeviation > scaleYDeviation ? Qt::Horizontal : Qt::Vertical;
174}

◆ toAbsolute()

QPointF KoFlake::toAbsolute ( const QPointF & relative,
const QSizeF & size )

Convert relative size to absolute size

Parameters
relativerelative position
sizefor which the absolute position needs to be calculated
Returns
absolute position

Definition at line 121 of file KoFlake.cpp.

122{
123 return QPointF(relative.x() * size.width(), relative.y() * size.height());
124}

◆ toRelative()

QPointF KoFlake::toRelative ( const QPointF & absolute,
const QSizeF & size )

Convert absolute to relative position

Parameters
absoluteabsolute position
sizefor which the relative position needs to be calculated
Returns
relative position

Definition at line 115 of file KoFlake.cpp.

116{
117 return QPointF(size.width() == 0 ? 0: absolute.x() / size.width(),
118 size.height() == 0 ? 0: absolute.y() / size.height());
119}