-
-
Notifications
You must be signed in to change notification settings - Fork 327
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: Move SbMask widget to main window statusbar #2089
wxGUI: Move SbMask widget to main window statusbar #2089
Conversation
gui/wxpython/main_window/frame.py
Outdated
@@ -351,6 +369,7 @@ def _createConsole(self, parent): | |||
) | |||
|
|||
self._gconsole.mapCreated.connect(self.OnMapCreated) | |||
self._gconsole.updateMap.connect(self.RefreshMask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be mapCreated?
You also need to refresh it initially, it doesn't seem to show up when you start GUI and mask exists. |
I agree. I was also thinking about GSConsole in forms.py - I think we should add r.mask to r.colours and other items in a list. But the problem is that the map returned from r.mask is the map from which the mask was created - not the resulting MASK. So we would probably need to update a bit a way r.mask works?.. |
I have prepared the list of situations when the Mask red button should be refreshed - or better said situations when we need to check whether the MASK file exists. Please @petrasovaa check it and add something if missing:
Probably all, but I am not sure about workspaces... |
Any raster/vector module that creates a raster layer can create MASK layer, probably not how most people would do that, but possible. |
I suggest these changes, that should cover most cases
|
I agree with that, in addition, I suggest adding |
There is also the thing with the Data Catalog grassdb update. It is not ideal but I would suggest adding a few rows to gconsole.py. And also after removing the MASK using the button, we should also emit grassdbChanged signal... , please look at 3f74719 |
I have just finished the last part regarding status bar repositioning, I think we are almost at the end. :-) |
gui/wxpython/main_window/frame.py
Outdated
def _createStatusbar(self): | ||
"""Create main window statusbar""" | ||
self.statusbar = wx.StatusBar(self, id=wx.ID_ANY) | ||
self.statusbar.SetMinHeight(24) | ||
self.statusbar.SetFieldsCount(2) | ||
self.statusbar.SetStatusWidths([-1, 100]) | ||
self.mask = SbMask(self.statusbar, self._giface) | ||
self._repositionStatusbar() | ||
|
||
def _repositionStatusbar(self): | ||
"""Reposition widgets in main window statusbar""" | ||
rect1 = self.statusbar.GetFieldRect(1) | ||
rect1.x += 1 | ||
rect1.y += 1 | ||
self.mask.GetWidget().SetRect(rect1) | ||
|
||
def OnSize(self, event): | ||
"""Adjust main window statusbar on changing size""" | ||
self._repositionStatusbar() | ||
|
||
def SetStatusText(self, *args): | ||
"""Overide wx.StatusBar method""" | ||
self.statusbar.SetStatusText(*args) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this into lmgr/statusbar.py, similarly to the SbManager, frame.py is already big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. :-) I made the class SbMain which encapsulates the creation as well as statusbar reposition..
gui/wxpython/lmgr/statusbar.py
Outdated
dlg.Destroy() | ||
return | ||
RunCommand("r.mask", flags="r") | ||
self.giface.updateMap.emit(render=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to emit updateMap whenever the status changes, maybe in Refresh(). Otherwise map display won't refresh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure. I think it is sufficient to emit updateMap just in gconsole.py. In this case, it refreshes when using the module - so when creating and removing mask through r.mask.
After currentMapsetChanged I think we do not need to update a map and after grassdbChanged a map is updated automatically. Which other possible scenarios are in your mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try also running r.mask from command console
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote some of the signals, let me know if you agree and please test, before that rerendering of map display didn't work.
Nice, it makes greater sense like that. I have tested it by running r.mask from the command console and I've also tested all other cases and checked the map rendering, data catalog updating, mask button updating. All seem to be working fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there!
Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
…eo#2089) Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
…eo#2089) Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
…eo#2089) Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
It moves statusbar Mask widget to the main statusbar. It is also changing the way Mask is updated - now it is updated using signals and method RefreshMask.