Browse Source

Added Optitrack

Rumei Ma 5 years ago
parent
commit
adfc76a9bc

+ 16 - 5
SketchAssistant/SketchAssistantWPF/MVP_Model.cs

@@ -7,6 +7,7 @@ using System.Threading.Tasks;
 using System.Windows.Controls;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
+using OptiTrack;
 
 namespace SketchAssistantWPF
 {
@@ -20,11 +21,12 @@ namespace SketchAssistantWPF
         /// History of Actions
         /// </summary>
         ActionHistory historyOfActions;
-        /// <summary>
-        /// The assistant responsible for the redraw mode
-        /// </summary>
-        //RedrawAssistant redrawAss;
-
+		/// <summary>
+		/// The assistant responsible for the redraw mode
+		/// </summary>
+		//RedrawAssistant redrawAss;
+		OptiTrackConnector connector;
+		OptiTrackConnector.OnFrameReady frameReady;
 
         /***********************/
         /*** CLASS VARIABLES ***/
@@ -116,6 +118,7 @@ namespace SketchAssistantWPF
             UpdateUI();
             rightImageSize = new ImageDimension(0, 0);
             leftImageSize = new ImageDimension(0, 0);
+			connector = new OptiTrackConnector();
         }
 
         /**************************/
@@ -375,6 +378,14 @@ namespace SketchAssistantWPF
         /// </summary>
         public void Tick()
         {
+			if(inDrawingMode)
+			{
+				if (connector.Init(@"optitracak_setup.ttp"))
+				{
+					connector.StartTracking(programPresenter.PassOptiTrackMessage);
+				}
+			}
+			
             if (cursorPositions.Count > 0) { previousCursorPosition = cursorPositions.Dequeue(); }
             else { previousCursorPosition = currentCursorPosition; }
             cursorPositions.Enqueue(currentCursorPosition);

+ 22 - 11
SketchAssistant/SketchAssistantWPF/MVP_Presenter.cs

@@ -8,6 +8,7 @@ using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Shapes;
+using OptiTrack;
 
 namespace SketchAssistantWPF
 {
@@ -353,16 +354,24 @@ namespace SketchAssistantWPF
             return programView.IsMousePressed();
         }
 
-        /*************************/
-        /*** HELPING FUNCTIONS ***/
-        /*************************/
-
-        /// <summary>
-        /// Sets the visibility of a polyline.
-        /// </summary>
-        /// <param name="line">The polyline</param>
-        /// <param name="visible">Whether or not it should be visible.</param>
-        private void SetVisibility(Shape line, bool visible)
+		public void PassOptiTrackMessage(OptiTrack.Frame frame)
+		{
+			float x = frame.Trackables[0].X;
+			float y = frame.Trackables[0].Y;
+			float z = frame.Trackables[0].Z;
+			programView.SetOptiTrackText("X: " + x + "Y: " + y + "Z: " + z);
+		}
+
+		/*************************/
+		/*** HELPING FUNCTIONS ***/
+		/*************************/
+
+		/// <summary>
+		/// Sets the visibility of a polyline.
+		/// </summary>
+		/// <param name="line">The polyline</param>
+		/// <param name="visible">Whether or not it should be visible.</param>
+		private void SetVisibility(Shape line, bool visible)
         {
             if (!visible)
             {
@@ -419,5 +428,7 @@ namespace SketchAssistantWPF
             }
             return realCoordinates;
         }
-    }
+
+		
+	}
 }

+ 7 - 1
SketchAssistant/SketchAssistantWPF/MVP_View.cs

@@ -119,5 +119,11 @@ namespace SketchAssistantWPF
         /// </summary>
         /// <returns>The cursor Position</returns>
         Point GetCursorPosition();
-    }
+
+		/// <summary>
+		/// Sets the contents of the last action taken indicator label.
+		/// </summary>
+		/// <param name="message">The new contents</param>
+		void SetOptiTrackText(String message);
+	}
 }

+ 2 - 0
SketchAssistant/SketchAssistantWPF/MainWindow.xaml

@@ -186,6 +186,8 @@
                 <TextBox Name="LoadStatusBox" Text="nothing loaded" Background="LightGray"/>
                 <Separator/>
                 <TextBox Name="LastActionBox" Text="none" Background="LightGray"/>
+                <Separator/>
+                <TextBox Name="OptiTrackBox" Text="none" Background="LightGray"/>
             </StatusBar>
         </DockPanel>
     </Grid>

+ 3 - 0
SketchAssistant/SketchAssistantWPF/SketchAssistantWPF.csproj

@@ -78,8 +78,11 @@
     <Compile Include="DebugData.cs" />
     <Compile Include="FileImporter.cs" />
     <Compile Include="FileImporterException.cs" />
+    <Compile Include="Frame.cs" />
     <Compile Include="GeometryCalculator.cs" />
+    <Compile Include="HighPerformanceTimer.cs" />
     <Compile Include="ImageDimension.cs" />
+    <Compile Include="OptiTrackConnector.cs" />
     <Compile Include="SketchAction.cs" />
     <Page Include="MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>

+ 0 - 13
userstory16.md

@@ -1,13 +0,0 @@
-# Userstory 16  
- 
-|**ID**|16|  
-|-|-|
-|**Name**|Änderung der Nutzeroberfläche & wpf|
-|**Beschreibung**|Die Nutzeroberfläche wird an die neuen Anforderungen des Auftraggebers angepasst.|
-|**Akzeptanzkriterium**|Die Userstory ist akzeptiert, wenn die UI eine Zeichenfläche enthält und eine Fläche zum Anzeigen von Grafiken, sowie alle vorherig verfügbare Knöpfe. Zusätzlich ist erforderlich, dass die UI statt auf WinForms auf WPF basiert. Auch sollen die Knöpfe in der Toolbar durch Symbole, statt durch Text markiert sein, und es einen Edit Button gibt in welchem zusätzlich die Funktionen vorhanden sind.|
-|Geschätzter Aufwand (Story Points)|10|
-|Entwickler|Martin Edlund|
-|Umgesetzt in Iteration|keine|
-|Tatsächlicher Aufwand (Std.)|keine|
-|Velocity (Std./Story Point)|keine|
-|Bemerkungen|Keine|