Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11960 > unrolled thread

Locator + EventHandler

Started byAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
First post2012-10-05 06:44 +0000
Last post2012-10-06 08:17 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Locator + EventHandler Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2012-10-05 06:44 +0000
    Re: Locator + EventHandler "Alexander Elkins" <alexander_elkins@hotmail.com> - 2012-10-06 08:17 +0000

#11960 — Locator + EventHandler

FromAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
Date2012-10-05 06:44 +0000
SubjectLocator + EventHandler
Message-ID<k4lvkh$d45$1@smc.vnet.net>
Dear Community,

There is a nice example at Help/EventHandler/Applications that enables one to set points on demand, that are interpolated on the spot. Here is the code:

interpolationCurve[p_, n_] :=
  Module[{x, f = Interpolation[p, InterpolationOrder -> n ]},
   First@Plot[Evaluate@f[x], {x, Min[p[[All, 1]]], Max[p[[All, 1]]]}]];

DynamicModule[{n = 2, p = {}, c = {}},
 EventHandler[
  Dynamic@Graphics[{Point[p], c}, PlotRange -> 1, Frame -> True],
  "MouseDown" :>
   (p = Union[Sort@Append[p, MousePosition["Graphics"]],
      SameTest -> (First[#1] == First[#2] &)];
    If[Length[p] >= n + 1, c = interpolationCurve[p, n]])]]

I am looking for a way to make there locators instead of the points. Technically, it is a combination of Locator, or LocatorPane with the EventHandler.  The idea behind is to be able to not only to set, but also to adjust each point. I tried, but if I succeeded to set locators, they have been motionless.
Have you ideas of how to make this?

Thank you, Alexei


Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu




[toc] | [next] | [standalone]


#11981

From"Alexander Elkins" <alexander_elkins@hotmail.com>
Date2012-10-06 08:17 +0000
Message-ID<k4opds$ip0$1@smc.vnet.net>
In reply to#11960
Here is an example using Locator with Manipulate and
LocatorAutoCreate->True. To use this example, see the help for
LocatorAutoCreate : With LocatorAutoCreate -> True, any Alt + Click that
does not hit an existing locator will cause a new locator to be created at
the position of the click.Alt + Click on an existing locator deletes the
locator.

Manipulate[
If[Length[p] < 2,
Graphics[Point[p], PlotRange -> {{-1, 1}, {-1, 1}}, Frame -> True],
Plot[Evaluate@Interpolation[p, InterpolationOrder -> Length[p] - 1][x], {x,
Min[p[[All, 1]]], Max[p[[All, 1]]]}, PlotRange -> {{-1, 1}, {-1, 1}},
Frame -> True, AspectRatio -> 1]], {{p, {}}, Locator,
LocatorAutoCreate -> True}]

Hope this helps...

"Alexei Boulbitch" <Alexei.Boulbitch@iee.lu> wrote in message
news:k4lvkh$d45$1@smc.vnet.net...
> Dear Community,
>
> There is a nice example at Help/EventHandler/Applications that enables one
to set points on demand, that are interpolated on the spot. Here is the
code:
>
> interpolationCurve[p_, n_] :=
>   Module[{x, f = Interpolation[p, InterpolationOrder -> n ]},
>    First@Plot[Evaluate@f[x], {x, Min[p[[All, 1]]], Max[p[[All, 1]]]}]];
>
> DynamicModule[{n = 2, p = {}, c = {}},
>  EventHandler[
>   Dynamic@Graphics[{Point[p], c}, PlotRange -> 1, Frame -> True],
>   "MouseDown" :>
>    (p = Union[Sort@Append[p, MousePosition["Graphics"]],
>       SameTest -> (First[#1] == First[#2] &)];
>     If[Length[p] >= n + 1, c = interpolationCurve[p, n]])]]
>
> I am looking for a way to make there locators instead of the points.
Technically, it is a combination of Locator, or LocatorPane with the
EventHandler.  The idea behind is to be able to not only to set, but also to
adjust each point. I tried, but if I succeeded to set locators, they have
been motionless.
> Have you ideas of how to make this?
>
> Thank you, Alexei
>
>
> Alexei BOULBITCH, Dr., habil.
> IEE S.A.
> ZAE Weiergewan,
> 11, rue Edmond Reuter,
> L-5326 Contern, LUXEMBOURG
>
> Office phone :  +352-2454-2566
> Office fax:       +352-2454-3566
> mobile phone:  +49 151 52 40 66 44
>
> e-mail: alexei.boulbitch@iee.lu
>
>
>
>
>




[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web