Changeset 405 for trunk/src/uvmat.m


Ignore:
Timestamp:
May 1, 2012, 10:08:36 PM (12 years ago)
Author:
sommeria
Message:

many bugs corrected: composition of 2 input fields, arrow colors from different scalar fields...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r404 r405  
    769769                Input.RootFile_1=Input.RootFile;
    770770            end
     771            if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"')
     772                Input.FileExt_1=Input.FileExt;
     773            end
     774            if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"')
     775                Input.NomType_1=Input.NomType;
     776            end
    771777            %updtate the indices of the second field series to correspond to the newly opened one
    772778            FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1,i2,j1,j2);
     
    10741080            col_vec={'get_field...'};
    10751081        end
    1076         set(handles.ListColorScalar,'String',col_vec)
     1082        set(handles.ColorScalar,'String',col_vec)
    10771083    end
    10781084end
     
    20042010            end
    20052011            if strcmp(FieldName,'velocity')
    2006                 list_code=get(handles.ListColorCode,'String');% list menu fields
    2007                 index_code=get(handles.ListColorCode,'Value');% selected string index
     2012                list_code=get(handles.ColorCode,'String');% list menu fields
     2013                index_code=get(handles.ColorCode,'Value');% selected string index
    20082014                if  ~strcmp(list_code{index_code},'black') &&  ~strcmp(list_code{index_code},'white')
    2009                     list_code=get(handles.ListColorScalar,'String');% list menu fields
    2010                     index_code=get(handles.ListColorScalar,'Value');% selected string index
     2015                    list_code=get(handles.ColorScalar,'String');% list menu fields
     2016                    index_code=get(handles.ColorScalar,'Value');% selected string index
    20112017                    ParamIn.ColorVar= list_code{index_code}; % selected field
    20122018                end
     
    20432049end
    20442050
    2045 %% choose a second field filename_1 if defined
     2051%% choose and read a second field filename_1 if defined
    20462052VelType_1=[];%default
    20472053FieldName_1=[];
     
    20532059    end
    20542060    Name=filename_1;
    2055 %     FileType_1=UvData.FileType{2};
    20562061    switch UvData.FileType{2}
    20572062        case {'civx','civdata','netcdf'};
     
    20642069                end
    20652070            end
    2066             if strcmp(FieldName_1,'velocity')
    2067                 list_code=get(handles.ListColorCode,'String');% list menu fields
    2068                 index_code=get(handles.ListColorCode,'Value');% selected string index
     2071            if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on')
     2072                list_code=get(handles.ColorCode,'String');% list menu fields
     2073                index_code=get(handles.ColorCode,'Value');% selected string index
    20692074                if  ~strcmp(list_code{index_code},'black') &&  ~strcmp(list_code{index_code},'white')
    2070                     list_code=get(handles.ListColorScalar,'String');% list menu fields
    2071                     index_code=get(handles.ListColorScalar,'Value');% selected string index
    2072                     ParamIn.ColorVar= list_code{index_code}; % selected field
     2075                    list_code=get(handles.ColorScalar,'String');% list menu fields
     2076                    index_code=get(handles.ColorScalar,'Value');% selected string index
     2077                    ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display                 
    20732078                end
    20742079            end
     
    20772082        case 'vol' %TODO: update
    20782083            if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
    2079                 ParamIn.Npy=UvData.XmlData.Npy;
    2080                 ParamIn.Npx=UvData.XmlData.Npx;
     2084                ParamIn_1.Npy=UvData.XmlData.Npy;
     2085                ParamIn_1.Npx=UvData.XmlData.Npx;
    20812086            else
    20822087                errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
     
    20942099        Field{2}=UvData.Field_1;% keep the stored field
    20952100    else
    2096         ParamIn.FieldName=FieldName_1;
    2097         ParamIn.VelType=VelType_1;
    2098         ParamIn.GUIName='get_field_1';
    2099         [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn,num_i1);
     2101        ParamIn_1.FieldName=FieldName_1;
     2102        ParamIn_1.VelType=VelType_1;
     2103        ParamIn_1.GUIName='get_field_1';
     2104        [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,num_i1);
    21002105        if ~isempty(errormsg)
    21012106            errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg];
    21022107            return
    21032108        end
    2104         UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
    2105     end
    2106     %     end
     2109%         UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
     2110    end
    21072111end
    21082112
     
    21392143    set(handles.VelType,'Visible','off')
    21402144end
     2145% display the Fields menu from the input file and pick the selected one:
    21412146field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList);
    21422147set(handles.Fields,'String',ParamOut.FieldList); %update the field menu
     
    21442149
    21452150%% update the display menu for the second velocity type (second menuline)
     2151
    21462152test_veltype_1=0;
    21472153if isempty(filename_1)
    21482154    set(handles.Fields_1,'Value',1); %update the field menu
    21492155    set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
    2150 else
     2156elseif ~test_keepdata_1
    21512157    if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...')
    21522158        set(handles.VelType_1,'Visible','off')
    2153     else 
     2159    else
    21542160        test_veltype_1=1;
    21552161        set(handles.VelType_1,'Visible','on')
    2156         if ~get(handles.FixVelType,'Value')
     2162%         if ~get(handles.FixVelType,'Value')
    21572163            menu=set_veltype_display(ParamOut_1.CivStage);
    21582164            index_menu=strcmp(ParamOut_1.VelType,menu);
    21592165            set(handles.VelType_1,'Value',1+find(index_menu,1))
    21602166            set(handles.VelType_1,'String',[{''};menu])
    2161         end
    2162     end
     2167%         end
     2168    end
     2169    % update the second field menu: the same quantity
     2170    set(handles.Fields_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu
     2171    % display the Fields menu from the input file and pick the selected one:
     2172    field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
     2173    set(handles.Fields_1,'Value',find(field_index,1)+1) 
     2174%     % synchronise  with the first menu if the first selection is not 'velocity'
     2175%     if ~strcmp(ParamOut.FieldName,'velocity')
     2176%         field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
     2177%         set(handles.Fields_1,'Value',field_index); %update the field menu
     2178%         ParamOut_1.FieldName=ParamOut.FieldName;
     2179%         set(handles.Fields_1,'String',ParamOut_1.FieldList)
     2180%     end
    21632181end
    21642182if test_veltype||test_veltype_1
     
    21672185     set(handles.FixVelType,'Visible','off')
    21682186end
     2187
     2188% field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
     2189% set(handles.Fields,'String',ParamOut.FieldList); %update the field menu
     2190% set(handles.Fields,'Value',find(field_index,1))
    21692191   
    21702192%% introduce w as background image by default for a new series (only for nbdim=2)
     
    22112233    Field{1}.ZIndex=z_index;
    22122234end
    2213 %px to phys or other transform on field
    22142235if ~isempty(transform)
    22152236    if length(Field)>=2
     
    22432264
    22442265%% calculate scalar
    2245 % if (strcmp(FileType,'civdata')||strcmp(FileType,'civx'))&&~strcmp(ParamOut.FieldName,'velocity')&& ~strcmp(ParamOut.FieldName,'get_field...');% ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
    2246 %     Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
    2247 % end
    2248 % if numel(Field)==2 && ~test_keepdata_1 && (strcmp(FileType,'civdata')||strcmp(FileType,'civx'))  &&~strcmp(ParamOut.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...')
    2249 %      Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
    2250 % end
     2266if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))%&&~strcmp(ParamOut.FieldName,'velocity')&& ~strcmp(ParamOut.FieldName,'get_field...');% ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
     2267    Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
     2268end
     2269if numel(Field)==2 && ~test_keepdata_1 && (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))  &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...')
     2270     Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
     2271end
    22512272
    22522273%% combine the two input fields (e.g. substract velocity fields)
    2253 Field{1}.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}];
     2274%Field{1}.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    22542275if numel(Field)==2
    2255     Field{2}.FieldList=[{ParamOut_1.FieldName} {ParamOut_1.ColorVar}];
     2276%    Field{2}.FieldList=[{ParamOut_1.FieldName} {ParamOut_1.ColorVar}];
    22562277   [UvData.Field,errormsg]=sub_field(Field{1},Field{2}); 
     2278   UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
    22572279else
    22582280   UvData.Field=Field{1};
     
    24232445
    24242446%% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
    2425 if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
    2426     set(handles.num_MinA,'String','0')
    2427     set(handles.num_MaxA,'String','255')
    2428 end
     2447% if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
     2448%     set(handles.num_MinA,'String','0')
     2449%     set(handles.num_MaxA,'String','255')
     2450% end
    24292451
    24302452%% Plot the projections on the selected  projection objects
     
    24482470%PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
    24492471PlotParam{1}=read_GUI(handles.uvmat);
     2472%default settings if vectors not visible (should not be needed)
    24502473if ~isfield(PlotParam{1},'Vectors')
    24512474    PlotParam{1}.Vectors.MaxVec=1;
     
    24542477    PlotParam{1}.Vectors.ColCode1=0.33;
    24552478    PlotParam{1}.Vectors.ColCode2=0.66;
    2456      PlotParam{1}.Vectors.ListColorScalar={'ima_cor'};
    2457      PlotParam{1}.Vectors.ListColorCode= {'rgb'};
     2479    PlotParam{1}.Vectors.ColorScalar={'ima_cor'};
     2480    PlotParam{1}.Vectors.ColorCode= {'rgb'};
    24582481end
    24592482%keeplim(1)=get(handles.CheckFixLimits,'Value');% test for fixed graph limits
     
    24662489        plot_handles{2}=guidata(view_field_handle);
    24672490        haxes(2)=plot_handles{2}.axes3;
    2468         %PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the viewinterface
    24692491        PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface
    2470        % keeplim(2)=get(plot_handles{2}.CheckFixLimits,'Value');
    24712492        PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
    24722493    end
    24732494end
    24742495
    2475 %loop on the projection objects: one or two
     2496%% loop on the projection objects: one or two
    24762497for imap=1:numel(IndexObj)
    24772498    iobj=IndexObj(imap);
    2478      if iobj==1 && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object)
    2479          [ObjectData,errormsg]=calc_field(UvData.Field.FieldList,UvData.Field);
    2480      else
     2499%      if imap==2 || check_proj==0  % field not yet projected) && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object)
     2500% %          [ObjectData,errormsg]=calc_field(UvData.Field.FieldList,UvData.Field);
     2501% %      else
    24812502        [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
    2482      end
     2503%      end
    24832504    if ~isempty(errormsg)
    24842505        return
     
    29913012UvData.filename_1='';% desactivate the use of a constant second file
    29923013list_fields=get(handles.Fields,'String');% list menu fields
    2993 index_fields=get(handles.Fields,'Value');% selected string index
    2994 field= list_fields{index_fields(1)}; % selected string
     3014field= list_fields{get(handles.Fields,'Value')}; % selected string
    29953015list_fields=get(handles.Fields_1,'String');% list menu fields
    2996 index_fields=get(handles.Fields_1,'Value');% selected string index
    2997 field_1= list_fields{index_fields(1)}; % selected string for the second field
    2998 if isequal(field_1,'')||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image'))
     3016field_1= list_fields{get(handles.Fields_1,'Value')}; % selected string for the second field
     3017if isempty(field_1)%||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image'))
    29993018    set(handles.SubField,'Value',0)
    3000     check_new=1;
     3019%     check_new=1;
    30013020    SubField_Callback(hObject, eventdata, handles)
    3002     if isempty(field_1)%remove second field if 'blank' field is selected
     3021%     if isempty(field_1)%remove second field if 'blank' field is selected
    30033022        return
    3004     end
    3005 end
    3006 set(handles.SubField,'Value',1)%state that a second field is now entered
     3023%     end
     3024else
     3025    set(handles.SubField,'Value',1)%state that a second field is now entered
     3026end
    30073027
    30083028%% read the rootfile input display
    3009 [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomTYpe_1]=read_file_boxes_1(handles);
     3029[RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
    30103030filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
    30113031[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
    3012 set(handles.FileIndex_1,'Visible','on')
    3013 set(handles.FileExt_1,'Visible','on')
     3032% set(handles.FileIndex_1,'Visible','on')
     3033% set(handles.FileExt_1,'Visible','on')
    30143034switch field_1
    30153035    case 'get_field...'
     
    30273047        set(handles.path_transform,'String','')
    30283048    case 'image'
    3029         % transform netc type to the corresponding image type
    3030         NomType=get(handles.NomType,'string');
    3031         check_letter=~isempty(regexp(NomType,'[ab|AB]$'));%detect pair label by letter
    3032 %         NomType_1=NomType;
    3033 %         if check_letter
    3034 %             NomType_1=NomType_1(1:end-1);
    3035 %         else
    3036 %             r=regexp(NomType_1,'.-(?<num2>\d+$','names');
    3037 %             if ~isempty(r)
    3038 %                 NomType_1=regexprep(NomType_1,['-' r.num2],'');
    3039 %             end
    3040 %         end
    3041         imagename=fullfile_uvmat(RootPath_1,'',RootFile_1,'.png',NomType,i1,[],j1);
    3042         if ~exist(imagename,'file')
     3049        % guess the image name corresponding to the current netcdf name (no unique correspondance)
     3050        imagename=fullfile_uvmat(RootPath_1,'',RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
     3051        if ~exist(imagename,'file') % browse for images if it is not found
    30433052            [FileName,PathName] = uigetfile( ...
    30443053                {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
     
    30503059                '*.*',  'All Files (*.*)'}, ...
    30513060                'Pick an image',imagename);
    3052             % display the selected field and related information
    30533061            imagename=[PathName FileName];
    30543062        end
    3055         set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons
    3056         set(handles.TitleNpy,'Visible','on')
    3057         set(handles.num_Npx,'Visible','on')
    3058         set(handles.num_Npy,'Visible','on')
    3059         display_file_name(hObject, eventdata, handles,imagename,2)%display the imag
     3063        if ~ischar(imagename)% quit if the browser has  been closed
     3064            set(handles.SubField,'Value',0)
     3065        else %valid browser input:  display the selected image
     3066            set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons
     3067            set(handles.TitleNpy,'Visible','on')
     3068            set(handles.num_Npx,'Visible','on')
     3069            set(handles.num_Npy,'Visible','on')
     3070            display_file_name(hObject, eventdata, handles,imagename,2)%display the imag
     3071        end
    30603072    otherwise
    30613073        if check_new
     
    30713083        end
    30723084        set(handles.uvmat,'UserData',UvData)
    3073 %         setfield(handles);% update the field structure ('civ1'....)
    30743085        if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
    30753086            run0_Callback(hObject, eventdata, handles)
     
    31123123        end
    31133124end
    3114 
    3115 
    3116 
    31173125menu=menu(1:imax);
    31183126
     
    31213129function FixVelType_Callback(hObject, eventdata, handles)
    31223130%------------------------------------------------------------------------
    3123 val=get(handles.FixVelType,'Value');
    3124 if ~val
     3131% refresh the current plot if the fixed  veltype is unselected
     3132if ~get(handles.FixVelType,'Value')
    31253133    run0_Callback(hObject, eventdata, handles)
    31263134end
     
    31373145function VelType_1_Callback(hObject, eventdata, handles)
    31383146%------------------------------------------------------------------------
    3139  
    31403147set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic)
    31413148UvData=get(handles.uvmat,'UserData');
    3142 %refresh field with a second filename=first fiel name
     3149%refresh field with a second filename=first file name
    31433150set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
    31443151drawnow   
     
    31463153[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    31473154filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    3148 % VelTypeList=get(handles.VelType_1,'String');
    3149 % VelType_1=VelTypeList{get(handles.VelType_1,'Value')};
     3155
    31503156if isempty(InputFile.VelType_1)
    31513157        filename_1='';% we plot the current field without the second field
     
    31553161      [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    31563162     filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
    3157 %       UvData.VelType{2}=InputFile.VelType_1;
    3158 else
    3159      filename_1=filename;% we compare two fields in the same file
     3163else
     3164     filename_1=filename;% we compare two fields in the same file by default
    31603165     UvData.FileType{2}=UvData.FileType{1};
    3161 %      UvData.VelType{2}=InputFile.VelType_1;
    31623166     set(handles.SubField,'Value',1)
    31633167end
     
    33693373%------------------------------------------------------------------
    33703374
    3371 %------------------------------------------------------------------
    3372 % --- Executes on selection change in ListColorScalar: choice of the color code.
    3373 function ListColorScalar_Callback(hObject, eventdata, handles)
    3374 %------------------------------------------------------------------
    3375 % edit the choice for color code
    3376 list_code=get(handles.ListColorScalar,'String');% list menu fields
    3377 index_code=get(handles.ListColorScalar,'Value');% selected string index
    3378 col_code= list_code{index_code(1)}; % selected field
    3379 if isequal(col_code,'black') || isequal(col_code,'white')
    3380    set(handles.Slider1,'Visible','off')
    3381    set(handles.Slider2,'Visible','off')
    3382    set(handles.num_ColCode1,'Visible','off')
    3383    set(handles.num_ColCode2,'Visible','off')
    3384    set(handles.CheckFixVecColor,'Visible','off')
    3385    set_vec_col_bar(handles)
    3386 else
    3387    set(handles.Slider1,'Visible','on')
    3388    set(handles.Slider2,'Visible','on')
    3389    set(handles.num_ColCode1,'Visible','on')
    3390    set(handles.num_ColCode2,'Visible','on')
    3391    set(handles.CheckFixVecColor,'Visible','on') 
    3392    if isequal(col_code,'ima_cor')
    3393        set(handles.CheckFixVecColor,'Value',0)%fixed scale by default
    3394        set(handles.VecColBar,'Value',0)% 3 colors r,g,b by default
    3395        set(handles.Slider1,'Min',0);
    3396        set(handles.Slider1,'Max',1);
    3397        set(handles.Slider2,'Min',0);
    3398        set(handles.Slider2,'Max',1);
    3399  %      set(handles.min_title_vec,'String','0')
    3400        set(handles.num_MaxVec,'String','1')
    3401        set(handles.num_ColCode1,'String','0.333')
    3402        num_ColCode1_Callback(hObject, eventdata, handles)
    3403        set(handles.num_ColCode2,'String','0.666')
    3404        num_ColCode2_Callback(hObject, eventdata, handles)
    3405    else
    3406        set(handles.CheckFixVecColor,'Value',1)%auto scale between min,max by default
    3407        set(handles.VecColBar,'Value',1)% colormap 'jet' by default
    3408        minval=get(handles.Slider1,'Min');
    3409        maxval=get(handles.Slider1,'Max');
    3410        set(handles.Slider1,'Value',minval)
    3411        set(handles.Slider2,'Value',maxval)
    3412        set_vec_col_bar(handles)
    3413    end
    3414 %    slider_update(handles)
    3415 end
    3416 %replot the current graph
    3417 run0_Callback(hObject, eventdata, handles)
    3418 
    3419 
    3420 %----------------------------------------------------------------
    3421 % -- Executes on slider movement to set the color code
    3422 %
    3423 function Slider1_Callback(hObject, eventdata, handles)
    3424 %------------------------------------------------------------------
    3425 slider1=get(handles.Slider1,'Value');
    3426 min_val=str2num(get(handles.num_MinVec,'String'));
    3427 max_val=str2num(get(handles.num_MaxVec,'String'));
    3428 col=min_val+(max_val-min_val)*slider1;
    3429 set(handles.num_ColCode1,'String',num2str(col))
    3430 if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed
    3431     set(handles.Slider2,'Value',col)
    3432     set(handles.num_ColCode2,'String',num2str(col))
    3433 end
    3434 num_ColCode1_Callback(hObject, eventdata, handles)
    3435 
    3436 %----------------------------------------------------------------
    3437 % Executes on slider movement to set the color code
    3438 %----------------------------------------------------------------
    3439 function Slider2_Callback(hObject, eventdata, handles)
    3440 slider2=get(handles.Slider2,'Value');
    3441 min_val=str2num(get(handles.num_MinVec,'String'));
    3442 max_val=str2num(get(handles.num_MaxVec,'String'));
    3443 col=min_val+(max_val-min_val)*slider2;
    3444 set(handles.num_ColCode2,'String',num2str(col))
    3445 if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed
    3446     set(handles.Slider1,'Value',col)
    3447     set(handles.num_ColCode1,'String',num2str(col))
    3448 end
    3449 num_ColCode2_Callback(hObject, eventdata, handles)
    3450 
    3451 %----------------------------------------------------------------
    3452 % --- Execute on return carriage on the edit box corresponding to slider 1
    3453 %----------------------------------------------------------------
    3454 function num_ColCode1_Callback(hObject, eventdata, handles)
    3455 set_vec_col_bar(handles)
    3456 update_plot(handles);
    3457 
    3458 %----------------------------------------------------------------
    3459 % --- Execute on return carriage on the edit box corresponding to slider 2
    3460 %----------------------------------------------------------------
    3461 function num_ColCode2_Callback(hObject, eventdata, handles)
    3462 set_vec_col_bar(handles)
    3463 update_plot(handles);
    3464 %------------------------------------------------------------------------
    3465 %-------------------------------------------------------
    3466 % --- Executes on button press in CheckFixVecColor.
    3467 %-------------------------------------------------------
    3468 function VecColBar_Callback(hObject, eventdata, handles)
    3469 set_vec_col_bar(handles)
     3375
    34703376
    34713377%-------------------------------------------------------------
     
    36493555%CALLBACKS FOR PLOTTING PARAMETERS
    36503556%-------------------------------------------------
    3651 
     3557%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     3558% Plot coordinates
     3559%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    36523560%------------------------------------------------------------------------
    36533561function num_MinX_Callback(hObject, eventdata, handles)
     
    36783586update_plot(handles);
    36793587
     3588%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     3589% Scalar or image representation
     3590%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    36803591%------------------------------------------------------------------------
    36813592function num_MinA_Callback(hObject, eventdata, handles)
     
    37443655update_plot(handles);
    37453656
     3657
     3658%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     3659% Vector representation
     3660%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    37463661%-------------------------------------------------------------------
    37473662function CheckHideWarning_Callback(hObject, eventdata, handles)
     
    37803695
    37813696%------------------------------------------------------------------------
    3782 % --- Executes on selection change in ListColorCode menu
    3783 function ListColorCode_Callback(hObject, eventdata, handles)
    3784 %------------------------------------------------------------------------
     3697% --- Executes on selection change in ColorCode menu
     3698function ColorCode_Callback(hObject, eventdata, handles)
     3699%------------------------------------------------------------------------
     3700% edit the choice for color code
     3701update_color_code_boxes(handles);
     3702update_plot(handles);
     3703
     3704%------------------------------------------------------------------------
     3705function update_color_code_boxes(handles)
     3706%------------------------------------------------------------------------
     3707list_code=get(handles.ColorCode,'String');% list menu fields
     3708colcode= list_code{get(handles.ColorCode,'Value')}; % selected field
     3709enable_slider='off';%default
     3710enable_bounds='off';%default
     3711enable_scalar='off';%default
     3712switch colcode
     3713    case {'rgb','bgr'}
     3714        enable_slider='on';
     3715        enable_bounds='on';
     3716        enable_scalar='on';
     3717    case '64 colors'
     3718        enable_bounds='on';
     3719        enable_scalar='on';
     3720end
     3721set(handles.Slider1,'Visible',enable_slider)
     3722set(handles.Slider2,'Visible', enable_slider)
     3723set(handles.num_ColCode1,'Visible',enable_slider)
     3724set(handles.num_ColCode2,'Visible',enable_slider)
     3725set(handles.TitleColCode1,'Visible',enable_slider)
     3726set(handles.TitleColCode2,'Visible',enable_slider)
     3727set(handles.CheckFixVecColor,'Visible',enable_bounds)
     3728set(handles.num_MinVec,'Visible',enable_bounds)
     3729set(handles.num_MaxVec,'Visible',enable_bounds)
     3730set(handles.ColorScalar,'Visible',enable_scalar)
     3731set_vec_col_bar(handles)
     3732
     3733%------------------------------------------------------------------
     3734% --- Executes on selection change in ColorScalar: choice of the color code.
     3735function ColorScalar_Callback(hObject, eventdata, handles)
     3736%------------------------------------------------------------------
     3737% edit the choice for color code
     3738list_scalar=get(handles.ColorScalar,'String');% list menu fields
     3739col_scalar= list_scalar{get(handles.ColorScalar,'Value')}; % selected field
     3740if isequal(col_scalar,'ima_cor')
     3741    set(handles.CheckFixVecColor,'Value',1)%fixed scale by default
     3742    ColorCode='rgb';
     3743    set(handles.num_MinVec,'String','0')
     3744    set(handles.num_MaxVec,'String','1')
     3745    set(handles.num_ColCode1,'String','0.333')
     3746    set(handles.num_ColCode2,'String','0.666')
     3747else
     3748    set(handles.CheckFixVecColor,'Value',0)%auto scale between min,max by default
     3749    ColorCode='64 colors';
     3750end
     3751ColorCodeList=get(handles.ColorCode,'String');
     3752ichoice=find(strcmp(ColorCode,ColorCodeList),1);
     3753set(handles.ColorCode,'Value',ichoice)% set color code in the menu
     3754
     3755update_color_code_boxes(handles);
     3756%replot the current graph
     3757run0_Callback(hObject, eventdata, handles)
     3758
     3759%----------------------------------------------------------------
     3760% -- Executes on slider movement to set the color code
     3761%
     3762function Slider1_Callback(hObject, eventdata, handles)
     3763%------------------------------------------------------------------
     3764slider1=get(handles.Slider1,'Value');
     3765min_val=str2num(get(handles.num_MinVec,'String'));
     3766max_val=str2num(get(handles.num_MaxVec,'String'));
     3767col=min_val+(max_val-min_val)*slider1;
     3768set(handles.num_ColCode1,'String',num2str(col))
     3769if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed
     3770    set(handles.Slider2,'Value',col)
     3771    set(handles.num_ColCode2,'String',num2str(col))
     3772end
    37853773set_vec_col_bar(handles)
    37863774update_plot(handles);
    37873775
     3776%----------------------------------------------------------------
     3777% Executes on slider movement to set the color code
     3778%----------------------------------------------------------------
     3779function Slider2_Callback(hObject, eventdata, handles)
     3780slider2=get(handles.Slider2,'Value');
     3781min_val=str2num(get(handles.num_MinVec,'String'));
     3782max_val=str2num(get(handles.num_MaxVec,'String'));
     3783col=min_val+(max_val-min_val)*slider2;
     3784set(handles.num_ColCode2,'String',num2str(col))
     3785if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed
     3786    set(handles.Slider1,'Value',col)
     3787    set(handles.num_ColCode1,'String',num2str(col))
     3788end
     3789set_vec_col_bar(handles)
     3790update_plot(handles);
     3791
     3792%----------------------------------------------------------------
     3793% --- Execute on return carriage on the edit box corresponding to slider 1
     3794%----------------------------------------------------------------
     3795function num_ColCode1_Callback(hObject, eventdata, handles)
     3796set_vec_col_bar(handles)
     3797update_plot(handles);
     3798
     3799%----------------------------------------------------------------
     3800% --- Execute on return carriage on the edit box corresponding to slider 2
     3801%----------------------------------------------------------------
     3802function num_ColCode2_Callback(hObject, eventdata, handles)
     3803set_vec_col_bar(handles)
     3804update_plot(handles);
     3805%------------------------------------------------------------------------
     3806%-------------------------------------------------------
     3807% --- Executes on button press in CheckFixVecColor.
     3808%-------------------------------------------------------
     3809function VecColBar_Callback(hObject, eventdata, handles)
     3810set_vec_col_bar(handles)
     3811
    37883812%------------------------------------------------------------------------
    37893813% --- Executes on button press in CheckFixVecColor.
    37903814function CheckFixVecColor_Callback(hObject, eventdata, handles)
    37913815%------------------------------------------------------------------------
    3792 test=get(handles.CheckFixVecColor,'Value');
    3793 if test
    3794     set(handles.CheckFixVecColor,'BackgroundColor',[1 1 0])
    3795 else
     3816if ~get(handles.CheckFixVecColor,'Value')
    37963817    update_plot(handles);
    3797     %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3))
    3798     set(handles.CheckFixVecColor,'BackgroundColor',[0.7 0.7 0.7])
    37993818end
    38003819
     
    38223841
    38233842%------------------------------------------------------------------------
    3824 % --- update the display of color code for vectors
     3843% --- update the display of color code for vectors (on vecColBar)
    38253844function set_vec_col_bar(handles)
    38263845%------------------------------------------------------------------------
     
    38333852
    38343853%get slider indications
    3835 list=get(handles.ListColorCode,'String');
    3836 ichoice=get(handles.ListColorCode,'Value');
    3837 colcode.ListColorCode=list{ichoice};
     3854list=get(handles.ColorCode,'String');
     3855ichoice=get(handles.ColorCode,'Value');
     3856colcode.ColorCode=list{ichoice};
    38383857colcode.MinVec=str2num(get(handles.num_MinVec,'String'));
    38393858colcode.MaxVec=str2num(get(handles.num_MaxVec,'String'));
    3840 test3color=strcmp(colcode.ListColorCode,'rgb') || strcmp(colcode.ListColorCode,'bgr');
     3859test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
    38413860if test3color
    38423861    colcode.ColCode1=str2num(get(handles.num_ColCode1,'String'));
    38433862    colcode.ColCode2=str2num(get(handles.num_ColCode2,'String'));
    38443863end
    3845 % colcode.FixedCbounds=0;
    3846 %colcode.CheckFixVecColor=1;
    38473864vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max
    38483865[colorlist,col_vec]=set_col_vec(colcode,vec_C);
     
    46414658    web(helpfile);
    46424659end
    4643 
    4644 
    4645 
    4646 
Note: See TracChangeset for help on using the changeset viewer.