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/mapdisp: it is also possible to remove the MASK interactively #1176

Merged
Merged
Changes from all 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
31 changes: 27 additions & 4 deletions gui/wxpython/mapdisp/statusbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from core import utils
from core.gcmd import RunCommand
from core.settings import UserSettings
from gui_core.wrap import StaticText, TextCtrl
from gui_core.wrap import Button, TextCtrl

from grass.script import core as grass

Expand Down Expand Up @@ -283,7 +283,6 @@ def Reposition(self):
wWin = rect.width - 6
if idx == 2: # mask
x += 5
y += 4
elif idx == 3: # render
x += 5
win.SetPosition((x, y))
Expand Down Expand Up @@ -894,14 +893,20 @@ def Update(self):


class SbMask(SbItem):
"""StaticText to show whether mask is activated."""
"""Button to show whether mask is activated and remove mask with
left mouse click
"""

def __init__(self, mapframe, statusbar, position=0):
SbItem.__init__(self, mapframe, statusbar, position)
self.name = "mask"

self.widget = StaticText(parent=self.statusbar, id=wx.ID_ANY, label=_("MASK"))
self.widget = Button(
parent=self.statusbar, id=wx.ID_ANY, label=_("MASK"), style=wx.NO_BORDER
)
self.widget.Bind(wx.EVT_BUTTON, self.OnRemoveMask)
self.widget.SetForegroundColour(wx.Colour(255, 0, 0))
self.widget.SetToolTip(tip=_("Left mouse click to remove the MASK"))
self.widget.Hide()

def Update(self):
Expand All @@ -912,6 +917,24 @@ def Update(self):
else:
self.Hide()

def OnRemoveMask(self, event):
if grass.find_file(
name="MASK", element="cell", mapset=grass.gisenv()["MAPSET"]
)["name"]:

dlg = wx.MessageDialog(
self.mapFrame,
message=_("Are you sure that you want to remove the MASK?"),
caption=_("Remove MASK"),
style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION,
)
if dlg.ShowModal() != wx.ID_YES:
dlg.Destroy()
return
RunCommand("r.mask", flags="r")
self.Hide()
self.mapFrame.OnRender(event=None)


class SbTextItem(SbItem):
"""Base class for items without widgets.
Expand Down