diff --git a/5_reconstruction/GtGuiThresholdGrain.m b/5_reconstruction/GtGuiThresholdGrain.m index 36cc9b0be6fa4d9e75d2959aa72d5ba08b164121..5d8adc7efaa365b41dd7c74978479481480b2083 100644 --- a/5_reconstruction/GtGuiThresholdGrain.m +++ b/5_reconstruction/GtGuiThresholdGrain.m @@ -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); diff --git a/zUtil_TomoUtils/GtVolView.m b/zUtil_TomoUtils/GtVolView.m index 604962a673b7507a3f6ce25701974a48b724696e..ae4d9766810344c7ceb3708b682b7662a1ec4f6f 100644 --- a/zUtil_TomoUtils/GtVolView.m +++ b/zUtil_TomoUtils/GtVolView.m @@ -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);