|
| 1 | +function obj = updateContourProjection(obj,contourIndex) |
| 2 | + |
| 3 | +%-FIGURE DATA STRUCTURE-% |
| 4 | +figure_data = get(obj.State.Figure.Handle); |
| 5 | + |
| 6 | +%-AXIS INDEX-% |
| 7 | +axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); |
| 8 | + |
| 9 | +%-AXIS DATA STRUCTURE-% |
| 10 | +axis_data = get(obj.State.Plot(contourIndex).AssociatedAxis); |
| 11 | + |
| 12 | +%-PLOT DATA STRUCTURE- % |
| 13 | +contour_data = get(obj.State.Plot(contourIndex).Handle) |
| 14 | + |
| 15 | +%-CHECK FOR MULTIPLE AXES-% |
| 16 | +[xsource, ysource] = findSourceAxis(obj,axIndex); |
| 17 | + |
| 18 | +%-AXIS DATA-% |
| 19 | +eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); |
| 20 | +eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); |
| 21 | + |
| 22 | +%-------------------------------------------------------------------------% |
| 23 | + |
| 24 | +%-contour xaxis-% |
| 25 | +obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; |
| 26 | + |
| 27 | +%-------------------------------------------------------------------------% |
| 28 | + |
| 29 | +%-contour yaxis-% |
| 30 | +obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; |
| 31 | + |
| 32 | +%-------------------------------------------------------------------------% |
| 33 | + |
| 34 | +%-contour name-% |
| 35 | +obj.data{contourIndex}.name = contour_data.DisplayName; |
| 36 | + |
| 37 | +%-------------------------------------------------------------------------% |
| 38 | + |
| 39 | +%-setting the plot-% |
| 40 | +xdata = contour_data.XData; |
| 41 | +ydata = contour_data.YData; |
| 42 | +zdata = contour_data.ZData; |
| 43 | + |
| 44 | +if isvector(zdata) |
| 45 | + |
| 46 | + %-contour type-% |
| 47 | + obj.data{contourIndex}.type = 'contour'; |
| 48 | + |
| 49 | + %-contour x data-% |
| 50 | + if ~isvector(x) |
| 51 | + obj.data{contourIndex}.xdata = xdata(1,:); |
| 52 | + else |
| 53 | + obj.data{contourIndex}.xdata = xdata; |
| 54 | + end |
| 55 | + |
| 56 | + %-contour y data-% |
| 57 | + if ~isvector(y) |
| 58 | + obj.data{contourIndex}.ydata = ydata'; |
| 59 | + else |
| 60 | + obj.data{contourIndex}.ydata = ydata'; |
| 61 | + end |
| 62 | + |
| 63 | + %-contour z data-% |
| 64 | + obj.data{contourIndex}.z = zdata; |
| 65 | + |
| 66 | +else |
| 67 | + |
| 68 | + %-contour type-% |
| 69 | + obj.data{contourIndex}.type = 'surface'; |
| 70 | + |
| 71 | + %-contour x and y data |
| 72 | +% [xmesh, ymesh] = meshgrid(xdata, ydata); |
| 73 | + obj.data{contourIndex}.x = xdata; |
| 74 | + obj.data{contourIndex}.y = ydata; |
| 75 | + |
| 76 | + %-contour z data-% |
| 77 | + obj.data{contourIndex}.z = zdata;%-2*ones(size(zdata)); |
| 78 | + |
| 79 | + %-setting for contour lines z-direction-% |
| 80 | + obj.data{contourIndex}.contours.z.start = contour_data.LevelList(1); |
| 81 | + obj.data{contourIndex}.contours.z.end = contour_data.LevelList(end); |
| 82 | + obj.data{contourIndex}.contours.z.size = contour_data.LevelStep; |
| 83 | + obj.data{contourIndex}.contours.z.show = true; |
| 84 | + obj.data{contourIndex}.contours.z.usecolormap = true; |
| 85 | + obj.data{contourIndex}.hidesurface = true; |
| 86 | + obj.data{contourIndex}.surfacecolor = zdata; |
| 87 | + |
| 88 | + obj.data{contourIndex}.contours.z.project.x = true; |
| 89 | + obj.data{contourIndex}.contours.z.project.y = true; |
| 90 | + obj.data{contourIndex}.contours.z.project.z = true; |
| 91 | + |
| 92 | +end |
| 93 | + |
| 94 | +%-------------------------------------------------------------------------% |
| 95 | + |
| 96 | +%-contour x type-% |
| 97 | + |
| 98 | +obj.data{contourIndex}.xtype = 'array'; |
| 99 | + |
| 100 | +%-------------------------------------------------------------------------% |
| 101 | + |
| 102 | +%-contour y type-% |
| 103 | + |
| 104 | +obj.data{contourIndex}.ytype = 'array'; |
| 105 | + |
| 106 | +%-------------------------------------------------------------------------% |
| 107 | + |
| 108 | +%-contour visible-% |
| 109 | + |
| 110 | +obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); |
| 111 | + |
| 112 | +%-------------------------------------------------------------------------% |
| 113 | + |
| 114 | +%-contour showscale-% |
| 115 | +obj.data{contourIndex}.showscale = false; |
| 116 | + |
| 117 | +%-------------------------------------------------------------------------% |
| 118 | + |
| 119 | +%-zauto-% |
| 120 | +obj.data{contourIndex}.zauto = false; |
| 121 | + |
| 122 | +%-------------------------------------------------------------------------% |
| 123 | + |
| 124 | +%-zmin-% |
| 125 | +obj.data{contourIndex}.zmin = axis_data.CLim(1); |
| 126 | + |
| 127 | +%-------------------------------------------------------------------------% |
| 128 | + |
| 129 | +%-zmax-% |
| 130 | +obj.data{contourIndex}.zmax = axis_data.CLim(2); |
| 131 | + |
| 132 | +%-------------------------------------------------------------------------% |
| 133 | + |
| 134 | +%-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% |
| 135 | +colormap = figure_data.Colormap; |
| 136 | + |
| 137 | +for c = 1:size((colormap),1) |
| 138 | + col = 255*(colormap(c,:)); |
| 139 | + obj.data{contourIndex}.colorscale{c} = {(c-1)/(size(colormap,1)-1), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; |
| 140 | +end |
| 141 | + |
| 142 | +%-------------------------------------------------------------------------% |
| 143 | + |
| 144 | +%-contour reverse scale-% |
| 145 | +obj.data{contourIndex}.reversescale = false; |
| 146 | + |
| 147 | +%-------------------------------------------------------------------------% |
| 148 | + |
| 149 | +%-autocontour-% |
| 150 | +obj.data{contourIndex}.autocontour = false; |
| 151 | + |
| 152 | +%-------------------------------------------------------------------------% |
| 153 | + |
| 154 | +%-contour contours-% |
| 155 | + |
| 156 | +%-coloring-% |
| 157 | +switch contour_data.Fill |
| 158 | + case 'off' |
| 159 | + obj.data{contourIndex}.contours.coloring = 'lines'; |
| 160 | + case 'on' |
| 161 | + obj.data{contourIndex}.contours.coloring = 'fill'; |
| 162 | +end |
| 163 | + |
| 164 | +%-start-% |
| 165 | +obj.data{contourIndex}.contours.start = contour_data.TextList(1); |
| 166 | + |
| 167 | +%-end-% |
| 168 | +obj.data{contourIndex}.contours.end = contour_data.TextList(end); |
| 169 | + |
| 170 | +%-step-% |
| 171 | +obj.data{contourIndex}.contours.size = diff(contour_data.TextList(1:2)); |
| 172 | + |
| 173 | +%-------------------------------------------------------------------------% |
| 174 | + |
| 175 | +if(~strcmp(contour_data.LineStyle,'none')) |
| 176 | + |
| 177 | + %-contour line colour-% |
| 178 | + if isnumeric(contour_data.LineColor) |
| 179 | + col = 255*contour_data.LineColor; |
| 180 | + obj.data{contourIndex}.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; |
| 181 | + else |
| 182 | + obj.data{contourIndex}.line.color = 'rgba(0,0,0,0)'; |
| 183 | + end |
| 184 | + |
| 185 | + %-contour line width-% |
| 186 | + obj.data{contourIndex}.line.width = contour_data.LineWidth; |
| 187 | + |
| 188 | + %-contour line dash-% |
| 189 | + switch contour_data.LineStyle |
| 190 | + case '-' |
| 191 | + LineStyle = 'solid'; |
| 192 | + case '--' |
| 193 | + LineStyle = 'dash'; |
| 194 | + case ':' |
| 195 | + LineStyle = 'dot'; |
| 196 | + case '-.' |
| 197 | + LineStyle = 'dashdot'; |
| 198 | + end |
| 199 | + |
| 200 | + obj.data{contourIndex}.line.dash = LineStyle; |
| 201 | + |
| 202 | + %-contour smoothing-% |
| 203 | + obj.data{contourIndex}.line.smoothing = 0; |
| 204 | + |
| 205 | +else |
| 206 | + |
| 207 | + %-contours showlines-% |
| 208 | + obj.data{contourIndex}.contours.showlines = false; |
| 209 | + |
| 210 | +end |
| 211 | + |
| 212 | +%-------------------------------------------------------------------------% |
| 213 | + |
| 214 | +%-contour showlegend-% |
| 215 | + |
| 216 | +leg = get(contour_data.Annotation); |
| 217 | +legInfo = get(leg.LegendInformation); |
| 218 | + |
| 219 | +switch legInfo.IconDisplayStyle |
| 220 | + case 'on' |
| 221 | + showleg = true; |
| 222 | + case 'off' |
| 223 | + showleg = false; |
| 224 | +end |
| 225 | + |
| 226 | +obj.data{contourIndex}.showlegend = showleg; |
| 227 | + |
| 228 | +%-------------------------------------------------------------------------% |
| 229 | + |
| 230 | +end |
0 commit comments