Skip to content

Commit

Permalink
add "maximize" option to figure_management
Browse files Browse the repository at this point in the history
  • Loading branch information
bbean23 committed Aug 6, 2024
1 parent a9dabac commit defee13
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions opencsp/common/lib/render/figure_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ def _setup_figure(
window.move(x, y) # qt
else:
window.geometry(f"+{x}+{y}") # tkinter
if figure_control.maximize:
window = fig.canvas.manager.window
if hasattr(window, "showMaximized"):
window.showMaximized() # qt
else:
window.state("zoomed") # tkinter
# Copying this command, as from Randy, which suppresses duplicate axes in tile_figure(). ~ BGB
plt.axis('off')

Expand Down
20 changes: 20 additions & 0 deletions opencsp/common/lib/render/test/test_figure_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ def test_upper_left_xy_no_exception(self):
fig_record.view.show()
fig_record.close()

def test_maximize_no_exception(self):
"""
Verify that figure_management._setup_figure() with the figure control
parameter "maximize" set doesn't raise an exception.
"""
# TODO how to test that the window has actually been maximized?
axis_control = rca.meters()
figure_control = rcfg.RenderControlFigure(tile=False, maximize=True)
view_spec_2d = vs.view_spec_xy()
fig_record = fm.setup_figure(
figure_control,
axis_control,
view_spec_2d,
title=self.test_name,
code_tag=f"{__file__}.{self.test_name}",
equal=False,
)
fig_record.view.show()
fig_record.close()

def test_save_figsize(self):
"""Verify that the size of the saved figure is as given in the save parameters."""
# create and save the figure with pixel sizes:
Expand Down
5 changes: 5 additions & 0 deletions opencsp/common/lib/render_control/RenderControlFigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(
figsize=(6.4, 4.8), # inch.
upper_left_xy=None, # pixel. (0,0) --> Upper left corner of screen.
grid=True,
maximize=False,
): # Whether or not to draw grid lines.
"""Set of controls for how to render figures.
Expand Down Expand Up @@ -53,6 +54,9 @@ def __init__(
grid : bool, optional
Whether or not to draw grid lines. Note: this value seems to be
inverted. Default True
maximize : bool, optional
Whether the figure should be maximized (made full screen) as soon as
it is made visible. Ignored if tile is True. Default False.
"""

super(RenderControlFigure, self).__init__()
Expand All @@ -66,6 +70,7 @@ def __init__(
# Figure size and placement.
self.figsize = figsize
self.upper_left_xy = upper_left_xy
self.maximize = maximize

# Axis control.
self.x_label = 'x (m)'
Expand Down

0 comments on commit defee13

Please sign in to comment.