|
@@ -21,7 +21,8 @@ namespace bbiwarg.Graphics
|
|
|
private Dictionary<int, List<Vector2D>> positions;
|
|
|
private Dictionary<int, long> lastUpdates;
|
|
|
private int nextFreeID;
|
|
|
-
|
|
|
+ private int lastUpdated;
|
|
|
+ private bool active;
|
|
|
|
|
|
public TouchEventVisualizer(int width, int height)
|
|
|
{
|
|
@@ -37,6 +38,8 @@ namespace bbiwarg.Graphics
|
|
|
timer.Start();
|
|
|
|
|
|
nextFreeID = 1;
|
|
|
+ lastUpdated = 0;
|
|
|
+ active = false;
|
|
|
idTranslations = new Dictionary<int, int>();
|
|
|
positions = new Dictionary<int, List<Vector2D>>();
|
|
|
lastUpdates = new Dictionary<int, long>();
|
|
@@ -52,6 +55,8 @@ namespace bbiwarg.Graphics
|
|
|
positions.Add(id, new List<Vector2D>());
|
|
|
positions[id].Add(tea.RelativePosition);
|
|
|
lastUpdates.Add(id, timer.ElapsedMilliseconds);
|
|
|
+ lastUpdated = id;
|
|
|
+ active = true;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -60,6 +65,7 @@ namespace bbiwarg.Graphics
|
|
|
int id = idTranslations[tea.TrackID];
|
|
|
positions[id].Add(tea.RelativePosition);
|
|
|
lastUpdates[id] = timer.ElapsedMilliseconds;
|
|
|
+ lastUpdated = id;
|
|
|
}
|
|
|
|
|
|
public void touchUp(object sender, TouchEventArgs tea)
|
|
@@ -67,6 +73,7 @@ namespace bbiwarg.Graphics
|
|
|
int id = idTranslations[tea.TrackID];
|
|
|
positions[id].Add(tea.RelativePosition);
|
|
|
lastUpdates[id] = timer.ElapsedMilliseconds;
|
|
|
+ lastUpdated = id;
|
|
|
|
|
|
idTranslations.Remove(tea.TrackID);
|
|
|
}
|
|
@@ -82,6 +89,8 @@ namespace bbiwarg.Graphics
|
|
|
if (currentTime - lastUpdates[id] > Parameters.TouchEventVisualizerFadeOutTime) {
|
|
|
positions.Remove(id);
|
|
|
lastUpdates.Remove(id);
|
|
|
+ if (id == lastUpdated)
|
|
|
+ active = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -96,6 +105,15 @@ namespace bbiwarg.Graphics
|
|
|
int widthPerColumn = width / numColumns;
|
|
|
int heightPerRow = height / numRows;
|
|
|
|
|
|
+ int activeRow = -1;
|
|
|
+ int activeCol = -1;
|
|
|
+ if (active && numRows*numColumns > 1) {
|
|
|
+ Vector2D position = positions[lastUpdated][positions[lastUpdated].Count-1];
|
|
|
+ activeRow = (int)Math.Floor(position.Y * Parameters.PalmGridNumRows);
|
|
|
+ activeCol = (int)Math.Floor(position.X * Parameters.PalmGridNumColumns);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
for (int i = 0; i <= numColumns; i++)
|
|
|
{
|
|
|
OutputImage.drawLineSegment(new LineSegment2D(new Vector2D(i * widthPerColumn, 0), new Vector2D(i * widthPerColumn, height - 1)), Parameters.TouchEventVisualizerGridColor);
|
|
@@ -108,6 +126,9 @@ namespace bbiwarg.Graphics
|
|
|
|
|
|
for (int row = 0; row < numRows; row++) {
|
|
|
for (int col = 0; col < numColumns; col++) {
|
|
|
+ if(row == activeRow && col == activeCol)
|
|
|
+ OutputImage.fillRectangle(col*widthPerColumn, row*heightPerRow, widthPerColumn, heightPerRow, Parameters.TouchEventVisualizerActiveBlockColor);
|
|
|
+
|
|
|
int x = (int)((col+0.5f)*widthPerColumn)-5;
|
|
|
int y = (int)((row+0.5f)*heightPerRow)+5;
|
|
|
OutputImage.drawText(x,y,(1+row*numColumns+col).ToString(),Parameters.TouchEventVisualizerTextColor);
|