Borrar filtros
Borrar filtros

how to add listener and action when listener detected

1 visualización (últimos 30 días)
nirit
nirit el 26 de Ag. de 2019
Editada: nirit el 26 de Ag. de 2019
i created a class which plots an image from 3d image matrix [img row size, img cols size , frame num] which have shared data (=staticprop) , shared between all instantes of the class.
this looked something like this:
classdef MyClass < handle
properties (Constant, GetAccess = private)
staticprop = containers.Map; %or just make a lightweight handle class
end
properties
...
currFrameCounter=1
images=[];
...
end
methods
function obj = MyClass(inputFrameCounter,input_images)
obj.images=input_images;
tmp=obj.staticprop;
if isempty(tmp)
tmp('currFrameCounter')=inputFrameCounter;
end
obj.currFrameCounter=inputFrameCounter %% so currFrameCounter will be "local" variable to the instantiation of the class, and
%% staticprop will be shared data to all of the instantiation of myClass.
end
end
function ShowIMG(obj,frame)
tmp=obj.staticprop;
imshow(obj.images(:,:, frame))
end
function keyPressFunc(obj)
%% change "shared" and local currFrameCounter when key pressed
tmp=obj.staticprop;
tmp('currFrameCounter')= some other value , say , tmp('currFrameCounter')+1
obj.currFrameCounter=tmp('currFrameCounter')
ShowIMG(tmp('currFrameCounter')); %%update the figure;
end
end
now I am creating 2 diffrent instantes to the same class, each conatins diffrent images.
I want to add event ( or listenerlistener, I really dont know how it is called) so that every time there is a change in the shared variable " tmp('currFrameCounter')" I will update the figure.
for example, if
a1=MyClass(1,input_images1);
a1.ShowIMG(1);
a2=MyClass(1,input_images2);
a2.ShowIMG(1);
in case i pressed on the "right arrow" of the figure of a1, the a1 figure was updated,
and I want that a2 will be updated automatically (update function will be called).
( this can be detected using the local obj.currFrameCounter. every time obj.currFrameCounter~=tmp('currFrameCounter') I want to call a function which will update my figures. )
can someone provied me with a simple examle?

Respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by