Changeset 690


Ignore:
Timestamp:
Sep 29, 2013, 1:19:30 PM (11 years ago)
Author:
sommeria
Message:

representation of ancillary data as table improved.

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_field_cells.m

    r675 r690  
    209209VarDimName=Data.VarDimName(~check_select);%dimensions of remaining variables
    210210check_coord_select= cellfun(@numel,VarDimName)==1|cellfun(@ischar,VarDimName)==1;% find remaining variables with a single dimension
     211check_coord_select=check_coord_select & ~strcmp('ancillary',Role(~check_select));% do not select ancillary variables as coordinates
    211212%check_coord(~check_select)=check_coord_select;
    212213ListCoordIndex=ivar_remain(check_coord_select);% indices of remaining variables with a single dimension
  • trunk/src/plot_field.m

    r688 r690  
    112112
    113113%% check input structure
    114 index_2D=[];
    115 index_1D=[];
    116 index_0D=[];
    117114% check the cells of fields :
    118115[CellInfo,NbDimArray,errormsg]=find_field_cells(Data);
    119 %[CellVarIndex,NbDim,CoordType,VarRole,errormsg]=find_field_cells(Data);
    120116if ~isempty(errormsg)
    121117    msgbox_uvmat('ERROR',['input of plot_field/find_field_cells: ' errormsg]);
     
    171167    set(haxes,'YLimMode', 'auto')
    172168end
    173 % if ~isfield(PlotParam.Coordinates,'CheckFixAspectRatio')&& isfield(Data,'CoordUnit')
    174 %     PlotParam.Coordinates.CheckFixAspectRatio=1;% if CoordUnit is defined, the two coordiantes should be plotted with equal scale by default
    175 % end
    176169errormsg='';
    177 %PlotParamOut.Coordinates=[]; %default output
    178170AxeData=get(haxes,'UserData');
    179171
     
    210202
    211203%% text display
    212 if isempty(index_2D) && isempty(index_1D)%text display alone
    213     htext=findobj(hfig,'Tag','TableDisplay');
    214 else  %text display added to plot
    215     htext=findobj(hfig,'Tag','text_display');
    216 end
    217 if ~isempty(htext)
     204
     205htext=findobj(hfig,'Tag','TableDisplay');
     206hchecktable=findobj(hfig,'Tag','CheckTable');
     207% if isempty(index_2D) && isempty(index_1D)%text display alone
     208%     htext=findobj(hfig,'Tag','TableDisplay');
     209% else  %text display added to plot
     210%     %htext=findobj(hfig,'Tag','text_display');
     211% end
     212if ~isempty(htext)&&~isempty(hchecktable)
    218213    if isempty(index_0D)
    219         if strcmp(get(htext,'Type'),'uitable')
    220             set(htext,'Data',{})
    221         else
    222             set(htext,'String',{''})
    223         end
     214        set(htext,'Data',{})
     215        set(htext,'visible','off')
     216        set(hchecktable,'visible','off')
     217        set(hchecktable,'Value',0)
    224218    else
    225         [errormsg]=plot_text(Data,CellInfo(index_0D),htext);
     219        errormsg=plot_text(Data,CellInfo(index_0D),htext);
     220        set(htext,'visible','on')
     221        set(hchecktable,'visible','on')
     222        set(hchecktable,'Value',1)
     223    end
     224    set(hfig,'Unit','pixels');
     225    set(htext,'Unit','pixels')
     226    PosFig=get(hfig,'Position');
     227    % case of no plot with view_field: only text display
     228    if strcmp(get(hfig,'Tag'),'view_field')
     229        if isempty(index_1D) && isempty(index_2D)% case of no plot: only text display
     230            set(haxes,'Visible','off')         
     231            PosTable=get(htext,'Position');
     232            set(hfig,'Position',[PosFig(1) PosFig(2)  PosTable(3) PosTable(4)])
     233        else
     234            set(haxes,'Visible','on')
     235            set(hfig,'Position',[PosFig(1) PosFig(2)  877 677])%default size for view_field
     236        end
    226237    end
    227238end
     
    252263
    253264%-------------------------------------------------------------------
     265% --- plot 0D fields: display data values without plot
     266%------------------------------------------------------------------
    254267function errormsg=plot_text(FieldData,CellInfo,htext)
    255 %-------------------------------------------------------------------
     268
    256269errormsg='';
    257270txt_cell={};
    258271Data={};
     272VarIndex=[];
    259273for icell=1:length(CellInfo)
    260274   
     
    267281        end
    268282    end
    269     VarIndex=find(check_proj);
    270     %
    271     %     VarIndex=CellInfo{icell}.VarIndex;%  indices of the selected variables in the list data.ListVarName
    272     %     for ivar=1:length(VarIndex)
    273     %         checkancillary=0;
    274     %         if length(FieldData.VarAttribute)>=VarIndex(ivar)
    275     %             VarAttribute=FieldData.VarAttribute{VarIndex(ivar)};
    276     %             if isfield(VarAttribute,'Role')&&(strcmp(VarAttribute.Role,'ancillary')||strcmp(VarAttribute.Role,'coord_tps')...
    277     %                     ||strcmp(VarAttribute.Role,'vector_x_tps')||strcmp(VarAttribute.Role,'vector_y_tps'))
    278     %                 checkancillary=1;
    279     %             end
    280     %         end
    281     %         if ~checkancillary% does not display variables with attribute '.Role=ancillary'
    282     for ivar=1:length(VarIndex)
    283     VarName=FieldData.ListVarName{VarIndex(ivar)};
    284     VarValue=FieldData.(VarName);
    285     if isvector(VarValue')
    286         VarValue=VarValue';% put the different values on a line
    287     end
    288     if numel(VarValue)>1 && numel(VarValue)<10
    289         for ind=1:numel(VarValue)
    290             VarNameCell{1,ind}=[VarName '_' num2str(ilist)];
    291         end
    292     else
    293         VarNameCell={VarName};
    294     end
    295     if numel(VarValue)<10
    296         if isempty(VarValue)
    297             VarValueCell={'[]'};
    298         else
    299             VarValueCell=num2cell(VarValue);
    300         end
    301         if isempty(Data)
    302             Data =[VarNameCell; VarValueCell];
    303         else
    304             Data =[Data [VarNameCell; VarValueCell]];
    305         end
    306     else
    307         if isempty(Data)
    308             Data =[VarNameCell; num2cell(VarValue)];
    309         else
    310         Data =[Data [VarNameCell; {['size ' num2str(size(VarValue))]}]];
    311         end
    312     end
    313     if size(VarValue,1)==1
    314         txt=[VarName '=' num2str(VarValue)];
    315         txt_cell=[txt_cell;{txt}];
    316     end
    317     end
    318 end
    319 if strcmp(get(htext,'Type'),'uitable')
    320     get(htext,'ColumnName')
    321     set(htext,'ColumnName',Data(1,:))
    322     set(htext,'Data',Data(2:end,:))
    323 else
    324     set(htext,'String',txt_cell)
    325     set(htext,'UserData',txt_cell)% for storage during mouse display
    326 end
    327 
    328 
     283    VarIndex=[VarIndex find(check_proj)];
     284end
     285
     286% data need to be displayed in a table
     287if strcmp(get(htext,'Type'),'uitable')% display data in a table
     288    VarNameCell=cell(1,numel(VarIndex));% prepare list of variable names to display (titles of columns)
     289    VarLength=zeros(1,numel(VarIndex));  % default number of values for each variable
     290    for ivar=1:numel(VarIndex)
     291        VarNameCell{ivar}=FieldData.ListVarName{VarIndex(ivar)};
     292        VarLength(ivar)=numel(FieldData.(VarNameCell{ivar}));
     293    end
     294    set(htext,'ColumnName',VarNameCell)
     295    Data=cell(max(VarLength),numel(VarIndex));% prepare the table of data display
     296   
     297    for ivar=1:numel(VarIndex)
     298        VarValue=FieldData.(VarNameCell{ivar});
     299        VarValue=reshape(VarValue,[],1);% reshape values array in a column
     300        Data(1:numel(VarValue),ivar)=num2cell(VarValue);
     301    end
     302    set(htext,'Data',Data)
     303end
     304%         if numel(VarValue)>1 && numel(VarValue)<10 % case of a variable with several values
     305%             for ind=1:numel(VarValue)
     306%                 VarNameCell{1,ind}=[VarName '_' num2str(ind)];% indicate each value by an index
     307%             end
     308%         else
     309%             VarNameCell={VarName};
     310%         end
     311%         if numel(VarValue)<10
     312%             if isempty(VarValue)
     313%                 VarValueCell={'[]'};
     314%             else
     315%                 VarValueCell=num2cell(VarValue);
     316%             end
     317%             if isempty(Data)
     318%                 Data =[VarNameCell VarValueCell];
     319%             else
     320%                 Data =[Data [VarNameCell VarValueCell]];
     321%             end
     322%         else
     323%             if isempty(Data)
     324%                 Data =[VarNameCell; num2cell(VarValue)];
     325%             else
     326%                 Data =[Data [VarNameCell; {['size ' num2str(size(VarValue))]}]];
     327%             end
     328%         end
     329%         if size(VarValue,1)==1
     330%             txt=[VarName '=' num2str(VarValue)];
     331%             txt_cell=[txt_cell;{txt}];
     332%         end
     333%     end
     334% end
     335% if strcmp(get(htext,'Type'),'uitable')% display data in a table
     336%
     337
     338%     set(htext,'Data',Data(2:end,:))
     339% else  % display in a text edit box
     340%     set(htext,'String',txt_cell)
     341%     set(htext,'UserData',txt_cell)% for temporary storage when the edit box is used for mouse display
     342% end
     343
     344
     345%-------------------------------------------------------------------
     346% --- plot 1D fields (usual x,y plots)
    329347%-------------------------------------------------------------------
    330348function CoordinatesOut=plot_profile(data,CellInfo,haxes,Coordinates,CheckHold)
    331 %-------------------------------------------------------------------
    332349
    333350%% initialization
     
    359376% end
    360377if CheckHold
    361      set(haxes,'NextPlot','add')
     378    set(haxes,'NextPlot','add')
    362379else
    363380    set(haxes,'NextPlot','replace')
     
    446463    end
    447464    if ~isempty(MinY)
    448     MinY_cell(icell)=min(MinY);
    449     MaxY_cell(icell)=max(MaxY);
     465        MinY_cell(icell)=min(MinY);
     466        MaxY_cell(icell)=max(MaxY);
    450467    end
    451468end
  • trunk/src/proj_field.m

    r684 r690  
    306306[ProjData,errormsg]=proj_heading(FieldData,ObjectData);
    307307
    308 objectfield=fieldnames(ObjectData);
     308%objectfield=fieldnames(ObjectData);
    309309widthx=0;
    310310widthy=0;
    311 if isfield(ObjectData,'RangeX')&~isempty(ObjectData.RangeX)
     311if isfield(ObjectData,'RangeX') && ~isempty(ObjectData.RangeX)
    312312    widthx=max(ObjectData.RangeX);
    313313end
    314 if isfield(ObjectData,'RangeY')&~isempty(ObjectData.RangeY)
     314if isfield(ObjectData,'RangeY') && ~isempty(ObjectData.RangeY)
    315315    widthy=max(ObjectData.RangeY);
    316316end
     
    324324CoordMesh=zeros(1,numel(FieldData.ListVarName));
    325325if isfield (FieldData,'VarAttribute')
    326     %ProjData.VarAttribute=FieldData.VarAttribute;%list of variable attribute names
    327326    for iattr=1:length(FieldData.VarAttribute)%initialization of variable attribute values
    328 %         ProjData.VarAttribute{iattr}={};
    329327        if isfield(FieldData.VarAttribute{iattr},'Unit')
    330328            unit{iattr}=FieldData.VarAttribute{iattr}.Unit;
     
    374372        ivar_Z=CellInfo{icell}.CoordIndex(1);
    375373    end
    376     if strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured coordinates
    377         %nbpoint=numel(FieldData.(FieldData.ListVarName{VarIndex(1)}));
    378         for ivar=[VarIndex ivar_X ivar_Y ivar_FF]
    379             VarName=FieldData.ListVarName{ivar};
    380             FieldData.(VarName)=reshape(FieldData.(VarName),[],1);
    381         end
    382         XName=FieldData.ListVarName{ivar_X};
    383         YName=FieldData.ListVarName{ivar_Y};
    384         coord_x=FieldData.(XName);
    385         coord_y=FieldData.(YName);
    386     end
    387     % image or 2D matrix
    388     if  strcmp(CellInfo{icell}.CoordType,'grid')%case of structured coordinates
    389         test_Amat=1;% test for image or 2D matrix
    390         AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
    391         AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};
    392         eval(['AX=FieldData.' AXName ';'])% x coordinate
    393         eval(['AY=FieldData.' AYName ';'])% y coordinate
    394         VarName=FieldData.ListVarName{VarIndex(1)};
    395         DimValue=size(FieldData.(VarName));
    396         if length(AX)==2
    397             AX=linspace(AX(1),AX(end),DimValue(2));
    398         end
    399         if length(AY)==2
    400             AY=linspace(AY(1),AY(end),DimValue(1));
    401         end
    402         if length(DimValue)==3
    403             testcolor=1;
    404             npxy(3)=3;
    405         else
    406             testcolor=0;
    407             npxy(3)=1;
    408         end
    409         [Xi,Yi]=meshgrid(AX,AY);
    410         npxy(1)=length(AY);
    411         npxy(2)=length(AX);
    412         Xi=reshape(Xi,npxy(1)*npxy(2),1);
    413         Yi=reshape(Yi,npxy(1)*npxy(2),1);
    414         for ivar=1:length(VarIndex)
    415             VarName=FieldData.ListVarName{VarIndex(ivar)};
    416             FieldData.(VarName)=reshape(FieldData.(VarName),npxy(1)*npxy(2),npxy(3)); % keep only non false vectors
    417         end
     374    switch CellInfo{icell}.CoordType
     375        case 'scattered' %case of unstructured coordinates
     376            for ivar=[VarIndex ivar_X ivar_Y ivar_FF]
     377                VarName=FieldData.ListVarName{ivar};
     378                FieldData.(VarName)=reshape(FieldData.(VarName),[],1);
     379            end
     380            XName=FieldData.ListVarName{ivar_X};
     381            YName=FieldData.ListVarName{ivar_Y};
     382            coord_x=FieldData.(XName);
     383            coord_y=FieldData.(YName);
     384            % image or 2D matrix
     385        case 'grid' %case of structured coordinates
     386            test_Amat=1;% test for image or 2D matrix
     387            AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
     388            AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};
     389            AX=FieldData.(AXName);% x coordinate
     390            AY=FieldData.(AYName);% y coordinate
     391            VarName=FieldData.ListVarName{VarIndex(1)};
     392            DimValue=size(FieldData.(VarName));
     393            if length(AX)==2
     394                AX=linspace(AX(1),AX(end),DimValue(2));
     395            end
     396            if length(AY)==2
     397                AY=linspace(AY(1),AY(end),DimValue(1));
     398            end
     399            if length(DimValue)==3
     400                testcolor=1;
     401                npxy(3)=3;
     402            else
     403                testcolor=0;
     404                npxy(3)=1;
     405            end
     406            [Xi,Yi]=meshgrid(AX,AY);
     407            npxy(1)=length(AY);
     408            npxy(2)=length(AX);
     409            Xi=reshape(Xi,npxy(1)*npxy(2),1);
     410            Yi=reshape(Yi,npxy(1)*npxy(2),1);
     411            for ivar=1:length(VarIndex)
     412                VarName=FieldData.ListVarName{VarIndex(ivar)};
     413                FieldData.(VarName)=reshape(FieldData.(VarName),npxy(1)*npxy(2),npxy(3)); % keep only non false vectors
     414            end
    418415    end
    419416    %select the indices in the range of action
     
    476473        end
    477474        if isfield(FieldData,'VarAttribute')&& numel(FieldData.VarAttribute)>=ivar
    478         ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}];
     475            ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}];
    479476        end
    480477    end
  • trunk/src/uvmat.m

    r689 r690  
    356356set(handles.InputFile,'Position',pos_InputFile);% [lower x lower y width height] for text_display
    357357
    358 %% reset position of text_display or TableDisplay
    359 if strcmp(get(handles.TableDisplay,'Visible'),'off')
     358%% reset position of text_display and TableDisplay
     359% if strcmp(get(handles.TableDisplay,'Visible'),'off')
    360360    set(handles.text_display,'Units','pixels')
    361361    pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display
     
    365365    set(handles.text_display,'Position',pos_1)
    366366    % reset position of TableDisplay
    367 else
    368     set(handles.TableDisplay,'Units','pixels')
    369     pos_1=get(handles.TableDisplay,'Position');
    370     pos_1(3)=1.2*ColumnWidth;
    371     pos_1(1)=size_fig(3)-pos_1(3);
    372     pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4);
     367% else
     368%     set(handles.TableDisplay,'Units','pixels')
     369%     pos_1=get(handles.TableDisplay,'Position');
     370%     pos_1(3)=1.2*ColumnWidth;
     371%     pos_1(1)=size_fig(3)-pos_1(3);
     372%     pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4);
    373373    set(handles.TableDisplay,'Position',pos_1)
    374 end
     374    % reset position of CheckTable
     375    set(handles.CheckTable,'Unit','pixels')
     376pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold
     377pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3);       % set 'CheckHold' to the right of the fig
     378pos_CheckTable(2)=pos_InputFile(2)-pos_CheckTable(4);          % set 'CheckHold' to the lower edge of text display
     379set(handles.CheckTable,'Position',pos_CheckTable)
     380% end
    375381
    376382%% reset position of CheckHold
     
    28462852%------------------------------------------------------------------------
    28472853
    2848 if get(handles.CheckFixAspectRatio,'Value')
     2854% if get(handles.CheckFixAspectRatio,'Value')
    28492855    update_plot(handles);
    2850 else
    2851     update_plot(handles);
    2852 end
     2856% else
     2857%     update_plot(handles);
     2858% end
    28532859
    28542860%------------------------------------------------------------------------
     
    40444050function update_plot(handles)
    40454051%-------------------------------------------------------------------
    4046 set(handles.run0,'BackgroundColor',[1 1 0]);% indicate plot activity by yellow color
     4052set(handles.run0,'BackgroundColor',[1 1 0]);% display plot activity by yellow color
    40474053drawnow
    40484054UvData=get(handles.uvmat,'UserData');
     
    40554061    return
    40564062end
    4057 % RUNColor=get(handles.run0,'BackgroundColor');%
    4058 % if isequal(RUNColor,[1 0 1])% suppress magenta color (indicate that plot is  updated)
    4059 %     set(handles.run0,'BackgroundColor',[1 0 0]);
    4060 % end
    40614063set(handles.run0,'BackgroundColor',[1 0 0]);
    40624064
     
    43774379            if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
    43784380                ObjectData=get(hdisplay(iview),'UserData');
    4379                 if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)
     4381                if isfield(ObjectData,'SubObject') && ishandle(ObjectData.SubObject)
    43804382                    delete(ObjectData.SubObject);% delete the graphic 'sub-objects (e.g. projection bounds)
    43814383                end
    4382                 check_suppress= isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
     4384                check_suppress= isfield(ObjectData,'DeformPoint') && ishandle(ObjectData.DeformPoint);
    43834385                delete(ObjectData.DeformPoint(check_suppress));% delete the graphic deformation points
    43844386                delete(hdisplay(iview))% delete the main graphic representation of the object
     
    53125314    end
    53135315end
     5316
     5317
     5318% --- Executes on button press in CheckTable.
     5319function CheckTable_Callback(hObject, eventdata, handles)
     5320if get(handles.CheckTable,'Value')
     5321    set(handles.TableDisplay,'Visible','on')
     5322else
     5323    set(handles.TableDisplay,'Visible','off')
     5324end
  • trunk/src/view_field.m

    r681 r690  
    117117set(handles.view_field,'UserData',Data)
    118118
    119 %% reset position of text_display or TableDisplay
    120 if strcmp(get(handles.TableDisplay,'Visible'),'off')
     119%% reset position of text_display and TableDisplay
     120% reset position of text_display
    121121    pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display
    122122    pos_1(1)=size_fig(3)-pos_1(3);             % set text display to the right of the fig
     
    124124    set(handles.text_display,'Position',pos_1)
    125125    % reset position of TableDisplay
    126 else
    127     pos_1=get(handles.TableDisplay,'Position');
    128     pos_1(1)=size_fig(3)-pos_1(3);
    129     pos_1(2)=size_fig(4)-pos_1(4);
     126%     pos_1=get(handles.TableDisplay,'Position');
     127%     pos_1(1)=size_fig(3)-pos_1(3);
     128%     pos_1(2)=size_fig(4)-pos_1(4);
    130129    set(handles.TableDisplay,'Position',pos_1)
    131 end
     130% end
     131% reset position of CheckTable
     132pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold
     133pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3);       % set 'CheckHold' to the right of the fig
     134pos_CheckTable(2)=size_fig(4)-pos_CheckTable(4);          % set 'CheckHold' to the lower edge of text display
     135set(handles.CheckTable,'Position',pos_CheckTable)
    132136
    133137%% reset position of CheckHold
     
    841845function num_ColCode2_Callback(hObject, eventdata, handles)
    842846
     847
     848
     849% --- Executes on button press in CheckTable.
     850function CheckTable_Callback(hObject, eventdata, handles)
     851if get(handles.CheckTable,'Value')
     852    set(handles.TableDisplay,'Visible','on')
     853else
     854    set(handles.TableDisplay,'Visible','off')
     855end
     856   
Note: See TracChangeset for help on using the changeset viewer.