Opened 9 years ago

Closed 7 years ago

#1463 closed defect (fixed)

Legend, Zoom to map, Map analysis and Map query does not work in Python wxgui using command line d.mon + d.rast

Reported by: huhabla Owned by: grass-dev@…
Priority: major Milestone: 7.0.0
Component: wxGUI Version: svn-trunk
Keywords: d.mon Cc:
CPU: Unspecified Platform: Unspecified

Description

Some important GUI features are missing when displaying raster maps using d.mon and d.rast from command line.

1.) Raster map legends are not displayed, error:

  File "/home/soeren/src/grass7.0/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/gui_modules/mapdisp.py", line 1528, in OnAddLegend
    if self.tree.layer_selected and \
AttributeError: 'NoneType' object has no attribute 'layer_selected'

2.) Zoom to selected map layers does not work

3.) Query raster/vector maps does not work, error:

  File "/home/soeren/src/grass7.0/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/gui_modules/mapdisp_window.py", line 1107, in MouseActions
    self.OnLeftUp(event)
  File "/home/soeren/src/grass7.0/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/gui_modules/mapdisp_window.py", line 1297, in OnLeftUp
    self.parent.QueryVector(self.mouse['begin'][0], self.mouse['begin'][1])
  File "/home/soeren/src/grass7.0/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/gui_modules/mapdisp.py", line 1067, in QueryVector
    if not self.tree.layer_selected or \
AttributeError: 'NoneType' object has no attribute 'layer_selected'

4.) Analyze map does not work, error:

  File "/home/soeren/src/grass7.0/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/gui/wxpython/gui_modules/mapdisp.py", line 1427, in OnScatterplot
    for layer in self.tree.GetSelections():
AttributeError: 'NoneType' object has no attribute 'GetSelections'

It seems to me that "self.tree" object is not initialized when mapdisp.py is run from command line?

Change History (6)

comment:1 Changed 9 years ago by huhabla

Is it possible to create an "invisible" dummy LayerTree?, filled with information about the map to be drawn from command line? So that the depending functionality in mapdisplay.py works?

comment:2 in reply to:  1 Changed 9 years ago by martinl

Replying to huhabla:

Is it possible to create an "invisible" dummy LayerTree?, filled with information about the map to be drawn from command line? So that the depending functionality in mapdisplay.py works?

I think that it's better to fix mapdisp.py in the sense to avoid using LayerTree? when starting wx display using d.mon. It seems to me that a dummy Layer Tree is not necessary, or better to say it would be anything usable.

comment:3 Changed 9 years ago by cmbarton

I agree with Martin. Most of the calls to LayerTree? here are simply 'convenience' functions to put current maps or currently selected maps into map selection controls. If we can tell if mapdisp.py is being started standalone from d.mon, we can just skip those convenience calls.

Michael

comment:4 in reply to:  description Changed 9 years ago by martinl

Replying to huhabla:

1.) Raster map legends are not displayed, error:

hopefully fixed in r48828

2.) Zoom to selected map layers does not work

hopefully fixed in r48828

3.) Query raster/vector maps does not work, error: 4.) Analyze map does not work, error:

I am not sure how treat "get selected maps", should it return lastly added map, or all maps in cmdfile?

Martin

comment:5 Changed 7 years ago by mlennert

I'm not sure I understand issue 4) (if it's creating a scatterplot it works for me), but the others seem fixed to me. Can we close ?

comment:6 in reply to:  5 Changed 7 years ago by wenzeslaus

Resolution: fixed
Status: newclosed

There were also refactoring which fixed a lot of issues like these. I cannot list particular changesets; there was a lot of them (in 2012 and 2013).

For GUI developers: The fix usually was replacing call of self.tree.DoSomething by self.giface.DoSomethingSimilar or by emitting Signal or wxevent. But the actual fixes may differ.

For testers: There is a test_mapdisp.py script in gui/wxpython/mapdisp which tests whether a map display and a map window works without any layer manager and layer tree objects. It should be accessible using:

cd gui/wxpython/mapdisp
python test_mapdisp.py

But currently I'm not able to run it this way since gparser (which is used) requires a module to by on-path (but it was working when I created this script a month ago).

Still there may be some non-working things in d.mon but I remember that I've fixed several of the issues above (they probably re-appeared after r48828). Since it works for mlennert, I'm closing the ticket.

If there is some other issue, I suggest to open a new ticket for it.

Note: See TracTickets for help on using tickets.