/// <summary>
        /// Show the input/output port fields
        /// </summary>
        private void ShowSeriesTrainingExamplesNodePorts()
        {
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();

            GUIContent inputPortLabel = new GUIContent("Live Data In");

            IMLNodeEditor.PortField(inputPortLabel, m_TrainingExamplesNode.GetInputPort("InputFeatures"), Resources.Load <GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(0));

            GUIContent outputPortLabel = new GUIContent("Recorded\nData Out");

            IMLNodeEditor.PortField(outputPortLabel, m_TrainingExamplesNode.GetOutputPort("TrainingExamplesNodeToOutput"), Resources.Load <GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(0));

            GUILayout.EndHorizontal();

            GUIContent secondInputPortLabel = new GUIContent("Target Values");

            IMLNodeEditor.PortField(secondInputPortLabel, m_TrainingExamplesNode.GetInputPort("TargetValues"), Resources.Load <GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(0));
        }
        /// <summary>
        /// Define rect values for node body and paint textures based on rects
        /// </summary>

        /// <summary>
        /// Show the input/output port fields
        /// </summary>
        private void ShowSystemNodePorts()
        {
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();

            GUIContent inputPortLabel = new GUIContent("Live Data In");

            IMLNodeEditor.PortField(inputPortLabel, m_CRIMLConfiguration.GetInputPort("InputFeatures"), Resources.Load <GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(0));

            GUIContent outputPortLabel = new GUIContent("ML Out");

            IMLNodeEditor.PortField(outputPortLabel, m_CRIMLConfiguration.GetOutputPort("ModelOutput"), Resources.Load <GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(0));

            GUILayout.EndHorizontal();

            GUIContent secondInputPortLabel = new GUIContent("Recorded Data In");

            IMLNodeEditor.PortField(secondInputPortLabel, m_CRIMLConfiguration.GetInputPort("IMLTrainingExamplesNodes"), Resources.Load <GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(0));
        }
Esempio n. 3
0
        /// <summary>
        /// Show the input/output port fields
        /// </summary>
        protected void ShowNodePorts(Dictionary <string, string> inputsNameOverride = null, Dictionary <string, string> outputsNameOverride = null, bool showOutputType = false)
        {
            if (NodeSubtitle != null)
            {
                GUILayout.Space(15);
            }
            else
            {
                GUILayout.Space(5);
            }


            // Iterate through dynamic ports and draw them in the order in which they are serialized
            // Init variables
            GUIContent inputPortLabel;
            GUIContent outputPortLabel;

            // Make sure port pair list is init
            if (m_PortPairs == null)
            {
                m_PortPairs = new List <IMLNodePortPair>();
            }

            bool updatePortPairs = false;

            // DIRTY CODE
            // If the node is an mls node, check if the output ports have been updated
            if (target is IMLConfiguration)
            {
                var mlsNode = (target as IMLConfiguration);
                updatePortPairs = mlsNode.OutputPortsChanged;
                // Set flag to false in mls node to not redraw every frame
                mlsNode.OutputPortsChanged = false;
            }
            // Generic check if the number ports changes to reduce the times we reserve memory
            if (m_NumInputs != target.Inputs.Count() || m_NumOutputs != target.Outputs.Count())
            {
                updatePortPairs = true;
            }

            // Get number of ports to avoid reserving memory twice
            if (updatePortPairs)
            {
                // Update known number of ports
                m_NumInputs  = target.Inputs.Count();
                m_NumOutputs = target.Outputs.Count();
                // Get inputs and outputs ports
                IEnumerator <NodePort> inputs  = target.Inputs.GetEnumerator();
                IEnumerator <NodePort> outputs = target.Outputs.GetEnumerator();
                // Add them to the list
                AddPairsToList(inputs, outputs, ref m_PortPairs);
            }



            // Go through port pairs to draw them together
            foreach (var pair in m_PortPairs)
            {
                // Will draw them in a horizontal pair
                GUILayout.BeginHorizontal();

                // Draw input (if any)
                if (pair.input != null)
                {
                    if (NodeEditorGUILayout.IsDynamicPortListPort(pair.input))
                    {
                        continue;
                    }
                    inputPortLabel = new GUIContent(pair.input.fieldName);
                    // Check if an override of the label is needed
                    if (inputsNameOverride != null)
                    {
                        if (inputsNameOverride.ContainsKey(pair.input.fieldName))
                        {
                            string newLabel = inputPortLabel.text;
                            inputsNameOverride.TryGetValue(pair.input.fieldName, out newLabel);
                            inputPortLabel.text = newLabel;
                        }
                    }
                    // Draw port
                    IMLNodeEditor.PortField(inputPortLabel, m_IMLNode.GetInputPort(pair.input.fieldName), m_NodeSkin.GetStyle("Port Label"), GUILayout.MinWidth(0));
                }
                // Draw output (if any)
                if (pair.output != null)
                {
                    if (NodeEditorGUILayout.IsDynamicPortListPort(pair.output))
                    {
                        continue;
                    }
                    outputPortLabel = new GUIContent(pair.output.fieldName);
                    // Check if an override of the label is needed
                    if (outputsNameOverride != null)
                    {
                        if (outputsNameOverride.ContainsKey(pair.output.fieldName))
                        {
                            string newLabel = outputPortLabel.text;
                            outputsNameOverride.TryGetValue(pair.output.fieldName, out newLabel);
                            outputPortLabel.text = newLabel;
                        }
                    }
                    // Check if we require to show the data type of the output
                    if (showOutputType == true)
                    {
                        string type = pair.output.ValueType.ToString();
                        // Remove namespace from string (if any)
                        if (type.Contains("."))
                        {
                            // Remove everything until "."
                            type = type.Remove(0, type.IndexOf(".") + 1);
                        }
                        // Add type to label text
                        outputPortLabel.text = string.Concat(outputPortLabel.text, " (", type, ")");
                    }
                    // Draw port
                    IMLNodeEditor.PortField(outputPortLabel, m_IMLNode.GetOutputPort(pair.output.fieldName), m_NodeSkin.GetStyle("Port Label"), GUILayout.MinWidth(0));
                }

                GUILayout.EndHorizontal();
            }

            serializedObject.ApplyModifiedProperties();
        }