function  ihb_ColorsTalSpaceCB
%----------------------------------------------------------------------------------
% Callback functions for ihb_ColorsTalSpace pushbuttons
%----------------------------------------------------------------------------------
%----------------------------------------------------------------------------------
%   16.04.01    Sergey Pakhomov
%----------------------------------------------------------------------------------
hPushButton = gcbo;
%----------------------------------------------------------------------------------
oldColor = get(hPushButton, 'BackgroundColor');
newColor = uisetcolor(oldColor, 'Select new color');
set(hPushButton, 'BackgroundColor', newColor);
%----------------------------------------------------------------------------------
dflFileName = ihb_FileFolderName('dfl');
tag = get(hPushButton, 'Tag');
%----------------------------------------------------------------------------------
switch tag
case 'ihb_clr_Orig'
    ihbdfl_color_clOrig = newColor;
    save(dflFileName, 'ihbdfl_color_clOrig', '-append');
    h = findobj('Type', 'line', 'Tag', 'ihb_LineOriginal');
    set(h, 'Color', newColor);
    % this select/unselect is needed to make lines visible
    % without this code sometimes Symm lines become invisible ????
    h = findobj('Type', 'line', 'Tag', 'ihb_LineSymmetrical');
    set(h, 'Selected', 'on');
    set(h, 'Selected', 'off');
case 'ihb_clr_Symm'
    ihbdfl_color_clSymm = newColor;
    save(dflFileName, 'ihbdfl_color_clSymm', '-append');
    h = findobj('Type', 'line', 'Tag', 'ihb_LineSymmetrical');
    set(h, 'Color', newColor);
    % this select/unselect is needed to make lines visible
    % without this code sometimes Orig lines become invisible ????
    h = findobj('Type', 'line', 'Tag', 'ihb_LineOriginal');
    set(h, 'Selected', 'on');
    set(h, 'Selected', 'off');
case 'ihb_clr_Surface'
    ihbdfl_color_surface = newColor;
    save(dflFileName, 'ihbdfl_color_surface', '-append');
    h = findobj('Type', 'patch', 'Tag', 'ihb_surfaceCluster');
    set(h, 'FaceColor', newColor);
case 'ihb_clr_Axial'
    ihbdfl_color_cntAx = newColor;
    save(dflFileName, 'ihbdfl_color_cntAx', '-append');
    h = findobj('Type', 'patch', 'Tag', 'ihb_cntAxial');
    set(h, 'EdgeColor', newColor);
case 'ihb_clr_Frontal'
    ihbdfl_color_cntFr = newColor;
    save(dflFileName, 'ihbdfl_color_cntFr', '-append');
    h = findobj('Type', 'patch', 'Tag', 'ihb_cntFrontal');
    set(h, 'EdgeColor', newColor);
case 'ihb_clr_Saggital'
    ihbdfl_color_cntSag = newColor;
    save(dflFileName, 'ihbdfl_color_cntSag', '-append');
    h = findobj('Type', 'patch', 'Tag', 'ihb_cntSaggitalL');
    if ~isempty(h)
        set(h, 'EdgeColor', newColor);
    end
    h = findobj('Type', 'patch', 'Tag', 'ihb_cntSaggitalR');
    if ~isempty(h)
        set(h, 'EdgeColor', newColor);
    end
end