Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pykat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sean Leavey
pykat
Commits
ad82f792
Commit
ad82f792
authored
Mar 4, 2014
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
updating gui on object removal
parent
fde8c507
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pykat/finesse.py
+11
-0
11 additions, 0 deletions
pykat/finesse.py
pykat/gui/graphics.py
+10
-4
10 additions, 4 deletions
pykat/gui/graphics.py
pykat/gui/gui.py
+23
-0
23 additions, 0 deletions
pykat/gui/gui.py
with
44 additions
and
4 deletions
pykat/finesse.py
+
11
−
0
View file @
ad82f792
...
...
@@ -822,6 +822,12 @@ class kat(object):
if
obj
.
removed
:
raise
pkex
.
BasePyKatException
(
"
{0} has already been removed
"
.
format
(
obj
.
name
))
nodes
=
None
# store nodes that this componet is attached to as a reference for gui
if
isinstance
(
obj
,
Component
):
nodes
=
self
.
nodes
.
getComponentNodes
(
obj
)
if
isinstance
(
obj
,
Component
):
del
self
.
__components
[
obj
.
name
]
self
.
__del_component
(
obj
)
...
...
@@ -837,6 +843,11 @@ class kat(object):
if
obj
in
self
.
__blocks
[
b
].
contents
:
self
.
__blocks
[
b
].
contents
.
remove
(
obj
)
if
self
.
pykatgui
!=
None
:
self
.
pykatgui
.
_onComponentRemoved
(
obj
,
nodes
)
del
nodes
import
gc
print
gc
.
get_referrers
(
obj
)
...
...
This diff is collapsed.
Click to expand it.
pykat/gui/graphics.py
+
10
−
4
View file @
ad82f792
...
...
@@ -11,6 +11,7 @@ from PyQt4 import QtSvg
from
PyQt4.QtSvg
import
QGraphicsSvgItem
import
pykat.components
import
exceptions
import
weakref
nsize
=
10
...
...
@@ -143,10 +144,15 @@ class SpaceQGraphicsItem(QGraphicsLineItem):
class
ComponentQGraphicsItem
(
QtSvg
.
QGraphicsSvgItem
):
def
__on_component_deleted
(
self
,
arg
):
import
gc
print
gc
.
get_referrers
(
self
)
def
__init__
(
self
,
svgfile
,
component
,
nodes
):
QGraphicsSvgItem
.
__init__
(
self
,
svgfile
)
self
.
__nodeGraphics
=
[]
self
.
__component
=
component
self
.
__component
=
weakref
.
ref
(
component
,
self
.
__on_component_deleted
)
# this signals the itemChange() method when this item is moved
# used for refreshing the spaces between components
self
.
setFlags
(
QGraphicsItem
.
ItemSendsGeometryChanges
)
...
...
@@ -170,7 +176,7 @@ class ComponentQGraphicsItem(QtSvg.QGraphicsSvgItem):
self
.
setHandlesChildEvents
(
True
)
@property
def
component
(
self
):
return
self
.
__component
def
component
(
self
):
return
self
.
__component
()
def
refresh
(
self
):
for
n
in
self
.
__nodeGraphics
:
...
...
@@ -179,10 +185,10 @@ class ComponentQGraphicsItem(QtSvg.QGraphicsSvgItem):
def
itemChange
(
self
,
change
,
value
):
# if the item is moved then update any spaces attached to it
if
change
==
QGraphicsItem
.
ItemPositionHasChanged
:
nodes
=
self
.
__
component
.
nodes
nodes
=
self
.
component
.
nodes
for
n
in
nodes
:
conn
=
n
.
amIConnected
(
self
.
__
component
)
conn
=
n
.
amIConnected
(
self
.
component
)
if
conn
[
0
]
and
isinstance
(
conn
[
1
],
pykat
.
components
.
space
):
conn
[
1
].
getQGraphicsItem
().
refresh
()
...
...
This diff is collapsed.
Click to expand it.
pykat/gui/gui.py
+
23
−
0
View file @
ad82f792
...
...
@@ -71,6 +71,29 @@ class pyKatGUI(QtGui.QMainWindow, qt_gui.Ui_MainWindow):
itm
.
setCacheMode
(
QGraphicsItem
.
NoCache
)
self
.
__scene
.
addItem
(
itm
)
def
_onComponentRemoved
(
self
,
comp
,
nodes
):
"""
When a component has been removed from the kat object this function should update
all gui objects.
comp - object that is removed
nodes - nodes that this comp was attached too, as that information may no longer be accessible
"""
itm
=
comp
.
getQGraphicsItem
()
if
itm
!=
None
:
itm
.
refresh
()
self
.
__scene
.
removeItem
(
itm
)
for
n
in
nodes
:
for
cc
in
self
.
_kat
.
nodes
.
getNodeComponents
(
n
):
print
"
refresh
"
,
cc
if
cc
!=
None
:
ccitm
=
cc
.
getQGraphicsItem
()
if
ccitm
!=
None
:
ccitm
.
refresh
()
def
exportToSVG
(
self
):
self
.
statusbar
.
showMessage
(
"
Saving to
'
output.svg
'
...
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment