Changeset 410 for trunk/src/uvmat.m


Ignore:
Timestamp:
May 6, 2012, 4:06:22 PM (9 years ago)
Author:
sommeria
Message:

projection on object improved: two menus for object projection dispalyed in uvmat and in view_field

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r408 r410  
    238238%% refresh projection plane
    239239UvData.Object{1}.ProjMode='projection';%main plotting plane
    240 set(handles.ListObject,'Value',1)% default: empty projection objectproj_field
    241 set(handles.ListObject,'String',{''})
     240set(handles.ListObject_1,'Value',1)% default: empty projection objectproj_field
     241set(handles.ListObject_1,'String',{''})
    242242set(handles.Fields,'Value',1)
    243243set(handles.Fields,'string',{''})
     
    364364        set(handles.OBJECT_txt,'Visible','on')
    365365        set(handles.edit_object,'Visible','on')
    366         set(handles.ListObject,'Visible','on')
     366%         set(handles.ListObject_1,'Visible','on')
    367367        set(handles.frame_object,'Visible','on')
    368368        if ~isempty(errormsg)
     
    802802        set(handles.OBJECT_txt,'Visible','on')
    803803        set(handles.edit_object,'Visible','on')
    804         set(handles.ListObject,'Visible','on')
     804         set(handles.ListObject_1,'Visible','on')
     805         set(handles.ViewObject_1,'Visible','on')
    805806        set(handles.frame_object,'Visible','on')
    806807       
     
    38913892%------------------------------------------------------------------------
    38923893
    3893 %------------------------------------------------------------------------
    3894 % --- Executes on selection change in ListObject.
    3895 function ListObject_Callback(hObject, eventdata, handles)
    3896 %------------------------------------------------------------------------
    3897 list_str=get(handles.ListObject,'String');
    3898 IndexObj_old=get(handles.ListObject,'UserData');%retrieve previous selection
    3899 IndexObj=get(handles.ListObject,'Value');%present object selection
    3900 
    3901 %% we select two objects or more at once (using the Ctrl key), keep only the last two items: the first is projected on uvmat, the second on view_field
    3902 if length(IndexObj)>2
    3903      IndexObj=[IndexObj(end-1) IndexObj(end)];%keeps only the last two selected items at most
    3904 end
    3905 
    3906 %% we select one object
    3907 if length(IndexObj)==1%
    3908     if length(IndexObj_old)>=2 && isequal(IndexObj_old(1),IndexObj)   % we select the first previously selected object->
    3909         IndexObj=[1 IndexObj_old(2)];% it desactivates this object and selects the first object for uvmat
    3910     elseif length(IndexObj_old)>=2 && isequal(IndexObj_old(2),IndexObj) % we select the second previously selected object->
    3911         IndexObj=IndexObj_old(1);% it desactivates this object  and keeps only the first previously selected object (uvmat)
    3912     else %
    3913         IndexObj=[IndexObj_old(1) IndexObj];% activates a second object while keeping the first previously selected one
    3914     end
    3915 end
    3916  
    3917 %% The second object is selected, it is displayed in set_object if this GUI is already opened
     3894% --- Executes on selection change in ListObject_1.
     3895function ListObject_1_Callback(hObject, eventdata, handles)
     3896list_str=get(handles.ListObject_1,'String');
     3897IndexObj=get(handles.ListObject_1,'Value');
    39183898UvData=get(handles.uvmat,'UserData');
    3919 ObjectData=UvData.Object{IndexObj(end)};
     3899ObjectData=UvData.Object{get(handles.ListObject_1,'Value')};
     3900
     3901%% update the projection plot on uvmat
     3902ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on UvData.Object{IndexObj(1)}
     3903plot_field(ProjData,handles.axes3,read_GUI(handles.uvmat));%read plotting parameters on the uvmat interfacPlotHandles);
     3904
     3905%% display the object parameters if the GUI set_object is already opened
    39203906hset_object=findobj(allchild(0),'tag','set_object');
    39213907if ~isempty(hset_object)
    3922     delete(hset_object)% delete to refesh the content
     3908%     delete(hset_object)% delete to refesh the content
    39233909    ZBounds=0; % default
    39243910    if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
     
    39263912        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
    39273913    end
    3928     ObjectData.Name=list_str{IndexObj(end)};
     3914    ObjectData.Name=list_str{IndexObj};
    39293915    set_object(ObjectData,[],ZBounds);
     3916    set(handles.ViewObject_1,'Value',1)% show that the selected object in ListObject_1 is currently visualised
    39303917end
    39313918%  desactivate the edit object mode
     
    39333920set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
    39343921
    3935 %% update the object value stored in ListObject
    3936 set(handles.ListObject,'Value',IndexObj); % marks the selected objects in the list
    3937 set(handles.ListObject,'UserData',IndexObj)% keep the current object selection in memory for next time
    3938 %
    3939 % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    3940 % if numel(UvData.Object)<max(IndexObj);
    3941 %     msgbox_uvmat('ERROR','invalid object list')
    3942 %     return
    3943 % end
    3944 % if numel(IndexObj)>=2
    3945 %     UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));%update the current object graphic representation
    3946 %     set(handles.uvmat,'UserData',UvData)
    3947 % end
    3948 
    3949 %% update the main plot (on uvmat) if the first selected object has been changed
    3950 if ~isequal(IndexObj(1),IndexObj_old(1))
    3951     ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on UvData.Object{IndexObj(1)}
    3952     plot_field(ProjData,handles.axes3,read_GUI(handles.uvmat));%read plotting parameters on the uvmat interfacPlotHandles);
    3953 end
     3922%------------------------------------------------------------------------
     3923% --- Executes on selection change in ListObject.
     3924
     3925function ListObject_Callback(hObject, eventdata, handles)
     3926%------------------------------------------------------------------------
     3927list_str=get(handles.ListObject,'String');
     3928IndexObj=get(handles.ListObject,'Value');%present object selection
     3929
     3930%% The object  is displayed in set_object if this GUI is already opened
     3931UvData=get(handles.uvmat,'UserData');
     3932ObjectData=UvData.Object{IndexObj};
     3933hset_object=findobj(allchild(0),'tag','set_object');
     3934if ~isempty(hset_object)
     3935%     delete(hset_object)% delete to refesh the content
     3936    ZBounds=0; % default
     3937    if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
     3938        ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
     3939        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
     3940    end
     3941    ObjectData.Name=list_str{IndexObj};
     3942    set_object(ObjectData,[],ZBounds);
     3943    set(handles.ViewObject,'Value',1)% show that the selected object in ListObject is currently visualised
     3944end
     3945%  desactivate the edit object mode
     3946set(handles.edit_object,'Value',0)
     3947set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
    39543948
    39553949%% update the second plot (on view_field) if view_field is already openened
     
    40234017
    40244018%------------------------------------------------------------------------
     4019% --- Executes on button press in ViewObject_1.
     4020function ViewObject_1_Callback(hObject, eventdata, handles)
     4021%------------------------------------------------------------------------
     4022check_view=get(handles.ViewObject_1,'Value');
     4023
     4024if check_view %activate set_object   
     4025    set(handles.ViewObject,'Value',0)% deselect ViewObject
     4026    IndexObj=get(handles.ListObject_1,'Value');
     4027    list_object=get(handles.ListObject_1,'String');
     4028    UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
     4029    UvData.Object{IndexObj}.Name=list_object{IndexObj};
     4030    if numel(UvData.Object)<IndexObj;% error in UvData
     4031        msgbox_uvmat('ERROR','invalid object list')
     4032        return
     4033    end
     4034    ZBounds=0; % default
     4035    if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
     4036        ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
     4037        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
     4038    end
     4039    set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion
     4040    data=UvData.Object{IndexObj};
     4041    if ~isfield(data,'Type')% default plane
     4042        data.Type='plane';
     4043    end
     4044    if isfield(UvData,'Field')
     4045        Field=UvData.Field;
     4046        if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh)
     4047            data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
     4048            if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')
     4049                data.RangeY=UvData.Field.Mesh;
     4050            else
     4051                data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
     4052            end
     4053            data.DX=UvData.Field.Mesh;
     4054            data.DY=UvData.Field.Mesh;
     4055        end
     4056        if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
     4057            data.Coord=[0 0 0]; %default
     4058        end
     4059        if isfield(Field,'CoordUnit')
     4060            data.CoordUnit=Field.CoordUnit;
     4061        end
     4062    end
     4063    hset_object=set_object(data,[],ZBounds);
     4064    hhset_object=guidata(hset_object);
     4065    if get(handles.edit_object,'Value')% edit mode
     4066        set(hhset_object.PLOT,'Enable','on')
     4067    else
     4068        set(hhset_object.PLOT,'Enable','off')
     4069    end
     4070else
     4071    hset_object=findobj(allchild(0),'tag','set_object');
     4072    if ~isempty(hset_object)
     4073        delete(hset_object)% delete existing version of set_object
     4074    end
     4075end
     4076 
     4077%------------------------------------------------------------------------
    40254078% --- Executes on button press in ViewObject.
    40264079function ViewObject_Callback(hObject, eventdata, handles)
    40274080%------------------------------------------------------------------------
    4028 IndexObj=get(handles.ListObject,'Value');
    4029 % IndexObj=IndexObj(end); %keeps only the second value
    4030 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    4031 if numel(UvData.Object)<IndexObj(end);% error in UvData
    4032     msgbox_uvmat('ERROR','invalid object list')
    4033     return
    4034 end
    4035 % ObjectData=UvData.Object{IndexObj(};
    4036 ZBounds=0; % default
    4037 if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
    4038     ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
    4039     ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
    4040 end
    4041 hset_object=findobj(allchild(0),'tag','set_object');
    4042 if ~isempty(hset_object)
    4043     delete(hset_object)% delete existing version of set_object
    4044 end
    4045 set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion
    4046 if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane
    4047     UvData.Object{IndexObj(1)}.Type='plane';
    4048 end
    4049 list_object=get(handles.ListObject,'String');
    4050 UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)};
    4051 hset_object=set_object(UvData.Object{IndexObj(end)},[],ZBounds);
    4052 hhset_object=guidata(hset_object);
    4053 if get(handles.edit_object,'Value')% edit mode
    4054     set(hhset_object.PLOT,'Enable','on')
    4055 else
    4056     set(hhset_object.PLOT,'Enable','off')
    4057 end
    4058 
    4059 %% show the second plot (on view_field)
    4060 if length(IndexObj)==2
    4061     ProjData= proj_field(UvData.Field,UvData.Object{IndexObj(2)});%project the current field on ObjectData
     4081check_view=get(handles.ViewObject,'Value');
     4082
     4083if check_view
     4084    set(handles.ViewObject_1,'Value',0)% unselect ViewObject_1
     4085    IndexObj=get(handles.ListObject,'Value');
     4086    UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
     4087    if numel(UvData.Object)<IndexObj(end);% error in UvData
     4088        msgbox_uvmat('ERROR','invalid object list')
     4089        return
     4090    end
     4091    ZBounds=0; % default
     4092    if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
     4093        ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
     4094        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
     4095    end
     4096    set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion
     4097    if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane
     4098        UvData.Object{IndexObj(1)}.Type='plane';
     4099    end
     4100    list_object=get(handles.ListObject,'String');
     4101    UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)};
     4102    hset_object=set_object(UvData.Object{IndexObj(end)},[],ZBounds);
     4103    hhset_object=guidata(hset_object);
     4104    if get(handles.edit_object,'Value')% edit mode
     4105        set(hhset_object.PLOT,'Enable','on')
     4106    else
     4107        set(hhset_object.PLOT,'Enable','off')
     4108    end
     4109   
     4110    %% show the second plot (on view_field)
     4111    ProjData= proj_field(UvData.Field,UvData.Object{IndexObj});%project the current field on ObjectData
    40624112    hview_field=findobj(allchild(0),'tag','view_field');
    40634113    if isempty(hview_field)
    40644114        hview_field=view_field;
    40654115    end
    4066     PlotHandles=guidata(hview_field);     
     4116    PlotHandles=guidata(hview_field);
    40674117    plot_field(ProjData,PlotHandles.axes3,read_GUI(hview_field));%read plotting parameters on the uvmat interfacPlotHandles);
    4068 end
    4069 
     4118else
     4119    hset_object=findobj(allchild(0),'tag','set_object');
     4120    if ~isempty(hset_object)
     4121        delete(hset_object)% delete existing version of set_object
     4122    end
     4123end
    40704124%-------------------------------------------------------------------
    40714125% --- Executes on selection change in edit_object.
     
    41054159%------------------------------------------------------------------------
    41064160IndexObj=get(handles.ListObject,'Value');
    4107 if IndexObj(end)>1
    4108     delete_object(IndexObj(end))
     4161IndexObj_1=get(handles.ListObject_1,'Value');
     4162
     4163if IndexObj>1 && ~isequal(IndexObj,IndexObj_1)
     4164    delete_object(IndexObj)
    41094165end
    41104166
     
    42524308data.Type='points';
    42534309data.ProjMode='projection';%default
     4310data.ProjModeMenu={};% do not restrict ProjMode menus
    42544311create_object(data,handles)
    42554312
     
    42594316data.Type='line';
    42604317data.ProjMode='projection';%default
     4318data.ProjModeMenu={};% do not restrict ProjMode menus
    42614319create_object(data,handles)
    42624320
     
    42664324data.Type='polyline';
    42674325data.ProjMode='projection';%default
     4326data.ProjModeMenu={};% do not restrict ProjMode menus
    42684327create_object(data,handles)
    42694328
     
    42734332data.Type='polygon';
    42744333data.ProjMode='inside';%default
     4334data.ProjModeMenu={};% do not restrict ProjMode menus
    42754335create_object(data,handles)
    42764336
     
    42804340data.Type='rectangle';
    42814341data.ProjMode='inside';%default
     4342data.ProjModeMenu={};% do not restrict ProjMode menus
    42824343create_object(data,handles)
    42834344
     
    42874348data.Type='ellipse';
    42884349data.ProjMode='inside';%default
     4350data.ProjModeMenu={};% do not restrict ProjMode menus
    42894351create_object(data,handles)
    42904352
     
    43034365data.Type='plane';
    43044366data.ProjMode='projection';%default
     4367data.ProjModeMenu={};% do not restrict ProjMode menus
    43054368create_object(data,handles)
    43064369
     
    43104373data.Type='volume';
    43114374data.ProjMode='interp';%default
     4375data.ProjModeMenu={};
    43124376% set(handles.create,'Visible','on')
    43134377% set(handles.create,'Value',1)
    4314 % VOLUME_Callback(hObject,eventdata,handles)
     4378% VOLUME_Callback(hObject,eventdata,handles)data.ProjModeMenu={};
    43154379create_object(data,handles)
    43164380
     
    43194383function create_object(data,handles)
    43204384%------------------------------------------------------------------------
    4321 
     4385% desactivate geometric calibration if opened
    43224386hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
    43234387if ishandle(hgeometry_calib)
     
    43264390    set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
    43274391end
    4328 UvData=get(handles.uvmat,'UserData');
    43294392set(handles.edit_object,'Value',0); %suppress the object edit mode
    43304393set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
    4331 % data.enable_plot=1;
     4394UvData=get(handles.uvmat,'UserData');
     4395data.Name=data.Type;% default name=type
    43324396data.Coord=[0 0]; %default
    43334397if isfield(UvData,'Field')
     
    43354399    if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh)
    43364400        data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
    4337         if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')
     4401        if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')||strcmp(data.Type,'points')
    43384402            data.RangeY=UvData.Field.Mesh;
    43394403        else
     
    43424406        data.DX=UvData.Field.Mesh;
    43434407        data.DY=UvData.Field.Mesh;
    4344        
    4345 %     elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
    4346 %         np=size(Field.A);
    4347 %         meshx=(Field.AX(end)-Field.AX(1))/np(2);
    4348 %         meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
    4349 %         data.RangeY=max(meshx,meshy);
    4350 %         data.RangeX=max(meshx,meshy);
    4351 %         data.DX=max(meshx,meshy);
    43524408    end
    43534409    if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
     
    43614417    delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
    43624418end
    4363 hset_object=findobj(allchild(0),'tag','set_object');
    4364 IndexObj=get(handles.ListObject,'Value');
    4365 if ~isempty(hset_object)
    4366     delete(hset_object)% delete existing version of set_object
    4367 end
    4368 set(handles.ListObject,'Value',IndexObj)
     4419set(handles.ListObject,'Visible','on')
     4420set(handles.ViewObject,'Visible','on')
     4421set(handles.ViewObject,'Value',1) % indicate that the object selected in ListObject (projection oin view_field) is visualised
     4422set(handles.ViewObject_1,'Value',0)% then the object selected in ListObject_1 is not visualised
    43694423hset_object=set_object(data,handles);% call the set_object interface
    43704424hhset_object=guidata(hset_object);
     
    43724426set(handles.MenuObject,'checked','on')
    43734427set(handles.uvmat,'UserData',UvData)
    4374 set(handles.CheckZoom,'Value',0)
     4428set(handles.CheckZoom,'Value',0) %desactivate the zoom for object creation by the mouse
    43754429CheckZoom_Callback(handles.uvmat, [], handles)
    43764430set(handles.delete_object,'Visible','on')
     
    44824536    return
    44834537else
    4484     set(handles.ListObject,'Max',2);%allow multiple selection
     4538%     set(handles.ListObject,'Max',2);%allow multiple selection
    44854539    set(handles.ListObject,'Value',val);
    44864540    flag=1;
Note: See TracChangeset for help on using the changeset viewer.