Changeset 874 for trunk/src/get_field.m
- Timestamp:
- Feb 19, 2015, 2:17:59 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r811 r874 36 36 function varargout = get_field(varargin) 37 37 38 % Last Modified by GUIDE v2.5 24-Apr-2014 22:45:3438 % Last Modified by GUIDE v2.5 18-Feb-2015 23:42:12 39 39 40 40 % Begin initialization code - DO NOT EDIT … … 66 66 guidata(hObject, handles); 67 67 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) 68 set(hObject,'CloseRequestFcn',{@closefcn,handles}) 68 69 69 70 %% enter input data … … 256 257 257 258 %% set z coordinate menu if relevant 258 if Field.MaxDim>=3 259 if Field.MaxDim>=3 && prod(Field.DimValue)<10^8; % 3D field (with memory content smaller than 400 Mo) 259 260 set(handles.Check3D,'Value',1) 260 261 else … … 269 270 270 271 %------------------------------------------------------------------------ 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 %------------------------------------------------------------------------279 272 % --- Executes when user attempts to close get_field. 280 273 %------------------------------------------------------------------------ 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 300 293 301 294 % ----------------------------------------------------------------------- … … 611 604 var_component=find(test_component);% list of variable indices elligible as unstructured coordinates 612 605 var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates 613 ListCoord=Field.Display.ListVarName([var_component var_coord]); 606 var_coord(var_coord==scalar_index)=[]; 607 var_component(var_component==scalar_index)=[]; 608 ListCoord=Field.Display.ListVarName([var_coord var_component]); 614 609 615 610 %% set default coord selection … … 634 629 elseif strcmp(Role,'coord_y') 635 630 coord_val(2)=ilist; 631 elseif strcmp(Role,'coord_z') 632 coord_val(3)=ilist; 636 633 end 637 634 end 638 635 end 639 636 if 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]; 642 642 else 643 643 coord_val=[1 2]; … … 745 745 %% set list of possible coordinates 746 746 test_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 coordi ante747 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate 748 748 check_consistent=1;%check that the selected vector components (and possibly color var) have the same dimensiosn 749 749 ListCoord={''}; … … 766 766 var_component=find(test_component);% list of variable indices elligible as unstructured coordinates 767 767 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]); 769 771 770 772 %% set default coord selection … … 776 778 ListCoord={''}; 777 779 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 780 788 end 781 789 else 782 coord_val=[0 0 ];790 coord_val=[0 0 0]; 783 791 for ilist=1:numel(var_component) 784 792 ivar=var_component(ilist); … … 789 797 elseif strcmp(Role,'coord_y') 790 798 coord_val(2)=ilist; 799 elseif strcmp(Role,'coord_z') 800 coord_val(3)=ilist; 791 801 end 792 802 end … … 797 807 if numel(find(coord_val))<2 798 808 %coord_val=[numel(var_component)+2 numel(var_component)+1]; 799 coord_val=[1 2 ];809 coord_val=[1 2 3]; 800 810 end 801 811 set(handles.Coord_x,'Value',coord_val(1)) 802 812 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 817 end 818 set(handles.Coord_z,'String',ListCoord) 805 819 set(handles.Coord_y,'String',ListCoord) 806 820 set(handles.Coord_x,'String',ListCoord) … … 1043 1057 % --- Executes on button press in Check3D. 1044 1058 function Check3D_Callback(hObject, eventdata, handles) 1045 if get(handles.Check3D,'Value') 1059 if get(handles.Check3D,'Value')% 3D fields 1046 1060 status='on'; 1047 else 1061 else% fields studied as 2D 1048 1062 status='off'; 1063 1049 1064 end 1050 1065 set(handles.Coord_z,'Visible',status) … … 1053 1068 set(handles.vector_z,'Visible',status) 1054 1069 set(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 %------------------------------------------------------------------------ 1083 function OK_Callback(hObject, eventdata, handles) 1084 handles.output=read_GUI(handles.get_field); 1085 guidata(hObject, handles);% Update handles structure 1086 uiresume(handles.get_field); 1087 drawnow 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 %------------------------------------------------------------------------ 1093 function closefcn(hObject, eventdata, handles) 1094 handles.output=[]; 1095 guidata(hObject, handles);% Update handles structure 1096 uiresume(handles.get_field); 1097 drawnow 1098 1099 %------------------------------------------------------------------------ 1100 % --- Outputs from this function are returned to the command line. 1101 %------------------------------------------------------------------------ 1102 function varargout = get_field_OutputFcn(hObject, eventdata, handles) 1103 1104 varargout{1} =handles.output; 1105 delete(handles.get_field)
Note: See TracChangeset
for help on using the changeset viewer.