Beispiel #1
0
      public void generatePreview(CanvasNode cn)
      {
          OutputGenerationParams ogp = new OutputGenerationParams();
          ogp.Width = 128;
          ogp.Height = 128;

          MaskDAGGraphNode gn = (MaskDAGGraphNode)cn;
          MaskParam mp = new MaskParam();
          InputConnectionPoint icp = new InputConnectionPoint(mp,true,"Preview",gn,this);
          gn.computeOutput(icp,ogp);

          if (onUpdateCallback != null)
          {
              DAGMask m = mp.Value;
              onUpdateCallback(ref m);
          }
       }
Beispiel #2
0
        public bool gatherInputAndParameters(OutputGenerationParams parms)
        {
            //walk all of our local params
            //find the associated connection point
            //copy the data from the connection point to our local point

            Type type = GetType();// Get object type

            System.Reflection.PropertyInfo[] pi = type.GetProperties();
            for (int i = 0; i < pi.Length; i++)
            {
                System.Reflection.PropertyInfo prop = pi[i];

                object[] custAttrib = prop.GetCustomAttributes(false);
                if (custAttrib == null)
                {
                    continue;
                }

                Type ptt = prop.PropertyType;

                for (int k = 0; k < custAttrib.Length; k++)
                {
                    if (custAttrib[k] is ConnectionType)
                    {
                        ConnectionType ct = custAttrib[k] as ConnectionType;
                        if (ct.ConnType == "Param")
                        {
                            for (int j = 0; j < mParamConnections.Count; j++)
                            {
                                if (mParamConnections[j].Neighbors.Count == 0)
                                {
                                    continue;
                                }

                                if (mParamConnections[j].ID == ct.Description)
                                {
                                    ConnectionPoint  CP = mParamConnections[j].Neighbors[0] as ConnectionPoint;
                                    MaskDAGGraphNode GN = CP.OwnerNode as MaskDAGGraphNode;
                                    if (!GN.computeOutput(mParamConnections[j], parms))
                                    {
                                        return(false);
                                    }

                                    if (ptt == typeof(float))
                                    {
                                        prop.SetValue(this, ((FloatParam)mParamConnections[j].ParamType).Value, null);
                                    }
                                    else if (ptt == typeof(int))
                                    {
                                        prop.SetValue(this, ((IntParam)mParamConnections[j].ParamType).Value, null);
                                    }
                                    else if (ptt == typeof(bool))
                                    {
                                        prop.SetValue(this, ((BoolParam)mParamConnections[j].ParamType).Value, null);
                                    }
                                    else if (ptt == typeof(DAGMask))
                                    {
                                        prop.SetValue(this, ((MaskParam)mParamConnections[j].ParamType).Value, null);
                                    }
                                }
                            }
                        }
                        else if (ct.ConnType == "Input")
                        {
                            for (int j = 0; j < mInputConnections.Count; j++)
                            {
                                if (mInputConnections[j].ID == ct.Description)
                                {
                                    ConnectionPoint  CP = mInputConnections[j].Neighbors[0] as ConnectionPoint;
                                    MaskDAGGraphNode GN = CP.OwnerNode as MaskDAGGraphNode;
                                    if (!GN.computeOutput(mInputConnections[j], parms))
                                    {
                                        return(false);
                                    }


                                    if (ptt == typeof(float))
                                    {
                                        prop.SetValue(this, ((FloatParam)mInputConnections[j].ParamType).Value, null);
                                    }
                                    else if (ptt == typeof(int))
                                    {
                                        prop.SetValue(this, ((IntParam)mInputConnections[j].ParamType).Value, null);
                                    }
                                    else if (ptt == typeof(bool))
                                    {
                                        prop.SetValue(this, ((BoolParam)mInputConnections[j].ParamType).Value, null);
                                    }
                                    else if (ptt == typeof(DAGMask))
                                    {
                                        prop.SetValue(this, ((MaskParam)mInputConnections[j].ParamType).Value, null);
                                    }
                                }
                            }
                        }
                        else if (ct.ConnType == "Constraint")
                        {
                            for (int j = 0; j < mConstraintConnections.Count; j++)
                            {
                                if (mConstraintConnections[j].Neighbors.Count == 0)
                                {
                                    if (ptt == typeof(float))
                                    {
                                        prop.SetValue(this, 0, null);
                                    }
                                    else if (ptt == typeof(int))
                                    {
                                        prop.SetValue(this, 0, null);
                                    }
                                    else if (ptt == typeof(bool))
                                    {
                                        prop.SetValue(this, false, null);
                                    }
                                    else if (ptt == typeof(DAGMask))
                                    {
                                        prop.SetValue(this, null, null);
                                    }
                                }
                                else if (mConstraintConnections[j].ID == ct.Description)
                                {
                                    ConnectionPoint  CP = mConstraintConnections[j].Neighbors[0] as ConnectionPoint;
                                    MaskDAGGraphNode GN = CP.OwnerNode as MaskDAGGraphNode;
                                    if (!GN.computeOutput(mConstraintConnections[j], parms))
                                    {
                                        return(false);
                                    }


                                    if (ptt == typeof(float))
                                    {
                                        prop.SetValue(this, ((FloatParam)mConstraintConnections[j].ParamType).Value, null);
                                    }
                                    else if (ptt == typeof(int))
                                    {
                                        prop.SetValue(this, ((IntParam)mConstraintConnections[j].ParamType).Value, null);
                                    }
                                    else if (ptt == typeof(bool))
                                    {
                                        prop.SetValue(this, ((BoolParam)mConstraintConnections[j].ParamType).Value, null);
                                    }
                                    else if (ptt == typeof(DAGMask))
                                    {
                                        prop.SetValue(this, ((MaskParam)mConstraintConnections[j].ParamType).Value, null);
                                    }
                                }
                            }
                        }


                        break;
                    }
                }
            }
            return(true);
        }