Suppress Callbacks From Firing During Model Comparison
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Hi all. I'm trying to figure out a way to surpress callbacks from firing during a model comparison? Or maybe a better question is if there is a way to check if a model comparison is being done.
Background: Our models have a callback (call it model resize) in them that finds the size of the primary monitor and will resize the model's window to an approprate size based on the monitor size, when the model is first opened. Well, when you use Matlab's comparison tool to compare the two different models, the model resize call back fires and overrides where the comparison tool puts the two model windows (upper right corner and lower right corner). I am hunting for a way to prevent this specific call back from firing. Any ideas? I can't really post a good example of it due to working restrictions.
댓글 수: 8
Walter Roberson
2018년 12월 7일
perhaps have the callback check aa variable, perhaps an environment variable, to see if the resize should be skipped ? and have aa small routine that sets the variable and runs the comparison and resets afterwards ?
Richard Hopple
2018년 12월 7일
Fangjun Jiang
2018년 12월 7일
It sounds like the model resize function is put in the "InitFcn" callback. I think it could be put in the "PreLoadFcn" callback based on your description of the function. Of course, I don't know the reason why it needs to be called when the user mannually pushes the "Model Update" button.
Richard Hopple
2018년 12월 7일
Walter Roberson
2018년 12월 7일
%inside callback
% if isempty(getenv('SKIP_MODEL_RESIZE'))
.... do the resize
end
together with
function compare_models(model1, model2)
cleanMe = onCleanup(@() setenv('SKIP_MODEL_RESIZE', ''));
setenv('SKIP_MODEL_RESIZE', 'Y')
visdiff(model1, model2)
end
Richard Hopple
2018년 12월 10일
Walter Roberson
2018년 12월 10일
편집: Walter Roberson
2018년 12월 14일
...so don't use the gui compare button ? ;)
Looking at the call stack might work, but there is a tendency to lose the call stack for callbacks which are eval() automatically because of button presses in the MATLAB gui.
Richard Hopple
2018년 12월 14일
답변 (0개)
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!