Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrKryslUCSD committed Sep 26, 2023
1 parent 1512e92 commit d9a2d21
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 73 deletions.
47 changes: 28 additions & 19 deletions examples/beams/graphics/edit_plot.jl
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
module edit_plot_examples
using FinEtools
using FinEtoolsFlexStructures.FESetCorotBeamModule: FESetL2CorotBeam
using FinEtoolsFlexStructures.FESetL2BeamModule: FESetL2Beam
using FinEtoolsFlexStructures.CrossSectionModule: CrossSectionCircle, CrossSectionRectangle
using FinEtoolsFlexStructures.MeshFrameMemberModule: frame_member, merge_members
using VisualStructures: plot_nodes, plot_midline, render, plot_space_box, plot_solid, space_aspectratio, default_layout_3d, plot_from_json
using PlotlyJS
using JSON

L = 42
xyz = [0 0 0;
0 L/4 L*1/4;
L/4 L/4 L*2/4;
L/4 0 L*3/4;
0 0 L]
nL = 20
function allrun()

cs = CrossSectionCircle(s -> 5.9910, s -> [0.0, 0.0, 1.0])
fens, fes = frame_member(xyz, nL, cs)
plots = cat(plot_nodes(fens),
plot_midline(fens, fes; color = "rgb(155, 155, 255)", lwidth = 4),
dims = 1)
layout = default_layout_3d(autosize=true)
L = 42
xyz = [0 0 0;
0 L/4 L*1/4;
L/4 L/4 L*2/4;
L/4 0 L*3/4;
0 0 L]
nL = 20

cs = CrossSectionCircle(s -> 5.9910, s -> [0.0, 0.0, 1.0])
fens, fes = frame_member(xyz, nL, cs)
plots = cat(plot_nodes(fens),
plot_midline(fens, fes; color = "rgb(155, 155, 255)", lwidth = 4),
dims = 1)
layout = default_layout_3d(autosize=true)
# layout = default_layout_3d(width=400, height=400)
layout[:showLegend] = true
layout[:showLegend] = true

config = PlotConfig(plotlyServerURL="https://chart-studio.plotly.com", showLink=true)
pl = plot(plots, layout; config = config)

config = PlotConfig(plotlyServerURL="https://chart-studio.plotly.com", showLink=true)
pl = plot(plots, layout; config = config)
display(pl)
true
end

display(pl)
true
@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")

end # module
nothing
51 changes: 31 additions & 20 deletions examples/beams/graphics/loading_plot.jl
Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
module edit_plot_examples
using FinEtools
using FinEtoolsFlexStructures.FESetCorotBeamModule: FESetL2CorotBeam
using FinEtoolsFlexStructures.FESetL2BeamModule: FESetL2Beam
using FinEtoolsFlexStructures.CrossSectionModule: CrossSectionCircle, CrossSectionRectangle
using FinEtoolsFlexStructures.MeshFrameMemberModule: frame_member, merge_members
using VisualStructures: plot_nodes, plot_midline, render, plot_space_box, plot_solid, space_aspectratio, default_layout_3d, plot_from_json
using PlotlyJS
using JSON

L = 42
xyz = [0 0 0;
0 L/4 L*1/4;
L/4 L/4 L*2/4;
L/4 0 L*3/4;
0 0 L]
nL = 20
function allrun()

cs = CrossSectionCircle(s -> 5.9910, s -> [0.0, 0.0, 1.0])
fens, fes = frame_member(xyz, nL, cs)
plots = cat(plot_nodes(fens),
plot_midline(fens, fes; color = "rgb(155, 155, 255)", lwidth = 4),
dims = 1)
layout = default_layout_3d(width = 500, height = 500)
layout[:title] = ""
config = PlotConfig(plotlyServerURL="https://chart-studio.plotly.com", showLink=true)
L = 42
xyz = [0 0 0;
0 L/4 L*1/4;
L/4 L/4 L*2/4;
L/4 0 L*3/4;
0 0 L]
nL = 20

cs = CrossSectionCircle(s -> 5.9910, s -> [0.0, 0.0, 1.0])
fens, fes = frame_member(xyz, nL, cs)
plots = cat(plot_nodes(fens),
plot_midline(fens, fes; color = "rgb(155, 155, 255)", lwidth = 4),
dims = 1)
layout = default_layout_3d(width = 500, height = 500)
layout[:title] = ""
config = PlotConfig(plotlyServerURL="https://chart-studio.plotly.com", showLink=true)


pl = plot(plots, layout; config=config)

display(pl)
pl = plot(plots, layout; config=config)

savejson(pl, "plot.json")
display(pl)

savejson(pl, "plot.json")

# The below works when run interactively from the command line:
pl = plot_from_json("plot.json")
pl = plot_from_json("plot.json")
true
end

@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")

end # module
nothing
79 changes: 45 additions & 34 deletions examples/beams/graphics/making_frames.jl
Original file line number Diff line number Diff line change
@@ -1,45 +1,51 @@
module making_frames_examples
using FinEtools
using FinEtoolsFlexStructures.FESetCorotBeamModule: FESetL2CorotBeam
using FinEtoolsFlexStructures.FESetL2BeamModule: FESetL2Beam
using FinEtoolsFlexStructures.CrossSectionModule: CrossSectionCircle, CrossSectionRectangle
using FinEtoolsFlexStructures.MeshFrameMemberModule: frame_member, merge_members
using VisualStructures: plot_nodes, plot_midline, render, plot_space_box, plot_solid, space_aspectratio, default_layout_3d, plot_from_json
using PlotlyJS
using JSON

L = 42
xyz = [0 0 0;
0 L/4 L*1/4;
L/4 L/4 L*2/4;
L/4 0 L*3/4;
0 0 L]
nL = 20

cs = CrossSectionCircle(s -> 5.9910, s -> [0.0, 0.0, 1.0])
fens, fes = frame_member(xyz, nL, cs)
plots = cat(plot_nodes(fens),
plot_midline(fens, fes; color = "rgb(155, 155, 255)", lwidth = 4),
dims = 1)
layout = default_layout_3d(width = 500, height = 500)
layout[:title] = ""


pl = plot(plots, layout;
config=PlotConfig(showLink = true, toImageButtonOptions = Dict(:format=>"webp")))
display(pl)

f(frame) = if frame < 10; "0$frame"; else "$frame"; end

sleep(0.5)
let
frame = 1
for eyex in 1.0:-0.1:-1.0
pl.plot.layout["scene"][:camera][:eye][:x] = eyex
pl.plot.layout[:title] = "$(eyex)"
react!(pl, pl.plot.data, pl.plot.layout)
sleep(0.05)
savefig(pl, "a$(f(frame)).png")
frame += 1
function allrun()

L = 42
xyz = [0 0 0;
0 L/4 L*1/4;
L/4 L/4 L*2/4;
L/4 0 L*3/4;
0 0 L]
nL = 20

cs = CrossSectionCircle(s -> 5.9910, s -> [0.0, 0.0, 1.0])
fens, fes = frame_member(xyz, nL, cs)
plots = cat(plot_nodes(fens),
plot_midline(fens, fes; color = "rgb(155, 155, 255)", lwidth = 4),
dims = 1)
layout = default_layout_3d(width = 500, height = 500)
layout[:title] = ""


pl = plot(plots, layout;
config=PlotConfig(showLink = true, toImageButtonOptions = Dict(:format=>"webp")))
display(pl)

f(frame) = if frame < 10; "0$frame"; else "$frame"; end

sleep(0.5)
let
frame = 1
for eyex in 1.0:-0.1:-1.0
pl.plot.layout["scene"][:camera][:eye][:x] = eyex
pl.plot.layout[:title] = "$(eyex)"
react!(pl, pl.plot.data, pl.plot.layout)
sleep(0.05)
savefig(pl, "a$(f(frame)).png")
frame += 1
end
end
true

end

# Convert to a gif
Expand All @@ -61,3 +67,8 @@ end
# savefig(pl, "a.png")
# end

@info "All examples may be executed with "
println("using .$(@__MODULE__); $(@__MODULE__).allrun()")

end # module
nothing

0 comments on commit d9a2d21

Please sign in to comment.