public override void Update(VrUpdateArgs args) { if (_painter == null) { return; } var session = args.Session; var input = session.SemanticInput(); // Cycle colors each time trigger is pressed if (input.SelectClick) { _curColorIndex++; if (_curColorIndex >= _colors.Length) { _curColorIndex = 0; } _painter.Color = _colors[_curColorIndex]; UpdatePreview(session); } if (input.IsSelectPressed) { var transform = session.RightController.PointerTransform; transform.CleanRigid(); //:TODO: Should not be needed. Review _painter.Render(transform); } if (input.DeleteClick) { _painter.Clear(); } }
public override void Update(VrUpdateArgs args) { var session = args.Session; if (session.SemanticInput().IsSelectPressed) { var transform = session.RightController.Transform; transform.CleanRigid(); //:TODO: Should not be needed. Review transform = transform * _attachOffset * Station.ActiveStation.ActiveTask.ActiveTool.Frame.Matrix; if (_pathBuilder == null) { _pathBuilder = new PathBuilder(Station.ActiveStation); _previewTrace = Station.ActiveStation.TemporaryGraphics.DrawTrace(transform.Translation, 1, 100); } else { _previewTrace.ContinueTrace(transform.Translation, System.Drawing.Color.LightYellow, false); } session.RightController.HapticFeedback(1); _pathBuilder.AddTransform(transform); } else { if (_pathBuilder != null) { _pathBuilder.Finish(); _pathBuilder = null; _previewTrace.Delete(); _previewTrace = null; } } }
public override void Update(VrUpdateArgs args) { var session = args.Session; var input = session.SemanticInput(); Matrix4 pointer = PointerFilter(session.RightController.PointerTransform); var hitResult = GetClosestHit(pointer.Translation); //KNARK: Review Deletebutton usage (used to capture on down, execute on up) /*if(input.SelectClick || input.DeleteClick) * { * _pressedAt = pointer; * } * else */if (input.IsSelectPressed && !_dragging) { _dragging = true; _hitResult = hitResult; var eventArgs = new VrEventArgs(pointer, _hitResult); BeginDrag?.Invoke(eventArgs); if (eventArgs.CreatedObject != null) { _hitResult = eventArgs.CreatedObject(); } } else if (_dragging && input.IsSelectPressed) { DeltaDrag?.Invoke(new VrEventArgs(pointer, _hitResult)); } else if (!input.IsSelectPressed && _dragging) { _dragging = false; EndDrag?.Invoke(new VrEventArgs(pointer, _hitResult)); } //else if (_gripPressed && !session.RightController.InputState.GripPressed // && CloseEnough(_pressedAt, pointer)) else if (input.DeleteClick) { AlternateClick?.Invoke(new VrEventArgs(pointer, hitResult)); } else if (hitResult != null) { HoverObject?.Invoke(new VrEventArgs(pointer, hitResult)); } }
public override void Update(VrUpdateArgs args) { var session = args.Session; _newHighlightTarget = null; _forceUpdateLine = false; base.Update(args); var view = (GraphicView)GraphicControl.ActiveGraphicControl.GetView(); if (_newHighlightTarget != _highlightTarget) { ClearHover(); _highlightTarget = _newHighlightTarget; _newHighlightTarget = null; _highlightTarget?.Highlight(System.Drawing.Color.FromArgb(128, 255, 255, 255)); if (_highlightTarget != null) { _frameGfx.Visible = false; _pointerToSelGfx = view.OpenVRAddAttachedLine( VrAttachedTo.RightController, session.RightController.PointerOffsetTransform.Translation, System.Drawing.Color.White, VrAttachedTo.Station, _highlightTarget.Transform.GlobalMatrix.Translation, System.Drawing.Color.Orange); } else { _frameGfx.Visible = true; if (_pointerToSelGfx != IntPtr.Zero) { view.OpenVRRemoveAttachedLine(_pointerToSelGfx); } _pointerToSelGfx = IntPtr.Zero; } } else if (_forceUpdateLine && _highlightTarget != null) { view.OpenVRRemoveAttachedLine(_pointerToSelGfx); _pointerToSelGfx = view.OpenVRAddAttachedLine( VrAttachedTo.RightController, session.RightController.PointerOffsetTransform.Translation, System.Drawing.Color.White, VrAttachedTo.Station, _highlightTarget.Transform.GlobalMatrix.Translation, System.Drawing.Color.White); } }
public override void Update(VrUpdateArgs args) { var session = args.Session; Vector3 xorigin = _controller.PointerOffsetTransform.Translation; Vector3 btrans = _controller.PointerOffsetTransform.Translation; var rwand = VrEnvironment.Session.RightController as VrViveWandController; if (rwand.InputState.IsTouchPadTouched) { double u = rwand.InputState.TouchPadPosition.u; double uPrev = rwand.PreviousInputState.TouchPadPosition.u; if ((u - uPrev) < 0 && Math.Abs(u - uPrev) >= 0.1 && btrans.x > xorigin.x) { btrans.x = btrans.x - 10; _pospointer.Delete(); } else if ((u - uPrev) >= 0 && Math.Abs(u - uPrev) >= 0.1) { btrans.x = btrans.x + 10; _pospointer.Delete(); } } Matrix4 boxpos = _controller.PointerOffsetTransform; boxpos.Translation = new Vector3(btrans.x, btrans.y, btrans.z); Vector3 box = new Vector3(.01, .01, .01); _pospointer = _controller.TemporaryGraphics.DrawBox(boxpos, box, Color.DarkBlue); }
public override void Update(VrUpdateArgs args) { var session = args.Session; DeleteBrushTempGfx(); var input = session.SemanticInput(); if (_trackedBrushInstruction != null) { if (input.IsSelectPressed) { // Drag brush var relatedMI = FindRelatedMoveInstruction(_trackedBrushInstruction); if (relatedMI != null) { Matrix4 wobjMat = relatedMI.GetWorkObject().ObjectFrame.GlobalMatrix; Vector3 point = wobjMat.InverseRigid().MultiplyPoint(session.RightController.PointerTransform.Translation); var pos = PathEditingHelper.GetBrushEventPosition(_trackedBrushInstruction); string val = ((int)(point[(int)pos.Item1 - 1] * 1000)).ToString(); if (val != pos.Item2.Value) { WithUndoAppend("VR Move SetBrush", () => { pos.Item2.Value = val; }); } _brushSelector.Caption = _trackedBrushInstruction.DisplayName; } return; } } var hitObj = GetHitObject(session.RightController.PointerTransform.Translation); var trackedMoveInstruction = hitObj?.Item1 as RsMoveInstruction; if (trackedMoveInstruction != null) { //:TODO: Supported for PaintC?? if (trackedMoveInstruction.Name != "PaintL" && trackedMoveInstruction.Name != "PaintC" || trackedMoveInstruction.GetToTarget() == null) { trackedMoveInstruction = null; } } var trackedBrushInstr = hitObj?.Item1 as RsActionInstruction; if (trackedBrushInstr != null && !string.Equals(trackedBrushInstr.Name, "SetBrush", StringComparison.OrdinalIgnoreCase)) { trackedBrushInstr = null; } if (trackedMoveInstruction != _trackedMoveInstruction) { _trackedMoveInstruction = trackedMoveInstruction; if (_brushSelector == null) { _brushSelector = new VrScrollSelector(session.RightController, "", _brushValues, _lastBrushNum); } _brushSelector.Caption = (_trackedMoveInstruction != null) ? "Add SetBrush" : "Brush Number"; } else if (trackedBrushInstr != _trackedBrushInstruction || _brushSelector == null) { if (_brushSelector != null) { _brushSelector.Dispose(); } _trackedBrushInstruction = trackedBrushInstr; if (_trackedBrushInstruction != null) { var numarg = _trackedBrushInstruction.InstructionArguments["BrushNumber"]; _brushSelector = new VrScrollSelector(session.RightController, _trackedBrushInstruction.DisplayName, _brushValues, numarg.Value); } else { _brushSelector = new VrScrollSelector(session.RightController, (_trackedMoveInstruction != null) ? "Add SetBrush" : "Brush Number", _brushValues, _lastBrushNum); } } if (_trackedBrushInstruction != null && input.DeleteClick) { var path = (RsPathProcedure)_trackedBrushInstruction.Parent; WithUndo("VR Delete SetBrush", () => { path.Instructions.Remove(_trackedBrushInstruction); }); _trackedBrushInstruction = null; return; } bool brushNumUpdated = _brushSelector.Update(); if (brushNumUpdated) { _lastBrushNum = _brushSelector.SelectedValue; } if (_trackedMoveInstruction != null && _trackedBrushInstruction == null) { Matrix4 wobjMat = _trackedMoveInstruction.GetWorkObject().ObjectFrame.GlobalMatrix; CreateBrushPlanePreview(hitObj.Item2, wobjMat); if (input.SelectClick) { Vector3 point = wobjMat.InverseRigid().MultiplyPoint(hitObj.Item2); var axis = ComputeBrushAxis(); int val = (int)(point[(int)axis - 1] * 1000); WithUndo("VR Create SetBrush", () => { PathEditingHelper.CreateSetBrush( _trackedMoveInstruction, axis, val, _brushSelector.SelectedValue); } ); DeleteBrushTempGfx(); } } else if (_trackedBrushInstruction != null && brushNumUpdated) { var numarg = _trackedBrushInstruction.InstructionArguments["BrushNumber"]; WithUndo("VR Edit SetBrush", () => { numarg.Value = _brushSelector.SelectedValue; }); _brushSelector.Caption = _trackedBrushInstruction.DisplayName; } }
public override void Update(VrUpdateArgs args) { if (Simulator.State == SimulationState.Running) { _recSig = true; RecData.signalList.Clear(); } else { var session = args.Session; var input = session.SemanticInput(); var rwand = _rcontroller as VrViveWandController; if (rwand == null) { return; } var lwand = _lcontroller as VrViveWandController; Station station = Project.ActiveProject as Station; if (RecData.JointValuesList.Count() < 1) { return; } if (rwand.InputState.IsTouchPadTouched) { press = false; double u = rwand.InputState.TouchPadPosition.u; double uPrev = rwand.PreviousInputState.TouchPadPosition.u; if ((u - uPrev) < 0 && Math.Abs(u - uPrev) >= 0.02) { if (RecData.JointValuesList.Count > 0) { station.TemporaryGraphics.Remove(_GraphPointer); _GraphPointer.Delete(); RecData.PrevPosition(); AddGfxPointer(); } else { Logger.AddMessage(new LogMessage("No positions recorded, run simulation first")); } } else if ((u - uPrev) >= 0 && Math.Abs(u - uPrev) >= 0.02) { // Flytt til neste pos if (RecData.JointValuesList.Count > 0) { station.TemporaryGraphics.Remove(_GraphPointer); _GraphPointer.Delete(); AddGfxPointer(); RecData.NextPosition(); } else { Logger.AddMessage(new LogMessage("No positions recorded, run simulation first")); } } } else if (input.IsSelectPressed && press) { if (_recSig) { RecData.Ysignal(); //::TODO:: Bedre logikk for kjøring av signal _recSig = false; } Logger.AddMessage(new LogMessage($"ListLentgth: {RecData.ToolValuesList.Count}")); if (atTrack) { if (TrackgraphList.Count() >= 0) { foreach (TemporaryGraphic j in TrackgraphList) { station.TemporaryGraphics.Remove(j); } station.TemporaryGraphics.RemoveAll(); TrackgraphList.Clear(); } Logger.AddMessage(new LogMessage($"listB: {RecData.listB.Count()}")); Logger.AddMessage(new LogMessage($"signalList: {RecData.signalList[0].Count()}")); int sig = GetCurrentSignal() + 1; SetCurrentSignal(sig); AddGfxAtTrack(); AddGfxGraph(); AddGfxPointer(); // Not implemented yet station.ActiveTask.ActivePathProcedure.Visible = false; RsPathProcedureCollection a = station.ActiveTask.PathProcedures; foreach (RsPathProcedure b in a) { b.Visible = false; } atTrack = false; } else if (!atTrack) { if (TrackgraphList.Count() >= 0) { foreach (TemporaryGraphic j in TrackgraphList) { station.TemporaryGraphics.Remove(j); } TrackgraphList.Clear(); station.TemporaryGraphics.RemoveAll(); _rcontroller.TemporaryGraphics.RemoveAll(); // _rcontroller.TemporaryGraphics.RemoveAll(); } //int sig = GetCurrentSignal() + 1; //SetCurrentSignal(sig); // AddGfxAtTrack(); atTrack = true; } press = false; } else if (!input.IsSelectPressed && !press) { press = true; } } }
public override void Update(VrUpdateArgs args) { var session = args.Session; // KNARK - Rift var wand = session.RightController as VrViveWandController; if (wand == null) { return; } RsMoveInstruction mi = null; if (_currentMoveInstruction != null) { // "Sticky" selection - don't remove the UI until 1) user releases the touchpad and 2) moves controller a bit away from path //:NOTE: Sticky distance can be annoying when editing nearby segments - review. Use shorter dist if another MI is closer/picked? if (wand.InputState.IsTouchPadTouched || _pickedPos.Distance(wand.PointerTransform.Translation) < _stickyDist && _hasScrolled) { mi = _currentMoveInstruction; } } if (mi == null && !wand.InputState.IsGripPressed && !wand.InputState.IsTouchPadPressed && !wand.InputState.IsTriggerPressed) { mi = GetPickedMoveInstruction(session); } if (mi != _currentMoveInstruction) { // Selected MI has changed, delete any old UI and create a new if needed if (_selector != null) { _selector.Dispose(); _selector = null; _hasScrolled = false; } _currentMoveInstruction = mi; if (mi != null) { _pickedPos = session.RightController.PointerTransform.Translation; var task = mi.GetInternalParentOfType <RsTask>(); //:TODO: Some paint stations have too many speeddatas for this type of UI to make sense. How to handle? string taskName = task.Name; if (string.IsNullOrEmpty(taskName)) { taskName = "T_ROB1"; // station/dummy tasks } var speeds = task.GetTaskContext().SymbolTable.GetVisibleDataDeclarations("/RAPID/" + taskName, "speeddata") .Where(s => !s.Name.StartsWith("vrot")) //??? .Take(60) //TEST .Select(s => s.Name) .ToList(); speeds.Sort(ABB.Robotics.RobotStudio.UI.UIServices.NaturalOrderSort); string speed = GetSpeedArg(mi).Value; int tmp = speeds.FindIndex(s => s.Equals(speed, StringComparison.OrdinalIgnoreCase)); if (tmp == -1) { speeds.Insert(0, "Unknown"); speed = speeds[0]; } else { speed = speeds[tmp]; // fix capitalization } string title = "->" + mi.GetToTarget().Name; // TEST - what do we want here? _selector = new VrScrollSelector(session.RightController, title, speeds, speed); _newSelection = true; } } else if (_currentMoveInstruction != null && _selector != null) { if (wand.InputState.IsTouchPadTouched) { _hasScrolled = true; } // Same selection - update _selector and apply results bool ok = _selector.Update(); if (ok && _selector.SelectedValue != "Unknown") { Action foo = () => { GetSpeedArg(_currentMoveInstruction).Value = _selector.SelectedValue; }; if (_newSelection) { _newSelection = false; WithUndo("VR Edit Speed", foo); } else { WithUndoAppend("VR Edit Speed", foo); } } } }