Permalink
Browse files

postproc.py: new --fgcolor, --bgcolor options

  • Loading branch information...
rc committed Jan 7, 2012
1 parent ee2a8e6 commit 572462a13c9c96c036d86cf6c856dbea0d587965
Showing with 43 additions and 9 deletions.
  1. +22 −1 postproc.py
  2. +21 −8 sfepy/postprocess/viewer.py
View
@@ -62,6 +62,11 @@
'[default: if --3d is True: "45,45", else: "0,0"]',
'roll' :
'camera roll angle [default: %default]',
+ 'fgcolor' :
+ 'foreground color, that is the color of all text annotation labels'
+ ' (axes, orientation axes, scalar bar labels) [default: %default]',
+ 'bgcolor' :
+ 'background color [default: %default]',
'layout' :
'layout for multi-field plots, one of: rowcol, colrow, row, col' \
' [default: %default]',
@@ -201,7 +206,9 @@ def view_file(filename, filter_names, options, view=None):
options.only_names = options.only_names.split(',')
view(show=options.show, is_3d=options.is_3d, view=options.view,
- roll=options.roll, layout=options.layout,
+ roll=options.roll,
+ fgcolor=options.fgcolor, bgcolor=options.bgcolor,
+ layout=options.layout,
scalar_mode=options.scalar_mode,
vector_mode=options.vector_mode,
rel_scaling=options.rel_scaling,
@@ -245,6 +252,12 @@ def main():
parser.add_option("--roll", type='float', metavar='angle',
action="store", dest="roll",
default=0.0, help=help['roll'])
+ parser.add_option("--fgcolor", metavar='R,G,B',
+ action="store", dest="fgcolor",
+ default='0.0,0.0,0.0', help=help['fgcolor'])
+ parser.add_option("--bgcolor", metavar='R,G,B',
+ action="store", dest="bgcolor",
+ default='1.0,1.0,1.0', help=help['bgcolor'])
parser.add_option("--layout", metavar='layout',
action="store", dest="layout",
default='rowcol', help=help['layout'])
@@ -333,6 +346,14 @@ def main():
parser.print_help(),
return
+ options.fgcolor = tuple([float(ii) for ii in
+ options.fgcolor.split(',')])
+ assert_(len(options.fgcolor) == 3)
+
+ options.bgcolor = tuple([float(ii) for ii in
+ options.bgcolor.split(',')])
+ assert_(len(options.bgcolor) == 3)
+
# Output dir / file names.
if options.filename is None:
options.filename = 'view.png'
@@ -207,11 +207,12 @@ def __init__(self, filename, watch=False,
insert_as_static_method(self.__class__, '__call__', self.call_empty)
else:
insert_as_static_method(self.__class__, '__call__', self.call_mlab)
-
+
def get_data_names(self, source=None, detailed=False):
if source is None:
mlab.options.offscreen = self.offscreen
- scene = mlab.figure(bgcolor=(1,1,1), fgcolor=(0, 0, 0), size=(1, 1))
+ mlab.figure(fgcolor=self.fgcolor, bgcolor=self.bgcolor,
+ size=(1, 1))
source = mlab.pipeline.open(self.filename)
point_scalar_names = sorted( source._point_scalars_list[:-1] )
point_vector_names = sorted( source._point_vectors_list[:-1] )
@@ -566,7 +567,7 @@ def _make_iterator(repeat, n_row, n_col):
name = '|%s|' % name
text = add_text(active, position, name,
float(rel_text_width * len(name))
- / float(max_label_width))
+ / float(max_label_width), color=self.fgcolor)
if not names:
# No data, so just show the mesh.
@@ -634,8 +635,10 @@ def __call__(self, *args, **kwargs):
def call_empty(self, *args, **kwargs):
pass
-
- def call_mlab(self, scene=None, show=True, is_3d=False, view=None, roll=None,
+
+ def call_mlab(self, scene=None, show=True, is_3d=False,
+ view=None, roll=None,
+ fgcolor=(1.0, 1.0, 1.0), bgcolor=(0.0, 0.0, 0.0),
layout='rowcol', scalar_mode='iso_surface',
vector_mode='arrows_norm', rel_scaling=None, clamping=False,
ranges=None, is_scalar_bar=False, is_wireframe=False,
@@ -660,6 +663,12 @@ def call_mlab(self, scene=None, show=True, is_3d=False, view=None, roll=None,
`mlab.view()`.
roll : float
Roll angle tuple as in mlab.roll().
+ fgcolor : tuple of floats (R, G, B)
+ The foreground color, that is the color of all text
+ annotation labels (axes, orientation axes, scalar bar
+ labels).
+ bgcolor : tuple of floats (R, G, B)
+ The background color.
layout : str
Grid layout for placing the datasets. Possible values are:
'row', 'col', 'rowcol', 'colrow'.
@@ -709,6 +718,9 @@ def call_mlab(self, scene=None, show=True, is_3d=False, view=None, roll=None,
domain_specific : dict
Domain-specific drawing functions and configurations.
"""
+ self.fgcolor = fgcolor
+ self.bgcolor = bgcolor
+
if filter_names is None:
filter_names = ['node_groups', 'mat_id']
@@ -769,11 +781,12 @@ def call_mlab(self, scene=None, show=True, is_3d=False, view=None, roll=None,
if self.scene is None:
if self.offscreen:
gui = None
- scene = mlab.figure(bgcolor=(1,1,1), fgcolor=(0, 0, 0),
+ scene = mlab.figure(fgcolor=fgcolor, bgcolor=bgcolor,
size=self.size_hint)
else:
- gui = ViewerGUI(viewer=self)
+ gui = ViewerGUI(viewer=self,
+ fgcolor=fgcolor, bgcolor=bgcolor)
scene = gui.scene.mayavi_scene
if scene is not self.scene:
@@ -955,7 +968,7 @@ def _post_init(self, name, old, new):
viewer.reset_view()
viewer.show_scalar_bars(viewer.scalar_bars)
- def __init__(self, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0),
+ def __init__(self, fgcolor=(0.0, 0.0, 0.0), bgcolor=(1.0, 1.0, 1.0),
**traits):
HasTraits.__init__(self, **traits)
scene = self.scene.scene

0 comments on commit 572462a

Please sign in to comment.