Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
d337d5bd
Commit
d337d5bd
authored
14 years ago
by
Marco Biasini
Browse files
Options
Downloads
Patches
Plain Diff
added glob-style access to GfxNodes
parent
865fea2a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/gfx/pymod/__init__.py
+44
-0
44 additions, 0 deletions
modules/gfx/pymod/__init__.py
with
44 additions
and
0 deletions
modules/gfx/pymod/__init__.py
+
44
−
0
View file @
d337d5bd
...
...
@@ -140,3 +140,47 @@ def FitToScreen(gfx_ent, width=None, height=None, margin=0.01):
factor_y
*
(
1
+
margin
)
*
geom
.
Length
(
sorted_axes
[
1
]))
+
z_off
)
scene
.
SetRTC
(
rtc
)
class
GfxNodeListAttrProxy
:
def
__init__
(
self
,
node_list
,
name
):
self
.
_node_list
=
node_list
self
.
_name
=
name
def
__iter__
(
self
):
for
node
in
self
.
_node_list
:
yield
getattr
(
node
,
self
.
_name
)
def
__call__
(
self
,
*
args
,
**
kwargs
):
for
node
in
self
.
_node_list
:
bound_method
=
getattr
(
node
,
self
.
_name
)
bound_method
(
*
args
,
**
kwargs
)
class
GfxNodeListProxy
(
object
):
def
__init__
(
self
,
node_list
):
self
.
_nodes
=
node_list
def
__getattr__
(
self
,
name
):
if
name
.
startswith
(
'
_
'
):
return
super
(
GfxNodeListProxy
,
self
).
__getattr__
(
name
)
return
GfxNodeListAttrProxy
(
self
.
_nodes
,
name
)
def
__setattr__
(
self
,
name
,
value
):
if
name
.
startswith
(
'
_
'
):
super
(
GfxNodeListProxy
,
self
).
__setattr__
(
name
,
value
)
for
node
in
self
.
_nodes
:
setattr
(
node
,
name
,
value
)
def
_Match
(
scene
,
pattern
=
"
*
"
):
import
os
import
fnmatch
def
_Recurse
(
path
,
node
,
pattern
):
matches
=
[]
for
child
in
node
.
children
:
full_name
=
os
.
path
.
join
(
path
,
child
.
name
)
if
fnmatch
.
fnmatchcase
(
full_name
,
pattern
):
matches
.
append
(
child
)
matches
.
extend
(
_Recurse
(
full_name
,
child
,
pattern
))
return
matches
return
GfxNodeListProxy
(
_Recurse
(
""
,
Scene
().
root_node
,
pattern
))
SceneSingleton
.
__getitem__
=
_Match
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