4
$\begingroup$

How can I achieve that the points on a Graphics element could be manipulated both by Locators (clicking and moving) and on the Manipulate panel as well.

As you can see, only one of the methods work. In this example only pt1 appears on the Manipulate panel.

So any ideas?

Here's my code:

Manipulate[ Graphics[{Polygon[{pt1, pt2, pt3}]}, PlotRangeClipping -> False, Frame -> True, PlotRange -> {{0, 10}, {0, 10}}], {{pt1, {0, 0}}}, {{pt2, {0, 1}}, Locator}, {{pt3, {1, 1}}, Locator}] 

loc1

$\endgroup$
1
  • $\begingroup$ I missed the Locator statement to show that if I miss it, pt1 appears in the manipulate bar $\endgroup$ Commented May 10, 2015 at 11:01

2 Answers 2

8
$\begingroup$

You can attach multiple controls to a variable:

Manipulate[Graphics[{Polygon[{pt1, pt2, pt3}]}, PlotRangeClipping -> False, Frame -> True, PlotRange -> {{0, 10}, {0, 10}}], {{pt1, {0, 0}}}, {{pt2, {0, 1}}}, {{pt3, {1, 1}}}, Row[{Control@{{pt1, {0, 0}}, {0, 0}, {10, 10}, Slider2D}, Control@{{pt2, {0, 1}}, {0, 0}, {10, 10}, Slider2D}, Control@{{pt3, {1, 1}}, {0, 0}, {10, 10}, Slider2D}}, Spacer[5]], {{pt1, {0, 0}}, Locator}, {{pt2, {0, 1}}, Locator}, {{pt3, {1, 1}}, Locator}] 

enter image description here

$\endgroup$
3
  • $\begingroup$ Recommend that you add Appearance -> "Labeled" to each Slider2D. $\endgroup$ Commented May 10, 2015 at 12:41
  • $\begingroup$ @BobHanlon, from your comment, I gather Slider2D finally got the Appearance option in Version 10. In version 9, the option Appearance is not supported. I am using the free cloud version of Version 10, where neither Locator nor Slider2D works. I would be curious to see the how the Labeled Slider2D` looks/works. $\endgroup$ Commented May 10, 2015 at 12:54
  • $\begingroup$ demonstrated in my "extended comment" $\endgroup$ Commented May 10, 2015 at 13:04
3
$\begingroup$

This is not an answer but rather an extended comment to @kguler to demonstrate Appearance -> "Labeled" with Slider2D in version 10.1

$Version 

"10.1.0 for Mac OS X x86 (64-bit) (March 24, 2015)"

Using @kguler answer

Manipulate[ Graphics[{Polygon[{pt1, pt2, pt3}]}, PlotRangeClipping -> False, Frame -> True, PlotRange -> {{0, 10}, {0, 10}}], {{pt1, {0, 0}}}, {{pt2, {0, 1}}}, {{pt3, {1, 1}}}, Row[{ Control@{{pt1, {0, 0}}, {0, 0}, {10, 10}, Slider2D, Appearance -> "Labeled"}, Control@{{pt2, {0, 1}}, {0, 0}, {10, 10}, Slider2D, Appearance -> "Labeled"}, Control@{{pt3, {1, 1}}, {0, 0}, {10, 10}, Slider2D, Appearance -> "Labeled"}}, Spacer[5]], {{pt1, {0, 0}}, Locator}, {{pt2, {0, 1}}, Locator}, {{pt3, {1, 1}}, Locator}] 

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.