def render_properties(self): """The rendering properties for this surface as (color, opacity, style). Can be set.""" color = gxapi.int_ref() trans = gxapi.float_ref() style = gxapi.int_ref() self._gxsurfaceitem.get_default_render_properties(color, trans, style) return gxg.Color(color.value), trans.value, style.value
def get_plane_relief_surface_info(self, plane): """ Get relief surface parameters for a plane. :param plane: plane number or plane name :returns: relief surface properties :rtype: :class:`geosoft.gxpy.view.PlaneReliefSurfaceInfo` .. versionadded::9.2 """ if isinstance(plane, str): plane = self.plane_number(plane) surface_grid_name = gxapi.str_ref() sample = gxapi.int_ref() base = gxapi.float_ref() scale = gxapi.float_ref() min_ref = gxapi.float_ref() max_ref = gxapi.float_ref() self.gxview.get_plane_surface(plane, surface_grid_name) self.gxview.get_plane_surf_info(plane, sample, base, scale, min_ref, max_ref) refine = 1 + int(sample.value / 16) min_val = None if min_ref.value == gxapi.rDUMMY else min_ref.value max_val = None if max_ref.value == gxapi.rDUMMY else max_ref.value return PlaneReliefSurfaceInfo(surface_grid_name.value, refine, base.value, scale.value, min_val, max_val)
def run_gx(self, gx): """ Runs a GX. :param gx: GX name to run :returns: success, cancelled, exit_val, error_list, warning_list .. versionadded:: 9.6 """ exit_val = gxapi.int_ref() ret = gxapi.GXSYS.run_gx_ex(gx, exit_val) success = ret == 0 cancelled = ret == -1 error_list = [] warning_list = [] for i in range(0, gxapi.GXSYS.num_errors_ap()): err_no = gxapi.GXSYS.get_error_ap(i) err = gxapi.str_ref() gxapi.GXSYS.get_error_message_ap(i, err) if err_no < 0: warning_list.append(err.value) else: error_list.append(err.value) gxapi.GXSYS.clear_err_ap() return success, cancelled, exit_val.value, error_list, warning_list
def _map_to_results(self, map_file, xml_file, image_file, map_result, format, pix_width): m = gxapi.GXMAP.create(map_file, gxapi.MAP_WRITEOLD) m_res = gxapi.GXMAP.create(map_result, gxapi.MAP_WRITENEW) m.dup_map(m_res, gxapi.DUPMAP_COPY) #m_res.pack_files() m_res = None os.remove(map_result + '.xml') m.export_all_raster(image_file, '', pix_width, 0, gxapi.rDUMMY, gxapi.MAP_EXPORT_BITS_24, gxapi.MAP_EXPORT_METHOD_NONE, format, '') if format == 'PNG': GXPYTest._remove_time_chunk_from_png(image_file) crc = gxapi.int_ref() m.crc_map(crc, xml_file) m = None try: os.remove(image_file + '.gi') os.remove(image_file + '.xml') except FileNotFoundError: pass
def draw_controls(self): """ Vox drawing settings, returned as a tuple: (box_on, opacity, extent) as (boolean, float, (min_x, min_y, min_z, max_x, max_y, max_z)) Can be set. .. versionadded:: 9.3.1 """ if self.is_vector: return None, None, None box = gxapi.int_ref() trans = gxapi.float_ref() x0 = gxapi.float_ref() x1 = gxapi.float_ref() y0 = gxapi.float_ref() y1 = gxapi.float_ref() z0 = gxapi.float_ref() z1 = gxapi.float_ref() self.gxvoxd.get_draw_controls(box, trans, x0, y0, z0, x1, y1, z1) return bool(box.value), trans.value, (x0.value, y0.value, z0.value, x1.value, y1.value, z1.value)
def test_none(self): self.start() verification_checked = gxapi.int_ref() gxapi.GXSYS.display_task_dialog_ui('Message Title', '', 'No Icon', gxapi.TD_BUTTON_CLOSE, gxapi.GXLST.null(), gxapi.TD_ICON_NONE, '', gxapi.TD_ICON_NONE, '', verification_checked, '', '', '')
def _crooked_path_from_ipj(gxipj): if gxipj.get_orientation() != gxapi.IPJ_ORIENT_SECTION_CROOKED: raise ViewException(_t('This coordinate system does not define a crooked path')) dvv = gxvv.GXvv() xvv = gxvv.GXvv() yvv = gxvv.GXvv() log_z = gxapi.int_ref() gxipj.get_crooked_section_view_v_vs(dvv.gxvv, xvv.gxvv, yvv.gxvv, log_z) return dvv, xvv, yvv, log_z.value
def test_confirm(self): self.start() verification_checked = gxapi.int_ref() answer = gxapi.GXSYS.display_task_dialog_ui( 'Message Title', '', 'Are you sure (click yes)?', gxapi.TD_BUTTON_YES + gxapi.TD_BUTTON_NO, gxapi.GXLST.null(), gxapi.TD_ICON_CONFIRMATION, '', gxapi.TD_ICON_NONE, '', verification_checked, '', '', '') self.assertEqual(answer, gxapi.TD_ID_YES)
def test_custom_buttons(self): self.start() lst = gxapi.GXLST.create(1024) lst.add_item("Don't press this one", "50") lst.add_item("Press this one!", "123") verification_checked = gxapi.int_ref() answer = gxapi.GXSYS.display_task_dialog_ui( 'Message Title', '', 'Custom Buttons', gxapi.TD_BUTTON_CLOSE, lst, gxapi.TD_ICON_CONFIRMATION, '', gxapi.TD_ICON_NONE, '', verification_checked, '', '', '') self.assertEqual(answer, 123)
def __init__(self, name=None, gxvox=None, dtype=None, mode=None, overwrite=False): self._file_name = _vox_file_name(name) self._name = _vox_name(self._file_name) super().__init__(name=self._name, file_name=self._file_name, mode=mode, overwrite=overwrite, gxobj=gxvox) self._gxvox = gxvox self._gxvoxe = None self._next = self._next_x = self._next_y = self._next_z = 0 self._locations = None self._cells = None self._pg = None self._buffered_plane = self._buffered_row = None self._is_depth = False ityp = gxapi.int_ref() iarr = gxapi.int_ref() nx = gxapi.int_ref() ny = gxapi.int_ref() nz = gxapi.int_ref() self._gxvox.get_info(ityp, iarr, nx, ny, nz) if dtype is None: self._dtype = gxu.dtype_gx(ityp.value) else: self._dtype = dtype self._return_int = gxu.is_int(gxu.gx_dtype(self._dtype)) self._dim = (nx.value, ny.value, nz.value) self._max_iter = nx.value * ny.value * nz.value # location self._setup_locations()
def test_full(self): self.start() verification_checked = gxapi.int_ref() verification_checked.value = 1 gxapi.GXSYS.display_task_dialog_ui( 'Message Title', 'Main Instruction', 'Content, with <a href="https://google.com">link</a>', gxapi.TD_BUTTON_OK, gxapi.GXLST.null(), gxapi.TD_ICON_ERROR, 'Footer with <a href="https://google.com">another link</a>', gxapi.TD_ICON_WARNING, 'Verification checkbox text (uncheck this!)', verification_checked, 'Expanded stuff...\n<a href="https://my.geosoft.com/subscriptions#/">My subscriptions</a>', '', '') self.assertEqual(verification_checked.value, 0)
def properties(self, refresh=False): """ Surface properties from `geosoft.gxapi.GXSURFACEITEM.get_properties_ex`. :param refresh: if True, computed properties will be refreshed on next access. .. versionadded:: 9.3.1 """ if refresh: self._properties = None if not self._properties: stype = gxapi.str_ref() name = gxapi.str_ref() source_guid = gxapi.str_ref() source_name = gxapi.str_ref() source_measure = gxapi.float_ref() second_source_guid = gxapi.str_ref() second_source_name = gxapi.str_ref() second_source_option = gxapi.int_ref() second_source_measure = gxapi.float_ref() second_source_measure2 = gxapi.float_ref() self._gxsurfaceitem.get_properties_ex( stype, name, source_guid, source_name, source_measure, second_source_guid, second_source_name, second_source_option, second_source_measure, second_source_measure2) self._properties = { 'type': stype.value, 'name': name.value, 'source_guid': source_guid.value, 'source_dataset': source_name.value, 'source_measure': source_measure.value, 'second_source_guid': second_source_guid.value, 'second_source_dataset': second_source_name.value, 'second_source_option': second_source_option.value, 'second_source_measure': second_source_measure.value, 'second_source_measure2': second_source_measure2.value } return self._properties
def computed_properties(self, refresh=False): """ Surface properties, see: `geosoft.gxapi.GXSURFACEITEM.compute_extended_info`. :param refresh: if True, computed properties will be refreshed on next access. :returns: dictionary of properties, 'components', 'verticies', edges', 'triangles', 'inconsistent', 'invalid', 'intersect' .. versionadded:: 9.3.1 """ if refresh: self._computed_properties = None if not self._computed_properties: comp = gxapi.int_ref() vert = gxapi.int_ref() edge = gxapi.int_ref() trng = gxapi.int_ref() incn = gxapi.int_ref() invd = gxapi.int_ref() intr = gxapi.int_ref() self._gxsurfaceitem.compute_extended_info(comp, vert, edge, trng, incn, invd, intr) self._computed_properties = { 'components': comp.value, 'verticies': vert.value, 'edges': edge.value, 'triangles': trng.value, 'inconsistent': incn.value, 'invalid': invd.value, 'intersect': intr.value } return self._computed_properties
def verticies_count(self): """number of verticies""" vert = gxapi.int_ref() tri = gxapi.int_ref() self._gxsurfaceitem.get_geometry_info(vert, tri) return vert.value
def export_to_gdb(self): ref = gxapi.int_ref() self.ltb.get_int(self.index, self._export_to_gdb_field, ref) return bool(ref.value)
def max(self): ref = gxapi.int_ref() self.ltb.get_int(self.index, self._min_field, ref) return ref.value
def faces_count(self): """number of triangular faces""" vert = gxapi.int_ref() tri = gxapi.int_ref() self._gxsurfaceitem.get_geometry_info(vert, tri) return tri.value
# set the coordinate system to 'NAD 83 / UTM zone 15N' gdb.coordinate_system = 'NAD83 / UTM zone 15N' # set the mag data units to 'nT' gxdb.Channel(gdb, 'mag').unit_of_measure = 'nT' print(list(gdb.list_lines())) # ['L0'] print(list(gdb.list_channels())) # ['mag', 'X', 'Y', 'Z'] print(gdb.xyz_channels) # ('X', 'Y', 'Z') # split the line into sections knowing lines are E-W, and separated by 200 m. # see https://geosoftinc.github.io/gxpy/9.2/python/GXDU.html?highlight=split_line_xy2#geosoft.gxapi.GXDU.split_line_xy2 # starting line number for split lines split_line_number_start = gxapi.int_ref() split_line_number_start.value = 1 # create instances to the lines and channels needed by the split_line_xy2 function line = gxdb.Line(gdb, 'L0') x_channel = gxdb.Channel(gdb, 'X') y_channel = gxdb.Channel(gdb, 'Y') # lock items as required line.lock = gxdb.SYMBOL_LOCK_READ x_channel.lock = gxdb.SYMBOL_LOCK_WRITE y_channel.lock = gxdb.SYMBOL_LOCK_WRITE # split the original line into segments, based on a lateral distance tolerance of 100 m. gxapi.GXDU.split_line_xy2( gdb.gxdb,
def render_mode(self): rm = gxapi.int_ref() self.gxvoxd.get_render_mode(rm) return rm.value