I've been developing a class for a specialized kind of axes. Since we cannot derive classes from the built-in axes class, I have created a handle class that has an associated axes object as one of its properties. Since a figure with one of these specialized axes will be saved in a .fig file rather than a .mat file, I am storing my class properties in the UserData property of the associated axes object. My class constructor will then look for these properties if it is passed a .fig file as in input argument.
Some of my class properties are customized graphics objects, which class methods will expect to see. My problem is that when I attempt to set the value of one of these properties, it deletes all the other UserData fields and replaces all of them with this single value.
Here is a simplified version of what is happening:
Before setting the property for the graphics object I have this:
myAxes.UserData.myClassProperties
where myClassProperties is a struct with a couple dozen fields for the class properties, one of which is called 'EarthPatchHandle'. When I attempt to set that by doing this:
myAxes.UserData.myClassProperties.EarthPatchHandle = surfl(...
All the other fields of myClassProperties disappear, and the only remaining field is EarthPatchHandle.
I suspect that I'm getting into trouble by storing a handle class object as a property of another handle class in the UserData property of another handle class, but I'm not sure about that.
Does anyone have any idea what's wrong with this?
[Note: there might well be a better design for what I'm trying to do, such as storing my full class object in the axes UserData, rather than individual properties. I'll start another question if that seems likely.]