Skip to content

Commit

Permalink
- TLM editor updateTLMConnectiontAnnotation API
Browse files Browse the repository at this point in the history
  • Loading branch information
alash325 committed Jun 24, 2015
1 parent d248ffe commit 8206e21
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
29 changes: 3 additions & 26 deletions OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp
Expand Up @@ -643,33 +643,10 @@ void LineAnnotation::handleComponentRotation()
void LineAnnotation::updateConnectionAnnotation()
{
if (mpGraphicsView->getModelWidget()->getLibraryTreeNode()->getLibraryType()== LibraryTreeNode::TLM) {
QDomDocument doc;
doc.setContent(mpGraphicsView->getModelWidget()->getEditor()->getPlainTextEdit()->toPlainText());
TLMEditor *pTLMEditor = dynamic_cast<TLMEditor*>(mpGraphicsView->getModelWidget()->getEditor());
pTLMEditor->updateTLMConnectiontAnnotation(getStartComponentName(), getEndComponentName(), getTLMShapeAnnotation());

// Get the "Root" element
QDomElement docElem = doc.documentElement();

QDomElement connections = docElem.firstChildElement();
while (!connections.isNull()) {
if(connections.tagName() == "Connections")
break;
connections = connections.nextSiblingElement();
}
QDomElement connection = connections.firstChildElement();
while (!connection.isNull()) {
if(connection.tagName() == "Connection" &&
StringHandler::getSubStringBeforeDots(connection.attribute("From")) == getStartComponentName() &&
StringHandler::getSubStringBeforeDots(connection.attribute("To")) == getEndComponentName()) {
QDomElement annotation = connection.firstChildElement("Annotation");
annotation.setAttribute("Points",getTLMShapeAnnotation());
break;
}
connection = connection.nextSiblingElement();
}
QString metaModelText = doc.toString();
MainWindow *pMainWindow = mpGraphicsView->getModelWidget()->getModelWidgetContainer()->getMainWindow();
pMainWindow->getModelWidgetContainer()->getCurrentModelWidget()->getEditor()->getPlainTextEdit()->setPlainText(metaModelText);
} else {
} else {
// get the connection line annotation.
QString annotationString = QString("annotate=").append(getShapeAnnotation());
// update the connection
Expand Down
28 changes: 28 additions & 0 deletions OMEdit/OMEditGUI/Editors/TLMEditor.cpp
Expand Up @@ -268,6 +268,34 @@ bool TLMEditor::createConnection(QString from, QString to, QString delay, QStrin
return false;
}

/*!
* \brief TLMEditor::updateTLMConnectiontAnnotation
* Updates the TLM connection annotation.
* \param fromSubModel
* \param toSubModel
* \param points
*/
void TLMEditor::updateTLMConnectiontAnnotation(QString fromSubModel, QString toSubModel, QString points)
{
QDomNodeList connectionList = mXmlDocument.elementsByTagName("Connection");
for (int i = 0 ; i < connectionList.size() ; i++) {
QDomElement connection = connectionList.at(i).toElement();
if (StringHandler::getSubStringBeforeDots(connection.attribute("From")).compare(fromSubModel) == 0
&& StringHandler::getSubStringBeforeDots(connection.attribute("To")).compare(toSubModel) == 0) {
QDomNodeList connectionChildren = connection.childNodes();
for (int j = 0 ; j < connectionChildren.size() ; j++) {
QDomElement annotationElement = connectionChildren.at(j).toElement();
if (annotationElement.tagName().compare("Annotation") == 0) {
annotationElement.setAttribute("Points", points);
mpPlainTextEdit->setPlainText(mXmlDocument.toString());
return;
}
}
break;
}
}
}

/*!
* \brief TLMEditor::addInterfacesData
* Adds the InterfacePoint tag to SubModel.
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Editors/TLMEditor.h
Expand Up @@ -58,6 +58,7 @@ class TLMEditor : public BaseEditor
void createAnnotationElement(QDomElement subModel, QString visible, QString origin, QString extent, QString rotation);
void updateSubModelPlacementAnnotation(QString name, QString visible, QString origin, QString extent, QString rotation);
bool createConnection(QString From, QString To, QString delay, QString alpha, QString zf, QString zfr, QString points);
void updateTLMConnectiontAnnotation(QString fromSubModel, QString toSubModel, QString points);
void addInterfacesData(QDomElement interfaces);
bool deleteSubModel(QString name);
bool deleteConnection(QString startComponentName, QString endComponentName );
Expand Down

0 comments on commit 8206e21

Please sign in to comment.