Skip to content

Commit

Permalink
Merge pull request #53 from vwaurich/FMU2animation
Browse files Browse the repository at this point in the history
added FMI 2 animation support
  • Loading branch information
adeas31 committed Nov 10, 2016
2 parents fc2a603 + 90c956c commit 205399a
Show file tree
Hide file tree
Showing 17 changed files with 1,257 additions and 44 deletions.
6 changes: 6 additions & 0 deletions OMEdit/OMEditGUI/Animation/AnimationUtil.h
Expand Up @@ -150,4 +150,10 @@ inline std::string extractCADFilename(const std::string& s)
}
}

inline const char* boolToString(bool b)
{
return b ? "true" : "false";
}


#endif //ANIMATIONUTIL_H
71 changes: 66 additions & 5 deletions OMEdit/OMEditGUI/Animation/AnimationWindow.cpp
Expand Up @@ -53,6 +53,7 @@ AnimationWindow::AnimationWindow(PlotWindowContainer *pPlotWindowContainer)
mpViewerWidget(nullptr),
mpUpdateTimer(new QTimer()),
mpAnimationToolBar(new QToolBar(QString("Animation Toolbar"),this)),
mpFMUSettingsDialog(nullptr),
mpAnimationChooseFileAction(nullptr),
mpAnimationInitializeAction(nullptr),
mpAnimationPlayAction(nullptr),
Expand Down Expand Up @@ -267,22 +268,34 @@ void AnimationWindow::loadVisualization()
//init visualizer
if (visType == VisType::MAT) {
mpVisualizer = new VisualizerMAT(mFileName, mPathName);
} else if (visType == VisType::CSV) {
}
else if (visType == VisType::CSV) {
mpVisualizer = new VisualizerCSV(mFileName, mPathName);
} else {
}
else if (visType == VisType::FMU) {
mpVisualizer = new VisualizerFMU(mFileName, mPathName);
}
else {
std::cout<<"could not init "<<mPathName<<mFileName<<std::endl;
}
//load the XML File, build osgTree, get initial values for the shapes
bool xmlExists = checkForXMLFile(mFileName, mPathName);
if (!xmlExists) {
std::cout<<"Could not find the visual XML file "<<assembleXMLFileName(mFileName, mPathName)<<std::endl;
} else {
}
else
{
mpVisualizer->initData();
mpVisualizer->setUpScene();
mpVisualizer->initVisualization();
//add scene for the chosen visualization
mpSceneView->setSceneData(mpVisualizer->getOMVisScene()->getScene().getRootNode());
}
//FMU settings dialog
if (visType == VisType::FMU)
{
//openFMUSettingsDialog();
}
//add window title
this->setWindowTitle(QString::fromStdString(mFileName));
//jump to xy-view
Expand Down Expand Up @@ -372,8 +385,11 @@ void AnimationWindow::updateSceneFunction()
mpTimeTextBox->setText(QString::number(mpVisualizer->getTimeManager()->getVisTime()));
mpTimeTextBox->blockSignals(state);
// set time slider
int time = mpVisualizer->getTimeManager()->getTimeFraction();
mpAnimationSlider->setValue(time);
if (mpVisualizer->getVisType() != VisType::FMU)
{
int time = mpVisualizer->getTimeManager()->getTimeFraction();
mpAnimationSlider->setValue(time);
}
}
//update the scene
mpVisualizer->sceneUpdate();
Expand Down Expand Up @@ -539,3 +555,48 @@ void AnimationWindow::setPerspective(int value)
break;
}
}

/*!
* \brief AnimationWindow::openmpFMUSettingsDialog
* opens a dialog to set the settings for the FMU visualization
*/
void AnimationWindow::openFMUSettingsDialog()
{
//create dialog
mpFMUSettingsDialog = new QDialog(this);
mpFMUSettingsDialog->setWindowTitle("FMU settings");
mpFMUSettingsDialog->setWindowIcon(QIcon(":/Resources/icons/animation.png"));
//the layouts
QVBoxLayout *mainLayout = new QVBoxLayout;
QHBoxLayout *simulationLayout = new QHBoxLayout;
QVBoxLayout *leftSimLayout = new QVBoxLayout;
QVBoxLayout *rightSimLayout = new QVBoxLayout;
//the widgets
QLabel *simulationLabel = new QLabel(tr("Simulation settings"));
QPushButton *okButton = new QPushButton(tr("OK"));
//solver settings
QLabel *solverLabel = new QLabel(tr("solver"));
QComboBox *solverComboBox = new QComboBox(mpFMUSettingsDialog);
solverComboBox->addItem(QString("euler forward"));
QLabel *stepsizeLabel = new QLabel(tr("step size"));
QTextEdit *stepSizeEdit = new QTextEdit("0.001");
stepSizeEdit->setMaximumSize(QSize(48,16));
//assemble
mainLayout->addWidget(simulationLabel);
mainLayout->addLayout(simulationLayout);
simulationLayout->addLayout(leftSimLayout);
simulationLayout->addLayout(rightSimLayout);
leftSimLayout->addWidget(solverLabel);
rightSimLayout->addWidget(solverComboBox);
mainLayout->addWidget(okButton);
mpFMUSettingsDialog->setLayout(mainLayout);
//connections
connect(okButton, SIGNAL(clicked()),this, SLOT(saveSimSettings()));
mpFMUSettingsDialog->show();
}

void AnimationWindow::saveSimSettings()
{
std::cout<<"save simulation settings"<<std::endl;
mpFMUSettingsDialog->close();
}
4 changes: 4 additions & 0 deletions OMEdit/OMEditGUI/Animation/AnimationWindow.h
Expand Up @@ -57,6 +57,7 @@
#include "Visualizer.h"
#include "VisualizerMAT.h"
#include "VisualizerCSV.h"
#include "VisualizerFMU.h"

class MainWindow;
class PlotWindowContainer;
Expand All @@ -74,6 +75,7 @@ class AnimationWindow : public QMainWindow, public osgViewer::CompositeViewer
void setPathName(std::string name);
void setFileName(std::string name);
void openAnimationFile(QString fileName);
void openFMUSettingsDialog();
public slots:
void sliderSetTimeSlotFunction(int value);
void playSlotFunction();
Expand All @@ -89,6 +91,7 @@ public slots:
void cameraPositionXZ();
void cameraPositionYZ();
void setPerspective(int value);
void saveSimSettings();
private:
PlotWindowContainer *mpPlotWindowContainer;
//to be animated
Expand All @@ -108,6 +111,7 @@ public slots:
Label *mpAnimationSpeedLabel;
QLineEdit *mpSpeedTextBox;
QComboBox *mpPerspectiveDropDownBox;
QDialog *mpFMUSettingsDialog;
//actions
QAction *mpAnimationChooseFileAction;
QAction *mpAnimationInitializeAction;
Expand Down

0 comments on commit 205399a

Please sign in to comment.