NDEVR
API Documentation
ColorByValueWidget.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: ColorByValueWidget
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/QTDesignObject.h>
35#include <NDEVR/Pointer.h>
36#include <QWidget>
37namespace Ui
38{
39 class ColorByValueWidgetUI;
40}
41namespace NDEVR
42{
43 class QCustomLabel;
44 class QCustomLineEdit;
45 class QCustomComboBox;
47 class Button;
51 class NDEVR_API ColorByValueWidget : public QWidget
52 {
53 Q_OBJECT
54 public:
59 ColorByValueWidget(QWidget* parent = nullptr);
66 //void setMaterial
75 void enterEvent(QEnterEvent*) override;
80 void leaveEvent(QEvent*) override;
85 void mousePressEvent(QMouseEvent*) override;
90 void mouseReleaseEvent(QMouseEvent*) override;
95 void mouseMoveEvent(QMouseEvent*) override;
120 QSize sizeHint() const override;
125 QSize minimumSizeHint() const override;
130 void setColors(const Buffer<RGBColor>& colors);
136 void setMinAndMax(fltp08 min, fltp08 max);
140 void clear();
141 protected slots:
150 protected:
160 void paintEvent(QPaintEvent*) override;
166 void drawGradient(QPainter& p, const QRect& r) const;
172 void drawTicksAndLabels(QPainter& p, const QRect& r) const;
179 QString valueAtIndex(int i, int n) const;
183 void init();
198 bool isHorizontal() const;
211 protected:
229 bool m_is_dialog = false;
230 bool m_hover = false;
231 bool m_pressed = false;
232 };
233}
234
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core widget that allows the user to click one of many button types.
Definition Button.h:68
void setupAsDialog()
Configures this widget instance as a popup dialog.
void paintEvent(QPaintEvent *) override
Paints the gradient bar and associated labels.
fltp08 m_max
The maximum value of the color range.
QSize minimumSizeHint() const override
Returns the minimum recommended size for this widget.
void enterEvent(QEnterEvent *) override
Handles the mouse enter event for hover effects.
void updatePopupLayout()
Updates the popup dialog layout orientation.
void setMinAndMax(fltp08 min, fltp08 max)
Sets the minimum and maximum values for the color range.
void clear()
Clears the widget, removing all color and value data.
void setTarget(const DynamicPointer< QTDesignObject > &target)
Sets the target design object, automatically detecting model or material.
void drawGradient(QPainter &p, const QRect &r) const
Draws the color gradient within the specified rectangle.
Buffer< Button * > m_delete_buttons
Buttons for removing color stops.
QSize sizeHint() const override
Returns the recommended size for this widget.
QCustomLineEdit * min_value_line_edit
Line edit for the minimum value.
ColorByValueWidget * m_popup
The popup dialog version of this widget.
void setTargetModel(const DynamicPointer< QTDesignObject > &target)
Sets the target model whose color-by-value properties are edited.
DynamicPointer< QTDesignObject > m_target_material
The target material design object.
Buffer< ColorChooserButton * > m_color_buttons
Buttons for choosing individual gradient colors.
bool m_pressed
Whether the mouse is pressed on the widget.
Buffer< Button * > m_add_buttons
Buttons for adding color stops.
bool m_is_unit_flipped
Whether the value axis is flipped.
void init()
Initializes the widget layout and default state.
void mouseMoveEvent(QMouseEvent *) override
Handles mouse move events for interaction.
void updateFromDialog()
Applies values from the popup dialog to the widget.
QRect m_gradient_rect
The rectangle area where the gradient is drawn.
void drawTicksAndLabels(QPainter &p, const QRect &r) const
Draws tick marks and value labels alongside the gradient.
void updatePopupValues()
Updates the popup dialog values from the main widget.
void updateColorsFromUI(const Buffer< RGBColor > &colors)
Updates the color palette from the UI controls.
bool m_is_dialog
Whether this widget is configured as a popup dialog.
void mousePressEvent(QMouseEvent *) override
Handles mouse press events for interaction.
Material material() const
Returns the material currently being edited.
ColorByValueWidget(QWidget *parent=nullptr)
Constructs a ColorByValueWidget without a material target.
QCustomComboBox * m_palette_combo
Combo box for selecting predefined palettes.
QCustomLineEdit * mid_value_line_edit
Line edit for the midpoint value.
void setTargetMaterial(const DynamicPointer< QTDesignObject > &target)
Sets the target material whose color-by-value properties are edited.
DynamicPointer< QTDesignObject > m_material
The material being edited.
QString valueAtIndex(int i, int n) const
Returns the formatted value string at a given tick index.
QCustomLineEdit * max_value_line_edit
Line edit for the maximum value.
bool m_hover
Whether the mouse is hovering over the widget.
ColorByValueWidget(const DynamicPointer< QTDesignObject > &material, QWidget *parent=nullptr)
Constructs a ColorByValueWidget bound to a specific material.
Vector< 3, fltp08 > getUIValues(const Material &mat) const
Extracts the current UI min, mid, and max values from the given material.
fltp08 m_min
The minimum value of the color range.
void updateFromTargetModel()
Updates the widget from the current target model state.
void updateFromTargetMaterial()
Updates the widget from the current target material state.
virtual ~ColorByValueWidget()
Destructor.
void leaveEvent(QEvent *) override
Handles the mouse leave event to clear hover effects.
void mouseReleaseEvent(QMouseEvent *) override
Handles mouse release events for interaction.
DynamicPointer< QTDesignObject > m_target_model
The target model design object.
RandomColorGenerator m_random_generator
Generator for random color palettes.
void setColors(const Buffer< RGBColor > &colors)
Sets the color palette used for the gradient display.
Buffer< RGBColor > m_colors
The color palette for the gradient.
bool isHorizontal() const
Returns whether the gradient is displayed horizontally.
A button that pops up a ColorChooserDialog and changes background color based on the color chosen.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:153
A compact way to present a list of options to the user.
Displays translated text.
A line edit allows users to enter and edit a single line of plain text with useful editing functions,...
Generates random colors based on configurable hue and luminosity settings.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
double fltp08
Defines an alias representing an 8 byte floating-point number.