Changeset 309 for trunk/src/set_object.m


Ignore:
Timestamp:
Nov 30, 2011, 11:09:12 PM (13 years ago)
Author:
sommeria
Message:

many bugs corrected, cleaning of civ.m, resize of the GUI civ

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/set_object.m

    r307 r309  
    8484end
    8585set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front)
    86 set(hObject,'WindowButtonDownFcn',{'mouse_alt_gui',handles}) % allows mouse action with right button (zoom for uicontrol display)
     86set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
    8787enable_plot=0;%default: does not allow plot of object and projection
    8888
     
    644644set(handles.XObject,'String',XObject)
    645645set(handles.YObject,'String',YObject)
     646
    646647%METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_object_Opening
    647648%------------------------------------------------------------------------
     
    649650% executed when closing: set the parent interface button to value 0
    650651function closefcn(gcbo,eventdata,parent_button)
    651 
    652652huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
    653653if ~isempty(huvmat)
     
    671671UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat
    672672hhuvmat=guidata(huvmat);%handles in the uvmat GUI
    673 ObjectName=get(handles.TITLE,'String');%name of the current object
    674673ListObject=get(hhuvmat.ListObject,'String');%position in the objet list
    675 IndexObj=get(hhuvmat.ListObject,'Value');
    676 IndexObj_1=IndexObj(1);
    677 % if isequal(get(hhuvmat.list_object_2,'Visible'),'on')
    678 %     IndexObj_2=get(hhuvmat.list_object_2,'Value');
    679 %     List2=get(hhuvmat.list_object_2,'String');
    680 if numel(IndexObj)==2
    681     IndexObj_2=IndexObj(2);
    682 else
    683     IndexObj_2=[];
    684 end
    685 testnew=0;
     674IndexObj=get(hhuvmat.ListObject,'Value')
     675% name of the object
     676ObjectName=get(handles.TITLE,'String');%name of the current object defiend in set_object
    686677ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object
    687 if ~isempty(ListObject) && strcmp(ListObject{IndexObj_1},ObjectName)% we are editing the object whose projection is viewed in the uvmat frame
    688     IndexObj=IndexObj_1;
    689     projview='uvmat';
    690 elseif ~isempty(IndexObj_2) && IndexObj_2<=numel(ListObject)&& strcmp(ListObject{IndexObj_2},ObjectName)% we are editing the object whose projection is viewed in view_field 
    691     IndexObj=IndexObj_2;
    692     projview='view_field';
    693 else %new object
    694     testnew=1;
    695     IndexObj=numel(ListObject)+1;
    696     projview='view_field';
    697 end
    698 if strcmp(projview,'view_field')
    699     hview_field=findobj(allchild(0),'tag','view_field');
    700     if isempty(hview_field)
    701         hview_field=view_field;
    702     end
    703     PlotHandles=guidata(hview_field);
    704     plotaxes=PlotHandles.axes3;%handle of axes3 in view_field
    705 else
    706     PlotHandles=hhuvmat;
    707     plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
    708 
    709 end   
    710 
    711 %% naming the object
    712 if length(ObjectName)<1% name of object not defined in set_object
    713     ObjectName=[num2str(IndexObj) '-' ObjectData.Style];%default name
    714 elseif ~get(hhuvmat.edit_object,'Value')%not in edit mode (new object created)
     678if isempty(ObjectName)
     679    if get(hhuvmat.edit_object,'Value')% edit mode
     680        ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item
     681    end
     682end
     683if ~get(hhuvmat.edit_object,'Value') %new object is being created
    715684    detectname=1;
    716685    ObjectNameNew=ObjectName;
    717686    vers=0;
    718     while detectname==1 
     687    while detectname==1
    719688        detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
    720689        if detectname% if the object name already exists
     
    725694            else
    726695                vers=vers+1;
    727                 ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];     
     696                ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
    728697            end
    729698        end
    730699    end
    731700    ObjectName=ObjectNameNew;
    732 end
    733 ListObject{IndexObj,1}=ObjectName;
     701    ObjectName=[num2str(IndexObj(end)) '-' ObjectData.Style];%default name
     702end
     703% IndexObj_1=IndexObj(1);
     704% % if isequal(get(hhuvmat.list_object_2,'Visible'),'on')
     705% %     IndexObj_2=get(hhuvmat.list_object_2,'Value');
     706% %     List2=get(hhuvmat.list_object_2,'String');
     707% if numel(IndexObj)==2
     708%     IndexObj_2=IndexObj(2);
     709% else
     710%     IndexObj_2=[];
     711% end
     712testnew=0;
     713
     714if numel(IndexObj)==1   % if only one object is selected, the projection is in uvmat
     715        PlotHandles=hhuvmat;
     716    plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
     717else  % if a second object is selected, the projection is in view_field, and this second object is selected
     718    hview_field=findobj(allchild(0),'tag','view_field');
     719    if isempty(hview_field)
     720        hview_field=view_field;
     721    end
     722    PlotHandles=guidata(hview_field);
     723    plotaxes=PlotHandles.axes3;%handle of axes3 in view_field
     724end
     725
     726%% naming the object
     727ListObject{IndexObj(end),1}=ObjectName;
    734728set(hhuvmat.ListObject,'String',ListObject)
    735 % set(hhuvmat.list_object_2,'String',ListObject)
    736729
    737730%% update the object plot and projection field
    738 if testnew
    739    set(hhuvmat.ListObject,'Value',IndexObj)
    740 %     set(hhuvmat.list_object_2,'Value',IndexObj)
     731if testnew
     732    set(hhuvmat.ListObject,'Value',IndexObj)
    741733    ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;
    742734    ObjectData.DisplayHandle_view_field=[];
    743735else
    744     IndexObj
    745     UvData.Object{IndexObj}
    746     if IndexObj<=length(UvData.Object) && isfield(UvData.Object{IndexObj},'DisplayHandle_uvmat')% save the previous object graph handles
    747         ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat;
     736    if IndexObj(end)<=length(UvData.Object) && isfield(UvData.Object{IndexObj(end)},'DisplayHandle_uvmat')% save the previous object graph handles
     737        ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj(end)}.DisplayHandle_uvmat;
    748738    else
    749739        ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;%there is no object handle, than the axes handles is used as input
    750740    end
    751     if isfield(UvData.Object{IndexObj},'DisplayHandle_view_field')% save the previous object graph handles
    752         ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field;
     741    if isfield(UvData.Object{IndexObj(end)},'DisplayHandle_view_field')% save the previous object graph handles
     742        ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj(end)}.DisplayHandle_view_field;
    753743    else
    754744        ObjectData.DisplayHandle_view_field=[];
    755745    end
    756746end
    757 UvData.Object{IndexObj}=ObjectData;%update the current object properties
    758 UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2);
     747UvData.Object{IndexObj(end)}=ObjectData;%update the current object properties
     748if numel(IndexObj)==2
     749    UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));
     750end
    759751set(huvmat,'UserData',UvData)
    760752
     
    765757    return
    766758end
    767 %PlotParam=read_plot_param(PlotHandles);
    768759fighandle=get(plotaxes,'parent');
    769760PlotParam=read_GUI(fighandle);
    770 [PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot
     761[PlotType,Object_out{IndexObj(end)}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot
    771762
    772763%% update the GUI uvmat
     
    775766set(hhuvmat.edit_object,'Value',1) % set uvmat to object edit mode to allow further object update
    776767set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
    777 %UvData.MouseAction='edit_object'; % set the edit button to 'on'
    778768
    779769%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.