You are here: Surpac Concepts > Macros > SCL > Viewport and Layers > SclSetActiveLayer
GEOVIA Surpac

SclSetActiveLayer

Overview

The 3D Graphics environment that Scl integrates with has viewports that string and triangle data are drawn in. There is always at least one viewport but there may be more than one viewport, depending on the users actions.

There is always one viewport that is known as the active viewport. This viewport is indicated by the title bar of the viewport being highlighted in a different colour to other viewports.

Each viewport has one layer (SWA) that is known as the active layer. This layer is treated as the top layer in a set of overlay plans and it is the only layer that conventional graphics editing commands may operate upon to modify data. Note that this restriction does not exist for Scl scripts as the script author may modify data in any layer that seems appropriate.

It may be necessary for the script author to be able to query and set the active layer depending upon the needs of the problem being solved. Note that different viewports can have different active layers.

The SclSetActiveLayer command sets the active layer for a specified viewport to be a particular graphics layer.

Synopsis

$ViewportHandle SclSetActiveLayer $SwaHandle

Description

Set the active layer for the specified viewport to be a particular graphics layer. Note that the SWA referenced by $SwaHandle must already be a graphics layer.

Arguments

  • ViewportHandle
  • The handle to the viewport for which the active layer is to be set must be stored in this variable.

  • SwaHandle
  • Passed by value. The handle to the graphics layer that is to be made the active layer for this viewport must be stored in this variable.

Examples

# 
# This example shows how the active layer is set for the active viewport.
# A string file is then loaded into this layer and drawn
# 
# create the new swa
SclCreateSwa SwaHandle "scl layer"
# set the active layer for the active viewport
SclGetActiveViewport ViewportHandle
sclGraphicsLayers SclAdd $SwaHandle $ViewportHandle
$ViewportHandle SclSetActiveLayer $SwaHandle
# load the file with error detection
if {[catch {$SwaHandle SclSwaOpenFile "pit1.str"}] != 0} {
  puts "Error loading pit1.str"
} else {
  # draw the data 
  $SwaHandle SclGetStrings StringsHandle
  $StringsHandle SclDraw
  # do a zoom all to ensure we can see everything
  SclFunction "ZOOM ALL" {}
}