geosoft.gxpy.view submodule

Views, both 2D and 3D.

Classes:
View single view on a 2D map
View_3d 3D view in a geosoft.3dv file, or a 3D view on a 2D map.

2D and 3D views can be placed on a geosoft.gxpy.map.Map, though 3D views are stored in a geosoft_3dv file which can be worked with and viewed separately from a map.

Note

Regression tests provide usage examples: Tests

class geosoft.gxpy.view.View(map, name='_unnamed_view', mode=2, coordinate_system=None, map_location=(0, 0), area=(0, 0, 30, 20), scale=100, copy=None)

Bases: object

Geosoft view class.

Parameters:
name:

view name, default is “_unnamed_view”.

map:

geosoft.gxpy.map.Map instance, if not specified a new unique default map is created and deleted when this session finished.

mode:

open view mode:

READ_ONLY
WRITE_NEW
WRITE_OLD

The following are used with mode=geosoft.gxpy.view.WRITE_NEW:

coordinate_system:
 coordinate system as a gxpy.coordinate_system.Coordinate_system instance, or one of the Coordinate_system constructor types.
map_location:(x, y) view location on the map, in map cm
area:(min_x, min_y, max_x, max_y) area in view units
scale:Map scale if a coordinate system is defined. If the coordinate system is not defined this is view units per map metre.
copy:name of a view to copy into the new view.

New in version 9.2.

aspect

view aspect ratio, usually 1.

close()

Close a view. Use to close a view when working outside of a with ... as: construct.

New in version 9.2.

coordinate_system

geosoft.gxpy.coordinate_system.Coordinate_system instance of the view.

delete_group(group_name)

Delete a group from a map. Nothing happens if the view does not contain this group.

Parameters:group_name – Name of the group to delete.

New in version 9.2.

extent_all

extent of all groups in the view as (x_min, y_min, x_max, y_max)

extent_clip

clip extent of the view as (x_min, y_min, x_max, y_max)

extent_group(group, unit=0)

Extent of a group

Parameters:
  • group – group name
  • unit

    units:

    UNITS_VIEW
    UNITS_MAP
    
Returns:

extent as (x_min, y_min, x_max, y_max)

extent_map_cm(extent)

Return an extent in map cm.

Parameters:extent – tuple returned from one of the extent property.

New in version 9.2.

extent_visible

extend of visible groups in the view as (x_min, y_min, x_max, y_max)

get_class_name(view_class)

Get the name associated with a view class.

Parameters:view_class – desired class in this view

Common view class names are:

'Plane'     the name of the default 2D drawing plane

Other class names may be defined, though they are not used by Geosoft.

Returns:name associated with the class, ‘’ if not defined.

New in version 9.2.

group_list

list of groups in this view

group_list_agg

list of geosoft.gxapi.GXAGG groups in this view

group_list_csymb

list of geosoft.gxapi.GXCSYMB groups in this view

group_list_marked

list of marked groups in this view

group_list_visible

list of visible groups in this view

group_list_voxel

list of voxel groups in this view

has_group(group)

Returns True if the map contains this group.

is_3d

True if this is a 3D view

locate(coordinate_system=None, map_location=None, area=None, scale=None)

Locate and scale the view on the map.

Parameters:
coordinate_system:
 coordinate system as a class:gxpy.coordinate_system.Coordinate_system instance, or one of the Coordinate_system constructor types.
map_location:New (x, y) view location on the map, in map cm.
area:New (min_x, min_y, max_x, max_y) area in view units
scale:New scale in view units per map metre, either as a single value or (x_scale, y_scale)

New in version 9.2.

lock

True if the view is locked by a group. Only one group may hold a lock on a view at the same time. When drawing with groups you should use a with geosoft.gxpy.group.Draw(...) as g: construct ensure group locks are properly created and released.

map

geosoft.gxpy.map.Map instance that contains this view.

map_cm_to_view(x, y=None)

Returns the location of this point on the map (in cm) to the view location in view units.

Parameters:
  • x – x, or a tupple (x,y), in map cm
  • y – y if x is not a tupple

New in version 9.2.

mdf(base_view=None)

Returns the Map Description File specification for this view as a data view.

Parameters:base_view – name of the base view on the map from which to calculate margins. If not specified only the left and bottom margin is calculated based on the view clip minimum location and the right and top margins will be 0.
Returns:((x_size, y_size, margin_bottom, margin_right, margin_top, margin_left), (scale, units_per_metre, x_origin, y_origin))
metadata

Return the view/map metadata as a dictionary. Can be set, in which case the dictionary items passed will be added to, or replace existing metadata. All views on a map share the metadata with the map.

New in version 9.2.

name

Name of the view

scale

map scale for the view

set_class_name(view_class, name)

Set the name associated with a class.

Parameters:
  • view_class – class name in this view
  • name – name of the view associated with this class.

Common view class names are:

'Plane'     the name of the default 2D drawing plane

New in version 9.2.

units_name

name of the view distance units

units_per_map_cm

view units per map cm. (eg. a view in ft, with a scale of 1:12000 returns 393.7 ft/cm)

units_per_metre

view units per view metres (eg. a view in ‘ft’ will be 3.28084)

view_to_map_cm(x, y=None)

Returns the location of this point on the map in the view.

Parameters:
  • x – x, or a tupple (x,y), in view units
  • y – y if x is not a tupple

New in version 9.2.

exception geosoft.gxpy.view.ViewException

Bases: Exception

Exceptions from geosoft.gxpy.view.

New in version 9.2.

class geosoft.gxpy.view.View_3d(file_name, mode, _internal=False, **kwargs)

Bases: geosoft.gxpy.view.View

Geosoft 3D views, which contain 3D drawing groups.

Geosoft 3D views are stored in a file with extension .geosoft_3dv. A 3d view is required to draw 3D elements using geosoft.gxpy.group.Draw_3d, which must be created from a geosoft.gxpy.view.View_3d instance.

3D views also contain 2D drawing planes on which gxpy.group.Draw groups are placed. A default horizontal plane at elevation 0, named ‘plane_0’ is created when a new 3d view is created.

Planes are flat by default, but can be provided a grid that defines the plane surface relief, which is intended for creating tinkgs like terrain surfaces on which 2d graphics are rendered.

Planes can also be oriented within the 3D space to create sections, or for other more esoteric purposes.

Constructors:
open() open an existing geosoft_3dv
new() create a new geosoft_3dv

New in version 9.2.

close()

close the view, releases resources.

current_3d_drawing_plane

Name of the current 2d drawing plane, None if not defined. Can be set to a plane number or a name.

file_name

the geosoft_3dv file name

groups_on_plane_list(plane)

List of groups on a plane.

Parameters:plane – name of the plane
Returns:list of groups on the plane

New in version 9.2.

has_plane(plane)

True if the view contains plane

Parameters:plane – name of the plane
Returns:True if the plane exists in the view

New in version 9.2.

name

the view name

classmethod new(file_name=None, area_2d=None, overwrite=False, **kwargs)

Createa a new 3D view.

Parameters:
  • file_name – name for the new 3D view file (.geosoft_3dv added). If not specified a unique temporary file is created.
  • area_2d – 2D drawing extent for the default 2D drawing plane
  • overwrite – True to overwrite an existing 3DV

New in version 9.2.

new_drawing_plane(name, rotation=(0.0, 0.0, 0.0), offset=(0.0, 0.0, 0.0), scale=(1.0, 1.0, 1.0))

Create a new drawing plane in a 3d view.

Parameters:
  • name – name of the plane, overwritten if it exists
  • rotation – plane rotation as (rx, ry, rz), default (0, 0, 0)
  • offset – (x, y, z) offset of the plane, default (0, 0, 0)
  • scale – (xs, ys, zs) axis scaling, default (1, 1, 1)
classmethod open(file_name)

Open an existing geosoft_3dv file.

Parameters:file_name – name of the geosoft_3dv file

New in version 9.2.

plane_list

list of drawing planes in the view

plane_name(plane)

Return the name of a numbered plane

plane_number(plane)

Return the plane number of a plane, or None if plane does not exist.