|
| 1 | +function obj = updateImage3D(obj, imageIndex) |
| 2 | + |
| 3 | +% AS SURFACE |
| 4 | +% z: ...[DONE] |
| 5 | +% x: ...[DONE] |
| 6 | +% y: ...[DONE] |
| 7 | +% name: ...[DONE] |
| 8 | +% zauto: ...[DONE] |
| 9 | +% zmin: ...[DONE] |
| 10 | +% zmax: ...[DONE] |
| 11 | +% colorscale: ...[DONE] |
| 12 | +% reversescale: ...[DONE] |
| 13 | +% showscale: ...[DONE] |
| 14 | +% colorbar: ...[HANDLED BY COLORBAR] |
| 15 | +% zsmooth: ...[NOT SUPPORTED BY MATLAB] |
| 16 | +% opacity: ---[TODO] |
| 17 | +% xaxis: ...[DONE] |
| 18 | +% yaxis: ...[DONE] |
| 19 | +% showlegend: ...[DONE] |
| 20 | +% stream: ...[HANDLED BY PLOTLYSTREAM] |
| 21 | +% visible: ...[DONE] |
| 22 | +% x0: ...[NOT SUPPORTED IN MATLAB] |
| 23 | +% dx: ...[NOT SUPPORTED IN MATLAB] |
| 24 | +% y0: ...[NOT SUPPORTED IN MATLAB] |
| 25 | +% dy: ...[NOT SUPPORTED IN MATLAB] |
| 26 | +% xtype: ...[NOT SUPPORTED IN MATLAB] |
| 27 | +% ytype: ...[NOT SUPPORTED IN MATLAB] |
| 28 | +% type: ...[DONE] |
| 29 | + |
| 30 | +%-FIGURE STRUCTURE-% |
| 31 | +figure_data = get(obj.State.Figure.Handle); |
| 32 | + |
| 33 | +%-AXIS STRUCTURE-% |
| 34 | +axis_data = get(obj.State.Plot(imageIndex).AssociatedAxis); |
| 35 | + |
| 36 | +%-AXIS INDEX-% |
| 37 | +axIndex = obj.getAxisIndex(obj.State.Plot(imageIndex).AssociatedAxis); |
| 38 | + |
| 39 | +%-CHECK FOR MULTIPLE AXES-% |
| 40 | +[xsource, ysource] = findSourceAxis(obj,axIndex); |
| 41 | + |
| 42 | +%-IMAGE DATA STRUCTURE- % |
| 43 | +image_data = get(obj.State.Plot(imageIndex).Handle); |
| 44 | + |
| 45 | +%-AXIS DATA-% |
| 46 | +eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); |
| 47 | +eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); |
| 48 | + |
| 49 | +%-------------------------------------------------------------------------% |
| 50 | + |
| 51 | +%-image xaxis-% |
| 52 | +obj.data{imageIndex}.xaxis = ['x' num2str(xsource)]; |
| 53 | + |
| 54 | +%-------------------------------------------------------------------------% |
| 55 | + |
| 56 | +%-image yaxis-% |
| 57 | +obj.data{imageIndex}.yaxis = ['y' num2str(ysource)]; |
| 58 | + |
| 59 | +%-------------------------------------------------------------------------% |
| 60 | + |
| 61 | +%-image type-% |
| 62 | +obj.data{imageIndex}.type = 'surface'; |
| 63 | + |
| 64 | +%-------------------------------------------------------------------------% |
| 65 | + |
| 66 | +%-format x an y data-% |
| 67 | +x = image_data.XData; |
| 68 | +y = image_data.YData; |
| 69 | +cdata = image_data.CData; |
| 70 | + |
| 71 | +if isvector(x) |
| 72 | + if size(x,2) == 2 |
| 73 | + x = linspace(x(1), x(2), size(cdata,2)); |
| 74 | + end |
| 75 | + |
| 76 | + if size(y,2) == 2 |
| 77 | + y = linspace(y(1), y(2), size(cdata,1)); |
| 78 | + end |
| 79 | + |
| 80 | + [x, y] = meshgrid(x, y); |
| 81 | +end |
| 82 | + |
| 83 | +%-------------------------------------------------------------------------% |
| 84 | + |
| 85 | +%-surface x-% |
| 86 | +obj.data{imageIndex}.x = x; |
| 87 | + |
| 88 | +%-------------------------------------------------------------------------% |
| 89 | + |
| 90 | +%-surface x-% |
| 91 | +obj.data{imageIndex}.y = y; |
| 92 | + |
| 93 | +%-------------------------------------------------------------------------% |
| 94 | + |
| 95 | +%-surface z-% |
| 96 | +isrgbimg = (size(image_data.CData,3) > 1); |
| 97 | + |
| 98 | +if isrgbimg |
| 99 | + [IND,colormap] = rgb2ind(cdata, 256); |
| 100 | + obj.data{imageIndex}.z = IND; |
| 101 | +else |
| 102 | + obj.data{imageIndex}.z = zeros(size(cdata)); |
| 103 | +end |
| 104 | + |
| 105 | +%-------------------------------------------------------------------------% |
| 106 | + |
| 107 | +%-surface coloring-% |
| 108 | +obj.data{imageIndex}.surfacecolor = cdata; |
| 109 | + |
| 110 | +%-------------------------------------------------------------------------% |
| 111 | + |
| 112 | +%-surface setting-% |
| 113 | +obj.layout.scene.aspectmode = 'cube'; |
| 114 | + |
| 115 | +%-------------------------------------------------------------------------% |
| 116 | + |
| 117 | +%-image name-% |
| 118 | +try |
| 119 | + obj.data{imageIndex}.name = image_data.DisplayName; |
| 120 | +catch |
| 121 | + obj.data{imageIndex}.name = ''; |
| 122 | +end |
| 123 | + |
| 124 | +%-------------------------------------------------------------------------% |
| 125 | + |
| 126 | +%-set the opacity-% |
| 127 | +obj.data{imageIndex}.opacity = image_data.AlphaData; |
| 128 | + |
| 129 | +%-------------------------------------------------------------------------% |
| 130 | + |
| 131 | +%-image visible-% |
| 132 | +obj.data{imageIndex}.visible = strcmp(image_data.Visible,'on'); |
| 133 | + |
| 134 | +%-------------------------------------------------------------------------% |
| 135 | + |
| 136 | +%-image showscale-% |
| 137 | +obj.data{imageIndex}.showscale = false; |
| 138 | + |
| 139 | +%-------------------------------------------------------------------------% |
| 140 | + |
| 141 | +%-image zauto-% |
| 142 | +obj.data{imageIndex}.zauto = false; |
| 143 | + |
| 144 | +%-------------------------------------------------------------------------% |
| 145 | + |
| 146 | +%-image zmin-% |
| 147 | +obj.data{imageIndex}.zmin = axis_data.CLim(1); |
| 148 | + |
| 149 | +%-------------------------------------------------------------------------% |
| 150 | + |
| 151 | +%-image zmax-% |
| 152 | +if ~strcmpi(image_data.CDataMapping, 'direct') |
| 153 | + obj.data{imageIndex}.zmax = axis_data.CLim(2); |
| 154 | +else |
| 155 | + obj.data{imageIndex}.zmax = 255; |
| 156 | +end |
| 157 | + |
| 158 | +%-------------------------------------------------------------------------% |
| 159 | + |
| 160 | +%-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-% |
| 161 | + |
| 162 | +%-image colorscale-% |
| 163 | + |
| 164 | +if ~isrgbimg |
| 165 | + colormap = figure_data.Colormap; |
| 166 | +end |
| 167 | + |
| 168 | +len = length(colormap) - 1; |
| 169 | + |
| 170 | +for c = 1:size(colormap, 1) |
| 171 | + col = 255*(colormap(c,:)); |
| 172 | + obj.data{imageIndex}.colorscale{c} = {(c-1)/len, ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; |
| 173 | +end |
| 174 | + |
| 175 | +%-------------------------------------------------------------------------% |
| 176 | + |
| 177 | +%-image showlegend-% |
| 178 | +try |
| 179 | + leg = get(image_data.Annotation); |
| 180 | + legInfo = get(leg.LegendInformation); |
| 181 | + |
| 182 | + switch legInfo.IconDisplayStyle |
| 183 | + case 'on' |
| 184 | + showleg = true; |
| 185 | + case 'off' |
| 186 | + showleg = false; |
| 187 | + end |
| 188 | + |
| 189 | + obj.data{imageIndex}.showlegend = showleg; |
| 190 | +catch |
| 191 | + %TODO to future |
| 192 | +end |
| 193 | + |
| 194 | +%-------------------------------------------------------------------------% |
| 195 | + |
| 196 | +end |
| 197 | + |
0 commit comments