Skip to content

Commit f30c6ec

Browse files
author
Brad Carman
committed
icon updates
1 parent 8a4e2a3 commit f30c6ec

File tree

18 files changed

+543
-29
lines changed

18 files changed

+543
-29
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.1.0"
4+
version = "0.2.0"
55

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

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,37 @@ Adding these components to your system will then allow for corners, tees, etc. t
141141

142142

143143
# Icons
144-
ModelingToolkitDesigner.jl comes with icons for the ModelingToolkitStandardLibrary.jl pre-loaded. For custom components, icons are loaded from the `path` variable supplied to `ODESystemDesign()`. To find the path ModelingToolkitDesign.jl is searching, pass the system of interest to `ODESystemDesign()` and replace the `.toml` with `.png`. For example if we want to make an icon for the `sys.vol` component, we can find the path by running...
144+
ModelingToolkitDesigner.jl comes with icons for the ModelingToolkitStandardLibrary.jl pre-loaded. For custom components, icons are loaded from either the `path` variable supplied to `ODESystemDesign()` or from an `icons` folder of the package namespace. To find the paths ModelingToolkitDesign.jl is searching, run the following on the component of interest (for example `sys.vol`)
145145

146146
```julia
147-
julia> ODESystemDesign(sys.vol, path).file
148-
"./design\\ModelingToolkitStandardLibrary\\Hydraulic\\IsothermalCompressible\\FixedVolume.toml"
147+
julia> println.(ModelingToolkitDesigner.get_icons(sys.vol, path));
148+
...\ModelingToolkitDesigner.jl\examples\design\ModelingToolkitStandardLibrary\Hydraulic\IsothermalCompressible\FixedVolume.png
149+
...\ModelingToolkitStandardLibrary.jl\icons\ModelingToolkitStandardLibrary\Hydraulic\IsothermalCompressible\FixedVolume.png
150+
...\ModelingToolkitDesigner.jl\icons\ModelingToolkitStandardLibrary\Hydraulic\IsothermalCompressible\FixedVolume.png
149151
```
150152

151-
Placing a "FixedVolume.png" file in this location will load that icon.
153+
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.
154+
155+
## 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
157+
158+
```
159+
[capacitor]
160+
n = "S"
161+
x = 0.51
162+
y = 0.29
163+
wall = "N"
164+
```
152165

153166
# Colors
154167
ModelingToolkitDesigner.jl colors the connections based on `ModelingToolkitDesigner.design_colors`. Colors for the ModelingToolkitStandardLibrary.jl are already loaded. To add a custom connector color, simply use `add_color(system::ODESystem, color::Symbol)` where `system` is a reference to the connector (e.g. `sys.vol.port`) and `color` is a named color from [Colors.jl](https://juliagraphics.github.io/Colors.jl/stable/namedcolors/).
155168

156169
# TODO
157170
- Finish adding icons for the ModelingToolkitStandardLibrary.jl
171+
- Rotate image feature
172+
- Improve text positioning and fontsize
173+
- How to include connection equations automatically, maybe implement the `input` macro
174+
- Provide `PassThru`'s without requiring user to add `PassThru` components to ODESystem
158175
- Add documentation
159176

160177
# [compat]

examples/design/Main/Circuit.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
n = "S"
33
x = 0.51
44
y = 0.29
5+
wall = "N"
56

67
[constant]
78
output = "N"

examples/hydraulic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import ModelingToolkitStandardLibrary.Blocks as B
1717
stp = B.Step(; height = 10e5, start_time = 0.005)
1818
src = IC.InputSource(; p_int = 0)
1919
vol = IC.FixedVolume(; p_int = 0, vol = 10.0)
20-
res = IC.Pipe(5; p_int = 0, area = 0.01, length = 500.0)
20+
res = IC.Tube(5; p_int = 0, area = 0.01, length = 500.0)
2121
end
2222

2323
eqs = [
2.84 KB
Loading
Lines changed: 81 additions & 0 deletions
Loading
826 Bytes
Loading
Lines changed: 114 additions & 0 deletions
Loading
5.18 KB
Loading

0 commit comments

Comments
 (0)