2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
* \file InsetMathExFunc.cpp
|
2003-08-19 13:00:56 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2001-12-05 08:04:20 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathExFunc.h"
|
2007-11-05 23:46:17 +00:00
|
|
|
|
2007-04-26 16:05:57 +00:00
|
|
|
#include "MathData.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
#include "MathStream.h"
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "MathSupport.h"
|
2007-11-05 23:46:17 +00:00
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
|
|
|
#include "support/docstream.h"
|
2001-11-07 13:15:59 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2001-11-07 13:15:59 +00:00
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathExFunc::InsetMathExFunc(Buffer * buf, docstring const & name)
|
|
|
|
: InsetMathNest(buf, 1), name_(name)
|
2001-11-13 18:33:48 +00:00
|
|
|
{}
|
2001-11-07 13:15:59 +00:00
|
|
|
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathExFunc::InsetMathExFunc(Buffer * buf, docstring const & name, MathData const & ar)
|
|
|
|
: InsetMathNest(buf, 1), name_(name)
|
2002-06-25 13:19:50 +00:00
|
|
|
{
|
|
|
|
cell(0) = ar;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
Inset * InsetMathExFunc::clone() const
|
2001-11-07 13:15:59 +00:00
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
return new InsetMathExFunc(*this);
|
2001-11-07 13:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-11-07 13:15:59 +00:00
|
|
|
{
|
2006-11-28 15:15:49 +00:00
|
|
|
mathed_string_dim(mi.base.font, name_, dim);
|
2001-11-09 12:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExFunc::draw(PainterInfo & pi, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
drawStrBlack(pi, x, y, name_);
|
2001-11-07 13:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
docstring InsetMathExFunc::name() const
|
2001-11-07 13:15:59 +00:00
|
|
|
{
|
2002-08-05 07:09:11 +00:00
|
|
|
return name_;
|
2001-11-07 13:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExFunc::maple(MapleStream & os) const
|
2001-11-07 13:15:59 +00:00
|
|
|
{
|
2002-06-25 13:49:29 +00:00
|
|
|
if (name_ == "det")
|
|
|
|
os << "linalg[det](" << cell(0) << ')';
|
|
|
|
else
|
|
|
|
os << name_ << '(' << cell(0) << ')';
|
2001-11-07 13:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExFunc::maxima(MaximaStream & os) const
|
2002-10-28 17:15:19 +00:00
|
|
|
{
|
|
|
|
if (name_ == "det")
|
|
|
|
os << "determinant(" << cell(0) << ')';
|
|
|
|
else
|
|
|
|
os << name_ << '(' << cell(0) << ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
static string asMathematicaName(string const & name)
|
2002-07-01 11:17:14 +00:00
|
|
|
{
|
|
|
|
if (name == "sin") return "Sin";
|
|
|
|
if (name == "sinh") return "Sinh";
|
|
|
|
if (name == "arcsin") return "ArcSin";
|
2006-09-02 01:57:36 +00:00
|
|
|
if (name == "asin") return "ArcSin";
|
2002-07-01 11:17:14 +00:00
|
|
|
if (name == "cos") return "Cos";
|
|
|
|
if (name == "cosh") return "Cosh";
|
2006-09-02 01:57:36 +00:00
|
|
|
if (name == "arccos") return "ArcCos";
|
|
|
|
if (name == "acos") return "ArcCos";
|
2002-07-01 11:17:14 +00:00
|
|
|
if (name == "tan") return "Tan";
|
|
|
|
if (name == "tanh") return "Tanh";
|
|
|
|
if (name == "arctan") return "ArcTan";
|
2006-09-02 01:57:36 +00:00
|
|
|
if (name == "atan") return "ArcTan";
|
2002-07-01 11:17:14 +00:00
|
|
|
if (name == "cot") return "Cot";
|
|
|
|
if (name == "coth") return "Coth";
|
|
|
|
if (name == "csc") return "Csc";
|
|
|
|
if (name == "sec") return "Sec";
|
|
|
|
if (name == "exp") return "Exp";
|
|
|
|
if (name == "log") return "Log";
|
|
|
|
if (name == "ln" ) return "Log";
|
2006-09-02 01:57:36 +00:00
|
|
|
if (name == "arg" ) return "Arg";
|
|
|
|
if (name == "det" ) return "Det";
|
|
|
|
if (name == "gcd" ) return "GCD";
|
|
|
|
if (name == "max" ) return "Max";
|
|
|
|
if (name == "min" ) return "Min";
|
|
|
|
if (name == "erf" ) return "Erf";
|
|
|
|
if (name == "erfc" ) return "Erfc";
|
2002-07-01 11:17:14 +00:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
static docstring asMathematicaName(docstring const & name)
|
|
|
|
{
|
|
|
|
return from_utf8(asMathematicaName(to_utf8(name)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExFunc::mathematica(MathematicaStream & os) const
|
2002-07-01 11:17:14 +00:00
|
|
|
{
|
|
|
|
os << asMathematicaName(name_) << '[' << cell(0) << ']';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 15:46:39 +00:00
|
|
|
void InsetMathExFunc::mathmlize(MathStream & os) const
|
2001-11-09 12:01:10 +00:00
|
|
|
{
|
2009-12-16 15:12:34 +00:00
|
|
|
os << "<mi>" << name_ << "</mi><mo>⁡</mo>";
|
2009-12-31 15:46:39 +00:00
|
|
|
os << cell(0);
|
2001-11-07 13:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathExFunc::octave(OctaveStream & os) const
|
2001-11-07 13:15:59 +00:00
|
|
|
{
|
2001-12-05 08:04:20 +00:00
|
|
|
os << name_ << '(' << cell(0) << ')';
|
2001-11-07 13:15:59 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|