Text Label Along a Path?

Started by Nikolay, February 06, 2015, 07:15:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nikolay

Recently we were discussing here how to make a dynamic connector with label with "snaps" to a connector (see picture)



It looks like it works more or less okay, but it seems that occasionally (?) the marker doesn't snap and runs away.

Now it is "designed" like this:

user moves control point -> Controls.Position -> User.Trigger is triggered (coordinate change)
User.Trigger -> causes recalculation of User.SetPos (which writes nearest point on the path to User.Pos)
Scratch.X1 and Scratch.Y1 are recalculated and set to the new nearest point on the path according to the User.Pos
User.Trigger -> also causes recalculation of User.SetXY which resets the control point position to a point on path.

The shapesheet screenshot and the test drawing are attached (note that it uses Point-path functions, so Visio 2010+)
Maybe somebody could suggest a better approach to the problem?

Visio Guy

#1
One thing that I've discovered doing this type of thing is that you don't need to make the control handle snap to the line.

You can determine if the distance from the control handle to the curve (NEARESTPOINTONPATH) is below a certain tolerance. If so, then pop the text block to the nearest point on the path, but leave the control handle where it is.

It looks like you've got the control handles snapping as well, which involves SETF formula blasting, which I like to avoid as much as possible.

For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Nikolay

#2
Yes, this makes perfect sense! Thanks!

But anyways, just out of the curiosity, is it possible to somehow write the value back to the cell which caused the change (i.e. to the control point)?
The tricky part here may be, when you move a control handle 2 cells are changed at once in fact.. X and Y. Is it possible to set them both on one blast?
I.e. the solution above uses some sort of "workaround" in form of "user.trigger" to trick recalculation..

Maybe there is a straightforward way to do this sort of things?

JuneTheSecond

#3
Ive downloaded your drawing, and tried once, but could not found any problem.
I wish to know when it happens.

By the way, the formulas in Shape Transform section are not familiar to me.
So, I tried to copy your section except Shape Transform on the new free curve.
Now I found the label behavior is somewhat smooth than your original label.

Here is my video in youtube.
http://youtu.be/EyrQ20p8XG8
Best Regards,

Junichi Yoda
http://june.minibird.jp/

Croc

#4
QuoteNow I found the label behavior is somewhat smooth than your original label.
This is the effect of "NoLiveDynamics" cell.

JuneTheSecond

#5
Oh! Exactly.
And I forgot this is a matter of dynamic connector.
Please forget my post.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

Visio Guy

#6
You can use the SETATREF, SETATREFEVAL, SETATREFEXPR functions to do weird things.

1. Formulas with these functions don't get overwritten.
2. SETATREFEXPR holds the actual input value from a UI element, such as Width, Height or Control handle. You can multiply by 0 to ignore it, which is cool.
3. SETATREF can push this value to another cell.

So, check this out: draw a rectangle with one control handle a few user cells.

The control handle will snap to the left or right side of the shape. There are no SETF or "trigger" cells.

Controls.Row_1.X = SETATREF( User.ui, SETATREFEXPR(Width*0.35) )*0+User.uiBoxed

The "Width*0.35" will change as the control handle is dragged. This is the "input from the user", so to speak.

The first half of the formula is multiplied by zero, so the user input is essentially ignored, and replaced by User.uiBoxed.

SETATREF pushes the value to User.ui, which then also changes while the handle is dragged:

User.ui = (Width*0.35)

User.uiBoxed then does the logic of snapping to the left or right side of the shape:

User.uiBoxed = IF(User.ui<Width*0.5,0,Width)

Note, after all this, User.ui will settle to Width*0 or Width*1, so there seems to be a bit of circularity, although Visio doesn't report any circular references when you set the formulae.

It is weird, but it works very nicely!
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Nikolay

#7
Thanks, that really helps!! :)

New version with inspiration from this "weird" SETATREFEXPR (no more SETF)!



Visio Guy

Very nice. There may be even shorter formulas, but I was just whipping up a quick example. Thanks for animating!

The first time I used these formulas was to constrain a control handle to a circle-- probably to make a clock shape or something :)
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Nikolay

About the animation, btw - there is a tiny free tool: http://www.cockos.com/licecap/ which allows to capture gifs very easily.

Also one question - why SETF() + DEPENDSON() is a bad idea? Because it results in heavy useless recalculation, or?

Visio Guy

Well, SETF is probably not so bad, but I don't like to have too much of it in a shape, or if I do use it, I like it to happen at a distinct time, like when a user right-clicks a custom menu item (Action).

I think that when it is used with DEPENDSON, sometimes it causes, like 41 recalculations (Visio stops circular calculations from going on forever). It just gives me a bad feeling, but I don't know the technical reasons in detail. I can't officially say "it's bad", but it does go against the nature of a spreadsheet, and is kind of a hack--although necessary to get shapes to do certain things!
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010