2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
|
* \file InsetMathExFunc.C
|
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.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* 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"
|
|
|
|
|
#include "MathData.h"
|
|
|
|
|
#include "MathMLStream.h"
|
|
|
|
|
#include "MathStream.h"
|
|
|
|
|
#include "MathSupport.h"
|
2001-11-07 13:15:59 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
|
2001-11-07 13:15:59 +00:00
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathExFunc::InsetMathExFunc(string const & name)
|
|
|
|
|
: InsetMathNest(1), name_(name)
|
2001-11-13 18:33:48 +00:00
|
|
|
|
{}
|
2001-11-07 13:15:59 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathExFunc::InsetMathExFunc(string const & name, MathArray const & ar)
|
|
|
|
|
: InsetMathNest(1), name_(name)
|
2002-06-25 13:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
cell(0) = ar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetMathExFunc::doClone() const
|
2001-11-07 13:15:59 +00:00
|
|
|
|
{
|
2006-09-16 18:11:38 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetMathExFunc(*this));
|
2001-11-07 13:15:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & /*dim*/) const
|
2001-11-07 13:15:59 +00:00
|
|
|
|
{
|
2006-10-17 14:46:45 +00:00
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
mathed_string_dim(mi.base.font, lyx::from_utf8(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-17 14:46:45 +00:00
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
drawStrBlack(pi, x, y, lyx::from_utf8(name_));
|
2001-11-07 13:15:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
string 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) << ')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-01 11:17:14 +00:00
|
|
|
|
string asMathematicaName(string const & name)
|
|
|
|
|
{
|
|
|
|
|
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-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) << ']';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathExFunc::mathmlize(MathMLStream & os) const
|
2001-11-09 12:01:10 +00:00
|
|
|
|
{
|
|
|
|
|
os << MTag(name_.c_str()) << cell(0) << ETag(name_.c_str());
|
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
|
|
|
|
}
|