diff --git a/tsg_util/tsg_preferences.m b/tsg_util/tsg_preferences.m index 22ea2fd77d15e549eb084409e9c7a769e3412712..5797d99d1c17372668a9f1e8abd825a8c759a74f 100644 --- a/tsg_util/tsg_preferences.m +++ b/tsg_util/tsg_preferences.m @@ -109,8 +109,7 @@ tsg.preference = preference; tsg.preference.map.border = ... str2double(tsg.preference.map.border_string(tsg.preference.map.border_value)); - -% Save structure tsg +% save structure tsg % ------------------ setappdata( hTsgGUI, 'tsg_data', tsg); @@ -177,9 +176,13 @@ return preference.map.climato.SSPS.max = 37; preference.map.climato.SSPS.step = .2; preference.map.track.size = 1; + preference.map.track.size_index = 1; preference.map.track.color = 'b'; + preference.map.track.color_index = 3; preference.map.ship.size = 5; + preference.map.ship.size_index = 2; preference.map.ship.color = 'r'; + preference.map.ship.color_index = 1; preference.plot_connected_string = {'none', '-', '--', ':', '-.'}; preference.plot_connected_value = 1; % 0, line not connected % QC test diff --git a/tsgqc.m b/tsgqc.m index e72cbd747fa218e7eafe766e181c90164c7a586c..0a5178639d919ae31672c7430c0f877de5778b29 100644 --- a/tsgqc.m +++ b/tsgqc.m @@ -54,7 +54,7 @@ global DEFAULT_PATH_FILE % ------------------------------------------------------------------- VERSION = 1.50; % -> 1.44 CHAR_VERSION = '1.50RC2'; -DATE_VERSION = '20/12/2018'; +DATE_VERSION = '07/01/2019'; % netcdf file version, see DATA FORMAT TSG document: % CORTSG_format_gosud.doc @@ -963,6 +963,11 @@ uimenu(hMapShipSizeMenu,'Label','7',... 'Enable', 'on',... 'Callback', {@mapCustomizeCallback, 7, 'SHIP_SIZE'}); +% set 'checked' property to 'on' for current map ship/size menu +% ---------------------------------------------------------- +hdls = flipud(findobj( '-regexp', 'tag', 'TAG_UIMENU_MAP_SHIP_SIZE_')); +set(hdls(tsg.preference.map.ship.size_index), 'checked', 'on'); + uimenu(hMapShipColorMenu,'Label','red',... 'Checked','off',... 'Tag','TAG_UIMENU_MAP_SHIP_COLOR_R',... @@ -987,6 +992,11 @@ uimenu(hMapShipColorMenu,'Label','green',... 'Enable', 'on',... 'Callback', {@mapCustomizeCallback, 'g', 'SHIP_COLOR'}); +% set 'checked' property to 'on' for current map ship/color menu +% ---------------------------------------------------------- +hdls = flipud(findobj( '-regexp', 'tag', 'TAG_UIMENU_MAP_SHIP_COLOR_')); +set(hdls(tsg.preference.map.ship.color_index), 'checked', 'on'); + uimenu(hMapTrackSizeMenu,'Label','1',... 'Checked','off',... 'Tag','TAG_UIMENU_MAP_TRACK_SIZE_1',... @@ -1011,29 +1021,10 @@ uimenu(hMapTrackSizeMenu,'Label','4',... 'Enable', 'on',... 'Callback', {@mapCustomizeCallback, 4, 'TRACK_SIZE'}); -% uimenu(hMapTrackColorMenu,'Label','red',... -% 'Checked','off',... -% 'Tag','TAG_UIMENU_MAP_TRACK_COLOR_R',... -% 'Enable', 'on',... -% 'Callback', {@mapCustomizeCallback, 'r', 'TRACK_COLOR'}); -% -% uimenu(hMapTrackColorMenu,'Label','black',... -% 'Checked','off',... -% 'Tag','TAG_UIMENU_MAP_TRACK_COLOR_K',... -% 'Enable', 'on',... -% 'Callback', {@mapCustomizeCallback, 'k', 'TRACK_COLOR'}); -% -% uimenu(hMapTrackColorMenu,'Label','blue',... -% 'Checked','off',... -% 'Tag','TAG_UIMENU_MAP_TRACK_COLOR_B',... -% 'Enable', 'on',... -% 'Callback', {@mapCustomizeCallback, 'b', 'TRACK_COLOR'}); -% -% uimenu(hMapTrackColorMenu,'Label','green',... -% 'Checked','off',... -% 'Tag','TAG_UIMENU_MAP_TRACK_COLOR_G',... -% 'Enable', 'on',... -% 'Callback', {@mapCustomizeCallback, 'g', 'TRACK_COLOR'}); +% set 'checked' property to 'on' for current map track/size menu +% ---------------------------------------------------------- +hdls = flipud(findobj( '-regexp', 'tag', 'TAG_UIMENU_MAP_TRACK_SIZE_')); +set(hdls(tsg.preference.map.track.size_index), 'checked', 'on'); % map Print menu % -------------------- @@ -4097,11 +4088,11 @@ end end -% function mapCustomizeCallback -% This function is generic for all customization menus. -% The tag argument is used to find the handle of the selected menu. +% Generic function for all customization menus. +% The tag argument (second) is used to extract the handle of the selected +% menu. % We use a regular expression to access and modify the preference structure -% ---------------------------------------------------------------------- +% ------------------------------------------------------------------------- function mapCustomizeCallback(src, evnt, val, tag) % get the tsg structure @@ -4112,11 +4103,17 @@ end set(hdls, 'Checked', 'off'); set(src, 'Checked', 'on'); - % change the map border from menu on map, dynamically transform + % change the value from customize menu on map, dynamically transform % tag to structure member % ------------------------------------------------------------- member = regexp(lower(tag),'(\w+)_(\w+)','tokens'); tsg.preference.map.(member{1}{1}).(member{1}{2}) = val; + + % save the selected position menu (index) for next use + index = [member{1}{2} '_index']; + tsg.preference.map.(member{1}{1}).(index) = get(src, 'position'); + + % save tsg struct setappdata( hMainFig, 'tsg_data', tsg); % redraw map @@ -4125,27 +4122,20 @@ end plot_map(hMainFig, hPlotAxes); end + % color picker callback + % --------------------- function mapColorPickerCallback(src, evnt, tag) - % get the tsg structure - % --------------------- - tsg = getappdata( hMainFig, 'tsg_data'); - - hdls = findobj( '-regexp', 'tag', ['TAG_UIMENU_MAP_' tag]); - set(hdls, 'Checked', 'off'); - set(src, 'Checked', 'on'); + % open color picker + theColor = uisetcolor; - % change the map border from menu on map, dynamically transform - % tag to structure member - % ------------------------------------------------------------- - member = regexp(lower(tag),'(\w+)_(\w+)','tokens'); - tsg.preference.map.(member{1}{1}).(member{1}{2}) = uisetcolor; - setappdata( hMainFig, 'tsg_data', tsg); + % if user select cancel, abort + if length(theColor) == 1 && theColor == 0 + return + end - % redraw map - % ------------------------------------------ - erase_Line( hPlotAxes, 4 ); - plot_map(hMainFig, hPlotAxes); + % call generic function + mapCustomizeCallback(src, evnt, theColor, tag) end % print map figure from menu @@ -4163,16 +4153,16 @@ end function mapToolBarCallback(src, evnt) get(hMapFig, 'toolbar') if( strcmp(get(hMapFig, 'toolbar'), 'none')) - set(hMapFig, 'toolbar', 'figure') + set(hMapFig, 'toolbar', 'figure'); % see Reverting axes controls in figure toolbar under: % https://undocumentedmatlab.com/blog/reverting-axes-controls-in-figure-toolbar % and Matlab Central: % https://fr.mathworks.com/matlabcentral/answers/419036-what-happened-to-the-figure-toolbar-in-r2018b-why-is-it-an-axes-toolbar-how-can-i-put-the-buttons if ~verLessThan('matlab','9.5') - addToolbarExplorationButtons(hMapFig) + addToolbarExplorationButtons(hMapFig); end else - set(hMapFig, 'toolbar', 'none') + set(hMapFig, 'toolbar', 'none'); end end