geosoft.gxpy.group submodule¶
Render groups in 3D views, or to 2D views on a map.
Classes: |
|
---|
Note
Regression tests provide usage examples: group drawing tests
See also
-
class
geosoft.gxpy.group.
Aggregate_group
(view, group_name, mode)¶ Bases:
geosoft.gxpy.group.Group
Aggregate groups on a map
Parameters: - view –
gxpy.view.View
instance - name – group name, default uses the aggregate name
- agg –
gxpy.agg.Aggregate_image
instance
Constructors: open() open an existing aggregate group new() create a new aggregate group Properties: name: aggregate group name agg: gxpy.agg.Aggregate_image
instanceNew in version 9.2.
-
classmethod
new
(view, agg, name=None)¶
-
classmethod
open
(view, group_name)¶
- view –
-
class
geosoft.gxpy.group.
Color
(color, model=0)¶ Bases:
object
Colours, which are stored as a 24-bit color integer.
Parameters: - color –
string descriptor (eg. ‘R255G0B125’), color letter R, G, B, C, M, Y, H, S or V.; tuple (r, g, b), (c, m, y) or (h, s, v), each item defined in the range 0 to 255; 24-bit color number, which can be an item selected from the following list:
C_BLACK C_RED C_GREEN C_BLUE C_CYAN C_MAGENTA C_YELLOW C_GREY C_LT_RED C_LT_GREEN C_LT_BLUE C_LT_CYAN C_LT_MAGENTA C_LT_YELLOW C_LT_GREY C_GREY10 C_GREY25 C_GREY50 C_WHITE C_TRANSPARENT
- model –
model of the tuple:
CMODEL_RGB (default) CMODEL_CMY CMODEL_HSV
New in version 9.2.
-
cmy
¶ color as an (cyan, magenta, yellow) tuple, can be set
-
int_value
¶ color as a 24-bit color integer, can be set
-
rgb
¶ color as an (red, green, brue) tuple, can be set
- color –
-
class
geosoft.gxpy.group.
Color_map
(cmap=None, title=None, units=None)¶ Bases:
object
Color map for establishing data color mapping for things like aggregates and color symbols.
Parameters: cmap – the name of a Geosoft color map file (.tbl, .zon, .itr, .agg) from which to establish the initial colors. If the file does not have zone values, which is the case for a .tbl file, the Color_map will be uninitialized and you can use one of the set methods to establish zone values.
You can also provide an int_value, which will create an uninitialized map of the the specified length, or a
geosoft.gxapi.GXITR
instance.If not specified the Geosoft default color table is used.
-
brightness
¶ Brightness is a value between -1 (black) and +1 (white), The default is 0. :returns: brightness, -1 to +1
New in version 9.2.
-
color_map
¶ list of zone limts, colours in the color map
-
color_map_rgb
¶ list of zone limits and (red, green, blue) colours
-
color_of_value
(value)¶ Return the gxg.Color of a value. The mapping is determined with exclusive minima, inclusive maxima for each color level. Values <= level [0] are assigned the [0] color, and values greater than the the [n-2] level are assigned the [n-1] color.
Parameters: value – data value Returns: Color
instanceNew in version 9.2.
-
initialized
¶ Returns True if the color_map has been initialized to have zone boundaries.
New in version 9.2.
-
length
¶ Number of color zones in the map.
-
model_type
¶ Geosoft colour model used in the Geosoft
geosoft.gxapi.GXITR
-
save_file
(file_name=None)¶ Save to a Geosoft file, .tbl, .itr or .zon. If the file_name does not have an extension and the color_map has not been initialized a .tbl file is created (colors only), otherwise a .itr is created, which contains both zone boundaries and colors.
Parameters: file_name – file name, if None a temporary file is created Returns:
-
set_linear
(minimum, maximum, inner_limits=True, contour_interval=None)¶ Set the map boundaries based on a linear distribution between minimum and maximum.
Parameters: - minimum – minimum
- maximum – maximum
- inner_limits – True if the range specifies the inner limits of the color mappings, in which case values less than or equal to the minimum are mapped to the first color and colors greater than the maximum are mapped to the last color. If False, the minimum and maximum are at the outer-edges of the color map.
- contour_interval – align color edges on this interval, which is useful for matching colors contour map, for example. The color map will be reduced in size by thinning of unneeded colors if necessary.
New in version 9.2.
-
set_logarithmic
(minimum, maximum, contour_interval=None)¶ Set the color boundaries based on a logarithmic distribution between minimum and maximum.
Parameters: - minimum – minimum, must be > 0
- maximum – maximum
- contour_interval – align color edges on this interval, 10 for powers of 10. unneeded colors if necessary.
New in version 9.2.
-
set_normal
(standard_deviation, mean, expansion=1.0, contour_interval=None)¶ Set the color boundaries using a normal distribution around a mean.
Parameters: - standard_deviation – the standard deviation of the normal distribution.
- mean – maximum
- contour_interval – align color edges on this interval, 10 for powers of 10. unneeded colors if necessary.
New in version 9.2.
-
set_sequential
(start=0, increment=1)¶ Set color map zones based on a start and increment between each color zone.
Parameters: - start – minimum zone boundary, values <= this value will have the first color
- increment – increment between each color.
New in version 9.2.
-
title
¶ Title, usually the name of the data from which the color bar was made or is intended. None if no title
New in version 9.2.
-
units
¶ Data units, expected to be the units of the data from which the color bar was made or is intended. None if no units
New in version 9.2.
-
-
class
geosoft.gxpy.group.
Color_symbols_group
(view, group_name, mode)¶ Bases:
geosoft.gxpy.group.Group
Create a color symbols group with color mapping.
Parameters: - view – the view in which to place the group
- name – group name
- data – iterable that yields ((x, y), data), or ((x, y, z), data, ...). Only ((x,y), data) is used.
- color_map – symbol fill color
Color_map
. Symbols are filled with the color lookup using data. - symbol_def –
Text_def
defines the symbol font to use, normally symbols.gfn is expected, and if used the symbols defined by the SYMBOL manifest are valid. For other fonts you will get the symbol requested. The default is Text_def(font=’dymbols.gfn’, color=’k’, weight=FONT_WEIGHT_ULTRALIGHT) - symbol – the symbol to plot, normally one of SYMBOL.
New in version 9.2.
-
classmethod
new
(view, name, data, color_map, symbol_def=None, symbol=20)¶
-
classmethod
open
(view, group_name)¶
-
class
geosoft.gxpy.group.
Draw
(*args, **kwargs)¶ Bases:
geosoft.gxpy.group.Group
Create (start) a drawing group for 2D drawing elements.
On a 3D view, 2D drawing elements are placed on the default drawing plane. Drawing groups will lock the view such that only one drawing group can be instantiated at a time.
Use with Draw() as group: to ensure correct unlocking when complete.
Inherits from the Group base class.
-
color
(cstr)¶ Return a color from a color string.
Parameters: cstr – color string (see below) Returns: color Colour strings may be “R”,”G”,”B”,”C”,”M”,”Y”, “H”,”S”,”V”, or “K” or a combination of these characters, each followed by up to three digits specifying a number between 0 and 255. An empty string will produce C_ANY_NONE.
You must stay in the same color model, RGB, CMY, HSV or K.
For example “R”, “R127G22”, “H255S127V32”
Characters are not case sensitive.
-
contour
(grid_file_name)¶ Draw contours for a grid file. A default contour interval is determined from the grid.
Parameters: grid_file_name – Grid file name New in version 9.2.
-
drawing_coordinate_system
¶ The coordinate of incoming spatial data, which are converted to the coordinate system of the view. This is normally the same as the view coordinate system, but it can be set to a different coordinate system to have automatic reprojection occur during drawing.
-
graticule
(dx=None, dy=None, ddx=None, ddy=None, style=1)¶ Draw a graticule reference on a view.
Parameters: - style – GRATICULE_LINE, GRATICULE_CROSS or GRATICULE_DOT
- dx – vertical line separation
- dy – horizontal line separation
- ddh – horizontal cross size for GRATICULE_CROSS
- ddv – vertical cross size for GRATICULE_CROSS
New in version 9.2.
-
line
(p2)¶ Draw a line on the current plane
Parameters: p2 – geometry.Point2
, or (p1, p2)New in version 9.2.
-
new_pen
(**kwargs)¶ Returns a pen that inherits default from the current view pen. Arguments are the same as the Pen constructor. This using this ensures that default sizing of view unit-based dimensions (such as line_thick) are not lost when new pens are created.
Parameters: kwargs – see Pen
Returns: Pen
instanceNew in version 9.2.
-
polygon
(pp, close=False)¶ Draw a polygon on the current plane.
Parameters: pp – gxpy.geometry.PPoint
Note
Smooth-line polygons must have at least 6 points for the closure to appear continuous.
New in version 9.2.
-
polyline
(pp, close=False)¶ Draw a polyline the current plane
Parameters: - pp –
gxpy.geometry.PPoint
- close – if True, draw a polygon, default is a polyline
Note
Smooth-line polygons must have at least 6 points for the closure to appear continuous.
New in version 9.2.
- pp –
-
rectangle
(p2)¶ Draw a 2D rectangle on the current plane :param p2: geometry.Point2, or (p1, p2), or (x0, y0, x2, y2)
New in version 9.2.
-
text
(text, location=(0, 0), reference=0, angle=0.0, text_def=None)¶ Draw text in the view.
Parameters: - text – text string. Use line-feed characters for multi-line text.
- location – (x, y) or a gxpy.geomerty.Point location
- reference –
reference point relative to the clip limits of the view to which reference location. The points are:
6 7 8 top left, center, right 3 4 5 middle left, center, right 0 1 2 bottom left, center, right
- angle – baseline angle in degrees clockwise
- text_def – text definition, if not set the current definition is used
- line_spacing – the line spacing for multi-line text as a factor of the text height, default is 1.5
New in version 9.2.
-
-
class
geosoft.gxpy.group.
Draw_3d
(view, *args, render_backfaces=False, **kwargs)¶ Bases:
geosoft.gxpy.group.Draw
Create a 3D drawing group within a 3D view.
3D drawing groups accept 3D drawing objects that can be created using methods of this class. 2D objects can also be drawn to a 3D group and will be placed on the default drawing plane within the 3D view.
Parameters: render_backfaces – True to turn backface rendering on. New in version 9.2.
-
box_3d
(p2, wireframe=False)¶ Draw a 3D box
Parameters: - p2 – box corners as geometry.Point2, or (p0, p1), or (x0, y0, z0, x1, y1, z1)
- wireframe – True to draw edges only
New in version 9.2.
-
cone_3d
(p2, radius)¶ Draw a cone.
Parameters: - p2 – end points as geometry.Point2, or (p0, p1), or (x0, y0, z0, x1, y1, z1).
- radius – cone base radius, base is as the the first point of p2.
New in version 9.2.
-
cylinder_3d
(p2, radius, r2=None, close=3)¶ Draw a cylinder.
Parameters: - p2 – end points as geometry.Point2, or (p0, p1), or (x0, y0, z0, x1, y1, z1)
- radius – cylinder radius.
- r2 – end radius if different from the start
- close –
one of:
CYLINDER_OPEN CYLINDER_CLOSE_START CYLINDER_CLOSE_END CYLINDER_CLOSE_ALL
New in version 9.2.
-
polydata_3d
(data, render_info_func=None, passback=None)¶ Create 3D objects rendered by the data.
Parameters: - view – a 3D view in which to place the group
- data – iterable that yields items passed to your render_info_func callback
- render_info_func –
a callback that given (item, passback) returns the rendering (symbol_type, geometry, color_integer, attibute):
Symbol Geometry Color Attributes SYMBOL_3D_SPHERE Point Color.int_value radius SYMBOL_3D_CUBE Point2 Color.int_value None SYMBOL_3D_CYLINDER Point2 Color.int_value radius SYMBOL_3D_CONE Point2 Color.int_value base_radius - passback – something passed back to your render_info_func function, default None.
Example
import geosoft.gxpy.geometry as gxgm import geosof.gxpy.view as gxv import geosogt.gxpy.group as gxg def render_spheres(xyz, cmap_radius): color, radius = cmap_radius return gxg.SYMBOL_3D_SPHERE, xyz, color.int_value, radius data = gxgm.PPoint(((5, 5, 5), (7, 5, 5), (7, 7, 7))) with gxv.View_3d.new('example_polydata') as v: with gxg.Draw_3d(v, 'red_spheres') as g: g.polydata_3d(data, render_spheres, (gxg.Color('r'), 0.25))
New in version 9.2.
-
polyline_3d
(points, style=0)¶ Draw a polyline.
Parameters: - points – verticies of the polyline,
gxpy.geometry.PPoint
instance, or array-like [x,y,z] - style – LINE3D_STYLE_LINE, LINE3D_STYLE_TUBE or LINE3D_STYLE_TUBE_JOINED. Lines are single-pixel-wide. Tubes have width defined by the pen line thickness. Joined tubes have a joints and rounded ends.
New in version 9.2.
- points – verticies of the polyline,
-
polypoint_3d
(points, style=0)¶ Draw multiple points.
Parameters: - points – points to draw,
gxpy.geometry.PPoint
instance, or array-like [x,y,z] - style – POINT_STYLE_DOT or POINT_STYLE_SPHERE. Dots are fast and intended for point clouds. The current pen thickness is used as the sphere sizes.
New in version 9.2.
- points – points to draw,
-
render_backfaces
¶ True if backface rendering is on, default is off (False). Backface rendering controls the rendering of parts of solid objects that would normally be hidden from view. If drawing solid objects that have an open face, such as cylinders with an open end, backface rendering will be be turned on. Once on it cannot be turned off for a view.
New in version 9.2.
-
sphere
(p, radius)¶ Draw a sphere.
Parameters: - p – location as geometry.Point, or (x, y, z)
- radius – sphere radius
New in version 9.2.
-
-
class
geosoft.gxpy.group.
Group
(view, name='_', plane=None, view_lock=False, mode=0)¶ Bases:
object
Geosoft group class.
Parameters: view: gxpy.View name: group name, default is “_”. plane: plane number, or plane name if drawing to a 3D view. Default is plane number 0. view_lock: True to lock the view for a single-stream drawwing group. Default is False. Properties: view: the geosoft.gxpy.view.View
instance that contains this groupname: the name of the group extent: extent of the group in view units extent_map_cm: extent of the group in map cm drawing_coordinate_system: the coordinate system of drawing coordinates. Setting to None will reset drawing coordinates to the view cs. If drawing_coordinate_system is set to some other cs the drawing coordinates will be transformed into the view cs. New in version 9.2.
-
close
()¶ Close the group, unlocks the view
-
extent
¶ group extent as (xmin, ymion, xmax, ymax)
-
extent_map_cm
(extent=None)¶ Return a view extent in map cm.
Parameters: extent – tuple returned an extent property. New in version 9.2.
-
locate
(location, reference=4)¶ Locate the group relative to a point.
Parameters: - location – location (x, y) or a gxpy.geometry.Point
- reference –
reference point relative to the clip limits of the view to which reference location. The points are:
6 7 8 top left, center, right 3 4 5 center left, center, right 0 1 2 bottom left, center, right
New in version 9.2.
-
name
¶ group name
-
number
¶ group number in the view
-
view
¶ view that contains this group.
-
visible
¶ True if group is visible, can be set.
-
-
exception
geosoft.gxpy.group.
GroupException
¶ Bases:
Exception
Exceptions from
geosoft.gxpy.group
.New in version 9.2.
-
class
geosoft.gxpy.group.
Pen
(**kwargs)¶ Bases:
object
Geosoft Pen class.
The default dimensioned properties (line_thick, line_pitch, pat_size and pat_thick) assume the view units are cm, and this is usually only the case for the base view. For views in other units either explicitly define the dimention in view units, or pass factor set the the view
geosoft.gxpy.view.View.units_per_map_cm
.Parameters: - line_color – line
Color
instance, default is black - fill_color – fill
Color
instance, default is transparent - line_thick – line thickness, default is 0.01
- line_style –
line pattern style
LINE_STYLE_SOLID (default) LINE_STYLE_LONG LINE_STYLE_DOTTED LINE_STYLE_SHORT LINE_STYLE_LONG_SHORT_LONG LINE_STYLE_LONG_DOT_LONG
- line_pitch – line style pitch, default is 0.5
- line_smooth –
smooth line:
SMOOTH_NONE (default) SMOOTH_AKIMA SMOOTH_CUBIC
- pat_number – pattern number for filled patterns (refer to etc/default.pat) default 0, flood fill
- pat_angle – pattern angle, default 0
- pat_density – pattern density, default 1
- pat_size – pattern size, default 1.0
- pat_style –
pattern style:
TILE_RECTANGULAR (default) TILE_DIAGONAL TILE_TRIANGULAR TILE_RANDOM
- pat_thick – pattern line thickness, default 0.01
- default – default
Pen
instance, if specified defaults are established from this - factor – default spatial properties are multiplied by this factor. This is useful
for creating pens scaled to the units of a view. The default pen properties
are scaled to cm. Typically you will pass
geosoft.gxpy.view.View.units_per_map_cm
.
-
fill_color
¶
-
classmethod
from_mapplot_string
(cstr)¶ Create a
Pen
instance from a mapplot-style string descriptor using either a rgbRGB or cmyCMY color model. Lower case letters indicate line color, uppercase indicates fill color, ‘k’, ‘K’ for black. Each letter may be followed by an intensity between 0 and 255. If an intensity is not specified 255 is assumed.Parameters: cstr – mapplot-style color definition Examples:
‘r’ red line ‘R’ red fill ‘rG64’ red line, light-green fill ‘c64’ light cyan line, equivalent to ‘R191G255B255’ ‘c64K96’ light cyan line, light-grey fill New in version 9.2.
-
line_color
¶ pen line color as a
color
instance, can be set.
-
mapplot_string
¶ line/fill colour and thickness string suing mapplor format, eg. ‘kR125B64t1000’
- line_color – line
-
class
geosoft.gxpy.group.
Text_def
(**kwargs)¶ Bases:
object
Text definition:
Parameters: - font – font name. TrueType fonts are assumed unless the name ends with ‘.gfn’, which is a Geosoft gfn font.
- weight –
one of:
FONT_WEIGHT_ULTRALIGHT FONT_WEIGHT_LIGHT FONT_WEIGHT_MEDIUM FONT_WEIGHT_BOLD FONT_WEIGHT_XBOLD FONT_WEIGHT_XXBOLD
- line_thick – line thickness from which to determine a weight, which is calculated from the ratio of line thickness to height.
- italics – True for italics fonts
- height – text height, default 0.25
- factor – default spatial properties are multiplied by this factor. This is useful for creating text scaled to the units of a view. The default text properties are scaled to cm.
Properties: height: font height in font: font name weight: font weight, one of FONT_WEIGHT line_thick: font line thickness for gfn stroke fonts italics: True for italics slant: Slant angle for stroke fonts, 0 if normal, 15 for italics mapplot_string: mapplot compatible text definition string New in version 9.2.
-
font
¶ text font name, can be set.
-
line_thick
¶ text line thickness determined from the font weight, can be set.
-
mapplot_string
¶ Return a text definition for mapplot. :returns:
-
slant
¶ text slant, 15 for italics, 0 for not italics, can be set.
-
geosoft.gxpy.group.
edge_reference
(area, reference)¶ Location of a reference point of an area.
Parameters: - area –
Point2
instance, or (x0, y0, x1, y1) - reference –
reference point relative to the clip limits of the view to which reference location. The points are:
6 7 8 top left, center, right 3 4 5 middle left, center, right 0 1 2 bottom left, center, right
Returns: Point desired reference location as a Point
New in version 9.2.
- area –
-
geosoft.gxpy.group.
font_weight_from_line_thickness
(line_thick, height)¶ Returns font weight for a text height and line thickness.
Parameters: - line_thick – line thickness in same units as the text height
- height – text height
Returns: one of:
FONT_WEIGHT_ULTRALIGHT FONT_WEIGHT_LIGHT FONT_WEIGHT_MEDIUM FONT_WEIGHT_BOLD FONT_WEIGHT_XBOLD FONT_WEIGHT_XXBOLD
New in version 9.2.
-
geosoft.gxpy.group.
legend_color_bar
(view, group_name, cmap, cmap2=None, bar_location=0, location=None, decimals=1, annotation_height=0.2, annotation_offset=None, annotation_side=1, box_size=None, bar_width=None, max_bar_size=None, minimum_gap=0, post_end_values=False, annotate_vertical=False, division_line=1, interval_1=None, interval_2=None, title=None)¶ Draw a color bar legend from :class:Color_map coloring definitions.
Parameters: - view –
gxpy.view.View
instance in which to place the bar - group_name – name for the color_bar group, overwrites group if it exists.
- cmap –
Color_map
instance - cmap2 – optional orthogonal blended
Color_map
instance. If making a shaded-color legend, provide the shaded color map here. - bar_location –
one of:
COLOR_BAR_RIGHT = 0 COLOR_BAR_LEFT = 1 COLOR_BAR_BOTTOM = 2 COLOR_BAR_TOP = 3
- location – offset or (x, y) offset from view reference point, in cm. The default is determined to center the bar off the location side specified.
- decimals – annotation decimal places
- annotation_height – annotation number height
- annotation_offset – offset of annotations from the bar (cm)
- annotation_side –
side of the bar for annotations
COLOR_BAR_ANNOTATE_RIGHT = 1 COLOR_BAR_ANNOTATE_LEFT = -1 COLOR_BAR_ANNOTATE_TOP = 1 COLOR_BAR_ANNOTATE_BOTTOM = -1
- box_size – box size, height for vertical bars, width for horizontal bars
- bar_width – width of the color boxes
- max_bar_size – maximum bar size, default is the size of the view edge
- minimum_gap – minimum gap to between annotations. Annotations are dropped in necessary.
- post_end_values – post the maximum and minimum values
- annotate_vertical – True to orient labels vertically
- division_line – 0, no division lines, 1 - line, 2 - tick
- interval_1 – annotation increment, default annotates everything
- interval_2 – secondary smaller annotations, 1/10, 1/ 5, 1/4 or 1/2 interval_1
- title – bar title, use new-lines for sub-titles.
New in version 9.2.
- view –
-
geosoft.gxpy.group.
thickness_from_font_weight
(weight, height)¶ Returns the line thickness appropriate for a text weight.
Parameters: - weight –
one of:
FONT_WEIGHT_ULTRALIGHT FONT_WEIGHT_LIGHT FONT_WEIGHT_MEDIUM FONT_WEIGHT_BOLD FONT_WEIGHT_XBOLD FONT_WEIGHT_XXBOLD
- height – font height
New in version 9.2.
- weight –