Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ requirements:
- python
- fabio
- hexrd=={{ hexrd_version }}
# We have some issue removing artists in matplotlib 3.10
# Fix the matplotlib version until that is resolved.
- matplotlib-base<3.10
- matplotlib-base
- Pillow
- pyhdf
# This next one is needed to fix the app name on Mac
Expand Down
4 changes: 3 additions & 1 deletion hexrdgui/blit_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from matplotlib.artist import Artist

from hexrdgui.utils.matplotlib import remove_artist


class BlitManager:
def __init__(self, canvas):
Expand Down Expand Up @@ -63,7 +65,7 @@ def remove_artists(self, *path):
d = d[key]

for artist in _recursive_yield_artists(d):
artist.remove()
remove_artist(artist)

if parent:
del parent[key]
Expand Down
3 changes: 2 additions & 1 deletion hexrdgui/calibration/calibration_dialog_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.utils import instr_to_internal_dict
from hexrdgui.utils.abc_qobject import ABCQObject
from hexrdgui.utils.matplotlib import remove_artist


# Number of decimal places to round calibration parameters
Expand Down Expand Up @@ -312,7 +313,7 @@ def on_undo_run_clicked(self):

def clear_drawn_picks(self):
while self.draw_picks_lines:
self.draw_picks_lines.pop(0).remove()
remove_artist(self.draw_picks_lines.pop(0))

self.canvas.draw_idle()

Expand Down
3 changes: 2 additions & 1 deletion hexrdgui/calibration/hedm/calibration_results_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from hexrdgui.navigation_toolbar import NavigationToolbar
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils.matplotlib import remove_artist


DEFAULT_STYLE = 'rx'
Expand Down Expand Up @@ -134,7 +135,7 @@ def grain_ids_to_plot(self):

def clear_artists(self):
while self.artists:
self.artists.pop(0).remove()
remove_artist(self.artists.pop(0))

def update_canvas(self):
self.clear_artists()
Expand Down
5 changes: 3 additions & 2 deletions hexrdgui/hand_picked_fibers_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from hexrdgui.fiber_pick_utils import _angles_from_orientation, _pick_to_fiber
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils import block_signals
from hexrdgui.utils.matplotlib import remove_artist


class HandPickedFibersWidget(QObject):
Expand Down Expand Up @@ -177,7 +178,7 @@ def general_spots(self, fibers):

def clear_current_plot(self):
if hasattr(self, '_current_lines'):
self._current_lines.remove()
remove_artist(self._current_lines)
del self._current_lines

def update_current_plot(self):
Expand Down Expand Up @@ -269,7 +270,7 @@ def picked(self, v):
def clear_selected_artists(self):
lines = getattr(self, '_selected_artists', [])
while lines:
lines.pop(0).remove()
remove_artist(lines.pop(0))

@property
def selected_rows(self):
Expand Down
27 changes: 14 additions & 13 deletions hexrdgui/image_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
q_to_tth,
tth_to_q,
)
from hexrdgui.utils.matplotlib import remove_artist
from hexrdgui.utils.tth_distortion import apply_tth_distortion_if_needed
from hexrdgui.waterfall_plot import WaterfallPlotDialog

Expand Down Expand Up @@ -232,10 +233,10 @@ def clear(self):
self.clear_figure()

def clear_figure(self):
self.remove_all_overlay_artists()
self.figure.clear()
self.raw_axes.clear()
self.axes_images.clear()
self.remove_all_overlay_artists()
self.clear_azimuthal_integral_axis()
self.mode = None

Expand All @@ -248,24 +249,24 @@ def clear_azimuthal_integral_axis(self):

def clear_wppf_plot(self):
if self.wppf_plot:
self.wppf_plot.remove()
remove_artist(self.wppf_plot)
self.wppf_plot = None

if self.wppf_background_plot:
self.wppf_background_plot.remove()
remove_artist(self.wppf_background_plot)
self.wppf_background_plot = None

if self.wppf_amorphous_plot:
self.wppf_amorphous_plot.remove()
remove_artist(self.wppf_amorphous_plot)
self.wppf_amorphous_plot = None

if self.wppf_difference_plot:
self.wppf_difference_plot.remove()
remove_artist(self.wppf_difference_plot)
self.wppf_difference_plot = None

def clear_auto_picked_data_artists(self):
while self.auto_picked_data_artists:
self.auto_picked_data_artists.pop(0).remove()
remove_artist(self.auto_picked_data_artists.pop(0))

def load_images(self, image_names):
HexrdConfig().emit_update_status_bar('Loading image view...')
Expand Down Expand Up @@ -851,7 +852,7 @@ def update_overlays(self):

def clear_detector_borders(self):
while self.cached_detector_borders:
self.cached_detector_borders.pop(0).remove()
remove_artist(self.cached_detector_borders.pop(0))

self.draw_idle()

Expand All @@ -875,7 +876,7 @@ def draw_detector_borders(self):

def clear_stereo_border_artists(self):
while self.stereo_border_artists:
self.stereo_border_artists.pop(0).remove()
remove_artist(self.stereo_border_artists.pop(0))

self.draw_idle()

Expand Down Expand Up @@ -916,7 +917,7 @@ def draw_auto_picked_data(self):

def clear_saturation(self):
for t in self.saturation_texts:
t.remove()
remove_artist(t)
self.saturation_texts.clear()
self.draw_idle()

Expand Down Expand Up @@ -981,7 +982,7 @@ def compute_saturation_and_size(detector_name):

def clear_beam_marker(self):
while self.beam_marker_artists:
self.beam_marker_artists.pop(0).remove()
remove_artist(self.beam_marker_artists.pop(0))

def update_beam_marker(self):
self.clear_beam_marker()
Expand Down Expand Up @@ -1766,7 +1767,7 @@ def clear_azimuthal_overlay_artists(self):
while self.azimuthal_overlay_artists:
item = self.azimuthal_overlay_artists.pop(0)
for artist in item['artists'].values():
artist.remove()
remove_artist(artist)

def save_azimuthal_plot(self):
if self.mode != ViewType.polar:
Expand Down Expand Up @@ -1835,7 +1836,7 @@ def update_azimuthal_plot_overlays(self):
self.azimuthal_integral_axis.legend()
elif (axis := self.azimuthal_integral_axis) and axis.get_legend():
# Only remove the legend if the axis exists and it has a legend
axis.get_legend().remove()
remove_artist(axis.get_legend())
self.draw_idle()

def update_azimuthal_integral_plot(self):
Expand Down Expand Up @@ -2268,7 +2269,7 @@ def update_mask_boundaries(self, axis):

def clear_mask_boundaries(self):
for artist in self._mask_boundary_artists:
artist.remove()
remove_artist(artist)

self._mask_boundary_artists.clear()

Expand Down
9 changes: 5 additions & 4 deletions hexrdgui/indexing/fit_grains_results_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils import block_signals
from hexrdgui.utils.dialog import add_help_url
from hexrdgui.utils.matplotlib import remove_artist


COORDS_SLICE = slice(6, 9)
Expand Down Expand Up @@ -219,15 +220,15 @@ def update_enable_states(self):
def clear_artists(self):
# Colorbar must be removed before the scatter artist
if self.colorbar is not None:
self.colorbar.remove()
remove_artist(self.colorbar)
self.colorbar = None

if self.scatter_artist is not None:
self.scatter_artist.remove()
remove_artist(self.scatter_artist)
self.scatter_artist = None

if self.highlight_artist is not None:
self.highlight_artist.remove()
remove_artist(self.highlight_artist)
self.highlight_artist = None

def on_colorby_changed(self):
Expand Down Expand Up @@ -444,7 +445,7 @@ def highlight_selected_grains(self):
selected_grain_ids = self.ui.table_view.selected_grain_ids

if self.highlight_artist is not None:
self.highlight_artist.remove()
remove_artist(self.highlight_artist)

# Now draw the highlight markers for these selected grains
data = self.converted_data[:, COORDS_SLICE][selected_grain_ids].T
Expand Down
5 changes: 3 additions & 2 deletions hexrdgui/indexing/indexing_results_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils import block_signals
from hexrdgui.utils.dialog import add_help_url
from hexrdgui.utils.matplotlib import remove_artist


class IndexingResultsDialog(QObject):
Expand Down Expand Up @@ -113,7 +114,7 @@ def export_grains(self, filename):
if filename.suffix.lower() == '.npz':
# Save as an npz
grain_data = GrainData.from_array(grains)
grain_data.save(selected_file)
grain_data.save(filename)
else:
# Save as txt
write_grains_txt(grains, filename)
Expand Down Expand Up @@ -299,7 +300,7 @@ def update_plot(self):

def clear_spot_lines(self):
if hasattr(self, '_spot_lines'):
self._spot_lines.remove()
remove_artist(self._spot_lines)
del self._spot_lines

def update_spots(self):
Expand Down
3 changes: 2 additions & 1 deletion hexrdgui/indexing/ome_maps_viewer_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils import block_signals
from hexrdgui.utils.dialog import add_help_url
from hexrdgui.utils.matplotlib import remove_artist

import hexrdgui.constants
import hexrdgui.resources.indexing
Expand Down Expand Up @@ -540,7 +541,7 @@ def display_spots(self):

def clear_spot_lines(self):
if hasattr(self, '_spot_lines'):
self._spot_lines.remove()
remove_artist(self._spot_lines)
del self._spot_lines

def update_spots(self):
Expand Down
5 changes: 3 additions & 2 deletions hexrdgui/interactive_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
)
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.utils import has_nan
from hexrdgui.utils.matplotlib import remove_artist
from hexrdgui.utils.polygon import polygon_to_mask


Expand Down Expand Up @@ -160,7 +161,7 @@ def rotation(self):

def clear(self):
if self.shape in self.axis.patches:
self.shape.remove()
remove_artist(self.shape)
self.redraw()
self.total_rotation = 0.

Expand All @@ -186,7 +187,7 @@ def toggle_boundaries(self, show):
self.axis.add_patch(shape)
if self.shape:
self.shape = self.axis.patches[-1]
self.shape.remove()
remove_artist(self.shape)
self.shape.set_linestyle(self.shape_styles[-1]['line'])
self.axis.add_patch(self.shape)
self.connect_translate_rotate()
Expand Down
5 changes: 3 additions & 2 deletions hexrdgui/line_picker_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from hexrdgui.constants import ViewType
from hexrdgui.markers import igor_marker
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils.matplotlib import remove_artist
from hexrdgui.zoom_canvas import ZoomCanvas


Expand Down Expand Up @@ -143,7 +144,7 @@ def move_dialog_to_left(self):

def clear(self):
while self.lines:
self.lines.pop(0).remove()
remove_artist(self.lines.pop(0))

self.linebuilder = None
self.previous_linebuilders.clear()
Expand Down Expand Up @@ -193,7 +194,7 @@ def restore_last_line(self):
self.unused_colors.append(self.lines[-1]._color)

self.linebuilder = self.previous_linebuilders.pop()
self.lines.pop().remove()
remove_artist(self.lines.pop())

self.canvas.draw_idle()

Expand Down
3 changes: 2 additions & 1 deletion hexrdgui/masking/hand_drawn_mask_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from hexrdgui.ui_loader import UiLoader
from hexrdgui.utils import add_sample_points
from hexrdgui.utils.dialog import add_help_url
from hexrdgui.utils.matplotlib import remove_artist

# TODO: How to handle image mode? Mode has changed byt the time the signal has been emitted.

Expand Down Expand Up @@ -91,7 +92,7 @@ def clear(self):
self.ring_data.clear()

while self.lines:
self.lines.pop(0).remove()
remove_artist(self.lines.pop(0))

if self.linebuilder:
self.linebuilder.disconnect()
Expand Down
5 changes: 3 additions & 2 deletions hexrdgui/physics_package_manager_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
exp_map_to_euler_angles,
)
from hexrdgui.utils.guess_instrument_type import guess_instrument_type
from hexrdgui.utils.matplotlib import remove_artist

import hexrd.resources as hexrd_resources
from hexrd.material import _angstroms, _kev, Material
Expand Down Expand Up @@ -403,8 +404,8 @@ def __init__(self, canvas):

def clear(self):
for text, patch in zip(self.ax.texts, self.ax.patches):
text.remove()
patch.remove()
remove_artist(text)
remove_artist(patch)

def add_text(self, patch, label):
if isinstance(patch, Polygon):
Expand Down
4 changes: 3 additions & 1 deletion hexrdgui/point_picker_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QDialog, QDialogButtonBox, QLabel, QVBoxLayout

from hexrdgui.utils.matplotlib import remove_artist


class PointPickerDialog(QDialog):
def __init__(self, canvas, window_title='Pick Points', parent=None):
Expand Down Expand Up @@ -57,7 +59,7 @@ def on_finished(self):
self.disconnect()

if self.scatter_artist is not None:
self.scatter_artist.remove()
remove_artist(self.scatter_artist)
self.scatter_artist = None

def disconnect(self):
Expand Down
Loading
Loading