diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 1d0c8327..6b0c76ee 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -19,6 +19,8 @@ updateLineseries(obj, dataIndex); elseif strcmpi(obj.PlotOptions.TreatAs, 'ezpolar') updateLineseries(obj, dataIndex); + elseif strcmpi(obj.PlotOptions.TreatAs, 'streamtube') + updateStreamtube(obj, dataIndex); end %-update plot based on plot call class-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m index 6ad5051c..e53bf56c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m @@ -10,7 +10,7 @@ axis_data = get(obj.State.Plot(contourIndex).AssociatedAxis); %-PLOT DATA STRUCTURE- % -contour_data = get(obj.State.Plot(contourIndex).Handle) +contour_data = get(obj.State.Plot(contourIndex).Handle); %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -40,68 +40,29 @@ xdata = contour_data.XData; ydata = contour_data.YData; zdata = contour_data.ZData; - -if isvector(zdata) - - %-contour type-% - obj.data{contourIndex}.type = 'contour'; - %-contour x data-% - if ~isvector(x) - obj.data{contourIndex}.xdata = xdata(1,:); - else - obj.data{contourIndex}.xdata = xdata; - end +%-contour type-% +obj.data{contourIndex}.type = 'surface'; - %-contour y data-% - if ~isvector(y) - obj.data{contourIndex}.ydata = ydata'; - else - obj.data{contourIndex}.ydata = ydata'; - end - - %-contour z data-% - obj.data{contourIndex}.z = zdata; - -else - - %-contour type-% - obj.data{contourIndex}.type = 'surface'; - - %-contour x and y data -% [xmesh, ymesh] = meshgrid(xdata, ydata); - obj.data{contourIndex}.x = xdata; - obj.data{contourIndex}.y = ydata; - - %-contour z data-% - obj.data{contourIndex}.z = zdata;%-2*ones(size(zdata)); - - %-setting for contour lines z-direction-% - obj.data{contourIndex}.contours.z.start = contour_data.LevelList(1); - obj.data{contourIndex}.contours.z.end = contour_data.LevelList(end); - obj.data{contourIndex}.contours.z.size = contour_data.LevelStep; - obj.data{contourIndex}.contours.z.show = true; - obj.data{contourIndex}.contours.z.usecolormap = true; - obj.data{contourIndex}.hidesurface = true; - obj.data{contourIndex}.surfacecolor = zdata; - - obj.data{contourIndex}.contours.z.project.x = true; - obj.data{contourIndex}.contours.z.project.y = true; - obj.data{contourIndex}.contours.z.project.z = true; - -end +%-contour x and y data +obj.data{contourIndex}.x = xdata; +obj.data{contourIndex}.y = ydata; -%-------------------------------------------------------------------------% +%-contour z data-% +obj.data{contourIndex}.z = zdata;%-2*ones(size(zdata)); -%-contour x type-% +%-setting for contour lines z-direction-% +obj.data{contourIndex}.contours.z.start = contour_data.LevelList(1); +obj.data{contourIndex}.contours.z.end = contour_data.LevelList(end); +obj.data{contourIndex}.contours.z.size = contour_data.LevelStep; +obj.data{contourIndex}.contours.z.show = true; +obj.data{contourIndex}.contours.z.usecolormap = true; +obj.data{contourIndex}.hidesurface = true; +obj.data{contourIndex}.surfacecolor = zdata; -obj.data{contourIndex}.xtype = 'array'; - -%-------------------------------------------------------------------------% - -%-contour y type-% - -obj.data{contourIndex}.ytype = 'array'; +obj.data{contourIndex}.contours.z.project.x = true; +obj.data{contourIndex}.contours.z.project.y = true; +obj.data{contourIndex}.contours.z.project.z = true; %-------------------------------------------------------------------------% @@ -116,21 +77,6 @@ %-------------------------------------------------------------------------% -%-zauto-% -obj.data{contourIndex}.zauto = false; - -%-------------------------------------------------------------------------% - -%-zmin-% -obj.data{contourIndex}.zmin = axis_data.CLim(1); - -%-------------------------------------------------------------------------% - -%-zmax-% -obj.data{contourIndex}.zmax = axis_data.CLim(2); - -%-------------------------------------------------------------------------% - %-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% colormap = figure_data.Colormap; @@ -144,69 +90,53 @@ %-contour reverse scale-% obj.data{contourIndex}.reversescale = false; -%-------------------------------------------------------------------------% - -%-autocontour-% -obj.data{contourIndex}.autocontour = false; +%---------------------------------------------------------------------% -%-------------------------------------------------------------------------% +%-aspect ratio-% +ar = obj.PlotOptions.AspectRatio; -%-contour contours-% +if ~isempty(ar) + if ischar(ar) + obj.layout.scene.aspectmode = ar; + elseif isvector(ar) && length(ar) == 3 + xar = ar(1); + yar = ar(2); + zar = ar(3); + end +else -%-coloring-% -switch contour_data.Fill - case 'off' - obj.data{contourIndex}.contours.coloring = 'lines'; - case 'on' - obj.data{contourIndex}.contours.coloring = 'fill'; + %-define as default-% + xar = max(xdata(:)); + yar = max(ydata(:)); + xyar = max([xar, yar]); + zar = 0.6*xyar; end -%-start-% -obj.data{contourIndex}.contours.start = contour_data.TextList(1); +obj.layout.scene.aspectratio.x = xyar; +obj.layout.scene.aspectratio.y = xyar; +obj.layout.scene.aspectratio.z = zar; -%-end-% -obj.data{contourIndex}.contours.end = contour_data.TextList(end); +%---------------------------------------------------------------------% -%-step-% -obj.data{contourIndex}.contours.size = diff(contour_data.TextList(1:2)); +%-camera eye-% +ey = obj.PlotOptions.CameraEye; -%-------------------------------------------------------------------------% - -if(~strcmp(contour_data.LineStyle,'none')) - - %-contour line colour-% - if isnumeric(contour_data.LineColor) - col = 255*contour_data.LineColor; - obj.data{contourIndex}.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - else - obj.data{contourIndex}.line.color = 'rgba(0,0,0,0)'; - end - - %-contour line width-% - obj.data{contourIndex}.line.width = contour_data.LineWidth; - - %-contour line dash-% - switch contour_data.LineStyle - case '-' - LineStyle = 'solid'; - case '--' - LineStyle = 'dash'; - case ':' - LineStyle = 'dot'; - case '-.' - LineStyle = 'dashdot'; +if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + obj.layout.scene.camera.eye.x = ey(1); + obj.layout.scene.camera.eye.y = ey(2); + obj.layout.scene.camera.eye.z = ey(3); end - - obj.data{contourIndex}.line.dash = LineStyle; - - %-contour smoothing-% - obj.data{contourIndex}.line.smoothing = 0; - else + + %-define as default-% + xey = - xyar; if xey>0 xfac = -0.2; else xfac = 0.2; end + yey = - xyar; if yey>0 yfac = -0.2; else yfac = 0.2; end + if zar>0 zfac = 0.2; else zfac = -0.2; end - %-contours showlines-% - obj.data{contourIndex}.contours.showlines = false; - + obj.layout.scene.camera.eye.x = xey + xfac*xey; + obj.layout.scene.camera.eye.y = yey + yfac*yey; + obj.layout.scene.camera.eye.z = zar + zfac*zar; end %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m new file mode 100644 index 00000000..f19ab522 --- /dev/null +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -0,0 +1,156 @@ +function obj = updateStreamtube(obj, surfaceIndex) +if strcmpi(obj.State.Plot(surfaceIndex).Class, 'surface') + updateSurfaceStreamtube(obj, surfaceIndex) +end +end + +function updateSurfaceStreamtube(obj, surfaceIndex) + +%-AXIS INDEX-% +axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + +%-CHECK FOR MULTIPLE AXES-% +[xsource, ysource] = findSourceAxis(obj,axIndex); + +%-SURFACE DATA STRUCTURE- % +image_data = get(obj.State.Plot(surfaceIndex).Handle); +figure_data = get(obj.State.Figure.Handle); + +%-AXIS DATA-% +eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); +eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); + +%-------------------------------------------------------------------------% + +%-surface xaxis-% +obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; + +%-------------------------------------------------------------------------% + +%-surface yaxis-% +obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; + + +%---------------------------------------------------------------------% + +%-surface type-% +obj.data{surfaceIndex}.type = 'surface'; + +%---------------------------------------------------------------------% + +%-format x an y data-% +ymax = 100; +x = image_data.XData; +y = image_data.YData; +z = image_data.ZData; +cdata = image_data.CData; + +ysize = size(x,1); +xsize = size(x,2); + +if ysize > ymax + ystep = round(ysize/ymax); + x = x(1:ystep:end, :); + y = y(1:ystep:end, :); + z = z(1:ystep:end, :); + cdata = cdata(1:ystep:end, :); +end + +if isvector(x) + [x, y] = meshgrid(x,y); +end + +%---------------------------------------------------------------------% + +%-surface x-% +obj.data{surfaceIndex}.x = x; + +%---------------------------------------------------------------------% + +%-surface y-% +obj.data{surfaceIndex}.y = y; + +%---------------------------------------------------------------------% + +%-surface z-% +obj.data{surfaceIndex}.z = z; + +%---------------------------------------------------------------------% + +%-if image comes would a 3D plot-% +obj.PlotOptions.Image3D = true; + +%-if contour comes would a ContourProjection-% +obj.PlotOptions.ContourProjection = true; + +%---------------------------------------------------------------------% + +%- setting grid mesh by default -% +% x-direction +xmin = min(x(:)); +xmax = max(x(:)); +xsize = (xmax - xmin) / (size(x, 2)-1); +obj.data{surfaceIndex}.contours.x.start = xmin; +obj.data{surfaceIndex}.contours.x.end = xmax; +obj.data{surfaceIndex}.contours.x.size = xsize; +obj.data{surfaceIndex}.contours.x.show = true; +obj.data{surfaceIndex}.contours.x.color = 'black'; +% y-direction +ymin = min(y(:)); +ymax = max(y(:)); +ysize = (ymax - ymin) / (size(y, 1)-1); +obj.data{surfaceIndex}.contours.y.start = ymin; +obj.data{surfaceIndex}.contours.y.end = ymax; +obj.data{surfaceIndex}.contours.y.size = ysize; +obj.data{surfaceIndex}.contours.y.show = true; +obj.data{surfaceIndex}.contours.y.color = 'black'; + +%-------------------------------------------------------------------------% + +%-image colorscale-% + +cmap = figure_data.Colormap; +len = length(cmap)-1; + +for c = 1: length(cmap) + col = 255 * cmap(c, :); + obj.data{surfaceIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] }; +end + +%-------------------------------------------------------------------------% + +%-surface coloring-% +obj.data{surfaceIndex}.surfacecolor = cdata; + +%-------------------------------------------------------------------------% + +%-surface name-% +obj.data{surfaceIndex}.name = image_data.DisplayName; + +%-------------------------------------------------------------------------% + +%-surface showscale-% +obj.data{surfaceIndex}.showscale = false; + +%-------------------------------------------------------------------------% + +%-surface visible-% +obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); + +%-------------------------------------------------------------------------% + +leg = get(image_data.Annotation); +legInfo = get(leg.LegendInformation); + +switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; +end + +obj.data{surfaceIndex}.showlegend = showleg; + +%-------------------------------------------------------------------------% + +end