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

GtVolView: Added Transparency toggle button (for the overlay)


It enables and disables transparency of the overlay

Signed-off-by: default avatarNicola Vigano <nicola.vigano@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@222 4c865b51-4357-4376-afb4-474e03ccb993
parent a9d29395
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ classdef GtGuiThresholdGrain < GtVolView
'Parent', obj.conf.upper_t_boxes);
obj.conf.radio_boxes = uiextras.HBox('Parent', obj.conf.upper_t_boxes);
set(obj.conf.upper_t_boxes, 'Sizes', [180, 60, -1]);
set(obj.conf.upper_t_boxes, 'Sizes', [250, 100, -1]);
obj.conf.h_thr_slider = uicontrol('Style', 'slider', ...
'Parent', obj.conf.center_t_boxes);
......
......@@ -87,6 +87,7 @@ classdef GtVolView < GtBaseGuiElem
% Internal parameters (not exposed to the user)
obj.conf.firsttime = true;
obj.conf.transparency = 0.66;
% modify the colour limits if a percentile is requested
obj.conf.clims = gtSetColourLimits(obj.conf.vol, obj.conf.clims, true);
......@@ -185,12 +186,18 @@ classdef GtVolView < GtBaseGuiElem
'String', 'Overlay transparency');
% adds brightness and contrast sliders to the figure containing the
% specified axis
obj.conf.trans_boxes = uiextras.HBox('Parent', obj.conf.display_boxes);
obj.conf.h_trans = uicontrol('Style', 'slider', ...
'Parent', obj.conf.display_boxes, ...
'Min', 0, 'Max', 1, 'Value', 0.5);
'Parent', obj.conf.trans_boxes, ...
'Min', 0, 'Max', 1);
set(obj.conf.h_trans, 'Units', 'normalized');
obj.conf.h_trans_butt = uicontrol('Style', 'togglebutton', ...
'Parent', obj.conf.trans_boxes, ...
'String', 'Overlay');
set(obj.conf.display_boxes, 'Sizes', [-1 15 20]);
set(obj.conf.trans_boxes, 'Sizes', [-1 70]);
set(obj.conf.h_figure, 'Renderer', 'OpenGL');
end
......@@ -229,7 +236,7 @@ classdef GtVolView < GtBaseGuiElem
set(obj.conf.radio_boxes, 'Sizes', [-1 -1 -1], 'Spacing', 0, 'Padding', 0);
% End perpective
set(obj.conf.upper_boxes, 'Sizes', [-1 -1 50 150]);
set(obj.conf.upper_boxes, 'Sizes', [-1 -1 50 200]);
% Reset back the zoom to the previous state (before the inclusion)
set(zoomOp, 'Enable', zoomState);
......@@ -280,6 +287,9 @@ classdef GtVolView < GtBaseGuiElem
obj.addUICallback(obj.conf.h_trans, ...
'AdjustmentValueChangedCallback', ...
@(src, evt)updateOverlay(obj), true);
obj.addUICallback(obj.conf.h_trans_butt, ...
'Callback', ...
@(src, evt)setOverlayButton(obj), false);
end
%%% End callbacks
end
......@@ -323,6 +333,10 @@ classdef GtVolView < GtBaseGuiElem
'Value', obj.conf.clims(1));
set(obj.conf.h_max, 'Min', obj.conf.clims(1), 'Max', obj.conf.clims(2), ...
'Value', obj.conf.clims(2));
if (~isempty(obj.conf.overlay))
set(obj.conf.h_trans, 'Value', obj.conf.transparency);
end
end
function guiQuit(obj)
......@@ -466,20 +480,43 @@ classdef GtVolView < GtBaseGuiElem
function updateOverlay(obj)
% GTVOLVIEW/UPDATEOVERLAY Function to update the Overlay Transparency
%
% TODO should have a guard here to prevent it running for all mouse
% movements
alphaval = get(obj.conf.h_trans, 'Value');
set(obj.conf.h_overlay, 'alphadata', alphaval);
obj.conf.transparency = get(obj.conf.h_trans, 'Value');
set(obj.conf.h_overlay, 'alphadata', obj.conf.transparency);
butt_value = get(obj.conf.h_trans_butt, 'Value');
if (obj.conf.transparency > 0)
if (butt_value == get(obj.conf.h_trans_butt, 'Min'))
new_value = get(obj.conf.h_trans_butt, 'Max');
set(obj.conf.h_trans_butt, 'Value', new_value);
end
else
if (butt_value == get(obj.conf.h_trans_butt, 'Max'))
new_value = get(obj.conf.h_trans_butt, 'Min');
set(obj.conf.h_trans_butt, 'Value', new_value);
end
end
drawnow;
end
function setOverlayButton(obj)
% GTVOLVIEW/UPDATEOVERLAYBUTTON Function to update the Overlay
% Transparency on the action of the toggle button
value = get(obj.conf.h_trans_butt, 'Value');
tempTransp = obj.conf.transparency;
if (value == get(obj.conf.h_trans_butt, 'Min'))
set(obj.conf.h_trans, 'Value', 0);
else
set(obj.conf.h_trans, 'Value', obj.conf.transparency);
end
drawnow;
obj.updateOverlay();
obj.conf.transparency = tempTransp;
end
function updateZoom(obj)
% GTVOLVIEW/UPDATEOVERLAY Function to update the Overlay Transparency
%
% TODO should have a guard here to prevent it running for all mouse
% movements
% GTVOLVIEW/UPDATEZOOM Function to update the Zoom state
zoomOp = zoom(obj.conf.h_figure);
value = get(obj.conf.h_zoom_button, 'Value');
......@@ -506,7 +543,7 @@ classdef GtVolView < GtBaseGuiElem
function changePerspective(obj, new_perspective)
if ( ~ischar(new_perspective) ...
|| ~ismember(new_perspective, {'xy', 'yz', 'zx'}) )
|| ~ismember(new_perspective, {'xy', 'yz', 'zx'}) )
mexc = MException('GUI:wrong_argument', ...
'Perspectives need to be one of "xy", "yz" or "zx"');
throw(mexc);
......
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