[GRASS5] New gui.tcl generic user interface

Good evening,

I have hammered out a new gui.tcl. This is the file that produces the generic
graphical user interface for all of the other programs.

Screenshots:

g.region, as it first comes up:
http://www.shockfamily.net/cedric/grass/newgui1.png

Sample output:
http://www.shockfamily.net/cedric/grass/newgui2.png

A fake test-script that shows guisections for a command like g.region
http://www.shockfamily.net/cedric/grass/newgui3.png

Output showing errors and progress bar:
http://www.shockfamily.net/cedric/grass/newgui7.png

File selection, very wide due to extremely long description text. This module
would benefit from labels:
http://www.shockfamily.net/cedric/grass/newgui4.png

Multiple selection, same deal:
http://www.shockfamily.net/cedric/grass/newgui5.png

Dropdown box, nothing has changed:
http://www.shockfamily.net/cedric/grass/newgui6.png

Changes:

Options and Output are now displayed in tabs instead of panes

There is a new command label which shows the current command as it is edited.
It has a button for copying the command to the clipboard. (Might be worth
noting in wish 2074)

Programs reporting guisections will have a tab made for options in each
toplevel section. Finer section grouping is obeyed, but no labels are created
or displayed.

The options frames scroll with the mouse wheel.

If possible the window opens wide enough to display its contents. This is
accomplished by adding a binding to the scrolled frames which report their
widths to their parent frames.

Programs using the label and description attributes on options or tabs will
now have the description displayed as balloon help.

The help button is not enabled if no help file exists for the program. (closes
wish 3799)

The type and required text for options is displayed right justified.

Module information is displayed differently. Both the label and description
are displayed if available. Module is displayed with an icon if a matching
one can be found in $(GISBASE)/etc/icons. See /gui/icons/README for more
information.

Buttons for file selection are displayed with an open file icon.

Buttons for selecting database elements and symbols are displayed with an icon
if a matching one can be found in $(GISBASE)/etc/icons.

It is now possible to determine when a command has finished executing. Output
text has an added graphic along with the command text when the command is
run. When the command finishes another graphic is displayed along with the
text "Done."

Testing:
Ran lots of different commands both from the console and from gis.m. Only
tested against tcl/tk 8.4 on Ubuntu Linux.

Patch:
Patch of lib/gis/gui.tcl and gui/Makefile is attached

gui.tcl also needs icons. To get the icons directory do the following in
grass6/:
tar xvfz gui-icons.tar.gz

I believe a "make install" is all that is needed, but I'm not sure.

Enjoy,

Cedric Shock

(attachments)

gui.tcl_patch (16.1 KB)
gui-icons.tar.gz (4.23 KB)

Oops,

I didn't see Hamish's post before posting. The attached files here put icons
in etc/gui/icons instead of etc/icons.

--Cedric Shock

(attachments)

gui-icons.tar.gz (4.24 KB)
gui.tcl_patch_guiicons (16.1 KB)

WOW!!!

This is excellent. It makes GRASS much easier to use and gives it a much
more polished look.

I'm glad you like the button "icons". It will really help people to have
this visual consistency between the GIS Manager and module dialogs. (If
anyone out there has mini-graphic design experience and would like to get
involved with making them even better, I'd welcome the help. )

I'd like to somehow collaborate with you on somehow better merging what you
are doing and the GIS Manager option panes. The latter are all hard coded.
I've long realized that this is inefficient, but until now didn't have much
in the way of an alternative. With the GUI output you've proposed, it should
be possible to capture the option settings from your new dialogs and reroute
them into the GIS Manager as appropriate. This will take some hefty recoding
to start with. After that, however, it should make things MUCH easier.

Congratulations! This is an enormous improvement.

Michael

On 3/13/06 8:34 PM, "Cedric Shock" <cedricgrass@shockfamily.net> wrote:

Good evening,

I have hammered out a new gui.tcl. This is the file that produces the generic
graphical user interface for all of the other programs.

Screenshots:

g.region, as it first comes up:
http://www.shockfamily.net/cedric/grass/newgui1.png

Sample output:
http://www.shockfamily.net/cedric/grass/newgui2.png

A fake test-script that shows guisections for a command like g.region
http://www.shockfamily.net/cedric/grass/newgui3.png

Output showing errors and progress bar:
http://www.shockfamily.net/cedric/grass/newgui7.png

File selection, very wide due to extremely long description text. This module
would benefit from labels:
http://www.shockfamily.net/cedric/grass/newgui4.png

Multiple selection, same deal:
http://www.shockfamily.net/cedric/grass/newgui5.png

Dropdown box, nothing has changed:
http://www.shockfamily.net/cedric/grass/newgui6.png

Changes:

Options and Output are now displayed in tabs instead of panes

There is a new command label which shows the current command as it is edited.
It has a button for copying the command to the clipboard. (Might be worth
noting in wish 2074)

Programs reporting guisections will have a tab made for options in each
toplevel section. Finer section grouping is obeyed, but no labels are created
or displayed.

The options frames scroll with the mouse wheel.

If possible the window opens wide enough to display its contents. This is
accomplished by adding a binding to the scrolled frames which report their
widths to their parent frames.

Programs using the label and description attributes on options or tabs will
now have the description displayed as balloon help.

The help button is not enabled if no help file exists for the program. (closes
wish 3799)

The type and required text for options is displayed right justified.

Module information is displayed differently. Both the label and description
are displayed if available. Module is displayed with an icon if a matching
one can be found in $(GISBASE)/etc/icons. See /gui/icons/README for more
information.

Buttons for file selection are displayed with an open file icon.

Buttons for selecting database elements and symbols are displayed with an icon
if a matching one can be found in $(GISBASE)/etc/icons.

It is now possible to determine when a command has finished executing. Output
text has an added graphic along with the command text when the command is
run. When the command finishes another graphic is displayed along with the
text "Done."

Testing:
Ran lots of different commands both from the console and from gis.m. Only
tested against tcl/tk 8.4 on Ubuntu Linux.

Patch:
Patch of lib/gis/gui.tcl and gui/Makefile is attached

gui.tcl also needs icons. To get the icons directory do the following in
grass6/:
tar xvfz gui-icons.tar.gz

I believe a "make install" is all that is needed, but I'm not sure.

Enjoy,

Cedric Shock

___________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Arizona State University
Tempe, AZ 85287

WWW - http://www.public.asu.edu/~cmbarton
Phone: 480-965-6262
Fax: 480-965-7671

It is now possible to determine when a command has finished executing.
Output text has an added graphic along with the command text when the
command is run. When the command finishes another graphic is
displayed along with the text "Done."

Does the "Run" button get greyed out during run-time?

Can the "Done." graphic check exit status and either be a green
check-mark or red "X" depending on $?.

a lot of long standing wishes here, thanks..

Hamish

Hamish,

These were both ideas I started with when I began work on this. They weren't
immediately fruitful like some other avenues.

Does the "Run" button get greyed out during run-time?

It could. Right now it's happy running multiple instances at once, which isn't
really a good thing but might be a "feature". Their output does get totally
mangled. If it is going to run multiple instances it really needs multiple
output windows, implementing of which would solve my output redirecting
dilemma for Michael. We could add a multiple attribute to modules (default
no) to determine if it's allowed or not. When multiple is no run ought get
greyed out.

Can the "Done." graphic check exit status and either be a green
check-mark or red "X" depending on $?.

Checking exit status is a bit tricky. It got cut from my short list because
there's no obvious way to do it. After poking around in the docs for a while
I just discovered that the exit code can be obtained by this archaic formula:

set exit_code [{catch [close $fh] error_text}]

Which is actually kind of convenient, if a little obscure, since I want the
exit code when I reach EOF and close the file handle.

This is only documented in 8.4, but seems to work in 8.0

--Cedric Shock

Michael,

I've been working on other stuff because it's the end of the term here, and I
haven't gotten a key activated and an id for CVS write access yet.

I'd like to somehow collaborate with you on somehow better merging what you
are doing and the GIS Manager option panes. The latter are all hard coded.
I've long realized that this is inefficient, but until now didn't have much
in the way of an alternative. With the GUI output you've proposed, it
should be possible to capture the option settings from your new dialogs and
reroute them into the GIS Manager as appropriate. This will take some hefty
recoding to start with. After that, however, it should make things MUCH
easier.

I'm not quite sure what you mean here, at all.

Do you mean you want to get automatically generated layouts of options for
things like the display of vectors? Provided by gui.tcl? If so we'd need to
radically expand the language of struct Option (to be consistent) to allow
for selections that influence other selections, like yours do (column
selection). This would be a good thing in my opinion, but also some hefty
coding. Perhaps we could change gis prompt options to:

new/old,element or class,Window Text,[optional] parent

And then have, for example:

key: boundaries
gisprompt: old,vector,Select Input Boundaries
...
key: layer
gisprompt: old,vector-layer,Select Layer,boundaries
...
key: columns
multiple: yes
gisprompt: old,vector-layer,Select Columns,layer

If so we'd need to patch everything else that reads from gisprompt. (console
UI, anything else?)

We'd need to agree on an interface for getting and setting commands and
possibly individual options (I have one already in unsubmitted stuff).

You would have to source gui.tcl into your program directly for these panes
(You run it in a separate wish for external command right now, right?)

Do you want the output from commands run in gui.tcl to come through to your
output windows? We'd need an interface for that, and hooking into stuff. We'd
also need to have a way of not getting those buttons (Run, Help, etc).
Perhaps separation of this little bitty UI from the code for making options
frames (libgui.tcl anyone?)

Your hand/hard-coded UIs are in may ways more flexible than what can be done
with a simple layout rule, however consistany of layout does have its
advantages.

--Cedric

Cedric Shock wrote:

You would have to source gui.tcl into your program directly for these panes
(You run it in a separate wish for external command right now, right?)

Both d.m and gis.m source gui.tcl. This is why parser.c has both
G_gui() and G_tcltk(). The former is for the stand-alone UI and the
latter for use by Tcl/Tk programs such as d.m and gis.m.

Having the Tcl/Tk code executed within the context of the main GUI
allows for things like command history.

Do you want the output from commands run in gui.tcl to come through to your
output windows? We'd need an interface for that, and hooking into stuff. We'd
also need to have a way of not getting those buttons (Run, Help, etc).
Perhaps separation of this little bitty UI from the code for making options
frames (libgui.tcl anyone?)

gui.tcl was designed to allow for the possibility of overriding some
of its procedures. It shouldn't be necessary to split it up.

Your hand/hard-coded UIs are in may ways more flexible than what can be done
with a simple layout rule, however consistany of layout does have its
advantages.

I think that hand-coding the layer panels is the way to go. Although
for the generic "command" layers, it would be useful (and probably not
too hard) to provide a facility to choose a command from a list and
bring up the command's auto-generated dialog.

--
Glynn Clements <glynn@gclements.plus.com>

Glynn and Michael,

Both d.m and gis.m source gui.tcl. This is why parser.c has both
G_gui() and G_tcltk(). The former is for the stand-alone UI and the
latter for use by Tcl/Tk programs such as d.m and gis.m.

Great, then we won't have to worry about namespace collisions, except with the
few new procs I added gui.tcl.

Having the Tcl/Tk code executed within the context of the main GUI
allows for things like command history.

> Do you want the output from commands run in gui.tcl to come through to
> your output windows? We'd need an interface for that, and hooking into
> stuff. We'd also need to have a way of not getting those buttons (Run,
> Help, etc). Perhaps separation of this little bitty UI from the code for
> making options frames (libgui.tcl anyone?)

gui.tcl was designed to allow for the possibility of overriding some
of its procedures. It shouldn't be necessary to split it up.

Ok, so we'll dispatch stuff by overriding procs. (Some part of my brain
thought that was an error in TCL; it isn't). It'd be wise, then, to make sure
we know exactly what the interface between d.m and gis.m and gui.tcl is going
to be. I know that how it was written before my changes, and even my first
revision, it could NOT be used to embed in a frame (without overloading
begin_dialog, which would be silly).

I suggest we take the following actions:

1. Heavily document gui.tcl OUTSIDE of gui.tcl (I had to do quite a bit of
this to figure out how to make small, effective changes to gui.tcl).

2. Collect a list of all the ways gui.tcl is currently being used andwhat
procedures are being overridden.

2. Propose extensions to the interface, and decide on small modifications to
make to divide up the work in a simple manner. Both for starting dialogs and
for this new idea I introduced, of a layout rule. My layout does three
different things, currently only one is easily factorable:

It sets up a notebook (this shouldn't be required)
It puts the output text window somewhere (should be generalized to windows)
It provides get_frame {dlg guisection} which provides frames for add_option
and add_flag to pack options and flags into.

So a layout rule should also implement something like make_layout {dlg, path}
which does the initial setup and packing in my case making the notebook.
get_frame should be renamed layout_get_freame. We should also have something
like layout_get_special_frame {dlg specialguisection} which would give out
frames for addins(like output). layout_get_special_frame should bind destroy
on its frame to any cleanup actions necessary (like removing a tab from the
notebook).

Then we can change begin_dialog so it does something along the line of the
following:

begin_dialog:
  Set up all the module variables, etc.
  make_module_description
  make_layout
  make_command_label
  make_progress
  make_buttons
  return the dialog's id

Then overridding any of make_module_description, make_command_label,
make_progress or make_buttons with an empty proc would cause them to not
happen.

We'd also need an interface to getting and setting command options, both all
at once and one at a time. I've already done this. we could call these procs:

dialog_get_answer and dialog_set_answer for individual options
dialog_get_command and dialog_set_command for the whole thing at once.

3. We also need to agree on who "owns" which of the opt global variables.

> Your hand/hard-coded UIs are in may ways more flexible than what can be
> done with a simple layout rule, however consistany of layout does have
> its advantages.

I think that hand-coding the layer panels is the way to go. Although
for the generic "command" layers, it would be useful (and probably not
too hard) to provide a facility to choose a command from a list and
bring up the command's auto-generated dialog.

I think hand-coding is the way to go for carefully designed user interfaces.
However if we could have the generic user interface be as wonderful as the
hand coded ones it would be worth persuing.

My complete lack of ability for automated version control is crippling. If
anyone knows an easy way to check sources out of a remote repository and
check the same directories into another repository, and then be able to
update from the first and commit to the second again that knowledge would be
extremely helpful to me. It ought be easy to do since making a development
branch of a remote repository seems like a common need (i.e. everyone without
write access, or for developing radical new features outside the main
repository).

--Cedric Shock

I wrote,

My complete lack of ability for automated version control is crippling. If
anyone knows an easy way to check sources out of a remote repository and
check the same directories into another repository, and then be able to
update from the first and commit to the second again that knowledge would
be extremely helpful to me. It ought be easy to do since making a
development branch of a remote repository seems like a common need (i.e.
everyone without write access, or for developing radical new features
outside the main repository).

Not so urgent anymore. I can use the grass repository. I'd still love to know
how to do this if I ever want to try that "radical new features" thing.

--Cedric Shock

Cedric, Glynn et al.

Here are some first reactions.

My first thought was that, instead of me having to change the hand-coded
options pane every time an option changes, I could just launch your nice new
module, get the option values from there, and use them in the GIS Manager
display. But you folks are right, there is a lot more flexibility in the
hand-coded panes than in the generic ones. And there are only a handful of
display modules that need to be coded in this way.

Several nice and exciting things are happing with the GRASS UI: much better
generic modules for launching commands, NVIZ working in TclTk 8.4, new NVIZ
functionality. So this is a good time to try to coordinate on these various
and welcome improvements in a couple of ways.

1. Maintaining a consistent look/function across different parts of the
GRASS UI. Cedric, your use of the same icons used in the GIS Manager makes
it much easier for users to operate diverse GRASS modules and displays. It
will also make it easier for people to use the GIS Manager. Can we move
toward the same kind of consistency in NVIZ? There are some other places for
consistency.

I changed TclTk entry widgets to white to signal that the user needs to
enter something there. I did the same for the output text widgets. You might
want to do the same.

I'd also changed the title of the option pane to blue--again to signal that
it is a title. Yours look very nice in black however. What do you all think?
Should we change the module titles to a different color (blue or something
other than black) or my option pane titles back to black?

Benjamin Ducke suggested adding a notebook widget to complex option panes to
help organize them. I don't really need a separate tab for output from the
GIS Manager, but tabs for organization might help. This probably only really
applies to vector panels (including chart and thematic). Any thoughts? Tabs
might be very helpful in NVIZ.

2. Using the same resources. Icons are the most obvious one at the moment.
We should put them all in the same place and all GUI components using them
could then get at them. I saw mention of $GISBASE/etc/icons Cedric. This
seems OK with me. Crishan and Glynn, if we shifted to QT, GTK, or another
GUI platform, would these also use GIF icons? Could they still be kept in
$GISBASE/etc/icons?

3. Consistent functionality. For example, I don't think that module output
should go to the output window at this time. The reason is that some people
would rather work without the GIS Manager. If all output goes to the output
pane, then the GIS Manager would always need to be launched. In the long
run, however, it does seem to be a good idea to have all command output go
to the same place, so people would always know where to look for it.

Also, if you can tell me how to bind the mouse wheel to widget scrollbars, I
will implement it in the GIS Manager option panes too.

4. Finally, we all might want to look at the UI roadmap on the GRASS WIKI
again. This is not set in stone, but should serve as a guide (an evolving
one) to moving to the next generation UI in a coordinated fashion. Along
these lines, Trevor proposed some nice ideas on how to implement some of the
roadmap ideas. Some echo some of the design ideas that Crishan proposed a
couple months back. (Could you put this on the WIKI in the UI section?).
This would involve adding a tabbed notebook to the GIS Manager so that it
could serve increasingly as a tool box for launching GRASS modules--rather
than only having them launched from (sometimes deeply hierarchical) menus.
The new generic module GUI's fit very nicely into this scheme.

To close, here are some other ideas that I've been thinking about for
continued updates to the UI.

1) using r.profile and TclTk charts to create a new terrain profile utility
that would replace d.profile, produce postscript text and graphics, and not
need x11.

2) creating a text layer that could read label files created by v.label.
This way, we could have high quality, postscript vector labeling.

3) rewriting the GRASS startup GUI. I realized in teaching it this Spring,
that it is much more intimidating than it needs to be. I've looked at the
code and it's ancient. I finally decided that it would probably be easier to
start fresh than to try and update the existing code. Unfortunately, I seem
to have lost what I'd done so far when my laptop went in for repair this
past week (I can't find it on my backup). The basic concept is that the user
needs to identify an existing GIS Mapset to start GRASS. This is a very
simple screen with clear help text. By identifying a mapset, the location
and default directory (GISDBASE) are implied. If there is no pre-existing
mapset available for use, the user is prompted to make a new one. This would
get a new window. And so one. There is more to think about here. But the
main thing is that I believe that starting GRASS can be much less
intimidating than it is.

4) Continuing to debug the GIS Manager so that it can become the default GUI
soon. There are several small tweaks I'd like to make. But the main issue
right now are strange results from compositing with g.pnmcomp. I have no
idea what's causing these. Cedric, since you appear to know both TclTk and C
pretty well, I'd like to ask if you can help us sort this out?

I'm open to suggestion from you folks too.

Cheers
Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Cedric Shock <cedricgrass@shockfamily.net>
Date: Thu, 16 Mar 2006 13:08:39 -0800
To: <grass5@grass.itc.it>
Subject: Re: [GRASS5] New gui.tcl generic user interface

Glynn and Michael,

Both d.m and gis.m source gui.tcl. This is why parser.c has both
G_gui() and G_tcltk(). The former is for the stand-alone UI and the
latter for use by Tcl/Tk programs such as d.m and gis.m.

Great, then we won't have to worry about namespace collisions, except with the
few new procs I added gui.tcl.

Having the Tcl/Tk code executed within the context of the main GUI
allows for things like command history.

Do you want the output from commands run in gui.tcl to come through to
your output windows? We'd need an interface for that, and hooking into
stuff. We'd also need to have a way of not getting those buttons (Run,
Help, etc). Perhaps separation of this little bitty UI from the code for
making options frames (libgui.tcl anyone?)

gui.tcl was designed to allow for the possibility of overriding some
of its procedures. It shouldn't be necessary to split it up.

Ok, so we'll dispatch stuff by overriding procs. (Some part of my brain
thought that was an error in TCL; it isn't). It'd be wise, then, to make sure
we know exactly what the interface between d.m and gis.m and gui.tcl is going
to be. I know that how it was written before my changes, and even my first
revision, it could NOT be used to embed in a frame (without overloading
begin_dialog, which would be silly).

I suggest we take the following actions:

1. Heavily document gui.tcl OUTSIDE of gui.tcl (I had to do quite a bit of
this to figure out how to make small, effective changes to gui.tcl).

2. Collect a list of all the ways gui.tcl is currently being used andwhat
procedures are being overridden.

2. Propose extensions to the interface, and decide on small modifications to
make to divide up the work in a simple manner. Both for starting dialogs and
for this new idea I introduced, of a layout rule. My layout does three
different things, currently only one is easily factorable:

It sets up a notebook (this shouldn't be required)
It puts the output text window somewhere (should be generalized to windows)
It provides get_frame {dlg guisection} which provides frames for add_option
and add_flag to pack options and flags into.

So a layout rule should also implement something like make_layout {dlg, path}
which does the initial setup and packing in my case making the notebook.
get_frame should be renamed layout_get_freame. We should also have something
like layout_get_special_frame {dlg specialguisection} which would give out
frames for addins(like output). layout_get_special_frame should bind destroy
on its frame to any cleanup actions necessary (like removing a tab from the
notebook).

Then we can change begin_dialog so it does something along the line of the
following:

begin_dialog:
Set up all the module variables, etc.
make_module_description
make_layout
make_command_label
make_progress
make_buttons
return the dialog's id

Then overridding any of make_module_description, make_command_label,
make_progress or make_buttons with an empty proc would cause them to not
happen.

We'd also need an interface to getting and setting command options, both all
at once and one at a time. I've already done this. we could call these procs:

dialog_get_answer and dialog_set_answer for individual options
dialog_get_command and dialog_set_command for the whole thing at once.

3. We also need to agree on who "owns" which of the opt global variables.

Your hand/hard-coded UIs are in may ways more flexible than what can be
done with a simple layout rule, however consistany of layout does have
its advantages.

I think that hand-coding the layer panels is the way to go. Although
for the generic "command" layers, it would be useful (and probably not
too hard) to provide a facility to choose a command from a list and
bring up the command's auto-generated dialog.

I think hand-coding is the way to go for carefully designed user interfaces.
However if we could have the generic user interface be as wonderful as the
hand coded ones it would be worth persuing.

My complete lack of ability for automated version control is crippling. If
anyone knows an easy way to check sources out of a remote repository and
check the same directories into another repository, and then be able to
update from the first and commit to the second again that knowledge would be
extremely helpful to me. It ought be easy to do since making a development
branch of a remote repository seems like a common need (i.e. everyone without
write access, or for developing radical new features outside the main
repository).

--Cedric Shock

Michael Barton wrote:

2. Using the same resources. Icons are the most obvious one at the moment.
We should put them all in the same place and all GUI components using them
could then get at them. I saw mention of $GISBASE/etc/icons Cedric. This
seems OK with me. Crishan and Glynn, if we shifted to QT, GTK, or another
GUI platform, would these also use GIF icons? Could they still be kept in
$GISBASE/etc/icons?

GTK and Qt both have image-loading mechanisms which will load any of
the common image formats without the application needing to worry
about the details.

3. Consistent functionality. For example, I don't think that module output
should go to the output window at this time. The reason is that some people
would rather work without the GIS Manager. If all output goes to the output
pane, then the GIS Manager would always need to be launched.

I suspect that this is a misunderstanding. The standalone UI would
send output to a text widget which was part of the UI dialog, as
happens now. A monolithic UI application such as d.m or gis.m would
omit the text widget from the per-command dialogs and send all output
to a single console window.

Also, if you can tell me how to bind the mouse wheel to widget scrollbars, I
will implement it in the GIS Manager option panes too.

Search for handle_scroll in gui.tcl. Scrollable windows usually have a
"yview" command which can be used to change the scroll offset.

4. Finally, we all might want to look at the UI roadmap on the GRASS WIKI
again. This is not set in stone, but should serve as a guide (an evolving
one) to moving to the next generation UI in a coordinated fashion. Along
these lines, Trevor proposed some nice ideas on how to implement some of the
roadmap ideas. Some echo some of the design ideas that Crishan proposed a
couple months back. (Could you put this on the WIKI in the UI section?).
This would involve adding a tabbed notebook to the GIS Manager so that it
could serve increasingly as a tool box for launching GRASS modules--rather
than only having them launched from (sometimes deeply hierarchical) menus.
The new generic module GUI's fit very nicely into this scheme.

To close, here are some other ideas that I've been thinking about for
continued updates to the UI.

1) using r.profile and TclTk charts to create a new terrain profile utility
that would replace d.profile, produce postscript text and graphics, and not
need x11.

That would be nice, but v.digit is probably the most urgent candidate
for replacement, followed by i.points.

More generally, in order to be able to show existing vector maps in a
Tk canvas, we need a way to export vectors to a usable text format.

v.out.ascii has the (major) drawback that areas are output as disjoint
segments which the application then has to piece together to form
closed polygons. AFAICT, currently the only tool which provides
polygons is v.out.pov, but that loses all of the structural
information.

--
Glynn Clements <glynn@gclements.plus.com>

Hi,

1. Maintaining a consistent look/function across different parts of the
GRASS UI. Cedric, your use of the same icons used in the GIS Manager makes
it much easier for users to operate diverse GRASS modules and displays. It
will also make it easier for people to use the GIS Manager. Can we move
toward the same kind of consistency in NVIZ? There are some other places
for consistency.

I changed TclTk entry widgets to white to signal that the user needs to
enter something there. I did the same for the output text widgets. You
might want to do the same.

I'd also changed the title of the option pane to blue--again to signal that
it is a title. Yours look very nice in black however. What do you all
think? Should we change the module titles to a different color (blue or
something other than black) or my option pane titles back to black?

We need to agree on names of fonts and a global variable and structure for
colors as well as on a file to source to get them. I suggest a global
gui_style variable. It would be indexed by class and attribute, like this:

set gui_style(button,background) red
set gui_style(button,foreground) yellow
set gui_style(button,font) funfont
...

We would have two commands:
style_set_class $path $class
Which would set the class of a widget to that specific class (it defaults to
its actual widget class)

And
style_apply $path
Which would recursively apply the style to that widget and all of its
children. It would also apply a default style gui_style(default,$attribute)
if applicable, and also apply styles of class inheritence (if this is
defined).
style_apply would also configure DynamicHelp based on the ballon-help style.

We could then do fun stuff like:
button .ok -text "Yes"
style_set_class .ok ok-button

with a style like this:
set gui_style(ok-button,image) [icon buttons ok]
set gui_style(ok-button,text) $LANG::Ok (Makes iternationalization easier)

Then we'd need a little ui for setting fonts and changing all of these.

This should be really simple and very impressive.

Here are the classes I've already thought of:
title - title text for a window or pane
balloon-help - handled by a special rule (probably the only special rule)

Any others you want? They can't be the names of tk classes (like label).

Benjamin Ducke suggested adding a notebook widget to complex option panes
to help organize them. I don't really need a separate tab for output from
the GIS Manager, but tabs for organization might help. This probably only
really applies to vector panels (including chart and thematic). Any
thoughts? Tabs might be very helpful in NVIZ.

I don't understand why the command log is in the main window of gis.m. I have
never been interested in what it says. I don't know what the buttons across
the bottom do at all, except for clear and open output window. I'm obviously
completely ignorant of what that is all for, but I think that log, and the
progress bar (display progress is shown in the other window), and the buttons
should go with the output somehow, giving more room for the main event.

2. Using the same resources. Icons are the most obvious one at the moment.
We should put them all in the same place and all GUI components using them
could then get at them. I saw mention of $GISBASE/etc/icons Cedric. This
seems OK with me. Crishan and Glynn, if we shifted to QT, GTK, or another
GUI platform, would these also use GIF icons? Could they still be kept in
$GISBASE/etc/icons?

Icons are in $GISBASE/etc/gui/icons to avoid confusion with symbols. Easily
work with QT, GTK. You can use [icon $class $member] from sourced gui.tcl to
load icons from there.

Also, if you can tell me how to bind the mouse wheel to widget scrollbars,
I will implement it in the GIS Manager option panes too.

No matter what I did I could not get <MouseWheel> <Button-4> and <Button-5> to
bind to and actually throw events from anything but All. This is a memory
leak and a code leak over the course of frames being created and destroyed
(the binding never goes away). I just realized there is a better way to do
this; I can manage the list of bindings myself and we'd need only one set of
All bindings. I tried this approach before to try to get events but events
just slide right off, however if I dispatch with commands from a global it'll
work. I'll make something like bind_scroll $path for you that will do it all.

4) Continuing to debug the GIS Manager so that it can become the default
GUI soon. There are several small tweaks I'd like to make.

I've got two tiny bugfixes.

But the main
issue right now are strange results from compositing with g.pnmcomp. I have
no idea what's causing these. Cedric, since you appear to know both TclTk
and C pretty well, I'd like to ask if you can help us sort this out?

Is g.pnmcomp written in both c and tcl? Can you put together a set of the
files that get composited and the commands and point out what's wrong with
the output?

--Cedric Shock

Cedric Shock wrote:

> But the main
> issue right now are strange results from compositing with g.pnmcomp. I have
> no idea what's causing these. Cedric, since you appear to know both TclTk
> and C pretty well, I'd like to ask if you can help us sort this out?

Is g.pnmcomp written in both c and tcl?

It's just C.

And a very simple C program at that: 8 functions, including main(),
using only ANSI C stdio/stdlib functions and basic libgis functions
(G_parser() etc plus G_malloc() and G_fatal_error()).

Logically, there shouldn't be any way in which g.pnmcomp could exhibit
the behaviour which Michael describes. It is reported to be generating
an output file composed from image files which no longer exist.

I'm /really/ curious to find out what's actually going on there.

--
Glynn Clements <glynn@gclements.plus.com>

Cedric,

Some responses to your questions below.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Cedric Shock <cedricgrass@shockfamily.net>
Date: Fri, 17 Mar 2006 08:33:54 -0800
To: <grass5@grass.itc.it>
Subject: Re: [GRASS5] New gui.tcl generic user interface

Hi,

1. Maintaining a consistent look/function across different parts of the
GRASS UI. Cedric, your use of the same icons used in the GIS Manager makes
it much easier for users to operate diverse GRASS modules and displays. It
will also make it easier for people to use the GIS Manager. Can we move
toward the same kind of consistency in NVIZ? There are some other places
for consistency.

I changed TclTk entry widgets to white to signal that the user needs to
enter something there. I did the same for the output text widgets. You
might want to do the same.

I'd also changed the title of the option pane to blue--again to signal that
it is a title. Yours look very nice in black however. What do you all
think? Should we change the module titles to a different color (blue or
something other than black) or my option pane titles back to black?

We need to agree on names of fonts and a global variable and structure for
colors as well as on a file to source to get them. I suggest a global
gui_style variable. It would be indexed by class and attribute, like this:

set gui_style(button,background) red
set gui_style(button,foreground) yellow
set gui_style(button,font) funfont
...

We would have two commands:
style_set_class $path $class
Which would set the class of a widget to that specific class (it defaults to
its actual widget class)

And
style_apply $path
Which would recursively apply the style to that widget and all of its
children. It would also apply a default style gui_style(default,$attribute)
if applicable, and also apply styles of class inheritence (if this is
defined).
style_apply would also configure DynamicHelp based on the ballon-help style.

We could then do fun stuff like:
button .ok -text "Yes"
style_set_class .ok ok-button

with a style like this:
set gui_style(ok-button,image) [icon buttons ok]
set gui_style(ok-button,text) $LANG::Ok (Makes iternationalization easier)

Then we'd need a little ui for setting fonts and changing all of these.

This should be really simple and very impressive.

Here are the classes I've already thought of:
title - title text for a window or pane
balloon-help - handled by a special rule (probably the only special rule)

Any others you want? They can't be the names of tk classes (like label).

This would be quite welcome. I just haven't had time to do it with the rest
of GIS Manager rewrite.

There are some style variables that could be set for the GIS Manager.
Background color is already global variable $bgcolor. There is a font
variable for the toplevel mainframe. I don't know if it affects the menus or
not. However, we could (and should) easily add this. The option pane title
could use the same variable that you do, along with the option pane text,
button appearance, and balloon help. We should probably use the same color
progress bars. I use the default blue, but I think the green in the modules
is kind of dayglow. This could also be a global variable (whether or not it
is user setable).

I don't think we need to make everything user setable (e.g., button style),
as this could make for a long and complicated interface. However, encoding
as much of the appearance as possible in global style variables to be used
across the interface is a very good idea.

Benjamin Ducke suggested adding a notebook widget to complex option panes
to help organize them. I don't really need a separate tab for output from
the GIS Manager, but tabs for organization might help. This probably only
really applies to vector panels (including chart and thematic). Any
thoughts? Tabs might be very helpful in NVIZ.

I don't understand why the command log is in the main window of gis.m. I have
never been interested in what it says. I don't know what the buttons across
the bottom do at all, except for clear and open output window. I'm obviously
completely ignorant of what that is all for, but I think that log, and the
progress bar (display progress is shown in the other window), and the buttons
should go with the output somehow, giving more room for the main event.

This is not just a command log anymore. It is a console for running
commands. If you place your cursor on a command and press "run", it sends
the command to the GRASS command parser. The idea is be able to run GRASS
without x11. You can also save a selected command history to a text file to
track what you've done or put it into a script. Because it is a TclTk text
widget, the command console is fully editable--considerably easier than in
an xterminal.

Currently, there are 2 limitations to the command console as a replacement
for the xterminal. One is that running display commands is a little
problematic, though that should be less of a problem as Glynn changes them
to output PPM files. The second is commands that require interactive input
in an xterminal. It seems that there should be some way around this, but I
haven't found it yet.

2. Using the same resources. Icons are the most obvious one at the moment.
We should put them all in the same place and all GUI components using them
could then get at them. I saw mention of $GISBASE/etc/icons Cedric. This
seems OK with me. Crishan and Glynn, if we shifted to QT, GTK, or another
GUI platform, would these also use GIF icons? Could they still be kept in
$GISBASE/etc/icons?

Icons are in $GISBASE/etc/gui/icons to avoid confusion with symbols. Easily
work with QT, GTK. You can use [icon $class $member] from sourced gui.tcl to
load icons from there.

OK. Once I'm back up and running with my computers (by next week I hope),
I'll switch all the GIS Manager icon calls to the $GISBASE/etc/gui/icons
folder. I'd been thinking of something like this to clean up the gm folder.

Also, if you can tell me how to bind the mouse wheel to widget scrollbars,
I will implement it in the GIS Manager option panes too.

No matter what I did I could not get <MouseWheel> <Button-4> and <Button-5> to
bind to and actually throw events from anything but All. This is a memory
leak and a code leak over the course of frames being created and destroyed
(the binding never goes away). I just realized there is a better way to do
this; I can manage the list of bindings myself and we'd need only one set of
All bindings. I tried this approach before to try to get events but events
just slide right off, however if I dispatch with commands from a global it'll
work. I'll make something like bind_scroll $path for you that will do it all.

Thanks

4) Continuing to debug the GIS Manager so that it can become the default
GUI soon. There are several small tweaks I'd like to make.

I've got two tiny bugfixes.

OK. What are they? I don't want to accidentally overwrite them.

But the main
issue right now are strange results from compositing with g.pnmcomp. I have
no idea what's causing these. Cedric, since you appear to know both TclTk
and C pretty well, I'd like to ask if you can help us sort this out?

Is g.pnmcomp written in both c and tcl? Can you put together a set of the
files that get composited and the commands and point out what's wrong with
the output?

G.pnmcomp is in C.

Here is what is happening on my Mac and at least some Linux systems.

1. I composite >2 layers to create a final map in g.pnmcomp. The 1st time I
do it, it works fine.

2. I change one of the layers. The next time I composite, I only see the
same final map created the FIRST time I ran g.pnmcomp.

3. I run g.pnmcomp with only 2 layers, add back in the additional layers,
and run g.pnmcomp again. I get the correct result.

I've done this via the GIS Manager AND from the command line. I've looked at
the PPM input files AND the PPM output file and confirm that this is really
happening. Especially baffling is that there is no apparent place that
g.pnmcomp is getting the wrong information to composite. That is, the old
input files are overwritten with the new data. So how can g.pnmcomp create
an output composited map that matches input files that no longer exist?

This issue is making it very difficult to debug any other compositing
issues. I want to check to see if the previous version of g.pnmcomp (before
transparency support was added on 21 February) gives the same behavior, but
haven't had a chance to do it yet.

The GUI is a LOT of lines of code. It's really a pleasure to have some more
help with it.

Michael

From: Glynn Clements <glynn@gclements.plus.com>
Date: Fri, 17 Mar 2006 10:14:19 +0000
To: Michael Barton <michael.barton@asu.edu>
Cc: Cedric Shock <cedricgrass@shockfamily.net>, <grass5@grass.itc.it>, Massimo
Cuomo <m.cuomo@acsys.it>, Trevor Wiens <twiens@interbaun.com>, Christian
Wygoda <crischan@wygoda.net>, Benjamin Ducke <benjamin.ducke@ufg.uni-kiel.de>
Subject: Re: [GRASS5] New gui.tcl generic user interface

Michael Barton wrote:

2. Using the same resources. Icons are the most obvious one at the moment.
We should put them all in the same place and all GUI components using them
could then get at them. I saw mention of $GISBASE/etc/icons Cedric. This
seems OK with me. Crishan and Glynn, if we shifted to QT, GTK, or another
GUI platform, would these also use GIF icons? Could they still be kept in
$GISBASE/etc/icons?

GTK and Qt both have image-loading mechanisms which will load any of
the common image formats without the application needing to worry
about the details.

OK. I'll shift all GIS Manager icon calls to this new standard directory.

3. Consistent functionality. For example, I don't think that module output
should go to the output window at this time. The reason is that some people
would rather work without the GIS Manager. If all output goes to the output
pane, then the GIS Manager would always need to be launched.

I suspect that this is a misunderstanding. The standalone UI would
send output to a text widget which was part of the UI dialog, as
happens now. A monolithic UI application such as d.m or gis.m would
omit the text widget from the per-command dialogs and send all output
to a single console window.

Right. We're kind of between either right now.

Also, if you can tell me how to bind the mouse wheel to widget scrollbars, I
will implement it in the GIS Manager option panes too.

Search for handle_scroll in gui.tcl. Scrollable windows usually have a
"yview" command which can be used to change the scroll offset.

Cedric noted that this is more complicated than it ought to be, but will
share the protocol he worked out.

4. Finally, we all might want to look at the UI roadmap on the GRASS WIKI
again. This is not set in stone, but should serve as a guide (an evolving
one) to moving to the next generation UI in a coordinated fashion. Along
these lines, Trevor proposed some nice ideas on how to implement some of the
roadmap ideas. Some echo some of the design ideas that Crishan proposed a
couple months back. (Could you put this on the WIKI in the UI section?).
This would involve adding a tabbed notebook to the GIS Manager so that it
could serve increasingly as a tool box for launching GRASS modules--rather
than only having them launched from (sometimes deeply hierarchical) menus.
The new generic module GUI's fit very nicely into this scheme.

To close, here are some other ideas that I've been thinking about for
continued updates to the UI.

1) using r.profile and TclTk charts to create a new terrain profile utility
that would replace d.profile, produce postscript text and graphics, and not
need x11.

That would be nice, but v.digit is probably the most urgent candidate
for replacement, followed by i.points.

I agree that these are more important. But they take rewriting the relevant
C code, so someone other than me will need to work on this.

More generally, in order to be able to show existing vector maps in a
Tk canvas, we need a way to export vectors to a usable text format.

v.out.ascii has the (major) drawback that areas are output as disjoint
segments which the application then has to piece together to form
closed polygons. AFAICT, currently the only tool which provides
polygons is v.out.pov, but that loses all of the structural
information.

If solved, this would produce the kind of high quality vector output that
many people wish for.

I'd add the integration of NVIZ and 2D displays as another important goal
for the raster side.

--
Glynn Clements <glynn@gclements.plus.com>

__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Michael Barton wrote:

>> 1) using r.profile and TclTk charts to create a new terrain profile utility
>> that would replace d.profile, produce postscript text and graphics, and not
>> need x11.
>
> That would be nice, but v.digit is probably the most urgent candidate
> for replacement, followed by i.points.

I agree that these are more important. But they take rewriting the relevant
C code, so someone other than me will need to work on this.

I would have thought that you could get a usable v.digit replacement
using only Tcl/Tk, v.in.ascii and a few other GRASS commands.

> More generally, in order to be able to show existing vector maps in a
> Tk canvas, we need a way to export vectors to a usable text format.
>
> v.out.ascii has the (major) drawback that areas are output as disjoint
> segments which the application then has to piece together to form
> closed polygons. AFAICT, currently the only tool which provides
> polygons is v.out.pov, but that loses all of the structural
> information.

If solved, this would produce the kind of high quality vector output that
many people wish for.

Unfortunately, I don't really know enough about the vector API to do
this myself.

AFAICT, the main issue is that v.out.ascii uses
Vect_set_open_level(1), whereas an application which displays filled
areas needs level 2.

--
Glynn Clements <glynn@gclements.plus.com>

Michael Barton wrote:

> I don't understand why the command log is in the main window of gis.m. I have
> never been interested in what it says. I don't know what the buttons across
> the bottom do at all, except for clear and open output window. I'm obviously
> completely ignorant of what that is all for, but I think that log, and the
> progress bar (display progress is shown in the other window), and the buttons
> should go with the output somehow, giving more room for the main event.

This is not just a command log anymore. It is a console for running
commands. If you place your cursor on a command and press "run", it sends
the command to the GRASS command parser. The idea is be able to run GRASS
without x11. You can also save a selected command history to a text file to
track what you've done or put it into a script. Because it is a TclTk text
widget, the command console is fully editable--considerably easier than in
an xterminal.

Currently, there are 2 limitations to the command console as a replacement
for the xterminal. One is that running display commands is a little
problematic, though that should be less of a problem as Glynn changes them
to output PPM files. The second is commands that require interactive input
in an xterminal. It seems that there should be some way around this, but I
haven't found it yet.

There are three types of interactive commands:

1. Commands which need stdin/stdout.
2. Commands which need a terminal (i.e. isatty() returns non-zero).
3. Commands which need a curses-compatible terminal.

The first issue for #1 is that Tcl's "open" command doesn't allow both
read and write access (popen() behaves the same way); I suspect that
this is because it's too easy to deadlock.

If the application is writing to the command's stdin, it probably
isn't reading from its stdout. If the output pipe fills up, the
command will block until it is no longer full, so it stops reading
from its stdin, so the input pipe fills, and the application blocks.

To support "slave" commands, you need to use non-blocking I/O or
threads, so that the output pipe is continuously being drained even
when the application is writing to the input pipe.

Once that's dealt with, supporting #2 would require the ability to
create pseudo-terminals. Tcl doesn't have this functionality built in,
so you would need a helper utility.

Supporting #3 would also require implementing a character-cell
terminal in Tcl/Tk, which would be a fair amount of work.

The ideal solution is to remove interaction from the individual
modules and put it in the GUI instead.

--
Glynn Clements <glynn@gclements.plus.com>

From: Glynn Clements <glynn@gclements.plus.com>
Date: Fri, 17 Mar 2006 20:53:54 +0000
To: Michael Barton <michael.barton@asu.edu>
Cc: <grass5@grass.itc.it>
Subject: Re: [GRASS5] New gui.tcl generic user interface

Michael Barton wrote:

1) using r.profile and TclTk charts to create a new terrain profile utility
that would replace d.profile, produce postscript text and graphics, and not
need x11.

That would be nice, but v.digit is probably the most urgent candidate
for replacement, followed by i.points.

I agree that these are more important. But they take rewriting the relevant
C code, so someone other than me will need to work on this.

I would have thought that you could get a usable v.digit replacement
using only Tcl/Tk, v.in.ascii and a few other GRASS commands.

You need to be able to display a vector in such a way that it can be
manipulated in a canvas (see your issue below), then add, delete, or change
the coordinates of vector nodes, selecting them interactively with a mouse.
You also need to be able to add/delete centroids of areas, and join them to
tables. I've thought about this a little and don't think that there any
GRASS tools available to do this...yet.

Michael

More generally, in order to be able to show existing vector maps in a
Tk canvas, we need a way to export vectors to a usable text format.

v.out.ascii has the (major) drawback that areas are output as disjoint
segments which the application then has to piece together to form
closed polygons. AFAICT, currently the only tool which provides
polygons is v.out.pov, but that loses all of the structural
information.

If solved, this would produce the kind of high quality vector output that
many people wish for.

Unfortunately, I don't really know enough about the vector API to do
this myself.

AFAICT, the main issue is that v.out.ascii uses
Vect_set_open_level(1), whereas an application which displays filled
areas needs level 2.

--
Glynn Clements <glynn@gclements.plus.com>

__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

AGREED!

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Glynn Clements <glynn@gclements.plus.com>
Date: Fri, 17 Mar 2006 21:18:33 +0000
To: Michael Barton <michael.barton@asu.edu>
Cc: Cedric Shock <cedricgrass@shockfamily.net>, <grass5@grass.itc.it>
Subject: Re: [GRASS5] New gui.tcl generic user interface

The ideal solution is to remove interaction from the individual
modules and put it in the GUI instead.

Michael Barton wrote:

>>>> 1) using r.profile and TclTk charts to create a new terrain profile utility
>>>> that would replace d.profile, produce postscript text and graphics, and not
>>>> need x11.
>>>
>>> That would be nice, but v.digit is probably the most urgent candidate
>>> for replacement, followed by i.points.
>>
>> I agree that these are more important. But they take rewriting the relevant
>> C code, so someone other than me will need to work on this.
>
> I would have thought that you could get a usable v.digit replacement
> using only Tcl/Tk, v.in.ascii and a few other GRASS commands.

You need to be able to display a vector in such a way that it can be
manipulated in a canvas (see your issue below), then add, delete, or change
the coordinates of vector nodes, selecting them interactively with a mouse.
You also need to be able to add/delete centroids of areas, and join them to
tables. I've thought about this a little and don't think that there any
GRASS tools available to do this...yet.

I'm thinking in terms of v.out.ascii -> Tcl/Tk -> v.in.ascii. I.e. the
entire process would be done in Tcl/Tk. The main requirement is the
ability to get complete vector maps into and out of GRASS.

--
Glynn Clements <glynn@gclements.plus.com>