[GRASS-dev] [GRASS GIS] #1059: wxGUI: No menu option for r.mapcalc

#1059: wxGUI: No menu option for r.mapcalc
-----------------------------+----------------------------------------------
Reporter: vesnikos | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Keywords: r.mapcalc wxGUI | Platform: Linux
      Cpu: x86-32 |
-----------------------------+----------------------------------------------
I was trying some of the examples of grassbook, and in one of them I
needed to use r.mapcalc

I searched it through the command search option using the gui (r.mapcalc)
but it didnt return anything. r3.mapcalc exits.

r.mapcalc command is accessible from cli

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Changes (by martinl):

* cc: grass-dev@lists.osgeo.org (added)
  * owner: grass-dev@lists.osgeo.org => martinl
  * status: new => assigned

Comment:

{{{r.mapcalc}}} added to the menu in r42183.

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by vesnikos):

when starting wxgui:

AttributeError: 'GMFrame' object has no attribute 'MapCalculator'

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by martinl):

Try r42184

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by vesnikos):

r42184 gave the error

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by vesnikos):

same error with r42183

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by mmetz):

Replying to [ticket:1059 vesnikos]:
> I was trying some of the examples of grassbook, and in one of them I
needed to use r.mapcalc
>
> I searched it through the command search option using the gui
(r.mapcalc) but it didnt return anything. r3.mapcalc exits.
>
> r.mapcalc command is accessible from cli

I think the menu entry "Map calculator" between "Mask" and "Neighborhood
Analysis" is what you are looking for, present in r42182 and earlier.

The wxGUI of r42183 and r42184 is broken for me too, same error here as in
comment 2.

Markus M

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by vesnikos):

thank you markus, thats what i was looking for.

Still shouldn't r.mapcalc open the said window?

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by martinl):

Replying to [comment:6 mmetz]:
> The wxGUI of r42183 and r42184 is broken for me too, same error here as
in comment 2.

r42187 ?

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by vesnikos):

works like charm. No crashes, starts up. good fix

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: closed
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Changes (by martinl):

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

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: reopened
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Changes (by mmetz):

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

Comment:

I am not so sure about these changes. In 6.4.0RC6 I can do

{{{
GRASS 6.4.0RC6 (nc_spm_08):~ > r.mapcalc
Enter expressions, "end" when done.
mapcalc> test = 1.1
mapcalc> test2 = 2.1
mapcalc> end

  100%
GRASS 6.4.0RC6 (nc_spm_08):~ >
}}}

This is now no longer possible in grass7. In grass6 there is
r.mapcalculator which pops up a GUI dialog and is a wrapper for r.mapcalc.
r.mapcalculator is present in grass7, but as bash script, apparently it
awaits translation to python? I personally would rather like to have
r.mapcalc in trunk as in r42182 and use r.mapcalculator to provide a GUI
interface like is done now for the modified r.mapcalc, another one than
the fancy Map calculator? All the recent changes are done only to get a
hit when searching the module in the wxGUI? IMHO, functionality has been
removed, not added.

Reopening the ticket for discussion.

Markus M

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: reopened
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by glynn):

Replying to [comment:11 mmetz]:

> This is now no longer possible in grass7.

r42183 was incomplete; this should be fixed by r42210.

> r.mapcalculator is present in grass7, but as bash script, apparently it
awaits translation to python?

The consensus was that it wasn't worth maintaining. In 7.0, r.mapcalc uses
G_parser(), so it can be run directly from the GUI without requiring a
wrapper.

> All the recent changes are done only to get a hit when searching the
module in the wxGUI?

r42183 had two parts: fixing the GUI menu, and cosmetic changes to
r.mapcalc. The latter included renaming the input= option to file=, but
overlooked the fact that it synthesises "input=-" when run without
arguments (to preserve the historical behaviour). The change broke this
behaviour; r42210 reinstates it.

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: reopened
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by mmetz):

Replying to [comment:12 glynn]:
> Replying to [comment:11 mmetz]:
>
> > This is now no longer possible in grass7.
>
> r42183 was incomplete; this should be fixed by r42210.
Thanks!
>
> > r.mapcalculator is present in grass7, but as bash script, apparently
it awaits translation to python?
>
> The consensus was that it wasn't worth maintaining. In 7.0, r.mapcalc
uses G_parser(), so it can be run directly from the GUI without requiring
a wrapper.

OK, nice.
>
> > All the recent changes are done only to get a hit when searching the
module in the wxGUI?
>
> r42183 had two parts: fixing the GUI menu, and cosmetic changes to
r.mapcalc. The latter included renaming the input= option to file=, but
overlooked the fact that it synthesises "input=-" when run without
arguments (to preserve the historical behaviour). The change broke this
behaviour; r42210 reinstates it.

Why not just

{{{
Index: gui/wxpython/xml/menudata.xml

--- gui/wxpython/xml/menudata.xml (revision 42182)
+++ gui/wxpython/xml/menudata.xml (working copy)
@@ -1010,7 +1010,9 @@
         <menuitem>
           <label>Map calculator</label>
           <help>Map calculator for raster map algebra</help>
+ <keywords>raster</keywords>
           <handler>DispMapCalculator</handler>
+ <command>r.mapcalc</command>
         </menuitem>
         <menu>
           <label>Neighborhood analysis</label>

}}}

against r42182? AFAICT, no modifications needed for raster/r.mapcalc

BTW, could the Map calculator get an output window and the r.mapcalc
manual?

Thanks,

Markus M

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: reopened
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by martinl):

Replying to [comment:13 mmetz]:
{{{
> Index: gui/wxpython/xml/menudata.xml
> ===================================================================
> --- gui/wxpython/xml/menudata.xml (revision 42182)
> +++ gui/wxpython/xml/menudata.xml (working copy)
> @@ -1010,7 +1010,9 @@
> <menuitem>
> <label>Map calculator</label>
> <help>Map calculator for raster map algebra</help>
> + <keywords>raster</keywords>
> <handler>DispMapCalculator</handler>
> + <command>r.mapcalc</command>
> </menuitem>
> <menu>
> <label>Neighborhood analysis</label>
>
}}}

It shows [http://grass.osgeo.org/wiki/WxPython-
based_GUI_for_GRASS#Map_Calculator wxGUI Map Calculator]. There is already
item for {{{r.mapcalc}}} in the menu
[source:grass/trunk/gui/wxpython/xml/menudata.xml@42210#L1011]

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: reopened
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by martinl):

Replying to [comment:13 mmetz]:
> > > r.mapcalculator is present in grass7, but as bash script, apparently
it awaits translation to python?

I think we don't need {{{r.mapcalculator}}}, {{{r.mapcalc}}} uses
G_parser() and moreover there is wxGUI Map Calculator also available. I
would suggest to remove this script from trunk.

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: reopened
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by mmetz):

Replying to [comment:14 martinl]:
> Replying to [comment:13 mmetz]:
> {{{
> > Index: gui/wxpython/xml/menudata.xml
> > ===================================================================
> > --- gui/wxpython/xml/menudata.xml (revision 42182)
> > +++ gui/wxpython/xml/menudata.xml (working copy)
> > @@ -1010,7 +1010,9 @@
> > <menuitem>
> > <label>Map calculator</label>
> > <help>Map calculator for raster map algebra</help>
> > + <keywords>raster</keywords>
> > <handler>DispMapCalculator</handler>
> > + <command>r.mapcalc</command>
> > </menuitem>
> > <menu>
> > <label>Neighborhood analysis</label>
> >
> }}}
>
> It shows [http://grass.osgeo.org/wiki/WxPython-
based_GUI_for_GRASS#Map_Calculator wxGUI Map Calculator]. There is already
item for {{{r.mapcalc}}} in the menu
[source:grass/trunk/gui/wxpython/xml/menudata.xml@42210#L1011]

I was talking about r42182, before this flood of changes came in. My diff
is against revision 42182, not revision 42210. In r42210, a lot of changes
have been made to the GUI and the module, some of the changes have been
changed again...

My point is that probably much less changes were required to make
r.mapcalc visible in the wxGUI command search, that the GUI should be
fixed first, before modules get broken by a quick fix, that the two
different interfaces for r.mapcalc are confusing, that more testing should
be done on the local copy before a commit, and that the Map Calculator
wxGUI interface is nice but unfinished work, no output, no help. I
personally would recommend to go back to r42182 and start anew, looking
for a solution that requires less modifications.

Sorry for the ranting, but even though trunk is the development version, I
would sometimes prefer some more testing before submitting changes, and a
flood of commits for the same problem within one day clearly indicates
that the first commits were not well thought through.

Markus M

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: reopened
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by martinl):

Replying to [comment:16 mmetz]:
> I was talking about r42182, before this flood of changes came in. My
diff is against revision 42182, not revision 42210. In r42210, a lot of
changes have been made to the GUI and the module, some of the changes have
been changed again...

Most of the changes are related to the major clean up of mcalc_builder.py
which is unrelated to this ticket. It was just long-term TODO.

> My point is that probably much less changes were required to make
r.mapcalc visible in the wxGUI command search, that the GUI should be
fixed first, before modules get broken by a quick

Seems to work for me, http://gama.fsv.cvut.cz/~landa/grass/swf/wxgui-
search-module.html.
{{{r.mapcalc}}} has been added to the menu by changing menudata.xml,
nothing more. Anyway sorry that I broke the {{{r.mapcalc}}} interface.

> fix, that the two different interfaces for r.mapcalc are confusing, that
more testing should be done on the local copy before a commit, and that
the Map Calculator wxGUI interface is nice but unfinished work, no output,
no help. I personally would recommend to go back to r42182 and start anew,
looking for a solution that requires less modifications.

I am not original author of wxGUI Map Calc. In any case it's a usable
tool. Of course it needs various fixes, any volunteer welcomed... See
simple example at http://gama.fsv.cvut.cz/~landa/grass/swf/wxgui-
mapcalc.html. Anyway to have two items in the menu can be confusing.

> Sorry for the ranting, but even though trunk is the development version,
I would sometimes prefer some more testing before submitting changes, and
a flood of commits for the same problem within one day clearly indicates
that the first commits were not well thought through.

wxGUI is quite experimental from my point of view. It's not part of
'core', anyway this flood of commits refers mostly to clean up of
mcalc_bulder.py module.

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: reopened
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by mmetz):

Replying to [comment:17 martinl]:
> Replying to [comment:16 mmetz]:
> > I was talking about r42182, before this flood of changes came in. My
diff is against revision 42182, not revision 42210. In r42210, a lot of
changes have been made to the GUI and the module, some of the changes have
been changed again...
>
> Most of the changes are related to the major clean up of
mcalc_builder.py which is unrelated to this ticket. It was just long-term
TODO.

There were at least 4 commits related to this ticket, these I mean. IMHO,
the first two were done a bit in a hurry, and I want to ask for some more
care and testing before committing (nice word in this context), granted
that some bugs can always slip through.

> > [snip], that the two different interfaces for r.mapcalc are confusing.
>
> [snip] Anyway to have two items in the menu can be confusing.

So is there really a need for two GUI interfaces for r.mapcalc? I'm sure
it is possible to link r.mapcalc to the Map calculator GUI in the GUI
command search.
>
>
> wxGUI is quite experimental from my point of view. It's not part of
'core',

From this point of view, even less reason to modify a core module like
r.mapcalc just for a quick wxGUI fix. OTOH, it's the only GUI in trunk,
and default for 6.4+ IIRC...

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

#1059: wxGUI: No menu option for r.mapcalc
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: martinl
      Type: defect | Status: reopened
  Priority: major | Milestone: 7.0.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: r.mapcalc wxGUI
  Platform: Linux | Cpu: x86-32
-----------------------+----------------------------------------------------
Comment (by cmbarton):

If you type a GRASS command and press return, the parser reads xml
information pass from running [command] --interface-description, and
builds a basic GUI from this. Actually, the module GUI it builds is pretty
sophisticated, with format control, choice boxes, color pickers, etc. If
you run r.mapcalc this way, this is the kind of GUI you get--one that
gives you a more accessible way to complete required and optional
arguments, see output, and have access to the manual.

The map calculator that is accessible from the GUI is a special module
that only runs in the wxPython environment of the GUI. It presents a much
more graphical interface, with a "calculator" like appearance. It is not
callable automatically by the parser when you run r.mapcalc.

To link this calculator-like interface to mapcalc, you probably would need
to change the parser code to make a special exception for r.mapcalc. Then
you would need to change the map calculator code to make it run stand-
alone. Neither of these changes are trivial.

And I don't think this is really necessary. Most people running r.mapcalc
from the command line will be comfortable with entering mapcalc
expressions. Those running the map calculator can use expressions, but
don't need to. The calculator can help them learn these expressions,
however. Nonetheless, they are likely to be a different set of users.

Michael

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