Skip to content

Commit

Permalink
wxGUI/mapwin: fix correct horizontal raster legend position after app…
Browse files Browse the repository at this point in the history
…ly new legend setting (#1080)
  • Loading branch information
tmszi committed Dec 3, 2020
1 parent b7bfe26 commit 47579af
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions gui/wxpython/mapwin/decorations.py
Expand Up @@ -267,8 +267,30 @@ def __init__(self, renderer, giface):
self._activateLabel = _("Raster legend properties")
# default is in the center to avoid trimmed legend on the edge
self._defaultAt = 'at=5,50,47,50'
self._actualAt = self._defaultAt
self._cmd = ['d.legend', self._defaultAt]

def SetCmd(self, cmd):
"""Overriden method
Required for setting default or actual raster legend position.
"""
hasAt = False
for i in cmd:
if i.startswith("at="):
hasAt = True
# reset coordinates, 'at' values will be used, see GetCoords
self._coords = None
break
if not hasAt:
if self._actualAt != self._defaultAt:
cmd.append(self._actualAt)
else:
cmd.append(self._defaultAt)
self._cmd = cmd

cmd = property(fset=SetCmd, fget=OverlayController.GetCmd)

def GetPlacement(self, screensize):
if not hasPIL:
self._giface.WriteWarning(
Expand Down Expand Up @@ -330,6 +352,7 @@ def ResizeLegend(self, begin, end, screenSize):
break

self._coords = None
self._actualAt = atStr
self.Show()

def StartResizing(self):
Expand Down

0 comments on commit 47579af

Please sign in to comment.