Changeset 1040 for trunk/src/get_field.m
- Timestamp:
- May 4, 2018, 10:57:13 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r1028 r1040 335 335 return 336 336 end 337 var_select=list_var{index};338 set(handles.attributes_txt,'String', ['attributes of ' var_select])337 VarName=list_var{index}; 338 set(handles.attributes_txt,'String', ['attributes of ' VarName]) 339 339 if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1 340 % nbline=0;341 340 VarAttr=Field.VarAttribute{index-1}; 342 341 if isstruct(VarAttr) … … 356 355 if ~isempty(Tabcell) 357 356 Tabchar=cell2tab(Tabcell,'='); 358 % Tabchar=[{''};Tabchar];359 357 end 360 358 set(handles.attributes,'Value',1);% select the first item … … 364 362 if isfield(Field,'ListDimName') 365 363 Tabdim={};%default 366 if isequal(index,1)%list all dimensions 364 if isequal(index,1)%list all dimensions if '*' is selected as the variable 367 365 dim_indices=1:length(Field.ListDimName); 368 366 set(handles.dimensions_txt,'String', 'dimensions') 369 else 367 else % a specific variable has been selected 370 368 DimCell=Field.VarDimName{index-1}; 371 369 if ischar(DimCell) 372 DimCell={DimCell}; 370 DimCell={DimCell};% transform into a cell for a single dimension defined by a char string 373 371 end 374 372 dim_indices=[]; … … 378 376 dim_indices=[dim_indices dim_index]; 379 377 end 380 set(handles.dimensions_txt,'String', ['dimensions of ' var_select])378 set(handles.dimensions_txt,'String', ['dimensions of ' VarName]) 381 379 end 382 380 for iline=1:length(dim_indices) … … 390 388 end 391 389 390 %% propose a plot by default if a variable has been selected 391 if ~isequal(index,1) 392 if numel(DimCell)==1 393 set(handles.FieldOption,'Value',1)%propose 1D plot 394 else 395 set(handles.FieldOption,'Value',2)%propose scalar plot 396 end 397 if numel(DimCell)<=2 398 set(handles.Check3D,'Value',0) 399 else 400 set(handles.Check3D,'Value',1) 401 end 402 FieldOption_Callback(hObject, VarName, handles) 403 end 404 392 405 %------------------------------------------------------------------------ 393 406 % --- Executes on selection change in FieldOption. 394 407 %------------------------------------------------------------------------ 395 function FieldOption_Callback(hObject, eventdata, handles)408 function FieldOption_Callback(hObject, VarName, handles) 396 409 397 410 Field=get(handles.get_field,'UserData'); … … 414 427 set(handles.Coord_z,'Visible','off') 415 428 set(handles.Z_title,'Visible','off') 416 ordinate_Callback(hObject, eventdata, handles)429 ordinate_Callback(hObject, VarName, handles) 417 430 418 431 case {'scalar'} … … 428 441 set(handles.Coord_y,'Visible','on') 429 442 set(handles.Y_title,'Visible','on') 443 444 if ~ischar(VarName) 445 430 446 %default scalar selection 431 447 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante … … 447 463 else 448 464 set(handles.scalar,'Value',scalar_index) 449 end 450 scalar_Callback(hObject, eventdata, handles) 465 end 466 end 467 scalar_Callback(hObject,VarName, handles) 468 451 469 452 470 case 'vectors' … … 501 519 502 520 %------------------------------------------------------------------------ 503 function ordinate_Callback(hObject, eventdata, handles)521 function ordinate_Callback(hObject, DimCell, handles) 504 522 %------------------------------------------------------------------------ 505 523 Field=get(handles.get_field,'UserData'); … … 584 602 set(handles.TimeName,'String',ListTime) 585 603 end 604 if ~ischar(DimCell) 586 605 update_field(handles,YName) 606 end 587 607 588 608 %------------------------------------------------------------------------ 589 609 % --- Executes on selection change in scalar menu. 590 610 %------------------------------------------------------------------------ 591 function scalar_Callback(hObject, eventdata, handles)611 function scalar_Callback(hObject, VarName, handles) 592 612 593 613 Field=get(handles.get_field,'UserData'); 594 scalar_index=get(handles.scalar,'Value');595 614 scalar_menu=get(handles.scalar,'String'); 596 ScalarName=scalar_menu{scalar_index}; 615 if ischar(VarName) 616 ScalarName=VarName; 617 scalar_index=find(strcmp(VarName,scalar_menu)); 618 set(handles.scalar,'Value',scalar_index) 619 else 620 scalar_index=get(handles.scalar,'Value'); 621 ScalarName=scalar_menu{scalar_index}; 622 end 597 623 598 624 %% set list of possible coordinates … … 696 722 set(handles.TimeName,'String',ListTime) 697 723 end 724 if ~ischar(VarName) 698 725 update_field(handles,ScalarName) 726 end 699 727 700 728 % --- Executes on button press in check_rgb. … … 705 733 % --- Executes on selection change in vector_x. 706 734 %------------------------------------------------------------------------ 707 function vector_x_Callback(hObject, eventdata, handles)735 function vector_x_Callback(hObject, DimCell, handles) 708 736 709 737 vector_x_menu=get(handles.vector_x,'String'); … … 711 739 vector_x=vector_x_menu{vector_x_index}; 712 740 vector_Callback(handles) 741 if ~ischar(DimCell) 713 742 update_field(handles,vector_x) 743 end 714 744 715 745 %------------------------------------------------------------------------ 716 746 % --- Executes on selection change in vector_x. 717 function vector_y_Callback(hObject, eventdata, handles) 718 %------------------------------------------------------------------------ 747 %------------------------------------------------------------------------ 748 function vector_y_Callback(hObject, DimCell, handles) 749 719 750 vector_y_menu=get(handles.vector_x,'String'); 720 751 vector_y_index=get(handles.vector_x,'Value'); 721 752 vector_y=vector_y_menu{vector_y_index}; 722 753 vector_Callback(handles) 754 if ~ischar(DimCell) 723 755 update_field(handles,vector_y) 756 end 724 757 725 758 %------------------------------------------------------------------------ 726 759 % --- Executes on selection change in vector_z. 727 function vector_z_Callback(hObject, eventdata, handles)760 function vector_z_Callback(hObject, DimCell, handles) 728 761 %------------------------------------------------------------------------ 729 762 vector_z_menu=get(handles.vector_z,'String'); … … 731 764 vector_z=vector_z_menu{vector_z_index}; 732 765 vector_Callback(handles) 766 if ~ischar(DimCell) 733 767 update_field(handles,vector_z) 734 768 end 735 769 %------------------------------------------------------------------------ 736 770 % --- Executes on selection change in vec_color. 737 function vec_color_Callback(hObject, eventdata, handles)771 function vec_color_Callback(hObject, DimCell, handles) 738 772 %------------------------------------------------------------------------ 739 773 index=get(handles.vec_color,'Value'); … … 741 775 VarName=string{index}; 742 776 vector_Callback(handles) 777 if ~ischar(DimCell) 743 778 update_field(handles,VarName) 744 779 end 745 780 %------------------------------------------------------------------------ 746 781 % --- Executes on selection change in vector_x or vector_y … … 860 895 % --- Executes on selection change in Coord_x. 861 896 %------------------------------------------------------------------------ 862 function Coord_x_Callback(hObject, eventdata, handles)897 function Coord_x_Callback(hObject, DimCell, handles) 863 898 864 899 index=get(handles.Coord_x,'Value'); 865 900 string=get(handles.Coord_x,'String'); 866 901 VarName=string{index}; 902 if ~ischar(DimCell) 867 903 update_field(handles,VarName) 868 904 end 869 905 %------------------------------------------------------------------------ 870 906 % --- Executes on selection change in Coord_y. 871 907 %------------------------------------------------------------------------ 872 function Coord_y_Callback(hObject, eventdata, handles)908 function Coord_y_Callback(hObject, DimCell, handles) 873 909 874 910 index=get(handles.Coord_y,'Value'); 875 911 string=get(handles.Coord_y,'String'); 876 912 VarName=string{index}; 913 if ~ischar(DimCell) 877 914 update_field(handles,VarName) 915 end 878 916 879 917 %------------------------------------------------------------------------ 880 918 % --- Executes on selection change in Coord_z. 881 919 %------------------------------------------------------------------------ 882 function Coord_z_Callback(hObject, eventdata, handles)920 function Coord_z_Callback(hObject, DimCell, handles) 883 921 884 922 index=get(handles.Coord_z,'Value'); 885 923 string=get(handles.Coord_z,'String'); 886 924 VarName=string{index}; 925 if ~ischar(DimCell) 887 926 update_field(handles,VarName) 927 end 888 928 889 929 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.