[3018] | 1 | function [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root,options);
|
---|
[1] | 2 | %ADDINSIDEPROFILE - add apoint inside a profile
|
---|
| 3 | %
|
---|
[8662] | 4 | % this script is used by exptool as an elementary operation
|
---|
[1] | 5 | % on an ARGUS profile
|
---|
| 6 | %
|
---|
| 7 | % Usage:
|
---|
[3018] | 8 | % [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
|
---|
[1] | 9 |
|
---|
| 10 | %some checks
|
---|
| 11 | if numprofiles==0
|
---|
[33] | 12 | disp('no profile present, exiting...')
|
---|
[1] | 13 | return
|
---|
| 14 | end
|
---|
| 15 | if numpoints<2
|
---|
[33] | 16 | disp('at least two points are required, exiting...')
|
---|
[1] | 17 | return
|
---|
| 18 | end
|
---|
| 19 | hold on
|
---|
| 20 |
|
---|
| 21 | %plot squares
|
---|
| 22 | for i=1:numprofiles
|
---|
[5088] | 23 | plot(A(i).x,A(i).y,'color',getfieldvalue(options,'color'),'LineStyle',getfieldvalue(options,'LineStyle'),'LineWidth',getfieldvalue(options,'LineWidth'),...
|
---|
| 24 | 'MarkerEdgeColor',getfieldvalue(options,'MarkerEdgeColor'),'MarkerSize',getfieldvalue(options,'MarkerSize'),'Marker',getfieldvalue(options,'Marker'));
|
---|
[1] | 25 | end
|
---|
| 26 |
|
---|
[3018] | 27 | loop=1;
|
---|
[1] | 28 | while loop
|
---|
| 29 |
|
---|
| 30 | %first step, select a segment
|
---|
| 31 | title('click on a segment, RETURN to exit','FontSize',14)
|
---|
| 32 | [xi,yi] = ginput(1);
|
---|
| 33 |
|
---|
| 34 | %first click
|
---|
| 35 | if ~isempty(xi)
|
---|
| 36 |
|
---|
| 37 | %get the closest segment
|
---|
| 38 | [profsel indsel]=closestsegment(A,numprofiles,xi,yi);
|
---|
| 39 |
|
---|
| 40 | %check that at least one segment exists
|
---|
| 41 | if indsel==0
|
---|
[33] | 42 | disp('at least two points in one profile are required, exiting...')
|
---|
[1] | 43 | return
|
---|
| 44 | end
|
---|
| 45 |
|
---|
| 46 | %highlight selected segment
|
---|
[3018] | 47 | plot([A(profsel).x(indsel) A(profsel).x(indsel+1)],[A(profsel).y(indsel) A(profsel).y(indsel+1)],...
|
---|
[5088] | 48 | 'color',getfieldvalue(options,'selectioncolor'),'LineStyle',getfieldvalue(options,'LineStyle'),'LineWidth',getfieldvalue(options,'LineWidth'),...
|
---|
| 49 | 'MarkerEdgeColor',getfieldvalue(options,'MarkerEdgeColor'),'MarkerSize',getfieldvalue(options,'MarkerSize'),'Marker',getfieldvalue(options,'Marker'));
|
---|
[1] | 50 |
|
---|
| 51 | %next click
|
---|
| 52 | title('click on the new point''s location, RETURN to exit','FontSize',14)
|
---|
| 53 | [xi,yi,but] = ginput(1);
|
---|
| 54 |
|
---|
| 55 | %second click
|
---|
| 56 | if ~isempty(xi)
|
---|
| 57 |
|
---|
| 58 | %add point to A
|
---|
| 59 | A(profsel).x=[A(profsel).x(1:indsel,1); xi; A(profsel).x(indsel+1:end,1)];
|
---|
| 60 | A(profsel).y=[A(profsel).y(1:indsel,1); yi; A(profsel).y(indsel+1:end,1)];
|
---|
| 61 | numpoints=numpoints+1;
|
---|
| 62 |
|
---|
| 63 | %plot new profile
|
---|
| 64 | undoplots(prevplot);
|
---|
| 65 | for i=1:numprofiles
|
---|
[5088] | 66 | plot(A(i).x,A(i).y,'color',getfieldvalue(options,'color'),'LineStyle',getfieldvalue(options,'LineStyle'),'LineWidth',getfieldvalue(options,'LineWidth'),...
|
---|
| 67 | 'MarkerEdgeColor',getfieldvalue(options,'MarkerEdgeColor'),'MarkerSize',getfieldvalue(options,'MarkerSize'),'Marker',getfieldvalue(options,'Marker'));
|
---|
[1] | 68 | end
|
---|
| 69 |
|
---|
| 70 | else
|
---|
| 71 | %RETURN->exit
|
---|
| 72 | return
|
---|
| 73 | end
|
---|
| 74 | else
|
---|
| 75 | %RETURN-> exit
|
---|
| 76 | return
|
---|
| 77 | end
|
---|
| 78 | end
|
---|
| 79 | end
|
---|