Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
95a42b1e
Commit
95a42b1e
authored
Oct 04, 2015
by
Maxime Perrotin
Browse files
Use ignore list to speed up cam
parent
76439431
Changes
2
Hide whitespace changes
Inline
Side-by-side
opengeode/genericSymbols.py
View file @
95a42b1e
...
...
@@ -606,6 +606,7 @@ class Symbol(QObject, QGraphicsPathItem, object):
# Since the cam function is recursive it may be time consuming
# Call the Qt event prcessing to avoid blocking the application
QApplication
.
processEvents
()
ignore
=
ignore
or
[]
if
not
self
.
scene
():
# Make sure the item is in a scene. For instance, when loading
# a model from a file, some items may be connected together
...
...
@@ -652,22 +653,15 @@ class Symbol(QObject, QGraphicsPathItem, object):
self
.
isAncestorOf
(
j
)
or
j
is
self
]]
# (c) Filter out the potentially colliding items
# if they belong in the cam caller
items
=
[
i
for
i
in
items
if
not
ignore
or
not
i
.
commonAncestorItem
(
ignore
)]
# Get the top level item of each collider
top_level_colliders
=
set
()
for
item
in
items
:
while
item
.
hasParent
:
item
=
item
.
parentItem
()
or
item
.
parent
top_level_colliders
.
add
(
item
)
# if they belong in the cam caller and keep only top-level items
items
=
{
i
.
top_level
()
for
i
in
items
if
not
any
(
c
for
c
in
ignore
if
i
.
commonAncestorItem
(
c
))}
# Determine how much we need to move the colliding groups and call
# their CAM with this delta
# Save colliders positions in case they are moved by a sub cam call
col_pos
=
{
i
:
i
.
position
for
i
in
top_level_collider
s
}
for
col
in
top_level_collider
s
:
col_pos
=
{
i
:
i
.
position
for
i
in
item
s
}
for
col
in
item
s
:
collider_rect
=
(
col
.
sceneBoundingRect
()
|
col
.
mapRectToScene
(
col
.
childrenBoundingRect
()))
if
old_pos
.
y
()
+
rect
.
height
()
<=
collider_rect
.
y
():
...
...
@@ -688,13 +682,14 @@ class Symbol(QObject, QGraphicsPathItem, object):
collider_rect
.
width
()
-
10
+
rect
.
x
())
delta
.
setY
(
col
.
y
())
if
col
.
position
==
col_pos
[
col
]:
col
.
cam
(
col
.
position
,
delta
,
ignore
=
self
)
#print unicode(self), 'collides with', unicode(col)
col
.
cam
(
col
.
position
,
delta
,
ignore
=
ignore
+
[
self
])
# Put it back at the new position to make sure recursive
# CAM can happen properly with all object in new positions
# (End of CAM reset to the old position for animation)
col
.
position
=
delta
# Place top level colliders in old position so that animation can run
for
col
in
top_level_collider
s
:
for
col
in
item
s
:
col
.
position
=
col_pos
[
col
]
self
.
update_connections
()
if
animation
:
...
...
@@ -702,6 +697,7 @@ class Symbol(QObject, QGraphicsPathItem, object):
# control loop runs again. Going back to original position
# so that the animation can be done from the starting point
self
.
position
=
old_pos
#print 'returning from cam'
class
Comment
(
Symbol
):
...
...
@@ -1240,4 +1236,4 @@ class VerticalSymbol(Symbol, object):
branch_entry
=
branch_entry
.
parentItem
()
or
branch_entry
.
parent
branch_entry
.
cam
(
branch_entry
.
position
,
branch_entry
.
position
)
else
:
super
(
VerticalSymbol
,
self
).
cam
(
old_pos
,
new_pos
)
super
(
VerticalSymbol
,
self
).
cam
(
old_pos
,
new_pos
,
ignore
)
opengeode/opengeode.py
View file @
95a42b1e
...
...
@@ -23,6 +23,7 @@ import traceback
import
re
import
code
import
pprint
import
random
from
functools
import
partial
from
itertools
import
chain
...
...
@@ -528,7 +529,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
symbol
.
update_position
()
else
:
# No CIF coordinates: (1) fix COMMENT position
# and (2) if floating
,
call CAM
# and (2) if floating call CAM
if
isinstance
(
symbol
,
genericSymbols
.
Comment
):
symbol
.
pos_x
=
\
symbol
.
parent
.
boundingRect
().
width
()
+
15
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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