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.

I understand how I can select a bookmark from the "+" menu of a Manipulate. Is there a way to select a bookmark from an arbitrary control, or define a control that implements bookmark functionality?

For example, if I have something like

Manipulate[{x, y, z},
 {x, 0, 10}, {y, 0, 10}, {z, 0, 10},
 Bookmarks -> {"Center" :> {x = 5, y = 5, z = 5},"Zero" :> {x = 0, y = 0, z = 0}}]

Can I add a control that does the same thing as selecting the bookmark from the menu? For example, can I add something similar to {preset, {"Center", "Zero"}}, to create something that looks like

enter image description here

where choosing one of the setters performs assignments to collections of Manipulate variables?

Specifically: is there

  1. a way to implement bookmark-like functionality by specifying a control that sets several Manipulate variables at once; is there
  2. a way to explicitly select a bookmark from an arbitrary control (e.g. is there something like an"SelectBookmark[bookmark]")?

I'd have thought that

Manipulate[{x, y, z}, {x, 0, 10}, {y, 0, 10}, {z, 0, 10},
 {{preset, 
   Which[# === "Center", (x = 5; y = 5; z = 5),
         # === "Zero",   (x = 0; y = 0; z = 0)] &}, {"Center", "Zero"}}]

would at least achieve (1), but it has no apparent effect; I see no way to do (2).

share|improve this question
2  
This needs some more thought but the dynamic values of the bookmarks can be displayed: Manipulate[Column[{Dynamic@Typeset`bookmarkList,{x, y, z}}],{x, 0, 10},{y, 0, 10},{z, 0, 10},Bookmarks -> (opts = {"Center" :> {x = 5, y = 5, z = 5},"Zero" :> {x = 0, y = 0, z = 0}})] so the task is how to convert that information into a dynamic setterbar. –  Mike Honeychurch Dec 7 '12 at 22:23
    
@NasserM.Abbasi: Yes, that would be relevant to (1). I've extended the question accordingly. –  raxacoricofallapatorius Dec 8 '12 at 17:47
add comment

1 Answer

Will this work for you? (I did this with radio button bar. I like to do this myself with pulldown menu. But the idea is the same)

Manipulate[
 {x, y, z},

 (*controls*)
 {x, 0, 10},
 {y, 0, 10},
 {z, 0, 10},

 (*bookmark control*)
 Grid[{
   {Style["bookmarks", Bold],
    RadioButtonBar[Dynamic[bookMark, {bookMark = #;

        Which[
         bookMark == "center", x = 5; y = 5; z = 5,
         bookMark == "zero", x = 0; y = 0; z = 0
         ]

        } &], {"center", "zero"}, Appearance -> "Horizontal"]

    }}, Spacings -> {.5, 1}, Frame -> True, 
  FrameStyle -> Directive[Thickness[.005], Gray]],

 {{bookMark, "zero"}, None}     
 ]

enter image description here

share|improve this answer
    
Why doesn't my approach to (1) work? In particular, I'm confused about the difference between {{preset {preset = #; Which[preset === "Center", (x = 5; y = 5; z = 5), preset === "Zero", (x = 0; y = 0; z = 0)]} &} and Dynamic[bookMark, {bookMark = #; Which[bookMark == "center", x = 5; y = 5; z = 5, bookMark == "zero", x = 0; y = 0; z = 0]} &], {"center", "zero"}]. –  raxacoricofallapatorius Dec 8 '12 at 19:02
    
I've suggested an edit to a form that parallels the form in the question, to focus on this aspect. I'd have thought that the approach I tried to do (1) in the question would have had the same effect, since the documentation for Manipulate says: "In the form {u,func}, Dynamic[u] is given as the first argument to func."; but there's something about either Manipulate or Dynamic I'm not grasping here. –  raxacoricofallapatorius Dec 8 '12 at 20:45
    
What happens when you add another bookmark after clicking "+"? I assumed what he was after was something that dynamically reads stored bookmarks? –  Mike Honeychurch Dec 9 '12 at 0:35
add comment

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.