This post in reply to the Question, Duplicating Mathematica's Locator

 

The Locator object is a nice piece of Mathematica's Manipulate command's functionality. Perhaps Maple's Explore command could do something as good.

Here below is a roughly laid out example, as a Worksheet. Of course, this is not using Explore. It's a prebuilt example, as a set of Standard GUI Components. But in principle there's no reason why the dynamic supporting procedures and various constructor procedures that could build such a Component assembly couldn't be part of a runtime suite of an enhanced Explore module/package.

A programmatic suite of constructors and runtime support procedures would needed in order to handle the set of names of the various GUI Components assembled together. Getting the Components' names (and their name's references in the code) all correct and consistent would be an interesting challenge. An end-goal would be to allow a multiple number of distinct assemblies like this to coexist in the same Worksheet or Document. (There are some intriguing pieces of new functionlity in Maple 16 which might be leveraged, but that deserves another post.)

(Sorry, the view of the worksheet embedded into Mapleprimes below does not look as good as the linked Worksheet. Actually, the GUI table's right column isn't displayed authentically at all. Screenshorts after export to html or pdf aren't perfect either. Please see the link to the worksheet.)

[edited: I've made some changes, so that the action doesn't break when dragging is done quickly. And now the default manipulator for the plot component is saved as "Click and Drag" and doesn't need to be manually set. I've added a second example, using the `odeplot` command and dsolve/numeric, with parameters for the initial conditions set by the locators. It flashes a bit in Maple 15, but is much smoother in Maple 16.]

 

restart:

1) Begin by assigning some entries to the table _Locator.

    See example below.

    Don't have gaps in the indexing by positive integers.

2) Assign an unevaluated command to _cmd, which will produce

    some plot object when evaluated.  See example below.

 

3) Press the Refresh button.

4) Drag the red circle manipulators.

 

 

 

_Locator[1]:=[0,0]:  _Locator[3]:=[1,0]:   _Locator[4]:=[1,1]:
_Locator[5]:=[0,1]:  _Locator[2]:=[1,-1]:

_cmd:='plots:-polygonplot([seq(_Locator[i],
                           i=1.._N)],
                          'view'=[-2..2,-2..2])':

 

   
 

 

     

 

 

 

 

 

 

 

Here is another example, illustrating the general purpose quality of the assembly of GUI components and the underlying code.

 

Execute these next sections, and then press the Refresh button once again.

 

 

desys:=diff(H(tau), tau)=-(1-H(tau)^2)*(1.995000000*Sigma(tau)^2
       +0.50000000e-2-H(tau)*Sigma(tau)),
       diff(Sigma(tau), tau)=-(1.995000000-1.995000000*Sigma(tau)^2)
       *H(tau)*Sigma(tau)-(1-H(tau)^2)*(1-Sigma(tau)^2)-11.97000000
       +11.97000000*Sigma(tau)^2:

ZZ := dsolve([desys, H(0) = P1, Sigma(0) = P2], [H(tau), Sigma(tau)],
             parameters=[P1,P2], 'numeric'):

master:=subs(dummy=eval(ZZ),
             proc(L) dummy('parameters'=['P1'=L[1],'P2'=L[2]]);
                     dummy; end proc):

_Locator:='_Locator':
_Locator[1]:=[4.0,-0.5]: _Locator[2]:=[6.0,-0.5]: _Locator[3]:=[8.0,-0.5]:

_cmd:='plots:-display(

          seq(plots:-odeplot(master(_Locator[i]),

                         [H(tau),Sigma(tau)],-1..1, color="DarkBlue",

                         'numpoints'=500,'thickness'=1), i=1.._N),

          plots:-fieldplot(subs(H(tau)=x,Sigma(tau)=y,

                          eval([diff(H(tau),tau),diff(Sigma(tau),tau)],

                               [desys])),

                     x=1..15,y=-1.1..1.1,

                     'fieldstrength'='fixed','grid'=[30,30]),

                      view=[1..10,-1..1],'axes'='box')':

 

 

Download locator2.mw

 

Comments and suggestions about functionality are welcome. But I already know that the layout is rough.

acer


Please Wait...