|
@@ -1,10 +1,11 @@
|
|
import { SMouseEvent, SUndoStack } from "@saga-web/base";
|
|
import { SMouseEvent, SUndoStack } from "@saga-web/base";
|
|
import { SGraphScene } from '@saga-web/graph/lib';
|
|
import { SGraphScene } from '@saga-web/graph/lib';
|
|
-import { SPoint } from '@saga-web/draw/lib';
|
|
|
|
|
|
+import { SPoint, SFont } from '@saga-web/draw/lib';
|
|
import { SFloorParser, SImageItem, STextItem, SLineItem, SPolylineItem, SItemStatus, ItemOrder } from "@saga-web/big";
|
|
import { SFloorParser, SImageItem, STextItem, SLineItem, SPolylineItem, SItemStatus, ItemOrder } from "@saga-web/big";
|
|
import { SGraphItem, SGraphPointListInsert, SGraphPointListDelete, SGraphPointListUpdate, SGraphAddCommand } from "@saga-web/graph/lib";
|
|
import { SGraphItem, SGraphPointListInsert, SGraphPointListDelete, SGraphPointListUpdate, SGraphAddCommand } from "@saga-web/graph/lib";
|
|
import { SPolygonItem } from "./SPolygonItem";
|
|
import { SPolygonItem } from "./SPolygonItem";
|
|
import { TipelineItem } from "@/lib/TipelineItem";
|
|
import { TipelineItem } from "@/lib/TipelineItem";
|
|
|
|
+import { SImgTextItem } from "@/lib/SImgTextItem"
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -40,20 +41,54 @@ export class EditScence extends SGraphScene {
|
|
};
|
|
};
|
|
/** 当前选中焦点Item */
|
|
/** 当前选中焦点Item */
|
|
focusItem: SGraphItem | null = null;
|
|
focusItem: SGraphItem | null = null;
|
|
-
|
|
|
|
constructor() {
|
|
constructor() {
|
|
super();
|
|
super();
|
|
-
|
|
|
|
|
|
+ // // 选择绑定选额item事件
|
|
|
|
+ this.selectContainer.connect("listChange", this, this.listChange);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 监听变化
|
|
|
|
+ * @param obj 变化后的对象
|
|
|
|
+ */
|
|
|
|
+ listChange(obj: any) {
|
|
|
|
+ let itemType: string = ''
|
|
|
|
+ if (obj.itemList[0] instanceof STextItem) {
|
|
|
|
+ itemType = 'text'
|
|
|
|
+ } else if (obj.itemList[0] instanceof SImageItem) {
|
|
|
|
+ itemType = 'images'
|
|
|
|
+ } else if (obj.itemList[0] instanceof SLineItem) {
|
|
|
|
+ itemType = 'line'
|
|
|
|
+ } else if (obj.itemList[0] instanceof SPolylineItem) {
|
|
|
|
+ itemType = 'pipeline'
|
|
|
|
+ } else if (obj.itemList[0] instanceof SImgTextItem) {
|
|
|
|
+ itemType = 'equipment'
|
|
|
|
+ }else{
|
|
|
|
+ itemType = ''
|
|
|
|
+ };
|
|
|
|
+ if (obj.itemList.length == 1) {
|
|
|
|
+ // 获取聚焦item
|
|
|
|
+ this.focusItem = obj.itemList[0]
|
|
|
|
+ }
|
|
|
|
+ let msg = {
|
|
|
|
+ itemList: obj.itemList,
|
|
|
|
+ itemType,
|
|
|
|
+ }
|
|
|
|
+ this.emitChange(msg)
|
|
}
|
|
}
|
|
|
|
+ emitChange(msg: any) {
|
|
|
|
|
|
|
|
+ }
|
|
/**
|
|
/**
|
|
* 增加线段item
|
|
* 增加线段item
|
|
*/
|
|
*/
|
|
|
|
+
|
|
addLine(event: SMouseEvent): boolean {
|
|
addLine(event: SMouseEvent): boolean {
|
|
const item = new SLineItem(null, new SPoint(event.x, event.y));
|
|
const item = new SLineItem(null, new SPoint(event.x, event.y));
|
|
this.addItem(item);
|
|
this.addItem(item);
|
|
item.connect("finishCreated", this, this.finishCreated);
|
|
item.connect("finishCreated", this, this.finishCreated);
|
|
- item.zOrder = ItemOrder.lineOrder
|
|
|
|
|
|
+ item.zOrder = ItemOrder.lineOrder;
|
|
|
|
+ item.moveable = true;
|
|
|
|
+ item.selectable = true;
|
|
this.grabItem = item;
|
|
this.grabItem = item;
|
|
this.undoStack.push(new SGraphAddCommand(this, item));
|
|
this.undoStack.push(new SGraphAddCommand(this, item));
|
|
// item.connect("onMove", this, this.onItemMove.bind(this));
|
|
// item.connect("onMove", this, this.onItemMove.bind(this));
|
|
@@ -64,9 +99,12 @@ export class EditScence extends SGraphScene {
|
|
* 增加折线item
|
|
* 增加折线item
|
|
*/
|
|
*/
|
|
addPolylineItem(event: SMouseEvent): boolean {
|
|
addPolylineItem(event: SMouseEvent): boolean {
|
|
|
|
+
|
|
const point = new SPoint(event.x, event.y)
|
|
const point = new SPoint(event.x, event.y)
|
|
const item = new TipelineItem(null, [point]);
|
|
const item = new TipelineItem(null, [point]);
|
|
//设置状态
|
|
//设置状态
|
|
|
|
+ item.moveable = true;
|
|
|
|
+ item.selectable = true;
|
|
item.status = SItemStatus.Create;
|
|
item.status = SItemStatus.Create;
|
|
item.zOrder = ItemOrder.polylineOrder
|
|
item.zOrder = ItemOrder.polylineOrder
|
|
this.addItem(item);
|
|
this.addItem(item);
|
|
@@ -74,13 +112,13 @@ export class EditScence extends SGraphScene {
|
|
// this.undoStack.push(new SGraphAddCommand(this, item));
|
|
// this.undoStack.push(new SGraphAddCommand(this, item));
|
|
this.grabItem = item;
|
|
this.grabItem = item;
|
|
this.focusItem = item;
|
|
this.focusItem = item;
|
|
- console.log(this)
|
|
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 增加多边形item
|
|
* 增加多边形item
|
|
*/
|
|
*/
|
|
|
|
+
|
|
addPolygonItem(event: SMouseEvent): void {
|
|
addPolygonItem(event: SMouseEvent): void {
|
|
//创建item
|
|
//创建item
|
|
const Polylines = new SPolygonItem(null);
|
|
const Polylines = new SPolygonItem(null);
|
|
@@ -90,6 +128,7 @@ export class EditScence extends SGraphScene {
|
|
const point = new SPoint(event.x, event.y);
|
|
const point = new SPoint(event.x, event.y);
|
|
Polylines.zOrder = ItemOrder.polygonOrder;
|
|
Polylines.zOrder = ItemOrder.polygonOrder;
|
|
Polylines.setPointList = [point];
|
|
Polylines.setPointList = [point];
|
|
|
|
+ Polylines.moveable = true;
|
|
this.addItem(Polylines);
|
|
this.addItem(Polylines);
|
|
Polylines.connect("finishCreated", this, this.finishCreated);
|
|
Polylines.connect("finishCreated", this, this.finishCreated);
|
|
this.grabItem = Polylines;
|
|
this.grabItem = Polylines;
|
|
@@ -105,6 +144,7 @@ export class EditScence extends SGraphScene {
|
|
item.url = url;
|
|
item.url = url;
|
|
item.zOrder = ItemOrder.imageOrder;
|
|
item.zOrder = ItemOrder.imageOrder;
|
|
item.selectable = true;
|
|
item.selectable = true;
|
|
|
|
+ item.moveable = true;
|
|
item.moveTo(event.x, event.y);
|
|
item.moveTo(event.x, event.y);
|
|
this.addItem(item);
|
|
this.addItem(item);
|
|
this.grabItem == null;
|
|
this.grabItem == null;
|
|
@@ -119,6 +159,7 @@ export class EditScence extends SGraphScene {
|
|
const item = new STextItem(null, '请在右侧属性栏输入文字!');
|
|
const item = new STextItem(null, '请在右侧属性栏输入文字!');
|
|
item.moveTo(event.x, event.y);
|
|
item.moveTo(event.x, event.y);
|
|
item.selectable = true;
|
|
item.selectable = true;
|
|
|
|
+ item.moveable = true;
|
|
item.zOrder = ItemOrder.textOrder;
|
|
item.zOrder = ItemOrder.textOrder;
|
|
this.addItem(item);
|
|
this.addItem(item);
|
|
this.grabItem == null
|
|
this.grabItem == null
|
|
@@ -140,8 +181,61 @@ export class EditScence extends SGraphScene {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 删除指定item
|
|
|
|
- */
|
|
|
|
|
|
+ * 更改文本对应属性
|
|
|
|
+ * @param str string 文字内容
|
|
|
|
+ */
|
|
|
|
+ updatedText(str: string): void {
|
|
|
|
+ if (this.focusItem) {
|
|
|
|
+ const old = this.focusItem.text;
|
|
|
|
+ this.focusItem.text = str;
|
|
|
|
+ this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "text", old, str));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更改文本fontSize属性
|
|
|
|
+ * @param size number 文字大小
|
|
|
|
+ */
|
|
|
|
+ updatedFontSize(size: number): void {
|
|
|
|
+ if (this.focusItem) {
|
|
|
|
+ let old = new SFont(this.focusItem.font);
|
|
|
|
+ let font = new SFont(this.focusItem.font);
|
|
|
|
+ font.size = size;
|
|
|
|
+ this.focusItem.font = font;
|
|
|
|
+ this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "font", old, font));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更改线宽属性
|
|
|
|
+ * @param lineWidth number 线宽大小
|
|
|
|
+ */
|
|
|
|
+ updatedLineWidth(lineWidth: number): void {
|
|
|
|
+ if (this.focusItem) {
|
|
|
|
+ // let old = new SFont(this.focusItem.font);
|
|
|
|
+ // let font = new SFont(this.focusItem.font);
|
|
|
|
+ // font.size = size;
|
|
|
|
+ this.focusItem.lineWidth = lineWidth;
|
|
|
|
+ // this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "font", old, font));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更改文本颜色属性
|
|
|
|
+ * @param str string 颜色
|
|
|
|
+ */
|
|
|
|
+ updatedColor(str: string): void {
|
|
|
|
+ if (this.focusItem.color) {
|
|
|
|
+ let old = this.focusItem.color;
|
|
|
|
+ this.focusItem.color = color;
|
|
|
|
+ this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "color", old, color));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除指定item
|
|
|
|
+ */
|
|
deleiteItemStatus(): void {
|
|
deleiteItemStatus(): void {
|
|
|
|
|
|
}
|
|
}
|
|
@@ -157,6 +251,7 @@ export class EditScence extends SGraphScene {
|
|
* 提取item
|
|
* 提取item
|
|
*/
|
|
*/
|
|
extractItem(): void {
|
|
extractItem(): void {
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -182,7 +277,6 @@ export class EditScence extends SGraphScene {
|
|
* 完成事件创建的回调函数
|
|
* 完成事件创建的回调函数
|
|
*/
|
|
*/
|
|
finishCreated(item: any) {
|
|
finishCreated(item: any) {
|
|
- console.log(3333333333333)
|
|
|
|
this.setCmd = 0;
|
|
this.setCmd = 0;
|
|
this.focusItem = item;
|
|
this.focusItem = item;
|
|
this.selectContainer.toggleItem(item)
|
|
this.selectContainer.toggleItem(item)
|