diff options
author | Karl Berry <karl@freefriends.org> | 2016-01-08 00:02:17 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-01-08 00:02:17 +0000 |
commit | 4e668f51370a93cc9dc26b1a11a949b50493b353 (patch) | |
tree | 85ab6891036f9a348e68f83e31c56b069332a9ca /Master/texmf-dist/tex/generic/pgfplots/lua | |
parent | f2995718d3db02b5ff46d4552b9281b9761327ae (diff) |
pgfplots (7jan16)
git-svn-id: svn://tug.org/texlive/trunk@39303 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/lua')
4 files changed, 74 insertions, 17 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua index ca8b894a7c3..bbce58d50c9 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua @@ -118,6 +118,17 @@ function texSurveyPoint(x,y,z,meta) gca.currentPlotHandler:surveypoint(pt) end +-- Called during \addplot, i.e. during the survey phase. It is only called in PARTIAL MODE (see above). +function texSurveyAddJump() + local pt = Coord.new() + pt.x[1] = nil + pt.x[2] = nil + pt.x[3] = nil + pt.meta = nil + + gca:addSurveyedJump(gca.currentPlotHandler, pt) +end + -- Copies survey results of the current plot back to TeX. It prints a couple of executable TeX statements as result. -- @see \pgfplots@LUA@survey@end function texSurveyEnd() diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua index e3fc089e25d..ba719753dad 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua @@ -148,6 +148,7 @@ function Plothandler:constructor(name, axis, pointmetainputhandler) self.pointmetamap = nil -- will be set later self.filteredCoordsAway = false self.plotHasJumps = false + self.hasUnboundedPointMeta = false -- will be set before the visualization phase starts. At least. self.plotIs3d = false return self @@ -173,6 +174,7 @@ function Plothandler:addSurveyedPoint(pt) -- log("addSurveyedPoint(" .. tostring(pt) .. ") ...\n") end + -- PRIVATE -- -- assigns the point meta value by means of the PointMetaHandler @@ -186,7 +188,7 @@ end -- -- updates point meta limits function Plothandler:setperpointmetalimits(pt) - if pt.meta ~= nil then + if self.pointmetainputhandler ~= nil and self.pointmetainputhandler:isPointMetaBounded(pt.meta) then if not type(pt.meta) == 'number' then error("got unparsed input "..tostring(pt)) end if self.autocomputeMetaMin then self.metamin = math.min(self.metamin, pt.meta ) @@ -195,6 +197,9 @@ function Plothandler:setperpointmetalimits(pt) if self.autocomputeMetaMax then self.metamax = math.max(self.metamax, pt.meta ) end + else + -- FIXME : the TeX code also checks for 'bounded point meta' if there is no point meta input!? + self.hasUnboundedPointMeta = true end end @@ -490,6 +495,25 @@ function PointMetaHandler.assign(pt) error("This instance of PointMetaHandler is not implemented") end +-- see \pgfplotsifpointmetaisbounded +function PointMetaHandler:isPointMetaBounded(meta) + if meta == nil then + return false + end + + if self.isSymbolic then + if meta == "" then + return false + else + return true + end + + else + -- check the number: + return pgfplotsmath.isfinite(meta) + end +end + -- A PointMetaHandler which merely acquires values of either x,y, or z. CoordAssignmentPointMetaHandler = newClassExtends( PointMetaHandler ) @@ -853,10 +877,7 @@ function Axis:datapointsurveyed(pt, plothandler) log("NOTE: coordinate " .. tostring(pt) .. " has been dropped because " .. reason .. "\n") end else - plothandler.plotHasJumps = true - - local serialized = self:addVisualizationDependencies(pt) - plothandler:addSurveyedPoint(serialized) + self:addSurveyedJump(plothandler, pt) end end end @@ -865,6 +886,13 @@ function Axis:datapointsurveyed(pt, plothandler) -- We do it it surveypoint. end +function Axis:addSurveyedJump(plothandler, pt) + plothandler.plotHasJumps = true + + local serialized = self:addVisualizationDependencies(pt) + plothandler:addSurveyedPoint(serialized) +end + local function axisLimitToTeXString(name, value) if value == math.huge or value == -math.huge then return "" @@ -937,6 +965,13 @@ function Axis:surveyToPgfplots(plothandler) result = result .. "\\def\\pgfplotsaxisplothasjumps{0}" end + if plothandler.hasUnboundedPointMeta then + result = result .. + "\\def\\pgfplotsaxisplothasunboundedpointmeta{1}" + else + result = result .. + "\\def\\pgfplotsaxisplothasunboundedpointmeta{0}" + end if plothandler.filteredCoordsAway then result = result .. "\\def\\pgfplotsaxisfilteredcoordsaway{1}" diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/functions.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/functions.lua index e5573f26f64..d8d32997e3f 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/functions.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/functions.lua @@ -19,7 +19,7 @@ -- with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: -- This file comes without any warranty as the rest of pgfplots; there is no obligation for help. ---------------------------------------------------------------------------------------------------- --- Date of this copy: Mi 14. Jan 21:15:32 CET 2015 --- +-- Date of this copy: Mi 6. Jan 11:32:04 CET 2016 --- @@ -32,7 +32,7 @@ -- -- See the file doc/generic/pgf/licenses/LICENSE for more details. -- --- $Id: functions.lua,v 1.2 2015/01/14 20:15:13 cfeuersaenger Exp $ +-- $Id: functions.lua,v 1.3 2015/05/10 20:34:13 cfeuersaenger Exp $ -- local pgfluamathfunctions = pgfluamathfunctions or {} @@ -561,6 +561,8 @@ function pgfluamathfunctions.tonumber(x) local lower = x:lower() if lower == 'nan' then result = nan + elseif lower == "-nan" then + result = nan elseif lower == 'inf' or lower == 'infty' then result = infty elseif lower == '-inf' or lower == '-infty' then diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/parser.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/parser.lua index cc9663f145f..072ac058546 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/parser.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplotsoldpgfsupp/luamath/parser.lua @@ -19,7 +19,7 @@ -- with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: -- This file comes without any warranty as the rest of pgfplots; there is no obligation for help. ---------------------------------------------------------------------------------------------------- --- Date of this copy: Mi 14. Jan 21:15:32 CET 2015 --- +-- Date of this copy: Mi 6. Jan 11:32:04 CET 2016 --- @@ -33,7 +33,7 @@ -- -- See the file doc/generic/pgf/licenses/LICENSE for more details. -- --- $Id: parser.lua,v 1.1 2014/12/27 14:11:49 cfeuersaenger Exp $ +-- $Id: parser.lua,v 1.3 2015/11/28 17:20:49 cfeuersaenger Exp $ -- -- usage: -- @@ -73,7 +73,7 @@ local integer_pattern = S("+-")^-1 * positive_integer_pattern local positive_integer_or_decimal_pattern = positive_integer_pattern * ( P(".") * one_digit_pattern^0)^-1 + (P(".") * one_digit_pattern^1) local integer_or_decimal_pattern = S("+-")^-1 * positive_integer_or_decimal_pattern -local fpu_pattern = R"15" * P"Y" * positive_integer_or_decimal_pattern * P"e" * P("-")^-1 * R("09")^1 * P"]" +local fpu_pattern = R"05" * P"Y" * positive_integer_or_decimal_pattern * P"e" * S("+-")^-1 * R("09")^1 * P"]" local unbounded_pattern = P"inf" + P"INF" + P"nan" + P"NaN" + P"Inf" local number_pattern = C(unbounded_pattern + fpu_pattern + integer_or_decimal_pattern * (S"eE" * integer_pattern + C(tex_unit))^-1) @@ -102,7 +102,8 @@ local comma_pattern = P(",") * space_pattern ---------------- local TermOp = C(S("+-")) * space_pattern -local RelationalOp = C( P"==" + P"!=" + P"<=" + P">=" + P"<" + P">" ) * space_pattern +local EqualityOp = C( P"==" + P"!=" ) * space_pattern +local RelationalOp = C( P"<=" + P">=" + P"<" + P">" ) * space_pattern local FactorOp = C(S("*/")) * space_pattern -- Grammar @@ -195,11 +196,18 @@ local function postfix_eval(prefix, op, arg) return result end -local function relational_eval(v1, op, v2) +local function equality_eval(v1, op, v2) local fct if (op == "==") then fct = pgfluamathfunctions.equal elseif (op == "!=") then fct = pgfluamathfunctions.notequal - elseif (op == "<") then fct = pgfluamathfunctions.less + else + error("This function must not be invoked for operator "..op) + end + return fct(v1,v2) +end +local function relational_eval(v1, op, v2) + local fct + if (op == "<") then fct = pgfluamathfunctions.less elseif (op == ">") then fct = pgfluamathfunctions.greater elseif (op == ">=") then fct = pgfluamathfunctions.notless elseif (op == "<=") then fct = pgfluamathfunctions.notgreater @@ -289,6 +297,7 @@ local initialRule = V"initial" local Summand = V"Summand" local Relational = V"Relational" +local Equality = V"Equality" local LogicalOr = V"LogicalOr" local LogicalAnd = V"LogicalAnd" @@ -324,11 +333,11 @@ local G = P{ "initialRule", initialRule = space_pattern* Exp * -1; -- ternary operator (or chained ternary operators): -- FIXME : is this chaining a good idea!? - Exp = Cf( Relational * Cg(P"?" * space_pattern * Relational * P":" *space_pattern * Relational )^0, ternary_eval) ; - -- FIXME : do we really allow something like " 1 == 1 != 2" ? I would prefer (1==1) != 2 !? - Relational = Cf(LogicalOr * Cg(RelationalOp * LogicalOr)^0, relational_eval); + Exp = Cf( LogicalOr * Cg(P"?" * space_pattern * LogicalOr * P":" *space_pattern * LogicalOr )^0, ternary_eval) ; LogicalOr = Cf(LogicalAnd * (P"||" * space_pattern * LogicalAnd)^0, pgfluamathfunctions.orPGF); - LogicalAnd = Cf(Summand * (P"&&" * space_pattern * Summand)^0, pgfluamathfunctions.andPGF); + LogicalAnd = Cf(Equality * (P"&&" * space_pattern * Equality)^0, pgfluamathfunctions.andPGF); + Equality = Cf(Relational * Cg(EqualityOp * Relational)^0, equality_eval); + Relational = Cf(Summand * Cg(RelationalOp * Summand)^0, relational_eval); Summand = Cf(Term * Cg(TermOp * Term)^0, eval) ; Term = Cf(Prefix * Cg(FactorOp * Prefix)^0, eval); Prefix = prefix_operator_pattern + Postfix; |