public static void DeleteInstruction(RsMoveInstruction instruction)
        {
            var path      = (RsPathProcedure)instruction.Parent;
            var target    = instruction.GetToTarget();
            var robTarget = instruction.GetToRobTarget();
            var task      = (RsTask)target.Parent;

            path.Instructions.Remove(instruction);
            task.Targets.Remove(target);
            task.DataDeclarations.Remove(robTarget);
        }
        public static void MoveInstructionToFrame(RsMoveInstruction instruction, Matrix4 frame)
        {
            if (instruction == null)
            {
                return;
            }

            var target = instruction.GetToTarget();

            target.Transform.GlobalMatrix = frame;
        }
Exemple #3
0
        RsTarget GetTarget(RsMoveInstruction instruction)
        {
            RsTarget target;

            if (!_targets.TryGetValue(instruction, out target))
            {
                target = instruction.GetToTarget();
                _targets[instruction] = target;
            }
            return(target);
        }
Exemple #4
0
        Axis ComputeBrushAxis()
        {
            var    path      = (RsPathProcedure)_trackedMoveInstruction.Parent;
            int    idx       = path.Instructions.IndexOf(_trackedMoveInstruction);
            var    prevInstr = path.Instructions.Where((mi, i) => i < idx).OfType <RsMoveInstruction>().Where(m => m.GetToTarget() != null).LastOrDefault();
            var    p1        = prevInstr.GetToTarget().Transform.Matrix.Translation;
            var    p2        = _trackedMoveInstruction.GetToTarget().Transform.Matrix.Translation;
            var    dir       = p2 - p1;
            double x         = Math.Abs(dir.x);
            double y         = Math.Abs(dir.y);
            double z         = Math.Abs(dir.z);
            var    plane     = Axis.X;

            if (y > x)
            {
                plane = Axis.Y;
            }
            if (z > x && z > y)
            {
                plane = Axis.Z;
            }
            return(plane);
        }
Exemple #5
0
        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);
                    }
                }
            }
        }