Skip to content

Commit

Permalink
Tracing overlay: prevent mixing connector types when creating new links
Browse files Browse the repository at this point in the history
The CATMAID front-end assigns types to connectors based on its links to
treenodes (or uses the default connector type), e.g. 'synaptic' or
'desmosome'. When creating new links it was possible so far to add links
to a connector that wouldn't fit to its existing links, even causing the
(non-persisted) connector type to be overridden. This is fixed now by
checking the connector types before adding a new link to a connector
that already has links. If they conflict, a warning is shown and now
link is added. Thanks to Sanja Jasek for bringing this up.
  • Loading branch information
tomka committed Feb 21, 2019
1 parent 9c38c8d commit 44d7503
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions django/applications/catmaid/static/js/widgets/overlay-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,8 @@
// connected activated treenode or connectornode
// to existing treenode or connectornode
if (atnType === SkeletonAnnotations.TYPE_CONNECTORNODE) {
var atnSubType = SkeletonAnnotations.getActiveNodeSubType();
let atnSubType = SkeletonAnnotations.getActiveNodeSubType();
let connectorNode = catmaidTracingOverlay.nodes.get(atnID);

// If the Alt key is pressed, we want to show a menu for
// connector type selection.
Expand All @@ -1514,11 +1515,19 @@
catmaidTracingOverlay.askForConnectorType()
.then(function(selection) {
if (selection) {
SkeletonAnnotations.atn.subtype = selection.value;
catmaidTracingOverlay.createLink(node.id, atnID, selection.relation)
.catch(CATMAID.handleError);
// Don't allow link combinations that would result in a
// mixed connector type.
if (connectorNode.links && connectorNode.links.length > 0 &&
connectorNode.subtype !== selection.value) {
throw new CATMAID.Warning(`Can't mix connector types ` +
`${connectorNode.subtype} and ${selection.value}`);
}
connectorNode.subtype = selection.value;
catmaidTracingOverlay.createLink(node.id, atnID,
selection.relation);
}
});
})
.catch(CATMAID.handleError);
return;
}

Expand Down Expand Up @@ -1778,11 +1787,19 @@
catmaidTracingOverlay.askForConnectorType()
.then(function(selection) {
if (selection) {
// Don't allow link combinations that would result in a
// mixed connector type.
if (connectornode.links && connectornode.links.length > 0 &&
connectornode.subtype !== selection.value) {
throw new CATMAID.Warning(`Can't mix connector types ` +
`${connectornode.subtype} and ${selection.value}`);
}
connectornode.subtype = selection.value;
catmaidTracingOverlay.createLink(atnID, connectornode.id, selection.relation)
.catch(CATMAID.handleError);
return catmaidTracingOverlay.createLink(atnID,
connectornode.id, selection.relation);
}
});
})
.catch(CATMAID.handleError);
return;
}
if (connectornode.subtype === CATMAID.Connectors.SUBTYPE_GAPJUNCTION_CONNECTOR) {
Expand Down

0 comments on commit 44d7503

Please sign in to comment.