private void UnregisterLinks(IToolElement tool) { IMachineElement me = tool; while (me.Parent != null) { if ((me.LinkToParent != null) && (me.LinkToParent.MoveType == MDE.LinkMoveType.Linear)) { if (_links.TryGetValue(me.LinkToParent.Id, out int n)) { if (n <= 1) { me.LinkToParent.ValueChanged -= OnLinkValueChanged; _links.Remove(me.LinkToParent.Id); } else { _links[me.LinkToParent.Id] = n - 1; } } } me = me.Parent; } }
public void Register(IToolElement tool) { lock (_toolsLockObj) { _tools.Add(tool); RegisterLinks(tool); } }
public void Unregister(IToolElement tool) { lock (_toolsLockObj) { if (_tools.Contains(tool)) { UnregisterLinks(tool); _tools.Remove(tool); } } }
private void GetToolPositionAndDirection(IToolElement tool, Matrix3D panelMatrix, out Point3D position, out Vector3D direction) { var matrix = tool.GetChainTransformation(); var p1 = matrix.Transform(new Point3D()); var d1 = matrix.Transform(new Vector3D(0.0, 0.0, -1.0)); var p2 = panelMatrix.Transform(p1); var d2 = panelMatrix.Transform(d1); position = p2 + d2 * tool.WorkLength; direction = d2; }
private Point3D GetToolPosition(IToolElement tool) { if (tool.Parent is IToolholderElement th) { return(new Point3D(th.Position.X, th.Position.Y, th.Position.Z)); } else if (tool.Parent is IATToolholder atth) { return(GetToolPositionOnATTH(atth)); } else { throw new NotImplementedException(); } }
private void RegisterLinks(IToolElement tool) { IMachineElement me = tool; while (me.Parent != null) { if ((me.LinkToParent != null) && (me.LinkToParent.MoveType == MDE.LinkMoveType.Linear)) { if (_links.TryGetValue(me.LinkToParent.Id, out int n)) { _links[me.LinkToParent.Id] = n + 1; } else { _links.Add(me.LinkToParent.Id, 1); me.LinkToParent.ValueChanged += OnLinkValueChanged; } } me = me.Parent; } }
public void Unregister(IToolElement tool) => _toolsObserver.Unregister(tool);