xfigure
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | xfigure [2011/04/04 18:27] (current) – created jochen | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== xfigure (class for UI object handling) ====== | ||
+ | |||
+ | ===== Motivation ===== | ||
+ | When I started writing Matlab code for handling UI events (using Matlab R11), I noticed that certain tasks were not at all easy to accomplish and that using the built-in figure editor was a bit cumbersome (for me, at least). I thus decided to come up with a set of functions that would manipulate Matlab' | ||
+ | |||
+ | Major features include: | ||
+ | |||
+ | * figure definitions (type, position and extended properties of controls and menus) can be stored in human-readable text files (see [[tfgparse]] for more information), | ||
+ | * properties can be read out and written to using the struct notation (see [[@xfigure/ | ||
+ | * groups of uicontrols and uimenus can be set enabled/ | ||
+ | * groups of uicontrols can be moved with one single call (see [[xfigure.SlideGroupXY]] method) | ||
+ | * uicontrols can be put on " | ||
+ | * groups of uicontrols with '' | ||
+ | * content of fields (edit fields, checkboxes, etc.) can be " | ||
+ | * multi-string uicontrols (listbox) have extended syntax available (e.g. to splice the content, move the selected portion, etc.) | ||
+ | |||
+ | ===== Reference ('help xfigure' | ||
+ | < | ||
+ | |||
+ | This class handles MATLAB' | ||
+ | Returned | ||
+ | objects can have a subtype of either | ||
+ | |||
+ | -> ROOT (the factory itself, corresponds to MATLAB handle 0) | ||
+ | -> Figure | ||
+ | -> UIControl | ||
+ | -> UIMenu | ||
+ | -> UIContextMenu | ||
+ | |||
+ | The following constructors are available: | ||
+ | |||
+ | xfigure | ||
+ | xfigure(matlabhandle [, ' | ||
+ | xfigure(objecttype, | ||
+ | xfigure(filename [, options]) | ||
+ | xfigure(objecttag) | ||
+ | |||
+ | For better object access, the struct notation | ||
+ | |||
+ | uiobject.Property | ||
+ | |||
+ | is implemented for both reading/ | ||
+ | |||
+ | Note: due to a MATLAB restriction of a maximum length for variable | ||
+ | names (31 characters), | ||
+ | |||
+ | ===== subsref overloading ===== | ||
+ | Just as with the [[xff]] class, fields of Matlab handles (e.g. the '' | ||
+ | |||
+ | <code matlab xfigure_struct_overload.m> | ||
+ | set(checkbox, | ||
+ | |||
+ | % xfigure way | ||
+ | checkbox.Value = 1 - double(checkbox.Value > 0);</ | ||
+ | |||
+ | ===== Object sub-types ===== | ||
+ | There are a few important differences to be aware of when working with xfigure objects. First of all, there are the five different major sub-types of objects: | ||
+ | |||
+ | * sub-type ROOT object (which represents handle 0, is unique and can not be deleted/ | ||
+ | * sub-type figure objects (which represent handles of '' | ||
+ | * sub-type uicontrol objects (which represent handles of '' | ||
+ | * sub-type uimenu objects (which represent handles of '' | ||
+ | * sub-type uicontextmenu objects (which represent handles of '' | ||
+ | |||
+ | ==== ROOT object ==== | ||
+ | A reference to the (unique, singleton) ROOT object can be created by calling xfigure without arguments (comparable to the [[xff]] class): | ||
+ | |||
+ | <code matlab xfigure_rootref.m> | ||
+ | xfig = xfigure;</ | ||
+ | |||
+ | With that object, one important method, '' | ||
+ | |||
+ | <code matlab xfigure_root_daf.m> | ||
+ | xfig.DeleteAllFigures;</ | ||
+ | |||
+ | And naturally, ROOT properties (such as '' | ||
+ | |||
+ | ==== figure objects ==== | ||
+ | First of all, a figure object can be created by passing a valid TFG filename (see [[tfgparse]] for more information) as argument to the ROOT object: | ||
+ | |||
+ | <code matlab xfigure_createfigfromfile.m> | ||
+ | tdclient_ui = xfigure([neuroelf_path '/ | ||
+ | |||
+ | And figure properties can then be set (and read out) via the struct notation: | ||
+ | |||
+ | <code matlab xfigure_setfigvisible.m> | ||
+ | tdclient_ui.Position(1: | ||
+ | |||
+ | Additionally, | ||
+ | |||
+ | <code matlab xfigure_figuremethods.m> | ||
+ | tdclient_ui.SetGroupEnabled(' | ||
+ | |||
+ | % hide a group of controls (as an example, the figure lacks the group!) | ||
+ | tdclient_ui.SetGroupVisible(' | ||
+ | |||
+ | % setting the first of a group of radio buttons to be selected | ||
+ | tdclient_ui.RadioGroupSetOne(' | ||
+ | |||
+ | % " | ||
+ | tdclient_ui.SlideGroupXY(' | ||
+ | |||
+ | % delete (close) the figure | ||
+ | tdclient_ui.Delete;</ | ||
xfigure.txt · Last modified: 2011/04/04 18:27 by jochen