29 using ecolab::cairo::Surface;
30 using ecolab::cairo::CairoSave;
46 cairo_rel_move_to(cairo, -0.5*
object.width(), 0);
break;
48 cairo_rel_move_to(cairo, -0.5*
object.width(), -
object.height());
break;
50 cairo_rel_move_to(cairo,
object.width(), -0.5*
object.height());
break;
52 cairo_rel_move_to(cairo, 0, -0.5*
object.height());
break;
54 cairo_rel_move_to(cairo, -
object.width(), 0);
break;
58 cairo_rel_move_to(cairo, -
object.width(), -
object.height());
break;
60 cairo_rel_move_to(cairo, 0, -
object.height());
break;
66 double print(cairo_t* cairo,
const string& text,
Anchor anchor)
70 const CairoSave cs(cairo);
71 pango.setMarkup(text);
75 cairo_rel_move_to(cairo, pango.width(), 0);
76 return pango.height();
82 (CAIRO_CONTENT_COLOR, nullptr))
83 {cairo_move_to(cairo(),0,0);}
88 double parenthesise(Surface& s, X x,
const string& left=
"(",
const string& right=
")")
91 cairo_get_current_point(
s.cairo(),&xx,&yy);
95 Pango pango(
s.cairo());
96 const double oldFs=pango.getFontSize();
97 pango.setFontSize(r.height());
98 pango.setMarkup(left);
99 cairo_rel_move_to(
s.cairo(),0,-(r.height()-oldFs));
101 cairo_rel_move_to(
s.cairo(),0,(r.height()-oldFs));
102 cairo_rel_move_to(
s.cairo(),pango.width(),0);
105 xx+=pango.width()+r.width();
106 pango.setMarkup(right);
107 cairo_move_to(
s.cairo(),xx,yy-r.height()+oldFs);
109 cairo_move_to(
s.cairo(),xx+pango.width(),yy);
114 void naryRender(Surface& dest,
const vector<WeakNodePtr>& arglist,
int BODMASlevel,
const char*
op,
const char *empty)
117 print(dest.cairo(),empty,Anchor::nw);
119 for (
size_t j=0; j<arglist.size(); j++)
121 if (arglist[j]->BODMASlevel()>BODMASlevel)
122 parenthesise(dest, [&](Surface& dest) {arglist[j]->render(dest);});
124 arglist[j]->render(dest);
125 if (j!=arglist.size()-1)
126 print(dest.cairo(),
op,Anchor::nw);
141 void SystemOfEquations::renderEquations(Surface& dest,
double height)
const 144 cairo_get_current_point(dest.cairo(),&x,&y);
145 const double origin=-y;
146 Pango den(dest.cairo());
149 const double fontHeight=30;
150 const int baseEqn=origin/fontHeight;
155 if (dynamic_cast<const IntegralInputVariableDAG*>(i))
continue;
156 if (!i || i->type==VariableType::constant)
continue;
157 if (eqnNo++ < baseEqn)
continue;
158 RecordingSurface line;
160 cairo_move_to(dest.cairo(), x, y-line.top());
163 cairo_move_to(dest.cairo(), x, y);
164 if (y>height)
return;
169 if (eqnNo++ < baseEqn)
continue;
171 cairo_move_to(dest.cairo(), x, y);
176 Pango num(dest.cairo());
178 double lineSpacing=num.height()+den.height()+2;
183 RecordingSurface rhs;
184 input->rhs->render(rhs);
185 lineSpacing = max(rhs.height(), lineSpacing);
189 const double eqY=y+max(num.height(), 0.5*lineSpacing);
191 cairo_move_to(dest.cairo(), x, eqY-num.height());
193 cairo_move_to(dest.cairo(), x, eqY);
194 const double solidusLength = max(num.width(),den.width());
195 cairo_rel_line_to(dest.cairo(), solidusLength, 0);
196 cairo_stroke(dest.cairo());
197 cairo_move_to(dest.cairo(), x+solidusLength, eqY);
201 print(dest.cairo(),
" = ", Anchor::w);
202 input->rhs->render(dest);
205 print(dest.cairo(),
" = 0", Anchor::w);
206 cairo_move_to(dest.cairo(), x+0.5*(num.width()-den.width()), eqY);
208 cairo_move_to(dest.cairo(), x, y+=lineSpacing);
210 if (y>height)
return;
214 void ConstantDAG::render(ecolab::cairo::Surface& surf)
const 219 void VariableDAG::render(ecolab::cairo::Surface& surf)
const 224 void LockDAG::render(ecolab::cairo::Surface& surf)
const 226 print(surf.cairo(),
"locked", Anchor::nw);
233 assert(!
"constant deprecated");
239 for (
size_t i=0; i<arguments.size(); ++i)
241 naryRender(surf, arguments[i], BODMASlevel(),
" + ",
"0");
242 if (i!=arguments.size()-1)
print(surf.cairo(),
" + ",Anchor::nw);
249 if (!arguments.empty())
250 naryRender(surf, arguments[0], BODMASlevel(),
" + ",
"0");
251 if (arguments.size()>1)
253 print(surf.cairo(),
" - ",Anchor::nw);
254 if (arguments[1].size()>1 ||
255 (!arguments[1].empty() && BODMASlevel() == arguments[1][0]->BODMASlevel()))
258 naryRender(surf, arguments[1], BODMASlevel(),
" + ",
"0");
265 for (
size_t i=0; i<arguments.size(); ++i)
267 naryRender(surf,arguments[i], BODMASlevel(),
" × ",
"1");
268 if (i!=arguments.size()-1)
print(surf.cairo(),
" × ",Anchor::nw);
275 RecordingSurface num, den;
276 if (!arguments.empty())
277 naryRender(num, arguments[0], BODMASlevel(),
" × ",
"1");
279 if (arguments.size()>1)
281 naryRender(den, arguments[1], BODMASlevel(),
" × ",
"1");
282 if (!arguments[1].empty())
285 cairo_get_current_point(surf.cairo(),&x,&y);
287 const double solidusLength = std::max(num.width(),den.width());
289 cairo_move_to(surf.cairo(), x+0.5*(solidusLength-num.width()), y-num.height());
290 naryRender(surf, arguments[0], BODMASlevel(),
" × ",
"1");
291 cairo_move_to(surf.cairo(), x+0.5*(solidusLength-den.width()), y+0.5*num.height()+5);
292 naryRender(surf, arguments[1], BODMASlevel(),
" × ",
"1");
294 cairo_move_to(surf.cairo(), x, y+0.5*num.height()+5);
295 cairo_rel_line_to(surf.cairo(), solidusLength, 0);
297 const CairoSave cs(surf.cairo());
298 cairo_set_line_width(surf.cairo(),1);
299 cairo_stroke(surf.cairo());
301 cairo_move_to(surf.cairo(),x+solidusLength,y);
304 naryRender(surf, arguments[0], BODMASlevel(),
" × ",
"1");
307 naryRender(surf, arguments[0], BODMASlevel(),
" × ",
"1");
313 if (arguments.empty() || arguments[0].empty() || !arguments[0][0])
314 print(surf.cairo(),
"<i>0</i>",Anchor::nw);
317 if (arguments.size()>1 && !arguments[1].empty() && arguments[1][0])
319 const double h=
print(surf.cairo(),
"log",Anchor::nw);
320 cairo_rel_move_to(surf.cairo(), 0, 0.5*h);
321 arguments[1][0]->render(surf);
322 cairo_rel_move_to(surf.cairo(), 0, -0.5*h);
325 print(surf.cairo(),
"ln",Anchor::nw);
326 arguments[0][0]->render(surf);
334 if (arguments.empty() || arguments[0].empty() || !arguments[0][0])
335 print(surf.cairo(),
"(0,0)",Anchor::nw);
338 arguments[0][0]->render(surf);
339 print(surf.cairo(),
",",Anchor::nw);
340 if (arguments.size()>1 && !arguments[1].empty() && arguments[1][0])
341 arguments[1][0]->render(surf);
343 print(surf.cairo(),
"0",Anchor::nw);
350 if (arguments.empty() || arguments[0].empty() || !arguments[0][0])
351 print(surf.cairo(),
"<i>0</i>",Anchor::nw);
354 if (arguments.size()>1 && !arguments[1].empty() && arguments[1][0])
356 if (arguments[0][0]->BODMASlevel()>BODMASlevel())
357 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
359 arguments[0][0]->render(surf);
361 RecordingSurface base;
362 arguments[0][0]->render(base);
363 cairo_rel_move_to(surf.cairo(), 0, -0.5*base.height());
364 arguments[1][0]->render(surf);
365 cairo_rel_move_to(surf.cairo(), 0, 0.5*base.height());
368 print(surf.cairo(),
"<i>1</i>",Anchor::nw);
376 {
print(surf.cairo(),
"<i>t</i>",Anchor::nw);}
379 {
print(surf.cairo(),
"<i>e</i>",Anchor::nw);}
382 {
print(surf.cairo(),
"<i>π</i>",Anchor::nw);}
385 {
print(surf.cairo(),
"<i>0</i>",Anchor::nw);}
388 {
print(surf.cairo(),
"<i>1</i>",Anchor::nw);}
391 {
print(surf.cairo(),
"<i>∞</i>",Anchor::nw);}
396 cairo_get_current_point(s.cairo(),&xx,&yy);
399 arguments[0][0]->
render(r);
401 Pango pango(s.cairo());
402 const double oldFs=pango.getFontSize();
403 pango.setFontSize(r.height());
404 cairo_rel_move_to(s.cairo(),0,-(r.height()-oldFs));
406 cairo_rel_move_to(s.cairo(),0,(r.height()-oldFs));
407 cairo_rel_move_to(s.cairo(),pango.width(),0);
408 arguments[0][0]->render(s);
409 xx+=pango.width()+r.width();
410 pango.setMarkup(
"%");
411 cairo_move_to(s.cairo(),xx,yy-r.height()+oldFs);
413 cairo_move_to(s.cairo(),xx+pango.width(),yy);
417 {
print(surf.cairo(),
"=",Anchor::nw);}
420 {
throw error(
"should not be rendering integration operations");}
428 {
throw error(
"should not be rendering differentiation operations");}
432 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
434 RecordingSurface arg;
435 arguments[0][0]->
render(arg);
438 Pango pango(surf.cairo());
440 const CairoSave cs(surf.cairo());
441 const double oldFs=pango.getFontSize();
442 pango.setFontSize(arg.height());
443 pango.setMarkup(
"√");
444 cairo_rel_move_to(surf.cairo(),0,oldFs-arg.height());
447 cairo_rel_move_to(surf.cairo(),pango.width(),0);
450 cairo_get_current_point(surf.cairo(),&x,&y);
452 const CairoSave cs(surf.cairo());
453 cairo_rel_line_to(surf.cairo(),arg.width(),0);
454 cairo_set_line_width(surf.cairo(),1);
455 cairo_stroke(surf.cairo());
458 cairo_move_to(surf.cairo(),x,y-arg.top()+2);
459 arguments[0][0]->render(surf);
465 if (
auto d=dynamic_cast<const minsky::DataOp*>(state.get()))
469 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
470 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
475 if (
auto d=dynamic_cast<const minsky::DataOp*>(state.get()))
479 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
480 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
485 print(surf.cairo(),
"exp",Anchor::nw);
486 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
487 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
492 print(surf.cairo(),
"ln",Anchor::nw);
493 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
494 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
499 print(surf.cairo(),
"sin",Anchor::nw);
500 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
501 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
506 print(surf.cairo(),
"cos",Anchor::nw);
507 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
508 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
513 print(surf.cairo(),
"tan",Anchor::nw);
514 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
515 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
520 print(surf.cairo(),
"sin<sup>-1</sup>",Anchor::nw);
521 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
522 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
527 print(surf.cairo(),
"cos<small><sup>-1</sup></small>",Anchor::nw);
528 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
529 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
534 print(surf.cairo(),
"tan<small><sup>-1</sup></small>",Anchor::nw);
535 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
536 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
541 print(surf.cairo(),
"sinh",Anchor::nw);
542 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
543 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
548 print(surf.cairo(),
"cosh",Anchor::nw);
549 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
550 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
555 print(surf.cairo(),
"tanh",Anchor::nw);
556 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
557 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
564 cairo_get_current_point(s.cairo(),&xx,&yy);
567 arguments[0][0]->
render(r);
569 Pango pango(s.cairo());
570 const double oldFs=pango.getFontSize();
571 pango.setFontSize(r.height());
572 pango.setMarkup(
"|");
573 cairo_rel_move_to(s.cairo(),0,-(r.height()-oldFs));
575 cairo_rel_move_to(s.cairo(),0,(r.height()-oldFs));
576 cairo_rel_move_to(s.cairo(),pango.width(),0);
577 arguments[0][0]->render(s);
578 xx+=pango.width()+r.width();
579 pango.setMarkup(
"|");
580 cairo_move_to(s.cairo(),xx,yy-r.height()+oldFs);
582 cairo_move_to(s.cairo(),xx+pango.width(),yy);
589 cairo_get_current_point(s.cairo(),&xx,&yy);
592 arguments[0][0]->
render(r);
594 Pango pango(s.cairo());
595 const double oldFs=pango.getFontSize();
596 pango.setFontSize(r.height());
597 pango.setMarkup(
"⌊");
598 cairo_rel_move_to(s.cairo(),0,-(r.height()-oldFs));
600 cairo_rel_move_to(s.cairo(),0,(r.height()-oldFs));
601 cairo_rel_move_to(s.cairo(),pango.width(),0);
602 arguments[0][0]->render(s);
603 xx+=pango.width()+r.width();
604 pango.setMarkup(
"⌋");
605 cairo_move_to(s.cairo(),xx,yy-r.height()+oldFs);
607 cairo_move_to(s.cairo(),xx+pango.width(),yy);
613 print(surf.cairo(),
"frac",Anchor::nw);
614 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
615 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
621 print(surf.cairo(),
"Γ",Anchor::nw);
622 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
623 {
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});}
629 print(surf.cairo(),
"ψ",Anchor::nw);
630 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
632 if (arguments.size()>1 && !arguments[1].empty() && arguments[1][0])
634 RecordingSurface base;
635 arguments[1][0]->render(base);
636 cairo_rel_move_to(surf.cairo(), 0, -0.5*base.height());
637 parenthesise(surf, [&](Surface& surf){arguments[1][0]->render(surf);});
638 arguments[0][0]->render(base);
639 cairo_rel_move_to(surf.cairo(), 0, 0.5*base.height());
640 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
643 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
651 cairo_get_current_point(s.cairo(),&xx,&yy);
654 arguments[0][0]->
render(r);
656 Pango pango(s.cairo());
657 const double oldFs=pango.getFontSize();
658 pango.setFontSize(r.height());
659 cairo_rel_move_to(s.cairo(),0,-(r.height()-oldFs));
661 cairo_rel_move_to(s.cairo(),0,(r.height()-oldFs));
662 cairo_rel_move_to(s.cairo(),pango.width(),0);
663 arguments[0][0]->render(s);
664 xx+=pango.width()+r.width();
665 pango.setMarkup(
"!");
666 cairo_move_to(s.cairo(),xx,yy-r.height()+oldFs);
668 cairo_move_to(s.cairo(),xx+pango.width(),yy);
674 print(surf.cairo(),
"∑<sub>i</sub>",Anchor::nw);
675 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
677 const double h=
parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
678 cairo_rel_move_to(surf.cairo(), 0, 0.5*h);
679 print(surf.cairo(),
"<sub>i</sub>",Anchor::nw);
680 cairo_rel_move_to(surf.cairo(), 0, -0.5*h);
687 print(surf.cairo(),
"∏<sub>i</sub>",Anchor::nw);
688 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
690 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
691 print(surf.cairo(),
"<sub>i</sub>",Anchor::nw);
698 print(surf.cairo(),
"min<sub>i</sub>",Anchor::nw);
699 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
701 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
702 print(surf.cairo(),
"<sub>i</sub>",Anchor::nw);
709 print(surf.cairo(),
"min<sub>i</sub>",Anchor::nw);
710 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
712 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
713 print(surf.cairo(),
"<sub>i</sub>",Anchor::nw);
720 print(surf.cairo(),
"indexOf",Anchor::nw);
727 print(surf.cairo(),
"indexOf",Anchor::nw);
734 print(surf.cairo(),
"Θ(max<sub>i</sub>",Anchor::nw);
735 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
737 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
738 print(surf.cairo(),
"<sub>i</sub>>0.5)",Anchor::nw);
745 print(surf.cairo(),
"∏<sub>i</sub>Θ(",Anchor::nw);
746 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
748 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
749 print(surf.cairo(),
"<sub>i</sub>>0.5)",Anchor::nw);
756 print(surf.cairo(),
"∑<sub>j=0</sub><sup>i</sup>",Anchor::nw);
757 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
759 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
760 print(surf.cairo(),
"<sub>i</sub>",Anchor::nw);
767 print(surf.cairo(),
"∏<sub>j=0</sub><sup>i</sup>",Anchor::nw);
768 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
770 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
771 print(surf.cairo(),
"<sub>i</sub>",Anchor::nw);
778 print(surf.cairo(),
"Δ⁻ᵢ",Anchor::nw);
779 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
781 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
782 print(surf.cairo(),
"<sub>i</sub>",Anchor::nw);
789 print(surf.cairo(),
"Δ⁺ᵢ",Anchor::nw);
790 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
792 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
793 print(surf.cairo(),
"<sub>i</sub>",Anchor::nw);
800 print(surf.cairo(),
"index",Anchor::nw);
801 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
803 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
810 if (!arguments.empty())
812 if (!arguments[1].empty() && arguments[1][0])
813 if (!arguments[0].empty() && arguments[0][0])
815 print(surf.cairo(),
"θ",Anchor::nw);
817 arguments[1][0]->render(surf);
818 print(surf.cairo(),
" - ",Anchor::nw);
819 if (arguments[0][0]->BODMASlevel()>1)
821 arguments[0][0]->render(surf);
824 arguments[0][0]->render(surf);
829 print(surf.cairo(),
"θ",Anchor::nw);
830 parenthesise(surf, [&](Surface& surf){arguments[1][0]->render(surf);});
833 if (!arguments[0].empty() && arguments[0][0])
835 print(surf.cairo(),
"θ",Anchor::nw);
837 print(surf.cairo(),
" - ",Anchor::nw);
838 if (arguments[0][0]->BODMASlevel()>1)
840 arguments[0][0]->render(surf);
843 arguments[0][0]->render(surf);
847 print(surf.cairo(),
"0",Anchor::nw);
850 print(surf.cairo(),
"0",Anchor::nw);
856 if (!arguments.empty())
858 if (!arguments[1].empty() && arguments[1][0])
859 if (!arguments[0].empty() && arguments[0][0])
861 print(surf.cairo(),
"δ",Anchor::nw);
863 arguments[0][0]->render(surf);
864 print(surf.cairo(),
" - ",Anchor::nw);
865 arguments[1][0]->render(surf);
870 print(surf.cairo(),
"δ",Anchor::nw);
871 parenthesise(surf, [&](Surface& surf){arguments[1][0]->render(surf);});
874 if (!arguments[0].empty() && arguments[0][0])
876 print(surf.cairo(),
"δ",Anchor::nw);
877 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
880 print(surf.cairo(),
"1",Anchor::nw);
883 print(surf.cairo(),
"1",Anchor::nw);
889 if ((!arguments.empty() && !arguments[0].empty() && arguments[0][0]) ||
890 (arguments.size()>1 && !arguments[1].empty() && arguments[1][0]))
895 print(surf.cairo(),
"+",Anchor::nw);
899 print(surf.cairo(),
"1",Anchor::nw);
906 if (!arguments.empty())
908 print(surf.cairo(),
"min",Anchor::nw);
910 naryRender(surf,arguments[0],BODMASlevel(),
",",
"∞");
911 if (!arguments[1].empty())
913 print(surf.cairo(),
",",Anchor::nw);
914 naryRender(surf,arguments[1],BODMASlevel(),
",",
"∞");
919 print(surf.cairo(),
"∞",Anchor::nw);
925 if (!arguments.empty())
927 print(surf.cairo(),
"max",Anchor::nw);
929 naryRender(surf,arguments[0],BODMASlevel(),
",",
"-∞");
930 if (!arguments[1].empty())
932 print(surf.cairo(),
",",Anchor::nw);
933 naryRender(surf,arguments[1],BODMASlevel(),
",",
"-∞");
938 print(surf.cairo(),
"-∞",Anchor::nw);
944 if (!arguments.empty())
946 naryRender(surf,arguments[0],BODMASlevel(),
"∧",
"1");
947 if (!arguments[1].empty())
949 print(surf.cairo(),
"∧",Anchor::nw);
950 naryRender(surf,arguments[0],BODMASlevel(),
"∧",
"1");
954 print(surf.cairo(),
"1",Anchor::nw);
961 if (!arguments.empty())
963 naryRender(surf,arguments[0],BODMASlevel(),
"∨",
"0");
964 if (!arguments[1].empty())
966 print(surf.cairo(),
"∨",Anchor::nw);
967 naryRender(surf,arguments[0],BODMASlevel(),
"∨",
"0");
971 print(surf.cairo(),
"0",Anchor::nw);
977 if (!arguments.empty())
979 if (!arguments[0].empty() && arguments[0][0])
981 print(surf.cairo(),
"¬",Anchor::nw);
983 arguments[0][0]->render(surf);
987 print(surf.cairo(),
"0",Anchor::nw);
994 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0] &&
995 arguments.size()>1 && !arguments[1].empty() && arguments[1][0])
997 print(surf.cairo(),
"cov",Anchor::nw);
999 arguments[0][0]->render(surf);
1000 print(surf.cairo(),
",",Anchor::nw);
1001 arguments[0][1]->render(surf);
1005 print(surf.cairo(),
"0",Anchor::nw);
1011 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0] &&
1012 arguments.size()>1 && !arguments[1].empty() && arguments[1][0])
1014 print(surf.cairo(),
"ρ",Anchor::nw);
1016 arguments[0][0]->render(surf);
1017 print(surf.cairo(),
",",Anchor::nw);
1018 arguments[0][1]->render(surf);
1022 print(surf.cairo(),
"0",Anchor::nw);
1028 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0] &&
1029 arguments.size()>1 && !arguments[1].empty() && arguments[1][0])
1031 print(surf.cairo(),
"linReg",Anchor::nw);
1033 arguments[0][0]->render(surf);
1034 print(surf.cairo(),
",",Anchor::nw);
1035 arguments[0][1]->render(surf);
1039 print(surf.cairo(),
"0",Anchor::nw);
1045 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
1047 print(surf.cairo(),
"dim",Anchor::nw);
1049 arguments[0][0]->render(surf);
1050 print(surf.cairo(),
",i",Anchor::nw);
1054 print(surf.cairo(),
"0",Anchor::nw);
1060 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
1062 print(surf.cairo(),
"shape",Anchor::nw);
1063 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
1066 print(surf.cairo(),
"0",Anchor::nw);
1072 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
1074 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);},
"<",
">");
1077 print(surf.cairo(),
"0",Anchor::nw);
1083 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
1085 print(surf.cairo(),
"median",Anchor::nw);
1086 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
1089 print(surf.cairo(),
"0",Anchor::nw);
1095 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
1097 print(surf.cairo(),
"σ",Anchor::nw);
1098 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
1101 print(surf.cairo(),
"0",Anchor::nw);
1107 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
1110 print(surf.cairo(),
"Δ",Anchor::nw);
1111 parenthesise(surf,[&](Surface& surf){arguments[0][0]->render(surf);});
1113 RecordingSurface base;
1114 arguments[0][0]->render(base);
1115 cairo_rel_move_to(surf.cairo(), 0, -0.5*base.height());
1116 print(surf.cairo(),
"k",Anchor::nw);
1117 cairo_rel_move_to(surf.cairo(), 0, 0.5*base.height());
1121 print(surf.cairo(),
"0",Anchor::nw);
1127 if (!arguments.empty() && !arguments[0].empty() && arguments[0][0])
1129 print(surf.cairo(),
"histogram",Anchor::nw);
1130 parenthesise(surf, [&](Surface& surf){arguments[0][0]->render(surf);});
1133 print(surf.cairo(),
"0",Anchor::nw);
1141 if (arguments.size()<2 || arguments[0].empty() || arguments[1].empty())
1142 throw error(
"incorrectly wired");
1144 arguments[0][0]->render(surf);
1146 print(surf.cairo(),
"·",Anchor::nw);
1148 arguments[1][0]->render(surf);
1155 if (arguments.size()<2 || arguments[0].empty() || arguments[1].empty())
1156 throw error(
"incorrectly wired");
1158 arguments[0][0]->render(surf);
1160 print(surf.cairo(),
"⊗",Anchor::nw);
1162 arguments[1][0]->render(surf);
1169 if (arguments.size()<2 || arguments[0].empty() || arguments[1].empty())
1170 throw error(
"incorrectly wired");
1172 arguments[0][0]->render(surf);});
1174 arguments[1][0]->render(surf);},
"[",
"]");
1180 if (arguments.size()<2 || arguments[0].empty() || arguments[1].empty())
1181 throw error(
"incorrectly wired");
1182 print(surf.cairo(),
"meld",Anchor::nw);
1184 for (
size_t i=0; i<arguments.size(); ++i)
1186 naryRender(surf, arguments[i], BODMASlevel(),
"",
"");
1187 if (i!=arguments.size()-1)
print(surf.cairo(),
",",Anchor::nw);
1195 if (arguments.size()<2 || arguments[0].empty() || arguments[1].empty())
1196 throw error(
"incorrectly wired");
1197 print(surf.cairo(),
"merge",Anchor::nw);
1199 for (
size_t i=0; i<arguments.size(); ++i)
1201 naryRender(surf, arguments[i], BODMASlevel(),
"",
"");
1202 if (i!=arguments.size()-1)
print(surf.cairo(),
",",Anchor::nw);
1210 if (arguments.empty() || arguments[0].empty())
1211 throw error(
"incorrectly wired");
1212 print(surf.cairo(),
"slice",Anchor::nw);
1214 arguments[0][0]->render(surf);
1215 print(surf.cairo(),
",",Anchor::nw);
1218 if (
auto o=state->operationCast())
1220 print(surf.cairo(),slice,Anchor::nw);
std::string description(const std::string &) override
name of the associated data operation
void variableRender(Surface &surf, const VariableDAG &v)
std::string latexToPango(const char *s)
double parenthesise(Surface &s, X x, const string &left="(", const string &right=")")
void naryRender(Surface &dest, const vector< WeakNodePtr > &arglist, int BODMASlevel, const char *op, const char *empty)
string latexInit(const string &)
convert an initialisation string into a matlab expression
virtual void render(ecolab::cairo::Surface &surf) const =0
renders a visual representation of this node to surf graphic extends right from the current pen posit...
void moveToAnchor(cairo_t *cairo, const T &object, Anchor anchor)
double print(cairo_t *cairo, const string &text, Anchor anchor)
vector< vector< WeakNodePtr > > arguments
string to_string(CONST84 char *x)
shared_ptr< VariableDAG > VariableDAGPtr
void render(ecolab::cairo::Surface &surf) const override
renders a visual representation of this node to surf graphic extends right from the current pen posit...
string mathrm(const string &nm)
wraps in if nm has more than one letter - and also takes into account LaTeX subscript/superscripts ...