fix:处理自定义图形 ,图片与文字,显示位置相关的问题
This commit is contained in:
@@ -1424,7 +1424,7 @@ export default {
|
|||||||
// 'topologyData.data':{
|
// 'topologyData.data':{
|
||||||
// handler(n){
|
// handler(n){
|
||||||
// setTimeout(()=>{
|
// setTimeout(()=>{
|
||||||
// let dataOption=getTopology(this.index).data;
|
// let dataOption=getTopology(this.index).data();
|
||||||
// Object.keys(this.topologyData.data).forEach((key)=>{
|
// Object.keys(this.topologyData.data).forEach((key)=>{
|
||||||
// dataOption[key]=this.topologyData.data[key];
|
// dataOption[key]=this.topologyData.data[key];
|
||||||
// });
|
// });
|
||||||
@@ -1472,7 +1472,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
const dataOption = this.index == -2 ? getTopology(-1).data : getTopology(this.index).data
|
const dataOption = this.index == -2 ? getTopology(-1).data : getTopology(this.index).data()
|
||||||
if (!dataOption.data) {
|
if (!dataOption.data) {
|
||||||
dataOption.data = {}
|
dataOption.data = {}
|
||||||
}
|
}
|
||||||
@@ -1686,7 +1686,7 @@ export default {
|
|||||||
},
|
},
|
||||||
changeTopologyOpt (val, key, isColor) {
|
changeTopologyOpt (val, key, isColor) {
|
||||||
//
|
//
|
||||||
// getTopology(this.index).data[key]=val;
|
// getTopology(this.index).data()[key]=val;
|
||||||
// getTopology(this.index).render();
|
// getTopology(this.index).render();
|
||||||
if (isColor) {
|
if (isColor) {
|
||||||
this.topologyData.data[key] = this.colorRGBtoHex(val)
|
this.topologyData.data[key] = this.colorRGBtoHex(val)
|
||||||
@@ -1695,9 +1695,9 @@ export default {
|
|||||||
}
|
}
|
||||||
Object.keys(this.topologyData.data).forEach((key1) => {
|
Object.keys(this.topologyData.data).forEach((key1) => {
|
||||||
if (key1 === 'projectInfo' || key1 === 'alertInfo' || key1 === 'fontSize' || key1 === 'align' || key1 === 'fontColor' || key1 === 'opacity') {
|
if (key1 === 'projectInfo' || key1 === 'alertInfo' || key1 === 'fontSize' || key1 === 'align' || key1 === 'fontColor' || key1 === 'opacity') {
|
||||||
getTopology(this.index).data.data[key1] = this.topologyData.data[key1]
|
getTopology(this.index).data().data[key1] = this.topologyData.data[key1]
|
||||||
} else {
|
} else {
|
||||||
getTopology(this.index).data[key1] = this.topologyData.data[key1]
|
getTopology(this.index).data()[key1] = this.topologyData.data[key1]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
getTopology(this.index).render()
|
getTopology(this.index).render()
|
||||||
|
|||||||
@@ -240,8 +240,20 @@ export function rectangleImg (ctx, pen) {
|
|||||||
}
|
}
|
||||||
// 必须判空再填充
|
// 必须判空再填充
|
||||||
(pen.fillStyle || pen.bkType) && ctx.fill()
|
(pen.fillStyle || pen.bkType) && ctx.fill()
|
||||||
pen.iconHeight = pen.height - 30
|
console.log(pen, pen.calculative.worldIconRect)
|
||||||
console.log(pen)
|
pen.calculative.worldIconRect = {
|
||||||
|
height: pen.height - 10 - 20,
|
||||||
|
rotate: 0,
|
||||||
|
width: pen.width - 10,
|
||||||
|
x: pen.x + 5,
|
||||||
|
y: pen.y + 5
|
||||||
|
}
|
||||||
|
pen.calculative.worldTextRect = {
|
||||||
|
height: 20,
|
||||||
|
width: pen.width - 10,
|
||||||
|
x: pen.x + 5,
|
||||||
|
y: pen.y + pen.height - 5 - 20
|
||||||
|
}
|
||||||
// pen.iconRect = new Rect(pen.x + pen.paddingLeft, pen.y + pen.paddingTop, pen.width - (pen.paddingLeft + pen.paddingRight), pen.height - 20 - (pen.paddingTop + pen.paddingBottom))
|
// pen.iconRect = new Rect(pen.x + pen.paddingLeft, pen.y + pen.paddingTop, pen.width - (pen.paddingLeft + pen.paddingRight), pen.height - 20 - (pen.paddingTop + pen.paddingBottom))
|
||||||
// pen.fullIconRect = { width: 80, height: 90, center: { x: 972, y: 456 }, ex: 1012, ey: 496 }
|
// pen.fullIconRect = { width: 80, height: 90, center: { x: 972, y: 456 }, ex: 1012, ey: 496 }
|
||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
@@ -253,7 +265,7 @@ export function rectangleImgAnchors (pen) {
|
|||||||
id: '0',
|
id: '0',
|
||||||
penId: pen.id,
|
penId: pen.id,
|
||||||
x: pen.x,
|
x: pen.x,
|
||||||
y: pen.y + pen.height / 4
|
y: pen.y + pen.height / 2
|
||||||
})
|
})
|
||||||
anchors.push({
|
anchors.push({
|
||||||
id: '1',
|
id: '1',
|
||||||
@@ -273,6 +285,12 @@ export function rectangleImgAnchors (pen) {
|
|||||||
x: pen.x + pen.width / 2,
|
x: pen.x + pen.width / 2,
|
||||||
y: pen.y + pen.height
|
y: pen.y + pen.height
|
||||||
})
|
})
|
||||||
|
anchors.push({
|
||||||
|
id: '4',
|
||||||
|
penId: pen.id,
|
||||||
|
x: pen.x,
|
||||||
|
y: pen.y + pen.height / 8
|
||||||
|
})
|
||||||
return anchors
|
return anchors
|
||||||
// pen.anchors.push(new Point(pen.x, pen.y + pen.height / 2, Direction.Left))
|
// pen.anchors.push(new Point(pen.x, pen.y + pen.height / 2, Direction.Left))
|
||||||
// pen.anchors.push(new Point(pen.x + pen.width / 2, pen.y, Direction.Up))
|
// pen.anchors.push(new Point(pen.x + pen.width / 2, pen.y, Direction.Up))
|
||||||
@@ -369,34 +387,9 @@ export function disposeTopoOldData (pen, allPen) { // 处理旧数据
|
|||||||
connectedLines: pen.connectedLines || [],
|
connectedLines: pen.connectedLines || [],
|
||||||
image: pen.image
|
image: pen.image
|
||||||
}
|
}
|
||||||
console.log(pen.connectedLines)
|
|
||||||
} else {
|
} else {
|
||||||
const anchors = [s16(), s16()]
|
|
||||||
const width = pen.from.x - pen.to.x
|
const width = pen.from.x - pen.to.x
|
||||||
const height = pen.from.y - pen.to.y
|
const height = pen.from.y - pen.to.y
|
||||||
// if (pen.from) {
|
|
||||||
// console.log('from')
|
|
||||||
// const find = allPen.find(item => item.id == pen.from.id)
|
|
||||||
// if (!find.connectedLines) {
|
|
||||||
// find.connectedLines = []
|
|
||||||
// }
|
|
||||||
// find.connectedLines.push({
|
|
||||||
// anchor: pen.from.anchorIndex,
|
|
||||||
// lineAnchor: pen.id + '-0',
|
|
||||||
// lineId: pen.id
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// if (pen.to) {
|
|
||||||
// const find = allPen.find(item => item.id == pen.to.id)
|
|
||||||
// if (!find.connectedLines) {
|
|
||||||
// find.connectedLines = []
|
|
||||||
// }
|
|
||||||
// find.connectedLines.push({
|
|
||||||
// anchor: pen.to.anchorIndex,
|
|
||||||
// lineAnchor: pen.id + '-1',
|
|
||||||
// lineId: pen.id
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
obj = {
|
obj = {
|
||||||
id: pen.id,
|
id: pen.id,
|
||||||
tags: [
|
tags: [
|
||||||
|
|||||||
@@ -728,7 +728,7 @@ export default {
|
|||||||
getTopology(this.topologyIndex).open(data)
|
getTopology(this.topologyIndex).open(data)
|
||||||
// getTopology(this.topologyIndex).lock(1)
|
// getTopology(this.topologyIndex).lock(1)
|
||||||
this.objChange = false
|
this.objChange = false
|
||||||
let flag = false
|
const flag = false
|
||||||
const position = {
|
const position = {
|
||||||
x: this.$refs['topology-canvas' + this.topologyIndexF].offsetWidth,
|
x: this.$refs['topology-canvas' + this.topologyIndexF].offsetWidth,
|
||||||
y: this.$refs['topology-canvas' + this.topologyIndexF].offsetHeight
|
y: this.$refs['topology-canvas' + this.topologyIndexF].offsetHeight
|
||||||
@@ -736,7 +736,7 @@ export default {
|
|||||||
this.oldScale = getTopology(this.topologyIndex).data().scale
|
this.oldScale = getTopology(this.topologyIndex).data().scale
|
||||||
getTopology(this.topologyIndex).data().pens.forEach(item => {
|
getTopology(this.topologyIndex).data().pens.forEach(item => {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// if (item.ex > position.x || item.ey > position.y) {
|
// if (item.ex > position.x || item.ey > position.y) {
|
||||||
// if (this.fromOverView) {
|
// if (this.fromOverView) {
|
||||||
@@ -826,7 +826,7 @@ export default {
|
|||||||
getTopology(this.topologyIndex).register(sequencePens())
|
getTopology(this.topologyIndex).register(sequencePens())
|
||||||
getTopology(this.topologyIndex).registerCanvasDraw(sequencePensbyCtx())
|
getTopology(this.topologyIndex).registerCanvasDraw(sequencePensbyCtx())
|
||||||
getTopology(this.topologyIndex).registerCanvasDraw(formPens())
|
getTopology(this.topologyIndex).registerCanvasDraw(formPens())
|
||||||
getTopology(this.topologyIndex).registerCanvasDraw({ rectangleImg })
|
getTopology(this.topologyIndex).registerCanvasDraw({ rectangleImg: rectangleImg })
|
||||||
getTopology(this.topologyIndex).registerAnchors({ rectangleImg: rectangleImgAnchors })
|
getTopology(this.topologyIndex).registerAnchors({ rectangleImg: rectangleImgAnchors })
|
||||||
this.getModule()// 获取module
|
this.getModule()// 获取module
|
||||||
resolve()
|
resolve()
|
||||||
@@ -840,7 +840,7 @@ export default {
|
|||||||
}
|
}
|
||||||
this.$get('monitor/project/topo', { projectId: this.obj.id }).then(res => {
|
this.$get('monitor/project/topo', { projectId: this.obj.id }).then(res => {
|
||||||
console.log(JSON.stringify(res.data.topo))
|
console.log(JSON.stringify(res.data.topo))
|
||||||
|
res.data.topo.oldData = 1
|
||||||
if (!res.data) {
|
if (!res.data) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1152,6 +1152,7 @@ export default {
|
|||||||
let arr = []
|
let arr = []
|
||||||
this.offsetX = getTopology(this.topologyIndex).data().x
|
this.offsetX = getTopology(this.topologyIndex).data().x
|
||||||
this.offsetY = getTopology(this.topologyIndex).data().y
|
this.offsetY = getTopology(this.topologyIndex).data().y
|
||||||
|
console.log(this.offsetX, this.offsetY)
|
||||||
arr = getTopology(this.topologyIndex).data().pens.filter(item => {
|
arr = getTopology(this.topologyIndex).data().pens.filter(item => {
|
||||||
if (!item.data) {
|
if (!item.data) {
|
||||||
item.data = {
|
item.data = {
|
||||||
@@ -1250,17 +1251,16 @@ export default {
|
|||||||
this.dragFlag = true
|
this.dragFlag = true
|
||||||
clearTimeout(timer)
|
clearTimeout(timer)
|
||||||
}, 100)
|
}, 100)
|
||||||
event.dataTransfer.setData('Text', JSON.stringify({ ...node.data, data: { imageId: node.data.imageId } }))
|
console.log(node)
|
||||||
|
event.dataTransfer.setData('Text', JSON.stringify({ ...node.data, ...node.data.rect, data: { imageId: node.data.imageId } }))
|
||||||
},
|
},
|
||||||
dragFlagChange (node) {
|
dragFlagChange (node) {
|
||||||
getTopology(this.topologyIndex).addNode(
|
getTopology(this.topologyIndex).addPen(
|
||||||
{
|
{
|
||||||
...node.data,
|
...node.data,
|
||||||
rect: {
|
|
||||||
...node.data.rect,
|
...node.data.rect,
|
||||||
x: this.$refs['topology-canvas' + this.topologyIndexF].offsetWidth / 2 - 50,
|
x: this.$refs['topology-canvas' + this.topologyIndexF].offsetWidth / 2 - 50,
|
||||||
y: this.$refs['topology-canvas' + this.topologyIndexF].offsetHeight / 2 - 50
|
y: this.$refs['topology-canvas' + this.topologyIndexF].offsetHeight / 2 - 50,
|
||||||
},
|
|
||||||
data: { imageId: node.data.imageId }
|
data: { imageId: node.data.imageId }
|
||||||
})
|
})
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user