/// <summary> /// Updates the object's screenLine /// </summary> /// <param name="obj"></param> /// <param name="_screenLine">the screen line. null, if no screen line exists</param> /// <returns>returns a screen line if a screenline needs to be created</returns> public static ScreenLine UpdateBeam(this SimulationObject obj, ScreenLine _screenLine, SimulationObject destination, Vector Direction) { if (obj.LastTableObject.RotationDefined) { if (_screenLine == null) { //recreate it _screenLine = new ScreenLine(obj.LastTableObject.Center, Direction * 1000, ScreenLine.EScreenLineElementType.Arrow); return _screenLine; } else { //just modify //If destination is set, let the screen line end.if not:infinite if (destination != null) { _screenLine.Source = obj.LastTableObject.Center; _screenLine.Destination = destination.LastTableObject.Center; } else { _screenLine.Source = obj.LastTableObject.Center; TPoint dest = new TPoint( Convert.ToInt32(obj.LastTableObject.Center.ScreenX + Direction.X * 1000), Convert.ToInt32(obj.LastTableObject.Center.ScreenY + Direction.Y * 1000), TPoint.PointCreationType.screen); _screenLine.Destination = dest; } } } return null; }
private void CreateScreenline() { TPoint center1 = _tableManager.TableObjects.Where( o2 => o2.TrackingStatus == TableObject.ETrackingStatus.LongTermTracked).ToList()[0].Center; TPoint center2 = _tableManager.TableObjects.Where( o2 => o2.TrackingStatus == TableObject.ETrackingStatus.LongTermTracked).ToList()[1].Center; if (sl == null) { _tableManager.DisplayManager.WorkThreadSafe((Action)(() => { sl = new ScreenLine(center1, center2); }), null); _tableManager.DisplayManager.AddElement(sl, ObjectTable.Code.Display.DisplayManager.DisplayLayer.middle); } sl.Source = center1; sl.Destination = center2; _tableManager.DisplayManager.WorkThreadSafe((Action) (() => sl.CalculateLine()), null); }