layerview.visualization.world.color module

Model color manipulation.

class layerview.visualization.world.color.ModelColorizer(color_default: Tuple[float, float, float, float], color_gradient_start: Tuple[float, float, float, float], color_gradient_end: Tuple[float, float, float, float])[source]

Bases: object

Model coloring tool.

_GRADIENT_RESOLUTION = 100
static _color_gradient(start: Tuple[float, float, float, float], end: Tuple[float, float, float, float], num_steps: int) ndarray[source]

Generate array with color gradient.

Parameters:
  • start (Tuple4) – Gradient start color.

  • end (Tuple4) – Gradient end color, included in the returned gradient array.

  • num_steps (int) – Total number of gradient steps.

Returns:

Array containing color gradient.

Return type:

np.ndarray

_colorize_default(model_node_manager: ModelManager)[source]

Colorize the model with a constant, default color

_colorize_feedrate(model_node_manager: ModelManager)[source]

Colorize the model based on feedrate.

_colorize_layers(model_node_manager: ModelManager, layer_index_to_val: Dict[int, float])[source]

Colorize layers based on their corresponding generic value.

_colorize_temperature(model_node_manager: ModelManager)[source]

Colorize the model based on nozzle temperature.

_colorize_thickness(model_node_manager: ModelManager)[source]

Colorize the model based on layer thickness.

colorize(model_node_manager: ModelManager, coloring_mode: ColoringMode)[source]

Colorize model’s layers based on current ColoringMode.

Parameters:
  • model_node_manager (ModelManager) – Manager of the model to colorize.

  • coloring_mode (ColoringMode) – Current coloring mode.

Raises:

TypeError – If the specified coloring mode is not supported.

get_gradient_pixmap(size: Tuple[int, int], coloring_mode: ColoringMode) QPixmap[source]

Returns color gradient pixmap for the specified coloring mode.

Parameters:
  • size (Tuple[int, int]) – Size in pixels (width, height).

  • coloring_mode (ColoringMode) –

Returns:

pixmap – Color gradient pixmap for the specified coloring mode.

Return type:

QPixmap

layerview.visualization.world.color.gradient_pixmap(color_start: Tuple[float, float, float, float], color_end: Tuple[float, float, float, float], size: Tuple[int, int]) QPixmap[source]

Generate color gradient pixmap.

Parameters:
  • color_start (Tuple[float, float, float]) – RGBA color tuple, values [0;1].

  • color_end (Tuple[float, float, float]) – RGBA color tuple, values [0;1].

  • size (Tuple[int, int]) – Size in pixels (width, height).

Returns:

pixmap

Return type:

QPixmap