<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi Juan,<br>
</p>
<p>Answer in the text.<br>
</p>
<div class="moz-cite-prefix">Le 25/06/2021 à 15:01, Juan Vuletich a
écrit :<br>
</div>
<blockquote type="cite" cite="mid:60D5D3C3.9080409@jvuletich.org">So,
what is that you are in need for?<br>
- The ability to select several morphs at a time (without grabbing
them), so you can later do something with them? (this could
include ways to add / remove morphs from "current selection")<br>
</blockquote>
<p>That is more like that. I want to select the morphs (views of
math models) at a given distance of the mouse cursors:<br>
</p>
<pre>DrGDynamicTool>>myMorphsNear: aPoint
"Only morphs where feedback and action are wished,
not hidden, wanted and under mouse cursor"
| globalPoint |
globalPoint _ self drawable morphPositionInWorld + aPoint.
^self app morphs select: [:aMorph |
aMorph style isNotHidden
and: [(self isWanted: {aMorph mathItem})
and: [aMorph containsPoint: globalPoint]]]
</pre>
<p>Previously I was doing this computation per type of morph. For
example, for a circle morph, I wrote a simple method (wrongly
named btw) like bellow to detect when the mouse cursor is at
distance below 20 pixels of the circle line:<br>
</p>
<pre>DrGCircleMorph>>containsPoint: aPoint
"it is a circle so height and width is the diameter"
^((self center dist: aPoint) - (self height / 2)) abs < 20
</pre>
<p>With thin morphs as line, to ease the user experience, you really
don't want to limit morph selection to the width of the line, it
will make a terrible usability. Of course I can rewrite these
methods, but as Vector Graphics comes with a new way to detect the
morph at a given coordinates, it will be a great addition to have
a general method to detect if a morph is within a given distance
of a point.</p>
<p>Just random though: If I understood correctly, you use an array
of points to represent the pixels of the screen and the morphs id
filling these pixels. I guess you can have several morph id per
pixels, then selecting the morph ids bellow a disc on this field
of pixel is reasonably doable. I guess morphs collision could be
done too.<br>
</p>
<p>Thanks</p>
<p>Hilaire<br>
</p>
<pre class="moz-signature" cols="72">--
GNU Dr. Geo
<a class="moz-txt-link-freetext" href="http://drgeo.eu">http://drgeo.eu</a>
<a class="moz-txt-link-freetext" href="http://blog.drgeo.eu">http://blog.drgeo.eu</a></pre>
</body>
</html>