Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Krita
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tusooa Zhu
Krita
Commits
a09e5840
Commit
a09e5840
authored
Mar 25, 2007
by
Thomas Zander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New features on KoShape::setAbsolutePosition
svn path=/trunk/koffice/; revision=646474
parent
b704c19e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
15 deletions
+49
-15
libs/flake/KoShape.cpp
libs/flake/KoShape.cpp
+15
-14
libs/flake/KoShape.h
libs/flake/KoShape.h
+1
-1
libs/flake/tests/TestPosition.cpp
libs/flake/tests/TestPosition.cpp
+32
-0
libs/flake/tests/TestPosition.h
libs/flake/tests/TestPosition.h
+1
-0
No files found.
libs/flake/KoShape.cpp
View file @
a09e5840
...
...
@@ -420,23 +420,15 @@ QPointF KoShape::absolutePosition(KoFlake::Position anchor) const {
QPointF
point
;
switch
(
anchor
)
{
case
KoFlake
::
TopLeftCorner
:
break
;
case
KoFlake
::
TopRightCorner
:
point
=
QPointF
(
size
().
width
(),
0.0
);
break
;
case
KoFlake
::
BottomLeftCorner
:
point
=
QPointF
(
0.0
,
size
().
height
());
break
;
case
KoFlake
::
BottomRightCorner
:
point
=
QPointF
(
size
().
width
(),
size
().
height
());
break
;
case
KoFlake
::
CenteredPositon
:
point
=
QPointF
(
size
().
width
()
/
2.0
,
size
().
height
()
/
2.0
);
break
;
case
KoFlake
::
TopRightCorner
:
point
=
QPointF
(
size
().
width
(),
0.0
);
break
;
case
KoFlake
::
BottomLeftCorner
:
point
=
QPointF
(
0.0
,
size
().
height
());
break
;
case
KoFlake
::
BottomRightCorner
:
point
=
QPointF
(
size
().
width
(),
size
().
height
());
break
;
case
KoFlake
::
CenteredPositon
:
point
=
QPointF
(
size
().
width
()
/
2.0
,
size
().
height
()
/
2.0
);
break
;
}
return
d
->
matrix
.
map
(
point
);
}
void
KoShape
::
setAbsolutePosition
(
QPointF
newPosition
)
{
void
KoShape
::
setAbsolutePosition
(
QPointF
newPosition
,
KoFlake
::
Position
anchor
)
{
QPointF
zero
(
0
,
0
);
QMatrix
matrix
;
// apply parents matrix to inherit any transformations done there.
...
...
@@ -468,7 +460,16 @@ void KoShape::setAbsolutePosition(QPointF newPosition) {
matrix
.
shear
(
d
->
shearX
,
d
->
shearY
);
matrix
.
scale
(
d
->
scaleX
,
d
->
scaleY
);
QPointF
vector2
=
matrix
.
map
(
QPointF
(
size
().
width
()
/
2.0
,
size
().
height
()
/
2.0
)
);
QPointF
point
;
switch
(
anchor
)
{
case
KoFlake
::
TopLeftCorner
:
break
;
case
KoFlake
::
TopRightCorner
:
point
=
QPointF
(
size
().
width
(),
0.0
);
break
;
case
KoFlake
::
BottomLeftCorner
:
point
=
QPointF
(
0.0
,
size
().
height
());
break
;
case
KoFlake
::
BottomRightCorner
:
point
=
QPointF
(
size
().
width
(),
size
().
height
());
break
;
case
KoFlake
::
CenteredPositon
:
point
=
QPointF
(
size
().
width
()
/
2.0
,
size
().
height
()
/
2.0
);
break
;
}
QPointF
vector2
=
matrix
.
map
(
point
);
// QPointF(size().width() / 2.0, size().height() / 2.0) );
//kDebug(30006) << "vector1: " << vector1 << ", vector2: " << vector2 << endl;
setPosition
(
newPosition
+
vector1
-
vector2
);
...
...
libs/flake/KoShape.h
View file @
a09e5840
...
...
@@ -467,7 +467,7 @@ public:
shape->setAbsolutePosition(QPointF(0,0));</pre>
* @param newPosition the new absolute center of the shape.
*/
void
setAbsolutePosition
(
QPointF
newPosition
);
void
setAbsolutePosition
(
QPointF
newPosition
,
KoFlake
::
Position
anchor
=
KoFlake
::
CenteredPositon
);
/**
* Move this shape from its current (absolute) position over a specified distance.
...
...
libs/flake/tests/TestPosition.cpp
View file @
a09e5840
...
...
@@ -60,6 +60,16 @@ void TestPosition::testAbsolutePosition() {
QCOMPARE
(
childShape2
->
absolutePosition
(),
QPointF
(
130
,
232.5
)
);
container2
->
setClipping
(
childShape2
,
true
);
QCOMPARE
(
childShape2
->
absolutePosition
(),
QPointF
(
167.5
,
230
)
);
shape1
->
rotate
(
90
);
shape1
->
setPosition
(
QPointF
(
10
,
10
));
QCOMPARE
(
shape1
->
absolutePosition
(),
QPointF
(
10
+
25
,
10
+
25
)
);
QCOMPARE
(
shape1
->
absolutePosition
(
KoFlake
::
CenteredPositon
),
QPointF
(
10
+
25
,
10
+
25
)
);
QCOMPARE
(
shape1
->
absolutePosition
(
KoFlake
::
TopLeftCorner
),
QPointF
(
10
+
50
,
10
)
);
QCOMPARE
(
shape1
->
absolutePosition
(
KoFlake
::
BottomRightCorner
),
QPointF
(
10
,
10
+
50
)
);
QCOMPARE
(
container2
->
absolutePosition
(
KoFlake
::
TopLeftCorner
),
QPointF
(
200
,
200
));
}
void
TestPosition
::
testSetAbsolutePosition
()
{
...
...
@@ -87,5 +97,27 @@ void TestPosition::testSetAbsolutePosition() {
QCOMPARE
(
childShape2
->
position
(),
QPointF
(
-
200
-
5
,
200
-
7.5
)
);
}
void
TestPosition
::
testSetAbsolutePosition2
()
{
shape1
->
rotate
(
90
);
shape1
->
setAbsolutePosition
(
QPointF
(
100
,
100
));
QCOMPARE
(
shape1
->
absolutePosition
(),
QPointF
(
100
,
100
));
shape1
->
setAbsolutePosition
(
QPointF
(
100
,
100
),
KoFlake
::
TopLeftCorner
);
QCOMPARE
(
shape1
->
absolutePosition
(
KoFlake
::
TopLeftCorner
),
QPointF
(
100
,
100
));
childShape1
->
setAbsolutePosition
(
QPointF
(
0
,
0
),
KoFlake
::
BottomRightCorner
);
QCOMPARE
(
childShape1
->
position
(),
QPointF
(
-
150
,
-
150
)
);
childShape1
->
setAbsolutePosition
(
QPointF
(
0
,
0
),
KoFlake
::
BottomLeftCorner
);
QCOMPARE
(
childShape1
->
position
(),
QPointF
(
-
100
,
-
150
)
);
childShape1
->
setAbsolutePosition
(
QPointF
(
0
,
0
),
KoFlake
::
TopRightCorner
);
QCOMPARE
(
childShape1
->
position
(),
QPointF
(
-
150
,
-
100
)
);
container2
->
setClipping
(
childShape2
,
true
);
childShape2
->
setAbsolutePosition
(
QPointF
(
0
,
0
),
KoFlake
::
TopLeftCorner
);
QCOMPARE
(
childShape2
->
position
(),
QPointF
(
-
200
,
200
)
);
}
QTEST_MAIN
(
TestPosition
)
#include "TestPosition.moc"
libs/flake/tests/TestPosition.h
View file @
a09e5840
...
...
@@ -19,6 +19,7 @@ private slots:
void
testBasePosition
();
void
testAbsolutePosition
();
void
testSetAbsolutePosition
();
void
testSetAbsolutePosition2
();
private:
void
resetValues
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment