Skip to content

Commit a61de9f

Browse files
committed
Merge branch 'master' of https://github.com/OpenModelica/OMEdit
2 parents f96db64 + ce2b3a4 commit a61de9f

File tree

3 files changed

+57
-26
lines changed

3 files changed

+57
-26
lines changed

OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,8 @@ bool ShapeAnnotation::isLineStraight(QPointF point1, QPointF point2)
18321832
*/
18331833
void ShapeAnnotation::showShapeProperties()
18341834
{
1835-
if (!mpGraphicsView) return;
1835+
if (!mpGraphicsView || mpGraphicsView->getModelWidget()->getLibraryTreeNode()->getLibraryType()== LibraryTreeNode::TLM)
1836+
return;
18361837
MainWindow *pMainWindow = mpGraphicsView->getModelWidget()->getModelWidgetContainer()->getMainWindow();
18371838
ShapePropertiesDialog *pShapePropertiesDialog = new ShapePropertiesDialog(this, pMainWindow);
18381839
pShapePropertiesDialog->exec();
@@ -1855,33 +1856,37 @@ void ShapeAnnotation::contextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent)
18551856
}
18561857

18571858
QMenu menu(mpGraphicsView);
1858-
menu.addAction(mpShapePropertiesAction);
1859-
menu.addSeparator();
1860-
if (isInheritedShape()) {
1861-
mpGraphicsView->getDeleteAction()->setDisabled(true);
1862-
mpGraphicsView->getDuplicateAction()->setDisabled(true);
1863-
mpGraphicsView->getRotateClockwiseAction()->setDisabled(true);
1864-
mpGraphicsView->getRotateAntiClockwiseAction()->setDisabled(true);
1865-
}
1866-
LineAnnotation *pLineAnnotation = dynamic_cast<LineAnnotation*>(this);
1867-
LineAnnotation::LineType lineType = LineAnnotation::ShapeType;
1868-
if (pLineAnnotation) {
1869-
lineType = pLineAnnotation->getLineType();
1870-
menu.addAction(mpManhattanizeShapeAction);
1871-
}
1872-
if (lineType == LineAnnotation::ConnectionType) {
1859+
if(mpGraphicsView->getModelWidget()->getLibraryTreeNode()->getLibraryType()== LibraryTreeNode::TLM){
18731860
menu.addAction(mpGraphicsView->getDeleteConnectionAction());
18741861
} else {
1875-
menu.addAction(mpGraphicsView->getDeleteAction());
1876-
menu.addAction(mpGraphicsView->getDuplicateAction());
1862+
menu.addAction(mpShapePropertiesAction);
18771863
menu.addSeparator();
1878-
menu.addAction(mpGraphicsView->getBringToFrontAction());
1879-
menu.addAction(mpGraphicsView->getBringForwardAction());
1880-
menu.addAction(mpGraphicsView->getSendToBackAction());
1881-
menu.addAction(mpGraphicsView->getSendBackwardAction());
1882-
menu.addSeparator();
1883-
menu.addAction(mpGraphicsView->getRotateClockwiseAction());
1884-
menu.addAction(mpGraphicsView->getRotateAntiClockwiseAction());
1864+
if (isInheritedShape()) {
1865+
mpGraphicsView->getDeleteAction()->setDisabled(true);
1866+
mpGraphicsView->getDuplicateAction()->setDisabled(true);
1867+
mpGraphicsView->getRotateClockwiseAction()->setDisabled(true);
1868+
mpGraphicsView->getRotateAntiClockwiseAction()->setDisabled(true);
1869+
}
1870+
LineAnnotation *pLineAnnotation = dynamic_cast<LineAnnotation*>(this);
1871+
LineAnnotation::LineType lineType = LineAnnotation::ShapeType;
1872+
if (pLineAnnotation) {
1873+
lineType = pLineAnnotation->getLineType();
1874+
menu.addAction(mpManhattanizeShapeAction);
1875+
}
1876+
if (lineType == LineAnnotation::ConnectionType) {
1877+
menu.addAction(mpGraphicsView->getDeleteConnectionAction());
1878+
} else {
1879+
menu.addAction(mpGraphicsView->getDeleteAction());
1880+
menu.addAction(mpGraphicsView->getDuplicateAction());
1881+
menu.addSeparator();
1882+
menu.addAction(mpGraphicsView->getBringToFrontAction());
1883+
menu.addAction(mpGraphicsView->getBringForwardAction());
1884+
menu.addAction(mpGraphicsView->getSendToBackAction());
1885+
menu.addAction(mpGraphicsView->getSendBackwardAction());
1886+
menu.addSeparator();
1887+
menu.addAction(mpGraphicsView->getRotateClockwiseAction());
1888+
menu.addAction(mpGraphicsView->getRotateAntiClockwiseAction());
1889+
}
18851890
}
18861891
menu.exec(pEvent->screenPos());
18871892
}

OMEdit/OMEditGUI/Editors/TLMEditor.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ void TLMEditor::addInterfacesData(QDomElement interfaces)
308308
QDomElement subModel = subModelList.at(i).toElement();
309309
QDomElement interfaceDataElement = interfaces.firstChildElement();
310310
while (!interfaceDataElement.isNull()) {
311-
if (subModel.attribute("Name").compare(interfaceDataElement.attribute("model")) == 0) {
311+
if (subModel.attribute("Name").compare(interfaceDataElement.attribute("model")) == 0
312+
&& !existInterfaceData(subModel.attribute("Name"), interfaceDataElement.attribute("name"))) {
312313
QDomElement interfacePoint = mXmlDocument.createElement("InterfacePoint");
313314
interfacePoint.setAttribute("Name",interfaceDataElement.attribute("name"));
314315
interfacePoint.setAttribute("Position",interfaceDataElement.attribute("Position"));
@@ -321,6 +322,30 @@ void TLMEditor::addInterfacesData(QDomElement interfaces)
321322
}
322323
}
323324

325+
/*!
326+
Checks whether the interface already exists in MetaModel or not.
327+
\param interfaceName - the name for the interface to check.
328+
\return true on success.
329+
*/
330+
bool TLMEditor::existInterfaceData(QString subModelName, QString interfaceName)
331+
{
332+
QDomNodeList subModelList = mXmlDocument.elementsByTagName("SubModel");
333+
for (int i = 0 ; i < subModelList.size() ; i++) {
334+
QDomElement subModel = subModelList.at(i).toElement();
335+
if (subModel.attribute("Name").compare(subModelName) == 0) {
336+
QDomNodeList subModelChildren = subModel.childNodes();
337+
for (int j = 0 ; j < subModelChildren.size() ; j++) {
338+
QDomElement interfaceElement = subModelChildren.at(j).toElement();
339+
if (interfaceElement.tagName().compare("InterfacePoint") == 0 && interfaceElement.attribute("Name").compare(interfaceName)== 0) {
340+
return true;
341+
}
342+
}
343+
break;
344+
}
345+
}
346+
return false;
347+
}
348+
324349
/*!
325350
* \brief TLMEditor::deleteSubModel
326351
* Delets a SubModel.

OMEdit/OMEditGUI/Editors/TLMEditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class TLMEditor : public BaseEditor
6060
bool createConnection(QString From, QString To, QString delay, QString alpha, QString zf, QString zfr, QString points);
6161
void updateTLMConnectiontAnnotation(QString fromSubModel, QString toSubModel, QString points);
6262
void addInterfacesData(QDomElement interfaces);
63+
bool existInterfaceData(QString subModelName, QString interfaceName);
6364
bool deleteSubModel(QString name);
6465
bool deleteConnection(QString startComponentName, QString endComponentName );
6566
private:

0 commit comments

Comments
 (0)