Skip to content

Commit

Permalink
#2367 - fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Olga Mazurina committed Sep 12, 2023
1 parent e72d947 commit c1558fe
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { RenderersManager } from 'application/render/renderers/RenderersManager';
import { Operation } from 'domain/entities/Operation';
import { DrawingEntity } from 'domain/entities/DrawingEntity';
import { Vec2 } from 'domain/entities';

export class DrawingEntityHoverOperation implements Operation {
constructor(private drawingEntity: DrawingEntity) {}
Expand All @@ -19,9 +18,9 @@ export class DrawingEntitySelectOperation implements Operation {
}
}
export class DrawingEntityMoveOperation implements Operation {
constructor(private drawingEntity: DrawingEntity, private offset: Vec2) {}
constructor(private drawingEntity: DrawingEntity) {}

public execute(renderersManager: RenderersManager) {
renderersManager.moveDrawingEntity(this.drawingEntity, this.offset);
renderersManager.moveDrawingEntity(this.drawingEntity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { BaseMonomer } from 'domain/entities/BaseMonomer';
import { D3SvgElementSelection } from 'application/render/types';
import { DrawingEntity } from 'domain/entities/DrawingEntity';
import { editorEvents } from 'application/editor/editorEvents';
import { Vec2 } from 'domain/entities';

export abstract class BaseMonomerRenderer extends BaseRenderer {
private editorEvents: typeof editorEvents;
Expand Down Expand Up @@ -279,9 +278,8 @@ export abstract class BaseMonomerRenderer extends BaseRenderer {
}
}

public moveSelection(offset: Vec2) {
public moveSelection() {
assert(this.rootElement);
this.monomer.moveRelative(offset);
this.appendSelection();
this.move();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export abstract class BaseRenderer implements IBaseRenderer {

public abstract show(theme): void;
public abstract drawSelection(): void;
public abstract moveSelection(offset): void;
public abstract moveSelection(): void;
protected abstract appendHover(
hoverArea,
): D3SvgElementSelection<SVGUseElement, void> | void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export class PolymerBondRenderer extends BaseRenderer {

public moveSelection() {
assert(this.rootElement);
this.polymerBond.moveToLinkedMonomers();
this.moveStart();
this.moveEnd();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { monomerFactory } from 'application/editor/operations/monomer/monomerFac
import { BaseMonomer } from 'domain/entities/BaseMonomer';
import { BaseMonomerRenderer } from 'application/render/renderers/BaseMonomerRenderer';
import { PolymerBond } from 'domain/entities/PolymerBond';
import { Vec2 } from 'domain/entities';

export class RenderersManager {
private theme;
Expand All @@ -27,9 +26,9 @@ export class RenderersManager {
drawingEntity.baseRenderer.drawSelection();
}

public moveDrawingEntity(drawingEntity: DrawingEntity, offset: Vec2) {
public moveDrawingEntity(drawingEntity: DrawingEntity) {
assert(drawingEntity.baseRenderer);
drawingEntity.baseRenderer.moveSelection(offset);
drawingEntity.baseRenderer.moveSelection();
}

public addMonomer(monomer: BaseMonomer, callback?: () => void) {
Expand Down
23 changes: 12 additions & 11 deletions packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,27 +122,28 @@ export class DrawingEntitiesManager {

this.monomers.forEach((drawingEntity) => {
if (drawingEntity.selected) {
command.merge(
this.createDrawingEntityMovingCommand(drawingEntity, offset),
);
drawingEntity.moveRelative(offset);
command.merge(this.createDrawingEntityMovingCommand(drawingEntity));
}
});

this.polymerBonds.forEach((drawingEntity) => {
command.merge(
this.createDrawingEntityMovingCommand(drawingEntity, offset),
);
if (
drawingEntity.selected ||
drawingEntity.firstMonomer.selected ||
drawingEntity.secondMonomer?.selected
) {
drawingEntity.moveToLinkedMonomers();
command.merge(this.createDrawingEntityMovingCommand(drawingEntity));
}
});
return command;
}

public createDrawingEntityMovingCommand(
drawingEntity: DrawingEntity,
offset: Vec2,
) {
public createDrawingEntityMovingCommand(drawingEntity: DrawingEntity) {
const command = new Command();

const movingCommand = new DrawingEntityMoveOperation(drawingEntity, offset);
const movingCommand = new DrawingEntityMoveOperation(drawingEntity);
command.addOperation(movingCommand);

return command;
Expand Down

0 comments on commit c1558fe

Please sign in to comment.