help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ginput equivalent in octave


From: Andy Adler
Subject: ginput equivalent in octave
Date: Thu, 11 Sep 1997 17:46:39 -0600

hi,

I'm looking for a way to achieve the functionality of Matlab's "ginput"
in octave. ([x,y]=ginput allows you to click on the graph and get the
locations of the points)

I've started coding the following hack. But I'd like to check if there
is an easier way.

My hack relies on the script

d201:~/octave>cat getmouse 
#!/bin/sh

GPID=$(xwininfo -name Gnuplot | awk '/Window id:/ {print $4}')
if [ -z GPID ] ; then
  echo "Gnuplot window not found"
  exit 
fi

xev -id $GPID | awk \
       '/ButtonPress event/ {x=1} ; \
        (x==2)   { printf("L=%sB=",$7) }; \
        (x++==3) { print $4 ; \
                   if ($4 ~ 2) system("killall xev") } ' \
        

This attaches xev to the Gnuplot window and sends all the X events to
awk which extracts the location from the Button Press events.

Pressing the second button kills the process, returning me to octave.

I invoke this with, and then click in the gnuplot window a little.

octave:54> system('/u/andy/octave/getmouse')
L=(658,107),B=1,
L=(675,107),B=1,
L=(700,105),B=1,
L=(801,118),B=1,
L=(851,119),B=1,
L=(851,119),B=2,

However, this has two problems.

1) It's slow. You have to wait a little (or move the mouse) after each
click
   before the pipe "flushes" into awk

2) It's difficult to convert from window coordinates. You have to click
on the
   axis and then calculate from there.


So, my question is:

1) Does this functionality exist in octave, or has someone already
written it?

2) If not, does anyone have any suggestions. I'm prepared to work this
code
   into something fairly user friendly and then contribute it to the
octave
   community.

thanks,
_____________________________________________________________________
Andy Adler,    | Pulmonary Physiology Unit         | Lab 303-398-1626
address@hidden | National Jewish Center,Denver,USA | Fax 303-398-1607

   For the Snark _was_ a Boojum, you see.    -Lewis Carroll



reply via email to

[Prev in Thread] Current Thread [Next in Thread]