From 9e302a79968591d88d2dc82f0d9d548dec9073bd Mon Sep 17 00:00:00 2001 From: Giorgos Vyronos Date: Mon, 28 Feb 2022 16:21:55 +0000 Subject: [PATCH] added rotation of ports hardcoded --- src/Renderer/DrawBlock/Symbol.fs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Renderer/DrawBlock/Symbol.fs b/src/Renderer/DrawBlock/Symbol.fs index 45022d7..09df2d4 100644 --- a/src/Renderer/DrawBlock/Symbol.fs +++ b/src/Renderer/DrawBlock/Symbol.fs @@ -113,6 +113,17 @@ let genPortPos (currentSymbol:Symbol) : Map = |> List.map (fun (str:String,pos) -> ((str:String), ri_to_universal(pos))) |> Map.ofList +//Map to return new coordinates of Position of ports and symbol +let rotatePortMap (map:Map) (symbol:Symbol) = + map |> Map.map(fun key port -> + match port.Side with + | 0 -> {Side=1; Offset= {X= port.Offset.Y; Y=port.Offset.X}} + | 1 -> {Side=2; Offset= {X= 0.0; Y= port.Offset.X}} + | 2 -> {Side=3; Offset= {X= port.Offset.Y; Y= port.Offset.X}} + | 3 -> {Side=0; Offset= {X= float(symbol.Compo.W); Y= port.Offset.X}} + | _ -> {Side=0; Offset= {X= port.Offset.X; Y=port.Offset.Y}} + ) + ///Insert titles compatible with greater than 1 buswidth let title t (n) = @@ -963,8 +974,8 @@ let update (msg : Msg) (model : Model): Model*Cmd<'a> = let newSymbols = // if ctrl is pressed make yellow initially, then try to change STransform for every time ctrl+R is pressed List.fold (fun prevSymbols sId -> - Map.add sId {model.Symbols[sId] with STransform = stransform_fsm(model.Symbols[sId].STransform)} prevSymbols) resetSymbols compList - printf "Rotated %A" model.Symbols[compList[0]].Pos + Map.add sId {model.Symbols[sId] with STransform = stransform_fsm(model.Symbols[sId].STransform); APortOffsetsMap = rotatePortMap model.Symbols[sId].APortOffsetsMap model.Symbols[sId]} prevSymbols) resetSymbols compList + printf "Rotated %A" Map.toList (model.Symbols[compList[0]].APortOffsetsMap) { model with Symbols = newSymbols }, Cmd.none | ErrorSymbols (errorCompList,selectCompList,isDragAndDrop) ->