|
| 1 | +function obj = updateFunctionContour(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 | +%-contour type-% |
| 40 | +obj.data{contourIndex}.type = 'contour'; |
| 41 | + |
| 42 | +%-------------------------------------------------------------------------% |
| 43 | + |
| 44 | +%-setting the plot-% |
| 45 | +xdata = contour_data.XData; |
| 46 | +ydata = contour_data.YData; |
| 47 | +zdata = contour_data.ZData; |
| 48 | + |
| 49 | +%-contour x data-% |
| 50 | +if ~isvector(xdata) |
| 51 | + obj.data{contourIndex}.x = xdata(1,:); |
| 52 | +else |
| 53 | + obj.data{contourIndex}.x = xdata; |
| 54 | +end |
| 55 | + |
| 56 | +%-contour y data-% |
| 57 | +if ~isvector(ydata) |
| 58 | + obj.data{contourIndex}.y = ydata(:,1); |
| 59 | +else |
| 60 | + obj.data{contourIndex}.y = ydata; |
| 61 | +end |
| 62 | + |
| 63 | +%-contour z data-% |
| 64 | +obj.data{contourIndex}.z = zdata; |
| 65 | + |
| 66 | +%-------------------------------------------------------------------------% |
| 67 | + |
| 68 | +%-contour x type-% |
| 69 | + |
| 70 | +obj.data{contourIndex}.xtype = 'array'; |
| 71 | + |
| 72 | +%-------------------------------------------------------------------------% |
| 73 | + |
| 74 | +%-contour y type-% |
| 75 | + |
| 76 | +obj.data{contourIndex}.ytype = 'array'; |
| 77 | + |
| 78 | +%-------------------------------------------------------------------------% |
| 79 | + |
| 80 | +%-contour visible-% |
| 81 | + |
| 82 | +obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); |
| 83 | + |
| 84 | +%-------------------------------------------------------------------------% |
| 85 | + |
| 86 | +%-contour showscale-% |
| 87 | +obj.data{contourIndex}.showscale = false; |
| 88 | + |
| 89 | +%-------------------------------------------------------------------------% |
| 90 | + |
| 91 | +%-zauto-% |
| 92 | +obj.data{contourIndex}.zauto = false; |
| 93 | + |
| 94 | +%-------------------------------------------------------------------------% |
| 95 | + |
| 96 | +%-zmin-% |
| 97 | +obj.data{contourIndex}.zmin = axis_data.CLim(1); |
| 98 | + |
| 99 | +%-------------------------------------------------------------------------% |
| 100 | + |
| 101 | +%-zmax-% |
| 102 | +obj.data{contourIndex}.zmax = axis_data.CLim(2); |
| 103 | + |
| 104 | +%-------------------------------------------------------------------------% |
| 105 | + |
| 106 | +%-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% |
| 107 | +colormap = figure_data.Colormap; |
| 108 | + |
| 109 | +for c = 1:size((colormap),1) |
| 110 | + col = 255*(colormap(c,:)); |
| 111 | + obj.data{contourIndex}.colorscale{c} = {(c-1)/(size(colormap,1)-1), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; |
| 112 | +end |
| 113 | + |
| 114 | +%-------------------------------------------------------------------------% |
| 115 | + |
| 116 | +%-contour reverse scale-% |
| 117 | +obj.data{contourIndex}.reversescale = false; |
| 118 | + |
| 119 | +%-------------------------------------------------------------------------% |
| 120 | + |
| 121 | +%-autocontour-% |
| 122 | +obj.data{contourIndex}.autocontour = false; |
| 123 | + |
| 124 | +%-------------------------------------------------------------------------% |
| 125 | + |
| 126 | +%-contour contours-% |
| 127 | + |
| 128 | +%-coloring-% |
| 129 | +switch contour_data.Fill |
| 130 | + case 'off' |
| 131 | + obj.data{contourIndex}.contours.coloring = 'lines'; |
| 132 | + case 'on' |
| 133 | + obj.data{contourIndex}.contours.coloring = 'fill'; |
| 134 | +end |
| 135 | + |
| 136 | +%-start-% |
| 137 | +obj.data{contourIndex}.contours.start = contour_data.LevelList(1); |
| 138 | + |
| 139 | +%-end-% |
| 140 | +obj.data{contourIndex}.contours.end = contour_data.LevelList(end); |
| 141 | + |
| 142 | +%-step-% |
| 143 | +obj.data{contourIndex}.contours.size = contour_data.LevelStep; |
| 144 | + |
| 145 | +%-------------------------------------------------------------------------% |
| 146 | + |
| 147 | +if(~strcmp(contour_data.LineStyle,'none')) |
| 148 | + |
| 149 | + %-contour line colour-% |
| 150 | + if isnumeric(contour_data.LineColor) |
| 151 | + col = 255*contour_data.LineColor; |
| 152 | + obj.data{contourIndex}.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; |
| 153 | + else |
| 154 | + obj.data{contourIndex}.line.color = 'rgba(0,0,0,0)'; |
| 155 | + end |
| 156 | + |
| 157 | + %-contour line width-% |
| 158 | + obj.data{contourIndex}.line.width = contour_data.LineWidth; |
| 159 | + |
| 160 | + %-contour line dash-% |
| 161 | + switch contour_data.LineStyle |
| 162 | + case '-' |
| 163 | + LineStyle = 'solid'; |
| 164 | + case '--' |
| 165 | + LineStyle = 'dash'; |
| 166 | + case ':' |
| 167 | + LineStyle = 'dot'; |
| 168 | + case '-.' |
| 169 | + LineStyle = 'dashdot'; |
| 170 | + end |
| 171 | + |
| 172 | + obj.data{contourIndex}.line.dash = LineStyle; |
| 173 | + |
| 174 | + %-contour smoothing-% |
| 175 | + obj.data{contourIndex}.line.smoothing = 0; |
| 176 | + |
| 177 | +else |
| 178 | + |
| 179 | + %-contours showlines-% |
| 180 | + obj.data{contourIndex}.contours.showlines = false; |
| 181 | + |
| 182 | +end |
| 183 | + |
| 184 | +%-------------------------------------------------------------------------% |
| 185 | + |
| 186 | +%-contour showlegend-% |
| 187 | + |
| 188 | +leg = get(contour_data.Annotation); |
| 189 | +legInfo = get(leg.LegendInformation); |
| 190 | + |
| 191 | +switch legInfo.IconDisplayStyle |
| 192 | + case 'on' |
| 193 | + showleg = true; |
| 194 | + case 'off' |
| 195 | + showleg = false; |
| 196 | +end |
| 197 | + |
| 198 | +obj.data{contourIndex}.showlegend = showleg; |
| 199 | + |
| 200 | +%-------------------------------------------------------------------------% |
| 201 | + |
| 202 | +end |
0 commit comments