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