Declaration: SelectSpectrum(var PosX, PosY, Layer, TimeSlot: integer; Caption: string): integer;
Opens the spectrum selection dialog which allows you to select a particular pixel (and a layer) of the image cube. You can move both the cursor in the spectrum (which changes the displayed layer) and the position cursor in the image. When changing the position cursor the corresponding spectrum is displayed in the spectral window at the left. Clicking the OK button selects the current spectrum and layer.

When calling the dialog the variable parameters PosX, PosY, Layer and TimeSlot control the initial cursor positions, on return these parameters contain the selected values (pixel coordinates and layer index). If PosX and PosY are both set to zero values when calling the function, the intial position is set to the center of the image. If the Layer parameter is set to zero the spectral cursor is set to the center of the spectrum. The parameter Caption controls the caption of the dialog, you may leave it empty to display the default caption "Please select a spectrum".

The following image shows the spectrum selection dialog:

The function provides the following return codes:

 0 ... everything is OK
-1 ... the initial position [PosX,PosY] is invalid
-2 ... the initial layer is invalid
-3 ... the user cancelled the dialog

Sample Program: The following short example shows how to select a spectrum and how to calculate the mean spectrum of the pixels surrounding the selected position:
program MeanSpec;

  QUADSIZE = 5;  // size of quadratic region to be averaged
  PAGE = 1;      // chartbook page

  PosX, PosY     : integer;
  Layer          : integer;
  TimeSlot       : integer;
  i              : integer;

if SelectSpectrum(PosX, PosY, Layer, TimeSlot, 'Please select a position') = 0 then
  GetMeanSpectrum (PosX-QUADSIZE div 2, PosY-QuadSize div 2,
                   PosX-QUADSIZE div 2+QUADSIZE-1, PosY-QuadSize div 2+QUADSIZE-1,
     (PAGE,               // page 1
      true, false, false, // only the chart is visible
      250, 250);          // default width & height
  ChartBook.TabCaption[PAGE] := 'Spectrum';
  with ChartBook.Charts[PAGE] do
    Caption := 'Mean spectrum at position ['+IntToStr(PosX)+','+IntToStr(PosY)+
               ']; averaged area: '+IntToStr(QUADSIZE)+'x'+IntToStr(QUADSIZE)+
               ' pixels';
    GridStyle := gsDotLines;
    GridColor := clSilver;
    ScalePropsY[1].ShortTicks := false;
    for i:=1 to MData.CubeSize[dimL] do
      DrawTo (i, spec[i-1]);
    AutoRange (1,4);