Exprimental feature auto lens distortion correction, on behalf of Guokai; see issue #576
This commit is contained in:
@@ -198,6 +198,12 @@ void BatchToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const G
|
||||
selected[i]->applyAutoExp (initialPP[i]);
|
||||
}
|
||||
|
||||
if (event==rtengine::EvAutoDIST) {
|
||||
for (int i=0; i<selected.size(); i++) {
|
||||
initialPP[i].distortion.amount = pparams.distortion.amount;
|
||||
}
|
||||
}
|
||||
|
||||
// combine with initial parameters and set
|
||||
ProcParams newParams;
|
||||
for (int i=0; i<selected.size(); i++) {
|
||||
|
@@ -24,6 +24,13 @@ using namespace rtengine::procparams;
|
||||
|
||||
Distortion::Distortion (): Gtk::VBox(), FoldableToolPanel(this) {
|
||||
|
||||
rlistener = NULL;
|
||||
autoDistor = Gtk::manage (new Gtk::Button (M("TP_DISTORTION_AUTO")));
|
||||
autoDistor->set_tooltip_text (M("TP_DISTORTION_AUTO_TIP"));
|
||||
idConn = autoDistor->signal_pressed().connect( sigc::mem_fun(*this, &Distortion::idPressed) );
|
||||
autoDistor->show();
|
||||
pack_start (*autoDistor);
|
||||
|
||||
distor = Gtk::manage (new Adjuster (M("TP_DISTORTION_AMOUNT"), -0.5, 0.5, 0.001, 0));
|
||||
distor->setAdjusterListener (this);
|
||||
distor->show();
|
||||
@@ -35,8 +42,9 @@ void Distortion::read (const ProcParams* pp, const ParamsEdited* pedited) {
|
||||
|
||||
disableListener ();
|
||||
|
||||
if (pedited)
|
||||
if (pedited) {
|
||||
distor->setEditedState (pedited->distortion.amount ? Edited : UnEdited);
|
||||
}
|
||||
|
||||
distor->setValue (pp->distortion.amount);
|
||||
|
||||
@@ -47,18 +55,21 @@ void Distortion::write (ProcParams* pp, ParamsEdited* pedited) {
|
||||
|
||||
pp->distortion.amount = distor->getValue ();
|
||||
|
||||
if (pedited)
|
||||
if (pedited) {
|
||||
pedited->distortion.amount = distor->getEditedState ();
|
||||
}
|
||||
}
|
||||
|
||||
void Distortion::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) {
|
||||
|
||||
distor->setDefault (defParams->distortion.amount);
|
||||
|
||||
if (pedited)
|
||||
if (pedited) {
|
||||
distor->setDefaultEditedState (pedited->distortion.amount ? Edited : UnEdited);
|
||||
else
|
||||
}
|
||||
else {
|
||||
distor->setDefaultEditedState (Irrelevant);
|
||||
}
|
||||
}
|
||||
|
||||
void Distortion::adjusterChanged (Adjuster* a, double newval) {
|
||||
@@ -78,6 +89,18 @@ void Distortion::setAdjusterBehavior (bool bvadd) {
|
||||
void Distortion::setBatchMode (bool batchMode) {
|
||||
|
||||
ToolPanel::setBatchMode (batchMode);
|
||||
if (batchMode) {
|
||||
autoDistor->set_sensitive(false);
|
||||
}
|
||||
distor->showEditedCB ();
|
||||
}
|
||||
|
||||
void Distortion::idPressed () {
|
||||
if (!batchMode) {
|
||||
if (rlistener) {
|
||||
double new_amount = rlistener->autoDistorRequested();
|
||||
distor->setValue(new_amount);
|
||||
adjusterChanged (distor, new_amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,12 +22,16 @@
|
||||
#include <gtkmm.h>
|
||||
#include <adjuster.h>
|
||||
#include <toolpanel.h>
|
||||
#include <lensgeomlistener.h>
|
||||
|
||||
class Distortion : public Gtk::VBox, public AdjusterListener, public FoldableToolPanel {
|
||||
|
||||
protected:
|
||||
Gtk::Button* autoDistor;
|
||||
Adjuster* distor;
|
||||
bool distAdd;
|
||||
sigc::connection idConn;
|
||||
LensGeomListener * rlistener;
|
||||
|
||||
public:
|
||||
|
||||
@@ -40,6 +44,8 @@ class Distortion : public Gtk::VBox, public AdjusterListener, public FoldableToo
|
||||
|
||||
void adjusterChanged (Adjuster* a, double newval);
|
||||
void setAdjusterBehavior (bool bvadd);
|
||||
void idPressed ();
|
||||
void setLensGeomListener (LensGeomListener* l) { rlistener = l; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -24,6 +24,7 @@ class LensGeomListener {
|
||||
public:
|
||||
virtual void straightenRequested ()=0;
|
||||
virtual void autoCropRequested ()=0;
|
||||
virtual double autoDistorRequested ()=0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <imagesource.h>
|
||||
#include <dfmanager.h>
|
||||
#include <ffmanager.h>
|
||||
#include <improcfun.h>
|
||||
|
||||
using namespace rtengine::procparams;
|
||||
|
||||
@@ -185,6 +186,7 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(NULL) {
|
||||
flatfield->setFFProvider (this);
|
||||
lensgeom->setLensGeomListener (this);
|
||||
rotate->setLensGeomListener (this);
|
||||
distortion->setLensGeomListener (this);
|
||||
crop->setCropPanelListener (this);
|
||||
icm->setICMPanelListener (this);
|
||||
|
||||
@@ -435,6 +437,12 @@ void ToolPanelCoordinator::straightenRequested () {
|
||||
toolBar->setTool (TMStraighten);
|
||||
}
|
||||
|
||||
double ToolPanelCoordinator::autoDistorRequested () {
|
||||
if (!ipc)
|
||||
return 0.0;
|
||||
return rtengine::ImProcFunctions::getAutoDistor (ipc->getInitialImage()->getFileName(), 400);
|
||||
}
|
||||
|
||||
void ToolPanelCoordinator::spotWBRequested (int size) {
|
||||
|
||||
if (!ipc)
|
||||
|
@@ -186,6 +186,7 @@ class ToolPanelCoordinator : public ToolPanelListener,
|
||||
// rotatelistener interface
|
||||
void straightenRequested ();
|
||||
void autoCropRequested ();
|
||||
double autoDistorRequested ();
|
||||
|
||||
// spotwblistener interface
|
||||
void spotWBRequested (int size);
|
||||
|
Reference in New Issue
Block a user