[Cuis-dev] Selecting Morph

Hilaire Fernandes hilaire at drgeo.eu
Sat Jun 26 04:49:10 PDT 2021


Hi Juan,

Answer in the text.

Le 25/06/2021 à 15:01, Juan Vuletich a écrit :
> So, what is that you are in need for?
> - 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")

That is more like that. I want to select the morphs (views of math 
models) at a given distance of the mouse cursors:

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]]]

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:

DrGCircleMorph>>containsPoint: aPoint
     "it is a circle so height and width is the diameter"
     ^((self center dist: aPoint) - (self height / 2)) abs < 20

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.

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.

Thanks

Hilaire

-- 
GNU Dr. Geo
http://drgeo.eu
http://blog.drgeo.eu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210626/85d770b0/attachment.htm>


More information about the Cuis-dev mailing list