From a8e8ad579c9241f3960c35b2440b7e20e9950e6c Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Thu, 3 Feb 2022 08:57:07 -0600 Subject: [PATCH 01/14] use map display settings in other Map Display applications --- doc/gui/wxpython/example/frame.py | 6 +- gui/wxpython/gcp/mapdisplay.py | 3 - gui/wxpython/gcp/toolbars.py | 5 + gui/wxpython/gui_core/mapdisp.py | 35 ++- gui/wxpython/iclass/frame.py | 18 +- gui/wxpython/iclass/toolbars.py | 5 + gui/wxpython/image2target/ii2t_mapdisplay.py | 3 - gui/wxpython/image2target/ii2t_toolbars.py | 5 + gui/wxpython/mapdisp/frame.py | 10 - gui/wxpython/mapdisp/statusbar.py | 216 ------------------- gui/wxpython/mapswipe/frame.py | 4 - gui/wxpython/mapswipe/toolbars.py | 5 + gui/wxpython/photo2image/ip2i_mapdisplay.py | 3 - gui/wxpython/photo2image/ip2i_toolbars.py | 5 + 14 files changed, 63 insertions(+), 260 deletions(-) diff --git a/doc/gui/wxpython/example/frame.py b/doc/gui/wxpython/example/frame.py index 39671173952..f1e99b9d31e 100644 --- a/doc/gui/wxpython/example/frame.py +++ b/doc/gui/wxpython/example/frame.py @@ -83,6 +83,8 @@ def __init__( self, parent=parent, title=title, name=name, Map=Map(), **kwargs ) + self._giface = giface + # Place debug message where appropriate # and set debug level from 1 to 5 (higher to lower level functions). # To enable debug mode write: @@ -114,13 +116,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) diff --git a/gui/wxpython/gcp/mapdisplay.py b/gui/wxpython/gcp/mapdisplay.py index e7596e5e984..89a0317bf8e 100644 --- a/gui/wxpython/gcp/mapdisplay.py +++ b/gui/wxpython/gcp/mapdisplay.py @@ -103,11 +103,8 @@ def __init__( sb.SbCoordinates, sb.SbRegionExtent, sb.SbCompRegionExtent, - sb.SbShowRegion, - sb.SbResolution, sb.SbDisplayGeometry, sb.SbMapScale, - sb.SbProjection, sbgcp.SbGoToGCP, sbgcp.SbRMSError, ] diff --git a/gui/wxpython/gcp/toolbars.py b/gui/wxpython/gcp/toolbars.py index e475e667c34..ac780731916 100644 --- a/gui/wxpython/gcp/toolbars.py +++ b/gui/wxpython/gcp/toolbars.py @@ -127,6 +127,11 @@ def _toolbarData(self): ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap), (None,), ("settings", icons["settings"], self.parent.OnSettings), + ( + "showMapSettings", + icons["settings"], + self.parent.OnMapDisplayProperties, + ), ("help", icons["help"], self.parent.OnHelp), (None,), ("quit", icons["quit"], self.parent.OnQuit), diff --git a/gui/wxpython/gui_core/mapdisp.py b/gui/wxpython/gui_core/mapdisp.py index d18655191df..1d89cd49247 100644 --- a/gui/wxpython/gui_core/mapdisp.py +++ b/gui/wxpython/gui_core/mapdisp.py @@ -160,17 +160,30 @@ def GetToolSwitcher(self): def SetProperty(self, name, value): """Sets property""" - if self.HasProperty("projection"): - self.statusbarManager.SetProperty(name, value) - else: + if not self.HasProperty("projection"): self.mapWindowProperties.useDefinedProjection = value + elif not self.HasProperty("resolution"): + self.mapWindowProperties.resolution = value + elif not self.HasProperty("alignExtent"): + self.mapWindowProperties.alignExtent = value + elif not self.HasProperty("region"): + self.mapWindowProperties.showRegion = value + else: + self.statusbarManager.SetProperty(name, value) def GetProperty(self, name): """Returns property""" - if self.HasProperty("projection"): - return self.statusbarManager.GetProperty(name) - else: + if not self.HasProperty("projection"): return self.mapWindowProperties.useDefinedProjection + elif not self.HasProperty("resolution"): + return self.mapWindowProperties.resolution + elif not self.HasProperty("alignExtent"): + return self.mapWindowProperties.alignExtent + elif not self.HasProperty("region"): + return self.mapWindowProperties.region + else: + print("bla") + return self.statusbarManager.GetProperty(name) def HasProperty(self, name): """Checks whether object has property""" @@ -484,6 +497,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, giface=self._giface, properties=self.mapWindowProperties + ) + dlg.CenterOnParent() + dlg.Show() + class SingleMapPanel(MapPanelBase): """Panel with one map window. diff --git a/gui/wxpython/iclass/frame.py b/gui/wxpython/iclass/frame.py index 2c2f9e1c10a..817437ca498 100644 --- a/gui/wxpython/iclass/frame.py +++ b/gui/wxpython/iclass/frame.py @@ -109,9 +109,9 @@ def __init__( **kwargs, ) if giface: - self.giface = giface + self._giface = giface else: - self.giface = StandaloneMapDisplayGrassInterface(self) + self._giface = StandaloneMapDisplayGrassInterface(self) self.tree = None self.mapWindowProperties = MapWindowProperties() self.mapWindowProperties.setValuesFromUserSettings() @@ -120,13 +120,13 @@ def __init__( self.firstMapWindow = IClassVDigitWindow( parent=self, - giface=self.giface, + giface=self._giface, properties=self.mapWindowProperties, map=self.firstMap, ) self.secondMapWindow = BufferedMapWindow( parent=self, - giface=self.giface, + giface=self._giface, properties=self.mapWindowProperties, Map=self.secondMap, ) @@ -188,20 +188,16 @@ def __init__( self.dialogs["category"] = None # PyPlot init - self.plotPanel = PlotPanel(self, giface=self.giface, stats_data=self.stats_data) + self.plotPanel = PlotPanel(self, giface=self._giface, stats_data=self.stats_data) # statusbar items statusbarItems = [ 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() @@ -239,7 +235,7 @@ def _cleanup(self): def OnHelp(self, event): """Show help page""" - self.giface.Help(entry="wxGUI.iclass") + self._giface.Help(entry="wxGUI.iclass") def _getTempVectorName(self): """Return new name for temporary vector map (training areas)""" @@ -374,7 +370,7 @@ def AddToolbar(self, name): toolSwitcher=self._toolSwitcher, MapWindow=self.GetFirstWindow(), digitClass=IClassVDigit, - giface=self.giface, + giface=self._giface, tools=[ "addArea", "moveVertex", diff --git a/gui/wxpython/iclass/toolbars.py b/gui/wxpython/iclass/toolbars.py index a9caa2cbd33..e5860eae8bf 100644 --- a/gui/wxpython/iclass/toolbars.py +++ b/gui/wxpython/iclass/toolbars.py @@ -112,6 +112,11 @@ def _toolbarData(self): (None,), ("zoomBack", icons["zoomBack"], self.parent.OnZoomBack), ("zoomToMap", icons["zoomExtent"], self.parent.OnZoomToMap), + ( + "showMapSettings", + icons["settings"], + self.parent.OnMapDisplayProperties, + ), ) ) diff --git a/gui/wxpython/image2target/ii2t_mapdisplay.py b/gui/wxpython/image2target/ii2t_mapdisplay.py index c8972242e82..0d78eefe6a6 100644 --- a/gui/wxpython/image2target/ii2t_mapdisplay.py +++ b/gui/wxpython/image2target/ii2t_mapdisplay.py @@ -105,11 +105,8 @@ def __init__( sb.SbCoordinates, sb.SbRegionExtent, sb.SbCompRegionExtent, - sb.SbShowRegion, - sb.SbResolution, sb.SbDisplayGeometry, sb.SbMapScale, - sb.SbProjection, sbgcp.SbGoToGCP, sbgcp.SbRMSError, ] diff --git a/gui/wxpython/image2target/ii2t_toolbars.py b/gui/wxpython/image2target/ii2t_toolbars.py index e475e667c34..ac780731916 100644 --- a/gui/wxpython/image2target/ii2t_toolbars.py +++ b/gui/wxpython/image2target/ii2t_toolbars.py @@ -127,6 +127,11 @@ def _toolbarData(self): ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap), (None,), ("settings", icons["settings"], self.parent.OnSettings), + ( + "showMapSettings", + icons["settings"], + self.parent.OnMapDisplayProperties, + ), ("help", icons["help"], self.parent.OnHelp), (None,), ("quit", icons["quit"], self.parent.OnQuit), diff --git a/gui/wxpython/mapdisp/frame.py b/gui/wxpython/mapdisp/frame.py index 48d85b9b1fd..f16189c2802 100644 --- a/gui/wxpython/mapdisp/frame.py +++ b/gui/wxpython/mapdisp/frame.py @@ -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, diff --git a/gui/wxpython/mapdisp/statusbar.py b/gui/wxpython/mapdisp/statusbar.py index 61c33bef796..8e77f694f31 100644 --- a/gui/wxpython/mapdisp/statusbar.py +++ b/gui/wxpython/mapdisp/statusbar.py @@ -8,12 +8,8 @@ - statusbar::SbManager - statusbar::SbItem - statusbar::SbRender - - statusbar::SbShowRegion - - statusbar::SbAlignExtent - - statusbar::SbResolution - statusbar::SbMapScale - statusbar::SbGoTo - - statusbar::SbProjection - statusbar::SbTextItem - statusbar::SbDisplayGeometry - statusbar::SbCoordinates @@ -434,172 +430,6 @@ def Update(self): self.Show() -class SbShowRegion(SbItem): - """Checkbox to enable and disable showing of computational region. - - Requires MapFrame.OnRender, MapFrame.IsAutoRendered, MapFrame.GetWindow. - """ - - def __init__(self, mapframe, statusbar, position=0): - SbItem.__init__(self, mapframe, statusbar, position) - self.name = "region" - self.label = _("Show comp. extent") - self._properties = mapframe.mapWindowProperties - - self.widget = wx.CheckBox( - parent=self.statusbar, id=wx.ID_ANY, label=_("Show computational extent") - ) - self.widget.SetValue(self._properties.showRegion) - self.widget.Hide() - self.widget.SetToolTip( - wx.ToolTip( - _( - "Show/hide computational " - "region extent (set with g.region). " - "Display region drawn as a blue box inside the " - "computational region, " - "computational region inside a display region " - "as a red box)." - ) - ) - ) - self.widget.Bind(wx.EVT_CHECKBOX, self.OnToggleShowRegion) - self._connectShowRegion() - - def _setValue(self, value): - self.widget.SetValue(value) - - def _connectShowRegion(self): - self._properties.showRegionChanged.connect(self._setValue) - - def _disconnectShowRegion(self): - self._properties.showRegionChanged.disconnect(self._setValue) - - def OnToggleShowRegion(self, event): - """Shows/Hides extent (comp. region) in map canvas. - - Shows or hides according to checkbox value. - - .. todo:: - needs refactoring - """ - self._disconnectShowRegion() - self._properties.showRegion = self.widget.GetValue() - self._connectShowRegion() - - # redraw map if auto-rendering is enabled - if self.mapFrame.IsAutoRendered(): - self.mapFrame.GetWindow().UpdateMap(render=False) - - def SetValue(self, value): - self._disconnectShowRegion() - self._properties.showRegion = value - SbItem.SetValue(self, value) - self._connectShowRegion() - - -class SbAlignExtent(SbItem): - """Checkbox to select zoom behavior. - - Used by BufferedWindow (through MapFrame property). - See tooltip for explanation. - """ - - def __init__(self, mapframe, statusbar, position=0): - SbItem.__init__(self, mapframe, statusbar, position) - self.name = "alignExtent" - self.label = _("Display mode") - self._properties = mapframe.mapWindowProperties - - self.widget = wx.CheckBox( - parent=self.statusbar, - id=wx.ID_ANY, - label=_("Align region extent based on display size"), - ) - self.widget.SetValue(self._properties.alignExtent) - self.widget.Hide() - self.widget.SetToolTip( - wx.ToolTip( - _( - "Align region extent based on display " - "size from center point. " - "Default value for new map displays can " - "be set up in 'User GUI settings' dialog." - ) - ) - ) - self._connectAlignExtent() - self.widget.Bind(wx.EVT_CHECKBOX, self._onCheckbox) - - # TODO: these four methods are in many stitems - # some generalization? - # passing properties as stings and set/get attr would work, but it is nice? - def _setValue(self, value): - self.widget.SetValue(value) - - def _connectAlignExtent(self): - self._properties.alignExtentChanged.connect(self._setValue) - - def _disconnectAlignExtent(self): - self._properties.alignExtentChanged.disconnect(self._setValue) - - def _onCheckbox(self, event): - self._disconnectAlignExtent() - self._properties.alignExtent = self.widget.GetValue() - self._connectAlignExtent() - - -class SbResolution(SbItem): - """Checkbox to select used display resolution. - - Requires MapFrame.OnRender method. - """ - - def __init__(self, mapframe, statusbar, position=0): - SbItem.__init__(self, mapframe, statusbar, position) - self.name = "resolution" - self.label = _("Display resolution") - self._properties = self.mapFrame.mapWindowProperties - self.widget = wx.CheckBox( - parent=self.statusbar, - id=wx.ID_ANY, - label=_("Constrain display resolution to computational settings"), - ) - self.widget.SetValue(self._properties.resolution) - self.widget.Hide() - self.widget.SetToolTip( - wx.ToolTip( - _( - "Constrain display resolution " - "to computational region settings. " - "Default value for new map displays can " - "be set up in 'User GUI settings' dialog." - ) - ) - ) - - self.widget.Bind(wx.EVT_CHECKBOX, self.OnToggleUpdateMap) - self._connectResolutionChange() - - def _setValue(self, value): - self.widget.SetValue(value) - - def _connectResolutionChange(self): - self._properties.resolutionChanged.connect(self._setValue) - - def _disconnectResolutionChange(self): - self._properties.resolutionChanged.disconnect(self._setValue) - - def OnToggleUpdateMap(self, event): - """Update display when toggle display mode""" - self._disconnectResolutionChange() - self._properties.resolution = self.widget.GetValue() - self._connectResolutionChange() - # redraw map if auto-rendering is enabled - if self.mapFrame.IsAutoRendered(): - self.mapFrame.GetWindow().UpdateMap() - - class SbMapScale(SbItem): """Editable combobox to get/set current map scale. @@ -841,52 +671,6 @@ def Update(self): self.mapFrame.StatusbarEnableLongHelp(False) -class SbProjection(SbItem): - """Checkbox to enable user defined projection (can be set in settings)""" - - def __init__(self, mapframe, statusbar, position=0): - SbItem.__init__(self, mapframe, statusbar, position) - self.name = "projection" - self.label = _("Projection") - - self.defaultLabel = _("Use defined projection") - - self.widget = wx.CheckBox( - parent=self.statusbar, id=wx.ID_ANY, label=self.defaultLabel - ) - - self.widget.SetValue(False) - - # necessary? - size = self.widget.GetSize() - self.widget.SetMinSize((size[0] + 150, size[1])) - - self.widget.Hide() - self.widget.SetToolTip( - wx.ToolTip( - _( - "Reproject coordinates displayed " - "in the statusbar. Projection can be " - "defined in GUI preferences dialog " - "(tab 'Projection')" - ) - ) - ) - - def Update(self): - self.statusbar.SetStatusText("") - epsg = UserSettings.Get(group="projection", key="statusbar", subkey="epsg") - if epsg: - label = "%s (EPSG: %s)" % (self.defaultLabel, epsg) - self.widget.SetLabel(label) - else: - self.widget.SetLabel(self.defaultLabel) - self.Show() - - # disable long help - self.mapFrame.StatusbarEnableLongHelp(False) - - class SbTextItem(SbItem): """Base class for items without widgets. diff --git a/gui/wxpython/mapswipe/frame.py b/gui/wxpython/mapswipe/frame.py index ecb39cc1fee..3693acee5ca 100644 --- a/gui/wxpython/mapswipe/frame.py +++ b/gui/wxpython/mapswipe/frame.py @@ -102,13 +102,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) diff --git a/gui/wxpython/mapswipe/toolbars.py b/gui/wxpython/mapswipe/toolbars.py index d425310f3e1..c6fe763dbf0 100644 --- a/gui/wxpython/mapswipe/toolbars.py +++ b/gui/wxpython/mapswipe/toolbars.py @@ -71,6 +71,11 @@ def _toolbarData(self): ("zoomToMap", icons["zoomExtent"], self.parent.OnZoomToMap), (None,), ("saveFile", icons["saveFile"], self.parent.SaveToFile), + ( + "showMapSettings", + icons["settings"], + self.parent.OnMapDisplayProperties, + ), ) ) diff --git a/gui/wxpython/photo2image/ip2i_mapdisplay.py b/gui/wxpython/photo2image/ip2i_mapdisplay.py index f512a635f5f..fca945646b3 100644 --- a/gui/wxpython/photo2image/ip2i_mapdisplay.py +++ b/gui/wxpython/photo2image/ip2i_mapdisplay.py @@ -99,11 +99,8 @@ def __init__( sb.SbCoordinates, sb.SbRegionExtent, sb.SbCompRegionExtent, - sb.SbShowRegion, - sb.SbResolution, sb.SbDisplayGeometry, sb.SbMapScale, - sb.SbProjection, sbgcp.SbGoToGCP, sbgcp.SbRMSError, ] diff --git a/gui/wxpython/photo2image/ip2i_toolbars.py b/gui/wxpython/photo2image/ip2i_toolbars.py index 6b403eb89f6..671bfd0da8a 100644 --- a/gui/wxpython/photo2image/ip2i_toolbars.py +++ b/gui/wxpython/photo2image/ip2i_toolbars.py @@ -127,6 +127,11 @@ def _toolbarData(self): ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap), (None,), ("settings", icons["settings"], self.parent.OnSettings), + ( + "showMapSettings", + icons["settings"], + self.parent.OnMapDisplayProperties, + ), ("help", icons["help"], self.parent.OnHelp), (None,), ("quit", icons["quit"], self.parent.OnQuit), From 6f281104c7a3e386bb93821056659d97944efbdd Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Thu, 3 Feb 2022 10:23:53 -0600 Subject: [PATCH 02/14] use different icon for Map Display settings --- gui/wxpython/gui_core/toolbars.py | 1 + gui/wxpython/iclass/toolbars.py | 6 +----- gui/wxpython/image2target/ii2t_toolbars.py | 6 +----- gui/wxpython/mapdisp/toolbars.py | 5 +---- gui/wxpython/mapswipe/toolbars.py | 6 +----- gui/wxpython/photo2image/ip2i_toolbars.py | 6 +----- 6 files changed, 6 insertions(+), 24 deletions(-) diff --git a/gui/wxpython/gui_core/toolbars.py b/gui/wxpython/gui_core/toolbars.py index c7dabd19223..a6a9dabe2be 100644 --- a/gui/wxpython/gui_core/toolbars.py +++ b/gui/wxpython/gui_core/toolbars.py @@ -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")), } diff --git a/gui/wxpython/iclass/toolbars.py b/gui/wxpython/iclass/toolbars.py index e5860eae8bf..bc0152cd5d4 100644 --- a/gui/wxpython/iclass/toolbars.py +++ b/gui/wxpython/iclass/toolbars.py @@ -112,11 +112,7 @@ def _toolbarData(self): (None,), ("zoomBack", icons["zoomBack"], self.parent.OnZoomBack), ("zoomToMap", icons["zoomExtent"], self.parent.OnZoomToMap), - ( - "showMapSettings", - icons["settings"], - self.parent.OnMapDisplayProperties, - ), + ("mapDispSettings", icons["mapDispSettings"], self.parent.OnMapDisplayProperties), ) ) diff --git a/gui/wxpython/image2target/ii2t_toolbars.py b/gui/wxpython/image2target/ii2t_toolbars.py index ac780731916..28847825408 100644 --- a/gui/wxpython/image2target/ii2t_toolbars.py +++ b/gui/wxpython/image2target/ii2t_toolbars.py @@ -127,11 +127,7 @@ def _toolbarData(self): ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap), (None,), ("settings", icons["settings"], self.parent.OnSettings), - ( - "showMapSettings", - icons["settings"], - self.parent.OnMapDisplayProperties, - ), + ("mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties), ("help", icons["help"], self.parent.OnHelp), (None,), ("quit", icons["quit"], self.parent.OnQuit), diff --git a/gui/wxpython/mapdisp/toolbars.py b/gui/wxpython/mapdisp/toolbars.py index e1145d44eb2..bbcf6d7af2d 100644 --- a/gui/wxpython/mapdisp/toolbars.py +++ b/gui/wxpython/mapdisp/toolbars.py @@ -183,10 +183,7 @@ def _toolbarData(self): ("analyze", MapIcons["analyze"], self.OnAnalyze), ("overlay", BaseIcons["overlay"], self.OnDecoration), ("saveFile", BaseIcons["saveFile"], self.parent.SaveToFile), - ( - "showMapSettings", - BaseIcons["settings"], - self.parent.OnMapDisplayProperties, + ("mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties, ), ) ) diff --git a/gui/wxpython/mapswipe/toolbars.py b/gui/wxpython/mapswipe/toolbars.py index c6fe763dbf0..bc62e3442df 100644 --- a/gui/wxpython/mapswipe/toolbars.py +++ b/gui/wxpython/mapswipe/toolbars.py @@ -71,11 +71,7 @@ def _toolbarData(self): ("zoomToMap", icons["zoomExtent"], self.parent.OnZoomToMap), (None,), ("saveFile", icons["saveFile"], self.parent.SaveToFile), - ( - "showMapSettings", - icons["settings"], - self.parent.OnMapDisplayProperties, - ), + ("mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties), ) ) diff --git a/gui/wxpython/photo2image/ip2i_toolbars.py b/gui/wxpython/photo2image/ip2i_toolbars.py index 671bfd0da8a..d7a27a284bd 100644 --- a/gui/wxpython/photo2image/ip2i_toolbars.py +++ b/gui/wxpython/photo2image/ip2i_toolbars.py @@ -127,11 +127,7 @@ def _toolbarData(self): ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap), (None,), ("settings", icons["settings"], self.parent.OnSettings), - ( - "showMapSettings", - icons["settings"], - self.parent.OnMapDisplayProperties, - ), + ("mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties), ("help", icons["help"], self.parent.OnHelp), (None,), ("quit", icons["quit"], self.parent.OnQuit), From e96b2dc480ed27869978b23a5c106c1b319f45eb Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Thu, 3 Feb 2022 10:29:56 -0600 Subject: [PATCH 03/14] black --- gui/wxpython/iclass/frame.py | 4 +++- gui/wxpython/iclass/toolbars.py | 6 +++++- gui/wxpython/image2target/ii2t_toolbars.py | 6 +++++- gui/wxpython/mapdisp/toolbars.py | 5 ++++- gui/wxpython/mapswipe/toolbars.py | 6 +++++- gui/wxpython/photo2image/ip2i_toolbars.py | 6 +++++- 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/gui/wxpython/iclass/frame.py b/gui/wxpython/iclass/frame.py index 817437ca498..c31a9473e3f 100644 --- a/gui/wxpython/iclass/frame.py +++ b/gui/wxpython/iclass/frame.py @@ -188,7 +188,9 @@ def __init__( self.dialogs["category"] = None # PyPlot init - self.plotPanel = PlotPanel(self, giface=self._giface, stats_data=self.stats_data) + self.plotPanel = PlotPanel( + self, giface=self._giface, stats_data=self.stats_data + ) # statusbar items statusbarItems = [ diff --git a/gui/wxpython/iclass/toolbars.py b/gui/wxpython/iclass/toolbars.py index bc0152cd5d4..b4a56711a30 100644 --- a/gui/wxpython/iclass/toolbars.py +++ b/gui/wxpython/iclass/toolbars.py @@ -112,7 +112,11 @@ def _toolbarData(self): (None,), ("zoomBack", icons["zoomBack"], self.parent.OnZoomBack), ("zoomToMap", icons["zoomExtent"], self.parent.OnZoomToMap), - ("mapDispSettings", icons["mapDispSettings"], self.parent.OnMapDisplayProperties), + ( + "mapDispSettings", + icons["mapDispSettings"], + self.parent.OnMapDisplayProperties, + ), ) ) diff --git a/gui/wxpython/image2target/ii2t_toolbars.py b/gui/wxpython/image2target/ii2t_toolbars.py index 28847825408..561dae3832b 100644 --- a/gui/wxpython/image2target/ii2t_toolbars.py +++ b/gui/wxpython/image2target/ii2t_toolbars.py @@ -127,7 +127,11 @@ def _toolbarData(self): ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap), (None,), ("settings", icons["settings"], self.parent.OnSettings), - ("mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties), + ( + "mapDispSettings", + BaseIcons["mapDispSettings"], + self.parent.OnMapDisplayProperties, + ), ("help", icons["help"], self.parent.OnHelp), (None,), ("quit", icons["quit"], self.parent.OnQuit), diff --git a/gui/wxpython/mapdisp/toolbars.py b/gui/wxpython/mapdisp/toolbars.py index bbcf6d7af2d..025b84adf85 100644 --- a/gui/wxpython/mapdisp/toolbars.py +++ b/gui/wxpython/mapdisp/toolbars.py @@ -183,7 +183,10 @@ def _toolbarData(self): ("analyze", MapIcons["analyze"], self.OnAnalyze), ("overlay", BaseIcons["overlay"], self.OnDecoration), ("saveFile", BaseIcons["saveFile"], self.parent.SaveToFile), - ("mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties, + ( + "mapDispSettings", + BaseIcons["mapDispSettings"], + self.parent.OnMapDisplayProperties, ), ) ) diff --git a/gui/wxpython/mapswipe/toolbars.py b/gui/wxpython/mapswipe/toolbars.py index bc62e3442df..7d2e2e679ef 100644 --- a/gui/wxpython/mapswipe/toolbars.py +++ b/gui/wxpython/mapswipe/toolbars.py @@ -71,7 +71,11 @@ def _toolbarData(self): ("zoomToMap", icons["zoomExtent"], self.parent.OnZoomToMap), (None,), ("saveFile", icons["saveFile"], self.parent.SaveToFile), - ("mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties), + ( + "mapDispSettings", + BaseIcons["mapDispSettings"], + self.parent.OnMapDisplayProperties, + ), ) ) diff --git a/gui/wxpython/photo2image/ip2i_toolbars.py b/gui/wxpython/photo2image/ip2i_toolbars.py index d7a27a284bd..e311b03057f 100644 --- a/gui/wxpython/photo2image/ip2i_toolbars.py +++ b/gui/wxpython/photo2image/ip2i_toolbars.py @@ -127,7 +127,11 @@ def _toolbarData(self): ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap), (None,), ("settings", icons["settings"], self.parent.OnSettings), - ("mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties), + ( + "mapDispSettings", + BaseIcons["mapDispSettings"], + self.parent.OnMapDisplayProperties, + ), ("help", icons["help"], self.parent.OnHelp), (None,), ("quit", icons["quit"], self.parent.OnQuit), From b57490f75bb4167ddf9a265aef61031855d79f7d Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Thu, 3 Feb 2022 10:32:03 -0600 Subject: [PATCH 04/14] fix for gcp --- gui/wxpython/gcp/toolbars.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/wxpython/gcp/toolbars.py b/gui/wxpython/gcp/toolbars.py index ac780731916..561dae3832b 100644 --- a/gui/wxpython/gcp/toolbars.py +++ b/gui/wxpython/gcp/toolbars.py @@ -128,8 +128,8 @@ def _toolbarData(self): (None,), ("settings", icons["settings"], self.parent.OnSettings), ( - "showMapSettings", - icons["settings"], + "mapDispSettings", + BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties, ), ("help", icons["help"], self.parent.OnHelp), From ec23b7de416fd93cbb88918151aaeb450bb123b0 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Mon, 7 Feb 2022 00:37:43 -0600 Subject: [PATCH 05/14] does not make sense now, show comp. region is controlled by Map Display settings --- gui/wxpython/mapdisp/statusbar.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/gui/wxpython/mapdisp/statusbar.py b/gui/wxpython/mapdisp/statusbar.py index 8e77f694f31..bba4297185d 100644 --- a/gui/wxpython/mapdisp/statusbar.py +++ b/gui/wxpython/mapdisp/statusbar.py @@ -294,12 +294,6 @@ def _progressHidden(self): def OnToggleStatus(self, event): """Toggle status text""" self.Update() - if event.GetSelection() == 3 and self.HasProperty("region"): - # show computation region extent by default - self.statusbarItems["region"].SetValue(True) - # redraw map if auto-rendering is enabled - if self.mapFrame.IsAutoRendered(): - self.mapFrame.GetWindow().UpdateMap(render=False) def SetMode(self, modeIndex): """Sets current mode From 1882fa2368fd18cdb15909cf2d387a97c6b5996c Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Mon, 7 Feb 2022 01:22:28 -0600 Subject: [PATCH 06/14] SetProperty and GetProperty fixed --- gui/wxpython/gui_core/mapdisp.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/gui/wxpython/gui_core/mapdisp.py b/gui/wxpython/gui_core/mapdisp.py index 1d89cd49247..2340b530e08 100644 --- a/gui/wxpython/gui_core/mapdisp.py +++ b/gui/wxpython/gui_core/mapdisp.py @@ -160,29 +160,39 @@ def GetToolSwitcher(self): def SetProperty(self, name, value): """Sets property""" - if not self.HasProperty("projection"): + if name == "projection": self.mapWindowProperties.useDefinedProjection = value - elif not self.HasProperty("resolution"): + elif name == "resolution": + print(name) + print(value) self.mapWindowProperties.resolution = value - elif not self.HasProperty("alignExtent"): + elif name == "alignExtent": + print(name) + print(value) self.mapWindowProperties.alignExtent = value - elif not self.HasProperty("region"): + elif name == "region": + print(name) + print(value) self.mapWindowProperties.showRegion = value else: + print(name) + print(value) self.statusbarManager.SetProperty(name, value) def GetProperty(self, name): """Returns property""" - if not self.HasProperty("projection"): + if name == "projection": return self.mapWindowProperties.useDefinedProjection - elif not self.HasProperty("resolution"): + elif name == "resolution": + print(name) return self.mapWindowProperties.resolution - elif not self.HasProperty("alignExtent"): + elif name == "alignExtent": + print(name) return self.mapWindowProperties.alignExtent - elif not self.HasProperty("region"): - return self.mapWindowProperties.region + elif name == "region": + print(name) + return self.mapWindowProperties.showRegion else: - print("bla") return self.statusbarManager.GetProperty(name) def HasProperty(self, name): From 11d0defe905d913a95bc43ed181d111ede249673 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Mon, 7 Feb 2022 01:23:30 -0600 Subject: [PATCH 07/14] prints removed --- gui/wxpython/gui_core/mapdisp.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/gui/wxpython/gui_core/mapdisp.py b/gui/wxpython/gui_core/mapdisp.py index 2340b530e08..482fbbdb414 100644 --- a/gui/wxpython/gui_core/mapdisp.py +++ b/gui/wxpython/gui_core/mapdisp.py @@ -163,20 +163,12 @@ def SetProperty(self, name, value): if name == "projection": self.mapWindowProperties.useDefinedProjection = value elif name == "resolution": - print(name) - print(value) self.mapWindowProperties.resolution = value elif name == "alignExtent": - print(name) - print(value) self.mapWindowProperties.alignExtent = value elif name == "region": - print(name) - print(value) self.mapWindowProperties.showRegion = value else: - print(name) - print(value) self.statusbarManager.SetProperty(name, value) def GetProperty(self, name): @@ -184,13 +176,10 @@ def GetProperty(self, name): if name == "projection": return self.mapWindowProperties.useDefinedProjection elif name == "resolution": - print(name) return self.mapWindowProperties.resolution elif name == "alignExtent": - print(name) return self.mapWindowProperties.alignExtent elif name == "region": - print(name) return self.mapWindowProperties.showRegion else: return self.statusbarManager.GetProperty(name) From 8171a83111cde92b521dd25904ae5234ff7573a2 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Mon, 7 Feb 2022 01:24:09 -0600 Subject: [PATCH 08/14] mode index adapted --- gui/wxpython/gcp/mapdisplay.py | 2 +- gui/wxpython/image2target/ii2t_mapdisplay.py | 2 +- gui/wxpython/photo2image/ip2i_mapdisplay.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/wxpython/gcp/mapdisplay.py b/gui/wxpython/gcp/mapdisplay.py index 89a0317bf8e..5d78186cad5 100644 --- a/gui/wxpython/gcp/mapdisplay.py +++ b/gui/wxpython/gcp/mapdisplay.py @@ -109,7 +109,7 @@ def __init__( 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) diff --git a/gui/wxpython/image2target/ii2t_mapdisplay.py b/gui/wxpython/image2target/ii2t_mapdisplay.py index 0d78eefe6a6..236fb57588d 100644 --- a/gui/wxpython/image2target/ii2t_mapdisplay.py +++ b/gui/wxpython/image2target/ii2t_mapdisplay.py @@ -114,7 +114,7 @@ def __init__( # 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) diff --git a/gui/wxpython/photo2image/ip2i_mapdisplay.py b/gui/wxpython/photo2image/ip2i_mapdisplay.py index fca945646b3..ea36f09802e 100644 --- a/gui/wxpython/photo2image/ip2i_mapdisplay.py +++ b/gui/wxpython/photo2image/ip2i_mapdisplay.py @@ -107,7 +107,7 @@ def __init__( # 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) From fa4ecb8f403d3f35e4d47dda2e9b731b8ed4ccb6 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Mon, 7 Feb 2022 01:48:08 -0600 Subject: [PATCH 09/14] better order of tabs in special map display applications --- gui/wxpython/gcp/toolbars.py | 3 ++- gui/wxpython/image2target/ii2t_toolbars.py | 3 ++- gui/wxpython/photo2image/ip2i_toolbars.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gui/wxpython/gcp/toolbars.py b/gui/wxpython/gcp/toolbars.py index 561dae3832b..9f1cf2ffcbb 100644 --- a/gui/wxpython/gcp/toolbars.py +++ b/gui/wxpython/gcp/toolbars.py @@ -126,12 +126,13 @@ def _toolbarData(self): ("zoomback", BaseIcons["zoomBack"], self.parent.OnZoomBack), ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap), (None,), - ("settings", icons["settings"], self.parent.OnSettings), ( "mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties, ), + (None,), + ("settings", icons["settings"], self.parent.OnSettings), ("help", icons["help"], self.parent.OnHelp), (None,), ("quit", icons["quit"], self.parent.OnQuit), diff --git a/gui/wxpython/image2target/ii2t_toolbars.py b/gui/wxpython/image2target/ii2t_toolbars.py index 561dae3832b..9f1cf2ffcbb 100644 --- a/gui/wxpython/image2target/ii2t_toolbars.py +++ b/gui/wxpython/image2target/ii2t_toolbars.py @@ -126,12 +126,13 @@ def _toolbarData(self): ("zoomback", BaseIcons["zoomBack"], self.parent.OnZoomBack), ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap), (None,), - ("settings", icons["settings"], self.parent.OnSettings), ( "mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties, ), + (None,), + ("settings", icons["settings"], self.parent.OnSettings), ("help", icons["help"], self.parent.OnHelp), (None,), ("quit", icons["quit"], self.parent.OnQuit), diff --git a/gui/wxpython/photo2image/ip2i_toolbars.py b/gui/wxpython/photo2image/ip2i_toolbars.py index e311b03057f..15697e094c6 100644 --- a/gui/wxpython/photo2image/ip2i_toolbars.py +++ b/gui/wxpython/photo2image/ip2i_toolbars.py @@ -126,12 +126,13 @@ def _toolbarData(self): ("zoomback", BaseIcons["zoomBack"], self.parent.OnZoomBack), ("zoomtomap", BaseIcons["zoomExtent"], self.parent.OnZoomToMap), (None,), - ("settings", icons["settings"], self.parent.OnSettings), ( "mapDispSettings", BaseIcons["mapDispSettings"], self.parent.OnMapDisplayProperties, ), + (None,), + ("settings", icons["settings"], self.parent.OnSettings), ("help", icons["help"], self.parent.OnHelp), (None,), ("quit", icons["quit"], self.parent.OnQuit), From fe1d30294f19f1938df80b5da89d0b8bc5aabe07 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Mon, 7 Feb 2022 04:13:08 -0600 Subject: [PATCH 10/14] put back mapFrame input parameter --- gui/wxpython/gui_core/mapdisp.py | 2 +- gui/wxpython/mapdisp/frame.py | 2 +- gui/wxpython/mapdisp/properties.py | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gui/wxpython/gui_core/mapdisp.py b/gui/wxpython/gui_core/mapdisp.py index 482fbbdb414..2931dae485f 100644 --- a/gui/wxpython/gui_core/mapdisp.py +++ b/gui/wxpython/gui_core/mapdisp.py @@ -501,7 +501,7 @@ def OnMapDisplayProperties(self, event): from mapdisp.properties import MapDisplayPropertiesDialog dlg = MapDisplayPropertiesDialog( - parent=self, giface=self._giface, properties=self.mapWindowProperties + parent=self, mapframe=self, properties=self.mapWindowProperties ) dlg.CenterOnParent() dlg.Show() diff --git a/gui/wxpython/mapdisp/frame.py b/gui/wxpython/mapdisp/frame.py index f16189c2802..c05c5626a67 100644 --- a/gui/wxpython/mapdisp/frame.py +++ b/gui/wxpython/mapdisp/frame.py @@ -1569,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 diff --git a/gui/wxpython/mapdisp/properties.py b/gui/wxpython/mapdisp/properties.py index a5888903e75..d1744ff576b 100644 --- a/gui/wxpython/mapdisp/properties.py +++ b/gui/wxpython/mapdisp/properties.py @@ -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, @@ -180,15 +180,15 @@ 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.mapFrame = mapframe self.name = "region" self.widget = wx.CheckBox( parent=parent, id=wx.ID_ANY, label=_("Show computational extent") @@ -229,7 +229,7 @@ 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): @@ -283,7 +283,7 @@ class MapDisplayPropertiesDialog(wx.Dialog): def __init__( self, parent, - giface, + mapframe, properties, title=_("Map Display Settings"), size=(-1, 250), @@ -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 @@ -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(), @@ -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(), From 590ce1e1fe1c3dc68e38f85b153b4bd525323816 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Tue, 8 Feb 2022 13:13:13 -0600 Subject: [PATCH 11/14] put giface that was originally used --- doc/gui/wxpython/example/frame.py | 2 -- gui/wxpython/iclass/frame.py | 14 +++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/doc/gui/wxpython/example/frame.py b/doc/gui/wxpython/example/frame.py index f1e99b9d31e..8a90c542894 100644 --- a/doc/gui/wxpython/example/frame.py +++ b/doc/gui/wxpython/example/frame.py @@ -83,8 +83,6 @@ def __init__( self, parent=parent, title=title, name=name, Map=Map(), **kwargs ) - self._giface = giface - # Place debug message where appropriate # and set debug level from 1 to 5 (higher to lower level functions). # To enable debug mode write: diff --git a/gui/wxpython/iclass/frame.py b/gui/wxpython/iclass/frame.py index c31a9473e3f..05c38fc47f0 100644 --- a/gui/wxpython/iclass/frame.py +++ b/gui/wxpython/iclass/frame.py @@ -109,9 +109,9 @@ def __init__( **kwargs, ) if giface: - self._giface = giface + self.giface = giface else: - self._giface = StandaloneMapDisplayGrassInterface(self) + self.giface = StandaloneMapDisplayGrassInterface(self) self.tree = None self.mapWindowProperties = MapWindowProperties() self.mapWindowProperties.setValuesFromUserSettings() @@ -120,13 +120,13 @@ def __init__( self.firstMapWindow = IClassVDigitWindow( parent=self, - giface=self._giface, + giface=self.giface, properties=self.mapWindowProperties, map=self.firstMap, ) self.secondMapWindow = BufferedMapWindow( parent=self, - giface=self._giface, + giface=self.giface, properties=self.mapWindowProperties, Map=self.secondMap, ) @@ -189,7 +189,7 @@ def __init__( # PyPlot init self.plotPanel = PlotPanel( - self, giface=self._giface, stats_data=self.stats_data + self, giface=self.giface, stats_data=self.stats_data ) # statusbar items @@ -237,7 +237,7 @@ def _cleanup(self): def OnHelp(self, event): """Show help page""" - self._giface.Help(entry="wxGUI.iclass") + self.giface.Help(entry="wxGUI.iclass") def _getTempVectorName(self): """Return new name for temporary vector map (training areas)""" @@ -372,7 +372,7 @@ def AddToolbar(self, name): toolSwitcher=self._toolSwitcher, MapWindow=self.GetFirstWindow(), digitClass=IClassVDigit, - giface=self._giface, + giface=self.giface, tools=[ "addArea", "moveVertex", From 51c394bf348c4cf16d98e6f5c5d9952525440c9c Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Tue, 8 Feb 2022 13:15:46 -0600 Subject: [PATCH 12/14] return change --- gui/wxpython/iclass/frame.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gui/wxpython/iclass/frame.py b/gui/wxpython/iclass/frame.py index 05c38fc47f0..4ffdef8add5 100644 --- a/gui/wxpython/iclass/frame.py +++ b/gui/wxpython/iclass/frame.py @@ -188,9 +188,7 @@ def __init__( self.dialogs["category"] = None # PyPlot init - self.plotPanel = PlotPanel( - self, giface=self.giface, stats_data=self.stats_data - ) + self.plotPanel = PlotPanel(self, giface=self.giface, stats_data=self.stats_data) # statusbar items statusbarItems = [ From c80f7d7ebf729162c8052ab9b37cc82c1657210b Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Tue, 8 Feb 2022 15:44:43 -0600 Subject: [PATCH 13/14] hasattr/getattr - not working solution yet --- gui/wxpython/core/workspace.py | 2 +- gui/wxpython/gui_core/mapdisp.py | 20 ++++---------------- gui/wxpython/mapdisp/properties.py | 4 ++-- gui/wxpython/mapdisp/statusbar.py | 8 ++++---- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/gui/wxpython/core/workspace.py b/gui/wxpython/core/workspace.py index 365ace9dbf6..3e523bb152d 100644 --- a/gui/wxpython/core/workspace.py +++ b/gui/wxpython/core/workspace.py @@ -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 diff --git a/gui/wxpython/gui_core/mapdisp.py b/gui/wxpython/gui_core/mapdisp.py index 2931dae485f..d94ab8a6190 100644 --- a/gui/wxpython/gui_core/mapdisp.py +++ b/gui/wxpython/gui_core/mapdisp.py @@ -160,27 +160,15 @@ def GetToolSwitcher(self): def SetProperty(self, name, value): """Sets property""" - if name == "projection": - self.mapWindowProperties.useDefinedProjection = value - elif name == "resolution": - self.mapWindowProperties.resolution = value - elif name == "alignExtent": - self.mapWindowProperties.alignExtent = value - elif name == "region": - self.mapWindowProperties.showRegion = value + if hasattr(self.mapWindowProperties, name): + setattr(self.mapWindowProperties, name, value) else: self.statusbarManager.SetProperty(name, value) def GetProperty(self, name): """Returns property""" - if name == "projection": - return self.mapWindowProperties.useDefinedProjection - elif name == "resolution": - return self.mapWindowProperties.resolution - elif name == "alignExtent": - return self.mapWindowProperties.alignExtent - elif name == "region": - return self.mapWindowProperties.showRegion + if hasattr(self.mapWindowProperties, name): + getattr(self.mapWindowProperties, name) else: return self.statusbarManager.GetProperty(name) diff --git a/gui/wxpython/mapdisp/properties.py b/gui/wxpython/mapdisp/properties.py index d1744ff576b..f7c4dfc5e08 100644 --- a/gui/wxpython/mapdisp/properties.py +++ b/gui/wxpython/mapdisp/properties.py @@ -189,7 +189,7 @@ class ChBShowRegion(PropertyItem): def __init__(self, parent, mapframe, mapWindowProperties): PropertyItem.__init__(self, mapWindowProperties) self.mapFrame = mapframe - self.name = "region" + self.name = "showRegion" self.widget = wx.CheckBox( parent=parent, id=wx.ID_ANY, label=_("Show computational extent") ) @@ -237,7 +237,7 @@ class ChBProjection(PropertyItem): 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) diff --git a/gui/wxpython/mapdisp/statusbar.py b/gui/wxpython/mapdisp/statusbar.py index bba4297185d..70e234fec73 100644 --- a/gui/wxpython/mapdisp/statusbar.py +++ b/gui/wxpython/mapdisp/statusbar.py @@ -568,7 +568,7 @@ def OnGoTo(self, event): """Go to position""" try: e, n = self.GetValue().split(";") - e, n = self.ReprojectENToMap(e, n, self.mapFrame.GetProperty("projection")) + e, n = self.ReprojectENToMap(e, n, self.mapFrame.GetProperty("useDefinedProjection")) self.mapFrame.GetWindow().GoTo(e, n) self.widget.SetFocus() except ValueError: @@ -614,7 +614,7 @@ def GetCenterString(self, map): group="projection", key="statusbar", subkey="proj4" ) - if self.mapFrame.GetProperty("projection"): + if self.mapFrame.GetProperty("useDefinedProjection"): if not projection: raise SbException(_("Projection not defined (check the settings)")) else: @@ -744,7 +744,7 @@ def Show(self): UserSettings.Get(group="projection", key="format", subkey="precision") ) format = UserSettings.Get(group="projection", key="format", subkey="ll") - projection = self.mapFrame.GetProperty("projection") + projection = self.mapFrame.GetProperty("useDefinedProjection") try: e, n = self.mapFrame.GetWindow().GetLastEN() self._basicValue = self.ReprojectENFromMap( @@ -827,7 +827,7 @@ def Show(self): UserSettings.Get(group="projection", key="format", subkey="precision") ) format = UserSettings.Get(group="projection", key="format", subkey="ll") - projection = self.mapFrame.GetProperty("projection") + projection = self.mapFrame.GetProperty("useDefinedProjection") region = self._getRegion() try: regionReprojected = self.ReprojectRegionFromMap( From 3883471bd172ab511732cde7977c8ca1d915cfe0 Mon Sep 17 00:00:00 2001 From: lindakladivova Date: Wed, 9 Feb 2022 08:35:25 -0600 Subject: [PATCH 14/14] bug fixed, black --- gui/wxpython/gui_core/mapdisp.py | 2 +- gui/wxpython/mapdisp/statusbar.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gui/wxpython/gui_core/mapdisp.py b/gui/wxpython/gui_core/mapdisp.py index d94ab8a6190..801b979d1ff 100644 --- a/gui/wxpython/gui_core/mapdisp.py +++ b/gui/wxpython/gui_core/mapdisp.py @@ -168,7 +168,7 @@ def SetProperty(self, name, value): def GetProperty(self, name): """Returns property""" if hasattr(self.mapWindowProperties, name): - getattr(self.mapWindowProperties, name) + return getattr(self.mapWindowProperties, name) else: return self.statusbarManager.GetProperty(name) diff --git a/gui/wxpython/mapdisp/statusbar.py b/gui/wxpython/mapdisp/statusbar.py index 70e234fec73..c3186078a98 100644 --- a/gui/wxpython/mapdisp/statusbar.py +++ b/gui/wxpython/mapdisp/statusbar.py @@ -568,7 +568,9 @@ def OnGoTo(self, event): """Go to position""" try: e, n = self.GetValue().split(";") - e, n = self.ReprojectENToMap(e, n, self.mapFrame.GetProperty("useDefinedProjection")) + e, n = self.ReprojectENToMap( + e, n, self.mapFrame.GetProperty("useDefinedProjection") + ) self.mapFrame.GetWindow().GoTo(e, n) self.widget.SetFocus() except ValueError: