chenjingyu 4 years ago
parent
commit
e855cb43de
  1. 13
      package-lock.json
  2. 1
      package.json
  3. 3
      src/app/key-unit/basicinfo/basicinfo.component.html
  4. 113
      src/app/key-unit/basicinfo/basicinfo.component.ts
  5. 2
      src/app/key-unit/key-unit-management/key-unit-management.component.ts
  6. 21
      src/app/tabbar/tabbar.component.ts
  7. 4
      src/app/working-area/model/axShape.ts
  8. 164
      src/app/working-area/model/configuration.ts
  9. 145
      src/app/working-area/model/dimensioning.ts
  10. 67
      src/app/working-area/model/events.ts
  11. 87
      src/app/working-area/model/grid2D.ts
  12. 3
      src/app/working-area/working-area.component.html
  13. 446
      src/app/working-area/working-area.component.ts

13
package-lock.json generated

@ -12876,6 +12876,11 @@
"sha.js": "^2.4.8" "sha.js": "^2.4.8"
} }
}, },
"penner": {
"version": "0.1.3",
"resolved": "https://registry.npm.taobao.org/penner/download/penner-0.1.3.tgz",
"integrity": "sha1-C4tILU6bOa8vPXw3WSIpuKzClwU="
},
"perfect-scrollbar": { "perfect-scrollbar": {
"version": "1.5.0", "version": "1.5.0",
"resolved": "https://registry.npm.taobao.org/perfect-scrollbar/download/perfect-scrollbar-1.5.0.tgz", "resolved": "https://registry.npm.taobao.org/perfect-scrollbar/download/perfect-scrollbar-1.5.0.tgz",
@ -12962,6 +12967,14 @@
"@pixi/filter-zoom-blur": "3.1.1" "@pixi/filter-zoom-blur": "3.1.1"
} }
}, },
"pixi-viewport": {
"version": "4.18.1",
"resolved": "https://registry.npm.taobao.org/pixi-viewport/download/pixi-viewport-4.18.1.tgz",
"integrity": "sha1-EP1/72igFjwcKhxvI83KVvzbRvM=",
"requires": {
"penner": "^0.1.3"
}
},
"pixi.js": { "pixi.js": {
"version": "5.3.3", "version": "5.3.3",
"resolved": "https://registry.npm.taobao.org/pixi.js/download/pixi.js-5.3.3.tgz", "resolved": "https://registry.npm.taobao.org/pixi.js/download/pixi.js-5.3.3.tgz",

1
package.json

@ -39,6 +39,7 @@
"ngx-perfect-scrollbar": "^8.0.0", "ngx-perfect-scrollbar": "^8.0.0",
"photo-sphere-viewer": "^4.0.7", "photo-sphere-viewer": "^4.0.7",
"pixi-filters": "^3.1.1", "pixi-filters": "^3.1.1",
"pixi-viewport": "^4.18.1",
"pixi.js": "^5.3.2", "pixi.js": "^5.3.2",
"rxjs": "~6.5.4", "rxjs": "~6.5.4",
"swiper": "^5.3.7", "swiper": "^5.3.7",

3
src/app/key-unit/basicinfo/basicinfo.component.html

@ -108,7 +108,8 @@
<div class="uploadimg" (click)="lookmaster()"> <div class="uploadimg" (click)="lookmaster()">
<span>单位照片:</span> <span>单位照片:</span>
<div class="uploadingimg"> <div class="uploadingimg">
<img [src]="imgsrc" alt="" style="width: 299px; height: 170px;" > <img *ngIf="imgsrc" [src]="imgsrc" alt="" style="width: 299px; height: 170px;">
<img *ngIf="!imgsrc" [src]="noImgSrc" alt="" style="width: 299px; height: 170px;">
</div> </div>
<mat-spinner *ngIf="isspinner" diameter= 50></mat-spinner> <mat-spinner *ngIf="isspinner" diameter= 50></mat-spinner>
</div> </div>

113
src/app/key-unit/basicinfo/basicinfo.component.ts

@ -5,21 +5,12 @@ import { HttpClient,HttpHeaders, HttpEventType } from '@angular/common/http';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { MatSnackBar ,MatSnackBarConfig} from '@angular/material/snack-bar'; import { MatSnackBar ,MatSnackBarConfig} from '@angular/material/snack-bar';
import format from 'date-fns/format';
import { TreeService } from '../../http-interceptors/tree.service' import { TreeService } from '../../http-interceptors/tree.service'
import { FileUploader, FileItem } from 'ng2-file-upload'
// import { House } from '../../interface'
import { AddHouseInfo } from './addhouseinfo.component' import { AddHouseInfo } from './addhouseinfo.component'
import { DomSanitizer } from '@angular/platform-browser'
import { Injectable } from "@angular/core"
import { filter } from 'rxjs/operators';
import { async } from '@angular/core/testing';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { isNgTemplate } from '@angular/compiler';
import * as _ from 'lodash'; import * as _ from 'lodash';
// import Swiper from 'swiper';
import { LookMaster } from './lookmaster.component' import { LookMaster } from './lookmaster.component'
import { Router,ActivatedRoute } from '@angular/router' import { ActivatedRoute } from '@angular/router'
import { TabbarAndScoreService } from 'src/app/http-interceptors/tabbar-and-score.service'; import { TabbarAndScoreService } from 'src/app/http-interceptors/tabbar-and-score.service';
declare var AMap: any; declare var AMap: any;
@ -48,16 +39,6 @@ export class BasicinfoComponent implements OnInit {
} }
] ]
} }
uploader:FileUploader = new FileUploader({ //初始化上传事件 ng2-upload
url: `/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}`,
method: "POST",
itemAlias: "uploadedfile",
autoUpload: false,
removeAfterUpload:true //上传之后是否在队列中移除,如果不移除就会出现无法上传第二次的情况
});
private _transformer = (node, level: number) => { //初始化tree private _transformer = (node, level: number) => { //初始化tree
@ -79,22 +60,22 @@ export class BasicinfoComponent implements OnInit {
isorganizationbox = false//控制辖区中队框的显示隐藏 isorganizationbox = false//控制辖区中队框的显示隐藏
selectedorganization: any//所选的辖区中队 selectedorganization: any//所选的辖区中队
selectedorganizationid:any //所选的辖区中队的id selectedorganizationid:any //所选的辖区中队的id
highhouse = false//控制高层表单的显示 highhouse = false//控制高层表单的显示
houses: any = [] //存储当前单位的建筑信息
defaultbuildingTypes :any //存储当前建筑的默认类型的id defaultbuildingTypes :any //存储当前建筑的默认类型的id
buildingTypesname:any//存储当前建筑的默认类型name buildingTypesname:any//存储当前建筑的默认类型name
buildingCustomData:any //存储当前建筑的自定义信息 buildingCustomData:any //存储当前建筑的自定义信息
allunittype: any //所有单位类型
allorganizing:any = [] //所有组织机构
constructor(private elementRef: ElementRef,public renderer2: Renderer2,private tabbarService: TabbarAndScoreService,private router:Router,private route:ActivatedRoute,private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { } constructor(private elementRef: ElementRef,public renderer2: Renderer2,private tabbarService: TabbarAndScoreService,private route:ActivatedRoute,private http: HttpClient, private tree: TreeService, public dialog: MatDialog,public snackBar: MatSnackBar) { }
unitId : any //当前单位id unitId : any //当前单位id
ngOnInit(): void { ngOnInit(): void {
this.getallunittype() this.getallunittype()//获得所有单位类型
this.getorganization() this.getorganization()//获得所有组织机构 + 获得当前单位的基本信息
// this.getunitinfo() this.getunitallbuilding()//获得当前单位所有建筑
this.getunitallbuilding()
this.unitId = this.route.snapshot.queryParams.id this.unitId = this.route.snapshot.queryParams.id
sessionStorage.setItem("companyId",this.route.snapshot.queryParams.id); sessionStorage.setItem("companyId",this.route.snapshot.queryParams.id);
} }
@ -107,7 +88,6 @@ export class BasicinfoComponent implements OnInit {
isGisTopBoxTwo:boolean = false//点击位置按钮 isGisTopBoxTwo:boolean = false//点击位置按钮
oldPositionMarker:any //旧位置marker实例 oldPositionMarker:any //旧位置marker实例
newPositionMarker:any //新位置marker实例 newPositionMarker:any //新位置marker实例
newPositionMarkerContent:any = newPositionMarkerContent:any =
'<div class="custom-content-marker">' + '<div class="custom-content-marker">' +
' <img src="/assets/images/newposition.png">' + ' <img src="/assets/images/newposition.png">' +
@ -179,13 +159,9 @@ export class BasicinfoComponent implements OnInit {
this.map.setCity('上海市'); this.map.setCity('上海市');
} }
} }
markerPosition2 markerPosition2
//点击位置按钮 //点击位置按钮
setPosition(){ setPosition(){
this.isGisTopBox = false this.isGisTopBox = false
this.isGisTopBoxTwo = true this.isGisTopBoxTwo = true
if(this.isMapLabel){//如果已经标注单位坐标 if(this.isMapLabel){//如果已经标注单位坐标
@ -304,12 +280,14 @@ export class BasicinfoComponent implements OnInit {
} }
//获得所有单位类型 //获得所有单位类型
allunittype: any //所有单位类型
getallunittype() { getallunittype() {
this.http.get("/api/BuildingTypes/Simple").subscribe(data => { this.http.get("/api/BuildingTypes/Simple").subscribe(data => {
this.allunittype = data this.allunittype = data
}) })
} }
//获得所有组织机构 //获得所有组织机构
allorganizing:any = [] //所有组织机构
getorganization() { getorganization() {
this.http.get('/api/Organizations').subscribe( this.http.get('/api/Organizations').subscribe(
(data: any) => { (data: any) => {
@ -323,15 +301,12 @@ export class BasicinfoComponent implements OnInit {
}else{//未标注 }else{//未标注
_this.isMapLabel = false _this.isMapLabel = false
} }
this.labelGis() this.labelGis()
}) })
} }
) )
} }
//获得当前单位的基本信息 //获得当前单位的基本信息
CompanyId
async getunitinfo(){ async getunitinfo(){
let result = await new Promise((resolve, reject) => { let result = await new Promise((resolve, reject) => {
this.http.get(`/api/Companies/${this.unitId}`).subscribe((data:any)=>{ this.http.get(`/api/Companies/${this.unitId}`).subscribe((data:any)=>{
@ -367,8 +342,7 @@ export class BasicinfoComponent implements OnInit {
}) })
this.selectedorganization = str.substr(1) this.selectedorganization = str.substr(1)
} }
} }
this.unitinfo = data this.unitinfo = data
resolve(this.unitinfo) resolve(this.unitinfo)
this.selectedorganizationid = data.organizationId this.selectedorganizationid = data.organizationId
@ -383,6 +357,7 @@ export class BasicinfoComponent implements OnInit {
}) })
} }
//石油化工 装置信息 勾选框 //石油化工 装置信息 勾选框
checkboxchange(item,e){ checkboxchange(item,e){
if(item.buildingBasicGroups){ if(item.buildingBasicGroups){
@ -395,13 +370,13 @@ export class BasicinfoComponent implements OnInit {
} }
unitallbuilding:any = []//用于存储当前单位所有的建筑 unitallbuilding:any = []//用于存储当前单位所有的建筑
buildinginfoId:any = []//用于存储当前单位所有具体建筑的id
presentbuildinfoId:any // 用于存储当前单位第一个建筑的id
bigfor:any//循环(储罐信息+罐区信息)大组 bigfor:any//循环(储罐信息+罐区信息)大组
npdata:any = [] npdata:any = []
newnpdata:any //用于存储石油化工 储罐信息/罐区情况的 datasource newnpdata:any //用于存储石油化工 储罐信息/罐区情况的 datasource
basicCategoryId:any //当前单位所有建筑中位于第一个的建筑id
deviceinfodata:any=[];//用于存储石油化工装置信息的数组 deviceinfodata:any=[];//用于存储石油化工装置信息的数组
zhuangzhiinfodatasource:any = [] //用于存储石油化工装置信息表格的数据来源 zhuangzhiinfodatasource:any = [] //用于存储石油化工装置信息表格的数据来源
newzhuangzhiinfodatasource:any= []//存储石油化工装置信息表格的 datasource形式 newzhuangzhiinfodatasource:any= []//存储石油化工装置信息表格的 datasource形式
@ -575,7 +550,11 @@ export class BasicinfoComponent implements OnInit {
item.buildingCustomData.customProperties.pop() item.buildingCustomData.customProperties.pop()
} }
//得到建筑信息数据并进行处理 //得到建筑信息数据并进行处理
allBuildings:any allBuildings:any //当前单位所有的建筑
houses: any = [] //存储当前单位的建筑信息
basicCategoryId:any //当前单位所有建筑中位于第一个的建筑类型id
presentbuildinfoId:any //用于存储当前单位第一个建筑的具体id
buildinginfoId:any = []//用于存储当前单位所有具体建筑的id
getunitallbuilding(){ getunitallbuilding(){
this.houses = [] this.houses = []
this.unitId = this.route.snapshot.queryParams.id this.unitId = this.route.snapshot.queryParams.id
@ -584,9 +563,9 @@ export class BasicinfoComponent implements OnInit {
companyId:this.unitId companyId:this.unitId
} }
}).subscribe(async (data:any)=>{ // 获得当前单位所有的建筑 }).subscribe(async (data:any)=>{ // 获得当前单位所有的建筑
console.log('所有建筑',data)
this.allBuildings = data this.allBuildings = data
// console.log(data) if(data.length != 0){//如果存在建筑
if(data.length != 0){
this.basicCategoryId = data[0].buildingTypes[0].id this.basicCategoryId = data[0].buildingTypes[0].id
this.presentbuildinfoId = data[0].id // 用于存储当前单位第一个建筑的id this.presentbuildinfoId = data[0].id // 用于存储当前单位第一个建筑的id
for (let i = 0, length = data.length; i < length; i++) {//循环所有建筑 for (let i = 0, length = data.length; i < length; i++) {//循环所有建筑
@ -601,17 +580,19 @@ export class BasicinfoComponent implements OnInit {
buildingType:n.buildingTypes[0].id buildingType:n.buildingTypes[0].id
} }
}).subscribe((data)=>{ }).subscribe((data)=>{
//获得当前建筑自定义信息并且添加到item自定义属性上 //获得当前建筑自定义信息并且添加到建筑属性对象中
let _data = data let _data = data
console.log('当前建筑信息'+index,data)
this.http.get("/api/BuildingCustomData",{params:{ this.http.get("/api/BuildingCustomData",{params:{
buildingId:n.id buildingId:n.id
}}).subscribe((data:any)=>{ }}).subscribe((data:any)=>{
console.log('当前建筑自定义信息'+index,data)
_data[0].buildingCustomData = data _data[0].buildingCustomData = data
if(data && data.customProperties.length != 0){ if(data && data.customProperties.length != 0){
_data[0].isCustomData = true _data[0].isCustomData = true
}else{ }else{
_data[0].isCustomData = false _data[0].isCustomData = false
_data[0].buildingCustomData ={ _data[0].buildingCustomData = {
id: "", id: "",
customProperties: [ customProperties: [
{ {
@ -623,7 +604,7 @@ export class BasicinfoComponent implements OnInit {
} }
} }
}) })
//为每个建筑添加自定义属性 //为每个建筑添加建筑名称等自定义属性 用于显示使用
data[0].buildingtypeId = n.buildingTypes[0].id data[0].buildingtypeId = n.buildingTypes[0].id
data[0].name = n.name data[0].name = n.name
data[0].username = n.name data[0].username = n.name
@ -714,7 +695,6 @@ export class BasicinfoComponent implements OnInit {
this.houses.push(result) // 并且把他添加到 tab 总体数组中 this.houses.push(result) // 并且把他添加到 tab 总体数组中
} }
} }
// console.log(666,this.houses)
}) })
} }
@ -1052,7 +1032,8 @@ export class BasicinfoComponent implements OnInit {
hasChild = (_: number, node: any) => node.expandable; hasChild = (_: number, node: any) => node.expandable;
imgsrc = "../../../assets/images/upload.jpg" //没有上传图片时显示的图片,当上传后就会被替换,即保存时需要传的图片地址参数 imgsrc = "" //没有上传图片时显示的图片,当上传后就会被替换,即保存时需要传的图片地址参数
noImgSrc = '../../../assets/images/upload.jpg'
// imgsrc = "" // imgsrc = ""
imgUrl = ""//返回来的图片地址后缀 imgUrl = ""//返回来的图片地址后缀
file: any; //上传的文件 file: any; //上传的文件
@ -1102,7 +1083,6 @@ export class BasicinfoComponent implements OnInit {
let shardSize = 5 * 1024 * 1024 //5MB一个分片 let shardSize = 5 * 1024 * 1024 //5MB一个分片
if (file && fileSize <= shardSize) { //上传文件<=5MB时 if (file && fileSize <= shardSize) { //上传文件<=5MB时
// this.upload()
let formData = new FormData() let formData = new FormData()
formData.append("file",file) formData.append("file",file)
this.http.post(`/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{ this.http.post(`/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{
@ -1124,38 +1104,6 @@ export class BasicinfoComponent implements OnInit {
}) })
} }
} }
//小于5MB不需要分块上传
upload(){
this.uploader.queue[0].upload();//开始上传
this.uploader.queue[0].onSuccess = (response, status, headers) => {
// 上传文件成功
if (status == 201) {
// 上传文件后获取服务器返回的数据
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传成功','确定',config);
this.isspinner = false
let tempRes = JSON.parse(response);
this.imgUrl = tempRes.objectName
this.imgsrc = `/api/Objects/PlanPlatform/${this.imgUrl}?x-oss-process=image/resize,m_fill,h_170,w_299`
}else {
// 上传文件后获取服务器返回的数据错误
}
};
this.uploader.queue[0].onError = (response, status, headers) => {
if (status == 401) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传失败','确定',config);
}
};
}
//开始分块上传 //开始分块上传
async subsectionUploading () { async subsectionUploading () {
@ -1194,7 +1142,6 @@ export class BasicinfoComponent implements OnInit {
this.imgsrc = `/api/Objects/PlanPlatform/${this.objectName}?x-oss-process=image/resize,m_fill,h_170,w_299` this.imgsrc = `/api/Objects/PlanPlatform/${this.objectName}?x-oss-process=image/resize,m_fill,h_170,w_299`
this.isspinner = false this.isspinner = false
this.PartNumberETag = [] this.PartNumberETag = []
this.uploader.clearQueue(); //清空input控件文件
}) })
} }
//删除具体建筑 //删除具体建筑

2
src/app/key-unit/key-unit-management/key-unit-management.component.ts

@ -636,7 +636,7 @@ export class KeyUnitManagementComponent implements OnInit {
sessionStorage.setItem("companyName",data.name) sessionStorage.setItem("companyName",data.name)
sessionStorage.setItem("editable","1") sessionStorage.setItem("editable","1")
sessionStorage.setItem("companyId",data.id) sessionStorage.setItem("companyId",data.id)
window.open(`/keyUnit/editplaninfo?id=${data.id}`); window.open(`/keyUnit/editplaninfo?id=${data.id}&usci=${data.usci}`);
} }
} }
); );

21
src/app/tabbar/tabbar.component.ts

@ -61,14 +61,21 @@ export class TabbarComponent implements OnInit {
// this.companyIntegrityScore = obj // this.companyIntegrityScore = obj
this.getIntegrityScore() this.getIntegrityScore()
this.tabbarService.getMessage().subscribe((message: any)=>{ this.tabbarService.getMessage().subscribe((message: any)=>{
console.log(789,message);//send a message
this.getIntegrityScore() this.getIntegrityScore()
}); });
} }
this.getUserInfo() this.getUserInfo()
} }
//根据usci获取当前单位的分数信息
getIntegrityScore(){
let params:any = {
USCI : this.route.snapshot.queryParams.usci
}
this.http.get('/api/Companies',{params:params}).subscribe((data:any) => {
this.companyIntegrityScore = data.items[0].companyIntegrityScore
})
}
isSpinner:boolean = false//下载帮助文档进度 isSpinner:boolean = false//下载帮助文档进度
//下载帮助文档 //下载帮助文档
downloadHelpFile () { downloadHelpFile () {
@ -151,15 +158,7 @@ export class TabbarComponent implements OnInit {
} //for循环 } //for循环
} }
//根据usci获取当前单位的分数信息
getIntegrityScore(){
let params:any = {
USCI : this.route.snapshot.queryParams.usci
}
this.http.get('/api/Companies',{params:params}).subscribe((data:any) => {
this.companyIntegrityScore = data.items[0].companyIntegrityScore
})
}
ngOnDestroy(){ ngOnDestroy(){
this.routerEventsListener.unsubscribe() this.routerEventsListener.unsubscribe()

4
src/app/working-area/model/axShape.ts

@ -55,8 +55,8 @@ export class AxShape extends Graphics {
this.workingArea.selection.all().forEach(item => { this.workingArea.selection.all().forEach(item => {
const x = event.data.global.x - this.mousePosition.x; const x = event.data.global.x - this.mousePosition.x;
const y = event.data.global.y - this.mousePosition.y; const y = event.data.global.y - this.mousePosition.y;
item.x += x * (1 / this.workingArea.backgroundImage.scale.x); item.x += x * (1 / this.workingArea.camera2D.scale.x);
item.y += y * (1 / this.workingArea.backgroundImage.scale.y); item.y += y * (1 / this.workingArea.camera2D.scale.y);
item.assetData.Point = new PIXI.Point(item.x, item.y); item.assetData.Point = new PIXI.Point(item.x, item.y);
this.workingArea.canvasData.isChange = true; this.workingArea.canvasData.isChange = true;
}); });

164
src/app/working-area/model/configuration.ts

@ -0,0 +1,164 @@
import { EventDispatcher } from 'three';
import { EVENT_CHANGED } from './events';
// GENERAL:
/** The dimensioning unit for 2D floorplan measurements. */
export var configDimUnit = 'dimUnit';
// WALL:
/** The initial wall height in cm. */
export const configWallHeight = 'wallHeight';
/** The initial wall thickness in cm. */
export const configWallThickness = 'wallThickness';
export const configSystemUI = 'systemUI';
export const scale = 'scale';
export const gridSpacing = 'gridSpacing';
export const snapToGrid = 'snapToGrid';
export const directionalDrag = 'directionalDrag';
export const dragOnlyX = 'dragOnlyX';
export const dragOnlyY = 'dragOnlyY';
export const snapTolerance = 'snapTolerance'; //In CMS
export const boundsX = 'boundsX'; //In CMS
export const boundsY = 'boundsY'; //In CMS
export const viewBounds = 'viewBounds';//In CMS
export const dimInch = 'inch';
/** Dimensioning in Inch. */
export const dimFeetAndInch = 'feetAndInch';
/** Dimensioning in Meter. */
export const dimMeter = 'm';
/** Dimensioning in Centi Meter. */
export const dimCentiMeter = 'cm';
/** Dimensioning in Milli Meter. */
export const dimMilliMeter = 'mm';
export const VIEW_TOP = 'topview';
export const VIEW_FRONT = 'frontview';
export const VIEW_RIGHT = 'rightview';
export const VIEW_LEFT = 'leftview';
export const VIEW_ISOMETRY = 'isometryview';
export enum WallTypes{
STRAIGHT,
CURVED
}
export const TEXTURE_DEFAULT_REPEAT = 300;
export const defaultWallTexture =
{
color: '#FFFFFF', repeat: TEXTURE_DEFAULT_REPEAT, normalmap: 'textures/Wall/Brick_Wall_017_SD/Brick_Wall_017_normal.jpg', roughnessmap: 'textures/Wall/Brick_Wall_017_SD/Brick_Wall_017_roughness.jpg', colormap: 'textures/Wall/Brick_Wall_017_SD/Brick_Wall_017_basecolor.jpg', ambientmap: 'textures/Wall/Brick_Wall_017_SD/Brick_Wall_017_ambientOcclusion.jpg', bumpmap: 'textures/Wall/Brick_Wall_017_SD/Brick_Wall_017_height.png'
};
export const defaultFloorTexture =
{
color: '#FFFFFF', emissive: '#181818', repeat: TEXTURE_DEFAULT_REPEAT, ambientmap: 'textures/Floor/Marble_Tiles_001/Marble_Tiles_001_ambientOcclusion.jpg', colormap: 'textures/Floor/Marble_Tiles_001/Marble_Tiles_001_basecolor.jpg', roughnessmap: 'textures/Floor/Marble_Tiles_001/Marble_Tiles_001_roughness.jpg', normalmap: 'textures/Floor/Marble_Tiles_001/Marble_Tiles_001_normal.jpg'
};
export const TEXTURE_PROPERTY_COLOR = 'color';
export const TEXTURE_NO_PREVIEW = 'textures/NoPreview.jpg';
export var config = {
dimUnit: dimCentiMeter,
wallHeight: 250,
wallThickness: 20,
systemUI: false,
scale: 1,
snapToGrid: true,
dragOnlyX: false,
dragOnlyY: false,
snapTolerance: 50,
gridSpacing: 20, // 50,
directionalDrag: true,
boundsX: 500,
boundsY: 500,
viewBounds: 20000 };
export var wallInformation = { exterior: false, interior: false, midline: true, labels: true, exteriorlabel: 'e:', interiorlabel: 'i:', midlinelabel: 'm:' };
/**
* The tolerance in cms between corners, otherwise below this tolerance they will snap together as one corner*/
export const cornerTolerance = 20;
/** Global configuration to customize the whole system.
* This is a singleton instance;
*/
export class Configuration extends EventDispatcher {
private static instance = new Configuration();
constructor() {
/** Configuration data loaded from/stored to extern. */
// this.data = {dimUnit: dimCentiMeter, wallHeight: 250, wallThickness: 10};
super();
}
static getInstance() {
if (this.instance === undefined
|| this.instance === null) {
this.instance = new Configuration();
}
return this.instance;
}
static getData() {
// return {dimUnit: dimCentiMeter,wallHeight: 250, wallThickness: 10};
return config;
}
/** Set a configuration parameter. */
static setValue(key, value) {
// this.data[key] = value;
config[key] = value;
// if(key !== viewBounds){
Configuration.getInstance().dispatchEvent({ type: EVENT_CHANGED, item: Configuration.getInstance(), 'key': key, 'value': value });
// }
}
/** Get a string configuration parameter. */
static getStringValue(key) {
switch (key) {
case configDimUnit:
// return String(this.data[key]);
return String(Configuration.getData()[key]);
default:
throw new Error('Invalid string configuration parameter: ' + key);
}
}
/** Get a numeric configuration parameter. */
static getNumericValue(key) {
switch (key) {
case configSystemUI:
case configWallHeight:
case configWallThickness:
case scale:
case snapTolerance:
case gridSpacing:
case boundsX:
case boundsY:
case viewBounds:
// return Number(this.data[key]);
return Number(Configuration.getData()[key]);
default:
throw new Error('Invalid numeric configuration parameter: ' + key);
}
}
/** Get a numeric configuration parameter. */
static getBooleanValue(key) {
switch (key) {
case snapToGrid:
case directionalDrag:
case dragOnlyX:
case dragOnlyY:
return Boolean(Configuration.getData()[key]);
default:
throw new Error('Invalid Boolean configuration parameter: ' + key);
}
}
}

145
src/app/working-area/model/dimensioning.ts

@ -0,0 +1,145 @@
import { Vector2, Vector3 } from 'three';
import { Configuration, configDimUnit,dimInch, dimFeetAndInch, dimMeter, dimCentiMeter, dimMilliMeter } from './configuration';
export const decimals = 1000;
export const cmPerFoot = 30.48;
export const pixelsPerFoot = 5.0;
export const pixelsPerCm = 1; // 0.5;
export const cmPerPixel = (1.0 / pixelsPerCm);
export const dimensioningOptions = [dimInch, dimFeetAndInch, dimMeter, dimCentiMeter, dimMilliMeter];
/** Dimensioning functions. */
export class Dimensioning {
static cmToPixelVector2D(cmV2d) {
let pixelV2d = new Vector2(Dimensioning.cmToPixel(cmV2d.x), Dimensioning.cmToPixel(cmV2d.y));
return pixelV2d;
}
static cmToPixelVector3D(cmV3d) {
let pixelV2d = new Vector3(Dimensioning.cmToPixel(cmV3d.x), Dimensioning.cmToPixel(cmV3d.y), Dimensioning.cmToPixel(cmV3d.z));
return pixelV2d;
}
static pixelToCmVector2D(pixelV2d) {
let cmV2d = new Vector2(Dimensioning.cmToPixel(pixelV2d.x), Dimensioning.cmToPixel(pixelV2d.y));
return cmV2d;
}
static pixelToCmVector3D(pixel3d) {
let cmV2d = new Vector3(Dimensioning.cmToPixel(pixel3d.x), Dimensioning.cmToPixel(pixel3d.y), Dimensioning.cmToPixel(pixel3d.z));
return cmV2d;
}
static cmToPixel(cm, apply_scale = true) {
if (apply_scale) {
return cm * pixelsPerCm * Configuration.getNumericValue('scale');
}
return cm * pixelsPerCm;
}
static pixelToCm(pixel, apply_scale = true) {
if (apply_scale) {
return pixel * cmPerPixel * (1.0 / Configuration.getNumericValue('scale'));
}
return pixel * cmPerPixel;
}
static roundOff(value, decimals) {
return Math.round(decimals * value) / decimals;
}
/** Converts cm to dimensioning number.
* @param cm Centi meter value to be converted.
* @returns Number representation.
*/
static cmFromMeasureRaw(measure) {
switch (Configuration.getStringValue(configDimUnit)) {
case dimFeetAndInch:
return Math.round(decimals * (measure * 30.480016459203095991)) / decimals;
case dimInch:
return Math.round(decimals * (measure * 2.5400013716002578512)) / decimals;
case dimMilliMeter:
return Math.round(decimals * (measure * 0.10000005400001014955)) / decimals;
case dimCentiMeter:
return measure;
case dimMeter:
default:
return Math.round(decimals * 100 * measure) / decimals;
}
}
/** Converts cm to dimensioning string.
* @param cm Centi meter value to be converted.
* @returns String representation.
*/
static cmFromMeasure(measure) {
switch (Configuration.getStringValue(configDimUnit)) {
case dimFeetAndInch:
return Math.round(decimals * (measure * 30.480016459203095991)) / decimals + 'cm';
case dimInch:
return Math.round(decimals * (measure * 2.5400013716002578512)) / decimals + 'cm';
case dimMilliMeter:
return Math.round(decimals * (measure * 0.10000005400001014955)) / decimals + 'cm';
case dimCentiMeter:
return measure;
case dimMeter:
default:
return Math.round(decimals * 100 * measure) / decimals + 'cm';
}
}
/** Converts cm to dimensioning string.
* @param cm Centi meter value to be converted.
* @returns String representation.
*/
static cmToMeasureRaw(cm, power = 1) {
switch (Configuration.getStringValue(configDimUnit)) {
case dimFeetAndInch: // dimFeetAndInch returns only the feet
var allInFeet = (cm * Math.pow(0.032808416666669996953, power));
return allInFeet;
case dimInch:
var inches = Math.round(decimals * (cm * Math.pow(0.393700, power))) / decimals;
return inches;
case dimMilliMeter:
var mm = Math.round(decimals * (cm * Math.pow(10, power))) / decimals;
return mm;
case dimCentiMeter:
return Math.round(decimals * cm) / decimals;
case dimMeter:
default:
var m = Math.round(decimals * (cm * Math.pow(0.01, power))) / decimals;
return m;
}
}
/** Converts cm to dimensioning string.
* @param cm Centi meter value to be converted.
* @returns String representation.
*/
static cmToMeasure(cm, power = 1) {
switch (Configuration.getStringValue(configDimUnit)) {
case dimFeetAndInch:
var allInFeet = (cm * Math.pow(0.032808416666669996953, power));
var floorFeet = Math.floor(allInFeet);
var remainingFeet = allInFeet - floorFeet;
var remainingInches = Math.round(remainingFeet * 12);
return floorFeet + '\'' + remainingInches + '';
case dimInch:
var inches = Math.round(decimals * (cm * Math.pow(0.393700, power))) / decimals;
return inches + '\'';
case dimMilliMeter:
var mm = Math.round(decimals * (cm * Math.pow(10, power))) / decimals;
return '' + mm + 'mm';
case dimCentiMeter:
return '' + Math.round(decimals * cm) / decimals + 'cm';
case dimMeter:
default:
var m = Math.round(decimals * (cm * Math.pow(0.01, power))) / decimals;
return '' + m + 'm';
}
}
}

67
src/app/working-area/model/events.ts

@ -0,0 +1,67 @@
export const EVENT_ACTION = 'ACTION_EVENT';
export const EVENT_DELETED = 'DELETED_EVENT';
export const EVENT_MOVED = 'MOVED_EVENT';
export const EVENT_REDRAW = 'REDRAW_EVENT';
export const EVENT_NEW = 'NEW_EVENT';
export const EVENT_LOADED = 'LOADED_EVENT';
export const EVENT_LOADING = 'LOADING_EVENT';
export const EVENT_UPDATED = 'UPDATED_EVENT';
export const EVENT_SAVED = 'SAVED_EVENT';
export const EVENT_CHANGED = 'CHANGED_EVENT';
export const EVENT_GLTF_READY = 'GLTF_READY_EVENT';
export const EVENT_EXTERNAL_FLOORPLAN_LOADED = 'EXTERNAL_FLOORPLAN_LOADED_EVENT';
export const EVENT_NEW_PARAMETRIC_ITEM = 'NEW_PARAMETRIC_ITEM_EVENT';
export const EVENT_NEW_ITEM = 'NEW_ITEM_EVENT';
export const EVENT_ITEM_LOADING = 'ITEM_LOADING_EVENT';
export const EVENT_ITEM_LOADED = 'ITEM_LOADED_EVENT';
export const EVENT_ITEM_REMOVED = 'ITEM_REMOVED_EVENT';
export const EVENT_ITEM_SELECTED = 'ITEM_SELECTED_EVENT';
export const EVENT_ITEM_MOVE = 'ITEM_MOVED_EVENT';
export const EVENT_ITEM_MOVE_FINISH = 'ITEM_MOVED_FINISH_EVENT';
export const EVENT_ITEM_HOVERON = 'ITEM_HOVERON_EVENT';
export const EVENT_ITEM_HOVEROFF = 'ITEM_HOVEROFF_EVENT';
export const EVENT_NO_ITEM_SELECTED = 'ITEM_NO_SELECTED_EVENT';
export const EVENT_MODE_RESET = 'MODE_RESET_EVENT';
export const EVENT_CAMERA_MOVED = 'CAMERA_MOVED_EVENT';
export const EVENT_CAMERA_ACTIVE_STATUS = 'CAMERA_ACTIVE_STATUS_EVENT';
export const EVENT_CAMERA_VIEW_CHANGE = 'CAMERA_VIEW_CHANGE_EVENT';
export const EVENT_FPS_EXIT = 'CAMERA_FPS_EXIT_EVENT';
export const EVENT_WALL_CLICKED = 'WALL_CLICKED_EVENT';
export const EVENT_ROOM_CLICKED = 'ROOM_CLICKED_EVENT';
export const EVENT_FLOOR_CLICKED = 'FLOOR_CLICKED_EVENT';
export const EVENT_NOTHING_CLICKED = 'NOTHING_CLICKED_EVENT';
export const EVENT_ROOM_NAME_CHANGED = 'CHANGED_ROOM_NAME_EVENT';
export const EVENT_NEW_ROOMS_ADDED = 'ADDED_NEW_ROOMS_EVENT';
export const EVENT_CORNER_ATTRIBUTES_CHANGED = 'CORNER_ATTRIBUTES_CHANGED_EVENT';
export const EVENT_WALL_ATTRIBUTES_CHANGED = 'WALL_ATTRIBUTES_CHANGED_EVENT';
export const EVENT_ROOM_ATTRIBUTES_CHANGED = 'ROOM_ATTRIBUTES_CHANGED_EVENT';
export const EVENT_CORNER_2D_CLICKED = 'CORNER_CLICKED_2D_EVENT';
export const EVENT_WALL_2D_CLICKED = 'WALL_CLICKED_2D_EVENT';
export const EVENT_ROOM_2D_CLICKED = 'ROOM_CLICKED_2D_EVENT';
export const EVENT_2D_UNSELECTED = 'UNSELECTED_2D_EVENT';
export const EVENT_2D_SELECTED = 'SELECTED_2D_EVENT';
export const EVENT_NOTHING_2D_SELECTED = 'NOTHING_2D_SELECTED_EVENT';
export const EVENT_CORNER_2D_DOUBLE_CLICKED = 'CORNER_DOUBLE_CLICKED_2D_EVENT';
export const EVENT_WALL_2D_DOUBLE_CLICKED = 'WALL_DOUBLE_CLICKED_2D_EVENT';
export const EVENT_ROOM_2D_DOUBLE_CLICKED = 'ROOM_DOUBLE_CLICKED_2D_EVENT';
export const EVENT_CORNER_2D_HOVER = 'CORNER_HOVER_2D_EVENT';
export const EVENT_WALL_2D_HOVER = 'WALL_HOVER_2D_EVENT';
export const EVENT_ROOM_2D_HOVER = 'ROOM_HOVER_2D_EVENT';
export const EVENT_KEY_PRESSED = 'KEY_PRESSED_EVENT';
export const EVENT_KEY_RELEASED = 'KEY_RELEASED_EVENT';
export const EVENT_UPDATE_TEXTURES = 'UPDATE_TEXTURES_EVENT';
export const EVENT_MODIFY_TEXTURE_ATTRIBUTE = 'MODIFY_TEXTURE_ATTRIBUTE_EVENT';
export const EVENT_PARAMETRIC_GEOMETRY_UPATED = 'PARAMETRIC_GEOMETRY_UPATED_EVENT';

87
src/app/working-area/model/grid2D.ts

@ -0,0 +1,87 @@
import { Configuration, gridSpacing, viewBounds } from './configuration';
import { EVENT_CHANGED } from './events';
import { Graphics } from 'pixi.js';
import { Vector2 } from 'three';
import { Dimensioning } from './dimensioning';
const GRID_SIZE = 10000;
export class Grid2D extends Graphics {
canvas;
options;
size;
gridScale;
constructor(canvas, options) {
super();
// this.drawRect(0, 0, GRID_SIZE, GRID_SIZE);
this.canvas = canvas;
this.options = options;
this.size = new Vector2(GRID_SIZE, GRID_SIZE);
this.gridScale = 1.0;
this.width = this.size.x;
this.height = this.size.y;
this.drawRect(0, 0, GRID_SIZE, GRID_SIZE);
this.pivot.x = this.pivot.y = 0.5;
Configuration.getInstance().addEventListener(EVENT_CHANGED, (evt) => this.updateGrid());
this.updateGrid();
}
updateGrid() {
let gridSize = Dimensioning.cmToPixel(Configuration.getNumericValue(viewBounds) * 1);
let spacingCMS = Configuration.getNumericValue(gridSpacing);
let spacing = Dimensioning.cmToPixel(spacingCMS);
let totalLines = gridSize / spacing;
let halfSize = gridSize * 0.5;
let linewidth = Math.max(1.0 / this.gridScale, 1.0) * 1/this.canvas.scale.x;// 增加缩放系数
let highlightLineWidth = Math.max(1 / this.gridScale, 1.0) * 1/this.canvas.scale.x;// 增加缩放系数
let normalColor = 0xE0E0E0;
let highlightColor = 0xD0D0D0;
const cellSize = 5;
this.clear();
for (let i = 0; i <= totalLines; i++) {
let co = (i * spacing) - halfSize;
if (i % cellSize === 0) {
this.lineStyle(highlightLineWidth, highlightColor).moveTo(-halfSize, co).lineTo(halfSize, co);
this.lineStyle(highlightLineWidth, highlightColor).moveTo(co, -halfSize).lineTo(co, halfSize);
} else {
this.lineStyle(linewidth, normalColor).moveTo(-halfSize, co).lineTo(halfSize, co);
this.lineStyle(linewidth, normalColor).moveTo(co, -halfSize).lineTo(co, halfSize);
}
}
this.endFill();
this.beginFill(0xFF0000, 1.0);
this.drawCircle(-halfSize, -halfSize,5);
this.drawCircle(halfSize, -halfSize,5);
this.drawCircle(halfSize, halfSize,5);
this.drawCircle(-halfSize, halfSize,5);
this.drawCircle(0, 0, 5);
this.endFill();
}
getGridScale() {
return this.gridScale;
}
setGridScale(value) {
this.gridScale = value;
this.updateGrid();
}
configurationUpdate(evt) {
if (evt.key === gridSpacing) {
this.updateGrid();
}
}
getCellCoordinates(x, y) {
let gridSize = Dimensioning.cmToPixel(Configuration.getNumericValue(viewBounds) * 1);
let spacingCMS = Configuration.getNumericValue(gridSpacing);
let spacing = Dimensioning.cmToPixel(spacingCMS);
let halfSize = gridSize * 0.5;
return {
x: Math.floor((x - -halfSize) / spacing),
y: Math.floor((y - -halfSize) / spacing),
};
}
}

3
src/app/working-area/working-area.component.html

@ -1,2 +1 @@
<div #content style="width:100%;height:100%;" (mousewheel)='this.mouseWheelHandel($event)' <div #content style="width:100%;height:100%;"></div>
(DOMMouseScroll)='this.mouseWheelHandel($event)'></div>

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

@ -19,6 +19,8 @@ import { AxLegend, Legend } from './model/axLegend';
import { AxGrid } from './model/axGrid'; import { AxGrid } from './model/axGrid';
import { AxSelection } from './model/axSelection'; import { AxSelection } from './model/axSelection';
import { AxMessageSystem } from './model/axMessageSystem'; import { AxMessageSystem } from './model/axMessageSystem';
import { Grid2D } from './model/grid2D';
import { Viewport } from 'pixi-viewport';
@Component({ @Component({
@ -44,7 +46,15 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
/** /**
* pixijs * pixijs
*/ */
public app: PIXI.Application; public app: PIXI.Application = null;
/**
*
*/
public camera2D: Viewport = null;
/**
*
*/
public grid2D: Grid2D = null;
/** /**
* *
*/ */
@ -137,13 +147,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
public animation; public animation;
public animationIcon; public animationIcon;
public animationTime; public animationTime;
/**
*
*/
public grid: AxGrid = null;
// 是否按下Ctrl键 // 是否按下Ctrl键
isCtrlKeyClicked = false; isCtrlKeyClicked = false;
isMove = false;
/** /**
* <主版本号><次版本号><修订版本号><日期加希腊字母版本号> 1.0.0.20210105_beta * <主版本号><次版本号><修订版本号><日期加希腊字母版本号> 1.0.0.20210105_beta
* Alpha版: 此版本表示该软件在此阶段主要是以实现软件功能为主Bug较多 * Alpha版: 此版本表示该软件在此阶段主要是以实现软件功能为主Bug较多
@ -151,7 +156,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
* RC版: 该版本已经相当成熟了BUG * RC版: 该版本已经相当成熟了BUG
* Release版: 该版本意味使Release不会以单词形式出现在软件封面上® * Release版: 该版本意味使Release不会以单词形式出现在软件封面上®
*/ */
public VERSION = '1.0.13.20210126_beta'; public VERSION = '1.0.14.20210202_beta';
/** /**
* *
*/ */
@ -181,10 +186,10 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
public setMulitSelect(b: boolean) { public setMulitSelect(b: boolean) {
if (b) { if (b) {
this.isCtrlKeyClicked = true; this.isCtrlKeyClicked = true;
this.camera2D.plugins.pause('drag');
} else { } else {
this.isCtrlKeyClicked = false; this.isCtrlKeyClicked = false;
this.rectToolGraphics.visible = false; this.camera2D.drag();
this.rectToolGraphics.clear();
} }
} }
/** /**
@ -258,44 +263,44 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
} }
/** /**
* *
* @param event * @param event ,ViewPort控制
*/ */
public mouseWheelHandel(event) { // public mouseWheelHandel(event) {
const delX = this.mousePosition.x - this.backgroundImage.position.x; // const delX = this.mousePosition.x - this.backgroundImage.position.x;
const delY = this.mousePosition.y - this.backgroundImage.position.y; // const delY = this.mousePosition.y - this.backgroundImage.position.y;
const pivot = this.backgroundImage.toLocal(this.mousePosition); // const pivot = this.backgroundImage.toLocal(this.mousePosition);
const delta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail))); // const delta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
if (delta > 0) { // if (delta > 0) {
if (this.backgroundImage.scale.x >= 32) { // if (this.backgroundImage.scale.x >= 32) {
this.backgroundImage.scale.x = 32; // this.backgroundImage.scale.x = 32;
this.backgroundImage.scale.y = 32; // this.backgroundImage.scale.y = 32;
this.resizeItem(1 / this.backgroundImage.scale.x); // this.resizeItem(1 / this.backgroundImage.scale.x);
return; // return;
} // }
this.backgroundImage.pivot.set(pivot.x, pivot.y); // this.backgroundImage.pivot.set(pivot.x, pivot.y);
this.backgroundImage.scale.x += this.backgroundImage.scale.x * 0.1; // this.backgroundImage.scale.x += this.backgroundImage.scale.x * 0.1;
this.backgroundImage.scale.y += this.backgroundImage.scale.y * 0.1; // this.backgroundImage.scale.y += this.backgroundImage.scale.y * 0.1;
this.backgroundImage.position.x += delX; // this.backgroundImage.position.x += delX;
this.backgroundImage.position.y += delY; // this.backgroundImage.position.y += delY;
} else if (delta < 0) { // } else if (delta < 0) {
if (this.backgroundImage.scale.x <= 0.1) { // if (this.backgroundImage.scale.x <= 0.1) {
this.backgroundImage.scale.x = 0.1; // this.backgroundImage.scale.x = 0.1;
this.backgroundImage.scale.y = 0.1; // this.backgroundImage.scale.y = 0.1;
this.resizeItem(1 / this.backgroundImage.scale.x); // this.resizeItem(1 / this.backgroundImage.scale.x);
return; // return;
} // }
this.backgroundImage.pivot.set(pivot.x, pivot.y); // this.backgroundImage.pivot.set(pivot.x, pivot.y);
this.backgroundImage.scale.x -= this.backgroundImage.scale.x * 0.1; // this.backgroundImage.scale.x -= this.backgroundImage.scale.x * 0.1;
this.backgroundImage.scale.y -= this.backgroundImage.scale.y * 0.1; // this.backgroundImage.scale.y -= this.backgroundImage.scale.y * 0.1;
this.backgroundImage.position.x += delX; // this.backgroundImage.position.x += delX;
this.backgroundImage.position.y += delY; // this.backgroundImage.position.y += delY;
} // }
this.resizeItem(1 / this.backgroundImage.scale.x); // this.resizeItem(1 / this.backgroundImage.scale.x);
} // }
// 重置图形缩放 // 重置图形缩放
public resizeItem(size: number) { public resizeItem(size: number) {
this.backgroundImage.children.forEach(item => { this.backgroundImage.children.forEach(item => {
@ -307,27 +312,149 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
} }
/** /**
* *
* @param icon * @param icon Viewport控制
*/ */
public moveIconToScreenCenter(icon) { // public moveIconToScreenCenter(icon) {
if (icon.parent === this.backgroundImage && ( // if (icon.parent === this.backgroundImage && (
icon.assetData.Type === 1 || // icon.assetData.Type === 1 ||
icon.assetData.Type === 2 || // icon.assetData.Type === 2 ||
icon.assetData.Type === 3 || // icon.assetData.Type === 3 ||
icon.assetData.Type === 4 // icon.assetData.Type === 4
)) { // )) {
this.backgroundImage.pivot.set(icon.x, icon.y); // this.backgroundImage.pivot.set(icon.x, icon.y);
this.backgroundImage.position.set(771, 404); // this.backgroundImage.position.set(771, 404);
clearTimeout(this.animationTime); // clearTimeout(this.animationTime);
this.animation?.pause(); // this.animation?.pause();
this.animationIcon?.scale.set(1); // this.animationIcon?.scale.set(1);
this.animation = this.animator.breathe(icon, 10, 10, 30, true, 0); // this.animation = this.animator.breathe(icon, 10, 10, 30, true, 0);
this.animationIcon = icon; // this.animationIcon = icon;
this.animationTime = setTimeout(() => { // this.animationTime = setTimeout(() => {
this.animation?.pause(); // this.animation?.pause();
this.animationIcon?.scale.set(1); // this.animationIcon?.scale.set(1);
}, 5000); // }, 5000);
} // }
// }
/**
* 2D相机
*/
private createViewport(): void {
this.camera2D = new Viewport({
screenWidth: this.app.view.width,
screenHeight: this.app.view.height,
worldWidth: 20000,
worldHeight: 20000,
interaction: this.app.renderer.plugins.interaction,
});
this.app.stage.addChild(this.camera2D);
this.camera2D
.clamp({
left: -10000,
right: 10000,
top: -10000,
bottom: 10000,
})
.drag()
.pinch()
.wheel()
.clampZoom({
minScale: 0.12,
maxScale: 16,
})
.decelerate();
this.camera2D.on('wheel', event => {
this.updateCamera2D();
});
this.camera2D.on('pointerdown', event => {
if (this.isCtrlKeyClicked === true) {
this.rectToolGraphics.visible = true;
this.initialScreenMousePos = this.backgroundImage.toLocal(this.mousePosition);
this.finalScreenMousePos = this.backgroundImage.toLocal(this.mousePosition);
}
});
this.camera2D.on('pointerup', event => {
if (this.isCtrlKeyClicked === true) {
this.rectToolGraphics.visible = false;
const shapes: AxShape[] = [];
this.backgroundImage.children.forEach(item => {
if ( item instanceof AxShape
&& item instanceof AxPreviewImageShape === false) {
// 判断2个矩形是否相交
const rect1 = this.rectToolGraphics.getBounds();
const rect2 = item.getBounds();
if (this.isOverlap(rect1, rect2)) {
shapes.push(item);
}
}
});
this.rectToolGraphics.clear();
this.selectAll(shapes);
}
});
this.camera2D.on('pointerupoutside', event => {
if (this.isCtrlKeyClicked === true) {
this.rectToolGraphics.visible = false;
const shapes: AxShape[] = [];
this.backgroundImage.children.forEach(item => {
if ( item instanceof AxShape
&& item instanceof AxPreviewImageShape === false) {
// 判断2个矩形是否相交
const rect1 = this.rectToolGraphics.getBounds();
const rect2 = item.getBounds();
if (this.isOverlap(rect1, rect2)) {
shapes.push(item);
}
}
});
this.rectToolGraphics.clear();
this.selectAll(shapes);
}
});
this.camera2D.on('pointermove', event => {
if (this.isCtrlKeyClicked === true
&& this.rectToolGraphics.visible === true) {
this.finalScreenMousePos = this.backgroundImage.toLocal(this.mousePosition);
const init = this.initialScreenMousePos;
const final = this.finalScreenMousePos;
this.rectToolGraphics.clear();
this.rectToolGraphics.lineStyle(2, 0x00ff00, 1);
this.rectToolGraphics.beginFill(0xccccf2, 0.25);
if (final.x > init.x && final.y > init.y) {
this.rectToolGraphics.drawRect(init.x, init.y, final.x - init.x, final.y - init.y);
} else if (final.x > init.x && final.y < init.y) {
this.rectToolGraphics.drawRect(init.x, final.y, final.x - init.x, init.y - final.y);
} else if (final.x < init.x && final.y > init.y) {
this.rectToolGraphics.drawRect(final.x, init.y, init.x - final.x, final.y - init.y);
} else if (final.x < init.x && final.y < init.y) {
this.rectToolGraphics.drawRect(final.x, final.y, init.x - final.x, init.y - final.y);
}
this.rectToolGraphics.endFill();
}
});
}
/**
* 2D相机
*/
private updateCamera2D() {
this.grid2D.updateGrid();
this.resizeItem(1 / this.camera2D.scale.x);
}
/**
* 2D网格
*/
private createGrid2D(): void {
this.grid2D = new Grid2D(this.camera2D, null);
this.camera2D.addChild(this.grid2D);
} }
/** /**
* *
@ -344,20 +471,11 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.content.nativeElement.appendChild(this.app.view); this.content.nativeElement.appendChild(this.app.view);
this.app.view.style.border = '1px dashed blue'; this.app.view.style.border = '1px dashed blue';
this.animator = new Charm(PIXI); this.animator = new Charm(PIXI);
// 创建网格
this.grid = new AxGrid(this.app.view.width, null, { color: 0xffffff }, true, true);
// this.grid.x = (this.app.view.width / 2) - (this.grid.gridWidth / 2);
// this.grid.y = (this.app.view.height / 2) - (this.grid.gridWidth / 2);
// this.grid.pivot.set(0.5);
this.grid.x = this.app.stage.x;
this.grid.y = this.app.stage.y;
this.app.stage.addChild(this.grid);
this.grid.drawGrid();
this.grid.onMousemove = (evt, gridCoord) => {
};
this.createViewport();
this.createGrid2D();
this.createBackgroundImage(); this.createBackgroundImage();
this.app.ticker.add((delta) => { this.app.ticker.add((delta) => {
this.animator.update(); this.animator.update();
this.mousePosition = this.app.renderer.plugins.interaction.mouse.global; this.mousePosition = this.app.renderer.plugins.interaction.mouse.global;
@ -371,28 +489,28 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.refreshPreviewLineSegment(this.currentClickPoint.position, this.circleShadow.position); this.refreshPreviewLineSegment(this.currentClickPoint.position, this.circleShadow.position);
this.refreshPreviewPoint(); this.refreshPreviewPoint();
} }
/** // /**
* // * 显示框选
*/ // */
if (this.rectToolGraphics.visible === true) { // if (this.rectToolGraphics.visible === true) {
const init = this.initialScreenMousePos; // const init = this.initialScreenMousePos;
const final = this.finalScreenMousePos; // const final = this.finalScreenMousePos;
this.rectToolGraphics.clear(); // this.rectToolGraphics.clear();
this.rectToolGraphics.lineStyle(2, 0x00ff00, 1); // this.rectToolGraphics.lineStyle(2, 0x00ff00, 1);
this.rectToolGraphics.beginFill(0xccccf2, 0.25); // this.rectToolGraphics.beginFill(0xccccf2, 0.25);
if (final.x > init.x && final.y > init.y) { // if (final.x > init.x && final.y > init.y) {
this.rectToolGraphics.drawRect(init.x, init.y, final.x - init.x, final.y - init.y); // this.rectToolGraphics.drawRect(init.x, init.y, final.x - init.x, final.y - init.y);
} else if (final.x > init.x && final.y < init.y) { // } else if (final.x > init.x && final.y < init.y) {
this.rectToolGraphics.drawRect(init.x, final.y, final.x - init.x, init.y - final.y); // this.rectToolGraphics.drawRect(init.x, final.y, final.x - init.x, init.y - final.y);
} else if (final.x < init.x && final.y > init.y) { // } else if (final.x < init.x && final.y > init.y) {
this.rectToolGraphics.drawRect(final.x, init.y, init.x - final.x, final.y - init.y); // this.rectToolGraphics.drawRect(final.x, init.y, init.x - final.x, final.y - init.y);
} else if (final.x < init.x && final.y < init.y) { // } else if (final.x < init.x && final.y < init.y) {
this.rectToolGraphics.drawRect(final.x, final.y, init.x - final.x, init.y - final.y); // this.rectToolGraphics.drawRect(final.x, final.y, init.x - final.x, init.y - final.y);
} // }
this.rectToolGraphics.endFill(); // this.rectToolGraphics.endFill();
} // }
}); });
/** /**
* *
@ -432,7 +550,27 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.emit('canvasDataChanged'); this.emit('canvasDataChanged');
this.canvasData.isChange = true; this.canvasData.isChange = true;
}); });
// ///
// this.app.renderer.plugins.interaction.on('pointerdown', (event) => {
// if (event.data.button !== 2) { return };
// this.dragFlag = true;
// this.startPoint = { x: event.data.global.x, y: event.data.global.y };
// });
// this.app.renderer.plugins.interaction.on('pointermove', (event) => {
// if (this.dragFlag) {
// const dx = event.data.global.x - this.startPoint.x;
// const dy = event.data.global.y - this.startPoint.y;
// this.app.stage.position.x += dx;
// this.app.stage.position.y += dy;
// this.startPoint = { x: event.data.global.x, y: event.data.global.y };
// }
// });
// this.app.renderer.plugins.interaction.on('pointerup', (event) => {
// this.dragFlag = false;
// });
} }
// dragFlag;
// startPoint;
/** /**
* *
*/ */
@ -602,13 +740,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.backgroundImage this.backgroundImage
.on('pointerdown', event => { .on('pointerdown', event => {
if (event.data.button !== 0) { return; } if (event.data.button !== 0) { return; }
console.log(this.backgroundImage.toLocal(this.mousePosition)); // console.log(this.backgroundImage.toLocal(this.mousePosition));
if (!this.isMove && this.isCtrlKeyClicked === false) { if (this.isCtrlKeyClicked === false) {
event.currentTarget.data = event.data;
this.isMove = true;
event.currentTarget.dragPoint = event.data.getLocalPosition(event.currentTarget.parent);
event.currentTarget.dragPoint.x -= event.currentTarget.x;
event.currentTarget.dragPoint.y -= event.currentTarget.y;
switch (this.paintMode) { switch (this.paintMode) {
case PaintMode.endPaint: case PaintMode.endPaint:
break; break;
@ -799,51 +932,49 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
// this.emit('backgroundScale', this.backgroundImage.scale.x); // this.emit('backgroundScale', this.backgroundImage.scale.x);
break; break;
} }
} else if (!this.isMove && this.isCtrlKeyClicked === true) {
this.rectToolGraphics.visible = true;
this.isMove = true;
this.initialScreenMousePos = this.backgroundImage.toLocal(this.mousePosition);
this.finalScreenMousePos = this.backgroundImage.toLocal(this.mousePosition);
} }
// else if (this.isCtrlKeyClicked === true) {
// this.rectToolGraphics.visible = true;
// this.initialScreenMousePos = this.backgroundImage.toLocal(this.mousePosition);
// this.finalScreenMousePos = this.backgroundImage.toLocal(this.mousePosition);
// }
}) })
.on('pointerup', event => { .on('pointerup', event => {
this.isMove = false; // event.currentTarget.data = null;
event.currentTarget.data = null;
if (this.rectToolGraphics.visible === true) { // if (this.rectToolGraphics.visible === true) {
const shapes: AxShape[] = []; // const shapes: AxShape[] = [];
this.backgroundImage.children.forEach(item => { // this.backgroundImage.children.forEach(item => {
if ( item instanceof AxShape // if ( item instanceof AxShape
&& item instanceof AxPreviewImageShape === false) { // && item instanceof AxPreviewImageShape === false) {
// 判断2个矩形是否相交 // // 判断2个矩形是否相交
const rect1 = this.rectToolGraphics.getBounds(); // const rect1 = this.rectToolGraphics.getBounds();
const rect2 = item.getBounds(); // const rect2 = item.getBounds();
if (this.isOverlap(rect1, rect2)) { // if (this.isOverlap(rect1, rect2)) {
shapes.push(item); // shapes.push(item);
} // }
} // }
}); // });
this.rectToolGraphics.clear(); // this.rectToolGraphics.clear();
this.rectToolGraphics.visible = false; // this.rectToolGraphics.visible = false;
this.selectAll(shapes); // this.selectAll(shapes);
} // }
}) })
.on('pointerupoutside', event => { .on('pointerupoutside', event => {
if (this.isMove) { // if (this.isMove) {
this.isMove = false; // event.currentTarget.data = null;
event.currentTarget.data = null; // }
}
}) })
.on('pointermove', event => { .on('pointermove', event => {
if (this.isMove && this.isCtrlKeyClicked === false) { // if (this.isCtrlKeyClicked === false) {
const newPosition = event.currentTarget.data.getLocalPosition(event.currentTarget.parent); // // const newPosition = event.currentTarget.data.getLocalPosition(event.currentTarget.parent);
event.currentTarget.x = newPosition.x - event.currentTarget.dragPoint.x; // // event.currentTarget.x = newPosition.x - event.currentTarget.dragPoint.x;
event.currentTarget.y = newPosition.y - event.currentTarget.dragPoint.y; // // event.currentTarget.y = newPosition.y - event.currentTarget.dragPoint.y;
} else if (this.isMove && this.isCtrlKeyClicked === true) { // } else if (this.isCtrlKeyClicked === true) {
if (this.rectToolGraphics.visible === true) { // if (this.rectToolGraphics.visible === true) {
this.finalScreenMousePos = this.backgroundImage.toLocal(this.mousePosition); // this.finalScreenMousePos = this.backgroundImage.toLocal(this.mousePosition);
} // }
} // }
}) })
.on('rightclick', event => { .on('rightclick', event => {
event.stopPropagation(); event.stopPropagation();
@ -862,7 +993,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.previewImage.visible = false; this.previewImage.visible = false;
} }
}); });
this.app.stage.addChild(this.backgroundImage); this.camera2D.addChild(this.backgroundImage);
this.createPreviewImage(); this.createPreviewImage();
this.createPreviewLineSegment(); this.createPreviewLineSegment();
this.createCircleShadow(); this.createCircleShadow();
@ -887,19 +1018,22 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
/** /**
* *
*/ */
public async refreshBackgroundImage(imageUrl: string, imageAngle: number): Promise<void> { public async refreshBackgroundImage(imageUrl: string = this.canvasData.selectStorey.imageUrl, imageAngle: number = this.canvasData.selectStorey.imageAngle): Promise<void> {
if (imageAngle === undefined || imageAngle === null) { if (imageAngle === undefined || imageAngle === null) {
imageAngle = 0; imageAngle = 0;
} }
this.backgroundImage.scale.set(1); this.backgroundImage.scale.set(1);
this.backgroundImage.pivot.set(0); this.backgroundImage.pivot.set(0);
this.backgroundImage.x = this.app.view.width / 2; // this.backgroundImage.x = this.app.view.width / 2;
this.backgroundImage.y = this.app.view.height / 2; // this.backgroundImage.y = this.app.view.height / 2;
if (imageUrl === undefined || imageUrl === null || imageUrl === '') { if (imageUrl === undefined || imageUrl === null || imageUrl === '') {
this.backgroundImage.texture = this.backgroundTexture; this.backgroundImage.texture = this.backgroundTexture;
} else { } else {
this.backgroundImage.texture = await PIXI.Texture.fromURL(imageUrl); this.backgroundImage.texture = await PIXI.Texture.fromURL(imageUrl);
console.log(imageUrl);
} }
this.backgroundImage.x = this.backgroundImage.width/2;
this.backgroundImage.y = this.backgroundImage.height/2;
this.backgroundImage.angle = imageAngle; this.backgroundImage.angle = imageAngle;
// 等待图片加载完成 // 等待图片加载完成
const imageWidth = this.backgroundImage.texture.width; const imageWidth = this.backgroundImage.texture.width;
@ -908,9 +1042,19 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
const appHeight = this.app.view.height; const appHeight = this.app.view.height;
const wScale = appWidth / imageWidth; const wScale = appWidth / imageWidth;
const hScale = appHeight / imageHeight; const hScale = appHeight / imageHeight;
const scale = wScale < hScale ? wScale : hScale; let scale = wScale < hScale ? wScale : hScale;
if (scale < 0.12) {
scale = 0.12;
}
if (scale > 16) {
scale = 16;
}
this.camera2D.scale.set(scale);
this.camera2D.x = 235;
this.camera2D.y = 0;
// 设置图片缩放 // 设置图片缩放
this.backgroundImage.scale.set(scale); // this.backgroundImage.scale.set(scale);
// this.backgroundImage.visible = true; // this.backgroundImage.visible = true;
this.backgroundImage.children.forEach((item) => { this.backgroundImage.children.forEach((item) => {
if (item instanceof AxShape) { if (item instanceof AxShape) {
@ -944,6 +1088,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
// 创建处置预案图形 // 创建处置预案图形
this.createNodeShape(this.canvasData.selectPanelPoint.Data); this.createNodeShape(this.canvasData.selectPanelPoint.Data);
this.createAxLegend(); this.createAxLegend();
this.updateCamera2D();
} }
/** /**
* *
@ -965,6 +1111,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
}); });
// 创建处置预案图形 // 创建处置预案图形
this.createNodeShape(this.canvasData.selectPanelPoint.Data); this.createNodeShape(this.canvasData.selectPanelPoint.Data);
this.updateCamera2D();
} }
/** /**
* *
@ -1351,6 +1499,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.createNodeShape(this.canvasData.selectPanelPoint.Data); this.createNodeShape(this.canvasData.selectPanelPoint.Data);
// 隐藏图标 // 隐藏图标
this.setIconVisible(this.canvasData.hiddenBasicInfoFacilities, false); this.setIconVisible(this.canvasData.hiddenBasicInfoFacilities, false);
this.updateCamera2D();
} }
/** /**
@ -1378,6 +1528,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.createNodeShape(this.canvasData.selectPanelPoint.Data); this.createNodeShape(this.canvasData.selectPanelPoint.Data);
// 隐藏图标 // 隐藏图标
this.setIconVisible(this.canvasData.hiddenBasicInfoFacilities, false); this.setIconVisible(this.canvasData.hiddenBasicInfoFacilities, false);
this.updateCamera2D();
} }
/** /**
* - * -
@ -1402,6 +1554,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.createNodeShape(this.canvasData.selectPanelPoint.Data); this.createNodeShape(this.canvasData.selectPanelPoint.Data);
// 隐藏图标 // 隐藏图标
this.setNameVisible(false, 0); this.setNameVisible(false, 0);
this.updateCamera2D();
} }
//////////////////////////////////////////////////////////////////// 选择逻辑 //////////////////////////////////////////////////////////////////// 选择逻辑
/** /**

Loading…
Cancel
Save