Ronen Abravanel wrote: > Hello, > > I created a patch that adds a Feynman diagram inset into lyx. The inset is > based on the inst "Diagram" in the package feyn ( > http://www.ctan.org/tex-archive/fonts/feyn/ ) . The inset is meant to > replace the hack described in the 3rd section of the following document: > http://www.technion.ac.il/~ronen/latex/lyx_quantum.pdf > http://www.technion.ac.il/~ronen/latex/lyx_quantum.lyx > > The patch is based on 2.0 Alpha 6, and based mostly on copied code from > XYMatrix inset. > > I will appreciate comments regarding the patch. Is it too late to include it > in 2.0?
hi, as i have already written in our private exchange this still can go in. the nice thing - its basically copy of another inset so i dont expect it to import many new bugs ;) from this follows one comment though - can you please try to make InsetMathDiagram to be descendant from the insetxymatrix class so only the new method which have different code are written in your InsetMathDiagram.h/cpp files? also it would be good to test it before commiting, so if you can provide some example file... few more comments: > diff -rupN lyx-2.0.0alpha6/src/insets/InsetCode.h > lyx-2.0.0alpha6_feynFinal/src/insets/InsetCode.h > --- lyx-2.0.0alpha6/src/insets/InsetCode.h 2010-09-15 16:33:43.000000000 > -0400 > +++ lyx-2.0.0alpha6_feynFinal/src/insets/InsetCode.h 2010-09-18 > 12:00:16.000000000 -0400 > @@ -223,6 +223,8 @@ enum InsetCode { > /// > PREVIEW_CODE, > /// > + MATH_DIAGRAM_CODE, //RCHANGE kill comment > + insetnames[MATH_DIAGRAM_CODE] = InsetName("mathdyagram"); "y" typo? > --- lyx-2.0.0alpha6/src/lyxmathed.cpp 2010-09-16 04:26:35.000000000 -0400 > +++ lyx-2.0.0alpha6_feynFinal/src/lyxmathed.cpp 2010-09-18 > 12:00:16.000000000 -0400 > @@ -52,6 +52,7 @@ > #include "mathed/InsetMathUnknown.cpp" > #include "mathed/InsetMathXArrow.cpp" > #include "mathed/InsetMathXYMatrix.cpp" > +#include "mathed/InsetMathDiagram.cpp" > #include "mathed/MathAtom.cpp" > #include "mathed/MathAutoCorrect.cpp" > #include "mathed/MathData.cpp" this file is generated, no need for patch... if you work under svn, not under the tarball, "svn diff" will report exactly those files which belongs to the tree and are not automatically generated... (http://www.lyx.org/HowToUseSVN) > + * \file InsetMathDiagram.cpp > + * This file is part of LyX, the document processor. > + * Licence details can be found in the file COPYING. > + * > + * \author André Pönitz, Ronen Abravanel two lines > diff -rupN lyx-2.0.0alpha6/src/mathed/MathFactory.cpp > lyx-2.0.0alpha6_feynFinal/src/mathed/MathFactory.cpp > --- lyx-2.0.0alpha6/src/mathed/MathFactory.cpp 2010-09-15 > 16:33:43.000000000 -0400 > +++ lyx-2.0.0alpha6_feynFinal/src/mathed/MathFactory.cpp 2010-09-18 > 12:19:44.000000000 -0400 > @@ -44,6 +44,7 @@ > #include "InsetMathHull.h" > #include "InsetMathXArrow.h" > #include "InsetMathXYMatrix.h" > +#include "InsetMathDiagram.h" > #include "MacroTable.h" > #include "MathMacro.h" > #include "MathMacroArgument.h" > @@ -417,6 +418,48 @@ MathAtom createInsetMath(docstring const > return MathAtom(new InsetMathXYMatrix(buf, spacing, > spacing_code, > equal_spacing)); > } > + > + if (s.substr(0, 8) == "Diagram") { > + char spacing_code = '\0'; > + Length spacing; > + bool equal_spacing = false; > + size_t const len = s.length(); > + size_t i = 8; > + if (i < len && s[i] == '@') { > + ++i; > + if (i < len && s[i] == '!') { > + equal_spacing = true; > + ++i; > + if (i < len) { > + switch (s[i]) { > + case '0': > + case 'R': > + case 'C': > + spacing_code = > static_cast<char>(s[i]); > + } > + } > + } else if (i < len) { > + switch (s[i]) { > + case 'R': > + case 'C': > + case 'M': > + case 'W': > + case 'H': > + case 'L': > + spacing_code = static_cast<char>(s[i]); > + ++i; > + break; > + } > + if (i < len && s[i] == '=') { > + ++i; > + spacing = Length(to_ascii(s.substr(i))); > + } > + } > + } > + return MathAtom(new InsetMathDiagram(buf, spacing, spacing_code, > + equal_spacing)); > + } > + do you have idea whether this code also applies to Diagram (i.e. all those 'R''C''M'... cases are not xymatrix-only feature?) also this is fileformat change - that is .lyx files generated with this patch cannot be correctly read by older version of lyx and we need to handle that. it should be simple here - either only bump file version or we just need that when file is converted to lyx 1.6 "\use_package{feyn}" is put into the preamble so its compilable even in 1.6. look on the beginning of this commit: http://www.lyx.org/trac/changeset/34748 to have idea how we handle bumping new fileformat versions. (the code of diagram math inset should be readable even in older version of lyx because we store all math insets as pure tex construct...) this looks like nice feature to have imho. pavel