diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex | 290 |
1 files changed, 178 insertions, 112 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex index 9d1ee9221e2..fb3ab9b42e2 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex @@ -134,6 +134,7 @@ % -> see also the legend image for mesh plots. % \def\pgfplotsplothandlermesh{% + \def\pgfplotsplothandlername{mesh}% \pgfkeysgetvalue{/pgfplots/patch type}\pgfplotsplothandlermesh@patchclass \ifx\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@defaulttext \let\pgfplotsplothandlermesh@patchclass=\pgfutil@empty @@ -158,6 +159,8 @@ \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@mesh \let\pgfplotsplothandlersurveyaftersetpointmeta=\pgfplotsplothandlersurveyaftersetpointmeta@mesh@cdatanormalize % + \def\pgfplotsplothandlerLUAfactory{pgfplots.MeshPlothandler.new}% + % \pgfkeysgetvalue{/pgfplots/patch table/value}\pgfplotsplothandlermesh@patchtable \ifx\pgfplotsplothandlermesh@patchtable\pgfutil@empty \else @@ -165,6 +168,9 @@ \let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@mesh@patchtable \let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@mesh@patchtable \let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@mesh@patchtable + % + % this is currently unsupported in LUA: + \let\pgfplotsplothandlerLUAfactory=\pgfutil@empty \fi \if0\pgfplotsplothandlermesh@colorinput % mesh/color input=colormap @@ -175,99 +181,18 @@ \fi \fi % + % + \pgfplotsifisvisualizationphase{% + \pgfplotsplothandlermesh@init@variables + }{}% + % + % \def\pgf@plotstreamstart{% % \scope % % this shouldn't be necessary, but it doesn't hurt either. \pgfplots@perpointmeta@preparetrafo % - \def\pgfplotsplothandlermesh@ONEDIMMODE{0}% - \pgfplotsplothandlermesh@init@meshkeys - % - % - \let\pgfplotsplothandlermesh@patchclass@input=\pgfplotsplothandlermesh@patchclass - \let\pgfplotsplothandlermesh@patchclass@output=\pgfplotsplothandlermesh@patchclass@input - \if0\pgfplotsplothandlermesh@triangulate - \else - \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@input}{triangulate class}% - \let\pgfplotsplothandlermesh@patchclass@output=\pgfplotsretval - \fi - % - \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@input}{init}% - \ifx\pgfplotsplothandlermesh@patchclass@input\pgfplotsplothandlermesh@patchclass@output - \else - \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{init}% - \fi - % - % assign boolean: - \let\b@pgfplotsplothandlermesh@matrixoutput=\pgfplotsplothandlermesh@matrixinput - \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{allow matrix}% - \if0\pgfplotsretval - \def\b@pgfplotsplothandlermesh@matrixoutput{0}% - \fi - \ifnum\pgfkeysvalueof{/pgfplots/patch refines}>0 - \def\b@pgfplotsplothandlermesh@matrixoutput{0}% - \fi - \if1\pgfplotsaxisplothasjumps - \def\b@pgfplotsplothandlermesh@matrixoutput{0}% - \fi - \if\pgfplotsplothandlermesh@zbuffer@choice4% 'z buffer=sort': - \def\b@pgfplotsplothandlermesh@matrixoutput{0}% - \fi - % - \if2\pgfplotsplothandlermesh@shader - % shader=interp - % - \pgfkeysgetvalue{/pgfplots/mesh/interior colormap name}\pgfplots@loc@TMPc - \ifx\pgfplots@loc@TMPc\pgfutil@empty - \else - \pgfplotswarning{interior colormap inefficient}\pgfeov% - \pgfplotsset{shader=faceted interp,faceted color=none}% - \fi - \fi - \if2\pgfplotsplothandlermesh@shader - % shader=interp - \if0\pgfplotsplothandlermesh@triangulate - % patch to triangles=false - \else - % no matrix output possible: - \def\b@pgfplotsplothandlermesh@matrixoutput{0}% - \fi - \else - % 'shader!=interp' - \def\b@pgfplotsplothandlermesh@matrixoutput{0}% - \fi - \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{get pdf shading type}% - \if5\pgfplotsretval - \else - \def\b@pgfplotsplothandlermesh@matrixoutput{0}% - \fi - % - % special handling: check if Type=5 shadings need to be - % converted to Type=4 - \if0\b@pgfplotsplothandlermesh@matrixoutput - % no matrix output possible - \if5\pgfplotsretval - % pdf shading type=5 (matrix output) - \if2\pgfplotsplothandlermesh@shader - % shader=interp - % - % FIXME : I am unsure if this here is still - % necessary as of 3fc734d7ac3020600c06258b1bc80b22da53edf3 - % -> perhaps the check can be skipped entirely. - % - % oh. shading type=5 is *essentially* the same as - % matrix output, but matrix output is forbidden. - % In that case, triangulate the matrix and shade the - % triangles: - \def\pgfplotsplothandlermesh@triangulate{1}% - \def\pgfplotsplothandlermesh@patchclass@output{triangle}% - % Note shader=faceted interp can be written as - % matrix -- it shades individual elements anyway; - % and one single patch can be written as matrix. - \fi - \fi - \fi % \pgfplotsplothandlermesh@init@DECODE \pgfplotsplothandlermesh@init@REFINE @@ -309,6 +234,133 @@ \let\pgfplotsplothandlerifcurrentpointcanbefirstlast=\pgfplotsplothandlerifcurrentpointcanbefirstlast@mesh }% +\def\pgfplotsplothandlermesh@init@variables{% + % Check if the current shader needs to be reset. + % Do this early as some processing steps depend on it: + \if\pgfplots@meshmode m% mesh + % this is processed by the 'shader=flat' code below. + \def\pgfplotsplothandlermesh@shader{0}% 'flat' + \fi + \ifnum\pgfplotsplothandlermesh@shader>1% 'shader=interp' and 'shader=faceted interp' + \pgflibrarysurfshadingifactive + {}% + {% + \pgfutil@ifundefined{pgfplotsplothandlermesh@shader@warning}{% + \pgfplots@error{Sorry, surface shading (shader=interp) is NOT available for the selected driver `\pgfsysdriver'. I will use 'shader=flat' if you continue now}% + \gdef\pgfplotsplothandlermesh@shader@warning{x}% + }{}% + \def\pgfplotsplothandlermesh@shader{0}% + }% + \fi + % + \def\pgfplotsplothandlermesh@ONEDIMMODE{0}% + \pgfplotsplothandlermesh@init@meshkeys + % + % + \let\pgfplotsplothandlermesh@patchclass@input=\pgfplotsplothandlermesh@patchclass + \let\pgfplotsplothandlermesh@patchclass@output=\pgfplotsplothandlermesh@patchclass@input + \if0\pgfplotsplothandlermesh@triangulate + \else + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@input}{triangulate class}% + \let\pgfplotsplothandlermesh@patchclass@output=\pgfplotsretval + \fi + % + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@input}{init}% + \ifx\pgfplotsplothandlermesh@patchclass@input\pgfplotsplothandlermesh@patchclass@output + \else + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{init}% + \fi + % + % assign boolean: + \let\b@pgfplotsplothandlermesh@matrixoutput=\pgfplotsplothandlermesh@matrixinput + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{allow matrix}% + \if0\pgfplotsretval + \def\b@pgfplotsplothandlermesh@matrixoutput{0}% + \fi + \ifnum\pgfkeysvalueof{/pgfplots/patch refines}>0 + \def\b@pgfplotsplothandlermesh@matrixoutput{0}% + \fi + \if1\pgfplotsaxisplothasjumps + \def\b@pgfplotsplothandlermesh@matrixoutput{0}% + \fi + \if\pgfplotsplothandlermesh@zbuffer@choice4% 'z buffer=sort': + \def\b@pgfplotsplothandlermesh@matrixoutput{0}% + \fi + % + \if2\pgfplotsplothandlermesh@shader + % shader=interp + % + \pgfkeysgetvalue{/pgfplots/mesh/interior colormap name}\pgfplots@loc@TMPc + \ifx\pgfplots@loc@TMPc\pgfutil@empty + \else + \pgfplotswarning{interior colormap inefficient}\pgfeov% + \pgfplotsset{shader=faceted interp,faceted color=none}% + \fi + \fi + \if2\pgfplotsplothandlermesh@shader + % shader=interp + \if0\pgfplotsplothandlermesh@triangulate + % patch to triangles=false + \else + % no matrix output possible: + \def\b@pgfplotsplothandlermesh@matrixoutput{0}% + \fi + \else + % 'shader!=interp' + \def\b@pgfplotsplothandlermesh@matrixoutput{0}% + \fi + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{get pdf shading type}% + \if5\pgfplotsretval + \else + \def\b@pgfplotsplothandlermesh@matrixoutput{0}% + \fi + % + % special handling: check if Type=5 shadings need to be + % converted to Type=4 + \if0\b@pgfplotsplothandlermesh@matrixoutput + % no matrix output possible + \if5\pgfplotsretval + % pdf shading type=5 (matrix output) + \if2\pgfplotsplothandlermesh@shader + % shader=interp + % + % FIXME : I am unsure if this here is still + % necessary as of 3fc734d7ac3020600c06258b1bc80b22da53edf3 + % -> perhaps the check can be skipped entirely. + % + % oh. shading type=5 is *essentially* the same as + % matrix output, but matrix output is forbidden. + % In that case, triangulate the matrix and shade the + % triangles: + \def\pgfplotsplothandlermesh@triangulate{1}% + \def\pgfplotsplothandlermesh@patchclass@output{triangle}% + % Note shader=faceted interp can be written as + % matrix -- it shades individual elements anyway; + % and one single patch can be written as matrix. + \fi + \fi + \fi + % + % + \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{LUA class}% + \ifx\pgfplotsretval\pgfutil@empty + \let\pgfplotsplothandlerLUAvisualizerfactory=\pgfutil@empty + \else + \edef\pgfplotsplothandlerLUAvisualizerfactory{ + function(plothandler) return pgfplots.MeshVisualizer.new( + plothandler, + \pgfplotsretval(), + pgfplots.pgftonumber("\pgfkeysvalueof{/pgfplots/mesh/rows}"), + pgfplots.pgftonumber("\pgfkeysvalueof{/pgfplots/mesh/cols}"), + \if0\pgfplots@plot@mesh@ordering true\else false\fi, + \if1\pgfplotsplothandlermesh@matrixinput true\else false\fi, + \if1\b@pgfplotsplothandlermesh@matrixoutput true\else false\fi, + \if4\pgfplotsplothandlermesh@zbuffer@choice true\else false\fi)% 'z buffer=sort' + end + }% + \fi +}% + \def\pgfplotsplothandlerifcurrentpointcanbefirstlast@mesh#1#2{% \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{if current point can be first last}{#1}{#2}% }% @@ -750,6 +802,7 @@ sample in unit cube={% \pgfplots@error{sample in unit cube: not implemented for \pgfplotspatchclassname}% }, + LUA class=, }% }{}% % @@ -984,6 +1037,14 @@ % point of the patch. Executes ##2 if that is not the case. if current point can be first last/.code= {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ if current point can be first last\endcsname##1##2{#1}},% + % + % Defines \pgfplotsretval to contain LUA code which returns a + % factory method (with no arguments) which returns an instance of the + % associated LUA pgfplots.PatchType + % + % If the returned \pgfplotsretval is empty: there is no LUA implementation. + LUA class/.code= + {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ LUA class\endcsname{\def\pgfplotsretval{#1}}},% } % This implements 'compute normal' : @@ -1328,6 +1389,7 @@ #1, get pdf shading type=4, get num vertices=\def\pgfplotsretval{3}, + LUA class=pgfplots.TrianglePatchType.new, }% \def\pgfplotspatchclass@tri@recursiverefine@@#1#2M,#3#4M;#5\relax#6{% \expandafter\let\expandafter\pgfplotspatchclass@tri@A@\csname pgfplotspatchclass@tri@#1\endcsname @@ -1459,6 +1521,7 @@ deserialize except vertices=, get pdf shading type=5, get num vertices=\def\pgfplotsretval{4}, + LUA class=pgfplots.RectanglePatchType.new, }% \def\pgfplots@rect@next@A{B} @@ -1786,16 +1849,21 @@ % \if1\pgfplotsplothandlermesh@ONEDIMMODE %\message{initialised DECODE for 1d mode.^^J}% + % FIXME : needs LUA support... \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@matrix@ONEDIMMODE \else \if0\b@pgfplotsplothandlermesh@matrixoutput - % in fact, this does only remember the maximum capacity; - % it doesn't fill the memory. - \c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax - \advance\c@pgfplots@scanlineindex by1 - \pgfplotsdequenewempty{lastscanline}\capacity{\the\c@pgfplots@scanlineindex}% - \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline + \if1\b@pgfplots@LUA@visualization@enabled +%\message{initialised DECODE for patch output (from matrix which has already been decoded in LUA).^^J}% + \else + % in fact, this does only remember the maximum capacity; + % it doesn't fill the memory. + \c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax + \advance\c@pgfplots@scanlineindex by1 + \pgfplotsdequenewempty{lastscanline}\capacity{\the\c@pgfplots@scanlineindex}% + \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline %\message{initialised DECODE for patch output (from matrix).^^J}% + \fi \else % SPECIAL HANDLING! \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@to@shader @@ -2165,6 +2233,8 @@ % % Prepare: \def\pgfplotsplothandlermesh@definecolor{% + % FIXME : use lua backend to improve this here! it is + % _extremely_ slow! \pgfplotsplothandlermesh@get@flat@color \pgfplotsplothandlermesh@definemappedcolor{\pgfplotsretval}% \pgfplots@drawoptions @@ -2247,24 +2317,6 @@ }% \def\pgfplotsplothandlermesh@init@shader{% - % - % Now, process the 'shader' key here: - \if\pgfplots@meshmode m% mesh - % this is processed by the 'shader=flat' code below. - \def\pgfplotsplothandlermesh@shader{0}% 'flat' - \fi - \ifnum\pgfplotsplothandlermesh@shader>1% 'shader=interp' and 'shader=faceted interp' - \pgflibrarysurfshadingifactive - {}% - {% - \pgfutil@ifundefined{pgfplotsplothandlermesh@shader@warning}{% - \pgfplots@error{Sorry, surface shading (shader=interp) is NOT available for the selected driver `\pgfsysdriver'. I will use 'shader=flat' if you continue now}% - \gdef\pgfplotsplothandlermesh@shader@warning{x}% - }{}% - \def\pgfplotsplothandlermesh@shader{0}% - }% - \fi - % % \ifnum\pgfplotsplothandlermesh@shader>1 % 'shader=2': 'interp': @@ -2568,6 +2620,16 @@ \fi % \if\pgfplotsplothandlermesh@zbuffer@choice4% + \def\pgfplotsplothandlermesh@zbuffer@sort@in@TeX{1}% + \else + \def\pgfplotsplothandlermesh@zbuffer@sort@in@TeX{0}% + \fi + \if1\b@pgfplots@LUA@visualization@enabled + % set it to 'z buffer=none' -- LUA did the job already. + \def\pgfplotsplothandlermesh@zbuffer@sort@in@TeX{0}% + \fi + % + \if\pgfplotsplothandlermesh@zbuffer@sort@in@TeX1% % z buffer=sort: % create a z buffer: % the z buffer contains elements {<view depth>}{{<pt1>}{<pt2>}{<pt3>}{<pt4>}} @@ -2618,6 +2680,8 @@ \expandafter\pgfplotsarraypushback\pgfplots@loc@TMPa\to\pgfplots@zbuffer@local }% \fi + \else + \def\pgfplotsplothandlermesh@zbuffer@sort@in@TeX{0}% \fi }% \def\pgfplotsplothandlermesh@init@mesh@stream{% @@ -2660,12 +2724,14 @@ /pgfplots/mesh/num points=, /pgfplots/mesh input=lattice, /pgfplots/patch type=rectangle, + /pgfplots/z buffer=default, /tikz/x={(0.44237cm,-0.07439cm)}, /tikz/y={(0.30942cm,0.23932cm)}, /tikz/z={(0.0cm,1.5cm)}, scale=0.4, yshift=-0.7cm, /pgfplots/point meta=explicit, + /pgfplots/mesh/color input=colormap, ] \let\pgfplots@metamax=\pgfutil@empty \pgfplots@curplot@threedimtrue @@ -2707,7 +2773,7 @@ }% \def\pgfplotsplothandlermesh@finish{% - \if\pgfplotsplothandlermesh@zbuffer@choice4% + \if\pgfplotsplothandlermesh@zbuffer@sort@in@TeX1% % z buffer=sort: % process the z buffer: \pgfkeyslet{/pgfplots/iflessthan/.@cmd}\pgfplotsplothandlermesh@zbuffer@sort@iflessthen |