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

Fix bugs #416

Merged
merged 10 commits into from
Aug 1, 2016
2 changes: 1 addition & 1 deletion docs/source/mayavi/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

# General substitutions.
project = 'mayavi'
copyright = u'2008-2015, Enthought Inc.'
copyright = u'2008-2016, Enthought Inc.'

# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
Expand Down
5 changes: 3 additions & 2 deletions docs/source/tvtk/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@

# General substitutions.
project = 'tvtk'
copyright = '2008-2015, Enthought Inc.'
copyright = '2008-2016, Enthought Inc.'

# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
d = {}
execfile(os.path.join('..', '..', '..', 'mayavi', '__init__.py'), d)
fname = os.path.join('..', '..', '..', 'mayavi', '__init__.py')
exec(compile(open(fname).read(), fname, 'exec'), d)
version = release = d['__version__']

# There are two options for replacing |today|: either, you set today to some
Expand Down
11 changes: 5 additions & 6 deletions tvtk/pyface/picker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
# Copyright (c) 2005, Enthought, Inc.
# Copyright (c) 2005-2016, Enthought, Inc.
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
Expand All @@ -9,7 +9,7 @@
# Thanks for using Enthought open source!
#
# Author: Enthought, Inc.
# Description: <Enthought pyface package component>
# Description: <Enthought mayavi package component>
#------------------------------------------------------------------------------
"""This module provides basic picking functionality. Using this, one
can interactively select a point and/or a cell in the data. One can
Expand All @@ -18,15 +18,15 @@

"""
# Author: Prabhu Ramachandran <prabhu_r@users.sf.net>
# Copyright (c) 2004, Enthought, Inc.
# Copyright (c) 2004-2016, Enthought, Inc.
# License: BSD Style.

from traits.api import HasTraits, Trait, Long, Array, Any, Float, \
Instance, Range, true, Str
from traitsui.api import View, Group, Item, Handler
from tvtk.api import tvtk
from tvtk.tvtk_base import TraitRevPrefixMap, false_bool_trait
from tvtk.common import configure_input_data
from tvtk.common import configure_input
from apptools.persistence import state_pickler


Expand Down Expand Up @@ -257,7 +257,7 @@ def __init__(self, renwin, **traits):
prop.line_width = 2
prop.ambient = 1.0
prop.diffuse = 0.0
configure_input_data(self.p_mapper, self.p_source.output)
configure_input(self.p_mapper, self.p_source)
self.p_actor.mapper = self.p_mapper

self.probe_data.points = [[0.0, 0.0, 0.0]]
Expand Down Expand Up @@ -449,4 +449,3 @@ def _setup_gui(self):
self.ui.control.Raise()
except AttributeError:
pass

5 changes: 5 additions & 0 deletions tvtk/pyface/tvtk_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from __future__ import print_function

import os
import os.path
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't import os make import os.path redundant?


from apptools.persistence import state_pickler
Expand Down Expand Up @@ -683,6 +684,10 @@ def save_gl2ps(self, file_name, exp=None):
self._exporter_write(ex)
else:
ex.write()
# Work around for a bug in VTK where it saves the file as a
# .pdf.gz when the file is really a PDF file.
Copy link
Member

Choose a reason for hiding this comment

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

Is this bug known to the VTK developers? If so, it would be useful to have a reference to a VTK issue, so that future readers of this code have a way to determine whether the upstream bug has been fixed or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know and its hard for me to find the time to follow up but I will try to do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I looked at the sources and it seems the GL2PS code has changed considerably with VTK 7.0 The GL2PS exporter has been completely changed and looks like the bug shouldn't be there -- but I did not test as I do not have a VTK 7 build with GL2PS enabled on my system.

if f_ext == '.pdf' and os.path.exists(f_prefix + '.pdf.gz'):
os.rename(f_prefix + '.pdf.gz', file_name)

def save_x3d(self, file_name):
"""Save scene to an X3D file (http://www.web3d.org/x3d/).
Expand Down
34 changes: 6 additions & 28 deletions tvtk/pyface/ui/qt4/decorated_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
# Authors: Prabhu Ramachandran <prabhu_r@users.sf.net>,
# Dave Peterson <dpeterson@enthought.com>
# Copyright (c) 2006, Enthought, Inc.
# Copyright (c) 2006-2016, Enthought, Inc.
# License: BSD Style.

# System imports.
Expand All @@ -14,13 +14,13 @@
from pyface.qt import QtGui

# Enthought library imports.
from pyface.api import ImageResource, FileDialog, OK
from pyface.api import ImageResource
from pyface.action.api import ToolBarManager, Group, Action
from tvtk.api import tvtk
from traits.api import Instance, false, Either, List

# Local imports.
from .scene import Scene
from .scene import Scene, popup_save


###########################################################################
Expand Down Expand Up @@ -148,33 +148,11 @@ def _save_snapshot(self):
determines what image type is saved. The default is PNG.
"""
if self._panel is not None:
extensions = ['*.png', '*.jpg', '*.tiff', '*.bmp', '*.ps',
'*.eps', '*.pdf', '*.tex', '*.rib', '*.wrl',
'*.oogl', '*.vrml', '*.obj', '*.iv', '*.pov',
'*.x3d']

descriptions = ["PNG", "JPG", "TIFF", "Bitmap", "PostScript",
"EPS", "PDF", "Tex", "RIB", "WRL",
"Geomview", "VRML", "Wavefront", "Open Inventor",
"Povray", "X3D"]

for description, extension in zip(descriptions, extensions):
wildcard += "{} ({})|{}|".format(description,
extension,
extension)
wildcard += "Determine by extension (*.*)|(*.*)"

dialog = FileDialog(
parent = self._panel,
title = 'Save scene to image',
action = 'save as',
default_filename = "snapshot.png",
wildcard = wildcard
)
if dialog.open() == OK:
path = popup_save(self._panel)
if len(path) > 0:
# The extension of the path will determine the actual
# image type saved.
self.save(dialog.path)
self.save(path)

def _configure_scene(self):
"""Invoked when the toolbar icon for configuration is clicked.
Expand Down
41 changes: 4 additions & 37 deletions tvtk/pyface/ui/qt4/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""

# Author: Prabhu Ramachandran <prabhu_r@users.sf.net>
# Copyright (c) 2004-2007, Enthought, Inc.
# Copyright (c) 2004-2016, Enthought, Inc.
# License: BSD Style.


Expand All @@ -31,9 +31,10 @@
from traits.api import Instance, Button, Any
from traitsui.api import View, Group, Item, InstanceEditor

from pyface.api import Widget, GUI, FileDialog, OK
from pyface.api import Widget, GUI
from tvtk.pyface import picker
from tvtk.pyface import light_manager
from tvtk.pyface.utils import popup_save
from tvtk.pyface.tvtk_scene import TVTKScene

from .QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
Expand Down Expand Up @@ -140,7 +141,7 @@ def keyPressEvent(self, e):
if key in [QtCore.Qt.Key_S] and modifiers == QtCore.Qt.NoModifier:
fname = popup_save(self.parent())
if len(fname) != 0:
self.save(fname)
self._scene.save(fname)
return

shift = ((modifiers & QtCore.Qt.ShiftModifier) == QtCore.Qt.ShiftModifier)
Expand Down Expand Up @@ -220,40 +221,6 @@ def _end_event_callback(self, obj, event):
self._scene.busy = False


######################################################################
# Utility functions.
######################################################################
def popup_save(parent=None):
"""Popup a dialog asking for an image name to save the scene to.
This is used mainly to save a scene in full screen mode. Returns a
filename, returns empty string if action was cancelled. `parent` is
the parent widget over which the dialog will be popped up.
"""

extensions = ['*.png', '*.jpg', '*.tiff', '*.bmp', '*.ps',
'*.eps', '*.pdf', '*.tex', '*.rib', '*.wrl',
'*.oogl', '*.vrml', '*.obj', '*.iv', '*.pov',
'*.x3d']
descriptions = ["PNG", "JPG", "TIFF", "Bitmap", "PostScript",
"EPS", "PDF", "Tex", "RIB", "WRL",
"Geomview", "VRML", "Wavefront", "Open Inventor",
"Povray", "X3D"]
wildcard = ""
for description, extension in zip(descriptions, extensions):
wildcard += "{} ({})|{}|".format(description,
extension,
extension)
wildcard += "Determine by extension (*.*)|(*.*)"

dialog = FileDialog(
parent = parent, title='Save scene to image',
action='save as', wildcard=wildcard
)
if dialog.open() == OK:
return dialog.path
else:
return ''


######################################################################
# `Scene` class.
Expand Down
32 changes: 5 additions & 27 deletions tvtk/pyface/ui/wx/decorated_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import wx

# Enthought library imports.
from pyface.api import ImageResource, FileDialog, OK
from pyface.api import ImageResource
from pyface.action.api import ToolBarManager, Group, Action
from tvtk.api import tvtk
from traits.api import Instance, false, List, Either

# Local imports.
from .scene import Scene
from .scene import Scene, popup_save


###########################################################################
Expand Down Expand Up @@ -163,33 +163,11 @@ def _save_snapshot(self):
determines what image type is saved. The default is PNG.
"""
if self._panel is not None:
extensions = ['*.png', '*.jpg', '*.tiff', '*.bmp', '*.ps',
'*.eps', '*.pdf', '*.tex', '*.rib', '*.wrl',
'*.oogl', '*.vrml', '*.obj', '*.iv', '*.pov'
'*.x3d']
descriptions = ["PNG", "JPG", "TIFF", "Bitmap", "PostScript",
"EPS", "PDF", "Tex", "RIB", "WRL",
"Geomview", "VRML", "Wavefront", "Open Inventor",
"Povray", "X3D"]
wildcard = ""
for description, extension in zip(descriptions, extensions):
wildcard += "{} ({})|{}|".format(description,
extension,
extension)
wildcard += "Determine by extension (*.*)|(*.*)"


dialog = FileDialog(
parent = self._panel,
title = 'Save scene to image',
action = 'save as',
default_filename = "snapshot.png",
wildcard = wildcard
)
if dialog.open() == OK:
path = popup_save(self._panel)
if len(path) > 0:
# The extension of the path will determine the actual
# image type saved.
self.save(dialog.path)
self.save(path)

def _configure_scene(self):
"""Invoked when the toolbar icon for configuration is clicked.
Expand Down
38 changes: 2 additions & 36 deletions tvtk/pyface/ui/wx/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,49 +30,15 @@
from traits.api import Instance, Button, Any, Bool
from traitsui.api import View, Group, Item, InstanceEditor

from pyface.api import Widget, GUI, FileDialog, OK
from pyface.api import Widget, GUI
from tvtk.pyface import picker
from tvtk.pyface import light_manager
from tvtk.pyface.utils import popup_save
from tvtk.pyface.tvtk_scene import TVTKScene

from .wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor


######################################################################
# Utility functions.
######################################################################
def popup_save(parent=None):
"""Popup a dialog asking for an image name to save the scene to.
This is used mainly to save a scene in full screen mode. Returns a
filename, returns empty string if action was cancelled. `parent` is
the parent widget over which the dialog will be popped up.
"""

extensions = ['*.png', '*.jpg', '*.tiff', '*.bmp', '*.ps',
'*.eps', '*.pdf', '*.tex', '*.rib', '*.wrl',
'*.oogl', '*.vrml', '*.obj', '*.iv', '*.pov',
'*.x3d']
descriptions = ["PNG", "JPG", "TIFF", "Bitmap", "PostScript",
"EPS", "PDF", "Tex", "RIB", "WRL",
"Geomview", "VRML", "Wavefront", "Open Inventor",
"Povray", "X3D"]
wildcard = ""
for description, extension in zip(descriptions, extensions):
wildcard += "{} ({})|{}|".format(description,
extension,
extension)
wildcard += "Determine by extension (*.*)|(*.*)"

dialog = FileDialog(
parent = parent, title='Save scene to image',
action='save as', wildcard=wildcard
)
if dialog.open() == OK:
return dialog.path
else:
return ''


######################################################################
# `FullScreen` class.
######################################################################
Expand Down
36 changes: 36 additions & 0 deletions tvtk/pyface/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Collection of utility functions common to different toolkits.
"""

def popup_save(parent=None):
"""Popup a dialog asking for an image name to save the scene to.
This is used mainly to save a scene in full screen mode. Returns a
filename, returns empty string if action was cancelled. `parent` is
the parent widget over which the dialog will be popped up.
"""
from pyface.api import FileDialog, OK

extensions = ['*.png', '*.jpg', '*.tiff', '*.bmp', '*.ps',
'*.eps', '*.pdf', '*.tex', '*.rib', '*.wrl',
'*.oogl', '*.vrml', '*.obj', '*.iv', '*.pov',
'*.x3d']
descriptions = ["PNG", "JPG", "TIFF", "Bitmap", "PostScript",
"EPS", "PDF", "Tex", "RIB", "WRL",
"Geomview", "VRML", "Wavefront", "Open Inventor",
"Povray", "X3D"]
wildcard = ""
for description, extension in zip(descriptions, extensions):
wildcard += "{} ({})|{}|".format(description,
extension,
extension)
wildcard += "Determine by extension (*.*)|(*.*)"

dialog = FileDialog(
parent=parent, title='Save scene to image',
action='save as', default_filename="snapshot.png",
wildcard=wildcard
)
if dialog.open() == OK:
return dialog.path
else:
return ''
Loading