mirror of
https://github.com/supleed2/ELEC60015-HLP-CW.git
synced 2024-12-22 21:45:49 +00:00
Fixed issues with BusWire.fs
This commit is contained in:
parent
dcaa702a0f
commit
7d41b95c2c
|
@ -439,8 +439,21 @@ let initialWireVerticesFromPorts
|
||||||
{X = endX ; Y = endY - Wire.stickLength}
|
{X = endX ; Y = endY - Wire.stickLength}
|
||||||
{X = endX; Y = endY}
|
{X = endX; Y = endY}
|
||||||
],
|
],
|
||||||
true // Left-to-right
|
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,
|
// Otherwise, if either X or Y delta is smaller than the stick length,
|
||||||
// add some creative meandering
|
// add some creative meandering
|
||||||
//
|
//
|
||||||
|
@ -454,8 +467,8 @@ let initialWireVerticesFromPorts
|
||||||
[
|
[
|
||||||
{X = startX; Y = startY};
|
{X = startX; Y = startY};
|
||||||
{X = startX + Wire.stickLength; Y = startY};
|
{X = startX + Wire.stickLength; Y = startY};
|
||||||
{X = startX + Wire.stickLength; Y = startY};
|
{X = startX + Wire.stickLength; Y = startY - 1.5 * Wire.stickLength};
|
||||||
{X = (startX + endX) / 2.0; Y = startY};
|
{X = (startX + endX) / 2.0; Y = startY - 1.5 * Wire.stickLength};
|
||||||
{X = (startX + endX) / 2.0; Y = endY - Wire.stickLength};
|
{X = (startX + endX) / 2.0; Y = endY - Wire.stickLength};
|
||||||
{X = endX; Y = endY - Wire.stickLength};
|
{X = endX; 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 ->
|
| true ->
|
||||||
[Horizontal;Horizontal;Horizontal;Horizontal;Vertical;Vertical;Vertical]
|
[Horizontal;Horizontal;Horizontal;Horizontal;Vertical;Vertical;Vertical]
|
||||||
| false ->
|
| false ->
|
||||||
[Horizontal;Horizontal;Horizontal;Vertical;Horizontal;Horizontal;Vertical]
|
[Horizontal;Vertical;Horizontal;Vertical;Horizontal;Horizontal;Vertical]
|
||||||
|
|
||||||
let draggable index =
|
let draggable index =
|
||||||
match routetype with
|
match routetype with
|
||||||
|
@ -796,11 +809,11 @@ let makeInitialASegList (hostId: ConnectionId)
|
||||||
let routetype, rotation, yreflect =
|
let routetype, rotation, yreflect =
|
||||||
match outputPortOri, inputPortOri with
|
match outputPortOri, inputPortOri with
|
||||||
| Symbol.Top, Symbol.Top -> Sameside, PosY, false
|
| 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.Bottom -> Oppositeside, NegX, false
|
||||||
| Symbol.Top, Symbol.Left -> Rightangle, 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.Right -> Sameside, PosX, false
|
||||||
| Symbol.Right, Symbol.Bottom -> Rightangle,NegY, true
|
| Symbol.Right, Symbol.Bottom -> Rightangle,NegY, true
|
||||||
| Symbol.Right, Symbol.Left -> Oppositeside, PosY, false
|
| 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.Top -> Oppositeside, PosX, false
|
||||||
| Symbol.Bottom, Symbol.Right -> Rightangle, PosX, false
|
| Symbol.Bottom, Symbol.Right -> Rightangle, PosX, false
|
||||||
| Symbol.Bottom, Symbol.Bottom -> Sameside, NegY, 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.Top -> Rightangle, PosY, true
|
||||||
| Symbol.Left, Symbol.Right -> Oppositeside, NegY, false
|
| 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
|
| Symbol.Left, Symbol.Left -> Sameside, NegX, false
|
||||||
|
|
||||||
// Get the adjusted input port position, applying any rotations and
|
// Get the adjusted input port position, applying any rotations and
|
||||||
|
|
|
@ -865,16 +865,16 @@ let update (msg : Msg) (model : Model): Model*Cmd<Msg> =
|
||||||
symbolCmd (Symbol.RotateSymbols model.SelectedComponents) // Rotate Symbol using keyboard combination
|
symbolCmd (Symbol.RotateSymbols model.SelectedComponents) // Rotate Symbol using keyboard combination
|
||||||
wireCmd (BusWire.UpdateWires (model.SelectedComponents, {X = 0.0; Y = 0.0}))
|
wireCmd (BusWire.UpdateWires (model.SelectedComponents, {X = 0.0; Y = 0.0}))
|
||||||
]
|
]
|
||||||
| KeyPress FlipV ->
|
// | KeyPress FlipV ->
|
||||||
model,
|
// model,
|
||||||
Cmd.batch [
|
// Cmd.batch [
|
||||||
symbolCmd (Symbol.FlipVSymbols model.SelectedComponents) // Flip Vertically Symbol using keyboard combination
|
// symbolCmd (Symbol.FlipVSymbols model.SelectedComponents) // Flip Vertically Symbol using keyboard combination
|
||||||
]
|
// ]
|
||||||
| KeyPress FlipH ->
|
// | KeyPress FlipH ->
|
||||||
model,
|
// model,
|
||||||
Cmd.batch [
|
// Cmd.batch [
|
||||||
symbolCmd (Symbol.FlipHSymbols model.SelectedComponents) // Flip Vertically Symbol using keyboard combination
|
// symbolCmd (Symbol.FlipHSymbols model.SelectedComponents) // Flip Vertically Symbol using keyboard combination
|
||||||
]
|
// ]
|
||||||
| KeyPress CtrlV ->
|
| KeyPress CtrlV ->
|
||||||
let newSymbolModel, pastedCompIds = Symbol.pasteSymbols model.Wire.Symbol model.LastMousePos // Symbol has Copied Symbols stored
|
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
|
let newBusWireModel, pastedConnIds = BusWire.pasteWires { model.Wire with Symbol = newSymbolModel } pastedCompIds
|
||||||
|
|
|
@ -1381,37 +1381,19 @@ let update (msg : Msg) (model : Model): Model*Cmd<'a> =
|
||||||
let newcompo = {compo with R = stransform_fsm model.Symbols[sId].STransform compo.Type ;}
|
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
|
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
|
{ 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
|
||||||
// | FlipHSymbols compList -> // NEW: flip a symbol Horizontally
|
// let newSymbols =
|
||||||
// let resetSymbols = Map.map (fun _ sym -> { sym with Colour = "Lightgray"; Opacity = 1.0 }) model.Symbols
|
// List.fold (fun prevSymbols sId ->
|
||||||
// let newSymbols =
|
// Map.add sId model.Symbols[sId] prevSymbols) resetSymbols compList //NEED TO DO APPROPRIATE CHANGES HERE, SEE ROTATION FOR INSPIRATION
|
||||||
// // The selected symbol is rotated by incrementing Stransform rotation and updating new APortOffsetsMap and Symbol Pos
|
// { model with Symbols = newSymbols }, Cmd.none
|
||||||
// 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
|
// | FlipVSymbols compList ->
|
||||||
// { model with Symbols = newSymbols }, Cmd.none
|
// let resetSymbols = Map.map (fun _ sym -> { sym with Colour = "Lightgray"; Opacity = 1.0 }) model.Symbols
|
||||||
|
// let newSymbols =
|
||||||
// | FlipVSymbols compList ->
|
// List.fold (fun prevSymbols sId ->
|
||||||
// let resetSymbols = Map.map (fun _ sym -> { sym with Colour = "Lightgray"; Opacity = 1.0 }) model.Symbols
|
// Map.add sId model.Symbols[sId] prevSymbols) resetSymbols compList //NEED TO DO APPROPRIATE CHANGES HERE, SEE ROTATION FOR INSPIRATION
|
||||||
// let newSymbols =
|
// { model with Symbols = newSymbols }, Cmd.none
|
||||||
// // 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
|
|
||||||
// { 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) ->
|
| ErrorSymbols (errorCompList,selectCompList,isDragAndDrop) ->
|
||||||
let resetSymbols = Map.map (fun _ sym -> { sym with Colour = "Lightgray"; Opacity = 1.0 }) model.Symbols
|
let resetSymbols = Map.map (fun _ sym -> { sym with Colour = "Lightgray"; Opacity = 1.0 }) model.Symbols
|
||||||
|
|
|
@ -149,8 +149,8 @@ let viewMenu dispatch =
|
||||||
makeItem "Diagram Zoom to Fit" (Some "CmdOrCtrl+W") (fun ev -> dispatch Sheet.KeyboardMsg.CtrlW)
|
makeItem "Diagram Zoom to Fit" (Some "CmdOrCtrl+W") (fun ev -> dispatch Sheet.KeyboardMsg.CtrlW)
|
||||||
menuSeparator
|
menuSeparator
|
||||||
makeItem "Rotate Symbol" (Some "Shift+R") (fun ev -> dispatch Sheet.KeyboardMsg.Rotate)
|
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 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 Vertically Symbol" (Some "Shift+V") (fun ev -> dispatch Sheet.KeyboardMsg.FlipV)
|
||||||
menuSeparator
|
menuSeparator
|
||||||
makeCondItem (JSHelpers.debugLevel <> 0) "Toggle Dev Tools" (Some devToolsKey) (fun _ ->
|
makeCondItem (JSHelpers.debugLevel <> 0) "Toggle Dev Tools" (Some devToolsKey) (fun _ ->
|
||||||
renderer.ipcRenderer.send("toggle-dev-tools", [||]) |> ignore)
|
renderer.ipcRenderer.send("toggle-dev-tools", [||]) |> ignore)
|
||||||
|
|
Loading…
Reference in a new issue