How do you get an impoly class object from its handle?
Mostrar comentarios más antiguos
I created impoly objects with impoly. Their tag is impoly. At some later point I want to get all the properties of all the created impolys. I can use findall on a Tag of impoly but that apparently just returns the handles as opposed to the class objects. I know this because when I try calling the impoly methods (e.g. getColor) on a returned handle it barfs because the handle, which is a double, isn't an impoly class object. Calling impoly on the class does not cast it.
I could store the objects when they are created to work on them later but they user might delete them etc. In any even it seems silly to do that.
=
specifics: On my gui a botton links to a callback which calls impoly. impoly returns an impoly object that the impoly members can operate. Eg h=impoly(axeshandle) setColor(h,'red');
When the user clicks my "Save" button, another callback is called and in that I use a H=findall(axeshandle, 'Tag', 'impoly') to find and return all the polygons. However, H is all double type graphics handles and so a call like GetColor(H(1)) will fail with the error :
Conversion to double from cell is not possible.
Respuestas (2)
Andrew Diamond
el 5 de Jun. de 2012
5 votos
3 comentarios
Jonathan
el 8 de Feb. de 2013
Never would have figure this out.. thanks!
Slim
el 31 de Mayo de 2015
Works great ! Thanks a lot !
Image Analyst
el 31 de Mayo de 2015
"I simply can't believe what it took to find this out." - probably because hardly anyone ever does that, and if they did, they'd just save the poly objects in a cell array if they knew they'd need them later.
Walter Roberson
el 5 de Jun. de 2012
imh = handle(h);
imh.setColor('red');
1 comentario
Andrew Diamond
el 5 de Jun. de 2012
Categorías
Más información sobre Data Type Identification en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!