Skip to content

Commit

Permalink
- add icons, remove old animation buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
vwaurich committed Aug 26, 2016
1 parent 8707392 commit dab8d02
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 97 deletions.
72 changes: 3 additions & 69 deletions OMEdit/OMEditGUI/Animation/AnimationWindowContainer.cpp
Expand Up @@ -53,14 +53,6 @@ AnimationWindowContainer::AnimationWindowContainer(MainWindow *pParent)
_sceneView(new osgViewer::View()),
_visualizer(nullptr),
_viewerWidget(nullptr),
_topWidget(nullptr),
_visFileButton(nullptr),
_playButton(nullptr),
_pauseButton(nullptr),
_initButton(nullptr),
_timeSlider(nullptr),
_timeDisplay(nullptr),
_RTFactorDisplay(nullptr),
_updateTimer(nullptr)
{
setThreadingModel(osgViewer::CompositeViewer::SingleThreaded);
Expand All @@ -70,8 +62,6 @@ AnimationWindowContainer::AnimationWindowContainer(MainWindow *pParent)
_viewerWidget->setParent(this);
_viewerWidget->setWindowFlags(Qt::SubWindow);
//_viewerWidget->setWindowState(Qt::WindowMaximized);
//the control widgets
_topWidget = AnimationWindowContainer::setupAnimationWidgets();
}


Expand All @@ -90,8 +80,8 @@ QWidget* AnimationWindowContainer::setupViewWidget(osg::ref_ptr<osg::Node> rootN
traits->x = 0;
traits->y = 0;

traits->width = 1000;
traits->height = 600;
traits->width = 2000;
traits->height = 1000;
traits->doubleBuffer = true;
traits->alpha = ds->getMinimumNumAlphaBits();
traits->stencil = ds->getMinimumNumStencilBits();
Expand All @@ -115,57 +105,6 @@ QWidget* AnimationWindowContainer::setupViewWidget(osg::ref_ptr<osg::Node> rootN
return gw->getGLWidget();
}


/*!
* \brief AnimationWindowContainer::setupAnimationWidgets
* creates the widgets for the animation
*/
QWidget* AnimationWindowContainer::setupAnimationWidgets()
{
// control widgets
_timeSlider = new QSlider(Qt::Horizontal,this);
_timeSlider->setFixedHeight(30);
_timeSlider->setMinimum(0);
_timeSlider->setMaximum(100);
_timeSlider->setSliderPosition(50);
_visFileButton = new QPushButton("Choose File",this);
_playButton = new QPushButton("Play",this);
_pauseButton = new QPushButton("Pause",this);
_initButton = new QPushButton("Initialize",this);
_timeDisplay = new QLabel(this);
_timeDisplay->setText(QString("Time [s]: ").append(QString::fromStdString("0.000")));
_RTFactorDisplay = new QLabel(this);
_RTFactorDisplay->setText(QString("RT-Factor: ").append(QString::fromStdString("0.000")));

//layout for all control widgets
QHBoxLayout* rowLayOut = new QHBoxLayout();
rowLayOut->addWidget(_visFileButton);
rowLayOut->addWidget(_initButton);
rowLayOut->addWidget(_playButton);
rowLayOut->addWidget(_pauseButton);
rowLayOut->addWidget(_timeSlider);
rowLayOut->addWidget(_RTFactorDisplay);
rowLayOut->addWidget(_timeDisplay);
QGroupBox* widgetRowBox = new QGroupBox();
widgetRowBox->setLayout(rowLayOut);
widgetRowBox->setFixedHeight(HEIGHT_CONTROLWIDGETS);

_topWidget = new QWidget(this);
QVBoxLayout* mainVLayout = new QVBoxLayout();
//mainVLayout->addWidget(_viewerWidget);
mainVLayout->addWidget(widgetRowBox);
_topWidget->setLayout(mainVLayout);

// Connect the buttons to the corresponding slot functions.
QObject::connect(_visFileButton, SIGNAL(clicked()), this, SLOT(chooseAnimationFileSlotFunction()));
QObject::connect(_timeSlider, SIGNAL(sliderMoved(int)), this, SLOT(sliderSetTimeSlotFunction(int)));
QObject::connect(_playButton, SIGNAL(clicked()), this, SLOT(playSlotFunction()));
QObject::connect(_pauseButton, SIGNAL(clicked()), this, SLOT(pauseSlotFunction()));
QObject::connect(_initButton, SIGNAL(clicked()), this, SLOT(initSlotFunction()));
return _topWidget;
}


/*!
* \brief AnimationWindowContainer::loadVisualization
* loads the data and the xml scene description
Expand Down Expand Up @@ -214,14 +153,13 @@ void AnimationWindowContainer::loadVisualization(){
* opens a file dialog to chooes an animation
*/
void AnimationWindowContainer::chooseAnimationFileSlotFunction(){
std::cout<<"animationFileSlotFunction "<<std::endl;
QFileDialog dialog(this);
std::string file = dialog.getOpenFileName(this,tr("Open Visualiation File"), "./", tr("Visualization MAT(*.mat)")).toStdString();
if (file.compare("")){
std::size_t pos = file.find_last_of("/\\");
_pathName = file.substr(0, pos + 1);
_fileName = file.substr(pos + 1, file.length());
std::cout<<"file "<<_fileName<<" path "<<_pathName<<std::endl;
//std::cout<<"file "<<_fileName<<" path "<<_pathName<<std::endl;
loadVisualization();
}
else
Expand Down Expand Up @@ -253,7 +191,6 @@ void AnimationWindowContainer::sliderSetTimeSlotFunction(int value){
int time = (_visualizer->getTimeManager()->getEndTime()
- _visualizer->getTimeManager()->getStartTime())
* (float) (value / 100.0);
std::cout<<"moveSliderSlotFunction "<<value<<" : "<<time<<std::endl;
_visualizer->getTimeManager()->setVisTime(time);
_visualizer->sceneUpdate();
}
Expand All @@ -264,7 +201,6 @@ void AnimationWindowContainer::sliderSetTimeSlotFunction(int value){
* slot function for the play button
*/
void AnimationWindowContainer::playSlotFunction(){
std::cout<<"playSlotFunction "<<std::endl;
_visualizer->getTimeManager()->setPause(false);
}

Expand All @@ -273,7 +209,6 @@ void AnimationWindowContainer::playSlotFunction(){
* slot function for the pause button
*/
void AnimationWindowContainer::pauseSlotFunction(){
std::cout<<"pauseSlotFunction "<<std::endl;
_visualizer->getTimeManager()->setPause(true);
}

Expand All @@ -282,7 +217,6 @@ void AnimationWindowContainer::pauseSlotFunction(){
* slot function for the init button
*/
void AnimationWindowContainer::initSlotFunction(){
std::cout<<"initSlotFunction "<<std::endl;
_visualizer->initVisualization();

}
Expand Down
9 changes: 0 additions & 9 deletions OMEdit/OMEditGUI/Animation/AnimationWindowContainer.h
Expand Up @@ -62,7 +62,6 @@ class AnimationWindowContainer : public QWidget, public osgViewer::CompositeView
Q_OBJECT
public:
AnimationWindowContainer(MainWindow *pParent);
QWidget* setupAnimationWidgets();
QWidget* setupViewWidget(osg::ref_ptr<osg::Node> rootNode);
void showWidgets();
void loadVisualization();
Expand All @@ -87,14 +86,6 @@ class AnimationWindowContainer : public QWidget, public osgViewer::CompositeView
VisualizerAbstract* _visualizer;
//widgets
QWidget* _viewerWidget;
QWidget* _topWidget;
QPushButton* _visFileButton;
QPushButton* _playButton;
QPushButton* _pauseButton;
QPushButton* _initButton;
QSlider* _timeSlider;
QLabel* _timeDisplay;
QLabel* _RTFactorDisplay;
QTimer* _updateTimer;
};

Expand Down
16 changes: 1 addition & 15 deletions OMEdit/OMEditGUI/Animation/Visualizer.cpp
Expand Up @@ -68,7 +68,6 @@ void OMVisualBase::initXMLDoc()
buff2.append("</visualization>");
char* buff3 = strdup(buff2.c_str()); // cast to char*
_xmlDoc.parse<0>(buff3);
std::cout<<"laoded XML"<<std::endl;

}

Expand Down Expand Up @@ -168,7 +167,6 @@ void OMVisualBase::initVisObjects()
shape._specCoeff = getObjectAttributeForNode(expNode);

_shapes.push_back(shape);
std::cout<<" done"<<std::endl;
}
} // end for-loop
}
Expand Down Expand Up @@ -230,28 +228,19 @@ VisualizerAbstract::VisualizerAbstract(const std::string& modelFile, const std::
{
_baseData = new OMVisualBase(modelFile, path);
_viewerStuff->getScene().setPath(path);
std::cout<<"INITED VisualizerAbstract"<<std::endl;
}

void VisualizerAbstract::initData()
{
std::cout<<"initData 1"<<std::endl;

// In case of reloading, we need to make sure, that we have empty members.
_baseData->clearXMLDoc();
std::cout<<"initData 2"<<std::endl;

// Initialize XML file and get visAttributes.
_baseData->initXMLDoc();
std::cout<<"initData 3"<<std::endl;

_baseData->initVisObjects();
std::cout<<"initData 4"<<std::endl;
}

void VisualizerAbstract::initVisualization()
{
std::cout<<"Initialize visualization."<<std::endl;
initializeVisAttributes(_timeManager->getStartTime());
_timeManager->setVisTime(_timeManager->getStartTime());
_timeManager->setRealTimeFactor(0.0);
Expand Down Expand Up @@ -379,16 +368,14 @@ void VisualizerMAT::readMat(const std::string& modelFile, const std::string& pat

void VisualizerMAT::updateVisAttributes(const double time)
{
std::cout<<"updateVisAttributes at "<<time <<std::endl;
//std::cout<<"updateVisAttributes at "<<time <<std::endl;
// Update all shapes.
unsigned int shapeIdx = 0;
rAndT rT;
osg::ref_ptr<osg::Node> child = nullptr;
ModelicaMatReader* tmpReaderPtr = &_matReader;
try
{
std::cout<<"try at "<<time <<std::endl;

for (auto& shape : _baseData->_shapes)
{
//std::cout<<"shape "<<shape._id <<std::endl;
Expand Down Expand Up @@ -523,7 +510,6 @@ OSGScene::OSGScene()

int OSGScene::setUpScene(std::vector<ShapeObject> allShapes)
{
std::cout<<"SETUPSCENE"<<std::endl;
int isOk(0);
for (std::vector<ShapeObject>::size_type i = 0; i != allShapes.size(); i++)
{
Expand Down
8 changes: 4 additions & 4 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -2731,16 +2731,16 @@ void MainWindow::createActions()
mpTLMCoSimulationAction->setEnabled(false);
connect(mpTLMCoSimulationAction, SIGNAL(triggered()), SLOT(TLMSimulate()));
// animation action
mpAnimationChooseFileAction = new QAction(QIcon(":/Resources/icons/tlm-simulate.svg"), Helper::animationChooseFile, this);
mpAnimationChooseFileAction = new QAction(QIcon(":/Resources/icons/openFile.png"), Helper::animationChooseFile, this);
mpAnimationChooseFileAction->setStatusTip(Helper::animationChooseFileTip);
mpAnimationChooseFileAction->setEnabled(true);
mpAnimationInitializeAction = new QAction(QIcon(":/Resources/icons/tlm-simulate.svg"), Helper::animationInitialize, this);
mpAnimationInitializeAction = new QAction(QIcon(":/Resources/icons/initialize.png"), Helper::animationInitialize, this);
mpAnimationInitializeAction->setStatusTip(Helper::animationInitializeTip);
mpAnimationInitializeAction->setEnabled(true);
mpAnimationPlayAction = new QAction(QIcon(":/Resources/icons/tlm-simulate.svg"), Helper::animationPlay, this);
mpAnimationPlayAction = new QAction(QIcon(":/Resources/icons/play.png"), Helper::animationPlay, this);
mpAnimationPlayAction->setStatusTip(Helper::animationPlayTip);
mpAnimationPlayAction->setEnabled(true);
mpAnimationPauseAction = new QAction(QIcon(":/Resources/icons/tlm-simulate.svg"), Helper::animationPause, this);
mpAnimationPauseAction = new QAction(QIcon(":/Resources/icons/pause.png"), Helper::animationPause, this);
mpAnimationPauseAction->setStatusTip(Helper::animationPauseTip);
mpAnimationPauseAction->setEnabled(true);
connect(mpAnimationChooseFileAction, SIGNAL(triggered()),mpAnimationWindowContainer, SLOT(chooseAnimationFileSlotFunction()));
Expand Down
Binary file added OMEdit/OMEditGUI/Resources/icons/animation.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added OMEdit/OMEditGUI/Resources/icons/initialize.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added OMEdit/OMEditGUI/Resources/icons/openFile.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added OMEdit/OMEditGUI/Resources/icons/pause.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added OMEdit/OMEditGUI/Resources/icons/play.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Resources/icons/play.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions OMEdit/OMEditGUI/resource_omedit.qrc
Expand Up @@ -137,5 +137,10 @@
<file>Resources/icons/align-interfaces.svg</file>
<file>Resources/icons/tlm-simulate.svg</file>
<file>Resources/XMLSchema/tlmModelDescription.xsd</file>
<file>Resources/icons/animation.png</file>
<file>Resources/icons/openFile.png</file>
<file>Resources/icons/play.png</file>
<file>Resources/icons/pause.png</file>
<file>Resources/icons/initialize.png</file>
</qresource>
</RCC>

0 comments on commit dab8d02

Please sign in to comment.