You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
354 lines
13 KiB
354 lines
13 KiB
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; |
|
import { Game } from 'src/app/babylon/game'; |
|
import { LoginSatus } from 'src/app/babylon/controller/status/login-status'; |
|
import { StatusManager } from 'src/app/babylon/controller/status/status-manager'; |
|
import { InsitutionDataSimple } from 'src/app/babylon/model/data/institution/institution-data-simple'; |
|
import { ModeManager } from 'src/app/babylon/controller/mode-manager'; |
|
import { ServeManager } from 'src/app/babylon/controller/serve-manager'; |
|
import { BuildingBasicInfosService } from 'src/app/service/babylon/building-basic-infos.service'; |
|
import { ObjectsService } from 'src/app/service/objects.service'; |
|
import { ToolbarWindow } from 'src/app/babylon/view/toolbar-window/toobar-window'; |
|
import { BuildingStatus } from 'src/app/babylon/controller/status/building-status'; |
|
import { BuildingUIItem } from 'src/app/babylon/view/building-window/building-ui-item'; |
|
import { BuildingType } from 'src/app/babylon/model/data/institution/building/building-data'; |
|
import { BuildingWindow } from 'src/app/babylon/view/building-window/building-window'; |
|
import { FacilityUIItem } from 'src/app/babylon/view/facility-window/facility-ui-item'; |
|
import { FacilityWindow } from 'src/app/babylon/view/facility-window/facility-window'; |
|
import { FacilityInfoUIItem } from 'src/app/babylon/view/facilityinfoinscene-window/facilityinfo-ui-item'; |
|
import { EventManager } from '@angular/platform-browser'; |
|
import { NzMessageService } from 'ng-zorro-antd/message'; |
|
import { LeftDomainComponent } from '../left-domain/left-domain.component'; |
|
import { JYZInfoMoudleType } from 'src/app/babylon/model/data/institution/jyz-show-data'; |
|
|
|
|
|
|
|
@Component({ |
|
selector: 'app-plan', |
|
templateUrl: './plan.component.html', |
|
styleUrls: ['./plan.component.scss', './publicPop.scss'] |
|
}) |
|
export class PlanComponent implements OnInit { |
|
|
|
constructor(private element: ElementRef, private buildingBISrv: BuildingBasicInfosService, private objectsSrv: ObjectsService, private eventManager: EventManager, private message: NzMessageService) { } |
|
|
|
static instance: PlanComponent; |
|
public game: Game = new Game(); |
|
public beforeOneSatus; //当前 satus |
|
public canvas: HTMLCanvasElement; //canvas 实例 |
|
public isShowLoading: boolean = false; //显隐 loading加载条 |
|
|
|
ngOnInit(): void { |
|
PlanComponent.instance = this; |
|
ServeManager.Init(this.buildingBISrv, this.objectsSrv); |
|
this.canvas = this.element.nativeElement.querySelector('#center') as HTMLCanvasElement; |
|
this.game.init(this.canvas); |
|
//监听 delete键盘事件 |
|
this.eventManager.addGlobalEventListener('window', 'keydown', (event: any) => { |
|
if (event.keyCode == 46) { //delete |
|
if (this.beforeOnePropertyData) { |
|
let isDelete = confirm("是否删除已选择模型?"); |
|
if (isDelete) { this.beforeOnePropertyData.askDelete(false) }; |
|
} |
|
} |
|
}) |
|
//监听 delete键盘事件 |
|
} |
|
|
|
ngAfterViewInit(): void { |
|
let loginStatus = StatusManager.getStatus<LoginSatus>(LoginSatus); |
|
loginStatus.getInstitutionListFromServe((result: InsitutionDataSimple[], data: any) => { |
|
if (ModeManager.institutionDemoKey == ModeManager.c_demoKey_null) { //无指定测试单位,则为正式启动,根据当前单位key寻找 |
|
let key = 'ceshi'; |
|
// console.log("获取数据", data); |
|
let find = data.find(item => { return item.key === key }) |
|
if (find) { //如果在data中找到了对应的单位key,则表示已经有三维数据,直接进入 |
|
// console.log("找到已有单位" + key); |
|
this.beforeOneSatus = StatusManager.getStatus<LoginSatus>(LoginSatus); |
|
this.beforeOneSatus.onSelectInsSuccess(find) |
|
} else { //如果没有找到对应的单位key,则调用新建单位 |
|
let isAdd = confirm('没有单位name,是否进行初始化?') |
|
if (isAdd) { |
|
let name = 'ceshi'; |
|
console.log("没找到单位,新建" + key); |
|
loginStatus.createInsitution(key, name); |
|
} |
|
} |
|
} else { |
|
let find = data.find(item => { return item.key === ModeManager.institutionDemoKey }) |
|
if (find) { |
|
sessionStorage.setItem('unitId', find.key) |
|
this.beforeOneSatus = StatusManager.getStatus<LoginSatus>(LoginSatus); |
|
this.beforeOneSatus.onSelectInsSuccess(find) |
|
} else { |
|
this.modelInit(data) //开发模式 选择单位 弹窗 |
|
} |
|
} |
|
}); |
|
} |
|
|
|
ngOnDestroy(): void { //组件销毁前 销毁canvas |
|
this.game.dispose(); |
|
this.game = null; |
|
} |
|
|
|
//开发模式 选择单位 弹窗 |
|
modelInit(InsList) { } |
|
|
|
allFence: string[] = ["基本信息", "加油机", "油罐设备", "消防设施", "安全疏散", "输油管线", "油气回收", "应急处置"]; //头部 功能栏 |
|
selectFence: number = -1; //选中 头部功能栏 |
|
isShowChildComponent: boolean = false; //是否 显示左侧子组件 |
|
@ViewChild('leftDomain') leftDomain: LeftDomainComponent; //子组件引用 |
|
isOpenAwning: boolean = true; //是否 打开罩棚 |
|
selectMeasure: number = 0; //当前选择 测量工具 |
|
|
|
//切换 头部功能栏 |
|
toggleHeaderFence(type: number) { |
|
this.beforeOneSatus = StatusManager.getStatus<BuildingStatus>(BuildingStatus); |
|
let buildingWindow: BuildingWindow = this.beforeOneSatus.buildingWindow; |
|
let fenceType: JYZInfoMoudleType = this.getFenceType(type) |
|
if (this.selectFence != type) { |
|
this.isShowChildComponent && this.leftDomain ? this.leftDomain.initComponent(type) : null; //手动初始化子组件 |
|
this.selectFence = type |
|
this.isShowChildComponent = true |
|
buildingWindow.showJYZInfoModel(fenceType, true) |
|
} else { //取消选中 |
|
this.selectFence = -1 |
|
this.isShowChildComponent = false |
|
buildingWindow.showJYZInfoModel(fenceType, false) |
|
} |
|
} |
|
|
|
//获取 头部功能栏Type |
|
getFenceType(type: number): JYZInfoMoudleType { |
|
let fenceType |
|
if (type === 0) { |
|
fenceType = JYZInfoMoudleType.JBXX |
|
} else if (type === 1) { |
|
fenceType = JYZInfoMoudleType.JYJ |
|
} else if (type === 2) { |
|
fenceType = JYZInfoMoudleType.YG |
|
} else if (type === 3) { |
|
fenceType = JYZInfoMoudleType.XF |
|
} else if (type === 4) { |
|
fenceType = JYZInfoMoudleType.AQSS |
|
} else if (type === 5) { |
|
fenceType = JYZInfoMoudleType.SYG |
|
} else if (type === 6) { |
|
fenceType = JYZInfoMoudleType.YQHSGX |
|
} else if (type === 7) { |
|
fenceType = JYZInfoMoudleType.YJCZ |
|
} |
|
return fenceType |
|
} |
|
|
|
//切换 头部罩棚 |
|
toggleHeaderAwning(isOpen: boolean) { |
|
this.isOpenAwning = isOpen; |
|
ToolbarWindow.instance.showZP(isOpen) |
|
} |
|
|
|
//切换 测量工具 |
|
toggleMeasure(type: number) { |
|
if (this.selectMeasure != type) { //切换工具 |
|
this.selectMeasure = type |
|
if (type === 1) { |
|
ToolbarWindow.instance.measureDistance() |
|
} else if (type === 2) { |
|
ToolbarWindow.instance.measureHeight() |
|
} else { |
|
ToolbarWindow.instance.measureArea() |
|
} |
|
} else { //关闭测量工具 |
|
this.selectMeasure = 0 |
|
ToolbarWindow.instance.endMeasure() |
|
} |
|
} |
|
|
|
buildingUIItems: BuildingUIItem[] = []; //左侧 建筑list |
|
beforeOneBuildingID: string = null; //选中 左侧建筑ID |
|
modelBuilding: modelBuilding = new modelBuilding(); //创建/编辑 建筑ngModel数据 |
|
addBuildingPop: boolean = false; //显隐 新增左侧建筑弹窗 |
|
editBuildingPop: BuildingUIItem = null; //显隐 编辑左侧建筑弹窗 |
|
isShowLeftBuilding: boolean = true; //显隐 建筑list |
|
toggleLeftBuilding(e) { this.isShowLeftBuilding = e }; //显隐 建筑list |
|
|
|
uploadList: File[] = []; //多选上传文件 |
|
//选择文件 |
|
selectFile(e) { |
|
if (e.target.files.length) { |
|
this.uploadList = [] //多选上传 |
|
Object.keys(e.target.files).forEach(item => { this.uploadList.push(e.target.files[item]) }) |
|
} |
|
} |
|
|
|
//选择建筑 |
|
selectLeftBuilding(e) { |
|
let item: BuildingUIItem = e; |
|
this.beforeOneBuildingID = item.getBuildingID() |
|
item.select(); |
|
} |
|
|
|
//创建/编辑建筑 |
|
addModelBuilding(e: modelBuilding) { |
|
if (this.addBuildingPop) { //新增 |
|
let order = this.buildingUIItems.length + 1; |
|
this.beforeOneSatus = StatusManager.getStatus<BuildingStatus>(BuildingStatus); |
|
let buildingWindow: BuildingWindow = this.beforeOneSatus.buildingWindow; |
|
let newBuildingData = this.beforeOneSatus.createOneBuildingInData(e.name, e.name, e.modelType); |
|
buildingWindow.changeModel(this.uploadList, newBuildingData); |
|
buildingWindow.createOneBuildingItem(newBuildingData, order); |
|
this.modelBuilding = new modelBuilding(); |
|
this.buildingUIItems = this.beforeOneSatus.buildingWindow.buildingUIItems; //更新 建筑列表list |
|
this.addBuildingPop = false; //关闭弹窗 |
|
} else if (this.editBuildingPop) { //编辑 |
|
this.editBuildingPop.setBuildingName(e.name); |
|
this.editBuildingPop.changeModel(this.uploadList); |
|
this.editBuildingPop = null; //关闭弹窗 |
|
} |
|
} |
|
|
|
//打开编辑建筑 弹窗 |
|
editModelBuilding(event, e: BuildingUIItem) { |
|
event.stopPropagation() |
|
this.modelBuilding.name = JSON.parse(JSON.stringify(e.getBuildingName())) |
|
this.modelBuilding.modelType = JSON.parse(JSON.stringify(e.getBuildingType())) |
|
this.editBuildingPop = e; //打开弹窗 |
|
} |
|
|
|
//聚焦 建筑 |
|
positionModelBuilding(event, e: BuildingUIItem) { |
|
event.stopPropagation() |
|
e.lookAt() |
|
} |
|
|
|
//删除建筑 |
|
deleteModelBuilding(event, e: BuildingUIItem) { |
|
event.stopPropagation() |
|
let isTrue = confirm('您确定要删除吗') |
|
if (isTrue) { |
|
this.beforeOneSatus = StatusManager.getStatus<BuildingStatus>(BuildingStatus); |
|
let buildingWindow: BuildingWindow = this.beforeOneSatus.buildingWindow; |
|
buildingWindow.deleteBuilding(e) |
|
this.buildingUIItems = this.beforeOneSatus.buildingWindow.buildingUIItems; //更新 建筑列表list |
|
} |
|
} |
|
|
|
allFacilityUIItemes: FacilityUIItem[] = []; //底部所有 图标 |
|
beforeOneIcon: string = null; //当前选择 图标 |
|
|
|
// 获取 底部图标栏list |
|
getAllIcons(e: FacilityWindow) { |
|
this.allFacilityUIItemes = e.allFacilityUIItemes |
|
this.beforeOneIcon = null |
|
} |
|
|
|
//选择底部图标 |
|
selectBottomIcon(e: FacilityUIItem) { |
|
if (this.beforeOneIcon != e.getIconID()) { |
|
this.beforeOneIcon = e.getIconID() |
|
e.select() |
|
} else { |
|
this.beforeOneIcon = null |
|
e.unSelect() |
|
} |
|
} |
|
|
|
//取消选择 底部图标 |
|
unSelectBottomIcon() { |
|
if (this.beforeOneIcon) { |
|
let e: FacilityUIItem = this.allFacilityUIItemes.find(item => { return item.getIconID() === this.beforeOneIcon }) |
|
e ? e.unSelect() : null |
|
this.beforeOneIcon = null |
|
} |
|
} |
|
|
|
//底部图标栏 滚动条 |
|
bottomScroll(e) { |
|
let bootomDiv = this.element.nativeElement.querySelector('#bottomCenter') |
|
e == 0 ? bootomDiv.scrollLeft = bootomDiv.scrollLeft + 50 : bootomDiv.scrollLeft = bootomDiv.scrollLeft - 50 |
|
} |
|
|
|
beforeOnePropertyData: FacilityInfoUIItem = null; //当前选择 设备 |
|
|
|
//选中 设备 |
|
selectProperty(e: FacilityInfoUIItem) { |
|
this.beforeOnePropertyData = e |
|
if (this.isShowChildComponent && this.leftDomain) { |
|
this.leftDomain.selectFacilityId = e.getID() |
|
} |
|
} |
|
|
|
selectRightTopFast: number = 0; //当前选择功能 快捷栏 |
|
selectAdsorb: boolean = false; //吸附状态 |
|
topLevelView: boolean = false; //顶视图状态 |
|
|
|
//获取设备 |
|
getDevice() { |
|
ToolbarWindow.instance.getModelAndCreateFacilityData() |
|
} |
|
|
|
//清空设备 |
|
clearDevice() { |
|
let isClear = confirm('您确定要清空吗?') |
|
if (isClear) { |
|
ToolbarWindow.instance.clearAllFacilityDataFromMesh() |
|
} |
|
} |
|
|
|
//平移 |
|
translation() { |
|
this.selectRightTopFast = 0 |
|
ToolbarWindow.instance.changeGizmoType_position(); |
|
} |
|
|
|
//旋转 |
|
revolve() { |
|
this.selectRightTopFast = 1 |
|
ToolbarWindow.instance.changeGizmoType_Rotation(); |
|
} |
|
|
|
//缩放 |
|
scale() { |
|
this.selectRightTopFast = 2 |
|
ToolbarWindow.instance.changeGizmoType_Scale(); |
|
} |
|
|
|
//吸附 |
|
adsorb() { |
|
ToolbarWindow.instance.changeMeshAdsorbY(); |
|
} |
|
|
|
//获取吸附的状态 |
|
updateSelectAdsorb() { |
|
this.selectAdsorb = ToolbarWindow.instance.isMeshAdsorb; |
|
} |
|
|
|
//切换至顶视图 |
|
toggleTopLevelView() { |
|
this.topLevelView = !this.topLevelView |
|
ToolbarWindow.instance.changeTopView(this.topLevelView) |
|
} |
|
|
|
//保存 |
|
preserve(type: boolean) { |
|
if (type) { |
|
ToolbarWindow.instance.onBtnSave(); |
|
} else { |
|
ToolbarWindow.instance.saveShowMoudleData(); |
|
} |
|
} |
|
|
|
//通用 消息通知栏 |
|
openSnackBar(title: string) { |
|
this.message.info(title); |
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//创建/编辑 建筑dataType |
|
export class modelBuilding { |
|
name: string = ""; |
|
modelType: BuildingType = BuildingType.Normal; |
|
}
|
|
|