Commit 2cde4dea authored by jayd1860's avatar jayd1860
Browse files

v1.42.1

-- Fix bug removing channels from display by mouse right-clicking in MainGUI axesSDG. Fixed incorrect distance criteria for source and detector from end points on clicked line.
parent 193cfd2c
Loading
Loading
Loading
Loading
+26 −24
Original line number Diff line number Diff line
function toggleLinesAxesSDG_ButtonDownFcn(hObject, ~, handles)

% This function is called when the user clicks on one of the meausrement
% lines in the SDG window

% This function is called when the user clicks directly on one of the measurement
% lines in the SDG axes
global maingui;

ch       = maingui.dataTree.currElem.GetMeasList();
SD    = maingui.dataTree.currElem.GetSDG('2D');
ch    = maingui.dataTree.currElem.GetMeasList();
ml    = ch.MeasList;

mouseevent = get(get(get(hObject,'parent'),'parent'),'selectiontype');

% Get the index of clicked channel
lst = [];
xdata = get(hObject,'xdata');
ydata = get(hObject,'ydata');
SD_clicked_pos = [xdata(:), ydata(:), zeros(length(xdata),1)];
ml = ch.MeasList;
errmgn = .5;
for ii = 1:size(ml,1)
    if      (dist3(SD.SrcPos(ml(ii,1),:), SD_clicked_pos(1,:)) < errmgn)  &&  (dist3(SD.DetPos(ml(ii,2),:), SD_clicked_pos(2,:)) < errmgn)
        lst = [lst; ii];
    elseif  (dist3(SD.DetPos(ml(ii,2),:), SD_clicked_pos(1,:)) < errmgn)  &&  (dist3(SD.SrcPos(ml(ii,1),:), SD_clicked_pos(2,:)) < errmgn)
        lst = [lst; ii];
    end
end
iChSelected = GetSelctedChannels(hObject, SD, ch);

%%%% Mouse right click: toggle channel visibility
if strcmp(mouseevent, 'alt')
    % TODO implement a more elegant setter
    maingui.dataTree.currElem.SetMeasListVis(ml(lst(1),1:2));
    maingui.dataTree.currElem.SetMeasListVis(ml(iChSelected(1),1:2));
    maingui.Update('PatchCallback');  % Refresh data display
    
%%%% Mouse left click: toggle manual exclude/deactivate channel
elseif strcmp(mouseevent, 'normal')
    if all(ch.MeasListActMan(lst))  % If the selected channel is active
        ch.MeasListActMan(lst) = 0;
    if all(ch.MeasListActMan(iChSelected))  % If the selected channel is active
        ch.MeasListActMan(iChSelected) = 0;
    else
        ch.MeasListActMan(lst) = 1;
        ch.MeasListActMan(iChSelected) = 1;
    end
    
    % TODO implement a more elegant setter
@@ -49,3 +36,18 @@ end

DisplayAxesSDG(handles);




% -------------------------------------------------------------------------------
function iChSelected = GetSelctedChannels(hObject, SD, ch)
xdata = get(hObject,'xdata');
ydata = get(hObject,'ydata');
ml    = ch.MeasList;
SD_clicked_pos = [xdata(:), ydata(:), zeros(length(xdata),1)];

[~, iS] = nearest_point(SD.SrcPos, SD_clicked_pos(1,:));
[~, iD] = nearest_point(SD.DetPos, SD_clicked_pos(2,:));

iChSelected = find(ml(:,1) == iS  &  ml(:,2) == iD);
+1 −1
Original line number Diff line number Diff line
1.42.0
1.42.1