Getting mouse coordinates from inside a gimp plug-in?

2000-06-27 Thread Frazer Williams

Hi,

I'm a novice at working with the gimp, and I'm trying to write a
plug-in.  I've run into an unexpected snag, and I would very much
appreciate a little help.  I'll start with what I think my question is,
and then afterwards, briefly describe what I want to do in case that
really isn't my question  :-).

I think my question is:

  If I have an image loaded into gimp, and displayed in a window, and my
  plug-in fired up, how do I get the coordinates of the mouse when one of
  the buttons is clicked into the plug-in?

Here's what I want to do:
  
  I'm trying to write an "unplot" plugin.  The idea is to load a graph
  image into the gimp (probably using a scanner), and then, using the mouse
  to click on points on the graph, write the x and y values of
  mouse-selected points to a file.  Thus, if I had a graph of, say,
  voltage vs. current, I could digitize it manually using the plug-in,
  obtaining a file with voltages and currents.

In order to do this, the plug-in has to be able to get the mouse
coordinates when a button is clicked.  I think I know how to do that in
a stand-alone gtk-based program, but I can't figure out how to do it
from a gimp plug-in.  I guess the optimum coordinate system would be the
local coordinates within the image window, but global coordinates of the
underlying root window would probably be OK too.

Advice would be much appreciated.  I've looked in Kevin Turner's "Writing
a GIMP Plug-in" tutorial, and in all the FAQ's I can find.  I've also
looked in the plug-in registry for an existing plug-in I could snarf.  If
the solution was in any of these places, I was too dense to realize it.

Thanks.

Frazer Williams
[EMAIL PROTECTED]
Department of Electrical Engineering
University of Nebraska-Lincoln
Lincoln, NE  68588-0511



Re: Getting mouse coordinates from inside a gimp plug-in?

2000-06-27 Thread furnace

On Tue, 27 Jun 2000, Frazer Williams wrote:

 I think my question is:
 
   If I have an image loaded into gimp, and displayed in a window, and my
   plug-in fired up, how do I get the coordinates of the mouse when one of
   the buttons is clicked into the plug-in?

thats a gtk question, which is nicely answered at http://www.gtk.org look
at the gtk tutorial (which can be downloaded). then look at events.
 
 Here's what I want to do:
   
   I'm trying to write an "unplot" plugin.  The idea is to load a graph
   image into the gimp (probably using a scanner), and then, using the mouse
   to click on points on the graph, write the x and y values of
   mouse-selected points to a file.  Thus, if I had a graph of, say,
   voltage vs. current, I could digitize it manually using the plug-in,
   obtaining a file with voltages and currents.

you could "detect" the plots automatically and with a little logic in your
code, get an approximate of the plots. maybe even something as simple as a
threshold then average those remaining values. this could be pretty
elaborate and thus possible end up taking more of your time than the plug
in you want to write would save you (but could be fun)
 
 In order to do this, the plug-in has to be able to get the mouse
 coordinates when a button is clicked.  I think I know how to do that in
 a stand-alone gtk-based program, but I can't figure out how to do it
 from a gimp plug-in.  I guess the optimum coordinate system would be the
 local coordinates within the image window, but global coordinates of the
 underlying root window would probably be OK too.

most gimp plug ins are gtk programs. they just happend to be called from
the gimp and share some resourcces (i have written a gimp plug in with
glut, and it worked, but gtk is usually easier) the same method should
work.





Re: XCF code in Imlib2

2000-06-27 Thread Dean Johnson

[EMAIL PROTECTED] spontaneously blurts out:
 
 On 25 Jun, Marc Lehmann wrote:
 
   He and Raster are going to meet next week and then they'll think
   about possible solutions for this conflict.
  
  Don't they think this is demanding some _action_ (like reverting that
  patch)? "meet next week" and "possible solutions" sounds, well, not
  very serious.
 
  The patch IS already reverted. About 5 minutes after my mail...
 

I talked to Raster right after the first email arrived and he said he
would take care of it. I was hoping to give him a running start before
the ugly free software posse jumped him. I must say that this mailing list
has degenerated into something akin to a Microsoft legal newsgroup. Shoot
first, let god sort'em out.

What happened was wrong, yes, but the ugly mob bristling with legal talent
doesn't seem too terribly community-like. Raster has provided more than
his share free software and is probably amongst the top ten people for
amount of code stolen from him, so a little 'slack' is appropriate.
Especially considering that he didn't even do it in the first place. I
could care less what you think of him or his code, but the ugly mob
crap is tiresome and downright juvenile.

I now await the mob turning on me.

-Dean Johnson
 Tool Hooligan
 Cluster Admin Tools  Jessie Project
 Silicon Graphics Inc.Eagan,MN  (651) 683-5880

 
  "I am Dyslexic of Borg, Your Ass will be Laminated"-- unknown
 




Re: Getting mouse coordinates from inside a gimp plug-in?

2000-06-27 Thread Ian Boreham

At 10:41 27/6/00 -0500, Frazer Williams [EMAIL PROTECTED] wrote:
Hi,

  I'm trying to write an "unplot" plugin.  The idea is to load a graph
  image into the gimp (probably using a scanner), and then, using the mouse
  to click on points on the graph, write the x and y values of
  mouse-selected points to a file.  Thus, if I had a graph of, say,
  voltage vs. current, I could digitize it manually using the plug-in,
  obtaining a file with voltages and currents.

An alternative hacky way to achieve the same results might be just add
(draw) a dot of a well-known colour that does not otherwise appear in the
image at each desired location, then post-process the image to extract the
data by searching for those dots...


Ian





Re: Getting mouse coordinates from inside a gimp plug-in?

2000-06-27 Thread Kevin Cozens

At 10:41 27/6/00 -0500, Frazer Williams [EMAIL PROTECTED] wrote:
  I'm trying to write an "unplot" plugin.  The idea is to load a graph
  image into the gimp (probably using a scanner), and then, using the mouse
  to click on points on the graph, write the x and y values of
  mouse-selected points to a file.  Thus, if I had a graph of, say,
  voltage vs. current, I could digitize it manually using the plug-in,
  obtaining a file with voltages and currents.

I would suggest you look at the code for the ImageMap plugin. Thinking
about what it how it works from the users point of view I suspect it has to
have a way of getting the mouse coordinates.



Re: Getting mouse coordinates from inside a gimp plug-in?

2000-06-27 Thread Alan F. Ho


Or, you could blur the image a little, then use the
Level curves to make the data a thin black line by squeezing the
fully-black and fully-white arrow tags close together. Make the image
indexed with one color. Finally, save the image as a .pgm or .xpm
file. (.pbm is probably ideal but it seems like GIMP can't save in
that format. Perhaps use ImageMagik's convert to go from pgm to pbm?)
The data format for such files is very simple and with a 
quick read of the relevant man page, you will be all set to read the
file, dump the data into an array and then off you go. If you have
lots of pictures and would like to automate the process, you could
even write a script to handle the GIMP part non-interactively. 

This has the advantage of probably being more accurate than using the
mouse for coordinates, but perhaps this is not what you wanted. If
that's the case, sorry...

Alan



Installing gimp-1.1.24 (Gimp-perl) Problems

2000-06-27 Thread Jeff Sheffield

I have spent two days (ok well nights really)
trying to get the gimp-1.1.24 source to compile correctly.

Everything appears to work except for the Gimp-perl stuff.

System Info 
---
Linux version 2.2.15-4mdk ([EMAIL PROTECTED]) (gcc version 2.95.3 19991030 
(prerelease)) #1 Wed May 10 15:31:30 CEST 2000
Detected 350804278 Hz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 699.60 BogoMIPS
Memory: 257544k/262144k available (1208k kernel code, 416k reserved, 2904k data, 72k 
init, 0k bigmem)

Perl 5.6 (i have also tried with perl5.004_05)

here is the output from gimp-perl's 
make test
snip--
make[1]: Entering directory `/home/jsheffie/build/gimp/gimp-1.1.24/plug-ins/perl/po'
make[1]: Leaving directory `/home/jsheffie/build/gimp/gimp-1.1.24/plug-ins/perl/po'
PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib 
-I/usr/lib/perl5/5.6.0/i386-linux -I/usr/lib/perl5/5.6.0 -e 'use Test::Harness 
qw(runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/loadlib...Can't load 'blib/arch/auto/Gimp/Lib/Lib.so' for module Gimp::Lib: 
blib/arch/auto/Gimp/Lib/Lib.so: undefined symbol: gimp_micro_version at 
/usr/lib/perl5/5.6.0/i386-linux/DynaLoader.pm line 200.
 at blib/lib/Gimp/Lib.pm line 16
BEGIN failed--compilation aborted at blib/lib/Gimp/Lib.pm line 16.
Compilation failed in require.
require Gimp.pm called at t/loadlib.t line 7
main::BEGIN() called at blib/lib/Gimp.pm line 0
require 0 called at blib/lib/Gimp.pm line 0
Compilation failed in require at /usr/lib/perl5/5.6.0/Carp.pm line 119.
BEGIN failed--compilation aborted at t/loadlib.t line 7.
t/loadlib...dubious  
Test returned status 255 (wstat 65280, 0xff00)
Undefined subroutine Test::Harness::WCOREDUMP called at 
/usr/lib/perl5/5.6.0/Test/Harness.pm line 334.
make: *** [test_dynamic] Error 255
[root@kelly perl]# pwd
/home/jsheffie/build/gimp/gimp-1.1.24/plug-ins/perl
---


Thanks, 
Jeff

--
| Do not try to cut your own hair.   |
|   -- Forrest Gump  |
|   -- Winston Groom |
--
| Jeff Sheffield |
| [EMAIL PROTECTED]   |
|  - http://buzzard.kdi.com/jeff/family/ |
|  - http://www.team-linux.com/  |
--