Active Forums => QB64 Discussion => Topic started by: OldMoses on June 28, 2019, 08:07:26 am
Title: Getting coordinates from a WINDOW _PUTIMAGE w/ mouse
Post by: OldMoses on June 28, 2019, 08:07:26 am
Is it possible to get relative coordinates with a mouse over from a smaller _putimage on a bigger screen?
I have a larger main display which I place a smaller view port on the right side which is created with VIEW and WINDOW and has coordinate system thus: WINDOW (-1000, 1000)-(1000, -1000) I'm looking to be able to get those coordinates when the mouse is over that viewport
The project in question is: https://www.qb64.org/forum/index.php?topic=1429.0 (https://www.qb64.org/forum/index.php?topic=1429.0) In searching the wiki and forum I came across PMAP, which seems to be the key, but the coordinates returned are only for the main screen and won't register the relative coordinates contained in the _PUTIMAGE. It works well only when working with the image in isolation, but not once it is put to the bigger display.
Is this even possible, and/or am I missing something....other than my marbles... ;)
Title: Re: Getting coordinates from a WINDOW _PUTIMAGE w/ mouse
Post by: Petr on June 28, 2019, 08:40:34 am
Hi. Why not use directly _PUTIMAGE own? Something as this:
Hi. Why not use directly _PUTIMAGE own? Something as this:
I'm looking to preserve the cartesian coordinate scheme in the graphics window to make the math simpler.
Now that you mention it, I suppose there's nothing preventing me from making the smaller view port 2000x2000, bypassing the whole WINDOW approach, and just using the _PUTIMAGE command to size it down to the main screen, but I assume that would still not address the mouseover issue.
Title: Re: Getting coordinates from a WINDOW _PUTIMAGE w/ mouse
Post by: SMcNeill on June 28, 2019, 02:20:19 pm
Sometimes you just have to do the math yourself.
Let’s say I’m running a program in a 1000x1000 window. (Goofy size, but easy numbers.). Now, let’s say I designate the top right 250x250 area as a mini “preview” window of sorts, but I want to interact with it as a 1000x1000 coordinate window, as well...
The mouse position is relative to the main window, so if it’s halfway in that 250x250 area, it’d be at point (875,125).
So the WindowMouseX would be (875 - 750) * (1000 / 250) = (125) * (4) = 500 And WindowMouseY would be (125 - 0) * (1000 / 250) = (125) * (4) = 500
And, in the mini-window, point (500,500) is indeed the center of the designated 1000x1000 coordinate system, which overall would be at (875, 125) on the main screen.
Just don’t forget to error check...
IF WindowMouseX < 0 OR WindowMouseX > 1000 OR WindowMouseY < 0 OR WindowMouseY > 1000 THEN ‘Result is not inside preview window. Skip any preview click results...
Title: Re: Getting coordinates from a WINDOW _PUTIMAGE w/ mouse
Post by: Petr on June 28, 2019, 02:35:06 pm
Hi. I look at it again, maybe this help you, it is the same as Steve wrote:
Title: Re: Getting coordinates from a WINDOW _PUTIMAGE w/ mouse
Post by: OldMoses on June 28, 2019, 06:14:59 pm
Thanks guys, I figured that once I put the image in the main screen it was part of the main screen and would react with mainscreen coordinates. When I'm doing the display updates I'm working with the "sub image", but once it's put in the main display I've lost the option of direct mouse interaction. I'm always keen to avoid the math, but as Steve says, sometimes you just have to bite that bullet.
What I'm essentially flirting with is an AutoCAD like system that has WCS and UCS based references. I want to be able to go into the screen and click on a particular "radar blip" and have it come up as an active viewpoint. I'm also flirting with a way to do a "zoom extents" in the window. It's quite a hunk for someone at my level to be chewing on. Maybe it'll work, since with things like this I approach it with the attitude that I'm too stupid to realize I can't do it, and it often happens that I can after all...
Title: Re: Getting coordinates from a WINDOW _PUTIMAGE w/ mouse
Post by: OldMoses on June 29, 2019, 07:35:33 pm
Success! It's working as I envisioned it would. Steve's equations and a little patient tweaking did the trick.