-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5107 - Implemented move and resize multitail head and tails
- Loading branch information
1 parent
d80f14c
commit 27849f6
Showing
19 changed files
with
853 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/ketcher-core/src/application/editor/operations/multitailArrow/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export * from './multitailArrowAddRemoveTail'; | ||
export * from './multitailArrowMove'; | ||
export * from './multitailArrowMoveHeadTail'; | ||
export * from './multitailArrowResizeTailHead'; | ||
export * from './multitailArrowUpsertDelete'; |
51 changes: 51 additions & 0 deletions
51
...tcher-core/src/application/editor/operations/multitailArrow/multitailArrowMoveHeadTail.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { BaseOperation } from 'application/editor/operations/base'; | ||
import { OperationType } from 'application/editor'; | ||
import { MultitailArrowRefName, ReStruct } from 'application/render'; | ||
import { MULTITAIL_ARROW_KEY } from 'domain/constants'; | ||
|
||
export class MultitailArrowMoveHeadTail extends BaseOperation { | ||
constructor( | ||
private id: number, | ||
private offset: number, | ||
private name: string, | ||
private tailId: number | null, | ||
private normalize?: true, | ||
) { | ||
super(OperationType.MULTITAIL_ARROW_MOVE_HEAD_TAIL); | ||
} | ||
|
||
execute(reStruct: ReStruct) { | ||
const reMultitailArrow = reStruct.multitailArrows.get(this.id); | ||
const multitailArrow = reStruct.molecule.multitailArrows.get(this.id); | ||
if (!multitailArrow || !reMultitailArrow) { | ||
return; | ||
} | ||
switch (this.name) { | ||
case MultitailArrowRefName.HEAD: | ||
this.offset = multitailArrow.moveHead(this.offset); | ||
break; | ||
case MultitailArrowRefName.TOP_TAIL: | ||
this.offset = multitailArrow.moveTail(this.offset, this.name); | ||
break; | ||
case MultitailArrowRefName.BOTTOM_TAIL: | ||
this.offset = multitailArrow.moveTail(this.offset, this.name); | ||
break; | ||
default: | ||
this.offset = multitailArrow.moveTail( | ||
this.offset, | ||
this.tailId as number, | ||
this.normalize, | ||
); | ||
} | ||
BaseOperation.invalidateItem(reStruct, MULTITAIL_ARROW_KEY, this.id, 1); | ||
} | ||
|
||
invert(): BaseOperation { | ||
return new MultitailArrowMoveHeadTail( | ||
this.id, | ||
-this.offset, | ||
this.name, | ||
this.tailId, | ||
); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...her-core/src/application/editor/operations/multitailArrow/multitailArrowResizeTailHead.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { BaseOperation } from 'application/editor/operations/base'; | ||
import { OperationType } from 'application/editor'; | ||
import { ReStruct } from 'application/render'; | ||
import { MULTITAIL_ARROW_KEY } from 'domain/constants'; | ||
|
||
export class MultitailArrowResizeTailHead extends BaseOperation { | ||
constructor( | ||
private id: number, | ||
private offset: number, | ||
private isHead: boolean, | ||
) { | ||
super(OperationType.MULTITAIL_ARROW_RESIZE_HEAD_TAIL); | ||
} | ||
|
||
execute(reStruct: ReStruct) { | ||
const multitailArrow = reStruct.molecule.multitailArrows.get(this.id); | ||
if (!multitailArrow) { | ||
return; | ||
} | ||
this.offset = this.isHead | ||
? multitailArrow.resizeHead(this.offset) | ||
: multitailArrow.resizeTails(this.offset); | ||
BaseOperation.invalidateItem(reStruct, MULTITAIL_ARROW_KEY, this.id, 1); | ||
} | ||
|
||
invert(): BaseOperation { | ||
return new MultitailArrowResizeTailHead(this.id, -this.offset, this.isHead); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.