Class LineTracer3D

java.lang.Object
uk.ac.starlink.ttools.plot2.layer.LineTracer3D

public abstract class LineTracer3D extends Object
Draws lines composed of a sequence of points onto a 3d plotting surface. Points are submitted one at a time.

There is no true 3d line plotting primitive available for a CubeSurface, so we have to do it by hand. To get the Z-stacking right it is necessary to plot non-tiny lines using a number of pixels or segments, each placed at the relevant Z coordinate (depth). This is not done very accurately, but it's hopefully good enough to look OK. It may also not be very efficient if there are lots of long lines criss-crossing the visible cube, but in that case even if it was done fast it would almost certainly be impossible to see anything useful.

Line segments may still be visible if the points they join are outside the visible cube. In general therefore non-visible points should still be submitted to this tracer for drawing. The code attempts to deal with them efficiently, avoiding painting where it is not required, and coping with points that are far from the visible region.

Since:
19 Jul 2018
Author:
Mark Taylor
  • Constructor Details

    • LineTracer3D

      protected LineTracer3D(PaperType3D paperType, Paper paper, CubeSurface surf)
      Constructor.
      Parameters:
      paperType - paper type
      paper - paper
      surf - target surface
  • Method Details

    • addPoint

      public void addPoint(double[] dpos, Color color)
      Submits a point for drawing. Except for the first invocation, this will notionally result in drawing a line segment to the previous point.
      Parameters:
      dpos - 3-element array giving the vertex position in data coordinates
      color - colour of line segment
    • createTracer

      public static LineTracer3D createTracer(PaperType3D paperType, Paper paper, CubeSurface surf, Stroke stroke)
      Creats a line segment tracer from a given stroke.
      Parameters:
      paperType - paper type
      paper - paper
      surf - target surface
      stroke - line stroke - probably only line width is honoured
      Returns:
      new tracer
    • createTracer

      public static LineTracer3D createTracer(PaperType3D paperType, Paper paper, CubeSurface surf, int thickness, int pixgap)
      Creates a line tracer from a given line thickness and pixel gap. If pixgap is non-zero, a tracer that draws points rather than line segments is returned. At present, the points are not very cleverly separated, so it doesn't look that good.
      Parameters:
      paperType - paper type
      paper - paper
      surf - target surface
      thickness - line thickness/marker size (minimum 1)
      pixgap - nominal gap in pixels between markers
      Returns:
      new tracer