Skip to content

Commit

Permalink
Update the DynamicSelect values after the simulation (#11862)
Browse files Browse the repository at this point in the history
Fixes #11811
  • Loading branch information
adeas31 committed Jan 23, 2024
1 parent d21f7d9 commit 389c764
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 49 deletions.
2 changes: 1 addition & 1 deletion OMEdit/OMEditLIB/Element/Element.cpp
Expand Up @@ -3934,7 +3934,7 @@ void Element::updateDynamicSelect(double time)
double value = MainWindow::instance()->getVariablesWidget()->readVariableValue(getName() + ".active", time);
setActiveState(value);
foreach (LineAnnotation *pTransitionLineAnnotation, mpGraphicsView->getTransitionsList()) {
if (pTransitionLineAnnotation->getEndElement()->getName().compare(getName()) == 0) {
if (pTransitionLineAnnotation && pTransitionLineAnnotation->getEndElement() && pTransitionLineAnnotation->getEndElement()->getName().compare(getName()) == 0) {
pTransitionLineAnnotation->setActiveState(value);
}
}
Expand Down
5 changes: 2 additions & 3 deletions OMEdit/OMEditLIB/MainWindow.cpp
Expand Up @@ -4741,9 +4741,8 @@ void MainWindow::switchToPlottingPerspective()
if (mpPlotWindowContainer->subWindowList().size() == 0) {
mpPlotWindowContainer->addPlotWindow(true);
}
QMdiSubWindow *pDiagramSubWindow = mpPlotWindowContainer->getDiagramSubWindowFromMdi();
if (pModelWidget && pDiagramSubWindow) {
mpPlotWindowContainer->getDiagramWindow()->showVisualizationDiagram(pModelWidget);
if (pModelWidget) {
mpPlotWindowContainer->showDiagramWindow(pModelWidget);
}
mpVariablesDockWidget->show();
// show/hide toolbars
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditLIB/Plotting/DiagramWindow.cpp
Expand Up @@ -67,7 +67,7 @@ void DiagramWindow::showVisualizationDiagram(ModelWidget *pModelWidget)
setWindowTitle(pModelWidget->getLibraryTreeItem()->getName());
mpModelWidget = pModelWidget;
mpModelWidget->getDiagramGraphicsView()->setIsVisualizationView(true);
connect(MainWindow::instance()->getVariablesWidget(), SIGNAL(updateDynamicSelect(double)), mpModelWidget->getDiagramGraphicsView(), SIGNAL(updateDynamicSelect(double)));
connect(MainWindow::instance()->getVariablesWidget(), SIGNAL(updateDynamicSelect(double)), mpModelWidget->getDiagramGraphicsView(), SIGNAL(updateDynamicSelect(double)), Qt::UniqueConnection);
MainWindow::instance()->getVariablesWidget()->updateVisualization();
mpModelWidget->getDiagramGraphicsView()->show();
mpMainLayout->addWidget(mpModelWidget->getDiagramGraphicsView());
Expand Down
45 changes: 13 additions & 32 deletions OMEdit/OMEditLIB/Plotting/PlotWindowContainer.cpp
Expand Up @@ -140,37 +140,6 @@ PlotWindow* PlotWindowContainer::getInteractiveWindow(QString targetWindow)
}
}

/*!
* \brief PlotWindowContainer::getTopPlotWindow
* Finds the top PlotWindow and returns it. If there is no PlotWindow then return 0.
* \return
*/
PlotWindow* PlotWindowContainer::getTopPlotWindow()
{
QList<QMdiSubWindow*> subWindowsList = subWindowList(QMdiArea::ActivationHistoryOrder);
for (int i = subWindowsList.size() - 1 ; i >= 0 ; i--) {
if (isPlotWindow(subWindowsList.at(i)->widget())) {
return qobject_cast<PlotWindow*>(subWindowsList.at(i)->widget());
}
}
return 0;
}

/*!
* \brief PlotWindowContainer::setTopPlotWindowActive
* Finds the top PlotWindow and sets it as active subwindow.
*/
void PlotWindowContainer::setTopPlotWindowActive()
{
QList<QMdiSubWindow*> subWindowsList = subWindowList(QMdiArea::ActivationHistoryOrder);
for (int i = subWindowsList.size() - 1 ; i >= 0 ; i--) {
if (isPlotWindow(subWindowsList.at(i)->widget())) {
setActiveSubWindow(subWindowsList.at(i));
return;
}
}
}

#if !defined(WITHOUT_OSG)
/*!
* \brief PlotWindowContainer::getCurrentAnimationWindow
Expand Down Expand Up @@ -291,6 +260,18 @@ void PlotWindowContainer::removePlotCurves(PlotWindow *pPlotWindow)
}
}

/*!
* \brief PlotWindowContainer::showDiagramWindow
* Shows/Updates the Diagram Window if there is any.
* \param pModelWidget
*/
void PlotWindowContainer::showDiagramWindow(ModelWidget *pModelWidget)
{
if (mpDiagramWindow) {
mpDiagramWindow->showVisualizationDiagram(pModelWidget ? pModelWidget : MainWindow::instance()->getModelWidgetContainer()->getCurrentModelWidget());
}
}

/*!
* \brief PlotWindowContainer::addPlotWindow
* Adds a new Plot Window.
Expand Down Expand Up @@ -514,7 +495,7 @@ void PlotWindowContainer::addDiagramWindow(ModelWidget *pModelWidget, bool maxim
if (!mpDiagramWindow) {
mpDiagramWindow = new DiagramWindow(this);
}
mpDiagramWindow->showVisualizationDiagram(pModelWidget ? pModelWidget : MainWindow::instance()->getModelWidgetContainer()->getCurrentModelWidget());
showDiagramWindow(pModelWidget);
QMdiSubWindow *pSubWindow = getDiagramSubWindowFromMdi();
if (!pSubWindow) {
pSubWindow = addSubWindow(mpDiagramWindow);
Expand Down
3 changes: 1 addition & 2 deletions OMEdit/OMEditLIB/Plotting/PlotWindowContainer.h
Expand Up @@ -55,8 +55,6 @@ class PlotWindowContainer : public QMdiArea
QString getUniqueName(QString name = QString("Plot"), int number = 1);
OMPlot::PlotWindow* getCurrentWindow();
OMPlot::PlotWindow* getInteractiveWindow(QString targetWindow);
OMPlot::PlotWindow* getTopPlotWindow();
void setTopPlotWindowActive();
#if !defined(WITHOUT_OSG)
AnimationWindow* getCurrentAnimationWindow();
#endif
Expand All @@ -68,6 +66,7 @@ class PlotWindowContainer : public QMdiArea
bool isUniqueName(QString name);
bool eventFilter(QObject *pObject, QEvent *pEvent);
void removePlotCurves(OMPlot::PlotWindow *pPlotWindow);
void showDiagramWindow(ModelWidget *pModelWidget = 0);
private:
void addRenameTabToSubWindowSystemMenu(QMdiSubWindow *pMdiSubWindow);
DiagramWindow *mpDiagramWindow;
Expand Down
14 changes: 4 additions & 10 deletions OMEdit/OMEditLIB/Simulation/SimulationDialog.cpp
Expand Up @@ -1934,11 +1934,9 @@ void SimulationDialog::simulationProcessFinished(SimulationOptions simulationOpt
// stay in current perspective and show variable browser
MainWindow::instance()->getVariablesDockWidget()->show();
}
bool showPlotWindow = true;
#if !defined(WITHOUT_OSG)
// if simulated with animation then open the animation directly.
if (simulationOptions.getSimulateWithAnimation()) {
showPlotWindow = false;
if (simulationOptions.getFullResultFileName().endsWith(".mat")) {
MainWindow::instance()->getPlotWindowContainer()->addAnimationWindow(MainWindow::instance()->getPlotWindowContainer()->subWindowList().isEmpty());
AnimationWindow *pAnimationWindow = MainWindow::instance()->getPlotWindowContainer()->getCurrentAnimationWindow();
Expand All @@ -1951,15 +1949,11 @@ void SimulationDialog::simulationProcessFinished(SimulationOptions simulationOpt
}
}
#endif
if (showPlotWindow) {
OMPlot::PlotWindow *pPlotWindow = MainWindow::instance()->getPlotWindowContainer()->getTopPlotWindow();
if (pPlotWindow) {
MainWindow::instance()->getPlotWindowContainer()->setTopPlotWindowActive();
} else {
MainWindow::instance()->getPlotWindowContainer()->addPlotWindow(true);
}
}
pVariablesWidget->insertVariablesItemsToTree(simulationOptions.getFullResultFileName(), workingDirectory, QStringList(), simulationOptions);
/* issue #11811
* Make sure we always update the diagramWindow after simulation.
*/
MainWindow::instance()->getPlotWindowContainer()->showDiagramWindow(0);
}
bool profiling = simulationOptions.getProfiling().compare(QStringLiteral("none")) != 0;
if (OptionsDialog::instance()->getDebuggerPage()->getAlwaysShowTransformationsCheckBox()->isChecked() ||
Expand Down

0 comments on commit 389c764

Please sign in to comment.