Page Contents

Topics

Classes

QLColorPlane Class

#include <QLayers/qlcolorplane.h>

Inherits: QWidget

Public Functions

QLColorPlane(QWidget* parent = nullptr)
LAttribute* color() const
void set_z_dimension(HSV z_dimension)
void setFixedHeight(int h)
void setFixedSize(const QSize& s)
void setFixedSize(int w, int h)
void setFixedWidth(int w)
LAttribute* z_axis()
HSV z_dimension() const

Protected Functions

bool eventFilter(QObject* object, QEvent* event) override
void paintEvent(QPaintEvent* event) override

Signals

void z_dimension_changed()

Detailed Description

QLColorPlane Example

A QLColorPlane is a QWidget that serves as a two-dimensional slider for selecting a color from an HSV cylinder.

A small cursor is displayed on the plane where the selected color is located. Clicking/dragging the mouse cursor anywhere on the plane will select the color underneath it.

Changing Dimensions

The plane can only represent two dimensions of an HSV cylinder at a time. The plane dimensions depend on the active HSV-dimension set for the Z-axis, referred to as the Z-dimension. For example, if the Z-dimension is set to Saturation, then the plane will represent the Hue and Value dimensions.

Z-Dimension Plane (Cycling Z-Axis)
Hue
Saturation
Value

Controlling the Z-Axis Value

The Z-axis is represented with an LAttribute intended to be linked to a external control widget, such as a QLSlider. The following is an example of how this can be setup:

QLColorPlane* color_plane = new QLColorPlane;
QLSlider* z_slider = new QLSlider(MAX_H);

z_slider->value()->set_link_attribute(color_plane->z_axis());

connect(color_plane, &QLColorPlane::z_dimension_changed,
    [this]
    {
        switch (color_plane->z_dimension())
        {
        case HSV::Hue:
            z_slider->set_limit(MAX_H);
            break;
        case HSV::Saturation:
        case HSV::Value:
            z_slider->set_limit(MAX_SV);
            break;
        }
    });

The connection in the example is established to update the slider's limit when the Z-axis dimension changes.

Member Function Documentation

QLColorPlane(QWidget* parent = nullptr)

Constructs a color plane.

LAttribute* color()

Returns a pointer to the color attribute.

void set_z_dimension(HSV z_dimension)

Sets the Z-axis dimension to z_dimension.

void setFixedHeight(int h)

Sets both the minimum and maximum heights of the widget to h without changing the widths.

void setFixedSize(const QSize& s)

Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking.

void setFixedSize(int w, int h)

Sets the width of the widget to w and the height to h.

void setFixedWidth(int w)

Sets both the minimum and maximum width of the widget to w without changing the heights.

LAttribute* z_axis()

Returns a pointer to the Z-axis attribute.

HSV z_dimension() const

Returns the active Z-axis dimension.

void z_dimension_changed()

Signal

This signal is emitted when the Z-axis dimension is changed.