Changeset 874 for trunk/src/get_field.m


Ignore:
Timestamp:
Feb 19, 2015, 2:17:59 AM (9 years ago)
Author:
sommeria
Message:

merge_proj corrected + various bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r811 r874  
    3636function varargout = get_field(varargin)
    3737
    38 % Last Modified by GUIDE v2.5 24-Apr-2014 22:45:34
     38% Last Modified by GUIDE v2.5 18-Feb-2015 23:42:12
    3939
    4040% Begin initialization code - DO NOT EDIT
     
    6666guidata(hObject, handles);
    6767set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
     68set(hObject,'CloseRequestFcn',{@closefcn,handles})
    6869
    6970%% enter input data
     
    256257
    257258%% set z coordinate menu if relevant
    258 if Field.MaxDim>=3
     259if Field.MaxDim>=3 && prod(Field.DimValue)<10^8; % 3D field (with memory content smaller than 400 Mo)
    259260    set(handles.Check3D,'Value',1)
    260261else
     
    269270
    270271%------------------------------------------------------------------------
    271 % --- Outputs from this function are returned to the command line.
    272 %------------------------------------------------------------------------
    273 function varargout = get_field_OutputFcn(hObject, eventdata, handles)
    274 
    275 varargout{1} = handles.output;
    276 delete(handles.get_field)
    277 
    278 %------------------------------------------------------------------------
    279272% --- Executes when user attempts to close get_field.
    280273%------------------------------------------------------------------------
    281 function get_field_CloseRequestFcn(hObject, eventdata, handles)
    282 
    283 if isequal(get(handles.get_field, 'waitstatus'), 'waiting')
    284     % The GUI is still in UIWAIT, us UIRESUME
    285     uiresume(handles.get_field);
    286 else
    287     % The GUI is no longer waiting, just close it
    288     delete(handles.get_field);
    289 end
    290 
    291 %------------------------------------------------------------------------
    292 % --- Executes on button press in OK.
    293 %------------------------------------------------------------------------
    294 function OK_Callback(hObject, eventdata, handles)
    295 
    296 handles.output=read_GUI(handles.get_field);
    297 guidata(hObject, handles);% Update handles structure
    298 uiresume(handles.get_field);
    299 drawnow
     274%------------------------------------------------------------------------
     275
     276
     277% Use UIRESUME instead of delete because the OutputFcn needs
     278% to get the updated handles structure.
     279
     280% function get_field_CloseRequestFcn(hObject, eventdata)
     281% handles.output=[];
     282% guidata(hObject, handles);% Update handles structure
     283% %delete(handles.get_field);
     284% uiresume(handles.get_field);
     285%drawnow
     286% if isequal(get(handles.get_field, 'waitstatus'), 'waiting')
     287%     % The GUI is still in UIWAIT, us UIRESUME
     288%     uiresume(handles.get_field);
     289% else
     290%     % The GUI is no longer waiting, just close it
     291%     delete(handles.get_field);
     292% end
    300293
    301294% -----------------------------------------------------------------------
     
    611604var_component=find(test_component);% list of variable indices elligible as unstructured coordinates
    612605var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates
    613 ListCoord=Field.Display.ListVarName([var_component var_coord]);
     606var_coord(var_coord==scalar_index)=[];
     607var_component(var_component==scalar_index)=[];
     608ListCoord=Field.Display.ListVarName([var_coord var_component]);
    614609
    615610%% set default coord selection
     
    634629        elseif strcmp(Role,'coord_y')
    635630            coord_val(2)=ilist;
     631            elseif strcmp(Role,'coord_z')
     632            coord_val(3)=ilist;
    636633        end
    637634    end
    638635end
    639636if numel(find(coord_val))<2
    640     if numel(var_coord)>=2
    641         coord_val=[numel(var_component)+2 numel(var_component)+1];
     637    if numel(var_coord)>=3
     638         coord_val=[3 2 1];
     639    elseif numel(var_coord)>=2
     640       % coord_val=[numel(var_component)+2 numel(var_component)+1];
     641       coord_val=[2 1];
    642642    else
    643643        coord_val=[1 2];
     
    745745%% set list of possible coordinates
    746746test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate
    747 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
     747test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate
    748748check_consistent=1;%check that the selected vector components (and possibly color var) have the same dimensiosn
    749749ListCoord={''};
     
    766766    var_component=find(test_component);% list of variable indices elligible as unstructured coordinates
    767767    var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates
    768     ListCoord=Field.Display.ListVarName([var_component var_coord]);
     768    var_component(var_component==vector_x_index|var_component==vector_y_index)=[];
     769    var_coord(var_coord==vector_x_index|var_coord==vector_y_index)=[];% remove vector components form te possible list of coordinates
     770    ListCoord=Field.Display.ListVarName([var_coord var_component]);
    769771   
    770772    %% set default coord selection
     
    776778            ListCoord={''};
    777779        else
    778             set(handles.Coord_x,'Value',2)
    779             set(handles.Coord_y,'Value',1)
     780            if numel(test_coord)>=3
     781                set(handles.Coord_x,'Value',3)
     782                set(handles.Coord_y,'Value',2)
     783                set(handles.Coord_z,'Value',1)
     784            else
     785                set(handles.Coord_x,'Value',2)
     786                set(handles.Coord_y,'Value',1)
     787            end
    780788        end
    781789    else
    782         coord_val=[0 0];
     790        coord_val=[0 0 0];
    783791        for ilist=1:numel(var_component)
    784792            ivar=var_component(ilist);
     
    789797                elseif strcmp(Role,'coord_y')
    790798                    coord_val(2)=ilist;
     799                elseif strcmp(Role,'coord_z')
     800                    coord_val(3)=ilist;
    791801                end
    792802            end
     
    797807        if numel(find(coord_val))<2
    798808            %coord_val=[numel(var_component)+2 numel(var_component)+1];
    799             coord_val=[1 2];
     809            coord_val=[1 2 3];
    800810        end
    801811        set(handles.Coord_x,'Value',coord_val(1))
    802812        set(handles.Coord_y,'Value',coord_val(2))
    803     end
    804 end
     813        if numel(ListCoord)>=3
     814            set(handles.Coord_z,'Value',coord_val(3))
     815        end
     816    end
     817end
     818set(handles.Coord_z,'String',ListCoord)
    805819set(handles.Coord_y,'String',ListCoord)
    806820set(handles.Coord_x,'String',ListCoord)
     
    10431057% --- Executes on button press in Check3D.
    10441058function Check3D_Callback(hObject, eventdata, handles)
    1045 if get(handles.Check3D,'Value')
     1059if get(handles.Check3D,'Value')% 3D fields
    10461060    status='on';
    1047 else
     1061else% fields studied as 2D
    10481062    status='off';
     1063 
    10491064end
    10501065set(handles.Coord_z,'Visible',status)
     
    10531068set(handles.vector_z,'Visible',status)
    10541069set(handles.W_title,'Visible',status)   
     1070   Field=get(handles.get_field,'UserData');
     1071    if Field.MaxDim>=3% for 3D fields, propose to use the third variable as time
     1072        menu=get(handles.SwitchVarIndexTime,'String');
     1073        val=find(strcmp('variable',menu));
     1074        if ~isempty(val)
     1075            set(handles.SwitchVarIndexTime,'Value',val)
     1076            SwitchVarIndexTime_Callback(handles.SwitchVarIndexTime,[], handles)
     1077        end
     1078    end
     1079
     1080%------------------------------------------------------------------------
     1081% --- Executes on button press in OK.
     1082%------------------------------------------------------------------------
     1083function OK_Callback(hObject, eventdata, handles)
     1084handles.output=read_GUI(handles.get_field);
     1085guidata(hObject, handles);% Update handles structure
     1086uiresume(handles.get_field);
     1087drawnow
     1088% this function then activate get_field_OutputFcn
     1089
     1090%------------------------------------------------------------------------
     1091% --- Executes when the GUI is closed by the mouse on upper right corner.
     1092%------------------------------------------------------------------------
     1093function closefcn(hObject, eventdata, handles)
     1094handles.output=[];
     1095guidata(hObject, handles);% Update handles structure
     1096uiresume(handles.get_field);
     1097drawnow
     1098
     1099%------------------------------------------------------------------------
     1100% --- Outputs from this function are returned to the command line.
     1101%------------------------------------------------------------------------
     1102function varargout = get_field_OutputFcn(hObject, eventdata, handles)
     1103
     1104varargout{1} =handles.output;
     1105delete(handles.get_field)
Note: See TracChangeset for help on using the changeset viewer.