Bonjour,
J'ai trouvé plusieurs topic à ce sujet, mais comme ils ne m'ont pas aidé à solutionner mon problème, je viens ouvrir un nouveau sujet sur l'appel de Callback.
J'essaye de faire une interface Matlab, et j'ai une fonction qui marche très bien. Mais je voudrais ajouter l'utilisation de la molette mais je ne veux pas tout réécrire, surtout que la fonction molette bug....
J'ai une fonction qui gere un scrollbar, pour naviguer dans la troisème dimension d'une image.
Quand je le fait avec la gestion de la molette, j'ai quelques fois Matlab qui s'emballe, et veux accéder à une slice bien supérieure à l'image...
Du coup, je voudrais passer par ma fonction scrollbar, pour cacher ce bug.
Voici ma fonction scrollbar :
Pour les curieux, voici ce que j'avais fait pour la molette :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 function sliceCall(varargin) if ~isempty(handles.ImX) try h=varargin{1}; % Get calling handle and structure. switch h % Who called? case handles.SliceEdit L = get(handles.Slicebar,{'min','max','value'}); % Get the slider's info. E = floor(str2double(get(h,'string'))); % Numerical edit string. if E >= L{1} && E <= L{2} set(handles.Slicebar,'value',E) % E falls within range of slider. else set(h,'string',L{3}) % User tried to set slider out of range. end case handles.Slicebar % Set edit to current slider. set(handles.SliceEdit,'string',floor(get(h,'value'))); handles.s3=floor(get(h,'value')); otherwise % Do nothing, or whatever. end iH=imagesc(handles.ImX(:,:,handles.s3), 'parent', handles.ImageAxes); map1=colormap; colormap(map1); set(iH, 'hittest', 'off'); axis(handles.ImageAxes, 'equal'); set(handles.ImageAxes, ... 'box' , 'on', ... 'xtick' , [], ... 'ytick' , [], ... 'buttondownfcn' , @winBtnDownFcn, ... 'interruptible' , 'off', ... 'busyaction' , 'queue', ... 'handlevisibility', 'callback'); catch end end end
Merci d'avance de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 function scrollWheelFcn(varargin) if ((~isempty(handles.ImX)) && (handles.in)) try edata = varargin{2}; r = edata.VerticalScrollCount; r2=r/abs(r); if (handles.s3+r2>0 && handles.s3+r2<=handles.s) handles.s3=handles.s3+r2; set(handles.SliceEdit, 'string', sprintf('%d',handles.s3)); % set(handles.SliceEdit, 'string', sprintf('%d',handles.s3)); % set(handles.Slicebar, 'value', handles.s3); % iH=imagesc(handles.ImX(:,:,handles.s3), 'parent', handles.ImageAxes); % map1=colormap; % colormap(map1); % set(iH, 'hittest', 'off'); % axis(handles.ImageAxes, 'equal'); % set(handles.ImageAxes, ... % 'box' , 'on', ... % 'xtick' , [], ... % 'ytick' , [], ... % 'buttondownfcn' , @winBtnDownFcn, ... % 'interruptible' , 'off', ... % 'busyaction' , 'queue', ... % 'handlevisibility', 'callback'); end catch end end end
Partager