Skip to content

Commit

Permalink
#4839 - System loses connections to molecule R2 if there is no R1 att…
Browse files Browse the repository at this point in the history
…achment point

- fixed attachment point number searching for molecules

#4836 - Molecule changes position after saving and opening from file
- added moving molecules structures in macromode for opening/pasting from file, snake layout

#4840 - Paste from clipboard does not work for molecules in macro mode
- changed serialization method in macromolecules paste
  • Loading branch information
rrodionov91 committed Jun 13, 2024
1 parent ee63599 commit 65a557b
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 13 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,15 @@ export abstract class BaseMode {
}
});
const ketSerializer = new KetSerializer();
const { serializedMacromolecules } = ketSerializer.serializeMacromolecules(
const serializedKet = ketSerializer.serialize(
new Struct(),
drawingEntitiesManager,
);
const clipboardItemString = JSON.stringify(serializedMacromolecules);
if (isClipboardAPIAvailable()) {
navigator.clipboard.writeText(clipboardItemString);
navigator.clipboard.writeText(serializedKet);
} else {
legacyCopy(event.clipboardData, {
'text/plain': clipboardItemString,
'text/plain': serializedKet,
});
event.preventDefault();
}
Expand Down Expand Up @@ -289,7 +288,7 @@ export abstract class BaseMode {
? new Vec2(monomer.position).add(offset)
: new Vec2(monomer.position);
}
monomer.moveAbsolute(position);
drawingEntitiesManager.moveMonomer(monomer, position);
index++;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,12 @@ export class DrawingEntitiesManager {
return { command, monomers };
}

private rearrangeChainModelChange(monomer: BaseMonomer, newPosition: Vec2) {
public rearrangeChainModelChange(monomer: BaseMonomer, newPosition: Vec2) {
if (monomer.monomerItem.props.isMicromoleculeFragment) {
const offset = newPosition.sub(monomer.position);
this.moveChemAtomsPoint(monomer, offset);
}

monomer.moveAbsolute(newPosition);

return monomer;
Expand Down Expand Up @@ -1365,7 +1370,7 @@ export class DrawingEntitiesManager {
const structCenter = this.getMacroStructureCenter();
const offset = Vec2.diff(centerPointOfModel, structCenter);
this.monomers.forEach((monomer: BaseMonomer) => {
monomer.moveAbsolute(new Vec2(monomer.position).add(offset));
this.moveMonomer(monomer, new Vec2(monomer.position).add(offset));
});
this.polymerBonds.forEach((bond: PolymerBond) => {
const { x: startX, y: startY } = new Vec2(bond.position).add(offset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,32 @@ export function polymerBondToDrawingEntity(
const firstAttachmentPoint =
connection.endpoint1.attachmentPointId ||
getAttachmentPointLabel(
(firstMonomer.monomerItem.struct.sgroups
firstMonomer.monomerItem.struct.sgroups
.get(0)
?.getAttachmentPoints()
.findIndex(
.find(
(attachmentPoint, attachmentPointIndex) =>
attachmentPoint.atomId ===
atomIdMap.get(Number(connection.endpoint1.atomId)) &&
!superatomMonomerToUsedAttachmentPoint
.get(firstMonomer)
?.has(getAttachmentPointLabel(attachmentPointIndex + 1)),
) as number) + 1,
)?.attachmentPointNumber as number,
);
const secondAttachmentPoint =
connection.endpoint2.attachmentPointId ||
getAttachmentPointLabel(
(secondMonomer.monomerItem.struct.sgroups
secondMonomer.monomerItem.struct.sgroups
.get(0)
?.getAttachmentPoints()
.findIndex(
.find(
(attachmentPoint, attachmentPointIndex) =>
attachmentPoint.atomId ===
atomIdMap.get(Number(connection.endpoint2.atomId)) &&
!superatomMonomerToUsedAttachmentPoint
.get(secondMonomer)
?.has(getAttachmentPointLabel(attachmentPointIndex + 1)),
) as number) + 1,
)?.attachmentPointNumber as number,
);

if (
Expand Down

0 comments on commit 65a557b

Please sign in to comment.