Skip to content

Commit

Permalink
fix: aemit operations for position transformation service (#400)
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Greiner <[email protected]>
  • Loading branch information
louisgreiner authored Jan 28, 2025
1 parent fe3e788 commit a7dae9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {Operation} from "./models/operation.model";
import {LabelService} from "./services/data/label.service";
import {NodeService} from "./services/data/node.service";
import {I18nService} from "./core/i18n/i18n.service";
import {PositionTransformationService} from "./services/util/position.transformation.service";

@Component({
selector: "sbb-root",
Expand Down Expand Up @@ -46,6 +47,7 @@ export class AppComponent {
private trainrunService: TrainrunService,
private trainrunSectionService: TrainrunSectionService,
private nodeService: NodeService,
private positionTransformationService: PositionTransformationService,
private labelService: LabelService,
private i18nService: I18nService,
) {
Expand Down Expand Up @@ -86,6 +88,7 @@ export class AppComponent {
this.trainrunService.operation,
this.trainrunSectionService.operation,
this.nodeService.operation,
this.positionTransformationService.operation,
this.labelService.operation,
);
}
8 changes: 7 additions & 1 deletion src/app/services/util/position.transformation.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {Injectable} from "@angular/core";
import {EventEmitter, Injectable} from "@angular/core";
import {TrainrunSectionService} from "../data/trainrunsection.service";
import {UiInteractionService} from "../ui/ui.interaction.service";
import {NodeService} from "../data/node.service";
import {NoteService} from "../data/note.service";
import {Vec2D} from "../../utils/vec2D";
import {Node} from "../../models/node.model";
import {ViewportCullService} from "../ui/viewport.cull.service";
import {NodeOperation, Operation, OperationType} from "src/app/models/operation.model";

@Injectable({
providedIn: "root",
Expand All @@ -19,6 +20,7 @@ export class PositionTransformationService {
private readonly viewportCullService: ViewportCullService,
) {
}
readonly operation = new EventEmitter<Operation>();

private scaleFullNetzgrafikArea(factor: number, zoomCenter: Vec2D, windowViewboxPropertiesMapKey: string) {
const scaleCenterCoordinates: Vec2D = this.computeScaleCenterCoordinates(zoomCenter, windowViewboxPropertiesMapKey);
Expand Down Expand Up @@ -135,6 +137,7 @@ export class PositionTransformationService {
if (leftX !== undefined) {
nodes.forEach((n) => {
n.setPosition(leftX, n.getPositionY());
this.operation.emit(new NodeOperation(OperationType.update, n));
});
}

Expand All @@ -157,6 +160,7 @@ export class PositionTransformationService {
if (rightX !== undefined) {
nodes.forEach((n) => {
n.setPosition(rightX - n.getNodeWidth(), n.getPositionY());
this.operation.emit(new NodeOperation(OperationType.update, n));
});
}

Expand All @@ -179,6 +183,7 @@ export class PositionTransformationService {
if (topY !== undefined) {
nodes.forEach((n) => {
n.setPosition(n.getPositionX(), topY);
this.operation.emit(new NodeOperation(OperationType.update, n));
});
}

Expand All @@ -201,6 +206,7 @@ export class PositionTransformationService {
if (bottomY !== undefined) {
nodes.forEach((n) => {
n.setPosition(n.getPositionX(), bottomY - n.getNodeHeight());
this.operation.emit(new NodeOperation(OperationType.update, n));
});
}

Expand Down

0 comments on commit a7dae9e

Please sign in to comment.