Merge branch 'master' of https://git.code.tencent.com/beijing-rtss-test/bj-rtss-client
This commit is contained in:
commit
3a9d7c5f7d
@ -8,6 +8,7 @@ import {
|
||||
MenuItemOptions,
|
||||
KeyListener,
|
||||
distance2,
|
||||
getRectangleCenter,
|
||||
} from 'jl-graphic';
|
||||
import { TrainState } from './graphics/TrainInteraction';
|
||||
import {
|
||||
@ -260,18 +261,49 @@ export function initCommonDrawApp(app: IDrawApp) {
|
||||
value: 'KeyA',
|
||||
global: true,
|
||||
onPress: () => {
|
||||
const copySection = graphicCopyPlugin.copys[0] as Section;
|
||||
const copySectionLength = distance2(
|
||||
copySection.datas.points[0],
|
||||
copySection.datas.points[1]
|
||||
const selectSection = app.selectedGraphics[0] as Section;
|
||||
const selectSectionPos = selectSection.localToCanvasPoint(
|
||||
getRectangleCenter(selectSection.getLocalBounds())
|
||||
);
|
||||
if (graphicCopyPlugin.container.position.x > 0) {
|
||||
graphicCopyPlugin.copys[0].position.x += copySectionLength;
|
||||
const copySection = graphicCopyPlugin.copys[0] as Section;
|
||||
const copySectionPos = copySection.localToCanvasPoint(
|
||||
getRectangleCenter(copySection.getLocalBounds())
|
||||
);
|
||||
const sections = app.queryStore.queryByType<Section>(Section.Type);
|
||||
const minDistanceSection = sections.reduce((prev, cur) => {
|
||||
return distance2(
|
||||
prev.localToCanvasPoint(getRectangleCenter(prev.getLocalBounds())),
|
||||
copySectionPos
|
||||
) >
|
||||
distance2(
|
||||
cur.localToCanvasPoint(getRectangleCenter(cur.getLocalBounds())),
|
||||
copySectionPos
|
||||
)
|
||||
? cur
|
||||
: prev;
|
||||
});
|
||||
const minDistanceRefSectionsPos = minDistanceSection.localToCanvasPoint(
|
||||
getRectangleCenter(minDistanceSection.getLocalBounds())
|
||||
);
|
||||
const minDistanceSectionLength = distance2(
|
||||
minDistanceSection.datas.points[0],
|
||||
minDistanceSection.datas.points[
|
||||
minDistanceSection.datas.points.length - 1
|
||||
]
|
||||
);
|
||||
if (copySectionPos.x > minDistanceRefSectionsPos.x) {
|
||||
graphicCopyPlugin.container.position.x =
|
||||
minDistanceRefSectionsPos.x -
|
||||
selectSectionPos.x +
|
||||
minDistanceSectionLength;
|
||||
} else {
|
||||
graphicCopyPlugin.copys[0].position.x -= copySectionLength;
|
||||
graphicCopyPlugin.container.position.x =
|
||||
minDistanceRefSectionsPos.x -
|
||||
selectSectionPos.x -
|
||||
minDistanceSectionLength;
|
||||
}
|
||||
graphicCopyPlugin.saveCopyGraphic();
|
||||
graphicCopyPlugin.clear();
|
||||
graphicCopyPlugin.container.position.y =
|
||||
minDistanceRefSectionsPos.y - selectSectionPos.y;
|
||||
},
|
||||
});
|
||||
graphicCopyPlugin.addGraphicControlers([
|
||||
|
Loading…
Reference in New Issue
Block a user