NDEVR
API Documentation
ColorByValueWidget

Allows the user to select a property and range to color a Model or Scene. More...

Collaboration diagram for ColorByValueWidget:
[legend]

Public Member Functions

 ColorByValueWidget (const DynamicPointer< QTDesignObject > &material, QWidget *parent=nullptr)
 Constructs a ColorByValueWidget bound to a specific material.
 ColorByValueWidget (QWidget *parent=nullptr)
 Constructs a ColorByValueWidget without a material target.
virtual ~ColorByValueWidget ()
 Destructor.
void clear ()
 Clears the widget, removing all color and value data.
void enterEvent (QEnterEvent *) override
 Handles the mouse enter event for hover effects.
void leaveEvent (QEvent *) override
 Handles the mouse leave event to clear hover effects.
Material material () const
 Returns the material currently being edited.
QSize minimumSizeHint () const override
 Returns the minimum recommended size for this widget.
void mouseMoveEvent (QMouseEvent *) override
 Handles mouse move events for interaction.
void mousePressEvent (QMouseEvent *) override
 Handles mouse press events for interaction.
void mouseReleaseEvent (QMouseEvent *) override
 Handles mouse release events for interaction.
void setColors (const Buffer< RGBColor > &colors)
 Sets the color palette used for the gradient display.
void setMinAndMax (fltp08 min, fltp08 max)
 Sets the minimum and maximum values for the color range.
void setTarget (const DynamicPointer< QTDesignObject > &target)
 Sets the target design object, automatically detecting model or material.
void setTargetMaterial (const DynamicPointer< QTDesignObject > &target)
 Sets the target material whose color-by-value properties are edited.
void setTargetModel (const DynamicPointer< QTDesignObject > &target)
 Sets the target model whose color-by-value properties are edited.
QSize sizeHint () const override
 Returns the recommended size for this widget.

Protected Member Functions

void drawGradient (QPainter &p, const QRect &r) const
 Draws the color gradient within the specified rectangle.
void drawTicksAndLabels (QPainter &p, const QRect &r) const
 Draws tick marks and value labels alongside the gradient.
Vector< 3, fltp08getUIValues (const Material &mat) const
 Extracts the current UI min, mid, and max values from the given material.
void init ()
 Initializes the widget layout and default state.
bool isHorizontal () const
 Returns whether the gradient is displayed horizontally.
void paintEvent (QPaintEvent *) override
 Paints the gradient bar and associated labels.
void setupAsDialog ()
 Configures this widget instance as a popup dialog.
void updateColorsFromUI (const Buffer< RGBColor > &colors)
 Updates the color palette from the UI controls.
void updateFromDialog ()
 Applies values from the popup dialog to the widget.
void updateFromTargetMaterial ()
 Updates the widget from the current target material state.
void updateFromTargetModel ()
 Updates the widget from the current target model state.
void updatePopupLayout ()
 Updates the popup dialog layout orientation.
void updatePopupValues ()
 Updates the popup dialog values from the main widget.
QString valueAtIndex (int i, int n) const
 Returns the formatted value string at a given tick index.

Protected Attributes

Buffer< Button * > m_add_buttons
 Buttons for adding color stops.
Buffer< ColorChooserButton * > m_color_buttons
 Buttons for choosing individual gradient colors.
Buffer< RGBColorm_colors
 The color palette for the gradient.
Buffer< Button * > m_delete_buttons
 Buttons for removing color stops.
QRect m_gradient_rect
 The rectangle area where the gradient is drawn.
bool m_hover = false
 Whether the mouse is hovering over the widget.
bool m_is_dialog = false
 Whether this widget is configured as a popup dialog.
bool m_is_unit_flipped
 Whether the value axis is flipped.
DynamicPointer< QTDesignObjectm_material
 The material being edited.
fltp08 m_max
 The maximum value of the color range.
fltp08 m_min
 The minimum value of the color range.
QCustomComboBoxm_palette_combo = nullptr
 Combo box for selecting predefined palettes.
ColorByValueWidgetm_popup = nullptr
 The popup dialog version of this widget.
bool m_pressed = false
 Whether the mouse is pressed on the widget.
RandomColorGenerator m_random_generator
 Generator for random color palettes.
DynamicPointer< QTDesignObjectm_target_material
 The target material design object.
DynamicPointer< QTDesignObjectm_target_model
 The target model design object.
QCustomLineEditmax_value_line_edit
 Line edit for the maximum value.
QCustomLineEditmid_value_line_edit
 Line edit for the midpoint value.
QCustomLineEditmin_value_line_edit
 Line edit for the minimum value.

Detailed Description

Allows the user to select a property and range to color a Model or Scene.


Definition at line 51 of file ColorByValueWidget.h.

Constructor & Destructor Documentation

◆ ColorByValueWidget() [1/2]

ColorByValueWidget::ColorByValueWidget ( QWidget * parent = nullptr)

Constructs a ColorByValueWidget without a material target.

Parameters
[in]parentThe optional parent widget.

◆ ColorByValueWidget() [2/2]

ColorByValueWidget::ColorByValueWidget ( const DynamicPointer< QTDesignObject > & material,
QWidget * parent = nullptr )

Constructs a ColorByValueWidget bound to a specific material.

Parameters
[in]materialThe material design object to color by value.
[in]parentThe optional parent widget.

References material().

Member Function Documentation

◆ drawGradient()

void ColorByValueWidget::drawGradient ( QPainter & p,
const QRect & r ) const
protected

Draws the color gradient within the specified rectangle.

Parameters
[in]pThe painter to draw with.
[in]rThe rectangle to draw in.

◆ drawTicksAndLabels()

void ColorByValueWidget::drawTicksAndLabels ( QPainter & p,
const QRect & r ) const
protected

Draws tick marks and value labels alongside the gradient.

Parameters
[in]pThe painter to draw with.
[in]rThe rectangle defining the gradient area.

◆ enterEvent()

void ColorByValueWidget::enterEvent ( QEnterEvent * )
override

Handles the mouse enter event for hover effects.

Parameters
[in]eventThe enter event (unused parameter name).

◆ getUIValues()

Vector< 3, fltp08 > ColorByValueWidget::getUIValues ( const Material & mat) const
protected

Extracts the current UI min, mid, and max values from the given material.

Parameters
[in]matThe material to read values from.
Returns
A 3D vector containing the min, mid, and max values.

◆ isHorizontal()

bool ColorByValueWidget::isHorizontal ( ) const
protected

Returns whether the gradient is displayed horizontally.

Returns
True if horizontal, false if vertical.

◆ leaveEvent()

void ColorByValueWidget::leaveEvent ( QEvent * )
override

Handles the mouse leave event to clear hover effects.

Parameters
[in]eventThe leave event (unused parameter name).

◆ material()

Material ColorByValueWidget::material ( ) const

Returns the material currently being edited.

Returns
The active Material.

Referenced by ColorByValueWidget().

◆ minimumSizeHint()

QSize ColorByValueWidget::minimumSizeHint ( ) const
override

Returns the minimum recommended size for this widget.

Returns
The minimum QSize.

◆ mouseMoveEvent()

void ColorByValueWidget::mouseMoveEvent ( QMouseEvent * )
override

Handles mouse move events for interaction.

Parameters
[in]eventThe mouse move event (unused parameter name).

◆ mousePressEvent()

void ColorByValueWidget::mousePressEvent ( QMouseEvent * )
override

Handles mouse press events for interaction.

Parameters
[in]eventThe mouse press event (unused parameter name).

◆ mouseReleaseEvent()

void ColorByValueWidget::mouseReleaseEvent ( QMouseEvent * )
override

Handles mouse release events for interaction.

Parameters
[in]eventThe mouse release event (unused parameter name).

◆ paintEvent()

void ColorByValueWidget::paintEvent ( QPaintEvent * )
overrideprotected

Paints the gradient bar and associated labels.

Parameters
[in]eventThe paint event (unused parameter name).

◆ setColors()

void ColorByValueWidget::setColors ( const Buffer< RGBColor > & colors)

Sets the color palette used for the gradient display.

Parameters
[in]colorsThe buffer of RGB colors forming the palette.

◆ setMinAndMax()

void ColorByValueWidget::setMinAndMax ( fltp08 min,
fltp08 max )

Sets the minimum and maximum values for the color range.

Parameters
[in]minThe minimum value.
[in]maxThe maximum value.

◆ setTarget()

void ColorByValueWidget::setTarget ( const DynamicPointer< QTDesignObject > & target)

Sets the target design object, automatically detecting model or material.

Parameters
[in]targetThe design object to target.

◆ setTargetMaterial()

void ColorByValueWidget::setTargetMaterial ( const DynamicPointer< QTDesignObject > & target)

Sets the target material whose color-by-value properties are edited.

Parameters
[in]targetThe material design object.

◆ setTargetModel()

void ColorByValueWidget::setTargetModel ( const DynamicPointer< QTDesignObject > & target)

Sets the target model whose color-by-value properties are edited.

Parameters
[in]targetThe model design object.

◆ sizeHint()

QSize ColorByValueWidget::sizeHint ( ) const
override

Returns the recommended size for this widget.

Returns
The preferred QSize.

◆ updateColorsFromUI()

void ColorByValueWidget::updateColorsFromUI ( const Buffer< RGBColor > & colors)
protected

Updates the color palette from the UI controls.

Parameters
[in]colorsThe new color palette from the UI.

◆ valueAtIndex()

QString ColorByValueWidget::valueAtIndex ( int i,
int n ) const
protected

Returns the formatted value string at a given tick index.

Parameters
[in]iThe tick index.
[in]nThe total number of ticks.
Returns
The formatted value string.

The documentation for this class was generated from the following file: