Selaa lähdekoodia

small changes for expertenevaluation

Rumei 5 vuotta sitten
vanhempi
commit
e39adf3cee

+ 46 - 46
SketchAssistant/SketchAssistantWPF/Armband.cs

@@ -6,56 +6,56 @@ namespace SketchAssistantWPF
 {
     internal class Armband
     {
-        [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 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
-            Thread thread;
-            Actuator* actuators; //TODO
-            uint tactorType;
-            uint modulation;
-            int deviceID;
-        }
+        //[StructLayout(LayoutKind.Sequential)]
+        //public class EAIHub
+        //{
+        //    bool valid;
+        //    pthread_mutex_t mutex; //TODO fix this
+        //    Thread 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
-            Thread thread;
-            ArduinoHub_Type arduinoType;
-            Serial* serial;
-            Actuator* actuators;
-        }
+        //[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
+        //    Thread 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);
+        //[DllImport("BodyActuator.dll", EntryPoint = "BodyActuator_actuate")]
+        //static extern void pushForward(ref BodyActuator self, byte tactor, double intensity, ulong duration);
 
         internal void pushForward()
         {

+ 12 - 3
SketchAssistant/SketchAssistantWPF/MVP_Model.cs

@@ -364,10 +364,17 @@ namespace SketchAssistantWPF
             UpdateUI();
         }
 
-
-        public void ChangeOptiTrack(bool usingOptiTrack)
+        /// <summary>
+        /// The function called by the Presenter to set a variable which describes if OptiTrack is in use
+        /// </summary>
+        /// <param name="usingOptiTrack"></param>
+        public void SetOptiTrack(bool usingOptiTrack)
         {
             optiTrackInUse = usingOptiTrack;
+            if (usingOptiTrack && optiTrackX == 0 && optiTrackY == 0 && optiTrackZ == 0)
+            {
+                programPresenter.PassMessageToView("Trackable not detected, please check if OptiTrack is activated and Trackable is recognized", "Warning");
+            }
         }
 
         /// <summary>
@@ -489,7 +496,9 @@ namespace SketchAssistantWPF
                         Console.WriteLine("line finished");
                     }
                 }
-                projectPointOntoScreen(optiTrackX, optiTrackY);
+                if(optiTrackX != 0 && optiTrackY != 0 && optiTrackZ != 0) {
+                    projectPointOntoScreen(optiTrackX, optiTrackY);
+                }
             }
             if (cursorPositions.Count > 0) { previousCursorPosition = cursorPositions.Dequeue(); }
             else { previousCursorPosition = currentCursorPosition; }

+ 13 - 3
SketchAssistant/SketchAssistantWPF/MVP_Presenter.cs

@@ -124,7 +124,7 @@ namespace SketchAssistantWPF
         /// </summary>
         public void ChangeOptiTrack(bool usingOptiTrack)
         {
-            programModel.ChangeOptiTrack(usingOptiTrack);
+            programModel.SetOptiTrack(usingOptiTrack);
         }
 
         /// <summary>
@@ -354,9 +354,19 @@ namespace SketchAssistantWPF
         /// Pass-trough function to display an info message in the view.
         /// </summary>
         /// <param name="msg">The message.</param>
-        public void PassMessageToView(String msg)
+        /// <param name="caption">The caption.</param>
+        public void PassMessageToView(String msg, String caption)
         {
-            programView.ShowInfoMessage(msg);
+            programView.ShowInfoMessage(msg, caption);
+        }
+
+        /// <summary>
+        /// Pass-through function to desplay an Warning message in the view
+        /// </summary>
+        /// <param name="msg"></param>
+        public void PassWarning(String msg)
+        {
+            programView.ShowWarning(msg);
         }
 
         /// <summary>

+ 1 - 1
SketchAssistant/SketchAssistantWPF/MVP_View.cs

@@ -87,7 +87,7 @@ namespace SketchAssistantWPF
         /// shows the given info message in a popup and asks the user to aknowledge it
         /// </summary>
         /// <param name="message">the message to show</param>
-        void ShowInfoMessage(String message);
+        void ShowInfoMessage(String message, String caption);
 
         /// <summary>
         /// Shows a warning box with the given message (Yes/No Buttons)and returns true if the user aknowledges it.

+ 1 - 1
SketchAssistant/SketchAssistantWPF/MainWindow.xaml

@@ -27,7 +27,7 @@
         <ToolBar x:Name="MenuToolbar" Grid.Column="0" Grid.ColumnSpan="5" Grid.Row="0" Background="LightGray">
             <Menu Background="LightGray">
                 <MenuItem x:Name="LoadMenuButton" Header="Load">
-                    <MenuItem Header="Load SVG File" Click="MenuItem_Click"/>
+                    <MenuItem Header="Load Template (.svg)" Click="MenuItem_Click"/>
                 </MenuItem>
                 <MenuItem x:Name="EditMenuButton" Header="Edit">
                     <MenuItem Header="New Canvas" Click="CanvasButton_Click"/>

+ 8 - 3
SketchAssistant/SketchAssistantWPF/MainWindow.xaml.cs

@@ -484,11 +484,16 @@ namespace SketchAssistantWPF
 
         /// <summary>
         /// shows the given info message in a popup and asks the user to aknowledge it
+        /// if caption is "Warning" add MessageBoxImage.Warning to the pop up window
         /// </summary>
         /// <param name="message">the message to show</param>
-        public void ShowInfoMessage(string message)
-        {
-            MessageBox.Show(message);
+        public void ShowInfoMessage(string message, string caption)
+        {   
+            if(caption == "Warning")
+            {
+                MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Warning);
+            }
+            else MessageBox.Show(message, caption);
         }
 
         /// <summary>