2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_exintinset.C
|
|
|
|
|
* 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>
|
|
|
|
|
|
2001-11-09 14:48:57 +00:00
|
|
|
|
#include "math_exintinset.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_data.h"
|
2001-11-09 14:48:57 +00:00
|
|
|
|
#include "math_mathmlstream.h"
|
2001-12-05 08:04:20 +00:00
|
|
|
|
#include "math_streamstr.h"
|
2001-11-09 14:48:57 +00:00
|
|
|
|
#include "math_symbolinset.h"
|
2001-11-13 16:27:06 +00:00
|
|
|
|
#include "debug.h"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2003-09-16 09:01:15 +00:00
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2001-11-09 14:48:57 +00:00
|
|
|
|
|
2001-12-18 03:16:46 +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;
|
2003-08-02 11:30:30 +00:00
|
|
|
|
using std::endl;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
|
2001-11-09 14:48:57 +00:00
|
|
|
|
|
2001-11-12 14:37:43 +00:00
|
|
|
|
MathExIntInset::MathExIntInset(string const & name)
|
2001-11-15 14:14:37 +00:00
|
|
|
|
: MathNestInset(4), symbol_(name)
|
2001-11-09 14:48:57 +00:00
|
|
|
|
{}
|
|
|
|
|
|
2001-11-15 14:14:37 +00:00
|
|
|
|
// 0 - core
|
|
|
|
|
// 1 - diff
|
|
|
|
|
// 2 - lower
|
|
|
|
|
// 3 - upper
|
|
|
|
|
|
2001-11-09 14:48:57 +00:00
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> MathExIntInset::doClone() const
|
2001-11-09 14:48:57 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new MathExIntInset(*this));
|
2001-11-09 14:48:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-12 14:37:43 +00:00
|
|
|
|
void MathExIntInset::symbol(string const & symbol)
|
|
|
|
|
{
|
|
|
|
|
symbol_ = symbol;
|
2001-11-09 14:48:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-09 16:27:44 +00:00
|
|
|
|
bool MathExIntInset::hasScripts() const
|
|
|
|
|
{
|
2001-11-15 09:51:57 +00:00
|
|
|
|
// take empty upper bound as "no scripts"
|
2001-11-15 14:14:37 +00:00
|
|
|
|
return !cell(3).empty();
|
2001-11-09 16:27:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-09 14:48:57 +00:00
|
|
|
|
void MathExIntInset::normalize(NormalStream & os) const
|
|
|
|
|
{
|
2002-03-21 17:42:56 +00:00
|
|
|
|
os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
|
2001-11-15 14:14:37 +00:00
|
|
|
|
<< cell(2) << ' ' << cell(3) << ']';
|
2001-11-09 14:48:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void MathExIntInset::metrics(MetricsInfo &, Dimension &) const
|
2001-11-09 14:48:57 +00:00
|
|
|
|
{
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "should not happen" << endl;
|
2001-11-09 14:48:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void MathExIntInset::draw(PainterInfo &, int, int) const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "should not happen" << endl;
|
2001-11-09 14:48:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathExIntInset::maple(MapleStream & os) const
|
2001-11-09 14:48:57 +00:00
|
|
|
|
{
|
2001-12-05 08:04:20 +00:00
|
|
|
|
os << symbol_ << '(';
|
2001-11-13 18:33:48 +00:00
|
|
|
|
if (cell(0).size())
|
|
|
|
|
os << cell(0);
|
2002-03-21 17:42:56 +00:00
|
|
|
|
else
|
2001-11-12 13:09:26 +00:00
|
|
|
|
os << '1';
|
2001-11-13 18:33:48 +00:00
|
|
|
|
os << ',' << cell(1);
|
2001-11-15 14:14:37 +00:00
|
|
|
|
if (hasScripts())
|
|
|
|
|
os << '=' << cell(2) << ".." << cell(3);
|
2001-11-09 16:27:44 +00:00
|
|
|
|
os << ')';
|
2001-11-09 14:48:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-30 17:51:19 +00:00
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathExIntInset::maxima(MaximaStream & os) const
|
2002-10-28 17:15:19 +00:00
|
|
|
|
{
|
2002-12-01 22:59:25 +00:00
|
|
|
|
if ( symbol_ == "int" )
|
2002-10-28 17:15:19 +00:00
|
|
|
|
os << "integrate(";
|
2002-12-01 22:59:25 +00:00
|
|
|
|
else
|
2002-10-28 17:15:19 +00:00
|
|
|
|
os << symbol_ << '(';
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2002-10-28 17:15:19 +00:00
|
|
|
|
if (cell(0).size())
|
|
|
|
|
os << cell(0) << ',';
|
|
|
|
|
else
|
|
|
|
|
os << '1' << ',';
|
|
|
|
|
if (hasScripts())
|
|
|
|
|
os << cell(1) << ',' << cell(2) << ',' << cell(3) << ')';
|
2002-12-01 22:59:25 +00:00
|
|
|
|
else
|
2002-10-28 17:15:19 +00:00
|
|
|
|
os << cell(1) << ')';
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathExIntInset::mathematica(MathematicaStream & os) const
|
2002-07-01 11:17:14 +00:00
|
|
|
|
{
|
2002-12-01 22:59:25 +00:00
|
|
|
|
if ( symbol_ == "int" )
|
2002-07-01 11:17:14 +00:00
|
|
|
|
os << "Integrate[";
|
2002-12-01 22:59:25 +00:00
|
|
|
|
else if (symbol_ == "sum")
|
2002-10-28 17:15:19 +00:00
|
|
|
|
os << "Sum[";
|
2002-12-01 22:59:25 +00:00
|
|
|
|
else
|
2002-10-28 17:15:19 +00:00
|
|
|
|
os << symbol_ << '[';
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2002-07-01 11:17:14 +00:00
|
|
|
|
if (cell(0).size())
|
|
|
|
|
os << cell(0) << ',';
|
|
|
|
|
else
|
|
|
|
|
os << '1' << ',';
|
|
|
|
|
if (hasScripts())
|
|
|
|
|
os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
|
2002-12-01 22:59:25 +00:00
|
|
|
|
else
|
2002-07-01 11:17:14 +00:00
|
|
|
|
os << cell(1) << ']';
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-09 16:27:44 +00:00
|
|
|
|
|
2001-11-09 14:48:57 +00:00
|
|
|
|
void MathExIntInset::mathmlize(MathMLStream & os) const
|
|
|
|
|
{
|
2001-12-18 03:16:46 +00:00
|
|
|
|
boost::scoped_ptr<MathSymbolInset> sym(new MathSymbolInset(symbol_));
|
2001-11-15 14:14:37 +00:00
|
|
|
|
//if (hasScripts())
|
|
|
|
|
// mathmlize(sym, os);
|
2002-03-21 17:42:56 +00:00
|
|
|
|
//else
|
2001-11-12 14:37:43 +00:00
|
|
|
|
sym->mathmlize(os);
|
2001-11-13 18:33:48 +00:00
|
|
|
|
os << cell(0) << "<mo> ⁢ </mo>"
|
2001-11-09 18:02:20 +00:00
|
|
|
|
<< MTag("mrow") << "<mo> ⅆ </mo>"
|
2001-11-13 18:33:48 +00:00
|
|
|
|
<< cell(1) << ETag("mrow");
|
2001-11-09 14:48:57 +00:00
|
|
|
|
}
|
2001-11-09 16:27:44 +00:00
|
|
|
|
|
|
|
|
|
|
2001-11-12 14:37:43 +00:00
|
|
|
|
void MathExIntInset::write(WriteStream &) const
|
2001-11-09 16:27:44 +00:00
|
|
|
|
{
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "should not happen" << endl;
|
2001-11-09 16:27:44 +00:00
|
|
|
|
}
|