Example #1
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(5f);

        foldout = EditorGUILayout.Foldout(foldout, "Bubbles", true);

        if (!foldout)
        {
            return;
        }

        bubbleType = (BubbleType)EditorGUILayout.EnumPopup("Bubble Type", bubbleType);

        if (bubbleType != BubbleType.None)
        {
            if (GUILayout.Button("Add"))
            {
                actorBubble.bubbles.Add(new GameObject());
                AddBubble(bubbleType, actorBubble.bubbles[actorBubble.bubbles.Count - 1]);
            }

            if (GUILayout.Button("Remove"))
            {
                foreach (GameObject item in actorBubble.bubbles)
                {
                    DestroyImmediate(item);
                }
                actorBubble.bubbles.Clear();
            }
        }

        foreach (GameObject item in actorBubble.bubbles)
        {
            if (item == null)
            {
                actorBubble.bubbles.Remove(item);
                break;
            }

            if (item.GetComponent <BubbleBehaviour>() == null)
            {
                break;
            }

            string label = item.GetComponent <IBubble>().BodyArea.ToString() + " " + item.GetComponent <IBubble>().Type.ToString();

            GUILayout.Label(label, EditorStyles.boldLabel);
            GUILayout.Space(10f);

            item.GetComponent <IBubble>().BodyArea = (BodyArea)EditorGUILayout.EnumPopup("Body Area", item.GetComponent <IBubble>().BodyArea);
            item.GetComponent <IBubble>().Offset   = EditorGUILayout.Vector3Field("Offset", item.GetComponent <IBubble>().Offset);
            item.GetComponent <IBubble>().Link     = (Transform)EditorGUILayout.ObjectField("Link", item.GetComponent <IBubble>().Link, typeof(Transform), true);
            BubbleShape bubbleShape = (BubbleShape)EditorGUILayout.EnumPopup("Bubble Shape", item.GetComponent <IBubble>().Shape);

            if (item.GetComponent <IBubble>().Link != null)
            {
                item.transform.SetParent(item.GetComponent <IBubble>().Link);
                item.layer = item.GetComponent <IBubble>().Link.gameObject.layer;
                item.transform.position = item.GetComponent <IBubble>().Link.position + item.GetComponent <IBubble>().Offset;
            }

            item.transform.position = item.transform.position + item.GetComponent <IBubble>().Offset;

            item.name = label;

            if (item.GetComponent <Collider>() == null || item.GetComponent <IBubble>().Shape != bubbleShape)
            {
                item.GetComponent <IBubble>().Shape = bubbleShape;

                DestroyImmediate(item.GetComponent <Collider>());
                switch (item.GetComponent <IBubble>().Shape)
                {
                case BubbleShape.Capsule:
                    item.AddComponent <CapsuleCollider>();
                    break;

                case BubbleShape.Box:
                    item.AddComponent <BoxCollider>();
                    break;

                case BubbleShape.Sphere:
                    item.AddComponent <SphereCollider>();
                    break;

                default:
                    break;
                }
            }

            if (GUILayout.Button("Delete"))
            {
                DestroyImmediate(item);
                actorBubble.bubbles.Remove(item);
                break;
            }

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Space(10f);
        }
    }
Example #2
0
        /// <summary>
        /// Displays the scan vs. NET values for a single analysis.
        /// </summary>
        /// <param name="analysis"></param>
        private void DisplayScansVsNet(Analysis analysis)
        {
            // Either the display does not have the analysis, or the display series was reset and needs to be re-rendered
            if (!m_displayCache.ContainsKey(analysis) || m_displayCache[analysis] == null)
            {
                BubbleShape      shape      = new BubbleShape(1, false);
                clsColorIterator colors     = new clsColorIterator();
                Color            plotColor  = colors.GetColor(analysis.Id);
                clsPlotParams    parameters = new clsPlotParams(shape, plotColor, false, true, true);
                parameters.Name = analysis.Name;

                float[] ordinate = new float[analysis.Targets.Count];
                float[] abscissa = new float[analysis.Targets.Count];
                int     i        = 0;
                if (!mcheckBox_useResiduals.Checked)
                {
                    foreach (Target target in analysis.Targets)
                    {
                        if (radioButtonAverageNET.Checked)
                        {
                            ordinate[i]   = Convert.ToSingle(target.ParentTarget.GaNetAverage);
                            abscissa[i++] = Convert.ToSingle(target.Scan);
                        }
                        else
                        {
                            /// Only display predicted peptides if not using average NET
                            if (!target.IsPredicted)
                            {
                                continue;
                            }

                            ordinate[i]   = Convert.ToSingle(target.NetPredicted);
                            abscissa[i++] = Convert.ToSingle(target.Scan);
                        }
                    }
                }
                else
                {
                    foreach (Target target in analysis.Targets)
                    {
                        if (radioButtonAverageNET.Checked)
                        {
                            ordinate[i]   = Convert.ToSingle(target.ParentTarget.GaNetAverage - target.NetAligned);
                            abscissa[i++] = Convert.ToSingle(target.Scan);
                        }
                        else
                        {
                            /// Only display predicted peptides if not using average NET
                            if (!target.IsPredicted)
                            {
                                continue;
                            }

                            ordinate[i]   = Convert.ToSingle(target.NetPredicted - target.NetAligned);
                            abscissa[i++] = Convert.ToSingle(target.Scan);
                        }
                    }
                }

                clsSeries newSeries = new clsSeries(new ArrayChartDataProvider(abscissa, ordinate), parameters);
                if (!m_displayCache.ContainsKey(analysis))
                {
                    m_displayCache.Add(analysis, null);
                }
                m_displayCache[analysis] = newSeries;
            }

            clsSeries series = m_displayCache[analysis];

            ctlChartScanVsNET.SeriesCollection.Add(series);
            ctlChartScanVsNET.AutoViewPort();
        }