Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxGUI: Statusbar settings as a part of Map Display Settings #2153

Merged
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gui/wxpython/gui_core/mapdisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,10 @@ def OnMapDisplayProperties(self, event):
from mapdisp.properties import MapDisplayPropertiesDialog

dlg = MapDisplayPropertiesDialog(
parent=self, mapframe=self, properties=self.mapWindowProperties
parent=self,
mapframe=self,
properties=self.mapWindowProperties,
sbmanager=self.statusbarManager,
)
dlg.CenterOnParent()
dlg.Show()
Expand Down
12 changes: 6 additions & 6 deletions gui/wxpython/mapdisp/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(
sb.SbMapScale,
sb.SbGoTo,
]
self.statusbarItemsHiddenInNviz = (
self.statusbarItemsDisabledInNviz = (
sb.SbDisplayGeometry,
sb.SbMapScale,
)
Expand Down Expand Up @@ -448,8 +448,8 @@ def AddNviz(self):
)
# update status bar

self.statusbarManager.HideStatusbarChoiceItemsByClass(
self.statusbarItemsHiddenInNviz
self.statusbarManager.DisableStatusbarItemsByClass(
self.statusbarItemsDisabledInNviz
)
self.statusbarManager.SetMode(0)

Expand Down Expand Up @@ -548,13 +548,13 @@ def RemoveNviz(self):
pass

# update status bar
self.statusbarManager.ShowStatusbarChoiceItemsByClass(
self.statusbarItemsHiddenInNviz
)
self.statusbarManager.disabledItems = {}
self.statusbarManager.SetMode(
UserSettings.Get(group="display", key="statusbarMode", subkey="selection")
)
self.SetStatusText(_("Please wait, unloading data..."), 0)
self.statusbarManager.Update()

# unloading messages from library cause highlight anyway
self._giface.WriteCmdLog(
_("Switching back to 2D view mode..."),
Expand Down
63 changes: 60 additions & 3 deletions gui/wxpython/mapdisp/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- properties::ChBShowRegion
- properties::ChBAlignExtent
- properties::ChBResolution
- properties::ChBProjection
- properties::RBShowInStatusbar
- properties::MapDisplayPropertiesDialog

(C) 2021 by the GRASS Development Team
Expand Down Expand Up @@ -277,6 +279,50 @@ def _onToggleCheckBox(self, event):
self.widget.SetLabel(self.defaultLabel)


class RBShowInStatusbar:
"""Radiobox managing widgets in statusbar."""

def __init__(self, parent, sbmanager):
self.name = "showInStatusbar"
self.statusbarManager = sbmanager

choices = self.statusbarManager.GetItemLabels()
self.widget = wx.RadioBox(
parent=parent,
id=wx.ID_ANY,
label="Displayed content",
choices=choices,
majorDimension=1,
style=wx.RA_SPECIFY_COLS,
)
self._setValue(self.statusbarManager.GetMode())
self._disableItems()

self.widget.Bind(wx.EVT_RADIOBOX, self._onToggleRadioBox)

def _setValue(self, value):
self.widget.SetSelection(value)

def GetValue(self):
return self.widget.GetSelection()

def _disableItems(self):
"""Disables a radiobox options"""
for item in self.statusbarManager.disabledItems.keys():
self.widget.EnableItem(n=item, enable=False)

def GetWidget(self):
"""Returns underlying widget.

:return: widget or None if doesn't exist
"""
return self.widget

def _onToggleRadioBox(self, event):
self.statusbarManager.SetMode(self.GetValue())
self.statusbarManager.Update()


class MapDisplayPropertiesDialog(wx.Dialog):
"""Map Display properties dialog"""

Expand All @@ -285,8 +331,9 @@ def __init__(
parent,
mapframe,
properties,
sbmanager,
title=_("Map Display Settings"),
size=(-1, 250),
size=(-1, 300),
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
):
wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style)
Expand All @@ -296,6 +343,7 @@ def __init__(
self.size = size
self.mapframe = mapframe
self.mapWindowProperties = properties
self.statusbarManager = sbmanager

# notebook
self.notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
Expand Down Expand Up @@ -382,10 +430,19 @@ def _createStatusBarPage(self, parent):
panel.SetupScrolling(scroll_x=False, scroll_y=True)
parent.AddPage(page=panel, text=_("Status bar"))

# General settings
sizer = wx.BoxSizer(wx.VERTICAL)

# Auto-rendering
self.shownInStatusbar = RBShowInStatusbar(
parent=panel, sbmanager=self.statusbarManager
)
sizer.Add(
self.shownInStatusbar.GetWidget(),
proportion=0,
flag=wx.EXPAND | wx.ALL,
border=3,
)

# Display coordinates in different CRS
self.projection = ChBProjection(panel, self.mapWindowProperties)
sizer.Add(
self.projection.GetWidget(),
Expand Down
Loading