示例#1
0
        /// <summary>
        /// Returns a depiction of the chemical structure as a bitmap.
        /// </summary>
        /// <param name="width">The desired width in pixels.</param>
        /// <param name="height">The desired height in pixels.</param>
        /// <returns>The bitmap depicting the chemical structure.</returns>
        public Bitmap ToBitmap(int width, int height)
        {
            Bitmap bitmap = null;

            try
            {
                using (Indigo indigo = new Indigo())
                {
                    IndigoRenderer indigoRenderer = new IndigoRenderer(indigo);
                    indigo.setOption("render-coloring", true);
                    indigo.setOption("render-image-size", width, height);
                    indigo.setOption("render-label-mode", "hetero");
                    indigo.setOption("render-margins", 10, 10);
                    indigo.setOption("render-output-format", "png");
                    indigo.setOption("render-relative-thickness", 1.6f);
                    IndigoObject structure = CreateIndigoStructure(indigo);
                    structure.dearomatize();
                    structure.layout();
                    bitmap = indigoRenderer.renderToBitmap(structure);
                    structure.Dispose();
                }
            }
            catch
            {
                bitmap = Properties.Resources.Error;
            }

            return(bitmap);
        }
示例#2
0
        public TemplateBuilder(List <IndigoObject> chemStructres, Indigo indigo, List <fragmentationRule> rules)
        {
            InitializeComponent();
            _indigo = indigo;
            //Preserve ordering.
            _indigo.setOption("serialize-preserve-ordering", true);
            _chemStructures = chemStructres;
            renderMolecule();

            foreach (fragmentationRule rule in rules)
            {
                this.comboBox1.Items.Add(rule);
            }
            comboBox1.SelectedIndex      = comboBox1.Items.Count - 1;
            this.comboBox1.DisplayMember = "fragmentName";
        }
示例#3
0
        private IndigoRenderer GetRenderer(Indigo indigo, string format = "png", int width = -1, int height = -1)
        {
            var renderer = new IndigoRenderer(indigo);

            indigo.setOption("render-output-format", format);
            indigo.setOption("render-stereo-style", "ext");
            indigo.setOption("render-margins", 5, 5);
            indigo.setOption("render-coloring", true);
            indigo.setOption("render-relative-thickness", "1.5");
            indigo.setOption("render-image-size", width, height);
            return(renderer);
        }
示例#4
0
        public void WriteImageFile(string fname, IndigoObject mol, string format, string comment, float weight)
        {
            switch (format)
            {
            case "png": { indigo.setOption("render-output-format", "png"); break; }

            case "svg": { indigo.setOption("render-output-format", "svg"); break; }

            case "pdf": { indigo.setOption("render-output-format", "pdf"); break; }

            case "emf": { indigo.setOption("render-output-format", "emf"); break; }

            default: throw new Exception("format not handled by Indigo: " + format);
            }

            // http://ggasoftware.com/opensource/indigo/api/options#rendering
            //png, svg, pdf are allowed. On Windows, emf is also allowed.
            indigo.setOption("render-bond-length", "18");

            indigo.setOption("render-relative-thickness", Math.Round(weight, 2).ToString());

            indigo.setOption("render-coloring", true);
            indigo.setOption("render-margins", 1, 1);
            //indigo.setOption("render-atom-ids-visible", true);
            indigo.setOption("render-comment", comment);
            indigo.setOption("render-implicit-hydrogens-visible", false);
            indigo.setOption("render-label-mode", "hetero");
            indigo.setOption("render-comment-font-size", "15");
            indigo.setOption("render-comment-offset", "6");
            mol.layout();
            renderer.renderToFile(mol, fname);

            //indigo.setOption("render-output-format", "svg");
        }
示例#5
0
 public MoleculeBuilder()
 {
     InitializeComponent();
     //Preserve ordering.
     _indigo.setOption("serialize-preserve-ordering", true);
 }