Changeset 445 for trunk/src/set_object.m


Ignore:
Timestamp:
Jun 8, 2012, 4:30:52 PM (9 years ago)
Author:
sommeria
Message:

possibility of dealing with series of multiple images eg tiff- introduced
bugs corrected in object creation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/set_object.m

    r432 r445  
    77% hset_object: handle of the GUI figure
    88%
    9 % INPUT:
     9% INPUT:u
    1010% data: structure describing the object properties
    1111%    .Style=...
     
    439439ListObject=get(hhuvmat.ListObject,'String');% list of objects displayed in uvmat
    440440IndexObj=get(hhuvmat.ListObject,'Value');% index of the selected object for display in uvmat
    441 if ~get(hhuvmat.edit_object,'Value') %new object is being created
    442     detectname=1;
    443     ObjectNameNew=ObjectName;
    444     vers=0;% index of the name
    445     while ~isempty(detectname)
    446         detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
    447         if detectname% if the object name already exists
    448             indstr=regexp(ObjectNameNew,'\D');%indices of non number characters
    449             if indstr(end)<length(ObjectNameNew) %object name ends by a number
    450                 vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
    451                 ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
    452             else
    453                 vers=vers+1;
    454                 ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
    455             end
    456         end
    457     end
    458     ObjectName=ObjectNameNew;
    459     set(handles.Name,'String',ObjectName)% display the default name in set_object
    460     IndexObj=numel(ListObject)+1;% append an object to the list in uvmat
    461     set(hhuvmat.ListObject,'String',[ListObject;{ObjectName}]);%complement the object list
    462     set(hhuvmat.ListObject_1,'String',[ListObject;{ObjectName}]);%complement the object list
    463     set(hhuvmat.ListObject,'Value',IndexObj)
    464     set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object
    465     UvData.Object{IndexObj}=[];%initiate a new object (empty yet)
     441%set or modify(edit mode) the nameof the currently selected object
     442detectname=1;
     443ObjectNameNew=ObjectName;
     444vers=0;% index of the name
     445ListOther=ListObject;
     446ListOther(IndexObj)=[];
     447while ~isempty(detectname)
     448    detectname=find(strcmp(ObjectNameNew,ListOther),1);%test the existence of the proposed name in the list
     449    if detectname% if the object name already exists
     450        indstr=regexp(ObjectNameNew,'\D');%indices of non number characters
     451        if indstr(end)<length(ObjectNameNew) %object name ends by a number
     452            vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
     453            ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
     454        else
     455            vers=vers+1;
     456            ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
     457        end
     458    end
     459end
     460ObjectName=ObjectNameNew;
     461set(handles.Name,'String',ObjectName)% display the default name in set_object
     462ListObject{IndexObj}=ObjectName;
     463set(hhuvmat.ListObject,'String',ListObject);%complement the object list
     464set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object
     465check_handle=isfield(UvData.Object{IndexObj},'DisplayHandle') && isfield(UvData.Object{IndexObj}.DisplayHandle,'uvmat')...
     466    && ~isempty(UvData.Object{IndexObj}.DisplayHandle.uvmat) && ishandle(UvData.Object{IndexObj}.DisplayHandle.uvmat);
     467if check_handle
     468    obj_handle=UvData.Object{IndexObj}.DisplayHandle.uvmat;
     469end
     470UvData.Object{IndexObj}=ObjectData;
     471if check_handle
     472    UvData.Object{IndexObj}.DisplayHandle.uvmat=obj_handle; %preserve the object plot handle if valid
     473else
    466474    UvData.Object{IndexObj}.DisplayHandle.uvmat=hhuvmat.axes3; %axes taken as object display handle by defualt
    467475end
     476set(hhuvmat.edit_object,'Value',1)% set the current object to edit mode
     477%     %IndexObj=numel(ListObject)+1;% append an object to the list in uvmat
     478%     
     479%     set(hhuvmat.ListObject,'String',[ListObject;{ObjectName}]);%complement the object list
     480%     set(hhuvmat.ListObject_1,'String',[ListObject;{ObjectName}]);%complement the object list
     481%     set(hhuvmat.ListObject,'Value',IndexObj)
     482%     set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object
     483%     UvData.Object{IndexObj}=[];%initiate a new object (empty yet)
     484%     UvData.Object{IndexObj}.DisplayHandle.uvmat=hhuvmat.axes3; %axes taken as object display handle by defualt
     485% end
    468486
    469487%% plot the field projected on the object
    470488hview_field=[];%default
     489IndexObj_1=get(hhuvmat.ListObject_1,'Value');
    471490if strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')||strcmp(ObjectData.ProjMode,'none')
    472491    PlotType='text';
     
    477496        return
    478497    end   
    479     IndexObj_1=get(hhuvmat.ListObject_1,'Value')
    480     if isequal(IndexObj_1,IndexObj) % if only one object is selected, the projection is in uvmat
     498    if isequal(IndexObj_1,IndexObj) % if  the projection is in uvmat
    481499        PlotType=plot_field(ProjData,hhuvmat.axes3,read_GUI(get(hhuvmat.axes3,'parent')));%update the current uvmat plot
    482     else  % if a second object is selected, the projection is in view_field, and this second object is selected
     500    else  % if the projection is in veiw_field
    483501        hview_field=findobj(allchild(0),'tag','view_field');
    484502        if isempty(hview_field)
     
    501519            set(hview_field,'Position',Data.GUISize)
    502520        end
     521        set(hhuvmat.ViewField,'Value',1)% indicate that the field projection on the current object is plotted in view_field
    503522    end
    504523end
    505524
    506525%% update the object plot
    507 % if IndexObj(end)<=length(UvData.Object) && isfield(UvData.Object{IndexObj(end)},'DisplayHandle')% save the previous object graph handles
    508 %     ObjectData.DisplayHandle.uvmat=UvData.Object{IndexObj(end)}.DisplayHandle.uvmat;
    509 % else
    510 %     ObjectData.DisplayHandle.uvmat=hhuvmat.axes3;%there is no object handle, than the axes handles is used as input
     526hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat;
     527% if we are editing the object used for projection in uvmat
     528if isequal(IndexObj_1,IndexObj)
     529    %update the representation of the current object for projection field represented in view_field
     530    %     UvData.Object{iobj}.DisplayHandle.view_field=...
     531    %                       plot_object(UvData.Object{IndexObj},UvData.Object{IndexObj_1},UvData.Object{iobj}.DisplayHandle.uvmat,'m');
     532    % update the representation of all objects in uvmat
     533    for iobj=1:numel(UvData.Object)
     534        UvData.Object{iobj}.DisplayHandle.uvmat=...
     535            plot_object(UvData.Object{iobj},UvData.Object{IndexObj_1},UvData.Object{iobj}.DisplayHandle.uvmat,'b');
     536    end
     537else %  we are editing the object used for projection field represented in view_field
     538    %update the representation of the current object in uvmat
     539    UvData.Object{IndexObj}.DisplayHandle.uvmat=...
     540             plot_object(UvData.Object{IndexObj},UvData.Object{IndexObj_1},UvData.Object{IndexObj}.DisplayHandle.uvmat,'m');
     541    %indicate the object index in the user data of the object plot (needed for further mouse editing)
     542    ObjectInfo=get(UvData.Object{IndexObj}.DisplayHandle.uvmat,'UserData');
     543    ObjectInfo.IndexObj=IndexObj;
     544    set(UvData.Object{IndexObj}.DisplayHandle.uvmat,'UserData',ObjectInfo)
     545    % update the representation of all objects in view_field
     546    for iobj=1:numel(UvData.Object)
     547        if isfield(UvData.Object{iobj}.DisplayHandle,'view_field')
     548            UvData.Object{iobj}.DisplayHandle.view_field=...
     549                plot_object(UvData.Object{iobj},UvData.Object{iobj},UvData.Object{iobj}.DisplayHandle.view_field,'b');
     550        end
     551    end
     552end
     553% UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(ObjectData,UvData.Object{IndexObj_1},hobject,'m');%draw the object in uvmat
     554% if ~isempty(hview_field)
     555%     if isfield(UvData.Object{IndexObj}.DisplayHandle,'view_field')
     556%         hobject=UvData.Object{IndexObj}.DisplayHandle.view_field;
     557%     end
     558%     if isempty(hobject)
     559%         hobject=haxes;
     560%     end   
     561%     %draw the object in view_field
     562%     if ~isequal(IndexObj_1,IndexObj) % if  the projection is in uvmat
     563%     UvData.Object{IndexObj}.DisplayHandle.view_field=plot_object(ObjectData,UvData.Object{IndexObj},hobject,'m');
     564%     end
    511565% end
    512 % if isfield(UvData.Object{IndexObj},'DisplayHandle')% save the previous object graph handles
    513 %     ObjectData.DisplayHandle.view_field=UvData.Object{IndexObj(end)}.DisplayHandle.view_field;
    514 % else
    515 %     ObjectData.DisplayHandle.view_field=[];
    516 % end
    517 % UvData.Object{IndexObj}=ObjectData;%update the current object properties
    518 % if numel(IndexObj)==2
    519 hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat;
    520 if isempty(hobject)
    521     hobject=hhuvmat.axes3;
    522 end
    523 UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(ObjectData,[],hobject,'m');%draw the object in uvmat
    524 if ~isempty(hview_field)
    525     if isfield(UvData.Object{IndexObj}.DisplayHandle,'view_field')
    526     hobject=UvData.Object{IndexObj}.DisplayHandle.view_field;
    527     end
    528     if isempty(hobject)
    529         hobject=haxes;
    530     end
    531     UvData.Object{IndexObj}.DisplayHandle.view_field=plot_object(ObjectData,[],hobject,'m');%draw the object in view_field
    532     %     UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));
    533 end
    534566set(huvmat,'UserData',UvData)
    535567
Note: See TracChangeset for help on using the changeset viewer.