Changeset 296


Ignore:
Timestamp:
Nov 22, 2011, 1:39:47 PM (12 years ago)
Author:
sommeria
Message:

various

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r292 r296  
    102102
    103103%% load the list of previously browsed files in menu Open
    104  dir_perso=prefdir; % path to the directory .matlab for personal data
    105  profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
    106  if exist(profil_perso,'file')
    107       h=load (profil_perso);
    108       if isfield(h,'MenuFile')
    109           set(handles.MenuFile_1,'Label',h.MenuFile{1})
    110           %set(handles.MenuFile_1,'Label',h.MenuFile_1);
    111       end
    112 %       if isfield(h,'MenuFile_2')
    113 %           set(handles.MenuFile_2,'Label',h.MenuFile_2);
    114 %       end
    115 %       if isfield(h,'MenuFile_3')
    116 %           set(handles.MenuFile_3,'Label',h.MenuFile_3);
    117 %       end
    118 %       if isfield(h,'MenuFile_4')
    119 %           set(handles.MenuFile_4,'Label',h.MenuFile_4);
    120 %       end
    121 %       if isfield(h,'MenuFile_5')
    122 %           set(handles.MenuFile_5,'Label',h.MenuFile_5);
    123 %       end
     104dir_perso=prefdir; % path to the directory .matlab for personal data
     105profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
     106if exist(profil_perso,'file')
     107    h=load (profil_perso);
     108    if isfield(h,'MenuFile')
     109        for ifile=1:min(length(h.MenuFile),5)
     110            eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
     111        end
     112    end
    124113end
    125114
     
    202191    set(handles.CheckPatch2,'Value',1)
    203192    enable_patch2(handles,1)
    204     set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
     193%     set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0])
    205194    set(handles.ListPairCiv2,'Enable','On')
    206195    enable_pair1(handles,'off')
     
    1001990end
    1002991set(handles.ListPairCiv1,'UserData',displ_num);
    1003 find_netcpair_civ1(hObject, eventdata, handles)
    1004 find_netcpair_civ2(hObject, eventdata, handles)
     992find_netcpair_civ1( handles)
     993find_netcpair_civ2(handles)
    1005994
    1006995%------------------------------------------------------------------------
  • trunk/src/mouse_down.m

    r292 r296  
    3636    hcurrentfig=hObject;%usual plot
    3737end
    38     set(hcurrentfig,'Units','pixels')
    39     currentfig_pos=get(hcurrentfig,'Position');%position of the GUI series (in pixels)
    40     set(hcurrentfig,'Units','normalized')
     38set(hcurrentfig,'Units','pixels')
     39GUI_pos=get(hcurrentfig,'Position');%position of the GUI series (in pixels)
     40set(hcurrentfig,'Units','normalized')
    4141hhcurrentfig=guidata(hcurrentfig);
    4242test_zoom=get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority
     
    7171xy=[];%default
    7272xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
    73 hchild=get(hObject,'Children');%handles of all objects in the current figure
     73hchildren=get(hObject,'Children');%handles of all objects in the current figure
    7474haxes=[];
    7575
    7676%% loop on all the objects in the current figure (selected by the last mouse click)
    77 %CurrentOrigin=get(hObject,'CurrentPoint')
    78 for ichild=1:length(hchild)
    79     obj_pos=get(hchild(ichild),'Position');%position of the object
     77output_str='';
     78for ichild=1:length(hchildren)
     79    hchild=hchildren(ichild); %handle of the current object
     80    obj_pos=get(hchild,'Position');%position of the object
    8081    if xy_fig(1) >=obj_pos(1) & xy_fig(2) >= obj_pos(2)& xy_fig(1) <=obj_pos(1)+obj_pos(3) & xy_fig(2) <= obj_pos(2)+obj_pos(4);
    81         htype=get(hchild(ichild),'Type');%type of object child of the current figure
    82         %if the mouse is over an axis, look at the data
    83         if isequal(htype,'axes')
    84             y_lim=get(hchild(ichild),'YLim');
    85             x_lim=get(hchild(ichild),'XLim');
    86             haxes=hchild(ichild);
    87             xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    88             if xy(1,1)>x_lim(1) && xy(1,1)<x_lim(2) && xy(1,2)>y_lim(1) && xy(1,2)<y_lim(2)
    89                 AxeData=get(haxes,'UserData');% data attached to the axis
    90                 AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
    91                 if test_edit_vect && ~isequal(tag_obj,'proj_object') & ~test_create
    92                     ivec=[];
    93                     FigData=get(hcurrentfig,'UserData');
    94                     tagaxes=get(haxes,'tag');
    95                     if isfield(FigData,tagaxes)
    96                         eval(['Field=FigData.' tagaxes ';'])
    97                         [CellVarIndex,NbDim,VarType]=find_field_indices(Field);%analyse the physical fields contained in Field
    98                         for icell=1:numel(CellVarIndex)%look for all physical fields
    99                             if NbDim(icell)==2 % select 2D field
    100                                 if  isfield(Field,'Mesh') && ~isempty(Field.Mesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data
    101                                     eval(['X=Field.' Field.ListVarName{VarType{icell}.coord_x} ';'])
    102                                     eval(['Y=Field.' Field.ListVarName{VarType{icell}.coord_y} ';'])
    103                                     flag_vec=(X<(xy(1,1)+Field.Mesh/4) & X>(xy(1,1)-Field.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
    104                                         (Y<(xy(1,2)+Field.Mesh/4) & Y>(xy(1,2)-Field.Mesh/4));%f
    105                                     ivec=find(flag_vec,1);% search the (first) selected vector index ivec
     82        htype=get(hchild,'Type');%type of object child of the current figure
     83
     84        switch htype
     85            %if the mouse is over an axis, look at the data
     86            case 'axes'
     87                y_lim=get(hchild,'YLim');
     88                x_lim=get(hchild,'XLim');
     89                haxes=hchild;
     90                xy=get(hchild,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     91                if xy(1,1)>x_lim(1) && xy(1,1)<x_lim(2) && xy(1,2)>y_lim(1) && xy(1,2)<y_lim(2)
     92                    AxeData=get(hchild,'UserData');% data attached to the axis
     93                    AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
     94                    if test_edit_vect && ~isequal(tag_obj,'proj_object') & ~test_create
     95                        ivec=[];
     96                        FigData=get(hcurrentfig,'UserData');
     97                        tagaxes=get(hchild,'tag');
     98                        if isfield(FigData,tagaxes)
     99                            eval(['Field=FigData.' tagaxes ';'])
     100                            [CellVarIndex,NbDim,VarType]=find_field_indices(Field);%analyse the physical fields contained in Field
     101                            for icell=1:numel(CellVarIndex)%look for all physical fields
     102                                if NbDim(icell)==2 % select 2D field
     103                                    if  isfield(Field,'Mesh') && ~isempty(Field.Mesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data
     104                                        eval(['X=Field.' Field.ListVarName{VarType{icell}.coord_x} ';'])
     105                                        eval(['Y=Field.' Field.ListVarName{VarType{icell}.coord_y} ';'])
     106                                        flag_vec=(X<(xy(1,1)+Field.Mesh/4) & X>(xy(1,1)-Field.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
     107                                            (Y<(xy(1,2)+Field.Mesh/4) & Y>(xy(1,2)-Field.Mesh/4));%f
     108                                        ivec=find(flag_vec,1);% search the (first) selected vector index ivec
     109                                    end
    106110                                end
    107111                            end
    108112                        end
    109113                    end
     114                else
     115                    hchild=[];%mouse out of axes
    110116                end
    111             else
    112                 haxes=[];%mouse out of axes
    113             end
    114             break
    115         elseif isequal(get(hObject,'SelectionType'),'alt') && isequal(htype,'uicontrol') && isequal(get(hchild(ichild),'Visible'),'on') && ~isequal(get(hchild(ichild),'tag'),'frame_object')&&...
    116              ~isequal(get(hchild(ichild),'tag'),'list_object_2') && ~isequal(get(hchild(ichild),'tag'),'list_object_1')
    117                 msg_pos(1:2)=currentfig_pos(1:2)+obj_pos(1:2).*currentfig_pos(3:4);
    118                 msgbox_uvmat(['uicontrol: ' get(hchild(ichild),'Tag')],'',get(hchild(ichild),'String'),msg_pos)
    119             break
    120         end
    121     end
    122 end
    123 
     117                break
     118            case 'uicontrol'  %if the mouse is over a uicontrol, duplicate the display  in an editable  zoom window
     119                if isequal(get(hObject,'SelectionType'),'alt')  && isequal(get(hchild,'Visible'),'on') && ~isequal(get(hchild,'tag'),'frame_object')&&...
     120                        ~isequal(get(hchild,'tag'),'list_object_2') && ~isequal(get(hchild,'tag'),'list_object_1')
     121                    if strcmp(get(hchild,'Visible'),'on')
     122                        msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
     123                        output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],'',get(hchild,'String'),msg_pos);
     124                        break
     125                    end
     126                end
     127            case 'uipanel'
     128                panel_pos=obj_pos;%position of the panel
     129                hhchildren=get(hchild,'Children');%handles of all objects in the current GUI
     130                %% loop on all the objects in the current figure (selected by the last mouse click)
     131                for iichild=1:length(hhchildren)
     132                    hchild=hhchildren(iichild);
     133                    rel_pos=get(hchild,'Position');%position of the object relative to the uipanel
     134                    obj_pos(1:2)=panel_pos(1:2)+rel_pos(1:2).*panel_pos(3:4);
     135                    obj_pos(3:4)=panel_pos(3:4).*rel_pos(3:4);
     136                    if numel(obj_pos)>=4 && xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4);
     137                        htype=get(hchild,'Type');%type of object child of the current figure
     138                        %if the mouse is over a uicontrol, look at the data
     139                        if strcmp(htype,'uicontrol') && strcmp(get(hchild,'Visible'),'on')
     140                            msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
     141                            output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],'',get(hchild,'String'),msg_pos);
     142                            break
     143                        end
     144                    end
     145                end
     146        end
     147    end
     148end
     149if ~isempty(output_str)               
     150    set(hObject,'Units','pixels')
     151    set(hchild,'String',output_str)
     152end
     153   
    124154%% desable  object creation and vector editing if NbDim different from 2
    125155if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2))
     
    138168     AxeData.Drawing='zoom'; %initiate drawing mode
    139169     AxeData.CurrentObject=[];%unselect objects
    140      set(haxes,'UserData',AxeData);
     170     set(hchild,'UserData',AxeData);
    141171     return
    142172end
     
    151181    AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');
    152182    AxeData.Drawing='ruler';
    153     set(haxes,'UserData',AxeData);
     183    set(hchild,'UserData',AxeData);
    154184    return
    155185end
     
    219249            end
    220250            set_object(UvData.Object{IndexObj})
    221             axes(haxes);%set back the current axes haxes
     251            axes(hchild);%set back the current axes haxes
    222252            testdeform=0;
    223253            set(gcbo,'Pointer','circle');
  • trunk/src/msgbox_uvmat.m

    r246 r296  
    5959set(handles.Cancel,'Position',[300 2 60 30])
    6060set(handles.Cancel,'FontSize',15)
     61
    6162
    6263% Update handles structure
     
    178179    set(handles.No,'Visible','off')
    179180end   
     181set(handles.figure1,'Units','normalized')
     182set(handles.edit_box,'Units','normalized')
     183
    180184set(handles.figure1,'WindowStyle','modal')% Make% Make the GUI modal
    181185% UIWAIT makes msgbox_uvmat wait for user response (see UIRESUME)
  • trunk/src/uvmat.m

    r295 r296  
    268268 if exist(profil_perso,'file')
    269269      h=load (profil_perso);
    270       if isfield(h,'MenuFile_1')
    271           set(handles.MenuFile_1,'Label',h.MenuFile_1);
    272           set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
    273       end
    274       if isfield(h,'MenuFile_2')
    275           set(handles.MenuFile_2,'Label',h.MenuFile_2);
    276           set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
    277       end
    278       if isfield(h,'MenuFile_3')
    279           set(handles.MenuFile_3,'Label',h.MenuFile_3);
    280           set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
    281       end
    282       if isfield(h,'MenuFile_4')
    283           set(handles.MenuFile_4,'Label',h.MenuFile_4);
    284           set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
    285       end
    286       if isfield(h,'MenuFile_5')
    287           set(handles.MenuFile_5,'Label',h.MenuFile_5);
    288           set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
     270      if isfield(h,'MenuFile')
     271          for ifile=1:min(length(h.MenuFile),5)
     272              eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
     273               eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});'])
     274          end
    289275      end
    290276      if isfield(h,'transform_fct') && iscell(h.transform_fct)
     
    312298set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
    313299
    314 
    315 
    316300%% case of an input argument for uvmat
    317301testinputfield=0;
     
    446430% display the selected field and related information
    447431display_file_name(hObject, eventdata, handles,fileinput)
    448 
    449 %update list of recent files in the menubar
    450 MenuFile_1=fileinput;
    451 MenuFile_2=get(handles.MenuFile_1,'Label');
    452 MenuFile_3=get(handles.MenuFile_2,'Label');
    453 MenuFile_4=get(handles.MenuFile_3,'Label');
    454 MenuFile_5=get(handles.MenuFile_4,'Label');
    455 set(handles.MenuFile_1,'Label',MenuFile_1)
    456 set(handles.MenuFile_2,'Label',MenuFile_2)
    457 set(handles.MenuFile_3,'Label',MenuFile_3)
    458 set(handles.MenuFile_4,'Label',MenuFile_4)
    459 set(handles.MenuFile_5,'Label',MenuFile_5)
    460 set(handles.MenuFile_1_1,'Label',MenuFile_1)
    461 set(handles.MenuFile_2_1,'Label',MenuFile_2)
    462 set(handles.MenuFile_3_1,'Label',MenuFile_3)
    463 set(handles.MenuFile_4_1,'Label',MenuFile_4)
    464 set(handles.MenuFile_5_1,'Label',MenuFile_5)
    465 dir_perso=prefdir;
    466 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    467 if exist(profil_perso,'file')
    468     save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
    469 else
    470     txt=ver('MATLAB');
    471     Release=txt.Release;
    472     relnumb=str2double(Release(3:4));
    473     if relnumb >= 14
    474         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
    475     else
    476         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
    477     end
    478 end
    479432
    480433% -----------------------------------------------------------------------
     
    909862drawnow
    910863set_scan_options(hObject, eventdata, handles)
     864
     865%% update list of recent files in the menubar
     866MenuFile=[{FileName};get(handles.MenuFile_1,'Label');get(handles.MenuFile_2,'Label');...
     867    get(handles.MenuFile_3,'Label');get(handles.MenuFile_4,'Label');get(handles.MenuFile_5,'Label')];
     868   
     869for ifile=1:length(MenuFile)
     870    eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
     871    eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',MenuFile{ifile});'])
     872end
     873dir_perso=prefdir;
     874profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     875if exist(profil_perso,'file')
     876    save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat
     877else
     878    save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat
     879end
    911880
    912881%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.