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
20d38df1
Commit
20d38df1
authored
Dec 12, 2014
by
Maxime Perrotin
Browse files
Add highlight function at scene level
parent
9dbd75a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
opengeode.py
View file @
20d38df1
...
...
@@ -320,6 +320,8 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
self
.
select_rect
=
None
# Keep a list of composite states: {'stateName': SDL_Scene}
self
.
_composite_states
=
{}
# Keep a track of highlighted symbols: { symbol: brush }
self
.
highlighted
=
{}
@
property
def
visible_symb
(
self
):
...
...
@@ -603,6 +605,27 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
nextstate
=
False
,
cpy
=
True
))
symbol
.
update_completion_list
(
pr_text
=
pr_text
)
def
highlight
(
self
,
item
):
''' Highlight a symbol '''
if
item
in
self
.
highlighted
:
return
bound
=
item
.
boundingRect
()
center
=
bound
.
center
.
x
()
gradient
=
QtGui
.
QLinearGradient
(
center
,
0
,
center
,
bound
.
height
())
gradient
.
setColorAt
(
0
,
Qt
.
cyan
)
gradient
.
setColorAt
(
1
,
Qt
.
white
)
self
.
highlighted
[
item
]
=
item
.
brush
()
item
.
setBrush
(
QtGui
.
QBrush
(
gradient
))
def
clear_highlight
(
self
,
item
=
None
,
reset
=
True
):
''' Remove the highlighting of one item or all items on the scene '''
if
item
in
self
.
highlighted
:
self
.
setBrush
(
self
.
highlighted
.
pop
(
item
))
if
reset
:
for
item
,
brush
in
self
.
highlighted
.
viewitems
():
item
.
setBrush
(
brush
)
self
.
highlighted
=
{}
def
find_text
(
self
,
pattern
):
''' Return all symbols with matching text '''
for
item
in
(
symbol
for
symbol
in
self
.
items
()
...
...
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