clean code

This commit is contained in:
Desmis 2018-04-15 15:34:36 +02:00
parent 02ce0e0e84
commit fe1114b7cf
2 changed files with 15 additions and 54 deletions

View File

@ -1316,13 +1316,12 @@ cmsHPROFILE rtengine::ICCStore::createGammaProfile(const procparams::ColorManage
enum class ColorTemp {
D50 = 5003, // for Widegamut, Prophoto Best, Beta -> D50
D65 = 6504, // for sRGB, AdobeRGB, Bruce Rec2020 -> D65
D60 = 6005 //for ACESc
D60 = 6005 //for ACESP0 and AcesP1
};
ColorTemp temp = ColorTemp::D50;
//primaries for 7 working profiles ==> output profiles
// eventually to adapt primaries if RT used special profiles !
//primaries for 10 working profiles ==> output profiles
if (icm.wprimari == "wideg") {
p[0] = 0.7350; //Widegamut primaries
p[1] = 0.2650;
@ -1400,7 +1399,7 @@ cmsHPROFILE rtengine::ICCStore::createGammaProfile(const procparams::ColorManage
p[4] = 0.0366;
p[5] = 0.0001;
} else {
p[0] = 0.7347; //ProPhoto and default primaries
p[0] = 0.7347; //default primaries
p[1] = 0.2653;
p[2] = 0.1596;
p[3] = 0.8404;
@ -1408,16 +1407,7 @@ cmsHPROFILE rtengine::ICCStore::createGammaProfile(const procparams::ColorManage
p[5] = 0.0001;
}
//printf("prim p2=%f \n", p[2]);
/*
p[0] = 0.6400; // sRGB primaries
p[1] = 0.3300;
p[2] = 0.3000;
p[3] = 0.6000;
p[4] = 0.1500;
p[5] = 0.0600;
temp = ColorTemp::D65;
*/
cmsCIExyY xyD;
cmsCIExyYTRIPLE Primaries = {
{p[0], p[1], 1.0}, // red
@ -1431,13 +1421,9 @@ cmsHPROFILE rtengine::ICCStore::createGammaProfile(const procparams::ColorManage
//lcmsMutex->lock(); Mutex acquired by the caller
cmsWhitePointFromTemp(&xyD, (double)temp);
// cmsCIExyY d60_aces= {0.32168, 0.33767, 1.0};
// xyD = d60_aces;
GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve(nullptr, 5, Parameters); //5 = smoother than 4
cmsHPROFILE oprofdef = cmsCreateRGBProfile(&xyD, &Primaries, GammaTRC); //oprofdef become Outputprofile
//cmsSetProfileVersion(oprofdef, 4.3);
cmsFreeToneCurve(GammaTRC[0]);
//lcmsMutex->unlock();
@ -1487,22 +1473,18 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
} else if (icm.wprimari == "sRGB" && rtengine::ICCStore::getInstance()->outputProfileExist(options.rtSettings.srgb10) && pro) {
outProfile = options.rtSettings.srgb10;
outPr = "RT_srgb";
} else if (icm.wprimari == "proph" && rtengine::ICCStore::getInstance()->outputProfileExist(options.rtSettings.prophoto10) && pro) {
outProfile = options.rtSettings.prophoto10;
outPr = "RT_large";
} else if (icm.wprimari == "rec2020" && rtengine::ICCStore::getInstance()->outputProfileExist(options.rtSettings.rec2020)) {
outProfile = options.rtSettings.rec2020;
outPr = "RT_rec2020";
} else if (icm.wprimari == "acesp0" && rtengine::ICCStore::getInstance()->outputProfileExist(options.rtSettings.ACESp0)) {
outProfile = options.rtSettings.ACESp0;
outPr = "RT_acesp0";
} else if (icm.wprimari == "acesp1" && rtengine::ICCStore::getInstance()->outputProfileExist(options.rtSettings.ACESp1)) {
outProfile = options.rtSettings.ACESp1;
outPr = "RT_acesp1";
} else {
// Should not occurs
if (settings->verbose) {
@ -1614,9 +1596,6 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
printf("Description error\n");
} else {
if (icm.wprofile == "v4") {
cmsSetProfileVersion(outputProfile, 4.3);
} else {
@ -1712,7 +1691,7 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
p[4] = 0.0366;
p[5] = 0.0001;
} else {
p[0] = 0.7347; //ProPhoto and default primaries
p[0] = 0.7347; //default primaries
p[1] = 0.2653;
p[2] = 0.1596;
p[3] = 0.8404;
@ -1743,7 +1722,7 @@ cmsHPROFILE rtengine::ICCStore::createCustomGammaOutputProfile(const procparams:
cmsWriteTag(outputProfile, cmsSigBlueTRCTag, GammaTRC[2]);
cmsWriteTag(outputProfile, cmsSigProfileDescriptionTag, mlu);//desc changed
/*
/* //to read XYZ values
cmsCIEXYZ *redT = static_cast<cmsCIEXYZ*>(cmsReadTag(outputProfile, cmsSigRedMatrixColumnTag));
cmsCIEXYZ *greenT = static_cast<cmsCIEXYZ*>(cmsReadTag(outputProfile, cmsSigGreenMatrixColumnTag));
cmsCIEXYZ *blueT = static_cast<cmsCIEXYZ*>(cmsReadTag(outputProfile, cmsSigBlueMatrixColumnTag));

View File

@ -224,13 +224,11 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iuncha
//Gtk::HBox* gaHBox = Gtk::manage(new Gtk::HBox());
Gtk::Label* galab = Gtk::manage(new Gtk::Label(M("TP_GAMMA_OUTPUT") + ":"));
//galab->set_alignment (0.0, 0.5);
gaHBox->pack_start(*galab, Gtk::PACK_SHRINK);
wgamma = Gtk::manage(new MyComboBoxText());
gaHBox->pack_start(*wgamma, Gtk::PACK_EXPAND_WIDGET);
// oVBox->pack_start(*gaHBox, Gtk::PACK_EXPAND_WIDGET);
std::vector<Glib::ustring> wpgamma = rtengine::ICCStore::getGamma();
@ -251,7 +249,7 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iuncha
fgFrame->set_label_widget(*freegamma);
//Gtk::HBox* priHBox = Gtk::manage(new Gtk::HBox());
//primaries
priHBox = Gtk::manage(new Gtk::HBox());
Gtk::Label* prilab = Gtk::manage(new Gtk::Label(M("TP_GAMMA_PRIM") + ":"));
@ -267,18 +265,10 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iuncha
wprimari->append(M("TP_GAMMA_PRIM_REC2020"));
wprimari->append(M("TP_GAMMA_PRIM_SRGB"));
wprimari->append(M("TP_GAMMA_PRIM_WIDEG"));
/*
std::vector<Glib::ustring> wprinames = rtengine::ICCStore::getInstance()->getWorkingProfiles();
for (size_t i = 0; i < wprinames.size(); i++) {
if (i <= 2 || i >= 6) {
wprimari->append(wprinames[i]);
}
}
*/
wprimari->set_active(5);
fgVBox->pack_start(*gaHBox, Gtk::PACK_EXPAND_WIDGET);
//sliders gampos and slpos
fgVBox->pack_start(*gaHBox, Gtk::PACK_EXPAND_WIDGET);
gampos = Gtk::manage(new Adjuster(M("TP_GAMMA_CURV"), 1, 3.5, 0.00001, 2.4));
gampos->setAdjusterListener(this);
@ -287,7 +277,6 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iuncha
}
gampos->show();
// slpos = Gtk::manage(new Adjuster(M("TP_GAMMA_SLOP"), 5800, 6200, 0.00001, 6000.));
slpos = Gtk::manage(new Adjuster(M("TP_GAMMA_SLOP"), 0, 15, 0.00001, 12.92310));
slpos->setAdjusterListener(this);
@ -300,9 +289,8 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iuncha
fgVBox->pack_start(*gampos, Gtk::PACK_SHRINK); //gamma
fgVBox->pack_start(*slpos, Gtk::PACK_SHRINK); //slope
//V2 or V4 profiles
profHBox = Gtk::manage(new Gtk::HBox());
// Gtk::HBox* profHBox = Gtk::manage(new Gtk::HBox());
Gtk::Label* proflab = Gtk::manage(new Gtk::Label(M("TP_GAMMA_PROF") + ":"));
profHBox->pack_start(*proflab, Gtk::PACK_SHRINK);
@ -313,7 +301,6 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iuncha
wprofile->append(M("TP_GAMMA_PROF_NONE"));
wprofile->append(M("TP_GAMMA_PROF_V2"));
wprofile->append(M("TP_GAMMA_PROF_V4"));
wprofileconn = wprofile->signal_changed().connect(sigc::mem_fun(*this, &ICMPanel::wprofileChanged));
wprofile->set_active(0);
@ -366,6 +353,7 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iuncha
wgammaconn = wgamma->signal_changed().connect(sigc::mem_fun(*this, &ICMPanel::gpChanged));
dcpillconn = dcpIll->signal_changed().connect(sigc::mem_fun(*this, &ICMPanel::dcpIlluminantChanged));
wprimariconn = wprimari->signal_changed().connect(sigc::mem_fun(*this, &ICMPanel::wprimariChanged));
wprofileconn = wprofile->signal_changed().connect(sigc::mem_fun(*this, &ICMPanel::wprofileChanged));
obpcconn = obpc->signal_toggled().connect(sigc::mem_fun(*this, &ICMPanel::oBPCChanged));
gamcsconn = freegamma->signal_toggled().connect(sigc::mem_fun(*this, &ICMPanel::GamChanged));
@ -592,8 +580,7 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited)
wnames->set_active_text(pp->icm.working);
wgamma->set_active_text(pp->icm.gamma);
gpChanged();
// wprimari->set_active_text(pp->icm.wprimari);
// wprofile->set_active_text (pp->icm.wprofile);
if (pp->icm.wprimari == "acesp0") {
wprimari->set_active(0);
@ -612,7 +599,6 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited)
}
if (pp->icm.wprofile == "none") {
wprofile->set_active(0);
} else if (pp->icm.wprofile == "v2") {
@ -621,7 +607,6 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited)
wprofile->set_active(2);
}
// wprofileChanged();
if (pp->icm.output == ColorManagementParams::NoICMString) {
@ -691,7 +676,6 @@ void ICMPanel::read(const ProcParams* pp, const ParamsEdited* pedited)
if (!pedited->icm.gamma) {
wgamma->set_active_text(M("GENERAL_UNCHANGED"));
wgamma->set_active_text(M("GENERAL_UNCHANGED"));
}
if (!pedited->icm.wprimari) {
@ -735,7 +719,6 @@ void ICMPanel::write(ProcParams* pp, ParamsEdited* pedited)
pp->icm.gamma = wgamma->get_active_text();
pp->icm.dcpIlluminant = rtengine::max<int>(dcpIll->get_active_row_number(), 0);
pp->icm.wprimari = wprimari->get_active_text();
// pp->icm.wprofile = wprofile->get_active_text ();
if (onames->get_active_text() == M("TP_ICM_NOICM")) {
pp->icm.output = ColorManagementParams::NoICMString;
@ -876,7 +859,7 @@ void ICMPanel::gpChanged()
if (listener) {
listener->panelChanged(EvGAMMA, wgamma->get_active_text());
onames->set_sensitive(wgamma->get_active_row_number() == 0); //"default"
onames->set_sensitive(wgamma->get_active_row_number() == 0);
}
}
@ -1066,7 +1049,6 @@ void ICMPanel::GamChanged()
listener->panelChanged(EvGAMFREE, M("GENERAL_DISABLED"));
if (!batchMode) {
// onames->set_sensitive(wgamma->get_active_row_number() == 0);
onames->set_sensitive(true);
wgamma->set_sensitive(false);
gampos->set_sensitive(false);