Browse Source

暂存

develop
徐振升 4 years ago
parent
commit
b6d49e2f39
  1. 2
      debug.log
  2. 10
      src/app/working-area/model/axArrowConnector.ts
  3. 122
      src/app/working-area/model/axLegend.ts
  4. 14
      src/app/working-area/model/axShape.ts
  5. 37
      src/app/working-area/model/messageSystem.ts
  6. 10
      src/app/working-area/model/multipointIcon.ts
  7. 10
      src/app/working-area/model/polygonIcon.ts
  8. 2
      src/app/working-area/working-area.component.ts

2
debug.log

@ -9,3 +9,5 @@
[0108/092244.401:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3)
[0108/100658.746:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3)
[0109/083452.962:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3)
[0111/084621.230:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3)
[0111/102545.331:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3)

10
src/app/working-area/model/axArrowConnector.ts

@ -127,6 +127,16 @@ export class AxArrowConnector extends AxShape {
this.text.visible = value;
}
}
/**
*
* @param scale
*/
public drawBorder(scale: number) {
let visible = this.pointSprites[0].visible;
this.setPointVisiable(false);
super.drawBorder(scale);
this.setPointVisiable(visible);
}
/**
*
*/

122
src/app/working-area/model/axLegend.ts

@ -10,6 +10,14 @@ export class AxLegend extends AxShape {
// 数据
public shapeMap: Map<string,Legend> = new Map<string,Legend>();
pen: Graphics = new Graphics();
// up: Sprite = new Sprite(this.pointTexture);
// down: Sprite= new Sprite(this.pointTexture);
// left: Sprite= new Sprite(this.pointTexture);
// right: Sprite= new Sprite(this.pointTexture);
upLeft: Sprite= new Sprite(this.pointTexture);
upRight: Sprite= new Sprite(this.pointTexture);
downLeft: Sprite= new Sprite(this.pointTexture);
downRight: Sprite= new Sprite(this.pointTexture);
/**
*
*/
@ -102,6 +110,120 @@ export class AxLegend extends AxShape {
}
this.addChild(this.pen);
this.angle = -this.workingArea.backgroundImage.angle;
// 添加border
this.addChild(this.border);
// 添加控制点
this.addChild(this.upLeft);
this.upLeft.anchor.set(0.5);
this.upLeft.interactive = true;
this.upLeft.visible = false;
var posX = 0;
var w = this.width;
this.upLeft
.on('pointerdown', event => {
event.stopPropagation();
event.currentTarget.data = event.data;
event.currentTarget.alpha = 0.5;
event.currentTarget.dragging = true;
event.currentTarget.dragPoint = event.data.getLocalPosition(event.currentTarget.parent);
var gPos = this.upLeft.getGlobalPosition(new Point(this.downRight.x, this.downRight.y));
var temp1 = this.workingArea.backgroundImage.toLocal(gPos);
this.pivot.set(this.downRight.x, this.downRight.y);
this.position.set(temp1.x,temp1.y);
})
.on('pointerup', event => {
if (event.currentTarget.dragging) {
event.currentTarget.alpha = 1;
event.currentTarget.dragging = false;
event.currentTarget.data = null;
}
})
.on('pointerupoutside', event => {
if (event.currentTarget.dragging) {
event.currentTarget.alpha = 1;
event.currentTarget.dragging = false;
event.currentTarget.data = null;
}
})
.on('pointermove', event => {
if (event.currentTarget.dragging) {
const newPosition = event.currentTarget.data.getLocalPosition(event.currentTarget.parent);
// event.currentTarget.x = newPosition.x;
// event.currentTarget.y = newPosition.y;
var width = -(newPosition.x - event.currentTarget.dragPoint.x)
var height = -(newPosition.y - event.currentTarget.dragPoint.y);
if (width > 0) {
this.scale.x += 0.01;
this.scale.y += 0.01;
} else {
this.scale.x -= 0.01;
this.scale.y -= 0.01;
}
}
})
.on('rightclick', event => {
this.border.visible = false;
})
.on('pointerover', event => {
event.stopPropagation();
})
.on('pointerout', event => {
event.stopPropagation();
});
this.addChild(this.upRight);
this.upRight.anchor.set(0.5);
this.upRight.interactive = true;
this.upRight.visible = false;
this.addChild(this.downLeft);
this.downLeft.anchor.set(0.5);
this.downLeft.interactive = true;
this.downLeft.visible = false;
this.addChild(this.downRight);
this.downRight.anchor.set(0.5);
this.downRight.interactive = true;
this.downRight.visible = false;
}
/**
*
* @param value
*/
public setPointVisiable(value: boolean) {
let rect = this.getLocalBounds();
this.upLeft.x = rect.left;
this.upLeft.y = rect.top;
this.upRight.x = rect.right;
this.upRight.y = rect.top;
this.downLeft.x = rect.left;
this.downLeft.y = rect.bottom;
this.downRight.x = rect.right;
this.downRight.y = rect.bottom;
this.upLeft.visible = value;
this.upRight.visible = value;
this.downLeft.visible = value;
this.downRight.visible = value;
}
/**
*
* @param scale
*/
public drawBorder(scale: number) {
let visible = this.upLeft.visible;
this.setPointVisiable(false);
super.drawBorder(scale);
let rect = this.getLocalBounds();
this.upLeft.x = rect.left;
this.upLeft.y = rect.top;
this.upRight.x = rect.right;
this.upRight.y = rect.top;
this.downLeft.x = rect.left;
this.downLeft.y = rect.bottom;
this.downRight.x = rect.right;
this.downRight.y = rect.bottom;
this.setPointVisiable(visible);
}
}

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

@ -101,18 +101,7 @@ export class AxShape extends Container {
public setItemScale(scale: number) {
}
/**
*
*/
public showBorder() {
if (this.assetData.FixedSize) {
this.drawBorder(1);
}
else {
this.drawBorder(1/this.workingArea.backgroundImage.scale.x);
}
this.border.visible = true;
}
/**
*
*/
@ -158,6 +147,7 @@ export class AxShape extends Container {
this.border.lineTo(p4.x, p4.y);
this.border.closePath();
this.border.endFill();
this.border.visible = true;
}
// 画虚线
drawDash(target, x1, y1, x2, y2,dashLength = 5, spaceLength = 1) {

37
src/app/working-area/model/messageSystem.ts

@ -0,0 +1,37 @@
class MyEvent<T> extends CustomEvent<T> {
public static readonly CMD: string = "EVENT_NAME";
public constructor($type: string , $data: T ) {
super( $type , { detail: $data, bubbles: true, cancelable: true, composed: true });
}
}
class MyDispatch extends EventTarget {
private static _instance: MyDispatch;
public static get Instance(): MyDispatch {
if (!MyDispatch._instance) MyDispatch._instance = new MyDispatch();
return MyDispatch._instance;
}
public send<T>($data: T, $type: string = MyEvent.CMD): void {
const $event: CustomEvent = new MyEvent<T>($type, $data);
this.dispatchEvent($event);
}
}
class Test {
public constructor() {
MyDispatch.Instance.addEventListener(MyEvent.CMD, this.onEvent as EventListener);
}
private onEvent($e: MyEvent<ITest>): void {
console.log(`target ${$e.target}`);
console.log(`name: ${$e.detail._name} , occupation: ${$e.detail._occupation}`);
}
}
interface ITest {
_name: string;
_occupation: string;
}
let $test: Test = new Test();
MyDispatch.Instance.send<ITest>({ _name: `Aonaufly`, _occupation: `it` });

10
src/app/working-area/model/multipointIcon.ts

@ -189,6 +189,16 @@ export class MultipointIcon extends AxShape {
item.visible = value;
});
}
/**
*
* @param scale
*/
public drawBorder(scale: number) {
let visible = this.pointsGraphics[0].visible;
this.setPointVisiable(false);
super.drawBorder(scale);
this.setPointVisiable(visible);
}
// 设置名称
public setNameVisible(value: boolean, mode: GameMode) {
if (this.assetData.GameMode === mode) {

10
src/app/working-area/model/polygonIcon.ts

@ -155,6 +155,16 @@ export class PolygonIcon extends AxShape {
item.visible = value;
});
}
/**
*
* @param scale
*/
public drawBorder(scale: number) {
let visible = this.pointsGraphics[0].visible;
this.setPointVisiable(false);
super.drawBorder(scale);
this.setPointVisiable(visible);
}
// 设置缩放
public setItemScale(scale: number) {
// this.text.scale.set(scale);

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

@ -341,7 +341,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
*
*/
this.on('select', (axShape:AxShape)=> {
axShape.showBorder();
axShape.drawBorder(1/this.backgroundImage.scale.x);
axShape.setPointVisiable(this.allowEdit);
});
/**

Loading…
Cancel
Save