Browse Source

Added support for multiple debug lines

Martin Edlund 5 năm trước cách đây
mục cha
commit
2ca10a6441

+ 32 - 1
SketchAssistant/SketchAssistantWPF/MVP_Presenter.cs

@@ -399,7 +399,7 @@ namespace SketchAssistantWPF
         }
 
         /// <summary>
-        /// 
+        /// Update the similarity score displayed in the UI.
         /// </summary>
         /// <param name="score">Score will be reset if NaN is passed, 
         /// will be ignored if the score is not between 0 and 1</param>
@@ -436,6 +436,9 @@ namespace SketchAssistantWPF
                     shape = ((MainWindow)programView).OverlayDictionary["startpoint"];
                     xDif = ((MainWindow)programView).markerRadius; yDif = xDif;
                     break;
+                default:
+                    Console.WriteLine("Unknown Overlay Item. Please check in MVP_Presenter if this item exists.");
+                    return;
             }
             if (visible) shape.Opacity = visibility;
             else shape.Opacity = 0.00001;
@@ -443,6 +446,34 @@ namespace SketchAssistantWPF
             shape.Margin = new Thickness(point.X - xDif, point.Y - yDif, 0, 0);
         }
 
+        /// <summary>
+        /// Change the properties of an overlay item.
+        /// </summary>
+        /// <param name="name">The name of the item in the overlay dictionary</param>
+        /// <param name="visible">If the element should be visible</param>
+        /// <param name="pos1">The new position of the element</param>
+        /// <param name="pos2">The new position of the element</param>
+        public void SetOverlayStatus(String name, bool visible, Point pos1, Point pos2)
+        {
+            Shape shape = new Ellipse();
+            switch (name.Substring(0,7))
+            {
+                case "dotLine":
+                    if (((MainWindow)programView).OverlayDictionary.ContainsKey(name))
+                    { shape = ((MainWindow)programView).OverlayDictionary[name];
+                        break;
+                    }
+                    goto default;
+                default:
+                    SetOverlayStatus(name, visible, pos1);
+                    return;
+            }
+            if (visible) shape.Opacity = 1;
+            else shape.Opacity = 0.00001;
+            Point p1 = ConvertRightCanvasCoordinateToOverlay(pos1); Point p2 = ConvertRightCanvasCoordinateToOverlay(pos2);
+            ((Line)shape).X1 = p1.X; ((Line)shape).X2 = p2.X; ((Line)shape).Y1 = p1.Y; ((Line)shape).Y2 = p2.Y;
+        }
+
         /// <summary>
         /// Move the optitrack pointer to a new position.
         /// </summary>

+ 23 - 6
SketchAssistant/SketchAssistantWPF/MainWindow.xaml.cs

@@ -367,7 +367,6 @@ namespace SketchAssistantWPF
         public Tuple<string, string> openNewDialog(string Filter)
         {
             openFileDialog.Filter = Filter;
-            openFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
             if (openFileDialog.ShowDialog() == true)
             {
                 return new Tuple<string, string>(openFileDialog.FileName, openFileDialog.SafeFileName);
@@ -544,18 +543,36 @@ namespace SketchAssistantWPF
         private void SetupOverlay()
         {
             DropShadowEffect effect = new DropShadowEffect(); effect.ShadowDepth = 0;
-            //Startpoint of a line to be redrawn
             OverlayCanvas.Background = null;
+            //Startpoint of a line to be redrawn
             Ellipse StartPointOverlay = new Ellipse();
             StartPointOverlay.Height = markerRadius * 2; StartPointOverlay.Width = markerRadius * 2;
-            StartPointOverlay.Opacity = 0.00001; StartPointOverlay.Fill = Brushes.Green; StartPointOverlay.IsHitTestVisible = false;
-            OverlayDictionary.Add("startpoint", StartPointOverlay); OverlayCanvas.Children.Add(StartPointOverlay);
+            StartPointOverlay.Fill = Brushes.Green;
             StartPointOverlay.Effect = effect;
+            OverlayDictionary.Add("startpoint", StartPointOverlay);
             //Pointer of the optitrack system
             Ellipse OptitrackMarker = new Ellipse(); OptitrackMarker.Height = 5; OptitrackMarker.Width = 5;
-            OptitrackMarker.Opacity = 0.00001; OptitrackMarker.Fill = Brushes.Black; OptitrackMarker.IsHitTestVisible = false;
-            OverlayDictionary.Add("optipoint", OptitrackMarker); OverlayCanvas.Children.Add(OptitrackMarker);
+            OptitrackMarker.Fill = Brushes.LightGray;
             OptitrackMarker.Effect = effect;
+            OverlayDictionary.Add("optipoint", OptitrackMarker);
+            //10 Dotted Lines for debugging (if more are needed simply extend the for-loop
+            for(int x = 0; x < 10; x++)
+            {
+                Line dotLine = new Line();
+                dotLine.Stroke = Brushes.Red;
+                dotLine.StrokeDashArray = new DoubleCollection { 2 + x, 2 + x };
+                dotLine.StrokeThickness = 1;
+                OverlayDictionary.Add("dotLine" + x.ToString(), dotLine);
+            }
+
+            //Common features of all overlay items
+            foreach (KeyValuePair<String, Shape> s  in OverlayDictionary)
+            {
+                OverlayCanvas.Children.Add(s.Value);
+                s.Value.Opacity = 0.00001;
+                s.Value.IsHitTestVisible = false;
+            }
+
             //Enable optipoint initially
             ProgramPresenter.SetOverlayStatus("optipoint", true, GetCursorPosition());
         }