Changeset 71 for trunk/src/set_object.m


Ignore:
Timestamp:
Mar 29, 2010, 6:34:55 PM (14 years ago)
Author:
sommeria
Message:

civ3D updated: introduction of image size
imadoc2struct: reding of image size from the xml file
set_object, view_field and related functions: improvement of projection object editing
mouse: possibility of adjusting the calibrations points with the mouse

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/set_object.m

    r67 r71  
    8989     PlotHandles=[];
    9090end
    91 enable_plot=0;%default
    92 SetData.PlotHandles=PlotHandles;
    93 % if exist('data','var') && isfield(data,'ParentButton')
    94 %         SetData.ParentButton=data.ParentButton;
    95 %         set(hObject,'DeleteFcn',{@closefcn,SetData.ParentButton})%
    96 % end
    97 set(hObject,'UserData',SetData)
     91enable_plot=0;%default: does not allow plot of object and projection
     92% SetData.PlotHandles=PlotHandles;
     93% set(hObject,'UserData',SetData)
    9894
    9995% fill the interface as set in the input data:
    10096if exist('data','var')
    101     if isfield(data,'desable_plot')
    102         enable_plot=~data.desable_plot;%test to desable button PLOT (display mode)
     97    if isfield(data,'enable_plot')
     98        enable_plot=data.enable_plot;%test to desable button PLOT (display mode)
     99    end
     100    if isfield(data,'Name')
     101        set(handles.TITLE,'String',data.Name)
    103102    end
    104103    if ~isfield(data,'NbDim')||~isequal(data.NbDim,3)%2D case
     
    732731function PLOT_Callback(hObject, eventdata, handles)
    733732
    734 SetData=get(handles.set_object,'UserData');%get the hidden interface data
    735 huvmat=findobj('Name','uvmat');%find the current uvmat interface handle
    736 hlist_object=findobj(huvmat,'Tag','list_object_1');%handles of the object list in the GUI uvmat
    737 IndexObj=get(hlist_object,'Value');%position in the objet list
     733%SetData=get(handles.set_object,'UserData');%get the hidden interface data
     734huvmat=findobj('tag','uvmat');%find the current uvmat interface handle
    738735UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat
     736hhuvmat=guidata(huvmat);%handles in the uvmat GUI
     737ObjectName=get(handles.set_object,'name');%name ome)f the current object (set_object na
     738ListObject=get(hhuvmat.list_object_1,'String');%position in the objet list
     739IndexObj_1=get(hhuvmat.list_object_1,'Value');
     740IndexObj_2=get(hhuvmat.list_object_2,'Value');
     741
     742% set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' ObjectData.Style]);
    739743ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object
    740 ObjectData.HandlesDisplay=[]; % new object plot by default
    741 if length(UvData.Object) >= IndexObj && isfield(UvData.Object{IndexObj},'HandlesDisplay')
    742     hdisplay=UvData.Object{IndexObj}.HandlesDisplay;
    743     if isequal(UvData.Object{IndexObj}.Style, ObjectData.Style) && isequal(UvData.Object{IndexObj}.ProjMode, ObjectData.ProjMode)
    744         ObjectData.HandlesDisplay=UvData.Object{IndexObj}.HandlesDisplay;
    745     else  % for a new object styl, delete the existing object plots
    746         for ih=1:length(hdisplay)
    747             PlotData=get(hdisplay(ih),'UserData');
    748             if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
    749                     delete(PlotData.SubObject);
    750             end
    751             if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
    752                    delete(PlotData.DeformPoint);
    753             end
    754             if ~isequal(hdisplay(ih),0)
    755                 delete(hdisplay(ih));
    756             end
    757         end
    758         if isfield(ObjectData,'plotaxes') && ishandle(ObjectData.plotaxes)
    759             delete(ObjectData.plotaxes)%delete the axes for plotting the current projection result
    760         end
    761     end     
    762 end
     744PlotHandles=[];%default
     745testnew=0;
     746if strcmp(ListObject{IndexObj_1},ObjectName)% we are editing the object whose projection is viewed in the uvmat frame
     747   ObjectData.HandlesDisplay=handles.axes3;
     748    PlotHandles=get_plot_handles(handles);
     749    IndexObj=IndexObj_1;
     750elseif strcmp(ListObject{IndexObj_2},ObjectName)% we are editing the object whose projection is viewed in view_field
     751    hview_field=findobj('tag','view_field');
     752    if ~isempty(hview_field)
     753        PlotHandles=guidata(hview_field);
     754%         PlotHandles=get_plot_handles( hhview_field);
     755        ObjectData.HandlesDisplay=PlotHandles.axes3;%handle of axes3 in view_field
     756    end
     757    IndexObj=IndexObj_2;
     758else %new object
     759    testnew=1;
     760   
     761    IndexObj=numel(ListObject)+1;
     762    %ObjectName=[num2str(IndexObj) '-' ObjectData.Style];
     763%     ListObject=[ListObject;ObjectName];
     764%     set(hhuvmat.list_object_2,'String',[ListObject;ObjectName;{'...'}])
     765%     set(hhuvmat.list_object_2,'Value',IndexObj)
     766end
     767ObjectName=get(handles.TITLE,'String');
     768if length(ObjectName)<1
     769    ObjectName=[num2str(IndexObj) '-' ObjectData.Style];
     770else
     771    for ilist=1:numel(ListObject)
     772        if strcmp(ListObject{ilist},ObjectName)
     773            ObjectName=[num2str(IndexObj) '-' ObjectName];
     774            break
     775        end
     776    end
     777end
     778ListObject{IndexObj,1}=ObjectName;
     779set(hhuvmat.list_object_1,'String',ListObject)
     780set(hhuvmat.list_object_2,'String',[ListObject;{'...'}])
     781set(handles.set_object,'name',ObjectName);%update the name of set_object so that it equals its corresponding object in the list
     782if testnew
     783    set(hhuvmat.list_object_2,'Value',IndexObj)
     784end
     785% ObjectData.HandlesDisplay=[]; % new object plot by default
     786% if length(UvData.Object) >= IndexObj && isfield(UvData.Object{IndexObj},'HandlesDisplay')
     787%     hdisplay=UvData.Object{IndexObj}.HandlesDisplay;
     788%     if isequal(UvData.Object{IndexObj}.Style, ObjectData.Style) && isequal(UvData.Object{IndexObj}.ProjMode, ObjectData.ProjMode)
     789%         ObjectData.HandlesDisplay=UvData.Object{IndexObj}.HandlesDisplay;
     790%     else  % for a new object styl, delete the existing object plots
     791%         for ih=1:length(hdisplay)
     792%             PlotData=get(hdisplay(ih),'UserData');
     793%             if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
     794%                     delete(PlotData.SubObject);
     795%             end
     796%             if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
     797%                    delete(PlotData.DeformPoint);
     798%             end
     799%             if ~isequal(hdisplay(ih),0)
     800%                 delete(hdisplay(ih));
     801%             end
     802%         end
     803%         if isfield(ObjectData,'plotaxes') && ishandle(ObjectData.plotaxes)
     804%             delete(ObjectData.plotaxes)%delete the axes for plotting the current projection result
     805%         end
     806%     end     
     807% end
    763808
    764809% update the object plot and projection field
    765 UvData.Object{IndexObj}=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles);
    766 
     810UvData.Object{IndexObj}=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
    767811
    768812set(huvmat,'UserData',UvData)%update the data in the uvmat interface
    769 list_str=get(hlist_object,'String');
    770 % TITLE=set_title(ObjectData.Style,ObjectData.ProjMode);
    771 % list_str{IndexObj}=[num2str(IndexObj) '-' TITLE];
    772 list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Style];
    773 % if isequal(length(list_str),IndexObj)
    774 %     list_str{IndexObj+1}='more...';
    775 % end
    776 set(hlist_object_1,'String',list_str)
    777 set(hlist_object_1,'Value',IndexObj)
    778 
    779 %update create buttons on the GUI uvmat: set to object edit mode after object plotting
     813% list_str=get(hlist_object,'String');
     814% list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Style];
     815% set(hlist_object_1,'String',list_str)
     816% set(hlist_object_1,'Value',IndexObj)
     817
     818%set uvmat to object edit mode to allow further object update
    780819hhuvmat=guidata(huvmat);%handles of elements in the uvmat GUI
    781 %desactivate all create buttons in mode edit
    782 % if isequal(get(hhuvmat.edit,'Value'),0)
    783 %     set(hhuvmat.create,'Value',0)
    784 %     set(hhuvmat.create,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    785 %     set(hhuvmat.LINE,'Value',0)
    786 %     set(hhuvmat.LINE,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    787 %     set(hhuvmat.PATCH,'Value',0)
    788 %     set(hhuvmat.PATCH,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    789 %     set(hhuvmat.PLANE,'Value',0)
    790 %     set(hhuvmat.PLANE,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    791 %     set(hhuvmat.VOLUME,'Value',0)
    792 %     set(hhuvmat.VOLUME,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    793 % end
    794820set(hhuvmat.MenuEditObject,'enable','on')
    795821set(hhuvmat.edit,'Value',1)
     
    848874title={'object name'};
    849875dir_save=uigetdir(RootPath);
    850 def={fullfile(dir_save,['Object' Object.CoordType '.xml'])};
     876ObjectName=get(handles.TITLE,'String');
     877if ~isempty(ObjectName)&&~strcmp(ObjectName,'')
     878    def={fullfile(dir_save,[ObjectName Object.CoordType '.xml'])};
     879else
     880    def={fullfile(dir_save,[Object.Style Object.CoordType '.xml'])};
     881end
    851882options.Resize='on';
    852883displ_txt='save object as an .xml file';%default display
Note: See TracChangeset for help on using the changeset viewer.