graphical interface to commands?



Hello,
  I am interested in developing a 'graphical' interface to some commands 
in maxima.  For instance, I would like to be able to use mouse input in 
a gnuplot window (or an openmath window) to generate some maxima 
commands.  This can, more or less, already be done using drop down menu 
buttons as in wxmaxima, or xmaxima, but I want mouse input to generate 
the commands.

  For example, one can already generate mouse coordinates and/or zooms 
with gnuplot and draw2d.
I would like more: e.g. generate line segments, press keyboard entries 
and evaluate some maxima commands.

  A very simple example would be as follows.

Note the following maxima commands.


(%o23) 
Line_Segment(p,q,NumPoints):=makelist((1-i/NumPoints)*p+i*q/NumPoints,
                     i,1,NumPoints)
(%i24) line: Line_Segment([0.1,0.2],[0.5,0.7],10);

(%o24) 
[[0.14,0.25],[0.18,0.3],[0.22,0.35],[0.26,0.4],[0.3,.4500000000000001],
         [.3400000000000001,.4999999999999999],[0.38,0.55],[0.42,0.6],
         [0.46,0.65],[0.5,.7000000000000001]]
(%i25) f(x):= [x[1]^2,sin(x[2])];

(%o25) f(x):=[x[1]^2,sin(x[2])]
(%i26) im_line: makelist(f(line[i]),i,1,length(line));

(%o26) [[0.0196,.2474039592545229],[.03240000000000001,.2955202066613396],
         [.04840000000000001,.3428978074554513],
         [.06760000000000001,.3894183423086505],[0.09,.4349655341112303],
         [0.1156,.4794255386042029],[0.1444,.5226872289306592],
         [0.1764,.5646424733950354],[0.2116,.6051864057360395],
         [0.25,.6442176872376911]]

(%i27) draw2d(points(im_line));



This generates the line segment 'line' between the points [0.1,0.2] and 
[0.5,0.7] as a list of 10 points.
Then, it plots the image of these points via the map
    f(x):=[x[1]^2,sin(x[2])]$

I would like to be able to do the following.
  Assume that f(x) is defined.
  1. Generate an empty plot window.
  2. Pick the points in the window with the mouse and generate a line 
segment on the plot.
  3. Perhaps with the use of another key pressed, generate the image of 
the line segment and plot it (just as the commands above do).

Thus, I want a graphic interface to the selection of the line segment 
and the plotting of its image.

Any ideas will be appreciated.

-sen