How to use multiple listeners on one axis?

2 ビュー (過去 30 日間)
Steven
Steven 2012 年 5 月 30 日
This question concerns how to have multiple listeners attached to a single object. I'm not sure if it is possible(!), but if it is not I'd be really happy to receive some suggestions on alternative approaches.
I have a function that draws a plot with a single line. I have set up a listener on that axis that 'listens' to changes in the camera properties. The callback (@local_cameraMoved) is a nested function that adjusts the X/Y/ZData of the line:
propNames = { 'CameraPosition','CameraTarget','CameraViewAngle' };
hListener = addlistener(dotAx, propNames,'PostSet',@local_cameraMoved);
setappdata(dotAx, 'listeners', hListener);
Next, I have a class set up that is able to receive an axis as an argument. This axis could be any figure, but if it is an axis that has a listener setup, I want that listener to continue to function. The problem seems to be that in the class, I define another listener again for the current axis camera properties. This listener calls a method of the class to do its thing:
hVA.AxisListener = addlistener(hAx, propNames,'PostSet',@cameraMoved);
Why do this? The class provides general functionality that modifies a plot based on the camera position, such that part of the plot appears to stay fixed in space (it's coordinates are changed) whilst another part appears to move in space. This works for patches, surfaces and lines in the figure.
The specific functionality provided by the listener set up in the first function alters the appearance of the line based on the camera position. It essentially makes it bigger or smaller. I don't want to write this into the class, in the sense of cohesion because it is specific to one figure and not applicable to any other line in any other figure (--AIM--).
What I'm wondering is if something like this is possible - which means I'm almost there - or if I should be pursuing the above aim from some other direction?
Thank you in advance for your help.
Best wishes
Steven

回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by