|
| 1 | +function obj = updateStreamtube(obj, surfaceIndex) |
| 2 | +if strcmpi(obj.State.Plot(surfaceIndex).Class, 'surface') |
| 3 | + updateSurfaceStreamtube(obj, surfaceIndex) |
| 4 | +end |
| 5 | +end |
| 6 | + |
| 7 | +function updateSurfaceStreamtube(obj, surfaceIndex) |
| 8 | + |
| 9 | +%-AXIS INDEX-% |
| 10 | +axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); |
| 11 | + |
| 12 | +%-CHECK FOR MULTIPLE AXES-% |
| 13 | +[xsource, ysource] = findSourceAxis(obj,axIndex); |
| 14 | + |
| 15 | +%-SURFACE DATA STRUCTURE- % |
| 16 | +image_data = get(obj.State.Plot(surfaceIndex).Handle); |
| 17 | +figure_data = get(obj.State.Figure.Handle); |
| 18 | + |
| 19 | +%-AXIS DATA-% |
| 20 | +eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); |
| 21 | +eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); |
| 22 | + |
| 23 | +%-------------------------------------------------------------------------% |
| 24 | + |
| 25 | +%-surface xaxis-% |
| 26 | +obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; |
| 27 | + |
| 28 | +%-------------------------------------------------------------------------% |
| 29 | + |
| 30 | +%-surface yaxis-% |
| 31 | +obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; |
| 32 | + |
| 33 | + |
| 34 | +%---------------------------------------------------------------------% |
| 35 | + |
| 36 | +%-surface type-% |
| 37 | +obj.data{surfaceIndex}.type = 'surface'; |
| 38 | + |
| 39 | +%---------------------------------------------------------------------% |
| 40 | + |
| 41 | +%-format x an y data-% |
| 42 | +ymax = 100; |
| 43 | +x = image_data.XData; |
| 44 | +y = image_data.YData; |
| 45 | +z = image_data.ZData; |
| 46 | +cdata = image_data.CData; |
| 47 | + |
| 48 | +ysize = size(x,1); |
| 49 | +xsize = size(x,2); |
| 50 | + |
| 51 | +if ysize > ymax |
| 52 | + ystep = round(ysize/ymax); |
| 53 | + x = x(1:ystep:end, :); |
| 54 | + y = y(1:ystep:end, :); |
| 55 | + z = z(1:ystep:end, :); |
| 56 | + cdata = cdata(1:ystep:end, :); |
| 57 | +end |
| 58 | + |
| 59 | +if isvector(x) |
| 60 | + [x, y] = meshgrid(x,y); |
| 61 | +end |
| 62 | + |
| 63 | +%---------------------------------------------------------------------% |
| 64 | + |
| 65 | +%-surface x-% |
| 66 | +obj.data{surfaceIndex}.x = x; |
| 67 | + |
| 68 | +%---------------------------------------------------------------------% |
| 69 | + |
| 70 | +%-surface y-% |
| 71 | +obj.data{surfaceIndex}.y = y; |
| 72 | + |
| 73 | +%---------------------------------------------------------------------% |
| 74 | + |
| 75 | +%-surface z-% |
| 76 | +obj.data{surfaceIndex}.z = z; |
| 77 | + |
| 78 | +%---------------------------------------------------------------------% |
| 79 | + |
| 80 | +%-if image comes would a 3D plot-% |
| 81 | +obj.PlotOptions.Image3D = true; |
| 82 | + |
| 83 | +%-if contour comes would a ContourProjection-% |
| 84 | +obj.PlotOptions.ContourProjection = true; |
| 85 | + |
| 86 | +%---------------------------------------------------------------------% |
| 87 | + |
| 88 | +%- setting grid mesh by default -% |
| 89 | +% x-direction |
| 90 | +xmin = min(x(:)); |
| 91 | +xmax = max(x(:)); |
| 92 | +xsize = (xmax - xmin) / (size(x, 2)-1); |
| 93 | +obj.data{surfaceIndex}.contours.x.start = xmin; |
| 94 | +obj.data{surfaceIndex}.contours.x.end = xmax; |
| 95 | +obj.data{surfaceIndex}.contours.x.size = xsize; |
| 96 | +obj.data{surfaceIndex}.contours.x.show = true; |
| 97 | +obj.data{surfaceIndex}.contours.x.color = 'black'; |
| 98 | +% y-direction |
| 99 | +ymin = min(y(:)); |
| 100 | +ymax = max(y(:)); |
| 101 | +ysize = (ymax - ymin) / (size(y, 1)-1); |
| 102 | +obj.data{surfaceIndex}.contours.y.start = ymin; |
| 103 | +obj.data{surfaceIndex}.contours.y.end = ymax; |
| 104 | +obj.data{surfaceIndex}.contours.y.size = ysize; |
| 105 | +obj.data{surfaceIndex}.contours.y.show = true; |
| 106 | +obj.data{surfaceIndex}.contours.y.color = 'black'; |
| 107 | + |
| 108 | +%-------------------------------------------------------------------------% |
| 109 | + |
| 110 | +%-image colorscale-% |
| 111 | + |
| 112 | +cmap = figure_data.Colormap; |
| 113 | +len = length(cmap)-1; |
| 114 | + |
| 115 | +for c = 1: length(cmap) |
| 116 | + col = 255 * cmap(c, :); |
| 117 | + obj.data{surfaceIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] }; |
| 118 | +end |
| 119 | + |
| 120 | +%-------------------------------------------------------------------------% |
| 121 | + |
| 122 | +%-surface coloring-% |
| 123 | +obj.data{surfaceIndex}.surfacecolor = cdata; |
| 124 | + |
| 125 | +%-------------------------------------------------------------------------% |
| 126 | + |
| 127 | +%-surface name-% |
| 128 | +obj.data{surfaceIndex}.name = image_data.DisplayName; |
| 129 | + |
| 130 | +%-------------------------------------------------------------------------% |
| 131 | + |
| 132 | +%-surface showscale-% |
| 133 | +obj.data{surfaceIndex}.showscale = false; |
| 134 | + |
| 135 | +%-------------------------------------------------------------------------% |
| 136 | + |
| 137 | +%-surface visible-% |
| 138 | +obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); |
| 139 | + |
| 140 | +%-------------------------------------------------------------------------% |
| 141 | + |
| 142 | +leg = get(image_data.Annotation); |
| 143 | +legInfo = get(leg.LegendInformation); |
| 144 | + |
| 145 | +switch legInfo.IconDisplayStyle |
| 146 | + case 'on' |
| 147 | + showleg = true; |
| 148 | + case 'off' |
| 149 | + showleg = false; |
| 150 | +end |
| 151 | + |
| 152 | +obj.data{surfaceIndex}.showlegend = showleg; |
| 153 | + |
| 154 | +%-------------------------------------------------------------------------% |
| 155 | + |
| 156 | +end |
0 commit comments