]> git.lyx.org Git - lyx.git/blob - src/mathed/math_exfuncinset.C
Geof Piroux's patch for Mathematica support
[lyx.git] / src / mathed / math_exfuncinset.C
1 #include <config.h>
2
3 #include "math_exfuncinset.h"
4 #include "math_support.h"
5 #include "math_mathmlstream.h"
6 #include "math_streamstr.h"
7
8
9 MathExFuncInset::MathExFuncInset(string const & name)
10         : MathNestInset(1), name_(name)
11 {}
12
13
14 MathExFuncInset::MathExFuncInset(string const & name, MathArray const & ar)
15         : MathNestInset(1), name_(name)
16 {
17         cell(0) = ar;
18 }
19
20
21 MathInset * MathExFuncInset::clone() const
22 {
23         return new MathExFuncInset(*this);
24 }
25
26
27 void MathExFuncInset::metrics(MathMetricsInfo & mi) const
28 {
29         mathed_string_dim(mi.base.font, name_, ascent_, descent_, width_);
30 }
31
32
33 void MathExFuncInset::draw(MathPainterInfo & pi, int x, int y) const
34 {
35         drawStrBlack(pi, x, y, name_);
36 }
37
38
39 void MathExFuncInset::normalize(NormalStream & os) const
40 {
41         os << '[' << name_ << ' ' << cell(0) << ']';
42 }
43
44
45 void MathExFuncInset::maplize(MapleStream & os) const
46 {
47         if (name_ == "det")
48                 os << "linalg[det](" << cell(0) << ')';
49         else
50                 os << name_ << '(' << cell(0) << ')';
51 }
52
53
54 string asMathematicaName(string const & name)
55 {
56         if (name == "sin")    return "Sin";
57         if (name == "sinh")   return "Sinh";
58         if (name == "arcsin") return "ArcSin";
59         if (name == "cos")    return "Cos";
60         if (name == "cosh")   return "Cosh";
61         if (name == "arcos")  return "ArcCos";
62         if (name == "tan")    return "Tan";
63         if (name == "tanh")   return "Tanh";
64         if (name == "arctan") return "ArcTan";
65         if (name == "cot")    return "Cot";
66         if (name == "coth")   return "Coth";
67         if (name == "csc")    return "Csc";
68         if (name == "sec")    return "Sec";
69         if (name == "exp")    return "Exp";
70         if (name == "log")    return "Log";
71         if (name == "ln" )    return "Log";
72         return name;
73 }
74
75
76 void MathExFuncInset::mathematicize(MathematicaStream & os) const
77 {
78         os << asMathematicaName(name_) << '[' << cell(0) << ']';
79 }
80
81
82 void MathExFuncInset::mathmlize(MathMLStream & os) const
83 {
84         os << MTag(name_.c_str()) << cell(0) << ETag(name_.c_str());
85 }
86
87
88 void MathExFuncInset::octavize(OctaveStream & os) const
89 {
90         os << name_ << '(' << cell(0) << ')';
91 }
92
93
94 void MathExFuncInset::write(WriteStream & os) const
95 {
96         os << '\\' << name_ << '{' << cell(0) << '}';
97 }