Skip to content

Commit

Permalink
- Don't close the simulation result set since we have a caching to ma…
Browse files Browse the repository at this point in the history
…t format.

- closeSimulationResultFile() :: Closes the current simulation result set. OMEdit uses it for windows to close the result file.
- some minor fixes in OMPlot.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11053 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Feb 9, 2012
1 parent 2e89514 commit 2c79d2e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
14 changes: 13 additions & 1 deletion OMEdit/OMEditGUI/OMCProxy.cpp
Expand Up @@ -1754,12 +1754,24 @@ bool OMCProxy::buildModel(QString modelName, QString simualtionParameters)
QList<QString> OMCProxy::readSimulationResultVars(QString fileName)
{
sendCommand("readSimulationResultVars(\"" + fileName + "\")");

QList<QString> variablesList = StringHandler::getSimulationResultVars(getResult());
qSort(variablesList.begin(), variablesList.end());
return variablesList;
}

//! Closes the current simulation result file.
//! @param fileName the result file name
//! @return QList<QString> the list of variables.
bool OMCProxy::closeSimulationResultFile()
{
#ifdef Q_OS_WIN
sendCommand("closeSimulationResultFile()");
return StringHandler::unparseBool(getResult());
#else
return true;
#endif
}

//! Plot the variables
//! @param plotVariables
//! @param fileName the result file name
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/OMCProxy.h
Expand Up @@ -175,6 +175,7 @@ class OMCProxy : public QObject
bool simulate(QString modelName, QString simualtionParameters);
bool buildModel(QString modelName, QString simualtionParameters);
QList<QString> readSimulationResultVars(QString fileName);
bool closeSimulationResultFile();
//bool plot(QString modelName, QString plotVariables);
// modified plot API call
bool plot(QString plotVariables, QString fileName);
Expand Down
6 changes: 2 additions & 4 deletions OMEdit/OMEditGUI/PlotWidget.cpp
Expand Up @@ -345,12 +345,11 @@ void PlotWidget::plotVariables(QTreeWidgetItem *item, int column)
// check the item checkstate
if (pItem->checkState(column) == Qt::Checked)
{
pPlotWindow->openFile(QString(mpParentMainWindow->mpOMCProxy->changeDirectory()).append("/").append(pItem->getFileName()));
pPlotWindow->initializeFile(QString(mpParentMainWindow->mpOMCProxy->changeDirectory()).append("/").append(pItem->getFileName()));
pPlotWindow->setVariablesList(QStringList(pItem->getPlotVariable()));
pPlotWindow->plot();
pPlotWindow->fitInView();
pPlotWindow->getPlot()->getPlotZoomer()->setZoomBase(false);
pPlotWindow->closeFile();
}
// if user unchecks the variable then remove it from the plot
else if (pItem->checkState(column) == Qt::Unchecked)
Expand Down Expand Up @@ -398,7 +397,7 @@ void PlotWidget::plotVariables(QTreeWidgetItem *item, int column)
return;
}
mPlotParametricVariables.last().append(QStringList(pItem->getPlotVariable()));
pPlotWindow->openFile(QString(mpParentMainWindow->mpOMCProxy->changeDirectory()).append("/").append(pItem->getFileName()));
pPlotWindow->initializeFile(QString(mpParentMainWindow->mpOMCProxy->changeDirectory()).append("/").append(pItem->getFileName()));
pPlotWindow->setVariablesList(mPlotParametricVariables.last());
pPlotWindow->plotParametric();
if (mPlotParametricVariables.size() > 1)
Expand All @@ -408,7 +407,6 @@ void PlotWidget::plotVariables(QTreeWidgetItem *item, int column)
}
pPlotWindow->fitInView();
pPlotWindow->getPlot()->getPlotZoomer()->setZoomBase(false);
pPlotWindow->closeFile();
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/SimulationWidget.cpp
Expand Up @@ -414,6 +414,8 @@ void SimulationWidget::simulateModel(QString simulationParameters)
OMCProxy *pOMCProxy = mpParentMainWindow->mpOMCProxy;
QList<QString> list;
list = pOMCProxy->readSimulationResultVars(QString(output_file).append("_res.").append(mpOutputFormatComboBox->currentText()));
// close the simulation result file.
pOMCProxy->closeSimulationResultFile();
emit showPlottingView();
pPlotWidget->addPlotVariablestoTree(QString(output_file).append("_res.").append(mpOutputFormatComboBox->currentText()),list);
mpParentMainWindow->plotdock->show();
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/mainwindow.cpp
Expand Up @@ -1053,6 +1053,7 @@ void MainWindow::importModelfromOMNotebook()
}
mpProgressBar->setValue(value++);
}
file.close();
// hide the progressbar and clear the message in status bar
mpStatusBar->clearMessage();
hideProgressBar();
Expand Down

0 comments on commit 2c79d2e

Please sign in to comment.