Mon 12 Jul 2010 07:34:55 PM UTC, comment #1:
Why can't we have Octave style properties added to the base properties and setappdata/getappdata properties as well. For example with the functions
function setappdata (h, name, val)
addproperty (name, h, "any", val);
endfunction
function x = isappdata (h, name)
x = any (strcmp (name, fieldnames (getappdata (h))));
endfunction
function rmappdata (h, name)
## FIXME Need to write this function in graphics.cc
delproperty (h, name);
endfunction
and then add the code
DEFUN (getappdata, args, , "there's no help for the wicked")
{
int nargin = args.length ();
octave_value retval;
if (nargin != 1 || nargin != 2)
print_usage ();
else
{
double h = args(0).double_value ();
if (! error_state)
{
graphics_handle gh = gh_manager::lookup (h);
if (gh.ok ())
{
graphics_object go = gh_manager::get_object (gh);
if (nargin == 1)
retval = go.get_properties ().get_dynamic ();
else
{
std::string name = args(1).string_value ();
if (! error_state)
retval = go.get_properties ().get_dynamic (name);
}
}
}
}
}
to src/graphics.cc. In this manner you could keep the old behavior and be compatible with matlab. If you want to get fancy you could do it all in graphics.cc, or at least the isappdata function as this could be more efficient as a DEFUN in graphics.cc.
For the fact the the appdata of the axes holds the data for the matlab line color, style and the hold style, this is undocumented and we shouldn't rely on it and don't need to implement it in the same fashion. Unless you're telling me its common knowledge and many people in the matlab world rely on this behavior..
As for the COM versions of addproperty, I say tough luck.
D.
|