function setselectmode(h,thismode)

%% Set all the time plots to the new state and update all theirr button states
 
%% Clear any old selections
h.clearselect;
%% If a translation/scale has just completed reset the axes limits
if (strcmp(h.State,'TimeseriesTranslate') || strcmp(h.State,'TimeseriesScale')) && ...
        ~isempty(h.SelectionStruct) && ~isempty(h.SelectionStruct.YLimMode)
    set(h.AxesGrid,'YLimMode',h.SelectionStruct.YLimMode)
end
if (strcmp(h.State,'TimeseriesTranslate') || strcmp(h.State,'TimeseriesScale')) && ...
        ~isempty(h.SelectionStruct) && ~isempty(h.SelectionStruct.XLimMode)
    set(h.AxesGrid,'XLimMode',h.SelectionStruct.XLimMode)
end

S = warning('off','all'); % Disable "Some data is missing ..."
h.draw
warning(S);

%% Set the new state
h.State = thismode;

%% Lock out the normalization menu when any of the special modes are in
%% affect. The reason is that the current mechanism for drawing normalized
%% plots introduces a flicker during mouse actions in special modes. The
%% reason is that when in normalization mode the view draw method sets the
%% XData and YData of all the lines to empty, leaving it to the view
%% adjustview method to reset them to non-empty values. The result is a
%% flicker during data selection actions.
if strcmp(thismode,'None') 
    % Resume normal event handling
    set(ancestor(h.AxesGrid.Parent,'figure'),'Interruptible','on','BusyAction','queue')
    set(ancestor(h.axesgrid.parent,'figure'),'Pointer','arrow')  
    set(h.AxesGrid.findMenu('normalize'),'Enable','on')
    set(h.AxesGrid,'XlimMode','auto','YlimMode','auto')
else
    % Delete datatips for performance and de-select normalize 
    delete(findall(h.axesGrid.getaxes,'Tag','DataTipMarker'));
    set(h.AxesGrid.findMenu('normalize'),'Enable','off')
end

%% Clear toolbar
cleartb(h.Parent,h.State);

%% Refresh
drawnow

