diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex | 904 |
1 files changed, 707 insertions, 197 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex index 6b64807a05c..d370f845a70 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotscoordprocessing.code.tex @@ -2539,6 +2539,7 @@ \expandafter\def\csname pgfpmeta@#1@issymbolic\endcsname{0}% \expandafter\def\csname pgfpmeta@#1@explicitinput\endcsname{0}% \expandafter\def\csname pgfpmeta@#1@activate\endcsname{}% + \expandafter\def\csname pgfpmeta@#1@LUA class\endcsname{}% \edef\pgfplotsdeclarepointmetasource@{#1}% \pgfqkeys{/pgfplots/@declare point meta src}{#2}% }% @@ -2605,6 +2606,11 @@ % explicitinput/.code= {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @explicitinput\endcsname{#1}},% + % + % the associated LUA class name (if any). Use an empty string if + % there is none. + LUA class/.code= + {\expandafter\def\csname pgfpmeta@\pgfplotsdeclarepointmetasource@ @LUA class\endcsname{#1}},% }% % An empty one. This is simple to check with @@ -2614,17 +2620,20 @@ \let\pgfplots@current@point@meta=\pgfplots@current@point@x \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}% \let\pgfplots@current@point@meta=\pgfmathresult - }} + }, + LUA class=pgfplots.XcoordAssignmentPointMetaHandler} \pgfplotsdeclarepointmetasource{y}{assign={% \let\pgfplots@current@point@meta=\pgfplots@current@point@y \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}% \let\pgfplots@current@point@meta=\pgfmathresult - }} + }, + LUA class=pgfplots.YcoordAssignmentPointMetaHandler} \pgfplotsdeclarepointmetasource{z}{assign={% \let\pgfplots@current@point@meta=\pgfplots@current@point@z \pgfplotscoordmath{meta}{parsenumber}{\pgfplots@current@point@meta}% \let\pgfplots@current@point@meta=\pgfmathresult - }} + }, + LUA class=pgfplots.ZcoordAssignmentPointMetaHandler} \pgfplotsdeclarepointmetasource{explicit}{% assign={% @@ -2634,7 +2643,8 @@ \let\pgfplots@current@point@meta=\pgfmathresult \fi }, - explicitinput=1% + explicitinput=1,% + LUA class=pgfplots.ExplicitPointMetaHandler.new(), }% \pgfplotsdeclarepointmetasource{explicit symbolic}{% assign={},% no math, simply collect. @@ -2664,7 +2674,19 @@ \ifx\pgfpmeta@expr@origchoice\pgfplots@loc@TMPa \let\pgfpmeta@expr@origchoice\pgfutil@empty \fi + % + \pgfplotsutilifcontainsmacro{#1}{% + % oh. The point meta expression contains a backslash - it + % depends on a macro. This means: it depends on \thisrow + % or similar TeX stuff - which must be evaluated by TeX. + % + % LUA cannot be used for this point meta handler. + \let\pgfpmeta@expr@LUA@class\pgfutil@empty + }{% + \def\pgfpmeta@expr@LUA@class{pgfplots.ExpressionPointMetaHandler.new("#1")}% + }% }, + LUA class=\pgfpmeta@expr@LUA@class, }% \pgfkeyssetvalue{/pgfplots/point meta/expr}{}% @@ -3220,6 +3242,7 @@ \let\pgfplots@coord@stream@start@=\pgfplots@PREPARE@COORD@STREAM@start@ \def\pgfplots@coord@stream@coord@{% \def\pgfplots@set@perpointmeta@done{0}% + % NOTE: this might call LUA (if supported): \pgfplotsplothandlersurveypoint }% \def\pgfplots@coord@stream@end@{\pgfplots@PREPARE@COORD@STREAM@end@{#1}}% @@ -3239,6 +3262,7 @@ % \edef\plotnumofactualtype{\numplotsofactualtype}% \csname pgfpmeta@\pgfplotspointmetainputhandler @activate\endcsname + \pgfplots@LUA@survey@start \pgfplotsplothandlersurveystart \pgfplotscoordstream@firstlast@init % @@ -3261,6 +3285,7 @@ % Inside of math expressions, 'x', 'y' and 'z' expand to the % current x,y and z coords respectively. Introduce these (and some % more) shortcuts: + % FIXME : defining the resulting x/y coordinates as 'x' and 'y' constants was a really really bad idea in the first place :-( \pgfplotsmathdeclarepseudoconstant{x}{\let\pgfmathresult=\pgfplots@current@point@x}% \pgfplotsmathdeclarepseudoconstant{y}{\let\pgfmathresult=\pgfplots@current@point@y}% \pgfplotsmathdeclarepseudoconstant{z}{\let\pgfmathresult=\pgfplots@current@point@z}% @@ -3348,6 +3373,9 @@ % #1,#2: see \pgfplots@PREPARE@COORD@STREAM \def\pgfplots@PREPARE@COORD@STREAM@end@#1{% \pgfkeysvalueof{/pgfplots/execute at end survey}% + \ifpgfplots@LUA@backend@supported + \pgfplots@LUA@survey@end + \fi % FIXME : move this the \pgfplotsplothandlersurveyend of mesh plot % handler: \pgfkeyssetvalue{/pgfplots/mesh/num points}{\pgfplots@current@point@coordindex}% @@ -3417,6 +3445,7 @@ \pgfplotssurveyphase@set@visphase@names{#1}% \let\pgfplots@visphase@names=\pgfplotsretval % + \t@pgfplots@tokc={#1}% % % SERIALIZE RESULT: % @@ -3431,6 +3460,13 @@ \noexpand\pgfplots@addplot@enqueue@coords {% precommand(s): \expandafter\noexpand\csname pgfplots@curplot@threedim\ifpgfplots@curplot@threedim true\else false\fi\endcsname + % + % Did we prepare the data within LUA? remember that! + \ifpgfplots@LUA@backend@supported + \noexpand\pgfplots@LUA@backend@supportedtrue + \else + \noexpand\pgfplots@LUA@backend@supportedfalse + \fi \noexpand\def\noexpand\plotnum{\the\pgfplots@numplots}% % % store \plotnumofactualtype @@ -3478,6 +3514,7 @@ \noexpand\def\noexpand\pgfplotsaxisfilteredcoordsaway{\pgfplotsaxisfilteredcoordsaway}% \noexpand\def\noexpand\pgfplotsaxisplothasjumps{\pgfplotsaxisplothasjumps}% \noexpand\pgfkeyssetvalue{/pgfplots/on layer}{\pgfkeysvalueof{/pgfplots/on layer}}% + \noexpand\def\noexpand\pgfplots@serialized@afterpath{\the\t@pgfplots@tokc}% }% {% draw command: \noexpand\path% @@ -3486,14 +3523,14 @@ \pgfplotsapplistXXlet\pgfplots@coord@stream@recorded \pgfplotsapplistXXclear \t@pgfplots@tokc=\expandafter{\pgfplots@coord@stream@recorded}% - \t@pgfplots@tokb={#1;}% \t@pgfplots@toka=\expandafter{\pgfplots@glob@TMPa}% \xdef\pgfplots@glob@TMPa{% \the\t@pgfplots@toka {% coordinates which need to be processed in \endaxis. % See % \pgfplots@coord@stream@finalize@storedcoords@START - normalized coordinates {\the\t@pgfplots@tokc}\the\t@pgfplots@tokb + % (will become available as \pgfplots@stored@current@data) + \the\t@pgfplots@tokc }% }% % @@ -3518,6 +3555,202 @@ \fi }% +\def\pgfplots@LUA@survey@log@deactivation#1{% + \pgfplots@log{\pgfplots@LUA@loglevel@info}{Using 'lua backend=false' for plot \the\pgfplots@numplots\space (type '\pgfplotsplothandlername'): #1.}% + \pgfplots@LUA@backend@failed +}% + +\def\pgfplots@LUA@survey@get@filter#1{% + \begingroup + \pgfkeysgetvalue{/pgfplots/#1 filter/.@cmd}\pgfplots@loc@TMPc + \ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key + \let\pgfplotsretval=\pgfutil@empty + \else + \pgfplots@ifisfilterexpression{#1 filter}{% + \pgfkeysgetvalue{/pgfplots/#1 filter/@expressionvalue}\pgfplotsretval + \expandafter\pgfplotsutilifcontainsmacro\expandafter{\pgfplotsretval}{% + \aftergroup\pgfplots@LUA@backend@supportedfalse + \pgfplots@command@to@string\pgfplotsretval\pgfplots@loc@TMPa + \pgfplots@LUA@survey@log@deactivation{#1 filter/.expression='\pgfplots@loc@TMPa' contains a TeX macro}% + \let\pgfplotsretval=\pgfutil@empty + }{% + }% + }{% + \aftergroup\pgfplots@LUA@backend@supportedfalse + \pgfplots@LUA@survey@log@deactivation{LUA does not support #1 filter (yet)}% + \let\pgfplotsretval=\pgfutil@empty + }% + \fi + \pgfmath@smuggleone\pgfplotsretval + \endgroup +}% + +\def\pgfplots@LUA@survey@start{% + \ifpgfplots@LUA@backend@supported + \ifx\pgfplotsplothandlerLUAfactory\pgfutil@empty + \pgfplots@LUA@survey@log@deactivation{plot handler does not support LUA}% + \pgfplots@LUA@backend@supportedfalse + \fi + % + \ifx\pgfplotspointmetainputhandler\pgfutil@empty + \def\pgfplots@loc@TMPa{nil}% + \else + \edef\pgfplots@loc@TMPa{% + \csname pgfpmeta@\pgfplotspointmetainputhandler @LUA class\endcsname}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \pgfplots@LUA@survey@log@deactivation{point meta choice does not support LUA}% + \pgfplots@LUA@backend@supportedfalse + \fi + \fi + \ifpgfplots@stackedmode + \pgfplots@LUA@survey@log@deactivation{LUA does not support stacked plots (yet)}% + \pgfplots@LUA@backend@supportedfalse + \fi + \ifpgfplots@errorbars@enabled + \pgfplots@LUA@survey@log@deactivation{LUA does not support error bars (yet)}% + \pgfplots@LUA@backend@supportedfalse + \fi + \ifpgfplots@collect@firstplot@astick + \pgfplots@LUA@survey@log@deactivation{LUA does not support xtick=data (yet)}% + \pgfplots@LUA@backend@supportedfalse + \fi + \pgfkeysgetvalue{/pgfplots/pre filter/.@cmd}\pgfplots@loc@TMPc\ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@survey@log@deactivation{LUA does not support filter (yet)}\fi + \pgfplots@LUA@survey@get@filter x% + \let\pgfplots@loc@filter@x=\pgfplotsretval + \pgfplots@LUA@survey@get@filter y% + \let\pgfplots@loc@filter@y=\pgfplotsretval + \pgfplots@LUA@survey@get@filter z% + \let\pgfplots@loc@filter@z=\pgfplotsretval + \pgfkeysgetvalue{/pgfplots/filter point/.@cmd}\pgfplots@loc@TMPc\ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@survey@log@deactivation{LUA does not support filter (yet)}\fi + % + \pgfkeysgetvalue{/pgfplots/execute for finished point}\pgfplots@loc@TMPc\ifx\pgfplots@loc@TMPc\pgfutil@empty\else \pgfplots@LUA@backend@supportedfalse\fi + % + \pgfkeysgetvalue{/pgfplots/visualization depends on/list}\pgfplots@loc@TMPc \ifx\pgfplots@loc@TMPc\pgfutil@empty\else \pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@survey@log@deactivation{LUA does not support 'visualization depends on' (yet)} \fi + % + % + \edef\pgfplots@loc@TMPc{\pgfkeysvalueof{/pgfplots/data cs}}% + \edef\pgfplots@loc@TMPd{\pgfkeysvalueof{/pgfplots/@expected axis cs}}% + \ifx\pgfplots@loc@TMPc\pgfplots@loc@TMPd\else\pgfplots@LUA@backend@supportedfalse\pgfplots@LUA@survey@log@deactivation{LUA does not support 'data cs' (yet)}\fi + % + % hm. There are various cases which are supported during a + % SURVEY -- but not during a visualization. Check that here: + \if m\pgfplots@colormap@access + \else + \pgfplots@LUA@survey@log@deactivation{color map access=direct not supported (yet)}% + \pgfplots@LUA@backend@supportedfalse + \fi + % + \ifpgfplots@LUA@backend@supported + \begingroup + \pgfkeysgetvalue{/pgfplots/point meta min}\pgfplots@loc@metamin + \pgfkeysgetvalue{/pgfplots/point meta max}\pgfplots@loc@metamax + \pgfplots@log{\pgfplots@LUA@loglevel@debug}{lua backend=true: Activating LUA backend for plot \the\pgfplots@numplots\space (type '\pgfplotsplothandlername').}% + \edef\pgfplots@loc@TMPa{% + local gca = pgfplots.gca;^^J% + gca.min = {^^J% + pgfplots.pgftonumber("\pgfplots@xmin"), ^^J% + pgfplots.pgftonumber("\pgfplots@ymin"), ^^J% + pgfplots.pgftonumber("\pgfplots@zmin")}; ^^J% + gca.max = {^^J% + pgfplots.pgftonumber("\pgfplots@xmax"), ^^J% + pgfplots.pgftonumber("\pgfplots@ymax"), ^^J% + pgfplots.pgftonumber("\pgfplots@zmax")}; ^^J% + % FIXME : what about datamin/datamax!? + local plothandlerFactory = \pgfplotsplothandlerLUAfactory; ^^J% + local plothandler = plothandlerFactory(gca, \pgfplots@loc@TMPa);^^J% second arg: point meta handler + \ifx\pgfplots@loc@metamin\pgfutil@empty + \else + plothandler.autocomputeMetaMin = false;^^J% + plothandler.metamin = pgfplots.pgftonumber("\pgfplots@loc@metamin");^^J% + \fi + \ifx\pgfplots@loc@metamax\pgfutil@empty + \else + plothandler.autocomputeMetaMax = false;^^J% + plothandler.metamax = pgfplots.pgftonumber("\pgfplots@loc@metamax");^^J% + \fi + local config = plothandler.config;^^J% + config.unboundedCoords = "\pgfplots@unbounded@handler";^^J% + config.warnForfilterDiscards = \pgfplots@boolval{pgfplots@warn@for@filter@discards};^^J% + config.pointmetarel = \pgfplots@perpointmeta@rel@choice;^^J% + config.updateLimits = \ifpgfplots@bb@isactive true\else false\fi;^^J% + config.filterExpressionByDir = {^^J% + "\pgfplots@loc@filter@x",^^J% + "\pgfplots@loc@filter@y",^^J% + "\pgfplots@loc@filter@z"};^^J% + gca.plothandlers[\the\pgfplots@numplots+1] = plothandler;^^J% + gca.currentPlotHandler = plothandler;^^J% + plothandler:surveystart();^^J% + }% +%\message{Executing ^^J\pgfplots@loc@TMPa^^J^^J}% + \directlua{\pgfplots@loc@TMPa}% + \endgroup + \fi + \fi +}% + +\def\pgfplots@LUA@survey@point{% + \directlua{pgfplots.texSurveyPoint("\pgfplots@current@point@x","\pgfplots@current@point@y","\pgfplots@current@point@z","\pgfplots@current@point@meta")}% +}% + +\def\pgfplots@LUA@survey@end{% + % LUA defines a couple of TeX macros here... + \directlua{pgfplots.texSurveyEnd()}% + % + \pgfplotsapplistXXpushback{--- acquire from LUA! --}% +}% + +% this appears to be necessary for the mesh legend... +\def\b@pgfplots@LUA@visualization@enabled{0}% + +% PRECONDITION : \pgfplots@LUA@visualization@init has already been +% executed. +\def\pgfplots@LUA@visualization@of@current@plot{% + \def\b@pgfplots@LUA@visualization@enabled{0}% + \ifpgfplots@LUA@backend@supported + \pgfkeysgetvalue{/pgfplots/axis type}\pgfplots@loc@TMPa + \def\pgfplots@loc@TMPb{rectangle}% + \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \else + % disable visualizer - we cannot do this right now. + \pgfplots@LUA@backend@failed + \let\pgfplotsplothandlerLUAvisualizerfactory=\pgfutil@empty + \fi + % + \ifx\pgfplotsplothandlerLUAvisualizerfactory\pgfutil@empty + % hm. This plot cannot be visualized in LUA - BUT it has a + % LUA survey! Ok, then: acquire the survey results. + % Otherwise we would have nothing here. + % FIXME : what about \pgfplots@LUA@backend@failed in this context!? + \pgfplots@log{\pgfplots@LUA@loglevel@info}{Using 'lua backend=false' for visualization of plot \the\pgfplots@numplots\space (type '\pgfplotsplothandlername'): it has no LUA visualizer.}% + \expandafter\def\expandafter\pgfplots@stored@current@data\expandafter{% + \directlua{pgfplots.texGetSurveyedCoordsToPgfplots()}% + }% + \else + % visualize using LUA! ... and acquire the coordinates. + \expandafter\def\expandafter\pgfplots@stored@current@data\expandafter{% + \directlua{pgfplots.texVisualizePlot(\pgfplotsplothandlerLUAvisualizerfactory)}% + }% +%\message{plot \plotnum: LUA backend returned \pgfplots@stored@current@data^^J}% + % + % ... and ensure that the resulting + % \pgfplots@stored@current@data can be deserialized. It + % contains the fully mapped X/Y coordinates as first item. + \let\pgfplotsaxisdeserializedatapointfrom@private@nonLUA=\pgfplotsaxisdeserializedatapointfrom@private + \def\pgfplotsaxisdeserializedatapointfrom@private##1{% + \pgfplotsaxisdeserializedatapointfrom@private@LUA##1% + }% + \def\pgfplotsaxisdeserializedatapointfrom@private@LUA##1##2##3{% + \global\pgf@x=##1pt % + \global\pgf@y=##2pt % + \pgfplotsaxisdeserializedatapointfrom@private@nonLUA{##3}% + }% + % FIXME : do I need to adopt the serializer as well!? + % + \def\b@pgfplots@LUA@visualization@enabled{1}% + \fi + \fi +}% + % Defines \pgfplotsretval to contain a comma-separated-list of % visualization phase names. May be empty. % @@ -3575,7 +3808,7 @@ % This defines \pgfplots@visphase@default: \expandafter\def\csname pgfplots@visphase@\pgfplotsaxis@visphase@name@default\endcsname{% - \expandafter\pgfplots@coord@stream@finalize@storedcoords@START\pgfplots@stored@current@data\pgfplots@EOI + \pgfplots@coord@stream@finalize@storedcoords@START }% % A routine which transforms the current set of @@ -3825,7 +4058,7 @@ \fi % \pgfkeysgetvalue{/pgfplots/execute for finished point}\pgfplots@loc@TMPa - \ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key + \ifx\pgfplots@loc@TMPa\pgfutil@empty \else \expandafter\def\expandafter\pgfplotsaxisserializedatapoint@private\expandafter{% \pgfplotsaxisserializedatapoint@private @@ -4003,6 +4236,12 @@ \def\pgfplots@perpointmeta@preparetrafo{% \def\pgfplotspointmetarangeexponent{1}% pre-fill \pgfutil@ifundefined{pgfplots@perpointmeta@trafo}{% + \edef\pgfplots@loc@TMPa{\pgfplotscolormaprange}% + \ifnum\pgfplots@loc@TMPa=1000 + \else + \pgfplots@error{LOGIC ERROR: sorry, I have hard-coded the assumption \string\pgfplotscolormaprange = 1000, but now it is \pgfplots@loc@TMPa.}% + \fi + % \let\pgfplots@current@point@meta=\pgfutil@empty \pgfutil@ifundefined{pgfplots@metamax}{\let\pgfplots@metamax=\pgfutil@empty}{} \ifpgfplots@warn@for@filter@discards @@ -4039,11 +4278,6 @@ % phi(m) = ( m- meta_min) * 1000/ (meta_max-meta_min). % % -> precompute the scaling factor! - \edef\pgfplots@loc@TMPa{\pgfplotscolormaprange}% - \ifnum\pgfplots@loc@TMPa=1000 - \else - \pgfplots@error{LOGIC ERROR: sorry, I have hard-coded the assumption \string\pgfplotscolormaprange = 1000, but now it is \pgfplots@loc@TMPa.}% - \fi \if\pgfplots@perpointmeta@rel@choice0% % point meta rel=axis wide: \pgfplots@perpointmeta@preparetrafo@initfrom{pgfplots@axiswide@}% @@ -4077,25 +4311,35 @@ \edef\pgfplotspointmetarange{\csname #1metamin\endcsname:\csname #1metamax\endcsname}% % Now, prepare the trafo as such. % It assigns \pgfmathresult (in fixed point). - \def\pgfplots@perpointmeta@trafo##1{% - \pgfplotscoordmath{meta}{if is}{##1}{u}{% - \def\pgfmathresult{0}% - \pgfplots@perpointmeta@unboundedwarning{##1}% - }{% - \pgfplotscoordmath{meta}{op}{subtract}{{##1}{\csname #1metamin\endcsname}}% - \pgfplotscoordmath{meta}{op}{multiply}{{\pgfmathresult}{\pgfplots@perpointmeta@trafo@factor}}% - \pgfplots@perpointmeta@trafo@clipresult - \pgfplotscoordmath{meta}{tofixed}{\pgfmathresult}% + \ifpgfplots@LUA@backend@supported + \def\pgfplots@perpointmeta@trafo##1{% + \edef\pgfmathresult{% + \directlua{% + pgfplots.texPerpointMetaTrafo("\pgfplots@current@point@meta") + }% + }% }% - }% - \pgfplotscoordmath{meta}{op}{subtract}{{\csname #1metamax\endcsname}{\csname #1metamin\endcsname}}% - \let\pgfplots@loc@TMPa=\pgfmathresult - \pgfplotscoordmath{meta}{zero}% - \let\pgfplots@perpointmeta@lowerrange=\pgfmathresult - \pgfplotscoordmath{meta}{parsenumber}{1000}% - \let\pgfplots@perpointmeta@upperrange=\pgfmathresult - \pgfplotscoordmath{meta}{op}{divide}{{\pgfmathresult}{\pgfplots@loc@TMPa}}% - \let\pgfplots@perpointmeta@trafo@factor=\pgfmathresult + \else + \def\pgfplots@perpointmeta@trafo##1{% + \pgfplotscoordmath{meta}{if is}{##1}{u}{% + \def\pgfmathresult{0}% + \pgfplots@perpointmeta@unboundedwarning{##1}% + }{% + \pgfplotscoordmath{meta}{op}{subtract}{{##1}{\csname #1metamin\endcsname}}% + \pgfplotscoordmath{meta}{op}{multiply}{{\pgfmathresult}{\pgfplots@perpointmeta@trafo@factor}}% + \pgfplots@perpointmeta@trafo@clipresult + \pgfplotscoordmath{meta}{tofixed}{\pgfmathresult}% + }% + }% + \pgfplotscoordmath{meta}{op}{subtract}{{\csname #1metamax\endcsname}{\csname #1metamin\endcsname}}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{meta}{zero}% + \let\pgfplots@perpointmeta@lowerrange=\pgfmathresult + \pgfplotscoordmath{meta}{parsenumber}{1000}% + \let\pgfplots@perpointmeta@upperrange=\pgfmathresult + \pgfplotscoordmath{meta}{op}{divide}{{\pgfmathresult}{\pgfplots@loc@TMPa}}% + \let\pgfplots@perpointmeta@trafo@factor=\pgfmathresult + \fi % % Expands to the transformation range as 'a:b': \def\pgfplots@perpointmeta@traforange{0:1000}% @@ -4982,22 +5226,27 @@ % \pgfplots@PREPARE@COORD@STREAM{#3}% % + \def\pgfplots@addplotimpl@expression@xEXPR{#1}% + % % Determine whether the x range is parameterized or uniform and % prepare a macro which assigns \pgfplots@current@point@x: \def\pgfplots@addplotimpl@expression@prepare@x{% \pgfmathparse{#1}% \let\pgfplots@current@point@x=\pgfmathresult }% + \def\pgfplots@addplotimpl@expression@prepare@y{% + \pgfmathparse{\pgfplots@addplotimpl@expression@yEXPR}% + \let\pgfplots@current@point@y=\pgfmathresult + }% \def\pgfplots@addplotimpl@expression@hasuniform@x{0}% - \def\pgfplots@loc@TMPa{#1}% % do we have '\x' as x coordinate? \expandafter\def\expandafter\pgfplots@loc@TMPb\expandafter{\tikz@plot@var}% - \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \ifx\pgfplots@addplotimpl@expression@xEXPR\pgfplots@loc@TMPb \def\pgfplots@addplotimpl@expression@hasuniform@x{1}% \else - \def\pgfplots@loc@TMPb{x}% + \edef\pgfplots@loc@TMPb{\pgfplots@plot@var@nonmacro}% % do we have 'x' as x coordinate? - \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb + \ifx\pgfplots@addplotimpl@expression@xEXPR\pgfplots@loc@TMPb \def\pgfplots@addplotimpl@expression@hasuniform@x{1}% \fi \fi @@ -5009,6 +5258,8 @@ }% \fi % + \def\pgfplots@addplotimpl@expression@hasuniform@y{0}% + % % % Now, prepare the loops. % @@ -5030,6 +5281,25 @@ \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@domain\relax{\pgfplots@plot@samples}% \let\pgfplots@expression@xdomain=\pgfplotsretval % + % do we have '\y' as y coordinate? + \expandafter\def\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@plot@var@y}% + \ifx\pgfplots@addplotimpl@expression@yEXPR\pgfplots@loc@TMPb + \def\pgfplots@addplotimpl@expression@hasuniform@y{1}% + \def\pgfplots@addplotimpl@expression@prepare@y{% + \edef\pgfplots@current@point@y{\pgfplots@plot@var@y}% + }% + \else + \edef\pgfplots@loc@TMPb{\pgfplots@plot@var@y@nonmacro}% + % do we have 'y' as y coordinate? + \ifx\addplotimpl@expression@yEXPR\pgfplots@loc@TMPb + \def\pgfplots@addplotimpl@expression@hasuniform@y{1}% + \def\pgfplots@addplotimpl@expression@prepare@y{% + \edef\pgfplots@current@point@y{\pgfplots@plot@var@y}% + }% + \fi + \fi + % + % \if0\b@pgfplots@should@sample@LINE % Samples twodimensionally (a lattice): \expandafter\pgfplots@domain@to@foreach\pgfplots@plot@ydomain\relax{\pgfplots@plot@samples@y}% @@ -5063,11 +5333,12 @@ % % If we have (\x,\y,f(x)), use (\x,0,f(x)) instead and % suppress the error message which would occur for \y. - \expandafter\pgfplotsutilifstringequal\expandafter{\pgfplots@addplotimpl@expression@yEXPR}{\pgfplots@plot@var@y}{% + \if1\pgfplots@addplotimpl@expression@hasuniform@y \def\pgfplots@addplotimpl@expression@yEXPR{0}% - }{% + \def\pgfplots@plot@var@y{0}% + \else \expandafter\edef\pgfplots@plot@var@y{\pgfplots@plot@var@y@nonmacro}% this provides an error message, see above. - }% + \fi \fi \else % Assemble a @@ -5140,14 +5411,130 @@ \fi \expandafter\def\pgfplots@plot@var@y{0}% \def\pgfplots@addplotimpl@expression@yEXPR{#2}% + \def\pgfplots@addplotimpl@expression@zEXPR{}% \def\pgfplots@current@point@z{}% \fi % + % % START: % (NOTE: this does also define 'x', 'y', and 'z' math % expressions!) \pgfplots@coord@stream@start % + \pgfplots@addplotimpl@expression@check@LUA + \if1\pgfplotsretval + \pgfplots@log{\pgfplots@LUA@loglevel@debug}{lua backend=true: Activating LUA version of plot expression for plot \the\pgfplots@numplots\space (type '\pgfplotsplothandlername').}% + \begingroup + \expandafter\def\tikz@plot@var{\pgfplots@plot@var@nonmacro}% + \expandafter\def\pgfplots@plot@var@y{\pgfplots@plot@var@y@nonmacro}% + \expandafter\pgfplots@parse@domain\pgfplots@plot@domain\relax{pgfplots@plot@domain}% + % + \pgfmathparse{\pgfplots@plot@samples}% + \let\pgfplots@plot@samples=\pgfmathresult + % + \if0\b@pgfplots@should@sample@LINE + \expandafter\pgfplots@parse@domain\pgfplots@plot@ydomain\relax{pgfplots@plot@ydomain}% + \pgfmathparse{\pgfplots@plot@samples@y}% + \let\pgfplots@plot@samples@y=\pgfmathresult + \else + \def\pgfplots@plot@ydomain@min{0}% + \def\pgfplots@plot@ydomain@max{0}% + \def\pgfplots@plot@samples@y{1}% + \fi + % + % FIXME : there are some cases in which this here might be a + % bad idea: + % - if someone has redefined math functions on TeX + % - if someone has defined his own math functions (only in + % TeX) + % - if a plot expression contains directlua -- the expansion will play + % funny tricks in this case + \xdef\pgfplotsglobalretval{% + \directlua{% + pgfplots.texAddplotExpressionCoordinateGenerator(^^J% + \ifpgfplots@curplot@threedim true \else false\fi,^^J% + "#1", ^^J% + "\pgfplots@addplotimpl@expression@yEXPR",^^J% + "\pgfplots@addplotimpl@expression@zEXPR",^^J% + \b@pgfplots@should@sample@LINE,^^J% + "\pgfplots@plot@domain@min", "\pgfplots@plot@domain@max",^^J% + "\pgfplots@plot@ydomain@min", "\pgfplots@plot@ydomain@max",^^J% + "\pgfplots@plot@samples",^^J% + "\pgfplots@plot@samples@y",^^J% + "\pgfplots@plot@var@nonmacro",^^J% + "\pgfplots@plot@var@y@nonmacro", + "\pgfplots@plot@samples@at", + "\pgfplots@LUA@backend@debugmode")^^J% + }% + }% + \endgroup + \if0\pgfplotsglobalretval + \pgfplots@log{\pgfplots@LUA@loglevel@info}{lua backend=true: LUA version of plot expression failed. Using TeX version. (plot \the\pgfplots@numplots).}% + \pgfplots@LUA@backend@failed + \pgfplots@addplotimpl@expression@streamall + \else + \fi + \else + \pgfplots@addplotimpl@expression@streamall + \fi + % + \pgfplots@coord@stream@end +}% + +% Defines \pgfplotsretval to be '1' if the pure LUA version of +% \addplot expression is enabled. It defines \pgfplotsretval to be 0 +% if not. +\def\pgfplots@addplotimpl@expression@check@LUA{% + \def\pgfplotsretval{0}% + \ifpgfplots@LUA@backend@supported + \def\pgfplotsretval{1}% + \ifpgfplotsplothandlermesh@patch@type@sampling + \def\pgfplotsretval{0}% + \pgfplots@LUA@plotexpression@log@deactivation{patch type sampling unsupported (yet)}% + \fi + % + \if1\pgfplots@addplotimpl@expression@hasuniform@x + \else + \expandafter\pgfplotsutilifcontainsmacro\expandafter{\pgfplots@addplotimpl@expression@xEXPR}{% + \def\pgfplotsretval{0}% + \pgfplots@command@to@string\pgfplots@addplotimpl@expression@xEXPR\pgfplots@loc@TMPa + \pgfplots@LUA@plotexpression@log@deactivation{x expression '\pgfplots@loc@TMPa' contains a TeX macro}% + }{% + }% + \fi + % + \if1\pgfplots@addplotimpl@expression@hasuniform@y + \else + \expandafter\pgfplotsutilifcontainsmacro\expandafter{\pgfplots@addplotimpl@expression@yEXPR}{% + \def\pgfplotsretval{0}% + \pgfplots@command@to@string\pgfplots@addplotimpl@expression@yEXPR\pgfplots@loc@TMPa + \pgfplots@LUA@plotexpression@log@deactivation{y expression '\pgfplots@loc@TMPa' contains a TeX macro}% + }{% + }% + \fi + % + \ifpgfplots@curplot@threedim + \expandafter\pgfplotsutilifcontainsmacro\expandafter{\pgfplots@addplotimpl@expression@zEXPR}{% + \def\pgfplotsretval{0}% + \pgfplots@command@to@string\pgfplots@addplotimpl@expression@zEXPR\pgfplots@loc@TMPa + \pgfplots@LUA@plotexpression@log@deactivation{z expression '\pgfplots@loc@TMPa' contains a TeX macro}% + }{% + }% + \fi + \fi +}% + +\def\pgfplots@LUA@plotexpression@log@deactivation#1{% + \pgfplots@log{\pgfplots@LUA@loglevel@info}{Deactivating LUA version of plot expression for plot \the\pgfplots@numplots\space (type '\pgfplotsplothandlername'): #1.}% + \pgfplots@LUA@backend@failed +} +\def\pgfplots@parse@domain#1:#2\relax#3{% + \pgfmathparse{#1}% + \expandafter\let\csname #3@min\endcsname=\pgfmathresult% + \pgfmathparse{#2}% + \expandafter\let\csname #3@max\endcsname=\pgfmathresult% +}% +\def\pgfplots@addplotimpl@expression@streamall{% % create a backup of the 'x' and 'y' math expressions which % have been defined in \pgfplots@coord@stream@start: \let\pgfplots@addplotimpl@expression@pseudoconst@old@x=\pgfmathx@ @@ -5188,8 +5575,7 @@ \let\pgfmathy@=\pgfplots@addplotimpl@expression@pseudoconst@y % eval expressions: \pgfplots@addplotimpl@expression@prepare@x% - \pgfmathparse{\pgfplots@addplotimpl@expression@yEXPR}% - \let\pgfplots@current@point@y=\pgfmathresult + \pgfplots@addplotimpl@expression@prepare@y% \ifpgfplots@curplot@threedim \pgfmathparse{\pgfplots@addplotimpl@expression@zEXPR}% \let\pgfplots@current@point@z=\pgfmathresult @@ -5203,8 +5589,7 @@ % process coords as usual: \pgfplots@coord@stream@coord }% - \pgfplots@coord@stream@end -}% +} % Typically, the FPU will generate stuff like '1Y1.0e5'. Since such % internal representations will be available to API users (especially @@ -5241,7 +5626,7 @@ % for that special string. \edef\pgfplots@loc@TMPb{% {\expandafter\noexpand\tikz@plot@var}% - {\noexpand\pgfplots@plot@var@y\the\t@pgfplots@toka}% + {\expandafter\noexpand\pgfplots@plot@var@y\the\t@pgfplots@toka}% }% \expandafter\pgfplots@addplotimpl@expression@@\pgfplots@loc@TMPb{#4}% \else @@ -6630,6 +7015,39 @@ \fi% }% +% #1 the target which will contain the filter +% #2 a math expression. +\def\pgfplots@install@filter@expression#1#2{% + \pgfkeysdef{/pgfplots/#1}{\pgfplots@filter@expression{#1}}% + \pgfkeyssetvalue{/pgfplots/#1/@expressionvalue}{#2}% +}% + +% Executes #2 if the filter key was defined by +% \pgfplots@install@filter@expression. +% +% #1 the target which will contain the filter (like 'x filter') +% #2: true code +% #3: false code +\def\pgfplots@ifisfilterexpression#1#2#3{% + \pgfkeysgetvalue{/pgfplots/#1/.@cmd}\pgfplots@loc@TMPc + \long\def\pgfplots@loc@TMPd##1\pgfeov{\pgfplots@filter@expression{#1}}% + \ifx\pgfplots@loc@TMPc\pgfplots@loc@TMPd + #2\relax + \else + #3\relax + \fi +}% + +% the key name (example: 'x filter') +\def\pgfplots@filter@expression#1{% + \begingroup + \pgfkeys{/pgf/fpu=true}% + \pgfkeysgetvalue{/pgfplots/#1/@expressionvalue}\pgfplots@loc@TMPa + \pgfmathparse{\pgfplots@loc@TMPa}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + % this is a convenience macro to save storage in the long coordinate % lists. \def\pgfplots@stream#1#2{\pgfplotstreampoint{\pgfqpoint{#1}{#2}}} @@ -6658,6 +7076,9 @@ \pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler \pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}% % + \ifpgfplots@threedim + \pgfplots@apply@zbuffer + \fi % \pgfplots@perpointmeta@preparetrafo % @@ -6678,13 +7099,17 @@ \def\pgfplots@loc@TMPa{1}% \fi % + % OK, initialize the plot handler. + \pgfplotsresetplothandler + \pgfplots@basiclevel@plothandler + \expandafter\pgfplotsplothandlerdeserializestatefrom\expandafter{\pgfplots@serialized@state@plothandler}% + % + \pgfplots@LUA@visualization@of@current@plot + % + \pgfplotstreamstart % % Now, set up coordinate streams. \def\pgfplots@coord@stream@start@{% - \pgfplotsresetplothandler - \pgfplots@basiclevel@plothandler - \expandafter\pgfplotsplothandlerdeserializestatefrom\expandafter{\pgfplots@serialized@state@plothandler}% - \pgfplotstreamstart \let\pgfplots@data@scaletrafo@result=\pgfutil@empty \c@pgfplots@coordindex=0 }% @@ -6695,10 +7120,8 @@ \ifpgfplots@errorbars@enabled \pgfplots@errorbars@visphase@end \fi - \ifpgfplots@apply@datatrafo - \pgfplots@addplot@get@named@startendpoints@command\pgfplots@loc@TMPa - \pgfplots@loc@TMPa - \fi + \pgfplots@addplot@get@named@startendpoints@command\pgfplots@loc@TMPa + \pgfplots@loc@TMPa \pgfplotstreamend }% \begingroup @@ -6729,18 +7152,48 @@ % %\message{Prepared macro \string \pgfplotsaxisvisphasetransformcoordinate {\meaning\pgfplotsaxisvisphasetransformcoordinate}}% %\message{Prepared macro \string \pgfplots@coord@stream@finalize@currentpt {\meaning\pgfplots@coord@stream@finalize@currentpt}}% - \def\pgfplots@coord@stream@coord@{% - \ifpgfplots@stackedmode - \pgfplots@stacked@visphase@stream@coord@ - \fi - \ifx\pgfplots@current@point@x\pgfutil@empty% this implements `unbounded coords=jump', for example - \pgfplotsplothandlervisualizejump + \if1\b@pgfplots@LUA@visualization@enabled + \def\pgfplots@coord@stream@coord@{% + \ifx\pgfplots@current@point@x\pgfutil@empty% this implements `unbounded coords=jump', for example + \pgfplotsplothandlervisualizejump + \else + \pgfplotscoordmath{x}{tofixed}{\pgfplots@current@point@x}\let\pgfplots@current@point@x=\pgfmathresult + \pgfplotscoordmath{y}{tofixed}{\pgfplots@current@point@y}\let\pgfplots@current@point@y=\pgfmathresult + \ifpgfplots@curplot@threedim + \pgfplotscoordmath{z}{tofixed}{\pgfplots@current@point@z}\let\pgfplots@current@point@z=\pgfmathresult + \fi + % no need to call this here -- we got them from LUA: + % \pgfplotsaxis@toPGF@coords + \pgfplots@coord@stream@finalize@currentpt + \fi + }% + \else + \def\pgfplots@coord@stream@coord@{% + \ifpgfplots@stackedmode + \pgfplots@stacked@visphase@stream@coord@ + \fi + \ifx\pgfplots@current@point@x\pgfutil@empty% this implements `unbounded coords=jump', for example + \pgfplotsplothandlervisualizejump + \else + \pgfplotsaxisvisphasegetpoint + \pgfplots@coord@stream@finalize@currentpt + \fi + }% + \fi +} + +\def\pgfplots@LUA@visualization@init{% + \ifpgfplots@LUA@backend@supported + \edef\pgfplots@loc@TMPa{% + \directlua{pgfplots.texVisualizationInit(\plotnum, \ifpgfplots@curplot@threedim true\else false\fi)}% + }% + \if1\pgfplots@loc@TMPa + \pgfplots@log{\pgfplots@LUA@loglevel@debug}{lua backend=true: Activating partial LUA backend for visualization of plot \plotnum.}% \else - \pgfplotsaxisvisphasegetpoint - \pgfplots@coord@stream@finalize@currentpt + \pgfplots@LUA@backend@supportedfalse \fi - }% -} + \fi +}% % Takes the current point (defined by a set of macros) as input and defines \pgf@x and \pgf@y % as the output point. It also defines @@ -6748,14 +7201,13 @@ % transformed canvas coords (those which can be given to % \pgfplotsqpointxyz). % -% Furthermore, it defines keys '/data point/x untransformed' to -% contain the untransformed coords. \def\pgfplotsaxisvisphasegetpoint{% - \pgfkeyslet{/data point/x untransformed}\pgfplots@current@point@x - \pgfkeyslet{/data point/y untransformed}\pgfplots@current@point@y - \pgfkeyslet{/data point/z untransformed}\pgfplots@current@point@z \pgfplotsaxisvisphasetransformcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z% \pgfplotsaxisvisphasepreparedatapoint + \pgfplotsaxis@toPGF@coords +}% + +\def\pgfplotsaxis@toPGF@coords{% \ifpgfplots@curplot@threedim \pgfplotsqpointxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% \else @@ -6773,15 +7225,43 @@ \pgfplotspointgetcoordinatesfromnormalized }% +% PRECONDITION: \pgfplots@current@point@x and its variants is given in +% TRANSFORMED format, i.e. we assume that we are in the visualization +% phase after the coordinates have been prepared. +% POSTCONDITION: the untransformed #1 coordinate is assigned to +% \pgfplotsretval +\def\pgfplotspointgetnormalizedcoordinates@#1{% + % XXX : this is slower than it used to be - in 1.11, I simply + % remembered 'x untransformed'! I switched it to this lazy + % computation due to the LUA backend in which case remembering it + % leads to extensive (=expensive?) communication between lua and + % TeX. Does it hurt here? Scatter plots compute this stuff... + \expandafter\let\expandafter\pgfplotsretval\csname pgfplots@current@point@#1\endcsname + \ifx\pgfplotsretval\pgfutil@empty + \else + \pgfplots@if{pgfplots@apply@datatrafo@#1}{% + \pgfplotscoordmath{#1}{datascaletrafo inverse}{\pgfplotsretval}% + \let\pgfplotsretval=\pgfmathresult + }{}% + \fi +}% + % Same as \pgfplotspointgetcoordinates, but the resulting values are % for use in 'normalized axis cs'. \def\pgfplotspointgetnormalizedcoordinates{% - \pgfkeysgetvalue{/data point/x untransformed}\pgfplots@loc@TMPa - \pgfkeyslet{/data point/x}\pgfplots@loc@TMPa - \pgfkeysgetvalue{/data point/y untransformed}\pgfplots@loc@TMPa - \pgfkeyslet{/data point/y}\pgfplots@loc@TMPa - \pgfkeysgetvalue{/data point/z untransformed}\pgfplots@loc@TMPa - \pgfkeyslet{/data point/z}\pgfplots@loc@TMPa + \pgfplotspointgetnormalizedcoordinates@ x% + \pgfkeyslet{/data point/x}\pgfplotsretval + % + \pgfplotspointgetnormalizedcoordinates@ y% + \pgfkeyslet{/data point/y}\pgfplotsretval + % + \ifpgfplots@curplot@threedim + \pgfplotspointgetnormalizedcoordinates@ z% + \pgfkeyslet{/data point/z}\pgfplotsretval + \else + \pgfkeyslet{/data point/z}\pgfutil@empty + \fi + % \pgfkeyslet{/data point/meta}\pgfplots@current@point@meta \edef\pgfplots@loc@TMPa{\pgfplots@current@point@coordindex}% \pgfkeyslet{/data point/index}\pgfplots@loc@TMPa @@ -7047,6 +7527,17 @@ %\message{NO cache hit for \string\pgfplotspointplotattime{#1}^^J}% \begingroup % + \if1\b@pgfplots@LUA@visualization@enabled + \ifx\pgfplots@plot@timer@args\relax + \expandafter\gdef\expandafter\pgfplots@plot@timer@args\expandafter{% + \directlua{pgfplots.texGetSurveyedCoordsToPgfplots()}% + }% + \fi + \let\pgfplotsaxisdeserializedatapointfrom@private=\pgfplotsaxisdeserializedatapointfrom@private@nonLUA + \else + \global\let\pgfplots@plot@timer@args=\pgfplots@stored@current@data + \fi + % % \edef\pgfplots@time{#1}% \pgfplotscoordmathparsemacro{default}{\pgfplots@time}% @@ -7265,19 +7756,12 @@ % either floating point or fixed point coordinates (depending on the % state of the \ifpgfplots@apply@datatrafo boolean) % -\long\def\pgfplots@coord@stream@finalize@storedcoords@START normalized coordinates #1#2;\pgfplots@EOI{% +\long\def\pgfplots@coord@stream@finalize@storedcoords@START{% % de-activate the FPU here! I fear its number % format may cause errors when used in low-level % routines. \pgfkeys{/pgf/fpu=false}% % - \ifpgfplots@threedim - \pgfplots@apply@zbuffer{#1}% - \let\pgfplots@coord@stream@finalize@storedcoords@START@coords=\pgfplotsglobalretval - \global\let\pgfplotsglobalretval=\relax - \else - \def\pgfplots@coord@stream@finalize@storedcoords@START@coords{#1}% - \fi \pgfplots@assert@tikzinternal@exists{tikz@make@last@position}% % \ifpgfplots@clip @@ -7290,8 +7774,10 @@ % \pgfplots@stored@current@cmd%[current plot style] <--- options are already set \pgfextra + % \tikzset{every plot/.try}% \pgfplots@coord@stream@INIT@finalize@storedcoords% + % \iffalse %\ifx\pgfplots@basiclevel@plothandler\pgfplothandlerdiscard % discard!? Well, no need to loop through the elements. @@ -7302,7 +7788,7 @@ \pgfplots@coord@stream@start \pgfplots@coord@stream@end \else - \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@coord@stream@finalize@storedcoords@START@coords}% + \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@stored@current@data}% \fi % % This here ensures that the LAST position of the path is the last plotted point. @@ -7311,16 +7797,18 @@ \xdef\pgfplotlastpoint{\noexpand\pgfpointanchor{current plot end}{center}}% \tikz@make@last@position{\pgfplotlastpoint}% % - \let\pgfplots@plot@timer@args=\pgfplots@coord@stream@finalize@storedcoords@START@coords + % the coordinate stream will be assigned as soon as it is needed: + \global\let\pgfplots@plot@timer@args=\relax \pgfplotspointplotattimeclearcache \let\tikz@timer=\pgfplots@plot@timer% - \pgfplotsaxisvisphase@get@afterpath{#2}% + \pgfplotsaxisvisphase@get@afterpath% \expandafter \endpgfextra \pgfplotsretval - ; + ;% % \pgfplotspointplotattimeclearcache + \global\let\pgfplots@plot@timer@args=\relax % }% @@ -7328,7 +7816,7 @@ % standard tikz instructions which are to be carried out after the % plot path. This depends on the current visualization phase and the % available visualization phases. -\def\pgfplotsaxisvisphase@get@afterpath#1{% +\def\pgfplotsaxisvisphase@get@afterpath{% \ifx\pgfplots@visphase@name\pgfplotsaxis@visphase@name@default % ah - we have the standard visualization phase. Draw them % here. @@ -7336,7 +7824,7 @@ % Note that the existance of (nontrivial) after path % instructions ALWAYS implies the existance of a standard % visualization phase (compare \pgfplotssurveyphase@set@visphase@names) - \def\pgfplotsretval{#1}% + \let\pgfplotsretval=\pgfplots@serialized@afterpath% \else \let\pgfplotsretval=\pgfutil@empty \fi @@ -7499,6 +7987,7 @@ \pgfplots@error{Sorry, plot graphics does not support 'unbounded coords=jump'.}% }% }% + \def\pgfplotsplothandlername{graphics}% }% \def\pgfplots@plot@handler@graphics@collectbb#1{% \pgf@process{#1}% @@ -8254,101 +8743,76 @@ -% #1: a normalized coordinate stream. -% -% Output: a normalized coordinate stream in \pgfplotsglobalretval. -\def\pgfplots@apply@zbuffer#1{% +% Input : \pgfplots@stored@current@data contains the coordinate stream +% Output: \pgfplots@stored@current@data contains the (modified) +% coordinate stream +\def\pgfplots@apply@zbuffer{% \ifcase\pgfplotsplothandlermesh@zbuffer@choice\relax % none. - \gdef\pgfplotsglobalretval{#1}% \or % reverse x seq: only for 'mesh' \if\pgfplots@meshmode n% \pgfplots@error{Sorry, `/pgfplots/z buffer=reverse x seq' can only be used for mesh/surf plots.}% - \gdef\pgfplotsglobalretval{#1}% \else \pgfplotsautocompletemeshkeys \if\pgfplots@plot@mesh@ordering0% % ordering = rowwise -> scanline is cols! \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsscanlinelength - \pgfplots@apply@zbuffer@reversescanline{#1}% + \pgfplots@apply@zbuffer@reversescanline% \else % ordering = colwise: scanline is rows! \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsscanlinelength - \pgfplots@apply@zbuffer@reversetransposed{#1}% + \pgfplots@apply@zbuffer@reversetransposed% \fi \fi \or % reverse y seq: only for 'mesh' \if\pgfplots@meshmode n% \pgfplots@error{Sorry, `/pgfplots/z buffer=reverse y seq' can only be used for mesh/surf plots.}% - \gdef\pgfplotsglobalretval{#1}% \else \pgfplotsautocompletemeshkeys \if\pgfplots@plot@mesh@ordering0% % ordering = rowwise -> scanline is cols! \pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplotsscanlinelength - \pgfplots@apply@zbuffer@reversetransposed{#1}% + \pgfplots@apply@zbuffer@reversetransposed% \else % ordering = colwise: scanline is rows! \pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplotsscanlinelength - \pgfplots@apply@zbuffer@reversescanline{#1}% + \pgfplots@apply@zbuffer@reversescanline% \fi \fi \or % reverse xy seq: - \begingroup - \def\pgfplots@coord@stream@start{% - \pgfplotsprependlistXnewempty{reversed}% - }% - \def\pgfplots@coord@stream@coord{% - \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced}\to{reversed}% - }% - \def\pgfplots@coord@stream@end{% - \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversed}% - \pgfplotsprependlistXnewempty{reversed}% clear it - \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa - }% - \pgfplots@coord@stream@foreach@NORMALIZED{#1}% - \endgroup - \or - % sort. - \if\pgfplots@meshmode n% + \ifpgfplots@LUA@backend@supported + \directlua{pgfplots.texApplyZBufferReverseStream()}% + \else \begingroup \def\pgfplots@coord@stream@start{% - \pgfplotsarraynewempty\pgfplots@zbuffer@local - \pgfplotsarrayresize\pgfplots@zbuffer@local{\numcoords}% - \c@pgfplots@scanlineindex=0 - \def\pgfplots@zbuffer@local@SETCUR####1{% - \expandafter\pgfplotsarrayset\c@pgfplots@scanlineindex\of\pgfplots@zbuffer@local\to{####1}% - }% + \pgfplotsprependlistXnewempty{reversed}% }% \def\pgfplots@coord@stream@coord{% - \expandafter\pgfplots@zbuffer@local@SETCUR\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded}% - \advance\c@pgfplots@scanlineindex by1 + \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced}\to{reversed}% }% \def\pgfplots@coord@stream@end{% - \ifnum\c@pgfplots@scanlineindex=\numcoords - \else - \pgfplotsarrayresize\pgfplots@zbuffer@local{\c@pgfplots@scanlineindex}% - \fi - \pgfkeyslet{/pgfplots/iflessthan/.@cmd}\pgfplots@apply@zbuffer@SORT@iflessthan - \pgfkeysdef{/pgfplots/array/unscope pre}{% - \pgfplotsapplistXnewempty{\pgfp@sortedlist}% - \pgfplotsarrayforeachungrouped\pgfplots@zbuffer@local\as\curelem{% - \expandafter\pgfplotsapplistXpushback\expandafter{\expandafter{\curelem}}\to{\pgfp@sortedlist}% - }% - \pgfplotsapplistXlet\pgfplots@loc@TMPa={\pgfp@sortedlist}% - \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa - }% - \pgfkeysdef{/pgfplots/array/unscope post}{}% - \pgfplotsarraysort\pgfplots@zbuffer@local + \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversed}% + \pgfplotsprependlistXnewempty{reversed}% clear it + \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa }% - \pgfplots@coord@stream@foreach@NORMALIZED{#1}% + \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@stored@current@data}% \endgroup + \let\pgfplots@stored@current@data=\pgfplotsglobalretval + \global\let\pgfplotsglobalretval=\pgfutil@empty + \fi + \or + % sort. + \if\pgfplots@meshmode n% + \ifpgfplots@LUA@backend@supported + \directlua{pgfplots.texApplyZBufferSort()}% + \else + \pgfplots@apply@zbuffer@sort@coordinates + \fi \else % meshmode handles sort separately! - \gdef\pgfplotsglobalretval{#1}% \fi \or % z buffer=auto @@ -8397,10 +8861,10 @@ \fi \fi %\message{z buffer=auto mode chose z buffer= \ifcase\pgfplotsplothandlermesh@zbuffer@choice NONE \or reverse x seq \or reverse y seq \or reverse xy seq \or sort\or default \fi. mesh ordering = \ifcase\pgfplots@plot@mesh@ordering x varies/rowwise\or y varies/colwise\fi}% - % 'z buffer' is no longer 'auto' now: - \pgfplots@apply@zbuffer{#1}% \pgfmath@smuggleone\pgfplotsplothandlermesh@zbuffer@choice \endgroup + % 'z buffer' is no longer 'auto' now: + \pgfplots@apply@zbuffer \else % mesh input=patches \ifpgfplots@threedim @@ -8411,21 +8875,55 @@ \else \pgfkeys{/pgfplots/z buffer=none}% \fi - \gdef\pgfplotsglobalretval{#1}% \fi \or % z buffer=default. \if\pgfplots@meshmode n% % mesh mode deactivated! - \gdef\pgfplotsglobalretval{#1}% \else % mesh=true \pgfkeysalso{/pgfplots/z buffer=auto}% - \pgfplots@apply@zbuffer{#1}% + \pgfplots@apply@zbuffer% \fi \fi }% +\def\pgfplots@apply@zbuffer@sort@coordinates{% + \begingroup + \def\pgfplots@coord@stream@start{% + \pgfplotsarraynewempty\pgfplots@zbuffer@local + \pgfplotsarrayresize\pgfplots@zbuffer@local{\numcoords}% + \c@pgfplots@scanlineindex=0 + \def\pgfplots@zbuffer@local@SETCUR####1{% + \expandafter\pgfplotsarrayset\c@pgfplots@scanlineindex\of\pgfplots@zbuffer@local\to{####1}% + }% + }% + \def\pgfplots@coord@stream@coord{% + \expandafter\pgfplots@zbuffer@local@SETCUR\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded}% + \advance\c@pgfplots@scanlineindex by1 + }% + \def\pgfplots@coord@stream@end{% + \ifnum\c@pgfplots@scanlineindex=\numcoords + \else + \pgfplotsarrayresize\pgfplots@zbuffer@local{\c@pgfplots@scanlineindex}% + \fi + \pgfkeyslet{/pgfplots/iflessthan/.@cmd}\pgfplots@apply@zbuffer@SORT@iflessthan + \pgfkeysdef{/pgfplots/array/unscope pre}{% + \pgfplotsapplistXnewempty{\pgfp@sortedlist}% + \pgfplotsarrayforeachungrouped\pgfplots@zbuffer@local\as\curelem{% + \expandafter\pgfplotsapplistXpushback\expandafter{\expandafter{\curelem}}\to{\pgfp@sortedlist}% + }% + \pgfplotsapplistXlet\pgfplots@loc@TMPa={\pgfp@sortedlist}% + \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa + }% + \pgfkeysdef{/pgfplots/array/unscope post}{}% + \pgfplotsarraysort\pgfplots@zbuffer@local + }% + \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@stored@current@data}% + \endgroup + \let\pgfplots@stored@current@data=\pgfplotsglobalretval + \global\let\pgfplotsglobalretval=\pgfutil@empty +}% % Defines \pgfplotsglobalretval (globally) to be a partial reversion of the % (normalized) 2d coordinate sequence '#1'. % @@ -8440,70 +8938,82 @@ % \pgfplotsscanlinelength contains the scanline length % POSTCONDITION: % \pgfplotsglobalretval contains the partial reversion. -\def\pgfplots@apply@zbuffer@reversescanline#1{% - \begingroup - \def\pgfplots@coord@stream@start{% - \pgfplotsprependlistXnewempty{reversedscanline}% - \c@pgfplots@scanlineindex=0 - \pgfplotsapplistXnewempty{\resultlist}% - }% - \def\pgfplots@coord@stream@coord{% - \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced}\to{reversedscanline}% - \advance\c@pgfplots@scanlineindex by1 - \ifnum\c@pgfplots@scanlineindex=\pgfplotsscanlinelength\relax - \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversedscanline}% - \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPa}\to\resultlist +\def\pgfplots@apply@zbuffer@reversescanline{% + \ifpgfplots@LUA@backend@supported + \directlua{pgfplots.texApplyZBufferReverseScanline(\pgfplotsscanlinelength)}% + \else + \begingroup + \def\pgfplots@coord@stream@start{% \pgfplotsprependlistXnewempty{reversedscanline}% \c@pgfplots@scanlineindex=0 - \fi - }% - \def\pgfplots@coord@stream@end{% - \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversedscanline}% - \ifx\pgfplots@loc@TMPa\pgfutil@empty - \else - \pgfplots@zbuffer@error - \fi - \pgfplotsapplistXlet\pgfplots@loc@TMPa={\resultlist}% - \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa - }% - \pgfplots@coord@stream@foreach@NORMALIZED{#1}% + \pgfplotsapplistXnewempty{\resultlist}% + }% + \def\pgfplots@coord@stream@coord{% + \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced}\to{reversedscanline}% + \advance\c@pgfplots@scanlineindex by1 + \ifnum\c@pgfplots@scanlineindex=\pgfplotsscanlinelength\relax + \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversedscanline}% + \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPa}\to\resultlist + \pgfplotsprependlistXnewempty{reversedscanline}% + \c@pgfplots@scanlineindex=0 + \fi + }% + \def\pgfplots@coord@stream@end{% + \pgfplotsprependlistXlet\pgfplots@loc@TMPa={reversedscanline}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfplots@zbuffer@error + \fi + \pgfplotsapplistXlet\pgfplots@loc@TMPa={\resultlist}% + \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa + }% + \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@stored@current@data}% + \endgroup + \let\pgfplots@stored@current@data=\pgfplotsglobalretval + \global\let\pgfplotsglobalretval=\pgfutil@empty + \fi %\message{I have performed partial reversion of '#1' and got '\pgfplotsglobalretval'!}% - \endgroup }% % A very similar method of \pgfplots@apply@zbuffer@reversescanline, % but this one keeps everything inside of each scanline in the % original ordering, and reverses the ordering in which whole % scanlines occur. -\def\pgfplots@apply@zbuffer@reversetransposed#1{% - \begingroup - \def\pgfplots@coord@stream@start{% - \pgfplotsapplistXnewempty{\scanline}% - \c@pgfplots@scanlineindex=0 - \pgfplotsprependlistXnewempty{resultlist}% - }% - \def\pgfplots@coord@stream@coord{% - \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced}\to{\scanline}% - \advance\c@pgfplots@scanlineindex by1 - \ifnum\c@pgfplots@scanlineindex=\pgfplotsscanlinelength\relax - \pgfplotsapplistXlet\pgfplots@loc@TMPa={\scanline}% - \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@loc@TMPa}\to{resultlist} +\def\pgfplots@apply@zbuffer@reversetransposed{% + \ifpgfplots@LUA@backend@supported + \directlua{pgfplots.texApplyZBufferReverseTransposed(\pgfplotsscanlinelength)}% + \else + \begingroup + \def\pgfplots@coord@stream@start{% \pgfplotsapplistXnewempty{\scanline}% \c@pgfplots@scanlineindex=0 - \fi - }% - \def\pgfplots@coord@stream@end{% - \pgfplotsapplistXlet\pgfplots@loc@TMPa={\scanline}% - \ifx\pgfplots@loc@TMPa\pgfutil@empty - \else - \pgfplots@zbuffer@error - \fi - \pgfplotsprependlistXlet\pgfplots@loc@TMPa={resultlist}% - \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa - }% - \pgfplots@coord@stream@foreach@NORMALIZED{#1}% -%\message{I have performed partial reversion of '#1' and got '\pgfplotsglobalretval'!}% - \endgroup + \pgfplotsprependlistXnewempty{resultlist}% + }% + \def\pgfplots@coord@stream@coord{% + \expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@coord@stream@foreach@NORMALIZED@curencoded@braced}\to{\scanline}% + \advance\c@pgfplots@scanlineindex by1 + \ifnum\c@pgfplots@scanlineindex=\pgfplotsscanlinelength\relax + \pgfplotsapplistXlet\pgfplots@loc@TMPa={\scanline}% + \expandafter\pgfplotsprependlistXpushfront\expandafter{\pgfplots@loc@TMPa}\to{resultlist} + \pgfplotsapplistXnewempty{\scanline}% + \c@pgfplots@scanlineindex=0 + \fi + }% + \def\pgfplots@coord@stream@end{% + \pgfplotsapplistXlet\pgfplots@loc@TMPa={\scanline}% + \ifx\pgfplots@loc@TMPa\pgfutil@empty + \else + \pgfplots@zbuffer@error + \fi + \pgfplotsprependlistXlet\pgfplots@loc@TMPa={resultlist}% + \global\let\pgfplotsglobalretval=\pgfplots@loc@TMPa + }% + \expandafter\pgfplots@coord@stream@foreach@NORMALIZED\expandafter{\pgfplots@stored@current@data}% + \endgroup + \let\pgfplots@stored@current@data=\pgfplotsglobalretval + \global\let\pgfplotsglobalretval=\pgfutil@empty + \fi +%\message{I have performed partial reversion (reverse transposed) of '#1' and got '\pgfplotsglobalretval'!}% }% \def\pgfplots@zbuffer@error{% \pgfplots@error{An internal error occured during z buffer reorderings: the rows/cols where not balanced! I have rows= \pgfkeysvalueof{/pgfplots/mesh/rows}, cols=\pgfkeysvalueof{/pgfplots/mesh/cols}. If this happens to be wrong, you might want to provide rows and cols manually.}% |