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
|
/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
*
* RawTherapee 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, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee 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.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <gtkmm.h>
#include "adjuster.h"
#include "controllines.h"
#include "lensgeomlistener.h"
#include "toolpanel.h"
#include "rtengine/tweakoperator.h"
class PerspCorrectionPanelListener
{
public:
virtual ~PerspCorrectionPanelListener() = default;
virtual void controlLineEditModeChanged(bool active) = 0;
};
class PerspCorrection final :
public rtengine::TweakOperator,
public ToolParamBlock,
public AdjusterListener,
public FoldableToolPanel
{
protected:
bool render = true;
MyComboBoxText* method;
Gtk::Box* simple;
Adjuster* horiz;
Adjuster* vert;
Gtk::Button* auto_pitch;
Gtk::Button* auto_yaw;
Gtk::Button* auto_pitch_yaw;
Gtk::Box* camera_based;
Adjuster* camera_crop_factor;
Adjuster* camera_focal_length;
Adjuster* camera_pitch;
Adjuster* camera_roll;
Adjuster* camera_shift_horiz;
Adjuster* camera_shift_vert;
Adjuster* camera_yaw;
std::unique_ptr<ControlLineManager> lines;
Gtk::Button* lines_button_apply;
Gtk::ToggleButton* lines_button_edit;
Gtk::Button* lines_button_erase;
Adjuster* projection_pitch;
Adjuster* projection_rotate;
Adjuster* projection_shift_horiz;
Adjuster* projection_shift_vert;
Adjuster* projection_yaw;
rtengine::ProcEvent EvPerspCamFocalLength;
rtengine::ProcEvent EvPerspCamShift;
rtengine::ProcEvent EvPerspCamAngle;
rtengine::ProcEvent EvPerspControlLines;
rtengine::ProcEvent EvPerspMethod;
rtengine::ProcEvent EvPerspProjShift;
rtengine::ProcEvent EvPerspProjRotate;
rtengine::ProcEvent EvPerspProjAngle;
rtengine::ProcEvent EvPerspRender;
rtengine::ProcEvent EvPerspCamFocalLengthVoid;
rtengine::ProcEvent EvPerspCamShiftVoid;
rtengine::ProcEvent EvPerspCamAngleVoid;
rtengine::ProcEvent EvPerspProjShiftVoid;
rtengine::ProcEvent EvPerspProjRotateVoid;
rtengine::ProcEvent EvPerspProjAngleVoid;
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_proj_angle;
LensGeomListener* lens_geom_listener;
PerspCorrectionPanelListener* panel_listener;
const rtengine::FramesMetaData* metadata;
void applyControlLines (void);
void tweakParams(rtengine::procparams::ProcParams &pparams) override;
void setCamBasedEventsActive (bool active = true);
void setFocalLengthValue (const rtengine::procparams::ProcParams* pparams, const rtengine::FramesMetaData* metadata);
void updateApplyDeleteButtons();
public:
/** Minimum number of horizontal lines for horizontal/full correction. */
static constexpr std::size_t MIN_HORIZ_LINES = 2;
/** Minimum number of vertical lines for vertical/full correction. */
static constexpr std::size_t MIN_VERT_LINES = 2;
static const Glib::ustring TOOL_NAME;
PerspCorrection ();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr) override;
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr) override;
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr) override;
void setBatchMode (bool batchMode) override;
void adjusterChanged (Adjuster* a, double newval) override;
void autoCorrectionPressed (Gtk::Button* b);
void lineChanged (void);
void linesApplyButtonPressed (void);
void linesEditButtonPressed (void);
void linesEraseButtonPressed (void);
void methodChanged (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 setControlLineEditMode(bool active);
void setEditProvider (EditDataProvider* provider) override;
void setLensGeomListener (LensGeomListener* listener)
{
lens_geom_listener = listener;
}
void setPerspCorrectionPanelListener(PerspCorrectionPanelListener* listener)
{
panel_listener = listener;
}
void setMetadata (const rtengine::FramesMetaData* metadata);
void switchOffEditMode (void);
void trimValues (rtengine::procparams::ProcParams* pp) override;
};
class LinesCallbacks: public ControlLineManager::Callbacks
{
protected:
PerspCorrection* tool;
public:
explicit LinesCallbacks(PerspCorrection* tool);
void lineChanged (void) override;
void switchOffEditMode (void) override;
};
|