SelectLayer

Declaration: SelectLayer(InitialLayer: integer; AllowMultiSelect, RestrictToGroup: boolean; var LayerList: TIntArray; Caption: string): integer;
Opens the layer selection dialog. The parameter InitialLayer sets the layer cursor to the specified layer. On return, the function delivers a positive integer which specifies the selected layer. A returned zero value indicates that the user did not make a selection at all, and a value of -1 indicates that the InitialLayer was invalid. If the parameter AllowMultiSelect is TRUE the user can select more than one layer. In this case the open integer array LayerList contains the list of selected layers (this parameter can be used as an input as well in order to pre-select specific layers). The parameter Caption controls the caption of the dialog.

The parameter RestrictToGroup allows you to disable the selection of layers other than the layers which belong to the same spectral group as the InitialLayer.

The following image shows the layer selection dialog with the option AllowMultiSelect set to TRUE:

Sample program: The following code lets you select a few layers, then calculates the sum of the selected layers and visualizes the resulting matrix as a special image in the 2D Imager:

program LayerSum;

var
  imgmat    : TDouble2DArray;
  i         : integer;
  ll        : TIntArray;
  Weights   : TDoubleArray;

begin
SetLength(ll,0);
if SelectLayer (1,true,true,ll,'Please select the layers to be added up') > 0 then
  begin
  SetLength(Weights, length(ll));
  for i:=1 to length(ll) do
    Weights[i-1] := 1;
  WeightedSumOfLayers (ll, Weights, 1, imgmat);
  AddImgToRepository (imgmat, 1, 1, 'Sum',
        'sum of the following layers: '+IntList(ll,'; '));
  end;
end.