20 #include <QPushButton>
33 : QDialog(parent, Qt::Tool),
34 Ui::ColorLevelsDialog(),
40 connect(channelComboBox,
41 static_cast<void (QComboBox::*)(
int)
>(
42 &QComboBox::currentIndexChanged),
44 connect(buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked,
53 histoFrame->setLayout(
new QHBoxLayout());
70 if (pointCount == 0) {
76 std::vector<unsigned> histoValues[3];
78 for (
int i = 0; i < 3; ++i) {
79 if (channelComboBox->currentIndex() ==
RGB ||
80 channelComboBox->currentIndex() == i + 1) {
84 }
catch (
const std::bad_alloc&) {
90 std::vector<unsigned>* histoValuesR =
91 (histoValues[0].empty() ? 0 : histoValues);
92 std::vector<unsigned>* histoValuesG =
93 (histoValues[1].empty() ? 0 : histoValues + 1);
94 std::vector<unsigned>* histoValuesB =
95 (histoValues[2].empty() ? 0 : histoValues + 2);
97 switch (channelComboBox->currentIndex()) {
102 histoValuesG = histoValuesR;
103 histoValuesB = histoValuesR;
121 for (
unsigned i = 0; i < pointCount; ++i) {
123 if (histoValuesR) histoValuesR->at(rgb.
r)++;
124 if (histoValuesG) histoValuesG->at(rgb.
g)++;
125 if (histoValuesB) histoValuesB->at(rgb.
b)++;
129 for (
int i = 0; i < 3; ++i) {
130 if (channelComboBox->currentIndex() ==
RGB ||
131 channelComboBox->currentIndex() == i + 1) {
151 (minInputSpinBox->value() != 0 || maxInputSpinBox->value() != 255 ||
152 minOutputSpinBox->value() != 0 || maxOutputSpinBox->value() != 255)) {
153 bool applyRGB[3] = {channelComboBox->currentIndex() ==
RGB ||
154 channelComboBox->currentIndex() ==
RED,
155 channelComboBox->currentIndex() ==
RGB ||
156 channelComboBox->currentIndex() ==
GREEN,
157 channelComboBox->currentIndex() ==
RGB ||
158 channelComboBox->currentIndex() ==
BLUE};
166 for (
unsigned i = 0; i < pointCount; ++i) {
169 for (
unsigned c = 0; c < 3; ++c) {
173 double u = (
static_cast<double>(rgb.
rgb[c]) -
181 newRgb.
rgb[c] = rgb.
rgb[c];
203 minInputSpinBox->setValue(0);
204 maxInputSpinBox->setValue(255);
205 minOutputSpinBox->setValue(0);
206 maxOutputSpinBox->setValue(255);
ccHistogramWindow * m_histogram
Associated histogram view.
void onChannelChanged(int)
ccColorLevelsDlg(QWidget *parent, ccGenericPointCloud *pointCloud)
Default constructor.
void updateHistogram()
Updates histogram.
ccGenericPointCloud * m_cloud
Associated point cloud (color source)
A 3D cloud interface with associated features (color, normals, octree, etc.)
virtual const ecvColor::Rgb & getPointColor(unsigned pointIndex) const =0
Returns color corresponding to a given point.
static ccPointCloud * ToPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccPointCloud.
void refresh()
Updates the display.
void setColorScheme(HISTOGRAM_COLOR_SCHEME scheme)
Sets how the gradient bars should be colored.
void fromBinArray(const std::vector< unsigned > &histoValues, double minVal, double maxVal)
void setSolidColor(QColor color)
Sets solid color.
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 setPointColor(size_t pointIndex, const ecvColor::Rgb &col)
Sets a particular point color.
virtual unsigned size() const =0
Returns the number of points.
static int s_inputLevels[2]
static bool s_outputLevelsEnabled
static int s_outputLevels[2]
unsigned char ColorCompType
Default color components type (R,G and B)
constexpr Rgb black(0, 0, 0)
constexpr ColorCompType MAX
Max value of a single color component (default type)
constexpr Rgb red(MAX, 0, 0)
constexpr Rgb blue(0, 0, MAX)
constexpr Rgb green(0, MAX, 0)