geosoft.gxpy.view submodule¶
Views, which can be 2D or 3D, contain groups of graphical elements that can be displayed to a user in a Geosoft Map viewer or a Geosoft 3D viewer. Geosoft maps can contain any number of 2D or 3D views.
Views contain one or more geosoft.gxpy.group.Group
instances. 2D views can contain 2D groups, while
3D views can contain both 2D and 3D groups.
Classes: |
|
---|
Both 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 also be viewed separately from a map.
Note
Regression tests provide usage examples: View tests
-
EXTENT_ALL
= 0¶
-
EXTENT_CLIPPED
= 1¶
-
EXTENT_VISIBLE
= 3¶
-
GROUP_AGG
= 3¶
-
GROUP_ALL
= 0¶
-
GROUP_CSYMB
= 4¶
-
GROUP_MARKED
= 1¶
-
GROUP_VISIBLE
= 2¶
-
GROUP_VOXD
= 5¶
-
READ_ONLY
= 0¶
-
UNIT_MAP
= 2¶
-
UNIT_VIEW
= 0¶
-
UNIT_VIEW_UNWARPED
= 3¶
-
class
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.
Constructors: open()
open an existing view in a map new()
create a new view in a map 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:
UNIT_VIEW UNIT_MAP
Returns: extent as (x_min, y_min, x_max, y_max)
-
extent_map_cm
(extent=None)¶ Return an extent in map cm.
Parameters: extent – tuple returned from one of the extent properties. Default is extent_clip
.New in version 9.2.
-
extent_visible
¶ extent 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
-
guid
¶ The view GUID.
New in version 9.3.
-
gxview
¶ The
geosoft.gxapi.GXIPJ
instance handle.
-
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), defaults to the current x 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 tuple (x,y), in map cm
- y – y if x is not a tuple
New in version 9.2.
-
map_scale
¶ Map scale for this view.
Can be set, in which case the entire view will move on the map.
-
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
-
classmethod
new
(map=None, name='_unnamed_view', coordinate_system=None, map_location=(0, 0), area=(0, 0, 30, 20), scale=100, copy=None)¶ Create a new view on a map.
Parameters: map: geosoft.gxpy.map.Map
instance, if not specified a new unique default map is created and deleted when this session finished.name: view name, default is “_unnamed_view”. 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.
-
classmethod
open
(map, view_name, read_only=False)¶ Open an en existing view on a map.
Parameters: - map –
geosoft.gxpy.map.Map
- view_name – name of the view
- read_only – True to open read-only
Returns: View
instanceNew in version 9.2.
- map –
-
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 tuple (x,y), in view units
- y – y if x is not a tuple
New in version 9.2.
-
-
exception
ViewException
¶ Bases:
Exception
Exceptions from
geosoft.gxpy.view
.New in version 9.2.
-
class
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 usinggeosoft.gxpy.group.Draw_3d
, which must be created from ageosoft.gxpy.view.View_3d
instance.3D views also contain 2D drawing planes on which
geosoft.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 things 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
¶ Current drawing plane name in a 3D view,
None
if not defined. Can be set to a plane number or name.
-
current_3d_drawing_plane_number
¶ The current drawing plane number, can be set.
-
file_name
¶ the
geosoft_3dv
file name
-
groups_on_plane_list
(plane=0)¶ List of groups on a plane.
Parameters: plane – name of the plane or plane number 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)¶ Create 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.
-
set_plane_relief_surface
(surface_grid_name, refine=2, base=0, scale=1, min=None, max=None)¶ Establish a relief surface for the current plane based on a grid.
Parameters: - surface_grid_name – grid file name
- refine – relief refinement between 1 (low) and 4 (high). Default is 2.
- base – base value in grid, will be at z=0. Default is 0.
- scale – scale to apply to grid after removing base, default is 1.
- min – minimum clip in unscaled grid values
- max – maximum clip in unscaled grid values
New in version 9.3.
-
-
WRITE_NEW
= 1¶
-
WRITE_OLD
= 2¶