Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit b1cb26e

Browse files
committed
Only show input/output connectors on the view
Fixed few minor bugs
1 parent ef02fdd commit b1cb26e

3 files changed

Lines changed: 5 additions & 163 deletions

File tree

OMEdit/OMEditGUI/MainWindow.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,9 +1552,7 @@ void MainWindow::openOMSModelFile()
15521552
pMessageBox->setStandardButtons(QMessageBox::Ok);
15531553
pMessageBox->exec();
15541554
} else {
1555-
/*! @todo Call LibraryWidget::openFile once we replace the TLM Composite modeling with OMSimulator. */
1556-
QFileInfo fileInfo(file);
1557-
mpLibraryWidget->openOMSModelFile(fileInfo);
1555+
mpLibraryWidget->openFile(file, Helper::utf8);
15581556
}
15591557
}
15601558
mpStatusBar->clearMessage();

OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp

Lines changed: 4 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -3838,6 +3838,7 @@ void ModelWidget::createModelWidgetComponents()
38383838
pViewButtonsHorizontalLayout->addWidget(mpTextViewToolButton);
38393839
// create an xml editor for CompositeModel
38403840
mpEditor = new OMSimulatorEditor(this);
3841+
mpEditor->getPlainTextEdit()->setReadOnly(true);
38413842
OMSimulatorEditor *pOMSimulatorEditor = dynamic_cast<OMSimulatorEditor*>(mpEditor);
38423843
if (mpLibraryTreeItem->getFileName().isEmpty()) {
38433844
QString contents;
@@ -5858,7 +5859,9 @@ void ModelWidget::drawOMSModelIconElements()
58585859
}
58595860
for (int i = 0 ; i < mpLibraryTreeItem->childrenSize() ; i++) {
58605861
LibraryTreeItem *pChildLibraryTreeItem = mpLibraryTreeItem->childAt(i);
5861-
if (pChildLibraryTreeItem->getOMSConnector()) {
5862+
if (pChildLibraryTreeItem->getOMSConnector()
5863+
&& (pChildLibraryTreeItem->getOMSConnector()->causality == oms_causality_input
5864+
|| pChildLibraryTreeItem->getOMSConnector()->causality == oms_causality_output)) {
58625865
double x = 0.5;
58635866
double y = 0.5;
58645867
if (pChildLibraryTreeItem->getOMSConnector()->geometry) {
@@ -5959,164 +5962,6 @@ void ModelWidget::drawOMSModelDiagramElements()
59595962
}
59605963
}
59615964

5962-
/*!
5963-
* \brief ModelWidget::drawOMSModelElements
5964-
* Draws the OMSimulator model elements.
5965-
*/
5966-
void ModelWidget::drawOMSModelElements()
5967-
{
5968-
if (mpLibraryTreeItem->getOMSElement()) {
5969-
if (mpLibraryTreeItem->isSystemElement()) {
5970-
for (int i = 0 ; i < mpLibraryTreeItem->childrenSize() ; i++) {
5971-
LibraryTreeItem *pChildLibraryTreeItem = mpLibraryTreeItem->childAt(i);
5972-
if (pChildLibraryTreeItem->getOMSElement() && pChildLibraryTreeItem->getOMSElement()->geometry) {
5973-
// check if we have zero width and height
5974-
double x1, y1, x2, y2;
5975-
x1 = pChildLibraryTreeItem->getOMSElement()->geometry->x1;
5976-
y1 = pChildLibraryTreeItem->getOMSElement()->geometry->y1;
5977-
x2 = pChildLibraryTreeItem->getOMSElement()->geometry->x2;
5978-
y2 = pChildLibraryTreeItem->getOMSElement()->geometry->y2;
5979-
double width = x2 - x1;
5980-
double height = y2 - y1;
5981-
if (width <= 0 && height <= 0) {
5982-
x1 = -10.0;
5983-
y1 = -10.0;
5984-
x2 = 10.0;
5985-
y2 = 10.0;
5986-
}
5987-
// Load the ModelWidget if not loaded already
5988-
if (!pChildLibraryTreeItem->getModelWidget()) {
5989-
MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->showModelWidget(pChildLibraryTreeItem, false);
5990-
}
5991-
5992-
QString annotation = QString("Placement(true,-,-,%1,%2,%3,%4,%5,-,-,-,-,-,-,)")
5993-
.arg(x1).arg(y1)
5994-
.arg(x2).arg(y2)
5995-
.arg(pChildLibraryTreeItem->getOMSElement()->geometry->rotation);
5996-
AddSubModelCommand *pAddSubModelCommand = new AddSubModelCommand(pChildLibraryTreeItem->getName(), "", pChildLibraryTreeItem,
5997-
annotation, true, mpDiagramGraphicsView);
5998-
mpUndoStack->push(pAddSubModelCommand);
5999-
}
6000-
}
6001-
} else if (mpLibraryTreeItem->isComponentElement()) {
6002-
if (mpLibraryTreeItem->getOMSElement()->geometry && mpLibraryTreeItem->getOMSElement()->geometry->iconSource) {
6003-
// Draw bitmap with icon source
6004-
QUrl url(mpLibraryTreeItem->getOMSElement()->geometry->iconSource);
6005-
QFileInfo fileInfo(url.toLocalFile());
6006-
BitmapAnnotation *pBitmapAnnotation = new BitmapAnnotation(fileInfo.absoluteFilePath(), mpDiagramGraphicsView);
6007-
pBitmapAnnotation->initializeTransformation();
6008-
pBitmapAnnotation->drawCornerItems();
6009-
pBitmapAnnotation->setCornerItemsActiveOrPassive();
6010-
mpDiagramGraphicsView->addShapeToList(pBitmapAnnotation);
6011-
mpDiagramGraphicsView->addItem(pBitmapAnnotation);
6012-
} else {
6013-
// Rectangle shape as base
6014-
RectangleAnnotation *pRectangleAnnotation = new RectangleAnnotation(mpDiagramGraphicsView);
6015-
pRectangleAnnotation->initializeTransformation();
6016-
pRectangleAnnotation->drawCornerItems();
6017-
pRectangleAnnotation->setCornerItemsActiveOrPassive();
6018-
mpDiagramGraphicsView->addShapeToList(pRectangleAnnotation);
6019-
mpDiagramGraphicsView->addItem(pRectangleAnnotation);
6020-
// Text for name
6021-
TextAnnotation *pTextAnnotation = new TextAnnotation(mpDiagramGraphicsView);
6022-
pTextAnnotation->initializeTransformation();
6023-
pTextAnnotation->drawCornerItems();
6024-
pTextAnnotation->setCornerItemsActiveOrPassive();
6025-
mpDiagramGraphicsView->addShapeToList(pTextAnnotation);
6026-
mpDiagramGraphicsView->addItem(pTextAnnotation);
6027-
}
6028-
for (int i = 0 ; i < mpLibraryTreeItem->childrenSize() ; i++) {
6029-
LibraryTreeItem *pChildLibraryTreeItem = mpLibraryTreeItem->childAt(i);
6030-
if (pChildLibraryTreeItem->getOMSConnector() && pChildLibraryTreeItem->getOMSConnector()->geometry) {
6031-
QString annotation = QString("Placement(true,%1,%2,-10,-10,10,10,-,-,-,-,-,-,-,)")
6032-
.arg(Utilities::mapToCoOrdinateSystem(pChildLibraryTreeItem->getOMSConnector()->geometry->x, 0, 1, -100, 100))
6033-
.arg(Utilities::mapToCoOrdinateSystem(pChildLibraryTreeItem->getOMSConnector()->geometry->y, 0, 1, -100, 100));
6034-
AddConnectorCommand *pAddConnectorCommand = new AddConnectorCommand(pChildLibraryTreeItem->getName(), pChildLibraryTreeItem,
6035-
annotation, mpDiagramGraphicsView, true,
6036-
pChildLibraryTreeItem->getOMSConnector()->causality,
6037-
pChildLibraryTreeItem->getOMSConnector()->type);
6038-
mpUndoStack->push(pAddConnectorCommand);
6039-
}
6040-
}
6041-
}
6042-
} else if (mpLibraryTreeItem->getOMSConnector()) {
6043-
qDebug() << "we should not reach here.";
6044-
// if (mpLibraryTreeItem->getOMSConnector()->causality == oms_causality_input) {
6045-
// QString annotation = "true, {0.0, 0.0}, 0, {0, 0, 127}, {0, 0, 127}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-100.0, 100.0}, {100.0, 0.0}, {-100.0, -100.0}}, Smooth.None";
6046-
// PolygonAnnotation *pPolygonAnnotation = new PolygonAnnotation(annotation, mpDiagramGraphicsView);
6047-
// switch (mpLibraryTreeItem->getOMSConnector()->type) {
6048-
// case oms_signal_type_integer:
6049-
// pPolygonAnnotation->setLineColor(QColor(255,127,0));
6050-
// pPolygonAnnotation->setFillColor(QColor(255,127,0));
6051-
// break;
6052-
// case oms_signal_type_boolean:
6053-
// pPolygonAnnotation->setLineColor(QColor(255,0,255));
6054-
// pPolygonAnnotation->setFillColor(QColor(255,0,255));
6055-
// break;
6056-
// case oms_signal_type_string:
6057-
// qDebug() << "ModelWidget::drawOMSModelElements oms_signal_type_string not implemented yet.";
6058-
// break;
6059-
// case oms_signal_type_enum:
6060-
// qDebug() << "ModelWidget::drawOMSModelElements oms_signal_type_enum not implemented yet.";
6061-
// break;
6062-
// case oms_signal_type_bus:
6063-
// qDebug() << "ModelWidget::drawOMSModelElements oms_signal_type_bus not implemented yet.";
6064-
// break;
6065-
// case oms_signal_type_real:
6066-
// default:
6067-
// pPolygonAnnotation->setLineColor(QColor(0, 0, 127));
6068-
// pPolygonAnnotation->setFillColor(QColor(0, 0, 127));
6069-
// break;
6070-
// }
6071-
// pPolygonAnnotation->initializeTransformation();
6072-
// pPolygonAnnotation->drawCornerItems();
6073-
// pPolygonAnnotation->setCornerItemsActiveOrPassive();
6074-
// pPolygonAnnotation->setToolTip(QString("%1 %2<br />%3: %4<br />%5: %6")
6075-
// .arg(Helper::name).arg(mpLibraryTreeItem->getOMSConnector()->name)
6076-
// .arg(Helper::type).arg(OMSProxy::getSignalTypeString(mpLibraryTreeItem->getOMSConnector()->type))
6077-
// .arg(tr("Causality")).arg(OMSProxy::getCausalityString(mpLibraryTreeItem->getOMSConnector()->causality)));
6078-
// mpDiagramGraphicsView->addShapeToList(pPolygonAnnotation);
6079-
// mpDiagramGraphicsView->addItem(pPolygonAnnotation);
6080-
// } else if (mpLibraryTreeItem->getOMSConnector()->causality == oms_causality_output) {
6081-
// QString annotation = "true, {0.0, 0.0}, 0, {0, 0, 127}, {255, 255, 255}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-100.0, 100.0}, {100.0, 0.0}, {-100.0, -100.0}}, Smooth.None";
6082-
// PolygonAnnotation *pPolygonAnnotation = new PolygonAnnotation(annotation, mpDiagramGraphicsView);
6083-
// switch (mpLibraryTreeItem->getOMSConnector()->type) {
6084-
// case oms_signal_type_integer:
6085-
// pPolygonAnnotation->setLineColor(QColor(255,127,0));
6086-
// pPolygonAnnotation->setFillColor(QColor(255,255,255));
6087-
// break;
6088-
// case oms_signal_type_boolean:
6089-
// pPolygonAnnotation->setLineColor(QColor(255,0,255));
6090-
// pPolygonAnnotation->setFillColor(QColor(255,255,255));
6091-
// break;
6092-
// case oms_signal_type_string:
6093-
// qDebug() << "ModelWidget::drawOMSModelElements oms_signal_type_string not implemented yet.";
6094-
// break;
6095-
// case oms_signal_type_enum:
6096-
// qDebug() << "ModelWidget::drawOMSModelElements oms_signal_type_enum not implemented yet.";
6097-
// break;
6098-
// case oms_signal_type_bus:
6099-
// qDebug() << "ModelWidget::drawOMSModelElements oms_signal_type_bus not implemented yet.";
6100-
// break;
6101-
// case oms_signal_type_real:
6102-
// default:
6103-
// pPolygonAnnotation->setLineColor(QColor(0, 0, 127));
6104-
// pPolygonAnnotation->setFillColor(QColor(255, 255, 255));
6105-
// break;
6106-
// }
6107-
// pPolygonAnnotation->initializeTransformation();
6108-
// pPolygonAnnotation->drawCornerItems();
6109-
// pPolygonAnnotation->setCornerItemsActiveOrPassive();
6110-
// pPolygonAnnotation->setToolTip(QString("%1 %2<br />%3: %4<br />%5: %6")
6111-
// .arg(Helper::name).arg(mpLibraryTreeItem->getOMSConnector()->name)
6112-
// .arg(Helper::type).arg(OMSProxy::getSignalTypeString(mpLibraryTreeItem->getOMSConnector()->type))
6113-
// .arg(tr("Causality")).arg(OMSProxy::getCausalityString(mpLibraryTreeItem->getOMSConnector()->causality)));
6114-
// mpDiagramGraphicsView->addShapeToList(pPolygonAnnotation);
6115-
// mpDiagramGraphicsView->addItem(pPolygonAnnotation);
6116-
// }
6117-
}
6118-
}
6119-
61205965
/*!
61215966
* \brief ModelWidget::drawOMSModelConnections
61225967
* Gets the OMSimulator model connections and draws them.

OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ class ModelWidget : public QWidget
491491
QString getCompositeModelName();
492492
void getCompositeModelSubModels();
493493
void getCompositeModelConnections();
494-
void drawOMSModelElements();
495494
void drawOMSModelIconElements();
496495
void drawOMSModelDiagramElements();
497496
void drawOMSModelConnections();

0 commit comments

Comments
 (0)