123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- import { SPolylineItem, ItemOrder, SItemStatus } from '@saga-web/big/lib'
- import { SColor } from '@saga-web/draw'
- import { SPoint } from '@saga-web/draw/lib'
- export class TipelineItem extends SPolylineItem {
- constructor(parent, data) {
- super(parent, [])
-
- this.startAnchor = null
-
- this.endAnchor = null
-
- this._graphElementId = ''
-
- this._node1Id = ''
-
- this._node2Id = ''
-
- this._anchor1ID = ''
-
- this._anchor2ID = ''
-
- this._maskFlag = false
-
- this.data = null
- this.zOrder = ItemOrder.polylineOrder
- this.pointList = data.PointList.map((item) => {
- return new SPoint(item.X, item.Y)
- })
- this.data = data
- this.name = data.Name
- this.id = data.ID
- if (data.GraphElementId) {
- this._graphElementId = data.GraphElementId
- }
- if (data.Node1ID) {
- this._node1Id = data.Node1ID
- }
- if (data.Node2ID) {
- this._node2Id = data.Node2ID
- }
- if (data.Anchor1ID) {
- this._anchor1ID = data.Anchor1ID
- }
- if (data.Anchor2ID) {
- this._anchor2ID = data.Anchor2ID
- }
- if (data.Properties && data.Properties.Color) {
- this.strokeColor = new SColor(data.Properties.Color)
- }
-
-
-
- if (data.Properties && data.Properties.LineWidth) {
- this.lineWidth = data.Properties.LineWidth
- }
- }
- get graphElementId() {
- return this._graphElementId
- }
- set graphElementId(v) {
- this._graphElementId = v
- if (this.data) {
- this.data.GraphElementId = this._graphElementId
- }
- }
- get node1Id() {
- return this._node1Id
- }
- set node1Id(v) {
- this._node1Id = v
- if (this.data) {
- this.data.Node1ID = this._node1Id
- }
- }
- get node2Id() {
- return this._node2Id
- }
- set node2Id(v) {
- this._node2Id = v
- if (this.data) {
- this.data.Node2ID = this._node2Id
- }
- }
- get anchor1ID() {
- return this._anchor1ID
- }
- set anchor1ID(v) {
- this._anchor1ID = v
- if (this.data) {
- this.data.Anchor1ID = this._anchor1ID
- }
- }
- get anchor2ID() {
- return this._anchor2ID
- }
- set anchor2ID(v) {
- this._anchor2ID = v
- if (this.data) {
- this.data.Anchor2ID = this._anchor2ID
- }
- }
- get maskFlag() {
- return this._maskFlag
- }
- set maskFlag(v) {
- if (v === this._maskFlag) {
- return
- }
- this._maskFlag = v
- this.update()
- }
-
- changePos() {
- if (this.startAnchor) {
-
- if (this.startAnchor.parent && this.startAnchor.parent.parent) {
- this.pointList[0] = this.startAnchor.mapToScene(0, 0)
- }
- }
- if (this.endAnchor) {
-
- if (this.endAnchor.parent && this.endAnchor.parent.parent) {
- this.pointList[this.pointList.length - 1] = this.endAnchor.mapToScene(0, 0)
- }
- }
- }
-
- toData() {
- let pointList = this.pointList.map((item) => {
- return {
- X: item.x,
- Y: item.y,
- }
- })
- if (this.data) {
- this.data.Name = this.name;
- this.data.PointList = pointList
- this.data.Properties.LineWidth = this.lineWidth
-
- this.data.Properties.Color = this.strokeColor.value
- }
- return this.data
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- onPaint(painter, rect) {
- super.onPaint(painter, rect);
- if (this.maskFlag && this.status == SItemStatus.Normal) {
- if (this.selected) {
- painter.pen.lineWidth = painter.toPx(this.lineWidth * 2);
- } else {
- painter.pen.lineWidth = painter.toPx(this.lineWidth);
- }
- painter.pen.color = new SColor('#ffffff80')
- painter.drawPolyline(this.pointList)
- }
- }
- }
|