Find custom graphics control object from graphics handle
조회 수: 2 (최근 30일)
이전 댓글 표시
I am trying to implement a controller family, managing gui interaction. My class should replace the standard m-file created when using guide.
Currently the controller class is very simple:
classdef Figure < handle
%FIGURE Summary of this class goes here
% Detailed explanation goes here
properties
gfx
end
methods
function obj = Figure()
% create new figure
obj.gfx = matlab.ui.Figure();
end
end
end
I would now like to add other elements to my figure. Matlab graphics therefore implements a composite pattern which enables adding or removing other matlab.ui elements in a simple fashion, i.e. each element has "Parent" and "Children" references. Moreover this enables travelling up and down the tree representing the structure of the graphical user interface.
At some point I might like to find my corresponding customized controller object. But since the composite is located in matlab.ui, this is not directly accessible.
What is the best solution to achieve this?
Thanks, Daniel
댓글 수: 3
Adam
2017년 1월 27일
If you use savefig and openfig all you are saving and loading is the Matlab figure and its contents. The object of your 'Figure' class is not saved or reloaded at all.
To do this you would need to save it as a .mat file not saving the current figure.
I still don't understand what you define as a 'controller' though. Do you just mean the graphics object? I have various classes containing the word controller, but they contain many functions that I have written that act on figures and their components so the terminology is confusing to me in your case.
If you are referring to your Figure class as the controller then I'm not sure what you mean by 'all controller objects in the subtree' as you only have the one controller, which is your 'Figure' object.
You can access child objects via the usual method of
gfx.Children
and then onwards down the tree from there.
채택된 답변
Steven Lord
2017년 1월 27일
It sounds like you may be trying to do the same type of thing App Designer is doing. You may want to see if that satisfies your needs (or comes close enough that you can use the code it creates as a starting point.)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!