Using ILFigure

Whenever a visual output is needed, but no control surface is available, one can use ILFigure to create a plotting dialog. ILFigure therefore enables the creation of plots for console applications also.

Basically, ILFigure is a Windows.Forms.Form, containing an ILSubfigure as only control.

Creation of ILFigure forms is simple:

  • include needed references (ILNumerics.Drawing.dll)
  • include needed namespaces
  • create and configure an instance of ILFigure
  • display the ILFigure as regular form or as dialog

ILFigure example

The following code creates an ILFigure dialog from within a console application, showing some example data as imagesc graph. In order to compile it with Visual Studio 2005, create a new Console Application project, include both references (ILNumerics.Drawing.dll and ILNumerics.Net.dll) and replace the content of the only class file with that code:

using ILNumerics; 
using ILNumerics.Drawing; 
using ILNumerics.Drawing.Graphs; 
using ILNumerics.Drawing.Controls; 
using ILNumerics.BuiltInFunctions; 
using System.Windows.Forms; 

namespace Example8 {
class Program {
    static void Main(string[] args) {
        ILArray<double> tmp = SampleData.CreateData(120,120,1); 
        ILFigure fig = new ILFigure(); 
        fig.ActiveSubfigure.Panel.Graphs.AddImageSCGraph(tmp);
        ILPanel panel = fig.ActiveSubfigure.Panel; 
        (panel.Graphs[0] as ILImageSCGraph).Wireframe.Visible = false; 
        fig.ShowDialog(); 
    }
    public class SampleData : ILNumerics.Algorithms.ILAlgorithm {
        public static ILArray<double> CreateData (int rows, int cols, float den) {
            ILArray<double> x = repmat(linspace(-pi*den,pi*den,rows).T,1,cols); 
            ILArray<double> y = repmat(linspace(-pi*den,pi*den,rows),rows,1); 
            ILArray<double> tmp = cos(x*y) * 2;
            return tmp; 
        }
    }
}
}

Notice the access of the panel contained in the figure: fig.ActiveSubfigure.Panel. This gives access to the panel, which is contained in the (currently 'only one') subfigure for the ILFigure.

The complete code for this example can be downloaded here.



Valid CSS! Valid XHTML 1.0 Transitional