Commit 041647d5 authored by cyrush's avatar cyrush

merge python expression changes from 2.0RC

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@10177 18c085ea-50e0-402c-830e-de6fd14e8384
parent 26f95008
......@@ -313,6 +313,9 @@ ExprScanner::UpdateScanState(const std::string &parsed)
// Cyrus Harrison, Thu Feb 11 21:21:46 PST 2010
// Add support escaped newlines.
//
// Cyrus Harrison, Thu Feb 11 21:21:46 PST 2010
// Add support for escaped spaces.
//
// ****************************************************************************
Token*
ExprScanner::ScanOneToken()
......@@ -336,6 +339,8 @@ ExprScanner::ScanOneToken()
lookahead = text[pos+1];
if(lookahead == 'n')
lookahead ='\n';
if(lookahead == 's')
lookahead =' ';
}
}
......
......@@ -838,6 +838,8 @@ QvisExpressionsWindow::UpdateWindowSingleItem()
stdDefinitionEdit->setText("");
pyArgsEdit->setText("");
pyFilterEdit->setSource("");
stdExprActive = true;
pyExprActive = true;
}
else
{
......@@ -851,9 +853,10 @@ QvisExpressionsWindow::UpdateWindowSingleItem()
QString expr_def = QString(e.GetDefinition().c_str());
stdDefinitionEdit->setText(expr_def);
UpdateStandardExpressionEditor(expr_def);
UpdatePythonExpressionEditor(expr_def);
if(expr_def.trimmed() == QString("") && pyExprActive)
stdExprActive = true;
}
UpdateWindowSensitivity();
......@@ -907,7 +910,7 @@ QvisExpressionsWindow::UpdateWindowSensitivity()
typeList->setEnabled(enable);
notHidden->setEnabled(enable);
stdEditorWidget->setEnabled(enable);
stdEditorWidget->setEnabled(enable && stdExprActive);
pyEditorWidget->setEnabled(enable && pyExprActive);
}
......@@ -1475,6 +1478,7 @@ QvisExpressionsWindow::UpdatePythonExpressionEditor(const QString &expr_def)
if(ParsePythonExpression(expr_def,res_args,res_script))
{
pyExprActive = true;
stdExprActive = false;
pyArgsEdit->setText(res_args);
pyFilterEdit->setSource(res_script,true);
if(res_script != QString(""))
......@@ -1483,6 +1487,7 @@ QvisExpressionsWindow::UpdatePythonExpressionEditor(const QString &expr_def)
else
{
pyExprActive = false;
stdExprActive = true;
pyArgsEdit->setText(QString(""));
pyFilterEdit->setSource(QString(""));
editorTabs->setCurrentIndex(0);
......@@ -1491,6 +1496,26 @@ QvisExpressionsWindow::UpdatePythonExpressionEditor(const QString &expr_def)
}
// ****************************************************************************
// Method: QvisExpressionsWindow::UpdateStandardExpressionEditor
//
// Purpose:
// Updates the standard expression editor.
//
// Programmer: Cyrus Harrison
// Creation: Fri Mar 5 16:55:08 PST 2010
//
// Modifications:
//
// ****************************************************************************
void
QvisExpressionsWindow::UpdateStandardExpressionEditor(const QString &expr_def)
{
BlockAllSignals(true);
stdDefinitionEdit->setText(expr_def);
BlockAllSignals(false);
}
// ****************************************************************************
// Method: QvisExpressionsWindow::ExpandFunction
//
......
......@@ -140,6 +140,7 @@ class GUI_API QvisExpressionsWindow : public QvisPostableWindowObserver
void CreatePythonFilterEditor();
void UpdatePythonExpression();
bool ParsePythonExpression(const QString &, QString &, QString &);
void UpdateStandardExpressionEditor(const QString &);
void UpdatePythonExpressionEditor(const QString &);
// Widgets and layouts.
......@@ -182,6 +183,7 @@ class GUI_API QvisExpressionsWindow : public QvisPostableWindowObserver
// State information
ExpressionList *exprList;
std::map<int,int> indexMap;
bool stdExprActive;
bool pyExprActive;
};
......
......@@ -147,7 +147,6 @@ QvisPythonFilterEditor::~QvisPythonFilterEditor()
QString
QvisPythonFilterEditor::getSource(bool escape)
{
// TODO test escape
QString res = editor->toPlainText();
res = res.trimmed() + QString("\n");
......@@ -155,6 +154,7 @@ QvisPythonFilterEditor::getSource(bool escape)
{
res.replace(QString("\""),QString("\\\""));
res.replace(QString("\n"),QString("\\n"));
res.replace(QString(" "),QString("\\s"));
}
return res;
......@@ -182,6 +182,7 @@ QvisPythonFilterEditor::setSource(const QString &py_script, bool escaped)
QString res = py_script;
res.replace(QString("\\\""),QString("\""));
res.replace(QString("\\n"),QString("\n"));
res.replace(QString("\\s"),QString(" "));
editor->setText(res);
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment