Skip to content

Commit

Permalink
- animation window
Browse files Browse the repository at this point in the history
  • Loading branch information
vwaurich authored and adeas31 committed Sep 30, 2016
1 parent 21e45ae commit 8b08221
Show file tree
Hide file tree
Showing 7 changed files with 302 additions and 0 deletions.
81 changes: 81 additions & 0 deletions OMEdit/OMEditGUI/Animation/AnimationWindowContainer.cpp
@@ -0,0 +1,81 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
/*
* @author Adeel Asghar <adeel.asghar@liu.se>
*/

#include "AnimationWindowContainer.h"


/*!
\class AnimationWindowContainer
\brief A MDI area for animation windows.
*/
/*!
* \brief AnimationWindowContainer::AnimationWindowContainer
* \param pParent
*/
AnimationWindowContainer::AnimationWindowContainer(MainWindow *pParent)
: MdiArea(pParent)
{
if (mpMainWindow->getOptionsDialog()->getAnimationPage()->getAnimationViewMode().compare(Helper::subWindow) == 0) {
setViewMode(QMdiArea::SubWindowView);
} else {
setViewMode(QMdiArea::TabbedView);
}
// dont show this widget at startup
setVisible(false);
}

/*!
* \brief AnimationWindowContainer::getUniqueName
* Returns a unique name for new animation window.
* \param name
* \param number
* \return
*/
QString AnimationWindowContainer::getUniqueName(QString name, int number)
{
QString newName;
newName = name + QString::number(number);

foreach (QMdiSubWindow *pWindow, subWindowList()) {
if (pWindow->widget()->windowTitle().compare(newName) == 0) {
newName = getUniqueName(name, ++number);
break;
}
}
return newName;
}




50 changes: 50 additions & 0 deletions OMEdit/OMEditGUI/Animation/AnimationWindowContainer.h
@@ -0,0 +1,50 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
/*
* @author Adeel Asghar <adeel.asghar@liu.se>
*/

#ifndef ANIMATIONWINDOWCONTAINER_H
#define ANIMATIONWINDOWCONTAINER_H

#include "MainWindow.h"

class MainWindow;

class AnimationWindowContainer : public MdiArea
{
Q_OBJECT
public:
AnimationWindowContainer(MainWindow *pParent);
QString getUniqueName(QString name = QString("Animation"), int number = 4);
};

#endif // ANIMATIONWINDOWCONTAINER_H
32 changes: 32 additions & 0 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -142,6 +142,11 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, bool debug, QWidget *parent
QShortcut *pAlgorithmicDebuggingShortcut = new QShortcut(QKeySequence("Ctrl+f5"), this);
connect(pAlgorithmicDebuggingShortcut, SIGNAL(activated()), SLOT(switchToAlgorithmicDebuggingPerspectiveSlot()));
mpPerspectiveTabbar->setTabToolTip(3, tr("Changes to debugging perspective (%1)").arg(pAlgorithmicDebuggingShortcut->key().toString()));
// 3d animation perspective
mpPerspectiveTabbar->addTab(QIcon(":/Resources/icons/debugger.svg"), tr("Animation"));
QShortcut *pAnimationShortcut = new QShortcut(QKeySequence("Ctrl+f6"), this);
connect(pAnimationShortcut, SIGNAL(activated()), SLOT(switchToAnimationPerspectiveSlot()));
mpPerspectiveTabbar->setTabToolTip(4, tr("Changes to animation perspective (%1)").arg(pAnimationShortcut->key().toString()));
// change the perspective when perspective tab bar selection is changed
connect(mpPerspectiveTabbar, SIGNAL(currentChanged(int)), SLOT(perspectiveTabChanged(int)));
// Create an object of QStatusBar
Expand Down Expand Up @@ -215,6 +220,8 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, bool debug, QWidget *parent
addDockWidget(Qt::RightDockWidgetArea, mpDocumentationDockWidget);
mpDocumentationDockWidget->hide();
connect(mpDocumentationDockWidget, SIGNAL(visibilityChanged(bool)), SLOT(documentationDockWidgetVisibilityChanged(bool)));
// Create an object of AnimationWindowContainer
mpAnimationWindowContainer = new AnimationWindowContainer(this);
// Create an object of PlotWindowContainer
mpPlotWindowContainer = new PlotWindowContainer(this);
// create an object of VariablesWidget
Expand Down Expand Up @@ -256,6 +263,7 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, bool debug, QWidget *parent
mpCentralStackedWidget->addWidget(mpWelcomePageWidget);
mpCentralStackedWidget->addWidget(mpModelWidgetContainer);
mpCentralStackedWidget->addWidget(mpPlotWindowContainer);
mpCentralStackedWidget->addWidget(mpAnimationWindowContainer);
// set the layout
QGridLayout *pCentralgrid = new QGridLayout;
pCentralgrid->setVerticalSpacing(4);
Expand Down Expand Up @@ -2189,6 +2197,9 @@ void MainWindow::perspectiveTabChanged(int tabIndex)
case 3:
switchToAlgorithmicDebuggingPerspective();
break;
case 4:
switchToAnimationPerspective();
break;
default:
switchToWelcomePerspective();
break;
Expand Down Expand Up @@ -2263,6 +2274,16 @@ void MainWindow::switchToAlgorithmicDebuggingPerspectiveSlot()
mpPerspectiveTabbar->setCurrentIndex(3);
}

/*!
* \brief MainWindow::switchToAnimationPerspectiveSlot
* Slot activated when Ctrl+f6 is clicked.
* Switches to animation perspective.
*/
void MainWindow::switchToAnimationPerspectiveSlot()
{
mpPerspectiveTabbar->setCurrentIndex(4);
}

/*!
* \brief MainWindow::showConfigureDialog
* Slot activated when mpDebugConfigurationsAction triggered signal is raised.\n
Expand Down Expand Up @@ -3044,6 +3065,17 @@ void MainWindow::switchToAlgorithmicDebuggingPerspective()
mpGDBLoggerDockWidget->show();
}


/*!
* \brief MainWindow::switchToAnimationPerspective
* Switches to animation perspective.
*/
void MainWindow::switchToAnimationPerspective()
{
storePlotWindowsStateAndGeometry();
mpCentralStackedWidget->setCurrentWidget(mpAnimationWindowContainer);
}

/*!
* \brief MainWindow::closeAllWindowsButThis
* Closes all windows except the active window.
Expand Down
6 changes: 6 additions & 0 deletions OMEdit/OMEditGUI/MainWindow.h
Expand Up @@ -67,6 +67,7 @@
#include "SimulationDialog.h"
#include "TLMCoSimulationDialog.h"
#include "Plotting/PlotWindowContainer.h"
#include "Animation/AnimationWindowContainer.h"
#include "ModelWidgetContainer.h"
#include "GDBAdapter.h"
#include "StackFramesWidget.h"
Expand All @@ -90,6 +91,7 @@ class GDBLoggerWidget;
class SimulationDialog;
class TLMCoSimulationDialog;
class PlotWindowContainer;
class AnimationWindowContainer;
class ModelWidgetContainer;
class InfoBar;
class WelcomePageWidget;
Expand Down Expand Up @@ -121,6 +123,7 @@ class MainWindow : public QMainWindow
SimulationDialog* getSimulationDialog() {return mpSimulationDialog;}
TLMCoSimulationDialog* getTLMCoSimulationDialog() {return mpTLMCoSimulationDialog;}
PlotWindowContainer* getPlotWindowContainer() {return mpPlotWindowContainer;}
AnimationWindowContainer* getAnimationWindowContainer() {return mpAnimationWindowContainer;}
ModelWidgetContainer* getModelWidgetContainer() {return mpModelWidgetContainer;}
WelcomePageWidget* getWelcomePageWidget() {return mpWelcomePageWidget;}
InfoBar* getInfoBar() {return mpInfoBar;}
Expand Down Expand Up @@ -230,6 +233,7 @@ class MainWindow : public QMainWindow
SimulationDialog *mpSimulationDialog;
TLMCoSimulationDialog *mpTLMCoSimulationDialog;
PlotWindowContainer *mpPlotWindowContainer;
AnimationWindowContainer *mpAnimationWindowContainer;
QList<Qt::WindowStates> mPlotWindowsStatesList;
QList<QByteArray> mPlotWindowsGeometriesList;
ModelWidgetContainer *mpModelWidgetContainer;
Expand Down Expand Up @@ -432,6 +436,7 @@ private slots:
void switchToModelingPerspectiveSlot();
void switchToPlottingPerspectiveSlot();
void switchToAlgorithmicDebuggingPerspectiveSlot();
void switchToAnimationPerspectiveSlot();
void showConfigureDialog();
void showAttachToProcessDialog();
private:
Expand All @@ -444,6 +449,7 @@ private slots:
void switchToModelingPerspective();
void switchToPlottingPerspective();
void switchToAlgorithmicDebuggingPerspective();
void switchToAnimationPerspective();
void closeAllWindowsButThis(QMdiArea *pMdiArea);
void tileSubWindows(QMdiArea *pMdiArea, bool horizontally);
void fetchInterfaceDataHelper(LibraryTreeItem *pLibraryTreeItem);
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/OMEditGUI.pro
Expand Up @@ -121,6 +121,7 @@ SOURCES += main.cpp \
Editors/MetaModelEditor.cpp \
Editors/MetaModelicaEditor.cpp \
Plotting/PlotWindowContainer.cpp \
Animation/AnimationWindowContainer.cpp \
Component/Component.cpp \
Annotations/ShapeAnnotation.cpp \
Component/CornerItem.cpp \
Expand Down Expand Up @@ -183,6 +184,7 @@ HEADERS += Util/Helper.h \
Editors/CEditor.h \
Editors/MetaModelEditor.h \
Editors/MetaModelicaEditor.h \
Animation/AnimationWindowContainer.h \
Plotting/PlotWindowContainer.h \
Component/Component.h \
Annotations/ShapeAnnotation.h \
Expand Down

0 comments on commit 8b08221

Please sign in to comment.