Changeset 402 for trunk/src/set_object.m


Ignore:
Timestamp:
Apr 29, 2012, 11:29:24 AM (12 years ago)
Author:
sommeria
Message:

bugs corrected and improved procedure for object projection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/set_object.m

    r397 r402  
    8585set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front)
    8686set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
     87set(hObject,'DeleteFcn',{@closefcn})
    8788enable_plot=0;%default: does not allow plot of object and projection
    8889
    8990% fill the interface as set in the input data:
    9091if exist('data','var')
    91     if isfield(data,'enable_plot')
    92         enable_plot=data.enable_plot;%test to desable button PLOT (display mode)
    93     end
     92%     if isfield(data,'enable_plot')
     93%         enable_plot=data.enable_plot;%test to desable button PLOT (display mode)
     94%     end
    9495    if isfield(data,'Coord') &&size(data.Coord,2)==3
    9596        set(handles.z_slider,'Visible','on')
     
    149150    end
    150151end
    151 if enable_plot
    152    set(handles.PLOT,'enable','on')
    153 else
     152% if enable_plot
     153%    set(handles.PLOT,'enable','on')
     154% else
     155% enable the PLOT (REFRESH) button by default
    154156   set(handles.PLOT,'enable','off')
    155 end
     157% end
    156158huvmat=findobj(allchild(0),'tag','uvmat');
    157159UvData=get(huvmat,'UserData');
     
    171173varargout{1} = handles.output;
    172174varargout{2}=handles;
     175
     176%------------------------------------------------------------------------
     177% executed when closing the GUI set_object
     178function closefcn(gcbo,eventdata)
     179%------------------------------------------------------------------------
     180huvmat=findobj(allchild(0),'Tag','uvmat');%find the current uvmat interface handle
     181if ~isempty(huvmat)
     182    hhuvmat=guidata(huvmat);
     183    set(hhuvmat.edit_object,'Value',0)
     184    set(hhuvmat.edit_object,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
     185    % deselect the object in ListObject when view_field is closed
     186    if isempty(findobj(allchild(0),'Tag','view_field'))
     187        ObjIndex=get(hhuvmat.ListObject,'Value');
     188        ObjIndex=ObjIndex(1);%keep only the first object selected
     189        set(hhuvmat.ListObject,'Value',ObjIndex)
     190        % draw all object colors in blue (unselected) in uvmat
     191        hother=[findobj(hhuvmat.axes3,'Tag','proj_object');findobj(hhuvmat.axes3,'Tag','DeformPoint')];%find all the proj object and deform point representations
     192        for iobj=1:length(hother)
     193            if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
     194                set(hother(iobj),'EdgeColor','b')
     195                if isequal(get(hother(iobj),'FaceColor'),'m')
     196                    set(hother(iobj),'FaceColor','b')
     197                end
     198            elseif isequal(get(hother(iobj),'Type'),'image')
     199                Acolor=get(hother(iobj),'CData');
     200                Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
     201                set(hother(iobj),'CData',Acolor);
     202            else
     203                set(hother(iobj),'Color','b')
     204            end
     205            set(hother(iobj),'Selected','off')
     206        end
     207    end
     208end
     209hseries=findobj(allchild(0),'Name','series');%find the current series interface handle
     210if ~isempty(hseries)
     211    hhseries=guidata(hseries);
     212    set(hhseries.GetObject,'Value',0)
     213    set(hhseries.GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green
     214end
     215
    173216
    174217%------------------------------------------------------------------------
     
    364407%------------------------------------------------------------------------
    365408
    366 %------------------------------------------------------------------------
    367 %------------------------------------------------------------------------
    368 %----------------------------------------------------
    369 % executed when closing: set the parent interface button to value 0
    370 function closefcn(gcbo,eventdata,parent_button)
    371 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
    372 if ~isempty(huvmat)
    373     hhuvmat=guidata(huvmat);
    374     set(hhuvmat.edit,'Value',0)
    375     set(hhuvmat.edit,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
    376 end
    377 hseries=findobj(allchild(0),'Name','series');%find the current series interface handle
    378 if ~isempty(hseries)
    379     hhseries=guidata(hseries);
    380     set(hhseries.GetObject,'Value',0)
    381     set(hhseries.GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    382 end
    383409
    384410%------------------------------------------------------------------------
     
    396422%% read the object on the GUI set_object
    397423ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object
    398 ObjectName=ObjectData.Name;%name of the current object defined in set_object
    399424if iscell(ObjectData.Coord)%check for empty line
    400425    ObjectData.Coord=[0 0 0];
     
    406431    ObjectData.Coord(checknan,:)=[];%remove the NaN lines
    407432end
     433ObjectName=ObjectData.Name;%name of the current object defined in set_object
    408434if isempty(ObjectName)
    409435    if get(hhuvmat.edit_object,'Value')% edit mode
     
    411437            ObjectName='Plane';
    412438        else
    413         ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item
     439            ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item
    414440        end
    415441    else %new object
    416         StyleList=get(handles.Type,'String');
    417         StyleVal=get(handles.Type,'Value');
    418         ObjectName=StyleList{StyleVal};
     442        ObjectName=ObjectData.Type;
    419443    end
    420444end
     
    422446    detectname=1;
    423447    ObjectNameNew=ObjectName;
    424     vers=0;
     448    vers=0;% index of the name
    425449    while detectname==1
    426450        detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
Note: See TracChangeset for help on using the changeset viewer.