Jelajahi Sumber

Added userstory 17 md file.

Martin Edlund 6 tahun lalu
induk
melakukan
c7d82c1de8

+ 49 - 17
SketchAssistant/SketchAssistant/Form1.cs

@@ -132,7 +132,9 @@ namespace SketchAssistant
             UpdateButtonStatus();
         }
 
-        //Resize Function connected to the form resize event, will refresh the form when it is resized
+        /// <summary>
+        /// Resize Function connected to the form resize event, will refresh the form when it is resized
+        /// </summary>
         private void Form1_Resize(object sender, System.EventArgs e)
         {
             this.Refresh();
@@ -193,7 +195,9 @@ namespace SketchAssistant
             UpdateButtonStatus();
         }
 
-        //Changes the state of the program to drawing
+        /// <summary>
+        /// Changes the state of the program to drawing
+        /// </summary>
         private void drawButton_Click(object sender, EventArgs e)
         {
             if(rightImage != null)
@@ -210,7 +214,9 @@ namespace SketchAssistant
             UpdateButtonStatus();
         }
 
-        //Changes the state of the program to deletion
+        /// <summary>
+        /// Changes the state of the program to deletion
+        /// </summary>
         private void deleteButton_Click(object sender, EventArgs e)
         {
             if (rightImage != null)
@@ -227,7 +233,9 @@ namespace SketchAssistant
             UpdateButtonStatus();
         }
 
-        //Undo an action
+        /// <summary>
+        /// Undo an Action.
+        /// </summary>
         private void undoButton_Click(object sender, EventArgs e)
         {
             if (historyOfActions.CanUndo())
@@ -247,12 +255,16 @@ namespace SketchAssistant
                     default:
                         break;
                 }
+                overlayItems = redrawAss.Tick(currentCursorPosition, rightLineList, -1);
+                RedrawRightImage();
             }
             historyOfActions.MoveAction(true);
             UpdateButtonStatus();
         }
 
-        //Redo an action
+        /// <summary>
+        /// Redo an Action.
+        /// </summary>
         private void redoButton_Click(object sender, EventArgs e)
         {
             if (historyOfActions.CanRedo())
@@ -273,11 +285,15 @@ namespace SketchAssistant
                     default:
                         break;
                 }
+                overlayItems = redrawAss.Tick(currentCursorPosition, rightLineList, -1);
+                RedrawRightImage();
             }
             UpdateButtonStatus();
         }
 
-        //Detect Keyboard Shortcuts
+        /// <summary>
+        /// Detect Keyboard Shortcuts.
+        /// </summary>
         private void Form1_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Z)
@@ -290,13 +306,17 @@ namespace SketchAssistant
             }
         }
 
-        //get current Mouse positon within the right picture box
+        /// <summary>
+        /// Get current Mouse positon within the right picture box.
+        /// </summary>
         private void pictureBoxRight_MouseMove(object sender, MouseEventArgs e)
         {
             currentCursorPosition = ConvertCoordinates(new Point(e.X, e.Y));
         }
-
-        //hold left mouse button to draw.
+        
+        /// <summary>
+        /// Hold left mouse button to start drawing.
+        /// </summary>
         private void pictureBoxRight_MouseDown(object sender, MouseEventArgs e)
         {
             mousePressed = true;
@@ -305,8 +325,10 @@ namespace SketchAssistant
                 currentLine = new List<Point>();
             }
         }
-
-        //Lift left mouse button to stop drawing and add a new Line.
+        
+        /// <summary>
+        /// Lift left mouse button to stop drawing and add a new Line.
+        /// </summary>
         private void pictureBoxRight_MouseUp(object sender, MouseEventArgs e)
         {
             mousePressed = false;
@@ -322,10 +344,12 @@ namespace SketchAssistant
             }
             UpdateButtonStatus();
         }
-
-        //Button to create a new Canvas. Will create an empty image 
-        //which is the size of the left image, if there is one.
-        //If there is no image loaded the canvas will be the size of the right picture box
+        
+        /// <summary>
+        /// Button to create a new Canvas. Will create an empty image 
+        /// which is the size of the left image, if there is one.
+        /// If there is no image loaded the canvas will be the size of the right picture box
+        /// </summary>
         private void canvasButton_Click(object sender, EventArgs e)
         {
             if (CheckSavedStatus())
@@ -349,7 +373,10 @@ namespace SketchAssistant
             UpdateSizes();
         }
 
-        //add a Point on every tick to the Drawpath
+        /// <summary>
+        /// Add a Point on every tick to the Drawpath.
+        /// Or detect lines for deletion on every tick
+        /// </summary>
         private void mouseTimer_Tick(object sender, EventArgs e)
         {
             if(cursorPositions.Count > 0) { previousCursorPosition = cursorPositions.Dequeue(); }
@@ -382,6 +409,8 @@ namespace SketchAssistant
                             rightLineList[lineID] = new Tuple<bool, Line>(false, rightLineList[lineID].Item2);
                         }
                         RepopulateDeletionMatrixes();
+                        //RedrawTick
+                        overlayItems = redrawAss.Tick(currentCursorPosition, rightLineList, -1);
                         RedrawRightImage();
                     }
                 }
@@ -735,7 +764,10 @@ namespace SketchAssistant
         /// Cast according to the Type definitions in the class variable section.</returns>
         public List<Tuple<String, Object>>GetAllVariables()
         {
-            var objArr = new Object[] { currentState, fileImporter, openFileDialog, leftImage, leftLineList, rightImage, currentLine, rightLineList, mousePressed, currentCursorPosition, previousCursorPosition, cursorPositions, rightGraph, isFilledMatrix, linesMatrix, deletionRadius, historyOfActions };
+            var objArr = new Object[] { currentState, fileImporter, openFileDialog, leftImage, leftLineList,
+                rightImage, currentLine, rightLineList, mousePressed, currentCursorPosition, previousCursorPosition,
+                cursorPositions, rightGraph, isFilledMatrix, linesMatrix, deletionRadius, historyOfActions,
+                overlayItems, redrawAss, markerRadius };
             var varArr = new List<Tuple<String, Object>>();
             foreach(Object obj in objArr)
             {

+ 41 - 9
SketchAssistant/SketchAssistant/RedrawAssistant.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Collections;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -19,6 +20,10 @@ namespace SketchAssistant
         /// </summary>
         List<Tuple<HashSet<Point>, HashSet<Point>>> startAndEndPoints;
         /// <summary>
+        /// A Hashtable for quick lookup for a line id and its respective tuple in linesToRedraw
+        /// </summary>
+        Hashtable redrawnLineLookupTable;
+        /// <summary>
         /// The position of the line currently being redrawn in the startAndEndPoints 
         /// & linesToRedraw lists. -1 if no line is being redrawn.
         /// </summary>
@@ -28,10 +33,6 @@ namespace SketchAssistant
         /// </summary>
         bool currentlyRedrawing;
         /// <summary>
-        /// The id of the Line currently being redrawn
-        /// </summary>
-        int redrawingID;
-        /// <summary>
         /// Whether or not the RedrawAssistant is active.
         /// </summary>
         bool isActive;
@@ -59,6 +60,7 @@ namespace SketchAssistant
             isActive = true;
             currentlyRedrawing = false;
             lineBeingRedrawn = -1;
+            redrawnLineLookupTable = new Hashtable();
             foreach (Line line in redrawItem)
             {
                 linesToRedraw.Add(new Tuple<Line, bool, int>(line, false, -1));
@@ -68,10 +70,9 @@ namespace SketchAssistant
         /// <summary>
         /// The main functionality of the RedrawAssistant, which updates the Assistant according to the inputs given.
         /// </summary>
-        /// <param name="currentPoint"></param>
-        /// <param name="rightLines"></param>
-        /// <param name="currLineID"></param>
-        /// <param name="markerRad"></param>
+        /// <param name="currentPoint">The current position of the cursor, as a point</param>
+        /// <param name="rightLines">The lines on the right canvas</param>
+        /// <param name="currLineID">The id of the currently finished line, -1 if no line was finished.</param>
         /// <returns></returns>
         public List<HashSet<Point>> Tick(Point currentPoint, List<Tuple<bool, Line>> rightLines, int currLineID)
         {
@@ -79,7 +80,7 @@ namespace SketchAssistant
             if (!isActive) { return returnList; }
             Tuple<Line, bool, int> newLineTuple = null;
             var returnAllStartPoints = true;
-
+            CheckForUndrawnLines(rightLines);
             // The current Endpoint has been intersected, and a line was finished here
             if (currentlyRedrawing && startAndEndPoints[lineBeingRedrawn].Item2.Contains(currentPoint) && currLineID != -1)
             {
@@ -124,6 +125,7 @@ namespace SketchAssistant
                         && redrawLine.GetStartPoint().Equals(newLine.GetStartPoint())
                         && redrawLine.GetEndPoint().Equals(newLine.GetEndPoint()))
                     {
+                        redrawnLineLookupTable.Add(currLineID, i);
                         linesToRedraw[i] = newLineTuple;
                     }
                 }
@@ -144,6 +146,36 @@ namespace SketchAssistant
             return returnList;
         }
 
+        /// <summary>
+        /// A helping function which checks for lines where previously redrawn, but were removed from the image again.
+        /// </summary>
+        /// <param name="rightLines">The lines in the right image.</param>
+        private void CheckForUndrawnLines(List<Tuple<bool, Line>> rightLines)
+        {
+            for (int i = 0; i < rightLines.Count; i++)
+            {
+                if (redrawnLineLookupTable.ContainsKey(rightLines[i].Item2.GetID()))
+                {
+                    if (!rightLines[i].Item1)
+                    {
+                        int listPos = (int)redrawnLineLookupTable[rightLines[i].Item2.GetID()];
+                        var oldTup = linesToRedraw[listPos];
+                        linesToRedraw[listPos] = new Tuple<Line, bool, int>(oldTup.Item1, false, -1);
+                    }
+                    else
+                    {
+                        int listPos = (int)redrawnLineLookupTable[rightLines[i].Item2.GetID()];
+                        var oldTup = linesToRedraw[listPos];
+                        linesToRedraw[listPos] = new Tuple<Line, bool, int>(oldTup.Item1, true, rightLines[i].Item2.GetID());
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// A function to set the marker radius for the markers returned by the RedrawAssistant
+        /// </summary>
+        /// <param name="markerRad">The Radius of the markers.</param>
         public void SetMarkerRadius(int markerRad)
         {
             markerRadius = markerRad;

+ 1 - 1
userstory13.md

@@ -4,7 +4,7 @@
 |-|-|
 |**Name**|Start und Endpunkt anzeigen|
 |**Beschreibung**|Beim Nachzeichnen kann der Start- & Endpunkt einer nachzuzeichnenden Linie angzeigt werden.|
-|**Akzeptanzkriterium**|Sofern auf der linken Seite eine nachzeichenbare Grafik dargestellt wird, wird der Start- und Endpunkt der ersten Linie der linken Grafik an der richtigen Stelle auf der rechten Seite angezeigt.|
+|**Akzeptanzkriterium**|Sofern auf der linken Seite eine nachzeichenbare Grafik dargestellt wird, kann der Start- und Endpunkt der ersten Linie der linken Grafik an der richtigen Stelle auf der rechten Seite angezeigt werden.|
 |Geschätzter Aufwand (Story Points)|2|
 |Entwickler|Martin|
 |Umgesetzt in Iteration|keine|

+ 13 - 0
userstory17.md

@@ -0,0 +1,13 @@
+# Userstory 17  
+ 
+|**ID**|17|  
+|-|-|
+|**Name**|Nachzeichenmodus|
+|**Beschreibung**|Es gibt einen speziellen Modus zum Nachzeichnen von Bildern.|
+|**Akzeptanzkriterium**|Sobald ein Bild geladen wird, welches sich nachzeichenen lässt, wird der Nachzeichenmodus aktiviert. Ist der Nachzeichen Modus aktiviert, so werden Startpunkte für alle Linien auf der rechten Seite angezeigt. Fängt der Nutzer an einem Startpunkt an zu zeichnen, werden die anderen Startpunkte ausgeblendet und der Endpunkt der aktuellen Linie angezeigt. Zeichnet der Nutzer die Linie bis zum Endpunkt fertig, werden die verbleibenden Startpunkte angezeigt und der Nutzer kann eine neue Linie nachzeichnen. Wenn der Nutzer die Linie nicht zuende Zeichnet, muss sie von vorne begonnen werden.|
+|Geschätzter Aufwand (Story Points)|10|
+|Entwickler|Martin|
+|Umgesetzt in Iteration|keine|
+|Tatsächlicher Aufwand (Std.)|keine|
+|Velocity (Std./Story Point)|keine|
+|Bemerkungen|Keine|