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: Use Map Display settings in other Map Display applications #2155

4 changes: 0 additions & 4 deletions doc/gui/wxpython/example/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,9 @@ def __init__(
sb.SbCoordinates,
sb.SbRegionExtent,
sb.SbCompRegionExtent,
sb.SbShowRegion,
sb.SbAlignExtent,
sb.SbResolution,
sb.SbDisplayGeometry,
sb.SbMapScale,
sb.SbGoTo,
sb.SbProjection,
]
self.statusbar = self.CreateStatusbar(statusbarItems)

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ def __init__(self, lmgr, file):
)
)
# projection statusbar info
if mapdisp.GetProperty("projection") and UserSettings.Get(
if mapdisp.GetProperty("useDefinedProjection") and UserSettings.Get(
group="display", key="projection", subkey="proj4"
):
self.indent += 4
Expand Down
5 changes: 1 addition & 4 deletions gui/wxpython/gcp/mapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,13 @@ def __init__(
sb.SbCoordinates,
sb.SbRegionExtent,
sb.SbCompRegionExtent,
sb.SbShowRegion,
sb.SbResolution,
sb.SbDisplayGeometry,
sb.SbMapScale,
sb.SbProjection,
sbgcp.SbGoToGCP,
sbgcp.SbRMSError,
]
self.statusbar = self.CreateStatusbar(statusbarItems)
self.statusbarManager.SetMode(8) # goto GCP
self.statusbarManager.SetMode(5) # goto GCP

#
# Init map display (buffered DC & set default cursor)
Expand Down
6 changes: 6 additions & 0 deletions gui/wxpython/gcp/toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ def _toolbarData(self):
("zoomback", BaseIcons["zoomBack"], self.parent.OnZoomBack),
("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap),
(None,),
(
"mapDispSettings",
BaseIcons["mapDispSettings"],
self.parent.OnMapDisplayProperties,
),
(None,),
("settings", icons["settings"], self.parent.OnSettings),
("help", icons["help"], self.parent.OnHelp),
(None,),
Expand Down
22 changes: 16 additions & 6 deletions gui/wxpython/gui_core/mapdisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ def GetToolSwitcher(self):

def SetProperty(self, name, value):
"""Sets property"""
if self.HasProperty("projection"):
self.statusbarManager.SetProperty(name, value)
if hasattr(self.mapWindowProperties, name):
setattr(self.mapWindowProperties, name, value)
else:
self.mapWindowProperties.useDefinedProjection = value
self.statusbarManager.SetProperty(name, value)

def GetProperty(self, name):
"""Returns property"""
if self.HasProperty("projection"):
return self.statusbarManager.GetProperty(name)
if hasattr(self.mapWindowProperties, name):
return getattr(self.mapWindowProperties, name)
else:
return self.mapWindowProperties.useDefinedProjection
return self.statusbarManager.GetProperty(name)

def HasProperty(self, name):
"""Checks whether object has property"""
Expand Down Expand Up @@ -484,6 +484,16 @@ def OnZoomToDefault(self, event):
"""Set display geometry to match default region settings"""
self.MapWindow.ZoomToDefault()

def OnMapDisplayProperties(self, event):
"""Show Map Display Properties dialog"""
from mapdisp.properties import MapDisplayPropertiesDialog

dlg = MapDisplayPropertiesDialog(
parent=self, mapframe=self, properties=self.mapWindowProperties
)
dlg.CenterOnParent()
dlg.Show()


class SingleMapPanel(MapPanelBase):
"""Panel with one map window.
Expand Down
1 change: 1 addition & 0 deletions gui/wxpython/gui_core/toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
img="layer-raster-histogram", label=_("Create histogram with d.histogram")
),
"settings": MetaIcon(img="settings", label=_("Settings")),
"mapDispSettings": MetaIcon(img="map-settings", label=_("Map Display Settings")),
}


Expand Down
4 changes: 0 additions & 4 deletions gui/wxpython/iclass/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,9 @@ def __init__(
sb.SbCoordinates,
sb.SbRegionExtent,
sb.SbCompRegionExtent,
sb.SbShowRegion,
sb.SbAlignExtent,
sb.SbResolution,
sb.SbDisplayGeometry,
sb.SbMapScale,
sb.SbGoTo,
sb.SbProjection,
]
self.statusbar = self.CreateStatusbar(statusbarItems)
self._addPanes()
Expand Down
5 changes: 5 additions & 0 deletions gui/wxpython/iclass/toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def _toolbarData(self):
(None,),
("zoomBack", icons["zoomBack"], self.parent.OnZoomBack),
("zoomToMap", icons["zoomExtent"], self.parent.OnZoomToMap),
(
"mapDispSettings",
icons["mapDispSettings"],
self.parent.OnMapDisplayProperties,
),
)
)

Expand Down
5 changes: 1 addition & 4 deletions gui/wxpython/image2target/ii2t_mapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,16 @@ def __init__(
sb.SbCoordinates,
sb.SbRegionExtent,
sb.SbCompRegionExtent,
sb.SbShowRegion,
sb.SbResolution,
sb.SbDisplayGeometry,
sb.SbMapScale,
sb.SbProjection,
sbgcp.SbGoToGCP,
sbgcp.SbRMSError,
]

# create statusbar and its manager
self.statusbar = self.CreateStatusbar(statusbarItems)

self.statusbarManager.SetMode(8) # goto GCP
self.statusbarManager.SetMode(5) # goto GCP

#
# Init map display (buffered DC & set default cursor)
Expand Down
6 changes: 6 additions & 0 deletions gui/wxpython/image2target/ii2t_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ def _toolbarData(self):
("zoomback", BaseIcons["zoomBack"], self.parent.OnZoomBack),
("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap),
(None,),
(
"mapDispSettings",
BaseIcons["mapDispSettings"],
self.parent.OnMapDisplayProperties,
),
(None,),
("settings", icons["settings"], self.parent.OnSettings),
("help", icons["help"], self.parent.OnHelp),
(None,),
Expand Down
12 changes: 1 addition & 11 deletions gui/wxpython/mapdisp/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1555,16 +1555,6 @@ def OnZoomMenu(self, event):
self.PopupMenu(zoommenu)
zoommenu.Destroy()

def OnMapDisplayProperties(self, event):
"""Show Map Display Properties dialog"""
from mapdisp.properties import MapDisplayPropertiesDialog

dlg = MapDisplayPropertiesDialog(
parent=self, giface=self._giface, properties=self.mapWindowProperties
)
dlg.CenterOnParent()
dlg.Show()

def SetProperties(
self,
render=False,
Expand All @@ -1579,7 +1569,7 @@ def SetProperties(
if self.statusbarManager:
self.statusbarManager.SetMode(mode)
self.StatusbarUpdate()
self.SetProperty("projection", projection)
self.mapWindowProperties.useDefinedProjection = projection
self.mapWindowProperties.showRegion = showCompExtent
self.mapWindowProperties.alignExtent = alignExtent
self.mapWindowProperties.resolution = constrainRes
Expand Down
24 changes: 12 additions & 12 deletions gui/wxpython/mapdisp/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def mapWindowPropertyChanged(self):
class ChBResolution(PropertyItem):
"""Checkbox to select used display resolution."""

def __init__(self, parent, giface, mapWindowProperties):
def __init__(self, parent, mapframe, mapWindowProperties):
PropertyItem.__init__(self, mapWindowProperties)
self.giface = giface
self.mapFrame = mapframe
self.name = "resolution"
self.widget = wx.CheckBox(
parent=parent,
Expand Down Expand Up @@ -180,16 +180,16 @@ def _onToggleCheckBox(self, event):

# redraw map if auto-rendering is enabled
if self._properties.autoRender:
self.giface.updateMap.emit()
self.mapFrame.GetWindow().UpdateMap()


class ChBShowRegion(PropertyItem):
"""Checkbox to enable and disable showing of computational region."""

def __init__(self, parent, giface, mapWindowProperties):
def __init__(self, parent, mapframe, mapWindowProperties):
PropertyItem.__init__(self, mapWindowProperties)
self.giface = giface
self.name = "region"
self.mapFrame = mapframe
self.name = "showRegion"
self.widget = wx.CheckBox(
parent=parent, id=wx.ID_ANY, label=_("Show computational extent")
)
Expand Down Expand Up @@ -229,15 +229,15 @@ def _onToggleCheckBox(self, event):

# redraw map if auto-rendering is enabled
if self._properties.autoRender:
self.giface.updateMap.emit(render=False)
self.mapFrame.GetWindow().UpdateMap(render=False)


class ChBProjection(PropertyItem):
"""Checkbox to enable user defined projection"""

def __init__(self, parent, mapWindowProperties):
PropertyItem.__init__(self, mapWindowProperties)
self.name = "projection"
self.name = "useDefinedProjection"
self.defaultLabel = _("Display coordinates in different CRS")
self.widget = wx.CheckBox(parent=parent, id=wx.ID_ANY, label=self.defaultLabel)
self.widget.SetValue(self.mapWindowProperty)
Expand Down Expand Up @@ -283,7 +283,7 @@ class MapDisplayPropertiesDialog(wx.Dialog):
def __init__(
self,
parent,
giface,
mapframe,
properties,
title=_("Map Display Settings"),
size=(-1, 250),
Expand All @@ -294,7 +294,7 @@ def __init__(
self.parent = parent
self.title = title
self.size = size
self.giface = giface
self.mapframe = mapframe
self.mapWindowProperties = properties

# notebook
Expand Down Expand Up @@ -353,7 +353,7 @@ def _createDisplayPage(self, parent):

# Use computation resolution
self.compResolution = ChBResolution(
panel, self.giface, self.mapWindowProperties
panel, self.mapframe, self.mapWindowProperties
)
sizer.Add(
self.compResolution.GetWidget(),
Expand All @@ -364,7 +364,7 @@ def _createDisplayPage(self, parent):

# Show computation extent
self.showCompExtent = ChBShowRegion(
panel, self.giface, self.mapWindowProperties
panel, self.mapframe, self.mapWindowProperties
)
sizer.Add(
self.showCompExtent.GetWidget(),
Expand Down
Loading