diff --git a/OMNotebook/OMNotebookGUI/cellapplication.cpp b/OMNotebook/OMNotebookGUI/cellapplication.cpp index dbc3174f83b..b4d3d556af4 100644 --- a/OMNotebook/OMNotebookGUI/cellapplication.cpp +++ b/OMNotebook/OMNotebookGUI/cellapplication.cpp @@ -125,6 +125,9 @@ namespace IAEX //Create a commandCenter. cmdCenter_ = new CellCommandCenter(this); + // set the plot command silent in OMC + OmcInteractiveEnvironment::setPlotSilent(tr("true")); + // 2006-04-10 AF, use environment variable to find xml files QString openmodelica = OmcInteractiveEnvironment::OpenModelicaHome(); diff --git a/OMNotebook/OMNotebookGUI/graphcell.cpp b/OMNotebook/OMNotebookGUI/graphcell.cpp index 13ed8f90acb..c0d12eb8ff9 100644 --- a/OMNotebook/OMNotebookGUI/graphcell.cpp +++ b/OMNotebook/OMNotebookGUI/graphcell.cpp @@ -1307,79 +1307,18 @@ namespace IAEX { bool GraphCell::isEvaluated() { return evaluated_; - } - - bool GraphCell::isQtPlot(QString text) - { - QRegExp exp("plot[ ]*\\(.*\\)|plotParametric[ ]*\\(.*\\)|plotAll[ ]*\\(.*\\)" ); - - if( text.isNull() ) - { - if( 0 <= input_->toPlainText().indexOf( exp, 0 ) ) - return true; - else - return false; - } - else - { - if( 0 <= text.indexOf( exp, 0 ) ) - return true; - else - return false; - } - } - - QString GraphCell::getQtPlot(QString text) - { - QRegExp exp("plot[ ]*\\(.*\\)|plotParametric[ ]*\\(.*\\)|plotAll[ ]*\\(.*\\)" ); - - if( text.isNull() ) - { - if( 0 <= input_->toPlainText().indexOf( exp, 0 ) ) - return exp.cap(0); - else - return ""; - } - else - { - if( 0 <= text.indexOf( exp, 0 ) ) - return exp.cap(0); - else - return ""; - } - } + } void GraphCell::setExpr(QString expr) { input_->setPlainText(expr); } - bool GraphCell::isVisualize(QString text) - { - QRegExp exp( "visualize[ ]*\\((.*)" ); - - - if( text.isNull() ) - { - if( 0 <= input_->toPlainText().indexOf( exp, 0 ) ) - return true; - else - return false; - } - else - { - if( 0 <= text.indexOf( exp, 0 ) ) - return true; - else - return false; - - } - } - void GraphCell::plotVariables(QStringList lst) { try { + mpPlotWindow->show(); // clear any curves if we have. foreach (PlotCurve *pPlotCurve, mpPlotWindow->getPlot()->getPlotCurvesList()) { @@ -1468,29 +1407,6 @@ namespace IAEX { output_->update(); QCoreApplication::processEvents(); - // remove plot.png if it already exist, don't want any - // old plot. - bool newPlot = isQtPlot(input_->toPlainText()); - - if(newPlot) - { - mpPlotWindow->show(); - setClosed(false); - // make the plot command silent i.e don't pop-up the OMPlot window. - QString plotCmd = getQtPlot(input_->toPlainText()); - QString plotArgs = plotCmd.mid(plotCmd.indexOf("(")+1); - plotArgs = plotArgs.left(plotArgs.lastIndexOf(")")); - QString newPlotCmd = plotCmd.left(plotCmd.lastIndexOf(")")); - if (plotArgs.trimmed().length() > 0) - newPlotCmd = newPlotCmd.append(",silent=true)"); - else - newPlotCmd = newPlotCmd.append("silent=true)"); - expr.replace(plotCmd, newPlotCmd, Qt::CaseInsensitive); - } - - // 2006-02-02 AF, Added try-catch - QString res, error; - // 2005-11-24 AF, added check to see if the user wants to quit if( 0 == expr.indexOf( "quit()", 0, Qt::CaseSensitive )) { @@ -1511,7 +1427,6 @@ namespace IAEX { EvalThread* et = new EvalThread(getDelegate(), expr); connect(et, SIGNAL(finished()), this, SLOT(delegateFinished())); et->start(); - if (!newPlot) { et->wait(); } } catch( exception &e ) { @@ -1545,6 +1460,7 @@ namespace IAEX { plotVariables(resLst); res = tr(""); } + else { mpPlotWindow->hide(); } } // if user has mixed plot command with other OMC commands. // we must extract the plot command result. @@ -1559,8 +1475,10 @@ namespace IAEX { { plotVariables(resLst); } + else { mpPlotWindow->hide(); } } } + else { mpPlotWindow->hide(); } if( res.isEmpty() && (error.isEmpty() || error.size() == 0) ) { diff --git a/OMNotebook/OMNotebookGUI/graphcell.h b/OMNotebook/OMNotebookGUI/graphcell.h index aa45cbb1929..1dd07eab0eb 100644 --- a/OMNotebook/OMNotebookGUI/graphcell.h +++ b/OMNotebook/OMNotebookGUI/graphcell.h @@ -87,9 +87,6 @@ namespace IAEX virtual bool isClosed(); // Added 2006-01-17 AF virtual bool isEditable(); virtual bool isEvaluated(); // Added 2005-11-23 AF - virtual bool isQtPlot(QString text = QString::null); - virtual QString getQtPlot(QString text = QString::null); - virtual bool isVisualize(QString text = QString::null); void plotVariables(QStringList lst); diff --git a/OMNotebook/OMNotebookGUI/notebook.cpp b/OMNotebook/OMNotebookGUI/notebook.cpp index 6e77b99573d..b3980008c0f 100644 --- a/OMNotebook/OMNotebookGUI/notebook.cpp +++ b/OMNotebook/OMNotebookGUI/notebook.cpp @@ -2865,7 +2865,7 @@ void NotebookWindow::saveas() //window->insertImage(filename); //window->SaveSketchImage(filename); - QMessageBox::about(this,"entered ","image witten "); + //QMessageBox::about(this,"entered ","image witten "); statusBar()->showMessage("Saving file"); application()->commandCenter()->executeCommand(new SaveDocumentCommand(subject_, filename)); diff --git a/OMNotebook/OMNotebookGUI/notebookcommands.h b/OMNotebook/OMNotebookGUI/notebookcommands.h index b2d38d0b2e1..7e4ae031c81 100644 --- a/OMNotebook/OMNotebookGUI/notebookcommands.h +++ b/OMNotebook/OMNotebookGUI/notebookcommands.h @@ -179,8 +179,8 @@ namespace IAEX file.fileName().toStdString(); throw runtime_error( msg.c_str() ); } - - if(file.exists() && (fileInfo.permission(QFile::WriteUser) != true)) + + if(file.exists() && (file.permissions().testFlag(QFile::WriteUser) != true)) { string msg = "The file for saving the document is not writable: " + file.fileName().toStdString() + "\nPlease use Save As."; diff --git a/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.cpp b/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.cpp index 4f6d8188c28..2b7d525fcc2 100644 --- a/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.cpp +++ b/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.cpp @@ -280,6 +280,17 @@ namespace IAEX return version; } + bool OmcInteractiveEnvironment::setPlotSilent(QString silent) + { + OmcInteractiveEnvironment *env = OmcInteractiveEnvironment::getInstance(); + env->evalExpression(QString("setPlotSilent("+silent+")")); + QString result = env->getResult(); + if (result.toLower().compare("true") == 0) + return true; + else + return false; + } + QString OmcInteractiveEnvironment::OpenModelicaHome() { OmcInteractiveEnvironment *env = OmcInteractiveEnvironment::getInstance(); diff --git a/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.h b/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.h index c41af82d9ad..416ac68a342 100644 --- a/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.h +++ b/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.h @@ -56,6 +56,7 @@ namespace IAEX virtual bool startDelegate(); static bool startOMC(); static QString OMCVersion(); + static bool setPlotSilent(QString silent); static QString OpenModelicaHome(); static QString TmpPath(); diff --git a/OMNotebook/OMNotebookGUI/xmlparser.cpp b/OMNotebook/OMNotebookGUI/xmlparser.cpp index 93ff6c4e4cc..fa28f5740da 100644 --- a/OMNotebook/OMNotebookGUI/xmlparser.cpp +++ b/OMNotebook/OMNotebookGUI/xmlparser.cpp @@ -572,11 +572,7 @@ namespace IAEX else if( e.tagName() == XML_OUTPUTPART ) { GraphCell *iCell = dynamic_cast(graphcell); - - if( iCell->isQtPlot() ) - iCell->setTextOutputHtml( e.text() ); - else - iCell->setTextOutput( e.text() ); + iCell->setTextOutput( e.text() ); } else if( e.tagName() == XML_IMAGE ) {