OpenGUI

This program shows how to start the VisIt GUI from within your Java application. By altering the arguments passed to the OpenClient() method, you could launch other VisIt clients too. A VisIt client is a program that uses the ViewerProxy class to control the viewer. Examples of VisIt clients are: VisIt’s GUI, VisIt’s Python interface (CLI), and any program that uses the VisIt Java interface.

Running the program

From a released client to an installed VisIt of the same version:

java -cp . OpenGUI -stay -path /path/to/visit/bin -datapath /path/to/silodata

From a development build/java directory:

java -cp .:visit.jar OpenGUI -stay -dv -datapath /path/to/silodata

Program source code

The important part of this code is the call to the OpenClient() method. The OpenClient method takes 3 arguments: clientName, clientProgram, clientArgs. The clientName is the internal name that will be used to identify the client inside of VisIt. You can pass any name that you want for this. The clientProgram argment is a string that identifies the executable for your program. The clientArgs argument lets you pass command line arguments to your program when it is started. When you call OpenClient(), the VisIt viewer will attempt to launch the specified VisIt client and then the client will be attached to VisIt and can control the VisIt viewer. Any number of VisIt clients can be connected to the VisIt viewer.

// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

import llnl.visit.ViewerProxy;
import java.util.Vector;

// ****************************************************************************
// Class: OpenGUI
//
// Purpose:
//   This class implements an example program that shows how to use the
//   ViewerProxy class and control VisIt's viewer from Java.
//
// Notes:
//
// Programmer: Brad Whitlock
// Creation:   Mon Aug 17 13:40:40 PDT 2009
//
// Modifications:
//
// ****************************************************************************

public class OpenGUI extends RunViewer
{
    public OpenGUI()
    {
        super();
    }

    protected void work(String[] args)
    {
        // Do a plot of the data.
        String db = new String("globe.silo");
        if(viewer.GetViewerMethods().OpenDatabase(viewer.GetDataPath() + db))
        {
            viewer.GetViewerMethods().AddPlot("Pseudocolor", "u");
            viewer.GetViewerMethods().AddPlot("Mesh", "mesh1");
            viewer.GetViewerMethods().DrawPlots();
        }
        else
        {
            System.out.println("Could not open the database!");
        }

        // Open the VisIt GUI.
        String clientName = new String("GUI");
        String clientProgram = new String("visit");
        Vector clientArgs = new Vector();
        clientArgs.add(new String("-gui"));
        viewer.GetViewerMethods().OpenClient(clientName, clientProgram, clientArgs);
    }

    public static void main(String args[])
    {
        OpenGUI r = new OpenGUI();
        r.run(args);
    }
}