Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Background: I want to split graphics in a Manipulate in several parts in a tabview control. But the tabview somehow interferes with the locators as in the following simplified example:

 Manipulate[
  TabView[{aa -> Graphics[Line[{{0, 0}, p}], PlotRange -> 1], 
    bb -> 1}] , {{p, {1, 1}}, Locator}]

Question: How to use Locators on a graphic in a tabview. ( How to get the snippet above working ? )

EDIT:

I left out too much in the previous example, this is a better description.

  Manipulate[
   pts1 = pts;
  TabView[{
    a -> Graphics[Line[pts1]],
    b -> Graphics[Line[pts]]}],
  {{pts, ptsI}, Locator, LocatorAutoCreate -> All}, 
  Initialization -> {pts = {{0, 0.5}, {0, 0.6}}}]

So, there is one set of data, in this example pts. In one part of the display (A) the data is modified, the data is then shown on ( B ). -

share|improve this question

3 Answers 3

up vote 12 down vote accepted

Maybe something like

Manipulate[pts1 = p; pltrng = {{-1, 1}, {-1, 1}};
pnts = LocatorPane[Dynamic[p, {(pts1 = p; p = #) &, (p = #) &}],
Dynamic@Graphics[Point[p], PlotRange -> pltrng], 
LocatorAutoCreate -> True];
tbl = Dynamic[Grid[Table[With[{i = i}, {i, Dynamic[pts1[[i]]]}], {i, Length@pts1}]]];
ln = Dynamic@  Graphics[{Red, Thick, Line[pts1]}, PlotRange -> pltrng]; 
bzc = Dynamic@ Graphics[{Blue, BezierCurve[pts1]}, PlotRange -> pltrng];
dsk = Dynamic@ Graphics[{Orange, Disk[#, .1] & /@ pts1}, PlotRange -> pltrng];
plygn = Dynamic@ Graphics[{Green, Polygon[pts1]}, PlotRange -> pltrng];
allviews =  Grid[{{pnts, tbl, dsk}, {ln, bzc, plygn}}, Dividers -> {All, All}];
TabView[{"locators" -> pnts, "table" -> tbl, "line" -> ln, "beziercurve" -> bzc, "disks" -> dsk, "polygon" -> plygn, "all" -> allviews}, Alignment -> Center], 
{{p, {{-.5, -0.5}, {-.25, .5}, {.6, 0.6}}}, None}]

Screenshots:

enter image description here

enter image description here

enter image description here

share|improve this answer
    
Very nice! I think this is exactly what he had in mind. However, the LocatorAutoCreate doesn't work as expected for me... Instead of creating a new one, it simply moves the previously selected one. –  rm -rf May 14 '12 at 2:45
    
@R.M Works OK for me. Remember to press "Alt - Mouse Click" instead of just "Mouse Click" to create a Locator –  belisarius May 14 '12 at 3:49
    
@R.M and belisarius thank you for the votes. I had to change the setting for LocatorAutoCreate to True from All in OP's question. With this setting, as belisarius notes, one needs to use Alt-Click to create a new locator. –  kguler May 14 '12 at 4:24
    
@belisarius Ah, thanks. Cmd-click for me. Indeed, it was because of what kguler says in his comment... I tried the OP's code which had All and created locators with a simple click and tried that here too :) –  rm -rf May 14 '12 at 4:30
1  
@ndroock1, glad it worked for you. –  kguler May 14 '12 at 6:31

You can move the TabView outside the Manipulate and it works:

TabView[{
    aa -> Manipulate[Graphics[Line[{{0, 0}, p}], PlotRange -> 2], {{p, {1, 1}}, Locator}], 
    bb -> 1}
]

enter image description here enter image description here

share|improve this answer
    
Damn ... by 10 seconds :) –  belisarius May 13 '12 at 18:58
    
@belisarius :-D –  rm -rf May 13 '12 at 18:59
    
I have Manipulates per tabview at the moment and that causes a lot of sync problems. –  ndroock1 May 13 '12 at 19:03
    
@ndroock1 I don't quite understand what you mean by "manipulates per tabview" –  rm -rf May 13 '12 at 19:04
    
@R.M - Like TabView[a->Manipulate[],b->Manipulate[],...] that works somewhat with an outer Manipulate but it is infact a workaround for the problem proposed in this question. –  ndroock1 May 13 '12 at 20:54

One way to get it working is to do something like

Manipulate[TabView[{
   aa -> LocatorPane[Dynamic[p], Dynamic@Graphics[Line[{{0, 0}, p}], PlotRange -> 1]], 
   bb -> 1}], 
 {{p, {1, 1}}, None}]
share|improve this answer
1  
This one has the additional benefit of allowing the usage of Dynamic[p] on the second tab –  belisarius May 13 '12 at 19:05
    
This works Heike, it may or may not be a solution to my problem but it definitely gives me something to study and work on. I just need a LOT of screen real estate to display graphics and manipulate it with controls. The best way to handle this is with tabs in my opinion and a lot of programs work like that. –  ndroock1 May 13 '12 at 19:09
    
I have edited ( improved ) the question. Your solution did not work ( immediately ) but I am still working with your idea. –  ndroock1 May 13 '12 at 19:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.