Paul,
I don't think it registered with you that Agustin was using Simpleplot - I'm guessing that you read it that he was using “simple plot” routines! I read your first reply, and was amazed to imagine that the mouse worked the same in a Simpleplot window as a %gr window – and I guess that it doesn’t.
Agustin,
In the documentation area of the Silverfrost website you will find a range of documents on Simpleplot. In some of them, mention is made of a routine GETXY for interaction using the mouse in a Simpleplot window. This is a Simpleplot (i.e. BUSS) routine not a Silverfrost one, as it doesn't end with @. One of the difficult things to discover is precisely what is present in the “bundled” version, and what extra facilities were in the full version. Whether or not GETXY is included in the bundled mini version of Simpleplot that is supplied with FTN95 I don't know. You should probably start by downloading all the Simpleplot documentation and read it all. You may find the answer there - although if the routine is available only in the full Simpleplot then you continue to have a problem.
In the Simpleplot documentation, it talks about placing Simpleplot graphics into a conventional %dw window. This is in the document 'Using Simpleplot with FTN95' in section 5.2.3. There is sample code there and a tutorial. I don't like %dw - it doesn't work properly with all the Silverfrost routines - so maybe it is worth trying with %gr instead. Then you can use the method Paul gave you for getting the mouse position.
When drawing any graphics, you always have to do a conversion from real world coordinates to pixels, both for scaling and for shifting the origin. To get back, reverse the process. Remember that the mouse position is given to 1 pixel accuracy, and this isn't very good (usually) in real world coordinates, so you may have to make an intelligent decision about what the real world equivalent should be and round (up or down) your mouse position accordingly.
I keep the conversions in “statement functions”, so, for example,
IPOSX(XX) = (XX - X_CENTRE)/SCREEN_SCALE_X + IXRES/2
IPOSY(YY) = IYRES/2 - (YY-Y_CENTRE)/SCREEN_SCALE_Y
give me the pixel coordinates of a point with real life coordinates (XX,YY) in a window of size (IXRES , IYRES). The scales for X and Y are possibly different (hence SCREEN_SCALE_X and _Y) and these have to be worked out from the range of X and Y coordinates, and whether the aspect ratio is fixed or not. My statement functions centre my plottable object in the window, and take account of the fact that my Y coordinates increase upwards, although the screen y-coordinates increase downwards. (I forget about whether or not the coordinates start at 1 or 0 !)
Reversing things is a matter of getting the pixel coordinates, and then getting the real life coordinates. In one of my programs this is done with
IXP = CLEARWIN_INFO@ ('GRAPHICS_MOUSE_X')
IYP = CLEARWIN_INFO@ ('GRAPHICS_MOUSE_Y')
RX = (IXP-ixres/2)*SCREEN_SCALE + X_CENTRE
RY = Y_CENTRE - (IYP-iyres/2)*SCREEN_SCALE
As I understand Simpleplot, the actual graph is plotted in (say) 60% of the available window pixels, so you need to take that into account as well when back-calculating the real world coordinates.
You may find this rather easier if you program the graphing yourself (in a %gr region) rather than using Simpleplot! (or try using SIMDEM).
Regards
Eddie
PS. It is always useful to download the FTN77 documentation as well. There are facilities still in FTN95 that come from the past, and which aren't always documented in FTN95.CHM.
E