All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -54,113 +54,127 @@ DlgSettingsLightSources::DlgSettingsLightSources(QWidget* parent)
|
||||
|
||||
configureViewer();
|
||||
|
||||
const auto connectLightEvents = [this](QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
QSpinBox* intensitySpinBox,
|
||||
ColorButton* colorButton,
|
||||
QCheckBox* enabledCheckbox,
|
||||
auto updateLightFunction) {
|
||||
connect(horizontalAngleSpinBox,
|
||||
qOverload<double>(&QuantitySpinBox::valueChanged),
|
||||
this,
|
||||
updateLightFunction);
|
||||
connect(verticalAngleSpinBox,
|
||||
qOverload<double>(&QuantitySpinBox::valueChanged),
|
||||
this,
|
||||
updateLightFunction);
|
||||
connect(intensitySpinBox,
|
||||
qOverload<int>(&QSpinBox::valueChanged),
|
||||
this,
|
||||
updateLightFunction);
|
||||
const auto connectLightEvents = [this](
|
||||
QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
QSpinBox* intensitySpinBox,
|
||||
ColorButton* colorButton,
|
||||
QCheckBox* enabledCheckbox,
|
||||
auto updateLightFunction
|
||||
) {
|
||||
connect(
|
||||
horizontalAngleSpinBox,
|
||||
qOverload<double>(&QuantitySpinBox::valueChanged),
|
||||
this,
|
||||
updateLightFunction
|
||||
);
|
||||
connect(
|
||||
verticalAngleSpinBox,
|
||||
qOverload<double>(&QuantitySpinBox::valueChanged),
|
||||
this,
|
||||
updateLightFunction
|
||||
);
|
||||
connect(intensitySpinBox, qOverload<int>(&QSpinBox::valueChanged), this, updateLightFunction);
|
||||
connect(colorButton, &ColorButton::changed, this, updateLightFunction);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6,7,0)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
||||
connect(enabledCheckbox, &QCheckBox::checkStateChanged, this, updateLightFunction);
|
||||
#else
|
||||
connect(enabledCheckbox, &QCheckBox::stateChanged, this, updateLightFunction);
|
||||
#endif
|
||||
};
|
||||
|
||||
const auto updateLight = [this](SoDirectionalLight* light,
|
||||
QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
QSpinBox* intensitySpinBox,
|
||||
ColorButton* colorButton,
|
||||
QCheckBox* enabledCheckbox,
|
||||
std::function<void(bool)> setLightEnabled) {
|
||||
const auto updateLight = [this](
|
||||
SoDirectionalLight* light,
|
||||
QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
QSpinBox* intensitySpinBox,
|
||||
ColorButton* colorButton,
|
||||
QCheckBox* enabledCheckbox,
|
||||
std::function<void(bool)> setLightEnabled
|
||||
) {
|
||||
light->color = Base::convertTo<SbColor>(colorButton->color());
|
||||
light->intensity = Base::fromPercent(intensitySpinBox->value());
|
||||
light->direction =
|
||||
Base::convertTo<SbVec3f>(azimuthElevationToDirection(horizontalAngleSpinBox->rawValue(),
|
||||
verticalAngleSpinBox->rawValue()));
|
||||
light->direction = Base::convertTo<SbVec3f>(azimuthElevationToDirection(
|
||||
horizontalAngleSpinBox->rawValue(),
|
||||
verticalAngleSpinBox->rawValue()
|
||||
));
|
||||
setLightEnabled(enabledCheckbox->isChecked());
|
||||
};
|
||||
|
||||
const auto updateHeadLight = [this, updateLight] {
|
||||
updateLight(view->getHeadlight(),
|
||||
ui->mainLightHorizontalAngle,
|
||||
ui->mainLightVerticalAngle,
|
||||
ui->mainLightIntensitySpinBox,
|
||||
ui->mainLightColor,
|
||||
ui->mainLightEnable,
|
||||
[this](bool enabled) {
|
||||
view->setHeadlightEnabled(enabled);
|
||||
});
|
||||
updateLight(
|
||||
view->getHeadlight(),
|
||||
ui->mainLightHorizontalAngle,
|
||||
ui->mainLightVerticalAngle,
|
||||
ui->mainLightIntensitySpinBox,
|
||||
ui->mainLightColor,
|
||||
ui->mainLightEnable,
|
||||
[this](bool enabled) { view->setHeadlightEnabled(enabled); }
|
||||
);
|
||||
};
|
||||
|
||||
const auto updateFillLight = [this, updateLight] {
|
||||
updateLight(view->getFillLight(),
|
||||
ui->fillLightHorizontalAngle,
|
||||
ui->fillLightVerticalAngle,
|
||||
ui->fillLightIntensitySpinBox,
|
||||
ui->fillLightColor,
|
||||
ui->fillLightEnable,
|
||||
[this](bool enabled) {
|
||||
view->setFillLightEnabled(enabled);
|
||||
});
|
||||
updateLight(
|
||||
view->getFillLight(),
|
||||
ui->fillLightHorizontalAngle,
|
||||
ui->fillLightVerticalAngle,
|
||||
ui->fillLightIntensitySpinBox,
|
||||
ui->fillLightColor,
|
||||
ui->fillLightEnable,
|
||||
[this](bool enabled) { view->setFillLightEnabled(enabled); }
|
||||
);
|
||||
};
|
||||
|
||||
const auto updateBackLight = [this, updateLight] {
|
||||
updateLight(view->getBacklight(),
|
||||
ui->backLightHorizontalAngle,
|
||||
ui->backLightVerticalAngle,
|
||||
ui->backLightIntensitySpinBox,
|
||||
ui->backLightColor,
|
||||
ui->backLightEnable,
|
||||
[this](bool enabled) {
|
||||
view->setBacklightEnabled(enabled);
|
||||
});
|
||||
updateLight(
|
||||
view->getBacklight(),
|
||||
ui->backLightHorizontalAngle,
|
||||
ui->backLightVerticalAngle,
|
||||
ui->backLightIntensitySpinBox,
|
||||
ui->backLightColor,
|
||||
ui->backLightEnable,
|
||||
[this](bool enabled) { view->setBacklightEnabled(enabled); }
|
||||
);
|
||||
};
|
||||
|
||||
connectLightEvents(ui->mainLightHorizontalAngle,
|
||||
ui->mainLightVerticalAngle,
|
||||
ui->mainLightIntensitySpinBox,
|
||||
ui->mainLightColor,
|
||||
ui->mainLightEnable,
|
||||
updateHeadLight);
|
||||
connectLightEvents(ui->backLightHorizontalAngle,
|
||||
ui->backLightVerticalAngle,
|
||||
ui->backLightIntensitySpinBox,
|
||||
ui->backLightColor,
|
||||
ui->backLightEnable,
|
||||
updateBackLight);
|
||||
connectLightEvents(ui->fillLightHorizontalAngle,
|
||||
ui->fillLightVerticalAngle,
|
||||
ui->fillLightIntensitySpinBox,
|
||||
ui->fillLightColor,
|
||||
ui->fillLightEnable,
|
||||
updateFillLight);
|
||||
connectLightEvents(
|
||||
ui->mainLightHorizontalAngle,
|
||||
ui->mainLightVerticalAngle,
|
||||
ui->mainLightIntensitySpinBox,
|
||||
ui->mainLightColor,
|
||||
ui->mainLightEnable,
|
||||
updateHeadLight
|
||||
);
|
||||
connectLightEvents(
|
||||
ui->backLightHorizontalAngle,
|
||||
ui->backLightVerticalAngle,
|
||||
ui->backLightIntensitySpinBox,
|
||||
ui->backLightColor,
|
||||
ui->backLightEnable,
|
||||
updateBackLight
|
||||
);
|
||||
connectLightEvents(
|
||||
ui->fillLightHorizontalAngle,
|
||||
ui->fillLightVerticalAngle,
|
||||
ui->fillLightIntensitySpinBox,
|
||||
ui->fillLightColor,
|
||||
ui->fillLightEnable,
|
||||
updateFillLight
|
||||
);
|
||||
|
||||
const auto updateAmbientLight = [this] {
|
||||
view->getEnvironment()->ambientColor =
|
||||
Base::convertTo<SbColor>(ui->ambientLightColor->color());
|
||||
view->getEnvironment()->ambientIntensity =
|
||||
Base::fromPercent(ui->ambientLightIntensitySpinBox->value());
|
||||
view->getEnvironment()->ambientColor = Base::convertTo<SbColor>(ui->ambientLightColor->color());
|
||||
view->getEnvironment()->ambientIntensity = Base::fromPercent(
|
||||
ui->ambientLightIntensitySpinBox->value()
|
||||
);
|
||||
};
|
||||
|
||||
connect(ui->ambientLightIntensitySpinBox,
|
||||
qOverload<int>(&QSpinBox::valueChanged),
|
||||
this,
|
||||
updateAmbientLight);
|
||||
connect(
|
||||
ui->ambientLightIntensitySpinBox,
|
||||
qOverload<int>(&QSpinBox::valueChanged),
|
||||
this,
|
||||
updateAmbientLight
|
||||
);
|
||||
connect(ui->ambientLightColor, &ColorButton::changed, this, updateAmbientLight);
|
||||
|
||||
connect(ui->zoomInButton, &QToolButton::clicked, this, &DlgSettingsLightSources::zoomIn);
|
||||
@@ -220,10 +234,10 @@ void DlgSettingsLightSources::configureViewer()
|
||||
|
||||
const auto callback = new SoEventCallback();
|
||||
root->addChild(callback);
|
||||
callback->addEventCallback(SoEvent::getClassTypeId(),
|
||||
[]([[maybe_unused]] void* ud, SoEventCallback* cb) {
|
||||
cb->setHandled();
|
||||
});
|
||||
callback->addEventCallback(
|
||||
SoEvent::getClassTypeId(),
|
||||
[]([[maybe_unused]] void* ud, SoEventCallback* cb) { cb->setHandled(); }
|
||||
);
|
||||
|
||||
view->setCameraType(SoOrthographicCamera::getClassTypeId());
|
||||
view->setViewDirection(defaultViewDirection);
|
||||
@@ -235,28 +249,29 @@ void DlgSettingsLightSources::configureViewer()
|
||||
zoomStep = cameraHeight / 14.0f;
|
||||
}
|
||||
|
||||
Base::Vector3d DlgSettingsLightSources::azimuthElevationToDirection(double azimuth,
|
||||
double elevation)
|
||||
Base::Vector3d DlgSettingsLightSources::azimuthElevationToDirection(double azimuth, double elevation)
|
||||
{
|
||||
azimuth = Base::toRadians(azimuth);
|
||||
elevation = Base::toRadians(elevation);
|
||||
|
||||
auto direction = Base::Vector3d {std::sin(azimuth) * std::cos(elevation),
|
||||
std::cos(azimuth) * std::cos(elevation),
|
||||
std::sin(elevation)};
|
||||
auto direction = Base::Vector3d {
|
||||
std::sin(azimuth) * std::cos(elevation),
|
||||
std::cos(azimuth) * std::cos(elevation),
|
||||
std::sin(elevation)
|
||||
};
|
||||
|
||||
direction.Normalize();
|
||||
|
||||
return direction;
|
||||
}
|
||||
|
||||
std::pair<double, double>
|
||||
DlgSettingsLightSources::directionToAzimuthElevation(Base::Vector3d direction)
|
||||
std::pair<double, double> DlgSettingsLightSources::directionToAzimuthElevation(Base::Vector3d direction)
|
||||
{
|
||||
const auto azimuth = std::atan2(direction[0], direction[1]);
|
||||
const auto elevation =
|
||||
std::atan2(direction[2],
|
||||
std::sqrt(direction[1] * direction[1] + direction[0] * direction[0]));
|
||||
const auto elevation = std::atan2(
|
||||
direction[2],
|
||||
std::sqrt(direction[1] * direction[1] + direction[0] * direction[0])
|
||||
);
|
||||
|
||||
return {Base::toDegrees(azimuth), Base::toDegrees(elevation)};
|
||||
}
|
||||
@@ -269,15 +284,18 @@ void DlgSettingsLightSources::saveSettings()
|
||||
}
|
||||
}
|
||||
|
||||
const auto saveAngles = [this](QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
const char* parameter) {
|
||||
const auto saveAngles = [this](
|
||||
QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
const char* parameter
|
||||
) {
|
||||
try {
|
||||
const auto direction = azimuthElevationToDirection(horizontalAngleSpinBox->rawValue(),
|
||||
verticalAngleSpinBox->rawValue());
|
||||
const auto direction = azimuthElevationToDirection(
|
||||
horizontalAngleSpinBox->rawValue(),
|
||||
verticalAngleSpinBox->rawValue()
|
||||
);
|
||||
|
||||
hGrp->SetASCII(parameter,
|
||||
Base::vectorToString(Base::convertTo<Base::Vector3f>(direction)));
|
||||
hGrp->SetASCII(parameter, Base::vectorToString(Base::convertTo<Base::Vector3f>(direction)));
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
@@ -296,13 +314,16 @@ void DlgSettingsLightSources::loadSettings()
|
||||
}
|
||||
}
|
||||
|
||||
const auto loadAngles = [this](QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
const char* parameter) {
|
||||
const auto loadAngles = [this](
|
||||
QuantitySpinBox* horizontalAngleSpinBox,
|
||||
QuantitySpinBox* verticalAngleSpinBox,
|
||||
const char* parameter
|
||||
) {
|
||||
try {
|
||||
const auto direction = Base::stringToVector(hGrp->GetASCII(parameter));
|
||||
const auto [azimuth, elevation] =
|
||||
directionToAzimuthElevation(Base::convertTo<Base::Vector3d>(direction));
|
||||
const auto [azimuth, elevation] = directionToAzimuthElevation(
|
||||
Base::convertTo<Base::Vector3d>(direction)
|
||||
);
|
||||
|
||||
horizontalAngleSpinBox->setValue(azimuth);
|
||||
verticalAngleSpinBox->setValue(elevation);
|
||||
|
||||
Reference in New Issue
Block a user