邵佳豪 4 years ago
parent
commit
ba56aa2966
  1. 15
      .vscode/launch.json
  2. 57
      src/app/ui/collection-tools/collection-tools.component.ts
  3. 38
      src/app/working-area/working-area.component.ts

15
.vscode/launch.json vendored

@ -0,0 +1,15 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4000",
"webRoot": "${workspaceFolder}"
}
]
}

57
src/app/ui/collection-tools/collection-tools.component.ts

@ -380,11 +380,6 @@ export class CollectionToolsComponent implements OnInit {
this.getAllLibrary()
this.getSitePlan()
this.getAllBuildings()
setTimeout(() => {
// console.log(1,this.canvasData.selectStorey)
// console.log(2,this.canvasData.originalcompanyBuildingData)
// console.log(3,this.canvasData.originaleveryStoreyData)
}, 3000);
}
@ -603,7 +598,7 @@ export class CollectionToolsComponent implements OnInit {
element.isLook = true //添加是否可见标识
// element.isLookPattern = false
element.children = []
element.children? element.children : element.children = []
if(storeyData){
for(let key in storeyData.data){
if(element.id == storeyData.data[key].FireElementId){
@ -697,6 +692,12 @@ export class CollectionToolsComponent implements OnInit {
storeyData.data[key] = companyBuildingData.data[key]
}
}
for(let key in storeyData.data){ //筛选数据 没有匹配全部放入到 其他 数组
let noMatch = this.allFireElements.find( every=> every.id===storeyData.data[key].FireElementId )
if (!noMatch) {
this.allFireElements[this.allFireElements.length-1].children.push(storeyData.data[key])
}
}
this.handleTreeData(storeyData) //处理tree数据结构
}
@ -770,6 +771,16 @@ export class CollectionToolsComponent implements OnInit {
let params = {ids:e}
let isTrue = this.http.get('/api/Companies/FireElements',{params}).subscribe((data:any)=>{
this.allFireElements = data //所有消防要素
let other = {
children: [],
computed: true,
id: '',
name: '其他',
order: 999,
parentId: null,
tag: "INPUT",
}
this.allFireElements.push(other)
return true
})
if (isTrue) { return 'success' }
@ -826,14 +837,32 @@ export class CollectionToolsComponent implements OnInit {
//点击选中 平面图 楼层/区域 时
selectSitePlan (item,index) {
if (this.selectSitePlanIndex != index) {
this.selectingSitePlan = item
this.selectSitePlanIndex = index
this.canvasData.selectStorey = item //服务中 存一份数据
if (this.checkedBuildingIndex==-1) { //总平面图时
this.getSitePlanStorey(item) //获取 平面图 楼层数据
} else { //楼层/区域时
this.getBuildingStorey(item) //获取 建筑 楼层数据
}
if (this.canvasData.isChange) { //true 数据被改动
let isTrue = confirm('是否保存当前编辑数据')
if (isTrue) { //保存一遍数据, 再刷新数据
} else {
this.selectingSitePlan = item
this.selectSitePlanIndex = index
this.canvasData.selectStorey = item //服务中 存一份数据
if (this.checkedBuildingIndex==-1) { //总平面图时
this.getSitePlanStorey(item) //获取 平面图 楼层数据
} else { //楼层/区域时
this.getBuildingStorey(item) //获取 建筑 楼层数据
}
}
} else { //false 数据没被改动
this.selectingSitePlan = item
this.selectSitePlanIndex = index
this.canvasData.selectStorey = item //服务中 存一份数据
if (this.checkedBuildingIndex==-1) { //总平面图时
this.getSitePlanStorey(item) //获取 平面图 楼层数据
} else { //楼层/区域时
this.getBuildingStorey(item) //获取 建筑 楼层数据
}
} //if
}
}

38
src/app/working-area/working-area.component.ts

@ -402,7 +402,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: Guid.NewGuid().ToString(),
ImageUrl: this.canvasData.selectTemplateData.imageUrl,
InteractiveMode: this.canvasData.selectTemplateData.interactiveMode,
MultiPoint: this.paintPoints,
MultiPoint: JSON.parse(JSON.stringify(this.paintPoints)),
Point: new PIXI.Point(0, 0),
Name: this.canvasData.selectTemplateData.name,
PropertyInfos: propertyList,
@ -671,7 +671,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: Guid.NewGuid().ToString(),
ImageUrl: this.canvasData.selectTemplateData.imageUrl,
InteractiveMode: this.canvasData.selectTemplateData.interactiveMode,
MultiPoint: this.paintPoints,
MultiPoint: JSON.parse(JSON.stringify(this.paintPoints)),
Point: new PIXI.Point(0, 0),
Name: this.canvasData.selectTemplateData.name,
PropertyInfos: propertyList,
@ -1066,12 +1066,10 @@ export class PolygonIcon extends PIXI.Container {
this.polygonLineGraphics.drawPolygon(this.getPoints());
this.polygonLineGraphics.closePath();
this.addChild(this.polygonLineGraphics);
// 名称
// const text = new PIXI.Text(this.assetData.Name, {
// fontFamily: 'Arial', fontSize: 18, fill: 0xffffff, align: 'center'
// });
this.text.anchor.set(0.5);
this.text.y -= this.assetData.Height;
// this.text.position = this.getCenterOfGravityPoint(this.pointsData);
console.log(this.polygonLineGraphics._bounds);
this.polygonLineGraphics.addChild(this.text);
// 添加圆点事件
this.pointsGraphics.forEach((item, index, array) => {
@ -1167,6 +1165,32 @@ export class PolygonIcon extends PIXI.Container {
item.visible = value;
});
}
public getCenterOfGravityPoint(points) {
let sumX = 0;
let sumY = 0;
let sumArea = 0;
let area = 0;
let p1 = points[1];
for (let i = 2; i < points.length; i++) {
const p2 = points[i];
area = this.Area(points[0], p1, p2);
sumArea += area;
sumX += (points[0][0] + p1[0] + p2[0]) * area;
sumY += (points[0][1] + p1[1] + p2[1]) * area;
p1 = p2;
}
const pointX = sumX / sumArea / 3;
const pointY = sumY / sumArea / 3;
console.log(pointX);
console.log(pointY);
return new PIXI.Point(pointX, pointY);
}
Area(p0, p1, p2) {
let area = 0.0;
area = p0[0] * p1[1] + p1[0] * p2[1] + p2[0] * p0[1] - p1[0] * p0[1] - p2[0] * p1[1] - p0[0] * p2[1];
return area / 2;
}
/**
*
*/

Loading…
Cancel
Save