Changeset 871 for trunk/src/uvmat.m


Ignore:
Timestamp:
Feb 16, 2015, 12:15:23 AM (6 years ago)
Author:
sommeria
Message:

histo improved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r867 r871  
    4444%          .Field: cell array of 1 or 2 structures representing the current  input field(s)
    4545%          .PlotAxes: field structure representing the current field plotted  on the main axes  (used for mouse operations)
    46 %          .HistoAxes: idem for histogram axes
     46%          .HistoAxes: idem for Histogram axes
    4747
    4848% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   DATA FLOW  (for REFRESH_Callback) %%%%%%%%%%%%%%%%%%%%:
     
    6969%                        (tps_coeff_field.m)               calculate tps coefficients (for filter projection or spatial derivatives).
    7070%                            |
    71 %                       UvData.Field-------------->histogram
     71%                       UvData.Field-------------->Histogram
    7272%               _____________|____________
    7373%              |                          |                   
     
    358358%% reset position of text_display and TableDisplay
    359359set(handles.text_display,'Units','pixels')
     360set(handles.TableDisplay,'Units','pixels')
    360361pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display
    361362    pos_1(3)=1.2*ColumnWidth;
     
    363364pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4);             % set text display to the top of the fig
    364365set(handles.text_display,'Position',pos_1)
    365 set(handles.TableDisplay,'Position',pos_1)
     366set(handles.TableDisplay,'Position',[pos_1(1) 10 pos_1(3) 5*pos_1(4)])
    366367% reset position of CheckTable
    367368set(handles.CheckTable,'Units','pixels')
     
    25562557    msgbox_uvmat('ERROR',errormsg);
    25572558end
     2559set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back in red
    25582560
    25592561%------------------------------------------------------------------------
     
    25742576    msgbox_uvmat('ERROR',errormsg);
    25752577end
     2578set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back in red
    25762579
    25772580%------------------------------------------------------------------------
     
    36143617if UvData.Field.NbDim<=1
    36153618    set(handles.Objects,'Visible','off')
     3619    set(handles.CheckFixAspectRatio,'Value',0)
    36163620    [PlotType,PlotParamOut,haxes]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat));
    36173621    UvData.PlotAxes=UvData.Field; %store data for further plot modifications
     
    36223626        end
    36233627    end
     3628    set(handles.Histogram,'Visible','off')
     3629    set(handles.HistoMenu,'Visible','off')
     3630    set(handles.HistoAxes,'Visible','off')
     3631    hlegend=findobj(handles.uvmat,'Tag','HistoLegend');
     3632    if ~isempty(hlegend)
     3633        delete(hlegend)
     3634    end
     3635    cla(handles.HistoAxes)% clear the curves and legend in histogram axes
    36243636    set(handles.uvmat,'UserData',UvData)
    36253637%% 2D or 3D fieldname are generally projected
     
    36903702        PlotParam{1}.Vectors.ColorCode= {'rgb'};
    36913703    end
    3692     %PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
    36933704   
    36943705    %% second projection object (view_field display)
     
    36993710            haxes(2)=plot_handles{2}.PlotAxes;
    37003711            PlotParam{2}=read_GUI(view_field_handle);
    3701             %PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
    37023712        end
    37033713    end
    37043714   
    3705     %% loop on the projection objects: one or two
    3706    
     3715    %% loop on the projection objects: one or two
    37073716    for imap=1:numel(IndexObj)
    37083717        iobj=IndexObj(imap);
     
    37583767        set(handles.uvmat,'UserData',UvData)
    37593768        if ~isempty(ObjectData)
    3760             %PlotType='none'; %default
    37613769            if imap==2 && isempty(view_field_handle)
    37623770                view_field(ObjectData)
     
    37723780                        set_object('ProjMode_Callback',hset_object,[],hhset_object);
    37733781                    end
    3774 %                     errormsg=PlotType;
    37753782                    return
    37763783                end
     
    37973804    end
    37983805   
    3799     %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
     3806    %% prepare the menus of histograms and plot them (Histogram of the whole volume in 3D case)
    38003807    menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
    38013808    ind_skip=[];
     
    38033810    Ustring='';
    38043811    Vstring='';
    3805     % suppress axes from the histogram menu
     3812    % suppress axes from the Histogram menu
    38063813    for ivar=1:numel(menu_histo)%l loop on field variables:
    38073814        if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
     
    38383845    test_v=0;
    38393846    if ~isempty(menu_histo)
    3840         set(handles.histo1_menu,'Value',1)
    3841         set(handles.histo1_menu,'String',menu_histo)
    3842         histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram
     3847        set(handles.HistoMenu,'Value',1)
     3848        set(handles.HistoMenu,'String',menu_histo)
     3849        set(handles.Histogram,'Visible','on')
     3850        set(handles.HistoMenu,'Visible','on')
     3851        set(handles.HistoAxes,'Visible','on')
     3852        HistoMenu_Callback(handles.HistoMenu, [], handles)% plot first histogram
    38433853    end
    38443854end
     
    38523862
    38533863%------------------------------------------------------------------------
    3854 function histo1_menu_Callback(hObject, eventdata, handles)
     3864function HistoMenu_Callback(hObject, eventdata, handles)
    38553865%--------------------------------------------
    38563866%% get the current field stored in uvmat user data
     
    38583868Field=UvData.Field;
    38593869
    3860 %% get from the menu 'histo1_menu' the name(s) of the fields to use
    3861 histo_menu=get(handles.histo1_menu,'String');
    3862 histo_value=get(handles.histo1_menu,'Value');
     3870%% get from the menu 'HistoMenu' the name(s) of the fields to use
     3871histo_menu=get(handles.HistoMenu,'String');
     3872histo_value=get(handles.HistoMenu,'Value');
    38633873FieldName=histo_menu{histo_value};
    38643874r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names');
     
    39023912end
    39033913
    3904 %% calculate and plot histogram
     3914%% calculate and plot Histogram
    39053915if isempty(Field)
    39063916    msgbox_uvmat('ERROR',['empty field ' FieldName])
     
    39353945            Histo.VarAttribute{1}.units=units;
    39363946        end
    3937         Histo.(FieldName)=linspace(Amin,Amax,50); %absissa values for histo
     3947        VarMesh=(Amax-Amin)/100;
     3948        ord=10^(floor(log10(VarMesh)));%order of magnitude
     3949        if VarMesh/ord >=5
     3950            VarMesh=5*ord;
     3951        elseif VarMesh/ord >=2
     3952            VarMesh=2*ord;
     3953        else
     3954            VarMesh=ord;
     3955        end
     3956        Amin=VarMesh*(ceil(Amin/VarMesh));
     3957        Amax=VarMesh*(floor(Amax/VarMesh));
     3958        Histo.(FieldName)=Amin:VarMesh:Amax; %absissa values for histo
    39383959        if isfield(Field,'NbDim') && isequal(Field.NbDim,3)
    39393960            C=reshape(double(FieldHisto),1,[]);% reshape in a vector
     
    39473968        end
    39483969        plot_field(Histo,handles.HistoAxes);
    3949         hlegend=legend;
     3970        hlegend=findobj(handles.uvmat,'Tag','HistoLegend');
     3971        if isempty(hlegend)
     3972            hlegend=legend;
     3973            set(hlegend,'Tag','HistoLegend')
     3974        end
    39503975        if isempty(FieldName_2)
    3951         set(hlegend,'String',FieldName)
     3976            set(hlegend,'String',FieldName)
    39523977        else
    39533978            set(hlegend,'String',{FieldName;FieldName_2})
     
    46774702        data.CoordType=UvData.CoordType;
    46784703    end
    4679     if isfield(UvData.Field,'CoordMesh')&~isempty(UvData.Field.CoordMesh)
     4704    if isfield(UvData.Field,'CoordMesh')&& ~isempty(UvData.Field.CoordMesh)
    46804705        data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
    46814706        data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
    46824707        data.DX=UvData.Field.CoordMesh;
    46834708        data.DY=UvData.Field.CoordMesh;
    4684     elseif isfield(UvData.Field,'Coord_x')&isfield(UvData.Field,'Coord_y')& isfield(UvData.Field,'A')%only image
     4709    elseif isfield(UvData.Field,'Coord_x')&& isfield(UvData.Field,'Coord_y') && isfield(UvData.Field,'A')%only image
    46854710        np=size(UvData.Field.A);
    46864711        meshx=(UvData.Field.Coord_x(end)-UvData.Field.Coord_x(1))/np(2);
     
    56865711    set(handles.PlotAxes,'Visible','on')
    56875712    set(handles.text_display,'Visible','on')
    5688     if isfield(handles,'TableDisplay')
    5689     set(handles.TableDisplay,'Visible','off')
    5690     end
     5713%     if isfield(handles,'TableDisplay')
     5714%     set(handles.TableDisplay,'Visible','off')
     5715%     end
    56915716    Coordinates=PlotParam.Axes;
    56925717    if isfield(Coordinates,'CheckFixAspectRatio')
Note: See TracChangeset for help on using the changeset viewer.