|
@@ -60,7 +60,7 @@ namespace BBIWARG.Output.DebugOutput
|
|
|
/// <param name="numRows">number of rows in the palm grid</param>
|
|
|
/// <param name="numColumns">number columns in the palm grid</param>
|
|
|
/// <returns>image showing touch events</returns>
|
|
|
- public OutputImage getOutputImage(ImageSize imageSize, int numRows, int numColumns)
|
|
|
+ public OutputImage getOutputImage(ImageSize imageSize, int numRows, int numColumns, int sliderPos, int sliderMax, int sliderCurr)
|
|
|
{
|
|
|
lock (sync)
|
|
|
{
|
|
@@ -79,37 +79,93 @@ namespace BBIWARG.Output.DebugOutput
|
|
|
int heightPerRow = imageHeight / numRows;
|
|
|
|
|
|
// find active blocks
|
|
|
- bool[,] activeBlocks = new bool[numRows, numColumns];
|
|
|
+ List<List<bool>> activeBlocks = getActiveBlocks(numRows, numColumns, sliderPos, sliderMax, sliderCurr);
|
|
|
if (numRows * numColumns > 1)
|
|
|
{
|
|
|
- foreach (List<Vector2D> positions in activeTouches.Values)
|
|
|
+ for (int i = 0; i < activeTouches.Values.Count; i++)
|
|
|
{
|
|
|
+ List<Vector2D> positions = activeTouches.Values.ElementAt(i);
|
|
|
Vector2D lastPosition = positions.Last();
|
|
|
int activeRow = (int)Math.Min(lastPosition.Y * numRows, numRows - 1);
|
|
|
- int activeCol = (int)Math.Min(lastPosition.X * numColumns, numColumns - 1);
|
|
|
- activeBlocks[activeRow, activeCol] = true;
|
|
|
+ int activeCol = (int)Math.Min(lastPosition.X * activeBlocks.ElementAt(activeRow).Count,
|
|
|
+ activeBlocks.ElementAt(activeRow).Count - 1);
|
|
|
+ if (activeRow != sliderPos)
|
|
|
+ activeBlocks.ElementAt(activeRow)[activeCol] = true;
|
|
|
+ if (activeRow == sliderPos)
|
|
|
+ {
|
|
|
+ if (Parameters.PalmSliderLastTouched != -1)
|
|
|
+ {
|
|
|
+ int temp = Parameters.PalmSliderCurr + (activeCol - Parameters.PalmSliderLastTouched);
|
|
|
+ if (temp < 0)
|
|
|
+ Parameters.PalmSliderCurr = 0;
|
|
|
+ if (temp > Parameters.PalmSliderMax)
|
|
|
+ Parameters.PalmSliderCurr = Parameters.PalmSliderMax;
|
|
|
+ else
|
|
|
+ Parameters.PalmSliderCurr = temp;
|
|
|
+ Parameters.PalmSliderLastTouched = activeCol;
|
|
|
+ }
|
|
|
+ else if (Parameters.PalmSliderLastTouched == -1)
|
|
|
+ {
|
|
|
+ Parameters.PalmSliderLastTouched = activeCol;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Parameters.PalmSliderLastTouched = -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (activeTouches.Values.Count < 1)
|
|
|
+ {
|
|
|
+ Parameters.PalmSliderLastTouched = -1;
|
|
|
}
|
|
|
}
|
|
|
+ if(sliderPos > -1 && sliderPos < numRows)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < Parameters.PalmSliderCurr; i++)
|
|
|
+ {
|
|
|
+ activeBlocks.ElementAt(sliderPos)[i] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// draw blocks
|
|
|
+
|
|
|
int index = 1;
|
|
|
for (int row = 0; row < numRows; row++)
|
|
|
{
|
|
|
- for (int col = 0; col < numColumns; col++)
|
|
|
+ for (int col = 0; col < activeBlocks.ElementAt(row).Count; col++)
|
|
|
{
|
|
|
- if (activeBlocks[row, col])
|
|
|
- outputImage.fillRectangle(new Rectangle(col * widthPerColumn, row * heightPerRow, widthPerColumn, heightPerRow), Parameters.TouchEventVisualizerActiveBlockColor);
|
|
|
+ if (activeBlocks.ElementAt(row)[col])
|
|
|
+ outputImage.fillRectangle(new Rectangle(col * imageWidth/activeBlocks.ElementAt(row).Count,
|
|
|
+ row * heightPerRow, imageWidth / activeBlocks.ElementAt(row).Count, heightPerRow),
|
|
|
+ Parameters.TouchEventVisualizerActiveBlockColor);
|
|
|
+ if(row != sliderPos)
|
|
|
+ {
|
|
|
+ int x = (int)((col + 0.5f) * imageWidth / activeBlocks.ElementAt(row).Count) - 5;
|
|
|
+ int y = (int)((row + 0.5f) * heightPerRow) + 5;
|
|
|
+ outputImage.drawText(new Point(x, y), index.ToString(), Parameters.TouchEventVisualizerTextColor);
|
|
|
+ index++;
|
|
|
|
|
|
- int x = (int)((col + 0.5f) * widthPerColumn) - 5;
|
|
|
- int y = (int)((row + 0.5f) * heightPerRow) + 5;
|
|
|
- outputImage.drawText(new Point(x, y), index.ToString(), Parameters.TouchEventVisualizerTextColor);
|
|
|
- index++;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// draw grid
|
|
|
- for (int i = 0; i <= numColumns; i++)
|
|
|
- outputImage.drawLineSegment(new LineSegment2D(new Vector2D(i * widthPerColumn, 0), new Vector2D(i * widthPerColumn, imageHeight - 1)), Parameters.TouchEventVisualizerGridColor);
|
|
|
+
|
|
|
+
|
|
|
+ for(int i = 0; i < activeBlocks.Count; i++)
|
|
|
+ {
|
|
|
+ for(int j = 0; j < activeBlocks.ElementAt(i).Count; j++)
|
|
|
+ {
|
|
|
+ outputImage.drawLineSegment(new LineSegment2D(
|
|
|
+ new Vector2D(j * imageWidth/activeBlocks.ElementAt(i).Count, i * heightPerRow),
|
|
|
+ new Vector2D(j * imageWidth / activeBlocks.ElementAt(i).Count, (i + 1) * heightPerRow -1)),
|
|
|
+ Parameters.TouchEventVisualizerGridColor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //for (int i = 0; i <= numColumns; i++)
|
|
|
+ // outputImage.drawLineSegment(new LineSegment2D(new Vector2D(i * widthPerColumn, 0), new Vector2D(i * widthPerColumn, imageHeight - 1)), Parameters.TouchEventVisualizerGridColor);
|
|
|
for (int i = 0; i <= numRows; i++)
|
|
|
outputImage.drawLineSegment(new LineSegment2D(new Vector2D(0, i * heightPerRow), new Vector2D(imageWidth - 1, i * heightPerRow)), Parameters.TouchEventVisualizerGridColor);
|
|
|
|
|
@@ -130,6 +186,25 @@ namespace BBIWARG.Output.DebugOutput
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private List<List<bool>> getActiveBlocks(int numRows, int numColumns, int sliderPos, int sliderMax, int sliderCurr)
|
|
|
+ {
|
|
|
+ List<List<bool>> res = new List<List<bool>>();
|
|
|
+ for(int i = 0; i < numRows; i++)
|
|
|
+ {
|
|
|
+ List<bool> temp = new List<bool>();
|
|
|
+ if (i == sliderPos)
|
|
|
+ {
|
|
|
+ for (int j = 0; j < sliderMax; j++) temp.Add(false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for (int j = 0; j < numColumns; j++) temp.Add(false);
|
|
|
+ }
|
|
|
+ res.Add(temp);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Handles the event that a new frame is finished processing by updating the touch events.
|
|
|
/// </summary>
|