From fb90908cbdfb3522da15e0db1e9f53bfe0ffa17e Mon Sep 17 00:00:00 2001 From: Alexander Brock Date: Sat, 11 Feb 2023 20:31:08 +0100 Subject: [PATCH] Add GUI elements for defish and scale in perspective tool. Doesn't work very good yet. --- rtdata/languages/English (UK) | 1 + rtdata/languages/English (US) | 1 + rtengine/iptransform.cc | 14 +++++------- rtengine/procparams.cc | 8 +++++++ rtengine/procparams.h | 2 ++ rtgui/addsetids.h | 2 ++ rtgui/batchtoolpanelcoord.cc | 4 ++-- rtgui/paramsedited.cc | 12 +++++++++++ rtgui/paramsedited.h | 2 ++ rtgui/perspective.cc | 40 ++++++++++++++++++++++++++++++++++- rtgui/perspective.h | 11 +++++++++- 11 files changed, 84 insertions(+), 13 deletions(-) diff --git a/rtdata/languages/English (UK) b/rtdata/languages/English (UK) index 7de3a54cc..3f21d8f6a 100644 --- a/rtdata/languages/English (UK) +++ b/rtdata/languages/English (UK) @@ -3478,6 +3478,7 @@ TP_WBALANCE_EQBLUERED_TOOLTIP;Allows to deviate from the normal behaviour of 'wh !TP_PERSPECTIVE_POST_CORRECTION_ADJUSTMENT_FRAME;Post-correction adjustment !TP_PERSPECTIVE_PROJECTION_PITCH;Vertical !TP_PERSPECTIVE_PROJECTION_ROTATE;Rotation +!TP_PERSPECTIVE_CAMERA_SCALE;Scale !TP_PERSPECTIVE_PROJECTION_SHIFT_HORIZONTAL;Horizontal shift !TP_PERSPECTIVE_PROJECTION_SHIFT_VERTICAL;Vertical shift !TP_PERSPECTIVE_PROJECTION_YAW;Horizontal diff --git a/rtdata/languages/English (US) b/rtdata/languages/English (US) index 40ad9c57b..580489e7e 100644 --- a/rtdata/languages/English (US) +++ b/rtdata/languages/English (US) @@ -3460,6 +3460,7 @@ !TP_PERSPECTIVE_POST_CORRECTION_ADJUSTMENT_FRAME;Post-correction adjustment !TP_PERSPECTIVE_PROJECTION_PITCH;Vertical !TP_PERSPECTIVE_PROJECTION_ROTATE;Rotation +!TP_PERSPECTIVE_CAMERA_SCALE;Scale !TP_PERSPECTIVE_PROJECTION_SHIFT_HORIZONTAL;Horizontal shift !TP_PERSPECTIVE_PROJECTION_SHIFT_VERTICAL;Vertical shift !TP_PERSPECTIVE_PROJECTION_YAW;Horizontal diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index 595112735..d863d3041 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -1244,15 +1244,11 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I pLCPMap->correctDistortion(x_d, y_d, w2, h2); } - // Hard-coded fisheye undistortion for testing purposes. - bool enableFish = true; - // Hard-coded focal length so it matches the image used for testing - double focal_source = maxRadius*1351.0/5206.416; - // A different destination focal length allows the user to shrink the image so more of the original FoV fits into the undistorted image. - // fish_scale = 0.5 means the source image is downscaled by a factor of two in the center. - double fish_scale = 0.5; - double focal_dst = focal_source*fish_scale; - if (enableFish) { + x_d /= params->perspective.camera_scale; + y_d /= params->perspective.camera_scale; + if (true || params->perspective.camera_defish) { + double const focal_source = params->perspective.camera_focal_length * maxRadius*1351.0/5206.416/6.5; + double focal_dst = focal_source; x_d /= focal_dst; y_d /= focal_dst; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index e6bdc9619..94f897110 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -1973,6 +1973,7 @@ PerspectiveParams::PerspectiveParams() : horizontal(0.0), vertical(0.0), camera_crop_factor(0.0), + camera_defish(false), camera_focal_length(0.0), camera_pitch(0.0), camera_roll(0.0), @@ -1981,6 +1982,7 @@ PerspectiveParams::PerspectiveParams() : camera_yaw(0.0), projection_pitch(0.0), projection_rotate(0.0), + camera_scale(1.0), projection_shift_horiz(0.0), projection_shift_vert(0.0), projection_yaw(0.0) @@ -1994,9 +1996,11 @@ bool PerspectiveParams::operator ==(const PerspectiveParams& other) const && render == other.render && horizontal == other.horizontal && vertical == other.vertical + && camera_defish == other.camera_defish && camera_focal_length == other.camera_focal_length && camera_crop_factor == other.camera_crop_factor && camera_pitch == other.camera_pitch + && camera_scale == other.camera_scale && camera_roll == other.camera_roll && camera_shift_horiz == other.camera_shift_horiz && camera_shift_vert == other.camera_shift_vert @@ -6301,6 +6305,8 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->perspective.camera_crop_factor, "Perspective", "CameraCropFactor", perspective.camera_crop_factor, keyFile); saveToKeyfile(!pedited || pedited->perspective.camera_focal_length, "Perspective", "CameraFocalLength", perspective.camera_focal_length, keyFile); saveToKeyfile(!pedited || pedited->perspective.camera_pitch, "Perspective", "CameraPitch", perspective.camera_pitch, keyFile); + saveToKeyfile(!pedited || pedited->perspective.camera_scale, "Perspective", "CameraScale", perspective.camera_scale, keyFile); + saveToKeyfile(!pedited || pedited->perspective.camera_defish, "Perspective", "CameraDefish", perspective.camera_defish, keyFile); saveToKeyfile(!pedited || pedited->perspective.camera_roll, "Perspective", "CameraRoll", perspective.camera_roll, keyFile); saveToKeyfile(!pedited || pedited->perspective.camera_shift_horiz, "Perspective", "CameraShiftHorizontal", perspective.camera_shift_horiz, keyFile); saveToKeyfile(!pedited || pedited->perspective.camera_shift_vert, "Perspective", "CameraShiftVertical", perspective.camera_shift_vert, keyFile); @@ -8384,6 +8390,8 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "Perspective", "CameraShiftHorizontal", pedited, perspective.camera_shift_horiz, pedited->perspective.camera_shift_horiz); assignFromKeyfile(keyFile, "Perspective", "CameraShiftVertical", pedited, perspective.camera_shift_vert, pedited->perspective.camera_shift_vert); assignFromKeyfile(keyFile, "Perspective", "CameraPitch", pedited, perspective.camera_pitch, pedited->perspective.camera_pitch); + assignFromKeyfile(keyFile, "Perspective", "CameraScale", pedited, perspective.camera_scale, pedited->perspective.camera_scale); + assignFromKeyfile(keyFile, "Perspective", "CameraDefish", pedited, perspective.camera_defish, pedited->perspective.camera_defish); assignFromKeyfile(keyFile, "Perspective", "CameraRoll", pedited, perspective.camera_roll, pedited->perspective.camera_roll); assignFromKeyfile(keyFile, "Perspective", "CameraCropFactor", pedited, perspective.camera_crop_factor, pedited->perspective.camera_crop_factor); assignFromKeyfile(keyFile, "Perspective", "CameraFocalLength", pedited, perspective.camera_focal_length, pedited->perspective.camera_focal_length); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index e86272b0a..7faf30fbb 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -960,6 +960,7 @@ struct PerspectiveParams { * be interpreted with {@link #DEFAULT_CAMERA_CROP_FACTOR}. */ double camera_crop_factor; + bool camera_defish; /** * Negative and zero values indicate an unspecified focal length and should * be interpreted with {@link #DEFAULT_CAMERA_FOCAL_LENGTH}. @@ -972,6 +973,7 @@ struct PerspectiveParams { double camera_yaw; double projection_pitch; double projection_rotate; + double camera_scale; double projection_shift_horiz; double projection_shift_vert; double projection_yaw; diff --git a/rtgui/addsetids.h b/rtgui/addsetids.h index 6f68c6ae7..d42efc1c0 100644 --- a/rtgui/addsetids.h +++ b/rtgui/addsetids.h @@ -19,7 +19,9 @@ enum { ADDSET_DIST_AMOUNT, ADDSET_PERSPECTIVE, ADDSET_PERSP_CAM_ANGLE, + ADDSET_PERSP_CAM_DEFISH, ADDSET_PERSP_CAM_FOCAL_LENGTH, + ADDSET_PERSP_CAM_SCALE, ADDSET_PERSP_CAM_SHIFT, ADDSET_PERSP_PROJ_ANGLE, ADDSET_PERSP_PROJ_ROTATE, diff --git a/rtgui/batchtoolpanelcoord.cc b/rtgui/batchtoolpanelcoord.cc index 9e74ddb90..189f25ca0 100644 --- a/rtgui/batchtoolpanelcoord.cc +++ b/rtgui/batchtoolpanelcoord.cc @@ -152,7 +152,7 @@ void BatchToolPanelCoordinator::initSession () rotate->setAdjusterBehavior (false); resize->setAdjusterBehavior (false); distortion->setAdjusterBehavior (false); - perspective->setAdjusterBehavior (false, false, false, false, false, false, false); + perspective->setAdjusterBehavior (false, false, false, false, false, false, false, false); gradient->setAdjusterBehavior (false, false, false, false); pcvignette->setAdjusterBehavior (false, false, false); cacorrection->setAdjusterBehavior (false); @@ -197,7 +197,7 @@ void BatchToolPanelCoordinator::initSession () rotate->setAdjusterBehavior (options.baBehav[ADDSET_ROTATE_DEGREE]); resize->setAdjusterBehavior (options.baBehav[ADDSET_RESIZE_SCALE]); distortion->setAdjusterBehavior (options.baBehav[ADDSET_DIST_AMOUNT]); - perspective->setAdjusterBehavior (options.baBehav[ADDSET_PERSPECTIVE], options.baBehav[ADDSET_PERSP_CAM_FOCAL_LENGTH], options.baBehav[ADDSET_PERSP_CAM_SHIFT], options.baBehav[ADDSET_PERSP_CAM_ANGLE], options.baBehav[ADDSET_PERSP_PROJ_ANGLE], options.baBehav[ADDSET_PERSP_PROJ_SHIFT], options.baBehav[ADDSET_PERSP_PROJ_ROTATE]); + perspective->setAdjusterBehavior (options.baBehav[ADDSET_PERSPECTIVE], options.baBehav[ADDSET_PERSP_CAM_FOCAL_LENGTH], options.baBehav[ADDSET_PERSP_CAM_SHIFT], options.baBehav[ADDSET_PERSP_CAM_ANGLE], options.baBehav[ADDSET_PERSP_PROJ_ANGLE], options.baBehav[ADDSET_PERSP_PROJ_SHIFT], options.baBehav[ADDSET_PERSP_PROJ_ROTATE], options.baBehav[ADDSET_PERSP_CAM_SCALE]); gradient->setAdjusterBehavior (options.baBehav[ADDSET_GRADIENT_DEGREE], options.baBehav[ADDSET_GRADIENT_FEATHER], options.baBehav[ADDSET_GRADIENT_STRENGTH], options.baBehav[ADDSET_GRADIENT_CENTER]); pcvignette->setAdjusterBehavior (options.baBehav[ADDSET_PCVIGNETTE_STRENGTH], options.baBehav[ADDSET_PCVIGNETTE_FEATHER], options.baBehav[ADDSET_PCVIGNETTE_ROUNDNESS]); cacorrection->setAdjusterBehavior (options.baBehav[ADDSET_CA]); diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 7d641d753..c16d1cfea 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -346,8 +346,10 @@ void ParamsEdited::set(bool v) perspective.horizontal = v; perspective.vertical = v; perspective.camera_crop_factor = v; + perspective.camera_defish = v; perspective.camera_focal_length = v; perspective.camera_pitch = v; + perspective.camera_scale = v; perspective.camera_roll = v; perspective.camera_shift_horiz = v; perspective.camera_shift_vert = v; @@ -1051,8 +1053,10 @@ void ParamsEdited::initFrom(const std::vector& perspective.horizontal = perspective.horizontal && p.perspective.horizontal == other.perspective.horizontal; perspective.vertical = perspective.vertical && p.perspective.vertical == other.perspective.vertical; perspective.camera_crop_factor = perspective.camera_crop_factor && p.perspective.camera_crop_factor == other.perspective.camera_crop_factor; + perspective.camera_defish = perspective.camera_defish && p.perspective.camera_defish == other.perspective.camera_defish; perspective.camera_focal_length = perspective.camera_focal_length && p.perspective.camera_focal_length == other.perspective.camera_focal_length; perspective.camera_pitch = perspective.camera_pitch && p.perspective.camera_pitch == other.perspective.camera_pitch; + perspective.camera_scale = perspective.camera_scale && p.perspective.camera_scale == other.perspective.camera_scale; perspective.camera_roll = perspective.camera_roll && p.perspective.camera_roll == other.perspective.camera_roll; perspective.camera_shift_horiz = perspective.camera_shift_horiz && p.perspective.camera_shift_horiz == other.perspective.camera_shift_horiz; perspective.camera_shift_vert = perspective.camera_shift_vert && p.perspective.camera_shift_vert == other.perspective.camera_shift_vert; @@ -3303,6 +3307,14 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.perspective.camera_crop_factor = dontforceSet && options.baBehav[ADDSET_PERSP_CAM_FOCAL_LENGTH] ? toEdit.perspective.camera_crop_factor + mods.perspective.camera_crop_factor : mods.perspective.camera_crop_factor; } + if (perspective.camera_defish) { + toEdit.perspective.camera_defish = dontforceSet && mods.perspective.camera_defish; + } + + if (perspective.camera_scale) { + toEdit.perspective.camera_scale = dontforceSet && options.baBehav[ADDSET_PERSP_CAM_FOCAL_LENGTH] ? toEdit.perspective.camera_scale + mods.perspective.camera_scale : mods.perspective.camera_scale; + } + if (perspective.camera_focal_length) { toEdit.perspective.camera_focal_length = dontforceSet && options.baBehav[ADDSET_PERSP_CAM_FOCAL_LENGTH] ? toEdit.perspective.camera_focal_length + mods.perspective.camera_focal_length : mods.perspective.camera_focal_length; } diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 616e6d261..31611bafd 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -1110,8 +1110,10 @@ struct PerspectiveParamsEdited { bool horizontal; bool vertical; bool camera_crop_factor; + bool camera_defish; bool camera_focal_length; bool camera_pitch; + bool camera_scale; bool camera_roll; bool camera_shift_horiz; bool camera_shift_vert; diff --git a/rtgui/perspective.cc b/rtgui/perspective.cc index fa0b24247..cddcb2da8 100644 --- a/rtgui/perspective.cc +++ b/rtgui/perspective.cc @@ -89,20 +89,24 @@ PerspCorrection::PerspCorrection () : FoldableToolPanel(this, "perspective", M(" auto mapper = ProcEventMapper::getInstance(); // Normal events. + EvPerspCamDefish = mapper->newEvent(TRANSFORM, "HISTORY_MSG_PERSP_CAM_DEFISH"); EvPerspCamAngle = mapper->newEvent(TRANSFORM, "HISTORY_MSG_PERSP_CAM_ANGLE"); EvPerspCamFocalLength = mapper->newEvent(TRANSFORM, "HISTORY_MSG_PERSP_CAM_FL"); EvPerspCamShift = mapper->newEvent(TRANSFORM, "HISTORY_MSG_PERSP_CAM_SHIFT"); EvPerspMethod = mapper->newEvent(TRANSFORM, "HISTORY_MSG_PERSP_METHOD"); EvPerspProjAngle = mapper->newEvent(TRANSFORM, "HISTORY_MSG_PERSP_PROJ_ANGLE"); EvPerspProjRotate = mapper->newEvent(TRANSFORM, "HISTORY_MSG_PERSP_PROJ_ROTATE"); + EvPerspCamScale = mapper->newEvent(TRANSFORM, "HISTORY_MSG_PERSP_PROJ_SCALE"); EvPerspProjShift = mapper->newEvent(TRANSFORM, "HISTORY_MSG_PERSP_PROJ_SHIFT"); EvPerspRender = mapper->newEvent(TRANSFORM, "GENERAL_NA"); // Void events. + EvPerspCamDefishVoid = mapper->newEvent(M_VOID, "HISTORY_MSG_PERSP_CAM_DEFISH"); EvPerspCamAngleVoid = mapper->newEvent(M_VOID, "HISTORY_MSG_PERSP_CAM_ANGLE"); EvPerspCamFocalLengthVoid = mapper->newEvent(M_VOID, "HISTORY_MSG_PERSP_CAM_FL"); EvPerspCamShiftVoid = mapper->newEvent(M_VOID, "HISTORY_MSG_PERSP_CAM_SHIFT"); EvPerspProjAngleVoid = mapper->newEvent(M_VOID, "HISTORY_MSG_PERSP_PROJ_ANGLE"); EvPerspProjRotateVoid = mapper->newEvent(M_VOID, "HISTORY_MSG_PERSP_PROJ_ROTATE"); + EvPerspCamScaleVoid = mapper->newEvent(M_VOID, "HISTORY_MSG_PERSP_PROJ_SCALE"); EvPerspProjShiftVoid = mapper->newEvent(M_VOID, "HISTORY_MSG_PERSP_PROJ_SHIFT"); setCamBasedEventsActive(); EvPerspControlLines = mapper->newEvent(M_VOID, "HISTORY_MSG_PERSP_CTRL_LINE"); @@ -247,6 +251,13 @@ PerspCorrection::PerspCorrection () : FoldableToolPanel(this, "perspective", M(" projection_rotate = Gtk::manage (new Adjuster (M("TP_PERSPECTIVE_PROJECTION_ROTATE"), -45, 45, 0.01, 0, ipers_rotate_left, ipers_rotate_right)); projection_rotate->setAdjusterListener (this); + camera_scale= Gtk::manage (new Adjuster (M("TP_PERSPECTIVE_CAMERA_SCALE"), .1, 10, 0.01, 0, ipers_rotate_left, ipers_rotate_right)); + camera_scale->setAdjusterListener (this); + + camera_defish = Gtk::manage(new Gtk::CheckButton(M("TP_PERSPECTIVE_CAMERA_DEFISH"))); + camera_defish->signal_toggled().connect(sigc::mem_fun(*this, &PerspCorrection::defishChanged)); + + Gtk::Frame* recovery_frame = Gtk::manage (new Gtk::Frame (M("TP_PERSPECTIVE_RECOVERY_FRAME"))); recovery_frame->set_label_align(0.025, 0.5); @@ -266,10 +277,12 @@ PerspCorrection::PerspCorrection () : FoldableToolPanel(this, "perspective", M(" auto_hbox->pack_start (*auto_yaw); auto_hbox->pack_start (*auto_pitch_yaw); + camera_vbox->pack_start (*camera_defish); camera_vbox->pack_start (*camera_focal_length); camera_vbox->pack_start (*camera_crop_factor); camera_vbox->pack_start (*camera_shift_horiz); camera_vbox->pack_start (*camera_shift_vert); + camera_vbox->pack_start (*camera_scale); camera_vbox->pack_start (*camera_roll); camera_vbox->pack_start (*camera_pitch); camera_vbox->pack_start (*camera_yaw); @@ -298,6 +311,7 @@ PerspCorrection::PerspCorrection () : FoldableToolPanel(this, "perspective", M(" vert->setLogScale(2, 0); camera_focal_length->setLogScale(4000, 0.5); camera_crop_factor->setLogScale(300, 0.1); + camera_scale->setLogScale(300, 0.1); method->signal_changed().connect(sigc::mem_fun(*this, &PerspCorrection::methodChanged)); @@ -315,6 +329,7 @@ void PerspCorrection::read (const ProcParams* pp, const ParamsEdited* pedited) camera_crop_factor->setEditedState (pedited->perspective.camera_crop_factor ? Edited : UnEdited); camera_focal_length->setEditedState (pedited->perspective.camera_focal_length ? Edited : UnEdited); camera_pitch->setEditedState (pedited->perspective.camera_pitch ? Edited : UnEdited); + camera_scale->setEditedState (pedited->perspective.camera_scale ? Edited : UnEdited); camera_roll->setEditedState (pedited->perspective.camera_roll ? Edited : UnEdited); camera_shift_horiz->setEditedState (pedited->perspective.camera_shift_horiz ? Edited : UnEdited); camera_shift_vert->setEditedState (pedited->perspective.camera_shift_vert ? Edited : UnEdited); @@ -331,6 +346,7 @@ void PerspCorrection::read (const ProcParams* pp, const ParamsEdited* pedited) vert->setValue (pp->perspective.vertical); setFocalLengthValue (pp, metadata); camera_pitch->setValue (pp->perspective.camera_pitch); + camera_scale->setValue (pp->perspective.camera_scale); camera_roll->setValue (pp->perspective.camera_roll); camera_shift_horiz->setValue (pp->perspective.camera_shift_horiz); camera_shift_vert->setValue (pp->perspective.camera_shift_vert); @@ -383,6 +399,7 @@ void PerspCorrection::write (ProcParams* pp, ParamsEdited* pedited) pp->perspective.camera_focal_length = camera_focal_length->getValue (); } pp->perspective.camera_pitch = camera_pitch->getValue (); + pp->perspective.camera_scale = camera_scale->getValue (); pp->perspective.camera_roll = camera_roll->getValue (); pp->perspective.camera_shift_horiz = camera_shift_horiz->getValue (); pp->perspective.camera_shift_vert = camera_shift_vert->getValue (); @@ -411,6 +428,7 @@ void PerspCorrection::write (ProcParams* pp, ParamsEdited* pedited) pedited->perspective.camera_crop_factor= camera_crop_factor->getEditedState (); pedited->perspective.camera_focal_length = camera_focal_length->getEditedState (); pedited->perspective.camera_pitch = camera_pitch->getEditedState(); + pedited->perspective.camera_scale = camera_scale->getEditedState(); pedited->perspective.camera_roll = camera_roll->getEditedState(); pedited->perspective.camera_shift_horiz = camera_shift_horiz->getEditedState(); pedited->perspective.camera_shift_vert = camera_shift_vert->getEditedState(); @@ -436,6 +454,7 @@ void PerspCorrection::setDefaults (const ProcParams* defParams, const ParamsEdit ? defParams->perspective.camera_focal_length : PerspectiveParams::DEFAULT_CAMERA_FOCAL_LENGTH); camera_pitch->setDefault (defParams->perspective.camera_pitch); + camera_scale->setDefault (defParams->perspective.camera_scale); camera_roll->setDefault (defParams->perspective.camera_roll); camera_shift_horiz->setDefault (defParams->perspective.camera_shift_horiz); camera_shift_vert->setDefault (defParams->perspective.camera_shift_vert); @@ -452,6 +471,7 @@ void PerspCorrection::setDefaults (const ProcParams* defParams, const ParamsEdit camera_crop_factor->setDefaultEditedState (pedited->perspective.camera_crop_factor ? Edited : UnEdited); camera_focal_length->setDefaultEditedState (pedited->perspective.camera_focal_length ? Edited : UnEdited); camera_pitch->setDefaultEditedState (pedited->perspective.camera_pitch ? Edited : UnEdited); + camera_scale->setDefaultEditedState (pedited->perspective.camera_scale? Edited : UnEdited); camera_roll->setDefaultEditedState (pedited->perspective.camera_roll ? Edited : UnEdited); camera_shift_horiz->setDefaultEditedState (pedited->perspective.camera_shift_horiz ? Edited : UnEdited); camera_shift_vert->setDefaultEditedState (pedited->perspective.camera_shift_vert ? Edited : UnEdited); @@ -467,6 +487,7 @@ void PerspCorrection::setDefaults (const ProcParams* defParams, const ParamsEdit camera_crop_factor->setDefaultEditedState (Irrelevant); camera_focal_length->setDefaultEditedState (Irrelevant); camera_pitch->setDefaultEditedState (Irrelevant); + camera_scale->setDefaultEditedState (Irrelevant); camera_roll->setDefaultEditedState (Irrelevant); camera_shift_horiz->setDefaultEditedState (Irrelevant); camera_shift_vert->setDefaultEditedState (Irrelevant); @@ -503,6 +524,9 @@ void PerspCorrection::adjusterChanged(Adjuster* a, double newval) camera_shift_horiz->getValue(), M("TP_PERSPECTIVE_CAMERA_SHIFT_VERTICAL"), camera_shift_vert->getValue())); + } else if (a == camera_scale) { + listener->panelChanged (*event_persp_cam_scale, + Glib::ustring::format(camera_scale->getValue())); } else if (a == camera_pitch || a == camera_roll|| a == camera_yaw) { listener->panelChanged (*event_persp_cam_angle, Glib::ustring::compose("%1=%2\n%3=%4\n%5=%6", @@ -617,7 +641,14 @@ void PerspCorrection::methodChanged (void) } -void PerspCorrection::setAdjusterBehavior (bool badd, bool camera_focal_length_add, bool camera_shift_add, bool camera_angle_add, bool projection_angle_add, bool projection_shift_add, bool projection_rotate_add) +void PerspCorrection::defishChanged() +{ + if (listener) { + listener->panelChanged(EvPerspCamDefish, camera_defish->get_active() ? M("GENERAL_ENABLED") : M("GENERAL_DISABLED")); + } +} + +void PerspCorrection::setAdjusterBehavior (bool badd, bool camera_focal_length_add, bool camera_shift_add, bool camera_angle_add, bool projection_angle_add, bool projection_shift_add, bool projection_rotate_add, bool projection_scale_add) { horiz->setAddMode(badd); @@ -625,6 +656,7 @@ void PerspCorrection::setAdjusterBehavior (bool badd, bool camera_focal_length_a camera_crop_factor->setAddMode(camera_focal_length_add); camera_focal_length->setAddMode(camera_focal_length_add); camera_pitch->setAddMode(camera_angle_add); + camera_scale->setAddMode(projection_scale_add); camera_roll->setAddMode(camera_angle_add); camera_shift_horiz->setAddMode(camera_shift_add); camera_shift_vert->setAddMode(camera_shift_add); @@ -665,6 +697,7 @@ void PerspCorrection::trimValues (rtengine::procparams::ProcParams* pp) camera_focal_length->trimValue(pp->perspective.camera_focal_length); } camera_pitch->trimValue(pp->perspective.camera_pitch); + camera_scale->trimValue(pp->perspective.camera_scale); camera_roll->trimValue(pp->perspective.camera_roll); camera_shift_horiz->trimValue(pp->perspective.camera_shift_horiz); camera_shift_vert->trimValue(pp->perspective.camera_shift_vert); @@ -685,6 +718,7 @@ void PerspCorrection::setBatchMode (bool batchMode) camera_crop_factor->showEditedCB (); camera_focal_length->showEditedCB (); camera_pitch->showEditedCB (); + camera_scale->showEditedCB (); camera_roll->showEditedCB (); camera_shift_horiz->showEditedCB (); camera_shift_vert->showEditedCB (); @@ -860,16 +894,20 @@ void PerspCorrection::requestApplyControlLines(void) void PerspCorrection::setCamBasedEventsActive(bool active) { if (active) { + event_persp_cam_defish = &EvPerspCamDefish; event_persp_cam_focal_length = &EvPerspCamFocalLength; event_persp_cam_shift = &EvPerspCamShift; event_persp_cam_angle = &EvPerspCamAngle; + event_persp_cam_scale = &EvPerspCamScale; event_persp_proj_shift = &EvPerspProjShift; event_persp_proj_rotate = &EvPerspProjRotate; event_persp_proj_angle = &EvPerspProjAngle; } else { + event_persp_cam_defish = &EvPerspCamDefishVoid; event_persp_cam_focal_length = &EvPerspCamFocalLengthVoid; event_persp_cam_shift = &EvPerspCamShiftVoid; event_persp_cam_angle = &EvPerspCamAngleVoid; + event_persp_cam_scale = &EvPerspCamScaleVoid; event_persp_proj_shift = &EvPerspProjShiftVoid; event_persp_proj_rotate = &EvPerspProjRotateVoid; event_persp_proj_angle = &EvPerspProjAngleVoid; diff --git a/rtgui/perspective.h b/rtgui/perspective.h index 404b02010..69a0ce7c9 100644 --- a/rtgui/perspective.h +++ b/rtgui/perspective.h @@ -64,9 +64,12 @@ protected: Gtk::Button* lines_button_erase; Adjuster* projection_pitch; Adjuster* projection_rotate; + Adjuster* camera_scale; + Gtk::CheckButton *camera_defish; Adjuster* projection_shift_horiz; Adjuster* projection_shift_vert; Adjuster* projection_yaw; + rtengine::ProcEvent EvPerspCamDefish; rtengine::ProcEvent EvPerspCamFocalLength; rtengine::ProcEvent EvPerspCamShift; rtengine::ProcEvent EvPerspCamAngle; @@ -74,19 +77,24 @@ protected: rtengine::ProcEvent EvPerspMethod; rtengine::ProcEvent EvPerspProjShift; rtengine::ProcEvent EvPerspProjRotate; + rtengine::ProcEvent EvPerspCamScale; rtengine::ProcEvent EvPerspProjAngle; rtengine::ProcEvent EvPerspRender; + rtengine::ProcEvent EvPerspCamDefishVoid; rtengine::ProcEvent EvPerspCamFocalLengthVoid; rtengine::ProcEvent EvPerspCamShiftVoid; rtengine::ProcEvent EvPerspCamAngleVoid; rtengine::ProcEvent EvPerspProjShiftVoid; rtengine::ProcEvent EvPerspProjRotateVoid; + rtengine::ProcEvent EvPerspCamScaleVoid; rtengine::ProcEvent EvPerspProjAngleVoid; + rtengine::ProcEvent* event_persp_cam_defish; rtengine::ProcEvent* event_persp_cam_focal_length; rtengine::ProcEvent* event_persp_cam_shift; rtengine::ProcEvent* event_persp_cam_angle; rtengine::ProcEvent* event_persp_proj_shift; rtengine::ProcEvent* event_persp_proj_rotate; + rtengine::ProcEvent* event_persp_cam_scale; rtengine::ProcEvent* event_persp_proj_angle; LensGeomListener* lens_geom_listener; PerspCorrectionPanelListener* panel_listener; @@ -119,8 +127,9 @@ public: void linesEditButtonPressed (void); void linesEraseButtonPressed (void); void methodChanged (void); + void defishChanged (void); void requestApplyControlLines(void); - void setAdjusterBehavior (bool badd, bool camera_focal_length_add, bool camera_shift_add, bool camera_angle_add, bool projection_angle_add, bool projection_shift_add, bool projection_rotate_add); + void setAdjusterBehavior (bool badd, bool camera_focal_length_add, bool camera_shift_add, bool camera_angle_add, bool projection_angle_add, bool projection_shift_add, bool projection_rotate_add, bool projection_scale_add); void setControlLineEditMode(bool active); void setEditProvider (EditDataProvider* provider) override; void setLensGeomListener (LensGeomListener* listener)