필터 지우기
필터 지우기

wait for colormapeditor to close

조회 수: 5 (최근 30일)
André
André 2018년 4월 18일
편집: Robin Larsson Nordström 2023년 11월 6일
Unfortunately the function colormapeditor doesn't accept output arguments. It happens that I need to freeze the program flow until the dialogue box of the colormap editor closes. I need to retrieve the colormap created here and use it on multiple axes. So I need to wait until the colormap editor finishes its job. Using waitfor(colormapeditor) doesn't work. Anybody knows a workaround for this?
Many thanks
  댓글 수: 1
André
André 2018년 4월 18일
편집: André 2018년 4월 18일
I found a workaround here which I am adopting for now.
Still, I would like a more orthodox way of solving this problem, without forcing the user to make an additional press.

댓글을 달려면 로그인하십시오.

답변 (2개)

Catarina Moura
Catarina Moura 2020년 8월 27일
Hello André,
I don't know if you managed to solve it, but here is my solution to workaround this issue.
I created a button to open colormapeditor. The button callback uses copyUIAxes. Basically, the current plot is copied as a "normal" figure (which is hidden during all process).
app.fig = figure;
app.fig.Visible = 'off';
copyUIAxes(app.UIAxes,app.fig);
colormap(app.fig,originalcolormap); % original colormap is the current colormap
colormapeditor;
I didn't find a good way to update the plot's colormap once the colormapeditor is closed... I tried using a "while" but then the colormapeditor was impossible to acess. However, I have a button "plot". So basically, the user has to click on "plot" button so the colormap updates. I created a private function to return the final colormap from the figure, like this:
figaxes = app.fig.CurrentAxes;
app.currCM = get(figaxes,'colormap'); %global variable to access it in any function of the code
In my case, the user also has the option to choose from MATLAB's colormaps - a drop down menu. So basically I use "clock" to save the time that the colormap was changed (for both colormapeditor button callback and drop down menu callback) and when the user clicks "plot", the times are compared and the most recent is chosen.
Sadly, I could not find a way to update the plots with the new colormap automatically.
  댓글 수: 1
y C
y C 2022년 3월 3일
Hello Catarina Moura :
I found sometimes my coloemapeditor become larger,and I can't change its size,I click it one time ,it bacome larger than before,I tried to reopen matlab ,but it don't work.sometimes coloemapeditor functions well,but everytime this problem happens,I don't know how to deal it.
Thanks a lot

댓글을 달려면 로그인하십시오.


Robin Larsson Nordström
Robin Larsson Nordström 2023년 11월 6일
편집: Robin Larsson Nordström 2023년 11월 6일
Hi,
Adding a listener for the colormapeditor event EditorClosed works in 2023b (undocumented feature, so might stop working in a later release).
Code below opens the colormapeditor pointing to the current axes. When closed it retrives the user selected colormap and updates all axes in the current figure with the selected colormap using an anonymous function.
h_currentFigure=gcf;
h_currentAxes=gca;
colormapeditor(h_currentAxes);
cme=getappdata(0,'CMEditor');
addlistener(cme.ColormapEditor,'EditorClosed',@(src,event)colormap(h_currentFigure,colormap(h_currentAxes)));
If you need the program to wait this could be done by adding another listener with the callback uiresume and then calling uiwait to make the program pause until the user have closed the colormapeditor.
colormapeditor;
cme=getappdata(0,'CMEditor');
addlistener(cme.ColormapEditor,'EditorClosed',@(src,event)uiresume);
disp(string(datetime("now")) + ' colormapeditor opened')
uiwait % pause program, wait for callback uiresume
disp(string(datetime("now")) + ' colormapeditor closed')

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by