Code covered by the BSD License  

Highlights from
Drag Patches Demo

5.0

5.0 | 3 ratings Rate this file 16 Downloads (last 30 days) File Size: 1.67 KB File ID: #17917
image thumbnail

Drag Patches Demo

by

 

06 Dec 2007 (Updated )

shows how to create patches that can be clicked and dragged around

| Watch this File

File Information
Description

This m-file demonstrates how to create patches that can be moved around when they are clicked on.

This functionality is ideal for interactive GUIs. For example, anyone who wants to write code for a board game with moving pieces could use this as a starting point.

MATLAB release MATLAB 7.3 (R2006b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
20 Jan 2014 Xiaoxi  
27 Oct 2010 Iacopo Mochi  
09 Jan 2009 Paul Foxgrover

Very helpful! Thanks you very much!

10 Dec 2007 V P

Indeed, a canon called "WindowButtonMotionFcn" is able to kill any of several numbered in advance sparrows fixed at canon barrel. However, a more flexible tool, "moverotateobj" was published earlier.

Some remarks:
1. If I plot several patches, last plotted is usually in the upper layer. If I move patches by drag_patch, in fact I am plotting them anew. However, they do not appear as upper objects, and this is not consistent.

2. If I have many graphical objects, which are not in advance labeled by UserData, drag_patch will not work. This labeling is not always possible, e.g. if some object is added after creation of patches is finished. Moreover, any labeling in advance is not neseccary.

3. Moverotateobj works with line, patch and text objects, and drag_patch can be applied only to patch or line.

4. If you open FigurePalette, you can drag and rotate line and arrows, and drag and modify rectangle and ellipse (probably, in releases after R14 you can more). I do not know exactly whether there is a trick to drag and rotate user-plotted objects using FigurePalette options.

5. The file is not correctly called, because "drag" means that you press button, move the cursor and after button release the dragging is finished. With drag_patch, you have to click once more to finish.

6. So what's really new?

Questions to those who uses latest ML releases.

1. I should expect that any object in plane should be easily dragged and rotated as a standard option, because this (and more) is asked in practice. Is this still not the case?

2. Rectangle and ellipse from FigurePalette do not have Xdata and Ydata, as patch and line do. In addition they have no Rotation property. Is it reasonable to use special class of objects which is less general than existing standard line, patch or text?

This is not any criticism of drag_patch. I have my own versions of drag, rotate, explode etc., but I have expected to find something more flexible.

Contact us