1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
|
//##########################################################################
//# #
//# CLOUDCOMPARE #
//# #
//# This program is free software; you can redistribute it and/or modify #
//# it under the terms of the GNU General Public License as published by #
//# the Free Software Foundation; version 2 or later of the License. #
//# #
//# This program is distributed in the hope that it will be useful, #
//# but WITHOUT ANY WARRANTY; without even the implied warranty of #
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
//# GNU General Public License for more details. #
//# #
//# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
//# #
//##########################################################################
#include "sfEditDlg.h"
//Local
#include "ccHistogramWindow.h"
//qCC_db
#include <ccScalarField.h>
//CCLib
#include <CCConst.h>
//system
#include <assert.h>
#include <cmath>
//! Default number of steps for spin-boxes
const int SPIN_BOX_STEPS = 1000;
sfEditDlg::sfEditDlg(QWidget* parent/*=0*/)
: QWidget(parent)
, Ui::SFEditDlg()
, m_associatedSF(0)
, m_associatedSFHisto(0)
{
setupUi(this);
//histogram window
{
m_associatedSFHisto = new ccHistogramWindow();
QHBoxLayout* hboxLayout = new QHBoxLayout(histoFrame);
hboxLayout->addWidget(m_associatedSFHisto);
hboxLayout->setContentsMargins(0,0,0,0);
m_associatedSFHisto->enableSFInteractionMode(true);
m_associatedSFHisto->xAxis->setTickLabels(false);
//m_associatedSFHisto->xAxis->setAutoSubTicks(false);
//m_associatedSFHisto->xAxis->setSubTickCount(0);
m_associatedSFHisto->xAxis->setAutoTickCount(6);
m_associatedSFHisto->yAxis->setTickLabels(false);
//m_associatedSFHisto->yAxis->setAutoSubTicks(false);
//m_associatedSFHisto->yAxis->setSubTickCount(0);
m_associatedSFHisto->yAxis->setAutoTickCount(3);
}
connect(minValSpinBox, SIGNAL(valueChanged(double)), this, SLOT(minValSBChanged(double)));
connect(maxValSpinBox, SIGNAL(valueChanged(double)), this, SLOT(maxValSBChanged(double)));
connect(minSatSpinBox, SIGNAL(valueChanged(double)), this, SLOT(minSatSBChanged(double)));
connect(maxSatSpinBox, SIGNAL(valueChanged(double)), this, SLOT(maxSatSBChanged(double)));
connect(m_associatedSFHisto, SIGNAL(sfMinDispValChanged(double)), this, SLOT(minValHistoChanged(double)));
connect(m_associatedSFHisto, SIGNAL(sfMaxDispValChanged(double)), this, SLOT(maxValHistoChanged(double)));
connect(m_associatedSFHisto, SIGNAL(sfMinSatValChanged(double)), this, SLOT(minSatHistoChanged(double)));
connect(m_associatedSFHisto, SIGNAL(sfMaxSatValChanged(double)), this, SLOT(maxSatHistoChanged(double)));
//checkboxes
connect(nanInGreyCheckBox, SIGNAL(toggled(bool)), this, SLOT(nanInGrayChanged(bool)));
connect(alwaysShow0CheckBox, SIGNAL(toggled(bool)), this, SLOT(alwaysShow0Changed(bool)));
connect(symmetricalScaleCheckBox, SIGNAL(toggled(bool)), this, SLOT(symmetricalScaleChanged(bool)));
connect(logScaleCheckBox, SIGNAL(toggled(bool)), this, SLOT(logScaleChanged(bool)));
show();
}
void sfEditDlg::fillDialogWith(ccScalarField* sf)
{
m_associatedSF = sf;
if (!sf)
{
assert(false);
setEnabled(false);
histoFrame->setVisible(false);
return;
}
//options (checkboxes)
{
bool nanValuesInGrey = sf->areNaNValuesShownInGrey();
bool alwaysShowZero = sf->isZeroAlwaysShown();
bool symmetricalScale = sf->symmetricalScale();
bool logScale = sf->logScale();
bool absoluteScale = sf->getColorScale() && !sf->getColorScale()->isRelative();
nanInGreyCheckBox->blockSignals(true);
nanInGreyCheckBox->setChecked(nanValuesInGrey);
nanInGreyCheckBox->blockSignals(false);
alwaysShow0CheckBox->blockSignals(true);
alwaysShow0CheckBox->setChecked(alwaysShowZero);
alwaysShow0CheckBox->setEnabled(!logScale);
alwaysShow0CheckBox->blockSignals(false);
symmetricalScaleCheckBox->blockSignals(true);
symmetricalScaleCheckBox->setChecked(symmetricalScale);
symmetricalScaleCheckBox->setEnabled(!absoluteScale && !logScale);
symmetricalScaleCheckBox->blockSignals(false);
logScaleCheckBox->blockSignals(true);
logScaleCheckBox->setChecked(logScale);
logScaleCheckBox->blockSignals(false);
if (logScale)
satLabel->setText("log sat.");
else if (symmetricalScale)
satLabel->setText("abs. sat.");
else
satLabel->setText("saturation");
}
//displayed and saturation values
{
const ccScalarField::Range& displayRange = sf->displayRange();
const ccScalarField::Range& saturationRange = sf->saturationRange();
//special case: no need to actiate this widget for flat scalar field
//(worse, divisions by zero may occur!)
bool flatSF = (displayRange.maxRange() == 0);
slidersFrame->setEnabled(!flatSF);
//show histogram
histoFrame->setVisible(true);
{
const ccScalarField::Histogram& histogram = m_associatedSF->getHistogram();
unsigned classNumber = static_cast<unsigned>(histogram.size());
if (classNumber == 0)
classNumber = 128;
m_associatedSFHisto->fromSF(m_associatedSF,classNumber,false);
}
/*** spinboxes ***/
minValSpinBox->blockSignals(true);
minSatSpinBox->blockSignals(true);
maxSatSpinBox->blockSignals(true);
maxValSpinBox->blockSignals(true);
if (!flatSF)
{
//Minimum displayed value
minValSpinBox->setRange(displayRange.min(),displayRange.stop());
minValSpinBox->setSingleStep(displayRange.maxRange()/SPIN_BOX_STEPS);
minValSpinBox->setValue(displayRange.start());
//Minimum color saturation value
minSatSpinBox->setRange(saturationRange.min(),saturationRange.stop());
minSatSpinBox->setSingleStep(saturationRange.maxRange()/SPIN_BOX_STEPS);
minSatSpinBox->setValue(saturationRange.start());
// Maximum color saturation value slider
maxSatSpinBox->setRange(saturationRange.start(),saturationRange.max());
maxSatSpinBox->setSingleStep(saturationRange.maxRange()/SPIN_BOX_STEPS);
maxSatSpinBox->setValue(saturationRange.stop());
// Maximum displayed value slider
maxValSpinBox->setRange(displayRange.start(),displayRange.max());
maxValSpinBox->setSingleStep(displayRange.maxRange()/SPIN_BOX_STEPS);
maxValSpinBox->setValue(displayRange.stop());
}
else
{
//unique value
double uniqueVal = displayRange.min();
minValSpinBox->setRange(uniqueVal,uniqueVal);
minSatSpinBox->setRange(uniqueVal,uniqueVal);
maxSatSpinBox->setRange(uniqueVal,uniqueVal);
maxValSpinBox->setRange(uniqueVal,uniqueVal);
}
minValSpinBox->blockSignals(false);
minSatSpinBox->blockSignals(false);
maxSatSpinBox->blockSignals(false);
maxValSpinBox->blockSignals(false);
}
}
void sfEditDlg::minValSBChanged(double val)
{
if (!m_associatedSF)
return;
m_associatedSFHisto->setMinDispValue(val);
emit entitySFHasChanged();
QApplication::processEvents();
}
void sfEditDlg::maxValSBChanged(double val)
{
if (!m_associatedSF)
return;
m_associatedSFHisto->setMaxDispValue(val);
emit entitySFHasChanged();
QApplication::processEvents();
}
void sfEditDlg::minSatSBChanged(double val)
{
if (!m_associatedSF)
return;
m_associatedSFHisto->setMinSatValue(val);
emit entitySFHasChanged();
QApplication::processEvents();
}
void sfEditDlg::maxSatSBChanged(double val)
{
if (!m_associatedSF)
return;
m_associatedSFHisto->setMaxSatValue(val);
emit entitySFHasChanged();
QApplication::processEvents();
}
void sfEditDlg::minValHistoChanged(double val)
{
if (!m_associatedSF)
return;
minValSpinBox->blockSignals(true);
minValSpinBox->setValue(val);
minValSpinBox->blockSignals(false);
emit entitySFHasChanged();
QApplication::processEvents();
}
void sfEditDlg::maxValHistoChanged(double val)
{
if (!m_associatedSF)
return;
maxValSpinBox->blockSignals(true);
maxValSpinBox->setValue(val);
maxValSpinBox->blockSignals(false);
emit entitySFHasChanged();
QApplication::processEvents();
}
void sfEditDlg::minSatHistoChanged(double val)
{
if (!m_associatedSF)
return;
minSatSpinBox->blockSignals(true);
minSatSpinBox->setValue(val);
minSatSpinBox->blockSignals(false);
emit entitySFHasChanged();
QApplication::processEvents();
}
void sfEditDlg::maxSatHistoChanged(double val)
{
if (!m_associatedSF)
return;
maxSatSpinBox->blockSignals(true);
maxSatSpinBox->setValue(val);
maxSatSpinBox->blockSignals(false);
emit entitySFHasChanged();
QApplication::processEvents();
}
void sfEditDlg::nanInGrayChanged(bool state)
{
if (!m_associatedSF)
return;
if (m_associatedSF->areNaNValuesShownInGrey() != state)
{
m_associatedSF->showNaNValuesInGrey(state);
emit entitySFHasChanged();
//m_associatedSFHisto->refreshBars();
}
}
void sfEditDlg::alwaysShow0Changed(bool state)
{
if (!m_associatedSF)
return;
if (m_associatedSF->isZeroAlwaysShown() != state)
{
m_associatedSF->alwaysShowZero(state);
emit entitySFHasChanged();
//m_associatedSFHisto->refreshBars();
}
}
void sfEditDlg::symmetricalScaleChanged(bool state)
{
if (!m_associatedSF)
return;
if (m_associatedSF->symmetricalScale() != state)
{
m_associatedSF->setSymmetricalScale(state);
fillDialogWith(m_associatedSF); //the saturation sliders may need to be updated!
emit entitySFHasChanged();
//Saturation might change!
m_associatedSFHisto->refresh();
//m_associatedSFHisto->refreshBars();
}
}
void sfEditDlg::logScaleChanged(bool state)
{
if (!m_associatedSF)
return;
if (m_associatedSF->logScale() != state)
{
m_associatedSF->setLogScale(state);
fillDialogWith(m_associatedSF); //the saturation sliders + the symmetrical scale checkbox may need to be updated!
emit entitySFHasChanged();
//Saturation might change!
m_associatedSFHisto->refresh();
//m_associatedSFHisto->refreshBars();
}
}
|