Revisiting an old friend... aka overlapping graphics

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
stam
Posts: 2682
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Revisiting an old friend... aka overlapping graphics

Post by stam » Tue Dec 06, 2022 4:43 am

Hi all,

I've been revisiting an 'old friend' and am happy I've improved on it dramatically - I thought I'd share my progress in case anyone found this useful - its a small element that fits into a number of my other projects and probably won't mean much to you if you're not working in cardiology...

The problem to tackle was creating a bullseye display, which is common in cardiology for assigning functional values to the 16/17 segments of the left ventricle, but required overlapping graphics. After several stuttering attempts including importing each segment as a PNG, SVG and so on I initially settled on creating a 'skeleton' with vector graphics under which were some hand drawn closed polygons that could take colouring etc. The data was stored internally in a table field (usually hidden). The problem is that this didn't scale well and re-sizeing was an issue because of the hand-drawn closed polygons - so the vector skeleton had to be much thicker to hide deficineies. That always grated. The previous thread is here: https://forums.livecode.com/viewtopic.p ... 30#p201854

I've redesigned this using exclusively oval graphics with their arcAngles and startAngles set and layered in such a way that the 'segments' can be coloured independently but still faced the same issue of overlapping graphics, as the 'hidden' parts of the ovals still intercepted mouse clicks to the deeper layers, so only the topmost in each group could actually be clicked.

This is a circle and as I've re-learned geometry I never knew I'd forgotten in a different project, it was now much easier to calculate which segment was clicked on using proper trigonometry functions to get the distance from the centre and the angle, so even though the invisible bits of some graphics cover all others, it's possible to get this react correctly to mouse clicks on the 'buried' graphics.

The added bonus is this is infinitely more scalable as it's purely ovals set at the same loc; and data management has been sampled dramatically to a comma separate list containing all values and this as well as calculations are all stored internally as custom properties. In fact I wrote a stack that will generate a bullseye of any size:

bullseyeFactory.jpg

Feel free to download it from my GitHub : https://github.com/stam66/bullseyeFactory (shared under MIT licence).
Maybe someone might find bits of it useful - any feedback welcome as always...

S.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Revisiting an old friend... aka overlapping graphics

Post by bn » Tue Dec 06, 2022 10:58 am

Hi Stam,

That is brilliant. Simple, effective and scalable.
Bravo.




The only thing that worries me is this:

LVEF.jpg
Troublesome values
LVEF.jpg (28.35 KiB) Viewed 1243 times

Circulation reverses which is an interesting condition... :D

Kind regards
Bernd

stam
Posts: 2682
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Revisiting an old friend... aka overlapping graphics

Post by stam » Tue Dec 06, 2022 11:06 am

Well, it’s an impossible situation. Dyskinetic means moving out of phase with the rest. But if all segments are dyskinetic they would actually all be in phase :)

The buttons are simply meant as a shortcut where a large number of segments are the same, it’s meant as a starting point so other segments can be changed manually.

But that’s a good point - it’s uncommon to have more that 6-7 dyskineetic segments so that button is not that useful.

I might replace it with a check box so the other 3 buttons only fill the unscored segments instead of all of them…

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Revisiting an old friend... aka overlapping graphics

Post by bn » Tue Dec 06, 2022 11:21 am

stam wrote:
Tue Dec 06, 2022 11:06 am
Well, it’s an impossible situation. Dyskinetic means moving out of phase with the rest. But if all segments are dyskinetic they would actually all be in phase :)
I interpret it in relation to systole/diastole. A negative Ejection Fraction would suck in blood. Then it reverses the blood flow. But enough of that questionable joke. :)

Kind regards
Bernd

stam
Posts: 2682
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Revisiting an old friend... aka overlapping graphics

Post by stam » Tue Dec 06, 2022 11:47 am

Questionable humour aside :)

You do make an important point - as usually there will be no more than 3-4 dyskinetic segments, no one (myself included) will ever use that button, so best to remove it.

On the other hand I will often start by noting the abnormal (or few normal) segments, and it would be useful to fill all the unscored segments. In truth that should be the default behaviour, and if needed all can be reset then coloured in one fell swoop… no checkbox required.

Thanks for the inspiration ;)
S.

stam
Posts: 2682
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Revisiting an old friend... aka overlapping graphics

Post by stam » Tue Dec 06, 2022 12:37 pm

Further to this, I've amended the stack as above - the 'mark all as dyskinetic' button has been removed as it served no real purpose and it also produced a rather 'sucky' negative LVEF ;)

I also changed the behaviour of the other 'mark all segments' buttons to only score the unscored segments. To mark all as previously, reset and click the 'mark all' button of choice.

Download: https://github.com/stam66/bullseyeFactory

S.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”