Example #1
0
        /// <summary>
        /// Gets the list of active managers based on the atom type provided and based on the bond type in UIData.
        /// </summary>
        /// <returns>
        /// The list of managers. A List<GenericManager> object that should contains the "atom" manager in position 0 and the "bond" manager in position 1 (if there is one).
        /// </returns>
        public static List <GenericManager> GetManagers()
        {
            UIData.AtomType       aType       = UIData.atomtype;
            List <GenericManager> managerList = new List <GenericManager>();

            if (aType == UIData.AtomType.hyperball)               //||  UIData.bondtype == UIData.BondType.hyperstick) {
            {
                GameObject   hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager");
                HBallManager hbManager    = hbManagerObj.GetComponent <HBallManager>();
                managerList.Add(hbManager);
            }
            else if (aType == UIData.AtomType.sphere)
            {
                GameObject    spManagerObj = GameObject.FindGameObjectWithTag("SphereManager");
                SphereManager spManager    = spManagerObj.GetComponent <SphereManager>();
                managerList.Add(spManager);
            }
            else if (aType == UIData.AtomType.cube)
            {
                GameObject  cubeManagerObj = GameObject.FindGameObjectWithTag("CubeManager");
                CubeManager cubeManager    = cubeManagerObj.GetComponent <CubeManager>();
                managerList.Add(cubeManager);
            }
            else if (aType == UIData.AtomType.particleball)
            {
                GameObject psObj = GameObject.FindGameObjectWithTag("ShurikenParticleManager");
                ShurikenParticleManager shManager = psObj.GetComponent <ShurikenParticleManager>();
                managerList.Add(shManager);
            }
            if (UIData.bondtype == UIData.BondType.line)
            {
                GameObject  lineManagerObj = GameObject.FindGameObjectWithTag("LineManager");
                LineManager lineManager    = lineManagerObj.GetComponent <LineManager>();
                managerList.Add(lineManager);
            }
            else if (UIData.bondtype == UIData.BondType.cube)
            {
                GameObject      cubeBondManagerObj = GameObject.FindGameObjectWithTag("CubeBondManager");
                CubeBondManager cubeBondManager    = cubeBondManagerObj.GetComponent <CubeBondManager>();
                managerList.Add(cubeBondManager);
            }
            else if (UIData.bondtype == UIData.BondType.hyperstick)
            {
                GameObject    hStickManagerObj = GameObject.FindGameObjectWithTag("HStickManager");
                HStickManager hStickManager    = hStickManagerObj.GetComponent <HStickManager>();
                managerList.Add(hStickManager);
            }
            return(managerList);
        }
Example #2
0
        public void DisplayBonds()
        {
            if (UIData.bondtype == UIData.BondType.cube)
            {
                bondList = MoleculeModel.bondEPList;
                MoleculeModel.bondsnumber = bondList.Count;
                if (UIData.secondarystruct)
                {
                    bondEPList = MoleculeModel.bondCAList;
                }
                else
                {
                    bondEPList = MoleculeModel.bondEPList;
                }
                int Number = bondEPList.Count / number;

                Debug.Log("DisplayBonds??bondList.Count " + bondList.Count);

                for (int i = 0; i < Number; i++)
                {
                    CreateCylinder(i * number);
                }
                GameObject      cbManagerObj = GameObject.FindGameObjectWithTag("CubeBondManager");
                CubeBondManager cbManager    = cbManagerObj.GetComponent <CubeBondManager>();
                cbManager.Init();

                // HERE COMES THE BONDMANAGER
            }
            else if (UIData.bondtype == UIData.BondType.hyperstick)
            {
                if (UIData.secondarystruct)
                {
                    bondEPList = MoleculeModel.bondCAList;
                }
                else
                {
                    bondEPList = MoleculeModel.bondEPList;
                }
                Debug.Log("Bonds?? bondEPList.Count :: " + bondEPList.Count);
                int Number = bondEPList.Count / number;

                for (int i = 0; i < Number; i++)
                {
                    CreateCylinderByShader(i * number);
                }
                GameObject    hsManagerObj = GameObject.FindGameObjectWithTag("HStickManager");
                HStickManager hsManager    = hsManagerObj.GetComponent <HStickManager>();
                hsManager.Init();

//				GameObject hbManagerObj = GameObject.FindGameObjectWithTag("HBallManager");
//				HBallManager hbManager = hbManagerObj.GetComponent<HBallManager>();
//				hbManager.findBonds();
//				if (UIData.atomtype == UIData.AtomType.hyperball)
//				{
//					if (hbManager.ellipsoidViewEnabled() == true)
//					{
//						Debug.Log ("+++++++++BONDCUBESTULE - Ellipsoid View enabled");
//						hbManager.RenderEllipsoids();
//					}
//					else {
//						Debug.Log ("+++++++++BONDCUBESTULE - Ellipsoid View disabled");
//						hbManager.RenderAtoms();
//					}
//				}
            }
            else if (UIData.bondtype == UIData.BondType.bbhyperstick)
            {
                if (UIData.secondarystruct)
                {
                    bondEPList = MoleculeModel.bondCAList;
                }
                else
                {
                    bondEPList = MoleculeModel.bondEPList;
                }
                Debug.Log("DisplayBonds??bondEPList.Count " + bondEPList.Count);
                int Number = bondEPList.Count / number;

                for (int i = 0; i < Number; i++)
                {
                    CreateBBCylinderByShader(i * number);
                }
            }
        }
Example #3
0
    void Update()
    {
        IMDEnergies energies = new IMDEnergies();

        if (MDDriver_isConnected())
        {
//			if (!logFPS)
//			{
//				logFPS = true;
//				Molecule3DComp.toggleFPSLog ();
//			}
            MDDriver_getEnergies(ref energies);
//			Debug.Log (energies.Etot);
            PlotManager.Instance.PlotAdd("Total Energy", energies.Etot);
            if (Input.GetKeyDown(KeyCode.A))
            {
                MDDriver_pause();
            }

            if (Input.GetKeyDown(KeyCode.Z))
            {
                MDDriver_play();
            }

            int readParticles = MDDriver_getNbParticles();
            //Debug.Log("readParticles: " + readParticles);
            if (readParticles != nbParticles)
            {
                Debug.Log("readParticles: " + readParticles);
                nbParticles = readParticles;
                pos2        = new float[nbParticles * 3];
            }
            else if (pos2.Length == readParticles * 3)
            {
                // Store retrieved positions but let managers update positions later
                readParticles = MDDriver_getPositions(pos2, readParticles);
                List <Vector3> lst = new List <Vector3>();
                for (int i = 0; i < readParticles; i++)
                {
                    lst.Add(new Vector3(pos2[i * 3], pos2[i * 3 + 1], pos2[i * 3 + 2]));
                }
                MoleculeModel.atomsMDDriverLocationlist = lst;
            }

            List <GenericManager> managers = Molecule.View.DisplayMolecule.GetManagers();

            GenericManager atomManager = managers[0];
            atomManager.ResetMDDriverPositions();

            // Copied from DisplayMolecule.GetManagers
            // Does not work otherwise. Why?
            if (UIData.bondtype == UIData.BondType.line)
            {
                GameObject  lineManagerObj = GameObject.FindGameObjectWithTag("LineManager");
                LineManager lineManager    = lineManagerObj.GetComponent <LineManager>();
                lineManager.ResetPositions();
            }
            else if (UIData.bondtype == UIData.BondType.cube)
            {
                GameObject      cubeBondManagerObj = GameObject.FindGameObjectWithTag("CubeBondManager");
                CubeBondManager cubeBondManager    = cubeBondManagerObj.GetComponent <CubeBondManager>();
                cubeBondManager.ResetPositions();
            }
            else if (UIData.bondtype == UIData.BondType.hyperstick)
            {
                GameObject    hStickManagerObj = GameObject.FindGameObjectWithTag("HStickManager");
                HStickManager hStickManager    = hStickManagerObj.GetComponent <HStickManager>();
                hStickManager.ResetPositions();
            }

            if (MDDriver.hb)
            {
//				Debug.Log (RNAView.findHbonds().Count);
//				List<int[]> hbonds = RNAView.findHbonds();
//				Debug.Log (bonds.Count + " bonds found");
//				int sequenceLength = MoleculeModel.sequence.Count();
//				string structure = VARNA.generateStructureString(sequenceLength, hbonds);
//				VARNA.generateImage(MoleculeModel.sequence, structure, "test.png");
            }
        }
        else
        {
            Debug.Log("Not connected...");
        }
    }