// ************ TAB 4 BEGIN *******************
void MainWindow::tab4_read_polinom()
{
QRegExp rx("([-+]?)([0-9]*)\\*?([x])?\\^?([0-9])?\\*?([y])?\\^?([0-9])?\\*?([z])?\\^?([0-9])?");
//QRegExp rx("([-+]?)((?:[0-9]*))\\*?([a-z]?)\\^?((?:[0-9]*))");
QString str = ui.lineEdit->text();
QString sym, coef, var, exp;
int pos = 0;
P.clear();
while ( pos < str.length() -1 )
{
rx.indexIn(str,pos);
pos += rx.matchedLength();
sym = rx.cap(1);
int coef = rx.cap(2).toInt(0,0);
int x,y,z;
z=0; y=0; x=0;
if (rx.cap(3)=="x")
{
x = rx.cap(4).toInt(0,0);
}
if (rx.cap(5)=="y")
{
y = rx.cap(6).toInt(0,0);
}
if (rx.cap(7)=="z")
{
z = rx.cap(8).toInt(0,0);
}
if ((coef==0) && ( (x!=0) || (y!=0) || (z!=0) ) )
{
if (coef == 0)
{
coef=1;
}
}
if (sym == "-")
{
P.put(-1*coef,x,y,z);
}
else
{
P.put(coef,x,y,z);
}
}
}
void MainWindow::tab4_simplify()
{
tab4_read_polinom();
P.simplify();
QString s = P.get();
ui.lineEdit->setText(s);
}
void MainWindow::tab4_clear()
{
P.clear();
ui.lineEdit->clear();
}
void MainWindow::tab4_save()
{
tab4_read_polinom();
QString fname = QFileDialog::getSaveFileName(this,"",QString::null,QString::null);
if (fname.length()>0) P.save_to_file(fname.toUtf8().data());
}
void MainWindow::tab4_load()
{
QString fname = QFileDialog::getOpenFileName(this,"",QString::null,QString::null);
if (fname.length()>0)
{
P.read_from_file(fname.toUtf8().data());
QString s = P.get();
ui.lineEdit->setText(s);
}
}
// ************ TAB 4 END *******************