Changeset 410 for trunk/src/set_object.m


Ignore:
Timestamp:
May 6, 2012, 4:06:22 PM (12 years ago)
Author:
sommeria
Message:

projection on object improved: two menus for object projection dispalyed in uvmat and in view_field

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/set_object.m

    r402 r410  
    8686set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
    8787set(hObject,'DeleteFcn',{@closefcn})
    88 enable_plot=0;%default: does not allow plot of object and projection
    8988
    9089% fill the interface as set in the input data:
    9190if exist('data','var')
    92 %     if isfield(data,'enable_plot')
    93 %         enable_plot=data.enable_plot;%test to desable button PLOT (display mode)
    94 %     end
    9591    if isfield(data,'Coord') &&size(data.Coord,2)==3
    9692        set(handles.z_slider,'Visible','on')
     
    10298    end
    10399    if isfield(data,'ProjModeMenu')
    104 %         set(handles.ProjMode,'String',data.ProjModeMenu) % data.ProjModeMenu as projMode menu
    105100        set(handles.ProjMode,'UserData',data.ProjModeMenu)% data.ProjModeMenu as default menu (used in Type_Callback)
    106101    end
    107102    errormsg=fill_GUI(data,handles);
     103    if ~isempty(errormsg)
     104        msgbox_uvmat('ERROR','bad data input in set_object')
     105        return
     106    end
    108107    Type_Callback(hObject, eventdata, handles)% update the GUI set_object depending on the object type   
    109108
     
    181180if ~isempty(huvmat)
    182181    hhuvmat=guidata(huvmat);
    183     set(hhuvmat.edit_object,'Value',0)
     182    set(hhuvmat.ViewObject_1,'value',0)% desactivate the two view buttons
     183    set(hhuvmat.ViewObject,'value',0)%
     184    set(hhuvmat.edit_object,'Value',0)% desactivate the edit option
    184185    set(hhuvmat.edit_object,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
    185186    % deselect the object in ListObject when view_field is closed
     
    257258    menu_proj=get(handles.ProjMode,'UserData');
    258259end
    259 proj_index=get(handles.ProjMode,'Value');
    260 if proj_index>numel(menu_proj)
    261     set(handles.ProjMode,'Value',1);% value index must not exceed the menu length
    262 end
     260ProjModeList=get(handles.ProjMode,'String');
     261menu_index=find(strcmp(ProjModeList{get(handles.ProjMode,'Value')},menu_proj));
     262if isempty(menu_index)
     263    menu_index=1;%
     264end
     265set(handles.ProjMode,'Value',menu_index);% value index must not exceed the menu length
    263266set(handles.ProjMode,'String',menu_proj)
    264267ProjMode_Callback(hObject, eventdata, handles)
     
    412415function PLOT_Callback(hObject, eventdata, handles)
    413416
    414 %% reading the object parameters on the GUI uvmat
     417%% reading the object selection in the GUI uvmat
    415418huvmat=findobj('tag','uvmat');%find the current uvmat GUI handle
    416419UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat
    417420hhuvmat=guidata(huvmat);%handles of the objects children of the  GUI uvmat
    418421ListObject=get(hhuvmat.ListObject,'String');% list of objects displyed in uvmat
    419 IndexObj=get(hhuvmat.ListObject,'Value');% index(indices) of the selected object(s) in uvmat
    420                                         % (the first one is plotted in uvmat axis, the second one in view_field)
    421 
    422 %% read the object on the GUI set_object
     422IndexObj(1)=get(hhuvmat.ListObject_1,'Value');% index of the selected object for display in uvmat
     423if get(hhuvmat.ViewObject,'Value')
     424    IndexObj(2)=get(hhuvmat.ListObject,'Value');% index of the object, possibly selected for display in view_field
     425end
     426
     427%% read the object parameters in the GUI set_object
    423428ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object
    424429if iscell(ObjectData.Coord)%check for empty line
     
    433438ObjectName=ObjectData.Name;%name of the current object defined in set_object
    434439if isempty(ObjectName)
    435     if get(hhuvmat.edit_object,'Value')% edit mode
    436         if isempty(ListObject)
    437             ObjectName='Plane';
    438         else
    439             ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item
    440         end
    441     else %new object
     440%     if get(hhuvmat.edit_object,'Value')% edit mode
     441%         if isempty(ListObject)
     442%             ObjectName='Plane';
     443%         else
     444%             ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item
     445%         end
     446%     else %new object
    442447        ObjectName=ObjectData.Type;
    443     end
     448%     end
    444449end
    445450if ~get(hhuvmat.edit_object,'Value') %new object is being created
     
    464469    IndexObj(2)=numel(ListObject)+1;% append an object to the list in uvmat
    465470    set(hhuvmat.ListObject,'String',[ListObject;{ObjectName}]);%complement the object list
    466     set(hhuvmat.ListObject,'Value',IndexObj)
     471    set(hhuvmat.ListObject_1,'String',[ListObject;{ObjectName}]);%complement the object list
     472    set(hhuvmat.ListObject,'Value',IndexObj(2))
    467473    UvData.Object{IndexObj(2)}=[];%initiate a new object (empty yet)
    468474end
     
    482488ListObject{IndexObj(end),1}=ObjectName;
    483489set(hhuvmat.ListObject,'String',ListObject)
     490set(hhuvmat.ListObject_1,'String',ListObject)
    484491
    485492%% update the object plot
    486 if testnew
    487     set(hhuvmat.ListObject,'Value',IndexObj)
    488     ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;
    489     ObjectData.DisplayHandle_view_field=[];
    490 else
     493% if testnew
     494%     set(hhuvmat.ListObject,'Value',IndexObj)
     495%     ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;
     496%     ObjectData.DisplayHandle_view_field=[];
     497% else
    491498    if IndexObj(end)<=length(UvData.Object) && isfield(UvData.Object{IndexObj(end)},'DisplayHandle_uvmat')% save the previous object graph handles
    492499        ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj(end)}.DisplayHandle_uvmat;
     
    499506        ObjectData.DisplayHandle_view_field=[];
    500507    end
    501 end
     508% end
    502509UvData.Object{IndexObj(end)}=ObjectData;%update the current object properties
    503 if numel(IndexObj)==2
     510 if numel(IndexObj)==2
    504511    UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));
    505 end
     512 end
    506513set(huvmat,'UserData',UvData)
    507514
     
    509516if strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')||strcmp(ObjectData.ProjMode,'none')
    510517    PlotType='text';
    511    
    512518else
    513519    [ProjData,errormsg]= proj_field(UvData.Field,ObjectData);%project the current field of uvmat on ObjectData
Note: See TracChangeset for help on using the changeset viewer.