You are here: Surpac Concepts > Macros > SCL > SWA Commands > SclAdd
GEOVIA Surpac

SclAdd

Overview

You can use SclAdd to add a specified SWA to the current set of layers in Graphics.

There are two sets of SWAs to which Scl provides access. These are represented by the sclSwas command and the sclGraphicsLayers command.

SWAs can be created at any time by using the SclCreateSwa command. If the SWA is to be made a Graphics layer the SclAdd command must be used in conjunction with the sclGraphicsLayers command to add a SWA to the list of Graphics layers and to include it into some, or all of the viewports that exist.

To draw data from a Graphics layer, the SWA must not only be added to the set of Graphics layers, it must also be included into at least one viewport. The SclAdd command permits a SWA to be included into one or more viewports at the time the SWA is added to the set of Graphics layers.

The only way to remove a SWA from the set of Graphics layers is to use the SclDestroy command to destroy the SWA and its contents.

Synopsis

sclGraphicsLayers SclAdd $SwaHandle
sclGraphicsLayers SclAdd $SwaHandle $ViewportHandle
sclGraphicsLayers SclAdd $SwaHandle $ViewportHandlesList

Description

Add the specified SWA to the set of Graphics layers and include the SWA into one or more viewports to enable drawing into viewports of interest.

Arguments

  • sclGraphicsLayers
  • This is the command that represents the set of Graphics layers. The SclAdd command can only be applied to this command.

  • SwaHandle
  • Passed by value. This variable must contain the handle to the SWA that is to be added to the set of Graphics layers.

  • ViewportHandle
  • Passed by value. This variable must contain the handle to a viewport. Common usage will often see this argument being the handle of the active viewport which can be obtained by using the SclGetActiveViewport command.

  • ViewportHandlesList
  • Passed by value. An alternate form of the SclAdd command permits a list of viewport handles to be used so that the SWA can be included into more than one viewport. The list of viewport handles can be created using the lappend command.

  • Draw the SWA in all viewports
  • If no viewport handle or viewport handle list is specified then the SWA is included and drawn in all viewports.

Examples

#
# This example shows how a new SWA is created, then added to the
# set of Graphics layers and drawn in the active viewport.
#
# To use this example either create a file called pit1.str or change
# the name of the file to match a file that exists in the current directory
#
SclGetActiveViewport ViewportHandle
# create the swa and add it to the set of Graphics layers
SclCreateSwa SwaHandle "scl graphics layer"
sclGraphicsLayers SclAdd $SwaHandle $ViewportHandle
# load the file and draw it
if {[catch {$SwaHandle SclSwaOpenFile "pit1.str"}] != 0} {
  puts "Error loading file"
} else {
  SclFunction "ZOOM ALL" {}
  $SwaHandle SclGetStrings StringsHandle
  $StringsHandle SclDraw
}

 

#
# This example shows how a new SWA is created, then added to the
# set of Graphics layers and drawn in all viewports by constructing
# a list of viewports to which the Graphics layer is to be added.
#
# To use this example either create a file called pit1.str or change
# the name of the file to match a file that exists in the current directory
#
# create the list of viewports
sclViewports SclIterateFirst Iterator
while {[$Iterator SclIterateNext ViewportHandle] == $SCL_TRUE} {
  lappend ViewportList $ViewportHandle
}
# create the swa and add it to the set of Graphics layers
SclCreateSwa SwaHandle "scl graphics layer"
sclGraphicsLayers SclAdd $SwaHandle $ViewportList
# load the file and draw it
if {[catch {$SwaHandle SclSwaOpenFile "pit1.str"}] != 0} {
  puts "Error loading file"
} else {
  SclFunction "ZOOM ALL" {}
  $SwaHandle SclGetStrings StringsHandle
  $StringsHandle SclDraw
}

 

#
# This example shows how a new SWA is created, then added to the
# set of Graphics layers and drawn in the active viewport.
#
# To use this example either create a file called pit1.str or change
# the name of the file to match a file that exists in the current directory
#
SclGetActiveViewport ViewportHandle
# create the swa and add it to the set of Graphics layers
SclCreateSwa SwaHandle "scl graphics layer"
sclGraphicsLayers SclAdd $SwaHandle
# load the file and draw it
if {[catch {$SwaHandle SclSwaOpenFile "pit1.str"}] != 0} {
  puts "Error loading file"
} else {
  SclFunction "ZOOM ALL" {}
  $SwaHandle SclGetStrings StringsHandle
  $StringsHandle SclDraw
}