Exemplo n.º 1
0
        /// <summary>
        /// Executes the command.
        /// Moves the selected Item's Joint according to a given vector.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            List <Canguro.Model.Joint> selection = new List <Canguro.Model.Joint>();
            List <Item> selectedItems            = services.GetSelection();

            if (selectedItems.Count == 0)
            {
                return;
            }

            foreach (Item item in selectedItems)
            {
                if (item is Joint)
                {
                    selection.Add((Joint)item);
                }
                else if (item is LineElement)
                {
                    LineElement l = (LineElement)item;
                    if (!selection.Contains(l.I))
                    {
                        selection.Add(l.I);
                    }
                    if (!selection.Contains(l.J))
                    {
                        selection.Add(l.J);
                    }
                }
            }

            Microsoft.DirectX.Vector3 v;

            if (selection.Count > 0 && services.GetVector(out v))
            {
                foreach (Joint j in selection)
                {
                    j.X += v.X;
                    j.Y += v.Y;
                    j.Z += v.Z;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the command.
        /// Asks for selected Items repetitions and a Vector, and makes the copies.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Dictionary <Joint, Joint> joints     = new Dictionary <Joint, Joint>();
            Dictionary <Joint, Joint> jSelection = new Dictionary <Joint, Joint>();
            List <LineElement>        lines      = new List <LineElement>();
            List <LineElement>        lSelection = new List <LineElement>();
            List <AreaElement>        areas      = new List <AreaElement>();
            List <AreaElement>        aSelection = new List <AreaElement>();
            ItemList <Joint>          jList      = services.Model.JointList;
            ItemList <LineElement>    lList      = services.Model.LineList;
            ItemList <AreaElement>    aList      = services.Model.AreaList;
            Joint       nJoint;
            LineElement nLine;
            AreaElement nArea;

            List <Item> selection = services.GetSelection();

            if (selection.Count == 0)
            {
                return;
            }

            foreach (Item item in selection)
            {
                if (item is Joint)
                {
                    jSelection.Add((Joint)item, null);
                    joints.Add((Joint)item, null);
                }
                else if (item is LineElement)
                {
                    LineElement l = (LineElement)item;
                    lSelection.Add(l);
                    lines.Add(l);
                    if (!jSelection.ContainsKey(l.I))
                    {
                        jSelection.Add(l.I, null);
                        joints.Add(l.I, null);
                    }
                    if (!jSelection.ContainsKey(l.J))
                    {
                        jSelection.Add(l.J, null);
                        joints.Add(l.J, null);
                    }
                }
                else if (item is AreaElement)
                {
                    AreaElement a = (AreaElement)item;
                    aSelection.Add(a);
                    areas.Add(a);
                    for (int i = 0; i < ((a.J4 != null) ? 4 : 3); i++)
                    {
                        if (!jSelection.ContainsKey(a[i]))
                        {
                            jSelection.Add(a[i], null);
                            joints.Add(a[i], null);
                        }
                    }
                }
            }

            Microsoft.DirectX.Vector3 v;
            services.GetVector(out v);

            uint   n;
            string str = services.GetString(Culture.Get("getArrayRepetition"));

            n = Convert.ToUInt32(str);

            List <Joint>       newJoints = new List <Joint>();
            List <LineElement> newLines  = new List <LineElement>();
            List <AreaElement> newAreas  = new List <AreaElement>();

            for (int i = 1; i <= n; i++)
            {
                foreach (Joint j in joints.Keys)
                {
                    jList.Add(nJoint = new Joint(j.X + i * v.X, j.Y + i * v.Y, j.Z + i * v.Z));
                    nJoint.Masses    = j.Masses;
                    nJoint.DoF       = j.DoF;
                    jSelection[j]    = nJoint;
                    newJoints.Add(nJoint);
                }
                foreach (LineElement l in lines)
                {
                    lList.Add(nLine = new LineElement(l, jSelection[l.I], jSelection[l.J]));
                    newLines.Add(nLine);
                }
                foreach (AreaElement a in areas)
                {
                    aList.Add(nArea = new AreaElement(a, jSelection[a.J1], jSelection[a.J2], jSelection[a.J3], jSelection[a.J4]));
                    newAreas.Add(nArea);
                }
                services.ReportProgress((uint)(100 * i / n));
                System.Windows.Forms.Application.DoEvents();
            }
            JoinCmd.Join(services.Model, newJoints, newLines, newAreas);
        }