Skip to content

Commit

Permalink
SBGN Brick multimer edge connection workaround
Browse files Browse the repository at this point in the history
  Since cytoscape automatically changes the rendered bounding box
  without changing the node's data properties, multimer edges on
  sbgn bricks were rendering tilted. This commit is a workaround
  to make the edges look better in previews.

  This is not a complete solution to the problem.

  Addresses iVis-at-Bilkent/newt#662.
  • Loading branch information
msalihaltun committed May 28, 2021
1 parent 80b2f08 commit 36835c9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
27 changes: 25 additions & 2 deletions chise.js

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion src/utilities/element-utilities-extender-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ module.exports = function () {
const widthPerChar = 6;
const tilingPaddingVertical = 15;
const tilingPaddingHorizontal = 15;
const multimerOffset = 6;

cy.startBatch();

Expand Down Expand Up @@ -960,6 +961,9 @@ module.exports = function () {
const regulatorMultimer = regulator.multimer;

let xPosOfRegulator = processPosition.x;
if (regulatorMultimer.enabled && orientation === "horizontal") {
xPosOfRegulator -= multimerOffset;
}
let yPosOfRegulator = processPosition.y - ((processHeight / 2) + (regulatorHeight / 2) + edgeLength);

nodePosition = {
Expand Down Expand Up @@ -1027,6 +1031,7 @@ module.exports = function () {
const processPortsOrdering = orientation === "vertical" ? "T-to-B" : "L-to-R";
const minInfoboxDimension = 20;
const widthPerChar = 6;
const multimerOffset = 6;

cy.startBatch();

Expand Down Expand Up @@ -1101,6 +1106,9 @@ module.exports = function () {
const regulatorEdgeType = regulator.edgeType;

let xPosOfRegulator = processPosition.x;
if (regulatorMultimer.enabled && orientation === "horizontal") {
xPosOfRegulator -= multimerOffset;
}
let yPosOfRegulator = processPosition.y - ((processHeight / 2) + (regulatorHeight / 2) + edgeLength);

nodePosition = {
Expand Down Expand Up @@ -1168,6 +1176,7 @@ module.exports = function () {
const processPortsOrdering = orientation === "vertical" ? "T-to-B" : "L-to-R";
const minInfoboxDimension = 20;
const widthPerChar = 6;
const multimerOffset = 6;

cy.startBatch();

Expand Down Expand Up @@ -1321,6 +1330,9 @@ module.exports = function () {
const regulatorName = regulator.name;
const regulatorType = regulator.type;
let xPosOfRegulator = processPosition.x;
if (regulatorMultimer.enabled && orientation === "horizontal") {
xPosOfRegulator -= multimerOffset;
}
let yPosOfRegulator = processPosition.y - ((processHeight / 2) + (regulatorHeight / 2) + edgeLength);

nodePosition = {
Expand Down Expand Up @@ -1397,11 +1409,11 @@ module.exports = function () {
const regulatorHeight = defaultRegulatorProperties.height || 50;
const processPosition = elementUtilities.convertToModelPosition({x: cy.width() / 2, y: cy.height() / 2});
const tilingPaddingVertical = 15;
const tilingPaddingHorizontal = 15;
const edgeLength = 30;
const processLeftSideEdgeType = reversible ? "production" : "consumption";
const processRightSideEdgeType = "production";
const processPortsOrdering = orientation === "vertical" ? "T-to-B" : "L-to-R";
const multimerOffset = 6;

cy.startBatch();
if (!elementUtilities.getMapType()) {
Expand Down Expand Up @@ -1494,6 +1506,9 @@ module.exports = function () {
const regulatorName = regulator.name;
const regulatorType = regulator.type;
let xPosOfRegulator = processPosition.x;
if (regulatorMultimer.enabled && orientation === "horizontal") {
xPosOfRegulator -= multimerOffset;
}
let yPosOfRegulator = processPosition.y - ((processHeight / 2) + (regulatorHeight / 2) + edgeLength);

let nodePosition = {
Expand Down

0 comments on commit 36835c9

Please sign in to comment.