# sec_interp.core.services.preview_service module

Preview service for SecInterp.

This module provides a service to orchestrate the generation of all preview components, decoupled from the GUI layer.

class sec_interp.core.services.preview_service.PreviewParams(raster_layer: qgis.core.QgsRasterLayer, line_layer: qgis.core.QgsVectorLayer, band_num: int, buffer_dist: float = 100.0, outcrop_layer: qgis.core.QgsVectorLayer | None = None, outcrop_name_field: str | None = None, struct_layer: qgis.core.QgsVectorLayer | None = None, dip_field: str | None = None, strike_field: str | None = None, dip_scale_factor: float = 1.0, collar_layer: qgis.core.QgsVectorLayer | None = None, collar_id_field: str | None = None, collar_use_geometry: bool = True, collar_x_field: str | None = None, collar_y_field: str | None = None, collar_z_field: str | None = None, collar_depth_field: str | None = None, survey_layer: qgis.core.QgsVectorLayer | None = None, survey_id_field: str | None = None, survey_depth_field: str | None = None, survey_azim_field: str | None = None, survey_incl_field: str | None = None, interval_layer: qgis.core.QgsVectorLayer | None = None, interval_id_field: str | None = None, interval_from_field: str | None = None, interval_to_field: str | None = None, interval_lith_field: str | None = None, max_points: int = 1000, canvas_width: int = 800, auto_lod: bool = True)

  Bases: `object`

  Parameters for preview generation.

  raster_layer: qgis.core.QgsRasterLayer
  line_layer: qgis.core.QgsVectorLayer
  band_num: int
  buffer_dist: float = 100.0
  outcrop_layer: qgis.core.QgsVectorLayer | None = None
  outcrop_name_field: str | None = None
  struct_layer: qgis.core.QgsVectorLayer | None = None
  dip_field: str | None = None
  strike_field: str | None = None
  dip_scale_factor: float = 1.0
  collar_layer: qgis.core.QgsVectorLayer | None = None
  collar_id_field: str | None = None
  collar_use_geometry: bool = True
  collar_x_field: str | None = None
  collar_y_field: str | None = None
  collar_z_field: str | None = None
  collar_depth_field: str | None = None
  survey_layer: qgis.core.QgsVectorLayer | None = None
  survey_id_field: str | None = None
  survey_depth_field: str | None = None
  survey_azim_field: str | None = None
  survey_incl_field: str | None = None
  interval_layer: qgis.core.QgsVectorLayer | None = None
  interval_id_field: str | None = None
  interval_from_field: str | None = None
  interval_to_field: str | None = None
  interval_lith_field: str | None = None
  max_points: int = 1000
  canvas_width: int = 800
  auto_lod: bool = True

class sec_interp.core.services.preview_service.PreviewResult(topo: list[tuple[float, float]] | None = None, geol: list[~sec_interp.core.types.GeologySegment] | None = None, struct: list[~sec_interp.core.types.StructureMeasurement] | None = None, drillhole: ~typing.Any | None = None, metrics: ~sec_interp.core.performance_metrics.MetricsCollector = <factory>, buffer_dist: float = 0.0)

  Bases: `object`

  Consolidated results of preview generation.

  topo: list[tuple[float, float]] | None = None
  geol: list[GeologySegment] | None = None
  struct: list[StructureMeasurement] | None = None
  drillhole: Any | None = None
  metrics: MetricsCollector
  buffer_dist: float = 0.0
  get_elevation_range() → tuple[float, float]

    Calculate the global elevation range across all data layers.

    Returns:

      (min_elevation, max_elevation)

    Return type:

      Tuple[float, float]

  get_distance_range() → tuple[float, float]

    Calculate the global distance range from topographic data.

    Returns:

      (min_distance, max_distance)

    Return type:

      Tuple[float, float]

class sec_interp.core.services.preview_service.PreviewService(controller: Any)

  Bases: `object`

  Orchestrates preview data generation.

  Initialize with plugin controller to access other services.

  Parameters:

    controller – The SecInterpController instance

  __init__(controller: Any)

    Initialize with plugin controller to access other services.

    Parameters:

      controller – The SecInterpController instance

  static calculate_max_points(canvas_width: int, manual_max: int = 1000, auto_lod: bool = True, ratio: float = 1.0) → int

    Calculate the optimal number of points for rendering.

    Parameters:

      - canvas_width – Current width of the preview canvas

      - manual_max – User-specified maximum points

      - auto_lod – Whether to use automatic level of detail

      - ratio – Current zoom ratio (full_extent / current_extent)

    Returns:

      Number of points to use for rendering

    Return type:

      int

  generate_all(params: PreviewParams, transform_context: Any) → PreviewResult

    Generate all preview components.

    Parameters:

      - params – Parameters for generation

      - transform_context – QgsCoordinateTransformContext from map settings

    Returns:

      Consolidated preview results