2

I found this trick posted by Aditya some time ago that allowed to use metaobj in context. Currently this code no longer works. Currently, are there any way to use metaobj in context? The main problem are the labels. There's a wiki article about this (http://wiki.contextgarden.net/MetaObj_and_Labels), but this solution don't work anymore.

From Aditya:

\startMPinclusions[+]
   input metaobj;
   boolean flag; flag := false;
\stopMPinclusions

\startMPdefinitions
   vardef newSegment@\#=
     if not flag :
       assignObj(@\#,"Segment");
       ObjPoint a,b;
       ObjCode "@\#b-@\#a=(1cm,2cm)";
     fi ;
   enddef;

   def drawSegment(suffix n)=
     draw n.a--n.b;
     draw btex \tt \overbar{E} etex shifted n.a; % 1
   enddef;
\stopMPdefinitions

\starttext
\startMPpage
   newSegment.s;
   ObjLabel.s(btex hello! etex) "labpoint(a)"; % 2
   s.a=origin;
   drawObj(s);
   flag := true ;
\stopMPpage
\stoptext
1

It works for me if I replace the btex … etex flags in your code by the textext("…") macro from ConTeXt/Metafun. But the resulting figure is somewhat ugly, so it is maybe not the result you expect.

  • When I need to make diagrams with nodes I'm forced to switch to TikZ. Metaobj is a fundamental tool for users of metapost, but it seems to me that is not properly supported: looks like an abandoned project. Metapost is more powerfull than TikZ, but needs to have nodes similar to the TikZ and pstricks policy. – Jorge Jan 23 '14 at 18:59
1

Please try this example posted some time ago by Aditya:

\startMPenvironment
   \setupbodyfont[8pt]
   \setupframed[width=3cm, align=center, frame=off]
\stopMPenvironment

\startMPinclusions[+]
   input metaobj;
   setObjectDefaultOption("Ellipse")("fit")(false)
   setCurveDefaultOption("arcangleA",15);
   setCurveDefaultOption("arcangleB",15);
   boolean flag; 
   flag := false; % flag is false in the first run
\stopMPinclusions

\starttext



\startMPpage
   % Metaobj provides a Circle command. But there seems to be
   % a bug in the interaction of Circle and Matix. So using Ellipse with
   % fit=false
if not flag:
   newEllipse.N1(textext("  \framed{" Mise Sous Tension "})) ;
   newEllipse.N2(textext("  \framed{Mesure du point zéro méchaique}  ")) ;
   newEllipse.N3(textext("  \framed{Régalage des paramèters de contrôle}  ")) ;
   newEllipse.N4(textext("  \framed{Envoi du contenu de l'\cap{EEPROM}}  ")) ;
   newEllipse.N5(textext("  \framed{{\bf Mode stop|/| réglage} Attente de commande}  "));
   newEllipse.N6(textext("  \framed{\bf Mode freins libres}  ")) ;
   newEllipse.N7(textext("  \framed{Le contenu de l'\cap{EEPROM} a changé}  ")) ;
   newEllipse.N8(textext("  \framed{Ëcriture du contenu de la \cap{RAM} vers l'\cap{EEPROM}}  "));
   newEllipse.N9(textext("  \framed{{\bf Mode  Contrôle} La valeur de la commande est rafraîchie à chaque cycle}  ")) ;

   newMatrix.diagram(3,3)(N1,N2,N3,N4,N5,N6,N7,N8,N9) "hsep(1.5cm)", "vsep(1.5cm)";
fi;

   diagram.c = origin ;
  drawObj(diagram) ;
   ncline(N1)(N5) ;
   for i = 2,3,4,6,7,8,9:
     ncarc(N[i])(N[5]) ;
     ncarc(N[5])(N[i]) ;
   endfor
   nccircle(N6) "angleA(-120)" ;
   nccircle(N9) "angleA(-120)" ;

flag:=true;
   % Labels can be added. See metaobj manual

\stopMPpage

\stoptext
  • I seem to have forgotten all these examples that I posted "some time ago" :) – Aditya Jan 23 '14 at 22:24
  • It's too hard to find support for metaobj in context. – Jorge Jan 24 '14 at 11:28
  • Didn't compile right out of the box because of input encoding issues. I had to change the accented French characters into unaccented ones. Then it works, but produces only something like a black point. I don't know much about MetaObj itself, but at first view it looks like a scaling problem, unrelated to MetaObj… – Franck Pastor Jan 24 '14 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.