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
7bb73199
Commit
7bb73199
authored
Feb 28, 2007
by
Thomas Zander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add zIndex to connection and paint it in the proper z-order
svn path=/trunk/koffice/; revision=638051
parent
8c544f49
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
19 deletions
+82
-19
libs/flake/KoShape.cpp
libs/flake/KoShape.cpp
+2
-2
libs/flake/KoShape.h
libs/flake/KoShape.h
+3
-3
libs/flake/KoShapeConnection.cpp
libs/flake/KoShapeConnection.cpp
+35
-7
libs/flake/KoShapeConnection.h
libs/flake/KoShapeConnection.h
+19
-1
libs/flake/KoShapeManager.cpp
libs/flake/KoShapeManager.cpp
+23
-6
No files found.
libs/flake/KoShape.cpp
View file @
7bb73199
...
...
@@ -345,8 +345,8 @@ QMatrix KoShape::transformationMatrix(const KoViewConverter *converter) const {
}
bool
KoShape
::
compareShapeZIndex
(
KoShape
*
g1
,
KoShape
*
g
2
)
{
return
g1
->
zIndex
()
<
g
2
->
zIndex
();
bool
KoShape
::
compareShapeZIndex
(
KoShape
*
s1
,
KoShape
*
s
2
)
{
return
s1
->
zIndex
()
<
s
2
->
zIndex
();
}
void
KoShape
::
setParent
(
KoShapeContainer
*
parent
)
{
...
...
libs/flake/KoShape.h
View file @
7bb73199
...
...
@@ -405,10 +405,10 @@ public:
/**
* This is a method used to sort a list using the STL sorting methods.
* @param
g
1 the first shape
* @param
g
2 the second shape
* @param
s
1 the first shape
* @param
s
2 the second shape
*/
static
bool
compareShapeZIndex
(
KoShape
*
g1
,
KoShape
*
g
2
);
static
bool
compareShapeZIndex
(
KoShape
*
s1
,
KoShape
*
s
2
);
/**
* Called internally whenever a property is changed that requires the matrix to be recalculated.
...
...
libs/flake/KoShapeConnection.cpp
View file @
7bb73199
...
...
@@ -33,11 +33,14 @@ public:
gluePointIndex2
(
gp2
)
{
Q_ASSERT
(
shape1
->
connectors
().
count
()
>
gp1
);
Q_ASSERT
(
shape2
&&
shape2
->
connectors
().
count
()
>
gp2
);
Q_ASSERT
(
shape2
==
0
||
shape2
->
connectors
().
count
()
>
gp2
);
point1
=
shape1
->
connectors
()[
gp1
];
if
(
shape2
)
point2
=
shape1
->
connectors
()[
gp2
];
zIndex
=
shape1
->
zIndex
()
+
1
;
if
(
shape2
)
{
point2
=
shape2
->
connectors
()[
gp2
];
zIndex
=
qMax
(
zIndex
,
shape2
->
zIndex
()
+
1
);
}
}
KoShape
*
const
shape1
;
...
...
@@ -45,10 +48,7 @@ public:
QPointF
point1
,
point2
;
int
gluePointIndex1
;
int
gluePointIndex2
;
/*
Properties like ConnectionType
*/
int
zIndex
;
};
KoShapeConnection
::
KoShapeConnection
(
KoShape
*
from
,
int
gp1
,
KoShape
*
to
,
int
gp2
)
...
...
@@ -92,3 +92,31 @@ KoShape *KoShapeConnection::shape2() const {
return
d
->
shape2
;
}
int
KoShapeConnection
::
zIndex
()
const
{
return
d
->
zIndex
;
}
void
KoShapeConnection
::
setZIndex
(
int
index
)
{
d
->
zIndex
=
index
;
}
int
KoShapeConnection
::
gluePointIndex1
()
const
{
return
d
->
gluePointIndex1
;
}
int
KoShapeConnection
::
gluePointIndex2
()
const
{
return
d
->
gluePointIndex2
;
}
QPointF
KoShapeConnection
::
gluePoint1
()
const
{
return
d
->
point1
;
}
QPointF
KoShapeConnection
::
gluePoint2
()
const
{
return
d
->
point2
;
}
bool
KoShapeConnection
::
compareConnectionZIndex
(
KoShapeConnection
*
c1
,
KoShapeConnection
*
c2
)
{
return
c1
->
zIndex
()
<
c2
->
zIndex
();
}
libs/flake/KoShapeConnection.h
View file @
7bb73199
...
...
@@ -19,7 +19,9 @@
#ifndef KOSHAPECONNECTION_H
#define KOSHAPECONNECTION_H
#include <flake_export.h>
#include "flake_export.h"
#include <QPointF>
class
KoShape
;
class
QPainter
;
...
...
@@ -42,6 +44,22 @@ public:
KoShape
*
shape1
()
const
;
KoShape
*
shape2
()
const
;
int
zIndex
()
const
;
void
setZIndex
(
int
index
);
int
gluePointIndex1
()
const
;
int
gluePointIndex2
()
const
;
QPointF
gluePoint1
()
const
;
QPointF
gluePoint2
()
const
;
/**
* This is a method used to sort a list using the STL sorting methods.
* @param c1 the first connection
* @param c2 the second connection
*/
static
bool
compareConnectionZIndex
(
KoShapeConnection
*
c1
,
KoShapeConnection
*
c2
);
private:
class
Private
;
Private
*
const
d
;
...
...
libs/flake/KoShapeManager.cpp
View file @
7bb73199
...
...
@@ -137,14 +137,23 @@ void KoShapeManager::paint( QPainter &painter, const KoViewConverter &converter,
updateTree
();
painter
.
setPen
(
Qt
::
NoPen
);
// painters by default have a black stroke, lets turn that off.
painter
.
setBrush
(
Qt
::
NoBrush
);
QList
<
KoShapeConnection
*>
sortedConnections
;
QList
<
KoShape
*>
sortedShapes
;
if
(
painter
.
hasClipping
())
sortedShapes
=
d
->
tree
.
intersects
(
converter
.
viewToDocument
(
painter
.
clipRegion
().
boundingRect
()
)
);
else
if
(
painter
.
hasClipping
())
{
QRectF
rect
=
converter
.
viewToDocument
(
painter
.
clipRegion
().
boundingRect
()
);
sortedShapes
=
d
->
tree
.
intersects
(
rect
);
sortedConnections
=
d
->
connectionTree
.
intersects
(
rect
);
}
else
{
sortedShapes
=
shapes
();
kWarning
()
<<
"KoShapeManager::paint Painting with a painter that has no clipping will lead to too much being painted and no connections being painted!
\n
"
;
}
qSort
(
sortedShapes
.
begin
(),
sortedShapes
.
end
(),
KoShape
::
compareShapeZIndex
);
const
QRegion
clipRegion
=
painter
.
clipRegion
();
qSort
(
sortedConnections
.
begin
(),
sortedConnections
.
end
(),
KoShapeConnection
::
compareConnectionZIndex
);
QList
<
KoShapeConnection
*>::
iterator
connectionIterator
=
sortedConnections
.
begin
();
const
QRegion
clipRegion
=
painter
.
clipRegion
();
foreach
(
KoShape
*
shape
,
sortedShapes
)
{
if
(
!
shape
->
isVisible
()
||
(
shape
->
parent
()
&&
!
shape
->
parent
()
->
isVisible
()
)
)
continue
;
...
...
@@ -158,6 +167,13 @@ void KoShapeManager::paint( QPainter &painter, const KoViewConverter &converter,
if
(
clipRegion
.
intersect
(
shapeRegion
).
isEmpty
())
continue
;
}
while
(
connectionIterator
!=
sortedConnections
.
end
()
&&
(
*
connectionIterator
)
->
zIndex
()
<
shape
->
zIndex
())
{
painter
.
save
();
(
*
connectionIterator
)
->
paint
(
painter
,
converter
);
painter
.
restore
();
connectionIterator
++
;
}
painter
.
save
();
painter
.
setMatrix
(
shape
->
transformationMatrix
(
&
converter
)
*
painter
.
matrix
()
);
...
...
@@ -178,10 +194,11 @@ void KoShapeManager::paint( QPainter &painter, const KoViewConverter &converter,
painter
.
restore
();
// for the matrix
}
foreach
(
KoShapeConnection
*
sc
,
d
->
connectionTree
.
intersects
(
clipRegion
.
boundingRect
()
)
)
{
while
(
connectionIterator
!=
sortedConnections
.
end
())
{
// paint connections that are above the rest.
painter
.
save
();
sc
->
paint
(
painter
,
converter
);
(
*
connectionIterator
)
->
paint
(
painter
,
converter
);
painter
.
restore
();
connectionIterator
++
;
}
#ifdef KOFFICE_RTREE_DEBUG
...
...
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