From 74e4b5aa668d06b65770c61ba2ad4738b2a6d504 Mon Sep 17 00:00:00 2001 From: Yves Gouriou <yves.gouriou@ird.fr> Date: Tue, 18 Dec 2007 14:14:50 +0000 Subject: [PATCH] =?UTF-8?q?Poursuite=20du=20d=C3=A9veloppement=20du=20modu?= =?UTF-8?q?le=20de=20correction=20des=20donn=C3=A9es=20TSG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tsg_util/tsg_initialisation.m | 6 +- tsg_util/tsg_plot_SalTsgSample.m | 32 +++- tsgcor_GUI.m | 247 +++++++++++++------------------ 3 files changed, 126 insertions(+), 159 deletions(-) diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m index cf501c3..c276343 100644 --- a/tsg_util/tsg_initialisation.m +++ b/tsg_util/tsg_initialisation.m @@ -8,7 +8,7 @@ function tsg_initialisation(hTsgGUI, hQcCmenu) % Output % ------ % $Id$ - +% % ************************************************************************* % Constants for the quality control procedure @@ -27,8 +27,8 @@ qc.Code.PROBABLY_GOOD = 3; qc.Code.PROBABLY_BAD = 4; qc.Code.BAD = 5; -% Store default value 'quality' a application data -% ------------------------------------------------ +% Store default value 'quality' a application data - It's not useful +% ------------------------------------------------------------------ quality.Code = qc.Code.GOOD; quality.Color = qc.Color.GOOD; set( hQcCmenu, 'UserData', quality ); diff --git a/tsg_util/tsg_plot_SalTsgSample.m b/tsg_util/tsg_plot_SalTsgSample.m index acb549d..29e1c54 100644 --- a/tsg_util/tsg_plot_SalTsgSample.m +++ b/tsg_util/tsg_plot_SalTsgSample.m @@ -9,6 +9,7 @@ function tsg_plot_SalTsgSample( hGUI, hAxes ) % % Output % ------ +% % Retrieve named application data % ------------------------------- @@ -52,14 +53,29 @@ end % Plot sample measurements % ------------------------ -ind = find( sample.TYPE == 1); -if ~isempty( ind ) - plot(hAxes(2), sample.TIME(ind), sample.PSAL(ind), '.'); -end -ind = find( sample.TYPE == 2); -if ~isempty( ind ) - plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), 'o'); -end +axes( hAxes(2)); + +ind = find(sample.PSAL_QC <= qc.Code.NO_CONTROL ); +plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), ... + strcat('o',qc.Color.NO_CONTROL)); + +hold on; + +ind = find(sample.PSAL_QC == qc.Code.GOOD ); +plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), ... + strcat('o',qc.Color.GOOD)); + +ind = find(sample.PSAL_QC == qc.Code.PROBABLY_GOOD ); +plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), ... + strcat('o',qc.Color.PROBABLY_GOOD)); + +ind = find(sample.PSAL_QC == qc.Code.PROBABLY_BAD ); +plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), ... + strcat('o',qc.Color.PROBABLY_BAD)); + +ind = find(sample.PSAL_QC == qc.Code.BAD ); +plot(hAxes(2), sample.TIME(ind), sample.PSAL_DIF(ind), ... + strcat('o',qc.Color.BAD)); %plot(hAxes(3), tsg.TIME, tsg.TEMP_TSG, '.'); diff --git a/tsgcor_GUI.m b/tsgcor_GUI.m index e197674..98bf8ac 100644 --- a/tsgcor_GUI.m +++ b/tsgcor_GUI.m @@ -5,6 +5,10 @@ function tsgcor_GUI( hMainFig ) % this GUI is a children of tsgqc_GUI % % +% TO DO +% Se baser sur le code developper ici pour modifier tsgqc_GUI pour +% le menu contextuel : 1 seule fonction pour attribuer le code qualite +% et de couleur %% COPYRIGHT & LICENSE % Copyright 2007 - IRD US191, all rights reserved. @@ -69,7 +73,14 @@ function tsgcor_GUI( hMainFig ) 'Visible','on',... 'Units', 'normalized',... 'Position',guiLimits); - + +% Get the data useful to the correction GUI +% ----------------------------------------- +tsg = getappdata( hMainFig, 'tsg_data' ); +sample = getappdata( hMainFig, 'sample' ); +cst = getappdata( hMainFig, 'constante'); +qc = getappdata( hMainFig, 'qcColor'); + % Construct the Menu % ----------------- hFileMenu = uimenu(... @@ -165,7 +176,7 @@ function tsgcor_GUI( hMainFig ) 'Visible', 'off', ... 'HandleVisibility','callback', ... 'Position',[.25, .6, .7, .32]); - hPlotAxes(2) = axes(... % the axes for plotting temperature + hPlotAxes(2) = axes(... % the axes for plotting sample 'Parent', hChild1Fig, ... 'Units', 'normalized', ... 'Visible', 'off', ... @@ -264,32 +275,32 @@ function tsgcor_GUI( hMainFig ) % Construct the context menu to delete samples % -------------------------------------------- - hSampleCmenu = uicontextmenu(... + hSampleCmenu = uicontextmenu(... 'Parent', hChild1Fig, ... 'HandleVisibility','callback' ); - hSampleCmenuDel = uimenu(... + hQcSampleNocontrol = uimenu(... 'Parent', hSampleCmenu,... 'HandleVisibility','off', ... - 'Label', 'Delete',... + 'Label', 'No control',... 'ForegroundColor', 'k',... - 'Callback', @QcDel); - hSampleCmenuNoDel = uimenu(... + 'Callback', @Qc); + hQcSampleGood = uimenu(... 'Parent', hSampleCmenu,... 'HandleVisibility','off', ... - 'Label', 'Keep',... + 'Label', 'Good',... 'ForegroundColor', 'b',... - 'Callback', @QcKeep); + 'Callback', @Qc); + hQcSampleBad = uimenu(... + 'Parent', hSampleCmenu,... + 'HandleVisibility','off', ... + 'Label', 'Bad',... + 'ForegroundColor', 'r',... + 'Callback', @Qc); % Pointer set to watch during reading and plotting % ------------------------------------------------ set( hChild1Fig, 'Pointer', 'watch' ); -% Get the data useful to the correction GUI -% ----------------------------------------- -tsg = getappdata( hMainFig, 'tsg_data' ); -sample = getappdata( hMainFig, 'sample' ); -cst = getappdata( hMainFig, 'constante'); - dateMin = datestr(tsg.TIME(1), 31); dateMax = datestr(tsg.TIME(end), 31); set( hetDateMin, 'String', dateMin); @@ -415,86 +426,82 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn'); end - %---------------------------------------------------------------------- - function StartLimitCallback(hObject, eventdata) - % Callback function run when the .... - - end - - %---------------------------------------------------------------------- - function QCMenuCallback(gcbo, eventdata,handles) +%---------------------------------------------------------------------- + function BottleMenuCallback(gcbo, eventdata,handles) % Callback function run when the QC pushbutton is selected % Desactivate the Zoom and Pan functions. % --------------------------------------- -% zoom off; pan off -% panAdaptiveDateTicks('off');zoomAdaptiveDateTicks('off'); + zoom off; pan off + panAdaptiveDateTicks('off');zoomAdaptiveDateTicks('off'); % Retrieve named application data % ------------------------------- -% tsg = getappdata( hMainFig, 'tsg_data'); + sample = getappdata( hMainFig, 'sample' ); % Toggle the tag of the Qc pushbutton to 'on' or 'off' % ---------------------------------------------------- -% switch get(hQCPushtool, 'Tag'); -% case 'off' -% set(hQCPushtool, 'Tag', 'on' ); -% set(hPlotAxes(1),'UIContextMenu', hQcCmenu); -% set( hMainFig, 'Pointer', 'crosshair'); -% case 'on' -% set(hQCPushtool, 'Tag', 'off' ); -% set(hPlotAxes(1),'UIContextMenu', []); -% set(hMainFig,'Pointer','arrow'); -% end + switch get(hBottlePushtool, 'Tag'); + case 'off' + set(hBottlePushtool, 'Tag', 'on' ); + set(hPlotAxes(2),'UIContextMenu', hSampleCmenu); + set(hChild1Fig, 'Pointer', 'crosshair'); + case 'on' + set(hBottlePushtool, 'Tag', 'off' ); + set(hPlotAxes(2),'UIContextMenu', []); + set(hChild1Fig,'Pointer','arrow'); + end -% qualityCode = -1; -% ind = []; -% while strcmp( get(hQCPushtool, 'Tag'),'on') + qualityCode = -1; + ind = []; + while strcmp( get(hBottlePushtool, 'Tag'),'on') -% k = waitforbuttonpress; + k = waitforbuttonpress; % If the QC pushbutton is pressed we quit the callback % ---------------------------------------------------- -% if strcmp( get(hQCPushtool, 'Tag'),'off') + if strcmp( get(hBottlePushtool, 'Tag'),'off') % Desactivate the context menu use to choose the % Quality Codes % ---------------------------------------------- -% set(hQcCmenu, 'Visible', 'off'); -% break -% end + set(hSampleCmenu, 'Visible', 'off'); + break + end % Test if the right mouse button is clicked % ----------------------------------------- -% if strcmp(get(hMainFig, 'SelectionType'), 'alt') && ~isempty(ind) + if strcmp(get(hChild1Fig, 'SelectionType'), 'alt') && ~isempty(ind) % Wait for a QC Context Menu choice : The user choose the % quality code % ------------------------------------------------------- -% uiwait -% qualityCode = 1; + uiwait + qualityCode = 1; -% else + else % Mouse motion callback desactivated when a selection is % made. Otherwise there is a conflict with the map if it % is activated % ------------------------------------------------------- -% set( hMainFig, 'Tag', 'ButtonMotionOff'); + set( hChild1Fig, 'Tag', 'ButtonMotionOff'); % Selection of the data within the figure % --------------------------------------- -% point1 = get(gca,'CurrentPoint'); % button down detected -% finalRect = rbbox; % return figure units -% point2 = get(gca,'CurrentPoint'); % button up detected + point1 = get(gca,'CurrentPoint'); % button down detected + finalRect = rbbox; % return figure units + point2 = get(gca,'CurrentPoint'); % button up detected -% point1 = point1(1,1:2); % extract x and y -% point2 = point2(1,1:2); + point1 = point1(1,1:2); % extract x and y + point2 = point2(1,1:2); -% p1 = min(point1,point2); -% p2 = max(point1,point2); % calculate locations + p1 = min(point1,point2); + p2 = max(point1,point2); % calculate locations -% ind = find(tsg.TIME > p1(1,1) & tsg.TIME < p2(1,1) & ... -% tsg.PSAL > p1(1,2) & tsg.PSAL < p2(1,2)); + ind = find(sample.TIME > p1(1,1) & ... + sample.TIME < p2(1,1) & ... + sample.PSAL_DIF > p1(1,2) & ... + sample.PSAL_DIF < p2(1,2)); % As soon as a modification took place the data should be % saved @@ -503,67 +510,63 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn'); % Selection made : Mouse motion callback re-activated % -------------------------------------------------- -% set( hMainFig, 'Tag', 'ButtonMotionOn'); + set( hChild1Fig, 'Tag', 'ButtonMotionOn'); -% end + end % Plot the data with the color of the chosen quality Code. % Is it the right place for this source code ???? % -------------------------------------------------------- -% if qualityCode ~= -1 + if qualityCode ~= -1 -% quality = get( hQcCmenu, 'UserData'); + quality = get( hSampleCmenu, 'UserData'); -% tsg.PSAL_QC(ind) = quality.Code; + sample.PSAL_QC(ind) = quality.Code; % Save the modifications % ---------------------- -% setappdata( hMainFig, 'tsg_data', tsg); + setappdata( hMainFig, 'sample', sample); -% axes(hPlotAxes(1)); -% hold on -% color = ['.' quality.Color]; -% plot(tsg.TIME(ind), tsg.PSAL(ind), color ); -% hold off + axes(hPlotAxes(2)); + hold on -% end -% end + color = ['o' quality.Color]; + + plot(sample.TIME(ind), sample.PSAL_DIF(ind), color ); + + hold off + + end + end end %--------------------------------------------------------------------- - function QcDel(hObject, eventdata) + function Qc(hObject, eventdata) % Callback function run when the QC context menu is selected - + % Retrieve Default Quality Code and Color % --------------------------------------- - %qc = getappdata( hMainFig, 'qcColor'); - - %quality.Code = qc.Code.NO_CONTROL; - %quality.Color = qc.Color.NO_CONTROL; - %set( hQcCmenu, 'UserData', quality ); - - % uiwait in the QCMenuCallback function - % ------------------------------------- - %uiresume - end - - %--------------------------------------------------------------------- - function QcKeep(hObject, eventdata) - % Callback function run when the QC context menu is selected + qc = getappdata( hMainFig, 'qcColor'); - % Retrieve named application data - % ------------------------------- - %qc = getappdata( hMainFig, 'qcColor'); + switch hObject + case hQcSampleNocontrol + quality.Code = qc.Code.NO_CONTROL; + quality.Color = qc.Color.NO_CONTROL; + case hQcSampleGood + quality.Code = qc.Code.GOOD; + quality.Color = qc.Color.GOOD; + case hQcSampleBad + quality.Code = qc.Code.BAD; + quality.Color = qc.Color.BAD; + end - %quality.Code = qc.Code.GOOD; - %quality.Color = qc.Color.GOOD; - %set( hQcCmenu, 'UserData', quality ); + set( hSampleCmenu, 'UserData', quality ); % uiwait in the QCMenuCallback function % ------------------------------------- - %uiresume - end - + uiresume + end + %--------------------------------------------------------------------- function MouseMotion(hObject, eventdata) @@ -606,58 +609,6 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn'); end end - %--------------------------------------------------------------------- - function BottleMenuCallback(hObject, eventdata) - % Callback function run when the Bottle tool bar item is selected - % - % Plot or Delete the buckets measurements on the Salinity graph - % - % Need to read them right now - but they will be soon in the NetCdf - % file - - % Test if the sample Push button has been pressed - % ----------------------------------------------- -% if strcmp( get(hBottlePushtool, 'Tag'), 'off') - - % Sample Push button - Tag set to 'on' - % ------------------------------------ -% set( hBottlePushtool, 'Tag', 'on' ); - - % Retrieve named application data - % ------------------------------- -% sample = getappdata( hMainFig, 'sample'); -% hLine = get( hPlotAxes(1), 'UserData'); - - - % Plot the samples if the TSG file has been read - % ---------------------------------------------- -% if strcmp( get(hOpenMenu, 'Tag'), 'on' ) && ~isempty( sample ) -% axes( hPlotAxes(1) ); -% hLine.Sample = line( ... -% sample.TIME, sample.PSAL,... -% 'Linestyle', 'none', 'Marker','o','MarkerSize',5, ... -% 'Color','r', 'MarkerFaceColor','r'); - - % Store the handle of the bucketline - % ---------------------------------- -% set( hPlotAxes(1), 'UserData', hLine ); -% end - -% else - -% set( hBottlePushtool, 'Tag', 'off' ); - - % The bucket pushbutton has been pressed again : - % Delete the bucket on figure - % ---------------------------------------------- -% hLine = get( hPlotAxes(1), 'UserData'); -% if ~isempty( hLine ) && ishandle( hLine.Sample ) -% delete(hLine.Sample); -% end -% end - end - - % ----------------------------------------------------------------- function SaveMenuCallback(hObject, eventdata) % Callback function run when the Save menu item is selected -- GitLab