Skip to content

Commit 9cc18d7

Browse files
fix issues and awesome improvements in fsurf functionality
1 parent ea58447 commit 9cc18d7

File tree

4 files changed

+376
-70
lines changed

4 files changed

+376
-70
lines changed

plotly/plotlyfig.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
obj.PlotlyDefaults.Bargap = 0;
100100
obj.PlotlyDefaults.CaptionMarginIncreaseFactor = 1.2;
101101
obj.PlotlyDefaults.MinCaptionMargin = 80;
102+
obj.PlotlyDefaults.IsLight = false;
102103

103104
%-State-%
104105
obj.State.Figure = [];
@@ -622,12 +623,16 @@ function validate(obj)
622623

623624
% reverse plots
624625
nprev = length(plots) - np + 1;
625-
626+
626627
% update the plot fields
627-
obj.State.Figure.NumPlots = obj.State.Figure.NumPlots + 1;
628-
obj.State.Plot(obj.State.Figure.NumPlots).Handle = handle(plots(nprev));
629-
obj.State.Plot(obj.State.Figure.NumPlots).AssociatedAxis = handle(ax(axrev));
630-
obj.State.Plot(obj.State.Figure.NumPlots).Class = getGraphClass(plots(nprev));
628+
if ~strcmpi(getGraphClass(plots(nprev)), 'light')
629+
obj.State.Figure.NumPlots = obj.State.Figure.NumPlots + 1;
630+
obj.State.Plot(obj.State.Figure.NumPlots).Handle = handle(plots(nprev));
631+
obj.State.Plot(obj.State.Figure.NumPlots).AssociatedAxis = handle(ax(axrev));
632+
obj.State.Plot(obj.State.Figure.NumPlots).Class = getGraphClass(plots(nprev));
633+
else
634+
obj.PlotlyDefaults.IsLight = true;
635+
end
631636
end
632637

633638
% this works for pareto

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
updateRectangle(obj,dataIndex);
7676
case 'surface'
7777
updateSurfaceplot(obj,dataIndex);
78-
case 'functionsurface'
78+
case {'functionsurface', 'parameterizedfunctionsurface'}
7979
updateFunctionSurface(obj,dataIndex);
8080
case 'implicitfunctionsurface'
8181
updateImplicitFunctionSurface(obj,dataIndex);

plotly/plotlyfig_aux/handlegraphics/updateFmesh.m

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@
9090
end
9191

9292
%-------------------------------------------------------------------------%
93-
9493
%-get edge color-%
9594
if isnumeric(meshData.EdgeColor)
9695
cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor);
9796

9897
elseif strcmpi(meshData.EdgeColor, 'interp')
9998
cDataContour = zDataContour(:);
10099
obj.data{contourIndex}.line.colorscale = colorScale;
100+
elseif strcmpi(meshData.EdgeColor, 'none')
101+
102+
cDataContour = 'rgba(0,0,0,0)';
101103
end
102104

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

126-
elseif strcmpi(meshData.FaseColor, 'interp')
128+
elseif strcmpi(meshData.FaceColor, 'interp')
127129
cDataSurface = zDataSurface;
130+
131+
if surfaceIndex > xsource
132+
cData = [];
133+
134+
for idx = xsource:surfaceIndex
135+
cData = [cData; obj.data{idx}.z];
136+
end
137+
138+
cMin = min(cData(:));
139+
cMax = max(cData(:));
140+
141+
for idx = xsource:surfaceIndex
142+
obj.data{idx}.cmin = cMin;
143+
obj.data{idx}.cmax = cMax;
144+
end
145+
end
146+
128147
end
129148

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

134153
%-lighting settings-%
135-
obj.data{surfaceIndex}.lighting.diffuse = 0.5;%0.5;
136-
obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha);%0.7;
154+
155+
if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1])
156+
obj.data{surfaceIndex}.lighting.diffuse = 0.5;
157+
obj.data{surfaceIndex}.lighting.ambient = 0.725;
158+
else
159+
% obj.data{surfaceIndex}.lighting.diffuse = 1.0;
160+
% obj.data{surfaceIndex}.lighting.ambient = 0.9;
161+
end
162+
163+
if meshData.FaceAlpha ~= 1
164+
obj.data{surfaceIndex}.lighting.diffuse = 0.5;
165+
obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha);
166+
end
167+
168+
if obj.PlotlyDefaults.IsLight
169+
obj.data{surfaceIndex}.lighting.diffuse = 1.0;
170+
obj.data{surfaceIndex}.lighting.ambient = 0.3;
171+
end
137172

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

158193
%-------------------------------------------------------------------------%
159194

195+
%-show contours-%
196+
197+
if strcmpi(meshData.ShowContours, 'on')
198+
obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1;
199+
projectionIndex = obj.PlotOptions.nPlots;
200+
201+
obj.data{projectionIndex}.type = 'surface';
202+
obj.data{projectionIndex}.scene = sprintf('scene%d', xsource);
203+
204+
obj.data{projectionIndex}.x = xDataSurface;
205+
obj.data{projectionIndex}.y = yDataSurface;
206+
obj.data{projectionIndex}.z = zDataSurface;
207+
208+
obj.data{projectionIndex}.colorscale = colorScale;
209+
obj.data{projectionIndex}.hidesurface = true;
210+
obj.data{projectionIndex}.surfacecolor = zDataSurface;
211+
obj.data{projectionIndex}.showscale = false;
212+
213+
obj.data{projectionIndex}.contours.z.show = true;
214+
obj.data{projectionIndex}.contours.z.width = 15;
215+
obj.data{projectionIndex}.contours.z.usecolormap = true;
216+
obj.data{projectionIndex}.contours.z.project.z = true;
217+
end
218+
219+
%-------------------------------------------------------------------------%
220+
160221
%-SCENE CONFIGUTATION-%
161222

162223
%-------------------------------------------------------------------------%
@@ -201,7 +262,7 @@
201262
%-define as default-%
202263
xey = - xyar; if xey>0 xfac = 0.0; else xfac = 0.0; end
203264
yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end
204-
if zar>0 zfac = 0.2; else zfac = -0.2; end
265+
if zar>0 zfac = 0.1; else zfac = -0.1; end
205266

206267
scene.camera.eye.x = xey + xfac*xey;
207268
scene.camera.eye.y = yey + yfac*yey;
@@ -261,6 +322,7 @@
261322
%-------------------------------------------------------------------------%
262323

263324
%-surface name-%
325+
obj.data{surfaceIndex}.name = meshData.DisplayName;
264326
obj.data{contourIndex}.name = meshData.DisplayName;
265327

266328
%-------------------------------------------------------------------------%
@@ -272,6 +334,7 @@
272334
%-------------------------------------------------------------------------%
273335

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

277340
%-------------------------------------------------------------------------%
@@ -286,7 +349,7 @@
286349
showleg = false;
287350
end
288351

289-
obj.data{contourIndex}.showlegend = showleg;
352+
obj.data{surfaceIndex}.showlegend = showleg;
290353

291354
%-------------------------------------------------------------------------%
292355

0 commit comments

Comments
 (0)