Example #1
0
        /// <summary>
        /// Downloads a PDB file from a specified URL.
        /// Shows a Message Dialog when an error occurs.
        /// </summary>
        /// <returns><c>true</c>, if molecule was imported properly, <c>false</c> otherwise.</returns>
        /// <param name="url">URL.</param>
        /// <param name="name">Name.</param>
        public bool DownloadFile(string url, string name)
        {
            WWW www = new WWW(url);

            while (!www.isDone)
            {
                EditorUtility.DisplayProgressBar("Download", "Downloading...", www.progress);
            }

            EditorUtility.ClearProgressBar();

            if (!string.IsNullOrEmpty(www.error))
            {
                EditorUtility.DisplayDialog("Error", www.error, "Close");
                return(false);
            }
            else
            {
                PdbParser p = PdbParser.FromString(url, www.text, name);
                Molecule  m = p.Parse();
                Create(m);

                return(true);
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CellUnity.Model.Pdb.PdbParser"/> class.
        /// The PDB data is aquired from the specified filename
        /// </summary>
        /// <returns>new PDB Parser instance.</returns>
        /// <param name="filename">Filename of the PDB file.</param>
        public static PdbParser FromFile(string filename)
        {
            PdbParser p = new PdbParser("file://" + filename);

            p.data = File.ReadAllLines(filename);
            return(p);
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CellUnity.Model.Pdb.PdbParser"/> class.
        /// The PDB data is aquired from the data string.
        /// </summary>
        /// <returns>new PDB Parser instance.</returns>
        /// <param name="source">Source of the definition. e.g. URL or Filename of the PDB file.</param>
        /// <param name="data">PDB data.</param>
        /// <param name="name">Name of the species.</param>
        public static PdbParser FromString(string source, string data, string name)
        {
            PdbParser p = new PdbParser(source);

            p.data = data.Replace("\r", "").Split('\n');
            p.name = name;
            return(p);
        }
Example #4
0
        /// <summary>
        /// Shows an OpenFilePanel and lets the user select a pdb file.
        /// </summary>
        public void UserSelectFile()
        {
            string filename = EditorUtility.OpenFilePanel("PDB File", "", "pdb");

            if (!string.IsNullOrEmpty(filename))
            {
                PdbParser p = PdbParser.FromFile(filename);
                Molecule  m = p.Parse();
                Create(m);
            }
        }