From 51aa7f57f361b6f017f4a0449eafb88111488fe9 Mon Sep 17 00:00:00 2001 From: Pierre Bonneel Date: Wed, 27 Jul 2022 15:48:17 +0200 Subject: [PATCH 1/2] [CO] Removing GUI --- SciDataTool/Classes/DataND.py | 14 - SciDataTool/Classes/VectorField.py | 14 - SciDataTool/GUI/DDataPlotter/DDataPlotter.py | 799 ------------------ SciDataTool/GUI/DDataPlotter/DDataPlotter.ui | 175 ---- .../GUI/DDataPlotter/Ui_DDataPlotter.py | 115 --- SciDataTool/GUI/DDataPlotter/__init__.py | 0 SciDataTool/GUI/Resources/SDT.qrc | 5 - SciDataTool/GUI/Resources/SDT_rc.py | 79 -- SciDataTool/GUI/Resources/__init__.py | 1 - .../Resources/images/icon/play-32px_SDT.png | Bin 369 -> 0 bytes SciDataTool/GUI/Tools/ButtonLabel.py | 27 - SciDataTool/GUI/Tools/CheckBox.py | 19 - SciDataTool/GUI/Tools/FloatEdit.py | 166 ---- SciDataTool/GUI/Tools/GifHandler.py | 11 - SciDataTool/GUI/Tools/HelpButton.py | 33 - SciDataTool/GUI/Tools/SaveGifWorker.py | 144 ---- SciDataTool/GUI/Tools/ThreadKillable.py | 33 - SciDataTool/GUI/Tools/__init__.py | 1 - .../GUI/WAxisManager/Ui_WAxisManager.py | 128 --- SciDataTool/GUI/WAxisManager/WAxisManager.py | 626 -------------- SciDataTool/GUI/WAxisManager/WAxisManager.ui | 216 ----- SciDataTool/GUI/WAxisManager/__init__.py | 0 .../GUI/WAxisSelector/Ui_WAxisSelector.py | 95 --- .../GUI/WAxisSelector/WAxisSelector.py | 530 ------------ .../GUI/WAxisSelector/WAxisSelector.ui | 155 ---- SciDataTool/GUI/WAxisSelector/__init__.py | 0 SciDataTool/GUI/WDataRange/Ui_WDataRange.py | 110 --- SciDataTool/GUI/WDataRange/WDataRange.py | 202 ----- SciDataTool/GUI/WDataRange/WDataRange.ui | 168 ---- SciDataTool/GUI/WDataRange/__init__.py | 0 SciDataTool/GUI/WFilter/Ui_WFilter.py | 69 -- SciDataTool/GUI/WFilter/WFilter.py | 380 --------- SciDataTool/GUI/WFilter/WFilter.ui | 85 -- SciDataTool/GUI/WFilter/__init__.py | 0 .../GUI/WPlotManager/Ui_WPlotManager.py | 103 --- SciDataTool/GUI/WPlotManager/WPlotManager.py | 595 ------------- SciDataTool/GUI/WPlotManager/WPlotManager.ui | 189 ----- SciDataTool/GUI/WPlotManager/__init__.py | 0 .../GUI/WSliceOperator/Ui_WSliceOperator.py | 208 ----- .../GUI/WSliceOperator/WSliceOperator.py | 508 ----------- .../GUI/WSliceOperator/WSliceOperator.ui | 285 ------- SciDataTool/GUI/WSliceOperator/__init__.py | 0 .../GUI/WVectorSelector/Ui_WVectorSelector.py | 126 --- .../GUI/WVectorSelector/WVectorSelector.py | 185 ---- .../GUI/WVectorSelector/WVectorSelector.ui | 164 ---- SciDataTool/GUI/WVectorSelector/__init__.py | 0 SciDataTool/GUI/__init__.py | 17 - SciDataTool/Generator/ClassesRef/DataND.csv | 1 - .../Generator/ClassesRef/VectorField.csv | 1 - SciDataTool/Methods/DataND/plot.py | 81 -- SciDataTool/Methods/VectorField/plot.py | 77 -- SciDataTool/__init__.py | 2 +- Tests/GUI/DataND/test_auto_plot_datand.py | 408 --------- Tests/GUI/DataND/test_is_overlay.py | 76 -- Tests/GUI/DataND/test_one_axis.py | 57 -- Tests/GUI/UI/test_animate.py | 160 ---- Tests/GUI/UI/test_axis_interaction.py | 154 ---- Tests/GUI/UI/test_export.py | 55 -- Tests/GUI/UI/test_filter_widget.py | 77 -- Tests/GUI/UI/test_frozen_type.py | 119 --- Tests/GUI/UI/test_refresh_policy.py | 84 -- Tests/GUI/UI/test_setup_GUI.py | 123 --- Tests/GUI/UI/test_slice_operation.py | 89 -- Tests/GUI/UI/test_string_gen_GUI.py | 208 ----- Tests/GUI/VectorField/__init__.py | 48 -- .../VectorField/test_auto_plot_vectorfield.py | 291 ------- Tests/GUI/VectorField/test_vectorfield.py | 83 -- Tests/GUI/__init__.py | 60 -- Tests/GUI/dev_GUI.py | 150 ---- Tests/__init__.py | 3 - 70 files changed, 1 insertion(+), 9186 deletions(-) delete mode 100644 SciDataTool/GUI/DDataPlotter/DDataPlotter.py delete mode 100644 SciDataTool/GUI/DDataPlotter/DDataPlotter.ui delete mode 100644 SciDataTool/GUI/DDataPlotter/Ui_DDataPlotter.py delete mode 100644 SciDataTool/GUI/DDataPlotter/__init__.py delete mode 100644 SciDataTool/GUI/Resources/SDT.qrc delete mode 100644 SciDataTool/GUI/Resources/SDT_rc.py delete mode 100644 SciDataTool/GUI/Resources/__init__.py delete mode 100644 SciDataTool/GUI/Resources/images/icon/play-32px_SDT.png delete mode 100644 SciDataTool/GUI/Tools/ButtonLabel.py delete mode 100644 SciDataTool/GUI/Tools/CheckBox.py delete mode 100644 SciDataTool/GUI/Tools/FloatEdit.py delete mode 100644 SciDataTool/GUI/Tools/GifHandler.py delete mode 100644 SciDataTool/GUI/Tools/HelpButton.py delete mode 100644 SciDataTool/GUI/Tools/SaveGifWorker.py delete mode 100644 SciDataTool/GUI/Tools/ThreadKillable.py delete mode 100644 SciDataTool/GUI/Tools/__init__.py delete mode 100644 SciDataTool/GUI/WAxisManager/Ui_WAxisManager.py delete mode 100644 SciDataTool/GUI/WAxisManager/WAxisManager.py delete mode 100644 SciDataTool/GUI/WAxisManager/WAxisManager.ui delete mode 100644 SciDataTool/GUI/WAxisManager/__init__.py delete mode 100644 SciDataTool/GUI/WAxisSelector/Ui_WAxisSelector.py delete mode 100644 SciDataTool/GUI/WAxisSelector/WAxisSelector.py delete mode 100644 SciDataTool/GUI/WAxisSelector/WAxisSelector.ui delete mode 100644 SciDataTool/GUI/WAxisSelector/__init__.py delete mode 100644 SciDataTool/GUI/WDataRange/Ui_WDataRange.py delete mode 100644 SciDataTool/GUI/WDataRange/WDataRange.py delete mode 100644 SciDataTool/GUI/WDataRange/WDataRange.ui delete mode 100644 SciDataTool/GUI/WDataRange/__init__.py delete mode 100644 SciDataTool/GUI/WFilter/Ui_WFilter.py delete mode 100644 SciDataTool/GUI/WFilter/WFilter.py delete mode 100644 SciDataTool/GUI/WFilter/WFilter.ui delete mode 100644 SciDataTool/GUI/WFilter/__init__.py delete mode 100644 SciDataTool/GUI/WPlotManager/Ui_WPlotManager.py delete mode 100644 SciDataTool/GUI/WPlotManager/WPlotManager.py delete mode 100644 SciDataTool/GUI/WPlotManager/WPlotManager.ui delete mode 100644 SciDataTool/GUI/WPlotManager/__init__.py delete mode 100644 SciDataTool/GUI/WSliceOperator/Ui_WSliceOperator.py delete mode 100644 SciDataTool/GUI/WSliceOperator/WSliceOperator.py delete mode 100644 SciDataTool/GUI/WSliceOperator/WSliceOperator.ui delete mode 100644 SciDataTool/GUI/WSliceOperator/__init__.py delete mode 100644 SciDataTool/GUI/WVectorSelector/Ui_WVectorSelector.py delete mode 100644 SciDataTool/GUI/WVectorSelector/WVectorSelector.py delete mode 100644 SciDataTool/GUI/WVectorSelector/WVectorSelector.ui delete mode 100644 SciDataTool/GUI/WVectorSelector/__init__.py delete mode 100644 SciDataTool/GUI/__init__.py delete mode 100644 SciDataTool/Methods/DataND/plot.py delete mode 100644 SciDataTool/Methods/VectorField/plot.py delete mode 100644 Tests/GUI/DataND/test_auto_plot_datand.py delete mode 100644 Tests/GUI/DataND/test_is_overlay.py delete mode 100644 Tests/GUI/DataND/test_one_axis.py delete mode 100644 Tests/GUI/UI/test_animate.py delete mode 100644 Tests/GUI/UI/test_axis_interaction.py delete mode 100644 Tests/GUI/UI/test_export.py delete mode 100644 Tests/GUI/UI/test_filter_widget.py delete mode 100644 Tests/GUI/UI/test_frozen_type.py delete mode 100644 Tests/GUI/UI/test_refresh_policy.py delete mode 100644 Tests/GUI/UI/test_setup_GUI.py delete mode 100644 Tests/GUI/UI/test_slice_operation.py delete mode 100644 Tests/GUI/UI/test_string_gen_GUI.py delete mode 100644 Tests/GUI/VectorField/__init__.py delete mode 100644 Tests/GUI/VectorField/test_auto_plot_vectorfield.py delete mode 100644 Tests/GUI/VectorField/test_vectorfield.py delete mode 100644 Tests/GUI/__init__.py delete mode 100644 Tests/GUI/dev_GUI.py diff --git a/SciDataTool/Classes/DataND.py b/SciDataTool/Classes/DataND.py index 484ba506..8ea31f57 100644 --- a/SciDataTool/Classes/DataND.py +++ b/SciDataTool/Classes/DataND.py @@ -135,11 +135,6 @@ except ImportError as error: orthogonal_mp = error -try: - from ..Methods.DataND.plot import plot -except ImportError as error: - plot = error - try: from ..Methods.DataND.plot_2D_Data import plot_2D_Data except ImportError as error: @@ -428,15 +423,6 @@ class DataND(Data): ) else: orthogonal_mp = orthogonal_mp - # cf Methods.DataND.plot - if isinstance(plot, ImportError): - plot = property( - fget=lambda x: raise_( - ImportError("Can't use DataND method plot: " + str(plot)) - ) - ) - else: - plot = plot # cf Methods.DataND.plot_2D_Data if isinstance(plot_2D_Data, ImportError): plot_2D_Data = property( diff --git a/SciDataTool/Classes/VectorField.py b/SciDataTool/Classes/VectorField.py index 5c517a51..d62d39e0 100644 --- a/SciDataTool/Classes/VectorField.py +++ b/SciDataTool/Classes/VectorField.py @@ -75,11 +75,6 @@ except ImportError as error: get_vectorfield_along = error -try: - from ..Methods.VectorField.plot import plot -except ImportError as error: - plot = error - try: from ..Methods.VectorField.plot_2D_Data import plot_2D_Data except ImportError as error: @@ -260,15 +255,6 @@ class VectorField(FrozenClass): ) else: get_vectorfield_along = get_vectorfield_along - # cf Methods.VectorField.plot - if isinstance(plot, ImportError): - plot = property( - fget=lambda x: raise_( - ImportError("Can't use VectorField method plot: " + str(plot)) - ) - ) - else: - plot = plot # cf Methods.VectorField.plot_2D_Data if isinstance(plot_2D_Data, ImportError): plot_2D_Data = property( diff --git a/SciDataTool/GUI/DDataPlotter/DDataPlotter.py b/SciDataTool/GUI/DDataPlotter/DDataPlotter.py deleted file mode 100644 index 53043922..00000000 --- a/SciDataTool/GUI/DDataPlotter/DDataPlotter.py +++ /dev/null @@ -1,799 +0,0 @@ -from json import tool -from PySide2.QtWidgets import QWidget -from SciDataTool.Functions import parser -from PySide2.QtCore import Qt -from SciDataTool.GUI.DDataPlotter.Ui_DDataPlotter import Ui_DDataPlotter -from matplotlib.backends.backend_qt5agg import ( - FigureCanvas, - NavigationToolbar2QT as NavigationToolbar, -) -from SciDataTool.Functions.Plot.init_fig import init_fig -import matplotlib.pyplot as plt -from matplotlib.lines import Line2D -from matplotlib.patches import Rectangle -from matplotlib.collections import PathCollection, QuadMesh -from matplotlib.text import Annotation -from numpy import array, allclose, argmin, argmax, where, abs as np_abs -from SciDataTool.Functions.is_axes_in_order import is_axes_in_order -from SciDataTool.Functions.Plot import TEXT_BOX, fft_dict -from SciDataTool.Classes.Norm_ref import Norm_ref - - -SYMBOL_DICT = { - "time": "t", - "angle": "\\alpha", - "axial direction": "z", - "frequency": "f", - "wavenumber": "r", - "rotation speed": "N0", - "stator current along d-axis": "I_d", - "stator current along q-axis": "I_q", - "speed": "N0", - "torque": "T", - "a-weighted sound power level": "ASWL", - "velocity level": "V", - "reference torque": "T_{ref}", -} - -PARAM_3D = [ - "is_2D_view", - "is_contour", - "is_same_size", - "N_stem", - "colormap", - "annotation_delim", - "marker_color", - "z_range", -] - -PARAM_2D = [ - "color_list", - "data_list", - "legend_list", - "fund_harm_dict", - "is_show_legend", -] - - -def latex(string): - """format a string for latex""" - if "_" in string or "^" in string or "\\" in string: - string = r"$" + string + "$" - return string - - -class DDataPlotter(Ui_DDataPlotter, QWidget): - """Main window of the SciDataTool UI""" - - def __init__( - self, - data, - axes_request_list=list(), - component=None, - unit=None, - z_min=None, - z_max=None, - is_auto_refresh=False, - frozen_type=0, - plot_arg_dict=dict(), - save_path="", - logger=None, - path_to_image=None, - text_box=None, - ): - """Initialize the UI according to the input given by the user - - Parameters - ---------- - self : DDataPlotter - a DDataPlotter object - data : DataND or VectorField object - A DataND/VectorField object to plot - axes_request_list: list - list of RequestedAxis which are the info given for the autoplot (for the axes and DataSelection) - component : str - Name of the component to plot (For VectorField only) - unit : str - unit in which to plot the field - z_min : float - Minimum value for Z axis (or Y if only one axe) - z_max : float - Minimum value for Z axis (or Y if only one axe) - is_auto_refresh : bool - True to refresh at each widget changed (else wait call to button) - plot_arg_dict : dict - Dictionnary with arguments that must be given to the plot - frozen_type : int - 0 to let the user modify the axis of the plot, 1 to let him switch them, 2 to not let him change them, - 3 to freeze both axes and operations, 4 to freeze fft, 5 to only allow switch, 6 to only allow overlay button - save_path : str - path to the folder where the animations are saved - logger : logger - logger used to print path to animation (if None using print instead) - path_to_image : str - path to the folder where the image for the animation button is saved - """ - - # Build the interface according to the .ui file - QWidget.__init__(self) - self.setupUi(self) - - self.auto_refresh = is_auto_refresh - if is_auto_refresh: - self.is_auto_refresh.setCheckState(Qt.Checked) - else: - self.is_auto_refresh.setCheckState(Qt.Unchecked) - - self.plot_arg_dict = plot_arg_dict - self.data = data - self.data_orig = data - self.text_box = text_box - - # Initializing the figure inside the UI - (self.fig, self.ax, _, _) = init_fig() - # self.set_figure(self.fig) - - if ( - "type_plot" in self.plot_arg_dict - and self.plot_arg_dict["type_plot"] == "quiver" - ): - is_quiver = True - else: - is_quiver = False - - # Initializing the WPlotManager - self.w_plot_manager.set_info( - data=data, - axes_request_list=axes_request_list, - component=component, - unit=unit, - z_min=z_min, - z_max=z_max, - frozen_type=frozen_type, - is_quiver=is_quiver, - plot_arg_dict=plot_arg_dict, - save_path=save_path, - logger=logger, - path_to_image=path_to_image, - main_widget=self, - ) - - # Building the interaction with the UI itself - self.b_refresh.clicked.connect(self.update_plot) - self.w_plot_manager.updatePlot.connect(self.auto_update) - self.w_plot_manager.updatePlotForced.connect(self.update_plot) - self.update_plot() - - # Adding an argument for testing autorefresh - self.is_plot_updated = False - self.is_auto_refresh.toggled.connect(self.set_auto_refresh) - - def auto_update(self): - """Method that checks if the autorefresh is enabled. If true, then it updates the plot. - Parameters - ---------- - self : WPlotManager - a WPlotManager object - - """ - - self.b_refresh.setDisabled(False) - - if self.auto_refresh == True: - self.update_plot() - self.is_plot_updated = True - else: - self.is_plot_updated = False - - def set_auto_refresh(self): - """Method that update the refresh policy according to the checkbox inside the UI - - Parameters - ---------- - self : WPlotManager - a WPlotManager object - - """ - self.auto_refresh = self.is_auto_refresh.isChecked() - - if self.is_auto_refresh.isChecked(): - # When auto-refresh is enabled, the refresh button must be disabled - self.b_refresh.setDisabled(True) - # Refresh - self.update_plot() - else: - # When auto-refresh is disabled, the refresh button must be enabled - self.b_refresh.setDisabled(False) - - def set_figure(self, fig, text_box=None): - """Method that set up the figure inside the GUI - - Parameters - ---------- - self : DDataPlotter - a DDataPlotter object - fig : Figure - A Figure object to put inside the UI - - """ - if text_box is None: - if self.text_box is None: - text_box = TEXT_BOX - else: - text_box = self.text_box - # Set plot layout - self.canvas = FigureCanvas(fig) - if self.toolbar is None: - toolbar = NavigationToolbar(self.canvas, self) - else: - toolbar = NavigationToolbar(self.canvas, self) - action_names = [action.text() for action in self.toolbar.actions()] - for action in toolbar.actions(): - if action.text() in action_names: - action.setIcon( - self.toolbar.actions()[action_names.index(action.text())].icon() - ) - else: - toolbar.removeAction(action) - - self.plot_layout.addWidget(toolbar) - self.plot_layout.addWidget(self.canvas) - - self.text = None - self.circle = None - self.line = None - - # Set labels for cursor and coordinates - ###################################### - def format_coord(x, y, z=None, sep=", ", ind=None): - # Use hidden annotations - annotations = [ - child - for child in self.ax.get_children() - if isinstance(child, Annotation) - ] - is_annot = True - X_str = None - if ( - ind is not None - and annotations != [] - and ind[0] in range(len(annotations)) - and not annotations[ind[0]]._visible - ): - if annotations[ind[0]]._x == x: - X_str = annotations[ind[0]]._text - is_annot = False - if is_annot: - # Use ticklabels - try: - if self.ax.get_xticklabels()[-1]._text == "": - X_str = format(x, ".4g") - else: - x_float = float(self.ax.get_xticklabels()[-1]._text) - X_str = format(x, ".4g") - except: - for ticklabel in self.ax.get_xticklabels(): - if ticklabel._x == x: - X_str = ticklabel._text - break - if self.ax.get_yticklabels() != []: - if "mathdefault" in self.ax.get_yticklabels()[-1]._text: - Y_str = format(y, ".4g") - else: - try: - if self.ax.get_yticklabels()[-1]._text == "": - Y_str = format(y, ".4g") - else: - y_float = float(self.ax.get_yticklabels()[-1]._text) - Y_str = format(y, ".4g") - except: - Y_str = None - for ticklabel in self.ax.get_yticklabels(): - if ticklabel._y == y: - Y_str = ticklabel._text - break - else: - Y_str = y - if X_str is None or Y_str is None: - return "" - - # Recovering the input of the user - [ - self.data, - axes_selected, - _, - output_range, - ] = self.w_plot_manager.get_plot_info() - - # Checking if the axes are following the order inside the data object - axes_selected_parsed = parser.read_input_strings( - axes_selected, axis_data=None - ) - - if axes_selected_parsed[0].name.lower() in SYMBOL_DICT: - xlabel = latex(SYMBOL_DICT[axes_selected_parsed[0].name.lower()]) - else: - xlabel = latex(axes_selected_parsed[0].name) - xunit = "[" + axes_selected_parsed[0].unit + "]" - - if len(axes_selected) == 2: - if axes_selected_parsed[1].name.lower() in SYMBOL_DICT: - ylabel = latex(SYMBOL_DICT[axes_selected_parsed[1].name.lower()]) - else: - ylabel = latex(axes_selected_parsed[1].name) - yunit = "[" + axes_selected_parsed[1].unit + "]" - - else: - if self.data.name.lower() in SYMBOL_DICT: - ylabel = latex(SYMBOL_DICT[self.data.name.lower()]) - else: - ylabel = latex(self.data.symbol) - - yunit = "[" + latex(output_range["unit"]) + "]" - - if ylabel == "W" and "dBA" in yunit: - ylabel = "ASWL" - elif ylabel == "W" and "dB" in yunit: - ylabel = "SWL" - - # Keep only one decimal in dB case - if "dB" in yunit: - Y_str = format(float(Y_str), ".1f") - - label = ( - xlabel - + " = " - + X_str - + " " - + xunit - + sep - + ylabel - + " = " - + Y_str - + " " - + yunit - ) - - if z is not None: - if hasattr(self, "data") and self.data is not None: - zlabel = latex(self.data.symbol) - elif self.data._name.lower() in SYMBOL_DICT: - zlabel = latex(SYMBOL_DICT[self.data._name.lower()]) - else: - zlabel = latex(self.data._name) - - zunit = "[" + latex(output_range["unit"]) + "]" - - if zlabel == "W" and "dBA" in zunit: - zlabel = "ASWL" - elif zlabel == "W" and "dB" in zunit: - zlabel = "SWL" - - # Keep only one decimal in dB case - if "dB" in yunit: - Z_str = format(z, ".1f") - else: - Z_str = format(z, ".4g") - - label += sep + zlabel + " = " + Z_str + " " + zunit - - # Add hidden annotations - if annotations != [] and not annotations[0]._visible and is_annot: - for ii, annotation in enumerate(annotations): - if annotation._x == x and annotation._y == y: - label += sep + annotation._text - - # Remove latex marks for top right corner - if sep == ", ": - label = label.replace("$", "").replace("{", "").replace("}", "") - - return label.replace("SI", "").replace(" []", "") # Remove dimless units - - # Set cursor - ###################################### - def set_cursor(event): - plot_obj = event.artist - Z = None - legend = None - annot = None - if hasattr(event, "ind"): - ind = event.ind - else: - ind = None - if isinstance(plot_obj, Line2D): - xdata = plot_obj.get_xdata() - ydata = plot_obj.get_ydata() - X = xdata[ind][0] # X position of the click - Y = ydata[ind][0] # Y position of the click - if self.ax.get_legend_handles_labels()[1] != []: - try: - self.ax.lines.index(plot_obj) # Test validation mode - except ValueError: - for line in self.ax.lines: - if allclose(ydata, line.get_ydata()): - plot_obj = line - break - legend = self.ax.get_legend_handles_labels()[1][ - self.ax.lines.index(plot_obj) - ].lstrip(" ") - annotations = [ - child - for child in self.ax.get_children() - if isinstance(child, Annotation) - ] - if ( - annotations != [] - and self.ax.lines.index(plot_obj) in range(len(annotations)) - and not annotations[self.ax.lines.index(plot_obj)]._visible - and "Overall" not in legend - ): - annot = annotations[self.ax.lines.index(plot_obj)]._text - if "main " in annot: - speed_index = argmin( - np_abs(self.data.get_axes("speed")[0].get_values() - X) - ) - H = "H" + legend.split("H")[1].split(" ")[0] - order_index = [ - True if H in string else False - for string in self.data.get_axes("order")[ - 0 - ].get_values() - ].index(True) - loadcases = self.data.get_axes("loadcases")[0].get_values() - lc_index = argmax( - self.data.values[speed_index, order_index, :] - ) - main_lc = loadcases[lc_index] - annot += main_lc - elif isinstance(plot_obj, PathCollection): - X = plot_obj.get_offsets().data[ind][0][0] - Y = plot_obj.get_offsets().data[ind][0][1] - if plot_obj.get_array() is not None: - Z = plot_obj.get_array().data[ind][0] - elif isinstance(plot_obj, Rectangle): - X = plot_obj.get_x() + plot_obj.get_width() / 2 - Y = plot_obj.get_height() - elif isinstance(plot_obj, QuadMesh): - if plot_obj._coordinates.shape[0] > 2: - # pcolormesh case - l = ind[0] // plot_obj._coordinates.shape[1] - X = plot_obj._coordinates[ - l, ind[0] - l * plot_obj._coordinates.shape[1] + 1, 0 - ] - Y = plot_obj._coordinates[ - l, ind[0] - l * plot_obj._coordinates.shape[1] + 1, 1 - ] - else: - X = ( - plot_obj._coordinates[0, ind[0] + 1, 0] - + plot_obj._coordinates[1, ind[0] + 1, 0] - ) / 2 - Y = ( - plot_obj._coordinates[0, ind[0] + 1, 1] - + plot_obj._coordinates[1, ind[0] + 1, 1] - ) / 2 - Z = plot_obj.get_array().data[ind[0]] - - # Offset for the label - x_min, x_max = self.ax.get_xlim() - dx = (x_max - x_min) / 20 - if X is not None and Y is not None: - if isinstance(X, str): - X = ind - label = format_coord(X, Y, Z, sep="\n", ind=ind) - if legend is not None: - if "f_e" in legend and "H" in legend: - H = float(legend.split("H")[1].split(" ")[0]) - legend = ( - legend.split(")")[0] - + "=" - + format(X * H / 60, "4g") - + "[Hz])" - ) - label = legend + "\n" + label - if annot is not None: - label += "\n" + annot - if label != "": - if self.text is None: - # Create label in box and black cross - self.text = self.ax.text( - X + dx, - Y, - label, - ha="left", - va="center", - bbox=text_box, - ) - # Draw line - self.line = self.ax.plot( - [X, X + dx], - [Y, Y], - color="k", - linestyle="-", - linewidth=0.5, - ) - # Draw circle - self.circle = self.ax.plot( - X, - Y, - ".", - markerfacecolor="w", - markeredgecolor="k", - markeredgewidth=0.5, - markersize=12, - ) - else: - # Update label, line and circle - self.text._x = X + dx - self.text._y = Y - self.text._text = label - self.circle[0].set_xdata(array(X)) - self.circle[0].set_ydata(array(Y)) - self.line[0].set_xdata(array([X, X + dx])) - self.line[0].set_ydata(array([Y, Y])) - - self.ax.texts[-1].set_visible(True) - self.ax.lines[-1].set_visible(True) - self.ax.lines[-2].set_visible(True) - self.ax.zorder = 10 - self.canvas.draw() - - def delete_cursor(event): - if event.button.name == "RIGHT": - if self.text is not None: - self.ax.texts[-1].set_visible(False) - if self.line is not None: - self.ax.lines[-1].set_visible(False) - if self.circle is not None: - self.ax.lines[-2].set_visible(False) - self.canvas.draw() - - self.ax.format_coord = format_coord - self.canvas.mpl_connect("pick_event", set_cursor) - self.canvas.mpl_connect("button_press_event", delete_cursor) - - def update_plot(self): - """Method that update the plot according to the info selected in the UI - Parameters - ---------- - self : DDataPlotter - a DDataPlotter object - - """ - # Disabling refresh button after clicking on it (similar to * for an unsaved file) - self.b_refresh.setDisabled(True) - - # Clear plots - for i in reversed(range(self.plot_layout.count())): - if self.plot_layout.itemAt(i).widget() is not None: - widgetToRemove = self.plot_layout.itemAt(i).widget() - widgetToRemove.deleteLater() - - if self.fig.get_axes(): - if len(self.fig.canvas.toolbar.actions()) == 11: - self.toolbar = None - else: - self.toolbar = self.fig.canvas.toolbar - self.fig.clear() - - (self.fig, self.ax, _, _) = init_fig() - self.set_figure(self.fig) - - # Recovering the input of the user - [ - self.data, - axes_selected, - data_selection, - output_range, - ] = self.w_plot_manager.get_plot_info() - - # Update reference value - if ( - output_range["norm"] not in [None, ""] - and "ref" in self.data.normalizations - and isinstance(self.data.normalizations["ref"], Norm_ref) - ): - self.data.normalizations["ref"].ref = output_range["norm"] - - # Checking if the axes are following the order inside the data object - not_in_order = False - - if len(axes_selected) == 2: - not_in_order, axes_selected = is_axes_in_order(axes_selected, self.data) - - if not None in data_selection: - if len(axes_selected) == 1: - plot_arg_dict_2D = self.plot_arg_dict.copy() - for param in PARAM_3D: - if param in plot_arg_dict_2D: - del plot_arg_dict_2D[param] - if ( - "type_plot" in plot_arg_dict_2D - and plot_arg_dict_2D["type_plot"] == "quiver" - ): - # Update reference values - for comp in self.data_orig.components.values(): - if ( - output_range["norm"] not in [None, ""] - and "ref" in comp.normalizations - and isinstance(comp.normalizations["ref"], Norm_ref) - ): - comp.normalizations["ref"].ref = output_range["norm"] - if ( - self.w_plot_manager.w_vect_selector.get_component_selected() - != "all" - ): - component_list = [ - self.w_plot_manager.w_vect_selector.get_component_selected() - ] - else: - component_list = None - angle_str = "angle" - if "is_smallestperiod" in plot_arg_dict_2D: - if plot_arg_dict_2D["is_smallestperiod"]: - angle_str = "angle[smallestperiod]" - del plot_arg_dict_2D["is_smallestperiod"] - if "fig" in plot_arg_dict_2D: - del plot_arg_dict_2D["fig"] - self.data_orig.plot_2D_Data( - *[*[angle_str], *data_selection], - **plot_arg_dict_2D, - unit=output_range["unit"], - fig=self.fig, - ax=self.ax, - y_min=output_range["min"], - y_max=output_range["max"], - component_list=component_list, - ) - else: - if "axis_data" in plot_arg_dict_2D: - for axis_name in plot_arg_dict_2D["axis_data"]: - for i, axis_selected in enumerate(axes_selected): - if axis_name in axis_selected: - if "axis_data" not in axis_selected: - axes_selected[i] = ( - axis_selected.split("{")[0] - + "=axis_data" - + "{" - + axis_selected.split("{")[1] - ) - if ( - "title" in plot_arg_dict_2D - and "[" in data_selection[-1] - and len(data_selection[-1].split("[")[1].split("]")[0]) == 1 - ): - axis_cont = data_selection[-1].split("[")[0] - index = int(data_selection[-1].split("[")[1].split("]")[0]) - plot_arg_dict_2D["title"] += ( - " for " - + axis_cont.rstrip("s") - + " " - + self.data.get_axes(axis_cont)[0].values[index] - ) - if "y_min" in plot_arg_dict_2D: - del plot_arg_dict_2D["y_min"] - if "y_max" in plot_arg_dict_2D: - del plot_arg_dict_2D["y_max"] - if ( - "data_list" in plot_arg_dict_2D - and "wavenumber" in axes_selected[0] - ): - data = plot_arg_dict_2D["data_list"][0] - del plot_arg_dict_2D["data_list"] - else: - data = self.data - data.plot_2D_Data( - *[*axes_selected, *data_selection], - **plot_arg_dict_2D, - unit=output_range["unit"], - fig=self.fig, - ax=self.ax, - y_min=output_range["min"], - y_max=output_range["max"], - ) - self.w_plot_manager.plot_arg_dict = plot_arg_dict_2D - - elif len(axes_selected) == 2: - plot_arg_dict_3D = self.plot_arg_dict.copy() - for param in PARAM_2D: - if param in plot_arg_dict_3D: - del plot_arg_dict_3D[param] - if "is_2D_view" not in self.plot_arg_dict: - self.plot_arg_dict["is_2D_view"] = True - if "axis_data" in plot_arg_dict_3D: - for axis_name in plot_arg_dict_3D["axis_data"]: - for i, axis_selected in enumerate(axes_selected): - if axis_name in axis_selected: - if "axis_data" not in axis_selected: - axes_selected[i] = ( - axis_selected.split("{")[0] - + "=axis_data" - + "{" - + axis_selected.split("{")[1] - ) - if "y_min" in plot_arg_dict_3D: - if "wavenumber" not in axes_selected[1]: - del plot_arg_dict_3D["y_min"] - if "y_max" in plot_arg_dict_3D: - if "wavenumber" not in axes_selected[1]: - del plot_arg_dict_3D["y_max"] - if output_range["min"] is not None: - plot_arg_dict_3D["z_min"] = output_range["min"] - if output_range["max"] is not None: - plot_arg_dict_3D["z_max"] = output_range["max"] - if "is_switch_axes" in plot_arg_dict_3D: - del plot_arg_dict_3D["is_switch_axes"] - self.data.plot_3D_Data( - *[*axes_selected, *data_selection], - **plot_arg_dict_3D, - unit=output_range["unit"], - fig=self.fig, - ax=self.ax, - is_switch_axes=not_in_order, - ) - self.w_plot_manager.plot_arg_dict = plot_arg_dict_3D - - else: - print("Operation not implemented yet, plot could not be updated") - - self.w_plot_manager.w_range.set_min_max() - - def set_info( - self, - data, - unit=None, - axes_request_list=None, - plot_arg_dict=dict(), - is_keep_config=False, - frozen_type=0, - save_path="", - logger=None, - path_to_image=None, - ): - """Method to set the DDataPlotter with information given - self : DDataPlotter - a DDataPlotter object - data : DataND or VectorField object - A DataND/VectorField object to plot - axes_request_list: list - list of RequestedAxis which are the info given for the autoplot (for the axes and DataSelection) - plot_arg_dict : dict - Dictionnary with arguments that must be given to the plot - frozen_type : int - 0 to let the user modify the axis of the plot, 1 to let him switch them, 2 to not let him change them, 3 to freeze both axes and operations, 4 to freeze fft - save_path : str - path to the folder where the animations are saved - logger : logger - logger used to print path to animation (if None using print instead) - path_to_image : str - path to the folder where the image for the animation button is saved - """ - - self.plot_arg_dict = plot_arg_dict - if ( - "type_plot" in self.plot_arg_dict - and self.plot_arg_dict["type_plot"] == "quiver" - ): - is_quiver = True - else: - is_quiver = False - - self.w_plot_manager.set_info( - data=data, - unit=unit, - axes_request_list=axes_request_list, - is_keep_config=is_keep_config, - frozen_type=frozen_type, - plot_arg_dict=plot_arg_dict, - is_quiver=is_quiver, - save_path=save_path, - logger=logger, - path_to_image=path_to_image, - ) - - def showEvent(self, ev): - super(DDataPlotter, self).showEvent(ev) - self.w_scroll.setFixedWidth( - 498 + self.w_scroll.verticalScrollBar().sizeHint().width() - ) - self.w_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) diff --git a/SciDataTool/GUI/DDataPlotter/DDataPlotter.ui b/SciDataTool/GUI/DDataPlotter/DDataPlotter.ui deleted file mode 100644 index 0139a181..00000000 --- a/SciDataTool/GUI/DDataPlotter/DDataPlotter.ui +++ /dev/null @@ -1,175 +0,0 @@ - - - DDataPlotter - - - true - - - - 0 - 0 - 1246 - 884 - - - - - 0 - 0 - - - - ArrowCursor - - - Data Plot - - - - - - - 0 - 0 - - - - - 200 - 0 - - - - - 400 - 16777215 - - - - Qt::ScrollBarAsNeeded - - - true - - - - - 0 - 0 - 398 - 823 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - - - - - - - - - - - 0 - 0 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - Auto Refresh - - - false - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::LeftToRight - - - Refresh - - - - - - - - - - WPlotManager - QWidget -
SciDataTool.GUI.WPlotManager.WPlotManager.h
- 1 -
-
- - -
diff --git a/SciDataTool/GUI/DDataPlotter/Ui_DDataPlotter.py b/SciDataTool/GUI/DDataPlotter/Ui_DDataPlotter.py deleted file mode 100644 index 7cf1130e..00000000 --- a/SciDataTool/GUI/DDataPlotter/Ui_DDataPlotter.py +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: utf-8 -*- - -# File generated according to DDataPlotter.ui -# WARNING! All changes made in this file will be lost! -## WARNING! All changes made in this file will be lost when recompiling UI file! -################################################################################ - -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * - -from SciDataTool.GUI.WPlotManager.WPlotManager import WPlotManager - - -class Ui_DDataPlotter(object): - def setupUi(self, DDataPlotter): - if not DDataPlotter.objectName(): - DDataPlotter.setObjectName(u"DDataPlotter") - DDataPlotter.setEnabled(True) - DDataPlotter.resize(1246, 884) - sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(DDataPlotter.sizePolicy().hasHeightForWidth()) - DDataPlotter.setSizePolicy(sizePolicy) - DDataPlotter.setCursor(QCursor(Qt.ArrowCursor)) - self.gridLayout = QGridLayout(DDataPlotter) - self.gridLayout.setObjectName(u"gridLayout") - self.w_scroll = QScrollArea(DDataPlotter) - self.w_scroll.setObjectName(u"w_scroll") - sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) - sizePolicy1.setHorizontalStretch(0) - sizePolicy1.setVerticalStretch(0) - sizePolicy1.setHeightForWidth(self.w_scroll.sizePolicy().hasHeightForWidth()) - self.w_scroll.setSizePolicy(sizePolicy1) - self.w_scroll.setMinimumSize(QSize(200, 0)) - self.w_scroll.setMaximumSize(QSize(400, 16777215)) - self.w_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) - self.w_scroll.setWidgetResizable(True) - self.scrollAreaWidgetContents = QWidget() - self.scrollAreaWidgetContents.setObjectName(u"scrollAreaWidgetContents") - self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 398, 823)) - self.lay_scroll = QVBoxLayout(self.scrollAreaWidgetContents) - self.lay_scroll.setObjectName(u"lay_scroll") - self.lay_scroll.setContentsMargins(0, 0, 0, 0) - self.w_plot_manager = WPlotManager(self.scrollAreaWidgetContents) - self.w_plot_manager.setObjectName(u"w_plot_manager") - sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) - sizePolicy2.setHorizontalStretch(0) - sizePolicy2.setVerticalStretch(0) - sizePolicy2.setHeightForWidth( - self.w_plot_manager.sizePolicy().hasHeightForWidth() - ) - self.w_plot_manager.setSizePolicy(sizePolicy2) - self.w_plot_manager.setMinimumSize(QSize(0, 0)) - - self.lay_scroll.addWidget(self.w_plot_manager) - - self.w_scroll.setWidget(self.scrollAreaWidgetContents) - - self.gridLayout.addWidget(self.w_scroll, 0, 1, 1, 1) - - self.plot_layout = QVBoxLayout() - self.plot_layout.setObjectName(u"plot_layout") - - self.gridLayout.addLayout(self.plot_layout, 0, 0, 2, 1) - - self.horizontalLayout_2 = QHBoxLayout() - self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") - self.is_auto_refresh = QCheckBox(DDataPlotter) - self.is_auto_refresh.setObjectName(u"is_auto_refresh") - sizePolicy2.setHeightForWidth( - self.is_auto_refresh.sizePolicy().hasHeightForWidth() - ) - self.is_auto_refresh.setSizePolicy(sizePolicy2) - self.is_auto_refresh.setMinimumSize(QSize(0, 24)) - self.is_auto_refresh.setMaximumSize(QSize(16777215, 24)) - self.is_auto_refresh.setChecked(False) - - self.horizontalLayout_2.addWidget(self.is_auto_refresh) - - self.b_refresh = QPushButton(DDataPlotter) - self.b_refresh.setObjectName(u"b_refresh") - self.b_refresh.setEnabled(True) - sizePolicy3 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) - sizePolicy3.setHorizontalStretch(0) - sizePolicy3.setVerticalStretch(0) - sizePolicy3.setHeightForWidth(self.b_refresh.sizePolicy().hasHeightForWidth()) - self.b_refresh.setSizePolicy(sizePolicy3) - self.b_refresh.setMinimumSize(QSize(0, 0)) - self.b_refresh.setMaximumSize(QSize(16777215, 16777215)) - self.b_refresh.setLayoutDirection(Qt.LeftToRight) - - self.horizontalLayout_2.addWidget(self.b_refresh) - - self.gridLayout.addLayout(self.horizontalLayout_2, 1, 1, 1, 1) - - self.retranslateUi(DDataPlotter) - - QMetaObject.connectSlotsByName(DDataPlotter) - - # setupUi - - def retranslateUi(self, DDataPlotter): - DDataPlotter.setWindowTitle( - QCoreApplication.translate("DDataPlotter", u"Data Plot", None) - ) - self.is_auto_refresh.setText( - QCoreApplication.translate("DDataPlotter", u"Auto Refresh", None) - ) - self.b_refresh.setText( - QCoreApplication.translate("DDataPlotter", u"Refresh", None) - ) - - # retranslateUi diff --git a/SciDataTool/GUI/DDataPlotter/__init__.py b/SciDataTool/GUI/DDataPlotter/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/SciDataTool/GUI/Resources/SDT.qrc b/SciDataTool/GUI/Resources/SDT.qrc deleted file mode 100644 index a92bc826..00000000 --- a/SciDataTool/GUI/Resources/SDT.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/icon/play-32px_SDT.png - - diff --git a/SciDataTool/GUI/Resources/SDT_rc.py b/SciDataTool/GUI/Resources/SDT_rc.py deleted file mode 100644 index 5fa355a1..00000000 --- a/SciDataTool/GUI/Resources/SDT_rc.py +++ /dev/null @@ -1,79 +0,0 @@ -# Resource object code (Python 3) -# Created by: object code -# Created by: The Resource Compiler for Qt version 5.15.2 -# WARNING! All changes made in this file will be lost! - -from PySide2 import QtCore - -qt_resource_data = b"\ -\x00\x00\x01q\ -\x89\ -PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0dIHDR\x00\ -\x00\x00 \x00\x00\x00 \x08\x06\x00\x00\x00szz\xf4\ -\x00\x00\x00\x01sRGB\x00\xae\xce\x1c\xe9\x00\x00\x00\ -\x04gAMA\x00\x00\xb1\x8f\x0b\xfca\x05\x00\x00\x00\ -\x09pHYs\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\ -\x9c\x18\x00\x00\x01\x06IDATXGc\x18\x05\xa3\ -`(\x01\x1d \x9e\x04\xa5\x07\x04\x80,\xff\xcf\xcc\xcc\ -\xfc\xdf\xc6\x91\xf7?\x94OW\xc7\x80\x1d\x00\xc2\x8c\x8c\ -\x8c`\x1a\x88\xb7C\xc5\xe9\xe2\x10\xb8\x03\xb0`\x90C\ -\xc8r\x04\x13\x94\xa6\x14x\x00q\x1a\x84I\x1a`\x86\ -\xd2\xc4\x00O 6\x870Q\x010J\x184u9\ -\xcd\xdf\xbc\xfa#\x0c\xe4\x82\xd4=\x06\xe2W 9j\ -\x02|Q\x80\x8e\x89\x8e\x12jE\x01: :Jh\ -\xe5\x00\x06]C\xce\x5c E\xd5\x1cBJ\x14\xa0g\ -U\x9c\x8e\xa0Y\x08\xfc\xff\x0f\xb2\x1b\x0c\xf0F\x07\xcd\ -\x1c@,\xa0\x99\x03@Y\x13\x0av\x00\xf1,\x08\x13\ -\x13\xd0\xcc\x01\x06\xa6\x1c j2\x10\x97\x02\xf1\x15\x10\ -\x87R@R\x22\x04b\x90z\x82\x80\x16!\x00\x0ar\ -\x90\xcfq\x06;\xb9\x00g\x08\xd0\xab\x8a\xc6\xe9\x80\xe0\ -\x18>\x10Ms\x80/\x0d\x10\x15\xdf\xd8\x00\xa5i\x80\ -f\xf1\x8d\x0d\x80C\x00\x14\xdf\x8e\x1e\x03\xd3$\x03Y\ -FwKG\xc1(\xa01``\x00\x00\x1a\xf6lp\ -\xfcO\xe9\xd3\x00\x00\x00\x00IEND\xaeB`\x82\ -\ -" - -qt_resource_name = b"\ -\x00\x06\ -\x07\x03}\xc3\ -\x00i\ -\x00m\x00a\x00g\x00e\x00s\ -\x00\x04\ -\x00\x06\xfa^\ -\x00i\ -\x00c\x00o\x00n\ -\x00\x11\ -\x06\x99\x08\xc7\ -\x00p\ -\x00l\x00a\x00y\x00-\x003\x002\x00p\x00x\x00_\x00S\x00D\x00T\x00.\x00p\x00n\x00g\ -\ -" - -qt_resource_struct = b"\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ -\x00\x00\x00\x00\x00\x00\x00\x00\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ -\x00\x00\x00\x00\x00\x00\x00\x00\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ -\x00\x00\x00\x00\x00\x00\x00\x00\ -\x00\x00\x00\x12\x00\x02\x00\x00\x00\x01\x00\x00\x00\x04\ -\x00\x00\x00\x00\x00\x00\x00\x00\ -\x00\x00\x00 \x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x00\x01\x7f\xc1}\x1fz\ -" - - -def qInitResources(): - QtCore.qRegisterResourceData( - 0x03, qt_resource_struct, qt_resource_name, qt_resource_data - ) - - -def qCleanupResources(): - QtCore.qUnregisterResourceData( - 0x03, qt_resource_struct, qt_resource_name, qt_resource_data - ) - - -qInitResources() diff --git a/SciDataTool/GUI/Resources/__init__.py b/SciDataTool/GUI/Resources/__init__.py deleted file mode 100644 index 40a96afc..00000000 --- a/SciDataTool/GUI/Resources/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/SciDataTool/GUI/Resources/images/icon/play-32px_SDT.png b/SciDataTool/GUI/Resources/images/icon/play-32px_SDT.png deleted file mode 100644 index df6035d611d3d8252439ae4e1bcef86d6da1eb93..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 369 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=G`DAk4@xYmNj^1DmIdV@QO1vIOhm1Pw-6g?TJX*;yKN{+~Z{ z=Fk0O6TjO}@ee=VAj@#5r>7@Ds$;wJ(U*?|b}(;9nBaV(h(&nHGLZ^~La7!{sf4ym zM;QDS%-RhC84bK7OiC@!-rw^}ndeE<6nOf`WGeVu(mS+0y$3RYejPZ`)^ zozKN6xL%cU@)B8)9y+IQK_thY|NNVzc|N$YpOtaYSum5?AySyDjNzjWhp_O4GmLD@ zWE8TD1g0~66cuO>atKmlNt#gA)F7tFz*RKid?B0lPKI=j3#+@1y=-_OVJF~Q+@Q}Z zAbS4>!_v%#w2!^K4bBWA_xt3SFRL&|x|MsoAJkZ2n2^B0AoVS$;E(^y%fMh_@O1Ta JS?83{1OS top: - # ... we replace it by the maximum - text = str(top) - # If the input is too low... - elif float(text) < bottom: - # ... we replace it by the minimum - text = str(bottom) - except ValueError: # Can't convert value to float => not complete - pass - return text diff --git a/SciDataTool/GUI/Tools/GifHandler.py b/SciDataTool/GUI/Tools/GifHandler.py deleted file mode 100644 index 73040f62..00000000 --- a/SciDataTool/GUI/Tools/GifHandler.py +++ /dev/null @@ -1,11 +0,0 @@ -import logging - - -class GifHandler(logging.Handler): - def __init__(self, parent): - super().__init__() - self.parent = parent - - def emit(self, record): - """Send signal gif_available to specify the end of the gif generation""" - self.parent.gif_available.emit() diff --git a/SciDataTool/GUI/Tools/HelpButton.py b/SciDataTool/GUI/Tools/HelpButton.py deleted file mode 100644 index 8ce94990..00000000 --- a/SciDataTool/GUI/Tools/HelpButton.py +++ /dev/null @@ -1,33 +0,0 @@ -from PySide2.QtCore import QUrl, Qt -from PySide2.QtGui import QCursor, QDesktopServices, QPixmap -from PySide2.QtWidgets import QLabel - - -class HelpButton(QLabel): - """A Qlabel with a ? icon, and a click event that open a link""" - - def __init__(self, *args, **kwargs): - """Same constructor as QLineEdit + config validator""" - self.url = "https://eomys.com/" - - # Call the QLabel constructor - super(HelpButton, self).__init__(*args, **kwargs) - - self.setCursor(QCursor(Qt.PointingHandCursor)) - self.setPixmap(QPixmap(":/images/images/icon/help_16.png")) - - def mousePressEvent(self, event=None): - """Open the help link in the default browser - - Parameters - ---------- - self : - A HelpButton object - event : - (Default value = None) - - Returns - ------- - - """ - QDesktopServices.openUrl(QUrl(self.url)) diff --git a/SciDataTool/GUI/Tools/SaveGifWorker.py b/SciDataTool/GUI/Tools/SaveGifWorker.py deleted file mode 100644 index 18c6de9e..00000000 --- a/SciDataTool/GUI/Tools/SaveGifWorker.py +++ /dev/null @@ -1,144 +0,0 @@ -from PySide2.QtCore import QObject, Signal, Slot -from SciDataTool.GUI.Tools.ThreadKillable import ThreadKillable -import multiprocessing -from SciDataTool.GUI.Tools.GifHandler import GifHandler -from logging.handlers import QueueListener - -from pytest import param - - -def save_gif( - queue, widget, main_widget, gif, plot_input, data_selection, is_3D, suptitle_ref -): - - animated_axis = plot_input.pop(0) - - param_dict = widget.param_dict.copy() - - param_dict["save_path"] = gif - - [ - _, - _, - _, - output_range, - ] = widget.get_plot_info() - - if "type_plot" in param_dict and param_dict["type_plot"] == "quiver": - param_dict = main_widget.plot_arg_dict.copy() - param_dict["save_path"] = gif - if widget.w_vect_selector.get_component_selected() != "all": - component_list = [widget.w_vect_selector.get_component_selected()] - else: - component_list = None - angle_str = "angle" - if "is_smallestperiod" in param_dict: - if param_dict["is_smallestperiod"]: - angle_str = "angle[smallestperiod]" - del param_dict["is_smallestperiod"] - if "fig" in param_dict: - fig = param_dict["fig"] - ax = fig.get_axes()[0] - del param_dict["fig"] - else: - fig = None - ax = None - if "colormap" in param_dict: - del param_dict["colormap"] - main_widget.data_orig.plot_2D_Data_Animated( - animated_axis, - *[*[angle_str], *data_selection], - **param_dict, - unit=output_range["unit"], - fig=fig, - ax=ax, - y_min=output_range["min"], - y_max=output_range["max"], - component_list=component_list, - ) - - else: - - param_dict["unit"] = output_range["unit"] - - if "component_list" in param_dict: - param_dict.pop("component_list") - - if is_3D: - widget.data.plot_3D_Data_Animated( - animated_axis, suptitle_ref, *plot_input, **param_dict - ) - else: - widget.data.plot_2D_Data_Animated( - animated_axis, suptitle_ref, *plot_input, **param_dict - ) - queue.put("gif generated") - - -class SaveGifWorker(QObject): - """Worker that saves a gif plot""" - - gif_available = Signal() - - def __init__( - self, - widget=None, - main_widget=None, - gif="", - plot_input=list(), - data_selection=list(), - is_3D=False, - suptitle_ref="", - ): - super().__init__() - self.widget = widget - self.main_widget = main_widget - self.gif = gif - self.plot_input = plot_input - self.data_selection = data_selection - self.is_3D = is_3D - self.suptitle_ref = suptitle_ref - self.queue = multiprocessing.Queue() - # used to check if the is finished - self.queue_handler = GifHandler(parent=self) - self.queue_listener = QueueListener(self.queue, self.queue_handler) - self.queue_listener.start() - - @Slot() - def run(self): - # Setting the thread that will start the run simulation - self.p = ThreadKillable( - target=save_gif, - args=( - self.queue, - self.widget, - self.main_widget, - self.gif, - self.plot_input, - self.data_selection, - self.is_3D, - self.suptitle_ref, - ), - ) - self.p.daemon = True - self.p.start() - - def kill_worker(self): - """ - Kill the worker - Parameters - ---------- - self: SaveGifWorker - the worker generating the gif - Returns - ------- - - """ - if self.queue_listener._thread is not None: - # Stopping the queue listener - self.queue_listener.stop() - self.queue_listener.queue.close() - self.queue_handler.close() - # Closing the process (running simu or saving output - self.p.kill() - self.p.join() diff --git a/SciDataTool/GUI/Tools/ThreadKillable.py b/SciDataTool/GUI/Tools/ThreadKillable.py deleted file mode 100644 index df5d1ec7..00000000 --- a/SciDataTool/GUI/Tools/ThreadKillable.py +++ /dev/null @@ -1,33 +0,0 @@ -import sys -import threading - - -class ThreadKillable(threading.Thread): - def __init__(self, *args, **keywords): - threading.Thread.__init__(self, *args, **keywords) - self.killed = False - - def start(self): - self.__run_backup = self.run - self.run = self.__run - threading.Thread.start(self) - - def __run(self): - sys.settrace(self.globaltrace) - self.__run_backup() - self.run = self.__run_backup - - def globaltrace(self, frame, event, arg): - if event == "call": - return self.localtrace - else: - return None - - def localtrace(self, frame, event, arg): - if self.killed: - if event == "line": - raise SystemExit() - return self.localtrace - - def kill(self): - self.killed = True diff --git a/SciDataTool/GUI/Tools/__init__.py b/SciDataTool/GUI/Tools/__init__.py deleted file mode 100644 index 40a96afc..00000000 --- a/SciDataTool/GUI/Tools/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/SciDataTool/GUI/WAxisManager/Ui_WAxisManager.py b/SciDataTool/GUI/WAxisManager/Ui_WAxisManager.py deleted file mode 100644 index c656b1dd..00000000 --- a/SciDataTool/GUI/WAxisManager/Ui_WAxisManager.py +++ /dev/null @@ -1,128 +0,0 @@ -# -*- coding: utf-8 -*- - -# File generated according to WAxisManager.ui -# WARNING! All changes made in this file will be lost! -## WARNING! All changes made in this file will be lost when recompiling UI file! -################################################################################ - -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * - -from SciDataTool.GUI.WAxisSelector.WAxisSelector import WAxisSelector - - -class Ui_WAxisManager(object): - def setupUi(self, WAxisManager): - if not WAxisManager.objectName(): - WAxisManager.setObjectName(u"WAxisManager") - WAxisManager.resize(461, 266) - self.verticalLayout_2 = QVBoxLayout(WAxisManager) - self.verticalLayout_2.setObjectName(u"verticalLayout_2") - self.g_axes = QGroupBox(WAxisManager) - self.g_axes.setObjectName(u"g_axes") - sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.g_axes.sizePolicy().hasHeightForWidth()) - self.g_axes.setSizePolicy(sizePolicy) - self.g_axes.setMinimumSize(QSize(0, 0)) - self.g_axes.setMaximumSize(QSize(16777215, 16777215)) - self.lay_axes = QHBoxLayout(self.g_axes) - self.lay_axes.setSpacing(4) - self.lay_axes.setObjectName(u"lay_axes") - self.lay_axes.setContentsMargins(5, 0, 5, 0) - self.verticalLayout = QVBoxLayout() - self.verticalLayout.setObjectName(u"verticalLayout") - self.label = QLabel(self.g_axes) - self.label.setObjectName(u"label") - self.label.setMinimumSize(QSize(0, 24)) - - self.verticalLayout.addWidget(self.label) - - self.label_4 = QLabel(self.g_axes) - self.label_4.setObjectName(u"label_4") - self.label_4.setMinimumSize(QSize(0, 18)) - - self.verticalLayout.addWidget(self.label_4) - - self.label_2 = QLabel(self.g_axes) - self.label_2.setObjectName(u"label_2") - self.label_2.setMinimumSize(QSize(0, 20)) - - self.verticalLayout.addWidget(self.label_2) - - self.label_3 = QLabel(self.g_axes) - self.label_3.setObjectName(u"label_3") - sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth()) - self.label_3.setSizePolicy(sizePolicy) - self.label_3.setMinimumSize(QSize(0, 18)) - - self.verticalLayout.addWidget(self.label_3) - - self.label_5 = QLabel(self.g_axes) - self.label_5.setObjectName(u"label_5") - self.label_5.setMinimumSize(QSize(0, 23)) - - self.verticalLayout.addWidget(self.label_5) - - self.lay_axes.addLayout(self.verticalLayout) - - self.w_axis_1 = WAxisSelector(self.g_axes) - self.w_axis_1.setObjectName(u"w_axis_1") - sizePolicy.setHeightForWidth(self.w_axis_1.sizePolicy().hasHeightForWidth()) - self.w_axis_1.setSizePolicy(sizePolicy) - self.w_axis_1.setMinimumSize(QSize(150, 0)) - self.w_axis_1.setMaximumSize(QSize(150, 16777215)) - - self.lay_axes.addWidget(self.w_axis_1) - - self.w_axis_2 = WAxisSelector(self.g_axes) - self.w_axis_2.setObjectName(u"w_axis_2") - sizePolicy.setHeightForWidth(self.w_axis_2.sizePolicy().hasHeightForWidth()) - self.w_axis_2.setSizePolicy(sizePolicy) - self.w_axis_2.setMinimumSize(QSize(150, 0)) - self.w_axis_2.setMaximumSize(QSize(150, 16777215)) - - self.lay_axes.addWidget(self.w_axis_2) - - self.verticalLayout_2.addWidget(self.g_axes) - - self.g_data_extract = QGroupBox(WAxisManager) - self.g_data_extract.setObjectName(u"g_data_extract") - sizePolicy.setHeightForWidth( - self.g_data_extract.sizePolicy().hasHeightForWidth() - ) - self.g_data_extract.setSizePolicy(sizePolicy) - self.g_data_extract.setMinimumSize(QSize(0, 0)) - self.g_data_extract.setMaximumSize(QSize(16777215, 16777215)) - self.lay_data_extract = QVBoxLayout(self.g_data_extract) - self.lay_data_extract.setObjectName(u"lay_data_extract") - - self.verticalLayout_2.addWidget(self.g_data_extract) - - self.retranslateUi(WAxisManager) - - QMetaObject.connectSlotsByName(WAxisManager) - - # setupUi - - def retranslateUi(self, WAxisManager): - WAxisManager.setWindowTitle( - QCoreApplication.translate("WAxisManager", u"WAxisManager", None) - ) - self.g_axes.setTitle( - QCoreApplication.translate("WAxisManager", u"Axes Selection", None) - ) - self.label.setText("") - self.label_4.setText(QCoreApplication.translate("WAxisManager", u"Axis", None)) - self.label_2.setText( - QCoreApplication.translate("WAxisManager", u"Action", None) - ) - self.label_3.setText(QCoreApplication.translate("WAxisManager", u"Unit", None)) - self.label_5.setText("") - self.g_data_extract.setTitle( - QCoreApplication.translate("WAxisManager", u"Axes Operations", None) - ) - - # retranslateUi diff --git a/SciDataTool/GUI/WAxisManager/WAxisManager.py b/SciDataTool/GUI/WAxisManager/WAxisManager.py deleted file mode 100644 index f2fe4f8d..00000000 --- a/SciDataTool/GUI/WAxisManager/WAxisManager.py +++ /dev/null @@ -1,626 +0,0 @@ -from PySide2.QtWidgets import QSpacerItem, QWidget -from PySide2.QtCore import Signal - -from SciDataTool.GUI.WAxisManager.Ui_WAxisManager import Ui_WAxisManager -from SciDataTool.GUI.WSliceOperator.WSliceOperator import WSliceOperator -from SciDataTool.Functions import axes_dict, rev_axes_dict -from SciDataTool.Functions.Plot import ifft_dict, fft_dict - - -EXTENSION_DICT = { - "slice": ["max", "min", "rss", "sum", "rms", "mean", "list", "single"], - "axis": [ - "derivate", - "oneperiod", - "antiperiod", - "smallestperiod", - "pattern", - "axis_data", - "interval", - "whole", - ], -} - - -class WAxisManager(Ui_WAxisManager, QWidget): - """Widget that will handle the selection of the axis as well as generating WDataExtractor""" - - refreshNeeded = Signal() - refreshForced = Signal() - refreshRange = Signal() - generateAnimation = Signal() - - def __init__(self, parent=None): - """Initializing the widget by hiding/showing widget and connecting buttons - - Parameters - ---------- - self : WAxisManager - a WAxisManager object - parent : QWidget - The parent widget - """ - - # Build the interface according to the .ui file - QWidget.__init__(self, parent=parent) - self.setupUi(self) - - self.axes_list = list() - self.path_to_image = None - - # Managing the signal emitted by the WAxisSelector widgets - self.w_axis_1.axisChanged.connect(self.axis_1_updated) - self.w_axis_2.axisChanged.connect(self.axis_2_updated) - - # The action in axis 2 is by default the one chosen in axis 1 - self.w_axis_1.actionChanged.connect(lambda: self.fft_sync("axis 1")) - self.w_axis_2.actionChanged.connect(lambda: self.fft_sync("axis 2")) - - self.w_axis_1.refreshNeeded.connect(self.update_needed) - self.w_axis_2.refreshNeeded.connect(self.update_needed) - - self.w_axis_1.refreshForced.connect(self.update_forced) - self.w_axis_2.refreshForced.connect(self.update_forced) - - def axis_1_updated(self): - """Method that remove the axis selected in w_axis_1 from w_axis_2 and call the method that generates - the layout with the WDataExtractor. - Parameters - ---------- - self : WAxisManager - a WAxisManager object - """ - self.blockSignals(True) - # Making sure that when axis 1 is updated, axis 1 and 2 are both on "None" for the action combobox - self.fft_sync("axis 1", is_refresh=False) - - # Recovering the axis selected by the user removing it from the the second axis combobox - self.w_axis_2.remove_axis(self.w_axis_1.get_axis_selected()) - self.gen_slice_op(is_refresh=False) - self.blockSignals(False) - self.update_needed() - - def axis_2_updated(self): - """Method that make sure that when axis 2 is selected (None->?) it has the same fft/ifft combobox selected as axis1 - then generates Data Selection - Parameters - ---------- - self : WAxisManager - a WAxisManager object - """ - # Making sure that when axis 2 is updated, axis 1 and 2 are both on "None" for the action combobox - self.blockSignals(True) - self.fft_sync("axis 2", is_refresh=False) - self.blockSignals(False) - self.update_needed() - - def gen_slice_op(self, axes_request_list=None, is_refresh=True): - """Method that gen the right WDataExtrator widget according to the axis selected by the user in the UI - Parameters - ---------- - self : WAxisManager - a WAxisManager object - """ - - # Step 1 : Recovering the axis that must be generated (those that are not selected) - # Getting all the possible axes - axes_list_1 = self.w_axis_1.get_axes_name()[:] - axes_list_2 = self.w_axis_2.get_axes_name()[:] - - # Getting the axes selected and removing them from the right axes_list - axis_selected_1 = self.w_axis_1.get_axis_selected() - axis_selected_2 = self.w_axis_2.get_axis_selected() - - if axis_selected_1 in axes_list_1: - axes_list_1.remove(axis_selected_1) - if axis_selected_2 in axes_list_2: - axes_list_2.remove(axis_selected_2) - - # Selecting the axes that are in common between the two axes lists - axes_gen = list() - axes_gen = [ax for ax in axes_list_1 if ax in axes_list_2] - - for ax in self.axes_list: - if ax.is_overlay: - axes_gen.append(ax.name) - - # Step 2 : Removing the items that are in the layout currently - for i in reversed(range(self.lay_data_extract.count())): - widget_to_del = self.lay_data_extract.takeAt(i).widget() - widget_to_del.deleteLater() - - # Step 3 : For each axis available, adding a WSliceOperator widget inside the layout - # If there are no slice to do (two axis available and selected before) then we hide the groupBox - if len(axes_gen) != 0: - self.g_data_extract.show() - self.w_slice_op = list() - - for axis in axes_gen: - temp = WSliceOperator( - self.g_data_extract, path_to_image=self.path_to_image - ) - temp.setObjectName(axis) - for i, ax in enumerate(self.axes_list): - if ( - ax.name == axis - or axis in axes_dict - and ax.name in axes_dict[axis] - or axis in rev_axes_dict - and ax.name in rev_axes_dict[axis] - ): - if axes_request_list is not None and axis in [ - x.name for x in axes_request_list - ]: - temp.update( - ax, - axis_request=axes_request_list[ - [x.name for x in axes_request_list].index(axis) - ], - ) - else: - temp.update(ax) - temp.refreshNeeded.connect(self.update_needed) - temp.refreshForced.connect(self.update_forced) - temp.generateAnimation.connect(self.gen_animate) - self.w_slice_op.append(temp) - self.lay_data_extract.addWidget(temp) - - else: - self.w_slice_op = list() - self.g_data_extract.hide() - if is_refresh: - self.update_needed() - - def gen_animate(self): - """Methods called after clicking on animate button to generate a gif on the axis selected and display it - Parameters - ---------- - self : WAxisManager - a WAxisManager object - - Output - --------- - None - """ - - self.generateAnimation.emit() - - def get_axes_selected(self): - """Method that return the axes chosen by the user and their unit as a string - so that we can use them to plot the data. - Parameters - ---------- - self : WAxisManager - a WAxisManager object - Output - --------- - string - name of the axis and their units - """ - - axes_selected = list() - - # Recovering the first axis - axes_selected.append(self.w_axis_1.get_axis_unit_selected()) - - # If a second axis is selected, then we add it as well - if self.w_axis_2.get_axis_unit_selected() != "None": - axes_selected.append(self.w_axis_2.get_axis_unit_selected()) - - return axes_selected - - def get_operation_selected(self): - """Method that return the operations chosen by the user and the related axis as a string - so that we can use them to plot the data. - Parameters - ---------- - self : WAxisManager - a WAxisManager object - Output - --------- - string - name of the operation and its axis - """ - operations_selected = list() - - for wid in self.w_slice_op: - ope_selected, is_animate = wid.get_operation_selected() - - if is_animate == True: - - axis = ope_selected.split("=")[0] - unit = "{" + ope_selected.split("{")[1] - operations_selected.append(axis + "[oneperiod]" + unit + "to_animate") - wid.is_animate = False - else: - operations_selected.append(ope_selected) - - return operations_selected - - def fft_sync(self, axis_changed, is_refresh=True): - """Method that will check the action chosen and that update the other action combobox to have the same action. - So that, by default, we have FFT and FFT or "None" and "None" - Parameters - ---------- - self : WAxisManager - a WAxisManager object - - """ - self.blockSignals(True) - if axis_changed == "axis 1": # and "FFT" in [ - # self.w_axis_1.c_action.itemText(i) - # for i in range(self.w_axis_1.c_action.count()) - # ]: - action_selected = self.w_axis_1.get_current_action_name() - self.w_axis_2.set_action(action_selected) - if action_selected == "FFT": - if self.w_axis_2.axis_selected in fft_dict: - if self.w_axis_2.axis_selected in self.w_axis_2.axes_list: - self.w_axis_2.axes_list[ - self.w_axis_2.axes_list.index(self.w_axis_2.axis_selected) - ] = fft_dict[self.w_axis_2.axis_selected] - self.w_axis_2.axis_selected = fft_dict[ - self.w_axis_2.axis_selected - ] - else: - self.w_axis_2.axis_selected = fft_dict[ - self.w_axis_2.axis_selected - ] - elif self.w_axis_2.axis_selected in ifft_dict: - if ( - self.w_axis_2.axis_selected not in self.w_axis_2.axes_list - and ifft_dict[self.w_axis_2.axis_selected] - in self.w_axis_2.axes_list - ): - self.w_axis_2.axes_list[ - self.w_axis_2.axes_list.index( - ifft_dict[self.w_axis_2.axis_selected] - ) - ] = self.w_axis_2.axis_selected - else: - if self.w_axis_2.axis_selected in ifft_dict: - if self.w_axis_2.axis_selected in self.w_axis_2.axes_list: - self.w_axis_2.axes_list[ - self.w_axis_2.axes_list.index(self.w_axis_2.axis_selected) - ] = ifft_dict[self.w_axis_2.axis_selected] - self.w_axis_2.axis_selected = ifft_dict[ - self.w_axis_2.axis_selected - ] - else: - self.w_axis_2.axis_selected = ifft_dict[ - self.w_axis_2.axis_selected - ] - elif self.w_axis_2.axis_selected in fft_dict: - if ( - self.w_axis_2.axis_selected not in self.w_axis_2.axes_list - and fft_dict[self.w_axis_2.axis_selected] - in self.w_axis_2.axes_list - ): - self.w_axis_2.axes_list[ - self.w_axis_2.axes_list.index( - fft_dict[self.w_axis_2.axis_selected] - ) - ] = self.w_axis_2.axis_selected - # Make sure that all axes are reset to ifft - for i, axis in enumerate(self.w_axis_1.axes_list): - if axis in ifft_dict: - self.w_axis_1.axes_list[i] = ifft_dict[axis] - self.gen_slice_op(is_refresh=False) - - elif axis_changed == "axis 2": - if self.w_axis_2.get_axis_selected() != "None": - action_selected = self.w_axis_2.get_current_action_name() - self.w_axis_1.set_action(action_selected) - if action_selected == "FFT": - if self.w_axis_1.axis_selected in fft_dict: - if self.w_axis_1.axis_selected in self.w_axis_1.axes_list: - self.w_axis_1.axes_list[ - self.w_axis_1.axes_list.index( - self.w_axis_1.axis_selected - ) - ] = fft_dict[self.w_axis_1.axis_selected] - self.w_axis_1.axis_selected = fft_dict[ - self.w_axis_1.axis_selected - ] - else: - self.w_axis_1.axis_selected = fft_dict[ - self.w_axis_1.axis_selected - ] - elif self.w_axis_1.axis_selected in ifft_dict: - if ( - self.w_axis_1.axis_selected not in self.w_axis_1.axes_list - and ifft_dict[self.w_axis_1.axis_selected] - in self.w_axis_1.axes_list - ): - self.w_axis_1.axes_list[ - self.w_axis_1.axes_list.index( - ifft_dict[self.w_axis_1.axis_selected] - ) - ] = self.w_axis_1.axis_selected - else: - if self.w_axis_1.axis_selected in ifft_dict and ( - self.w_axis_2.axis_selected in fft_dict - or self.w_axis_2.axis_selected in ifft_dict - ): - if self.w_axis_1.axis_selected in self.w_axis_1.axes_list: - self.w_axis_1.axes_list[ - self.w_axis_1.axes_list.index( - self.w_axis_1.axis_selected - ) - ] = ifft_dict[self.w_axis_1.axis_selected] - self.w_axis_1.axis_selected = ifft_dict[ - self.w_axis_1.axis_selected - ] - else: - self.w_axis_1.axis_selected = ifft_dict[ - self.w_axis_1.axis_selected - ] - elif self.w_axis_1.axis_selected in fft_dict and ( - self.w_axis_2.axis_selected in fft_dict - or self.w_axis_2.axis_selected in ifft_dict - ): - if ( - self.w_axis_1.axis_selected not in self.w_axis_1.axes_list - and fft_dict[self.w_axis_1.axis_selected] - in self.w_axis_1.axes_list - ): - self.w_axis_1.axes_list[ - self.w_axis_1.axes_list.index( - fft_dict[self.w_axis_1.axis_selected] - ) - ] = self.w_axis_1.axis_selected - # Make sure that all axes are reset to ifft - for i, axis in enumerate(self.w_axis_2.axes_list): - if axis in ifft_dict and ( - self.w_axis_2.axis_selected in fft_dict - or self.w_axis_2.axis_selected in ifft_dict - ): - self.w_axis_2.axes_list[i] = ifft_dict[axis] - else: - # Make sure that all axes are reset to ifft - for i, axis in enumerate(self.w_axis_2.axes_list): - if axis in ifft_dict: - self.w_axis_2.axes_list[i] = ifft_dict[axis] - self.gen_slice_op(is_refresh=False) - self.w_axis_1.set_unit() - self.w_axis_2.set_unit() - self.blockSignals(False) - if is_refresh: - self.update_needed() - - def set_axis_widgets( - self, - data, - axes_request_list, - frozen_type=0, - is_keep_config=False, - path_to_image=None, - ): - """Method used to set the axes of the Axes group box as well as setting the widgets of the DataSelection groupbox - Parameters - ---------- - self : WAxisManager - a WAxisManager object - data : DataND - The DataND object that we want to plot - axes_request_list: - list of RequestedAxis which are the info given for the autoplot (for the axes and DataSelection) - frozen_type : int - 0 to let the user modify the axis of the plot, 1 to let him switch them, 2 to not let him change them, - 3 to freeze both axes and operations, 4 to freeze fft, 5 to only allow switch, 6 to only allow overlay button - path_to_image : str - path to the folder where the image for the animation button is saved - """ - # Setting path to recover the image for the animate button - self.path_to_image = path_to_image - self.w_axis_1.path_to_image = self.path_to_image - self.w_axis_2.path_to_image = self.path_to_image - - if is_keep_config: # Only update slider - for wid in self.w_slice_op: - if hasattr(wid, "axis_value"): - wid.slider.blockSignals(True) - axis = data.get_axes(wid.axis.name)[0] - wid.axis = axis - index = wid.slider.value() - wid.set_slider_floatedit() - wid.slider.setValue(index) - wid.update_floatEdit() - wid.slider.blockSignals(False) - axes_list = data.get_axes() - - else: - # Step 1 : If only one axis is given with the object, then we hide w_axis_2 and g_data_extract - # We also have to hide if we have more than one axis but one have is_overlay = True - if len(data.get_axes()) == 1 or ( - len(data.get_axes()) - - len([ax for ax in data.get_axes() if ax.is_overlay == True]) - == 1 - ): - self.w_axis_2.hide() - self.g_data_extract.hide() - - else: - self.w_axis_2.show() - self.g_data_extract.show() - - # Step 2 : If we have user input, the we set the UI according to user_input. - # Otherwise we use the default info - self.w_axis_1.blockSignals(True) - self.w_axis_2.blockSignals(True) - - # Reinitialize filter indices - self.w_axis_1.indices = None - self.w_axis_2.indices = None - - if axes_request_list == []: - # Case where no user_input was given - # Sending the info of data to the widget (mainly the axis) - self.axes_list = data.get_axes() - self.w_axis_1.update(self.axes_list) - self.w_axis_2.update(self.axes_list, axis_name="Y") - - # Updating w_axis_2 according to w_axis_1 then generating DataSelection - self.axis_1_updated() - axes_list = self.axes_list - - else: - # Case where a userinput was given (auto plot) - - # If user_input are given (auto-plot), we have to process them - axes_list = [ - ax - for ax in axes_request_list - if ax.extension in EXTENSION_DICT["axis"] - ] - - slices_op_list = [ - ax - for ax in axes_request_list - if ax.extension in EXTENSION_DICT["slice"] - ] - - # Sending the info of data to the widget (mainly the axis) - self.axes_list = data.get_axes() - self.w_axis_1.update(self.axes_list) - self.w_axis_2.update(self.axes_list, axis_name="Y") - # Setting the axis selected in w_axis_1 according to user_input_list - self.w_axis_1.set_axis(axes_list[0]) - - # Updating w_axis_2 according to w_axis_1 then generating DataSelection - self.axis_1_updated() - - # Setting the axis selected in w_axis_1 according to user_input_list if we have a second axis - if len(axes_list) == 2: - self.w_axis_2.set_axis(axes_list[1]) - - # Making sure that we have the same fft/ifft selected for both axis - # self.axis_2_updated() - - # Generating DataSelection with the input of user if they are given or by default (like in a manual plot) - if len(slices_op_list) != 0: - self.gen_slice_op(axes_request_list) - self.set_slice_op(slices_op_list) - else: - self.gen_slice_op(axes_request_list) - - # Depending on the value of frozen type we are going to act on the UI - if frozen_type == 1 and len(axes_list) == 2: - # Recovering the axis requested by the user as they will be soft frozen (possible to switch but not possible to choose another axis) - axes_list_name = [ax.name for ax in axes_list] - axes_soft_frozen = [ - ax for ax in self.axes_list if ax.name in axes_list_name - ] - - # We update the WAxisSelector widget with the axes that will be soft frozen - self.w_axis_1.update(axes_soft_frozen) - self.w_axis_2.update(axes_soft_frozen) - - self.axis_1_updated() - - elif frozen_type == 2: - # If we want to hard freeze the axis, we just have to disable the axis comboboxes - self.w_axis_1.c_axis.setDisabled(True) - self.w_axis_2.c_axis.setDisabled(True) - - elif frozen_type == 3: - # Freezing the axes - self.w_axis_1.c_axis.setDisabled(True) - self.w_axis_1.c_action.setDisabled(True) - self.w_axis_2.c_axis.setDisabled(True) - self.w_axis_2.c_action.setDisabled(True) - - # Freezing the operations (allowing only slice and requested ope) - for w_slice in self.w_slice_op: - current_ope = w_slice.c_operation.currentText() - if current_ope not in ["slice", "overlay"]: - w_slice.c_operation.blockSignals(True) - w_slice.c_operation.clear() - w_slice.c_operation.addItems(["slice", current_ope]) - w_slice.c_operation.setCurrentIndex(1) - w_slice.c_operation.blockSignals(False) - else: - w_slice.c_operation.setDisabled(True) - # w_slice.lf_value.setDisabled(True) - # w_slice.slider.setDisabled(True) - - elif frozen_type == 4: - self.w_axis_1.c_axis.setDisabled(True) - self.w_axis_2.c_axis.setDisabled(True) - if axes_list[0].name in ifft_dict or axes_list[0].name in fft_dict: - self.w_axis_1.c_action.setDisabled(True) - if len(axes_list) == 2 and ( - axes_list[1].name in ifft_dict or axes_list[0].name in fft_dict - ): - self.w_axis_2.c_action.setDisabled(True) - - elif frozen_type == 5: - # Freezing the axes - self.w_axis_1.c_action.setDisabled(True) - self.w_axis_2.c_action.setDisabled(True) - - # Freezing the operations - for w_slice in self.w_slice_op: - w_slice.b_action.setDisabled(True) - w_slice.c_operation.setDisabled(True) - w_slice.lf_value.setDisabled(True) - w_slice.slider.setDisabled(True) - - elif frozen_type == 6: - # Freezing the axes - self.w_axis_1.c_axis.setDisabled(True) - self.w_axis_1.c_action.setDisabled(True) - self.w_axis_2.c_axis.setDisabled(True) - self.w_axis_2.c_action.setDisabled(True) - - # Freezing the operations - for w_slice in self.w_slice_op: - w_slice.c_operation.setDisabled(True) - w_slice.lf_value.setDisabled(True) - w_slice.slider.setDisabled(True) - - if len(axes_list) == 1: - self.w_axis_2.hide() - - self.w_axis_1.blockSignals(False) - self.w_axis_2.blockSignals(False) - - def set_slice_op(self, user_input_list): - """Method that set the right operation inside each WSliceOperator inside of w_slice_op - according to user input (auto plot). - Parameters - ---------- - self : WAxisManager - a WAxisManager object - user_input_list : list - list of the inputs from the user to set the DataSelection (auto-plot) - """ - for wid in self.w_slice_op: - if self.w_slice_op.index(wid) < len(user_input_list): - wid.set_operation(user_input_list[self.w_slice_op.index(wid)]) - - def update_needed(self): - """Method that emits a signal (refreshNeeded) that will be used to automaticaly update the plot inside the GUI. - This signal is triggered by other signals comming from WSliceOperator or WAxisSelector. - refreshRange is a different signal that we use to update the values of min and max inside w_range - Parameters - ---------- - self : WAxisManager - a WAxisManager object - """ - - self.refreshRange.emit() - self.refreshNeeded.emit() - - def update_forced(self): - """Method that emits a signal (refreshNeeded) that will be used to automaticaly update the plot inside the GUI. - This signal is triggered by other signals comming from WSliceOperator or WAxisSelector. - refreshRange is a different signal that we use to update the values of min and max inside w_range - Parameters - ---------- - self : WAxisManager - a WAxisManager object - """ - - self.refreshRange.emit() - self.refreshForced.emit() diff --git a/SciDataTool/GUI/WAxisManager/WAxisManager.ui b/SciDataTool/GUI/WAxisManager/WAxisManager.ui deleted file mode 100644 index 9e3a4514..00000000 --- a/SciDataTool/GUI/WAxisManager/WAxisManager.ui +++ /dev/null @@ -1,216 +0,0 @@ - - - WAxisManager - - - - 0 - 0 - 461 - 266 - - - - WAxisManager - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Axes Selection - - - - 4 - - - 5 - - - 0 - - - 5 - - - 0 - - - - - - - - 0 - 24 - - - - - - - - - - - - 0 - 18 - - - - Axis - - - - - - - - 0 - 20 - - - - Action - - - - - - - - 0 - 0 - - - - - 0 - 18 - - - - Unit - - - - - - - - 0 - 23 - - - - - - - - - - - - - - 0 - 0 - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - - - - - - 0 - 0 - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Axes Operations - - - - - - - - - WAxisSelector - QWidget -
SciDataTool.GUI.WAxisSelector.WAxisSelector.h
- 1 -
-
- - -
diff --git a/SciDataTool/GUI/WAxisManager/__init__.py b/SciDataTool/GUI/WAxisManager/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/SciDataTool/GUI/WAxisSelector/Ui_WAxisSelector.py b/SciDataTool/GUI/WAxisSelector/Ui_WAxisSelector.py deleted file mode 100644 index eac0326a..00000000 --- a/SciDataTool/GUI/WAxisSelector/Ui_WAxisSelector.py +++ /dev/null @@ -1,95 +0,0 @@ -# -*- coding: utf-8 -*- - -# File generated according to WAxisSelector.ui -# WARNING! All changes made in this file will be lost! -## WARNING! All changes made in this file will be lost when recompiling UI file! -################################################################################ - -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * - - -class Ui_WAxisSelector(object): - def setupUi(self, WAxisSelector): - if not WAxisSelector.objectName(): - WAxisSelector.setObjectName(u"WAxisSelector") - WAxisSelector.resize(152, 160) - self.verticalLayout = QVBoxLayout(WAxisSelector) - self.verticalLayout.setObjectName(u"verticalLayout") - self.in_name = QLabel(WAxisSelector) - self.in_name.setObjectName(u"in_name") - sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.in_name.sizePolicy().hasHeightForWidth()) - self.in_name.setSizePolicy(sizePolicy) - self.in_name.setMinimumSize(QSize(0, 0)) - self.in_name.setMaximumSize(QSize(16777215, 16777215)) - self.in_name.setAlignment(Qt.AlignCenter) - - self.verticalLayout.addWidget(self.in_name) - - self.c_axis = QComboBox(WAxisSelector) - self.c_axis.setObjectName(u"c_axis") - sizePolicy.setHeightForWidth(self.c_axis.sizePolicy().hasHeightForWidth()) - self.c_axis.setSizePolicy(sizePolicy) - self.c_axis.setMinimumSize(QSize(0, 0)) - self.c_axis.setMaximumSize(QSize(16777215, 16777215)) - - self.verticalLayout.addWidget(self.c_axis) - - self.c_action = QComboBox(WAxisSelector) - self.c_action.addItem("") - self.c_action.addItem("") - self.c_action.addItem("") - self.c_action.setObjectName(u"c_action") - sizePolicy.setHeightForWidth(self.c_action.sizePolicy().hasHeightForWidth()) - self.c_action.setSizePolicy(sizePolicy) - self.c_action.setMinimumSize(QSize(0, 0)) - self.c_action.setMaximumSize(QSize(16777215, 16777215)) - - self.verticalLayout.addWidget(self.c_action) - - self.c_unit = QComboBox(WAxisSelector) - self.c_unit.setObjectName(u"c_unit") - sizePolicy.setHeightForWidth(self.c_unit.sizePolicy().hasHeightForWidth()) - self.c_unit.setSizePolicy(sizePolicy) - self.c_unit.setMinimumSize(QSize(0, 0)) - self.c_unit.setMaximumSize(QSize(16777215, 16777215)) - - self.verticalLayout.addWidget(self.c_unit) - - self.b_filter = QPushButton(WAxisSelector) - self.b_filter.setObjectName(u"b_filter") - sizePolicy.setHeightForWidth(self.b_filter.sizePolicy().hasHeightForWidth()) - self.b_filter.setSizePolicy(sizePolicy) - self.b_filter.setMinimumSize(QSize(0, 0)) - self.b_filter.setMaximumSize(QSize(16777215, 16777215)) - - self.verticalLayout.addWidget(self.b_filter) - - self.retranslateUi(WAxisSelector) - - QMetaObject.connectSlotsByName(WAxisSelector) - - # setupUi - - def retranslateUi(self, WAxisSelector): - WAxisSelector.setWindowTitle("") - self.in_name.setText(QCoreApplication.translate("WAxisSelector", u"X", None)) - self.c_action.setItemText( - 0, QCoreApplication.translate("WAxisSelector", u"None", None) - ) - self.c_action.setItemText( - 1, QCoreApplication.translate("WAxisSelector", u"FFT", None) - ) - self.c_action.setItemText( - 2, QCoreApplication.translate("WAxisSelector", u"Filter", None) - ) - - self.b_filter.setText( - QCoreApplication.translate("WAxisSelector", u"Filter", None) - ) - - # retranslateUi diff --git a/SciDataTool/GUI/WAxisSelector/WAxisSelector.py b/SciDataTool/GUI/WAxisSelector/WAxisSelector.py deleted file mode 100644 index b7dbcfba..00000000 --- a/SciDataTool/GUI/WAxisSelector/WAxisSelector.py +++ /dev/null @@ -1,530 +0,0 @@ -from PySide2.QtWidgets import QWidget - -from SciDataTool.GUI.WAxisSelector.Ui_WAxisSelector import Ui_WAxisSelector -from SciDataTool.GUI.WFilter.WFilter import WFilter -from PySide2.QtCore import Signal -from SciDataTool.Functions.Plot import ( - unit_dict, - norm_name_dict, - axis_norm_dict, - axes_dict, - fft_dict, - ifft_dict, -) -from SciDataTool.GUI import update_cb_enable -from SciDataTool.Functions.Load.import_class import import_class - - -class WAxisSelector(Ui_WAxisSelector, QWidget): - """Widget to select the axis to plot""" - - refreshNeeded = Signal() - refreshForced = Signal() - axisChanged = Signal() - actionChanged = Signal() - - def __init__(self, parent=None, path_to_image=None): - """Initialize the arguments, linking the buttons and setting up the UI - - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - parent : QWidget - The parent widget - """ - - # Build the interface according to the .ui file - QWidget.__init__(self, parent) - self.setupUi(self) - - self.name = "X" # Name of the axis - self.axes_list = list() # List of the different axes of the DataND object - self.norm_list = None # List of available normalizations for each axis - self.indices = None - self.path_to_image = path_to_image - - self.axis_selected = "None" # Name of the axis selected (time, angle...) - self.norm = None # Name of the unit of the axis (s,m...) - self.b_filter.setEnabled(False) - self.current_dialog = None - - self.c_axis.currentTextChanged.connect(self.update_axis) - self.c_action.currentTextChanged.connect(self.update_action) - self.c_unit.currentTextChanged.connect(self.update_unit) - self.b_filter.clicked.connect(self.open_filter) - - def get_axes_name(self): - """Method that return the axes that can be selected - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - Output - --------- - list - name of the axes avalaible - """ - return self.axes_list - - def get_axis_unit_selected(self): - """Method that return the axis and the unit currently selected so that we can use it in the plot method - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - Output - --------- - string - name of the current axis and unit selected in the right format - """ - - axis_unit_selected = self.get_axis_selected() - - # Add indices if necessary - if self.get_current_action_name() == "Filter": - if self.indices is not None: - axis_unit_selected += str(self.indices) - else: - axis_unit_selected += "[]" - - if self.norm is not None: # Add normalization - axis_unit_selected += "{" + self.norm + "}" - - elif axis_unit_selected != "None": # adding unit - axis_unit_selected += "{" + self.c_unit.currentText() + "}" - - return axis_unit_selected - - def get_current_action_name(self): - """Method that return the action currently selected - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - Output - --------- - string - name of the current action selected - """ - return self.c_action.currentText() - - def get_axis_selected(self): - """Method that return the name of the axis selected of the WAxisSelector - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - Output - --------- - string - name of the axis selected - """ - if self.c_axis.currentText() == "None": - return "None" - else: - return self.axis_selected - - def open_filter(self): - """Open the Filter widget""" - # Close previous dialog - if self.current_dialog is not None: - self.current_dialog.close() - self.current_dialog.setParent(None) - self.current_dialog = None - - axis_selected_obj = [ - ax for ax in self.axes_list_obj if ax.name == self.axis_selected - ][0] - - self.current_dialog = WFilter( - axis_selected_obj, - self.indices, - path_to_image=self.path_to_image, - ) - self.current_dialog.refreshNeeded.connect(self.update_indices) - self.current_dialog.show() - - def update_indices(self): - self.indices = self.current_dialog.indices - self.refreshForced.emit() - - def remove_axis(self, axis_to_remove): - """Method that remove a given axis from the axis ComboBox. - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - axis_to_remove : string - name of the axis to remove from c_axis - - """ - # if the axis to remove is wavenumber of freqs then we have to remove angle or time - if axis_to_remove in ifft_dict: - axis_to_remove = ifft_dict[axis_to_remove] - - if axis_to_remove in self.axes_list: - axes_list = self.axes_list.copy() # Getting the axes available - axes_list.remove(axis_to_remove) # Removing the axis selected - - # Building the new ComboBox - self.c_axis.blockSignals(True) - index = 0 - if self.c_axis.currentText() != "None": - index = self.c_axis.currentIndex() - self.c_axis.clear() - - for ax in axes_list: - if ax in axes_dict: - self.c_axis.addItem(axes_dict[ax]) - else: - self.c_axis.addItem(ax) - - update_cb_enable(self.c_axis) - self.c_axis.setCurrentIndex(index) - self.c_axis.blockSignals(False) - - self.update_axis(is_refresh=True) - - def set_axis(self, axis): - """Method that will set the comboboxes to have the axis given as an input when calling the plot method (auto-plot). - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - axis : RequestedAxis - axis that we want to have in the WAxisSelector - """ - self.blockSignals(True) - self.indices = axis.indices - # Step 1 : Getting the name of the axis and selecting the right combobox (axis and action) - axis_name = axis.name - - # If the axis is freqs or wavenumber, then we have to select time/angle and fft - if axis_name in ifft_dict: - # Selecting the right axis - self.c_axis.setCurrentIndex(self.c_axis.findText(ifft_dict[axis_name])) - # Making sure that we select FFT - self.c_action.setCurrentIndex(1) - else: - # Selecting the right axis - if axis_name in axes_dict: - self.c_axis.setCurrentIndex(self.c_axis.findText(axes_dict[axis_name])) - else: - self.c_axis.setCurrentIndex(self.c_axis.findText(axis_name)) - - # Step 2 : Recovering the unit and setting the combobox according to it - unit_name = axis.unit - self.c_unit.blockSignals(True) - self.set_unit() - if self.c_unit.findText(unit_name) != -1: - self.c_unit.setCurrentIndex(self.c_unit.findText(unit_name)) - elif unit_name in unit_dict: - self.c_unit.setCurrentIndex(self.c_unit.findText(unit_dict[unit_name])) - elif unit_name in norm_name_dict: - self.c_unit.setCurrentIndex(self.c_unit.findText(norm_name_dict[unit_name])) - elif unit_name == "SI": - self.c_unit.setCurrentIndex(0) - else: - self.c_unit.setCurrentIndex(self.c_unit.findText(unit_name)) - self.c_unit.blockSignals(False) - - self.blockSignals(False) - - def set_axis_options(self, axes_list): - """Method that will put the axes of data in the combobox of the widget - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - axes_list : list - A list of axis object from the Data object that we want to plot - - """ - # Dynamic import to avoid import loop - DataPattern = import_class("SciDataTool.Classes", "DataPattern") - - self.c_axis.blockSignals(True) - # Step 1 : Getting the name of the different axes of the DataND object - self.axes_list = [ - axis.name - for axis in axes_list - if axis.is_overlay == False - and not (isinstance(axis, DataPattern) and len(axis.unique_indices) == 1) - ] # Remove overlay axes + slice axes with single slice - self.norm_list = [ - list(axis.normalizations.keys()) - for axis in axes_list - if axis.is_overlay == False - and not (isinstance(axis, DataPattern) and len(axis.unique_indices) == 1) - ] - - # Adding a safety, so that we cannot have frequency or wavenumber inside axes_list (we should have time and angle instead) - for i in range(len(self.axes_list)): - if self.axes_list[i] in ifft_dict: - self.axes_list[i] = ifft_dict[self.axes_list[i]] - - # At least one axis must be selected => impossible to have none for X axis - if self.name.lower() != "x": - self.axes_list.insert(0, "None") - self.norm_list.insert(0, None) - - # Step 2 : Replacing the items inside of the ComboBox with the axes recovered - self.c_axis.clear() - for ax in self.axes_list: - if ax in ifft_dict: - self.c_axis.addItem(ifft_dict[ax]) - else: - if ax in axes_dict: - self.c_axis.addItem(axes_dict[ax]) - else: - self.c_axis.addItem(ax) - - update_cb_enable(self.c_axis) - self.c_axis.blockSignals(False) - - # Step 3 : Modifying axis_selected - if self.c_axis.currentText() in [axes_dict[key] for key in axes_dict]: - self.axis_selected = [key for key in axes_dict][ - [axes_dict[key] for key in axes_dict].index(self.c_axis.currentText()) - ] - else: - self.axis_selected = self.c_axis.currentText() - - self.c_axis.view().setMinimumWidth(max([len(ax) for ax in self.axes_list]) * 6) - - if self.c_axis.currentText() == "None": - self.c_action.setDisabled(True) - else: - self.c_action.setDisabled(False) - - def set_name(self, axis_name): - """Method to change of the label of the widget - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - axis_name : string - string that we will use to set the in_name of the widget - - """ - - self.name = axis_name - self.in_name.setText(axis_name) - - def set_action(self, action): - """Method that set the action of the WAxisSelector - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - action : string - name of the new action""" - - action_list = [self.c_action.itemText(i) for i in range(self.c_action.count())] - self.c_action.blockSignals(True) - if action in action_list and action != "Filter": - self.c_action.setCurrentIndex(action_list.index(action)) - self.c_action.blockSignals(False) - - def set_unit(self, is_refresh=True): - """Method that update the unit comboxbox according to the axis selected in the other combobox. - We can also give the axis selected and put its units inside the combobox - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - """ - self.c_unit.blockSignals(True) - # Adding the right units according to a dictionnary - if self.axis_selected == "None": - # If the axis is not selected, then we can not choose the unit - self.c_unit.clear() - self.c_unit.setDisabled(True) - else: - unit_index = self.c_unit.currentIndex() - self.c_unit.setDisabled(False) - self.c_unit.clear() - - # Adding the axis unit + available normalizations - if self.axis_selected in unit_dict: - self.c_unit.addItem(unit_dict[self.axis_selected]) - norms = self.norm_list[self.axes_list.index(self.axis_selected)] - norm_id = None - if norms is not None: - for norm in norms: - if norm in axis_norm_dict[self.axis_selected]: - self.c_unit.addItem(norm_name_dict[norm]) # Add longer names - if "_id" in norm: - norm_id = norm_name_dict[norm] - - # Use tooth index as only normalization - if norm_id is not None: - self.c_unit.clear() - self.c_unit.addItem(norm_id) - - # Modifying the size of the list according to the units available (adapting it when normalization) - cb_width = 0 - for idx_unit in range(self.c_unit.count()): - self.c_unit.setCurrentIndex(idx_unit) - if len(self.c_unit.currentText()) > cb_width: - cb_width = len(self.c_unit.currentText()) - if unit_index != -1: - if unit_index >= self.c_unit.count(): - unit_index = 0 - self.c_unit.setCurrentIndex(unit_index) - - self.c_unit.view().setMinimumWidth(cb_width * 8) - - update_cb_enable(self.c_unit) - self.c_unit.blockSignals(False) - self.update_unit(is_refresh=is_refresh) - - def update(self, axes_list, axis_name="X"): - """Method used to update the widget by calling the other method for the label, the axes and the units - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - axes_list : list - A list of axis object from the Data object that we want to plot - axis_name : string - string that will set the text of in_name (=name of the axis) - """ - self.axes_list_obj = axes_list - self.set_name(axis_name) - self.set_axis_options(axes_list) - self.update_axis() - self.set_unit() - - def update_axis(self, text=None, is_refresh=True): - """Method called when an axis is changed that change axis_selected, the units available and the action combobox. - It will also emit a signal used in WAxisManager. - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - """ - self.c_action.blockSignals(True) - if is_refresh: - self.c_action.setCurrentIndex(0) - - if self.c_axis.currentText() == "None": - self.c_action.setDisabled(True) - else: - self.c_action.setDisabled(False) - - # Updating the units and the axis selected - # Making sure that self.axis_selected is a "tag" and not a "label". Example : z instead of axial direction - if self.c_axis.currentText() in [axes_dict[key] for key in axes_dict]: - self.axis_selected = [key for key in axes_dict][ - [axes_dict[key] for key in axes_dict].index(self.c_axis.currentText()) - ] - else: - self.axis_selected = self.c_axis.currentText() - - if not is_refresh: - self.set_unit() - - # Updating the action combobox - # Handling specific case to disable certain parts of the GUI - if self.c_axis.currentText() == "None": - self.c_action.setDisabled(True) - else: - self.c_action.setDisabled(False) - - if self.axis_selected in fft_dict: - action = ["None", "FFT"] - elif ( - self.axis_selected in [axis.name for axis in self.axes_list_obj] - and self.axes_list_obj[ - [axis.name for axis in self.axes_list_obj].index(self.axis_selected) - ].is_components - ): - action = ["None", "Filter"] - else: - action = ["None"] - self.c_action.clear() - self.c_action.addItems(action) - update_cb_enable(self.c_action) - self.c_action.blockSignals(False) - - self.c_action.view().setMinimumWidth(max([len(ac) for ac in action]) * 6) - - if "Filter" in action: - self.b_filter.show() - else: - sp_retain = self.b_filter.sizePolicy() - sp_retain.setRetainSizeWhenHidden(True) - self.b_filter.setSizePolicy(sp_retain) - self.b_filter.hide() - - # Emitting the signals - if is_refresh: - self.axisChanged.emit() - - def update_action(self): - """Method called when an action is changed that will change axis_selected, - update the units available and emit a signal. - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - - """ - # If the action selected is filter, then we enable the button - if self.c_action.currentText() == "Filter": - self.b_filter.setEnabled(True) - - else: - self.b_filter.setEnabled(False) - - # Converting the axes according to action selected if possible/necessary - if self.c_action.currentText() == "FFT" and self.axis_selected in fft_dict: - self.axes_list.insert( - self.axes_list.index(self.axis_selected), fft_dict[self.axis_selected] - ) - self.axes_list.remove(self.axis_selected) - self.axis_selected = fft_dict[self.axis_selected] - - elif self.c_action.currentText() == "None" and self.axis_selected in ifft_dict: - self.axes_list.insert( - self.axes_list.index(self.axis_selected), ifft_dict[self.axis_selected] - ) - self.axes_list.remove(self.axis_selected) - self.axis_selected = ifft_dict[self.axis_selected] - - # Handling the case where axis_selected is updated but axes_list is not - # We check if fft(axis_selected) is in the list and when it is the case we replace it by axis_selected - if not self.axis_selected in self.axes_list: - if fft_dict[self.axis_selected] in self.axes_list: - self.axes_list.insert( - self.axes_list.index(fft_dict[self.axis_selected]), - self.axis_selected, - ) - self.axes_list.remove(fft_dict[self.axis_selected]) - - # Now that the quantiy has been updated according to the action, we can set the units and emit the signals - self.set_unit(is_refresh=False) - - self.actionChanged.emit() - - def update_unit(self, is_refresh=True): - """Method called when a new unit is selected so that we can update self.norm - Parameters - ---------- - self : WAxisSelector - a WAxisSelector object - - """ - normalization = self.c_unit.currentText() - is_match = False - # Replace normalization title with normalization name - for norm in norm_name_dict: - if normalization == norm_name_dict[norm]: - self.norm = norm - is_match = True - if not is_match: - self.norm = None - if is_refresh: - self.refreshNeeded.emit() diff --git a/SciDataTool/GUI/WAxisSelector/WAxisSelector.ui b/SciDataTool/GUI/WAxisSelector/WAxisSelector.ui deleted file mode 100644 index 5ef06db3..00000000 --- a/SciDataTool/GUI/WAxisSelector/WAxisSelector.ui +++ /dev/null @@ -1,155 +0,0 @@ - - - WAxisSelector - - - - 0 - 0 - 152 - 160 - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - X - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - None - - - - - FFT - - - - - Filter - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Filter - - - - - - - - diff --git a/SciDataTool/GUI/WAxisSelector/__init__.py b/SciDataTool/GUI/WAxisSelector/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/SciDataTool/GUI/WDataRange/Ui_WDataRange.py b/SciDataTool/GUI/WDataRange/Ui_WDataRange.py deleted file mode 100644 index 181ad433..00000000 --- a/SciDataTool/GUI/WDataRange/Ui_WDataRange.py +++ /dev/null @@ -1,110 +0,0 @@ -# -*- coding: utf-8 -*- - -# File generated according to WDataRange.ui -# WARNING! All changes made in this file will be lost! -## WARNING! All changes made in this file will be lost when recompiling UI file! -################################################################################ - -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * - -from SciDataTool.GUI.Tools.FloatEdit import FloatEdit - - -class Ui_WDataRange(object): - def setupUi(self, WDataRange): - if not WDataRange.objectName(): - WDataRange.setObjectName(u"WDataRange") - WDataRange.resize(300, 163) - self.gridLayout_2 = QGridLayout(WDataRange) - self.gridLayout_2.setObjectName(u"gridLayout_2") - self.g_range = QGroupBox(WDataRange) - self.g_range.setObjectName(u"g_range") - sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.g_range.sizePolicy().hasHeightForWidth()) - self.g_range.setSizePolicy(sizePolicy) - self.g_range.setMinimumSize(QSize(0, 0)) - self.g_range.setMaximumSize(QSize(16777215, 16777215)) - self.gridLayout = QGridLayout(self.g_range) - self.gridLayout.setObjectName(u"gridLayout") - self.in_unit = QLabel(self.g_range) - self.in_unit.setObjectName(u"in_unit") - - self.gridLayout.addWidget(self.in_unit, 0, 0, 1, 1) - - self.c_unit = QComboBox(self.g_range) - self.c_unit.setObjectName(u"c_unit") - self.c_unit.setMinimumSize(QSize(0, 20)) - - self.gridLayout.addWidget(self.c_unit, 0, 1, 1, 1) - - self.in_min = QLabel(self.g_range) - self.in_min.setObjectName(u"in_min") - - self.gridLayout.addWidget(self.in_min, 1, 0, 1, 1) - - self.lf_min = FloatEdit(self.g_range) - self.lf_min.setObjectName(u"lf_min") - sizePolicy1 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) - sizePolicy1.setHorizontalStretch(70) - sizePolicy1.setVerticalStretch(0) - sizePolicy1.setHeightForWidth(self.lf_min.sizePolicy().hasHeightForWidth()) - self.lf_min.setSizePolicy(sizePolicy1) - self.lf_min.setMinimumSize(QSize(0, 20)) - self.lf_min.setMaximumSize(QSize(70, 16777215)) - - self.gridLayout.addWidget(self.lf_min, 1, 1, 1, 1) - - self.in_max = QLabel(self.g_range) - self.in_max.setObjectName(u"in_max") - - self.gridLayout.addWidget(self.in_max, 2, 0, 1, 1) - - self.lf_max = FloatEdit(self.g_range) - self.lf_max.setObjectName(u"lf_max") - sizePolicy1.setHeightForWidth(self.lf_max.sizePolicy().hasHeightForWidth()) - self.lf_max.setSizePolicy(sizePolicy1) - self.lf_max.setMinimumSize(QSize(0, 20)) - self.lf_max.setMaximumSize(QSize(70, 16777215)) - - self.gridLayout.addWidget(self.lf_max, 2, 1, 1, 1) - - self.in_norm = QLabel(self.g_range) - self.in_norm.setObjectName(u"in_norm") - - self.gridLayout.addWidget(self.in_norm, 3, 0, 1, 1) - - self.lf_norm = FloatEdit(self.g_range) - self.lf_norm.setObjectName(u"lf_norm") - sizePolicy1.setHeightForWidth(self.lf_norm.sizePolicy().hasHeightForWidth()) - self.lf_norm.setSizePolicy(sizePolicy1) - self.lf_norm.setMinimumSize(QSize(0, 20)) - self.lf_norm.setMaximumSize(QSize(70, 16777215)) - - self.gridLayout.addWidget(self.lf_norm, 3, 1, 1, 1) - - self.gridLayout_2.addWidget(self.g_range, 0, 0, 1, 1) - - self.retranslateUi(WDataRange) - - QMetaObject.connectSlotsByName(WDataRange) - - # setupUi - - def retranslateUi(self, WDataRange): - WDataRange.setWindowTitle("") - self.g_range.setTitle(QCoreApplication.translate("WDataRange", u"Range", None)) - self.in_unit.setText(QCoreApplication.translate("WDataRange", u"unit", None)) - self.in_min.setText(QCoreApplication.translate("WDataRange", u"min", None)) - self.lf_min.setText(QCoreApplication.translate("WDataRange", u"0.314", None)) - self.in_max.setText(QCoreApplication.translate("WDataRange", u"max", None)) - self.lf_max.setText(QCoreApplication.translate("WDataRange", u"0.314", None)) - self.in_norm.setText( - QCoreApplication.translate("WDataRange", u"reference value", None) - ) - self.lf_norm.setText(QCoreApplication.translate("WDataRange", u"0.314", None)) - - # retranslateUi diff --git a/SciDataTool/GUI/WDataRange/WDataRange.py b/SciDataTool/GUI/WDataRange/WDataRange.py deleted file mode 100644 index f90e1155..00000000 --- a/SciDataTool/GUI/WDataRange/WDataRange.py +++ /dev/null @@ -1,202 +0,0 @@ -from PySide2.QtWidgets import QWidget -import matplotlib.pyplot as plt - -from SciDataTool.GUI.WDataRange.Ui_WDataRange import Ui_WDataRange -from PySide2.QtCore import Signal -from SciDataTool.Functions import parser -from SciDataTool.GUI import update_cb_enable -from SciDataTool.Classes.Norm_ref import Norm_ref - - -class WDataRange(Ui_WDataRange, QWidget): - """Widget to select the Data/output range""" - - refreshNeeded = Signal() - - def __init__(self, parent=None): - """Linking the button with their method + initializing the arguments used - - Parameters - ---------- - self : WDataRange - a WDataRange object - parent : QWidget - The parent QWidget - """ - - # Build the interface according to the .ui file - QWidget.__init__(self, parent=parent) - self.setupUi(self) - self.name = "" - self.unit_list = list() - self.unit = None - - self.c_unit.currentTextChanged.connect(self.update_unit) - self.lf_min.editingFinished.connect(self.update_needed) - self.lf_max.editingFinished.connect(self.update_needed) - self.lf_norm.editingFinished.connect(self.update_unit) - - def get_field_selected(self): - """Method that will sent the parameters on the field selected by the user (unit and min/max) - Parameters - ---------- - self : WDataRange - a WDataRange object - Output - --------- - string - name of the action on the field - """ - - return { - "unit": self.c_unit.currentText(), - "min": self.lf_min.value(), - "max": self.lf_max.value(), - "norm": self.lf_norm.value(), - } - - def set_min_max(self): - """Method that will set the FloatEdit of the widget that are responsible for the min value and for the max value. - Parameters - ---------- - self : WDataRange - a WDataRange object - """ - - field_min = None - field_max = None - - # Get limits from figure - fig = plt.gcf() - if fig is not None: - if len(fig.axes) == 1: - field_min = fig.axes[0].get_ylim()[0] - field_max = fig.axes[0].get_ylim()[1] - else: - field_min = fig.axes[1].dataLim.extents[0] - field_max = fig.axes[1].dataLim.extents[-1] - - if field_min is not None: - is_dB = "dB" in self.unit - self.lf_min.setValue(field_min, is_dB) - self.lf_max.setValue(field_max, is_dB) - else: - self.lf_min.clear() - self.lf_max.clear() - - def set_name(self, field_name): - """Method that set the name of the widget which is the name of the field that we are plotting - - Parameters - ---------- - self : WDataRange - a WDataRange object - field : DataND - the data object that hold the field that we want to plot - """ - self.name = field_name - - def set_range(self, data, unit=None): - """Method that set the data range widget with the value from the DataND object - - Parameters - ---------- - self : WDataRange - a WDataRange object - data : DataND - the data object that hold the field that will set the widget - """ - if unit is not None: - self.unit = unit - self.set_unit(data) - if unit != "SI": # Adding unit to unit combobox - if self.c_unit.currentText() != unit: - self.c_unit.insertItem(0, unit) - if unit == "dBA" and self.c_unit.count() > 1: # Also adding dB - self.c_unit.insertItem(1, "dB") - self.c_unit.setCurrentIndex(0) - update_cb_enable(self.c_unit) - # else: - # self.set_unit(data) - self.lf_min.clear() - self.lf_max.clear() - if "ref" in data.normalizations and isinstance( - data.normalizations["ref"], Norm_ref - ): - self.lf_norm.setValue(data.normalizations["ref"].ref) - self.in_norm.show() - self.lf_norm.show() - else: - self.lf_norm.clear() - self.in_norm.hide() - self.lf_norm.hide() - - def set_range_user_input( - self, - z_min=None, - z_max=None, - ): - """Method that modify the unit selected and the floatEdit according to the inputs given by the user (auto-plot) - Parameters - ---------- - self : WDataRange - a WDataRange object - z_min : float - Minimum value for Z axis (or Y if only one axe) - z_max : float - Minimum value for Z axis (or Y if only one axe) - """ - is_dB = "dB" in self.unit - if z_max is not None: - # Setting max float edit - self.lf_max.setValue(z_max, is_dB) - if z_min is not None: - # Setting min float edit - self.lf_min.setValue(z_min, is_dB) - - def set_unit(self, field): - """Method that set the unit combobox according to the unit of the field that we are plotting - - Parameters - ---------- - self : WDataRange - a WDataRange object - data : DataND - the data object that hold the field that we want to plot - """ - - # # Updating the unit combobox - self.c_unit.clear() - self.c_unit.addItem(field.unit) - update_cb_enable(self.c_unit) - self.unit = field.unit - - def update_unit(self): - """Method that clears min/max then calls update_needed - Parameters - ---------- - self : WDataRange - a WDataRange object - """ - self.lf_max.clear() - self.lf_min.clear() - self.update_needed() - - def update_needed(self): - """Method that emit a signal to automatically refresh the plot inside the GUI - Parameters - ---------- - self : WDataRange - a WDataRange object - """ - # Making sure that we always have min < max - if self.lf_min.value() != None and self.lf_max.value() != None: - if self.lf_min.value() > self.lf_max.value(): - is_dB = "dB" in self.unit - self.blockSignals(True) - temp = self.lf_max.value() - self.lf_max.setValue(self.lf_min.value(), is_dB) - self.lf_min.setValue(temp, is_dB) - self.blockSignals(False) - - self.refreshNeeded.emit() diff --git a/SciDataTool/GUI/WDataRange/WDataRange.ui b/SciDataTool/GUI/WDataRange/WDataRange.ui deleted file mode 100644 index 6b6f2254..00000000 --- a/SciDataTool/GUI/WDataRange/WDataRange.ui +++ /dev/null @@ -1,168 +0,0 @@ - - - WDataRange - - - - 0 - 0 - 300 - 163 - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Range - - - - - - unit - - - - - - - - 0 - 20 - - - - - - - - min - - - - - - - - 70 - 0 - - - - - 0 - 20 - - - - - 70 - 16777215 - - - - 0.314 - - - - - - - max - - - - - - - - 70 - 0 - - - - - 0 - 20 - - - - - 70 - 16777215 - - - - 0.314 - - - - - - - reference value - - - - - - - - 70 - 0 - - - - - 0 - 20 - - - - - 70 - 16777215 - - - - 0.314 - - - - - - - - - - - FloatEdit - QLineEdit -
SciDataTool.GUI/Tools/FloatEdit.h
-
-
- - -
diff --git a/SciDataTool/GUI/WDataRange/__init__.py b/SciDataTool/GUI/WDataRange/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/SciDataTool/GUI/WFilter/Ui_WFilter.py b/SciDataTool/GUI/WFilter/Ui_WFilter.py deleted file mode 100644 index 12f1e124..00000000 --- a/SciDataTool/GUI/WFilter/Ui_WFilter.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- - -# File generated according to WFilter.ui -# WARNING! All changes made in this file will be lost! -## WARNING! All changes made in this file will be lost when recompiling UI file! -################################################################################ - -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * - -from SciDataTool.GUI.Tools.CheckBox import CheckBox - - -class Ui_WFilter(object): - def setupUi(self, WFilter): - if not WFilter.objectName(): - WFilter.setObjectName(u"WFilter") - WFilter.resize(831, 644) - WFilter.setMinimumSize(QSize(630, 470)) - WFilter.setMaximumSize(QSize(16777215, 16777215)) - self.gridLayout = QGridLayout(WFilter) - self.gridLayout.setObjectName(u"gridLayout") - self.tab_indices = QTableView(WFilter) - self.tab_indices.setObjectName(u"tab_indices") - - self.gridLayout.addWidget(self.tab_indices, 0, 0, 1, 1) - - self.cb_all = CheckBox(WFilter) - self.cb_all.setObjectName(u"cb_all") - self.cb_all.setTristate(True) - - self.gridLayout.addWidget(self.cb_all, 1, 0, 1, 1) - - self.horizontalLayout = QHBoxLayout() - self.horizontalLayout.setObjectName(u"horizontalLayout") - self.horizontalSpacer = QSpacerItem( - 40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum - ) - - self.horizontalLayout.addItem(self.horizontalSpacer) - - self.b_Ok = QPushButton(WFilter) - self.b_Ok.setObjectName(u"b_Ok") - - self.horizontalLayout.addWidget(self.b_Ok) - - self.b_cancel = QPushButton(WFilter) - self.b_cancel.setObjectName(u"b_cancel") - - self.horizontalLayout.addWidget(self.b_cancel) - - self.gridLayout.addLayout(self.horizontalLayout, 2, 0, 1, 1) - - self.retranslateUi(WFilter) - - QMetaObject.connectSlotsByName(WFilter) - - # setupUi - - def retranslateUi(self, WFilter): - WFilter.setWindowTitle(QCoreApplication.translate("WFilter", u"WFilter", None)) - self.cb_all.setText( - QCoreApplication.translate("WFilter", u"Select/Deselect all", None) - ) - self.b_Ok.setText(QCoreApplication.translate("WFilter", u"Ok", None)) - self.b_cancel.setText(QCoreApplication.translate("WFilter", u"Cancel", None)) - - # retranslateUi diff --git a/SciDataTool/GUI/WFilter/WFilter.py b/SciDataTool/GUI/WFilter/WFilter.py deleted file mode 100644 index f2203b0c..00000000 --- a/SciDataTool/GUI/WFilter/WFilter.py +++ /dev/null @@ -1,380 +0,0 @@ -from PySide2.QtWidgets import ( - QWidget, - QStyle, - QStyledItemDelegate, - QStyleOptionButton, - QApplication, - QCheckBox, - QHeaderView, -) -from PySide2.QtCore import Qt, QEvent, QPoint, QRect -from PySide2.QtGui import QStandardItemModel, QStandardItem, QPixmap, QIcon -from PySide2.QtCore import Signal, QSortFilterProxyModel, QSize - -from numpy import array, argsort - -from SciDataTool.GUI.WFilter.Ui_WFilter import Ui_WFilter -from SciDataTool.Functions.Plot import axes_dict - -# Column id -VALUE_COL = 0 -PLOT_COL = 1 - - -class WFilter(Ui_WFilter, QWidget): - """Widget to select the Data/output range""" - - refreshNeeded = Signal() - - def __init__(self, axis, indices=None, parent=None, path_to_image=None): - """Linking the button with their method + initializing the arguments used - - Parameters - ---------- - self : WDataRange - a WDataRange object - parent : QWidget - The parent QWidget - """ - - # Build the interface according to the .ui file - QWidget.__init__(self, parent=parent) - self.setupUi(self) - - self.axis = axis - self.indices = indices - self.axis_values = self.axis.get_values() - self.path_to_image = path_to_image - self.init_table() - - if self.axis.name in axes_dict: - self.setWindowTitle("Filtering on " + axes_dict[self.axis.name]) - else: - self.setWindowTitle("Filtering on " + self.axis.name) - - self.cb_all.stateChanged.connect(self.select_all) - self.b_Ok.clicked.connect(self.update_and_close) - self.b_cancel.clicked.connect(self.cancel_and_close) - - def select_all(self): - for i in range(self.tab_indices.model().rowCount()): - # Check all checkboxes - self.tab_indices.model().data( - self.tab_indices.model().index( - i, self.tab_indices.model().columnCount() - 1 - ) - ).setCheckState(self.cb_all.checkState()) - - def cancel_and_close(self): - """Method called when the user click on the cancel button - Parameters - ---------- - self : WDataRange - a WDataRange object - """ - - self.close() - - def init_table(self): - """Method that fill the table with the values of the axis, each line corresponds to one index - Parameters - ---------- - self : WDataRange - a WDataRange object""" - self.tab_indices.setSortingEnabled(True) - - if self.axis.is_components: - # If we have an axis with components, then we use the filters to build the complete table - if hasattr(self.axis, "filter") and self.axis.filter is not None: - filter_list = list(self.axis.filter.keys()) - else: - ncol = len(self.axis_values[0].split(self.axis.delimiter)) - filter_list = ["" for i in range(ncol)] - if ( - hasattr(self.axis, "sort_indices") - and self.axis.sort_indices is not None - ): - filter_list.append("Rank") - filter_list.append("Plot") # Adding the column with checkbox - - # Prepare strings - data = [] - for i, value in enumerate(self.axis_values): - data_i = [] - elems = value.split(self.axis.delimiter) - for j, elem in enumerate(elems): - string = elem.replace(filter_list[j] + "=", "") - if " [" in string: - if i == len(self.axis_values) - 1: - filter_list[j] = ( - filter_list[j] + " [" + string.split(" [")[1] - ).replace(" (failed)", "") - if "failed" in string: - string = string.split(" [")[0] + " (failed)" - else: - string = string.split(" [")[0] - if self.axis.char_to_rm is not None: - for char in self.axis.char_to_rm: - string = string.replace(char, "") - try: - string = float(string) - except: - pass - data_i.append(string) - if "Rank" in filter_list: - data_i.append(self.axis.sort_indices.index(i) + 1) - data.append(data_i) - - # Setting up the table - data_model = MyTableModel( - data, - filter_list, - self, - ) - for i in range(len(self.axis_values)): - item = QStandardItem() - data_model.setItem(i, len(filter_list), item) - self.tab_indices.setModel(data_model) - - self.tab_indices.setItemDelegateForColumn( - len(filter_list) - 1, - CheckBoxDelegate( - self, data_model, self.indices, self.path_to_image, self - ), - ) - - else: - # Setting up the table - data_model = MyTableModel( - array([[format(value, ".4g") for value in self.axis_values]]).T, - ["Value", "Plot?"], - self, - ) - for i in range(len(self.axis_values)): - item = QStandardItem() - data_model.setItem(i, 2, item) - self.tab_indices.setModel(data_model) - - self.tab_indices.setItemDelegateForColumn( - 1, - CheckBoxDelegate( - self, data_model, self.indices, self.path_to_image, self - ), - ) - - if self.indices is None or len(self.indices) == len(self.axis_values): - self.cb_all.setChecked(True) - - # Enable sorting - tableModel = self.tab_indices.model() - proxyModel = QSortFilterProxyModel() - proxyModel.setSourceModel(tableModel) - self.tab_indices.setModel(proxyModel) - - # Adjust column width - header = self.tab_indices.horizontalHeader() - for i in range(self.tab_indices.model().columnCount()): - header.setSectionResizeMode(i, QHeaderView.ResizeToContents) - - # Connect signal - data_model.cb_edited.connect(self.update_cb_all) - - def update_cb_all(self): - self.cb_all.blockSignals(True) - self.cb_all.setCheckState(Qt.PartiallyChecked) - self.cb_all.blockSignals(False) - - def update_and_close(self): - """Method called when the click on the Ok button - Parameters - ---------- - self : WDataRange - a WDataRange object - """ - - # Get checked indices - indices = [] - indices_ordered = [] - for i in range(self.tab_indices.model().rowCount()): - # Get checked indices - if ( - self.tab_indices.model() - .data( - self.tab_indices.model().index( - i, self.tab_indices.model().columnCount() - 1 - ) - ) - .checkState() - .__bool__() - ): # Use mapping to get indices before sorting - indices.append( - self.tab_indices.model() - .mapToSource(self.tab_indices.model().index(i, 0)) - .row() - ) - indices_ordered.append(self.tab_indices.model().index(i, 0).row()) - # Keep same order as in table - sort_idx = argsort(indices_ordered) - indices = array(indices)[sort_idx].tolist() - if indices != self.indices: - self.indices = indices - self.refreshNeeded.emit() - self.close() - - -class MyTableModel(QStandardItemModel): - cb_edited = Signal() - - def __init__(self, datain, header, parent=None): - QStandardItemModel.__init__(self, parent) - self.arraydata = datain - self.header_labels = header - - def rowCount(self, parent): - return len(self.arraydata) - - def columnCount(self, parent): - return len(self.header_labels) - - def data(self, index, role): - if role == Qt.EditRole: - return None - elif role != Qt.DisplayRole: - return None - if index.column() == self.columnCount(None) - 1: - return self.itemFromIndex(index) - else: - return self.arraydata[index.row()][index.column()] - - def headerData(self, section, orientation, role=Qt.DisplayRole): - if role == Qt.DisplayRole and orientation == Qt.Horizontal: - return self.header_labels[section] - return QStandardItemModel.headerData(self, section, orientation, role) - - def setData(self, index, value, role): - if role == Qt.EditRole: - if index.column() == self.columnCount(None) - 1: - self.itemFromIndex(index).setCheckState(Qt.CheckState(value)) - self.cb_edited.emit() - else: - super(MyTableModel, self).setData(index, value, role) - return value - - -class CheckBoxDelegate(QStyledItemDelegate): - """ - A delegate that places a fully functioning QCheckBox in every - cell of the column to which it's applied - """ - - def __init__(self, parent, model, indices=None, path_to_image=None, widget=None): - QStyledItemDelegate.__init__(self, parent) - self.model = model - self.widget = widget - self.path_to_image = path_to_image - # Check all boxes at initialization - if indices is None: - indices = [i for i in range(self.model.rowCount(None))] - for index in indices: - self.model.setData( - self.model.index(index, self.model.columnCount(None) - 1), - True, - Qt.EditRole, - ) - - def createEditor(self, parent, option, index): - """ - Important, otherwise an editor is created if the user clicks in this cell. - ** Need to hook up a signal to the model - """ - return None - - def paint(self, painter, option, index): - """ - Paint a checkbox without the label. - """ - - checked = index.data().checkState().__bool__() - check_box_style_option = QStyleOptionButton() - check_box_style_option.rect = self.getCheckBoxRect(option) - if self.path_to_image is not None: - icon = QIcon() - icon.addPixmap( - QPixmap(self.path_to_image + "/images/icon/checkbox-1-checked.png"), - QIcon.Normal, - QIcon.On, - ) - icon.addPixmap( - QPixmap(self.path_to_image + "/images/icon/checkbox-1-unchecked.png"), - QIcon.Normal, - QIcon.Off, - ) - check_box_style_option.iconSize = QSize(16, 16) - check_box_style_option.icon = icon - check_box_style_option.features = QStyleOptionButton.Flat - - if (index.flags() & Qt.ItemIsEditable) > 0: - check_box_style_option.state |= QStyle.State_Enabled - else: - check_box_style_option.state |= QStyle.State_ReadOnly - - if checked: - check_box_style_option.state |= QStyle.State_On - else: - check_box_style_option.state |= QStyle.State_Off - - # check_box_style_option.state |= QStyle.State_Enabled - - QApplication.style().drawControl( - QStyle.CE_PushButton, check_box_style_option, painter - ) - - def editorEvent(self, event, model, option, index): - """ - Change the data in the model and the state of the checkbox - if the user presses the left mousebutton or presses - Key_Space or Key_Select and this cell is editable. Otherwise do nothing. - """ - if not (index.flags() & Qt.ItemIsEditable) > 0: - return False - - # Do not change the checkbox-state - if event.type() == QEvent.MouseButtonPress: - return False - if ( - event.type() == QEvent.MouseButtonRelease - or event.type() == QEvent.MouseButtonDblClick - ): - if event.button() != Qt.LeftButton or not self.getCheckBoxRect( - option - ).contains(event.pos()): - return False - if event.type() == QEvent.MouseButtonDblClick: - return True - elif event.type() == QEvent.KeyPress: - if event.key() != Qt.Key_Space and event.key() != Qt.Key_Select: - return False - else: - return False - - # Change the checkbox-state - self.setModelData(None, model, index) - return True - - def setModelData(self, editor, model, index): - """ - The user wanted to change the old state in the opposite. - """ - newValue = not index.data().checkState() - model.setData(index, newValue, Qt.EditRole) - - def getCheckBoxRect(self, option): - check_box_style_option = QStyleOptionButton() - check_box_rect = QApplication.style().subElementRect( - QStyle.SE_CheckBoxIndicator, check_box_style_option, None - ) - check_box_point = QPoint( - option.rect.x() + option.rect.width() / 2 - check_box_rect.width() / 2, - option.rect.y() + option.rect.height() / 2 - check_box_rect.height() / 2, - ) - return QRect(check_box_point, check_box_rect.size()) diff --git a/SciDataTool/GUI/WFilter/WFilter.ui b/SciDataTool/GUI/WFilter/WFilter.ui deleted file mode 100644 index 805982cf..00000000 --- a/SciDataTool/GUI/WFilter/WFilter.ui +++ /dev/null @@ -1,85 +0,0 @@ - - - WFilter - - - - 0 - 0 - 831 - 644 - - - - - 630 - 470 - - - - - 16777215 - 16777215 - - - - WFilter - - - - - - - - - Select/Deselect all - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Ok - - - - - - - Cancel - - - - - - - - - - CheckBox - QCheckBox -
SciDataTool/GUI/Tools/CheckBox.h
- 1 -
-
- - -
diff --git a/SciDataTool/GUI/WFilter/__init__.py b/SciDataTool/GUI/WFilter/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/SciDataTool/GUI/WPlotManager/Ui_WPlotManager.py b/SciDataTool/GUI/WPlotManager/Ui_WPlotManager.py deleted file mode 100644 index b7a50621..00000000 --- a/SciDataTool/GUI/WPlotManager/Ui_WPlotManager.py +++ /dev/null @@ -1,103 +0,0 @@ -# -*- coding: utf-8 -*- - -# File generated according to WPlotManager.ui -# WARNING! All changes made in this file will be lost! -## WARNING! All changes made in this file will be lost when recompiling UI file! -################################################################################ - -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * - -from SciDataTool.GUI.WDataRange.WDataRange import WDataRange -from SciDataTool.GUI.WAxisManager.WAxisManager import WAxisManager -from SciDataTool.GUI.WVectorSelector.WVectorSelector import WVectorSelector - - -class Ui_WPlotManager(object): - def setupUi(self, WPlotManager): - if not WPlotManager.objectName(): - WPlotManager.setObjectName(u"WPlotManager") - WPlotManager.resize(376, 683) - self.verticalLayout = QVBoxLayout(WPlotManager) - self.verticalLayout.setObjectName(u"verticalLayout") - self.verticalLayout.setContentsMargins(0, 0, 0, 0) - self.w_vect_selector = WVectorSelector(WPlotManager) - self.w_vect_selector.setObjectName(u"w_vect_selector") - sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( - self.w_vect_selector.sizePolicy().hasHeightForWidth() - ) - self.w_vect_selector.setSizePolicy(sizePolicy) - self.w_vect_selector.setMinimumSize(QSize(0, 0)) - self.w_vect_selector.setMaximumSize(QSize(16777215, 16777215)) - - self.verticalLayout.addWidget(self.w_vect_selector) - - self.w_axis_manager = WAxisManager(WPlotManager) - self.w_axis_manager.setObjectName(u"w_axis_manager") - sizePolicy.setHeightForWidth( - self.w_axis_manager.sizePolicy().hasHeightForWidth() - ) - self.w_axis_manager.setSizePolicy(sizePolicy) - self.w_axis_manager.setMinimumSize(QSize(0, 0)) - self.w_axis_manager.setMaximumSize(QSize(16777215, 16777215)) - - self.verticalLayout.addWidget(self.w_axis_manager) - - self.w_range = WDataRange(WPlotManager) - self.w_range.setObjectName(u"w_range") - sizePolicy.setHeightForWidth(self.w_range.sizePolicy().hasHeightForWidth()) - self.w_range.setSizePolicy(sizePolicy) - self.w_range.setMinimumSize(QSize(0, 0)) - self.w_range.setMaximumSize(QSize(16777215, 16777215)) - - self.verticalLayout.addWidget(self.w_range) - - self.gridLayout_2 = QGridLayout() - self.gridLayout_2.setSpacing(5) - self.gridLayout_2.setObjectName(u"gridLayout_2") - self.gridLayout_2.setContentsMargins(11, 11, 10, 11) - self.horizontalSpacer = QSpacerItem( - 40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum - ) - - self.gridLayout_2.addItem(self.horizontalSpacer, 0, 0, 1, 1) - - self.b_export = QPushButton(WPlotManager) - self.b_export.setObjectName(u"b_export") - sizePolicy1 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) - sizePolicy1.setHorizontalStretch(0) - sizePolicy1.setVerticalStretch(0) - sizePolicy1.setHeightForWidth(self.b_export.sizePolicy().hasHeightForWidth()) - self.b_export.setSizePolicy(sizePolicy1) - self.b_export.setMinimumSize(QSize(0, 0)) - self.b_export.setMaximumSize(QSize(16777215, 16777215)) - - self.gridLayout_2.addWidget(self.b_export, 0, 1, 1, 1) - - self.verticalLayout.addLayout(self.gridLayout_2) - - self.verticalSpacer = QSpacerItem( - 20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding - ) - - self.verticalLayout.addItem(self.verticalSpacer) - - self.retranslateUi(WPlotManager) - - QMetaObject.connectSlotsByName(WPlotManager) - - # setupUi - - def retranslateUi(self, WPlotManager): - WPlotManager.setWindowTitle( - QCoreApplication.translate("WPlotManager", u"WPlotManager", None) - ) - self.b_export.setText( - QCoreApplication.translate("WPlotManager", u"Export", None) - ) - - # retranslateUi diff --git a/SciDataTool/GUI/WPlotManager/WPlotManager.py b/SciDataTool/GUI/WPlotManager/WPlotManager.py deleted file mode 100644 index eb06426e..00000000 --- a/SciDataTool/GUI/WPlotManager/WPlotManager.py +++ /dev/null @@ -1,595 +0,0 @@ -from PySide2.QtWidgets import QWidget, QFileDialog, QMessageBox, QVBoxLayout -from PySide2.QtCore import Signal -from PySide2.QtCore import QByteArray, Qt -from PySide2.QtCore import QThread -from PySide2.QtGui import QMovie -from PySide2.QtWidgets import ( - QFileDialog, - QLabel, - QSizePolicy, - QMessageBox, -) - -from os.path import dirname, basename, join, isfile -from SciDataTool.Functions.Load.import_class import import_class -from SciDataTool.Functions.is_axes_in_order import is_axes_in_order -from SciDataTool.GUI.Tools.SaveGifWorker import SaveGifWorker -import matplotlib.pyplot as plt - -from SciDataTool.GUI.WPlotManager.Ui_WPlotManager import Ui_WPlotManager - -SYMBOL_DICT = { - "time": "t", - "angle": "\\alpha", - "axial direction": "z", - "frequency": "f", - "wavenumber": "r", - "rotation speed": "N0", - "stator current along d-axis": "I_d", - "stator current along q-axis": "I_q", - "speed": "N0", - "torque": "T", - "a-weighted sound power level": "ASWL", - "velocity level": "V", - "reference torque": "T_{ref}", -} - - -def latex(string): - """format a string for latex""" - if "_" in string or "^" in string or "\\" in string: - string = r"$" + string + "$" - return string - - -class WPlotManager(Ui_WPlotManager, QWidget): - """Main widget of the SciDataTool UI""" - - updatePlot = Signal() - updatePlotForced = Signal() - gifDisplayed = Signal() - dataExported = Signal() - - def __init__(self, parent=None): - """Initialize the widget by linking buttons to methods - - Parameters - ---------- - self : WPlotManager - a WPlotManager object - parent : QWidget - The parent widget - """ - - # Build the interface according to the .ui file - QWidget.__init__(self, parent=parent) - self.setupUi(self) - - self.default_file_path = None # Path to export in csv - self.param_dict = dict() # Dict with param for animation to animation - module = __import__("SciDataTool") - DATA_DIR = getattr(module, "DATA_DIR") - self.save_path = DATA_DIR # Path to directory where animation are stored - self.gif_path = None - self.path_to_image = None # Path to recover the image for the animate button - self.main_widget = None - self.plot_arg_dict = {} - - self.is_test = False # Used in test to disable showing the animation - self.gif_path_list = list() # List of path to the gifs created (used in test) - self.logger = None - - # Initializing the thread that will be used for the animation - self.th = QThread(parent=self) - - # Storing each animation as a list with a QMovie, a QLabel and the path to the gif inside gif_widget_list - self.gif_widget_list = list() - - # Building the interaction with the UI and the UI itself - self.w_axis_manager.refreshRange.connect(self.update_range) - self.b_export.clicked.connect(self.export) - - # Linking the signals for the autoRefresh - self.w_axis_manager.refreshNeeded.connect(self.auto_update) - self.w_axis_manager.refreshForced.connect(self.update_plot_forced) - self.w_axis_manager.generateAnimation.connect(self.gen_animate) - self.w_range.refreshNeeded.connect(self.auto_update) - - def auto_update(self): - """Method that update range before sending the signal to update the plot. The auto-refresh policy will be handled in the DDataPlotter - Parameters - ---------- - self : WPlotManager - a WPlotManager object - - """ - self.updatePlot.emit() - - def close_gif(self, ev, animation_label_closed): - """Stops the gif and closes the pop up running""" - - for idx in range(len(self.gif_widget_list)): - - animation_label = self.gif_widget_list[idx][1] - - if animation_label == animation_label_closed: - gif_widget = self.gif_widget_list[idx][0] - widget = self.gif_widget_list[idx][3] - break - - # Stopping the animation and resetting the gif widget (QMovie) - gif_widget.stop() - gif_widget.setParent(None) - gif_widget = None - # Closing and resetting to None the windows that pops up to show animation - animation_label.close() - animation_label.setParent(None) - animation_label = None - - # Closing the widget containing the animation - widget.close() - widget.setParent(None) - widget = None - - # Removing the animation from the list - self.gif_widget_list.pop(idx) - - def close_all_gif(self): - """Method used to close all the gif currently running. Only used in test for now""" - - for _, _, _, widget in self.gif_widget_list: - widget.close() - - def display_gif(self, gif): - "Method that create a display an animation and store it inside gif_widget_list" - - # Creating widget and layout that will contain the animation and its path - widget = QWidget() - layout = QVBoxLayout() - - # Adding the animation (QMovie inside a QLabel) inside the widget - new_gif_widget = QMovie(gif, QByteArray(), self) - new_gif_widget.setCacheMode(QMovie.CacheAll) - new_gif_widget.setSpeed(100) - # set up the movie screen on a label - new_animation_label = QLabel(self, Qt.Window) - - # expand and center the label - new_animation_label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - new_animation_label.setAlignment(Qt.AlignCenter) - new_animation_label.setMovie(new_gif_widget) - new_gif_widget.start() - - layout.addWidget(new_animation_label) - - # Setting size of the widget showing the animation to the size of the gif - widget.resize(new_gif_widget.currentImage().size()) - - # Setting the rest of the widget and showing it - widget.closeEvent = lambda ev: self.close_gif(ev, new_animation_label) - widget.setWindowTitle(gif.split("/")[-1].replace(".gif", "")) - widget.setLayout(layout) - if not self.is_test: - widget.show() - - # Hiding the "Generating..." label - self.l_loading.setHidden(True) - - # Adding the animation to the list - self.gif_widget_list.append([new_gif_widget, new_animation_label, gif, widget]) - - self.gifDisplayed.emit() - - def gen_animate(self): - """Methods called after clicking on animate button to generate a gif on the axis selected and display it - Parameters - ---------- - self : WPlotManager - a WPlotManager object - - Output - --------- - None - """ - # Recovering axes and operations selected - axes_selected = self.w_axis_manager.get_axes_selected() - operations_selected = self.w_axis_manager.get_operation_selected() - - is_3D = len(axes_selected) == 2 - - if is_3D: - not_in_order, axes_selected = is_axes_in_order(axes_selected, self.data) - self.param_dict["is_switch_axes"] = not_in_order - - # Recovering the axis to animate (operation axis with "to_animate") - for idx_ope in range(len(operations_selected)): - ope = operations_selected[idx_ope] - if "to_animate" in ope: - animated_axis = ope.split("to_animate")[0] - idx_animate = idx_ope - - operations_selected.pop(idx_animate) - - # Gathering the other axes and operations selected - plot_input = [animated_axis] - plot_input.extend(axes_selected) - plot_input.extend(operations_selected) - - str_format = ".gif" - - # Updating the figure to make sure that we are recovering the limit of the right figure - self.update_plot_forced() - fig = plt.gcf() - if is_3D and len(plt.gcf().axes) == 2: - # If we are animating a 3D plot, then we must keep the axes limit - - self.param_dict["x_min"] = fig.axes[0].get_xlim()[0] - self.param_dict["x_max"] = fig.axes[0].get_xlim()[1] - self.param_dict["y_min"] = fig.axes[0].get_ylim()[0] - self.param_dict["y_max"] = fig.axes[0].get_ylim()[1] - self.param_dict["z_min"] = fig.axes[1].dataLim.extents[0] - self.param_dict["z_max"] = fig.axes[1].dataLim.extents[-1] - - elif not is_3D: - - if ( - len(axes_selected) == 1 - and axes_selected[0].split("{")[0] - in [ - "freqs", - "wavenumber", - ] - and len(plt.gcf().axes) == 1 - ): - # if we are animating an FFT plot then we set the limit according to the current figure - self.param_dict["x_min"] = fig.axes[0].get_xlim()[0] - self.param_dict["x_max"] = fig.axes[0].get_xlim()[1] - self.param_dict["y_min"] = fig.axes[0].get_ylim()[0] - self.param_dict["y_max"] = fig.axes[0].get_ylim()[1] - - else: - # if we animate a regular 2D plot then we set the limit on y-axis later - self.param_dict["y_min"] = None - self.param_dict["y_max"] = None - - # Recovering the suptitle of the figure and adding to the animation - if fig._suptitle is not None: - suptitle_ref = fig._suptitle._text - else: - suptitle_ref = "" - - # Recovering the name of the gif if not already given - # if self.default_file_path is None: - gif_name = self.get_file_name() - - # Recovering "Generating label" from the WSliceOperator with the axis that we want to animate - for wid in self.w_axis_manager.w_slice_op: - if wid.axis_name == animated_axis.split("[")[0]: - self.l_loading = wid.l_loading - - if self.gif_path is not None: - gif_path = self.gif_path - else: - gif_path = self.save_path - - gif = join(gif_path, gif_name + str_format) - - # Using an index to make sure that we are generating a new gif everytime - idx = 1 - while gif in self.gif_path_list: - gif = gif.split(".")[0].split("(")[0] + "(" + str(idx) + ")" + str_format - idx += 1 - - self.gif_path_list.append(gif) - - # Indicating the path to the .gif in the console - if self.logger is not None: - self.logger.info("Gif stored at: " + gif) - else: - print("Gif stored at: " + gif) - - # Generating a new animation each time - # Creating a QThread associated to the worker saving the gif - self.th = QThread(parent=self) - self.worker = SaveGifWorker( - widget=self, - main_widget=self.main_widget, - gif=gif, - plot_input=plot_input, - data_selection=operations_selected, - is_3D=is_3D, - suptitle_ref=suptitle_ref, - ) - self.worker.moveToThread(self.th) - - # Connecting the end of generation of GIF to display, end thread and killing process - self.worker.gif_available.connect(self.th.finished) - self.worker.gif_available.connect(lambda: self.worker.kill_worker()) - self.worker.gif_available.connect(lambda: self.display_gif(gif)) - - self.th.started.connect(self.worker.run) - self.th.finished.connect(self.th.quit) - self.th.start() - - # Showing "Generating..." under the animate button - self.l_loading.setHidden(False) - - def get_file_name(self): - """Method that create the name of the file with the name of the field selected""" - - file_name = self.data.name - file_name = file_name.replace("{", "[").replace("}", "]").replace(".", ",") - - if "contribution_axis" in self.plot_arg_dict: - file_name += "_contribution" - elif "overall_axes" in self.plot_arg_dict: - file_name += "_order_tracking" - - return file_name - - def export(self, save_file_path=False): - """Method that export the plot as a csv file - Parameters - ---------- - self : WPlotManager - a WPlotManager object - """ - # Getting the inputs of the user to export the plot + for the name of the csv file - [ - data, - axes_selected, - data_selection, - output_range, - ] = self.get_plot_info() - - if self.default_file_path is None: - file_name = self.get_file_name() - default_file_path = file_name + ".csv" - else: - default_file_path = self.default_file_path + ".csv" - - # Opening a dialog window to select the directory where the file will be saved if we are not testing - if save_file_path == False: - save_file_path = QFileDialog.getSaveFileName( - self, - self.tr("Export plot data"), - default_file_path, - filter="csv (*.csv)", - )[0] - else: - save_file_path += "\\" + default_file_path - - # Exporting the file to the right folder - if save_file_path not in ["", False]: - save_path = dirname(save_file_path) - file_name = basename(save_file_path).split(".")[0] - is_2D = True if len(axes_selected) == 1 else False - try: - data.export_along( - *[*axes_selected, *data_selection], - unit=output_range["unit"], - save_path=save_path, - file_name=file_name, - is_2D=is_2D, - plot_options=self.plot_arg_dict - ) - except Exception as e: - # Displaying the error inside abox instead of the console - err_msg = "Error while exporting Data:\n" + str(e) - - QMessageBox().critical( - self, - self.tr("Error"), - err_msg, - ) - - self.dataExported.emit() - - def get_plot_info(self): - """Method that gather all the information necessary to plot the new graph. - Parameters - ---------- - self : WPlotManager - a WPlotManager object - - Output - ---------- - data : DataND - DataND object that we want to plot - axes_selected : list - a list of string corresponding to the axis/axes of the new plot - data_selection : list - a list of string corresponding to the operations on the remaining axes for the new plot - output_range : dict - a dictionnary with all the info related to WDataRange for the new plot - """ - - # Recovering the axis selected and their units - axes_selected = self.w_axis_manager.get_axes_selected() - - # Recovering the operation on the other axes - data_selection = self.w_axis_manager.get_operation_selected() - - # Recovering the operation on the field values - output_range = self.w_range.get_field_selected() - - return self.data, axes_selected, data_selection, output_range - - def set_info( - self, - data, - axes_request_list=list(), - component=None, - unit=None, - z_min=None, - z_max=None, - frozen_type=0, - is_keep_config=False, - is_quiver=False, - plot_arg_dict=dict(), - save_path="", - logger=None, - path_to_image=None, - main_widget=None, - ): - """Method that use the info given by DDataPlotter to setup the widget - - Parameters - ---------- - self : WPlotManager - a WPlotManager object - data : DataND or VectorField object - A DataND/VectorField object to plot - axes_request_list: - list of RequestedAxis which are the info given for the autoplot (for the axes and DataSelection) - component : str - Name of the component to plot (For VectorField only) - unit : str - unit in which to plot the field - z_min : float - Minimum value for Z axis (or Y if only one axe) - z_max : float - Minimum value for Z axis (or Y if only one axe) - frozen_type : int - 0 to let the user modify the axis of the plot, 1 to let him switch them, 2 to not let him change them, - 3 to freeze both axes and operations, 4 to freeze fft, 5 to only allow switch, 6 to only allow overlay button - plot_arg_dict : dict - Dictionnary with arguments that must be given to the plot (used for animated plot) - save_path : str - path to the folder where the animations are saved - logger : logger - logger used to print path to animation (if None using print instead) - path_to_image : str - path to the folder where the image for the animation button is saved - """ - self.main_widget = main_widget - # Recovering the object that we want to show and how we want to show it - self.data = data - self.param_dict = plot_arg_dict.copy() - if save_path != "": - self.save_path = save_path - - self.logger = logger - self.path_to_image = path_to_image - - # Dynamic import to avoid import loop - VectorField = import_class("SciDataTool.Classes", "VectorField") - - # Hide or show the comboBox related to the component of a VectorField - if isinstance(data, VectorField): - self.data_obj = data # storing the Vectorfield with all the components while data will only have one component - self.w_vect_selector.show() - # Adding/removing axial and comp_z depending on the VectorField object - self.w_vect_selector.update(self.data_obj) - self.w_vect_selector.refreshComponent.connect(self.update_component) - if component is not None: - self.w_vect_selector.set_component(component) - self.update_component(is_update_plot=False) - else: - self.update_component(is_update_plot=False) - # Add "all" components in case of quiver plot - if is_quiver: - self.w_vect_selector.c_component.blockSignals(True) - self.w_vect_selector.c_component.insertItem(0, "all") - self.w_vect_selector.c_component.setCurrentIndex(0) - self.w_vect_selector.c_component.blockSignals(False) - else: - self.w_vect_selector.hide() - - self.w_axis_manager.set_axis_widgets( - self.data, - axes_request_list, - frozen_type, - is_keep_config=is_keep_config, - path_to_image=self.path_to_image, - ) - self.update_range( - unit=unit, - z_min=z_min, - z_max=z_max, - ) - - if is_keep_config: - self.update_plot() - - def update_component(self, is_update_plot=True): - """Method that update data according to the component selected in w_vect_selector. - Parameters - ---------- - self : WPlotManager - a WPlotManager object - - """ - component_name = self.w_vect_selector.get_component_selected() - - if component_name in ["radial", "tangential", "axial"]: - self.data = self.data_obj.to_rphiz().components[component_name] - elif component_name in ["comp_x", "comp_y", "comp_z"]: - self.data = self.data_obj.to_xyz().components[component_name] - elif component_name == "all": - self.data = self.data_obj.components[ - list(self.data_obj.components.keys())[0] - ] - - self.w_range.set_range(self.data) - - # Force plot refresh - if is_update_plot: - self.update_plot_forced() - - def update_plot(self): - """Method that update the plot according to the info selected in the UI - Parameters - ---------- - self : WPlotManager - a WPlotManager object - - """ - # Emitting a signal meaning that the plot must be updated - self.updatePlot.emit() - - def update_plot_forced(self): - """Method that update the plot according to the info selected in the UI - Parameters - ---------- - self : WPlotManager - a WPlotManager object - - """ - # Emitting a signal meaning that the plot must be updated - self.updatePlotForced.emit() - - def update_range(self, unit=None, z_min=None, z_max=None): - """Method that will update the range widget with either the user input or the default value of the DataND object - Parameters - ---------- - self : WPlotManager - a WPlotManager object - unit : str - unit in which to plot the field - z_min : float - Minimum value for Z axis (or Y if only one axe) - z_max : float - Minimum value for Z axis (or Y if only one axe) - """ - self.w_range.blockSignals(True) - - # Recovering the axis selected and their units - axes_selected = self.w_axis_manager.get_axes_selected() - # Recovering the operation on the other axes - data_selection = self.w_axis_manager.get_operation_selected() - - # Updating the name of the groupBox according to the number of axes selected - if len(axes_selected) == 1: - self.w_range.g_range.setTitle("Y Range") - elif len(axes_selected) == 2: - self.w_range.g_range.setTitle("Z Range") - - # Setting the WDataRange by sending the necessary info to the widget - self.w_range.set_range(self.data, unit=unit) - - # If user inputs have been sent (auto plot), then we modify the WDataRange according to these info - if z_min is not None or z_max is not None: - self.w_range.set_range_user_input(z_min=z_min, z_max=z_max) - - self.w_range.blockSignals(False) diff --git a/SciDataTool/GUI/WPlotManager/WPlotManager.ui b/SciDataTool/GUI/WPlotManager/WPlotManager.ui deleted file mode 100644 index 9b5de562..00000000 --- a/SciDataTool/GUI/WPlotManager/WPlotManager.ui +++ /dev/null @@ -1,189 +0,0 @@ - - - WPlotManager - - - - 0 - 0 - 376 - 683 - - - - WPlotManager - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - 11 - - - 11 - - - 10 - - - 11 - - - 5 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Export - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - WDataRange - QWidget -
SciDataTool.GUI.WDataRange.WDataRange.h
- 1 -
- - WAxisManager - QWidget -
SciDataTool.GUI.WAxisManager.WAxisManager.h
- 1 -
- - WVectorSelector - QWidget -
SciDataTool.GUI.WVectorSelector.WVectorSelector.h
- 1 -
-
- - -
diff --git a/SciDataTool/GUI/WPlotManager/__init__.py b/SciDataTool/GUI/WPlotManager/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/SciDataTool/GUI/WSliceOperator/Ui_WSliceOperator.py b/SciDataTool/GUI/WSliceOperator/Ui_WSliceOperator.py deleted file mode 100644 index 09f3be4d..00000000 --- a/SciDataTool/GUI/WSliceOperator/Ui_WSliceOperator.py +++ /dev/null @@ -1,208 +0,0 @@ -# -*- coding: utf-8 -*- - -# File generated according to WSliceOperator.ui -# WARNING! All changes made in this file will be lost! -## WARNING! All changes made in this file will be lost when recompiling UI file! -################################################################################ - -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * - -from SciDataTool.GUI.Tools.FloatEdit import FloatEdit -from SciDataTool.GUI.Tools.ButtonLabel import ButtonLabel - -from SciDataTool.GUI.Resources import SDT_rc - - -class Ui_WSliceOperator(object): - def setupUi(self, WSliceOperator): - if not WSliceOperator.objectName(): - WSliceOperator.setObjectName(u"WSliceOperator") - WSliceOperator.resize(375, 160) - self.gridLayout = QGridLayout(WSliceOperator) - self.gridLayout.setObjectName(u"gridLayout") - self.horizontalLayout = QHBoxLayout() - self.horizontalLayout.setObjectName(u"horizontalLayout") - self.in_name = QLabel(WSliceOperator) - self.in_name.setObjectName(u"in_name") - sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.in_name.sizePolicy().hasHeightForWidth()) - self.in_name.setSizePolicy(sizePolicy) - self.in_name.setMinimumSize(QSize(0, 20)) - - self.horizontalLayout.addWidget(self.in_name) - - self.c_operation = QComboBox(WSliceOperator) - self.c_operation.addItem("") - self.c_operation.addItem("") - self.c_operation.addItem("") - self.c_operation.addItem("") - self.c_operation.addItem("") - self.c_operation.addItem("") - self.c_operation.addItem("") - self.c_operation.addItem("") - self.c_operation.setObjectName(u"c_operation") - sizePolicy.setHeightForWidth(self.c_operation.sizePolicy().hasHeightForWidth()) - self.c_operation.setSizePolicy(sizePolicy) - self.c_operation.setMinimumSize(QSize(0, 20)) - - self.horizontalLayout.addWidget(self.c_operation) - - self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 2) - - self.horizontalLayout_2 = QHBoxLayout() - self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") - self.lf_value = FloatEdit(WSliceOperator) - self.lf_value.setObjectName(u"lf_value") - sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) - sizePolicy1.setHorizontalStretch(70) - sizePolicy1.setVerticalStretch(0) - sizePolicy1.setHeightForWidth(self.lf_value.sizePolicy().hasHeightForWidth()) - self.lf_value.setSizePolicy(sizePolicy1) - self.lf_value.setMinimumSize(QSize(0, 20)) - self.lf_value.setMaximumSize(QSize(70, 16777215)) - - self.horizontalLayout_2.addWidget(self.lf_value) - - self.in_unit = QLabel(WSliceOperator) - self.in_unit.setObjectName(u"in_unit") - - self.horizontalLayout_2.addWidget(self.in_unit) - - self.slider = QSlider(WSliceOperator) - self.slider.setObjectName(u"slider") - sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) - sizePolicy2.setHorizontalStretch(0) - sizePolicy2.setVerticalStretch(0) - sizePolicy2.setHeightForWidth(self.slider.sizePolicy().hasHeightForWidth()) - self.slider.setSizePolicy(sizePolicy2) - self.slider.setMinimumSize(QSize(0, 20)) - self.slider.setOrientation(Qt.Horizontal) - - self.horizontalLayout_2.addWidget(self.slider) - - self.b_animate = ButtonLabel(WSliceOperator) - self.b_animate.setObjectName(u"b_animate") - sizePolicy3 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) - sizePolicy3.setHorizontalStretch(0) - sizePolicy3.setVerticalStretch(0) - sizePolicy3.setHeightForWidth(self.b_animate.sizePolicy().hasHeightForWidth()) - self.b_animate.setSizePolicy(sizePolicy3) - self.b_animate.setMinimumSize(QSize(20, 20)) - self.b_animate.setMaximumSize(QSize(20, 20)) - self.b_animate.setFrameShadow(QFrame.Sunken) - self.b_animate.setScaledContents(True) - - self.horizontalLayout_2.addWidget(self.b_animate) - - self.gridLayout.addLayout(self.horizontalLayout_2, 1, 0, 1, 2) - - self.c_values = QComboBox(WSliceOperator) - self.c_values.addItem("") - self.c_values.addItem("") - self.c_values.addItem("") - self.c_values.addItem("") - self.c_values.addItem("") - self.c_values.addItem("") - self.c_values.addItem("") - self.c_values.addItem("") - self.c_values.setObjectName(u"c_values") - sizePolicy.setHeightForWidth(self.c_values.sizePolicy().hasHeightForWidth()) - self.c_values.setSizePolicy(sizePolicy) - self.c_values.setMinimumSize(QSize(0, 20)) - - self.gridLayout.addWidget(self.c_values, 2, 0, 1, 2) - - self.b_action = QPushButton(WSliceOperator) - self.b_action.setObjectName(u"b_action") - sizePolicy3.setHeightForWidth(self.b_action.sizePolicy().hasHeightForWidth()) - self.b_action.setSizePolicy(sizePolicy3) - self.b_action.setMinimumSize(QSize(0, 30)) - - self.gridLayout.addWidget(self.b_action, 3, 1, 1, 1) - - self.l_loading = QLabel(WSliceOperator) - self.l_loading.setObjectName(u"l_loading") - self.l_loading.setEnabled(True) - - self.gridLayout.addWidget(self.l_loading, 4, 0, 1, 1) - - self.retranslateUi(WSliceOperator) - - QMetaObject.connectSlotsByName(WSliceOperator) - - # setupUi - - def retranslateUi(self, WSliceOperator): - WSliceOperator.setWindowTitle( - QCoreApplication.translate("WSliceOperator", u"WSliceOperator", None) - ) - self.in_name.setText( - QCoreApplication.translate("WSliceOperator", u"angle", None) - ) - self.c_operation.setItemText( - 0, QCoreApplication.translate("WSliceOperator", u"slice", None) - ) - self.c_operation.setItemText( - 1, QCoreApplication.translate("WSliceOperator", u"slice (fft)", None) - ) - self.c_operation.setItemText( - 2, QCoreApplication.translate("WSliceOperator", u"rms", None) - ) - self.c_operation.setItemText( - 3, QCoreApplication.translate("WSliceOperator", u"rss", None) - ) - self.c_operation.setItemText( - 4, QCoreApplication.translate("WSliceOperator", u"sum", None) - ) - self.c_operation.setItemText( - 5, QCoreApplication.translate("WSliceOperator", u"mean", None) - ) - self.c_operation.setItemText( - 6, QCoreApplication.translate("WSliceOperator", u"integrate", None) - ) - self.c_operation.setItemText( - 7, QCoreApplication.translate("WSliceOperator", u"overlay/filter", None) - ) - - self.lf_value.setText( - QCoreApplication.translate("WSliceOperator", u"0.314", None) - ) - self.in_unit.setText(QCoreApplication.translate("WSliceOperator", u"[m]", None)) - self.b_animate.setText("") - self.c_values.setItemText( - 0, QCoreApplication.translate("WSliceOperator", u"slice", None) - ) - self.c_values.setItemText( - 1, QCoreApplication.translate("WSliceOperator", u"slice (fft)", None) - ) - self.c_values.setItemText( - 2, QCoreApplication.translate("WSliceOperator", u"rms", None) - ) - self.c_values.setItemText( - 3, QCoreApplication.translate("WSliceOperator", u"rss", None) - ) - self.c_values.setItemText( - 4, QCoreApplication.translate("WSliceOperator", u"sum", None) - ) - self.c_values.setItemText( - 5, QCoreApplication.translate("WSliceOperator", u"mean", None) - ) - self.c_values.setItemText( - 6, QCoreApplication.translate("WSliceOperator", u"integrate", None) - ) - self.c_values.setItemText( - 7, QCoreApplication.translate("WSliceOperator", u"overlay/filter", None) - ) - - self.b_action.setText( - QCoreApplication.translate("WSliceOperator", u"Overlay", None) - ) - self.l_loading.setText( - QCoreApplication.translate("WSliceOperator", u"Generating...", None) - ) - - # retranslateUi diff --git a/SciDataTool/GUI/WSliceOperator/WSliceOperator.py b/SciDataTool/GUI/WSliceOperator/WSliceOperator.py deleted file mode 100644 index 9af12375..00000000 --- a/SciDataTool/GUI/WSliceOperator/WSliceOperator.py +++ /dev/null @@ -1,508 +0,0 @@ -from PySide2.QtWidgets import QWidget -from PySide2.QtGui import QPixmap - -from SciDataTool.GUI.WSliceOperator.Ui_WSliceOperator import Ui_WSliceOperator -from SciDataTool.GUI.WFilter.WFilter import WFilter -from PySide2.QtCore import Signal -from SciDataTool.Functions.Plot import axes_dict, fft_dict, ifft_dict, unit_dict -from SciDataTool.Classes.Data import Data -from numpy import where -from numpy import argmin, abs as np_abs -from os.path import join, abspath, dirname - -type_extraction_dict = { - "max": "=max", - "min": "=min", - "rms": "=rms", - "rss": "=rss", - "sum": "=sum", - "mean": "=mean", -} - -OPERATION_LIST = [ - "slice", - "slice (fft)", - "max", - "min", - "rms", - "rss", - "sum", - "mean", - "overlay", -] - - -class WSliceOperator(Ui_WSliceOperator, QWidget): - """Widget to define how to handle the 'non-plot' axis""" - - refreshNeeded = Signal() - refreshForced = Signal() - generateAnimation = Signal() - - def __init__(self, parent=None, path_to_image=None): - """Initialize the GUI according to info given by the WAxisManager widget - - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - parent : QWidget - The parent QWidget - path_to_image : str - path to the folder where the image for the animation button is saved - """ - - # Build the interface according to the .ui file - QWidget.__init__(self, parent=parent) - self.setupUi(self) - self.name = "angle" - self.axis = Data - self.current_dialog = None - self.indices = None - self.is_animate = False # boolean to define if an animation must on this axis (must be on slice) - self.is_pattern = False # Detecting if the axis is a DataPattern (important for handling of slice + slider + lf_value) - self.is_components = False - self.path_to_image = path_to_image - - # Setting path to recover the image for the animate button - if self.path_to_image is None: - path_to_image = ":/images/images/icon/play-32px_SDT.png" - else: - path_to_image = self.path_to_image + "/images/icon/play-32px.png" - - self.b_animate.setPixmap(QPixmap(path_to_image)) - self.is_sliderpressed = False - self.c_operation.currentTextChanged.connect(self.update_layout) - self.slider.sliderPressed.connect(self.set_sliderpressed) - self.slider.sliderReleased.connect(self.set_sliderreleased) - self.slider.valueChanged.connect(self.update_floatEdit) - self.slider.valueChanged.connect(self.update_plot) - self.lf_value.editingFinished.connect(self.update_slider) - self.c_values.currentTextChanged.connect(self.update_plot) - self.b_action.clicked.connect(self.open_filter) - self.b_animate.mousePressEvent = self.gen_animate - self.l_loading.setHidden(True) - - def gen_animate(self, e): - """Methods called after clicking on animate button that emit a signal to generate a gif on the axis selected and display it - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - - Output - --------- - None - """ - self.is_animate = True - self.generateAnimation.emit() - - def get_operation_selected(self): - """Method that return a string of the action selected by the user on the axis of the widget. - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - - Output - --------- - string - name of the current action selected - """ - - # Recovering the action selected by the user - action_type = self.c_operation.currentText().split(" over")[0] - - # Formatting the string to have the right syntax - if action_type == "slice": - # slice_index = self.slider.value() - # action = "[" + str(slice_index) + "]" - - if self.is_pattern: - # When working with DataPattern we must use index to give the exact value - action = "[" + str(self.slider.value()) + "]" - elif not self.c_values.isHidden(): - action = "[" + str(self.c_values.currentIndex()) + "]" - else: - action = "=" + str(self.lf_value.value()) - - return self.get_name() + action + "{" + self.unit + "}", self.is_animate - - elif action_type == "slice (fft)": - action = "=" + str(self.lf_value.value()) - return self.get_name() + action, None - - elif action_type == "overlay": - if self.indices is None: - return self.get_name() + "[]", None - else: - return self.get_name() + str(self.indices), None - - elif action_type in type_extraction_dict: - action = type_extraction_dict[action_type] - return self.get_name() + action, None - else: - return None, None - - def get_name(self): - """Method that return the name of the axis of the WSliceOperator - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - """ - return self.name - - def open_filter(self): - """Open the Filter widget""" - # Close previous dialog - if self.current_dialog is not None: - self.current_dialog.close() - self.current_dialog.setParent(None) - self.current_dialog = None - - self.current_dialog = WFilter( - self.axis, self.indices, path_to_image=self.path_to_image - ) - self.current_dialog.refreshNeeded.connect(self.update_indices) - self.current_dialog.show() - - def update_indices(self): - self.indices = self.current_dialog.indices - self.refreshForced.emit() - - def set_name(self, name): - """Method that set the name of the axis of the WSliceOperator - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - name : string - string that hold the name of the axis - """ - # Checking if the name of the axis is the name as the one displayed (z =/= axial direction for example) - if name in axes_dict: - self.in_name.setText(axes_dict[name]) - else: - self.in_name.setText(name) - - self.name = name - - def set_operation(self, user_input): - """Method that set the operation of the combobox of the WSliceOperator - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - user_input : list - list of RequestedAxis that we use to set up the UI for the auto-plot - """ - # Recovering the type of the operation and on which axis we are applying it - operation_type = user_input.extension - operation_name = user_input.name - - # Setting the label of the widget with the right name - self.set_name(operation_name) - - # Converting type of the operation if we have a slice or an overlay - if operation_type == "single": - operation_type = "slice" - - elif operation_type == "list": - operation_type = "overlay" - - else: - operation_type += " over " + self.name - - # Setting operation combobox to the right operation - self.c_operation.setCurrentIndex(self.c_operation.findText(operation_type)) - - # Setting the slider to the right value if the operation is slice - if operation_type == "slice": - if user_input.indices is None: - index = 0 - else: - index = user_input.indices[0] - self.set_slider(index) - - def set_slider(self, index): - """Method that set the value of the slider of the WSliceOperator and then update floatEdit - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - index : int - index at which the slider should be placed - """ - self.slider.blockSignals(True) - if index >= 0: - self.slider.setValue(index) - else: - self.slider.setValue(self.slider.maximum() + index) - self.slider.blockSignals(False) - self.update_floatEdit() - - def set_slider_floatedit(self): - """Method that set the value of the slider and the one of the floatEdit - according to the axis sent by WAxisManager. - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - """ - if self.axis.is_components: - self.is_components = True - self.axis_value = self.axis.values - name = self.axis.name - else: - # Converting the axis from rad to degree if the axis is angle as we do slice in degrees - # Recovering the value from the axis as well - if self.c_operation.currentText() == "slice": - if self.axis.name in ifft_dict: - operation = self.axis.name + "_to_" + self.axis_name - else: - operation = None - if self.axis_name in ifft_dict: - name = ifft_dict[self.axis_name] - else: - name = self.axis_name - self.set_name(name) - if self.axis_name == "angle": - self.axis_value = self.axis.get_values( - unit="°", operation=operation, corr_unit="rad", is_full=True - ) - self.unit = "°" - else: - self.axis_value = self.axis.get_values( - operation=operation, is_full=True - ) - elif self.c_operation.currentText() == "slice (fft)": - if self.axis_name in fft_dict: - name = fft_dict[self.axis_name] - else: - name = self.axis_name - self.set_name(name) - if self.axis.name == "angle": - self.axis_value = self.axis.get_values( - operation="angle_to_wavenumber" - ) - self.unit = "" - elif self.axis.name == "time": - self.axis_value = self.axis.get_values(operation="time_to_freqs") - self.unit = "Hz" - else: # already wavenumber of freqs case - self.axis_value = self.axis.get_values() - - # Setting the axis unit - if name in unit_dict: - self.unit = unit_dict[name] - - if self.is_pattern: - # Setting the initial value of the floatEdit to the minimum slice (=1) - self.lf_value.setValue(1) - self.in_unit.setText("[-]") - self.c_values.hide() - elif self.is_components: - self.lf_value.hide() - self.b_animate.hide() - self.in_unit.hide() - self.c_values.clear() - self.c_values.addItems(self.axis_value) - self.slider.hide() - else: - # Setting the initial value of the floatEdit to the minimum inside the axis - self.lf_value.setValue(min(self.axis_value)) - self.in_unit.setText("[" + self.unit + "]") - self.c_values.hide() - - # Setting the slider by giving the number of index according to the size of the axis - self.slider.setMinimum(0) - self.slider.setMaximum(len(self.axis_value) - 1) - self.slider.setValue(0) - - def update(self, axis, axis_request=None): - """Method that will update the WSliceOperator widget according to the axis given to it - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - axis : string - string with the name of the axis that should set the WSliceOperator widget - """ - self.axis = axis - - # Relative import of DataPattern to prevent circular import - module = __import__("SciDataTool.Classes.DataPattern", fromlist=["DataPattern"]) - DataPattern = getattr(module, "DataPattern") - - # Detecting if the axis is a DataPattern (important for handling of slice + slider + lf_value) - if isinstance(self.axis, DataPattern): - self.is_pattern = True - - if axis_request is not None: - axis_request.corr_unit = axis_request.unit - axis_request.get_axis(axis, True) - self.indices = axis_request.indices - self.unit = axis.unit - if axis.name in ifft_dict: # DataFreq case - self.axis_name = ifft_dict[axis.name] - else: - self.axis_name = axis.name - self.set_name(self.axis_name) - - self.c_operation.blockSignals(True) - operation_list = [ - ope + " over " + self.name if ope in type_extraction_dict else ope - for ope in OPERATION_LIST - ] - - # Remove slice for string axes - if self.axis.is_components: - operation_list.remove("slice") - else: - self.set_slider_floatedit() - - # Remove overlay for non is_components axes - if not self.axis.is_components: - operation_list.remove("overlay") - - # Remove fft slice for non fft axes - if not self.axis_name in fft_dict: - operation_list.remove("slice (fft)") - - self.c_operation.clear() - self.c_operation.addItems(operation_list) - self.update_layout() - if self.axis.is_overlay: - self.c_operation.setCurrentIndex(operation_list.index("overlay")) - self.b_action.show() - self.b_action.setText("Overlay") - self.c_operation.blockSignals(False) - - def update_floatEdit(self): - """Method that set the value of the floatEdit according to the value returned by the slider - and the axis sent by WAxisManager. - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - """ - - self.lf_value.blockSignals(True) - - if self.is_pattern: - # When working with DataPattern, we have to work with the exact value given - self.lf_value.setValue(self.slider.value() + 1) - elif self.is_components: - self.in_unit.setText(self.axis_value[self.slider.value()]) - else: - self.lf_value.setValue(self.axis_value[self.slider.value()]) - - self.lf_value.blockSignals(False) - - def update_plot(self): - """Method that set the value of the floatEdit according to the value returned by the slider - and the axis sent by WAxisManager. - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - """ - if not self.is_sliderpressed: - - self.lf_value.blockSignals(True) - - if self.is_pattern: - # When working with DataPattern, we have to work with the exact value given - self.lf_value.setValue(self.slider.value() + 1) - elif self.is_components: - self.in_unit.setText(self.axis_value[self.slider.value()]) - else: - self.lf_value.setValue(self.axis_value[self.slider.value()]) - - self.lf_value.blockSignals(False) - self.refreshNeeded.emit() - - def update_layout(self): - """Method that update the layout of the WSliceOperator according to the extraction chosen - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - """ - # Recovering the operation selected - extraction_selected = self.c_operation.currentText().split(" over")[0] - - # If the operation selected is a slice, then we show the slider and the floatEdit - if extraction_selected == "slice" or extraction_selected == "slice (fft)": - self.set_slider_floatedit() - if not self.is_components: - self.lf_value.show() - self.in_unit.show() - self.slider.show() - self.c_values.hide() - else: - self.c_values.show() - self.b_action.hide() - if extraction_selected == "slice" and not self.is_components: - self.b_animate.show() - else: - self.b_animate.hide() - self.refreshNeeded.emit() - # If the operation selected is overlay then we show the related button - elif extraction_selected == "overlay": - if self.axis_name in ifft_dict: - name = ifft_dict[self.axis_name] - else: - name = self.axis_name - self.set_name(name) - self.lf_value.hide() - self.in_unit.hide() - self.slider.hide() - self.b_animate.hide() - self.b_action.show() - self.b_action.setText("Overlay") - self.c_values.hide() - self.refreshNeeded.emit() - else: - if self.axis_name in ifft_dict: - name = ifft_dict[self.axis_name] - else: - name = self.axis_name - self.set_name(name) - self.lf_value.hide() - self.in_unit.hide() - self.slider.hide() - self.b_animate.hide() - self.b_action.hide() - self.c_values.hide() - self.refreshNeeded.emit() - - def update_slider(self): - """Method that set the value of the slider according to the value of the floatEdit - according to the axis sent by WAxisManager. - Parameters - ---------- - self : WSliceOperator - a WSliceOperator object - """ - - self.slider.blockSignals(True) - # We set the value of the slider to the index closest to the value given - if self.is_pattern: - # When working with DataPattern, we have to work with the exact value given - self.slider.setValue(self.lf_value.value() - 1) - else: - index = argmin(np_abs(self.axis_value - self.lf_value.value())) - self.slider.setValue(index) - # We update the value of floatEdit to the index selected - # self.lf_value.setValue(self.axis_value[index]) - self.slider.blockSignals(False) - self.refreshNeeded.emit() - - def set_sliderpressed(self): - self.is_sliderpressed = True - - def set_sliderreleased(self): - self.is_sliderpressed = False - self.update_plot() diff --git a/SciDataTool/GUI/WSliceOperator/WSliceOperator.ui b/SciDataTool/GUI/WSliceOperator/WSliceOperator.ui deleted file mode 100644 index c753bc28..00000000 --- a/SciDataTool/GUI/WSliceOperator/WSliceOperator.ui +++ /dev/null @@ -1,285 +0,0 @@ - - - WSliceOperator - - - - 0 - 0 - 375 - 160 - - - - WSliceOperator - - - - - - - - - 0 - 0 - - - - - 0 - 20 - - - - angle - - - - - - - - 0 - 0 - - - - - 0 - 20 - - - - - slice - - - - - slice (fft) - - - - - rms - - - - - rss - - - - - sum - - - - - mean - - - - - integrate - - - - - overlay/filter - - - - - - - - - - - - - 70 - 0 - - - - - 0 - 20 - - - - - 70 - 16777215 - - - - 0.314 - - - - - - - [m] - - - - - - - - 0 - 0 - - - - - 0 - 20 - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - - 20 - 20 - - - - - 20 - 20 - - - - QFrame::Sunken - - - - - - true - - - - - - - - - - 0 - 0 - - - - - 0 - 20 - - - - - slice - - - - - slice (fft) - - - - - rms - - - - - rss - - - - - sum - - - - - mean - - - - - integrate - - - - - overlay/filter - - - - - - - - - 0 - 0 - - - - - 0 - 30 - - - - Overlay - - - - - - - true - - - Generating... - - - - - - - - FloatEdit - QLineEdit -
SciDataTool.GUI/Tools/FloatEdit.h
-
- - ButtonLabel - QLabel -
SciDataTool.GUI/Tools/ButtonLabel.h
-
-
- - - - -
diff --git a/SciDataTool/GUI/WSliceOperator/__init__.py b/SciDataTool/GUI/WSliceOperator/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/SciDataTool/GUI/WVectorSelector/Ui_WVectorSelector.py b/SciDataTool/GUI/WVectorSelector/Ui_WVectorSelector.py deleted file mode 100644 index 978c0afb..00000000 --- a/SciDataTool/GUI/WVectorSelector/Ui_WVectorSelector.py +++ /dev/null @@ -1,126 +0,0 @@ -# -*- coding: utf-8 -*- - -# File generated according to WVectorSelector.ui -# WARNING! All changes made in this file will be lost! -## WARNING! All changes made in this file will be lost when recompiling UI file! -################################################################################ - -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * - - -class Ui_WVectorSelector(object): - def setupUi(self, WVectorSelector): - if not WVectorSelector.objectName(): - WVectorSelector.setObjectName(u"WVectorSelector") - WVectorSelector.resize(218, 122) - self.verticalLayout_2 = QVBoxLayout(WVectorSelector) - self.verticalLayout_2.setObjectName(u"verticalLayout_2") - self.g_vector_comp = QGroupBox(WVectorSelector) - self.g_vector_comp.setObjectName(u"g_vector_comp") - sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( - self.g_vector_comp.sizePolicy().hasHeightForWidth() - ) - self.g_vector_comp.setSizePolicy(sizePolicy) - self.g_vector_comp.setMinimumSize(QSize(0, 0)) - self.g_vector_comp.setMaximumSize(QSize(16777215, 16777215)) - self.gridLayout = QGridLayout(self.g_vector_comp) - self.gridLayout.setObjectName(u"gridLayout") - self.in_component = QLabel(self.g_vector_comp) - self.in_component.setObjectName(u"in_component") - self.in_component.setMinimumSize(QSize(0, 21)) - - self.gridLayout.addWidget(self.in_component, 0, 0, 1, 1) - - self.c_component = QComboBox(self.g_vector_comp) - self.c_component.addItem("") - self.c_component.addItem("") - self.c_component.addItem("") - self.c_component.addItem("") - self.c_component.addItem("") - self.c_component.addItem("") - self.c_component.setObjectName(u"c_component") - sizePolicy1 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) - sizePolicy1.setHorizontalStretch(0) - sizePolicy1.setVerticalStretch(0) - sizePolicy1.setHeightForWidth(self.c_component.sizePolicy().hasHeightForWidth()) - self.c_component.setSizePolicy(sizePolicy1) - self.c_component.setMinimumSize(QSize(0, 21)) - self.c_component.setMaximumSize(QSize(16777215, 16777215)) - font = QFont() - font.setBold(False) - font.setWeight(50) - self.c_component.setFont(font) - - self.gridLayout.addWidget(self.c_component, 0, 1, 1, 1) - - self.in_referential = QLabel(self.g_vector_comp) - self.in_referential.setObjectName(u"in_referential") - self.in_referential.setEnabled(True) - self.in_referential.setMinimumSize(QSize(0, 21)) - - self.gridLayout.addWidget(self.in_referential, 1, 0, 1, 1) - - self.c_referential = QComboBox(self.g_vector_comp) - self.c_referential.addItem("") - self.c_referential.addItem("") - self.c_referential.setObjectName(u"c_referential") - self.c_referential.setEnabled(True) - sizePolicy1.setHeightForWidth( - self.c_referential.sizePolicy().hasHeightForWidth() - ) - self.c_referential.setSizePolicy(sizePolicy1) - self.c_referential.setMinimumSize(QSize(100, 21)) - - self.gridLayout.addWidget(self.c_referential, 1, 1, 1, 1) - - self.verticalLayout_2.addWidget(self.g_vector_comp) - - self.retranslateUi(WVectorSelector) - - QMetaObject.connectSlotsByName(WVectorSelector) - - # setupUi - - def retranslateUi(self, WVectorSelector): - WVectorSelector.setWindowTitle( - QCoreApplication.translate("WVectorSelector", u"WVectorSelector", None) - ) - self.g_vector_comp.setTitle("") - self.in_component.setText( - QCoreApplication.translate("WVectorSelector", u"Component", None) - ) - self.c_component.setItemText( - 0, QCoreApplication.translate("WVectorSelector", u"radial", None) - ) - self.c_component.setItemText( - 1, QCoreApplication.translate("WVectorSelector", u"tangential", None) - ) - self.c_component.setItemText( - 2, QCoreApplication.translate("WVectorSelector", u"axial", None) - ) - self.c_component.setItemText( - 3, QCoreApplication.translate("WVectorSelector", u"comp_x", None) - ) - self.c_component.setItemText( - 4, QCoreApplication.translate("WVectorSelector", u"comp_y", None) - ) - self.c_component.setItemText( - 5, QCoreApplication.translate("WVectorSelector", u"comp_z", None) - ) - - self.in_referential.setText( - QCoreApplication.translate("WVectorSelector", u"Referential", None) - ) - self.c_referential.setItemText( - 0, QCoreApplication.translate("WVectorSelector", u"xyz", None) - ) - self.c_referential.setItemText( - 1, QCoreApplication.translate("WVectorSelector", u"radphiz", None) - ) - - # retranslateUi diff --git a/SciDataTool/GUI/WVectorSelector/WVectorSelector.py b/SciDataTool/GUI/WVectorSelector/WVectorSelector.py deleted file mode 100644 index 2edf9d4c..00000000 --- a/SciDataTool/GUI/WVectorSelector/WVectorSelector.py +++ /dev/null @@ -1,185 +0,0 @@ -from PySide2.QtWidgets import QWidget - -from SciDataTool.GUI.WVectorSelector.Ui_WVectorSelector import Ui_WVectorSelector -from PySide2.QtCore import Signal -from PySide2.QtGui import QStandardItem - -COMP_DICT = { - "all": "all", - "radial": "radial", - "circumferential": "tangential", - "axial": "axial", - "x-axis component": "comp_x", - "y-axis component": "comp_y", - "z-axis component": "comp_z", -} - -REV_COMP_DICT = { - "radial": "radial", - "tangential": "circumferential", - "axial": "axial", - "comp_x": "x-axis component", - "comp_y": "y-axis component", - "comp_z": "z-axis component", -} - - -class WVectorSelector(Ui_WVectorSelector, QWidget): - """Widget to select how to export the data""" - - refreshComponent = Signal() - - def __init__(self, parent=None): - """Initialize the UI and linking buttons to their methods - - Parameters - ---------- - self : WExport - a WVectorSelector object - parent : QWidget - The parent widget - """ - - # Build the interface according to the .ui file - QWidget.__init__(self, parent=parent) - self.setupUi(self) - - self.c_component.currentTextChanged.connect(self.update_needed) - - self.c_referential.hide() - self.in_referential.hide() - - # self.c_referential.currentTextChanged.connect(self.update_needed) - - self.component_selected = None - self.component_list = list() - - def get_component_selected(self): - """Getting the component selected - - Parameters - ---------- - self : WExport - a WVectorSelector object - - """ - return COMP_DICT[self.c_component.currentText()] - - def set_component(self, component_selected): - """Method that set the component selected according to the input of the user (auto-plot) - Parameters - ---------- - self : DDataPlotter - a DDataPlotter object - component_selected : str - Component to select - """ - - # Setting the combobox with the right component - if REV_COMP_DICT[component_selected] in self.component_list: - self.c_component.setCurrentText(REV_COMP_DICT[component_selected]) - else: - print( - "WARNING : Trying to set the vector to " - + component_selected - + " a component which is not available. Setting to default component" - ) - self.c_component.setCurrentIndex(1) - - def update(self, data): - """Updating the combobox according to the components store in the VectorField - - Parameters - ---------- - self : WExport - a WVectorSelector object - data : VectorField - the object that we want to plot - """ - comp_stored = data.components.keys() - - self.blockSignals(True) - self.c_component.clear() - self.c_component.addItems([REV_COMP_DICT[comp] for comp in comp_stored]) - model = self.c_component.model() - if ( - "radial" in comp_stored - or "tangential" in comp_stored - or "axial" in comp_stored - ): - item = QStandardItem("Polar coordinates") - font = item.font() - font.setBold(True) - item.setFont(font) - item.setEnabled(False) - model.insertRow(0, item) - try: - data.to_xyz() - item = QStandardItem("Cartesian coordinates") - font = item.font() - font.setBold(True) - item.setFont(font) - item.setEnabled(False) - model.insertRow(self.c_component.count(), item) - self.c_component.addItem("x-axis component") - self.c_component.addItem("y-axis component") - if "axial" in comp_stored: - self.c_component.addItem("z-axis component") - except: - pass - elif "comp_x" in comp_stored or "comp_y" in comp_stored: - item = QStandardItem("Cartesian coordinates") - font = item.font() - font.setBold(True) - item.setFont(font) - item.setEnabled(False) - model.insertRow(0, item) - try: - data.to_rphiz() - item = QStandardItem("Polar coordinates") - font = item.font() - font.setBold(True) - item.setFont(font) - item.setEnabled(False) - model.insertRow(self.c_component.count(), item) - self.c_component.addItem("radial") - self.c_component.addItem("circumferential") - if "comp_z" in comp_stored: - self.c_component.addItem("axial") - except: - pass - - # Recovering all the components available after the update - self.component_list = [ - self.c_component.itemText(i) - for i in range(self.c_component.count()) - if self.c_component.itemText(i) - not in ["Polar coordinates", "Cartesian coordinates"] - ] - - # Modifying the width of the dropdown list to make sure that all the element are readable - component_list = [ - self.c_component.itemText(i) for i in range(self.c_component.count()) - ] - width_drop_down = max([len(ac) for ac in component_list]) * 6 - self.c_component.view().setMinimumWidth(width_drop_down) - - self.c_component.setCurrentIndex(1) - self.blockSignals(False) - - def update_needed(self): - """Emit a signal when the component must be changed - - Parameters - ---------- - self : WExport - a WVectorSelector object - - """ - # if self.c_component.currentText() in [ - # "Polar coordinates", - # "Cartesian coordinates", - # ]: - # self.c_component.setCurrentIndex(self.c_component.currentIndex() + 1) - - self.refreshComponent.emit() diff --git a/SciDataTool/GUI/WVectorSelector/WVectorSelector.ui b/SciDataTool/GUI/WVectorSelector/WVectorSelector.ui deleted file mode 100644 index 2b89347e..00000000 --- a/SciDataTool/GUI/WVectorSelector/WVectorSelector.ui +++ /dev/null @@ -1,164 +0,0 @@ - - - WVectorSelector - - - - 0 - 0 - 218 - 122 - - - - WVectorSelector - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - - - 0 - 21 - - - - Component - - - - - - - - 0 - 0 - - - - - 0 - 21 - - - - - 16777215 - 16777215 - - - - - 50 - false - - - - - radial - - - - - tangential - - - - - axial - - - - - comp_x - - - - - comp_y - - - - - comp_z - - - - - - - - true - - - - 0 - 21 - - - - Referential - - - - - - - true - - - - 0 - 0 - - - - - 100 - 21 - - - - - xyz - - - - - radphiz - - - - - - - - - - - - diff --git a/SciDataTool/GUI/WVectorSelector/__init__.py b/SciDataTool/GUI/WVectorSelector/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/SciDataTool/GUI/__init__.py b/SciDataTool/GUI/__init__.py deleted file mode 100644 index bf331a2a..00000000 --- a/SciDataTool/GUI/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -from matplotlib import use - -# Set Matplotlib backend -use("Qt5Agg") # Use PySide2 backend - - -def update_cb_enable(combobox): - # To disable a combobox with only one item - if combobox.count() <= 1: - combobox.setEnabled(False) - else: - combobox.setEnabled(True) - - -from os.path import dirname, abspath, join - -DATA_DIR = join(abspath(dirname(__file__)), "Results") diff --git a/SciDataTool/Generator/ClassesRef/DataND.csv b/SciDataTool/Generator/ClassesRef/DataND.csv index cd8393d9..885d4765 100644 --- a/SciDataTool/Generator/ClassesRef/DataND.csv +++ b/SciDataTool/Generator/ClassesRef/DataND.csv @@ -23,7 +23,6 @@ is_real,,To indicate if the signal is real (use only positive frequencies),,bool ,,,,,,,,,,,get_phase_along,,,, ,,,,,,,,,,,has_period,,,, ,,,,,,,,,,,orthogonal_mp,,,, -,,,,,,,,,,,plot,,,, ,,,,,,,,,,,plot_2D_Data,,,, ,,,,,,,,,,,plot_2D_Data_Animated,,,, ,,,,,,,,,,,plot_3D_Data,,,, diff --git a/SciDataTool/Generator/ClassesRef/VectorField.csv b/SciDataTool/Generator/ClassesRef/VectorField.csv index 334a6464..2a0d2e80 100644 --- a/SciDataTool/Generator/ClassesRef/VectorField.csv +++ b/SciDataTool/Generator/ClassesRef/VectorField.csv @@ -11,7 +11,6 @@ components,,Dict of the components,,{SciDataTool.Classes.DataND},-1,,,,,,filter_ ,,,,,,,,,,,get_rphiz_along,,,, ,,,,,,,,,,,get_xyz_along,,,, ,,,,,,,,,,,get_vectorfield_along,,,, -,,,,,,,,,,,plot,,,, ,,,,,,,,,,,plot_2D_Data,,,, ,,,,,,,,,,,plot_2D_Data_Animated,,,, ,,,,,,,,,,,plot_3D_Data,,,, diff --git a/SciDataTool/Methods/DataND/plot.py b/SciDataTool/Methods/DataND/plot.py deleted file mode 100644 index 0c7bf4b5..00000000 --- a/SciDataTool/Methods/DataND/plot.py +++ /dev/null @@ -1,81 +0,0 @@ -from SciDataTool.GUI.DDataPlotter.DDataPlotter import DDataPlotter -from sys import argv, exit -from PySide2.QtWidgets import QApplication -from PySide2 import QtCore -from SciDataTool.Functions import parser - -QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) - - -def plot( - self, - *args, - component=None, - unit=None, - z_min=None, - z_max=None, - is_auto_refresh=False, - is_show_fig=True, - is_create_appli=True, - frozen_type=0, - plot_arg_dict=dict(), - path_to_image=None, -): - """Plot the Data object in the GUI - - Parameters: - ----------- - self : DataND - A DataND object - *args : 1 or 2 str - Example ("time", "angle[0]") or ("angle") - component : str - Name of the component to plot (For VectorField only) - unit : str - unit in which to plot the field - z_min : float - Minimum value for Z axis (or Y if only one axe) - z_max : float - Minimum value for Z axis (or Y if only one axe) - is_auto_refresh : bool - True to refresh at each widget changed (else wait call to button) - is_show_fig : bool - To show the GUI or return the widget (False for testing) - is_create_appli : bool - True to create an QApplication (required if not already created by another GUI) - frozen_type : int - 0 to let the user modify the axis of the plot, 1 to let him switch them, 2 to not let him change them, - 3 to freeze both axes and operations, 4 to freeze fft, 5 to only allow switch, 6 to only allow overlay button - """ - - if is_create_appli: - a = QApplication(argv) - - # Parse the first arguments to get the axes - axes_request_list = parser.read_input_strings( - [arg for arg in args if arg != None], axis_data=None - ) - - if unit is None: - unit = self.unit - - wid = DDataPlotter( - data=self, - axes_request_list=axes_request_list, - component=component, - unit=unit, - z_min=z_min, - z_max=z_max, - is_auto_refresh=is_auto_refresh, - plot_arg_dict=plot_arg_dict, - frozen_type=frozen_type, - path_to_image=path_to_image, - ) - - if is_show_fig: - wid.show() - - if is_create_appli: - exit(a.exec_()) - else: - return wid diff --git a/SciDataTool/Methods/VectorField/plot.py b/SciDataTool/Methods/VectorField/plot.py deleted file mode 100644 index d19e1eb0..00000000 --- a/SciDataTool/Methods/VectorField/plot.py +++ /dev/null @@ -1,77 +0,0 @@ -from SciDataTool.GUI.DDataPlotter.DDataPlotter import DDataPlotter -from sys import argv, exit -from PySide2.QtWidgets import QApplication -from PySide2 import QtCore -from SciDataTool.Functions import parser - -QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) - - -def plot( - self, - *args, - component=None, - unit=None, - z_min=None, - z_max=None, - is_auto_refresh=False, - is_show_fig=True, - is_create_appli=True, - frozen_type=0, -): - """Plot the Data object in the GUI - - Parameters: - ----------- - self : VectorField - A VectorField object - *args : 1 or 2 str - Example ("time", "angle[0]") or ("angle") - component : str - Name of the component to plot (For VectorField only) - unit : str - unit in which to plot the field - z_min : float - Minimum value for Z axis (or Y if only one axe) - z_max : float - Minimum value for Z axis (or Y if only one axe) - is_auto_refresh : bool - True to refresh at each widget changed (else wait call to button) - is_show_fig : bool - To show the GUI or return the widget (False for testing) - is_create_appli : bool - True to create an QApplication (required if not already created by another GUI) - frozen_type : int - 0 to let the user modify the axis of the plot, 1 to let him switch them, 2 to not let him change them, - 3 to freeze both axes and operations, 4 to freeze fft, 5 to only allow switch, 6 to only allow overlay button - """ - - if is_create_appli: - a = QApplication(argv) - - # Parse the first arguments to get the axes - axes_request_list = parser.read_input_strings( - [arg for arg in args if arg != None], axis_data=None - ) - - if unit is None: - unit = self.components[list(self.components.keys())[0]].unit - - wid = DDataPlotter( - data=self, - axes_request_list=axes_request_list, - component=component, - unit=unit, - z_min=z_min, - z_max=z_max, - is_auto_refresh=is_auto_refresh, - frozen_type=frozen_type, - ) - - if is_show_fig: - wid.show() - - if is_create_appli: - exit(a.exec_()) - else: - return wid diff --git a/SciDataTool/__init__.py b/SciDataTool/__init__.py index ceb89342..03fe4960 100644 --- a/SciDataTool/__init__.py +++ b/SciDataTool/__init__.py @@ -18,4 +18,4 @@ DATA_DIR = abspath(join(dirname(__file__), "Data")) -__version__ = "2.4.10" +__version__ = "2.5.0" diff --git a/Tests/GUI/DataND/test_auto_plot_datand.py b/Tests/GUI/DataND/test_auto_plot_datand.py deleted file mode 100644 index b8d9f8fb..00000000 --- a/Tests/GUI/DataND/test_auto_plot_datand.py +++ /dev/null @@ -1,408 +0,0 @@ -from types import FrameType -import pytest - -# from PySide2.QtWidgets import * -from PySide2 import QtWidgets -import sys - -from numpy import pi -from numpy.random import random -from SciDataTool import DataLinspace, DataTime -from SciDataTool.Functions.Plot import ifft_dict -from SciDataTool.Functions import parser - -a_p_list = list() - -a_p_list.append( - { - "axis": ["time"], - "action": ["angle[-1]", "z[2]"], - "is_create_appli": False, - "is_show_fig": False, - "unit": "T", - "z_min": 0, - "z_max": 50, - } -) # Testing the autoplot for XY plot - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": ["z[2]"], - "is_create_appli": False, - "is_show_fig": False, - "unit": "T", - "z_min": 0, - "z_max": 50, - } -) # Testing the autoplot for 2D plot - -a_p_list.append( - { - "axis": ["freqs"], - "action": ["angle[-1]", "z[1]"], - "is_create_appli": False, - "is_show_fig": False, - "unit": "T", - "z_min": 0, - "z_max": 50, - } -) # Testing the autoplot for XY FFT plot - -a_p_list.append( - { - "axis": ["freqs", "wavenumber"], - "action": ["z[1]"], - "is_create_appli": False, - "is_show_fig": False, - "unit": "T", - "z_min": 0, - "z_max": 50, - } -) # Testing the autoplot for 2D FFT plot - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": ["z=sum"], - "is_create_appli": False, - "is_show_fig": False, - "unit": "T", - "z_min": 0, - "z_max": 50, - } -) # Testing the autoplot with sum as action on z - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": ["z=rms"], - "is_create_appli": False, - "is_show_fig": False, - "unit": "T", - "z_min": 0, - "z_max": 50, - } -) # Testing the autoplot with rms as action on z - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": ["z=rss"], - "is_create_appli": False, - "is_show_fig": False, - "unit": "T", - "z_min": 0, - "z_max": 50, - } -) # Testing the autoplot with rss as action on z - - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": ["z=mean"], - "is_create_appli": False, - "is_show_fig": False, - "unit": "T", - "z_min": 0, - "z_max": 50, - } -) # Testing the autoplot with mean as action on z - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": [None], - "is_create_appli": False, - "is_show_fig": False, - "unit": "T", - "z_min": 0, - "z_max": 50, - } -) # Testing the autoplot for 2D plot without giving any action - - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": ["z[2]"], - "is_create_appli": False, - "is_show_fig": False, - "unit": None, - "z_min": None, - "z_max": None, - } -) # Testing the autoplot without WDataRange given - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": [None], - "is_create_appli": False, - "is_show_fig": False, - "unit": None, - "z_min": None, - "z_max": None, - } -) # Testing the autoplot for 2D plot without giving slice and WdataRange - -a_p_list.append( - { - "axis": ["angle{°}", "time"], - "action": ["z[2]"], - "is_create_appli": False, - "is_show_fig": False, - "unit": "T", - "z_min": 0, - "z_max": 50, - } -) # Testing the autoplot for 2D plot where axes are inverted - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - f = 50 - Nt_tot = 16 - Na_tot = 20 - - Time = DataLinspace( - name="time", unit="s", initial=0, final=1 / (2 * f), number=Nt_tot - ) - Angle = DataLinspace( - name="angle", unit="rad", initial=0, final=2 * pi, number=Na_tot - ) - Z = DataLinspace(name="z", unit="m", initial=-1, final=1, number=3) - - field = random((Nt_tot, Na_tot, 3)) - - cls.Field = DataTime( - name="Airgap flux density", - symbol="B_r", - unit="T", - axes=[Time, Angle, Z], - values=field, - ) - - @pytest.mark.gui - @pytest.mark.parametrize("test_dict", a_p_list) - def test_check_a_p(self, test_dict): - """Test to make sure that the auto-plot works as intended""" - - # Launching the auto plot with info from the dict - if len(test_dict["axis"]) == 1: - self.UI = self.Field.plot( - test_dict["axis"][0], - test_dict["action"][0], - test_dict["action"][1], - is_create_appli=test_dict["is_create_appli"], - is_show_fig=test_dict["is_show_fig"], - unit=test_dict["unit"], - z_min=test_dict["z_min"], - z_max=test_dict["z_max"], - ) - - elif len(test_dict["axis"]) == 2: - self.UI = self.Field.plot( - test_dict["axis"][0], - test_dict["axis"][1], - test_dict["action"][0], - is_create_appli=test_dict["is_create_appli"], - is_show_fig=test_dict["is_show_fig"], - unit=test_dict["unit"], - z_min=test_dict["z_min"], - z_max=test_dict["z_max"], - ) - - # Recovering the string generated - [_, axes_sent, actions_sent, drange] = self.UI.w_plot_manager.get_plot_info() - - axes_sent = parser.read_input_strings(axes_sent, axis_data=None) - - actions_sent = parser.read_input_strings(actions_sent, axis_data=None) - - # Step 1 : Checking the axes (1 and 2 if given) - assert len(axes_sent) == len(test_dict["axis"]) - - axes_given = parser.read_input_strings(test_dict["axis"], axis_data=None) - - # Checking the name of the axes - assert axes_sent[0].name == axes_given[0].name - - # Checking the unit - if axes_given[0].unit == "SI": - # If the unit is not given, then we make sure that the unit by default is selected - assert axes_sent[ - 0 - ].unit == self.UI.w_plot_manager.w_axis_manager.w_axis_1.get_axis_unit_selected().split( - "{" - )[ - 1 - ].rstrip( - "}" - ) - else: - assert axes_sent[0].unit == axes_given[0].unit - - # Checking axis 2 if we have one - if len(axes_sent) == 2: - assert axes_sent[1].name == axes_given[1].name - if axes_given[1].unit == "SI": - # If the unit is not given, then we make sure that the unit by default is selected - assert axes_sent[ - 1 - ].unit == self.UI.w_plot_manager.w_axis_manager.w_axis_2.get_axis_unit_selected().split( - "{" - )[ - 1 - ].rstrip( - "}" - ) - - # Step 2 : Checking the actions - if test_dict["action"] != [None]: - - actions_given = parser.read_input_strings( - test_dict["action"], axis_data=None - ) - assert len(actions_sent) == len(actions_given) - - for i in range(len(actions_sent)): - # Checking the name of the axis - assert actions_sent[i].name == actions_given[i].name - - # Checking the operation given - assert actions_sent[i].extension == actions_given[i].extension - - # Special case when slice is the operation selected (we have to check the index) - if actions_sent[i].extension == "single": - - if actions_given[i].indices[0] < 0: - # if we gave a negative index, we have to update the value manually (slider accept/return only positive value) - assert ( - self.UI.w_plot_manager.w_axis_manager.w_slice_op[ - i - ].slider.value() - == self.UI.w_plot_manager.w_axis_manager.w_slice_op[ - i - ].slider.maximum() - + actions_given[i].indices[0] - ) - else: - assert ( - self.UI.w_plot_manager.w_axis_manager.w_slice_op[ - i - ].slider.value() - == actions_given[i].indices[0] - ) - - # Checking the units - if actions_given[i].unit == "SI" and actions_sent[i].unit != "SI": - assert ( - # If the unit is not given, then we make sure that the unit by default is selected - actions_sent[i].unit - == self.UI.w_plot_manager.w_axis_manager.w_slice_op[i].unit - ) - else: - assert actions_sent[i].unit == actions_given[i].unit - else: - # If no action are specified, then we apply a slice on the first index for all the axes - for i in range(len(actions_sent)): - assert ( - actions_sent[i].name - == self.UI.w_plot_manager.w_axis_manager.w_slice_op[i].axis.name - ) - assert actions_sent[i].extension == "single" - assert ( - self.UI.w_plot_manager.w_axis_manager.w_slice_op[i].slider.value() - == 0 - ) - assert ( - actions_sent[i].unit - == self.UI.w_plot_manager.w_axis_manager.w_slice_op[i].unit - ) - - # Comparing the info given to range with those emitted - - # Checking the unit of the field - if test_dict["unit"] == None: - assert drange["unit"] == self.UI.w_plot_manager.w_range.c_unit.currentText() - else: - assert drange["unit"] == test_dict["unit"] - - # To check the value of min and max when they are not given we have to do a get_along/get_magnitude_along to recover min and max - if test_dict["z_min"] == None or test_dict["z_min"] == None: - if len(axes_given) == 1: - if axes_given[0].name in ifft_dict: - field_value = self.Field.get_magnitude_along( - self.UI.w_plot_manager.w_axis_manager.get_operation_selected()[ - 0 - ], - self.UI.w_plot_manager.w_axis_manager.get_operation_selected()[ - 1 - ], - self.UI.w_plot_manager.w_axis_manager.get_axes_selected()[0], - ) - else: - field_value = self.Field.get_along( - self.UI.w_plot_manager.w_axis_manager.get_operation_selected()[ - 0 - ], - self.UI.w_plot_manager.w_axis_manager.get_operation_selected()[ - 1 - ], - self.UI.w_plot_manager.w_axis_manager.get_axes_selected()[0], - ) - - elif len(axes_given) == 2: - if axes_given[0].name in ifft_dict and axes_given[1].name in ifft_dict: - field_value = self.Field.get_magnitude_along( - self.UI.w_plot_manager.w_axis_manager.get_operation_selected()[ - 0 - ], - self.UI.w_plot_manager.w_axis_manager.get_axes_selected()[0], - self.UI.w_plot_manager.w_axis_manager.get_axes_selected()[1], - ) - else: - field_value = self.Field.get_along( - self.UI.w_plot_manager.w_axis_manager.get_operation_selected()[ - 0 - ], - self.UI.w_plot_manager.w_axis_manager.get_axes_selected()[0], - self.UI.w_plot_manager.w_axis_manager.get_axes_selected()[1], - ) - if test_dict["z_min"] == None: - # Making sure that the value are equal with a threshold of 1e-4 - eps = 1e-4 - assert drange["min"] - field_value[self.Field.symbol].min() < eps - if test_dict["z_max"] == None: - # Making sure that the value are equal with a threshold of 1e-4 - eps = 1e-4 - assert drange["max"] - field_value[self.Field.symbol].max() < eps - else: - # If min and max are given, we just have to compare them - assert drange["min"] == float(test_dict["z_min"]) - assert drange["max"] == float(test_dict["z_max"]) - - # Making sure that we update the name of g_data_extract with the plot selected - title = self.UI.w_plot_manager.w_range.g_range.title() - if len(test_dict["axis"]) == 1: - assert title == "Y Range" - elif len(test_dict["axis"]) == 2: - assert title == "Z Range" - - -if __name__ == "__main__": - - for ii, a_p_test in enumerate(a_p_list): - a = TestGUI() - a.setup_class() - a.test_check_a_p(a_p_test) - print("Test n°" + str(ii) + " done") diff --git a/Tests/GUI/DataND/test_is_overlay.py b/Tests/GUI/DataND/test_is_overlay.py deleted file mode 100644 index f376d019..00000000 --- a/Tests/GUI/DataND/test_is_overlay.py +++ /dev/null @@ -1,76 +0,0 @@ -import pytest -from PySide2 import QtWidgets -import sys -from numpy import ones -from SciDataTool import DataTime, DataLinspace, Data1D -from numpy import pi - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - X = DataLinspace(name="time", unit="s", initial=0, final=10, number=11) - Y = Data1D( - name="angle", - unit="rad", - values=[str(2 * i * pi / 21) for i in range(21)], - is_overlay=True, - is_components=True, - ) - field_2d = ones((11, 21)) - for i in range(11): - field_2d[i] *= i - - cls.Field = DataTime( - name="Airgap flux density", - symbol="B_r", - unit="T", - axes=[X, Y], - values=field_2d, - ) - - cls.UI = cls.Field.plot(is_show_fig=False, is_create_appli=False) - - @pytest.mark.gui - def test_check_combobox(self): - """Testing that the combobox is disabled if there is only one item""" - - # As we only have one axis then the combobox is disabled - assert ( - self.UI.w_plot_manager.w_axis_manager.w_axis_1.c_axis.isEnabled() == False - ) - - def test_check_axis_2(self): - """Testing that the second WAxisSelector is hidden as the second axis has is_overlay = True""" - - assert self.UI.w_plot_manager.w_axis_manager.w_axis_2.isHidden() == True - - def test_check_slice_op(self): - """Testing that the is_overlay axis generated a WSliceOperator widget""" - - axis_slice_op = self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].axis - overlay_axis = self.Field.get_axes()[1] - - assert axis_slice_op.name == overlay_axis.name - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - - # Testing that the checkbox are disabled if there is only one item in them - a.test_check_combobox() - - # Testing that axis 2 is hidden - a.test_check_axis_2() - - # Testing that the second axis is a WSliceOperator widget - a.test_check_slice_op() - - print("Done") diff --git a/Tests/GUI/DataND/test_one_axis.py b/Tests/GUI/DataND/test_one_axis.py deleted file mode 100644 index 61f66d77..00000000 --- a/Tests/GUI/DataND/test_one_axis.py +++ /dev/null @@ -1,57 +0,0 @@ -import pytest -from PySide2 import QtWidgets -import sys -from numpy import ones -from SciDataTool import DataTime, DataLinspace - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - X = DataLinspace(name="time", unit="s", initial=0, final=10, number=11) - field_1d = ones((11)) - for i in range(11): - field_1d[i] *= i - - Field = DataTime( - name="Airgap flux density", - symbol="B_r", - unit="T", - axes=[X], - values=field_1d, - ) - - cls.UI = Field.plot(is_show_fig=False, is_create_appli=False) - - @pytest.mark.gui - def test_check_combobox(self): - """Testing that the combobox is disabled if there is only one item""" - - # As we only have one axis then the combobox is disabled - assert ( - self.UI.w_plot_manager.w_axis_manager.w_axis_1.c_axis.isEnabled() == False - ) - - def test_check_axis_2(self): - """Testing that the second WAxisSelector is hidden as we only have one axis inside the data object""" - - assert self.UI.w_plot_manager.w_axis_manager.w_axis_2.isHidden() == True - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - - # Testing that the checkbox are disabled if there is only one item in them - a.test_check_combobox() - - # Testing that axis 2 is hidden - a.test_check_axis_2() - - print("Done") diff --git a/Tests/GUI/UI/test_animate.py b/Tests/GUI/UI/test_animate.py deleted file mode 100644 index 5bc0eeaf..00000000 --- a/Tests/GUI/UI/test_animate.py +++ /dev/null @@ -1,160 +0,0 @@ -from os.path import isfile -from os import remove -import pytest -from PySide2 import QtWidgets -import sys -from SciDataTool import DataPattern, DataLinspace, DataTime -from tenacity import sleep -from Tests.GUI import Field -from numpy.random import random -from numpy import pi - - -@pytest.mark.skip -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - # Slice = DataPattern( - # name="z", - # unit="m", - # values=[-1, -0.5], - # is_step=True, - # values_whole=[-1, -0.5, 0.5, 1], - # rebuild_indices=[0, 1, 1, 0], - # unique_indices=[0, 1, 1, 0], - # ) - - # f = 50 - # Nt_tot = 16 - # Na_tot = 20 - - # Time = DataLinspace( - # name="time", unit="s", initial=0, final=1 / (2 * f), number=Nt_tot - # ) - # Angle = DataLinspace( - # name="angle", unit="rad", initial=0, final=2 * pi, number=Na_tot - # ) - # Z = DataLinspace(name="z", unit="m", initial=-1, final=1, number=3) - - # field = random((Nt_tot, Na_tot, 2)) - - # Field = DataTime( - # name="Airgap flux density", - # symbol="B_r", - # unit="T", - # axes=[Time, Angle, Slice], - # values=field, - # ) - - cls.Field = Field - cls.UI = cls.Field.plot(is_show_fig=False, is_create_appli=False) - - @classmethod - def teardown_class(cls): - """Exit the app after the test""" - cls.app.quit() - - @pytest.mark.gui - def test_check_animation_2D(self): - """Testing that when the user click on the animate button, then animation is created and stored at the right place""" - - # Selection WSliceOperator + emitting signal to generate animation - w_slice_angle = self.UI.w_plot_manager.w_axis_manager.w_slice_op[0] - assert w_slice_angle.axis_name == "angle" - w_slice_angle.is_animate = True - w_slice_angle.generateAnimation.emit() - sleep(30) - - path_to_gif = self.UI.w_plot_manager.gif_path_list.pop(-1) - - # Making sure that the gif is saved at the right place - assert isfile(path_to_gif) == True - - # Closing the animation - self.UI.w_plot_manager.close_all_gif() - - # Deleting gif for future test - remove(path_to_gif) - - @pytest.mark.gui - def test_close_few_animation(self): - """Testing that the animation are correctly closed when there are more than one displayed""" - - # Selection WSliceOperator + emitting signal to generate animation - w_slice_angle = self.UI.w_plot_manager.w_axis_manager.w_slice_op[0] - assert w_slice_angle.axis_name == "angle" - w_slice_angle.is_animate = True - w_slice_angle.generateAnimation.emit() - sleep(30) - - path_to_file_a = self.UI.w_plot_manager.gif_path_list[-1] - - # Making sure that the gif are saved at the right place - assert isfile(path_to_file_a) == True - - # Selection WSliceOperator + emitting signal to generate animation - w_slice_z = self.UI.w_plot_manager.w_axis_manager.w_slice_op[1] - assert w_slice_z.axis_name == "z" - w_slice_z.is_animate = True - w_slice_z.generateAnimation.emit() - sleep(30) - - path_to_file_z = self.UI.w_plot_manager.gif_path_list[-1] - - # Making sure that the gif are saved at the right place - assert isfile(path_to_file_z) == True - - # Closing the animation - self.UI.w_plot_manager.close_all_gif() - - # Deleting gif for future test - remove(path_to_file_a) - remove(path_to_file_z) - - @pytest.mark.gui - def test_check_animation_3D(self): - """Testing that when the user click on the animate button, then animation is created and stored at the right place""" - - # Selecting an axis on Y to go 3D - self.UI.w_plot_manager.w_axis_manager.w_axis_2.c_axis.setCurrentIndex(1) - - # Selection WSliceOperator + emitting signal to generate animation - w_slice_angle = self.UI.w_plot_manager.w_axis_manager.w_slice_op[0] - assert w_slice_angle.axis_name == "z" - w_slice_angle.is_animate = True - w_slice_angle.generateAnimation.emit() - sleep(60) - - path_to_file = self.UI.w_plot_manager.gif_path_list.pop(-1) - - # Making sure that the gif is saved at the right place - assert isfile(path_to_file) == True - - # Closing the animation - self.UI.w_plot_manager.close_all_gif() - - # Deleting gif for future test - remove(path_to_file) - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - - # # Testing that the gif is created and located at the right path (2D plot) - # a.test_check_animation_2D() - - # # Testing that the animations are closed correctly - # a.test_close_few_animation() - - # # Testing that the gif is created and located at the right path (3D plot) - # a.test_check_animation_3D() - - # a.teardown_class() - print("Done") diff --git a/Tests/GUI/UI/test_axis_interaction.py b/Tests/GUI/UI/test_axis_interaction.py deleted file mode 100644 index 897d2c7a..00000000 --- a/Tests/GUI/UI/test_axis_interaction.py +++ /dev/null @@ -1,154 +0,0 @@ -import pytest -from PySide2 import QtWidgets -import sys -from Tests.GUI import Field -from SciDataTool.Functions.Plot import fft_dict, unit_dict - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - cls.UI = Field.plot(is_show_fig=False, is_create_appli=False) - - @pytest.mark.gui - def test_check_axis_removal(self): - """Test that make sure that when an axis is selected in axis 1 then it is not in axis 2""" - axis_1 = self.UI.w_plot_manager.w_axis_manager.w_axis_1 - axis_2 = self.UI.w_plot_manager.w_axis_manager.w_axis_2 - - for index_axis_1 in range(axis_1.c_axis.count()): - - axis_1.c_axis.setCurrentIndex(index_axis_1) - for index_axis_2 in range(axis_2.c_axis.count()): - axis_2.c_axis.setCurrentIndex(index_axis_2) - assert axis_1.c_axis.currentText() != axis_2.c_axis.currentText() - - @pytest.mark.gui - def test_check_filter(self): - """Checking that when Filter is selected, then the button is enabled. Otherwise it must be disabled.""" - # Making sure that the two axis have their default value (time and None) - axis_1 = self.UI.w_plot_manager.w_axis_manager.w_axis_1 - axis_2 = self.UI.w_plot_manager.w_axis_manager.w_axis_2 - - axis_1.c_axis.setCurrentIndex(0) - axis_2.c_axis.setCurrentIndex(0) - - for index in range(axis_1.c_action.count()): - axis_1.c_action.setCurrentIndex(index) - - if axis_1.c_action.currentText() == "Filter": - assert axis_1.b_filter.isEnabled() - else: - assert not axis_1.b_filter.isEnabled() - - @pytest.mark.gui - def test_check_ope_available(self): - """Test to make sure that the action available for each axis is correct""" - axis_1 = self.UI.w_plot_manager.w_axis_manager.w_axis_1 - - for index_axis in range(axis_1.c_axis.count()): - axis_1.c_axis.setCurrentIndex(index_axis) - - action_list = list() - for index_ope in range(axis_1.c_action.count()): - axis_1.c_action.setCurrentIndex(index_ope) - action_list.append(axis_1.c_action.currentText()) - - assert "None" in action_list - if axis_1.axes_list_obj[ - axis_1.axes_list.index(axis_1.axis_selected) - ].is_components: - assert "Filter" in action_list - else: - assert "Filter" not in action_list - - if axis_1.c_axis.currentText() in fft_dict: - assert "FFT" in action_list - else: - assert "FFT" not in action_list - - @pytest.mark.gui - def test_check_ope_sync(self): - """Checking that when FFT or '' is selected in axis 1 then the action of the axis 2 is synchronized to be the same""" - axis_1 = self.UI.w_plot_manager.w_axis_manager.w_axis_1 - axis_2 = self.UI.w_plot_manager.w_axis_manager.w_axis_2 - - # Making sure that two axis where we can apply a fft are selected - # selecting time - axis_1.c_axis.setCurrentIndex(0) - # selecting angle - axis_2.c_axis.setCurrentIndex(1) - - for index in range(axis_1.c_action.count()): - axis_1.c_action.setCurrentIndex(index) - - if ( - axis_1.c_action.currentText() == "" - or axis_1.c_action.currentText() == "FFT" - ): - assert axis_1.c_action.currentText() == axis_2.c_action.currentText() - - for index in range(axis_2.c_action.count()): - axis_2.c_action.setCurrentIndex(index) - - if ( - axis_2.c_action.currentText() == "" - or axis_2.c_action.currentText() == "FFT" - ): - assert axis_1.c_action.currentText() == axis_2.c_action.currentText() - - # Checking what happened on axis2 if axis1 already had an action selected - # selecting time on axis 1 - axis_1.c_axis.setCurrentIndex(0) - # selecting None on axis 2 - axis_2.c_axis.setCurrentIndex(0) - # selecting fft for axis 1 - axis_1.c_action.setCurrentIndex(1) - # selecting angle on axis 2 - axis_2.c_axis.setCurrentIndex(1) - # Making sure that FFT is selected on second axis - assert axis_2.c_action.currentIndex() == axis_1.c_action.currentIndex() - - @pytest.mark.gui - def test_check_unit_available(self): - """Test to make sure that the unit available are adapting correctly depending on the combination of axis and action""" - axis_1 = self.UI.w_plot_manager.w_axis_manager.w_axis_1 - - # Gathering all the units available for a specific combination and we compare it with the reference with is unit_dict - for index_axis in range(axis_1.c_axis.count()): - axis_1.c_axis.setCurrentIndex(index_axis) - for index_ope in range(axis_1.c_action.count()): - axis_1.c_action.setCurrentIndex(index_ope) - - unit_list = list() - for index_unit in range(axis_1.c_unit.count()): - unit_list.append(axis_1.c_unit.itemText(index_unit)) - - if isinstance(unit_dict[axis_1.get_axis_selected()], list): - assert unit_list == unit_dict[axis_1.get_axis_selected()] - else: - assert unit_list[0] == unit_dict[axis_1.get_axis_selected()] - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - - # Testing the removal of axis1 in axis2 - a.test_check_axis_removal() - # Checking the update of the action according to the choice of the axis selected - a.test_check_ope_available() - # Checking the update of the unit according to the action and the axis selected - a.test_check_unit_available() - # Checking the update of the FFT action of axis2 if selected in axis1 - a.test_check_ope_sync() - # Checking the interaction with filter button - a.test_check_filter() - - print("Done") diff --git a/Tests/GUI/UI/test_export.py b/Tests/GUI/UI/test_export.py deleted file mode 100644 index c1f55317..00000000 --- a/Tests/GUI/UI/test_export.py +++ /dev/null @@ -1,55 +0,0 @@ -import pytest -from PySide2 import QtWidgets -import sys -from Tests.GUI import Field -from Tests import save_gui_path -from os.path import join, isfile - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - cls.UI = Field.plot(is_show_fig=False, is_create_appli=False) - - @pytest.mark.gui - def test_check_export_path(self): - """Testing that the export function save a file at the right place by checking the path""" - - # Exporting the file - self.UI.w_plot_manager.export(save_gui_path) - - # Building the path where the file should be stored - param_list = [ - *self.UI.w_plot_manager.w_axis_manager.get_axes_selected(), - *self.UI.w_plot_manager.w_axis_manager.get_operation_selected(), - ] - - data_unit = ( - "[" + self.UI.w_plot_manager.w_range.get_field_selected()["unit"] + "]" - ) - - file_name = ( - (self.UI.w_plot_manager.data.name) - .replace("{", "[") - .replace("}", "]") - .replace(".", ",") - ) + ".csv" - - # Testing that the file exists - assert isfile(join(save_gui_path, file_name)) - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - - # Testing that the file exists in the right folder - a.test_check_export_path() - - print("Done") diff --git a/Tests/GUI/UI/test_filter_widget.py b/Tests/GUI/UI/test_filter_widget.py deleted file mode 100644 index 5b92b4a3..00000000 --- a/Tests/GUI/UI/test_filter_widget.py +++ /dev/null @@ -1,77 +0,0 @@ -import pytest -from PySide2 import QtWidgets -from PySide2.QtCore import Qt -import sys -from Tests.GUI import Field_filter -from SciDataTool.GUI.WFilter.WFilter import WFilter - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - cls.UI = Field_filter.plot( - "time", "loadcases[]", is_show_fig=False, is_create_appli=False - ) - - @pytest.mark.gui - def test_check_filter_buttons(self): - axis_1 = self.UI.w_plot_manager.w_axis_manager.w_axis_1 - slice_op = self.UI.w_plot_manager.w_axis_manager.w_slice_op[0] - assert not slice_op.b_action.isHidden() - - @pytest.mark.gui - def test_check_filter_table_init(self): - # Check that filter table initializes correctly - self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].b_action.clicked.emit() - wfilter = self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].current_dialog - assert isinstance(wfilter, WFilter) - assert wfilter.indices == [i for i in range(12)] - wfilter.b_Ok.clicked.emit() - assert wfilter.indices == [i for i in range(12)] - assert self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].indices == [ - i for i in range(12) - ] - # Select 3 indices and check table initialization - self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].indices = [0, 2, 5] - self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].b_action.clicked.emit() - wfilter = self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].current_dialog - assert isinstance(wfilter, WFilter) - assert wfilter.indices == [0, 2, 5] - - @pytest.mark.gui - def test_check_filter_table_manip(self): - self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].b_action.clicked.emit() - wfilter = self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].current_dialog - assert isinstance(wfilter, WFilter) - assert wfilter.indices == [0, 2, 5] - # Uncheck one line and check indices - wfilter.tab_indices.model().data( - wfilter.tab_indices.model().index( - 2, wfilter.tab_indices.model().columnCount() - 1 - ) - ).setCheckState(Qt.CheckState(False)) - wfilter.b_Ok.clicked.emit() - assert wfilter.indices == [0, 5] - # Sort by first column and check indices - self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].b_action.clicked.emit() - wfilter = self.UI.w_plot_manager.w_axis_manager.w_slice_op[0].current_dialog - assert isinstance(wfilter, WFilter) - wfilter.tab_indices.model().sort(0, Qt.AscendingOrder) - wfilter.b_Ok.clicked.emit() - assert list(set(wfilter.indices)) == [0, 5] - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - # a.test_check_filter_buttons() - # a.test_check_filter_table_init() - a.test_check_filter_table_manip() - - print("Done") diff --git a/Tests/GUI/UI/test_frozen_type.py b/Tests/GUI/UI/test_frozen_type.py deleted file mode 100644 index eaac43b3..00000000 --- a/Tests/GUI/UI/test_frozen_type.py +++ /dev/null @@ -1,119 +0,0 @@ -import pytest -from PySide2 import QtWidgets -import sys -from SciDataTool import DataTime, DataLinspace -from numpy import pi -from numpy.random import random - -f_t_test_list = list() - -f_t_test_list.append( - { - "axis": ["time", "angle"], - "is_create_appli": False, - "is_show_fig": False, - "frozen_type": 1, - } -) # Testing plot which is soft frozen - -f_t_test_list.append( - { - "axis": ["time", "angle"], - "is_create_appli": False, - "is_show_fig": False, - "frozen_type": 2, - } -) # Testing plot which is hard frozen - -f_t_test_list.append( - { - "axis": ["time", "angle"], - "is_create_appli": False, - "is_show_fig": False, - "frozen_type": 3, - } -) # Testing plot which is very hard frozen - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - f = 50 - Nt_tot = 16 - Na_tot = 20 - - Time = DataLinspace( - name="time", unit="s", initial=0, final=1 / (2 * f), number=Nt_tot - ) - Angle = DataLinspace( - name="angle", unit="rad", initial=0, final=2 * pi, number=Na_tot - ) - Z = DataLinspace(name="z", unit="m", initial=-1, final=1, number=3) - - field = random((Nt_tot, Na_tot, 3)) - - cls.Field = DataTime( - name="Airgap flux density", - symbol="B_r", - unit="T", - axes=[Time, Angle, Z], - values=field, - ) - - @pytest.mark.gui - @pytest.mark.parametrize("test_dict", f_t_test_list) - def test_check_frozen_type(self, test_dict): - """Test to make sure that the auto-plot works as intended""" - - # Launching the auto plot with info from the dict - self.UI = self.Field.plot( - test_dict["axis"][0], - test_dict["axis"][1], - is_create_appli=test_dict["is_create_appli"], - is_show_fig=test_dict["is_show_fig"], - frozen_type=test_dict["frozen_type"], - ) - - # Checking that we fill the combobox with the requested axis if the frozen type is "soft" (==1) - if test_dict["frozen_type"] == 1: - assert ( - self.UI.w_plot_manager.w_axis_manager.w_axis_1.get_axes_name() - == test_dict["axis"] - ) - assert ( - self.UI.w_plot_manager.w_axis_manager.w_axis_2.get_axes_name() - == test_dict["axis"] - ) - - # Checking that we disable the combobox if the frozen type chosen is "hard" (==2) - elif test_dict["frozen_type"] == 2: - assert not self.UI.w_plot_manager.w_axis_manager.w_axis_1.c_axis.isEnabled() - assert not self.UI.w_plot_manager.w_axis_manager.w_axis_2.c_axis.isEnabled() - - # Checking that we disable the axes and the operations if the frozen type chosen is "very hard" (3) - elif test_dict["frozen_type"] == 3: - assert not self.UI.w_plot_manager.w_axis_manager.w_axis_1.c_axis.isEnabled() - assert not self.UI.w_plot_manager.w_axis_manager.w_axis_2.c_axis.isEnabled() - - for w_op in self.UI.w_plot_manager.w_axis_manager.w_slice_op: - assert not w_op.c_operation.isEnabled() - assert w_op.lf_value.isEnabled() - assert w_op.slider.isEnabled() - - -if __name__ == "__main__": - - for ii, f_t_test in enumerate(f_t_test_list): - a = TestGUI() - a.setup_class() - - # Testing that the checkbox are disabled if there is only one item in them - a.test_check_frozen_type(f_t_test) - - print("Test n°" + str(ii) + " done") diff --git a/Tests/GUI/UI/test_refresh_policy.py b/Tests/GUI/UI/test_refresh_policy.py deleted file mode 100644 index ffbdf1d6..00000000 --- a/Tests/GUI/UI/test_refresh_policy.py +++ /dev/null @@ -1,84 +0,0 @@ -import pytest -from PySide2 import QtWidgets -from Tests.GUI import Field -import sys - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - cls.UI = Field.plot(is_show_fig=False, is_create_appli=False) - - @pytest.mark.gui - def test_check_autorefresh_update(self): - """Testing that the auto-refresh combobox update the policy correctly""" - - self.UI.is_auto_refresh.setChecked(True) - assert self.UI.auto_refresh == True - - self.UI.is_auto_refresh.setChecked(False) - assert self.UI.auto_refresh == False - - @pytest.mark.gui - def test_check_signal(self): - """Testing that the signals are handled correctly depending on the autorefresh policy""" - - # Setting the policy to true - self.UI.is_auto_refresh.setChecked(True) - # Changing axis 1 to send the signal to refresh the plot - self.UI.w_plot_manager.w_axis_manager.w_axis_1.c_axis.setCurrentIndex(1) - # making sure that the is_plot_updated is set to True as Autorefresh is activated - assert self.UI.is_plot_updated == True - - # Setting the policy to true - self.UI.is_auto_refresh.setChecked(False) - # Changing axis 1 to send the signal to refresh the plot - self.UI.w_plot_manager.w_axis_manager.w_axis_1.c_axis.setCurrentIndex(0) - # making sure that the is_plot_updated is set to False as Autorefresh is desactivated - assert self.UI.is_plot_updated == False - - @pytest.mark.gui - def test_check_b_refresh_auto_refresh(self): - """Testing that the refresh button is enabled and disabled according to the action on the UI""" - - # Testing that when auto-refresh is checked, then the refresh button is disabled - self.UI.is_auto_refresh.setChecked(True) - assert self.UI.b_refresh.isEnabled() == False - - # Testing that when auto-refresh is unchecked, then the refresh button is enabled - self.UI.is_auto_refresh.setChecked(False) - assert self.UI.b_refresh.isEnabled() == True - - @pytest.mark.gui - def test_check_b_refresh_auto(self): - "Testing that when a plot is updated, then the refresh button is disabled and that we enable it once the UI is modified" - - # After updating the plot, the button should be disabled - self.UI.update_plot() - assert self.UI.b_refresh.isEnabled() == False - - # After modifying the UI, the button shoud be enabled - self.UI.w_plot_manager.updatePlot.emit() - assert self.UI.b_refresh.isEnabled() == True - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - - # Testing the checkbox - a.test_check_autorefresh_update() - # Verifying the handling of the signals - a.test_check_signal() - # Testing that we disable/enable b_refresh according to is_auto_refresh (checkBox) - a.test_check_b_refresh_auto_refresh() - # Testing that the button is disabled after the plot is updated and enabled after changing the UI - a.test_check_b_refresh_auto - - print("Done") diff --git a/Tests/GUI/UI/test_setup_GUI.py b/Tests/GUI/UI/test_setup_GUI.py deleted file mode 100644 index f6b5b10a..00000000 --- a/Tests/GUI/UI/test_setup_GUI.py +++ /dev/null @@ -1,123 +0,0 @@ -import pytest -from PySide2 import QtWidgets -import sys -from Tests.GUI import Field -from SciDataTool.Functions.Plot import ifft_dict -from SciDataTool.Functions import parser - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - cls.UI = Field.plot(is_show_fig=False, is_create_appli=False) - - @pytest.mark.gui - def test_check_axes(self): - """Checking that the axes_list inside WAxisSelector corresponds to the axes of Field""" - axes_expected = [axis.name for axis in Field.get_axes()] - assert self.UI.w_plot_manager.w_axis_manager.w_axis_1.axes_list == axes_expected - # On the second axis, we also have None as a possibility - axes_expected.insert(0, "None") - assert self.UI.w_plot_manager.w_axis_manager.w_axis_2.axes_list == axes_expected - - @pytest.mark.gui - def test_check_data_sel(self): - """Checking the axis/axes of DataSelection have not been selected by the user before""" - - axes_selected = [ - self.UI.w_plot_manager.w_axis_manager.w_axis_1.get_axis_selected(), - self.UI.w_plot_manager.w_axis_manager.w_axis_2.get_axis_selected(), - ] - - for wid in self.UI.w_plot_manager.w_axis_manager.w_slice_op: - assert not wid.axis in axes_selected - - @pytest.mark.gui - def test_check_range(self): - """Method that check that the units and the values of min and max set by default in the app corresponds to those of the field.""" - - # Checking the unit of WDataRange - assert Field.unit == self.UI.w_plot_manager.w_range.c_unit.currentText() - - # Recovering the axis selected and their units - axes_selected = self.UI.w_plot_manager.w_axis_manager.get_axes_selected() - # Recovering the operation on the other axes - data_selection = self.UI.w_plot_manager.w_axis_manager.get_operation_selected() - - axes_selected_parsed = parser.read_input_strings(axes_selected, axis_data=None) - - # Recovering the minimum and the maximum of the field - if len(axes_selected) == 1: - # Checking that the right name is given to the groupBow with WDataRange - assert self.UI.w_plot_manager.w_range.g_range.title() == "Y Range" - - # Checking if the field is plotted in fft, then we use get_magnitude_along - # Otherwise we use get_along - - if axes_selected_parsed[0].name in ifft_dict: - field_value = Field.get_magnitude_along( - data_selection[0], data_selection[1], axes_selected[0] - ) - else: - field_value = Field.get_along( - data_selection[0], data_selection[1], axes_selected[0] - ) - - field_min = field_value[Field.symbol].min() - field_max = field_value[Field.symbol].max() - - elif len(axes_selected) == 2: - # Checking that the right name is given to the groupBow with WDataRange - assert self.UI.w_plot_manager.w_range.g_range.title() == "Z" - - # Checking if the field is plotted in fft, then we use get_magnitude_along - # Otherwise we use get_along - if ( - axes_selected_parsed[0].name in ifft_dict - and axes_selected_parsed[1].name in ifft_dict - ): - field_value = Field.get_magnitude_along( - data_selection[0], axes_selected[0], axes_selected[1] - ) - else: - field_value = Field.get_along( - data_selection[0], axes_selected[0], axes_selected[1] - ) - - field_min = field_value[Field.symbol].min() - field_max = field_value[Field.symbol].max() - - # Taking into account the delta that we add to improve the plot - delta = field_max - field_min - - # Checking that the values are close enough - eps = 1e-4 - assert ( - abs( - field_min - delta * 0.05 - self.UI.w_plot_manager.w_range.lf_min.value() - ) - < eps - ) - assert ( - abs( - field_max + delta * 0.05 - self.UI.w_plot_manager.w_range.lf_max.value() - ) - < eps - ) - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - - a.test_check_axes() - a.test_check_data_sel() - a.test_check_range() - - print("Done") diff --git a/Tests/GUI/UI/test_slice_operation.py b/Tests/GUI/UI/test_slice_operation.py deleted file mode 100644 index 58a3bbbe..00000000 --- a/Tests/GUI/UI/test_slice_operation.py +++ /dev/null @@ -1,89 +0,0 @@ -import pytest -from PySide2 import QtWidgets -import sys -from Tests.GUI import Field - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - cls.UI = Field.plot(is_show_fig=False, is_create_appli=False) - - @pytest.mark.gui - def test_check_layout(self): - """Test that the layout is set up according to the operation selected""" - - for wid in self.UI.w_plot_manager.w_axis_manager.w_slice_op: - for ope in range(wid.c_operation.count()): - - wid.blockSignals(True) - wid.c_operation.setCurrentIndex(ope) - - if wid.c_operation.currentText() == "slice": - assert ( - not wid.slider.isHidden() - and not wid.lf_value.isHidden() - and wid.b_action.isHidden() - ) - - elif wid.c_operation.currentText() == "slice (fft)": - assert ( - not wid.slider.isHidden() - and not wid.lf_value.isHidden() - and wid.b_action.isHidden() - ) - - elif wid.c_operation.currentText() == "overlay": - assert ( - wid.slider.isHidden() - and wid.lf_value.isHidden() - and not wid.b_action.isHidden() - ) - - else: - assert ( - wid.slider.isHidden() - and wid.lf_value.isHidden() - and wid.b_action.isHidden() - ) - - wid.blockSignals(False) - - @pytest.mark.gui - def test_check_slider_floatEdit(self): - """Testing that the slider is updated correctly according to the slider and vice versa""" - - for wid in self.UI.w_plot_manager.w_axis_manager.w_slice_op: - if not wid.c_operation.currentText() in ["slice", "slice (fft)"]: - wid.c_operation.setCurrentIndex(0) - - # Making sure that we have the same number of index inside the slider as in axis_value - assert (wid.slider.maximum() - wid.slider.minimum() + 1) == len( - wid.axis_value - ) - # Modifying the value of the slider and checking if the floatEdit change correctly - wid.slider.setValue(0) - assert wid.lf_value.value() == wid.axis_value[wid.slider.value()] - - # Modifying the floatEdit and making sure that the slider is at the right index - wid.lf_value.setValue(wid.axis_value[-1]) - wid.update_slider() - assert wid.axis_value[wid.slider.value()] == wid.axis_value[-1] - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - - # Checking the interaction between the slider and floatEdit - a.test_check_slider_floatEdit() - # Checking the generation of the layout - a.test_check_layout() - - print("Done") diff --git a/Tests/GUI/UI/test_string_gen_GUI.py b/Tests/GUI/UI/test_string_gen_GUI.py deleted file mode 100644 index 975299b9..00000000 --- a/Tests/GUI/UI/test_string_gen_GUI.py +++ /dev/null @@ -1,208 +0,0 @@ -import pytest -from PySide2 import QtWidgets -import sys -from Tests.GUI import Field -from SciDataTool.Functions.Plot import ifft_dict, fft_dict, axes_dict -from SciDataTool.Functions import parser -from SciDataTool.GUI.WSliceOperator.WSliceOperator import type_extraction_dict - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - cls.UI = Field.plot(is_show_fig=False, is_create_appli=False) - - @pytest.mark.gui - def test_check_axes_strings(self): - "Testing that the string generated corresponds to the info given by the user" - axis_1 = self.UI.w_plot_manager.w_axis_manager.w_axis_1 - axis_2 = self.UI.w_plot_manager.w_axis_manager.w_axis_2 - - for index_axis_1 in range(axis_1.c_axis.count()): - axis_1.c_axis.setCurrentIndex(index_axis_1) - for index_axis_2 in range(axis_2.c_axis.count()): - axis_2.c_axis.setCurrentIndex(index_axis_2) - - axes_selected = parser.read_input_strings( - self.UI.w_plot_manager.w_axis_manager.get_axes_selected(), - axis_data=None, - ) - - # Checking that the axis string is correct - if axes_selected[0].name in ifft_dict: - assert ( - ifft_dict[axes_selected[0].name] == axis_1.c_axis.currentText() - and axis_1.c_action.currentText() == "FFT" - ) - - elif axes_selected[0].name in axes_dict: - assert ( - axes_dict[axes_selected[0].name] == axis_1.c_axis.currentText() - ) - - else: - assert axes_selected[0].name == axis_1.c_axis.currentText() - # Checking that the unit in the string is correct - assert axes_selected[0].unit == axis_1.c_unit.currentText() - - # if an axis is selected on axis 2 the we check its string as well - if len(axes_selected) == 2: - - # Checking that the axis string is correct - if axes_selected[1].name in ifft_dict: - assert ( - ifft_dict[axes_selected[1].name] - == axis_2.c_axis.currentText() - and axis_2.c_action.currentText() == "FFT" - ) - - elif axes_selected[1].name in axes_dict: - assert ( - axes_dict[axes_selected[1].name] - == axis_2.c_axis.currentText() - ) - - else: - assert axes_selected[1].name == axis_2.c_axis.currentText() - # Checking that the unit in the string is correct - assert axes_selected[1].unit == axis_2.c_unit.currentText() - - @pytest.mark.gui - def test_check_axis_updated(self): - """Test to make sure that when we switch from time to frequency (or from angle to wavenb), the string is updated correclty""" - axis_1 = self.UI.w_plot_manager.w_axis_manager.w_axis_1 - axis_2 = self.UI.w_plot_manager.w_axis_manager.w_axis_2 - - for index_axis in range(axis_1.c_axis.count()): - axis_1.c_axis.setCurrentIndex(index_axis) - axes = list() - - if axis_1.get_axis_selected() in fft_dict: - # Recovering the string when '' is selected - axis_1.c_action.setCurrentIndex(0) - axes.append(axis_1.get_axis_unit_selected()) - # Recovering the string when 'FFT' is selected - axis_1.c_action.setCurrentIndex(1) - axes.append(axis_1.get_axis_unit_selected()) - # Processing the string to compare them - axes_parsed = parser.read_input_strings(axes, axis_data=None) - - assert axes_parsed[1].name == fft_dict[axes_parsed[0].name] - - @pytest.mark.gui - def test_check_range_updated(self): - """Testing how WDataRange string are generated after updating the widget""" - - # Test 1 : Making sure that min and max are updated - new_min = 15.0 - new_max = 50.0 - self.UI.w_plot_manager.w_range.lf_min.setValue(new_min) - self.UI.w_plot_manager.w_range.lf_max.setValue(new_max) - - dict_gen = self.UI.w_plot_manager.w_range.get_field_selected() - - assert dict_gen["min"] == new_min and dict_gen["max"] == new_max - - # Test 2 : Making sure that min and max are switched if min > max - self.UI.w_plot_manager.w_range.lf_min.setValue(new_max) - self.UI.w_plot_manager.w_range.lf_max.setValue(new_min) - self.UI.w_plot_manager.w_range.update_needed() - - dict_gen = self.UI.w_plot_manager.w_range.get_field_selected() - - assert dict_gen["min"] == new_min and dict_gen["max"] == new_max - - # Test 3 : Checking that the unit is updated when changed - if self.UI.w_plot_manager.w_range.c_unit.count() > 1: - for index_unit in range(self.UI.w_plot_manager.w_range.c_unit.count()): - self.UI.w_plot_manager.w_range.c_unit.setCurrentIndex(index_unit) - - dict_gen = self.UI.w_plot_manager.w_range.get_field_selected() - - assert ( - dict_gen["unit"] - == self.UI.w_plot_manager.w_range.c_unit.currentText() - ) - - @pytest.mark.gui - def test_check_string_dataselection(self): - """Test to make sure that when DataSelection is modified, the string is updated correctly""" - - # Modifying the operation and making sure that the string is updated - for wid in self.UI.w_plot_manager.w_axis_manager.w_slice_op: - wid.blockSignals(True) - for index_ope in range(wid.c_operation.count()): - - wid.c_operation.setCurrentIndex(index_ope) - - operation = wid.c_operation.currentText() - if operation == "slice": - assert wid.get_operation_selected() == ( - wid.axis.name - + "=" - + str(wid.lf_value.value()) - + "{" - + wid.unit - + "}", - False, - ) - elif operation == "slice (fft)": - assert wid.get_operation_selected() == ( - fft_dict[wid.axis.name] + "=" + str(wid.lf_value.value()), - None, - ) - elif operation.split(" ")[0] in type_extraction_dict: - assert wid.get_operation_selected() == ( - wid.axis.name + type_extraction_dict[operation.split(" ")[0]], - None, - ) - else: - assert wid.get_operation_selected() == None - - wid.blockSignals(False) - - for wid in self.UI.w_plot_manager.w_axis_manager.w_slice_op: - wid.blockSignals(True) - for index_ope in range(wid.c_operation.count()): - - wid.c_operation.setCurrentIndex(index_ope) - - operation = wid.c_operation.currentText() - if operation == "slice": - # Modifying the slider (to put it at a different position) - index = 5 - wid.slider.setValue(index) - action = parser.read_input_strings( - [wid.get_operation_selected()[0]], axis_data=None - ) - assert action[0].input_data[0] == wid.lf_value.value() - - # Modifying the floatEdit by setting it to the initial value (index = 0) - wid.lf_value.setValue(wid.axis.initial) - wid.update_slider() - action = parser.read_input_strings( - [wid.get_operation_selected()[0]], axis_data=None - ) - assert action[0].input_data[0] == wid.lf_value.value() - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - - # Checking that the string generated for the axes are correct - a.test_check_axes_strings() - # Making sure that the string is updated according to the change of the UI (FFT to '' for ex) - a.test_check_axis_updated() - # When modifying WDataRange, making sure that the string is updated correctly - a.test_check_range_updated() - # When modifying DataSelection, making sure that the string is updated correctly (slice to sum for ex) - a.test_check_string_dataselection() - - print("Done") diff --git a/Tests/GUI/VectorField/__init__.py b/Tests/GUI/VectorField/__init__.py deleted file mode 100644 index 266b90aa..00000000 --- a/Tests/GUI/VectorField/__init__.py +++ /dev/null @@ -1,48 +0,0 @@ -from SciDataTool import DataLinspace, DataTime, VectorField, Norm_ref -from numpy import pi, cos, meshgrid - -f = 50 -Time = DataLinspace( - name="time", - unit="s", - initial=0, - final=1 / f, - number=10, - include_endpoint=False, -) - -Angle = DataLinspace( - name="angle", - unit="rad", - initial=0, - final=2 * pi, - number=20, - include_endpoint=False, -) - -ta, at = meshgrid(Time.get_values(), Angle.get_values()) -field = 5 * cos(2 * pi * f * ta + 3 * at) - -Field_r = DataTime( - name="Radial field", - symbol="X_r", - unit="m", - normalizations={"ref": Norm_ref(ref=2e-5)}, - axes=[Time, Angle], - values=field.T, -) - -Field_t = DataTime( - name="Tangential field", - symbol="X_t", - unit="m", - normalizations={"ref": Norm_ref(ref=2e-5)}, - axes=[Time, Angle], - values=-field.T, -) - -VecField = VectorField( - name="Example field", - symbol="X", - components={"radial": Field_r, "tangential": Field_t}, -) diff --git a/Tests/GUI/VectorField/test_auto_plot_vectorfield.py b/Tests/GUI/VectorField/test_auto_plot_vectorfield.py deleted file mode 100644 index 9d6ef88d..00000000 --- a/Tests/GUI/VectorField/test_auto_plot_vectorfield.py +++ /dev/null @@ -1,291 +0,0 @@ -import pytest -import sys -from PySide2 import QtWidgets - -from Tests.GUI.VectorField import VecField -from numpy.testing import assert_almost_equal -from SciDataTool.Functions import parser - -a_p_list = list() - -a_p_list.append( - { - "axis": ["time"], - "action": ["angle[-1]"], - "is_create_appli": False, - "is_show_fig": False, - "component": "comp_x", - } -) # Testing the autoplot for XY plot and component 'comp_x' - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": [], - "is_create_appli": False, - "is_show_fig": False, - "component": "comp_x", - } -) # Testing the autoplot for 2D plot and component 'comp_x' - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": [], - "is_create_appli": False, - "is_show_fig": False, - "component": "comp_y", - } -) # Testing the autoplot for 2D plot and component 'comp_y' - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": [], - "is_create_appli": False, - "is_show_fig": False, - "component": "radial", - } -) # Testing the autoplot for 2D plot and component 'radial' - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": [], - "is_create_appli": False, - "is_show_fig": False, - "component": "tangential", - } -) # Testing the autoplot for 2D plot and component 'tangential' - -a_p_list.append( - { - "axis": ["time", "angle{°}"], - "action": [], - "is_create_appli": False, - "is_show_fig": False, - "component": "axial", - } -) # Testing the autoplot with an unavaible component - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - cls.VecField = VecField - - @pytest.mark.gui - @pytest.mark.parametrize("test_dict", a_p_list) - def test_check_a_p(self, test_dict): - """Test to make sure that the auto-plot works as intended""" - - # Launching the auto plot with info from the dict - if len(test_dict["axis"]) == 1: - self.UI = self.VecField.plot( - test_dict["axis"][0], - test_dict["action"][0], - is_create_appli=test_dict["is_create_appli"], - is_show_fig=test_dict["is_show_fig"], - component=test_dict["component"], - ) - - elif len(test_dict["axis"]) == 2: - self.UI = self.VecField.plot( - test_dict["axis"][0], - test_dict["axis"][1], - is_create_appli=test_dict["is_create_appli"], - is_show_fig=test_dict["is_show_fig"], - component=test_dict["component"], - ) - - # Step 0 : Making sure that the components in the combobox : - if ( - "axial" not in self.VecField.components - or "comp_z" not in self.VecField.components - ): - assert self.UI.w_plot_manager.w_vect_selector.component_list == [ - "radial", - "circumferential", - "x-axis component", - "y-axis component", - ] - else: - assert self.UI.w_plot_manager.w_vect_selector.component_list == [ - "radial", - "circumferential", - "axial", - "x-axis component", - "y-axis component", - "z-axis component", - ] - - # Step 1 : making sure that the right component is selected - if test_dict["component"] in ["radial"]: - assert_almost_equal( - self.UI.w_plot_manager.data.values, - VecField.to_rphiz().components[test_dict["component"]].values, - 7, - ) - - elif test_dict["component"] in ["comp_x", "comp_y"]: - assert_almost_equal( - self.UI.w_plot_manager.data.values, - VecField.to_xyz().components[test_dict["component"]].values, - 7, - ) - - elif ( - test_dict["component"] == "axial" - and test_dict["component"] in self.VecField.components - ): - assert_almost_equal( - self.UI.w_plot_manager.data.values, - VecField.to_xyz().components[test_dict["component"]].values, - 7, - ) - - elif ( - test_dict["component"] == "comp_z" - and test_dict["component"] in self.VecField.components - ): - assert_almost_equal( - self.UI.w_plot_manager.data.values, - VecField.to_xyz().components[test_dict["component"]].values, - 7, - ) - - elif ( - test_dict["component"] == "tangential" - and test_dict["component"] in self.VecField.components - ): - assert_almost_equal( - self.UI.w_plot_manager.data.values, - VecField.to_rphiz().components[test_dict["component"]].values, - 7, - ) - - else: - assert_almost_equal( - self.UI.w_plot_manager.data.values, - VecField.to_rphiz().components["radial"].values, - 7, - ) - - # Step 2 : Checking that the axes and the operations given/sent are correct - # Recovering the string generated - axes_sent = parser.read_input_strings( - self.UI.w_plot_manager.w_axis_manager.get_axes_selected(), axis_data=None - ) - - actions_sent = parser.read_input_strings( - self.UI.w_plot_manager.w_axis_manager.get_operation_selected(), - axis_data=None, - ) - - # Step 2-1 : Checking the axes (1 and 2 if given) - assert len(axes_sent) == len(test_dict["axis"]) - - axes_given = parser.read_input_strings(test_dict["axis"], axis_data=None) - - # Checking the name of the axes - assert axes_sent[0].name == axes_given[0].name - - # Checking the unit - if axes_given[0].unit == "SI": - # If the unit is not given, then we make sure that the unit by default is selected - assert axes_sent[ - 0 - ].unit == self.UI.w_plot_manager.w_axis_manager.w_axis_1.get_axis_unit_selected().split( - "{" - )[ - 1 - ].rstrip( - "}" - ) - else: - assert axes_sent[0].unit == axes_given[0].unit - - # Checking axis 2 if we have one - if len(axes_sent) == 2: - assert axes_sent[1].name == axes_given[1].name - if axes_given[1].unit == "SI": - # If the unit is not given, then we make sure that the unit by default is selected - assert ( - axes_sent[1].unit - == self.UI.w_plot_manager.w_axis_manager.w_axis_2.get_current_unit() - ) - - # Step 2-2 : Checking the actions - if test_dict["action"] != [None]: - - actions_given = parser.read_input_strings( - test_dict["action"], axis_data=None - ) - assert len(actions_sent) == len(actions_given) - - for i in range(len(actions_sent)): - # Checking the name of the axis - assert actions_sent[i].name == actions_given[i].name - - # Checking the operation given - assert actions_sent[i].extension == actions_given[i].extension - - # Special case when slice is the operation selected (we have to check the index) - if actions_sent[i].extension == "single": - - if actions_given[i].indices[0] < 0: - # if we gave a negative index, we have to update the value nmanally (slider accept/return only positive value) - assert ( - self.UI.w_plot_manager.w_axis_manager.w_slice_op[ - i - ].slider.value() - == self.UI.w_plot_manager.w_axis_manager.w_slice_op[ - i - ].slider.maximum() - + actions_given[i].indices[0] - ) - else: - assert ( - self.UI.w_plot_manager.w_axis_manager.w_slice_op[ - i - ].slider.value() - == actions_given[i].indices[0] - ) - - # Checking the units - if actions_given[i].unit == "SI": - assert ( - # If the unit is not given, then we make sure that the unit by default is selected - actions_sent[i].unit - == self.UI.w_plot_manager.w_axis_manager.w_slice_op[i].unit - ) - else: - assert actions_sent[i].unit == actions_given[i].unit - else: - # If no action are specified, then we apply a slice on the first index for all the axes - for i in range(len(actions_sent)): - assert ( - actions_sent[i].name - == self.UI.w_plot_manager.w_axis_manager.w_slice_op[i].axis.name - ) - assert actions_sent[i].extension == "single" - assert actions_sent[i].indices[0] == 0 - assert ( - actions_sent[i].unit - == self.UI.w_plot_manager.w_axis_manager.w_slice_op[i].unit - ) - - -if __name__ == "__main__": - - for ii, a_p_test in enumerate(a_p_list): - a = TestGUI() - a.setup_class() - a.test_check_a_p(a_p_test) - print("Test n°" + str(ii) + " done") diff --git a/Tests/GUI/VectorField/test_vectorfield.py b/Tests/GUI/VectorField/test_vectorfield.py deleted file mode 100644 index 1d25aa55..00000000 --- a/Tests/GUI/VectorField/test_vectorfield.py +++ /dev/null @@ -1,83 +0,0 @@ -import pytest -from PySide2 import QtWidgets -import sys -from Tests.GUI.VectorField import VecField - - -class TestGUI(object): - @classmethod - def setup_class(cls): - """Run at the begining of every test to setup the gui""" - if not QtWidgets.QApplication.instance(): - cls.app = QtWidgets.QApplication(sys.argv) - else: - cls.app = QtWidgets.QApplication.instance() - - cls.VecField = VecField - cls.UI = cls.VecField.plot(is_show_fig=False, is_create_appli=False) - - @pytest.mark.gui - def test_check_component_selected(self): - """Testing that when the user select a component, then it is used for the rest of the calculation""" - w_selector = self.UI.w_plot_manager.w_vect_selector - - for index_component in range(w_selector.c_component.count()): - if w_selector.c_component.itemText(index_component) not in [ - "Polar coordinates", - "Cartesian coordinates", - ]: - w_selector.c_component.setCurrentIndex(index_component) - component_selected = w_selector.c_component.currentText() - - if component_selected in ["radial", "tangential", "axial"]: - assert ( - self.UI.w_plot_manager.data - == self.UI.w_plot_manager.data_obj.to_rphiz().components[ - component_selected - ] - ) - - elif component_selected in ["comp_x", "comp_y", "comp_z"]: - assert ( - self.UI.w_plot_manager.data - == self.UI.w_plot_manager.data_obj.to_xyz().components[ - component_selected - ] - ) - - @pytest.mark.gui - def test_check_hide_show(self): - """Testing that the UI is rightly updated as we are plotting a VectorField""" - - # Testing that the groupbox is shown - assert not self.UI.w_plot_manager.w_vect_selector.isHidden() - # Testing that the referential is hidden - assert self.UI.w_plot_manager.w_vect_selector.c_referential.isHidden() - assert self.UI.w_plot_manager.w_vect_selector.in_referential.isHidden() - - # Testing that axial and comp_z are not available if they are not in VectorField - - components_list = list() - for i in range(self.UI.w_plot_manager.w_vect_selector.c_component.count()): - components_list.append( - self.UI.w_plot_manager.w_vect_selector.c_component.currentText() - ) - - if not "axial" in self.VecField.components: - assert not "axial" in components_list - assert not "z-axis component" in components_list - - elif not "tangential" in self.VecField.components: - assert not "circumferential" in components_list - - -if __name__ == "__main__": - a = TestGUI() - a.setup_class() - - # Testing the checkbox - # a.test_check_hide_show() - # Verifying the handling of the signals - a.test_check_component_selected() - - print("Done") diff --git a/Tests/GUI/__init__.py b/Tests/GUI/__init__.py deleted file mode 100644 index c01e7778..00000000 --- a/Tests/GUI/__init__.py +++ /dev/null @@ -1,60 +0,0 @@ -from SciDataTool import DataLinspace, DataTime, Data1D -from numpy.random import random -from numpy import pi, zeros - - -f = 50 -Nt_tot = 16 -Na_tot = 20 - -Time = DataLinspace(name="time", unit="s", initial=0, final=1 / (2 * f), number=Nt_tot) -Angle = DataLinspace(name="angle", unit="rad", initial=0, final=2 * pi, number=Na_tot) -Z = DataLinspace(name="z", unit="m", initial=-1, final=1, number=3) - -field = random((Nt_tot, Na_tot, 3)) - -Field = DataTime( - name="Airgap flux density", - symbol="B_r", - unit="T", - axes=[Time, Angle, Z], - values=field, -) - -X = DataLinspace(name="time", unit="s", initial=0, final=1, number=11) -Y = Data1D( - name="loadcases", - unit="", - values=[ - "r=0, radial, stator", - "r=-2, radial, stator", - "r=2, radial, stator", - "r=0, circumferential, stator", - "r=-2, circumferential, stator", - "r=2, circumferential, stator", - "r=0, radial, rotor", - "r=-2, radial, rotor", - "r=2, radial, rotor", - "r=0, circumferential, rotor", - "r=-2, circumferential, rotor", - "r=2, circumferential, rotor", - ], - is_components=True, - delimiter=", ", - filter={ - "wavenumber": ["r=0", "r=-2", "r=2"], - "direction": ["radial", "circumferential"], - "application": ["stator", "rotor"], - }, - is_overlay=True, -) -field_filter = zeros((11, 12)) -for i in range(12): - field_filter[:, i] = i -Field_filter = DataTime( - name="Airgap flux density", - symbol="B_r", - unit="T", - axes=[X, Y], - values=field_filter, -) diff --git a/Tests/GUI/dev_GUI.py b/Tests/GUI/dev_GUI.py deleted file mode 100644 index a93e98d8..00000000 --- a/Tests/GUI/dev_GUI.py +++ /dev/null @@ -1,150 +0,0 @@ -from PySide2.QtWidgets import * -from SciDataTool.Classes.DataLinspace import DataLinspace -from SciDataTool.Classes.DataTime import DataTime -from SciDataTool.Classes.VectorField import VectorField -from SciDataTool import Norm_ref -import numpy as np - - -if __name__ == "__main__": - X = DataLinspace(name="time", unit="s", initial=0, final=10, number=11) - Y = DataLinspace(name="angle", unit="rad", initial=0, final=2 * np.pi, number=21) - Z = DataLinspace(name="z", unit="m", initial=-1, final=1, number=3, is_overlay=True) - y, x = np.meshgrid(Y.get_values(), X.get_values()) - field = x + y - field_3d = np.zeros((11, 21, 3)) - for i in range(3): - field_3d[:, :, i] = (i + 1) * field - - Field = DataTime( - name="Airgap flux density", - symbol="B_r", - unit="T", - axes=[X, Y, Z], - values=field_3d, - ) - - test = "plot" - # test = "autoplot" - # test = "plot_2axis" - # test = "oneaxis" - # test = "vect" - # test = "is_overlay" - - if test == "plot": - Field.plot() - - elif test == "plot_2axis": - X = DataLinspace(name="time", unit="s", initial=0, final=10, number=11) - Y = DataLinspace( - name="angle", unit="rad", initial=0, final=2 * np.pi, number=21 - ) - y, x = np.meshgrid(Y.get_values(), X.get_values()) - field = x + y - field_2d = np.zeros((11, 21)) - for i in range(21): - field_2d[:, i] *= i + 1 - - Field = DataTime( - name="Airgap flux density", - symbol="B_r", - unit="T", - axes=[X, Y], - values=field_2d, - ) - - Field.plot("freqs", "angle[2]", unit="T", z_max=50) - - elif test == "autoplot": - # Field.plot("angle{°}", "time", "z[2]", unit="T", z_max=50) - Field.plot("time", "angle", "z[2]", frozen_type=1) - # Field.plot("angle{°}", "z") - # Field.plot("time", "angle[0]", "z[2]", unit="T", z_max=10) - # Field.plot("wavenumber", "freqs", "z[2]", unit="T", z_max=50) - # Field.plot("freqs", "wavenumber", "z=mean", unit="T", z_max=50) - - elif test == "is_overlay": - Z = DataLinspace( - name="z", unit="m", initial=-1, final=1, number=3, is_overlay=True - ) - - field_2d = np.ones((11, 3)) - for i in range(3): - field_2d[:, i] *= i + 1 - - Field = DataTime( - name="Airgap flux density", - symbol="B_r", - unit="T", - axes=[X, Z], - values=field_2d, - ) - - Field.plot("time", "z[-1,0,1]") - - elif test == "oneaxis": - - field_1d = np.ones((11)) - for i in range(11): - field_1d[i] *= i - - Field = DataTime( - name="Airgap flux density", - symbol="B_r", - unit="T", - axes=[X], - values=field_1d, - ) - - Field.plot() - - elif test == "vect": - - f = 50 - Time = DataLinspace( - name="time", - unit="s", - initial=0, - final=1 / f, - number=10, - include_endpoint=False, - ) - - Angle = DataLinspace( - name="angle", - unit="rad", - initial=0, - final=2 * np.pi, - number=20, - include_endpoint=False, - ) - - ta, at = np.meshgrid(Time.get_values(), Angle.get_values()) - field = 5 * np.cos(2 * np.pi * f * ta + 3 * at) - - Field_r = DataTime( - name="Radial field", - symbol="X_r", - unit="m", - normalizations={"ref": Norm_ref(ref=2e-5)}, - axes=[Time, Angle], - values=field.T, - ) - - Field_t = DataTime( - name="Tangential field", - symbol="X_t", - unit="m", - normalizations={"ref": Norm_ref(ref=2e-5)}, - axes=[Time, Angle], - values=-field.T, - ) - - VecField = VectorField( - name="Example field", - symbol="X", - components={"radial": Field_r, "tangential": Field_t}, - ) - VecField.plot() - - # VecField.plot("B[0]0", "time", "angle{°}", component="comp_x") diff --git a/Tests/__init__.py b/Tests/__init__.py index 226d591b..064072b5 100644 --- a/Tests/__init__.py +++ b/Tests/__init__.py @@ -29,8 +29,5 @@ # To save the Save/Load .json results save_load_path = join(save_path, "Save_Load") makedirs(save_load_path) -# To save the GUI results -save_gui_path = join(save_path, "GUI") -makedirs(save_gui_path) # To clean all the results at the end of the corresponding test is_clean_result = False From 73e3e6446897ab55c243cf8837560fc9c22f632b Mon Sep 17 00:00:00 2001 From: Pierre Bonneel Date: Wed, 27 Jul 2022 17:04:07 +0200 Subject: [PATCH 2/2] [CC] Moving old GUI variables --- SciDataTool/Functions/Plot/__init__.py | 28 +++++++++++++++++++ .../Methods/DataND/plot_2D_Data_Animated.py | 3 +- .../Methods/DataND/plot_3D_Data_Animated.py | 3 +- .../Methods/VectorField/plot_2D_Data.py | 2 +- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/SciDataTool/Functions/Plot/__init__.py b/SciDataTool/Functions/Plot/__init__.py index d9dda542..1af55db5 100644 --- a/SciDataTool/Functions/Plot/__init__.py +++ b/SciDataTool/Functions/Plot/__init__.py @@ -126,3 +126,31 @@ MAIN_LINE_COLOR = "0.5" # Gray MAIN_LINE_STYLE = "dotted" MAIN_LINE_WIDTH = 1 + +REV_COMP_DICT = { + "radial": "radial", + "tangential": "circumferential", + "axial": "axial", + "comp_x": "x-axis component", + "comp_y": "y-axis component", + "comp_z": "z-axis component", +} + +PARAM_3D = [ + "is_2D_view", + "is_contour", + "is_same_size", + "N_stem", + "colormap", + "annotation_delim", + "marker_color", + "z_range", +] + +PARAM_2D = [ + "color_list", + "data_list", + "legend_list", + "fund_harm_dict", + "is_show_legend", +] \ No newline at end of file diff --git a/SciDataTool/Methods/DataND/plot_2D_Data_Animated.py b/SciDataTool/Methods/DataND/plot_2D_Data_Animated.py index 798a0b40..2a6f6448 100644 --- a/SciDataTool/Methods/DataND/plot_2D_Data_Animated.py +++ b/SciDataTool/Methods/DataND/plot_2D_Data_Animated.py @@ -1,8 +1,7 @@ import matplotlib.pyplot as plt from numpy import arange, nanmax, nanmin, frombuffer import imageio -from ...GUI.DDataPlotter.DDataPlotter import PARAM_3D -from SciDataTool.Functions.Plot import fft_dict, ifft_dict +from SciDataTool.Functions.Plot import fft_dict, ifft_dict, PARAM_3D def plot_2D_Data_Animated( diff --git a/SciDataTool/Methods/DataND/plot_3D_Data_Animated.py b/SciDataTool/Methods/DataND/plot_3D_Data_Animated.py index 242bcac7..f138deaa 100644 --- a/SciDataTool/Methods/DataND/plot_3D_Data_Animated.py +++ b/SciDataTool/Methods/DataND/plot_3D_Data_Animated.py @@ -1,8 +1,7 @@ import matplotlib.pyplot as plt from numpy import arange, nanmax, nanmin, frombuffer import imageio -from ...GUI.DDataPlotter.DDataPlotter import PARAM_2D -from ...Functions.Plot import ifft_dict +from ...Functions.Plot import ifft_dict, PARAM_2D def plot_3D_Data_Animated( diff --git a/SciDataTool/Methods/VectorField/plot_2D_Data.py b/SciDataTool/Methods/VectorField/plot_2D_Data.py index 69796b80..3a13017f 100644 --- a/SciDataTool/Methods/VectorField/plot_2D_Data.py +++ b/SciDataTool/Methods/VectorField/plot_2D_Data.py @@ -5,7 +5,7 @@ xyz_to_rphiz, rphiz_to_xyz_field, ) -from SciDataTool.GUI.WVectorSelector.WVectorSelector import REV_COMP_DICT +from SciDataTool.Functions.Plot import REV_COMP_DICT from SciDataTool.Functions.Load.import_class import import_class