Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Only allow simulation for Model, Class & Block.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23849 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Dec 18, 2014
1 parent 8ea9c8b commit ee9b2ea
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
42 changes: 30 additions & 12 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -1124,6 +1124,22 @@ LibraryTreeNode* LibraryTreeWidget::findParentLibraryTreeNodeSavedInSameFile(Lib
}
}

bool LibraryTreeWidget::isSimulationAllowed(LibraryTreeNode *pLibraryTreeNode)
{
if (pLibraryTreeNode) {
switch (pLibraryTreeNode->getModelicaType()) {
case StringHandler::Model:
case StringHandler::Class:
case StringHandler::Block:
return true;
default:
return false;
}
} else {
return false;
}
}

bool LibraryTreeWidget::saveModelicaLibraryTreeNode(LibraryTreeNode *pLibraryTreeNode)
{
bool result = false;
Expand Down Expand Up @@ -1573,31 +1589,33 @@ void LibraryTreeWidget::showContextMenu(QPoint point)
{
int adjust = 24;
LibraryTreeNode *pLibraryTreeNode = dynamic_cast<LibraryTreeNode*>(itemAt(point));
if (pLibraryTreeNode)
{
if (pLibraryTreeNode) {
QMenu menu(this);
switch (pLibraryTreeNode->getLibraryType())
{
switch (pLibraryTreeNode->getLibraryType()) {
case LibraryTreeNode::Modelica:
default:
menu.addAction(mpViewClassAction);
menu.addAction(mpViewDocumentationAction);
if (!(pLibraryTreeNode->isSystemLibrary() || isSearchedTree()))
{
if (!(pLibraryTreeNode->isSystemLibrary() || isSearchedTree())) {
menu.addSeparator();
menu.addAction(mpNewModelicaClassAction);
}
menu.addSeparator();
menu.addAction(mpInstantiateModelAction);
menu.addAction(mpCheckModelAction);
menu.addAction(mpCheckAllModelsAction);
menu.addAction(mpSimulateAction);
menu.addAction(mpSimulateWithTransformationalDebuggerAction);
menu.addAction(mpSimulateWithAlgorithmicDebuggerAction);
menu.addAction(mpSimulationSetupAction);
/*
Ticket #3040.
Only show the simulation actions for Modelica types on which the simulation is allowed.
*/
if (isSimulationAllowed(pLibraryTreeNode)) {
menu.addAction(mpSimulateAction);
menu.addAction(mpSimulateWithTransformationalDebuggerAction);
menu.addAction(mpSimulateWithAlgorithmicDebuggerAction);
menu.addAction(mpSimulationSetupAction);
}
/* If item is OpenModelica or part of it or is search tree item then don't show the unload for it. */
if (!((StringHandler::getFirstWordBeforeDot(pLibraryTreeNode->getNameStructure()).compare("OpenModelica") == 0) || isSearchedTree()))
{
if (!((StringHandler::getFirstWordBeforeDot(pLibraryTreeNode->getNameStructure()).compare("OpenModelica") == 0) || isSearchedTree())) {
menu.addSeparator();
menu.addAction(mpCopyClassAction);
menu.addAction(mpUnloadClassAction);
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.h
Expand Up @@ -183,6 +183,7 @@ class LibraryTreeWidget : public QTreeWidget
void unloadClassHelper(LibraryTreeNode *pLibraryTreeNode);
bool saveLibraryTreeNode(LibraryTreeNode *pLibraryTreeNode);
LibraryTreeNode* findParentLibraryTreeNodeSavedInSameFile(LibraryTreeNode *pLibraryTreeNode, QFileInfo fileInfo);
bool isSimulationAllowed(LibraryTreeNode *pLibraryTreeNode);
private:
MainWindow *mpMainWindow;
bool mIsSearchTree;
Expand Down
8 changes: 4 additions & 4 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -3141,10 +3141,10 @@ void ModelWidgetContainer::currentModelWidgetChanged(QMdiSubWindow *pSubWindow)
getMainWindow()->getResetZoomAction()->setEnabled(enabled && modelica);
getMainWindow()->getZoomInAction()->setEnabled(enabled && modelica);
getMainWindow()->getZoomOutAction()->setEnabled(enabled && modelica);
getMainWindow()->getSimulateModelAction()->setEnabled(enabled && modelica);
getMainWindow()->getSimulateWithTransformationalDebuggerAction()->setEnabled(enabled && modelica);
getMainWindow()->getSimulateWithAlgorithmicDebuggerAction()->setEnabled(enabled && modelica);
getMainWindow()->getSimulationSetupAction()->setEnabled(enabled && modelica);
getMainWindow()->getSimulateModelAction()->setEnabled(enabled && modelica && mpMainWindow->getLibraryTreeWidget()->isSimulationAllowed(pLibraryTreeNode));
getMainWindow()->getSimulateWithTransformationalDebuggerAction()->setEnabled(enabled && modelica && mpMainWindow->getLibraryTreeWidget()->isSimulationAllowed(pLibraryTreeNode));
getMainWindow()->getSimulateWithAlgorithmicDebuggerAction()->setEnabled(enabled && modelica && mpMainWindow->getLibraryTreeWidget()->isSimulationAllowed(pLibraryTreeNode));
getMainWindow()->getSimulationSetupAction()->setEnabled(enabled && modelica && mpMainWindow->getLibraryTreeWidget()->isSimulationAllowed(pLibraryTreeNode));
getMainWindow()->getInstantiateModelAction()->setEnabled(enabled && modelica);
getMainWindow()->getCheckModelAction()->setEnabled(enabled && modelica);
getMainWindow()->getCheckAllModelsAction()->setEnabled(enabled && modelica);
Expand Down

0 comments on commit ee9b2ea

Please sign in to comment.