-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
284 clear proofs #287
284 clear proofs #287
Changes from all commits
9184621
ff147be
1670123
5090a38
565499a
b1802c5
a25bbfb
06a9766
ff24657
33a1096
eaa667f
b07c67b
d4c333b
b27096f
52016f5
f6adfef
c793ee1
29632f5
d2173e0
b3b4a52
97e8828
dd419b2
0d26448
209c624
08e2e11
b47f394
2daeaad
158b61d
b1c5657
05b1923
e720f85
3e6ca2b
90be43e
21fadc2
4107afe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Creates the history bar on the left side of the screen and handles returning to a previous state. | ||
* @author Dawn Moore | ||
*/ | ||
|
||
import {treeContext} from "./treeContext"; | ||
import {redrawProof} from "./DrawModes/DrawUtils"; | ||
import {ProofNode} from "./AEG/ProofNode"; | ||
|
||
/** | ||
* Creates a button representing the proof step allowing a user to return to that step. | ||
* Creates a new row, a piece of text, and a button for it. | ||
* @param newStep The newest step of our proof | ||
*/ | ||
export function appendStep(newStep: ProofNode) { | ||
const newDiv = document.createElement("div"); | ||
newDiv.className = "row"; | ||
newDiv.id = "Row: " + treeContext.proof.length; | ||
|
||
//Create the new button with the function stepBack calling the step it represents | ||
const button = document.createElement("button"); | ||
button.type = "button"; | ||
button.id = "Step: " + treeContext.proof.length; | ||
button.className = "proofNodeButton"; | ||
button.title = newStep.tree.toString(); | ||
button.onclick = function () { | ||
stepBack(newStep); | ||
}; | ||
|
||
//Determine which action was just taken to give the button the corresponding icon. | ||
const icon = document.createElement("Text"); | ||
icon.className = | ||
"fa fa-" + | ||
{ | ||
"Single Move": "mouse-pointer", | ||
"Multi Move": "arrows", | ||
Resize: "arrows-alt", | ||
"DC Insert": "dot-circle-o", | ||
"DC Delete": "times-circle", | ||
Insertion: "plus", | ||
Erasure: "trash", | ||
Iteration: "expand", | ||
Deiteration: "compress", | ||
Pasted: "files-o", | ||
}[newStep.appliedRule]; | ||
|
||
button.appendChild(icon); | ||
newDiv.appendChild(button); | ||
document.getElementById("proofHistoryBar")?.appendChild(newDiv); | ||
} | ||
|
||
/** | ||
* Sets the selected step to be the current step and redraws the canvas to represent this. | ||
* This will be called when a button representing a proof step is pushed. | ||
* @param selectedStep The selected proof Node that will become the current step | ||
*/ | ||
export function stepBack(selectedStep: ProofNode) { | ||
treeContext.currentProofStep = selectedStep; | ||
redrawProof(); | ||
} | ||
|
||
/** | ||
* Removes buttons related to proof steps that are no longer a part of the proof. | ||
* @param stopIndex The index to stop removing buttons. | ||
*/ | ||
export function deleteButtons(stopIndex: number) { | ||
for (let i = treeContext.proof.length; i > stopIndex + 1; i--) { | ||
document.getElementById("Row: " + i)?.remove(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* File containing clear proof tool event handlers | ||
* @author Anusha Tiwari | ||
*/ | ||
|
||
import {treeContext} from "../treeContext"; | ||
import {cleanCanvas, highlightNode, redrawProof} from "../DrawModes/DrawUtils"; | ||
import {AEGTree} from "../AEG/AEGTree"; | ||
import {illegalColor} from "../Themes"; | ||
import {deleteButtons} from "../ProofHistory"; | ||
|
||
//The current tree in the proof chain | ||
let currentProofTree: AEGTree; | ||
|
||
//Whether or not the node can be cleared | ||
let legalNode: boolean; | ||
|
||
/** | ||
* Handles the mouseDown event for clearProofTool | ||
* Gets the tree of the current step and highlights it in the illegal color | ||
*/ | ||
export function clearProofMouseDown() { | ||
//Get the tree of the current step | ||
currentProofTree = new AEGTree(); | ||
if (treeContext.currentProofStep) { | ||
currentProofTree.sheet = treeContext.currentProofStep.tree.sheet.copy(); | ||
} | ||
|
||
//As long as we are within the canvas, we can legally perform clear | ||
legalNode = true; | ||
//Clear the canvas and redraw the tree in illegal color to show that it will be deleted | ||
cleanCanvas(); | ||
highlightNode(currentProofTree.sheet, illegalColor()); | ||
} | ||
|
||
/** | ||
* Handles the mouseOut event for clearProofTool | ||
* If we are within the canvas, delete the proof history buttons and clear the proof | ||
*/ | ||
export function clearProofMouseUp() { | ||
if (legalNode) { | ||
deleteButtons(-1); | ||
treeContext.clearProof(); | ||
redrawProof(); | ||
} | ||
} | ||
|
||
/** | ||
* Handles the mouseOut event for clearProofTool | ||
* If we move out of the canvas, the proof cannot be cleared | ||
*/ | ||
export function clearProofMouseOut() { | ||
legalNode = false; | ||
redrawProof(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,10 @@ let currentProofTree: AEGTree; | |
*/ | ||
export function deiterationMouseDown(event: MouseEvent) { | ||
const currentPoint: Point = new Point(event.x - offset.x, event.y - offset.y); | ||
currentProofTree = new AEGTree(treeContext.getLastProofStep().tree.sheet); | ||
currentProofTree = new AEGTree(); | ||
if (treeContext.currentProofStep) { | ||
currentProofTree.sheet = treeContext.currentProofStep.tree.sheet.copy(); | ||
} | ||
Comment on lines
+33
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we need this exact block of code in every single proof mode tool it should be turned into a helper function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still holds There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been added to the master clean up issue. |
||
currentNode = currentProofTree.getLowestNode(currentPoint); | ||
|
||
setLegal(); | ||
|
@@ -65,7 +68,7 @@ export function deiterationMouseUp(event: MouseEvent) { | |
if (currentParent instanceof CutNode) { | ||
currentParent.remove(currentPoint); | ||
} | ||
treeContext.proofHistory.push(new ProofNode(currentProofTree, "Deiteration")); | ||
treeContext.pushToProof(new ProofNode(currentProofTree, "Deiteration")); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suspicious that this may not work without quotations, though its possible it will, add them anyway for quality.