Author Topic: Text Label Along a Path?  (Read 8720 times)

0 Members and 1 Guest are viewing this topic.

Nikolay

  • Hero Member
  • *****
  • Posts: 764
    • UnmanagedVisio
Text Label Along a Path?
« on: February 06, 2015, 02:15:41 PM »
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?
« Last Edit: February 09, 2015, 10:33:14 AM by Visio Guy »

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1613
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Text Label Along a Path?
« Reply #1 on: February 06, 2015, 04:44:01 PM »
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.

« Last Edit: February 09, 2015, 10:33:30 AM by Visio Guy »
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

  • Hero Member
  • *****
  • Posts: 764
    • UnmanagedVisio
Re: Text Label Along a Path?
« Reply #2 on: February 06, 2015, 06:04:15 PM »
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?
« Last Edit: February 09, 2015, 10:33:38 AM by Visio Guy »

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1023
    • Visio Shapes, Stencils and Sample Drawings
Re: Text Label Along a Path?
« Reply #3 on: February 07, 2015, 11:51:52 PM »
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
« Last Edit: February 09, 2015, 10:33:43 AM by Visio Guy »
Best Regards,

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

Croc

  • Full Member
  • ***
  • Posts: 148
Re: Text Label Along a Path?
« Reply #4 on: February 08, 2015, 03:48:43 AM »
Quote
Now I found the label behavior is somewhat smooth than your original label.
This is the effect of "NoLiveDynamics" cell.
« Last Edit: February 09, 2015, 10:33:53 AM by Visio Guy »

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1023
    • Visio Shapes, Stencils and Sample Drawings
Re: Text Label Along a Path?
« Reply #5 on: February 08, 2015, 05:36:55 AM »
Oh! Exactly.
And I forgot this is a matter of dynamic connector.
Please forget my post.
« Last Edit: February 09, 2015, 10:33:48 AM by Visio Guy »
Best Regards,

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

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1613
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Text Label Along a Path?
« Reply #6 on: February 09, 2015, 04:58:00 AM »
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!
« Last Edit: February 09, 2015, 10:34:01 AM by Visio Guy »
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

  • Hero Member
  • *****
  • Posts: 764
    • UnmanagedVisio
Re: Text Label Along a Path?
« Reply #7 on: February 09, 2015, 10:02:18 AM »
Thanks, that really helps!! :)

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


« Last Edit: February 09, 2015, 10:34:10 AM by Visio Guy »

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1613
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Text Label Along a Path?
« Reply #8 on: February 09, 2015, 10:32:52 AM »
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

  • Hero Member
  • *****
  • Posts: 764
    • UnmanagedVisio
Re: Text Label Along a Path?
« Reply #9 on: February 09, 2015, 11:15:18 AM »
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 1613
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Text Label Along a Path?
« Reply #10 on: February 09, 2015, 11:26:05 AM »
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