Universal Point Tool - possible modification?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Universal Point Tool - possible modification?

Post by heyvern »

I love that UPT! It is perfect... uh...

I have an idea though.

There was talk about the limits on modifier keys... and I keep thinking it would make more sense if it worked just by clicking one point or drag selecting multiple points without using a modifier.

Would it be possible to change the function based on where the mouse is clicked in relation to other points?

For instance if the mouse is say... within 5 pixels of the nearest point when clicked it selects one point. If it is within 5 pixels of a selected point, dragging will translate the point.

If it is outside that range dragging would switch to the "multi-select" option and you could drag select points... or deselect... without having to use a modifier.

This would then "add" those modifier keys back into the mix... I could have my beloved shift/constrain back. ;)

I have just begun looking over the scripting documentation. There is a

Code: Select all

pt (LM_Point) and startPt (LM_Point)
that would track the mouse position. It would then be a matter of determining pixel distance to the nearest point... maybe that pixel distance could be settable as well.

Before I go too far on my own, I was wondering if there would be any reason specifically something like this wouldn't be possible.

-Vern
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Quick reply without a lot of study - I don't see why not. A checkbox in the UI to enable that kind of function would be useful (might not always want to use it). The code from the Magnet tool that selects points within a certain distance from the cursor based on the magnet strength should be pretty easy to drop in there. If the number of points it picks up is zero or 1, and there are points in the current selected points list, then you go with the selected points list. I don't have much time lately, but I'll try to whip up a few bit's of code for pointers if you want to give it a whack.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Thanks 7feet.

If you feel inspired to do so that would be great and much appreciated. However hearing from you that it probably should work...

... and after going through the code very carefully and studying the LUA script reference and tutorials for Moho... I think... maybe... with time and patience I could make it happen.

The only reason I want this... is that... that is how so many other applications work. Plus... sometimes... I... uh...

... well... I lean back in my chair and I am way to lazy to reach to the keyboard to hold down a modifier key... all that effort just to select some points!
;)

... I am very lazy. But that's what it's all about. We are lazy... so we will spend hours writing a script that saves us a few seconds. God forbid I have to actually lean up to the desk and press another key.

;)

-Vern
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I... see the light... the light at the end of the tunnel! I can see the glow of hope approaching me...

Why do I get as much joy from solving a programming problem as I do creating a beautiful picture?

The two sides of my brain constantly fight for control.

This is fun. It is hard work considering I never heard of lua before I bought Moho... lots of resources.

(took me ages to figure out that "WorldToScreen" thingy...)

Basically... I have a "routine"? or "function"? (not a "real" programmer) that can pinpoint a user defined selection radius for the "click". Now it is just a matter of using that instead of the modifier keys to activate the Selection/Lasso or the Translate... thingies.

So it is going to work just as I wanted. If you click within X pixels of a single previously selected point or one of a multiple selection of points... you can move it or them....

If you click outside the preset selection radius... all points get deselected and you get the selection/lasso tool.

I get to put the shift/constrain back in.... PLUS I can remove both the "old" selection tool and the translate tool... I get those two key commands back (G and T) for other tools if I need them!

I am leaving in all the other "stuff" for scaling and rotating.

I haven't found it yet but is there a MouseEvent for the "hovering" mouse location? Before you click? Like... a mouseover kind of thing? I was thinking something like that would allow for scaling and rotating based on the location of the mouse near the bounding rectangle of the selection.

------------

I know that some people probably won't like working this way... but it is what I am use to... so... cool! Just like the Photoshop transform tool.

WooHoo!
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

MouseEvent.pt should return a Vector2 object (y'know, just an x/y point) that tells you the mouses current pixel location on the screen, and then use the ScreenToWorld to figure out where in the project you are.

Sounds like great progress, post it when you can - even if it's still a work in progress I'm curious how you structured it.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Oh good grief!

ScreenToWorld... so it goes the other way too? Should've known. That would be simpler.

As soon as I get something reasonably functional that doesn't "break" Moho I will post it.

Currently I can select and deselect a point based on a mouse click near a point (within 5 pixels). I am working on adding the lasso into this mix.

I sort of just... attack one thing at a time. I am a bit slow.

Yikes! I hope you won't make fun of my programming skills. It looks absolutely hideous at the moment... more "comments" then code.

;)

Vernon "!" Zehr
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I know I should just shut up till it's done...

... but it is so much fun! I made a big jump in my understanding of Lua and the code structure in Moho scripting.

I don't really need the ScreenToWorld stuff now. Just "stole" the code from the magnet.lua as suggested for finding the mouse click relationship to a point. Couple of days ago it made no sense... 5 minutes ago it was invaluable.

I am about 80% there... I don't want to post it till it works... that way when people look at my clunky horrible code... they can't make too much fun of me...

;)

7feet,

When I do post this... what should I call it? Should I should leave the name the same and hope no one overwrites your "sure bet"... or should I give it a new name?

99% of the code is still yours... er... well... yours and LM's... if you follow me.

I don't know what the "etiquette" is for this type of thing.

I don't plan on putting in a "checkbox" for deactivating it... since I will be using it all the time. If you or someone else wants to do that later that would be cool.

I will also be "switching" some of the modifiers so I can assign the shift key to constraining translation. Since the Lasso won't need a modifier anymore I can use that for either scaling or rotating.

I will be putting in a user definable selection radius. I just have to figure out if I want to leave it as a "world" radius or change it to a "screen" pixel radius.

I am having a similar problem to that pen pressure/freehand tool you did... I think you did that... Zooming out makes my radius really tiny. Zooming in makes it huge. It isn't a huge problem... I have to play with it some more and see if it needs to be changed.

... wait a second... that would be that "WorldToScreen" thingy wouldn't it?

-Vern
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

See the new thread on this tool script here:

http://www.lostmarble.com/forum/viewtopic.php?t=3298

-Vern
Post Reply