Commits

Anonymous committed e9dd380

drawmode option (defaults to luagraph

  • Participants
  • Parent commits 5ffc9eb

Comments (0)

Files changed (3)

 \stopbuffer
 
 \startcombination[2*2]
-  {\syntaxtree[%                                1,1
+  {\syntaxtree[%                                                        1,1
+     drawmode=dot
      notation=unicode,
      treefont=Iwona,
      width=7cm,
    ] {~p*~q<->~(p+q)}}
   {DeMorgan’s law 1}
-  {\syntaxtree[%                                1,2
+  {\syntaxtree[%                                                        1,2
      notation=unicode,
      treefont=Iwona,
      width=7cm,
    ] {~(p*q)<->~p+~q}}
   {DeMorgan’s law 2}
-  {\framed[frame=off,align=left]{\getbuffer[demorg1]}}{Truth table 1}
-  {\framed[frame=off,align=left]{\getbuffer[demorg2]}}{Truth table 2}
+  {\framed[frame=off,align=left]{\getbuffer[demorg1]}}{Truth table 1} % 2,1
+  {\framed[frame=off,align=left]{\getbuffer[demorg2]}}{Truth table 2} % 2,2
 \stopcombination
 %\fi
 
         assert(tonumber(os.execute(cmd_string)) == 0, "[RAT] something is wrong with the dot syntax, email the author!")
     end
 
+    local function set_graph (drawmode)
+        if drawmode == "lg" or
+           drawmode == "luagraph" then
+            if trace_rat then
+                report_rat("using LuaGRAPH library for graphviz processing")
+            end
+            rat.graph.draw = rat.graph.lg_draw
+        else
+            if trace_rat then
+                report_rat("using external dot binary for graphviz processing")
+            end
+            rat.graph.draw = rat.graph.dot_draw
+        end
+    end
+
     local tmp_file_cnt = 0
     local function next_tmp_file ()
         tmp_file_cnt = tmp_file_cnt + 1
             local parsed = rat.tree(expr)
             tmpfile = next_tmp_file()
             --rat.graph.lg_draw(parsed, id, tmpfile)
-            rat.graph.dot_draw(parsed, id, tmpfile)
+            rat.graph.draw(parsed, id, tmpfile)
             graph_cache[id] = tmpfile
         else
             if trace_rat then
         rat.current_filename = tmpfile..".pdf"
     end
 
+    rat.graph.setgraph = set_graph
     rat.graph.lg_draw  = lg_draw
     rat.graph.dot_draw = dot_draw
+    rat.graph.draw     = lg_draw -- initially, will be reset via setups
     rat.graph.dograph  = dograph
     rat.ctx.syntaxtree = syntaxtree
 end

t-ratiocinator.mkiv

 %D Expected module parameters:
 %D \placetable[here]{none}{%
 %D    \starttabulate[|Ir|l|]
-%D      \NC compress       \NC boolean: compress truth tables            \AR
-%D      \NC highlightcolor \NC color of your choice                      \AR
-%D      \NC notation       \NC pm, pm\letterunderscore tex, tex, unicode \AR
-%D      \NC truthstyle     \NC boole, frege, unicode, tf                 \AR
-%D      \NC treefont       \NC font for use with GraphViz                \AR
-%D      \NC labelfont      \NC font to pass to MP as “defaultfont”       \AR
+%D      \NC compress       \NC boolean: compress truth tables                  \AR
+%D      \NC drawmode       \NC string: “luagraph” or “dot” (graphviz renderer) \AR
+%D      \NC highlightcolor \NC color of your choice                            \AR
+%D      \NC notation       \NC pm, pm\letterunderscore tex, tex, unicode       \AR
+%D      \NC truthstyle     \NC boole, frege, unicode, tf                       \AR
+%D      \NC treefont       \NC font for use with GraphViz                      \AR
+%D      \NC labelfont      \NC font to pass to MP as “defaultfont”             \AR
 %D    \stoptabulate
 %D }
 %D The {\italic treefont} needs to be a valid fontconfig
 %D matching pattern.
 \setuprat[
   compress=false,
+  drawmode=luagraph,
+  highlightcolor=gray:2,
+  labelfont={latin-modern},
   notation=tex,
+  treefont={CMU Serif},
   truthstyle=unicode,
-  highlightcolor=gray:2,
-  treefont={CMU Serif},
-  labelfont={latin-modern},
+  \c!height=,     % item
   \c!width=,      % locally, for GraphViz inclusion
-  \c!height=,     % item
 ]
 
 %D Loading the Lua internals.
   \fi
   \startluacode
     local rat = thirddata.ratiocinator
+    rat.graph.setgraph("\luaescapestring{\ratparameter{drawmode}}")
     rat.options.notation.output = rat.notations["\ratparameter{notation}"]
     rat.options.treefont = "\luaescapestring{\ratparameter{treefont}}"
     rat.ctx.syntaxtree("\luaescapestring{#2}")