Esempio n. 1
0
        public override bool Equals(object obj)
        {
            Vctr vector = obj as Vctr;

            return((vector != null) &&
                   Equals(vector.X, vector.Y, vector.Z));
        }
Esempio n. 2
0
        private void ButtonExecute_Click(object sender, EventArgs e)
        {
            if (!IsRobotActive())
            {
                return;
            }

            Vctr   movementVector = new Vctr();
            string str_coord;

            double[] validatedCoordsList = { 0, 0, 0 };
            selection = structure.Selections.Get(IRobotObjectType.I_OT_NODE);

            if (selection.Count == 0)
            {
                ErrorDialog("No nodes have been selected", "ERROR: No selection");
                return;
            }

            // If Relative to Node No. has been selected, fetch coordinates
            // of the node referred to in the input field
            if (radioRelativeNode.Checked)
            {
                try
                {
                    str_coord = ReturnCoordString(helpers.ValidateNodeID(coordInput.Text), comboBoxCoords.Text);
                }
                catch (ArgumentOutOfRangeException)
                {
                    ErrorDialog("Node does not exist", "ERROR: Node Not Found");
                    return;
                }
                catch (ArgumentException)
                {
                    ErrorDialog("Invalid node number input", "ERROR: Invalid Node Input");
                    return;
                }
            }
            else
            {
                str_coord = coordInput.Text.Replace(" ", "");

                // Validate coordinate inputs before any changes are made
                try
                {
                    if (comboBoxCoords.SelectedItem.ToString() == "XYZ")
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            validatedCoordsList[i] = helpers.ValidateSingleCoord(str_coord, i);
                        }
                    }
                    else
                    {
                        if (str_coord.Contains(","))
                        {
                            ErrorDialog("Please enter a single coordinate into the input field", "ERROR: Invalid Coordinates");
                            return;
                        }
                        else
                        {
                            validatedCoordsList[0] = helpers.ValidateSingleCoord(str_coord);
                        }
                    }
                }
                catch (ArgumentException)
                {
                    ErrorDialog("Invalid coordinates input in text box. Please use a format of 'x,y,z'", "ERROR: Invalid Coordinates");
                    return;
                }
            }

            for (int i = 1; i <= selection.Count; i++)
            {
                var node = (IRobotNode)nodes.Get(selection.Get(i));

                movementVector.X = node.X;
                movementVector.Y = node.Y;
                movementVector.Z = node.Z;

                if (comboBoxCoords.SelectedItem.ToString() == "XYZ")
                {
                    for (int j = 0; j < 3; j++)
                    {
                        movementVector.Move(j, validatedCoordsList[j], radioRelative.Checked);
                    }
                }
                else
                {
                    movementVector.Move(comboBoxCoords.SelectedItem.ToString(), validatedCoordsList[0], radioRelative.Checked);
                }

                if (radioButtonMove.Checked)
                {
                    node.X = movementVector.X;
                    node.Y = movementVector.Y;
                    node.Z = movementVector.Z;
                }
                else
                {
                    nodes.Create(nodes.FreeNumber, movementVector.X, movementVector.Y, movementVector.Z);
                }
            }

            MessageBox.Show("Finished modifying " + selection.Count + " nodes.", "Action Completed");
        }