Skip to content

Commit f1c2cec

Browse files
author
Brad Carman
committed
v0.3.0
1 parent 7ee4371 commit f1c2cec

File tree

11 files changed

+132
-35
lines changed

11 files changed

+132
-35
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkitDesigner"
22
uuid = "23d639d0-9462-4d1e-84fe-d700424865b8"
33
authors = ["Brad Carman <[email protected]>"]
4-
version = "0.2.0"
4+
version = "0.3.0"
55

66
[deps]
77
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
The ModelingToolkitDesigner.jl package is a helper tool for visualizing and editing ModelingToolkit.jl system connections.
44

5+
# Updates
6+
## v0.3.0
7+
- Settings Files (*.toml) Updates/Breaking Changes
8+
- icon rotation now saved with key `r`, previously was `wall` which was not the best name
9+
- connectors nodes now saved with an underscore: `_name`, this helps prevent a collision with nodes named `x`, `y`, or `r`
10+
511
## Examples
612
Examples can be found in the "examples" folder.
713

@@ -153,14 +159,14 @@ julia> println.(ModelingToolkitDesigner.get_icons(sys.vol, path));
153159
The first file location comes from the `path` variable. The second is looking for a folder `icons` in the component parent package, in this case `ModelingToolkitStandardLibrary`, and the third path is from the `icons` folder of this `ModelingToolkitDesigner` package. The first real file is the chosen icon load path. Feel free to contribute icons here for any other public component libraries.
154160

155161
## Icon Rotation
156-
The icon rotation is controlled by the `wall` atribute in the saved `.toml` design file. Currently this must be edited by hand. The default direction is "E" for east. The image direciton can change to any "N","S","E","W". For example, to rotate the capacitor icon by -90 degrees (i.e. from "E" to "N") simply edit the design file as
162+
The icon rotation is controlled by the `r` atribute in the saved `.toml` design file. Currently this must be edited by hand. The default direction is "E" for east. The image direciton can change to any "N","S","E","W". For example, to rotate the capacitor icon by -90 degrees (i.e. from "E" to "N") simply edit the design file as
157163

158164
```
159165
[capacitor]
160-
n = "S"
166+
_n = "S"
161167
x = 0.51
162168
y = 0.29
163-
wall = "N"
169+
r = "N"
164170
```
165171

166172
# Colors

examples/design/Main/Circuit.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
[capacitor]
2-
n = "S"
2+
_n = "S"
33
x = 0.51
44
y = 0.29
5-
wall = "N"
5+
r = "N"
66

77
[constant]
8-
output = "N"
8+
_output = "N"
99
x = 0.71
1010
y = -0.08
1111

1212
[ground]
13-
g = "N"
13+
_g = "N"
1414
x = 0.51
1515
y = -0.08
1616

1717
[pt2]
18-
p1 = "N"
19-
p2 = "W"
18+
_p1 = "N"
19+
_p2 = "W"
2020
x = 0.9
2121
y = 0.11
2222

2323
[pt3]
24-
p1 = "N"
25-
p3 = "S"
24+
_p1 = "N"
25+
_p3 = "S"
2626
x = 0.51
2727
y = 0.11
2828

2929
[resistor]
30-
n = "W"
31-
p = "S"
30+
_n = "W"
31+
_p = "S"
3232
x = 0.9
3333
y = 0.29
3434

3535
[source]
36-
V = "S"
37-
n = "W"
36+
_V = "S"
37+
_n = "W"
3838
x = 0.71
3939
y = 0.11

examples/design/Main/MassSpringDamper.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ x = 0.09
33
y = 0.15
44

55
[dv]
6-
flange_a = "W"
6+
_flange_a = "W"
77
x = 0.44
88
y = 0.2
99

1010
[gv]
11-
flange = "W"
11+
_flange = "W"
1212
x = 0.82
1313
y = 0.15
1414

1515
[pt1]
16-
p1 = "S"
17-
p3 = "N"
16+
_p1 = "S"
17+
_p3 = "N"
1818
x = 0.65
1919
y = 0.15
2020

2121
[pt2]
22-
p1 = "S"
23-
p2 = "W"
24-
p3 = "N"
22+
_p1 = "S"
23+
_p2 = "W"
24+
_p3 = "N"
2525
x = 0.25
2626
y = 0.15
2727

2828
[sv]
29-
flange_a = "W"
29+
_flange_a = "W"
3030
x = 0.44
3131
y = 0.1

examples/design/Main/System.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
connect(stp.output, src.input)
1+
connect(stp.output, src.p)
22
connect(src.port, res.port_a)
33
connect(vol.port, res.port_b)
44
connect(src.port, fluid)

examples/design/Main/System.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ x = 0.38
33
y = -0.01
44

55
[res]
6-
port_a = "W"
6+
_port_a = "W"
77
x = 0.49
88
y = 0.09
99

1010
[src]
11-
input = "W"
11+
_p = "W"
1212
x = 0.28
1313
y = 0.09
1414

@@ -17,6 +17,6 @@ x = 0.06
1717
y = 0.09
1818

1919
[vol]
20-
port = "W"
20+
_port = "W"
2121
x = 0.7
2222
y = 0.09

examples/hydraulic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import ModelingToolkitStandardLibrary.Blocks as B
2121
end
2222

2323
eqs = [
24-
connect(stp.output, src.input)
24+
connect(stp.output, src.p)
2525
connect(src.port, res.port_a)
2626
connect(vol.port, res.port_b)
2727
connect(src.port, fluid)
2.62 KB
Loading
Lines changed: 77 additions & 0 deletions
Loading

src/ModelingToolkitDesigner.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,19 @@ function process_children!(
277277

278278

279279
if !is_connector
280+
#if x and y are missing, add defaults
280281
if !haskey(kwargs, "x") & !haskey(kwargs, "y")
281282
push!(kwargs_pair, :x => i * 3 * Δh)
282283
push!(kwargs_pair, :y => i * Δh)
283284
end
285+
286+
# r => wall for icon rotation
287+
if haskey(kwargs, "r")
288+
push!(kwargs_pair, :wall => kwargs["r"])
289+
end
284290
else
285-
if haskey(connectors, system.name)
286-
push!(kwargs_pair, :wall => connectors[system.name])
291+
if haskey(connectors, safe_connector_name(system.name))
292+
push!(kwargs_pair, :wall => connectors[safe_connector_name(system.name)])
287293
end
288294
end
289295

@@ -1113,6 +1119,8 @@ function connection_code(io::IO, design::ODESystemDesign)
11131119

11141120
end
11151121

1122+
safe_connector_name(name::Symbol) = Symbol("_$name")
1123+
11161124
function save_design(design::ODESystemDesign)
11171125

11181126

@@ -1127,9 +1135,15 @@ function save_design(design::ODESystemDesign)
11271135
:y => round(y; digits = 2)
11281136
]
11291137

1138+
if component.wall[] != :E
1139+
push!(pairs,
1140+
:r => string(component.wall[])
1141+
)
1142+
end
1143+
11301144
for connector in component.connectors
11311145
if connector.wall[] != :E #don't use get_wall() here, need to preserve E1, E2, etc
1132-
push!(pairs, connector.system.name => string(connector.wall[]))
1146+
push!(pairs, safe_connector_name(connector.system.name) => string(connector.wall[]))
11331147
end
11341148
end
11351149

0 commit comments

Comments
 (0)