Skip to content

Commit

Permalink
ticket:4956 Fixed color and width of connecting lines
Browse files Browse the repository at this point in the history
Use the color of the icon layer first shape for connection line.
Use the thickness 0.5 when both connectors are expandable otherwise 0.25
  • Loading branch information
adeas31 committed Aug 13, 2018
1 parent 1c58f5d commit 390f239
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
22 changes: 18 additions & 4 deletions OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp
Expand Up @@ -122,10 +122,24 @@ LineAnnotation::LineAnnotation(LineAnnotation::LineType lineType, Component *pSt
setSynchronize(false);
setPriority(1);
if (mLineType == LineAnnotation::ConnectionType) {
// use the linecolor of start component for the connection line.
if (pStartComponent->getShapesList().size() > 0) {
ShapeAnnotation *pShapeAnnotation = pStartComponent->getShapesList().at(0);
mLineColor = pShapeAnnotation->getLineColor();
/* Use the linecolor of the first shape from icon layer of start component for the connection line.
* Or use black color if there is no shape in the icon layer
* Dymola is doing it the way explained above. The Modelica specification doesn't say anything about it.
* We are also doing it the same way except that we will use the diagram layer shape if there is no shape in the icon layer.
* If there is no shape even in diagram layer then use the default black color.
*/
if (pStartComponent->getLibraryTreeItem()) {
if (!pStartComponent->getLibraryTreeItem()->getModelWidget()) {
MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->showModelWidget(pStartComponent->getLibraryTreeItem(), false);
}
ShapeAnnotation *pShapeAnnotation;
if (pStartComponent->getLibraryTreeItem()->getModelWidget()->getIconGraphicsView()->getShapesList().size() > 0) {
pShapeAnnotation = pStartComponent->getLibraryTreeItem()->getModelWidget()->getIconGraphicsView()->getShapesList().at(0);
mLineColor = pShapeAnnotation->getLineColor();
} else if (pStartComponent->getShapesList().size() > 0) {
ShapeAnnotation *pShapeAnnotation = pStartComponent->getShapesList().at(0);
mLineColor = pShapeAnnotation->getLineColor();
}
}
mpTextAnnotation = 0;
} else if (mLineType == LineAnnotation::TransitionType) {
Expand Down
18 changes: 18 additions & 0 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -1468,6 +1468,24 @@ void GraphicsView::addConnection(Component *pComponent)
GUIMessages::getMessage(GUIMessages::SAME_COMPONENT_CONNECT), Helper::ok);
removeCurrentConnection();
} else {
/* Ticket:4956
* Only set the connection line thickness to 0.5 when both connectors are either expandable or array.
* Otherwise set it to 0.25 i.e., default.
*/
if (((pStartComponent->getLibraryTreeItem() && pStartComponent->getLibraryTreeItem()->getRestriction() == StringHandler::ExpandableConnector) ||
(pStartComponent->getParentComponent() && pStartComponent->getRootParentComponent()->getComponentInfo()->isArray()) ||
(!pStartComponent->getParentComponent() && pStartComponent->getRootParentComponent()->getLibraryTreeItem() && pStartComponent->getRootParentComponent()->getLibraryTreeItem()->getRestriction() == StringHandler::ExpandableConnector) ||
(pStartComponent->getParentComponent() && pStartComponent->getLibraryTreeItem() && pStartComponent->getLibraryTreeItem()->getRestriction() == StringHandler::ExpandableConnector) ||
(pStartComponent->getComponentInfo() && pStartComponent->getComponentInfo()->isArray())) &&
((pComponent->getLibraryTreeItem() && pComponent->getLibraryTreeItem()->getRestriction() == StringHandler::ExpandableConnector) ||
(pComponent->getParentComponent() && pComponent->getRootParentComponent()->getComponentInfo()->isArray()) ||
(!pComponent->getParentComponent() && pComponent->getRootParentComponent()->getLibraryTreeItem() && pComponent->getRootParentComponent()->getLibraryTreeItem()->getRestriction() == StringHandler::ExpandableConnector) ||
(pComponent->getParentComponent() && pComponent->getLibraryTreeItem() && pComponent->getLibraryTreeItem()->getRestriction() == StringHandler::ExpandableConnector) ||
(pComponent->getComponentInfo() && pComponent->getComponentInfo()->isArray()))) {
mpConnectionLineAnnotation->setLineThickness(0.5);
} else {
mpConnectionLineAnnotation->setLineThickness(0.25);
}
// check of any of starting or ending components are array
bool showConnectionArrayDialog = false;
if ((pStartComponent->getParentComponent() && pStartComponent->getRootParentComponent()->getComponentInfo()->isArray()) ||
Expand Down

0 comments on commit 390f239

Please sign in to comment.