@@ -7,6 +7,7 @@ import {Vec2D} from "../../utils/vec2D";
77import { Node } from "../../models/node.model" ;
88import { ViewportCullService } from "../ui/viewport.cull.service" ;
99import { NodeOperation , Operation , OperationType } from "src/app/models/operation.model" ;
10+ import { Note } from "../../models/note.model" ;
1011
1112@Injectable ( {
1213 providedIn : "root" ,
@@ -47,6 +48,22 @@ export class PositionTransformationService {
4748 }
4849 n . setPosition ( newPos . getX ( ) , newPos . getY ( ) ) ;
4950 } ) ;
51+
52+ this . noteService . getNotes ( ) . forEach ( ( n , index ) => {
53+ let newPos = new Vec2D (
54+ ( n . getPositionX ( ) - scaleCenterCoordinates . getX ( ) ) * factor + scaleCenterCoordinates . getX ( ) ,
55+ ( n . getPositionY ( ) - scaleCenterCoordinates . getY ( ) ) * factor + scaleCenterCoordinates . getY ( ) ,
56+ ) ;
57+
58+ if ( focalNode ?. getId ( ) === n . getId ( ) ) {
59+ const delta = Vec2D . sub (
60+ newPos ,
61+ new Vec2D ( focalNode . getPositionX ( ) , focalNode . getPositionY ( ) ) ,
62+ ) ;
63+ newPos = Vec2D . sub ( newPos , delta ) ;
64+ }
65+ n . setPosition ( newPos . getX ( ) , newPos . getY ( ) ) ;
66+ } ) ;
5067 }
5168
5269 private computeScaleCenterCoordinates (
@@ -80,6 +97,7 @@ export class PositionTransformationService {
8097 factor : number ,
8198 zoomCenter : Vec2D ,
8299 nodes : Node [ ] ,
100+ notes : Note [ ] ,
83101 windowViewboxPropertiesMapKey : string ,
84102 ) {
85103 const scaleCenterCoordinates : Vec2D = this . computeScaleCenterCoordinates (
@@ -128,6 +146,18 @@ export class PositionTransformationService {
128146
129147 n . setPosition ( newPos . getX ( ) , newPos . getY ( ) ) ;
130148 } ) ;
149+
150+ notes . forEach ( ( n , index ) => {
151+ const newPos = new Vec2D (
152+ ( n . getPositionX ( ) + n . getWidth ( ) / 2.0 - scaleCenterCoordinates . getX ( ) ) * factor +
153+ scaleCenterCoordinates . getX ( ) -
154+ n . getWidth ( ) / 2.0 ,
155+ ( n . getPositionY ( ) + n . getHeight ( ) / 2.0 - scaleCenterCoordinates . getY ( ) ) * factor +
156+ scaleCenterCoordinates . getY ( ) -
157+ n . getHeight ( ) / 2.0 ,
158+ ) ;
159+ n . setPosition ( newPos . getX ( ) , newPos . getY ( ) ) ;
160+ } ) ;
131161 }
132162
133163 private updateRendering ( ) {
@@ -143,14 +173,19 @@ export class PositionTransformationService {
143173
144174 scaleNetzgrafikArea ( factor : number , zoomCenter : Vec2D , windowViewboxPropertiesMapKey : string ) {
145175 const nodes : Node [ ] = this . nodeService . getSelectedNodes ( ) ;
146-
147176 if ( nodes . length < 2 ) {
148177 this . scaleFullNetzgrafikArea ( factor , zoomCenter , windowViewboxPropertiesMapKey ) ;
149178 } else {
179+ let notes : Note [ ] = this . noteService . getSelectedNotes ( ) ;
180+ if ( notes . length === 0 ) {
181+ notes = this . noteService . getNotes ( ) ;
182+ }
183+ this . noteService . getSelectedNote ( ) ;
150184 this . scaleNetzgrafikSelectedNodesArea (
151185 factor ,
152186 zoomCenter ,
153187 nodes ,
188+ notes ,
154189 windowViewboxPropertiesMapKey ,
155190 ) ;
156191 }
0 commit comments