Indigo

Distribution

The following items are included:

All binaries except dingonet.dll are offered in 32-bit and 64-bit versions. Depending on the architecture, proper DLL files are loaded automatically from lib32 or lib64 directories. The path to those directories may be set up when creating a library instance.

Rendering

Dingo class object represents a library instance. All operations are represented by methods of this object. Several library instances may be created within one thread to act simultaneously and independently. Please note, however, that the instances cannot be shared across multiple threads. Also, each instance requires a certain amount of memory, and thus it is recommended to have as few instances as possible.

The procedure for rendering workflow is the following:

  1. Create library instance.
  2. Load molecule/reaction structural formula from file/string/buffer.
  3. Set target — file or HDC. If the target is not set, rendering is done to the buffer.
  4. When rendering to file or buffer, set format desired (png, pdf, svg).
  5. Set the target image size in pixels (optional). If the size is not set, it is determined by the average bond size in pixels. The latter one can be set using the setBondLength() method.
  6. Set additional options if necessary (see below)
  7. Call render().
  8. When rendering to buffer, call getResult().

Error Handling

Whenever an error occurs DingoException is thrown. The Message field normally contains the error information passed by the underlying C++ library.

Dingo Class Public Methods

Constructor

Dingo (String prefix);

Receives the relative path to lib32 and lib64 (see Distribution section above for details). E.g., if the libraries are stored in lib/Dingo/lib32 and lib/Dingo/lib64, call new Dingo(“lib/Dingo”).

Dingo ();

Same as Dingo(“.”)

Before loading

void setLogPath (String path);

Sets the path to the log file. If not set, no logging is done.

See also load-highlighting option in option reference.

Loading

void loadMoleculeFromFile (String filename);
void loadMolecule (String str);
void loadMolecule (byte[] buf);

Loads the molecule from file, string, or buffer.

void loadReactionFromFile (string filename);
void loadReaction (byte[] buf);
void loadReaction (String buf);

Loads the reaction from file, string, or buffer.

bool isEmpty ();

Checks whether the loaded molecule/reaction structural formula is empty.

Target and format

void setOutputFormat (String format)

Sets the output format to png, svg, pdf, or wmf for rendering or mol or rxn for molecule and reaction layout respectively. No default value. Case-insensitive.

void setOutputFile (String filename)

Sets the output file. If not set, rendering is performed to internal buffer, which you can later obtain with getResult().

void setOutputHDC (IntPtr hdc);
void setOutputPrintingHDC (IntPtr hdc);

Sets the output to given HDC (display or printer).

Note: HDC is not disposed automatically. E.g., if it is obtained by means of Graphics.GetDC(), call Graphics.ReleaseDC() as the rendering is complete, and call Graphics.Dispose() as you finish with this object. Both are to be done after calling Dingo.render() but before using the result, e.g. saving or displaying the image.

Image size

void setImageSize (int width, int height);

Sets the desired image size in pixels. If no size is given, the picture is adjusted automatically according to the specified bond length and margins:

void setBondLength (float length);

Sets the average bond length in pixels. If the size is not set, this determines the size of the resulting image; otherwise it is ignored. The default value is 100 pixels.

See also margin-factor setting in option reference.

Additional options

The concept of options in Dingo is to make the interface more flexible. Examples of options are relative- thickness, implicit-hydrogen-mode, background-color, etc (names are case-insensitive). image-size, bond-length, output-format, output-file options duplicate the setImageSize, setBondLength, setOutputFormat, and setOutputFile calls, respectively. See Option reference for the complete list of options.

Use an appropriate method depending on the type of the option.

void setOption (string name, string value)
void setOption (string name, bool value)
void setOption (string name, float value)
void setOption (string name, Color value)
void setOption (string name, int w, int h)

One can use the first method for to set options of any kind, e.g. setOption(“base-color”, “0.0,0.0,1.0”) instead of setOption(“base-color”, Color.Blue).

The components of the value are comma-separated, and C-style formatting is used for floats, i.e. decimal point is a period, not a comma.

void setOptions (String options)

It is also possible to set multiple options at once, e.g. setOptions(“implicit-hydrogen-mode=none; coloring=1; aam-color=0.2,0.5,0.3”). The options within the string should be separated by a semicolon. Equality sign may be surrounded by spaces, too.

Rendering

void render ();

Layout

void layout ();

Perform layout and store the result as a MOLFile or RXNFile. Proper format should be set using setOutputFormat().

Getting the result

byte[] getResult ();

Macros

Macros are provided for simplicity. They are called after a structural formula is loaded. You can also set the options before calling a macro.

Bitmap renderToBitmap (int width, int height);

Creates a transparent Bitmap of the size given and performs rendering.

Bitmap renderToBitmap (int width, int height, Color background);

Creates a Bitmap of size given with background given and performs rendering.

Metafile renderToMetafile (int width, int height);

Creates Metafile of the size given and perform rendering.

Metafile renderToMetafile ();

Creates Metafile and perform rendering. Size is determined automatically, based on the molecule/reaction loaded.

Known bugs

Example

Dingo dingo = new Dingo();
try
{
    dingo.loadMoleculeFromFile("test.mol");
        dingo.setOptions("aromatization=aromatize; output-file=out.png;");
        dingo.setOption("output-format", "png");
        dingo.setOption("background-color", Color.White);
        dingo.setOption("relative-thickness", 1.7f);
    dingo.render();
    Console.WriteLine("Done");
}
catch (DingoException ex) 
{
    Console.WriteLine(ex.Message);
}
Console.ReadLine();