Changeset 388 for trunk/src/set_object.m


Ignore:
Timestamp:
Apr 6, 2012, 4:37:12 PM (12 years ago)
Author:
sommeria
Message:

several bugs corrected
file indexing, color images...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/set_object.m

    r387 r388  
    220220set(handles.ProjMode,'String',menu_proj)
    221221ProjMode_Callback(hObject, eventdata, handles)
    222 
    223 %store the current option
    224 % str=get(handles.Type,'String');
    225 % val=get(handles.Type,'Value');
    226 % set(handles.Type,'UserData',style)
    227 
    228 %------------------------------------------------------------------------
    229 function xObject_Callback(hObject, eventdata, handles)
    230 
    231 %------------------------------------------------------------------------
    232 function yObject_Callback(hObject, eventdata, handles)
    233 
    234 %------------------------------------------------------------------------
    235 % --- Executes on selection change in zObject.
    236 function zObject_Callback(hObject, eventdata, handles)
    237 %------------------------------------------------------------------------
    238222
    239223%------------------------------------------------------------------------
     
    403387
    404388%% reading the object parameters on the GUI uvmat
    405 huvmat=findobj('tag','uvmat');%find the current uvmat interface handle
     389huvmat=findobj('tag','uvmat');%find the current uvmat GUI handle
    406390UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat
    407 hhuvmat=guidata(huvmat);%handles in the uvmat GUI
    408 ListObject=get(hhuvmat.ListObject,'String');%position in the objet list
    409 IndexObj=get(hhuvmat.ListObject,'Value');
     391hhuvmat=guidata(huvmat);%handles of the objects children of the  GUI uvmat
     392ListObject=get(hhuvmat.ListObject,'String');% list of objects displyed in uvmat
     393IndexObj=get(hhuvmat.ListObject,'Value');% index(indices) of the selected object(s) in uvmat
     394                                        % (the first one is plotted in uvmat axis, the second one in view_field)
    410395
    411396%% read the object on the GUI set_object
    412 %ObjectData=read_set_object(handles.set_object);%read the input parameters defining the object in the GUI set_object
    413 ObjectData=read_GUI(handles.set_object);%read the input parameters defining the object in the GUI set_object
    414 %ObjectData.Coord=cell2mat(ObjectData.Coord);
    415 ObjectName=ObjectData.Name;%name of the current object defiend in set_object
     397ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object
     398ObjectName=ObjectData.Name;%name of the current object defined in set_object
     399checknan=isnan(sum(ObjectData.Coord,2));%check for NaN lines
     400if ~isempty(checknan)
     401    ObjectData.Coord(checknan,:)=[];%remove the NaN lines
     402end
    416403if isempty(ObjectName)
    417404    if get(hhuvmat.edit_object,'Value')% edit mode
     
    449436testnew=0;
    450437if numel(IndexObj)==1   % if only one object is selected, the projection is in uvmat
    451  %       PlotHandles=hhuvmat;
    452438    plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
    453439else  % if a second object is selected, the projection is in view_field, and this second object is selected
    454440    hview_field=findobj(allchild(0),'tag','view_field');
    455441    if isempty(hview_field)
    456         hview_field=view_field;
     442        hview_field=view_field;%open the GUI view_field if it is not found
    457443    end
    458444    PlotHandles=guidata(hview_field);
     
    464450set(hhuvmat.ListObject,'String',ListObject)
    465451
    466 %% update the object plot and projection field
     452%% update the object plot
    467453if testnew
    468454    set(hhuvmat.ListObject,'Value',IndexObj)
     
    488474
    489475%% plot the field projected on the object and store in the corresponding figue
    490 [ProjData,errormsg]= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
    491 if ~isempty(errormsg)
    492     msgbox_uvmat('ERROR', errormsg)
    493     return
    494 end
    495 fighandle=get(plotaxes,'parent');
    496 PlotParam=read_GUI(fighandle);
    497 [PlotType,Object_out{IndexObj(end)}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot
    498 
     476if strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')||strcmp(ObjectData.ProjMode,'none')
     477    PlotType='text';
     478   
     479else
     480    [ProjData,errormsg]= proj_field(UvData.Field,ObjectData);%project the current field of uvmat on ObjectData
     481    if ~isempty(errormsg)
     482        msgbox_uvmat('ERROR', errormsg)
     483        return
     484    end
     485    fighandle=get(plotaxes,'parent');
     486    PlotParam=read_GUI(fighandle);
     487    PlotType=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot
     488end
     489if strcmp(PlotType,'text')
     490    hview_field=findobj(allchild(0),'tag','view_field'); %case of no projection (pure object display)
     491    if ~isempty(hview_field)
     492        delete(hview_field)
     493    end
     494end
     495   
    499496%% update the GUI uvmat
    500497hhuvmat=guidata(huvmat);%handles of elements in the uvmat GUI
     
    603600end
    604601
    605 %set new plane position and update graph
    606 % set(handles.XObject,'String',num2str(norm_plane(1)*Z_value,4))
    607 % set(handles.YObject,'String',num2str(norm_plane(2)*Z_value,4))
    608 % set(handles.ZObject,'String',num2str(norm_plane(3)*Z_value,4))
     602% update graph
    609603PLOT_Callback(hObject, eventdata, handles)
    610604
     
    616610pathelp=fileparts(path_to_uvmat);
    617611helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
    618 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
    619 else
     612if ~isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
    620613    addpath (fullfile(pathelp,'uvmat_doc'))
    621614    web([helpfile '#set_object'])
     
    641634    case{'points','polyline','polygon'}
    642635        Coord=get(handles.Coord,'Data');
    643         if isequal(size(Coord,2),3)
    644             Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case)
    645         else
    646             Coord=[Coord;{[]} {[]}]; %add a line for edition (2D case)
    647         end
    648         set(handles.Coord,'Data',Coord)
     636        if ~isnan(Coord(end,1))
     637            if isequal(size(Coord,2),3)
     638                %Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case)
     639                Coord=[Coord;NaN NaN NaN]; %add a line for edition (3D case)
     640            else
     641                Coord=[Coord;NaN NaN]; %add a line for edition (2D case)
     642            end
     643            set(handles.Coord,'Data',Coord)
     644        end
    649645end
    650646
Note: See TracChangeset for help on using the changeset viewer.