123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- import { mathUtil } from '../MathUtil'
- import { arrowService } from '../Service/ArrowService'
- import { circleService } from '../Service/CircleService'
- import { floorplanService } from '../Service/FloorplanService'
- import { iconService } from '../Service/IconService'
- import { rectangleService } from '../Service/RectangleService'
- import { signService } from '../Service/SignService'
- import { tableService } from '../Service/TableService'
- import { tagService } from '../Service/TagService'
- import { wallService } from '../Service/WallService'
- export default class HistoryUtil {
- constructor() {}
- isDifferentForWalls(wall1, wall2) {
- if (wall1.start == wall2.start && wall1.end == wall2.end) {
- return false
- } else {
- return true
- }
- }
-
- isDifferentForTags(tag1, tag2) {
- if (mathUtil.equalPoint(tag1.center, tag2.center) && tag1.value == tag2.value) {
- return false
- } else {
- return true
- }
- }
- isDifferentForTables(table1, table2) {
- if(!mathUtil.equalPoint(table1.center, table2.center)){
- return true;
- }
- else if(table1.rowLen != table2.rowLen || table1.colLen != table2.colLen || table1.cells.length != table2.cells.length){
- return true;
- }
- else{
- for(let i=0;i<table1.cells.length;++i){
- for(let j=0;j<table1.cells[i].length;++j){
- const cell1 = floorplanService.getCell(table1.cells[i][j]);
- const cell2 = floorplanService.getCell(table2.cells[i][j]);
- if(this.isDifferentForCells(cell1,cell2)){
- return true;
- }
- }
- }
- }
- return false
- }
- isDifferentForCells(cell1, cell2) {
- if (cell1.value == cell2.value&&cell1.width == cell2.width&&cell1.height == cell2.height) {
- return false
- } else {
- return true
- }
- }
- isDifferentForRectangles(rectangle1, rectangle2) {
- for(let i=0;i<rectangle1.points.length;++i){
- if(!mathUtil.equalPoint(rectangle1.points[i], rectangle2.points[i])){
- return true;
- }
- }
- return false;
- }
- isDifferentForCircles(circle1, circle2) {
- if(!mathUtil.equalPoint(circle1.center, circle2.center)){
- return true;
- }
- else if(circle1.radius != circle2.radius){
- return true;
- }
- else {
- for(let i=0;i<circle1.points.length;++i){
- if(!mathUtil.equalPoint(circle1.points[i], circle2.points[i])){
- return true;
- }
- }
- }
- return false;
- }
- isDifferentForArrows(arrow1, arrow2) {
- if (mathUtil.equalPoint(arrow1.startPoint, arrow2.startPoint) && mathUtil.equalPoint(arrow1.endPoint, arrow2.endPoint)) {
- return false
- } else {
- return true
- }
- }
- isDifferentForIcons(icon1, icon2) {
- if(!mathUtil.equalPoint(icon1.center, icon2.center)){
- return true;
- }
- else if(icon1.radius != icon2.radius){
- return true;
- }
- else if(icon1.value != icon2.value){
- return true;
- }
- else if(icon1.angle != icon2.angle){
- return true;
- }
- else {
- for(let i=0;i<icon1.points.length;++i){
- if(!mathUtil.equalPoint(icon1.points[i], icon2.points[i])){
- return true;
- }
- }
- }
- return false;
- }
- isDifferentForSigns(sign1, sign2) {
- if (sign1.scale == sign2.scale && JSON.stringify(sign1.center) == JSON.stringify(sign2.center) && sign1.angle == sign2.angle) {
- return false
- } else {
- return true
- }
- }
- isDifferentForTitle(title1, title2) {
- if (title1.value == title2.value) {
- return false
- } else {
- return true
- }
- }
- isDifferentForImage(image1, image2) {
- if (image1.src == image2.src) {
- return false
- } else {
- return true
- }
- }
- isDifferentForCompass(compass1, compass2) {
- if (compass1.angle == compass2.angle) {
- return false
- } else {
- return true
- }
- }
- // isDifferentForAngle(angle1, angle2) {
- // if (angle1 == angle2) {
- // return false
- // } else {
- // return true
- // }
- // }
- // wall2赋值给wall1
- assignWallFromWall(wall1, wall2) {
- const wallInfo = {}
- wallInfo.vectorId = wall1.vectorId
- wallInfo.start = wall2.start
- wallInfo.end = wall2.end
- wallService.setWallInfo(wallInfo)
- }
- assignPointFromPoint(point1, point2) {
- const pointInfo = {}
- pointInfo.vectorId = point1.vectorId
- pointInfo.position = { x: point2.x, y: point2.y }
- pointInfo.parent = JSON.parse(JSON.stringify(point2.parent))
- wallService.setPointInfo(pointInfo)
- }
- assignTagFromTag(tag1, tag2) {
- const tagInfo = {}
- tagInfo.vectorId = tag1.vectorId
- tagInfo.value = tag2.value
- tagInfo.center = JSON.parse(JSON.stringify(tag2.center))
- tagInfo.points2d = JSON.parse(JSON.stringify(tag2.points))
- tagService.setTagInfo(tagInfo)
- }
- assignTableFromTable(table1, table2) {
- const tableInfo = {}
- tableInfo.vectorId = table1.vectorId
- tableInfo.rowLen = table2.rowLen
- tableInfo.colLen = table2.colLen
- tableInfo.center = JSON.parse(JSON.stringify(table2.center))
- tableInfo.points = JSON.parse(JSON.stringify(table2.points))
- tableInfo.cells = table2.cells
- tableService.setTableInfo(tableInfo)
- }
- assignTagFromTag(tag1, tag2) {
- const tagInfo = {}
- tagInfo.vectorId = tag1.vectorId
- tagInfo.value = tag2.value
- tagInfo.center = JSON.parse(JSON.stringify(tag2.center))
- tagInfo.points2d = JSON.parse(JSON.stringify(tag2.points))
- tagService.setTagInfo(tagInfo)
- }
- assignRectangleFromRectangle(rectangle1, rectangle2) {
- const rectangleInfo = {}
- rectangleInfo.vectorId = rectangle1.vectorId
- rectangleInfo.angle = rectangle2.angle
- rectangleInfo.points = JSON.parse(JSON.stringify(rectangle2.points))
- rectangleService.setRectangleInfo(rectangleInfo)
- }
- assignCircleFromCircle(circle1, circle2) {
- const circleInfo = {}
- circleInfo.vectorId = circle1.vectorId
- circleInfo.radius = circle2.radius
- circleInfo.center = JSON.parse(JSON.stringify(circle2.center))
- circleInfo.points = JSON.parse(JSON.stringify(circle2.points))
- circleService.setCircleInfo(circleInfo)
- }
- assignArrowFromArrow(arrow1, arrow2) {
- const arrowInfo = {}
- arrowInfo.vectorId = arrow1.vectorId
- arrowInfo.startPoint = JSON.parse(JSON.stringify(arrow2.startPoint))
- arrowInfo.endPoint = JSON.parse(JSON.stringify(arrow2.endPoint))
- arrowService.setArrowInfo(arrowInfo)
- }
- assignIconFromIcon(icon1, icon2) {
- const iconInfo = {}
- iconInfo.vectorId = icon1.vectorId
- iconInfo.radius = icon2.radius
- iconInfo.value = icon2.value
- iconInfo.angle = icon2.angle
- iconInfo.center = JSON.parse(JSON.stringify(icon2.center))
- iconInfo.points = JSON.parse(JSON.stringify(icon2.points))
- iconService.setIconInfo(iconInfo)
- }
- assignSignFromSign(sign1, sign2) {
- const SignInfo = {}
- SignInfo.vectorId = sign1.vectorId
- SignInfo.angle = sign2.angle
- SignInfo.center = JSON.parse(JSON.stringify(sign2.center))
- SignInfo.scale = sign2.scale
- signService.setSignInfo(SignInfo)
- }
- assignTitleFromTitle(title1, title2) {
- const titleInfo = {}
- titleInfo.vectorId = title1.vectorId
- titleInfo.value = title2.value
- floorplanService.updateTitle(titleInfo.value)
- }
- assignImageFromImage(image1, image2) {
- const imageInfo = {}
- imageInfo.vectorId = image1.vectorId
- imageInfo.src = image2.src
- floorplanService.updateBgImage(imageInfo.src)
- }
- assignCompassFromCompass(compass1, compass2) {
- const compassInfo = {}
- compassInfo.vectorId = compass1.vectorId
- compassInfo.angle = compass2.angle
- floorplanService.updateCompass(compassInfo.angle )
- }
- deletePoint(pointId) {
- const point = floorplanService.getPoint(pointId)
- const parent = point.parent
- for (const key in parent) {
- floorplanService.deletePoint(pointId, key)
- }
- }
- getDataForPoint(point) {
- const data = {}
- data.id = point.vectorId
- mathUtil.clonePoint(data, point)
- data.parent = JSON.parse(JSON.stringify(point.parent))
- data.type = point.geoType
- return data
- }
- getDataForWall(wall) {
- const data = {}
- data.id = wall.vectorId
- data.start = wall.start
- data.end = wall.end
- data.type = wall.geoType
- return data
- }
- getDataForSign(sign) {
- const data = {}
- data.id = sign.vectorId
- data.type = sign.geoType
- data.center = JSON.parse(JSON.stringify(sign.center))
- data.scale = sign.scale
- data.angle = sign.angle
- return data
- }
- getDataForTag(tag) {
- const data = {}
- data.id = tag.vectorId
- data.type = tag.geoType
- data.center = {}
- mathUtil.clonePoint(data.center, tag.center)
- data.points = [].concat(tag.points2d)
- data.value = tag.value
- return data
- }
- getDataForTable(table) {
- const data = {}
- data.id = table.vectorId
- data.type = table.geoType
- data.rowLen = table.rowLen
- data.colLen = table.colLen
- data.center = {}
- mathUtil.clonePoint(data.center, table.center)
- data.points = [].concat(table.points)
- data.cells = [].concat(table.cells)
- return data
- }
- getDataForRectangle(rectangle) {
- const data = {}
- data.id = rectangle.vectorId
- data.type = rectangle.geoType
- data.angle = rectangle.angle
- data.points = [].concat(rectangle.points)
- return data
- }
- getDataForCircle(circle) {
- const data = {}
- data.id = circle.vectorId
- data.type = circle.geoType
- data.center = {}
- mathUtil.clonePoint(data.center, circle.center)
- data.points = [].concat(circle.points)
- data.radius = circle.radius
- return data
- }
- getDataForArrow(arrow) {
- const data = {}
- data.id = arrow.vectorId
- data.type = arrow.geoType
- data.startPoint = {}
- mathUtil.clonePoint(data.startPoint, arrow.startPoint)
- data.endPoint = {}
- mathUtil.clonePoint(data.endPoint, arrow.endPoint)
- return data
- }
- getDataForIcon(icon) {
- const data = {}
- data.id = icon.vectorId
- data.type = icon.geoType
- data.value = icon.value
- data.angle = icon.angle
- data.center = {}
- mathUtil.clonePoint(data.center, icon.center)
- data.points = [].concat(icon.points)
- data.radius = icon.radius
- return data
- }
- getDataForTitle(title) {
- const data = {}
- data.id = title.vectorId
- data.type = title.geoType
- data.value = title.value
- return data
- }
- getDataForImage(image) {
- const data = {}
- data.id = image.vectorId
- data.type = image.geoType
- data.src = image.src
- return data
- }
- getDataForCompass(compass) {
- const data = {}
- data.id = compass.vectorId
- data.type = compass.geoType
- data.angle = compass.angle
- return data
- }
- // getDataForAngle(angle) {
- // return angle
- // }
- // getDataForRes(res) {
- // return res
- // }
- }
- const historyUtil = new HistoryUtil()
- export { historyUtil }
|