Esempio n. 1
0
        private void PatchEditor_OpenHostingView(uint obj)
        {
            var app = RuntimeHost.HostingAppInstances.FirstOrDefault(x => x.Object?.Context?.Path.Stack?.Peek() == obj) as NodePlugin;

            if (app != null)
            {
                var node  = FHDEHost.GetNodeFromPath(app.PluginHost.GetNodePath(false));
                var patch = FHDEHost.GetNodeFromPath(app.PluginHost.ParentNode.GetNodePath(false));
                if (patch != null)
                {
                    FHDEHost.ShowEditor(patch);
                    FHDEHost.SelectNodes(new INode2[1] {
                        node
                    });
                }
            }
        }
Esempio n. 2
0
        public void getExposedPinSettings()
        {
            var.Clear();
            FLogger.Log(LogType.Debug, "ADDING EXPOSED PINS");

            for (int i = 0; i < exposedPins.Count; i++)
            {
                var nodePath = exposedPins[i].Substring(0, exposedPins[i].LastIndexOf('/'));
                var node     = FHDEHost.GetNodeFromPath(nodePath);



                //	if (exposedPins[i]) {
                if (node != null)
                {
                    var parts = exposedPins[i].Split('/');
                    var pin   = node.FindPin(parts[parts.Length - 1]);

                    //FValues[i] = pin.Spread;
                    string nodeID = parts[parts.Length - 2];

                    FLogger.Log(LogType.Debug, parts[parts.Length - 2]);
                    //string nodeType

                    if (pin.Spread.Contains("|"))
                    {
                        string trimValue = pin.Spread.Substring(1, pin.Spread.Length - 2);

                        //		trimValue.Remove(',');

                        string[] nodeValues = trimValue.Split('|');


                        List <String> colorValues = new List <String>();

                        for (int v = 0; v < nodeValues.Length; v++)
                        {
                            if (nodeValues[v] != ",")
                            {
                                colorValues.Add(nodeValues[v]);
                            }
                        }

                        var.Add(new Variable(name[i], nodeID, RetrieveType(nodeSubType[i]), colorValues));
                    }
                    else
                    {
                        string[] nodeValues = pin.Spread.Split(',');
                        var.Add(new Variable(name[i], nodeID, RetrieveType(nodeSubType[i]), nodeValues));
                    }
                }
                //}
            }
        }
Esempio n. 3
0
#pragma warning restore
        #endregion fields & pins

        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (FUpdate.IsChanged)
            {
                FLabel.SliceCount   = SpreadMax;
                FTag.SliceCount     = SpreadMax;
                FSubtype.SliceCount = SpreadMax;

                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FUpdate[i])
                    {
                        var nodePath = FInput[i].Substring(0, FInput[i].LastIndexOf('/'));
                        var node     = FHDEHost.GetNodeFromPath(nodePath);
                        if (node != null)
                        {
                            FLabel[i] = node.LabelPin.Spread.Trim('|');
                            var tag = node.FindPin("Tag");
                            if (tag != null)
                            {
                                FTag[i] = tag.Spread.Trim('|');
                            }
                            else
                            {
                                FTag[i] = "";
                            }

                            var parts = FInput[i].Split('/');
                            var pin   = node.FindPin(parts[parts.Length - 1]);
                            if (pin != null)
                            {
                                FSubtype[i] = pin.SubType;
                            }
                            else
                            {
                                FSubtype[i] = "Pin not found.";
                            }
                        }
                        else
                        {
                            FLabel[i]   = "Node not found.";
                            FSubtype[i] = "Pin not found.";
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public void Evaluate(int SpreadMax)
        {
            this.cursorDisplay.HideCursor = !this.FInShowCursor[0];

            if (this.FOutQueryable[0] == null)
            {
                this.FOutQueryable[0] = this;
            }
            if (this.FOutBackBuffer[0] == null)
            {
                this.FOutBackBuffer[0] = new DX11Resource <DX11SwapChain>();
                this.FOuFS             = new Spread <DX11Resource <DX11SwapChain> >();
                this.FOuFS.SliceCount  = 1;
                this.FOuFS[0]          = new DX11Resource <DX11SwapChain>();
            }

            this.updateddevices.Clear();
            this.rendereddevices.Clear();
            this.FInvalidateSwapChain = false;

            if (!this.depthmanager.FormatChanged) // do not clear reset if format changed
            {
                this.depthmanager.NeedReset = false;
            }
            else
            {
                this.depthmanager.FormatChanged = false; //Clear flag ok
            }

            if (FInAASamplesPerPixel.IsChanged || this.FInBufferCount.IsChanged || this.FInFlipSequential.IsChanged || this.FInRefreshRate.IsChanged)
            {
                this.depthmanager.NeedReset = true;
                this.FInvalidateSwapChain   = true;
            }

            if (this.FInFullScreen.IsChanged)
            {
                string path;
                this.FHost.GetNodePath(false, out path);
                INode2 n2 = hde.GetNodeFromPath(path);

                if (n2.Window != null)
                {
                    if (n2.Window.IsVisible)
                    {
                        if (this.FInFullScreen[0])
                        {
                            // if the pin is true we want to give it priority over the component mode set in the patch. also in the first frame.
                            hde.SetComponentMode(n2, ComponentMode.Fullscreen);
                        }
                        else
                        {
                            // checking for first frame is necessary. the pin will always report to be changed in the very first frame.
                            // however in the first frame we want to respect the component mode that is saved in the patch
                            if (!FirstFrame)
                            {
                                hde.SetComponentMode(n2, ComponentMode.InAWindow);
                            }
                        }
                    }
                }
            }

            this.FOutKState[0]         = new KeyboardState(this.FKeys);
            this.FOutMouseState[0]     = MouseState.Create(this.FMousePos.x, this.FMousePos.y, this.FMouseButtons.x > 0.5f, this.FMouseButtons.y > 0.5f, this.FMouseButtons.z > 0.5f, false, false, this.wheel);
            this.FOutBackBufferSize[0] = new Vector2D(this.Width, this.Height);

            this.FOutTouchSupport[0] = this.touchsupport;

            this.FOutTouchData.SliceCount = this.touches.Count;

            int   tcnt = 0;
            float fw   = (float)this.ClientSize.Width;
            float fh   = (float)this.ClientSize.Height;

            lock (m_touchlock)
            {
                foreach (int key in touches.Keys)
                {
                    TouchData t = touches[key];

                    this.FOutTouchData[tcnt] = t.Clone(fw, fh);
                    t.IsNew = false;
                    tcnt++;
                }
            }
            FirstFrame = false;
        }
Esempio n. 5
0
        private void ProcessOSCMessage(OSCMessage message)
        {
            IPin2 pin = null;

            switch (FAcceptMode[0])
            {
            case AcceptMode.OnlyCached:
            {
                if (FCachedPins.ContainsKey(message.Address))
                {
                    pin = FCachedPins[message.Address];
                }
                break;
            }

            case AcceptMode.OnlyExposed:
            {
                if (FExposedPins.ContainsKey(message.Address))
                {
                    pin = FExposedPins[message.Address];
                }
                break;
            }

            case AcceptMode.ExposedAndCached:
            {
                if (FExposedPins.ContainsKey(message.Address))
                {
                    pin = FExposedPins[message.Address];
                }
                else if (FCachedPins.ContainsKey(message.Address))
                {
                    pin = FCachedPins[message.Address];
                }
                break;
            }

            case AcceptMode.Any:
            {
                if (FCachedPins.ContainsKey(message.Address))
                {
                    pin = FCachedPins[message.Address];
                }
                else
                {
                    //check if address is in the format of a nodepath
                    //ie. /4/545/46/pinname
                    var path    = message.Address.Split('/');
                    var pinName = path[path.Length - 1];

                    int id = 0;
                    //last entry in path has to be a string (ie. pinname) not a number
                    var validAddress = !string.IsNullOrEmpty(pinName) && !int.TryParse(pinName, out id);

                    if (validAddress)
                    {
                        var pathIDs = new int[path.Length - 1];
                        for (int i = 1; i < pathIDs.Length; i++)
                        {
                            if (int.TryParse(path[i], out id))
                            {
                                pathIDs[i] = id;
                            }
                            else
                            {
                                validAddress = false;
                                break;
                            }
                        }
                    }

                    if (validAddress)
                    {
                        //check if a pin is available under this address
                        var nodePath = message.Address.Substring(0, message.Address.LastIndexOf('/'));
                        var node     = FHDEHost.GetNodeFromPath(nodePath);
                        if (node != null)
                        {
                            //FLogger.Log(LogType.Warning, node.Name);
                            pin = node.FindPin(pinName.Trim());

                            if (pin != null)
                            {
                                FCachedPins.Add(message.Address, pin);
                                pin.Changed += PinChanged;
                            }
                            else
                            {
                                FLogger.Log(LogType.Warning, "No pin available under: \"" + message.Address + "\"!");
                            }
                        }
                        else
                        {
                            FLogger.Log(LogType.Warning, "No node available under: \"" + nodePath + "\"!");
                        }
                    }
                    else
                    {
                        FLogger.Log(LogType.Warning, "\"" + message.Address + "\" is not a valid pin address!");
                    }
                }
                break;
            }
            }

            //send values to pin
            if (pin != null)
            {
                var values = "";
                foreach (var v in message.Values)
                {
                    if (v is float)
                    {
                        values += ((float)v).ToString(System.Globalization.CultureInfo.InvariantCulture) + ",";
                    }
                    else if (v is double)
                    {
                        values += ((double)v).ToString(System.Globalization.CultureInfo.InvariantCulture) + ",";
                    }
                    else
                    {
                        values += v.ToString() + ",";
                    }
                }
                values = values.TrimEnd(',');

                pin.Spread = values;
            }
        }
Esempio n. 6
0
        public void Evaluate(int SpreadMax)
        {
            this.FOutCtrl[0] = this;
            this.FOutRef[0]  = (INode)this.FHost;

            if (this.FOutQueryable[0] == null)
            {
                this.FOutQueryable[0] = this;
            }
            if (this.FOutBackBuffer[0] == null)
            {
                this.FOutBackBuffer[0] = new DX11Resource <DX11SwapChain>();
                this.FOuFS             = new Spread <DX11Resource <DX11SwapChain> >();
                this.FOuFS.SliceCount  = 1;
                this.FOuFS[0]          = new DX11Resource <DX11SwapChain>();
            }

            this.updateddevices.Clear();
            this.rendereddevices.Clear();
            this.FInvalidateSwapChain = false;

            if (!this.depthmanager.FormatChanged) // do not clear reset if format changed
            {
                this.depthmanager.NeedReset = false;
            }
            else
            {
                this.depthmanager.FormatChanged = false; //Clear flag ok
            }

            if (FInAASamplesPerPixel.IsChanged || this.FInBufferCount.IsChanged)
            {
                this.depthmanager.NeedReset = true;
                this.FInvalidateSwapChain   = true;
            }

            if (this.FInFullScreen.IsChanged)
            {
                string path;
                this.FHost.GetNodePath(false, out path);
                INode2 n2 = hde.GetNodeFromPath(path);

                if (n2.Window != null)
                {
                    if (n2.Window.IsVisible)
                    {
                        if (this.FInFullScreen[0])
                        {
                            hde.SetComponentMode(n2, ComponentMode.Fullscreen);
                        }
                        else
                        {
                            hde.SetComponentMode(n2, ComponentMode.InAWindow);
                        }
                    }
                }
            }

            /*if (this.FInFullScreen.IsChanged)
             * {
             *  if (this.FInFullScreen[0])
             *  {
             *      string path;
             *      this.FHost.GetNodePath(false, out path);
             *      INode2 n2 = hde.GetNodeFromPath(path);
             *      hde.SetComponentMode(n2, ComponentMode.Fullscreen);
             *  }
             *  else
             *  {
             *      string path;
             *      this.FHost.GetNodePath(false, out path);
             *      INode2 n2 = hde.GetNodeFromPath(path);
             *      hde.SetComponentMode(n2, ComponentMode.InAWindow);
             *  }
             * }*/

            this.FOutKState[0]         = new KeyboardState(this.FKeys);
            this.FOutMouseState[0]     = MouseState.Create(this.FMousePos.x, this.FMousePos.y, this.FMouseButtons.x > 0.5f, this.FMouseButtons.y > 0.5f, this.FMouseButtons.z > 0.5f, false, false, this.wheel);
            this.FOutBackBufferSize[0] = new Vector2D(this.Width, this.Height);

            this.FOutTouchSupport[0] = this.touchsupport;

            this.FOutTouchData.SliceCount = this.touches.Count;

            int   tcnt = 0;
            float fw   = (float)this.ClientSize.Width;
            float fh   = (float)this.ClientSize.Height;

            lock (m_touchlock)
            {
                foreach (int key in touches.Keys)
                {
                    TouchData t = touches[key];

                    this.FOutTouchData[tcnt] = t.Clone(fw, fh);
                    t.IsNew = false;
                    tcnt++;
                }
            }
        }
Esempio n. 7
0
        private void ProcessOSCMessage(OSCMessage message)
        {
            IPin2 pin = null;

            switch (FAcceptMode[0])
            {
            case AcceptMode.OnlyCached:
            {
                if (FCachedPins.ContainsKey(message.Address))
                {
                    pin = FCachedPins[message.Address];
                }
                break;
            }

            case AcceptMode.OnlyExposed:
            {
                if (FExposedPins.ContainsKey(message.Address))
                {
                    pin = FExposedPins[message.Address];
                }
                break;
            }

            case AcceptMode.ExposedAndCached:
            {
                if (FExposedPins.ContainsKey(message.Address))
                {
                    pin = FExposedPins[message.Address];
                }
                else if (FCachedPins.ContainsKey(message.Address))
                {
                    pin = FCachedPins[message.Address];
                }
                break;
            }

            case AcceptMode.Any:
            {
                if (FCachedPins.ContainsKey(message.Address))
                {
                    pin = FCachedPins[message.Address];
                }
                else
                {
                    //check if address is in the format of a nodepath
                    //ie. /4/545/46/pinname
                    var path    = message.Address.Split('/');
                    var pinName = path[path.Length - 1];

                    int id = 0;
                    //last entry in path has to be a string (ie. pinname) not a number
                    var validAddress = !string.IsNullOrEmpty(pinName) && !int.TryParse(pinName, out id);

                    if (validAddress)
                    {
                        var pathIDs = new int[path.Length - 1];
                        for (int i = 1; i < pathIDs.Length; i++)
                        {
                            if (int.TryParse(path[i], out id))
                            {
                                pathIDs[i] = id;
                            }
                            else
                            {
                                validAddress = false;
                                break;
                            }
                        }
                    }

                    if (validAddress)
                    {
                        //check if a pin is available under this address
                        var nodePath = message.Address.Substring(0, message.Address.LastIndexOf('/'));
                        var node     = FHDEHost.GetNodeFromPath(nodePath);
                        if (node != null)
                        {
                            //FLogger.Log(LogType.Warning, node.Name);
                            pin = node.FindPin(pinName.Trim());

                            if (pin != null)
                            {
                                FCachedPins.Add(message.Address, pin);
                                pin.Changed += PinChanged;
                            }
                            else
                            {
                                FLogger.Log(LogType.Warning, "No pin available under: \"" + message.Address + "\"!");
                            }
                        }
                        else
                        {
                            FLogger.Log(LogType.Warning, "No node available under: \"" + nodePath + "\"!");
                        }
                    }
                    else
                    {
                        FLogger.Log(LogType.Warning, "\"" + message.Address + "\" is not a valid pin address!");
                    }
                }
                break;
            }
            }

            //send values to pin
            if (pin != null)
            {
                var values = "";
                foreach (var v in message.Values)
                {
                    if (v is float)
                    {
                        values += ((float)v).ToString(System.Globalization.CultureInfo.InvariantCulture) + ",";
                    }
                    else if (v is double)
                    {
                        values += ((double)v).ToString(System.Globalization.CultureInfo.InvariantCulture) + ",";
                    }
                    else
                    {
                        //pipes are used in pin values only to surround slices that have a "space", "comma" or "pipe" in them
                        //therefore they only make sense in string and color values in the first place
                        //but also it does no harm if a slice is surrounded by pipes anyway
                        //so lets check if first and last character is a pipe, then assume user knows those rules and don't do anything
                        //otherwise:
                        //- always escape a single pipe with an extra pipe
                        //- always surround the string with pipes
                        string s = v.ToString();
                        if (s.StartsWith("|") && s.EndsWith("|"))
                        {
                            values += s + ",";
                        }
                        else
                        {
                            s       = s.Replace("|", "||"); //escape a single pipe with a double pipe
                            values += "|" + s + "|,";       //quote the string with pipes in order for it to be treated as a single slice
                        }
                    }
                }
                values = values.TrimEnd(',');

                pin.Spread = values;
            }
        }
Esempio n. 8
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            exposedNodes.SliceCount = exposedPins.Count;


            for (int i = 0; i < exposedPins.Count; i++)
            {
                exposedNodes[i] = "";

                if (receiveNewValue[0])
                {
                    var nodePath = exposedPins[i].Substring(0, exposedPins[i].LastIndexOf('/'));
                    var node     = FHDEHost.GetNodeFromPath(nodePath);



                    //
                    //	if (exposedPins[i]) {
                    if (node != null)
                    {
                        var parts = exposedPins[i].Split('/');
                        var pin   = node.FindPin(parts[parts.Length - 1]);

                        // FLogger.Log(LogType.Debug, oldValues.Equals(pin.Spread).ToString());
                        //if(receiveNewValue[0]){


                        //FValues[i] = pin.Spread;
                        string nodeID = parts[parts.Length - 2];


                        //string nodeType

                        if (pin.Spread.Contains("|"))
                        {
                            string trimValue = pin.Spread.Substring(1, pin.Spread.Length - 2);

                            //		trimValue.Remove(',');

                            string[] nodeValues = trimValue.Split(new string[] { "|,|" }, StringSplitOptions.None);


                            string values = "";


                            for (int n = 0; n < nodeValues.Length; n++)
                            {
                                values += nodeValues[n];
                                if (n < nodeValues.Length - 1)
                                {
                                    values += ";";
                                }
                            }



                            //var.Add(new Variable(name[i], nodeID, RetrieveType(nodeSubType[i]), colorValues));

                            exposedNodes[i] = name[i] + "/" + nodeID + "/" + RetrieveType(nodeSubType[i]) + "/" + values;
                        }
                        else
                        {
                            string[] nodeValues = pin.Spread.Split(',');

                            string values = "";

                            for (int n = 0; n < nodeValues.Length; n++)
                            {
                                values += nodeValues[n];
                                if (n < nodeValues.Length - 1)
                                {
                                    values += ";";
                                }
                            }
                            //var.Add(new Variable(name[i], nodeID, RetrieveType(nodeSubType[i]), nodeValues));
                            exposedNodes[i] = name[i] + "/" + nodeID + "/" + RetrieveType(nodeSubType[i]) + "/" + values;
                        }



                        //}
                        //oldValues = pin.Spread;
                    }
                }
            }
        }