Inheritance: ICloneable
Esempio n. 1
0
        /// <summary>
        /// Al construir un AreaElement se necesita un prototipo de Propiedades, que define el tipo de elemento que
        /// se forma. De esta manera, después de construir el elemento no se le puede cambiar el tipo, además de que
        /// se pueden crear varios elementos con las mismas propiedades. La constructora clona al prototipo, de manera
        /// que un objeto externo puede crear varios elementos con el mismo objeto de propiedades.
        /// </summary>
        /// <param name="prototype">El prototipo de propiedades.</param>
        public AreaElement(AreaProps prototype)
        {
            props  = (AreaProps)prototype.Clone();
            joints = new Joint[4];
            angle  = 0;
            mass   = 0;
            materialTemperature = 0;
            offsets             = new float[4];
            //springs = new ManagedList<AreaSprings>();
            flipJoints = 0;

            Joint j = Model.Instance.JointList[1];
            int   i = 1;

            while (j == null && i < Model.Instance.JointList.Count)
            {
                j = Model.Instance.JointList[i++];
            }
            if (j != null)
            {
                J1        = J2 = J3 = j;
                joints[3] = null;
            }
            else
            {
                throw new NullReferenceException(Culture.Get("EM0020"));
            }
        }
Esempio n. 2
0
 private static void TestModel(Canguro.Model.Model model)
 {
     model.JointList.Add(new Canguro.Model.Joint(-2, 5, 0));
     model.JointList.Add(new Canguro.Model.Joint(0, 0, 0));
     model.JointList.Add(new Canguro.Model.Joint(2, 5, 0));
     model.JointList.Add(new Canguro.Model.Joint(0, 1, 0));
     Model.AreaProps   props = new Model.AreaProps();
     Model.AreaElement area  = new Canguro.Model.AreaElement(props, model.JointList[1], model.JointList[2], model.JointList[3], model.JointList[4]);
     model.AreaList.Add(area);
     Canguro.Model.Load.Load l = null;
     area.Loads.Add(l);
 }
Esempio n. 3
0
        /// <summary>
        /// Método heredado de IClonable
        /// </summary>
        /// <returns>Regresa una copia superficial (completa en este caso) de sí mismo</returns>
        public object Clone()
        {
            AreaProps clone = (AreaProps)this.MemberwiseClone();

            if (clone.section != null)
            {
                if (Model.Instance.Sections[clone.section.Name] == null)
                {
                    Model.Instance.Sections[clone.section.Name] = clone.section;
                }
                else if (Model.Instance.Sections[clone.section.Name] is Canguro.Model.Section.AreaSection)
                {
                    clone.section = (Canguro.Model.Section.AreaSection)Model.Instance.Sections[clone.section.Name];
                }
            }
            return(clone);
        }
Esempio n. 4
0
        /// <summary>
        /// Constructor de copia que clona un AreaElement a partir de src
        /// </summary>
        /// <param name="src">El AreaElement a copiar.</param>
        internal AreaElement(AreaElement src, Joint j1, Joint j2, Joint j3, Joint j4) : base(src)
        {
            props  = (AreaProps)src.Properties.Clone();
            joints = new Joint[4];
            angle  = src.Angle;
            mass   = src.Mass;
            materialTemperature = src.MaterialTemperature;
            offsets             = src.Offsets;
            //springs = a.Springs;
            //springs = new ManagedList<AreaSprings>();
            flipJoints = src.FlipJoints;

            joints[0] = j1;
            joints[1] = j2;
            joints[2] = j3;
            joints[3] = j4;
        }
Esempio n. 5
0
        /// <summary>
        /// Constructora que inicializa el AreaElement con un clon de las propiedades indicadas y los nodos indicados.
        /// Si los nodos no están en la lista correspondiente, en la posición adecuada, se lanza una NullReferenceException
        /// Se recomienda usar esta constructora para minimizar el consumo de memoria en Model.Undo
        /// </summary>
        /// <param name="prototype">Prototype properties to copy from</param>
        /// <param name="jointList">Joints to be added to this AreaElement</param>
        public AreaElement(AreaProps prototype, Joint j1, Joint j2, Joint j3, Joint j4)
        {
            props = (AreaProps)prototype.Clone();
            joints = new Joint[4];
            angle = 0;
            mass = 0;
            materialTemperature = 0;
            offsets = new float[4];
            //springs = new ManagedList<AreaSprings>();

            if (j1 == null || j2 == null || j3 == null)
                throw new NullReferenceException(Culture.Get("EM0021"));

            J1 = j1;
            J2 = j2;
            J3 = j3;
            J4 = j4;
        }
Esempio n. 6
0
        /// <summary>
        /// Constructora que inicializa el AreaElement con un clon de las propiedades indicadas y los nodos indicados.
        /// Si los nodos no están en la lista correspondiente, en la posición adecuada, se lanza una NullReferenceException
        /// Se recomienda usar esta constructora para minimizar el consumo de memoria en Model.Undo
        /// </summary>
        /// <param name="prototype">Prototype properties to copy from</param>
        /// <param name="jointList">Joints to be added to this AreaElement</param>
        public AreaElement(AreaProps prototype, Joint j1, Joint j2, Joint j3, Joint j4)
        {
            props  = (AreaProps)prototype.Clone();
            joints = new Joint[4];
            angle  = 0;
            mass   = 0;
            materialTemperature = 0;
            offsets             = new float[4];
            //springs = new ManagedList<AreaSprings>();

            if (j1 == null || j2 == null || j3 == null)
            {
                throw new NullReferenceException(Culture.Get("EM0021"));
            }

            J1 = j1;
            J2 = j2;
            J3 = j3;
            J4 = j4;
        }
Esempio n. 7
0
        /// <summary>
        /// Executes the command. 
        /// Creates one AreaElement.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            AreaElement area;
            List<Joint> joints = new List<Joint>();
            Joint joint1, joint2, joint3, joint4;
            AreaProps props = new AreaProps();
            List<LineElement> newLines = new List<LineElement>();

            try
            {
            services.GetProperties(Culture.Get("addAreaProps"), props);

            joint1 = services.GetJoint(newLines);
            services.TrackingService = PolygonTrackingService.Instance;
            services.TrackingService.SetPoint(joint1.Position);
            services.Model.ChangeModel();

            joint2 = services.GetJoint(newLines);
            services.TrackingService.SetPoint(joint2.Position);
            services.Model.ChangeModel();

            joint3 = services.GetJoint(newLines);
            services.TrackingService.SetPoint(joint3.Position);
            services.Model.ChangeModel();

            joint4 = services.GetJoint(newLines);
            if (joint4 != null)
                services.TrackingService.SetPoint(joint4.Position);

            services.Model.AreaList.Add(area = new AreaElement(props, joint1, joint2, joint3, joint4));
            services.Model.ChangeModel();

            }
            catch (Canguro.Controller.CancelCommandException) { }
            //if (newLines.Count == 0)
            //    services.Model.Undo.Rollback();
            //else
            //    JoinCmd.Join(services.Model, new List<Joint>(), newLines);
        }
Esempio n. 8
0
        /// <summary>
        /// Al construir un AreaElement se necesita un prototipo de Propiedades, que define el tipo de elemento que
        /// se forma. De esta manera, después de construir el elemento no se le puede cambiar el tipo, además de que
        /// se pueden crear varios elementos con las mismas propiedades. La constructora clona al prototipo, de manera
        /// que un objeto externo puede crear varios elementos con el mismo objeto de propiedades.
        /// </summary>
        /// <param name="prototype">El prototipo de propiedades.</param>
        public AreaElement(AreaProps prototype)
        {
            props = (AreaProps)prototype.Clone();
            joints = new Joint[4];
            angle = 0;
            mass = 0;
            materialTemperature = 0;
            offsets = new float[4];
            //springs = new ManagedList<AreaSprings>();
            flipJoints = 0;

            Joint j = Model.Instance.JointList[1];
            int i = 1;
            while (j == null && i < Model.Instance.JointList.Count)
                j = Model.Instance.JointList[i++];
            if (j != null)
            {
                J1 = J2 = J3 = j;
                joints[3] = null;
            }
            else
                throw new NullReferenceException(Culture.Get("EM0020"));
        }
Esempio n. 9
0
        /// <summary>
        /// Constructor de copia que clona un AreaElement a partir de src
        /// </summary>
        /// <param name="src">El AreaElement a copiar.</param>
        internal AreaElement(AreaElement src, Joint j1, Joint j2, Joint j3, Joint j4)
            : base(src)
        {
            props = (AreaProps)src.Properties.Clone();
            joints = new Joint[4];
            angle = src.Angle;
            mass = src.Mass;
            materialTemperature = src.MaterialTemperature;
            offsets = src.Offsets;
            //springs = a.Springs;
            //springs = new ManagedList<AreaSprings>();
            flipJoints = src.FlipJoints;

            joints[0] = j1;
            joints[1] = j2;
            joints[2] = j3;
            joints[3] = j4;
        }
Esempio n. 10
0
 private static void TestModel(Canguro.Model.Model model)
 {
     model.JointList.Add(new Canguro.Model.Joint(-2, 5, 0));
     model.JointList.Add(new Canguro.Model.Joint(0, 0, 0));
     model.JointList.Add(new Canguro.Model.Joint(2, 5, 0));
     model.JointList.Add(new Canguro.Model.Joint(0, 1, 0));
     Model.AreaProps props = new Model.AreaProps();
     Model.AreaElement area = new Canguro.Model.AreaElement(props, model.JointList[1], model.JointList[2], model.JointList[3], model.JointList[4]);
     model.AreaList.Add(area);
     Canguro.Model.Load.Load l = null;
     area.Loads.Add(l);
 }