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/digitizer: fix digitizer - VDigitToolbar.OnTool method was not called #3027

Merged
merged 4 commits into from Jun 21, 2023

Conversation

petrasovaa
Copy link
Contributor

The bug could be reproduced by:

  1. Starting digitizer
  2. Switch to panning
  3. Switch to a digitizer tool -> doesn't work

Also g.gui.iclass doesn't work.

The toolbar tools were bound to the ToolbarController.OnTool method, this PR replaces the controller's method in runtime by the specific one in digitizer toolbar. Probably there could be a better solution, but this seems to work and the code is changed minimally.

Unrelated change is removing setting focus, seems to help with using keyboard shortcuts.

@petrasovaa petrasovaa added bug Something isn't working GUI wxGUI related backport to 8.3 PR needs to be backported to release branch 8.3 backport to 8.2 PR needs to be backported to release branch 8.2 labels Jun 6, 2023
@petrasovaa petrasovaa added this to the 8.3.0 milestone Jun 6, 2023
@@ -446,14 +449,15 @@ def OnTool(self, event):
3,
f"VDigitToolbar.OnTool(): id = {event.GetId() if event else event}",
)
if self.toolSwitcher:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you try activate Digitize new boundary (Ctrl+B) or Digitize new centroid (Ctrl+C) tool by keyboard shortcut you get error:

Traceback (most recent call last):
  File
"/usr/lib64/grass84/gui/wxpython/vdigit/mapwindow.py", line
220, in OnKeyDown

event = self.toolbar.OnTool(tool["event"])
  File "/usr/lib64/grass84/gui/wxpython/vdigit/toolbars.py",
line 453, in OnTool

self.toolSwitcher.ToolChanged(event.GetId())
AttributeError
:
'NoneType' object has no attribute 'GetId'

code line should be:

if self.toolSwitcher and event:

@@ -467,8 +471,7 @@ def OnTool(self, event):
if self.action["id"] == -1:
self.action = {"desc": "", "type": "", "id": -1}

# set focus
self.MapWindow.SetFocus()
event.Skip()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment.

code line should be:

if event:
    event.Skip()

@tmszi
Copy link
Member

tmszi commented Jun 8, 2023

g.gui.iclass has another bug (vdigit keyboard shortcut not working)

Traceback (most recent call last):
  File "/usr/lib64/grass84/gui/wxpython/vdigit/mapwindow.py", line 141, in OnKeyDown
    "event": wx.CommandEvent(id=self.toolbar.addPoint),
  File "/usr/lib64/grass84/gui/wxpython/gui_core/toolbars.py", line 386, in __getattr__
    return getattr(self.controller, name)
AttributeError: 'ToolbarController' object has no attribute 'addPoint'

All bugs fix patch attached.
bugfix.patch.zip

git am bugfix.patch

@petrasovaa
Copy link
Contributor Author

Thanks, I further simplified your code.

@petrasovaa petrasovaa requested a review from tmszi June 18, 2023 21:30
Copy link
Member

@tmszi tmszi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With your simplification commit ef5d9e7 activation Digitize new boundary (Ctrl+B) and Digitize new centroid (Ctrl+C) by keyboard shortcut is not working as expected.

Steps to reproduce:

  1. Display some vector map d.vect geology
  2. Activate Vector digitizer for geology vector map
  3. Change focus on actual map display
  4. Activate and use Pan tool
  5. Try activate Digitize new point (Ctrl+P) tool by keyboard shortcut
  6. Try activate Digitize new boundary (Ctrl+B) tool, or Digitize new centroid (Ctrl+C) tool by keyboard shortcut is not working

@petrasovaa
Copy link
Contributor Author

petrasovaa commented Jun 21, 2023

Thanks, I believe it's all fixed now, I think this is good to be merged.

Copy link
Contributor

@nilason nilason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works good on Mac with Python 3.10.10 and wxPython 4.2.0.

@tmszi
Copy link
Member

tmszi commented Jun 21, 2023

It works as expected.

@landam landam modified the milestones: 8.3.0, 8.4.0 Jun 21, 2023
@petrasovaa petrasovaa merged commit 84fc38f into OSGeo:main Jun 21, 2023
19 checks passed
@petrasovaa petrasovaa deleted the fix-digitizer branch June 21, 2023 17:06
petrasovaa added a commit that referenced this pull request Jun 21, 2023
…called (#3027)

Co-authored-by: Tomas Zigo <tomas.zigo@slovanet.sk>
@petrasovaa petrasovaa removed the backport to 8.3 PR needs to be backported to release branch 8.3 label Jun 21, 2023
@petrasovaa petrasovaa modified the milestones: 8.4.0, 8.3.0 Jun 21, 2023
@landam
Copy link
Member

landam commented Jun 21, 2023

@petrasovaa are you planning also backport to 8.2?

@petrasovaa
Copy link
Contributor Author

@petrasovaa are you planning also backport to 8.2?

Yes, will get back to it, it can't be simply cherry-picked due to conflict.

landam pushed a commit to landam/grass that referenced this pull request Oct 25, 2023
…called (OSGeo#3027)

Co-authored-by: Tomas Zigo <tomas.zigo@slovanet.sk>
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
…called (OSGeo#3027)

Co-authored-by: Tomas Zigo <tomas.zigo@slovanet.sk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport to 8.2 PR needs to be backported to release branch 8.2 bug Something isn't working GUI wxGUI related
Development

Successfully merging this pull request may close these issues.

None yet

4 participants