Fixed issues with BusWire.fs

This commit is contained in:
Giorgos Vyronos 2022-03-24 19:12:35 +00:00
parent dcaa702a0f
commit 7d41b95c2c
4 changed files with 47 additions and 52 deletions

View file

@ -440,7 +440,20 @@ let initialWireVerticesFromPorts
{X = endX; Y = endY}
],
true // Left-to-right
//fix issue by wrapping wire input port and not through for 1st quadrant
else if (endX - startX < Wire.stickLength)
&& (endY - startY >= 2.5 * Wire.stickLength) then
[
{X = startX; Y = startY};
{X = startX + Wire.stickLength; Y = startY};
{X = startX + Wire.stickLength; Y = startY + 1.5 * Wire.stickLength};
{X = endX; Y = startY + 1.5 * Wire.stickLength};
{X = endX; Y = endY - Wire.stickLength};
{X = endX; Y = endY - Wire.stickLength};
{X = endX; Y = endY - Wire.stickLength};
{X = endX; Y = endY}
],
false // not Left-to-right
// Otherwise, if either X or Y delta is smaller than the stick length,
// add some creative meandering
//
@ -454,8 +467,8 @@ let initialWireVerticesFromPorts
[
{X = startX; Y = startY};
{X = startX + Wire.stickLength; Y = startY};
{X = startX + Wire.stickLength; Y = startY};
{X = (startX + endX) / 2.0; Y = startY};
{X = startX + Wire.stickLength; Y = startY - 1.5 * Wire.stickLength};
{X = (startX + endX) / 2.0; Y = startY - 1.5 * Wire.stickLength};
{X = (startX + endX) / 2.0; Y = endY - Wire.stickLength};
{X = endX; Y = endY - Wire.stickLength};
{X = endX; Y = endY - Wire.stickLength};
@ -574,7 +587,7 @@ let convertVerticesToASegs connId (isLeftToRight: bool) routetype rotation (yref
| true ->
[Horizontal;Horizontal;Horizontal;Horizontal;Vertical;Vertical;Vertical]
| false ->
[Horizontal;Horizontal;Horizontal;Vertical;Horizontal;Horizontal;Vertical]
[Horizontal;Vertical;Horizontal;Vertical;Horizontal;Horizontal;Vertical]
let draggable index =
match routetype with
@ -796,11 +809,11 @@ let makeInitialASegList (hostId: ConnectionId)
let routetype, rotation, yreflect =
match outputPortOri, inputPortOri with
| Symbol.Top, Symbol.Top -> Sameside, PosY, false
| Symbol.Top, Symbol.Right -> Rightangle, NegX, true
| Symbol.Top, Symbol.Right -> Rightangle, PosX, true
| Symbol.Top, Symbol.Bottom -> Oppositeside, NegX, false
| Symbol.Top, Symbol.Left -> Rightangle, NegX, false
| Symbol.Right, Symbol.Top -> Rightangle, PosY, false
| Symbol.Right, Symbol.Top -> Rightangle, PosY, false //TODO: WRONG - stick coming out of output+input wrong direction
| Symbol.Right, Symbol.Right -> Sameside, PosX, false
| Symbol.Right, Symbol.Bottom -> Rightangle,NegY, true
| Symbol.Right, Symbol.Left -> Oppositeside, PosY, false
@ -808,11 +821,11 @@ let makeInitialASegList (hostId: ConnectionId)
| Symbol.Bottom, Symbol.Top -> Oppositeside, PosX, false
| Symbol.Bottom, Symbol.Right -> Rightangle, PosX, false
| Symbol.Bottom, Symbol.Bottom -> Sameside, NegY, false
| Symbol.Bottom, Symbol.Left -> Rightangle, PosX, true
| Symbol.Bottom, Symbol.Left -> Rightangle, NegX, true
| Symbol.Left, Symbol.Top -> Rightangle, PosY, true
| Symbol.Left, Symbol.Right -> Oppositeside, NegY, false
| Symbol.Left, Symbol.Bottom -> Rightangle, NegY, false
| Symbol.Left, Symbol.Bottom -> Rightangle, NegY, false //TODO: WRONG - stick coming out of output+input wrong direction
| Symbol.Left, Symbol.Left -> Sameside, NegX, false
// Get the adjusted input port position, applying any rotations and

View file

@ -865,16 +865,16 @@ let update (msg : Msg) (model : Model): Model*Cmd<Msg> =
symbolCmd (Symbol.RotateSymbols model.SelectedComponents) // Rotate Symbol using keyboard combination
wireCmd (BusWire.UpdateWires (model.SelectedComponents, {X = 0.0; Y = 0.0}))
]
| KeyPress FlipV ->
model,
Cmd.batch [
symbolCmd (Symbol.FlipVSymbols model.SelectedComponents) // Flip Vertically Symbol using keyboard combination
]
| KeyPress FlipH ->
model,
Cmd.batch [
symbolCmd (Symbol.FlipHSymbols model.SelectedComponents) // Flip Vertically Symbol using keyboard combination
]
// | KeyPress FlipV ->
// model,
// Cmd.batch [
// symbolCmd (Symbol.FlipVSymbols model.SelectedComponents) // Flip Vertically Symbol using keyboard combination
// ]
// | KeyPress FlipH ->
// model,
// Cmd.batch [
// symbolCmd (Symbol.FlipHSymbols model.SelectedComponents) // Flip Vertically Symbol using keyboard combination
// ]
| KeyPress CtrlV ->
let newSymbolModel, pastedCompIds = Symbol.pasteSymbols model.Wire.Symbol model.LastMousePos // Symbol has Copied Symbols stored
let newBusWireModel, pastedConnIds = BusWire.pasteWires { model.Wire with Symbol = newSymbolModel } pastedCompIds

View file

@ -1381,38 +1381,20 @@ let update (msg : Msg) (model : Model): Model*Cmd<'a> =
let newcompo = {compo with R = stransform_fsm model.Symbols[sId].STransform compo.Type ;}
Map.add sId {model.Symbols[sId] with Compo = newcompo ; STransform = stransform_fsm model.Symbols[sId].STransform compo.Type ; APortOffsetsMap = rotatePortMap model.Symbols[sId].APortOffsetsMap model.Symbols[sId]} prevSymbols) resetSymbols compList
{ model with Symbols = newSymbols }, Cmd.none
//////////////PENDING///////////////////
// | FlipHSymbols compList -> // NEW: flip a symbol Horizontally
// let resetSymbols = Map.map (fun _ sym -> { sym with Colour = "Lightgray"; Opacity = 1.0 }) model.Symbols
// let newSymbols =
// // The selected symbol is rotated by incrementing Stransform rotation and updating new APortOffsetsMap and Symbol Pos
// List.fold (fun prevSymbols sId ->
// Map.add sId {model.Symbols[sId] with STransform = stransform_fsm(stransform_fsm model.Symbols[sId].STransform); APortOffsetsMap = flipHPortMap model.Symbols[sId].APortOffsetsMap model.Symbols[sId]} prevSymbols) resetSymbols compList
// Map.add sId model.Symbols[sId] prevSymbols) resetSymbols compList //NEED TO DO APPROPRIATE CHANGES HERE, SEE ROTATION FOR INSPIRATION
// { model with Symbols = newSymbols }, Cmd.none
//
// | FlipVSymbols compList ->
// let resetSymbols = Map.map (fun _ sym -> { sym with Colour = "Lightgray"; Opacity = 1.0 }) model.Symbols
// let newSymbols =
// // The selected symbol is rotated by incrementing Stransform rotation and updating new APortOffsetsMap and Symbol Pos
// List.fold (fun prevSymbols sId ->
// Map.add sId {model.Symbols[sId] with STransform = stransform_fsm(stransform_fsm(model.Symbols[sId].STransform)); APortOffsetsMap = flipVPortMap model.Symbols[sId].APortOffsetsMap model.Symbols[sId]} prevSymbols) resetSymbols compList
// Map.add sId model.Symbols[sId] prevSymbols) resetSymbols compList //NEED TO DO APPROPRIATE CHANGES HERE, SEE ROTATION FOR INSPIRATION
// { model with Symbols = newSymbols }, Cmd.none
| FlipHSymbols compList -> // NEW: flip a symbol Horizontally
let resetSymbols = Map.map (fun _ sym -> { sym with Colour = "Lightgray"; Opacity = 1.0 }) model.Symbols
let newSymbols =
List.fold (fun prevSymbols sId ->
Map.add sId model.Symbols[sId] prevSymbols) resetSymbols compList //NEED TO DO APPROPRIATE CHANGES HERE, SEE ROTATION FOR INSPIRATION
{ model with Symbols = newSymbols }, Cmd.none
| FlipVSymbols compList ->
let resetSymbols = Map.map (fun _ sym -> { sym with Colour = "Lightgray"; Opacity = 1.0 }) model.Symbols
let newSymbols =
List.fold (fun prevSymbols sId ->
Map.add sId model.Symbols[sId] prevSymbols) resetSymbols compList //NEED TO DO APPROPRIATE CHANGES HERE, SEE ROTATION FOR INSPIRATION
{ model with Symbols = newSymbols }, Cmd.none
| ErrorSymbols (errorCompList,selectCompList,isDragAndDrop) ->
let resetSymbols = Map.map (fun _ sym -> { sym with Colour = "Lightgray"; Opacity = 1.0 }) model.Symbols
let selectSymbols =

View file

@ -149,8 +149,8 @@ let viewMenu dispatch =
makeItem "Diagram Zoom to Fit" (Some "CmdOrCtrl+W") (fun ev -> dispatch Sheet.KeyboardMsg.CtrlW)
menuSeparator
makeItem "Rotate Symbol" (Some "Shift+R") (fun ev -> dispatch Sheet.KeyboardMsg.Rotate)
makeItem "Flip Horizontally Symbol" (Some "Shift+H") (fun ev -> dispatch Sheet.KeyboardMsg.FlipH)
makeItem "Flip Vertically Symbol" (Some "Shift+V") (fun ev -> dispatch Sheet.KeyboardMsg.FlipV)
// makeItem "Flip Horizontally Symbol" (Some "Shift+H") (fun ev -> dispatch Sheet.KeyboardMsg.FlipH)
// makeItem "Flip Vertically Symbol" (Some "Shift+V") (fun ev -> dispatch Sheet.KeyboardMsg.FlipV)
menuSeparator
makeCondItem (JSHelpers.debugLevel <> 0) "Toggle Dev Tools" (Some devToolsKey) (fun _ ->
renderer.ipcRenderer.send("toggle-dev-tools", [||]) |> ignore)