Changeset 674 for trunk/src/set_object.m


Ignore:
Timestamp:
Aug 23, 2013, 2:56:17 PM (11 years ago)
Author:
sommeria
Message:

various bugs repaired, in particula timing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/set_object.m

    r667 r674  
    9393    ZBounds=0; %default
    9494end
    95 set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front)
     95set(handles.Coord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function (allow action on uvmat when set_object is in front)
    9696set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
    9797set(hObject,'DeleteFcn',{@closefcn})
     
    722722    % add lines if multi line input needed
    723723    case{'points','polyline','polygon'}
     724        Input=str2num(eventdata.EditData);%pasted input
    724725        Coord=get(handles.Coord,'Data');
    725         if ~isnan(Coord(end,1))
    726             if isequal(size(Coord,2),3)
    727                 %Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case)
    728                 Coord=[Coord;NaN NaN NaN]; %add a line for edition (3D case)
     726        iline=eventdata.Indices(1);% selected line number
     727        if size(Coord,1)<iline+numel(Input)
     728            Coord=[Coord ; zeros(iline+numel(Input)-size(Coord,1),size(Coord,2))];% append zeros to fit the new column
     729        end
     730        Coord(iline:iline+numel(Input)-1,eventdata.Indices(2))=Input';
     731        set(handles.Coord,'Data',Coord)
     732end
     733
     734% --- Executes when selected cell(s) is changed in ListCoord.
     735function Coord_CellSelectionCallback(hObject, eventdata, handles)
     736
     737if ~isempty(eventdata.Indices)
     738    iline=eventdata.Indices(1);% selected line number
     739    set(handles.Coord,'UserData',iline)
     740end
     741
     742%------------------------------------------------------------------------
     743% --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
     744%------------------------------------------------------------------------
     745function key_press_fcn(hObject,eventdata,handles)
     746
     747xx=double(get(handles.set_object,'CurrentCharacter')); %get the keyboard character
     748if ismember(xx,[8 127 31])%backspace or delete, or downward
     749    Coord=get(handles.Coord,'Data');
     750    iline=get(handles.Coord,'UserData');
     751            if isequal(xx, 31)
     752                if isequal(iline,size(Coord,1))% arrow downward
     753                Coord=[Coord;zeros(1,size(Coord,2))];
     754                end
    729755            else
    730                 Coord=[Coord;NaN NaN]; %add a line for edition (2D case)
     756    Coord(iline,:)=[];% suppress the current line
    731757            end
    732             set(handles.Coord,'Data',Coord)
    733         end
    734 end
    735 
    736 
     758    set(handles.Coord,'Data',Coord);
     759end
    737760
    738761function num_Angle_3_Callback(hObject, eventdata, handles)
Note: See TracChangeset for help on using the changeset viewer.