Skip to content

Commit

Permalink
wxGUI/history: fix for updating command info after updating current r…
Browse files Browse the repository at this point in the history
…egion (#3714)

Fixes #3713 and #3711.
  • Loading branch information
lindakarlovska authored May 16, 2024
1 parent c17eaff commit d505efb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
50 changes: 31 additions & 19 deletions gui/wxpython/history/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _layout(self):
self.general_info_box_sizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5
)
mainSizer.Add(
self.region_settings_box_sizer,
self.sizer_region_settings,
proportion=0,
flag=wx.EXPAND | wx.ALL,
border=5,
Expand Down Expand Up @@ -137,12 +137,12 @@ def _createRegionSettingsBox(self):
id=wx.ID_ANY,
label=_("Computational region during command execution"),
)
self.region_settings_box_sizer = wx.StaticBoxSizer(
self.sizer_region_settings = wx.StaticBoxSizer(
self.region_settings_box, wx.VERTICAL
)

self.sizer_region_settings_match = wx.BoxSizer(wx.HORIZONTAL)
self.region_settings_box_sizer.Add(
self.sizer_region_settings.Add(
self.sizer_region_settings_match,
proportion=0,
flag=wx.ALL | wx.EXPAND,
Expand All @@ -153,7 +153,7 @@ def _createRegionSettingsBox(self):
self.sizer_region_settings_grid.SetCols(2)
self.sizer_region_settings_grid.SetRows(9)

self.region_settings_box_sizer.Add(
self.sizer_region_settings.Add(
self.sizer_region_settings_grid,
proportion=1,
flag=wx.ALL | wx.EXPAND,
Expand All @@ -173,7 +173,10 @@ def _region_settings_filter(self, key):
return (key != "projection") and (key != "zone") and (key != "cells")

def _updateGeneralInfoBox(self, command_info):
"""Update a static box for displaying general info about the command"""
"""Update a static box for displaying general info about the command.
:param dict command_info: command info entry for update
"""
self.sizer_general_info.Clear(True)

idx = 0
Expand Down Expand Up @@ -206,8 +209,12 @@ def _updateGeneralInfoBox(self, command_info):
self.general_info_box.Layout()
self.general_info_box.Show()

def _updateRegionSettingsBox(self, command_info):
"""Update a static box for displaying region settings of the command"""
def _updateRegionSettingsGrid(self, command_info):
"""Update a grid that displays numerical values
for the regional settings of the executed command.
:param dict command_info: command info entry for update
"""
self.sizer_region_settings_grid.Clear(True)

self.region_settings = command_info["region"]
Expand Down Expand Up @@ -238,6 +245,10 @@ def _updateRegionSettingsBox(self, command_info):
)
idx += 1

self.region_settings_box.Show()

def _updateRegionSettingsMatch(self):
"""Update text, icon and button dealing with region update"""
self.sizer_region_settings_match.Clear(True)

# Region condition
Expand Down Expand Up @@ -290,27 +301,26 @@ def _updateRegionSettingsBox(self, command_info):
border=10,
)

self.region_settings_box.Layout()
self.region_settings_box.Show()

def showCommandInfo(self, command_info):
"""Show command info input."""
"""Show command info input.
:param dict command_info: command info entry for update
"""
if command_info:
self._updateGeneralInfoBox(command_info)
self._updateRegionSettingsBox(command_info)
self._updateRegionSettingsGrid(command_info)
self._updateRegionSettingsMatch()
else:
self.clearCommandInfo()
self.hideCommandInfo()
self.SetupScrolling(scroll_x=False, scroll_y=True)
self.Layout()

def clearCommandInfo(self):
"""Clear command info."""
self.sizer_general_info.Clear(True)
self.sizer_region_settings_grid.Clear(True)
self.sizer_region_settings_text.Clear(True)
self._createGeneralInfoBox()
self._createRegionSettingsBox()
self._layout()
def hideCommandInfo(self):
"""Hide command info input."""
self.general_info_box.Hide()
self.region_settings_box.Hide()

def _get_current_region(self):
"""Get current computational region settings."""
Expand All @@ -329,6 +339,8 @@ def OnUpdateRegion(self, event):
history_region = self._get_history_region()
gs.run_command("g.region", **history_region)
self.giface.updateMap.emit(render=False, renderVector=False)
self._updateRegionSettingsMatch()
self.Layout()


class HistoryBrowser(wx.SplitterWindow):
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/history/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def UpdateHistoryModelFromScratch(self):
"""Reload tree history model based on the current history log from scratch."""
self._model.RemoveNode(self._model.root)
self._initHistoryModel()
self.infoPanel.clearCommandInfo()
self.infoPanel.hideCommandInfo()

def InsertCommand(self, entry):
"""Insert command node to the model and refresh the tree.
Expand Down Expand Up @@ -499,7 +499,7 @@ def OnRemoveCmd(self, event):

# Remove the entry from history
self.RemoveEntryFromHistory(history_index)
self.infoPanel.clearCommandInfo()
self.infoPanel.hideCommandInfo()
self._giface.entryFromHistoryRemoved.emit(index=history_index)
self._model.RemoveNode(selected_command)

Expand Down

0 comments on commit d505efb

Please sign in to comment.