ApplicationEnvironment.h

Classes

ApplicationEnvironment -- (full description)

class ApplicationEnvironment

Interface

Public Members
static Bool isInteractive()
static Bool hasGUI()
static Bool view(String &name)
static Bool stop()
static String choice(const String &descriptiveText, const Vector<String> &choices)
static void registerPGPlotter()
static PlotDevice defaultPlotter(const ObjectID &id)
static PGPlotter getPlotter(const PlotDevice &which)
static PGPlotter createPlotter (const String &device, uInt mincolors=2, uInt maxcolors=100, uInt sizex=600, uInt sizey=450)
static ObjectController *objectController()
Private Members
static Int makeProgressDisplay(Double min, Double max, const String &title, const String &subtitle, const String &minlabel, const String &maxlabel, Bool estimateTime = True)
static void updateProgressDisplay(Int id, Double value)

Description

or

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Etymology

Synopsis

Example

Motivation

Template Type Argument Requirements (T)

Thrown Exceptions

To Do

Member Description

static Bool isInteractive()

Hints

static Bool hasGUI()

Do we have a GUI available ? Usually False if DISPLAY environment variable is unset.

static Bool view(String &name)

View a table

static Bool stop()

If isInteractive() and connected to Glish, get a choice from the user. If !isInteractive(), always return False, else check to see if the user has told this object to stop.

static String choice(const String &descriptiveText, const Vector<String> &choices)

If isInteractive() and connected to Glish, get a choice from the user. IF !isInteractive(), always return the first choice, so it should be the default. For example, if you are asking whether or not the user wants to overwrite a file, the default should be "no". If choices is zero length, always return the empty string.

static void registerPGPlotter()

Register the create function for a PGPlotter object, so it is created in the correct way. It has to be done for each Glish client using PGPlotter.

static PlotDevice defaultPlotter(const ObjectID &id)

Get the default device specification that corresponds to some ObjectID.

Presently, the rules are as follows:

  1. If aipsrc variable user.plot.device is found, it is used. It is a PGPLOT style device representation, with the additional "device"/glish, which sends the plot commands to a Glish PGPlotter if possible. Question marks (?) are turned into unique file names, e.g. plot_?.ps/ps becomes plot_1.ps, plot_2.ps etc. for consecutive plots.
  2. If a user device isn't specified, aipsplot_?.plot/glish is tried if we are attached to glish, otherwise /XS (X-windows server) is tried, otherwise aipsplot_?.ps/cps is tried if no DISPLAY environment variable is set.
  3. If all else fails, use /NULL.

static PGPlotter getPlotter(const PlotDevice &which)

Get the plotter corresponding to the device specification. Applications should be able to deal with the case where plotting isn't possible for some reason, i.e. you should check that isAttached() is True.

static PGPlotter createPlotter (const String &device, uInt mincolors=2, uInt maxcolors=100, uInt sizex=600, uInt sizey=450)

Create a PGPlotter object according to the given device and so. It is a function which can be registered in PGPlotter as the create function.
Open "device", which must be a valid PGPLOT style device. For example, /cps for colour postscript, (or myfile.ps/cps if you want to name the file), or /xs or /xw for an X-windows display.

If your plot cannot back-off gracefully to black and white, you should set mincolors to the minimum number of colors your plot needs to succeed. Generally you should only need to do this for color-raster displays. Similarly, if you know the maximum number of colors you will use, you can prevent colormap flashing by setting maxcolors. If the device cannot supply at least mincolors, isAttached will return False.

Thrown Exceptions

static ObjectController *objectController()

So you can get DO's, etc. Returns null if this process does not have a controller. If the process has more than one controller returns the most recent one created. Do not delete this pointer.

static Int makeProgressDisplay(Double min, Double max, const String &title, const String &subtitle, const String &minlabel, const String &maxlabel, Bool estimateTime = True)
static void updateProgressDisplay(Int id, Double value)

makeProgressDisplay returns an id for a "progress bar" which can be updated with updateProgressDisplay. If the session is not interactive, a null id will be returned and updates will be no-ops. Null strings for the various labels will result in default labels. In particular, if minlabel and maxlabel are empty they will be set to the min and max values.

Progress bar updates are relatively inefficient, so you should try not to send them at the rate of more than probably few a second. The progress bar will automatically remove itself when it hits max, so updates after an update of "max" has been sent will not be visible.

Note that if min is in fact larger than max, the progress bar will still work correctly (counting down instead of up).