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

SclDraw

Overview

The SWA (Surpac Work Area) is where all String and DTM data processed by Surpac applications is stored. A complete description of the SWA can be found here.

String and triangle data may be drawn from any SWA that has been added to the set of graphics layers to permit drawing into a 3D graphics viewport. If data that has already been drawn is modified by an Scl script then that data MUST be drawn again using the SclDraw command so that the image of the data matches the data after changes have been made.

The SclDraw command can be applied to the Scl object handles that represent:

  • SWAs
  • Segments
  • Strings
  • Set of strings in a SWA
  • Trisolations
  • Triobjects
  • Set of triobjects in a SWA

At its simplest the SclDraw command draws all child objects of the parent object to which the SclDraw command is applied. For example, to draw all strings in a SWA, obtain the handle to the set of strings in the SWA using the SclGetStrings command and then apply the SclDraw command.

Alternatively a range of child objects that are to be drawn can be specified, with the exception of SWAs. A SWA consists of only two objects, a string table and a triobject table. Therefore applying a range specification to a SWA object will have no effect.

Unless used otherwise, the SclDraw command will use the drawing styles associated with the .str and .dtm file that are defined by the name of the drawing styles file in the string file header. If there is no styles file explicitly defined in the header of the string file then the default styles file defined in the defaults.ssi file by the drawing styles file default option is used.

The drawing styles defined in the styles file can be overridden so that the string or triangle data can be drawn as required without any prior defaults having any influence at all.

Synopsis

$ParentObjectHandle SclDraw <optional child range><optional style specification>

Description

Draw child objects from the specified Scl set of objects into the viewports that the SWA containing the ParentObjectHandle has been added.

Arguments

ParentObjectHandle - This variable must contain the Scl object handle to either a segment, string, set of strings, trisolation, triobject or set of triobjects.

<optional child range> - Passed by value. This argument must take the form range=range expression where the range expression is a conventional Surpac range. The literal range= must be present. It is required so that the order of the range and style arguments are unimportant. The table below shows the various parent object types to which the SclDraw command can be applied and how the optional range is interpreted.

Parent object Child objects Description
SWA Not applicable The range specification has no effect. All strings and all triobjects in the Swa are drawn
Segment Points The optional range is ignored when SclDraw is applied to a segment. This is because all points in a segment are always drawn. If you want finer control over drawing and erasing of individual points then they must exist in different segments.
String Segments The optional range defines the segments that are to be drawn with segment 0 being the first segment in the string. If the range is undefined then all segments of the string are drawn.
Set of strings Strings The optional range defines the strings that are to be drawn with the range defining the string numbers, positive integer values that is. If the range is undefined then all strings are drawn.
Trisolation Triangles The optional range is ignored when SclDraw is applied to a trisolation. This is because all triangles in a trisolation are always drawn. If you want finer control over drawing and erasing of individual triangles then they must exist in different trisolations.
Triobject Trisolations The optional range defines the trisolations that are to be drawn with trisolation 1 being the first trisolation in the triobject. If the range is undefined then all trisolations of the triobject are drawn.
Set of triobjects triobjects The optional range defines the triobjects that are to be drawn with the range defining the triobject numbers, positive integer values that is. If the range is undefined then all triobjects are drawn.

<optional style specification> - Passed by value. String and triangle data that is drawn in a viewport uses a drawing style to determine how the data is rendered in the viewport. The optional style argument takes the form of stlye=style specification where style specification can be an extensive description of how to render the string and triangle data. The literal style= must be present. It is required so that the order of the range and style arguments are unimportant.

Rendering of string and triangle data can have great variation with some of the rendering attributes that can be controlled including:

  • line colour for polylines
  • face colour for triangles and polygons
  • edge colour for triangle and polygon edges
  • line and edge thickness
  • line patterns
  • face patterns
  • text colour, size, font and orientation
  • drawing method, whether to use markers, polylines, polygons or drawing of various point attributes.

A summary of the useful drawing attributes is described below for quick reference.

The style specification takes the form of option=value,option=value, option=value, .... As many options, and values, that are required to describe how the data are to be rendered maybe defined. The entire list may become a very lengthy string. If the drawing style is undefined the SclDraw command will draw the data in some default style as determined by the default styles file.

Option name Description Permitted values Examples
ssi_method Determines how string data is to be drawn, as polylines, polygons, markers, with points attributes or other characteristics. One or more values from the list of permitted values separated using the | character.
  • line - to draw a line
  • marker - to draw a marker
  • polygon - to draw as a colour filled polygon - only if coplanar
  • x, y, z, d1, d2, ... - to draw the specified point attribute
  • <attribute name><alignment code> - draw the specified attribute at the point but offset according to the alignment codes <, >, ^, v, * to indicate left, right, top, bottom or centre justified respectively in any meaningful combination
  • <attribute name>/<spacing>/<text size> - to draw the specified attribute at a defined frequency along a segment at a text height in real world units
  • arrow/<spacing>/<text size> - to draw a special arrow marker at a defined frequency along a segment at a text height in real world units
ssi_method=line - draw a simple line
ssi_method=line|marker - draw a line and a marker at each point
ssi_method=line|marker|z - draw a line, marker and Z value
ssi_method=line|z/100/2 - draw a line and the Z of the first segment point at an interval of 100 and text height of 2 - good for contours
HGS_color

Note: the spelling determines the colour to be used for various characteristics. Multiple HGS_color definitions can be used, each to define the colour of different aspects if they must be different. Colour names may be any of the crayola colour names or colour name combinations used in Surpac or, an RGB colour can be used if required.

RGB colour names can be defined by replacing the colour name in the examples with something of the form R=value G=value B=value where value ranges between 0 and 1.

  • faces=colour name
  • edges=colour name
  • lines=colour name
  • text=colour name
  • faces=colour name
  • faces=(diffuse=colour name,specular=colour name, transmission=colour name,gloss=factor)
  • lines=edges=faces=text= colour name
HGS_color=line=markers=text=red - make it red
HGS_color=line=markers=text=R=1 G=0 B=0 - make it red another way
HGS_color=line=red,HGS_color=marker=blue
HGS_color=faces=(diffuse=red,specular=white,transmission=yellow,gloss=3) - appropriate for solids and surfaces but not strings. Transmission colour is expensive in CPU resources
HGS_line_pattern Defines the pattern to be used for drawing lines. Either a solid line or one of a set of predefined line types can be used. These predefined line types are expressed as a sequence of characters, generally, that give a symbolic representation of the way the line will be rendered.
  • ----
  • - -
  • ....
  • -.-.
  • -..-..
  • -...
  • -- --
  • center
  • phantom

The symbolic representation for the line may have an optional prefix to define how the line ends and optional suffix to define how line joins (at changes in direction) are represented. Permitted line end and join symbols are:

  • | - a butt line end cap
  • [ - a square line end cap
  • ( - a round line end cap
  • ] - a bevel line join
  • > - a mitre line join
  • ) - a round line join

The line end and join styles are generally not noticeable unless thick lines are used.

HGS_line_pattern=----
HGS_line_pattern=- -
HGS_line_pattern=phantom
HGS_line_pattern=(---->
HGS_edge_pattern Defines the pattern to be used for drawing the edges of triangles and polygons. The permitted values are identical to those used for line patterns. Same as for line patterns. Same as for line patterns.
HGS_face_pattern Faces of triangles and polygons are normally drawn with a solid colour. A variety of patterns exist that can be used to render the interior of the face with geometric pattern. as with line and edge patterns, a number of characters are used to define a symbolic representation of the patterns. Permitted patterns for faces include:
  • solid
  • ##
  • ||
  • ==
  • \\
  • //
  • ::
  • <><>
  • [][]
HGS_face_pattern=solid - the default pattern to give colour fill
HGS_face_pattern=## vertical and horizontal lines
HGS_face_pattern=|| - vertical lines only
HGS_face_pattern=// - sloping lines
HGS_line_weight Lines may be drawn with a different thickness. The line weight is a multiplier to be applied to the basic line thickness. A line weight of 2 should give a line about 2 times thicker than the basic line while a line weight of .5 should give a line about half as thick. Line weights are only approximate though since the screen resolution influence the rendering. Any valid floating point number. Extreme values will probably give unexpected results. HGS_line_weight=1
HGS_line_weight=0.5
HGS_line_weight=3
HGS_edge_weight Works similar to line weight, described above, except for triangle and polygon edges. As for HGS_line_weight As for HGS_line_weight
HGS_marker_symbol defines the type of marker symbol that will be used if markers are to be drawn at points. As with line and face patterns, a sequence of characters is used to define a symbolic representation. Basic marker symbols are:
  • *
  • x
  • +
  • .

Hollow marker symbols are:

  • []
  • ()
  • <>
  • |>
  • <|
  • /\
  • /_\

The basic and hollow marker symbols can be combined to give interesting combinations like:

  • (.)
  • (x)
  • [*]
  • |*>
  • (())
  • <+>
  • and so on.
HGS_marker_symbol=.
HGS_marker_symbol=+
HGS_marker_symbol=(+)
HGS_marker_symbol=[*]
HGS_marker_symbol=[x]
HGS_marker_size Defines a factor to apply to the basic marker size. A marker size of 2 will give a marker twice the size of a basic marker while a marker size of .5 will give a marker half the size of the basic marker. Any valid floating point number. Extreme values will probably give unexpected results. HGS_Marker_size=.5
HGS_Marker_size=2
HGS_text_font Defines how the text is to be drawn. A number of constituent parts, separated by the | character go together to form a fully qualified text font definition. The individual text font components that can be defined are shown in the next column. These may be combined with a | separator into a single string as shown in the examples.
  • name=<font name>
  • size=<font size>
  • slant=<slant angle>

Text font names are variable but names that usually always exist include:

  • roman
  • sans serif
  • typewriter
  • stroked
  • Newfield
  • Enfield
  • Brooktondale

Font size is defined as a number and units. The number is any valid floating point number. The units, using a mnemonic code, determine how the size is used. Permitted unit codes for font size are:

  • oru - object relative units i.e. real world units
  • sru - subscreen relative units - a fraction of the height of the containing window
  • point - As in units used by type setters, i.e. 12 point font.
  • pixels - Expressed directly in pixels, i.e. 10 pixels high

Slant angle is a single floating point number that permits the slant of the text, i.e. the angle off vertical, to be defined. A text slant of 0 will give vertical text while a value of 10 degrees will give an italic looking font. The slant angle must be between -75 and + 75 degrees.

HGS_text_font=name=roman|size=0.18 sru
HGS_text_font=name=stroked|size=2 oru|slant=10
HGS_text_path Defines a vector (X Y Z quantities) the describe the angle along which the text will be drawn. Each of the X, Y and Z values is a floating point number, separated by a space. HGS_text_path=1 0 0 - horizontal text drawn along the X axis
HGS_text_path=1 1 0 - text drawn at an angle of 45 degrees
HGS_text_path=1 1 1 - text drawn at 45 degrees and sticking up intro the air

Examples

# 
# This example requires files called draw1.str and draw1.dtm that
# contain at least string 1 and 2 each with multiple segments and
# triobjects 1 and 2.
# 
# The example shows how SclDraw and SclErase can be used.
# 
# 
SclCreateSwa swa "main graphics layer"
$swa SclSwaOpenFile "draw1.dtm"
SclFunction "ZOOM ALL" {}
$swa SclGetStrings strings
# Draw all strings as lines using RGB colour definition
puts "Press a key to draw all strings as lines using RGB colour definition"
SclPause
$strings SclDraw "style=ssi_method=line,HGS_color=line=text=marker=R=1 G=0 B=1"
puts "Press a key to erase the strings"
SclPause
$strings SclErase
# Draw all strings 1 and 2 only as lines with markers using a colour name
puts "Press a key to draw strings 1 & 2 as lines with markers using a colour name"
SclPause
$strings SclDraw "range=1,2" "style=ssi_method=line|marker,HGS_color=line=green,HGS_color=marker=blue"
# just erase string 2
puts "Press a key to erase string 2"
SclPause
$strings SclErase 2
puts "press a key to clear the screen"
SclPause
SclFunction "CLEAR SCREEN" {}
# draw segment string 1 with markers and Z values
puts "Press a key to draw string 1 with markers and Z values"
SclPause
$swa SclCreateString string 1
$string SclDraw "style=ssi_method=marker|z*,HGS_color=marker=pink,HGS_color=text=black,\
HGS_text_font=name=roman|size=0.02 sru"
# window in to have a closer look at the text
SclFunction "WINDOW IN" {}
# zoom all to see everything again
SclFunction "ZOOM ALL" {}
puts "Press a key to erase segment 2 of string 1"
SclPause
$string SclErase 1
puts "press a key to clear the screen"
SclPause
SclFunction "CLEAR SCREEN" {}
# drawing and erasing of a single segment
puts "Press a key to draw segment 1 of string 1"
SclPause
$string SclCreateSegment segment 0
$segment SclDraw 
puts "Press a key to erase segment 1 of string 1"
SclPause
$segment SclErase 
$swa SclGetTriobjects triobjects
# draw triobjects with different face and edge colours
puts "Press a key to draw all triobjects with different face and edge colour and face pattern"
SclPause
$triobjects SclDraw "style=HGS_color=face=green,HGS_color=edge=pink,HGS_face_pattern=##"
puts "Press a key to erase triobject 2"
SclPause
$triobjects SclErase 2
puts "press a key to clear the screen"
SclPause
SclFunction "CLEAR SCREEN" {}