Skip to content

fix issues and awesome improvements in fsurf functionality #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions plotly/plotlyfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
obj.PlotlyDefaults.Bargap = 0;
obj.PlotlyDefaults.CaptionMarginIncreaseFactor = 1.2;
obj.PlotlyDefaults.MinCaptionMargin = 80;
obj.PlotlyDefaults.IsLight = false;

%-State-%
obj.State.Figure = [];
Expand Down Expand Up @@ -622,12 +623,16 @@ function validate(obj)

% reverse plots
nprev = length(plots) - np + 1;

% update the plot fields
obj.State.Figure.NumPlots = obj.State.Figure.NumPlots + 1;
obj.State.Plot(obj.State.Figure.NumPlots).Handle = handle(plots(nprev));
obj.State.Plot(obj.State.Figure.NumPlots).AssociatedAxis = handle(ax(axrev));
obj.State.Plot(obj.State.Figure.NumPlots).Class = getGraphClass(plots(nprev));
if ~strcmpi(getGraphClass(plots(nprev)), 'light')
obj.State.Figure.NumPlots = obj.State.Figure.NumPlots + 1;
obj.State.Plot(obj.State.Figure.NumPlots).Handle = handle(plots(nprev));
obj.State.Plot(obj.State.Figure.NumPlots).AssociatedAxis = handle(ax(axrev));
obj.State.Plot(obj.State.Figure.NumPlots).Class = getGraphClass(plots(nprev));
else
obj.PlotlyDefaults.IsLight = true;
end
end

% this works for pareto
Expand Down
2 changes: 1 addition & 1 deletion plotly/plotlyfig_aux/core/updateData.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
updateRectangle(obj,dataIndex);
case 'surface'
updateSurfaceplot(obj,dataIndex);
case 'functionsurface'
case {'functionsurface', 'parameterizedfunctionsurface'}
updateFunctionSurface(obj,dataIndex);
case 'implicitfunctionsurface'
updateImplicitFunctionSurface(obj,dataIndex);
Expand Down
75 changes: 69 additions & 6 deletions plotly/plotlyfig_aux/handlegraphics/updateFmesh.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@
end

%-------------------------------------------------------------------------%

%-get edge color-%
if isnumeric(meshData.EdgeColor)
cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor);

elseif strcmpi(meshData.EdgeColor, 'interp')
cDataContour = zDataContour(:);
obj.data{contourIndex}.line.colorscale = colorScale;
elseif strcmpi(meshData.EdgeColor, 'none')

cDataContour = 'rgba(0,0,0,0)';
end

%-set edge color-%
Expand All @@ -123,17 +125,50 @@
obj.data{surfaceIndex}.cmin = 0;
obj.data{surfaceIndex}.cmax = 255;

elseif strcmpi(meshData.FaseColor, 'interp')
elseif strcmpi(meshData.FaceColor, 'interp')
cDataSurface = zDataSurface;

if surfaceIndex > xsource
cData = [];

for idx = xsource:surfaceIndex
cData = [cData; obj.data{idx}.z];
end

cMin = min(cData(:));
cMax = max(cData(:));

for idx = xsource:surfaceIndex
obj.data{idx}.cmin = cMin;
obj.data{idx}.cmax = cMax;
end
end

end

%-set face color-%
obj.data{surfaceIndex}.colorscale = colorScale;
obj.data{surfaceIndex}.surfacecolor = cDataSurface;

%-lighting settings-%
obj.data{surfaceIndex}.lighting.diffuse = 0.5;%0.5;
obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha);%0.7;

if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1])
obj.data{surfaceIndex}.lighting.diffuse = 0.5;
obj.data{surfaceIndex}.lighting.ambient = 0.725;
else
% obj.data{surfaceIndex}.lighting.diffuse = 1.0;
% obj.data{surfaceIndex}.lighting.ambient = 0.9;
end

if meshData.FaceAlpha ~= 1
obj.data{surfaceIndex}.lighting.diffuse = 0.5;
obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha);
end

if obj.PlotlyDefaults.IsLight
obj.data{surfaceIndex}.lighting.diffuse = 1.0;
obj.data{surfaceIndex}.lighting.ambient = 0.3;
end

%-opacity-%
obj.data{surfaceIndex}.opacity = meshData.FaceAlpha;
Expand All @@ -157,6 +192,32 @@

%-------------------------------------------------------------------------%

%-show contours-%

if strcmpi(meshData.ShowContours, 'on')
obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1;
projectionIndex = obj.PlotOptions.nPlots;

obj.data{projectionIndex}.type = 'surface';
obj.data{projectionIndex}.scene = sprintf('scene%d', xsource);

obj.data{projectionIndex}.x = xDataSurface;
obj.data{projectionIndex}.y = yDataSurface;
obj.data{projectionIndex}.z = zDataSurface;

obj.data{projectionIndex}.colorscale = colorScale;
obj.data{projectionIndex}.hidesurface = true;
obj.data{projectionIndex}.surfacecolor = zDataSurface;
obj.data{projectionIndex}.showscale = false;

obj.data{projectionIndex}.contours.z.show = true;
obj.data{projectionIndex}.contours.z.width = 15;
obj.data{projectionIndex}.contours.z.usecolormap = true;
obj.data{projectionIndex}.contours.z.project.z = true;
end

%-------------------------------------------------------------------------%

%-SCENE CONFIGUTATION-%

%-------------------------------------------------------------------------%
Expand Down Expand Up @@ -201,7 +262,7 @@
%-define as default-%
xey = - xyar; if xey>0 xfac = 0.0; else xfac = 0.0; end
yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end
if zar>0 zfac = 0.2; else zfac = -0.2; end
if zar>0 zfac = 0.1; else zfac = -0.1; end

scene.camera.eye.x = xey + xfac*xey;
scene.camera.eye.y = yey + yfac*yey;
Expand Down Expand Up @@ -261,6 +322,7 @@
%-------------------------------------------------------------------------%

%-surface name-%
obj.data{surfaceIndex}.name = meshData.DisplayName;
obj.data{contourIndex}.name = meshData.DisplayName;

%-------------------------------------------------------------------------%
Expand All @@ -272,6 +334,7 @@
%-------------------------------------------------------------------------%

%-surface visible-%
obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on');
obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on');

%-------------------------------------------------------------------------%
Expand All @@ -286,7 +349,7 @@
showleg = false;
end

obj.data{contourIndex}.showlegend = showleg;
obj.data{surfaceIndex}.showlegend = showleg;

%-------------------------------------------------------------------------%

Expand Down
Loading