|
@@ -39,7 +39,7 @@ namespace SketchAssistantWPF
|
|
|
|
|
|
|
|
|
|
|
|
- bool inDrawingMode;
|
|
|
+ public bool inDrawingMode { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
@@ -60,6 +60,21 @@ namespace SketchAssistantWPF
|
|
|
|
|
|
|
|
|
Queue<Point> cursorPositions = new Queue<Point>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Point currentOptiCursorPosition;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Point previousOptiCursorPosition;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Queue<Point> optiCursorPositions = new Queue<Point>();
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -101,15 +116,15 @@ namespace SketchAssistantWPF
|
|
|
|
|
|
public bool optitrackAvailable { get; private set; }
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
public float optiTrackX;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
public float optiTrackY;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
public float optiTrackZ;
|
|
|
|
|
@@ -129,7 +144,6 @@ namespace SketchAssistantWPF
|
|
|
|
|
|
bool testing = false;
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -294,8 +308,11 @@ namespace SketchAssistantWPF
|
|
|
Console.WriteLine("raw coordinates: " + p.X + ";" + p.Y);
|
|
|
Console.WriteLine(correctedPoint.X + "," + correctedPoint.Y);
|
|
|
}
|
|
|
- currentCursorPosition = correctedPoint;
|
|
|
- programPresenter.MoveOptiPoint(currentCursorPosition);
|
|
|
+ currentOptiCursorPosition = correctedPoint;
|
|
|
+ if (optiCursorPositions.Count > 0) { previousOptiCursorPosition = optiCursorPositions.Dequeue(); }
|
|
|
+ else { previousOptiCursorPosition = currentOptiCursorPosition; }
|
|
|
+
|
|
|
+ programPresenter.MoveOptiPoint(currentOptiCursorPosition);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -473,13 +490,10 @@ namespace SketchAssistantWPF
|
|
|
|
|
|
public void FinishCurrentLine(bool valid)
|
|
|
{
|
|
|
- foreach (Point p in currentLine)
|
|
|
- {
|
|
|
- if (testing)
|
|
|
- {
|
|
|
+ if (testing)
|
|
|
+ foreach (Point p in currentLine)
|
|
|
Console.WriteLine(p.X + ";" + p.Y);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
mouseDown = false;
|
|
|
if (valid)
|
|
|
{
|
|
@@ -541,22 +555,35 @@ namespace SketchAssistantWPF
|
|
|
{
|
|
|
if (cursorPositions.Count > 0) { previousCursorPosition = cursorPositions.Dequeue(); }
|
|
|
else { previousCursorPosition = currentCursorPosition; }
|
|
|
- if (optiTrackInUse)
|
|
|
+
|
|
|
+ if (optiTrackInUse && inDrawingMode)
|
|
|
{
|
|
|
+ SetCurrentFingerPosition(new Point(optiTrackX, optiTrackY));
|
|
|
+
|
|
|
+
|
|
|
+ if (!CheckInsideDrawingZone(optiTrackZ))
|
|
|
+ {
|
|
|
+
|
|
|
+ if (optiTrackInsideDrawingZone && inDrawingMode)
|
|
|
+ {
|
|
|
+ optiTrackInsideDrawingZone = false;
|
|
|
+ FinishCurrentLine(true);
|
|
|
+ if (testing) Console.WriteLine("line finished");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (CheckInsideDrawingZone(optiTrackZ))
|
|
|
{
|
|
|
- SetCurrentFingerPosition(new Point(optiTrackX, optiTrackY));
|
|
|
- currentLine.Add(currentCursorPosition);
|
|
|
- programPresenter.UpdateCurrentLine(currentLine);
|
|
|
+
|
|
|
if (!optiTrackInsideDrawingZone)
|
|
|
{
|
|
|
optiTrackInsideDrawingZone = true;
|
|
|
StartNewLine();
|
|
|
- if (testing)
|
|
|
- {
|
|
|
- Console.WriteLine("new line begun");
|
|
|
- }
|
|
|
+ if (testing) Console.WriteLine("new line begun");
|
|
|
}
|
|
|
+ else currentLine.Add(currentOptiCursorPosition);
|
|
|
+ programPresenter.UpdateCurrentLine(currentLine);
|
|
|
if (optiTrackZ > WARNING_ZONE_BOUNDARY)
|
|
|
{
|
|
|
armband.pushForward();
|
|
@@ -566,36 +593,32 @@ namespace SketchAssistantWPF
|
|
|
armband.pushBackward();
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- if (optiTrackInsideDrawingZone)
|
|
|
- {
|
|
|
- optiTrackInsideDrawingZone = false;
|
|
|
- FinishCurrentLine(true);
|
|
|
- if (testing)
|
|
|
- {
|
|
|
- Console.WriteLine("line finished");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
projectPointOntoScreen(optiTrackX, optiTrackY);
|
|
|
|
|
|
- cursorPositions.Enqueue(currentCursorPosition);
|
|
|
}
|
|
|
- else
|
|
|
+ else if( !optiTrackInUse && inDrawingMode)
|
|
|
{
|
|
|
+
|
|
|
cursorPositions.Enqueue(currentCursorPosition);
|
|
|
if (inDrawingMode && programPresenter.IsMousePressed())
|
|
|
{
|
|
|
currentLine.Add(currentCursorPosition);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
- if (!inDrawingMode && programPresenter.IsMousePressed())
|
|
|
+
|
|
|
+
|
|
|
+ if (!inDrawingMode)
|
|
|
{
|
|
|
- List<Point> uncheckedPoints = GeometryCalculator.BresenhamLineAlgorithm(previousCursorPosition, currentCursorPosition);
|
|
|
+ List<Point> uncheckedPoints = new List<Point>();
|
|
|
+ if (programPresenter.IsMousePressed() && !optiTrackInUse)
|
|
|
+ uncheckedPoints = GeometryCalculator.BresenhamLineAlgorithm(previousCursorPosition, currentCursorPosition);
|
|
|
+ if(optiTrackInUse && CheckInsideDrawingZone(optiTrackZ))
|
|
|
+ uncheckedPoints = GeometryCalculator.BresenhamLineAlgorithm(previousOptiCursorPosition, currentOptiCursorPosition);
|
|
|
|
|
|
foreach (Point currPoint in uncheckedPoints)
|
|
|
{
|
|
@@ -608,7 +631,6 @@ namespace SketchAssistantWPF
|
|
|
rightLineList[lineID] = new Tuple<bool, InternalLine>(false, rightLineList[lineID].Item2);
|
|
|
}
|
|
|
RepopulateDeletionMatrixes();
|
|
|
-
|
|
|
programPresenter.UpdateRightLines(rightLineList);
|
|
|
}
|
|
|
}
|