Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to new pipeline #114

Merged
merged 80 commits into from Apr 17, 2014
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
16074af
First simple step to change pipeline topology using input connection
dmsurti Jan 24, 2014
fb7d034
Remove print statements
dmsurti Jan 24, 2014
a80f36c
Merge pull request #115 from prabhuramachandran/nose_integration_tests
dmsurti Jan 27, 2014
1d84a15
First simple step to change pipeline topology using input connection
dmsurti Jan 24, 2014
6990bc7
Remove print statements
dmsurti Jan 24, 2014
0962b1f
Refactor actor component to new pipeline topology.
dmsurti Jan 27, 2014
34f9294
Merge branch 'new-pipeline' of github.com:dmsurti/mayavi into new-pip…
dmsurti Jan 27, 2014
51e6cff
Refactor actor2d component to new pipeline topology.
dmsurti Jan 27, 2014
9507555
Refactor contour component to new pipeline topology
dmsurti Jan 28, 2014
4ec242c
Refactor custom grid plane component to new pipeline topology
dmsurti Jan 28, 2014
eb4e341
Refactor custom grid plane, cutter, glyph to new pipeline topology
dmsurti Jan 28, 2014
c49c6c4
Fix incorrect doc string
dmsurti Jan 28, 2014
a32ca8f
Refactor grid plane and poly data normals components to new pipeline …
dmsurti Jan 28, 2014
b4456c0
Refactor filters to the new pipeline topology.
dmsurti Jan 28, 2014
6655191
Refactor sources to the new pipeline topology.
dmsurti Jan 28, 2014
8185cb9
(Round 2) Refactor components to new pipeline topology.
dmsurti Jan 30, 2014
6408e7a
(Round 2) Refactor filters to new pipeline topology.
dmsurti Jan 30, 2014
af9faae
Refactor modules to new pipeline topology.
dmsurti Jan 30, 2014
741ae92
Fix TVTK for new pipeline (VTK 6.0 only, back incompat)
dmsurti Feb 5, 2014
23aeb81
Fix TVTK for new pipeline
dmsurti Feb 10, 2014
d32b64b
Add logging info to handle mayavi.core logger not found
dmsurti Feb 14, 2014
a6f22d3
First set of changes to update mayavi module to VTK 6. Uses test_cont…
dmsurti Feb 14, 2014
be70e14
Backport fixes to make tvtk, mayavi modules work with new and old pip…
dmsurti Mar 13, 2014
d6137bd
Revert "Add logging info to handle mayavi.core logger not found"
dmsurti Mar 13, 2014
3c2b0e0
Add function to check old pipeline
dmsurti Mar 18, 2014
70bfec9
Handle scalar components as per new pipeline
dmsurti Mar 18, 2014
c210d60
Fixing color for TVTKBase
dmsurti Mar 18, 2014
b1bd084
Handle array sources for new pipeline
dmsurti Mar 19, 2014
2aabef9
Upgrade built in image to new pipeline
dmsurti Apr 2, 2014
25c3e57
Upgrade extract grid filter to new pipeline
dmsurti Apr 2, 2014
89e4c6e
Upgrading built in surface to new pipeline
dmsurti Apr 2, 2014
62ad693
Upgrade image data probe to new pipeline
dmsurti Apr 2, 2014
89e9ba2
Upgrade input plane widget to new pipeline
dmsurti Apr 2, 2014
e36ae0b
Upgrade image data probe to new pipeline
dmsurti Apr 2, 2014
651e549
Upgrade user defined filter for mlab to new pipeline
dmsurti Apr 2, 2014
4e361ad
Upgrade user defined filters to new pipeline
dmsurti Apr 2, 2014
352a64e
Upgrade to new pipeline except glyph,mlab,scripting,streamline,exodus ii
dmsurti Apr 3, 2014
9530de4
Upgrade to pipeline glyph and mlab except 2 mlab failures
dmsurti Apr 3, 2014
df72e9a
Fix for mlab integration test colorbar
dmsurti Apr 4, 2014
dab2862
Upgrade vtk data sources
dmsurti Apr 7, 2014
bcc2e66
Regression fix for glyph
dmsurti Apr 7, 2014
3b9e4e0
Fix for script recording
dmsurti Apr 7, 2014
0f7b9ae
Regression fix for glyph and vtk data source
dmsurti Apr 7, 2014
91091e2
Fix streamline serialization for position attribute
dmsurti Apr 7, 2014
4528e59
Upgrade to ExodusIIReader.
dmsurti Apr 8, 2014
1878216
Fix build for VTK-6.1.
prabhuramachandran Apr 9, 2014
a2ca82e
Merge pull request #1 from prabhuramachandran/fix_6_1
dmsurti Apr 9, 2014
77dac31
Fix more VTK 6.1 related issues.
prabhuramachandran Apr 9, 2014
e618a7e
Fix vtk parser tests for vtk 6.1
dmsurti Apr 10, 2014
46b47ab
Merge branch 'new-pipeline' of github.com:dmsurti/mayavi into new-pip…
dmsurti Apr 10, 2014
80cb4e3
Fix VTK 6.1 releated issues, img geo filter and vol mapper.
dmsurti Apr 10, 2014
0a513c2
Refactoring input connection.
dmsurti Apr 10, 2014
416bc83
Regression fix for refactored connection.
dmsurti Apr 10, 2014
074f76a
Add example file for ExodusIIReader
dmsurti Apr 10, 2014
5bfa118
Refactor input connection in tvtk.
dmsurti Apr 10, 2014
19f9b31
Fix incorrect definition
dmsurti Apr 10, 2014
269d7cd
Move connection configuration to tvtk common.
dmsurti Apr 11, 2014
4216fc4
Only error fixes for tvtk examples.
dmsurti Apr 11, 2014
ef292e0
Fixes for tvtk examples.
dmsurti Apr 14, 2014
72dc9f2
More tvtk examples fixed.
dmsurti Apr 14, 2014
f1d8417
Fixes for glyph and mayavi examples.
dmsurti Apr 16, 2014
d4880ea
WIP: Fix glyph example and add configure_outputs...
prabhuramachandran Apr 16, 2014
7c5b7d2
Fix one more example.
prabhuramachandran Apr 16, 2014
e15651b
Fixing streamline and outline modules.
prabhuramachandran Apr 16, 2014
66a3957
Fix streamlines for real now.
prabhuramachandran Apr 16, 2014
5a403f4
Fix bug with the save_* methods.
prabhuramachandran Apr 16, 2014
7b47efb
Fix `mlab.imshow()`.
prabhuramachandran Apr 16, 2014
d8fcbdd
Fix tvtk example array_animation.py.
prabhuramachandran Apr 16, 2014
6b3163c
Fixing links to canyon example.
prabhuramachandran Apr 16, 2014
edf6ae9
Fix atomic_orbital.py example.
prabhuramachandran Apr 16, 2014
6c99e25
Fixing plotting_many_lines.py example.
prabhuramachandran Apr 17, 2014
025760a
Fixing issue with updating spacing and other attributes.
prabhuramachandran Apr 17, 2014
58376eb
Fix invalid earlier fix for test.
prabhuramachandran Apr 17, 2014
0a58b33
Fix last non-passing test and skip the ...
prabhuramachandran Apr 17, 2014
2558b21
Fix accidental comment in code.
prabhuramachandran Apr 17, 2014
c492d0a
Remove swap file.
dmsurti Apr 17, 2014
3580b18
Fix regression introduced by removal of update...
prabhuramachandran Apr 17, 2014
da306a1
Make the test_object_cache more robust.
prabhuramachandran Apr 17, 2014
ae4ec93
Regression fix for object cache test.
dmsurti Apr 17, 2014
74bec8f
Fix many of the integration tests.
prabhuramachandran Apr 17, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 29 additions & 9 deletions mayavi/components/actor.py
Expand Up @@ -13,7 +13,7 @@
# Local imports.
from mayavi.core.component import Component
from mayavi.core.source import Source

from mayavi.core.common import is_old_pipeline

######################################################################
# `Actor` class.
Expand Down Expand Up @@ -133,7 +133,10 @@ def _mapper_changed(self, old, new):
self.set_lut(old.lookup_table)
# Setup the inputs to the mapper.
if (len(self.inputs) > 0) and (len(self.inputs[0].outputs) > 0):
new.input = self.inputs[0].outputs[0]
if self.inputs[0].has_output_port():
new.input_connection = self.inputs[0].get_output_object()
else:
new.input = self.inputs[0].outputs[0]
# Setup the actor's mapper.
actor = self.actor
if actor is not None:
Expand Down Expand Up @@ -191,8 +194,12 @@ def _can_object_give_image_data(self, source):

def _change_texture_input(self):
if self._can_object_give_image_data(self.texture_source_object):
img_data = self.texture_source_object.outputs[0]
self.texture.input = img_data
if self.texture_source_object.has_output_port():
output_port = self.texture_source_object.get_output_object()
self.texture.input_connection = output_port
else:
img_data = self.texture_source_object.outputs[0]
self.texture.input = img_data
self.actor.texture = self.texture
else:
self.texture_source_object = None
Expand All @@ -211,11 +218,13 @@ def _texture_source_object_changed(self,old,new):
else:
self.actor.texture = None
self.texture.input = None
self.texture.input_connection = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work with older pipelines? vtk-5.10.1 or 5.6 should work I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this will work with vtk 5.10.1 and 5.6.


def _texture_changed(self,value):
# Setup the actor's texture.
actor = self.actor
if actor is not None and value.input is not None:
if actor is not None and (value.input is not None
or value.input_connection is not None):
actor.texture = value
self.texture.on_trait_change(self.render)

Expand All @@ -226,21 +235,32 @@ def _tcoord_generator_mode_changed(self, value):
if (len(inp) == 0) or \
(len(inp[0].outputs) == 0):
return
input = inp[0].outputs[0]
old_tg = self.tcoord_generator
if old_tg is not None:
old_tg.on_trait_change(self.render, remove=True)
if value == 'none':
self.tcoord_generator = None
self.mapper.input = input
if inp[0].has_output_port():
self.mapper.input_connection = inp[0].get_output_object()
else:
if is_old_pipeline():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? The logic for this seems rather complex. Can't this block be wrapped into one reusable function which takes care of setting the input/input_connection from the appropriate output depending on the object being given? i.e. something like common.set_input(self.mapper, input) which encapsulates all of the logic. This makes the intent clear and puts all the logic in one place and also avoids repetition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will look into relevant similar pieces of code and refactor them. Kept these as is, as would refactor these only after mayavi module is also updated for VTK 6, so that the refactor is once and for all.

self.mapper.input = inp[0].get_output_object()
else:
self.mapper.set_input_data(inp[0].get_output_object())
else:
tg_dict = {'cylinder': tvtk.TextureMapToCylinder,
'sphere': tvtk.TextureMapToSphere,
'plane': tvtk.TextureMapToPlane}
tg = tg_dict[value]()
self.tcoord_generator = tg
tg.input = input
self.mapper.input = tg.output
if inp[0].has_output_port():
tg.input_connection = inp[0].get_output_object()
else:
tg.input = inp[0].get_output_object()
if inp[0].has_output_port():
self.mapper.input_connection = inp[0].get_output_object()
else:
self.mapper.input = inp[0].get_output_object()
tg = self.tcoord_generator
if tg is not None:
tg.on_trait_change(self.render)
Expand Down
10 changes: 8 additions & 2 deletions mayavi/components/actor2d.py
Expand Up @@ -88,7 +88,10 @@ def update_pipeline(self):
if (len(self.inputs) == 0) or \
(len(self.inputs[0].outputs) == 0):
return
self.mapper.input = self.inputs[0].outputs[0]
if self.inputs[0].has_output_port():
self.mapper.input_connection = self.inputs[0].get_output_object()
else:
self.mapper.input = self.inputs[0].get_output_object()
self.render()

def update_data(self):
Expand All @@ -114,7 +117,10 @@ def _mapper_changed(self, old, new):
self._setup_handlers(old, new)
# Setup the inputs to the mapper.
if (len(self.inputs) > 0) and (len(self.inputs[0].outputs) > 0):
new.input = self.inputs[0].outputs[0]
if self.inputs[0].has_output_port():
new.input_connection = self.inputs[0].get_output_object()
else:
new.input = self.inputs[0].outputs[0]
# Setup the actor's mapper.
actor = self.actor
if actor is not None:
Expand Down
23 changes: 21 additions & 2 deletions mayavi/components/contour.py
Expand Up @@ -20,7 +20,7 @@

# Local imports.
from mayavi.core.component import Component
from mayavi.core.common import error
from mayavi.core.common import error, is_old_pipeline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import.

from mayavi.components.common \
import get_module_source, convert_to_poly_data

Expand Down Expand Up @@ -189,6 +189,14 @@ def update_data(self):
# Propagage the data changed event.
self.data_changed = True

def has_output_port(self):
""" The contour filter has an output port."""
return True

def get_output_object(self):
""" Returns the output port."""
return self.contour_filter.output_port

######################################################################
# Non-public methods.
######################################################################
Expand Down Expand Up @@ -297,7 +305,18 @@ def _set_contour_input(self):
cf = self.contour_filter
if self.filled_contours:
inp = convert_to_poly_data(inp)
cf.input = inp
if is_old_pipeline():
cf.input = inp
else:
cf.set_input_data(inp)
else:
if self.inputs[0].has_output_port():
cf.input_connection = self.inputs[0].get_output_object()
else:
if is_old_pipeline():
cf.input = self.inputs[0].get_output_object()
else:
cf.set_input_data(self.inputs[0].outputs[0])
cf.update()
return cf

Expand Down
53 changes: 52 additions & 1 deletion mayavi/components/custom_grid_plane.py
Expand Up @@ -125,7 +125,10 @@ def update_pipeline(self):
error(msg)
raise TypeError, msg

plane.input = input
if self.inputs[0].has_output_port():
plane.input_connection = self.inputs[0].get_output_object()
else:
plane.input = self.inputs[0].get_output_object()
self.plane = plane
self._update_limits()
self._update_voi()
Expand All @@ -143,6 +146,54 @@ def update_data(self):
# Propagate the data_changed event.
self.data_changed = True

def has_output_port(self):
""" The contour filter has an output port."""
return True

def get_output_object(self):
""" Returns the output port."""
return self.plane.output_port

######################################################################
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these relevant for the custom_grid_plane? This seems to be incorrect. I mean all the additions below this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these are incorrect. (BAD: these most likely ended up when I did copy/paste from contour vim buffer). Reverting.

# Non-public methods.
######################################################################
def _contours_items_changed(self, list_event):
if self.auto_contours or not self._has_input():
return
cf = self.contour_filter
added, removed, index = (list_event.added, list_event.removed,
list_event.index)
if len(added) == len(removed):
cf.set_value(index, added[0])
cf.update()
self.data_changed = True
else:
self._contours_changed(self.contours)

def _contours_changed(self, values):
if self.auto_contours or not self._has_input():
return
cf = self.contour_filter
cf.number_of_contours = len(values)
for i, x in enumerate(values):
cf.set_value(i, x)
cf.update()
self.data_changed = True

def _update_ranges(self):
# Here we get the module's source since the input of this
# component may not in general represent the entire object.
if not self.auto_update_range:
return
src = get_module_source(self.inputs[0])
sc = src.outputs[0].point_data.scalars
if sc is not None:
sc_array = sc.to_array()
has_nan = numpy.isnan(sc_array).any()
if has_nan:
rng = (float(numpy.nanmin(sc_array)),
float(numpy.nanmax(sc_array)))

######################################################################
# Non-public methods.
######################################################################
Expand Down
17 changes: 16 additions & 1 deletion mayavi/components/cutter.py
Expand Up @@ -12,6 +12,7 @@

# Local imports.
from mayavi.core.component import Component
from mayavi.core.common import is_old_pipeline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import.



######################################################################
Expand Down Expand Up @@ -50,7 +51,13 @@ def update_pipeline(self):
if (len(self.inputs) == 0) or (len(self.inputs[0].outputs) == 0):
return
c = self.cutter
c.input = self.inputs[0].outputs[0]
if self.inputs[0].has_output_port():
c.input_connection = self.inputs[0].get_output_object()
else:
if is_old_pipeline():
c.input = self.inputs[0].get_output_object()
else:
c.set_input_data(self.inputs[0].get_output_object())
self.outputs = [c.output]

def update_data(self):
Expand All @@ -62,6 +69,14 @@ def update_data(self):
"""
self.data_changed = True

def has_output_port(self):
""" The contour filter has an output port."""
return True

def get_output_object(self):
""" Returns the output port."""
return self.cutter.output_port

######################################################################
# `Cutter` interface
######################################################################
Expand Down
38 changes: 33 additions & 5 deletions mayavi/components/glyph.py
Expand Up @@ -18,6 +18,7 @@
from mayavi.core.component import Component
from mayavi.core.module import Module
from mayavi.components import glyph_source
from mayavi.core.common import is_old_pipeline


######################################################################
Expand Down Expand Up @@ -209,14 +210,28 @@ def stop(self):
self.glyph_source.stop()
super(Glyph, self).stop()

def has_output_port(self):
""" The filter has an output port."""
return True

def get_output_object(self):
""" Returns the output port."""
return self.glyph.output_port

######################################################################
# Non-public methods.
######################################################################
def _update_source(self):
self.glyph.source = self.glyph_source.outputs[0]
if is_old_pipeline():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use configure_source?

self.glyph.source = self.glyph_source.outputs[0]
else:
self.glyph.set_source_data(self.glyph_source.outputs[0])

def _glyph_source_changed(self, value):
self.glyph.source = value.outputs[0]
if is_old_pipeline():
self.glyph.source = value.outputs[0]
else:
self.glyph.set_source_data(value.outputs[0])

def _color_mode_changed(self, value):
if len(self.inputs) == 0:
Expand Down Expand Up @@ -261,10 +276,23 @@ def _mask_input_points_changed(self, value):
return
if value:
mask = self.mask_points
mask.input = inputs[0].outputs[0]
self.glyph.input = mask.output
if is_old_pipeline():
mask.input = inputs[0].outputs[0]
self.glyph.input = mask.output
else:
if inputs[0].has_output_port():
mask.input_connection = inputs[0].get_output_object()
else:
mask.input = inputs[0].outputs[0]
self.glyph.input_connection = mask.output_port
else:
self.glyph.input = inputs[0].outputs[0]
if is_old_pipeline():
self.glyph.input = inputs[0].outputs[0]
else:
if inputs[0].has_output_port():
self.glyph.input_connection = inputs[0].get_output_object()
else:
self.glyph.input = inputs[0].get_output_object()

def _glyph_type_changed(self, value):
if self.glyph_type == 'vector':
Expand Down
19 changes: 17 additions & 2 deletions mayavi/components/grid_plane.py
Expand Up @@ -13,7 +13,7 @@

# Local imports.
from mayavi.core.component import Component
from mayavi.core.common import error
from mayavi.core.common import error, is_old_pipeline


def _get_extent(inp):
Expand Down Expand Up @@ -117,8 +117,15 @@ def update_pipeline(self):
error(msg)
raise TypeError, msg

plane.input = input
if self.inputs[0].has_output_port():
plane.input_connection = self.inputs[0].get_output_object()
else:
if is_old_pipeline():
plane.input = self.inputs[0].get_output_object()
else:
plane.set_input_data(self.inputs[0].get_output_object())
self.plane = plane
self.plane.update()
self.outputs = [plane.output]
self._update_limits()
self._update_extents()
Expand All @@ -142,6 +149,14 @@ def update_data(self):
# Propagate the data_changed event.
self.data_changed = True

def has_output_port(self):
""" The filter has an output port."""
return True

def get_output_object(self):
""" Returns the output port."""
return self.plane.output_port

######################################################################
# Non-public methods.
######################################################################
Expand Down
6 changes: 5 additions & 1 deletion mayavi/components/implicit_plane.py
Expand Up @@ -11,6 +11,7 @@

# Local imports.
from mayavi.core.component import Component
from mayavi.core.common import is_old_pipeline

VTK_VER = tvtk.Version().vtk_version

Expand Down Expand Up @@ -110,7 +111,10 @@ def update_pipeline(self):
return
inp = self.inputs[0].outputs[0]
w = self.widget
w.input = inp
if is_old_pipeline():
w.input = inp
else:
w.set_input_data(inp)
if self._first:
w.place_widget()
self.origin = inp.center
Expand Down
2 changes: 1 addition & 1 deletion mayavi/components/optional.py
Expand Up @@ -104,7 +104,7 @@ def _get_outputs(self):
if self.enabled:
return self.component.outputs
else:
return self.inputs[0].outputs
return self.inputs[0].get_output_object()

def _enabled_changed(self, value):
# Force downstream modules to update.
Expand Down