예제 #1
0
    void OnGUI()
    {
        CUE cue = CUE.GetInstance();

        ReactionType[] reactionTypes = cue.ReactionTypes;

        // Make a background box
        GUI.Box(new Rect(10, 10, 300, 30 + reactionTypes.Length * 25), "Reaction For Molecule");

        if (GUI.Button(new Rect(20, 40, 280, 20), "Attach"))
        {
            ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork);
            Thread      myThread         = new Thread(myThreadDelegate);
            myThread.Start();
            Thread.Sleep(100);
            Debug.Log("Main - aborting my thread.");
            myThread.Abort();
            myThread.Join();
            Debug.Log("Main ending.");
        }

        int i = 1;

        foreach (var item in reactionTypes)
        {
            if (GUI.Button(new Rect(20, 40 + 25 * i, 280, 20), item.ToString()))
            {
            }

            i++;
        }
    }
예제 #2
0
    protected override void OnItemGui(MoleculeSpecies item)
    {
        if (item == null)
        {
            base.OnItemGui(item);
            return;
        }

        CUE cue = CUE.GetInstance();

        item.Name            = EditorGUILayout.TextField("Name", item.Name);
        item.InitialQuantity = EditorGUILayout.IntField("Initial Quantity [1]", item.InitialQuantity);
        item.Mass            = EditorGUILayout.FloatField("Mass [u]", item.Mass);
        EditorGUILayout.LabelField("~Size [nm]", Utils.ScaleToNm(item.Size).ToString());
        //EditorGUILayout.LabelField("ID", item.GetInstanceID().ToString());

        EditorUtility.SetDirty(item);

        if (GUILayout.Button("remove"))
        {
            cue.RemoveSpecies(item);

            EditorUtility.SetDirty(cue);
        }
    }
예제 #3
0
        /// <summary>
        /// Set a molecule ready for reactiong.
        /// Called when molecules collide with each other.
        /// When all molecules are ready, cue.ReactionManager.PerformReaction is called.
        /// </summary>
        /// <param name="molecule">Molecule.</param>
        public void Ready(Molecule molecule)
        {
            bool allReady = true;

            for (int i = 0; i < molecules.Count; i++)
            {
                if (molecule == molecules[i])
                {
                    ready[i] = true;

                    if (!allReady)
                    {
                        break;
                    }
                }

                allReady = allReady & ready[i];
            }

            if (allReady && !performed)
            {
                performed = true;

                CUE cue = CUE.GetInstance();
                cue.ReactionManager.PerformReaction(this);
            }
        }
예제 #4
0
    private MoleculeSpecies[] GuiSpeciesList(CUE cue, MoleculeSpecies[] speciesArray)
    {
        MoleculeSpeciesPopup speciesPopup = new MoleculeSpeciesPopup(cue, speciesArray.Length > 0);

        List <MoleculeSpecies> species = new List <MoleculeSpecies>(speciesArray);

        species.Add(null);

        for (int i = 0; i < species.Count; i++)
        {
            if (i != 0)
            {
                EditorGUILayout.LabelField("+", GUILayout.MaxWidth(10));
            }

            species[i] = speciesPopup.Popup(species[i], (species[i] == null && i > 0));
        }

        while (species.Contains(null))
        {
            species.Remove(null);
        }

        return(species.ToArray());
    }
예제 #5
0
        public override bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, DoWorkEventArgs e, bool forced = false)
        {
            for (int i = 0; i < deviceInfos.Count; i++)
            {
                SetDeviceColors(deviceInfos[i].Type, i, keyColors);
            }

            return(CUE.Update());
        }
예제 #6
0
        private void Deselect()
        {
            CameraControl.Follow = null;
            CUE cue = CUE.GetInstance();

            cue.ReactionManager.SelectedMolecule = null;

            RemoveScript();
        }
예제 #7
0
        void OnDrawGizmos()
        {
            Gizmos.color = new Color(0, 0, 1, 0.5f);

            CUE cue = CUE.GetInstance();

            float r = Utils.GetSphereRadius(cue.Volume);

            Gizmos.DrawSphere(Vector3.zero, Utils.ScaleFromNm(r));
        }
예제 #8
0
        /// <summary>
        /// Simulates one step.
        /// </summary>
        private void SimulateStep()
        {
            Debug.Log("Step");

            CUE cue = CUE.GetInstance();

            SimulationStep step = simulator.Step(cue.SimulationStep);

            EnqueueStep(step);
            nextStep = nextStep.AddSeconds(cue.VisualizationStep);
        }
예제 #9
0
    public override void OnInspectorGUI()
    {
        Molecule t   = (Molecule)target;
        CUE      cue = CUE.GetInstance();

        MoleculeSpeciesPopup speciesPopup = new MoleculeSpeciesPopup(cue, false);

        t.Species = speciesPopup.Popup(t.Species, false);

        EditorUtility.SetDirty(t);

        if (GUILayout.Button("show CellUnity Editor"))
        {
            CellUnityWindow.Init();
        }
    }
예제 #10
0
        private bool SetDeviceColors(CorsairDeviceType type, int index, Dictionary <DeviceKeys, Color> keyColors)
        {
            List <CorsairLedColor> colors = new List <CorsairLedColor>();

            if (LedMaps.MapsMap.TryGetValue(type, out var dict) && dict.Count != 0)
            {
                foreach (var led in keyColors)
                {
                    if (dict.TryGetValue(led.Key, out var ledid))
                    {
                        colors.Add(new CorsairLedColor()
                        {
                            LedId = ledid,
                            R     = led.Value.R,
                            G     = led.Value.G,
                            B     = led.Value.B
                        });
                    }
                }
            }
            else
            {
                if (keyColors.TryGetValue(DeviceKeys.Peripheral_Logo, out var clr))
                {
                    foreach (CorsairLedId led in LedMaps.DIYLeds)
                    {
                        colors.Add(new CorsairLedColor()
                        {
                            LedId = led,
                            R     = clr.R,
                            G     = clr.G,
                            B     = clr.B
                        });
                    }
                }
            }

            if (colors.Count == 0)
            {
                return(false);
            }

            return(CUE.SetDeviceColors(index, colors.ToArray()));
        }
예제 #11
0
        public void Reload()
        {
            CUE cue = CUE.GetInstance();

            SimulationState oldState = state;

            if (state != SimulationState.Stopped)
            {
                Stop();
            }

            if (simulator == null)
            {
                this.simulator = new Copasi.CopasiSimulator();
                simulator.Init(cue);
            }
            else
            {
                simulator.Reload();
            }

            cue.ScriptManager.GetOrAddScript <CellUnity.Simulation.SimulatorScript>();

            simulationThread = new Thread(new ThreadStart(RunSimulation));
            simulationThread.IsBackground = true;

            // restore old state

            if (oldState == SimulationState.Running)
            {
                Start();
            }
            else if (oldState == SimulationState.Paused)
            {
                Pause();
            }
            else if (oldState == SimulationState.Stopped)
            {
                state = SimulationState.Stopped;
            }
        }
예제 #12
0
    protected override void OnItemGui(ReactionType item)
    {
        CUE cue = CUE.GetInstance();

        if (item == null)
        {
            base.OnItemGui(item);
            return;
        }

        item.Name = EditorGUILayout.TextField("Name", item.Name);

        EditorGUILayout.BeginHorizontal();

        item.Reagents = GuiSpeciesList(cue, item.Reagents);

        EditorGUILayout.LabelField(" \u2192 ", GUILayout.MaxWidth(30));

        item.Products = GuiSpeciesList(cue, item.Products);

        EditorGUILayout.EndHorizontal();

        item.Rate = EditorGUILayout.FloatField("Rate [nl/(nmol*s)]", item.Rate);

        EditorUtility.SetDirty(item);

        if (Application.isPlaying)
        {
            if (GUILayout.Button("start reaction"))
            {
                cue.ReactionManager.InitiateReaction(item, true);
            }
        }

        if (GUILayout.Button("remove"))
        {
            cue.RemoveReaction(item);

            EditorUtility.SetDirty(cue);
        }
    }
예제 #13
0
        /// <summary>
        /// Should be called every frame.
        /// Processes Simulation results and initiates reactions.
        /// </summary>
        public void Update()
        {
            if (runInMainThread)
            {
                MainThreadRunSimulation();
            }

            // Process Simulation Results
            while (true)
            {
                SimulationStep step;
                lock (stepsQueueLock)
                {
                    if (stepsQueue.Count == 0)
                    {
                        break;
                    }
                    step = stepsQueue.Dequeue();
                }

                CUE cue = CUE.GetInstance();

                System.Text.StringBuilder info = new System.Text.StringBuilder();                 // TODO: remove

                foreach (ReactionCount item in step.Reactions)
                {
                    info.Append(item.ReactionType.ToString() + ": " + item.Count + ";   ");

                    for (ulong i = 0; i < item.Count; i++)
                    {
                        cue.ReactionManager.InitiateReaction(item.ReactionType, true);
                    }
                }

                Debug.Log(info.ToString());
            }
        }
예제 #14
0
        public override bool Initialize()
        {
            CUE.PerformProtocolHandshake();
            var error = CUE.GetLastError();

            if (error != CorsairError.Success)
            {
                LogError("Corsair Error: " + error);
                return(isInitialized = false);
            }

            for (int i = 0; i < CUE.GetDeviceCount(); i++)
            {
                deviceInfos.Add(CUE.GetDeviceInfo(i));
            }

            if (!CUE.RequestControl())
            {
                LogError("Error requesting cuesdk exclusive control:" + CUE.GetLastError());
                return(isInitialized = false);
            }

            return(isInitialized = true);
        }
예제 #15
0
    public MoleculeSpeciesPopup(CUE cue, bool nullPossible)
    {
        MoleculeSpecies[] cueSpecies = cue.Species;

        moleculeSpecies = new MoleculeSpecies[cueSpecies.Length + (nullPossible ? 1 : 0)];

        moleculeSpeciesString = new string[moleculeSpecies.Length];

        int i = 0;

        if (nullPossible)
        {
            moleculeSpecies[i]       = null;
            moleculeSpeciesString[i] = "none";
            i++;
        }

        foreach (var item in cueSpecies)
        {
            moleculeSpecies[i]       = item;
            moleculeSpeciesString[i] = item.Name;
            i++;
        }
    }
예제 #16
0
 public override void Shutdown()
 {
     isInitialized = false;
     deviceInfos.Clear();
     CUE.ReleaseControl();
 }
예제 #17
0
        public MoleculeSpecies Create()
        {
            // find a name if not specified
            findName();

            // create main object of the species
            GameObject mol = new GameObject(name);

            mol.transform.position = Vector3.zero;

            float colliderRadius = 0;

            //
            // Find center of all gameObjects
            //

            Vector3 center = Vector3.zero;

            foreach (var obj in gameObjects)
            {
                // set main object as parent
                obj.transform.parent = mol.transform;

                center += obj.transform.position;

                // remove collider for performance boost
                if (obj.collider != null)
                {
                    obj.collider.enabled = false;
                    CellUnity.Utility.ScriptManager.RemoveComponent(obj.collider);
                }
            }

            center = center / gameObjects.Length;

            //
            // locate object to (0,0,0) by setting center to (0,0,0)
            // and calculate the colliderRadius by making sure every atom is inside this radius
            //
            foreach (var obj in gameObjects)
            {
                obj.transform.position -= center;

                colliderRadius = Math.Max(colliderRadius, Math.Abs(obj.renderer.bounds.min.x));
                colliderRadius = Math.Max(colliderRadius, Math.Abs(obj.renderer.bounds.min.y));
                colliderRadius = Math.Max(colliderRadius, Math.Abs(obj.renderer.bounds.min.z));
                colliderRadius = Math.Max(colliderRadius, Math.Abs(obj.renderer.bounds.max.x));
                colliderRadius = Math.Max(colliderRadius, Math.Abs(obj.renderer.bounds.max.y));
                colliderRadius = Math.Max(colliderRadius, Math.Abs(obj.renderer.bounds.max.z));
            }

            // Create a new species and add it to the CUE
            CUE             cue     = CUE.GetInstance();
            MoleculeSpecies species = cue.CreateMoleculeSpecies();

            species.Name = name;
            cue.AddSpecies(species);

            // Add the molecule script to the main object
            CellUnity.Molecule script = mol.AddComponent <CellUnity.Molecule>();
            script.Species = species;
            species.Mass   = mass;
            species.Size   = colliderRadius * 2;

            // Add a sphere collider to the main object
            SphereCollider sphereCollider = mol.AddComponent <SphereCollider> ();
            Rigidbody      rigidbody      = mol.AddComponent <Rigidbody> ();

            rigidbody.useGravity  = false;
            rigidbody.mass        = mass;
            sphereCollider.radius = colliderRadius;

            // Add a diffusion script to the main object
            View.Diffusion diffusion = mol.AddComponent <View.Diffusion> ();
            diffusion.Intensity = Diffusion;

            // create the prefab used as template for the species
            string assetPath = "Assets/Molecules/" + name + ".prefab";

            UnityEngine.Object prefab = PrefabUtility.CreateEmptyPrefab(assetPath);
            PrefabUtility.ReplacePrefab(mol, prefab);
            AssetDatabase.Refresh();

            species.PrefabPath = assetPath;

            EditorUtility.SetDirty(cue);

            // Delete game objects
            foreach (var obj in gameObjects)
            {
                GameObject.DestroyImmediate(obj);
            }
            GameObject.DestroyImmediate(mol);

            return(species);
        }
예제 #18
0
        /// <summary>
        /// Initiates a reaction.
        /// </summary>
        /// <returns><c>true</c>, if the reaction was initiated, <c>false</c> otherwise.</returns>
        /// <param name="reaction">Reaction.</param>
        /// <param name="queueIfNotPossible">If set to <c>true</c>, the reaction is queued and performed later if the reaction is not possible at the moment.</param>
        public bool InitiateReaction(ReactionType reaction, bool queueIfNotPossible)
        {
            CUE cue = CUE.GetInstance();

            ReactionPrep reactionPrep = new ReactionPrep(reaction);

            bool moleculesFound;

            // Select molecules

            // Prefer selected molecule if suitable
            if (
                selectedMolecule != null && selectedReaction != null &&                 // molecule and reaction must be selected
                selectedReaction == reaction &&                                         // selected reaction must match current reaction
                selectedMolecule.ReactionPrep == null                                   // selected molecule must not be already involved in a reaction
                )
            {
                moleculesFound = cue.Molecules.FindMolecuelsForReaction(reactionPrep, selectedMolecule);
            }
            else
            {
                // select random molecules
                moleculesFound = cue.Molecules.FindMolecuelsForReaction(reactionPrep);
            }

            if (moleculesFound)
            {
                // Ready reactions for 0 to 1 reagents because Collision is never called for these molecules

                if (reactionPrep.MoleculeCount == 0)
                {
                    reactionPrep.Ready(null);
                }
                if (reactionPrep.MoleculeCount == 1)
                {
                    reactionPrep.Ready(reactionPrep.Molecules[0]);                     // necessary if only one reagent in reaction
                }

                return(true);
            }
            else
            {
                // not sufficient molecules for reaction

                reactionPrep.Release();                 // remove ReactonPrep from Molecules

                if (queueIfNotPossible)
                {
                    // --> queue Reaction for later

                    ShortKeyDict <ReactionType, int> .Entry entry;
                    if (!openReactions.Find(reaction, out entry))
                    {
                        entry = openReactions.Set(reaction, 0);
                    }

                    entry.Value++;
                }

                return(false);
            }
        }
예제 #19
0
    public static void CueGui(CUE cue)
    {
        EditorGUILayout.LabelField("ID", cue.ID.ToString());

        GUILayout.Label("Molecule Species", EditorStyles.boldLabel);

        listViewMolecules.Gui(cue.Species);

        Space();

        GUILayout.Label("Add Molecule", EditorStyles.miniLabel);

        /*GUILayout.BeginHorizontal ();
         * if (GUILayout.Button ("From Selection")) {
         *
         *      MoleculeCreator creator = new MoleculeCreator();
         *      creator.gameObjects = Selection.gameObjects;
         *      MoleculeSpecies species = creator.Create();
         *
         *      listViewMolecules.FoldOpen(species);
         * }
         * GUILayout.EndHorizontal ();*/

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("From PDB File"))
        {
            PdbImport pdbImport = new PdbImport();
            pdbImport.UserSelectFile();
        }

        if (GUILayout.Button("Download From PDB"))
        {
            PdbImportWindow.UserDownload();
        }
        GUILayout.EndHorizontal();

        Space();
        GUILayout.Label("Reactions", EditorStyles.boldLabel);

        listViewReactions.Gui(cue.ReactionTypes);

        Space();
        GUILayout.Label("Add Reaction", EditorStyles.miniLabel);
        if (GUILayout.Button("Add Reaction"))
        {
            var item = cue.CreateReactionType();
            cue.AddReaction(item);
            EditorUtility.SetDirty(cue);

            listViewReactions.FoldOpen(item);
        }

        Space();
        GUILayout.Label("Placing", EditorStyles.boldLabel);

        GUILayout.BeginHorizontal();
        dispenser.Radius = EditorGUILayout.FloatField("Radius [nm]:", dispenser.Radius);
        if (GUILayout.Button("f.Sim", GUILayout.MaxWidth(50)))
        {
            dispenser.Radius = Utils.GetSphereRadius(cue.Volume);
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Remove all Molecules"))
        {
            cue.RemoveMolecules();
        }

        if (GUILayout.Button("Place Molecules"))
        {
            foreach (var species in cue.Species)
            {
                dispenser.AddMolecules(species, species.InitialQuantity);
            }

            dispenser.Place();
        }

        Space();

        GUILayout.Label("Simulation", EditorStyles.boldLabel);

        cue.Volume = Mathf.Max(0, EditorGUILayout.FloatField("Volume [nl]:", (float)cue.Volume));

        /*bool volumeGizom = EditorGUILayout.Toggle ("Volume Visible:", cue.ScriptManager.HasScript<CellUnity.View.VolumeGizmo> ());
         * if (volumeGizom)
         * { cue.ScriptManager.GetOrAddScript<CellUnity.View.VolumeGizmo>(); }
         * else
         * { cue.ScriptManager.RemoveScript<CellUnity.View.VolumeGizmo>(); }
         */


        EditorGUILayout.LabelField("Radius [nm]", Utils.GetSphereRadius(cue.Volume).ToString());
        cue.SimulationStep    = Mathf.Max(0, EditorGUILayout.FloatField("Simulation Step [s]:", (float)cue.SimulationStep));
        cue.VisualizationStep = Mathf.Max(0, EditorGUILayout.FloatField("Visualization Step [s]:", (float)cue.VisualizationStep));

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Reload", GUILayout.MaxWidth(80)))
        {
            cue.SimulationManager.Reload();
        }

        SimulationState simulationState = cue.SimulationManager.State;
        int             oldSimulatorSelection;

        if (simulationState == SimulationState.Running)
        {
            oldSimulatorSelection = 0;
        }
        else if (simulationState == SimulationState.Paused)
        {
            oldSimulatorSelection = 1;
        }
        else if (simulationState == SimulationState.Stopped)
        {
            oldSimulatorSelection = 2;
        }
        else
        {
            oldSimulatorSelection = -1;
        }

        int simulaorSelection =
            GUILayout.SelectionGrid(oldSimulatorSelection, new string[] { "Start", "Pause", "Stop" }, 3);

        if (simulaorSelection != oldSimulatorSelection)
        {
            if (simulaorSelection == 0)
            {
                cue.SimulationManager.Start();
            }
            else if (simulaorSelection == 1)
            {
                cue.SimulationManager.Pause();
            }
            else if (simulaorSelection == 2)
            {
                cue.SimulationManager.Stop();
            }
        }

        GUILayout.EndHorizontal();

        Space();
        GUILayout.Label("Export", EditorStyles.boldLabel);
        if (GUILayout.Button("Export SBML..."))
        {
            string filename = EditorUtility.SaveFilePanel("Export SBML", "", "model.xml", "xml");
            new CellUnity.Export.SbmlExportCopasi(cue).Export(filename);
        }
        Space();

        GUILayout.Label("Debug", EditorStyles.boldLabel);
        if (GUILayout.Button("Auto Run Reactions"))
        {
            GameObject autoRun = new GameObject("AutoRun");
            autoRun.AddComponent <AutoReaction>();
        }

        if (GUILayout.Button("Save Assets"))
        {
            AssetDatabase.SaveAssets();
        }

        Space();

        //if (GUILayout.Button ("Reset")) {
        //	cue.ResetData();
        //}
    }
예제 #20
0
 // Use this for initialization
 void Start()
 {
     this.cue = CUE.GetInstance();
 }
예제 #21
0
 // Use this for initialization
 void Start()
 {
     cue = CUE.GetInstance();
     Debug.Log("Auto Reaction started");
 }
예제 #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CellUnity.Export.SbmlExportCopasi"/> class.
 /// </summary>
 /// <param name="cue">CUE to export</param>
 public SbmlExportCopasi(CUE cue)
 {
     this.cue = cue;
 }
예제 #23
0
        static void Main(string[] args)
        {
            var dets = CUE.PerformProtocolHandshake();

            if (CUE.RequestControl())
            {
                int a = CUE.GetDeviceCount();
                List <CorsairDeviceInfo> infos = new List <CorsairDeviceInfo>();
                for (int i = 0; i < a; i++)
                {
                    var info = CUE.GetDeviceInfo(i);
                    Console.WriteLine(info.Model);
                    infos.Add(info);
                }

                var colorbuffer = new CorsairLedColor[]
                {
                    new CorsairLedColor()
                    {
                        LedId = CorsairLedId.K_W,
                        R     = 0,
                        G     = 0,
                        B     = 255
                    },
                    new CorsairLedColor()
                    {
                        LedId = CorsairLedId.K_A,
                        R     = 0,
                        G     = 0,
                        B     = 255
                    },
                    new CorsairLedColor()
                    {
                        LedId = CorsairLedId.K_S,
                        R     = 0,
                        G     = 0,
                        B     = 255
                    },
                    new CorsairLedColor()
                    {
                        LedId = CorsairLedId.K_D,
                        R     = 0,
                        G     = 0,
                        B     = 255
                    },
                    new CorsairLedColor()
                    {
                        LedId = CorsairLedId.M_1,
                        R     = 0,
                        G     = 0,
                        B     = 255
                    },
                    new CorsairLedColor()
                    {
                        LedId = CorsairLedId.M_2,
                        R     = 0,
                        G     = 0,
                        B     = 255
                    },
                    new CorsairLedColor()
                    {
                        LedId = CorsairLedId.M_3,
                        R     = 0,
                        G     = 0,
                        B     = 255
                    },
                    new CorsairLedColor()
                    {
                        LedId = CorsairLedId.M_4,
                        R     = 0,
                        G     = 0,
                        B     = 255
                    },
                    new CorsairLedColor()
                    {
                        LedId = CorsairLedId.M_5,
                        R     = 0,
                        G     = 0,
                        B     = 255
                    },
                    new CorsairLedColor()
                    {
                        LedId = CorsairLedId.M_6,
                        R     = 0,
                        G     = 0,
                        B     = 255
                    },
                };
                CUE.SetLedColors(colorbuffer);
                CUE.Update();
            }

            Console.ReadLine();
            CUE.ReleaseControl();
            Console.ReadLine();
        }
예제 #24
0
        void OnGUI()
        {
            CUE cue = CUE.GetInstance();

            // Get selected molecule
            Molecule m = cue.ReactionManager.SelectedMolecule;

            // Set following
            if (following)
            {
                CameraControl.Follow = m.gameObject;
            }
            else
            {
                CameraControl.Follow = null;
            }

            // Draw menu or remove script if no moleule is selected
            if (m == null)
            {
                RemoveScript();
            }
            else
            {
                GuiBoxReset();

                GuiBeginBox("Molecule", 94);

                string reaction;
                string reactionStatus;

                if (m.ReactionPrep != null)
                {
                    reaction       = m.ReactionPrep.ReactionType.ToString();
                    reactionStatus = "performing";
                }
                else
                {
                    ReactionType selectedReaction = cue.ReactionManager.SelectedReaction;
                    if (selectedReaction != null)
                    {
                        reaction       = selectedReaction.ToString();
                        reactionStatus = "waiting";
                    }
                    else
                    {
                        reaction       = "none";
                        reactionStatus = "";
                    }
                }

                GuiCaptionValue("Species:", m.Species.Name);
                GuiCaptionValue("Reaction:", reaction + "\n\r" + reactionStatus);

                GUILayout.BeginHorizontal();

                if (GUILayout.Button(following ? "Stay" : "Follow"))
                {
                    following = !following;
                }

                if (GUILayout.Button("Deselect"))
                {
                    Deselect();
                }

                if (GUILayout.Button("Hide"))
                {
                    Hide();
                }

                GUILayout.EndHorizontal();

                GuiEndBox();

                //
                // Reactions
                //

                List <ReactionType> reactions = new List <ReactionType>();
                foreach (var r in cue.ReactionTypes)
                {
                    if (Utils.ArrayContains <MoleculeSpecies>(r.Reagents, m.Species))
                    {
                        reactions.Add(r);
                    }
                }

                GuiBeginBox("Reaction", (reactions.Count + 1) * (guiReactionHeight) + guiReactionSpace);

                if (GUILayout.Button("none"))
                {
                    cue.ReactionManager.SelectedReaction = null;
                }

                GUILayout.Space(guiReactionSpace);

                foreach (var r in reactions)
                {
                    if (GUILayout.Button(r.ToString()))
                    {
                        cue.ReactionManager.SelectedReaction = r;
                    }
                }

                GuiEndBox();

                if (Input.GetKey("escape"))
                {
                    Deselect();
                }
                if (Input.GetKey("return"))
                {
                    Hide();
                }
            }
        }
예제 #25
0
        /// <summary>
        /// Init Simulator with CUE
        /// </summary>
        /// <param name="cue">CUE</param>
        public void Init(CUE cue)
        {
            this.cue = cue;

            Reload();
        }
예제 #26
0
 void OnGUI()
 {
     CueEditor.CueGui(CUE.GetInstance());
 }