diff --git a/pymead/gui/analysis_graph.py b/pymead/gui/analysis_graph.py
index 0eab6df8..01984ada 100644
--- a/pymead/gui/analysis_graph.py
+++ b/pymead/gui/analysis_graph.py
@@ -10,7 +10,8 @@
class AnalysisGraph:
- def __init__(self, theme: dict, pen=None, size: tuple = (1000, 300), background_color: str = 'w'):
+ def __init__(self, theme: dict, pen=None, size: tuple = (1000, 300), background_color: str = 'w',
+ grid: bool = False):
pg.setConfigOptions(antialias=True)
if pen is None:
@@ -20,6 +21,7 @@ def __init__(self, theme: dict, pen=None, size: tuple = (1000, 300), background_
self.v = self.w.addPlot(pen=pen)
self.v.invertY(True)
+ self.v.showGrid(x=grid, y=grid)
self.legend = self.v.addLegend(offset=(300, 20))
self.set_formatting(theme=theme)
@@ -45,7 +47,7 @@ def set_legend_label_format(self, theme: dict):
class ResidualGraph:
- def __init__(self, theme: dict, pen=None, size: tuple = (1000, 300)):
+ def __init__(self, theme: dict, pen=None, size: tuple = (1000, 300), grid: bool = False):
pg.setConfigOptions(antialias=True)
if pen is None:
@@ -55,6 +57,7 @@ def __init__(self, theme: dict, pen=None, size: tuple = (1000, 300)):
self.v = self.w.addPlot(pen=pen)
self.v.setLogMode(x=False, y=True)
+ self.v.showGrid(x=grid, y=grid)
self.legend = self.v.addLegend(offset=(-5, 5))
target_pen = self.make_target_pen(theme)
@@ -108,7 +111,7 @@ def set_legend_label_format(self, theme: dict):
class SinglePolarGraph:
def __init__(self, theme: dict, graph_color_key: str, x_axis_label: str, y_axis_label: str,
- pen=None, size: tuple = (350, 300)):
+ pen=None, size: tuple = (350, 300), grid: bool = False):
pg.setConfigOptions(antialias=True)
if pen is None:
@@ -117,6 +120,7 @@ def __init__(self, theme: dict, graph_color_key: str, x_axis_label: str, y_axis_
self.w = pg.GraphicsLayoutWidget(show=True, size=size)
self.v = self.w.addPlot(pen=pen)
+ self.v.showGrid(x=grid, y=grid)
# Set up the line
self.plot_items = [self.v.plot(pen=pg.mkPen(color=theme[graph_color_key]))]
@@ -147,16 +151,16 @@ def set_formatting(self, theme: dict):
class PolarGraphCollection(QWidget):
- def __init__(self, theme: dict):
+ def __init__(self, theme: dict, grid: bool = False):
self.polar_graphs = [
SinglePolarGraph(theme=theme, graph_color_key="polar-color-1",
- x_axis_label="α (°)", y_axis_label="Cl"),
+ x_axis_label="α (°)", y_axis_label="Cl", grid=grid),
SinglePolarGraph(theme=theme, graph_color_key="polar-color-2",
- x_axis_label="Cd", y_axis_label="Cl"),
+ x_axis_label="Cd", y_axis_label="Cl", grid=grid),
SinglePolarGraph(theme=theme, graph_color_key="polar-color-3",
- x_axis_label="α (°)", y_axis_label="L/D"),
+ x_axis_label="α (°)", y_axis_label="L/D", grid=grid),
SinglePolarGraph(theme=theme, graph_color_key="polar-color-4",
- x_axis_label="α (°)", y_axis_label="Cm")
+ x_axis_label="α (°)", y_axis_label="Cm", grid=grid)
]
super().__init__(parent=None)
self.lay = QGridLayout()
@@ -185,11 +189,6 @@ def clear_data(self):
for polar_graph in self.polar_graphs:
polar_graph.plot_items[0].setData([], [])
- def toggle_grid(self):
+ def toggle_grid(self, checked: bool):
for polar_graph in self.polar_graphs:
- x_state = polar_graph.v.ctrl.xGridCheck.checkState()
- y_state = polar_graph.v.ctrl.yGridCheck.checkState()
- if x_state or y_state:
- polar_graph.v.showGrid(x=False, y=False)
- else:
- polar_graph.v.showGrid(x=True, y=True)
+ polar_graph.v.showGrid(x=checked, y=checked)
diff --git a/pymead/gui/gui.py b/pymead/gui/gui.py
index c19c265d..205214eb 100644
--- a/pymead/gui/gui.py
+++ b/pymead/gui/gui.py
@@ -1195,8 +1195,11 @@ def single_airfoil_inviscid_analysis(self, plot_cp: bool):
return
if self.analysis_graph is None:
- self.analysis_graph = AnalysisGraph(theme=self.themes[self.current_theme],
- background_color=self.themes[self.current_theme]["graph-background-color"])
+ self.analysis_graph = AnalysisGraph(
+ theme=self.themes[self.current_theme],
+ background_color=self.themes[self.current_theme]["graph-background-color"],
+ grid=self.main_icon_toolbar.buttons["grid"]["button"].isChecked()
+ )
self.add_new_tab_widget(self.analysis_graph.w, "Analysis")
name = f"[{self.n_analyses}] P ({selected_airfoil_name}, \u03b1 = {alpha:.1f}\u00b0)"
pg_plot_handle = self.analysis_graph.v.plot(pen=pg.mkPen(color=self.pen(self.n_converged_analyses)[0],
@@ -1362,8 +1365,11 @@ def single_airfoil_viscous_analysis(self):
if aero_data['converged'] and not aero_data['errored_out'] and not aero_data['timed_out']:
if self.analysis_graph is None:
# TODO: Need to set analysis_graph to None if analysis window is closed! Might also not want to allow geometry docking window to be closed
- self.analysis_graph = AnalysisGraph(theme=self.themes[self.current_theme],
- background_color=self.themes[self.current_theme]["graph-background-color"])
+ self.analysis_graph = AnalysisGraph(
+ theme=self.themes[self.current_theme],
+ background_color=self.themes[self.current_theme]["graph-background-color"],
+ grid=self.main_icon_toolbar.buttons["grid"]["button"].isChecked()
+ )
self.add_new_tab_widget(self.analysis_graph.w, "Analysis")
if xfoil_settings["visc"]:
@@ -1543,8 +1549,11 @@ def display_svg():
def plot_mses_pressure_coefficient_distribution(self, aero_data: dict, mea: MEA, mses_settings: dict):
if self.analysis_graph is None:
# Need to set analysis_graph to None if analysis window is closed
- self.analysis_graph = AnalysisGraph(theme=self.themes[self.current_theme],
- background_color=self.themes[self.current_theme]["graph-background-color"])
+ self.analysis_graph = AnalysisGraph(
+ theme=self.themes[self.current_theme],
+ background_color=self.themes[self.current_theme]["graph-background-color"],
+ grid=self.main_icon_toolbar.buttons["grid"]["button"].isChecked()
+ )
self.add_new_tab_widget(self.analysis_graph.w, "Analysis")
# Get the maximum physical extent of the airfoil system in the x-direction (used to prevent showing
@@ -1933,7 +1942,10 @@ def progress_update(self, status: str, data: object):
self.switch_to_tab("Residuals")
elif status == "mses_residual" and isinstance(data, tuple):
if self.residual_graph is None:
- self.residual_graph = ResidualGraph(theme=self.themes[self.current_theme])
+ self.residual_graph = ResidualGraph(
+ theme=self.themes[self.current_theme],
+ grid=self.main_icon_toolbar.buttons["grid"]["button"].isChecked()
+ )
self.add_new_tab_widget(self.residual_graph.w, "Residuals")
self.switch_to_tab("Residuals")
@@ -1962,7 +1974,10 @@ def progress_update(self, status: str, data: object):
self.polar_graph_collection.clear_data()
elif status == "plot_polars" and isinstance(data, dict):
if self.polar_graph_collection is None:
- self.polar_graph_collection = PolarGraphCollection(theme=self.themes[self.current_theme])
+ self.polar_graph_collection = PolarGraphCollection(
+ theme=self.themes[self.current_theme],
+ grid=self.main_icon_toolbar.buttons["grid"]["button"].isChecked()
+ )
self.add_new_tab_widget(self.polar_graph_collection, "Polars")
self.switch_to_tab("Polars")
self.polar_graph_collection.set_data(data)