Changeset 302 for trunk/src/uvmat.m


Ignore:
Timestamp:
Nov 26, 2011, 4:31:48 PM (9 years ago)
Author:
sommeria
Message:

improve the display of projection objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r299 r302  
    236236set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
    237237set(hObject,'DeleteFcn',{@closefcn})%
    238 set(handles.list_object_1,'ButtonDownFcn',{@list_object_1_Callback,handles})% allows activation of lis_object_1_callback with right mouse click
    239 set(handles.list_object_2,'ButtonDownFcn',{@list_object_2_Callback,handles})
     238%set(handles.ListObject,'ButtonDownFcn',{@list_object_1_Callback,handles})% allows activation of lis_object_1_callback with right mouse click
     239%set(handles.list_object_2,'ButtonDownFcn',{@list_object_2_Callback,handles})
    240240
    241241%% refresh projection plane
     
    366366        set(handles.OBJECT_txt,'Visible','on')
    367367        set(handles.edit_object,'Visible','on')
    368         set(handles.list_object_1,'Visible','on')
     368        set(handles.ListObject,'Visible','on')
    369369        set(handles.frame_object,'Visible','on')
    370370        if ~isempty(errormsg)
     
    559559        set(handles.OBJECT_txt,'Visible','on')
    560560        set(handles.edit_object,'Visible','on')
    561         set(handles.list_object_1,'Visible','on')
     561        set(handles.ListObject,'Visible','on')
    562562        set(handles.frame_object,'Visible','on')
    563563         %%%%%% initiate input file:
     
    864864
    865865%% update list of recent files in the menubar
    866 MenuFile=[{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    
     866MenuFile=[{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')}];
     868str_find=strcmp(FileName,MenuFile);
     869if isempty(find(str_find,1))
     870    MenuFile=[{FileName};MenuFile];%insert the current file if not already in the list
     871end
    869872for ifile=1:min(length(MenuFile),5)
    870873    eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
     
    24752478    end
    24762479    if test_set_object% reinitiate the GUI set_object
    2477         delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.list_object_1 and 2
     2480        delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2
    24782481        UvData.Object{1}.Style='plane';%main plotting plane
    24792482        UvData.Object{1}.ProjMode='projection';%main plotting plane
     
    24902493        UvData.Object{1}.enable_plot=1;
    24912494        set_object(UvData.Object{1},handles,ZBounds);
    2492         set(handles.list_object_1,'Value',1);
    2493         set(handles.list_object_1,'String',{'1-PLANE'});
     2495        set(handles.ListObject,'Value',1);
     2496        set(handles.ListObject,'String',{'1-PLANE'});
    24942497        set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor
    24952498        edit_object_Callback([],[], handles)
     
    25142517    UvData.Object{1}.ProjMode='projection';%main plotting plane
    25152518    UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
    2516     set(handles.list_object_1,'Value',1);
    2517     list_object=get(handles.list_object_1,'String');
     2519    set(handles.ListObject,'Value',1);
     2520    list_object=get(handles.ListObject,'String');
    25182521    if isempty(list_object)
    25192522        list_object={''};
     
    25212524        list_object=[{''};list_object];
    25222525    end
    2523     set(handles.list_object_1,'String',list_object);
    2524     set(handles.list_object_2,'String',list_object);
     2526    set(handles.ListObject,'String',list_object);
     2527%     set(handles.list_object_2,'String',list_object);
    25252528end
    25262529testnewseries=UvData.NewSeries;
     
    25362539%% Plot the projections on the selected  projection objects
    25372540% main projection object (uvmat display)
    2538 list_object=get(handles.list_object_1,'String');
     2541list_object=get(handles.ListObject,'String');
    25392542if isequal(list_object,{''})%refresh list of objects if the menu is empty
    25402543    UvData.Object={[]};
    2541     set(handles.list_object_1,'Value',1)
    2542     set(handles.list_object_2,'Value',1)
    2543     set(handles.list_object_2,'String',{''})
    2544     set(handles.list_object_2,'Visible','off')
    2545 end
    2546 IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view
     2544    set(handles.ListObject,'Value',1)
     2545%     set(handles.list_object_2,'Value',1)
     2546%     set(handles.list_object_2,'String',{''})
     2547%     set(handles.list_object_2,'Visible','off')
     2548end
     2549IndexObj=get(handles.ListObject,'Value');%selected projection object for main view
    25472550if IndexObj(1)> numel(UvData.Object)
    25482551    IndexObj(1)=1;%select the first object if the selected one does not exist
    2549     set(handles.list_object_1,'Value',1)
     2552    set(handles.ListObject,'Value',1)
    25502553end
    25512554plot_handles{1}=handles;
     
    25612564
    25622565% second projection object (view_field display)
    2563 IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
    2564 if IndexObj_2==0
    2565     IndexObj_2=1;
    2566 end
    2567 if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
    2568     IndexObj(2)=IndexObj_2;
     2566% IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
     2567% if IndexObj_2==0
     2568%     IndexObj_2=1;
     2569% end
     2570%if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
     2571 if length( IndexObj)>=2
     2572%      IndexObj(2)=IndexObj_2;
    25692573    view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
    25702574    if ~isempty(view_field_handle)
     
    38463850     UvData.Object=UvData.Object(1);
    38473851end
    3848 list_object=get(handles.list_object_1,'String');
    3849 set(handles.list_object_1,'Value',1)
    3850 set(handles.list_object_1,'String',{''})
    3851 set(handles.list_object_2,'Value',1)
    3852 set(handles.list_object_2,'String',{''})
    3853 list_object_2_Callback(hObject, eventdata, handles)
     3852list_object=get(handles.ListObject,'String');
     3853set(handles.ListObject,'Value',1)
     3854set(handles.ListObject,'String',{''})
     3855%set(handles.list_object_2,'Value',1)
     3856%set(handles.list_object_2,'String',{''})
     3857%list_object_2_Callback(hObject, eventdata, handles)
    38543858
    38553859%delete mask if it is displayed
     
    41814185    %suppress the other options
    41824186    set(handles.CheckZoom,'Value',0)
    4183     zoom_Callback(hObject, eventdata, handles)
     4187    CheckZoom_Callback(hObject, eventdata, handles)
    41844188    hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
    41854189    if ishandle(hgeometry_calib)
     
    41914195    UvData.MouseAction='none';
    41924196    set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])   
    4193     hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
    4194     if ~isempty(hset_object)
    4195         delete(hset_object)% delete the current GUI set_object
    4196     end
     4197%     hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
     4198%     if ~isempty(hset_object)
     4199%         delete(hset_object)% delete the current GUI set_object
     4200%     end
    41974201end
    41984202set(handles.uvmat,'UserData',UvData);
     
    42084212
    42094213%------------------------------------------------------------------------
    4210 % --- Executes on selection change in list_object_1.
    4211 function list_object_1_Callback(hObject, eventdata, handles)
    4212 %------------------------------------------------------------------------
    4213 list_str=get(handles.list_object_1,'String');
    4214 IndexObj=get(handles.list_object_1,'Value');
    4215 %IndexObj(2)=get(handles.list_object_2,'Value');
    4216 update_object(handles,IndexObj,1,list_str{IndexObj})
    4217 
    4218 %------------------------------------------------------------------------
    4219 % --- Executes on selection change in list_object_1.
    4220 function list_object_2_Callback(hObject, eventdata, handles)
    4221 %------------------------------------------------------------------------
    4222 list_str=get(handles.list_object_2,'String');
    4223 IndexObj=get(handles.list_object_2,'Value');
    4224 %IndexObj(2)=get(handles.list_object_2,'Value')-1;
    4225 % if no projection object is selected, close view_field
    4226 if ischar(list_str) || isempty(list_str{IndexObj})
    4227     hview_field=findobj(allchild(0),'Tag','view_field');
    4228     if ~isempty(hview_field)
    4229         delete(hview_field)
    4230     end
    4231     hset_object=findobj(allchild(0),'Tag','set_object');
    4232     if ~isempty(hset_object)
    4233         delete(hset_object)
    4234     end
    4235 else
    4236     if isequal(get(handles.uvmat,'SelectionType'),'alt')
    4237         option=4;%will show object properties on the GUI set_object
     4214% --- Executes on selection change in ListObject.
     4215function ListObject_Callback(hObject, eventdata, handles)
     4216%------------------------------------------------------------------------
     4217
     4218list_str=get(handles.ListObject,'String');
     4219IndexObj_old=get(handles.ListObject,'UserData');%retrieve previous selection
     4220IndexObj=get(handles.ListObject,'Value');
     4221if length(IndexObj)>2
     4222     IndexObj=[IndexObj(end-1) IndexObj(end)];%keeps only the last two selected items at most
     4223end
     4224if length(IndexObj)==1
     4225    if length(IndexObj_old)>=2 && isequal(IndexObj_old(1),IndexObj)       
     4226        IndexObj=IndexObj_old(2);
     4227    elseif length(IndexObj_old)>=2 && isequal(IndexObj_old(2),IndexObj)
     4228        IndexObj=IndexObj_old(1);
    42384229    else
    4239         option=2; % just update the projection
    4240     end
    4241     update_object(handles,IndexObj,option,list_str{IndexObj})   
    4242 end
    4243 
    4244 %------------------------------------------------------------------------
    4245 function update_object(handles,IndexObj,option,ObjectName)
    4246 %------------------------------------------------------------------------
     4230        IndexObj=[IndexObj_old(1) IndexObj];
     4231    end
     4232end
     4233set(handles.ListObject,'Value',IndexObj); %keeps only the two first selected objects
     4234set(handles.ListObject,'UserData',IndexObj)
     4235 %desactivate the edit object mode
     4236set(handles.edit_object,'Value',0)
     4237edit_object_Callback(hObject, eventdata, handles)
    42474238UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    42484239if numel(UvData.Object)<max(IndexObj);
     4240    msgbox_uvmat('ERROR','invalid object list')
    42494241    return
    42504242end
    4251 % if option==1 ||option==3
     4243UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));
     4244set(handles.uvmat,'UserData',UvData)
     4245
     4246%project on the selected object and update the corresponding plot
     4247hview_field=findobj(allchild(0),'tag','view_field');
     4248ViewObjectAxes=[];%default
     4249if ~isequal(IndexObj(1),IndexObj_old(1))
     4250update_object(handles,IndexObj(1),handles.axes3,list_str{IndexObj(1)})%plot the projection in uvmat
     4251end
     4252if length(IndexObj)==2 && (length(IndexObj_old)==1 || ~isequal(IndexObj(2),IndexObj_old(2)))
     4253    hview_field=findobj(allchild(0),'tag','view_field');
     4254    if isempty(hview_field)
     4255        hview_field=view_field;
     4256    end
     4257    PlotHandles=guidata(hview_field);
     4258    update_object(handles,IndexObj(2),PlotHandles.axes3,list_str{IndexObj(2)})%plot the projection in view_field
     4259end
     4260update_object_color(handles.axes3,PlotHandles.axes3,UvData.Object{IndexObj(2)}.DisplayHandle_uvmat)
     4261
     4262%------------------------------------------------------------------------
     4263function update_object(handles,IndexObj,ViewObjectAxes,ObjectName)
     4264%------------------------------------------------------------------------
     4265UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    42524266ObjectData=UvData.Object{IndexObj};
    4253 % else
    4254 %    ObjectData=UvData.Object{IndexObj};
    4255 % end
    42564267ObjectData.Name=ObjectName;
    42574268if isequal(get(handles.edit_object,'Value'),1)
     
    42664277if ~isempty(hset_object)
    42674278    delete(hset_object)% delete existing version of set_object
     4279    hset_object=set_object(ObjectData,[],ZBounds);
    42684280end
    42694281edit_test=get(handles.edit_object,'Value');
     
    42764288end
    42774289
    4278 if option==3 ||option==4% right mouse selection, show the GUI set_object:
    4279     hset_object=set_object(ObjectData,[],ZBounds);
    4280 end
    4281 
    4282 %project on the selected object and update the corresponding plot
    4283 hview_field=findobj(allchild(0),'tag','view_field');
    4284 % PlotHandles=guidata(hview_field);
    4285 if option==1 ||  option==3%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
    4286     PlotHandles=handles;
    4287 else
    4288     if isempty(hview_field)
    4289         hview_field=view_field;
    4290     end
    4291     PlotHandles=guidata(hview_field);
    4292 end
    4293 if option==1 ||option==2% lefet mouse selection, peroject the field:
    4294     ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
    4295     %plot_field(ProjData,PlotHandles.axes3,read_plot_param(PlotHandles));%read plotting parameters on the uvmat interfacPlotHandles);
    4296     plot_field(ProjData,PlotHandles.axes3,read_GUI(get(PlotHandles.axes3,'Parent')));%read plotting parameters on the uvmat interfacPlotHandles);
    4297     UvData.Object=update_obj(UvData,IndexObj,[]);
    4298     set(handles.uvmat,'UserData',UvData)
    4299 end
    4300 
    4301 
     4290uistack(ViewObjectAxes,'top')% display the plotting axes at the top
     4291ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
     4292plot_field(ProjData,ViewObjectAxes,read_GUI(get(ViewObjectAxes,'Parent')));%read plotting parameters on the uvmat interfacPlotHandles);
     4293%
     4294% UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));
    43024295% set(handles.uvmat,'UserData',UvData)
    4303 hother=[findobj(handles.axes3,'Tag','proj_object') ;findobj(PlotHandles.axes3,'Tag','proj_object')] ;%find all the proj objects
    4304 hother=[hother ;findobj(handles.axes3,'Tag','DeformPoint'); findobj(PlotHandles.axes3,'Tag','DeformPoint')];
     4296
     4297%------------------------------------------------------------------------
     4298%--- update the representation of objects
     4299function update_object_color(axes_uvmat,axes_view_field,DisplayHandle)
     4300%------------------------------------------------------------------------
     4301hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object')] ;%find all the proj objects
     4302hother=[hother ;findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];
    43054303for iobj=1:length(hother)
    43064304    if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
     
    43184316    set(hother(iobj),'Selected','off')
    43194317end
    4320 if isfield(ObjectData,'DisplayHandle_uvmat')
    4321     if ishandle(ObjectData.DisplayHandle_uvmat)
    4322         uistack(ObjectData.DisplayHandle_uvmat,'top')
    4323         linetype=get(ObjectData.DisplayHandle_uvmat,'Type');
    4324         if isequal(linetype,'line')
    4325             set(ObjectData.DisplayHandle_uvmat,'Color','m'); %set the selected object to magenta color
    4326         elseif isequal(linetype,'rectangle')
    4327             set(ObjectData.DisplayHandle_uvmat,'EdgeColor','m'); %set the selected object to magenta color
    4328         elseif isequal(linetype,'patch')
    4329             set(ObjectData.DisplayHandle_uvmat,'FaceColor','m'); %set the selected object to magenta color
    4330         end
    4331         SubObjectData=get(ObjectData.DisplayHandle_uvmat,'UserData');
    4332         if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)
    4333             uistack(SubObjectData.SubObject,'top')
    4334             for iobj=1:length(SubObjectData.SubObject)
    4335                 hsub=SubObjectData.SubObject(iobj);
    4336                 if isequal(get(hsub,'Type'),'rectangle')
    4337                     set(hsub,'EdgeColor','m'); %set the selected object to magenta color
    4338                 elseif isequal(get(hsub,'Type'),'image')
    4339                     Acolor=get(hsub,'CData');
    4340                     Acolor(:,:,1)=Acolor(:,:,3);
    4341                     set(hsub,'CData',Acolor);
    4342                 else
    4343                     set(hsub,'Color','m')
    4344                 end
    4345             end
    4346         end
    4347         if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
    4348             set(SubObjectData.DeformPoint,'Color','m')
    4349         end
    4350     end
    4351 end
     4318linetype=get(DisplayHandle,'Type');
     4319if isequal(linetype,'line')
     4320    set(DisplayHandle,'Color','m'); %set the selected object to magenta color
     4321elseif isequal(linetype,'rectangle')
     4322    set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color
     4323elseif isequal(linetype,'patch')
     4324    set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color
     4325end
     4326SubObjectData=get(DisplayHandle,'UserData');
     4327if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)
     4328    for iobj=1:length(SubObjectData.SubObject)
     4329        hsub=SubObjectData.SubObject(iobj);
     4330        if isequal(get(hsub,'Type'),'rectangle')
     4331            set(hsub,'EdgeColor','m'); %set the selected object to magenta color
     4332        elseif isequal(get(hsub,'Type'),'image')
     4333            Acolor=get(hsub,'CData');
     4334            Acolor(:,:,1)=Acolor(:,:,3);
     4335            set(hsub,'CData',Acolor);
     4336        else
     4337            set(hsub,'Color','m')
     4338        end
     4339    end
     4340end
     4341if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
     4342    set(SubObjectData.DeformPoint,'Color','m')
     4343end
     4344
     4345%         SubObjectData=get(ObjectData.DisplayHandle_uvmat,'UserData');
     4346
     4347
     4348
     4349
     4350
     4351
    43524352
    43534353%------------------------------------------------------
     
    44874487set(handles.CheckZoom,'Value',0)
    44884488set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
    4489 set(handles.list_object_1,'Value',1)     
     4489set(handles.ListObject,'Value',1)     
    44904490% initiate display of GUI geometry_calib
    44914491data=[]; %default
     
    45244524    return
    45254525else
    4526     set(handles.list_object_1,'Max',2);%allow multiple selection
    4527     set(handles.list_object_1,'Value',val);
     4526    set(handles.ListObject,'Max',2);%allow multiple selection
     4527    set(handles.ListObject,'Value',val);
    45284528    flag=1;
    45294529    npx=size(UvData.Field.A,2);
     
    46094609        imwrite(imflag,answer,'BitDepth',8);
    46104610    end
    4611     set(handles.list_object_1,'Value',1)
    4612     set(handles.list_object_1,'Max',1)
     4611    set(handles.ListObject,'Value',1)
     4612    set(handles.ListObject,'Max',1)
    46134613end
    46144614
     
    46214621edit_vect_Callback(hObject, eventdata, handles)
    46224622set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
    4623 set(handles.list_object_1,'Value',1)     
     4623set(handles.ListObject,'Value',1)     
    46244624
    46254625%prepare display of the set_grid GUI
     
    49154915CheckZoom_Callback(handles.uvmat, [], handles)
    49164916set(handles.delete_object,'Visible','on')
    4917 set(handles.uvmat_title,'Visible','on')
    4918 set(handles.view_field_title,'Visible','on')
     4917% set(handles._title,'Visible','on')
     4918% set(handles.view_field_title,'Visible','on')
    49194919
    49204920%------------------------------------------------------------------------
     
    49514951function delete_object_Callback(hObject, eventdata, handles)
    49524952%------------------------------------------------------------------------
    4953 IndexObj=get(handles.list_object_2,'Value');
    4954 if IndexObj>1
    4955     delete_object(IndexObj)
     4953IndexObj=get(handles.ListObject,'Value');
     4954if IndexObj(end)>1
     4955    delete_object(IndexObj(end))
    49564956end
    49574957
     
    49644964
    49654965
     4966% --- Executes on button press in ViewObject.
     4967function ViewObject_Callback(hObject, eventdata, handles)
     4968IndexObj=get(handles.ListObject,'Value');
     4969IndexObj=IndexObj(end); %keeps only the secodn value
     4970UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
     4971if numel(UvData.Object)<IndexObj;% error in UvData
     4972    msgbox_uvmat('ERROR','invalid object list')
     4973    return
     4974end
     4975ObjectData=UvData.Object{IndexObj};
     4976ZBounds=0; % default
     4977if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
     4978    ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
     4979    ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
     4980end
     4981hset_object=findobj(allchild(0),'tag','set_object');
     4982if ~isempty(hset_object)
     4983    delete(hset_object)% delete existing version of set_object
     4984end
     4985hset_object=set_object(ObjectData,[],ZBounds);
Note: See TracChangeset for help on using the changeset viewer.