Browse Source

Cleaned up code for codereview

Martin Edlund (Laptop) 5 years ago
parent
commit
0a045c3164

+ 11 - 15
SketchAssistant/SketchAssistantWPF/MVP_Model.cs

@@ -34,6 +34,10 @@ namespace SketchAssistantWPF
         /*** CLASS VARIABLES ***/
         /***********************/
 
+        /// <summary>
+        /// this is a variable used for detecting whether the tracker is in the warning zone (0 +- variable), no drawing zone (0 +- 2 * variable) or normal drawing zone
+        /// </summary>
+        readonly double WARNING_ZONE_BOUNDARY = 0.10; //10cm
         /// <summary>
         /// If the program is in drawing mode.
         /// </summary>
@@ -127,10 +131,6 @@ namespace SketchAssistantWPF
         /// </summary>
         private bool optiTrackInsideDrawingZone = false;
         /// <summary>
-        /// this is a variable used for detecting whether the tracker is in the warning zone (0 +- variable), no drawing zone (0 +- 2 * variable) or normal drawing zone
-        /// </summary>
-        private double WARNING_ZONE_BOUNDARY = 0.10; //10cm
-        /// <summary>
         /// object of class wristband used for controlling the vibrotactile wristband
         /// </summary>
         private Wristband wristband;
@@ -246,7 +246,7 @@ namespace SketchAssistantWPF
             if(PathTraveled > 2)
             {
                 PathTraveled = 0; 
-                //Activate vibration here
+                //TODO: Activate vibration here
             }
         }
 
@@ -352,6 +352,7 @@ namespace SketchAssistantWPF
 
             if (optiCursorPositions.Count > 0) { previousOptiCursorPosition = optiCursorPositions.Dequeue(); }
             else { previousOptiCursorPosition = currentOptiCursorPosition; }
+            optiCursorPositions.Enqueue(currentOptiCursorPosition);
         }
 
         /********************************************/
@@ -361,9 +362,8 @@ namespace SketchAssistantWPF
         /// <summary>
         /// A function to update the dimensions of the left and right canvas when the window is resized.
         /// </summary>
-        /// <param name="LeftCanvas">The size of the left canvas.</param>
         /// <param name="RightCanvas">The size of the right canvas.</param>
-        public void ResizeEvent(ImageDimension LeftCanvas, ImageDimension RightCanvas)
+        public void ResizeEvent(ImageDimension RightCanvas)
         {
             if (RightCanvas.Height >= 0 && RightCanvas.Width >= 0) { rightImageSize = RightCanvas; }
             RepopulateDeletionMatrixes();
@@ -479,7 +479,7 @@ namespace SketchAssistantWPF
         /// <summary>
         /// The function called by the Presenter to set a variable which describes if OptiTrack is in use
         /// </summary>
-        /// <param name="usingOptiTrack"></param>
+        /// <param name="usingOptiTrack">The status of optitrack button</param>
         public void SetOptiTrack(bool usingOptiTrack)
         {
             optiTrackInUse = usingOptiTrack;
@@ -489,11 +489,9 @@ namespace SketchAssistantWPF
                 optiTrackInUse = false;
                 //Disable optipoint
                 programPresenter.SetOverlayStatus("optipoint", false, currentCursorPosition);
-                Console.WriteLine("Point disabled");
             }
             else
             {
-                Console.WriteLine("Point enabled: {0}",optiTrackInUse);
                 //Enable optipoint
                 programPresenter.SetOverlayStatus("optipoint", true, currentCursorPosition);
             }
@@ -603,9 +601,7 @@ namespace SketchAssistantWPF
                         FinishCurrentLine(true);
                     }
                 }
-
-                //Draw with optitrack, when in drawing zone
-                if (CheckInsideDrawingZone(optiTrackZ))
+                else //Draw with optitrack, when in drawing zone
                 {
                     //Optitrack wasn't in the drawing zone last tick -> start a new line
                     if (!optiTrackInsideDrawingZone)
@@ -617,11 +613,11 @@ namespace SketchAssistantWPF
                     programPresenter.UpdateCurrentLine(currentLine);
                     if (optiTrackZ > WARNING_ZONE_BOUNDARY)
                     {
-                        wristband.pushForward();
+                        wristband.PushForward();
                     }
                     else if (optiTrackZ < -1 * WARNING_ZONE_BOUNDARY)
                     {
-                        wristband.pushBackward();
+                        wristband.PushBackward();
                     }
                 }
             }

+ 3 - 3
SketchAssistant/SketchAssistantWPF/MVP_Presenter.cs

@@ -86,7 +86,7 @@ namespace SketchAssistantWPF
         {
             canvasSizeLeft.ChangeDimension(leftPBS.Item1, leftPBS.Item2);
             canvasSizeRight.ChangeDimension(rightPBS.Item1, rightPBS.Item2);
-            programModel.ResizeEvent(canvasSizeLeft, canvasSizeRight);
+            programModel.ResizeEvent(canvasSizeRight);
         }
 
         /// <summary>
@@ -111,7 +111,7 @@ namespace SketchAssistantWPF
                         Tuple<int, int, List<InternalLine>> values = fileImporter.ParseSVGInputFile(fileNameTup.Item1, programModel.leftImageBoxWidth, programModel.leftImageBoxHeight);
                         values.Item3.ForEach(line => line.MakePermanent(0)); //Make all lines permanent
                         programModel.SetLeftLineList(values.Item1, values.Item2, values.Item3);
-                        programModel.ResizeEvent(canvasSizeLeft, canvasSizeRight);
+                        programModel.ResizeEvent(canvasSizeRight);
                         programModel.ResetRightImage();
                         programModel.CanvasActivated();
                         programModel.ChangeState(true);
@@ -206,7 +206,7 @@ namespace SketchAssistantWPF
             }
             if (okToContinue)
             {
-                programModel.ResizeEvent(canvasSizeLeft, canvasSizeRight);
+                programModel.ResizeEvent(canvasSizeRight);
                 programModel.ResetRightImage();
                 programModel.CanvasActivated();
                 programModel.ChangeState(true);

+ 4 - 56
SketchAssistant/SketchAssistantWPF/Wristband.cs

@@ -1,66 +1,14 @@
 using System;
-using System.Runtime.InteropServices;
-using System.Threading;
 
 namespace SketchAssistantWPF
 {
-    internal class Wristband
+    public class Wristband
     {
-        //[StructLayout(LayoutKind.Sequential)]
-        //public class BodyActuator
-        //{
-        //    enum BodyActuator_Type
-        //    {
-        //        BODYACTUATOR_TYPE_NONE,
-        //        BODYACTUATOR_TYPE_EAI,
-        //        BODYACTUATOR_TYPE_PIEZO,
-        //        BODYACTUATOR_TYPE_ERM,
-        //        BODYACTUATOR_TYPE_EMS
-        //    };
-        //    bool valid;
-        //    ushort actuatorCount;
-        //    BodyActuator_Type type;
-        //    ArduinoHub arduinoHub;
-        //    EAIHub eaiHub;
-        //}
-
-
-        //[StructLayout(LayoutKind.Sequential)]
-        //public class EAIHub
-        //{
-        //    bool valid;
-        //    pthread_mutex_t mutex; //TODO fix this
-        //    pthread_t thread;
-        //    Actuator* actuators; //TODO
-        //    uint tactorType;
-        //    uint modulation;
-        //    int deviceID;
-        //}
-
-        //[StructLayout(LayoutKind.Sequential)]
-        //public class ArduinoHub
-        //{
-        //    enum ArduinoHub_Type
-        //    {
-        //        ARDUINOHUB_TYPE_PIEZO = 'P',
-        //        ARDUINOHUB_TYPE_ERM = 'E',
-        //        ARDUINOHUB_TYPE_EMS = 'M'
-        //    }
-        //    bool valid;
-        //    pthread_mutex_t mutex; //TODO fix this
-        //    pthread_t thread;
-        //    ArduinoHub_Type arduinoType;
-        //    Serial* serial;
-        //    Actuator* actuators;
-        //}
-
-        //[DllImport("BodyActuator.dll", EntryPoint = "BodyActuator_actuate")]
-        //static extern void pushForward(ref BodyActuator self, byte tactor, double intensity, ulong duration);
-
+        
         /// <summary>
         /// Function to call when the wristband should push forwards.
         /// </summary>
-        internal void pushForward()
+        public void PushForward()
         {
             Console.WriteLine("FORWARD_PUSH");
         }
@@ -68,7 +16,7 @@ namespace SketchAssistantWPF
         /// <summary>
         /// Function to call when the wristband should push backwards.
         /// </summary>
-        internal void pushBackward()
+        public void PushBackward()
         {
             Console.WriteLine("BACKWARD_PUSH");
         }