Thank you Mehmet -
Tried to follow the math within the svg (inkscape) on my first attempt(s)
got completely lost (which leads to questioning ones intelligence) on
the transforms, scales and differing units :)
So now fully fudging it by dividing the Svg source Height and Width by a
grid format and call each one a quadrant location (x,y).
Then do the same with the OnClick position of the viewer (so relative
quadrants / sizes), and find closest matching (for me) object. All
depends on granularity of grid for accuracy.
Works, but is very dependent on complexity of the svg (not a problem for
my use case so far)
On 18/1/22 9:53 am, Mehmet Erol Sanliturk wrote:
On Tue, Jan 18, 2022 at 2:37 AM Steve Gatenby via lazarus
<lazarus@lists.lazarus-ide.org <mailto:lazarus@lists.lazarus-ide.org>>
wrote:
Thanks Marc - seems I will need to stick with what I have then.
Currently I am pulling all object info from the SVG into an array and
assigning quadrant positions.
Then do best guess by relative quadrant of mouse click position -
works
fine, but feels sloppy :)
If it is feasible for you , you may do the following :
In an array of a record , define approximate "bounding boxes" of your
SVG graphic ( You may generate a "bounding box" array conforming to
the given SVG ) .
In the "bounding box" array record , you may define a pointer showing
the SVG object .
When a mouse click is obtained , you may search "bounding box" array and
if it is related with an element of the SVG , from it you reach to the
SVG element and
do whatever you want to do with it .
https://en.wikipedia.org/wiki/Minimum_bounding_box
<https://en.wikipedia.org/wiki/Minimum_bounding_box>
Minimum bounding box
( Please see attached pages . )
This idea may be considered as an alternative view which I can not say
that
it is very suitable for you . Only you may decide its usefulness .
Mehmet Erol Sanliturk
On 17/1/22 8:55 pm, Marc Weustink via lazarus wrote:
> I'm afraid there is no easy solution for that. SVGs are rendered
from
> the first element to the last, where ever element (atleast in
theory)
> can be a part of a given pixel. SVG elements do have a
> x,y,width,height but they may also be part of one or more
> transformations.
> To give you an idea, the (browser)app I'm currently working on
> displays several object, where every object has an origin(x,y)
of 0,0
> and they are finally placed by translations.
> The easiest way (if you are in a browser context) is to add an
onclick
> handler to your elements of interest.
>
> Marc
>
>
>
> On 16-1-2022 23:34, Steve Gatenby via lazarus wrote:
>> Not sure if this is the right place to ask about this one -
>>
>> I am using the BCSVGViewer from bgra controls - for SVG viewing
>> obviously :)
>>
>> Would anybody know if there is a method to retrieve the object
>> (within the svg) at specified x,y ?
>>
>> or is it possible to use embedded links within the svg ?
>>
>> I am looking to find which object has been clicked on within
the svg
>> to create a 'clickable' map
>>
>> Any suggestions on a better place to post this also appreciated
>>
>> Regards SteveG
>>
--
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org <mailto:lazarus@lists.lazarus-ide.org>
https://lists.lazarus-ide.org/listinfo/lazarus
<https://lists.lazarus-ide.org/listinfo/lazarus>
--
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus