/// <summary> /// Overridden <see cref="VGElement.GrabHandleMoved(ref GrabHandle, Point)"/>. /// Resets bounds of the arrow /// according to the movement of the given grab handle /// </summary> /// <param name="handle">GrabHandle that moved</param> /// <param name="handleMovement">Movement in stimulus coordinates</param> public override void GrabHandleMoved(ref GrabHandle handle, Point handleMovement) { if (handle.GrabHandlePosition == GrabHandle.HandlePosition.Center) { PointF newCenter = new PointF(this.Center.X - handleMovement.X, this.Center.Y - handleMovement.Y); this.Center = newCenter; this.AddGrabHandles(); } else { if (VGPolyline.Distance(handle.Center, this.firstPoint) < GrabHandle.HANDLESIZE) { this.firstPoint.X -= handleMovement.X; this.firstPoint.Y -= handleMovement.Y; } else if (VGPolyline.Distance(handle.Center, this.secondPoint) < GrabHandle.HANDLESIZE) { this.secondPoint.X -= handleMovement.X; this.secondPoint.Y -= handleMovement.Y; } PointF newHandleLocation = new PointF( handle.Location.X - handleMovement.X, handle.Location.Y - handleMovement.Y); handle.Location = newHandleLocation; } this.Modified = true; }
/// <summary> /// Initializes a new instance of the VGPolyline class. /// Clone Constructor. Creates new polyline element that is /// identical to the given polyline. /// </summary> /// <param name="newPolyline">Polyline to clone</param> private VGPolyline(VGPolyline newPolyline) : base( newPolyline.ShapeDrawAction, newPolyline.Pen, newPolyline.Brush, newPolyline.Font, newPolyline.FontColor, newPolyline.Bounds, newPolyline.StyleGroup, newPolyline.Name, newPolyline.ElementGroup, newPolyline.Sound) { this.Path = new GraphicsPath(); this.Path = newPolyline.GetPathCopy(); }
/// <summary> /// Loads the shapes that are listed in the given database table /// and creates corresponding graphic elements. /// </summary> /// <param name="areaOfInterestTableRows"> /// Areas of interest table as /// a <see cref="DataGridViewRowCollection"/> /// </param> public void LoadShapesFromDataGridView(DataGridViewRowCollection areaOfInterestTableRows) { try { // Create aoi elements from data view this.AoiCollection = new VGElementCollection(); foreach (DataGridViewRow row in areaOfInterestTableRows) { if (!row.IsNewRow) { // retrieve shape parameters from cell values. var shapeName = row.Cells["colShapeName"].Value.ToString(); var strPtList = row.Cells["colShapePts"].Value.ToString(); Pen usedPen; Font usedFont; Color usedFontColor; VGAlignment usedAlignment; VGStyleGroup usedStyleGroup; var pointList = ObjectStringConverter.StringToPointFList(strPtList); var usedElementGroup = row.Cells["colShapeGroup"].Value.ToString(); switch (usedElementGroup) { case "Target": usedPen = this.TargetPen; usedFont = this.TargetFont; usedFontColor = this.TargetFontColor; usedStyleGroup = VGStyleGroup.AOI_TARGET; usedAlignment = this.TargetTextAlignment; break; case "SearchRect": usedPen = this.SearchRectPen; usedFont = this.SearchRectFont; usedFontColor = this.SearchRectFontColor; usedStyleGroup = VGStyleGroup.AOI_SEARCHRECT; usedAlignment = this.SearchRectTextAlignment; break; default: usedPen = this.DefaultPen; usedFont = this.DefaultFonts; usedFontColor = this.DefaultFontColor; usedStyleGroup = VGStyleGroup.AOI_NORMAL; usedAlignment = this.DefaultTextAlignment; break; } // Create the shape depending on ShapeType var boundingRect = new RectangleF(); switch (row.Cells["colShapeType"].Value.ToString()) { case "Rectangle": boundingRect.Location = pointList[0]; boundingRect.Width = pointList[2].X - pointList[0].X; boundingRect.Height = pointList[2].Y - pointList[0].Y; // Create Rect with defined stroke var newRect = new VGRectangle( this.hideAOIDescription ? ShapeDrawAction.Edge : ShapeDrawAction.NameAndEdge, usedPen, usedFont, usedFontColor, boundingRect, usedStyleGroup, shapeName, usedElementGroup); newRect.TextAlignment = usedAlignment; this.AoiCollection.Add(newRect); break; case "Ellipse": boundingRect.Location = pointList[0]; boundingRect.Width = pointList[2].X - pointList[0].X; boundingRect.Height = pointList[2].Y - pointList[0].Y; // Create Rect with defined stroke var newEllipse = new VGEllipse( this.hideAOIDescription ? ShapeDrawAction.Edge : ShapeDrawAction.NameAndEdge, usedPen, usedFont, usedFontColor, boundingRect, usedStyleGroup, shapeName, usedElementGroup); newEllipse.TextAlignment = usedAlignment; this.AoiCollection.Add(newEllipse); break; case "Polyline": // Create Polyline with defined stroke var newPolyline = new VGPolyline( this.hideAOIDescription ? ShapeDrawAction.Edge : ShapeDrawAction.NameAndEdge, usedPen, usedFont, usedFontColor, usedStyleGroup, shapeName, usedElementGroup); newPolyline.TextAlignment = usedAlignment; foreach (var point in pointList) { newPolyline.AddPt(point); } newPolyline.ClosePolyline(); this.AoiCollection.Add(newPolyline); break; } } } // Reset Elements (deselect and clear all) this.ResetPicture(); this.Elements.AddRange(this.AoiCollection); // If there were a selected element before updating, try // to select it again. if (this.SelectedElement != null) { foreach (VGElement element in this.Elements) { if (VGPolyline.Distance(element.Location, this.SelectedElement.Location) < 1) { this.SelectedElement = element; element.IsInEditMode = true; } } } this.DrawForeground(true); } catch (Exception ex) { ExceptionMethods.HandleException(ex); } }
/////////////////////////////////////////////////////////////////////////////// // Eventhandler for Custom Defined Events // /////////////////////////////////////////////////////////////////////////////// #region CUSTOMEVENTHANDLER #endregion //CUSTOMEVENTHANDLER #endregion //EVENTS /////////////////////////////////////////////////////////////////////////////// // Methods and Eventhandling for Background tasks // /////////////////////////////////////////////////////////////////////////////// #region BACKGROUNDWORKER #endregion //BACKGROUNDWORKER /////////////////////////////////////////////////////////////////////////////// // Inherited methods // /////////////////////////////////////////////////////////////////////////////// #region OVERRIDES #endregion //OVERRIDES /////////////////////////////////////////////////////////////////////////////// // Methods for doing main class job // /////////////////////////////////////////////////////////////////////////////// #region METHODS /// <summary> /// This method creates the shape that is defined in this dialog to be added to a slide. /// </summary> /// <returns>The ready to use <see cref="VGElement"/>.</returns> private VGElement GenerateNewShape() { VGElement element = null; if (this.rdbRectangle.Checked) { element = new VGRectangle( this.pbcStyle.DrawAction, this.pbcStyle.NewPen, this.pbcStyle.NewBrush, this.pbcStyle.NewFont, this.pbcStyle.NewFontColor, new RectangleF(0, 0, 100, 100), VGStyleGroup.None, this.pbcStyle.NewName, string.Empty); } else if (this.rdbEllipse.Checked) { element = new VGEllipse( this.pbcStyle.DrawAction, this.pbcStyle.NewPen, this.pbcStyle.NewBrush, this.pbcStyle.NewFont, this.pbcStyle.NewFontColor, new RectangleF(0, 0, 100, 100), VGStyleGroup.None, this.pbcStyle.NewName, string.Empty); } else if (this.rdbPolyline.Checked) { element = new VGPolyline( this.pbcStyle.DrawAction, this.pbcStyle.NewPen, this.pbcStyle.NewBrush, this.pbcStyle.NewFont, this.pbcStyle.NewFontColor, VGStyleGroup.None, this.pbcStyle.NewName, string.Empty); } else if (this.rdbSharp.Checked) { element = new VGSharp( this.pbcStyle.DrawAction, this.pbcStyle.NewPen, this.pbcStyle.NewFont, this.pbcStyle.NewFontColor, new RectangleF(0, 0, 100, 100), VGStyleGroup.None, this.pbcStyle.NewName, string.Empty); } else if (this.rdbLine.Checked) { element = new VGLine( this.pbcStyle.DrawAction, this.pbcStyle.NewPen, this.pbcStyle.NewFont, this.pbcStyle.NewFontColor, VGStyleGroup.None, this.pbcStyle.NewName, string.Empty); } element.Sound = this.audioControl.Sound; return element; }
/// <summary> /// Adds new points to given polyline, and truncates to <see cref="maxLengthPath"/> /// if DiscreteLength flag is set. /// </summary> /// <param name="polyline"> /// Polyline to modify /// </param> /// <param name="validSamples"> /// A <see cref="List{PointF}"/> with the new samples /// to be added to the <see cref="VGPolyline"/>. /// </param> /// <param name="discreteLength"> /// <strong>True</strong>, if path should be truncated, /// otherwise <strong>false</strong>. /// </param> /// <param name="time"> /// The <see cref="Int64"/> with the last points time. /// </param> private void AddPtsToPolyline(VGPolyline polyline, List<PointF> validSamples, bool discreteLength, long time) { // Add Point to Polyline polyline.AddPts(validSamples); polyline.EndTime = time; // Switch to fixed length if choosen in UI if (discreteLength && (polyline.GetPointCount() > this.maxLengthPath)) { polyline.RemoveFirstPts(polyline.GetPointCount() - this.maxLengthPath); } }
/// <summary> /// Adds new point to given polyline, and truncates to <see cref="maxLengthPath"/> /// if DiscreteLength flag is set. /// </summary> /// <param name="polyline"> /// Polyline to modify /// </param> /// <param name="currPt"> /// new Position /// </param> /// <param name="discreteLength"> /// <strong>True</strong>, if path should be truncated, /// otherwise <strong>false</strong>. /// </param> /// <param name="time"> /// The <see cref="Int64"/> with the points time. /// </param> private void AddPtToPolyline(VGPolyline polyline, PointF currPt, bool discreteLength, long time) { // Add Point to Polyline polyline.AddPt(currPt); polyline.EndTime = time; // Switch to fixed length if choosen in UI if (discreteLength && (polyline.GetPointCount() > this.maxLengthPath)) { polyline.RemoveFirstPt(); } }
/// <summary> /// Initializes standard values of drawing elements /// </summary> private void InitializeElements() { try { this.penGazeCursor = new Pen(Properties.Settings.Default.GazeCursorColor, Properties.Settings.Default.GazeCursorWidth); this.penGazeCursor.DashStyle = Properties.Settings.Default.GazeCursorStyle; this.penGazePath = new Pen(Properties.Settings.Default.GazePathColor, Properties.Settings.Default.GazePathWidth); this.penGazePath.DashStyle = Properties.Settings.Default.GazePathStyle; this.penGazePath.LineJoin = LineJoin.Round; this.penGazeFixation = new Pen(Properties.Settings.Default.GazeFixationsPenColor, Properties.Settings.Default.GazeFixationsPenWidth); this.penGazeFixation.DashStyle = Properties.Settings.Default.GazeFixationsPenStyle; this.penGazeFixationConnection = new Pen(Properties.Settings.Default.GazeFixationConnectionsPenColor, Properties.Settings.Default.GazeFixationConnectionsPenWidth); this.penGazeFixation.DashStyle = Properties.Settings.Default.GazeFixationConnectionsPenStyle; this.penGazeNoData = new Pen(Properties.Settings.Default.GazeNoDataColor, Properties.Settings.Default.GazeNoDataWidth); this.penGazeNoData.DashStyle = Properties.Settings.Default.GazeNoDataStyle; this.penMouseCursor = new Pen(Properties.Settings.Default.MouseCursorColor, Properties.Settings.Default.MouseCursorWidth); this.penMouseCursor.DashStyle = Properties.Settings.Default.MouseCursorStyle; this.penMousePath = new Pen(Properties.Settings.Default.MousePathColor, Properties.Settings.Default.MousePathWidth); this.penMousePath.DashStyle = Properties.Settings.Default.MousePathStyle; this.penMousePath.LineJoin = LineJoin.Round; this.penMouseFixation = new Pen(Properties.Settings.Default.MouseFixationsPenColor, Properties.Settings.Default.MouseFixationsPenWidth); this.penMouseFixation.DashStyle = Properties.Settings.Default.MouseFixationsPenStyle; this.penMouseFixationConnection = new Pen(Properties.Settings.Default.MouseFixationConnectionsPenColor, Properties.Settings.Default.MouseFixationConnectionsPenWidth); this.penMouseFixationConnection.DashStyle = Properties.Settings.Default.MouseFixationConnectionsPenStyle; this.gazePicEllipse = new VGEllipse(ShapeDrawAction.Fill, this.GrayBrush); this.gazePicEllipse.Inverted = true; this.gazePicEllipse.ElementGroup = "Default"; this.mousePicEllipse = new VGEllipse(ShapeDrawAction.Fill, this.GrayBrush); this.mousePicEllipse.Inverted = true; this.mousePicEllipse.ElementGroup = "Default"; this.gazeRawPolyline = new VGPolyline(ShapeDrawAction.Edge, this.penGazePath, VGStyleGroup.RPL_PEN_GAZE_PATH, string.Empty, string.Empty); this.gazeRawPolyline.ElementGroup = "Default"; this.mouseRawPolyline = new VGPolyline(ShapeDrawAction.Edge, this.penMousePath, VGStyleGroup.RPL_PEN_MOUSE_PATH, string.Empty, string.Empty); this.mouseRawPolyline.ElementGroup = "Default"; this.gazeFixEllipse = new VGEllipse(ShapeDrawAction.Edge, this.penGazeFixation, VGStyleGroup.RPL_PEN_GAZE_FIX, string.Empty, string.Empty); this.gazeFixEllipse.ElementGroup = "Default"; this.mouseFixEllipse = new VGEllipse(ShapeDrawAction.Edge, this.penMouseFixation, VGStyleGroup.RPL_PEN_MOUSE_FIX, string.Empty, string.Empty); this.mouseFixEllipse.ElementGroup = "Default"; this.gazeFixConPolyline = new VGPolyline(ShapeDrawAction.Edge, this.penGazeFixationConnection, VGStyleGroup.RPL_PEN_GAZE_FIXCON, string.Empty, string.Empty); this.gazeFixConPolyline.ElementGroup = "Default"; this.mouseFixConPolyline = new VGPolyline(ShapeDrawAction.Edge, this.penMouseFixationConnection, VGStyleGroup.RPL_PEN_MOUSE_FIXCON, string.Empty, string.Empty); this.mouseFixConPolyline.ElementGroup = "Default"; this.gazeFixConLine = new VGLine(ShapeDrawAction.Edge, this.penGazeFixationConnection, VGStyleGroup.RPL_PEN_GAZE_FIXCON, string.Empty, string.Empty); this.gazeFixConLine.ElementGroup = "Default"; this.mouseFixConLine = new VGLine(ShapeDrawAction.Edge, this.penMouseFixationConnection, VGStyleGroup.RPL_PEN_MOUSE_FIXCON, string.Empty, string.Empty); this.mouseFixConLine.ElementGroup = "Default"; var gazeCursorSize = (float)Properties.Settings.Default.GazeCursorSize; var gazeCursorType = (VGCursor.DrawingCursors)Enum.Parse( typeof(VGCursor.DrawingCursors), Properties.Settings.Default.GazeCursorType); this.gazeCursor = new VGCursor(this.penGazeCursor, gazeCursorType, gazeCursorSize, VGStyleGroup.RPL_PEN_GAZE_CURSOR); this.gazeCursor.ElementGroup = "Default"; var mouseCursorSize = (float)Properties.Settings.Default.MouseCursorSize; var mouseCursorType = (VGCursor.DrawingCursors)Enum.Parse( typeof(VGCursor.DrawingCursors), Properties.Settings.Default.MouseCursorType); this.mouseCursor = new VGCursor(this.penMouseCursor, mouseCursorType, mouseCursorSize, VGStyleGroup.RPL_PEN_MOUSE_CURSOR); this.mouseCursor.ElementGroup = "Default"; if (Document.ActiveDocument != null) { this.visiblePartOfScreen = new VGRectangle( ShapeDrawAction.Edge, Pens.Red, Document.ActiveDocument.PresentationSizeRectangle); this.visiblePartOfScreen.Visible = false; } } catch (Exception ex) { ExceptionMethods.HandleException(ex); } }
/// <summary> /// This method returns an default colored <see cref="VGElement"/> /// that represents the object in the database described by the three parameters /// </summary> /// <param name="shapeType">A <see cref="String"/> with the shape type Rectangle, Ellipse or Polyline</param> /// <param name="shapeName">A <see cref="String"/> with the shape name</param> /// <param name="shapeGroup">A <see cref="String"/> with the shapes group</param> /// <param name="strPtList">A <see cref="String"/> with the list of points to be converted /// with <see cref="ObjectStringConverter.StringToPointFList(String)"/></param> /// <returns>A <see cref="VGElement"/> that represents the object in the database described by the three parameters.</returns> public static VGElement GetVGElementFromDatabase( string shapeType, string shapeName, string shapeGroup, string strPtList) { // Create the shape depending on ShapeType RectangleF boundingRect = new RectangleF(); List<PointF> pointList = ObjectStringConverter.StringToPointFList(strPtList); switch (shapeType) { case "Rectangle": boundingRect.Location = pointList[0]; boundingRect.Width = pointList[2].X - pointList[0].X; boundingRect.Height = pointList[2].Y - pointList[0].Y; // Create Rect with defined stroke VGRectangle newRect = new VGRectangle( ShapeDrawAction.NameAndEdge, Pens.Red, SystemFonts.MenuFont, Color.Black, boundingRect, VGStyleGroup.None, shapeName, shapeGroup); newRect.TextAlignment = VGAlignment.Center; return newRect; case "Ellipse": boundingRect.Location = pointList[0]; boundingRect.Width = pointList[2].X - pointList[0].X; boundingRect.Height = pointList[2].Y - pointList[0].Y; // Create Rect with defined stroke VGEllipse newEllipse = new VGEllipse( ShapeDrawAction.NameAndEdge, Pens.Red, SystemFonts.MenuFont, Color.Black, boundingRect, VGStyleGroup.None, shapeName, shapeGroup); newEllipse.TextAlignment = VGAlignment.Center; return newEllipse; case "Polyline": // Create Polyline with defined stroke VGPolyline newPolyline = new VGPolyline( ShapeDrawAction.NameAndEdge, Pens.Red, SystemFonts.MenuFont, Color.Black, VGStyleGroup.None, shapeName, shapeGroup); newPolyline.TextAlignment = VGAlignment.Center; foreach (PointF point in pointList) { newPolyline.AddPt(point); } newPolyline.ClosePolyline(); boundingRect = newPolyline.Bounds; return newPolyline; } return null; }
/// <summary> /// This method converts the AOI table with areas of interest from the database /// into a list of <see cref="VGElement"/>s. /// </summary> /// <param name="aoiTable">The <see cref="DataTable"/> with the AOIs.</param> /// <returns>A <see cref="List{VGElement}"/> with the shapes.</returns> protected virtual VGElementCollection GetAOIElements(DataTable aoiTable) { Pen defaultPen = new Pen(Properties.Settings.Default.AOIStandardColor, Properties.Settings.Default.AOIStandardWidth); Pen targetPen = new Pen(Properties.Settings.Default.AOITargetColor, Properties.Settings.Default.AOITargetWidth); Pen searchRectPen = new Pen(Properties.Settings.Default.AOISearchRectColor, Properties.Settings.Default.AOISearchRectWidth); Font defaultFont = (Font)Properties.Settings.Default.AOIStandardFont.Clone(); Font targetFont = (Font)Properties.Settings.Default.AOITargetFont.Clone(); Font searchRectFont = (Font)Properties.Settings.Default.AOISearchRectFont.Clone(); Color defaultFontColor = Properties.Settings.Default.AOIStandardFontColor; Color targetFontColor = Properties.Settings.Default.AOITargetFontColor; Color searchRectFontColor = Properties.Settings.Default.AOISearchRectFontColor; VGElementCollection aoiList = new VGElementCollection(); int counter = 0; try { foreach (DataRow row in aoiTable.Rows) { string strPtList = row["ShapePts"].ToString(); string shapeName = row["ShapeName"].ToString(); Pen usedPen = defaultPen; Font usedFont = defaultFont; Color usedFontColor = defaultFontColor; VGStyleGroup usedStyleGroup = VGStyleGroup.AOI_NORMAL; List<PointF> pointList = ObjectStringConverter.StringToPointFList(strPtList); string usedElementGroup = row["ShapeGroup"].ToString(); switch (usedElementGroup) { case "Target": usedPen = targetPen; usedFont = targetFont; usedFontColor = targetFontColor; usedStyleGroup = VGStyleGroup.SCA_GRID_AOI; break; case "SearchRect": usedPen = searchRectPen; usedFont = searchRectFont; usedFontColor = searchRectFontColor; usedStyleGroup = VGStyleGroup.SCA_GRID_AOI; break; default: usedPen = defaultPen; usedFont = defaultFont; usedFontColor = defaultFontColor; usedStyleGroup = VGStyleGroup.SCA_GRID_AOI; break; } // Create the shape depending on ShapeType RectangleF boundingRect = new RectangleF(); switch (row["ShapeType"].ToString()) { case "Rectangle": boundingRect.Location = pointList[0]; boundingRect.Width = pointList[2].X - pointList[0].X; boundingRect.Height = pointList[2].Y - pointList[0].Y; // Create Rect with defined stroke VGRectangle newRect = new VGRectangle( ShapeDrawAction.NameAndEdge, usedPen, usedFont, usedFontColor, boundingRect, usedStyleGroup, shapeName, usedElementGroup); aoiList.Add(newRect); break; case "Ellipse": boundingRect.Location = pointList[0]; boundingRect.Width = pointList[2].X - pointList[0].X; boundingRect.Height = pointList[2].Y - pointList[0].Y; // Create Rect with defined stroke VGEllipse newEllipse = new VGEllipse( ShapeDrawAction.NameAndEdge, usedPen, usedFont, usedFontColor, boundingRect, usedStyleGroup, shapeName, usedElementGroup); aoiList.Add(newEllipse); break; case "Polyline": // Create Polyline with defined stroke VGPolyline newPolyline = new VGPolyline( ShapeDrawAction.NameAndEdge, usedPen, usedFont, usedFontColor, usedStyleGroup, shapeName, usedElementGroup); foreach (PointF point in pointList) { newPolyline.AddPt(point); } newPolyline.ClosePolyline(); aoiList.Add(newPolyline); boundingRect = newPolyline.Bounds; break; } counter++; } } catch (Exception ex) { ExceptionMethods.HandleException(ex); } return aoiList; }
/// <summary> /// Initializes a new instance of the VGPolyline class. /// Clone Constructor. Creates new polyline element that is /// identical to the given polyline. /// </summary> /// <param name="newPolyline">Polyline to clone</param> private VGPolyline(VGPolyline newPolyline) : base( newPolyline.ShapeDrawAction, newPolyline.Pen, newPolyline.Brush, newPolyline.Font, newPolyline.FontColor, newPolyline.Bounds, newPolyline.StyleGroup, newPolyline.Name, newPolyline.ElementGroup, newPolyline.Sound) { this.Path = new GraphicsPath(); this.Path = newPolyline.GetPathCopy(); }
/// <summary> /// This static method calculates the sum of fixation connections, /// which is a gaze path length. /// </summary> /// <param name="fixationTable">A <see cref="DataTable"/> with the fixations /// to use.</param> /// <returns>A <see cref="Single"/> with the path length in pixel.</returns> private static float CalcPathLengthOfFixationConnections(DataTable fixationTable) { // Fixation PathLength // no fixation available float pathLengthGaze = -1f; VGPolyline polylineGaze = new VGPolyline(ShapeDrawAction.Edge, Pens.Green); foreach (DataRow row in fixationTable.Rows) { float gazeX = !row.IsNull("PosX") ? Convert.ToSingle(row["PosX"]) : 0; float gazeY = !row.IsNull("PosY") ? Convert.ToSingle(row["PosY"]) : 0; if (gazeX != 0 || gazeY != 0) { polylineGaze.AddPt(new PointF(gazeX, gazeY)); } } if (polylineGaze.GetPointCount() >= 2) { // Connections available pathLengthGaze = polylineGaze.GetLength(); } else if (polylineGaze.GetPointCount() == 1) { // Only one fixation, so no connections pathLengthGaze = 0; } return pathLengthGaze; }
/// <summary> /// This static method calculates the raw data related variables as there /// are distance of gaze and mouse path along with loss and out of /// monitor values. /// </summary> /// <param name="subjectName">A <see cref="string"/> with the subject name.</param> /// <param name="trialSequence">An <see cref="int"/> with the trial sequence number.</param> /// <param name="countBlinkLoss">Ref. Counts the samples the are lost due to blinks.</param> /// <param name="countOutOfMonitorLoss">Ref. Counts the samples the are lost due to out of monitor samples.</param> /// <param name="pathLengthMouse">Ref. Returns the path length of the mouse path.</param> /// <param name="averageDistance">Ref. Returns the average distance of gaze and mouse path in pixel.</param> /// <param name="countSamples">Ref. Counts the number of samples.</param> private static void CalcRawDataRelatedVariables( string subjectName, int trialSequence, ref int countBlinkLoss, ref int countOutOfMonitorLoss, ref float pathLengthMouse, ref float averageDistance, ref int countSamples) { // Get RawData DataTable rawDataTable = Queries.GetRawDataBySubjectAndTrialSequenceWithoutEvents(subjectName, trialSequence); // In this section only mouse polyline is created, // because the gaze path length is calculated as the // distance between fixations to avoid // including microsaccade movements. VGPolyline polylineMouse = new VGPolyline(ShapeDrawAction.Edge, Pens.Red); float sumDistance = 0; int distancesCount = 0; // Loop RawData and drawPolyline foreach (DataRow row in rawDataTable.Rows) { PointF? newGazePoint; SampleValidity isGazeValidData = Queries.GetGazeData( row, Document.ActiveDocument.PresentationSize, out newGazePoint); switch (isGazeValidData) { case SampleValidity.Valid: break; case SampleValidity.Empty: countBlinkLoss++; break; case SampleValidity.Null: countBlinkLoss++; break; case SampleValidity.OutOfStimulus: countOutOfMonitorLoss++; break; } PointF? newMousePoint; SampleValidity isMouseValidData = Queries.GetMouseData( row, Document.ActiveDocument.PresentationSize, out newMousePoint); switch (isMouseValidData) { case SampleValidity.Valid: case SampleValidity.Empty: case SampleValidity.OutOfStimulus: // mouse is always detected and never out of screen polylineMouse.AddPt(newMousePoint.Value); break; case SampleValidity.Null: break; } // Calculate Distance of Gaze And Mouse Path if (isGazeValidData == SampleValidity.Valid && (isMouseValidData == SampleValidity.Valid || isMouseValidData == SampleValidity.Empty)) { sumDistance += VGPolyline.Distance(newGazePoint.Value, newMousePoint.Value); distancesCount++; } } if (polylineMouse.GetPointCount() >= 2) { pathLengthMouse = polylineMouse.GetLength(); } else if (polylineMouse.GetPointCount() == 1) { pathLengthMouse = 0; // No Movement in MouseData } if (distancesCount > 0) { averageDistance = sumDistance / distancesCount; } else { averageDistance = -1; } countSamples = rawDataTable.Rows.Count; rawDataTable.Dispose(); }