/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;

void emph(const std::string& prog)
{
  if (prog == "all")
    black();
  else
    {
      bbold(Red());
      label_color(Blue());
      label_mask(Yellow(0.1));
      label_border(Red(), "0.1pt");
    }
}

void restore(const std::string& prog)
{
  if (prog == "all")
    emph(prog);

  else
    {
      plain();
      black(0.5);
      label_mask(Neutral());
    }
}

void diagram(const std::string& prog)
{
  font_size("footnotesize");
  arrow_width(1.5);
  restore(prog);

  if (prog != "laps")
    emph(prog);

  arrow(P(0,1), P(1,1));

  dot(P(0,1), P(0,4), "\\texttt{xp}, \\texttt{flx}", t);
  dot(P(1,1), P(2,4), "\\texttt{eepic}", t);
  restore(prog);

  if (prog != "epix")
    emph(prog);

  spline(P(1,1), P(1.2,1), P(1.3,0.5), P(1.5,0.5));
  arrow(P(1.5,0.5), P(2,0.5));
  arrow(P(2,0.5), P(3,0.5));

  dot(P(2,0.5), P(0,4), "\\texttt{dvi}", t);
  dot(P(3,0.5), P(-2,2), "\\texttt{ps}", tl);
  restore(prog);

  if(prog == "laps")
    emph(prog);

  spline(P(1,0), P(1.2,0), P(1.3,0.5), P(1.5,0.5));

  dot(P(1,0), P(2,-4), "\\texttt{tex}", b);

  if (prog == "elaps") // and laps
    emph(prog);

  arrow(P(3,0.5), P(3.5,0), P(4,0));

  dot(P(4,0), P(4,0), "\\texttt{pdf}", r);
  restore(prog);

  if (prog == "elaps" || prog == "flix")
    emph(prog);

  arrow(P(3,0.5), P(3.5,1), P(4,1));

  dot(P(4,1), P(-2,4), "\\texttt{eps}", t);
  restore(prog);

  if(prog == "flix")
    emph(prog);

  arrow(P(4,1), P(5,1));

  dot(P(5,1), P(4,0),
      "\\begin{minipage}{0.225in}\\texttt{png mng gif}\\end{minipage}", r);
  restore(prog);

  if (prog != "all")
    {
      font_size("Large");
      font_face("tt");
      label_color(Green(0.6));
      label(P(2.5,0), prog);
    }

}

int main()
{
#ifdef SHOW_ALL
  picture(P(-0.5,0), P(5.75,10), "4 x 7.5 in");
#else
  picture(P(-0.5,2), P(5.75,10), "4 x 7.5 in");
#endif

  begin();
  //  border();

  screen laps(P(0,0), P(5,1));
  activate(laps);

  diagram("laps");
  laps.v_scale(0.5, P(0,0.5));
  inset(laps, P(0,8), P(5,10));
  deactivate(laps);


  screen epix(P(0,0), P(5,1));
  activate(epix);

  diagram("epix");
  epix.v_scale(0.5, P(0,0.5));
  inset(epix, P(0,6), P(5,8));
  deactivate(epix);


  screen elaps(P(0,0), P(5,1));
  activate(elaps);

  diagram("elaps");
  elaps.v_scale(0.5, P(0,0.5));
  inset(elaps, P(0,4), P(5,6));
  deactivate(elaps);


  screen flix(P(0,0), P(5,1));
  activate(flix);

  diagram("flix");
  flix.v_scale(0.5, P(0,0.5));
  inset(flix, P(0,2), P(5,4));
  deactivate(flix);

#ifdef SHOW_ALL
  screen all(P(0,0), P(5,1));
  activate(all);

  diagram("all");
  all.v_scale(0.5, P(0,0.5));
  inset(all, P(0,0), P(5,2));
  deactivate(all);
#endif

  end();
}
