20 #include <QPushButton>
23 #include <ui_colorFromScalarDlg.h>
31 : QDialog(parent, Qt::Tool),
33 m_systemInvalid(false),
34 m_ui(new
Ui::ColorFromScalarDialog) {
67 m_ui->fixA->setChecked(
true);
70 QFrame* histoFrame[
c_channelCount] = {m_ui->histoFrameR, m_ui->histoFrameG,
71 m_ui->histoFrameB, m_ui->histoFrameA};
75 auto layout =
new QHBoxLayout;
77 layout->setContentsMargins(0, 0, 0, 0);
80 histoFrame[i]->setLayout(layout);
99 "[ccColorFromScalarDlg] Get current scalar field failed!");
142 "[ccColorFromScalarDlg] Current cloud has no scalar fields!");
148 connect(m_ui->channelComboR,
149 static_cast<void (QComboBox::*)(
int)
>(
150 &QComboBox::currentIndexChanged),
152 connect(m_ui->channelComboG,
153 static_cast<void (QComboBox::*)(
int)
>(
154 &QComboBox::currentIndexChanged),
156 connect(m_ui->channelComboB,
157 static_cast<void (QComboBox::*)(
int)
>(
158 &QComboBox::currentIndexChanged),
160 connect(m_ui->channelComboA,
161 static_cast<void (QComboBox::*)(
int)
>(
162 &QComboBox::currentIndexChanged),
165 connect(m_ui->buttonBox->button(QDialogButtonBox::Apply),
167 connect(m_ui->minInputSpinBoxR,
168 static_cast<void (QDoubleSpinBox::*)(
double)
>(
169 &QDoubleSpinBox::valueChanged),
171 connect(m_ui->maxInputSpinBoxR,
172 static_cast<void (QDoubleSpinBox::*)(
double)
>(
173 &QDoubleSpinBox::valueChanged),
175 connect(m_ui->minInputSpinBoxG,
176 static_cast<void (QDoubleSpinBox::*)(
double)
>(
177 &QDoubleSpinBox::valueChanged),
179 connect(m_ui->maxInputSpinBoxG,
180 static_cast<void (QDoubleSpinBox::*)(
double)
>(
181 &QDoubleSpinBox::valueChanged),
183 connect(m_ui->minInputSpinBoxB,
184 static_cast<void (QDoubleSpinBox::*)(
double)
>(
185 &QDoubleSpinBox::valueChanged),
187 connect(m_ui->maxInputSpinBoxB,
188 static_cast<void (QDoubleSpinBox::*)(
double)
>(
189 &QDoubleSpinBox::valueChanged),
191 connect(m_ui->minInputSpinBoxA,
192 static_cast<void (QDoubleSpinBox::*)(
double)
>(
193 &QDoubleSpinBox::valueChanged),
195 connect(m_ui->maxInputSpinBoxA,
196 static_cast<void (QDoubleSpinBox::*)(
double)
>(
197 &QDoubleSpinBox::valueChanged),
200 connect(m_ui->reverseR, &QCheckBox::stateChanged,
this,
202 connect(m_ui->reverseG, &QCheckBox::stateChanged,
this,
204 connect(m_ui->reverseB, &QCheckBox::stateChanged,
this,
206 connect(m_ui->reverseA, &QCheckBox::stateChanged,
this,
208 connect(m_ui->toggleHSV, &QRadioButton::toggled,
this,
210 connect(m_ui->toggleRGB, &QRadioButton::toggled,
this,
213 connect(m_ui->fixR, &QCheckBox::stateChanged,
this,
215 connect(m_ui->fixG, &QCheckBox::stateChanged,
this,
217 connect(m_ui->fixB, &QCheckBox::stateChanged,
this,
219 connect(m_ui->fixA, &QCheckBox::stateChanged,
this,
263 m_ui->reverseR->isChecked(), m_ui->reverseG->isChecked(),
264 m_ui->reverseB->isChecked(), m_ui->reverseA->isChecked()};
267 if (m_ui->toggleRGB->isChecked()) {
269 m_ui->mRedLabel->setText(QStringLiteral(
"Red"));
270 m_ui->mGreenLabel->setText(QStringLiteral(
"Green"));
271 m_ui->mBlueLabel->setText(QStringLiteral(
"Blue"));
272 m_ui->mAlphaLabel->setText(QStringLiteral(
"Alpha"));
300 m_ui->mRedLabel->setText(QStringLiteral(
"Hue"));
301 m_ui->mGreenLabel->setText(QStringLiteral(
"Sat"));
302 m_ui->mBlueLabel->setText(QStringLiteral(
"Value"));
303 m_ui->mAlphaLabel->setText(QStringLiteral(
"Alpha"));
336 for (
unsigned i = 0; i < 360; i += 2) {
350 QColor(col.
r, col.
g, col.
b, 255)));
389 "[ccColorFromScalarDlg] updateHistogram called with an "
390 "invalid channel index");
396 m_ui->fixR->isChecked(), m_ui->fixG->isChecked(),
397 m_ui->fixB->isChecked(), m_ui->fixA->isChecked()};
417 if (n == 0 && m_ui->toggleHSV->isChecked()) {
461 "[ccColorFromScalarDlg] updateSpinBoxLimits called with an "
462 "invalid channel index");
466 m_ui->fixR->isChecked(), m_ui->fixG->isChecked(),
467 m_ui->fixB->isChecked(), m_ui->fixA->isChecked()};
477 if (singleStepSize < 0.01) {
478 singleStepSize = 0.01;
487 QAbstractSpinBox::CorrectionMode::CorrectToNearestValue);
496 "[ccColorFromScalarDlg] updateChannel called with an "
497 "invalid channel index");
518 "[ccColorFromScalarDlg] setDefaultSatValuePerChannel "
519 "called with an invalid channel index");
544 "[ccColorFromScalarDlg] minChanged called with an invalid "
568 "[ccColorFromScalarDlg] maxChanged called with an invalid "
597 m_ui->reverseR->isChecked(), m_ui->reverseG->isChecked(),
598 m_ui->reverseB->isChecked(), m_ui->reverseA->isChecked()};
602 m_ui->fixR->isChecked(), m_ui->fixG->isChecked(),
603 m_ui->fixB->isChecked(), m_ui->fixA->isChecked()};
606 if (m_ui->toggleRGB->isChecked()) {
613 col[i] =
static_cast<int>(
m_boxes_min[i]->value());
616 col[i] =
static_cast<int>(
627 if (reversed[i] && !fixed[i]) {
628 col[i] = 255 - col[i];
633 QColor(col[0], col[1], col[2], col[3])));
660 if (reversed[i] && !fixed[i]) {
661 col[i] = 1.0f - col[i];
691 m_ui->toggleHSV->setEnabled(
false);
692 m_ui->toggleRGB->setEnabled(
false);
693 m_ui->fixR->setEnabled(
false);
694 m_ui->fixG->setEnabled(
false);
695 m_ui->fixB->setEnabled(
false);
696 m_ui->fixA->setEnabled(
false);
697 m_ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(
false);
static bool Error(const char *format,...)
Display an error dialog with formatted message.
QDoubleSpinBox * m_boxes_min[c_channelCount]
ccColorScale::Shared m_storedOrigColorScale
Associated point cloud scalar field original scale (to restore on exit)
QLabel * m_labels_max[c_channelCount]
void minSpinChangedG(double val)
void minChanged(int n, double val, bool slider)
void disableAllButCancel()
void maxSpinChangedA(double val)
void minChangedR(double val)
void minSpinChangedA(double val)
void maxSpinChangedG(double val)
void onChannelChangedR(int)
void maxChangedB(double val)
void minChangedB(double val)
void toggleColorMode(bool state)
void maxChangedG(double val)
void maxChanged(int n, double val, bool slider)
void maxSpinChangedB(double val)
ccHistogramWindow * m_histograms[c_channelCount]
Associated histogram view.
double m_maxSat[c_channelCount]
void minSpinChangedR(double val)
ccColorScale::Shared m_colors[c_channelCount]
Associated colour scales.
QCheckBox * m_reverse[c_channelCount]
void setDefaultSatValuePerChannel(int)
void updateSpinBoxLimits(int)
QLabel * m_labels_min[c_channelCount]
void maxChangedR(double val)
ccScalarField * m_scalars[c_channelCount]
void onChannelChangedA(int)
static constexpr int c_channelCount
ccScalarField::Range m_storedOrigSatRange
void minSpinChangedB(double val)
void maxChangedA(double val)
void minChangedG(double val)
void minChangedA(double val)
bool m_prevFixed[c_channelCount]
QDoubleSpinBox * m_boxes_max[c_channelCount]
QComboBox * m_combos[c_channelCount]
void onChannelChangedB(int)
ccScalarField::Range m_storedOrigDisplayRange
void resizeEvent(QResizeEvent *event)
void toggleColors(int val)
void updateHistogram(int)
ccColorFromScalarDlg(QWidget *parent, ccPointCloud *pointCloud)
Default constructor.
ccPointCloud * m_cloud
Associated point cloud (color source)
void onChannelChangedG(int)
double m_minSat[c_channelCount]
void maxSpinChangedR(double val)
Color scale element: one value + one color.
QSharedPointer< ccColorScale > Shared
Shared pointer type.
virtual void showColors(bool state)
Sets colors visibility.
virtual void showSF(bool state)
Sets active scalarfield visibility.
virtual void redrawDisplay(bool forceRedraw=true, bool only2D=false)
Redraws associated display.
void sfMaxSatValChanged(double)
void sfMinSatValChanged(double)
void setMinSatValue(double)
void refresh()
Updates the display.
void fromSF(ccScalarField *sf, unsigned initialNumberOfClasses=0, bool numberOfClassesCanBeChanged=true, bool showNaNValuesInGrey=true)
Computes histogram from a scalar field.
void fromBinArray(const std::vector< unsigned > &histoValues, double minVal, double maxVal)
void setAxisDisplayOption(AxisDisplayOptions axisOptions)
void setRefreshAfterResize(bool refreshAfterResize)
void setSFInteractionMode(SFInteractionModes modes)
Enables SF interaction mode.
void setMaxSatValue(double)
void clear()
Clears the display.
void setAxisLabels(const QString &xLabel, const QString &yLabel)
Sets axis labels.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
void setCurrentDisplayedScalarField(int index)
Sets the currently displayed scalar field.
bool resizeTheRGBTable(bool fillWithWhite=false)
Resizes the RGB colors array.
int getCurrentDisplayedScalarFieldIndex() const
Returns the currently displayed scalar field index (or -1 if none)
bool hasColors() const override
Returns whether colors are enabled or not.
void setPointColor(size_t pointIndex, const ecvColor::Rgb &col)
Sets a particular point color.
ccScalarField * getCurrentDisplayedScalarField() const
Returns the currently displayed scalar (or 0 if none)
A scalar field associated to display-related parameters.
const ccColorScale::Shared & getColorScale() const
Returns associated color scale.
void setSaturationStop(ScalarType val)
Sets the value at which to stop color gradient.
void setMinDisplayed(ScalarType val)
Sets the minimum displayed value.
void setColorScale(ccColorScale::Shared scale)
Sets associated color scale.
const Range & saturationRange() const
Access to the range of saturation values.
const Range & displayRange() const
Access to the range of displayed values.
void setSaturationStart(ScalarType val)
Sets the value at which to start color gradient.
void setMaxDisplayed(ScalarType val)
Sets the maximum displayed value.
ScalarField * getScalarField(int index) const
Returns a pointer to a specific scalar field.
unsigned getNumberOfScalarFields() const
Returns the number of associated (and active) scalar fields.
unsigned size() const override
const char * getScalarFieldName(int index) const
Returns the name of a specific scalar field.
ScalarType getMin() const
Returns the minimum value.
ScalarType & getValue(std::size_t index)
ScalarType getMax() const
Returns the maximum value.
static Rgb hsv2rgb(float H, float S, float V)
Converts a HSV color to RGB color space.
constexpr utility::nullopt_t None
constexpr Rgb black(0, 0, 0)
constexpr Rgb white(MAX, MAX, MAX)
constexpr ColorCompType MAX
Max value of a single color component (default type)
Rgba FromQColora(QColor qColor)
Conversion from QColor'a'.
constexpr Rgb red(MAX, 0, 0)
constexpr Rgb blue(0, 0, MAX)
constexpr Rgb green(0, MAX, 0)