[GRASS-dev] [GRASS GIS] #1463: Legend, Zoom to map, Map analysis and Map query does not work in Python wxgui using command line d.mon + d.rast

#1463: Legend, Zoom to map, Map analysis and Map query does not work in Python
wxgui using command line d.mon + d.rast
-------------------------+--------------------------------------------------
Reporter: huhabla | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: d.mon | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
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?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1463&gt;
GRASS GIS <http://grass.osgeo.org>

#1463: Legend, Zoom to map, Map analysis and Map query does not work in Python
wxgui using command line d.mon + d.rast
-------------------------+--------------------------------------------------
Reporter: huhabla | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: d.mon | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(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?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1463#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1463: Legend, Zoom to map, Map analysis and Map query does not work in Python
wxgui using command line d.mon + d.rast
-------------------------+--------------------------------------------------
Reporter: huhabla | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: d.mon | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by martinl):

Replying to [comment:1 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.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1463#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1463: Legend, Zoom to map, Map analysis and Map query does not work in Python
wxgui using command line d.mon + d.rast
-------------------------+--------------------------------------------------
Reporter: huhabla | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: d.mon | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(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

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1463#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1463: Legend, Zoom to map, Map analysis and Map query does not work in Python
wxgui using command line d.mon + d.rast
-------------------------+--------------------------------------------------
Reporter: huhabla | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: d.mon | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by martinl):

Replying to [ticket:1463 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

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1463#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#1463: Legend, Zoom to map, Map analysis and Map query does not work in Python
wxgui using command line d.mon + d.rast
-------------------------+--------------------------------------------------
Reporter: huhabla | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: d.mon | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(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 ?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1463#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#1463: Legend, Zoom to map, Map analysis and Map query does not work in Python
wxgui using command line d.mon + d.rast
--------------------------+-------------------------------------------------
  Reporter: huhabla | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: d.mon
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by wenzeslaus):

  * status: new => closed
  * resolution: => fixed

Comment:

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 [comment:5 mlennert], I'm closing the ticket.

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

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1463#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>