How can i get the status of cameratoolbar light?

14 visualizaciones (últimos 30 días)
Dimitrios
Dimitrios el 9 de Feb. de 2012
Comentada: Adam Danz el 6 de Oct. de 2021
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

Respuestas (2)

Sven
Sven el 9 de Feb. de 2012
Editada: Sven el 20 de Ag. de 2013
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 comentario
Sven
Sven el 20 de Ag. de 2013
Dimitros, the question's now been answered... the findall function get there eventually.

Iniciar sesión para comentar.


Dimitrios
Dimitrios el 9 de Feb. de 2012
Hi Sven,
i have tried what you proposed, but the camHandle = findobj(gcf,'Type','light'); call returns an empty handle. I changed the gcf function to my figure handle, but that still does not work. Could it be that my figure is a GUI dialog with several components one of which is also an axes? I find it illogical as the calls to the cameratoolbar() function work correctly.
Nevertheless, thanks for the pointer, i will focus my search in the object finding direction.
regards
Dimitrios
  2 comentarios
Sven
Sven el 9 de Feb. de 2012
Oh... sorry when I tested I must have first run the command "camlight"... I'll get an answer back to you in a couple of minutes...
Sven
Sven el 9 de Feb. de 2012
Hi Dimitrios, I've updated my answer above now.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by