Solving issue 1894: "White balance adjustements" ; Warning: it is recommended to clear the "cache\data" folder

This commit is contained in:
natureh 510
2013-07-20 20:48:59 +02:00
parent 6ae0dd0166
commit 1a6619a035
66 changed files with 1339 additions and 349 deletions

View File

@@ -65,8 +65,9 @@
#define ADDSET_CAT_CHROMA_M 57
#define ADDSET_CAT_HUE 58
#define ADDSET_CAT_BADPIX 59
#define ADDSET_WB_EQUAL 60
// When adding items, make sure to update ADDSET_PARAM_NUM
#define ADDSET_PARAM_NUM 60 // THIS IS USED AS A DELIMITER!!
#define ADDSET_PARAM_NUM 61 // THIS IS USED AS A DELIMITER!!
#endif

View File

@@ -126,7 +126,7 @@ void BatchToolPanelCoordinator::initSession () {
toneCurve->setAdjusterBehavior (false, false, false, false, false, false, false, false);
lcurve->setAdjusterBehavior (false, false, false);
whitebalance->setAdjusterBehavior (false, false);
whitebalance->setAdjusterBehavior (false, false, false);
vibrance->setAdjusterBehavior (false, false, false);
vignetting->setAdjusterBehavior (false, false, false, false);
colorappearance->setAdjusterBehavior (false, false, false, false, false, false, false, false, false, false, false, false, false);
@@ -154,7 +154,7 @@ void BatchToolPanelCoordinator::initSession () {
toneCurve->setAdjusterBehavior (options.baBehav[ADDSET_TC_EXPCOMP], options.baBehav[ADDSET_TC_HLCOMPAMOUNT],options.baBehav[ADDSET_TC_HLCOMPTHRESH], options.baBehav[ADDSET_TC_BRIGHTNESS], options.baBehav[ADDSET_TC_BLACKLEVEL],options.baBehav[ADDSET_TC_SHCOMP], options.baBehav[ADDSET_TC_CONTRAST], options.baBehav[ADDSET_TC_SATURATION]);
lcurve->setAdjusterBehavior (options.baBehav[ADDSET_LC_BRIGHTNESS], options.baBehav[ADDSET_LC_CONTRAST], options.baBehav[ADDSET_LC_CHROMATICITY]);
whitebalance->setAdjusterBehavior (options.baBehav[ADDSET_WB_TEMPERATURE], options.baBehav[ADDSET_WB_GREEN]);
whitebalance->setAdjusterBehavior (options.baBehav[ADDSET_WB_TEMPERATURE], options.baBehav[ADDSET_WB_GREEN], options.baBehav[ADDSET_WB_EQUAL]);
vignetting->setAdjusterBehavior (options.baBehav[ADDSET_VIGN_AMOUNT], options.baBehav[ADDSET_VIGN_RADIUS], options.baBehav[ADDSET_VIGN_STRENGTH], options.baBehav[ADDSET_VIGN_CENTER]);
colorappearance->setAdjusterBehavior (options.baBehav[ADDSET_CAT_DEGREE], options.baBehav[ADDSET_CAT_ADAPTSCENE], options.baBehav[ADDSET_CAT_ADAPTVIEWING],options.baBehav[ADDSET_CAT_BADPIX], options.baBehav[ADDSET_CAT_LIGHT], options.baBehav[ADDSET_CAT_CHROMA],options.baBehav[ADDSET_CAT_CONTRAST],options.baBehav[ADDSET_CAT_RSTPRO],options.baBehav[ADDSET_CAT_BRIGHT],options.baBehav[ADDSET_CAT_CONTRAST_Q],options.baBehav[ADDSET_CAT_CHROMA_S],options.baBehav[ADDSET_CAT_CHROMA_M],options.baBehav[ADDSET_CAT_HUE]);
rotate->setAdjusterBehavior (options.baBehav[ADDSET_ROTATE_DEGREE]);
@@ -201,6 +201,7 @@ void BatchToolPanelCoordinator::initSession () {
if (options.baBehav[ADDSET_WB_TEMPERATURE]) pparams.wb.temperature = 0;
if (options.baBehav[ADDSET_WB_GREEN]) pparams.wb.green = 0;
if (options.baBehav[ADDSET_WB_EQUAL]) pparams.wb.equal = 0;
if (options.baBehav[ADDSET_VIBRANCE_PASTELS]) pparams.vibrance.pastels = 0;
if (options.baBehav[ADDSET_VIBRANCE_SATURATED]) pparams.vibrance.saturated = 0;
@@ -314,10 +315,10 @@ void BatchToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const G
paramcListeners[i]->procParamsChanged (&pparams, event, descr, &pparamsEdited);
}
void BatchToolPanelCoordinator::getAutoWB (double& temp, double& green) {
void BatchToolPanelCoordinator::getAutoWB (double& temp, double& green, double equal) {
if (!selected.empty())
selected[0]->getAutoWB (temp, green);
selected[0]->getAutoWB (temp, green, equal);
}
void BatchToolPanelCoordinator::getCamWB (double& temp, double& green) {

View File

@@ -60,7 +60,7 @@ class BatchToolPanelCoordinator :
void profileChange (const rtengine::procparams::PartialProfile* nparams, rtengine::ProcEvent event, const Glib::ustring& descr, const ParamsEdited* paramsEdited=NULL);
// wbprovider interface
void getAutoWB (double& temp, double& green);
void getAutoWB (double& temp, double& green, double equal);
void getCamWB (double& temp, double& green);
// thumbnaillistener interface

View File

@@ -25,9 +25,12 @@
CacheImageData::CacheImageData ()
: md5(""), supported(false), format(FT_Invalid), rankOld(-1), inTrashOld(false), recentlySaved(false),
timeValid(false), exifValid(false), thumbImgType(0) {
timeValid(false), exifValid(false), redAWBMul(-1.0), greenAWBMul(-1.0), blueAWBMul(-1.0), thumbImgType(0) {
}
/*
* Load the General, DateTime, ExifInfo, File info and ExtraRawInfo sections of the image data file
*/
int CacheImageData::load (const Glib::ustring& fname) {
rtengine::SafeKeyFile keyFile;
@@ -104,6 +107,9 @@ int CacheImageData::load (const Glib::ustring& fname) {
return 1;
}
/*
* Save the General, DateTime, ExifInfo, File info and ExtraRawInfo sections of the image data file
*/
int CacheImageData::save (const Glib::ustring& fname) {
rtengine::SafeKeyFile keyFile;

View File

@@ -56,6 +56,11 @@ class CacheImageData {
Glib::ustring filetype;
Glib::ustring expcomp;
// store a copy of the autoWB's multipliers computed in Thumbnail::_generateThumbnailImage
// they are not stored in the cache file by this class, but by rtengine::Thumbnail
// -1 = Unknown
double redAWBMul, greenAWBMul, blueAWBMul;
// additional info on raw images
int rotate;
int thumbImgType;

View File

@@ -423,6 +423,7 @@ void Options::setDefaults () {
0, // ADDSET_CAT_JLIGHT
0, // ADDSET_CAT_CHROMA
0, // ADDSET_CAT_CONTRAST
0, // ADDSET_WB_EQUAL
};
baBehav = std::vector<int> (babehav, babehav+ADDSET_PARAM_NUM);
@@ -679,7 +680,6 @@ if (keyFile.has_group ("Color Management")) {
if (keyFile.has_key ("Color Management", "MonitorProfile")) rtSettings.monitorProfile = keyFile.get_string ("Color Management", "MonitorProfile");
if (keyFile.has_key ("Color Management", "AutoMonitorProfile")) rtSettings.autoMonitorProfile = keyFile.get_boolean ("Color Management", "AutoMonitorProfile");
if (keyFile.has_key ("Color Management", "Autocielab")) rtSettings.autocielab = keyFile.get_boolean ("Color Management", "Autocielab");
if (keyFile.has_key ("Color Management", "Ciencamfloat")) rtSettings.ciecamfloat = keyFile.get_boolean ("Color Management", "Ciecamfloat");
if (keyFile.has_key ("Color Management", "RGBcurvesLumamode_Gamut")) rtSettings.rgbcurveslumamode_gamut = keyFile.get_boolean ("Color Management", "RGBcurvesLumamode_Gamut");
if (keyFile.has_key ("Color Management", "Intent")) rtSettings.colorimetricIntent = keyFile.get_integer("Color Management", "Intent");

View File

@@ -133,6 +133,7 @@ void ParamsEdited::set (bool v) {
wb.method = v;
wb.green = v;
wb.temperature = v;
wb.equal = v;
//colorShift.a = v;
//colorShift.b = v;
//lumaDenoise.enabled = v;
@@ -375,6 +376,7 @@ void ParamsEdited::initFrom (const std::vector<rtengine::procparams::ProcParams>
//colorBoost.saturationlimit = colorBoost.saturationlimit && p.colorBoost.saturationlimit == other.colorBoost.saturationlimit;
wb.method = wb.method && p.wb.method == other.wb.method;
wb.green = wb.green && p.wb.green == other.wb.green;
wb.equal = wb.equal && p.wb.equal == other.wb.equal;
wb.temperature = wb.temperature && p.wb.temperature == other.wb.temperature;
//colorShift.a = colorShift.a && p.colorShift.a == other.colorShift.a;
//colorShift.b = colorShift.b && p.colorShift.b == other.colorShift.b;
@@ -593,6 +595,7 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
//if (colorBoost.enable_saturationlimiter)toEdit.colorBoost.enable_saturationlimiter = mods.colorBoost.enable_saturationlimiter;
//if (colorBoost.saturationlimit) toEdit.colorBoost.saturationlimit = mods.colorBoost.saturationlimit;
if (wb.method) toEdit.wb.method = mods.wb.method;
if (wb.equal) toEdit.wb.equal = dontforceSet && options.baBehav[ADDSET_WB_EQUAL] ? toEdit.wb.equal + mods.wb.equal : mods.wb.equal;
if (wb.green) toEdit.wb.green = dontforceSet && options.baBehav[ADDSET_WB_GREEN] ? toEdit.wb.green + mods.wb.green : mods.wb.green;
if (wb.temperature) toEdit.wb.temperature = dontforceSet && options.baBehav[ADDSET_WB_TEMPERATURE] ? toEdit.wb.temperature + mods.wb.temperature : mods.wb.temperature;
//if (colorShift.a) toEdit.colorShift.a = dontforceSet && options.baBehav[ADDSET_CS_BLUEYELLOW] ? toEdit.colorShift.a + mods.colorShift.a : mods.colorShift.a;

View File

@@ -143,6 +143,7 @@ class WBParamsEdited {
bool method;
bool temperature;
bool green;
bool equal;
};
/*class ColorShiftParamsEdited {

View File

@@ -2,7 +2,7 @@
#define _PPVERSION_
// This number have to be incremented whenever the PP3 file format is modified
#define PPVERSION 308
#define PPVERSION 309
#define PPVERSION_AEXP 301 //value of PPVERSION when auto exposure algorithm was modified
/* Log of version changes

View File

@@ -201,6 +201,7 @@ Gtk::Widget* Preferences::getBatchProcPanel () {
mi->set_value (behavColumns.label, M("TP_WBALANCE_LABEL"));
appendBehavList (mi, M("TP_WBALANCE_TEMPERATURE"), ADDSET_WB_TEMPERATURE, true);
appendBehavList (mi, M("TP_WBALANCE_GREEN"), ADDSET_WB_GREEN, true);
appendBehavList (mi, M("TP_WBALANCE_EQREDBLUE"), ADDSET_WB_EQUAL, true);
mi = behModel->append ();
mi->set_value (behavColumns.label, M("TP_COLORAPP_LABEL"));

View File

@@ -72,13 +72,13 @@ Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::s
cfs.md5 = md5;
_generateThumbnailImage ();
if (pparams) {
this->pparams = *pparams;
pparamsValid = true;
}
else
loadProcParams ();
_generateThumbnailImage ();
cfs.recentlySaved = false;
initial_ = false;
@@ -107,17 +107,17 @@ void Thumbnail::_generateThumbnailImage () {
cfs.timeValid = false;
if (ext.lowercase()=="jpg" || ext.lowercase()=="jpeg") {
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, 1);
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, 1, pparams.wb.equal);
if (tpp)
cfs.format = FT_Jpeg;
}
else if (ext.lowercase()=="png") {
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, 1);
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, 1, pparams.wb.equal);
if (tpp)
cfs.format = FT_Png;
}
else if (ext.lowercase()=="tif" || ext.lowercase()=="tiff") {
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, 1);
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, 1, pparams.wb.equal);
if (tpp)
cfs.format = FT_Tiff;
}
@@ -136,7 +136,7 @@ void Thumbnail::_generateThumbnailImage () {
if ( tpp == NULL )
{
quick = false;
tpp = rtengine::Thumbnail::loadFromRaw (fname, ri, tw, th, 1, TRUE);
tpp = rtengine::Thumbnail::loadFromRaw (fname, ri, tw, th, 1, pparams.wb.equal, TRUE);
}
if (tpp) {
cfs.format = FT_Raw;
@@ -146,7 +146,8 @@ void Thumbnail::_generateThumbnailImage () {
}
if (tpp)
{
{
tpp->getAutoWBMultipliers(cfs.redAWBMul, cfs.greenAWBMul, cfs.blueAWBMul);
_saveThumbnail ();
cfs.supported = true;
needsReProcessing = true;
@@ -178,7 +179,7 @@ const ProcParams& Thumbnail::getProcParams () {
}
else if (pparams.wb.method=="Auto") {
double ct;
getAutoWB (ct, pparams.wb.green);
getAutoWB (ct, pparams.wb.green, pparams.wb.equal);
pparams.wb.temperature = ct;
}
}
@@ -558,6 +559,17 @@ const Glib::ustring& Thumbnail::getDateTimeString () {
return dateTimeString;
}
void Thumbnail::getAutoWB (double& temp, double& green, double equal) {
if (cfs.redAWBMul != -1.0) {
rtengine::ColorTemp ct(cfs.redAWBMul, cfs.greenAWBMul, cfs.blueAWBMul, equal);
temp = ct.getTemp();
green = ct.getGreen();
}
else
temp = green = -1.0;
}
ThFileType Thumbnail::getType () {
return (ThFileType) cfs.format;
@@ -615,6 +627,14 @@ int Thumbnail::infoFromImage (const Glib::ustring& fname, rtengine::RawMetaDataL
return deg;
}
/*
* Read all thumbnail's data from the cache; build and save them if doesn't exist - NON PROTECTED
* This includes:
* - image's bitmap (*.rtti)
* - auto exposure's histogram (full thumbnail only)
* - embedded profile (full thumbnail only)
* - LiveThumbData section of the data file
*/
void Thumbnail::_loadThumbnail(bool firstTrial) {
needsReProcessing = true;
@@ -626,7 +646,10 @@ void Thumbnail::_loadThumbnail(bool firstTrial) {
// load supplementary data
bool succ = tpp->readData (getCacheFileName ("data")+".txt");
if (succ)
tpp->getAutoWBMultipliers(cfs.redAWBMul, cfs.greenAWBMul, cfs.blueAWBMul);
// thumbnail image
succ = succ && tpp->readImage (getCacheFileName ("images"));
@@ -656,11 +679,27 @@ void Thumbnail::_loadThumbnail(bool firstTrial) {
if (!initial_ && tpp) tw = tpp->getImageWidth (getProcParams(), th, imgRatio); // this might return 0 if image was just building
}
/*
* Read all thumbnail's data from the cache; build and save them if doesn't exist - MUTEX PROTECTED
* This includes:
* - image's bitmap (*.rtti)
* - auto exposure's histogram (full thumbnail only)
* - embedded profile (full thumbnail only)
* - LiveThumbData section of the data file
*/
void Thumbnail::loadThumbnail (bool firstTrial) {
Glib::Mutex::Lock lock(mutex);
_loadThumbnail(firstTrial);
}
/*
* Save thumbnail's data to the cache - NON PROTECTED
* This includes:
* - image's bitmap (*.rtti)
* - auto exposure's histogram (full thumbnail only)
* - embedded profile (full thumbnail only)
* - LiveThumbData section of the data file
*/
void Thumbnail::_saveThumbnail () {
if (!tpp)
@@ -686,12 +725,26 @@ void Thumbnail::_saveThumbnail () {
tpp->writeData (getCacheFileName ("data")+".txt");
}
/*
* Save thumbnail's data to the cache - MUTEX PROTECTED
* This includes:
* - image's bitmap (*.rtti)
* - auto exposure's histogram (full thumbnail only)
* - embedded profile (full thumbnail only)
* - LiveThumbData section of the data file
*/
void Thumbnail::saveThumbnail ()
{
Glib::Mutex::Lock lock(mutex);
_saveThumbnail();
}
/*
* Update the cached files
* - updatePParams==true (default) : write the procparams file (sidecar or cache, depending on the options)
* - updateCacheImageData==true (default) : write the CacheImageData values in the cache folder,
* i.e. some General, DateTime, ExifInfo, File info and ExtraRawInfo,
*/
void Thumbnail::updateCache (bool updatePParams, bool updateCacheImageData) {
if (updatePParams && pparamsValid) {

View File

@@ -109,7 +109,7 @@ class Thumbnail {
const Glib::ustring& getExifString ();
const Glib::ustring& getDateTimeString ();
void getCamWB (double& temp, double& green) { if (tpp) tpp->getCamWB (temp, green); else temp = green = -1.0; }
void getAutoWB (double& temp, double& green) { if (tpp) tpp->getAutoWB (temp, green); else temp = green = -1.0; }
void getAutoWB (double& temp, double& green, double equal);
void getSpotWB (int x, int y, int rect, double& temp, double& green) { if (tpp) tpp->getSpotWB (getProcParams(), x, y, rect, temp, green); else temp = green = -1.0; }
void applyAutoExp (rtengine::procparams::ProcParams& pparams) { if (tpp) tpp->applyAutoExp (pparams); }

View File

@@ -179,7 +179,7 @@ class ToolPanelCoordinator : public ToolPanelListener,
virtual ~ToolPanelCoordinator ();
bool getChangedState () { return hasChanged; }
void updateCurveBackgroundHistogram (LUTu & histToneCurve, LUTu & histLCurve,LUTu & histCCurve, LUTu & histLCAM, LUTu & histCCAM, LUTu & histRed, LUTu & histGreen, LUTu & histBlue, LUTu & histLuma);
void updateCurveBackgroundHistogram (LUTu & histToneCurve, LUTu & histLCurve,LUTu & histCCurve, LUTu & histLCAM, LUTu & histCCAM, LUTu & histRed, LUTu & histGreen, LUTu & histBlue, LUTu & histLuma);
void foldAllButOne (Gtk::Box* parent, FoldableToolPanel* openedSection);
// multiple listeners can be added that are notified on changes (typical: profile panel and the history)
@@ -195,16 +195,19 @@ class ToolPanelCoordinator : public ToolPanelListener,
// to support the GUI:
CropGUIListener* getCropGUIListener (); // through the CropGUIListener the editor area can notify the "crop" ToolPanel when the crop selection changes
// init the toolpanelcoordinator with an image & close it
// init the toolpanelcoordinator with an image & close it
void initImage (rtengine::StagedImageProcessor* ipc_, bool israw);
void closeImage ();
// read/write the "expanded" state of the expanders & read/write the crop panel settings (ratio, guide type, etc.)
void readOptions ();
void writeOptions ();
void writeOptions ();
// wbprovider interface
void getAutoWB (double& temp, double& green) { if (ipc) ipc->getAutoWB (temp, green); }
void getAutoWB (double& temp, double& green, double equal) {
if (ipc)
ipc->getAutoWB (temp, green, equal);
}
void getCamWB (double& temp, double& green) { if (ipc) ipc->getCamWB (temp, green); }
//DFProvider interface

View File

@@ -23,7 +23,8 @@
class WBProvider {
public:
virtual void getAutoWB (double& temp, double& green) {}
virtual ~WBProvider() {}
virtual void getAutoWB (double& temp, double& green, double equal) {}
virtual void getCamWB (double& temp, double& green) {}
virtual void spotWBRequested (int size) {}
};

View File

@@ -22,12 +22,12 @@
#include "options.h"
#include "../rtengine/safegtk.h"
#define MINTEMP 2000 //1200
#define MAXTEMP 25000 //12000
#define MINTEMP 1500 //1200
#define MAXTEMP 60000 //12000
#define MINGREEN 0.02
#define MAXGREEN 5.0
extern Glib::ustring argv0;
#define MINEQUAL 0.8
#define MAXEQUAL 1.5
using namespace rtengine;
using namespace rtengine::procparams;
@@ -45,6 +45,8 @@ void WhiteBalance::init () {
wbPixbufs[WBT_DAYLIGHT] = safe_create_from_file("wb-sun.png");
wbPixbufs[WBT_CLOUDY] = safe_create_from_file("wb-cloudy.png");
wbPixbufs[WBT_SHADE] = safe_create_from_file("wb-shade.png");
wbPixbufs[WBT_WATER] = safe_create_from_file("wb-water.png");
// wbPixbufs[WBT_WATER2] = safe_create_from_file("wb-water.png");
wbPixbufs[WBT_TUNGSTEN] = safe_create_from_file("wb-tungsten.png");
wbPixbufs[WBT_FLUORESCENT] = safe_create_from_file("wb-fluorescent.png");
wbPixbufs[WBT_LAMP] = safe_create_from_file("wb-lamp.png");
@@ -75,7 +77,6 @@ WhiteBalance::WhiteBalance () : Gtk::VBox(), FoldableToolPanel(this), wbp(NULL),
// Assign the model to the Combobox
method->set_model(refTreeModel);
custom_green = new double[WBParams::wbEntries.size()];
enum WBTypes oldType = WBParams::wbEntries[0]->type;
enum WBTypes currType;
Gtk::TreeModel::Row row, childrow;
@@ -89,6 +90,13 @@ WhiteBalance::WhiteBalance () : Gtk::VBox(), FoldableToolPanel(this), wbp(NULL),
row[methodColumns.colLabel] = M("TP_WBALANCE_FLUO_HEADER");
row[methodColumns.colId] = i+100;
}
if (currType == WBT_WATER) {
// Creating the under water subcategory header
row = *(refTreeModel->append());
row[methodColumns.colIcon] = wbPixbufs[currType];
row[methodColumns.colLabel] = M("TP_WBALANCE_WATER_HEADER");
row[methodColumns.colId] = i+100;
}
if (currType == WBT_LAMP) {
// Creating the Lamp subcategory header
row = *(refTreeModel->append());
@@ -113,6 +121,7 @@ WhiteBalance::WhiteBalance () : Gtk::VBox(), FoldableToolPanel(this), wbp(NULL),
}
if (currType == WBT_FLUORESCENT
|| currType == WBT_LAMP
|| currType == WBT_WATER
|| currType == WBT_FLASH
|| currType == WBT_LED
) {
@@ -129,7 +138,8 @@ WhiteBalance::WhiteBalance () : Gtk::VBox(), FoldableToolPanel(this), wbp(NULL),
}
oldType = currType;
custom_green[i] = 1.0;
custom_green = 1.0;
custom_equal = 1.0;
}
//Add the model columns to the Combo (which is a kind of view),
@@ -173,29 +183,30 @@ WhiteBalance::WhiteBalance () : Gtk::VBox(), FoldableToolPanel(this), wbp(NULL),
temp = Gtk::manage (new Adjuster (M("TP_WBALANCE_TEMPERATURE"), MINTEMP, MAXTEMP, 5, 4750));
green = Gtk::manage (new Adjuster (M("TP_WBALANCE_GREEN"), MINGREEN, MAXGREEN, 0.001, 1.0));
equal = Gtk::manage (new Adjuster (M("TP_WBALANCE_EQBLUERED"), MINEQUAL, MAXEQUAL, 0.001, 1.0));
equal->set_tooltip_markup (M("TP_WBALANCE_EQBLUERED_TOOLTIP"));
temp->show ();
green->show ();
equal->show ();
pack_start (*temp);
pack_start (*green);
pack_start (*equal);
temp->setAdjusterListener (this);
green->setAdjusterListener (this);
equal->setAdjusterListener (this);
spotbutton->signal_pressed().connect( sigc::mem_fun(*this, &WhiteBalance::spotPressed) );
methconn = method->signal_changed().connect( sigc::mem_fun(*this, &WhiteBalance::optChanged) );
spotsize->signal_changed().connect( sigc::mem_fun(*this, &WhiteBalance::spotSizeChanged) );
}
WhiteBalance::~WhiteBalance () {
delete[] custom_green;
}
void WhiteBalance::adjusterChanged (Adjuster* a, double newval) {
int tVal = (int)temp->getValue();
double gVal = green->getValue();
double eVal = equal->getValue();
Gtk::TreeModel::Row row = getActiveMethod();
if (row == refTreeModel->children().end()) return;
@@ -203,25 +214,42 @@ void WhiteBalance::adjusterChanged (Adjuster* a, double newval) {
WBEntry* ppMethod = findWBEntry (row[methodColumns.colLabel], WBLT_GUI);
WBEntry* wbCustom = findWBEntry ("Custom", WBLT_PP);
if (!ppMethod || ppMethod->ppLabel != wbCustom->ppLabel) {
if (!ppMethod || a==temp || (ppMethod->type==WBT_CAMERA || ppMethod->type==WBT_AUTO) ) {
methconn.block(true);
opt = setActiveMethod(wbCustom->GUILabel);
methconn.block(false);
}
if (!ppMethod || (ppMethod->ppLabel!=wbCustom->ppLabel && !(a==equal && ppMethod->type==WBT_AUTO)) ) {
methconn.block(true);
opt = setActiveMethod(wbCustom->GUILabel);
cache_customWB (tVal, gVal);
cache_customEqual(eVal);
methconn.block(false);
}
//cache custom WB setting to allow its recall
if (a==temp)
cache_customTemp (tVal);
else
else if (a==green)
cache_customGreen (gVal);
else if (a==equal) {
cache_customEqual (eVal);
// Recomputing AutoWB if it's the current method
if (wbp && ppMethod->type==WBT_AUTO) {
double ctemp=-1.0; double cgreen=-1.0;
wbp->getAutoWB (ctemp, cgreen, eVal);
if (ctemp != -1.0) {
// Set the automatics temperature value only if in SET mode
if (temp->getEditedState() && !temp->getAddMode() ) temp->setValue (ctemp);
// Set the automatics green value only if in SET mode
if (green->getEditedState() && !green->getAddMode()) green->setValue (cgreen);
}
}
}
if (listener) {
if (a==temp)
listener->panelChanged (EvWBTemp, Glib::ustring::format ((int)a->getValue()));
else if (a==green)
listener->panelChanged (EvWBGreen, Glib::ustring::format (std::setw(4), std::fixed, std::setprecision(3), a->getValue()));
else if (a==equal)
listener->panelChanged (EvWBequal, Glib::ustring::format (std::setw(4), std::fixed, std::setprecision(3), a->getValue()));
}
}
@@ -244,6 +272,7 @@ void WhiteBalance::optChanged () {
if (row[methodColumns.colLabel] == M("GENERAL_UNCHANGED")) {
temp->setEditedState (UnEdited);
green->setEditedState (UnEdited);
equal->setEditedState (UnEdited);
}
else {
int methodId = findWBEntryId (row[methodColumns.colLabel], WBLT_GUI);
@@ -256,23 +285,28 @@ void WhiteBalance::optChanged () {
wbp->getCamWB (ctemp, cgreen);
temp->setValue (temp->getAddMode() ? 0.0 : (int)ctemp);
green->setValue (green->getAddMode() ? 0.0 : cgreen);
equal->setValue (equal->getAddMode() ? 0.0 : 1.0);
if (batchMode) {
temp->setEditedState (UnEdited);
green->setEditedState (UnEdited);
equal->setEditedState (UnEdited);
}
}
break;
case WBT_AUTO:
if (wbp) {
double ctemp, cgreen;
wbp->getAutoWB (ctemp, cgreen);
if (ctemp != -1.0) {
temp->setValue (temp->getAddMode() ? 0.0 : (int)ctemp);
green->setValue (green->getAddMode() ? 0.0 : cgreen);
}
if (batchMode) {
temp->setEditedState (UnEdited);
green->setEditedState (UnEdited);
// equal remain as is
}
if (!batchMode || equal->getEditedState()) {
double ctemp, cgreen;
wbp->getAutoWB (ctemp, cgreen, equal->getValue());
if (ctemp != -1.0) {
temp->setValue (temp->getAddMode() ? 0.0 : (int)ctemp);
green->setValue (green->getAddMode() ? 0.0 : cgreen);
}
}
}
break;
@@ -280,10 +314,12 @@ void WhiteBalance::optChanged () {
if (custom_temp>0){
temp->setValue (temp->getAddMode() ? 0.0 : custom_temp);
}
green->setValue (green->getAddMode() ? 0.0 : custom_green[methodId]);
green->setValue (green->getAddMode() ? 0.0 : custom_green);
equal->setValue (equal->getAddMode() ? 0.0 : custom_equal);
if (batchMode) {
temp->setEditedState (Edited);
green->setEditedState (Edited);
equal->setEditedState (Edited);
}
break;
/* All other solution are the default cases
@@ -297,11 +333,13 @@ void WhiteBalance::optChanged () {
case WBT_LED:*/
default:
// recall custom WB settings if it exists, set to 1.0 otherwise
temp->setValue (temp->getAddMode() ? 0.0 : (double)(currMethod->temperature));
green->setValue (green->getAddMode() ? 0.0 : custom_green[methodId]);
temp->setValue ( temp->getAddMode() ? 0.0 : (double)(currMethod->temperature));
green->setValue (green->getAddMode() ? 0.0 : (double)(currMethod->green));
equal->setValue (equal->getAddMode() ? 0.0 : (double)(currMethod->equal));
if (batchMode) {
temp->setEditedState (Edited);
green->setEditedState (Edited);
equal->setEditedState (Edited);
}
break;
}
@@ -326,13 +364,16 @@ void WhiteBalance::spotSizeChanged () {
}
void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited) {
disableListener ();
methconn.block (true);
equal->setValue (pp->wb.equal);
if (pedited) {
// By default, temperature and green are said "UnEdited", but it may change later
temp->setEditedState (UnEdited);
green->setEditedState (UnEdited);
equal->setEditedState (pedited->wb.equal ? Edited : UnEdited);
}
if (pedited && !pedited->wb.method) {
@@ -350,12 +391,12 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited) {
case WBT_CUSTOM:
temp->setValue (pp->wb.temperature);
green->setValue (pp->wb.green);
if (pedited) {
equal->setValue (pp->wb.equal);
if (pedited) {
// The user may have changed the temperature and green value
temp->setEditedState (pedited->wb.temperature ? Edited : UnEdited);
green->setEditedState (pedited->wb.green ? Edited : UnEdited);
}
//cache_customWB (pp->wb.temperature, pp->wb.green);
break;
case WBT_CAMERA:
if (wbp) {
@@ -366,23 +407,34 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited) {
temp->setValue (temp->getAddMode() ? 0.0 : ctemp);
// Set the camera's green value, or 0.0 if in ADD mode
green->setValue (green->getAddMode() ? 0.0 : cgreen);
//cache_customWB ((int)ctemp, cgreen); // this will be used to set initial Custom WB setting
equal->setValue (equal->getAddMode() ? 0.0 : 1.);
}
break;
case WBT_AUTO:
// the equalizer's value is restored for the AutoWB
equal->setValue (equal->getAddMode() ? 0.0 : pp->wb.equal);
// set default values first if in ADD mode, otherwise keep the current ones
if (temp->getAddMode() ) temp->setValue (0.0);
if (green->getAddMode()) green->setValue (0.0);
// then check for the correct ones, if possible
if (wbp) {
double ctemp; double cgreen;
wbp->getAutoWB (ctemp, cgreen);
double ctemp=-1.0; double cgreen=-1.0;
wbp->getAutoWB (ctemp, cgreen, pp->wb.equal);
if (ctemp != -1.0) {
// Set the automatics temperature value, or 0.0 if in ADD mode
temp->setValue (temp->getAddMode() ? 0.0 : ctemp);
// Set the automatics green value, or 0.0 if in ADD mode
green->setValue (green->getAddMode() ? 0.0 : cgreen);
// Set the automatics temperature if in SET mode
if (!pedited || (pedited->wb.temperature && !temp->getAddMode()) ) {
temp->setValue (ctemp);
if (pedited) temp->setEditedState (Edited);
}
// Set the automatics green value if in SET mode
if (!pedited || (pedited->wb.green && !green->getAddMode())) {
green->setValue (cgreen);
if (pedited) green->setEditedState (Edited);
}
}
//cache_customWB ((int)ctemp, cgreen); // this will be used to set initial Custom WB setting
}
break;
/*
@@ -401,16 +453,19 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited) {
temp->setValue(temp->getAddMode() ? 0.0 : (double)wbValues->temperature);
// Set the stored temperature, or 0.0 if in ADD mode
green->setValue(green->getAddMode() ? 0.0 : pp->wb.green);
equal->setValue(equal->getAddMode() ? 0.0 : pp->wb.equal);
// The user may have changed the green value even for predefined WB values
if (pedited) {
green->setEditedState (pedited->wb.green ? Edited : UnEdited);
equal->setEditedState (pedited->wb.equal ? Edited : UnEdited);
}
//cache_customGreen (pp->wb.green);
break;
}
}
methconn.block (false);
enableListener ();
}
void WhiteBalance::write (ProcParams* pp, ParamsEdited* pedited) {
@@ -420,6 +475,7 @@ void WhiteBalance::write (ProcParams* pp, ParamsEdited* pedited) {
if (pedited) {
pedited->wb.temperature = temp->getEditedState ();
pedited->wb.green = green->getEditedState ();
pedited->wb.equal = equal->getEditedState ();
pedited->wb.method = row[methodColumns.colLabel]!=M("GENERAL_UNCHANGED");
}
@@ -429,10 +485,11 @@ void WhiteBalance::write (ProcParams* pp, ParamsEdited* pedited) {
pp->wb.method = ppMethod->ppLabel;
pp->wb.temperature = temp->getIntValue ();
pp->wb.green = green->getValue ();
pp->wb.equal = equal->getValue ();
}
void WhiteBalance::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) {
equal->setDefault (defParams->wb.equal);
if (wbp && defParams->wb.method == "Camera") {
double ctemp; double cgreen;
@@ -444,7 +501,7 @@ void WhiteBalance::setDefaults (const ProcParams* defParams, const ParamsEdited*
// this setDefaults method is called too early ; the wbp has been set,
// but wbp is not ready to provide!
double ctemp; double cgreen;
wbp->getAutoWB (ctemp, cgreen);
wbp->getAutoWB (ctemp, cgreen, defParams->wb.equal);
if (ctemp != -1.0) {
temp->setDefault (temp->getAddMode() ? 0 : (int)ctemp);
green->setDefault (green->getAddMode() ? 0 : cgreen);
@@ -462,10 +519,12 @@ void WhiteBalance::setDefaults (const ProcParams* defParams, const ParamsEdited*
if (pedited) {
temp->setDefaultEditedState (pedited->wb.temperature ? Edited : UnEdited);
green->setDefaultEditedState (pedited->wb.green ? Edited : UnEdited);
equal->setDefaultEditedState (pedited->wb.equal ? Edited : UnEdited);
}
else {
temp->setDefaultEditedState (Irrelevant);
green->setDefaultEditedState (Irrelevant);
equal->setDefaultEditedState (Irrelevant);
}
}
@@ -474,6 +533,7 @@ void WhiteBalance::setBatchMode (bool batchMode) {
ToolPanel::setBatchMode (batchMode);
temp->showEditedCB ();
green->showEditedCB ();
equal->showEditedCB ();
Gtk::TreeModel::Row row = *(refTreeModel->append());
row[methodColumns.colId] = WBParams::wbEntries.size();
row[methodColumns.colLabel] = M("GENERAL_UNCHANGED");
@@ -493,6 +553,7 @@ void WhiteBalance::setWB (int vtemp, double vgreen) {
green->setValue (vgreen);
opt = setActiveMethod(wbValues->GUILabel);
cache_customWB (vtemp,vgreen); // sequence in which this call is made is important; must be before "method->set_active (2);"
cache_customEqual(equal->getValue());
temp->setEditedState (Edited);
green->setEditedState (Edited);
methconn.block(false);
@@ -501,16 +562,18 @@ void WhiteBalance::setWB (int vtemp, double vgreen) {
listener->panelChanged (EvWBTemp, Glib::ustring::compose("%1, %2", (int)temp->getValue(), Glib::ustring::format (std::setw(4), std::fixed, std::setprecision(3), green->getValue())));
}
void WhiteBalance::setAdjusterBehavior (bool tempadd, bool greenadd) {
void WhiteBalance::setAdjusterBehavior (bool tempadd, bool greenadd, bool equaladd) {
temp->setAddMode(tempadd);
green->setAddMode(greenadd);
equal->setAddMode(equaladd);
}
void WhiteBalance::trimValues (rtengine::procparams::ProcParams* pp) {
temp->trimValue(pp->wb.temperature);
green->trimValue(pp->wb.green);
equal->trimValue(pp->wb.equal);
}
inline void WhiteBalance::cache_customTemp(int temp) {
@@ -518,11 +581,10 @@ inline void WhiteBalance::cache_customTemp(int temp) {
}
void WhiteBalance::cache_customGreen(double green) {
Gtk::TreeModel::Row row = getActiveMethod();
if (row == refTreeModel->children().end()) return;
custom_green[row[methodColumns.colId]] = green;
//printf("WhiteBalance::cache_customWB(%d, %f): the \"green\" value of \"%s\" has been set to: %f\n", temp, green, row[methodColumns.colLabel], custom_green[row[methodColumns.colId]]);
custom_green = green;
}
void WhiteBalance::cache_customEqual(double equal) {
custom_equal = equal;
}
void WhiteBalance::cache_customWB(int temp, double green) {

View File

@@ -55,18 +55,23 @@ class WhiteBalance : public Gtk::VBox, public AdjusterListener, public FoldableT
MyComboBoxText* spotsize;
Adjuster* temp;
Adjuster* green;
Adjuster* equal;
Gtk::Button* spotbutton;
int opt;
double nextTemp;
double nextGreen;
WBProvider *wbp;
WBProvider *wbp; // pointer to a ToolPanelCoordinator object, or its subclass BatchToolPanelCoordinator
SpotWBListener* wblistener;
sigc::connection methconn;
int custom_temp;
double* custom_green;
double custom_green;
double custom_equal;
void cache_customWB (int temp, double green); //cache custom WB setting to allow its recall
void cache_customTemp (int temp); //cache Temperature only to allow its recall
void cache_customGreen (double green); //cache Green only to allow its recall
void cache_customEqual (double equal); //cache Equal only to allow its recall
int setActiveMethod (Glib::ustring label);
int _setActiveMethod (Glib::ustring &label, Gtk::TreeModel::Children &children);
@@ -77,7 +82,7 @@ class WhiteBalance : public Gtk::VBox, public AdjusterListener, public FoldableT
public:
WhiteBalance ();
~WhiteBalance ();
~WhiteBalance () {};
static void init ();
static void cleanup ();
@@ -86,7 +91,6 @@ class WhiteBalance : public Gtk::VBox, public AdjusterListener, public FoldableT
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL);
void setBatchMode (bool batchMode);
void optChanged ();
void spotPressed ();
void spotSizeChanged ();
@@ -96,7 +100,7 @@ class WhiteBalance : public Gtk::VBox, public AdjusterListener, public FoldableT
void setSpotWBListener (SpotWBListener* l) { wblistener = l; }
void setWB (int temp, double green);
void setAdjusterBehavior (bool tempadd, bool greenadd);
void setAdjusterBehavior (bool tempadd, bool greenadd, bool equaladd);
void trimValues (rtengine::procparams::ProcParams* pp);
};