Skip to content
Snippets Groups Projects
Commit 13c26724 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

GtVolView: added simple/not-fully-functional zoom propagation mechanics

parent 8b947460
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,8 @@ classdef GtEventLinkerVolView < handle
perspective;
horflip;
verflip;
zoom_state;
end
properties (Access = private)
......@@ -12,26 +14,29 @@ classdef GtEventLinkerVolView < handle
end
methods (Access = public)
function self = GtEventLinkerVolView(volDims, slicendx, persp, hflip, vflip, volViewer)
function self = GtEventLinkerVolView(volDims, slicendx, persp, hflip, vflip, zoom_state, volViewer)
self.dims = volDims;
self.slice = slicendx;
self.perspective = persp;
self.horflip = hflip;
self.verflip = vflip;
self.zoom_state = zoom_state;
addlistener(self, 'slice', 'PostSet', @(src, evt)self.propagateSlice);
addlistener(self, 'perspective', 'PostSet', @(src, evt)self.propagatePerspective);
addlistener(self, 'horflip', 'PostSet', @(src, evt)self.propagateHorFlip);
addlistener(self, 'verflip', 'PostSet', @(src, evt)self.propagateVerFlip);
addlistener(self, 'zoom_state', 'PostSet', @(src, evt)self.propagateZoom);
self.attach(volViewer, volDims)
end
function notify(self, slicendx, persp, hflip, vflip)
function notify(self, slicendx, persp, hflip, vflip, zoom_state)
self.slice = slicendx;
self.perspective = persp;
self.horflip = hflip;
self.verflip = vflip;
self.zoom_state = zoom_state;
end
function attach(self, volViewer, volDims)
......@@ -40,7 +45,7 @@ classdef GtEventLinkerVolView < handle
'Volume dimensions mismatch for linkname')
end
% Attach listener's callback
self.handles = [self.handles volViewer];
self.handles = [self.handles, volViewer];
end
function isNowEmpty = detach(self, volViewer)
......@@ -74,5 +79,11 @@ classdef GtEventLinkerVolView < handle
self.handles(ii).verFlip(self.verflip);
end
end
function propagateZoom(self)
for ii = 1:length(self.handles)
self.handles(ii).setZoom(self.zoom_state);
end
end
end
end
......@@ -253,6 +253,11 @@ classdef GtVolView < GtBaseGuiElem
obj.updateDisplay();
end
function setZoom(obj, xy_lims)
set(obj.conf.h_ax, 'XLim', xy_lims{1})
set(obj.conf.h_ax, 'YLim', xy_lims{2})
end
function value = getVolValue(obj, point)
% GTVOLVIEW/GETVOLVALUE Returns the value for the given point, from the
% volume stored in the object
......@@ -534,7 +539,9 @@ classdef GtVolView < GtBaseGuiElem
appdata.(obj.conf.linkname) = ...
GtEventLinkerVolView(obj.conf.dim, obj.conf.slicendx, ...
obj.conf.plane, obj.conf.horflip, ...
obj.conf.verflip, obj);
obj.conf.verflip, ...
get(obj.conf.h_ax, {'XLim', 'YLim'}), ...
obj);
end
else
disp('First instance of GtVolView linkname');
......@@ -542,7 +549,9 @@ classdef GtVolView < GtBaseGuiElem
appdata.(obj.conf.linkname) = ...
GtEventLinkerVolView(obj.conf.dim, obj.conf.slicendx, ...
obj.conf.plane, obj.conf.horflip, ...
obj.conf.verflip, obj);
obj.conf.verflip, ...
get(obj.conf.h_ax, {'XLim', 'YLim'}), ...
obj);
end
setappdata(0, 'GtVolView', appdata);
end
......@@ -807,8 +816,8 @@ classdef GtVolView < GtBaseGuiElem
end
frame = 'XYZ';
xlabel(obj.conf.h_ax,frame(obj.conf.horDim));
ylabel(obj.conf.h_ax,frame(obj.conf.verDim));
xlabel(obj.conf.h_ax, frame(obj.conf.horDim));
ylabel(obj.conf.h_ax, frame(obj.conf.verDim));
set(obj.conf.h_im, 'xdata', linspace(obj.conf.hordisplay(1), obj.conf.hordisplay(2), obj.conf.dim(obj.conf.horDim)));
set(obj.conf.h_im, 'ydata', linspace(obj.conf.verdisplay(1), obj.conf.verdisplay(2), obj.conf.dim(obj.conf.verDim)));
......@@ -831,7 +840,8 @@ classdef GtVolView < GtBaseGuiElem
if (isfield(appdata, obj.conf.linkname))
appdata.(obj.conf.linkname).notify(...
obj.conf.slicendx, obj.conf.plane, ...
obj.conf.horflip, obj.conf.verflip);
obj.conf.horflip, obj.conf.verflip, ...
{xlim, ylim});
else
gtError('GtVolView:linkname_inconsistency', ...
'Linkname "%s" doesn''t exist!', ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment