From: mevans@Ingres.COM (Mike Evans)
Subject: Re: Ingres Windows4GL - Tolerencing Mouse Clicks
Date: 23 Jul 92 15:57:44 GMT

    Rajesh,
        I'm assuming that you have either the form or the imagefield set to
    a bias of CLICKPOINT, since that's the only way you can generate x and y
    coordinate values when clicking.

> I have the following problem when using Ingres-Windows4GL with Ingres v6.3
> on HP 9000/700 Workstations
> 
> Outline : I am using an Imagefield in a windows form into which is loaded
>           an image from the unix filesystem.
>           (The image is not stored in Ingres)
>           - The image is in SUN raster format,
>             is 256x256 pixels and greyscaled.
> 
> I have a script associated with the imagefield which is activated each time
> the mouse is clicked in the image field.
> 
> What I want to do now is to read the mouse position when the button was 
> clicked, place an 'X' at that point, and redisplay the image.
> 
> Problem (1).
>   I cannot perform this in straight Ingres because Windows4GL places the
>   image in the 'foreground' and any drawn attributes in the background, so
>   they cannot be seen.
>   ... What I do to try to get around this is to edit the sun raster file
>       and physically put an 'X' in and then reload and redisplay the image.
> 
>   Unfortunately ... I can't read the mouse position accurately enough, and
>   convert it to pixels rather than in thousands of an inch or whatever Ingres
>   returns in the Curframe.XStart and Curframe.YStart variables.
> 
    
    There's no way to place any subclass of the SHAPEFIELD class on top
    of any subclass of the ACTIVEFIELD class.  They exist in different
    form 'layers', with the shape layer being below the field layer.

    Do you have to draw an 'X'?  You might be able to a field to mark
    where you click, and fields can be placed on top of one another.
    A very small square barfield, for example, could be used as a marker.

> (2)
>   I physically set the size of the imagefield (in the script) to 2560x2560 by
>   setting the width and height attributes of the imagefield, but when I read
>   back the points I get when clicking in the TopLeft and BottomRight corners of
>   the image field I get (22,88) - TopLeft, and (2516,2588) - BottomRight.
>   In addition when I check FIELD().Width and Height I get Width = 2560, and
>   Height = 2555, wheras I have set them previously to 2560x2560, also I have
>   set the Imagefield to resize the image (width and height) to fit the field.
> 
> The outcome of these problems is that the 'X' is not placed at the position
> where the mouse was clicked, this is important because subsequently I want to
> be able to click on the 'X' and store information in Ingres spacifically about
> that point on the image.
> 

    The problem is that the consequences of the form grid is not fully
    documented.  The form on a frame has a grid which is used to align
    its fields, if desired by the developer.  A field can be aligned to
    the grid by using the 'snap to grid' menu item in the frame editor.
    The grid cell size can also be modified within the frame editor.
    The problem you're experiencing is due to the CLICKPOINT event that's
    being generated is giving you the x and y coordinates of the nearest
    intersection of the form's grid lines, not the actual coordinates that
    you clicked on.

    The way to fix this problem is to set the grid size to zero, effectively
    getting rid of the grid altogether.  By setting the GridX and GridY
    attributes of the CurFrame variable, your clickpoint events will give
    you the exact x and y coordinates you clicked on.

> Can anybody Help ???

    Below is an export file of a frame that you should look at and play
    with.  It shows you how to get rid of the round-off problem with
    getting x and y from clickpoint events, and uses barfields to mark
    where you clicked.

    To import this frame, remove all text above the line that says 
    'remove all text above and including this line', save the result
    to a file, and import it with the command:

	importapp <some db name> <some app name> <the file name> -caframe

    Good luck,
	Mike
-------------remove all text above and including this line----------------------
1
11: Tag Header
1

6:HEADER
1
1

1
-1:
0

$
=
28
13: Cache Object
1

11:FRAMESOURCE
1
1

2001
15997
15994
11:framesource
6:aframe
0:
-1
15996
1
6:mevans
1:s
1023412168
458774
79530000
0:
1:n
1:n
6:mevans
1023412168
458775
56692000
4

2001
23:1992_07_23 15:44:52 GMT
6:mevans
4
1
0
0:
0
0
0
1
-1:

2001
2
0

2007
0:
2
0
0
0
0
0
0
4002
4081
250
250
0
4
3
27
0
0
0
0

$
12:STRINGOBJECT
2
1

0
593:initialize
(
	drawrectangles = smallint;
	newrec = barfield;
)=
begin
	curframe.topform.curbias = fb_clickpoint;
	drawrectangles = false;
end;

on click drawrec =
begin
	drawrectangles = true;
end;

on click setgrid =
begin
    curframe.gridx = 0;
    curframe.gridy = 0;
end;

on clickpoint =
begin
	x = curframe.xstart;
	y = curframe.ystart;

	if drawrectangles = true then
		newrec = field(recprototype).duplicate();
		newrec.xleft = x - (newrec.outerwidth/2);
		newrec.ytop = y - (newrec.outerheight/2);
		newrec.parentfield = curframe.topform;
		newrec.curbias = fb_visible;
	endif;
end;


$
9:FRAMEFORM
3
1

8
0
1

11
111
111
23995
23998
16
8
16
16
32
16
16
16
0
0
1
-1
1

7
1
2
1
1
0
1
0
-1

7
4
1
1
1
1

5
0
0
4081
4002
0
0
0
-1:
0
0
0
0

$
3:BAG
4
1

1
10
5
5
9
12
14
16

$
11:BUTTONFIELD
5
1

8
6
2

11
256
3469
367
811
3
256
16
16
32
16
16
16
3
0
1
-1
1

7
1
2
1
1
0
2
-1
-1

7
4:Exit
8
0
0

$
13:VARDESCRIPTOR
6
1

0
10:exitbutton
2:i4
-1:
0
0
1
7
30
4
0

$
12:STRINGOBJECT
7
1

0
30:ON CLICK =
BEGIN
	return;
END


$
4:FONT
8
1

1
1
0
0
2
12
-1:

$
11:BUTTONFIELD
9
1

8
10
1

11
1278
3447
367
811
3
256
16
16
32
16
16
16
3
0
1
-1
1

7
1
2
1
1
0
1
-1
-1

7
8:Set Grid
11
0
0

$
13:VARDESCRIPTOR
10
1

0
7:setgrid
2:i4
-1:
0
0
1
0
30
4
0

$
4:FONT
11
1

1
1
0
0
2
12
-1:

$
8:BARFIELD
12
1

8
13
2

11
0
0
78
78
3
256
1024
16
32
16
16
16
3
0
1
-1
1

7
1
2
1
-1
0
2
-1
-1

11
0
100
25

1
6
-1

$
13:VARDESCRIPTOR
13
1

0
12:recprototype
2:i4
3:100
0
0
3
0
30
4
0

$
11:BUTTONFIELD
14
1

8
15
1

11
2334
3447
367
1489
3
256
16
16
32
16
16
16
3
0
1
-1
1

7
1
2
1
1
0
1
-1
-1

7
15:Draw Rectangles
11
0
1

$
13:VARDESCRIPTOR
15
1

0
7:drawrec
2:i4
-1:
0
0
1
0
30
4
0

$
11:MATRIXFIELD
16
1

8
0
1

11
1012
356
645
1556
2
8
16
16
32
16
16
16
3
0
1
-1
1

7
1
2
1
-1
0
1
0
-1

7
17
1
0
1
1

1
2
2
-1
-1
0
0
0
0
0
0
18
3
18
20
23
25

$
3:BAG
17
1

1
10
4
18
20
23
25

$
8:FREETRIM
18
1

8
0
3

11
0
22
278
211
2
16
256
256
256
256
256
256
16
0
1
-1
1

7
1
2
1
-1
0
3
-1
-1

10
19
1
0
0
1
0
-1:
1
1
0

2
1:X
0

$
4:FONT
19
1

1
1
0
0
2
14
-1:

$
10:ENTRYFIELD
20
1

8
21
4

11
222
0
322
1334
3
256
16
16
32
16
16
16
16
0
1
-1
1

7
1
2
1
-1
0
4
-1
-1

10
22
0
0
0
1
0
-1:
1
13
0

$
13:VARDESCRIPTOR
21
1

0
1:x
7:integer
-1:
0
0
1
0
30
4
0

$
4:FONT
22
1

1
1
0
0
1
12
-1:

$
8:FREETRIM
23
1

8
0
3

11
0
345
278
222
2
16
256
256
256
256
256
256
16
0
1
-1
1

7
1
2
1
-1
0
3
-1
-1

10
24
1
0
0
1
0
-1:
1
1
0

2
1:Y
0

$
4:FONT
24
1

1
1
0
0
2
14
-1:

$
10:ENTRYFIELD
25
1

8
26
4

11
222
322
322
1334
3
256
16
16
32
16
16
16
16
0
1
-1
1

7
1
2
1
-1
0
4
-1
-1

10
22
0
0
0
1
0
-1:
1
13
0

$
13:VARDESCRIPTOR
26
1

0
1:y
7:integer
-1:
0
0
1
0
30
4
0

$
7:MENUBAR
27
1

8
0
2

4
0
-1:
16384
16384
16384
16384
16384
16384
16384
16384

2
28
0

1

1

$
3:BAG
28
1

1
10
0

$
=
1
12: Tag Trailer
1

7:TRAILER
1
1

1
-1:
0

$
=