Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions OMEdit/OMEditGUI/Interfaces/InformationInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, 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 <[email protected]>
*/

#ifndef INFORMATIONINTERFACE_H
#define INFORMATIONINTERFACE_H

class InformationInterface
{
public:
virtual QString name() = 0;
virtual QIcon icon() = 0;
};

Q_DECLARE_INTERFACE(InformationInterface, "org.openmodelica.OMEdit.InformationInterface")

#endif // INFORMATIONINTERFACE_H
61 changes: 61 additions & 0 deletions OMEdit/OMEditGUI/Interfaces/Model.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, 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 <[email protected]>
*/

#include "Model.h"
#include "Modeling/ModelWidgetContainer.h"

Model::Model(ModelWidget *pModelWidget)
{
mModelName = pModelWidget->getLibraryTreeItem()->getNameStructure();
mFilePath = pModelWidget->getLibraryTreeItem()->getFileName();

foreach (Component *pComponent, pModelWidget->getDiagramGraphicsView()->getComponentsList()) {
ComponentInformation componentInformation;
componentInformation.mClassName = pComponent->getComponentInfo()->getClassName();
componentInformation.mName = pComponent->getComponentInfo()->getName();
componentInformation.mComment = pComponent->getComponentInfo()->getComment();
componentInformation.mIsProtected = pComponent->getComponentInfo()->getProtected();
componentInformation.mIsFinal = pComponent->getComponentInfo()->getFinal();
componentInformation.mIsFlow = pComponent->getComponentInfo()->getFlow();
componentInformation.mIsStream = pComponent->getComponentInfo()->getStream();
componentInformation.mIsReplaceable = pComponent->getComponentInfo()->getReplaceable();
componentInformation.mVariability = pComponent->getComponentInfo()->getVariablity();
componentInformation.mIsInner = pComponent->getComponentInfo()->getInner();
componentInformation.mIsOuter = pComponent->getComponentInfo()->getOuter();
componentInformation.mCasuality = pComponent->getComponentInfo()->getCausality();
componentInformation.mArrayIndex = pComponent->getComponentInfo()->getArrayIndex();
componentInformation.mParameterValue = pComponent->getComponentInfo()->getParameterValue(MainWindow::instance()->getOMCProxy(), mModelName);

mComponents.append(componentInformation);
}
}
69 changes: 69 additions & 0 deletions OMEdit/OMEditGUI/Interfaces/Model.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, 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 <[email protected]>
*/

#ifndef MODEL_H
#define MODEL_H

#include <QString>
#include <QList>

class ModelWidget;

typedef struct {
QString mClassName;
QString mName;
QString mComment;
bool mIsProtected;
bool mIsFinal;
bool mIsFlow;
bool mIsStream;
bool mIsReplaceable;
QString mVariability;
bool mIsInner;
bool mIsOuter;
QString mCasuality;
QString mArrayIndex;
QString mParameterValue;
} ComponentInformation;

class Model
{
public:
Model(ModelWidget *pModelWidget);

QString mModelName;
QString mFilePath;
QList<ComponentInformation> mComponents;
};

#endif // MODEL_H
47 changes: 47 additions & 0 deletions OMEdit/OMEditGUI/Interfaces/ModelInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, 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 <[email protected]>
*/

#ifndef MODELINTERFACE_H
#define MODELINTERFACE_H

#include "Model.h"

class ModelInterface
{
public:
virtual void analyzeModel(const Model &model) = 0;
};

Q_DECLARE_INTERFACE(ModelInterface, "org.openmodelica.OMEdit.ModelInterface")

#endif // MODELINTERFACE_H
43 changes: 43 additions & 0 deletions OMEdit/OMEditGUI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
#include "Traceability/TraceabilityInformationURI.h"
#include "Traceability/TraceabilityGraphViewWidget.h"
#include "Plotting/DiagramWindow.h"
#include "Interfaces/InformationInterface.h"
#include "Interfaces/ModelInterface.h"
#include "Interfaces/Model.h"
#include "omc_config.h"

#include <QtSvg/QSvgGenerator>
Expand Down Expand Up @@ -2518,6 +2521,24 @@ void MainWindow::openConfigurationOptions()
OptionsDialog::instance()->show();
}

/*!
* \brief MainWindow::runOMSensPlugin
* Slots activated when OMSens plugin action is triggered.\n
* Runs OMSens plugin.
*/
void MainWindow::runOMSensPlugin()
{
ModelWidget *pModelWidget = mpModelWidgetContainer->getCurrentModelWidget();
if (pModelWidget) {
QAction *pAction = qobject_cast<QAction *>(sender());
ModelInterface *pModelInterface = qobject_cast<ModelInterface*>(pAction->parent());
pModelInterface->analyzeModel(Model(pModelWidget));
} else {
QMessageBox::information(this, QString("%1 - %2").arg(Helper::applicationName).arg(Helper::information),
tr("Please open a model before starting the OMSens plugin."), Helper::ok);
}
}

/*!
* \brief MainWindow::openUsersGuide
* Slot activated when mpUsersGuideAction triggered signal is raised.\n
Expand Down Expand Up @@ -3867,6 +3888,28 @@ void MainWindow::createMenus()
pToolsMenu->addAction(mpOpenTerminalAction);
pToolsMenu->addSeparator();
pToolsMenu->addAction(mpOptionsAction);
// Plugins View Menu
mpPluginsMenu = new QMenu(menuBar());
mpPluginsMenu->setObjectName("PluginsMenu");
mpPluginsMenu->setTitle(tr("Plugins"));
// load OMSens plugin
#ifdef Q_OS_WIN
QPluginLoader loader("../../../OMSensPlugin/bin/OMSensPlugin.dll");
#elif defined(Q_OS_MAC)
QPluginLoader loader("../../../OMSensPlugin/bin/libOMSensPlugin.dylib");
#else
QPluginLoader loader("../../../OMSensPlugin/bin/libOMSensPlugin.so");
#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of asking the user to load plugin, I changed it to load the plugin automatically. Once the actual OMSens plugin is placed in the OpenModelica repos then we need to update these links. Right now they are using a dummy OMSensPlugin which just shows how to implement and use the interfaces.

QObject *pOMSensPlugin = loader.instance();
if (pOMSensPlugin) {
InformationInterface *pInformationInterface = qobject_cast<InformationInterface*>(pOMSensPlugin);
// Add OMSens plugin action to plugins menu
QAction *pOMSensPluginAction = new QAction(pInformationInterface->icon(), pInformationInterface->name(), pOMSensPlugin);
connect(pOMSensPluginAction, SIGNAL(triggered()), SLOT(runOMSensPlugin()));
mpPluginsMenu->addAction(pOMSensPluginAction);
}
pToolsMenu->addSeparator();
pToolsMenu->addMenu(mpPluginsMenu);
// add Tools menu to menu bar
menuBar()->addAction(pToolsMenu->menuAction());
// Help menu
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ class MainWindow : public QMainWindow
// Toolbars
QMenu *mpRecentFilesMenu;
QMenu *mpLibrariesMenu;
QMenu *mpPluginsMenu;
QToolBar *mpFileToolBar;
QToolBar *mpEditToolBar;
QToolBar *mpViewToolBar;
Expand Down Expand Up @@ -509,6 +510,7 @@ public slots:
void openWorkingDirectory();
void openTerminal();
void openConfigurationOptions();
void runOMSensPlugin();
void openUsersGuide();
void openUsersGuidePdf();
void openUsersGuideOldPdf();
Expand Down
8 changes: 6 additions & 2 deletions OMEdit/OMEditGUI/OMEditGUI.pro
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ SOURCES += main.cpp \
OMS/InstantiateDialog.cpp \
OMS/OMSSimulationDialog.cpp \
OMS/OMSSimulationOutputWidget.cpp \
Animation/TimeManager.cpp
Animation/TimeManager.cpp \
Interfaces/Model.cpp

HEADERS += Util/Helper.h \
Util/Utilities.h \
Expand Down Expand Up @@ -296,7 +297,10 @@ HEADERS += Util/Helper.h \
OMS/OMSSimulationOptions.h \
OMS/OMSSimulationDialog.h \
OMS/OMSSimulationOutputWidget.h \
Animation/TimeManager.h
Animation/TimeManager.h \
Interfaces/InformationInterface.h \
Interfaces/ModelInterface.h \
Interfaces/Model.h

CONFIG(osg) {

Expand Down