예제 #1
0
    void Start()
    {
        Instance = this;
        StartCoroutine(this.Load());

        startingPosition = transform.localPosition;
        this.Started     = false;
    }
예제 #2
0
    private void HandleMenuClicked(object sender, ClickedEventArgs e)
    {
        molnum = molnum + 1;
        MoleculeLoader.deleteAllBonds();
        MoleculeLoader.deleteAllAtoms();
        MoleculeLoader x = new MoleculeLoader();

        x.AtomUpdate(molnum, molParent, atomParent, bondParent);
    }
예제 #3
0
        private void SupportedFormatsInfoDlg_Load(object sender, EventArgs e)
        {
            int temp;

            if (MoleculeLoader.supportedFormats == null)
            {
                MoleculeLoader.CreateOpenFilter(out temp, null);
            }

            //FileStream fs = new FileStream("formats.txt", FileMode.Create);
            //StreamWriter file = new StreamWriter(fs, Encoding.UTF8);

            foreach (IChemFormatMatcher format in MoleculeLoader.supportedFormats)
            {
                StringBuilder exts = new StringBuilder();

                string io = "";
                if (format.ReaderClassName != null && format.ReaderClassName.Length > 0)
                {
                    io += "Read";
                }
                if (format.WriterClassName != null && format.WriterClassName.Length > 0)
                {
                    if (io.Length > 0)
                    {
                        io += "/Write";
                    }
                    else
                    {
                        io += "Write";
                    }
                }

                int idx = 0;
                foreach (string ext in format.NameExtensions)
                {
                    if (idx++ > 0)
                    {
                        exts.Append(",");
                    }

                    exts.Append("*.");
                    exts.Append(ext);
                }

                ListViewItem item = new ListViewItem(new string[] { format.FormatName, exts.ToString(), format.MIMEType,
                                                                    format.XMLBased.ToString(), io });

                listView1.Items.Add(item);

                //file.WriteLine(format.FormatName + " | " + exts.ToString());
            }

            //file.Close();
            //fs.Close();
        }
예제 #4
0
        private void LoadingProcess()
        {
            progress                  = new LoadingProgress(3);
            progress.OnUpdate        += new LoadingProgress.ProgressUpdateHandler(progress_OnUpdate);
            progress.OnProcessUpdate += new LoadingProgress.ProcessUpdateHandler(progress_OnProcessUpdate);
            loadedChemFile            = MoleculeLoader.LoadFromFile(filename, progress);

            // close dlg
            this.Invoke(closeDelegate);
        }
예제 #5
0
 private void HandleUngripped(object sender, ClickedEventArgs e)
 {
     gripped  = 0;
     searched = 0;
     MoleculeLoader.updateAllPositions();
     if (mode == 3)
     {
         MoleculeLoader.deleteAllBonds();
         MoleculeLoader.updateAllPositions();
         MoleculeLoader.redrawBonds();
     }
 }
예제 #6
0
        public void OpenMoleculeDialog()
        {
            OpenFileDialog dialog = new OpenFileDialog();
            // TODO: Build filter from known formats
            int filterIdx;

            dialog.Filter      = MoleculeLoader.CreateOpenFilter(out filterIdx, dialog.InitialDirectory);
            dialog.FilterIndex = filterIdx;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                LoadFile(dialog.FileName);
            }
            dialog.Dispose();
        }
예제 #7
0
        private void OpenMolecule()
        {
            if (openDlg == null)
            {
                openDlg       = new OpenFileDialog();
                openDlg.Title = "Open Molecule";

                int filterIdx;
                //if (lastLocation == null)
                //    lastLocation = Application.StartupPath;
                //openDlg.InitialDirectory = Environment.CurrentDirectory;
                openDlg.Filter = MoleculeLoader.CreateOpenFilter(out filterIdx, null);
            }
            //dlg.FilterIndex = filterIdx;
            if (openDlg.ShowDialog(this) == DialogResult.OK)
            {
                OpenMolecule(openDlg.FileName);
            }
            //dlg.Dispose();
        }
예제 #8
0
    private void Update()
    {
        if (mode == 0 && (gripped == 1))
        {
            Vector3 ang = _controller.transform.eulerAngles;
            ang.x += -90;
            mol.transform.eulerAngles = ang;
        }

        if (mode == 3 && (gripped == 1))
        {
            if (searched == 0)
            {
                xb       = MoleculeLoader.findMole(transform.position);
                searched = 1;
            }
            //xb.pos = _controller.transform.position;
            xb.sphere.transform.position = _controller.transform.position;
        }
    }
예제 #9
0
        public void LoadFile(string file)
        {
            MoleculeLoadingResults results = null;

            try
            {
                renderSource = new ChemRenderingSource3D(MoleculeLoader.LoadFromFile(file, settings, MoleculeLoader.FileUsage.ThreeD, null, out results));
                if (renderContext != null)
                {
                    renderContext.ChemRenderSource = renderSource;
                    renderContext.OnResize(Width, Height);
                    renderContext.Render(null);
                }
            }
            catch (UserLevelException ule)
            {
                // post to user
                MessageBox.Show(ule.Message, "Loading File", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            UleDlg dlg = new UleDlg(results, null);

            dlg.ShowDialog();
            dlg.Dispose();
        }
예제 #10
0
    private void HandleTriggerClicked(object sender, ClickedEventArgs e)
    {
        MoleculeLoader.atom_info x = MoleculeLoader.findMole(transform.position);
        tvNameText.text = x.name;

        switch (x.name)
        {
        case "Pb":
            tvRadiusText.text = "1.47" + " Å";
            tvWeightText.text = "207.2";
            break;

        case "I":
            tvRadiusText.text = "1.33" + " Å";
            tvWeightText.text = "126.904";
            break;

        case "C":
            tvRadiusText.text = "0.77" + " Å";
            tvWeightText.text = "12.011";
            break;

        case "H":
            tvRadiusText.text = "0.37" + " Å";
            tvWeightText.text = "1.008";
            break;

        case "N":
            tvRadiusText.text = "0.75" + " Å";
            tvWeightText.text = "14.007";
            break;

        case "Zn":
            tvRadiusText.text = "1.31" + " Å";
            tvWeightText.text = "65.38";
            break;

        case "Cu":
            tvRadiusText.text = "1.38" + " Å";
            tvWeightText.text = "63.546";
            break;

        case "S":
            tvRadiusText.text = "1.02" + " Å";
            tvWeightText.text = "32.06";
            break;

        default:
            tvRadiusText.text = "1" + " Å";
            tvWeightText.text = "10";
            break;
        }


        // Rotate Entire Molecule
        if (mode == 0)
        {
            // Code is in update
        }

        // Get Distance Between 2
        if (mode == 1)
        {
            if (f1 == 0)
            {
                a1 = x;
                f1 = 1;
            }
            else
            {
                a2 = x;
                f2 = 1;
            }
            if ((f1 == 1) && (f2 == 1))
            {
                f1 = 0;
                f2 = 0;
                tvModeValueText.text = (Vector3.Distance(a1.pos, a2.pos) * 22).ToString() + " Å";
            }
        }

        // Get Angle Between 3
        if (mode == 2)
        {
            if (f1 == 0)
            {
                a1 = x;
                f1 = 1;
            }
            else if ((f2 == 0) && (f1 == 1))
            {
                a2 = x;
                f2 = 1;
            }
            else if ((f2 == 1) && (f1 == 1))
            {
                a3 = x;
                f3 = 1;
            }
            if ((f1 == 1) && (f2 == 1) && (f3 == 1))
            {
                f1 = 0;
                f2 = 0;
                f3 = 0;
                Vector3 AB = a1.pos - a2.pos;
                Vector3 BC = a3.pos - a2.pos;

                tvModeValueText.text = Vector3.Angle(AB, BC).ToString() + " °";
            }
        }

        // Move single molecule and then redraw bonds
        if (mode == 3)
        {
        }

        if (mode == 4)
        {
            MoleculeLoader.writeXYZ();
        }
    }