Skip to content

Commit

Permalink
Undoing a circular backbone will remove it from the "otherTypes" fiel…
Browse files Browse the repository at this point in the history
…d of circuit containers
  • Loading branch information
Drock54651 committed Sep 23, 2024
1 parent a98f1ee commit d4d29cc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
17 changes: 17 additions & 0 deletions SBOLCanvasFrontend/src/app/graph-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,23 @@ export class GraphHelpers extends GraphBase {
return false
}

/**
* Made specifically for undo, since it does not affect glyph info.
* Removes "Circular" from the "otherTypes" property of Circuit Containers.
*/
protected removeCircularType() {
let allGraphCells = this.graph.getDefaultParent().children
if (allGraphCells != null) {
for (let i = 0; i < allGraphCells.length; i++) {
if (allGraphCells[i].isCircuitContainer() && !allGraphCells[i].isCircularBackboneOnCircuitContainer()) {
const otherTypes = this.getGlyphInfo(allGraphCells[i]).otherTypes
const index = otherTypes.indexOf("Circular")
otherTypes.splice(index, 1)
}
}
}
}

protected flipInteractionEdge(cell) {
if (!cell.isInteraction()) {
console.error("flipInteraction attempted on something other than an interaction!")
Expand Down
17 changes: 14 additions & 3 deletions SBOLCanvasFrontend/src/app/graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,14 @@ export class GraphService extends GraphHelpers {
if (combinatorial)
combinatorial.removeVariableComponentInfo(cell.getId())

if (cell.stayAtBeginning || cell.stayAtEnd) cell.getParent().circularBackbone = false

if (cell.stayAtBeginning || cell.stayAtEnd) {
cell.getParent().circularBackbone = false

// remove the circular type from "otherTypes" since circular parts are deleted
const otherTypes = this.getGlyphInfo(cell.getParent()).otherTypes
const index = otherTypes.indexOf("Circular")
otherTypes.splice(index, 1)
}
circuitContainers.push(cell.getParent())
}
} else if (cell.isCircuitContainer() && this.graph.getCurrentRoot() && this.graph.getCurrentRoot().isComponentView())
Expand Down Expand Up @@ -554,6 +560,9 @@ export class GraphService extends GraphHelpers {
this.graph.clearSelection()
this.editor.execute('undo')

// Undo does not affect glyph info, if circular backbone is not present, remove it from "otherTypes" property
this.removeCircularType()

//console.log(this.editor.undoManager);

// If the undo caused scars to become visible, we should update
Expand Down Expand Up @@ -844,7 +853,9 @@ export class GraphService extends GraphHelpers {

// Add additional type to Circuit Container if Circular present
const circuitContainerGlyphInfo = (this.getGlyphInfo(circuitContainer))
circuitContainerGlyphInfo.otherTypes.push("Circular")
if(!circuitContainerGlyphInfo.otherTypes.includes("Circular")){
circuitContainerGlyphInfo.otherTypes.push("Circular")
}

// there cannot be more than one circular backbone on a circuit container
if(circuitContainer.isCircularBackboneOnCircuitContainer()) return
Expand Down

0 comments on commit d4d29cc

Please sign in to comment.