pnty, pntx
are not scoped. If many instances of your gui share them, change in any will trigger each other resulting in a loop.
You can scope it as follows:
DynamicModule[{pnty, pntx}, Manipulate[...
But this makes the performance of Locators really bad. I don't know why but it should not happen.
Manipulate
is a big black box, I don't think there is a point in spending time investigating that issue. For more complicate case you can rewrite everything as DynamicModule
and for less, like here, we can scope pnty
in Manipulate
itself with {pnty, None}
variable spec, see more in:
What does None mean in a control specification for Manipulate?
GraficoSeno[] := {Manipulate[
Graphics[
{ {Red, Circle[]}
, {Thick, Dynamic @ Line[{{0, 0}, pt}]}
, {Dynamic @ Point[{{0, 0}, {0, pnty}}]}
, {Dynamic @ Point[{{0, 0}, {pntx, 0}}]}
, {Thick, Blue, Dynamic @ Line[{{0, 0}, {0, pnty}}]}
, {Thick, Blue, Dynamic@Line[{{pntx, 0}, pt}]}
}
, Axes -> True
, PlotRange -> 3/2
]
, {{pt, {1, 1}/Sqrt[2]}, Locator, TrackingFunction -> ((pt = Normalize[#]; {pntx, pnty} = pt) &)}
, {pntx, None}
, {pnty, None}
, ContentSize -> {300, 300}
]}
p.s. I've moved pntx
to the TrackingFunction
, as well as I've added Dynamic
inside Graphics
, this way the whole Graphics
does not have to be recreated when you move controllers. See e.g.:
https://mathematica.stackexchange.com/a/143939/5478