From 114a4680de8d7bce6b55f2b56a6e9c3309ea9e38 Mon Sep 17 00:00:00 2001 From: Daniel Gao Date: Thu, 7 Nov 2024 18:22:59 -0500 Subject: [PATCH] Implement FramingParamsEdited operations * Implements edited param manipulation operations for framing tool --- rtgui/paramsedited.cc | 130 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 3 deletions(-) diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 7a92194ba..a77c48d3a 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -25,6 +25,124 @@ #include "../rtengine/procparams.h" +namespace +{ + +using namespace rtengine::procparams; + +void setAll(FramingParamsEdited& framing, bool v) +{ + framing.enabled = v; + framing.framingMethod = v; + framing.aspectRatio = v; + framing.orientation = v; + framing.framedWidth = v; + framing.framedHeight = v; + framing.allowUpscaling = v; + + framing.borderSizingMethod = v; + framing.basis = v; + framing.relativeBorderSize = v; + framing.minSizeEnabled = v; + framing.minWidth = v; + framing.minHeight = v; + framing.absWidth = v; + framing.absHeight = v; + + framing.borderRed = v; + framing.borderGreen = v; + framing.borderBlue = v; +} + +void initFrom(FramingParamsEdited& edits, const ProcParams& params, const ProcParams& otherParams) +{ + const FramingParams& curr = params.framing; + const FramingParams& other = otherParams.framing; + + edits.enabled &= curr.enabled == other.enabled; + edits.framingMethod &= curr.framingMethod == other.framingMethod; + edits.aspectRatio &= curr.aspectRatio == other.aspectRatio; + edits.orientation &= curr.orientation == other.orientation; + edits.framedWidth &= curr.framedWidth == other.framedWidth; + edits.framedHeight &= curr.framedHeight == other.framedHeight; + edits.allowUpscaling &= curr.allowUpscaling == other.allowUpscaling; + + edits.borderSizingMethod &= curr.borderSizingMethod == other.borderSizingMethod; + edits.basis &= curr.basis == other.basis; + edits.relativeBorderSize &= curr.relativeBorderSize == other.relativeBorderSize; + edits.minSizeEnabled &= curr.minSizeEnabled == other.minSizeEnabled; + edits.minWidth &= curr.minWidth == other.minWidth; + edits.minHeight &= curr.minHeight == other.minHeight; + edits.absWidth &= curr.absWidth == other.absWidth; + edits.absHeight &= curr.absHeight == other.absHeight; + + edits.borderRed &= curr.borderRed == other.borderRed; + edits.borderGreen &= curr.borderGreen == other.borderGreen; + edits.borderBlue &= curr.borderBlue == other.borderBlue; +} + +void combine(FramingParams& toEdit, const FramingParams& mod, const FramingParamsEdited& edits) +{ + if (edits.enabled) { + toEdit.enabled = mod.enabled; + } + if (edits.framingMethod) { + toEdit.framingMethod = mod.framingMethod; + } + if (edits.aspectRatio) { + toEdit.aspectRatio = mod.aspectRatio; + } + if (edits.orientation) { + toEdit.orientation = mod.orientation; + } + if (edits.framedWidth) { + toEdit.framedWidth = mod.framedWidth; + } + if (edits.framedHeight) { + toEdit.framedHeight = mod.framedHeight; + } + if (edits.allowUpscaling) { + toEdit.allowUpscaling = mod.allowUpscaling; + } + + if (edits.borderSizingMethod) { + toEdit.borderSizingMethod = mod.borderSizingMethod; + } + if (edits.basis) { + toEdit.basis = mod.basis; + } + if (edits.relativeBorderSize) { + toEdit.relativeBorderSize = mod.relativeBorderSize; + } + if (edits.minSizeEnabled) { + toEdit.minSizeEnabled = mod.minSizeEnabled; + } + if (edits.minWidth) { + toEdit.minWidth = mod.minWidth; + } + if (edits.minHeight) { + toEdit.minHeight = mod.minHeight; + } + if (edits.absWidth) { + toEdit.absWidth = mod.absWidth; + } + if (edits.absHeight) { + toEdit.absHeight = mod.absHeight; + } + + if (edits.borderRed) { + toEdit.borderRed = mod.borderRed; + } + if (edits.borderGreen) { + toEdit.borderGreen = mod.borderGreen; + } + if (edits.borderBlue) { + toEdit.borderBlue = mod.borderBlue; + } +} + +} // namespace + ParamsEdited::ParamsEdited(bool value) { @@ -446,7 +564,6 @@ void ParamsEdited::set(bool v) blackwhite.autoc = v; blackwhite.algo = v; - resize.scale = v; resize.appliesTo = v; resize.method = v; @@ -456,11 +573,13 @@ void ParamsEdited::set(bool v) resize.longedge = v; resize.shortedge = v; resize.enabled = v; + resize.allowUpscaling = v; + + ::setAll(framing, v); spot.enabled = v; spot.entries = v; - resize.allowUpscaling = v; icm.inputProfile = v; icm.toneCurve = v; icm.applyLookTable = v; @@ -1984,9 +2103,12 @@ void ParamsEdited::initFrom(const std::vector& resize.longedge = resize.longedge && p.resize.longedge == other.resize.longedge; resize.shortedge = resize.shortedge && p.resize.shortedge == other.resize.shortedge; resize.enabled = resize.enabled && p.resize.enabled == other.resize.enabled; + resize.allowUpscaling = resize.allowUpscaling && p.resize.allowUpscaling == other.resize.allowUpscaling; + + ::initFrom(framing, p, other); + spot.enabled = spot.enabled && p.spot.enabled == other.spot.enabled; spot.entries = spot.entries && p.spot.entries == other.spot.entries; - resize.allowUpscaling = resize.allowUpscaling && p.resize.allowUpscaling == other.resize.allowUpscaling; icm.inputProfile = icm.inputProfile && p.icm.inputProfile == other.icm.inputProfile; icm.toneCurve = icm.toneCurve && p.icm.toneCurve == other.icm.toneCurve; icm.applyLookTable = icm.applyLookTable && p.icm.applyLookTable == other.icm.applyLookTable; @@ -6856,6 +6978,8 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.resize.allowUpscaling = mods.resize.allowUpscaling; } + ::combine(toEdit.framing, mods.framing, framing); + if (icm.inputProfile) { toEdit.icm.inputProfile = mods.icm.inputProfile; }