Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# rtTransPres1.qry
# This is a sample script for drawing a solid line symbol for a
# right-lateral transpressional fault. Triangle symbols are
# drawn on the upthrown (left) side of the fault line.
# If this is the wrong side for an individual line, use
# the Spatial Data Editor to reverse its start and end points.
# Strike-slip arrows are drawn centered between triangles,
# at an interval specified by the number of triangles separating
# arrow symbol sets.
# Version March 2008
# Requires TNTmips 2006:72 or later.
# Version 30 April 2008
# Improved drawing of displacement arrows so they look better for
# wider line widths. Arrow offset determined from line width.
# Procedures defined for drawing triangles and displacement arrows.
# Special drawing instructions added for LegendView.
numeric red, green, blue;
numeric triMap, triWidth, halfTri, heightFac, height, spacing, halfSpacing, dist;
numeric arrowLengthMap, arrowSize, wingSizeFac, wingSize, angle, offsetFac, arrowOffset;
numeric triInt, arrowInt, count;
class RVC_GEOREFERENCE vGeoref;
class SR_COORDREFSYS vectCRS;
class STRING coordUnit$;
###################### Set Parameters ##############################
# red, green, blue variables define the color of the line
red = 255; green = 0; blue = 0;
# This variable defines the denominator of the intended map scale.
# It is used as the basis for defining line width and symbol size
# and spacing.
# Example: for 1:24,000 map scale, Scale = 24000
scale = 24000;
# These variables set the dimensions of the triangle symbols.
# TriMap is the desired triangle width in mm, assuming vector
# coordinates are in meters:
triMap = 3;
heightFac = 0.6; # height of triangle as fraction of width
# This variable sets the interval between dashes as multiple of triangle width
triInt = 4;
# This variable sets the width of the lines.
# WidthMap is the desired map width in mm, assuming vector
# coordinates are in meters.
widthMap = 0.6;
# Strike-slip displacement arrows are drawn periodically centered
# between triangles. This variable sets how many triangles
# separate each set of arrows
arrowInt = 3;
# This variable sets the length of the arrows
# ArrowLengthMap is the desired arrow length in mm, assuming vector
# coordinates are in meters:
arrowLengthMap = 6;
# This variable controls the sweep angle of the arrow in degrees
angle = 30; # 30 degree angle
# This variable sets the length of the side of the arrowhead as a
# fraction of the arrow length
wingSizeFac = 0.4;
# This variable controls how far from the base line to draw arrows
# as a multiple of line width
offsetFac = 2.5;
####################### Compute Derived Values ########################
# Check if vector has geographic coordinates (units of degrees instead of meters)
# and if so adjust scale factor to draw symbols of appropriate size.
Vect.GetDefaultGeoref(vGeoref);
vectCRS = vGeoref.GetCoordRefSys();
if (vectCRS.IsProjected() <> 1) {
if (vectCRS.IsLocal() <> 1) {
scale = scale * 0.000009;
}
}
else { # CRS is projected; check coordinate units to adjust scale
# get coordinate unit from the first axis of the planar coordinate system
coordUnit$ = vectCRS.Coordsys.GetAxis(1).Unit.GetSymbol();
scale = scale * GetUnitConvDist("m", coordUnit$);
}
# set final dimensions for drawing
if (DrawingLegendView == 1) { # set dimensions for LegendView based on sample size
triWidth = 0.15 * SampleRect.GetWidth();
width = 0.1 * SampleRect.GetHeight();
arrowSize = 0.4 * SampleRect.GetWidth();
triInt = 3.5;
arrowInt = 1;
}
else { # set dimensions for drawing elements in View using scale
scale = scale / 1000; # conversion from meters to millimeters
triWidth = triMap * scale;
width = widthMap * scale;
arrowSize = arrowLengthMap * scale;
}
# Compute final triangle dimensions
height = heightFac * triWidth; # height of triangle as a fraction of width
halfTri = triWidth * 0.5;
# Compute spacing between triangles as a multiple of width.
spacing = triWidth * triInt;
# Distance derived from spacing to use as origin for drawing displacement arrows
halfSpacing = (spacing * 0.5) - (arrowSize * 0.5);
# Compute final dimensions of the arrow head
wingSize = wingSizeFac * arrowSize;
headBase = wingSize * sind(angle); # length of base of half arrow head
# Compute arrow offset from the base line
arrowOffset = offsetFac * width;
########################## Procedures #######################
### procedure to draw triangle along line
proc drawTriangle ()
{
LineStyleDropAnchor(1); # anchor at left corner of triangle
LineStyleRoll(halfTri); # roll to midpoint of triangle base
LineStyleMoveTo(0,0); # move pen to current line position
LineStyleMoveTo(90, height); # move pen to top corner of triangle
LineStyleDropAnchor(2); # drop anchor at top corner
LineStyleRoll(-halfTri); # roll line pointer back along line to left corner
LineStyleRecordPolygon(); # set up to record vertex positions for triangle polygon
LineStyleRollPen(triWidth); # draw complete base of triangle (to right corner)
LineStyleLineToAnchor(2); # line to top corner anchor
LineStyleLineToAnchor(1); # line from top to left corner anchor
LineStyleDrawPolygon(1); # fill the polygon
}
### procedure to draw right-lateral displacement arrows along line
proc drawArrows ()
{
# Draw first half-arrow forward on left side of line
LineStyleMoveTo(90, arrowOffset);
LineStyleDropAnchor(3); # anchor at base of arrow shaft
LineStyleMoveTo(0, arrowSize); # move forward to tip of arrow
LineStyleDropAnchor(4); # anchor at tip of arrow
LineStyleRecordPolygon(1); # start recording vertices for arrow head polygon
LineStyleLineTo(180 - angle, wingSize); # draw arrowhead side
LineStyleLineTo(-90, headBase); # draw arrowhead base
LineStyleDropAnchor(5);
LineStyleLineToAnchor(4);
LineStyleDrawPolygon(1); # fill polygon
LineStyleMoveToAnchor(5);
LineStyleLineToAnchor(3); # draw arrow shaft back to base
LineStyleMoveToAnchor(4);
# Draw other half-arrow backward on right side of line
LineStyleMoveTo(-90, 2 * arrowOffset); # offset to other side of line
LineStyleDropAnchor(6); # anchor at base of arrow
LineStyleMoveTo(180, arrowSize); # move backward to tip of arrow
LineStyleDropAnchor(7); # anchor at tip of arrow
LineStyleRecordPolygon(1); # start recording vertices for arrow head polygon
LineStyleLineTo(-angle, wingSize);
LineStyleLineTo(90, headBase);
LineStyleDropAnchor(8);
LineStyleLineToAnchor(7);
LineStyleDrawPolygon(1);
LineStyleMoveToAnchor(8);
LineStyleLineToAnchor(6); # draw arrow shaft back to base
}
############################### Draw ###########################
# Set line color and width and draw solid fault line
LineStyleSetColor(red, green, blue);
LineStyleSetLineWidth(width);
LineStyleSetCapJoinType(0,0);
count = arrowInt - 1;
LineStyleDrawLine(); # draw the solid line
# special drawing instructions for LegendView
if (DrawingLegendView)
{
LineStyleRoll(triWidth);
drawTriangle();
LineStyleRoll(triWidth);
drawArrows();
}
else # draw in View
{
# LineStyleRoll(halfSpacing);
# drawTriangle();
# Draw triangles at specified spacing along line
while (LineStyleRoll(spacing) != 1) # while not at end of line, roll spacing distance
{
dist = LineStyleGetDistanceTo(3); # distance to end of line
if (dist > triWidth) {
drawTriangle();
count++;
# draw displacement arrows when line triangle count matches arrowInt
# and set flag to indicate they have been drawn
if (count == arrowInt && dist > halfSpacing + triWidth)
{
LineStyleRoll(halfSpacing); # move pointer along line halfway to next triangle;
# pointer remains at this position while arrows are drawn
drawArrows();
LineStyleRoll(-halfSpacing); # roll pointer back along line to end of previous
# triangle for next triangle iteration to preserve spacing
count = 0; # reset triangle counter to 0;
}
}
}
}