How can i get the status of cameratoolbar light?
16 次查看(过去 30 天)
显示 更早的评论
Hi everybody,
I am using the command cameratoolbar('togglescenelight')
to change the light conditions of my axes. I use this command several times from different control locations in my code and i lose track what state the light is ON or OFF (unless of course i look at the image or use a counter).
I want to know if there is a handle that i can check to find out whether the light in cammeratoolbar is ON or OFF.
best regards
Dimitrios
回答(2 个)
Sven
2012-2-9
编辑:Sven
2013-8-20
Hi Dimitrios,
It seems like they've gone to a lot of trouble to hide the cameratoolbar from programmatic users. cameratoolbar.m is actually a .p file (encrypted), and the uitoolbar that it creates has its own handle, but all of its children (ie, the buttons it has and any lights that it creates) must have their HandleVisibility property set to 'off', because they don't show up via any findobj() call.
I'm not sure that there's a lot to work with here because it seems like any time a user clicks the "Toggle Scene Lighting" button, that action (or the resulting lights that are set to visible/invisible) are untraceable.
If, on the other hand, you never allow the user to click those buttons (ie, if you are calling cameratoolbar('togglescenelight') yourself and the user never sees the actual toolbar) - then yes, I suggest you keep a counter of those calls to cameratoolbar, and that counter will tell you the current state of the lighting.
If you are indeed doing this entirely programmatically, can I suggest using actual lights rather than letting cameratoolbar make its own? The code below uses camlight to add a simple light to a scene (with similar but not identical properties to the default cameratoolbar scene light - as above, they've made these properties entirely hidden), and its state can be readily accessed.
figure
peaks
camHandle = camlight;
Finally, ask whether it's on or off:
set(camHandle,'Visible','off')
set(camHandle,'Visible','on')
Does that do what you wanted?
-- EDITED MUCH MUCH LATER --
Dimitrios, I've found an answer. Here's a short function which will return whether the camera scene light is toggled to on or not:
function camSceneLightOn = isSceneLightOn
camSceneLightOn = false;
cslHandle = findall(gca,'tag','CameraToolBarScenelight');
if ishandle(cslHandle)
camSceneLightOn = strcmp('on',get(cslHandle,'Visible'))
end
1 个评论
Sven
2013-8-20
Dimitros, the question's now been answered... the findall function get there eventually.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!