Exemplo n.º 1
0
        /// <summary>
        /// Base constructor
        /// </summary>
        /// <param name="inOwnerRig">Node which contains the Port</param>
        /// <param name="inPortObj">The PortObj in the Port</param>
        /// <param name="inIndex">The position in the ports list</param>
        /// <param name="inIsOutput">true to generate an Output Port, false to generate an Input Port</param>
        public Port(Node inOwnerRig, PortObj inPortObj, int inIndex, bool inIsOutput)
        {
            _name = _nativeName = inPortObj.Name;

            _owner    = inOwnerRig;
            _portObj  = inPortObj;
            _isOutput = inIsOutput;
            Index     = inIndex;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Copy the PortObj (Initialize its variables FROM the given PortObj)
        /// </summary>
        /// <param name="inLink">PortObj to copy into this PortObj instance</param>
        public void Copy(PortObj inPort)
        {
            _nativeName = inPort.NativeName;
            _name       = inPort.Name;
            _owner      = inPort.Owner;
            _default    = inPort.Default;
            _isInput    = inPort._isInput;
            _isOutput   = inPort._isOutput;

            CopyCustomFields(inPort, true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes its members from the Xml reader
        /// </summary>
        /// <param name="reader">The reader streaming the xml</param>
        public void ReadXml(XmlReader reader)
        {
            reader.Read();

            _name       = reader.ReadElementString();
            _nativeName = reader.ReadElementString();

            _visible   = bool.Parse(reader.ReadElementString());
            _isDynamic = bool.Parse(reader.ReadElementString());
            _isOutput  = bool.Parse(reader.ReadElementString());

            _portObj         = new PortObj();
            _portObj.Name    = reader.ReadElementString();
            Owner            = new Node();
            Owner.NativeName = "";
            Owner.Name       = reader.ReadElementString();

            string type = "Default";

            if (reader.LocalName == "Links")
            {
                reader.Read(); // Skip ahead to next node

                while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "Link")
                {
                    if (reader.HasAttributes)
                    {
                        type = reader.GetAttribute("Type");
                    }

                    XmlSerializer linkSerializer = null;

                    if (!Serializer.LinkSerializers.TryGetValue(type, out linkSerializer))
                    {
                        linkSerializer = Serializer.LinkSerializers["Default"];
                    }

                    Link dep = (Link)linkSerializer.Deserialize(reader);
                    dep.Target = this;
                    Dependencies.Add(dep);
                }

                if (reader.LocalName == "Links")
                {
                    reader.Read();
                }
            }

            reader.ReadEndElement();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Inserts a port object
        /// </summary>
        /// <param name="inNode">Node on which to add the port</param>
        /// <param name="inObj">Port object</param>
        /// <param name="index">Index of where to insert the object</param>
        /// <returns></returns>
        internal static List <Port> AddPortObj(Node inNode, PortObj inObj, int index)
        {
            List <Port> ports = new List <Port>();

            foreach (PortObj portObj in inNode.Elements)
            {
                if (portObj.FullName == inObj.FullName)
                {
                    NodalDirector.ShowError(string.Format("Node '{0}' already have a port object named '{1}'", inNode.FullName, inObj.FullName), "Cannot add Port");
                    return(ports);
                }
            }

            inObj.Owner = inNode;
            inNode.Elements.Insert(index, inObj);

            if (inObj.IsInput)
            {
                Port newInput = new Port(inNode, inObj, inNode.Inputs.Count, false);
                inNode.Inputs.Insert(index, newInput);

                if (!inObj.ExposeInput)
                {
                    newInput.Visible = false;
                }

                ports.Add(newInput);
            }

            if (inObj.IsOutput)
            {
                Port newOutput = new Port(inNode, inObj, inNode.Outputs.Count, true);
                inNode.Outputs.Insert(index, newOutput);

                if (!inObj.ExposeOutput)
                {
                    newOutput.Visible = false;
                }

                ports.Add(newOutput);
            }

            return(ports);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Copy the Port (Initialize its variables FROM the given Port)
 /// </summary>
 /// <param name="inPort">Port to copy into this Port instance</param>
 public void Copy(Port inPort)
 {
     _nativeName   = inPort.NativeName;
     _name         = inPort.Name;
     _visible      = inPort.Visible;
     _displayIndex = inPort.DisplayIndex;
     _isDynamic    = inPort.IsDynamic;
     _isOutput     = inPort.IsOutput;
     _portObj      = (PortObj)Activator.CreateInstance(inPort.PortObj.GetType(), new object[0]);
     _portObj.Copy(inPort.PortObj);
     if (!IsOutput)
     {
         CopyDependencies(inPort);
     }
     else
     {
         _owner            = (Node)Activator.CreateInstance(inPort.Owner.GetType(), new object[0]);
         _owner.NativeName = "";
         _owner.Name       = inPort.Owner.Name;
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Override of ToString()
 /// @todo return "" if not visible ? Seems weird with insight
 /// </summary>
 /// <returns>The string version of the object</returns>
 public override string ToString()
 {
     return(PortObj.ToString());
 }
Exemplo n.º 7
0
 /// <summary>
 /// Used to return the PortObj's list of custom values (Parameters)
 /// </summary>
 /// <returns>The PortObj's parameters values</returns>
 public object[] GetPortParams()
 {
     return(PortObj.GetPortParams());
 }
Exemplo n.º 8
0
        /// <summary>
        /// Computes a message for substitution of this PortObj with another
        /// @todo could be more elegant, move that to a static ?
        /// </summary>
        /// <param name="portObj"></param>
        /// <returns></returns>
        public virtual string Substitute(PortObj portObj)
        {
            string message = " * Substitute " + Name + " with " + portObj.Name + "\n";

            return(message);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Clone constructor
 /// </summary>
 /// <param name="inRef">The PortObj that have to be cloned</param>
 public PortObj(PortObj inRef)
 {
     this.Copy(inRef);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Update method for fields in inherited classes
 /// </summary>
 /// <param name="refObj">The PortObj used as reference for the update</param>
 /// <param name="All">Indicates if we have to match every members</param>
 public virtual void Update(PortObj refObj, bool All)
 {
 }
Exemplo n.º 11
0
 /// <summary>
 /// Virtual method called used by inherited classes to serialize their added members
 /// <seealso cref="TK_OSCARLib.PortParam">
 /// <seealso cref="TK_OSCARLib.RigElement">
 /// </summary>
 protected virtual void CopyCustomFields(PortObj inPortObj, bool Resolve)
 {
 }
Exemplo n.º 12
0
 /// <summary>
 /// Add a port object
 /// </summary>
 /// <param name="inNode">Node on which to add the port</param>
 /// <param name="inObj">Port object</param>
 /// <returns>The port(s) created by adding the port Object</returns>
 public static List <Port> AddPortObj(Node inNode, PortObj inObj)
 {
     return(AddPortObj(inNode, inObj, inNode.Inputs.Count));
 }