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.
|
|
|
|
|
*
|
|
|
|
|
* \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"
|
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 "MathStream.h"
|
|
|
|
|
#include "MathSupport.h"
|
2001-11-07 13:15:59 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2006-10-21 11:15:37 +00:00
|
|
|
|
using std::vector;
|
2006-10-22 10:15:23 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
|
2001-11-07 13:15:59 +00:00
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
InsetMathExFunc::InsetMathExFunc(docstring const & name)
|
2006-09-16 18:11:38 +00:00
|
|
|
|
: InsetMathNest(1), name_(name)
|
2001-11-13 18:33:48 +00:00
|
|
|
|
{}
|
2001-11-07 13:15:59 +00:00
|
|
|
|
|
|
|
|
|
|
2007-04-26 16:05:57 +00:00
|
|
|
|
InsetMathExFunc::InsetMathExFunc(docstring const & name, MathData const & ar)
|
2006-09-16 18:11:38 +00:00
|
|
|
|
: InsetMathNest(1), name_(name)
|
2002-06-25 13:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
cell(0) = ar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
auto_ptr<Inset> InsetMathExFunc::doClone() const
|
2001-11-07 13:15:59 +00:00
|
|
|
|
{
|
2007-04-29 13:39:47 +00:00
|
|
|
|
return auto_ptr<Inset>(new InsetMathExFunc(*this));
|
2001-11-07 13:15:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool 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);
|
|
|
|
|
if (dim_ == dim)
|
|
|
|
|
return false;
|
|
|
|
|
dim_ = dim;
|
|
|
|
|
return true;
|
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) << ']';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void InsetMathExFunc::mathmlize(MathStream & 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
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|