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

SclViewport

Overview

You use the SclViewport command to create, delete, maximise, restore, and interact with graphical viewports. The command provides you with a number of sub functions to control, query, and set attributes associated with viewports. The standard system SclSetValueByName and SclGetValueByName functions also provide access to a number of viewport attributes that you can query and set.

Multiple viewports are created by splitting an existing viewport. When you create multiple viewports, you provide information on the orientation of the split, either horizontal or vertical, and the percentage of the split. When a viewport is created, it will contain no visible graphical layers. It is your responsibility as the macro writer to organise the layers within the viewport by making them visible and selectable. You use the SclGetValueByName function, with the viewport reference handle, to make layers visible and selectable.

When a viewport is deleted, the space on the graphics workspace that it occupied is reclaimed by the bordering viewports. Usually, this will be the viewport that had been previously split. Viewports can be maximised to occupy the full graphics workspace and overlay any other viewports that are present. Only one viewport can be maximised at a time.

Synopsis

SclViewport <sub option> <optional parameters>

Description

The SclViewport command supports the following options:

SclViewport split <orientation> <percentage> <viewportHandle>
SclViewport delete <$viewportHandle>
SclViewport maximise <$viewportHandle>
SclViewport restore <$viewportHandle>
SclViewport getById <id>
SclViewport getActive
SclViewport setActive <$viewportHandle>
SclViewport getActiveLayer <$viewportHandle>
SclViewport setActiveLayer <$viewportHandle> <layerHandle>
SclViewport getExtents <$viewportHandle> <minx> <maxx> <miny> <maxy> <minz> <maxz>
SclViewport setExtents <$viewportHandle> <$minx> <$maxx> <$miny> <$maxy> <$minz> <$maxz>
SclViewport getViewScale <$viewportHandle> <x> <y> <z>
SclViewport setViewScale <$viewportHandle> <$x> <$y> <$z>
SclViewport getCameraPosition <$viewportHandle> <x> <y> <z>
SclViewport setCameraPosition <$viewportHandle> <$x> <$y> <$z>
SclViewport getCameraUpVector <$viewportHandle> <x> <y> <z>
SclViewport setCameraUpVector <$viewportHandle> <$x> <$y> <$z>
SclViewport getTargetPosition <$viewportHandle> <x> <y> <z>
SclViewport setTargetPosition <$viewportHandle> <$x> <$y> $<z>
SclViewport action <$viewportHandle>
SclViewport clear <$viewportHandle>
SclViewport eraseTemporaryMarkers <$viewportHandle>
SclViewport eraseGrid <$viewportHandle>
SclViewport erase3DGrid <$viewportHandle>
SclViewport plan <$viewportHandle>
SclViewport section <$viewportHandle>
SclViewport longSection <$viewportHandle>
SclViewport zoomAll <$viewportHandle>
SclViewport zoomIn <$viewportHandle>
SclViewport zoomOut <$viewportHandle>
SclViewport orbitUp <$viewportHandle>
SclViewport orbitDown <$viewportHandle>
SclViewport orbitLeft <$viewportHandle>
SclViewport orbitRight <$viewportHandle>
SclViewport rollLeft <$viewportHandle>
SclViewport rollRight <$viewportHandle>
SclViewport resetView <$viewportHandle>
SclViewport viewToWorld <$viewportHandle> <$xv> <$yv> <xw> <yw> <zw>
SclViewport getpixelsize <$viewportHandle> <$xPixelSize> <$yPixelSize>

Viewports and the Scl Attribute Commands

The standard SclSetValueByName and SclGetValueByName commands can be used to query and set a number of attributes associated with viewports, and with graphical layers loaded into viewports. The tables below list each of these attributes.

Viewport and Layer Attributes

The viewport and layer attribute commands require a valid layer handle as well as the viewport handle. These attributes control how an individual layer is loaded into a viewport. For example, a graphical layer can be visible in one viewport and not another. In this case, the visibility setting for the same layer will be different for each viewport.

Attribute Name Description
visibility A layer can be made visible or invisible for the viewport. If a layer is made invisible, it automatically is not selectable and all data associated with that layer, which is presently visible, is erased from the viewport. The data still exists but it cannot be seen in the viewport. If a layer that is currently invisible is made visible, all data associated with that layer becomes visible again.

The return value from getting visibility is either on or off. When setting visibility the only valid options are on and off.

set setting [$vp SclGetValueByName visibility $layer]
$vp SclSetValueByName visibility $layer "off"
facevisibility A layer in a viewport can have the visibility of the faces of objects turned on or off. This setting does not affect the edges of objects, strings, or any other data displayed in the viewport. The return value from getting face visibility is either on or off. When setting face visibility the only valid options are on or off.
set setting [$vp SclGetValueByName facevisibility $layer]
$vp SclSetValueByName facevisibility $layer "off"
edgevisibility A layer in a viewport can have the visibility of the edges of objects turned on or off. This setting does not affect the faces of objects, strings, or any other data displayed in the viewport. The return value from getting edge visibility is either on or off. When setting edge visibility the only valid options are on or off.
set setting [$vp SclGetValueByName edgevisibility $layer]
$vp SclSetValueByName edgevisibility $layer "off"
selectability A layer can be made selectable or unable to be selected. Any layer that is invisible for the viewport cannot be made selectable. Any layer that is visible can be either selectable or not selectable. If a layer is not selectable then it will not be possible to select any of the data associated with that layer until it is made selectable.

The return value from getting selectability is either on or off. When setting selectability the only valid options are on or off.

set setting [$vp SclGetValueByName selectability $layer]
$vp SclSetValueByName selectability $layer "off"
rendering A layer can have a rendering type for lighting which is limited to that layer. Valid settings for rendering are none, gourand or phong. See the lights on command for further information on rendering methods.
set setting [$vp SclGetValueByName rendering $layer]
$vp SclSetValueByName rendering $layer "phong"
edgelighting A layer can have an edge lighting type which is limited to that layer. The return value from getting edge lighting is either on or off. When setting edge lighting the only valid options are on and off. See the lights on command for further information on edge lighting.
set setting [$vp SclGetValueByName edgelighting $layer]
$vp SclSetValueByName edgelighting $layer "off"
colourinterpolation A layer can have colour interpolation limited to that layer. The return value from getting colour interpolation is either on or off. When setting colour interpolation the only valid options are on and off. See the colour interpolation command for further information on colour interpolation.
set setting [$vp SclGetValueByName colourinterpolation $layer]
$vp SclSetValueByName colourinterpolation $layer "off"

Viewport Attributes

The viewport attribute commands affect settings that relate to only the viewport, or to all layers that are visible in the viewport. No layer handle is required for these attributes.

Attribute Name Description
title When a viewport is created it is assigned an id number. This id is used as the viewport title. You can assign a more descriptive title using the title attribute. The current title of the viewport can also be returned using this attribute.
set title [$vp SclGetValueByName title]
$vp SclSetValueByName title "Section View"
readonly A viewport can be made read only which stops the viewport from becoming active. This means that no user interaction with the viewport can occur. The return value from getting the read only setting is either on or off. When setting the read only attribute the only valid options are on and off.
set setting [$vp SclGetValueByName readonly]
$vp SclSetValueByName readonly "off"
rotationincrement The rotation increment is the angle that is used as the value for incremental rotations of the view. The value is an angle expressed in decimal degrees.
set rotation [$vp SclGetValueByName rotationincrement]
$vp SclSetValueByName rotationincrement 25.0
zoomfactor The zoom factor is a value that is applied when zooming the view to determine the extent of the zoom in or out.
set zoom [$vp SclGetValueByName zoomfactor]
$vp SclSetValueByName zoomfactor 1.5
projection The projection setting determines how lines are drawn in a viewport. The possible settings are either orthographic or perspective. In an orthographic projection, lines that are parallel will remain parallel. In a perspective projection, lines that are parallel get closer together as they get further away from the eye point.
set projection [$vp SclGetValueByName projection]
$vp SclSetValueByName projection "perspective"
stereo The return value from getting the stereo setting is either on or off. When setting the stereo attribute the only valid options are on and off.
set setting [$vp SclGetValueByName stereo]
$vp SclSetValueByName stereo "on"
hiddensurfaces Any graphical display, which would normally be hidden behind any polygons and triobjects, is removed from the display when hidden surfaces are on. The display will normally provide a more meaningful view of the data, but the tradeoff is a longer display refresh time because of the hidden line removal calculations. The return value from getting the hidden surfaces setting is either on or off. When setting the hidden surfaces attribute the only valid options are on or off.
set surfaces [$vp SclGetValueByName hiddensurfaces]
$vp SclSetValueByName hiddensurfaces "off"
3daxis The 3D axis that is displayed in a viewport may be turned on or off. The return value from getting the 3daxis setting is either on or off. When setting the 3daxis attribute the only valid options are on or off.
set axis [$vp SclGetValueByName 3daxis]
$vp SclSetValueByName 3daxis "off"
controls On the viewport title bar are controls for you to split, maximise, and adjust the viewport dimensions. These controls may be turned on or off so they are not visible or selectable. The return value from getting the controls setting is either on or off. When setting the controls attribute the only valid options are on or off.
set setting [$vp SclGetValueByName controls]
$vp SclSetValueByName controls "off"
blockmodeledges When a block model is displayed into a viewport the edges of the model can be set to be on (visible) or off (not visible). The return value from getting the block model edges setting is either on or off. When setting the block model edges attribute the only valid options are on and off.
set bmEdges [$vp SclGetValueByName blockmodeledges]
$vp SclSetValueByName blockmodeledges "off"
blockmodelfaces When a block model is displayed into a viewport the faces (sides of the block) of the model can be set to be on (visible) or off (not visible). The return value from getting the block model edges setting is either on or off. When setting the block model edges attribute the only valid options are on and off.
set bmFaces [$vp SclGetValueByName blockmodelfaces]
$vp SclSetValueByName blockmodelfaces "off"

Working Example

This example demonstrates using some of the functions of the SclViewport command and the various attribute settings, which you can apply to viewports and layers in viewports.

# example to demonstrate using the SclViewport and viewport attribute commands
# divide the main viewport into 6 viewports
set vp1 [SclViewport getActive]
set vp2 [SclViewport split vertical 50 $vp1 ]
set vp3 [SclViewport split horizontal 33 $vp1 ]
set vp4 [SclViewport split horizontal 33 $vp2 ]
set vp5 [SclViewport split horizontal 50 $vp3 ]
set vp6 [SclViewport split horizontal 50 $vp4 ]
# turn the 3daxis and controls off on all viewports
$vp1 SclSetValueByName 3daxis "off" ; $vp1 SclSetValueByName controls "off"
$vp2 SclSetValueByName 3daxis "off" ; $vp2 SclSetValueByName controls "off"
$vp3 SclSetValueByName 3daxis "off" ; $vp3 SclSetValueByName controls "off"
$vp4 SclSetValueByName 3daxis "off" ; $vp4 SclSetValueByName controls "off"
$vp5 SclSetValueByName 3daxis "off" ; $vp5 SclSetValueByName controls "off"
$vp6 SclSetValueByName 3daxis "off" ; $vp6 SclSetValueByName controls "off"
# recall some data and add it to the set of graphics layers
set status [ SclFunction "OPEN FILE" {
  layer="pit1"
  location="SSI_DEMO:surpac_demo/pit1.dtm"
  plugin="Surpac DTM Files"
}]
SclCreateSwa layer "pit1"
# make sure the layer is visible in each viewport
# and only show edges in the right hand viewports
$vp1 SclSetValueByName visibility $layer "on"
$vp2 SclSetValueByName visibility $layer "on"
$vp2 SclSetValueByName facevisibility  $layer "off"
$vp2 SclSetValueByName edgevisibility  $layer "on"
$vp3 SclSetValueByName visibility $layer "on"
$vp4 SclSetValueByName visibility $layer "on"
$vp4 SclSetValueByName facevisibility  $layer "off"
$vp4 SclSetValueByName edgevisibility  $layer "on"
$vp5 SclSetValueByName visibility $layer "on"
$vp6 SclSetValueByName visibility $layer "on"
$vp6 SclSetValueByName facevisibility  $layer "off"
$vp6 SclSetValueByName edgevisibility  $layer "on"
# zoom each viewport to the data extents
SclViewport zoomAll $vp1
SclViewport zoomAll $vp2
SclViewport zoomAll $vp3
SclViewport zoomAll $vp4
SclViewport zoomAll $vp5
SclViewport zoomAll $vp6
# place each viewport into a particular view direction
SclViewport plan $vp1
SclViewport plan $vp2
SclViewport section $vp3
SclViewport section $vp4
SclViewport longSection $vp5
SclViewport longSection $vp6
# rotate the right hand viewports a few times
for {set i 0} {$i < 50000} {incr i} {
  if {!($i % 100)} {
    SclViewport orbitUp $vp2
    SclViewport orbitLeft $vp4
    SclViewport rollRight $vp6
  }
}
# remove all but the first viewport
SclViewport delete $vp2
SclViewport delete $vp3
SclViewport delete $vp4
SclViewport delete $vp5
SclViewport delete $vp6
# turn the axis and controls back on main viewport
$vp1 SclSetValueByName 3daxis "on" ; $vp1 SclSetValueByName controls "on"