 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
RL912 Guest
|
Posted: Sat Apr 07, 2007 12:07 am Post subject: Image map (sort of) |
|
|
Hello,
I need to set up a Gui where the user should click on an area of the
canvas to select something.
It should be possible to use any image painted on the canvas. To make it
even worse, the area should change color or shape after being clicked.
I already used an enhanced stringgrid where the cells changed color, but
that is not flexible enough in terms of placing the clickable areas.
Imagine a circus where the seats should be selected and their status be
changed by mouseclick.
I thought about something like GIS ??? but found it a litte bit too
heavy for such a purpose.
Any Suggestions ?
Thanks for your help.
Rolf |
|
| Back to top |
|
 |
Anders Isaksson Guest
|
Posted: Sat Apr 07, 2007 1:56 am Post subject: Re: Image map (sort of) |
|
|
RL912 wrote:
| Quote: | I need to set up a Gui where the user should click on an area of the
canvas to select something.
|
Regions and PointInRegion is one way to do it.
In my BlockCAD program (see sig.), you can click on any (visible) brick, and
it will get selected. I do this on mouse click by looping through all parts
of a model, creating the 2D region it covers on the screen and checking if
the mouse coordinates are inside this region. Works fast enough for a couple
of thousand bricks. The source is available but I warn you - it's not
beautiful code as it started in Delphi 1 and has grown through the years
together with my Delphi knowledge...
--
Anders Isaksson, Sweden
BlockCAD: http://web.telia.com/~u16122508/proglego.htm
Gallery: http://web.telia.com/~u16122508/gallery/index.htm |
|
| Back to top |
|
 |
Nils Haeck Guest
|
Posted: Sat Apr 07, 2007 2:48 am Post subject: Re: Image map (sort of) |
|
|
| Quote: | In my BlockCAD program (see sig.), you can click on any (visible) brick,
and it will get selected. I do this on mouse click by looping through all
parts of a model, creating the 2D region it covers on the screen and
checking if the mouse coordinates are inside this region.
|
This can be optimized.. you can define group regions, e.g. seats
left/middle/right, and first check if the mouse is in one of these groups,
then check subgroups, etc, until you end up at the individual seats.
Question is: do you need optimization.. if you can do a few thousand
PtInRegion calls with no noticable delay, then probably not :)
| Quote: | Imagine a circus where the seats should be selected and their status be
changed by mouseclick.
|
There are some good examples of this kind of interface on the Adobe website,
using SVG.
So.. if you'd define your interface as SVG, you could render it on a canvas,
change properties on the fly (like seat colours), and detect mouse clicks.
It so happens that I have just finished a new rendering component, Pyro,
which also has an SVG plugin. You could use the combination of the two to do
the trick.
For creation of the actual SVG image, any 2D vector editor with SVG output
would do.
Nils Haeck
www.simdesign.nl |
|
| Back to top |
|
 |
RandomAccess Guest
|
Posted: Sat Apr 07, 2007 5:07 am Post subject: Re: Image map (sort of) |
|
|
Hi Anders,
| Quote: | ...and checking if the mouse coordinates are inside this region. Works
fast enough for a couple of thousand bricks.
|
I would agree with you here, as I think this is the simplest solution as
long as
you have regions already defined, or have a convenient method for creating
them. The speed you are seeing in BlockCAD is probably because ptInRegion
performs a bounding rectangle check first. (At least that's what I would
do).
By the way, I looked at BlockCAD some time ago. Quite impressive.
best regards |
|
| Back to top |
|
 |
RL912 Guest
|
Posted: Sat Apr 07, 2007 8:11 am Post subject: Re: Image map (sort of) |
|
|
RL912 schrieb:
| Quote: | Hello,
I need to set up a Gui where the user should click on an area of the
canvas to select something.
It should be possible to use any image painted on the canvas. To make it
even worse, the area should change color or shape after being clicked.
I already used an enhanced stringgrid where the cells changed color, but
that is not flexible enough in terms of placing the clickable areas.
Imagine a circus where the seats should be selected and their status be
changed by mouseclick.
I thought about something like GIS ??? but found it a litte bit too
heavy for such a purpose.
Any Suggestions ?
Thanks for your help.
Rolf
|
Many thanks to all of you, I never would have found any of these ways to
solve the problem. |
|
| Back to top |
|
 |
Anders Isaksson Guest
|
Posted: Sat Apr 07, 2007 1:16 pm Post subject: Re: Image map (sort of) |
|
|
RandomAccess wrote:
| Quote: | I would agree with you here, as I think this is the simplest
solution as long as you have regions already defined, or have
a convenient method for creating them.
|
In the BlockCAD program, there's not much gain in having the regions defined
all the time, as they would need to be re-defined as soon as you zoom
in/out, rotate or pan (or add another brick). There's also the risk of
running out of Windows resources (I think WinAPI regions are a resource).
The loop looks like this:
for each 3D object in the list:
create its 2D screen region
do the hit test
release the region
end;
and I just did a quick, unscientific test - clicking on a >7000 bricks model
it finds the part and redraws the complete model with the selected part(s)
recoloured in less than 1 second on my computer. The hit testing is
definitely less than half of that time, so it's certainly not a bottleneck.
| Quote: | By the way, I looked at BlockCAD some time ago. Quite impressive.
|
Thanks!
--
Anders Isaksson, Sweden
BlockCAD: http://web.telia.com/~u16122508/proglego.htm
Gallery: http://web.telia.com/~u16122508/gallery/index.htm |
|
| Back to top |
|
 |
RandomAccess Guest
|
Posted: Sat Apr 07, 2007 2:37 pm Post subject: Re: Image map (sort of) |
|
|
Hi Anders,
| Quote: |
In the BlockCAD program, there's not much gain in having the regions
defined all the time, as they would need to be re-defined as soon as you
zoom in/out, rotate or pan (or add another brick). There's also the risk
of running out of Windows resources (I think WinAPI regions are a
resource).
|
Understood. I never produced an editor that worked with so many entities,
so I'm a bit "in the dark" concerning resources.
| Quote: |
The loop looks like this:
for each 3D object in the list:
create its 2D screen region
do the hit test
release the region
end;
|
I never thought of creating the regions that close to the test.
If it's as fast as you say, then that's terrific. I personally would still
have
done a bounding box hit test before creating a region, but then again,
your resulting performance seems to indicate that it simply isn't necessary.
best regards |
|
| Back to top |
|
 |
Joey Guest
|
Posted: Sun Apr 08, 2007 3:42 pm Post subject: Re: Image map (sort of) |
|
|
hello
i recommend the excellent
http://www.mirkes.de/en/delphi/vcls/rgnimg.php
hth
| Quote: | Hello,
I need to set up a Gui where the user should click on an area of the
canvas to select something.
It should be possible to use any image painted on the canvas. To make it
even worse, the area should change color or shape after being clicked.
Any Suggestions ?
Thanks for your help.
Rolf |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|