Пример #1
0
        public void SetMolecularInteractionSettings(MolecularInteractionSettings settings)
        {
            this.interactionSettings = settings;

            if (!interactionSettings.HighlightInteracingAtoms)
            {
                interactionsRenderer.ClearAtomHighlights();
            }

            if (!interactionSettings.RenderInteractionLines)
            {
                interactionsRenderer.ClearInteractionLines();
            }
        }
Пример #2
0
        public void Awake()
        {
            InteractionScoreText.text = "";
            InformationText.text      = "";

            MonitoringEnabled = false;
            ResetPositionsButton.interactable = false;

            interactionSettings = MolecularInteractionSettings.Default();

            highlightInteractingAtomsToggle.isOn    = interactionSettings.HighlightInteracingAtoms;
            renderInteractionLinesToggle.isOn       = interactionSettings.RenderInteractionLines;
            renderAttractiveInteractionsToggle.isOn = interactionSettings.ShowAttractiveInteractions;
            renderStableInteractionsToggle.isOn     = interactionSettings.ShowStableInteractions;
            renderRepulsiveInteractionsToggle.isOn  = interactionSettings.ShowRepulsiveInteractions;
        }
        public void StartMonitoringInteractions(int molecule1ID, int molecule2ID, MolecularInteractionSettings interactionSettings, MoleculeRenderSettings molecule1Settings, MoleculeRenderSettings molecule2Settings)
        {
            if (!molecules.ContainsKey(molecule1ID))
            {
                MoleculeEvents.RaiseInteractionsMessage("Can't monitor interactions. Molecule " + molecule1ID + " not found", true);
                return;
            }

            if (!molecules.ContainsKey(molecule2ID))
            {
                MoleculeEvents.RaiseInteractionsMessage("Can't monitor interactions. Molecule " + molecule2ID + " not found", true);
                return;
            }

            moleculeInterations.StartMonitoring(molecules[molecule1ID], molecules[molecule2ID], interactionSettings, molecule1Settings, molecule2Settings);
        }
Пример #4
0
        public void StartMonitoring(Molecule molecule1, Molecule molecule2, MolecularInteractionSettings interactionSettings, MoleculeRenderSettings molecule1Settings, MoleculeRenderSettings molecule2Settings)
        {
            UnityEngine.Debug.Log("Start monitoring " + Time.time);

            if (molecule1 == null)
            {
                MoleculeEvents.RaiseInteractionsMessage("Can't monitor interactions. First molecule is null.", true);
                return;
            }

            if (molecule2 == null)
            {
                MoleculeEvents.RaiseInteractionsMessage("Can't monitor interactions. Second molecule is null.", true);
                return;
            }

            if (molecule1.PrimaryStructureTrajectory != null || molecule2.PrimaryStructureTrajectory != null)
            {
                MoleculeEvents.RaiseInteractionsMessage("Can't monitor interactions. Monitored molecules cannot have trajectories loaded.", true);
                return;
            }

            this.Molecule1           = molecule1;
            this.Molecule2           = molecule2;
            this.interactionSettings = interactionSettings;

            SetMolecule1RenderSettings(molecule1Settings);
            SetMolecule2RenderSettings(molecule2Settings);

            interactionsRenderer.Molecule1 = molecule1;
            interactionsRenderer.Molecule2 = molecule2;

            reportSigmaEpsilonValueDefaults(molecule1, molecule2);

            Active = true;
        }
        // atom highlights are generally re-rendered only when interaction settings have been updated
        public void RenderAtomHighlights(MolecularInteractionSettings interactionSettings)
        {
            List <HighLightedAtom> molecule1Atoms = new List <HighLightedAtom>();
            List <HighLightedAtom> molecule2Atoms = new List <HighLightedAtom>();

            if (interactions != null)
            {
                foreach (AtomInteraction interaction in interactions)
                {
                    if (interaction.InteractionColour == null)
                    {
                        continue;
                    }

                    if ((interaction.InteractionType == InteractionType.Attractive && !interactionSettings.ShowAttractiveInteractions) ||
                        (interaction.InteractionType == InteractionType.Stable && !interactionSettings.ShowStableInteractions) ||
                        (interaction.InteractionType == InteractionType.Repulsive && !interactionSettings.ShowRepulsiveInteractions))
                    {
                        continue;
                    }

                    HighLightedAtom atom1 = new HighLightedAtom();
                    atom1.Atom           = interaction.Atom1;
                    atom1.HighlightColor = (Color)interaction.InteractionColour;
                    molecule1Atoms.Add(atom1);

                    HighLightedAtom atom2 = new HighLightedAtom();
                    atom2.Atom           = interaction.Atom2;
                    atom2.HighlightColor = (Color)interaction.InteractionColour;
                    molecule2Atoms.Add(atom2);
                }
            }

            Molecule1.RenderAtomHighlights(molecule1Atoms);
            Molecule2.RenderAtomHighlights(molecule2Atoms);
        }
Пример #6
0
 private void Awake()
 {
     interactionSettings = MolecularInteractionSettings.Default();
 }
        // interaction lines are generally rendered every frame
        public void RenderInteractionLines(MolecularInteractionSettings interactionSettings)
        {
            if (interactions == null || Molecule1 == null || Molecule2 == null)
            {
                return;
            }

            HashSet <int> newInteractions = new HashSet <int>();

            foreach (AtomInteraction interaction in interactions)
            {
                if (interaction.InteractionColour == null)
                {
                    continue;
                }

                if ((interaction.InteractionType == InteractionType.Attractive && !interactionSettings.ShowAttractiveInteractions) ||
                    (interaction.InteractionType == InteractionType.Stable && !interactionSettings.ShowStableInteractions) ||
                    (interaction.InteractionType == InteractionType.Repulsive && !interactionSettings.ShowRepulsiveInteractions))
                {
                    continue;
                }

                int key = interaction.GetHashCode();

                LineRenderer lineRenderer = null;

                if (interactionLines.ContainsKey(key))
                {
                    lineRenderer = interactionLines[key];
                }
                else
                {
                    GameObject lineGO = GameObject.Instantiate(interactionLinePrefab);
                    lineGO.transform.SetParent(interactionLineParent.transform);
                    lineRenderer = lineGO.GetComponent <LineRenderer>();
                    interactionLines.Add(key, lineRenderer);
                }

                Vector3 atom1Position = interaction.Atom1.Position;
                atom1Position.z *= -1;
                Vector3 atom2Position = interaction.Atom2.Position;
                atom2Position.z *= -1;

                Vector3[] positions = new Vector3[] {
                    Molecule1.MoleculeRender.transform.TransformPoint(atom1Position),
                    Molecule2.MoleculeRender.transform.TransformPoint(atom2Position)
                };

                lineRenderer.SetPositions(positions);
                lineRenderer.startWidth     = 0.01f;
                lineRenderer.endWidth       = 0.01f;
                lineRenderer.material.color = (Color)interaction.InteractionColour;

                lineRenderer.gameObject.SetActive(true);
                newInteractions.Add(key);
            }

            foreach (KeyValuePair <int, LineRenderer> line in interactionLines)
            {
                if (!newInteractions.Contains(line.Key))
                {
                    line.Value.gameObject.SetActive(false);
                }
            }
        }
 public void UpdateMolecularInteractionSettings(MolecularInteractionSettings settings)
 {
     moleculeInterations.SetMolecularInteractionSettings(settings);
 }