Commit 8deb1632 authored by Thorsten Wißmann's avatar Thorsten Wißmann 🐧
Browse files

Make rail examples freely rotatable

parent dfea71ff
......@@ -25,8 +25,10 @@ $(TARGET): src/Main.elm $(SRC) elm-package.json
clean:
rm -f $(TARGET)
INSTALL_SSH=uber:html/p/rails/
INSTALL_HTTP=http://thorsten-wissmann.de/p/rails/
#INSTALL_SSH=uber:html/p/rails/
#INSTALL_HTTP=http://thorsten-wissmann.de/p/rails/
INSTALL_SSH=i8:web/rails/
INSTALL_HTTP=https://www8.cs.fau.de/ext/thorsten/rails
install: $(CSS) rails.html $(IMG) $(wildcard *.js)
rsync -Pravdtze ssh $^ $(INSTALL_SSH)
@echo $(INSTALL_HTTP)/rails.html
......
......@@ -69,7 +69,7 @@ init =
(smv, initial_cmd) = NuSmvInput.init
in
( { rails =
RailPuzzle.init ex.car_positions ex.rail_net
RailPuzzle.init ex.car_positions ex.rail_net ex.rotation
|> RailPuzzle.runCommand initial_cmd
|> RailPuzzle.runCommand initial_query
, network_index = initial_network_index
......@@ -159,7 +159,7 @@ update msg model =
))
, rails =
RailPuzzle.init rail_example.car_positions rail_example.rail_net
RailPuzzle.init rail_example.car_positions rail_example.rail_net rail_example.rotation
|> RailPuzzle.runCommand (RPCmd.SetQuery new_query)
|> RailPuzzle.importHistory new_hist
|> RailPuzzle.importOptions (RailPuzzle.exportOptions model.rails)
......
......@@ -13,6 +13,7 @@ type alias RailExample =
, rail_net : RailTree (Has RT.Hint ()) (Has RT.Angles ())
, car_positions : List RT.Path
, queries : List (List Int) -- 0-indexed query
, rotation : Float -- the initial angle
}
{-| permute the cars on a rail example
......@@ -83,6 +84,7 @@ big =
]
]
, queries = []
, rotation = -40
}
type alias Shunt =
......@@ -137,6 +139,7 @@ one_junction head subs =
|> List.map ((++) head_prefix)
)
, queries = []
, rotation = 0
}
inglenook_422 =
......@@ -158,6 +161,7 @@ inglenook_422 =
, [ RT.Further, RT.Further, RT.Choose 1, RT.Choose 0, RT.Further ]
]
, queries = []
, rotation = -20
}
inglenook_533 =
......@@ -181,6 +185,7 @@ inglenook_533 =
, [ RT.Further, RT.Further, RT.Further, RT.Choose 1, RT.Choose 0, RT.Further, RT.Further ]
]
, queries = []
, rotation = -20
}
merge_sort n =
......
......@@ -51,6 +51,7 @@ import Debug
type alias RawModel render_cache =
{ rt : RT.LayoutedRailTree (Has RT.Path ()) ()
, cars : Array C.Carriage
, rotation : Float -- the rotation of the entire network in degrees
, initial_car_positions : Array RT.Path
, car_selected : Int
-- the train to be built, refering to indices in the cars array
......@@ -93,8 +94,11 @@ type alias Options = -- Some gui options
cmd : RPCmd.Command -> Msg
cmd = Command
init : List RT.Path -> RailTree (Has RT.Hint ()) (Has RT.Angles ()) -> Model
init car_positions rail_net =
{-|
The float is an angle [0,360] denoting the rotation of the rail net
-}
init : List RT.Path -> RailTree (Has RT.Hint ()) (Has RT.Angles ()) -> Float -> Model
init car_positions rail_net rotation =
let
new_car idx =
let f = C.defaultFlags in
......@@ -105,7 +109,7 @@ init car_positions rail_net =
}
layouted_rail_net =
rail_net
|> RT.layoutRailTree
|> RT.layoutRailTreeAt (P2D.Angled rotation (P2D.P2D 0.0 0.0))
|> RT.indexify
|> RT.map Has.swap identity
cars = Array.indexedMap new_car <| Array.fromList car_positions
......@@ -121,6 +125,7 @@ init car_positions rail_net =
, show_shunt_labels = False
, history = RPHistory.init
, render_cache = ()
, rotation = rotation
}
in
fillRenderCache model
......@@ -386,7 +391,7 @@ fillRenderCache model =
root_bumper =
RT.Junction (Has.unit RT.AutoAngles) [] -- take a simple bumper
-- layout it at the root but with the reversed angle
|> RT.layoutRailTreeAt (P2D.Angled -180 (P2D.P2D 0.0 0.0))
|> RT.layoutRailTreeAt (P2D.Angled (model.rotation-180) (P2D.P2D 0.0 0.0))
root_bumper_svg : List (Svg.Svg Msg)
root_bumper_svg =
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment