Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gojs-project
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jlc
gojs-project
Commits
1eafc031
Commit
1eafc031
authored
Jul 05, 2024
by
jlc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:节点旋转后的端口移动
parent
467c2351
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
14 deletions
+35
-14
PortShiftingTool.ts
src/stageAchievements/extensions/PortShiftingTool.ts
+25
-4
imageNode.vue
src/stageAchievements/imageNode.vue
+10
-10
No files found.
src/stageAchievements/extensions/PortShiftingTool.ts
View file @
1eafc031
...
@@ -144,15 +144,36 @@ export class PortShiftingTool extends go.Tool {
...
@@ -144,15 +144,36 @@ export class PortShiftingTool extends go.Tool {
* inside the main element -- it cannot wander away from the node.
* inside the main element -- it cannot wander away from the node.
* This does not modify the port's {@link go.GraphObject.alignmentFocus} property.
* This does not modify the port's {@link go.GraphObject.alignmentFocus} property.
*/
*/
// updateAlignment(): void {
// if (this.port === null || this.port.panel === null) return;
// const last = this.diagram.lastInput.documentPoint;
// const main = this.port.panel.findMainElement();
// if (main === null) return;
// const tl = main.getDocumentPoint(go.Spot.TopLeft);
// const br = main.getDocumentPoint(go.Spot.BottomRight);
// const x = Math.max(0, Math.min((last.x - tl.x) / (br.x - tl.x), 1));
// const y = Math.max(0, Math.min((last.y - tl.y) / (br.y - tl.y), 1));
// this.port.alignment = new go.Spot(x, y);
// }
// 修改updateAlignment函数,使端口可以在节点旋转后进行正常的移动
updateAlignment
():
void
{
updateAlignment
():
void
{
if
(
this
.
port
===
null
||
this
.
port
.
panel
===
null
)
return
;
if
(
this
.
port
===
null
||
this
.
port
.
panel
===
null
)
return
;
// 获取最后输入的文档点
const
last
=
this
.
diagram
.
lastInput
.
documentPoint
;
const
last
=
this
.
diagram
.
lastInput
.
documentPoint
;
const
main
=
this
.
port
.
panel
.
findMainElement
();
const
main
=
this
.
port
.
panel
.
findMainElement
();
if
(
main
===
null
)
return
;
if
(
main
===
null
)
return
;
const
tl
=
main
.
getDocumentPoint
(
go
.
Spot
.
TopLeft
);
const
br
=
main
.
getDocumentPoint
(
go
.
Spot
.
BottomRight
);
// 将最后输入的点转换为局部坐标系中的点
const
x
=
Math
.
max
(
0
,
Math
.
min
((
last
.
x
-
tl
.
x
)
/
(
br
.
x
-
tl
.
x
),
1
));
const
localPoint
=
main
.
getLocalPoint
(
last
);
const
y
=
Math
.
max
(
0
,
Math
.
min
((
last
.
y
-
tl
.
y
)
/
(
br
.
y
-
tl
.
y
),
1
));
const
tl
=
new
go
.
Point
(
0
,
0
);
const
br
=
new
go
.
Point
(
main
.
actualBounds
.
width
,
main
.
actualBounds
.
height
);
const
x
=
Math
.
max
(
0
,
Math
.
min
((
localPoint
.
x
-
tl
.
x
)
/
(
br
.
x
-
tl
.
x
),
1
));
const
y
=
Math
.
max
(
0
,
Math
.
min
((
localPoint
.
y
-
tl
.
y
)
/
(
br
.
y
-
tl
.
y
),
1
));
this
.
port
.
alignment
=
new
go
.
Spot
(
x
,
y
);
this
.
port
.
alignment
=
new
go
.
Spot
(
x
,
y
);
}
}
}
}
src/stageAchievements/imageNode.vue
View file @
1eafc031
...
@@ -202,7 +202,7 @@ function initDiagram() {
...
@@ -202,7 +202,7 @@ function initDiagram() {
$
(
go
.
Node
,
"Spot"
,
$
(
go
.
Node
,
"Spot"
,
{
{
resizable
:
true
,
resizable
:
true
,
rotatable
:
true
,
rotatable
:
true
},
},
new
go
.
Binding
(
"location"
,
"loc"
),
new
go
.
Binding
(
"location"
,
"loc"
),
new
go
.
Binding
(
"desiredSize"
,
"size"
,
go
.
Size
.
parse
).
makeTwoWay
(
go
.
Size
.
stringify
),
// 进行元素位置信息的绑定
new
go
.
Binding
(
"desiredSize"
,
"size"
,
go
.
Size
.
parse
).
makeTwoWay
(
go
.
Size
.
stringify
),
// 进行元素位置信息的绑定
...
@@ -219,7 +219,7 @@ function initDiagram() {
...
@@ -219,7 +219,7 @@ function initDiagram() {
$
(
go
.
Shape
,
"RoundedRectangle"
,
$
(
go
.
Shape
,
"RoundedRectangle"
,
{
{
fill
:
"white"
,
fill
:
"white"
,
strokeWidth
:
0
strokeWidth
:
0
,
},
},
new
go
.
Binding
(
"fill"
,
"color"
),
new
go
.
Binding
(
"fill"
,
"color"
),
),
),
...
@@ -711,13 +711,13 @@ function initDiagram() {
...
@@ -711,13 +711,13 @@ function initDiagram() {
// 检查连接的起点或终点是否是信息面板
// 检查连接的起点或终点是否是信息面板
if
((
fromNode
&&
fromNode
.
category
===
"infoPanel"
)
||
(
toNode
&&
toNode
.
category
===
"infoPanel"
))
{
if
((
fromNode
&&
fromNode
.
category
===
"infoPanel"
)
||
(
toNode
&&
toNode
.
category
===
"infoPanel"
))
{
// 设置连接的类别为 infoPanelLink
// 设置连接的类别为 infoPanelLink
myDiagram
.
model
.
set
(
link
.
data
,
"
c
ategory"
,
"infoPanelLink"
);
myDiagram
.
model
.
set
(
link
.
data
,
"
LinkC
ategory"
,
"infoPanelLink"
);
}
}
});
});
const
nodeDataArray
=
[
const
nodeDataArray
=
[
{
key
:
"add1"
,
color
:
"lightyellow"
,
loc
:
new
go
.
Point
(
-
150
,
200
),
portArray
:
[{
portId
:
"top0"
,
portKey
:
"top"
},
{
portId
:
"left0"
,
portKey
:
"left"
},
{
portId
:
"right0"
,
portKey
:
"right"
},
{
portId
:
"bottom0"
,
portKey
:
"bottom"
}],
markArray
:
[]
},
{
key
:
"add1"
,
color
:
"lightyellow"
,
loc
:
new
go
.
Point
(
-
150
,
200
),
portArray
:
[{
portId
:
"top0"
,
portKey
:
"top"
},
{
portId
:
"left0"
,
portKey
:
"left"
},
{
portId
:
"right0"
,
portKey
:
"right"
},
{
portId
:
"bottom0"
,
portKey
:
"bottom"
}],
markArray
:
[]
},
{
key
:
"add2"
,
color
:
"lightblue"
,
loc
:
new
go
.
Point
(
100
,
50
),
category
:
"zhaChi"
,
portArray
:
[{
portId
:
"bottom0"
,
portKey
:
"bottom"
}],
markArray
:
[]
,
geometry
:
zhaChiGeometry
,
isHorizontalFlipped
:
false
,
isVerticalFlipped
:
false
},
{
key
:
"add2"
,
color
:
"lightblue"
,
loc
:
new
go
.
Point
(
100
,
50
),
category
:
"zhaChi"
,
portArray
:
[{
portId
:
"bottom0"
,
portKey
:
"bottom"
}],
markArray
:
[]
},
{
key
:
"add3"
,
color
:
"lightblue"
,
loc
:
new
go
.
Point
(
300
,
150
),
category
:
"zhaChi"
,
portArray
:
[{
portId
:
"bottom0"
,
portKey
:
"bottom"
}],
markArray
:
[]
},
{
key
:
"add3"
,
color
:
"lightblue"
,
loc
:
new
go
.
Point
(
300
,
150
),
category
:
"zhaChi"
,
portArray
:
[{
portId
:
"bottom0"
,
portKey
:
"bottom"
}],
markArray
:
[]
},
{
key
:
"pipe1"
,
color
:
"gray"
,
loc
:
new
go
.
Point
(
0
,
100
),
category
:
"pipe"
,
portArray
:
[{
portId
:
"top0"
,
portKey
:
"top"
}],
markArray
:
[{
portId
:
"mark0"
}]},
{
key
:
"pipe1"
,
color
:
"gray"
,
loc
:
new
go
.
Point
(
0
,
100
),
category
:
"pipe"
,
portArray
:
[{
portId
:
"top0"
,
portKey
:
"top"
}],
markArray
:
[{
portId
:
"mark0"
}]},
{
key
:
"pipe1信息面板"
,
color
:
"red"
,
loc
:
new
go
.
Point
(
-
80
,
-
120
),
portArray
:
[{
portId
:
"top0"
,
portKey
:
"top"
},
{
portId
:
"left0"
,
portKey
:
"left"
},
{
portId
:
"right0"
,
portKey
:
"right"
},
{
portId
:
"bottom0"
,
portKey
:
"bottom"
}],
DCSArray
:
[{
name
:
"流速"
,
value
:
"20"
,
unit
:
"m/s"
},
{
name
:
"温度"
,
value
:
"30"
,
unit
:
"℃"
}],
damageArray
:
[{
damageName
:
"盐酸腐蚀"
,
damageValue
:
"100%"
}],
alarmArray
:
[{
alarmName
:
"警报"
}],
riskData
:
"高风险"
,
category
:
"infoPanel"
}
{
key
:
"pipe1信息面板"
,
color
:
"red"
,
loc
:
new
go
.
Point
(
-
80
,
-
120
),
portArray
:
[{
portId
:
"top0"
,
portKey
:
"top"
},
{
portId
:
"left0"
,
portKey
:
"left"
},
{
portId
:
"right0"
,
portKey
:
"right"
},
{
portId
:
"bottom0"
,
portKey
:
"bottom"
}],
DCSArray
:
[{
name
:
"流速"
,
value
:
"20"
,
unit
:
"m/s"
},
{
name
:
"温度"
,
value
:
"30"
,
unit
:
"℃"
}],
damageArray
:
[{
damageName
:
"盐酸腐蚀"
,
damageValue
:
"100%"
}],
alarmArray
:
[{
alarmName
:
"警报"
}],
riskData
:
"高风险"
,
category
:
"infoPanel"
}
...
@@ -725,7 +725,7 @@ function initDiagram() {
...
@@ -725,7 +725,7 @@ function initDiagram() {
const
linkDataArray
=
[
const
linkDataArray
=
[
{
from
:
"add1"
,
fromPort
:
"top0"
,
to
:
"add2"
,
toPort
:
"bottom0"
,
labelKeys
:
[
"pipe1"
]
},
{
from
:
"add1"
,
fromPort
:
"top0"
,
to
:
"add2"
,
toPort
:
"bottom0"
,
labelKeys
:
[
"pipe1"
]
},
{
from
:
"add1"
,
fromPort
:
"bottom0"
,
to
:
"add3"
,
toPort
:
"bottom0"
},
{
from
:
"add1"
,
fromPort
:
"bottom0"
,
to
:
"add3"
,
toPort
:
"bottom0"
},
{
from
:
"pipe1信息面板"
,
fromPort
:
"bottom0"
,
to
:
"pipe1"
,
toPort
:
"top0"
,
c
ategory
:
"infoPanelLink"
}
{
from
:
"pipe1信息面板"
,
fromPort
:
"bottom0"
,
to
:
"pipe1"
,
toPort
:
"top0"
,
LinkC
ategory
:
"infoPanelLink"
}
];
];
myDiagram
.
model
=
myDiagram
.
model
=
...
@@ -738,6 +738,8 @@ function initDiagram() {
...
@@ -738,6 +738,8 @@ function initDiagram() {
linkDataArray
:
linkDataArray
linkDataArray
:
linkDataArray
}
}
);
);
myDiagram
.
model
.
linkCategoryProperty
=
"LinkCategory"
;
}
}
// 导出画布中的节点和连线数据
// 导出画布中的节点和连线数据
...
@@ -1010,10 +1012,8 @@ function addDataPanel(){
...
@@ -1010,10 +1012,8 @@ function addDataPanel(){
}
}
function
APItest
(){
function
APItest
(){
var
node
=
myDiagram
.
findNodeForKey
(
"add1"
);
const
linkData
=
myDiagram
.
model
.
linkDataArray
[
0
];
if
(
node
)
{
myDiagram
.
model
.
setLabelKeysForLinkData
(
linkData
,
[
'pipe1'
,
'add3'
]);
myDiagram
.
model
.
setDataProperty
(
node
.
data
,
"color"
,
"red"
);
}
}
}
// svg节点进行水平翻转
// svg节点进行水平翻转
...
@@ -1050,7 +1050,7 @@ function verticalFlip() {
...
@@ -1050,7 +1050,7 @@ function verticalFlip() {
if
(
!
(
node
instanceof
go
.
Node
))
return
;
if
(
!
(
node
instanceof
go
.
Node
))
return
;
// 获取节点翻转标志
// 获取节点翻转标志
var
isHorizontalFlipped
=
node
.
data
.
isHorizontalFlipped
||
false
;
var
isHorizontalFlipped
=
node
.
data
.
isHorizontalFlipped
||
false
;
// 如果属性不存在则默认为false
var
isVerticalFlipped
=
node
.
data
.
isVerticalFlipped
||
false
;
var
isVerticalFlipped
=
node
.
data
.
isVerticalFlipped
||
false
;
var
zhaChiGeometrySample
=
go
.
Geometry
.
parse
(
"XFM88 77.8 0 77.8 0 53.8 88 53.8 136.6 0 181.4 0 181.4 35.3 157.5 35.3 157.5 24.5 136.6 24.5z XM 86.8 70.1 L 141.7 10.2 XM 82.8 66.1 L 137.1 6.4 XM142 8.8B 0 360 139 8.8 3 3 XM87 68.8B 0 360 84 68.8 3 3"
);
var
zhaChiGeometrySample
=
go
.
Geometry
.
parse
(
"XFM88 77.8 0 77.8 0 53.8 88 53.8 136.6 0 181.4 0 181.4 35.3 157.5 35.3 157.5 24.5 136.6 24.5z XM 86.8 70.1 L 141.7 10.2 XM 82.8 66.1 L 137.1 6.4 XM142 8.8B 0 360 139 8.8 3 3 XM87 68.8B 0 360 84 68.8 3 3"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment