Merge pull request #5404 from Beep6581/58_cppcheck_coverity_fixes
cppcheck and coverity fixes
This commit is contained in:
commit
f7ec852e05
@ -18,10 +18,10 @@
|
||||
*
|
||||
* Author: reine
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef STOPWATCH_H
|
||||
#define STOPWATCH_H
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "mytime.h"
|
||||
|
||||
#ifdef BENCHMARK
|
||||
@ -36,45 +36,34 @@ class StopWatch
|
||||
{
|
||||
public:
|
||||
|
||||
explicit StopWatch( const char* msg, bool microseconds = false ) : microseconds(microseconds)
|
||||
explicit StopWatch(const char* msg, bool microSeconds = false) : message(msg), unit(microSeconds ? " us" : " ms"), divisor(microSeconds ? 1 : 1000)
|
||||
{
|
||||
message = msg;
|
||||
start();
|
||||
stopped = false;
|
||||
}
|
||||
~StopWatch()
|
||||
{
|
||||
if(!stopped) {
|
||||
if (!stopped) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
void start()
|
||||
{
|
||||
startTime.set();
|
||||
};
|
||||
}
|
||||
void stop()
|
||||
{
|
||||
stopTime.set();
|
||||
if(!microseconds) {
|
||||
long elapsedTime = stopTime.etime(startTime) / 1000;
|
||||
std::cout << message << " took " << elapsedTime << " ms" << std::endl;
|
||||
} else {
|
||||
long elapsedTime = stopTime.etime(startTime);
|
||||
std::cout << message << " took " << elapsedTime << " us" << std::endl;
|
||||
}
|
||||
const long elapsedTime = stopTime.etime(startTime) / divisor;
|
||||
std::cout << message << " took " << elapsedTime << unit << std::endl;
|
||||
stopped = true;
|
||||
}
|
||||
void stop(const char *msg)
|
||||
{
|
||||
message = msg;
|
||||
stop();
|
||||
};
|
||||
|
||||
private:
|
||||
bool microseconds;
|
||||
MyTime startTime;
|
||||
MyTime stopTime;
|
||||
const char *message;
|
||||
const std::string message;
|
||||
const std::string unit;
|
||||
const int divisor;
|
||||
bool stopped;
|
||||
};
|
||||
|
||||
#endif /* STOPWATCH_H */
|
||||
|
@ -40,7 +40,7 @@ void RawImageSource::ahd_demosaic()
|
||||
{
|
||||
BENCHFUN
|
||||
|
||||
constexpr int dir[4] = { -1, 1, -TS, TS };
|
||||
constexpr int dirs[4] = { -1, 1, -TS, TS };
|
||||
float xyz_cam[3][3];
|
||||
LUTf cbrt(65536);
|
||||
|
||||
@ -55,9 +55,10 @@ void RawImageSource::ahd_demosaic()
|
||||
constexpr float d65_white[3] = { 0.950456, 1, 1.088754 };
|
||||
|
||||
double progress = 0.0;
|
||||
|
||||
if (plistener) {
|
||||
plistener->setProgressStr (Glib::ustring::compose(M("TP_RAW_DMETHOD_PROGRESSBAR"), M("TP_RAW_AHD")));
|
||||
plistener->setProgress (0.0);
|
||||
plistener->setProgress (progress);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 65536; i++) {
|
||||
@ -65,16 +66,17 @@ void RawImageSource::ahd_demosaic()
|
||||
cbrt[i] = r > 0.008856 ? std::cbrt(r) : 7.787 * r + 16 / 116.0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (unsigned int j = 0; j < 3; j++) {
|
||||
xyz_cam[i][j] = 0;
|
||||
for (int k = 0; k < 3; k++) {
|
||||
xyz_cam[i][j] += xyz_rgb[i][k] * imatrices.rgb_cam[k][j] / d65_white[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
border_interpolate2(W, H, 5, rawData, red, green, blue);
|
||||
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
@ -153,9 +155,9 @@ void RawImageSource::ahd_demosaic()
|
||||
auto lix = &lab[d][tr][tc];
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ldiff[d][i] = std::fabs(lix[0][0] - lix[dir[i]][0]);
|
||||
abdiff[d][i] = SQR(lix[0][1] - lix[dir[i]][1])
|
||||
+ SQR(lix[0][2] - lix[dir[i]][2]);
|
||||
ldiff[d][i] = std::fabs(lix[0][0] - lix[dirs[i]][0]);
|
||||
abdiff[d][i] = SQR(lix[0][1] - lix[dirs[i]][1])
|
||||
+ SQR(lix[0][2] - lix[dirs[i]][2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,11 +49,11 @@ void RawImageSource::amaze_demosaic_RT(int winx, int winy, int winw, int winh, c
|
||||
stop.reset(new StopWatch("amaze demosaic"));
|
||||
}
|
||||
|
||||
volatile double progress = 0.0;
|
||||
double progress = 0.0;
|
||||
|
||||
if (plistener) {
|
||||
plistener->setProgressStr (Glib::ustring::compose(M("TP_RAW_DMETHOD_PROGRESSBAR"), M("TP_RAW_AMAZE")));
|
||||
plistener->setProgress (0.0);
|
||||
plistener->setProgressStr(Glib::ustring::compose(M("TP_RAW_DMETHOD_PROGRESSBAR"), M("TP_RAW_AMAZE")));
|
||||
plistener->setProgress(progress);
|
||||
}
|
||||
|
||||
const int width = winw, height = winh;
|
||||
@ -768,7 +768,7 @@ void RawImageSource::amaze_demosaic_RT(int winx, int winy, int winw, int winh, c
|
||||
|
||||
//if both agree on interpolation direction, choose the one with strongest directional discrimination;
|
||||
//otherwise, choose the u/d and l/r difference fluctuation weights
|
||||
if ((0.5 - varwt) * (0.5 - diffwt) > 0 && fabsf(0.5 - diffwt) < fabsf(0.5 - varwt)) {
|
||||
if ((0.5f - varwt) * (0.5f - diffwt) > 0.f && fabsf(0.5f - diffwt) < fabsf(0.5f - varwt)) {
|
||||
hvwt[indx >> 1] = varwt;
|
||||
} else {
|
||||
hvwt[indx >> 1] = diffwt;
|
||||
@ -1236,7 +1236,7 @@ void RawImageSource::amaze_demosaic_RT(int winx, int winy, int winw, int winh, c
|
||||
//first ask if one gets more directional discrimination from nearby B/R sites
|
||||
float pmwtalt = xdivf(pmwt[(indx - m1) >> 1] + pmwt[(indx + p1) >> 1] + pmwt[(indx - p1) >> 1] + pmwt[(indx + m1) >> 1], 2);
|
||||
|
||||
if (fabsf(0.5 - pmwt[indx1]) < fabsf(0.5 - pmwtalt)) {
|
||||
if (fabsf(0.5f - pmwt[indx1]) < fabsf(0.5f - pmwtalt)) {
|
||||
pmwt[indx1] = pmwtalt; //a better result was obtained from the neighbours
|
||||
}
|
||||
|
||||
@ -1304,7 +1304,7 @@ void RawImageSource::amaze_demosaic_RT(int winx, int winy, int winw, int winh, c
|
||||
|
||||
for (int cc = 12 + (FC(rr, 2) & 1), indx = rr * ts + cc, indx1 = indx >> 1; cc < cc1 - 12; cc += 2, indx += 2, indx1++) {
|
||||
|
||||
if (fabsf(0.5 - pmwt[indx >> 1]) < fabsf(0.5 - hvwt[indx >> 1]) ) {
|
||||
if (fabsf(0.5f - pmwt[indx >> 1]) < fabsf(0.5f - hvwt[indx >> 1]) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -54,15 +54,15 @@ void RawImageSource::CLASS cfa_linedn(float noise, bool horizontal, bool vertica
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
double progress = 0.0;
|
||||
if (plistener) {
|
||||
plistener->setProgressStr ("PROGRESSBAR_LINEDENOISE");
|
||||
plistener->setProgress (0.0);
|
||||
plistener->setProgressStr("PROGRESSBAR_LINEDENOISE");
|
||||
plistener->setProgress(progress);
|
||||
}
|
||||
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
float noisevar = SQR(3 * noise * 65535); // _noise_ (as a fraction of saturation) is input to the algorithm
|
||||
float noisevarm4 = 4.0f * noisevar;
|
||||
volatile double progress = 0.0;
|
||||
float* RawDataTmp = (float*)malloc( width * height * sizeof(float));
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
|
@ -1088,11 +1088,11 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul,
|
||||
//};
|
||||
gmul /= green;
|
||||
//printf("rmul=%f gmul=%f bmul=%f\n",rmul, gmul, bmul);
|
||||
double max = rtengine::max(rmul, gmul, bmul);
|
||||
double maxRGB = rtengine::max(rmul, gmul, bmul);
|
||||
|
||||
rmul /= max;
|
||||
gmul /= max;
|
||||
bmul /= max;
|
||||
rmul /= maxRGB;
|
||||
gmul /= maxRGB;
|
||||
bmul /= maxRGB;
|
||||
|
||||
|
||||
if(settings->CRI_color != 0) { //activate if CRi_color !=0
|
||||
@ -1104,7 +1104,6 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul,
|
||||
// and calcul with : blackbody at equivalent temp of lamp
|
||||
// CRI_color-1 = display Lab values of color CRI_color -1
|
||||
const double whiteD50[3] = {0.9646019585, 1.0, 0.8244507152}; //calculate with this tool : spect 5nm
|
||||
double CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22; //for CIECAT02
|
||||
double Xchk[50], Ychk[50], Zchk[50]; //50 : I think it's a good limit for number of color : for CRI and Palette
|
||||
double Xcam02[50], Ycam02[50], Zcam02[50];
|
||||
|
||||
@ -1113,9 +1112,6 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul,
|
||||
const double epsilon = 0.008856; //Lab
|
||||
|
||||
double xr[50], yr[50], zr[50];
|
||||
double fx[50], fy[50], fz[50];
|
||||
double x, y, z;
|
||||
double Ywb = 1.0;
|
||||
|
||||
int illum;
|
||||
int numero_color = settings->CRI_color - 1;
|
||||
@ -1223,6 +1219,9 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul,
|
||||
}
|
||||
|
||||
if (CRI_type) {
|
||||
double x, y, z;
|
||||
double Ywb = 1.0;
|
||||
|
||||
const double* spect_illum[] = {
|
||||
Daylight5300_spect, Cloudy6200_spect, Shade7600_spect, A2856_spect, FluoF1_spect, FluoF2_spect, FluoF3_spect,
|
||||
FluoF4_spect, FluoF5_spect, FluoF6_spect, FluoF7_spect, FluoF8_spect, FluoF9_spect, FluoF10_spect, FluoF11_spect,
|
||||
@ -1281,6 +1280,7 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul,
|
||||
|
||||
//calculate Matrix CAM02 : better than Von Kries and Bradford==> for Lamp
|
||||
double adap = 1.0;
|
||||
double CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22; //for CIECAT02
|
||||
cieCAT02(Xwb, Ywb, Zwb, CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22, adap);
|
||||
|
||||
//here new value of X,Y,Z for lamp with chromatic CAM02 adaptation
|
||||
@ -1306,6 +1306,7 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul,
|
||||
|
||||
//now conversion to Lab
|
||||
// Lamp
|
||||
double fx[50], fy[50], fz[50];
|
||||
|
||||
for(int i = 0; i < N_c; i++) {
|
||||
xr[i] = Xcam02Lamp[i] / whiteD50[0];
|
||||
|
@ -641,15 +641,15 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
|
||||
}
|
||||
// gamma correction
|
||||
|
||||
float val = Color::gammatab_srgb1[0];
|
||||
float val0 = Color::gammatab_srgb1[0];
|
||||
|
||||
// apply brightness curve
|
||||
if (brightcurve) {
|
||||
val = brightcurve->getVal(val); // TODO: getVal(double) is very slow! Optimize with a LUTf
|
||||
val0 = brightcurve->getVal(val0); // TODO: getVal(double) is very slow! Optimize with a LUTf
|
||||
}
|
||||
|
||||
// store result in a temporary array
|
||||
dcurve[0] = LIM01<float>(val);
|
||||
dcurve[0] = LIM01<float>(val0);
|
||||
|
||||
for (int i = 1; i < 0x10000; i++) {
|
||||
|
||||
@ -1508,10 +1508,10 @@ void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3],
|
||||
Color::gamutLchonly(h1, Lr, c1, RR, GG, BB, xyz_rgb, false, 0.15f, 0.96f);
|
||||
#endif
|
||||
L1 = Lr * 327.68f;
|
||||
float a, b, X, Y, Z;
|
||||
float La, Lb, X, Y, Z;
|
||||
// converting back to rgb
|
||||
Color::Lch2Lab(c1, h1, a, b);
|
||||
Color::Lab2XYZ(L1, a, b, X, Y, Z);
|
||||
Color::Lch2Lab(c1, h1, La, Lb);
|
||||
Color::Lab2XYZ(L1, La, Lb, X, Y, Z);
|
||||
lut1[i] = X;
|
||||
lut2[i] = Y;
|
||||
lut3[i] = Z;
|
||||
@ -1822,12 +1822,12 @@ float PerceptualToneCurve::calculateToneCurveContrastValue() const
|
||||
{
|
||||
// look at midtone slope
|
||||
const float xd = 0.07;
|
||||
const float tx[] = { 0.30, 0.35, 0.40, 0.45 }; // we only look in the midtone range
|
||||
const float tx0[] = { 0.30, 0.35, 0.40, 0.45 }; // we only look in the midtone range
|
||||
|
||||
for (size_t i = 0; i < sizeof(tx) / sizeof(tx[0]); i++) {
|
||||
float x0 = tx[i] - xd;
|
||||
for (size_t i = 0; i < sizeof(tx0) / sizeof(tx0[0]); i++) {
|
||||
float x0 = tx0[i] - xd;
|
||||
float y0 = CurveFactory::gamma2(lutToneCurve[CurveFactory::igamma2(x0) * 65535.f] / 65535.f) - k * x0;
|
||||
float x1 = tx[i] + xd;
|
||||
float x1 = tx0[i] + xd;
|
||||
float y1 = CurveFactory::gamma2(lutToneCurve[CurveFactory::igamma2(x1) * 65535.f] / 65535.f) - k * x1;
|
||||
float slope = 1.0 + (y1 - y0) / (x1 - x0);
|
||||
|
||||
@ -1967,15 +1967,15 @@ void PerceptualToneCurve::BatchApply(const size_t start, const size_t end, float
|
||||
saturated_scale_factor = 1.f;
|
||||
} else if (C < hilim) {
|
||||
// S-curve transition between low and high limit
|
||||
float x = (C - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim
|
||||
float cx = (C - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim
|
||||
|
||||
if (x < 0.5f) {
|
||||
x = 2.f * SQR(x);
|
||||
if (cx < 0.5f) {
|
||||
cx = 2.f * SQR(cx);
|
||||
} else {
|
||||
x = 1.f - 2.f * SQR(1 - x);
|
||||
cx = 1.f - 2.f * SQR(1.f - cx);
|
||||
}
|
||||
|
||||
saturated_scale_factor = (1.f - x) + saturated_scale_factor * x;
|
||||
saturated_scale_factor = (1.f - cx) + saturated_scale_factor * cx;
|
||||
} else {
|
||||
// do nothing, high saturation color, keep scale factor
|
||||
}
|
||||
@ -1995,15 +1995,15 @@ void PerceptualToneCurve::BatchApply(const size_t start, const size_t end, float
|
||||
// do nothing, keep scale factor
|
||||
} else if (nL < hilim) {
|
||||
// S-curve transition
|
||||
float x = (nL - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim
|
||||
float cx = (nL - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim
|
||||
|
||||
if (x < 0.5f) {
|
||||
x = 2.f * SQR(x);
|
||||
if (cx < 0.5f) {
|
||||
cx = 2.f * SQR(cx);
|
||||
} else {
|
||||
x = 1.f - 2.f * SQR(1 - x);
|
||||
cx = 1.f - 2.f * SQR(1 - cx);
|
||||
}
|
||||
|
||||
dark_scale_factor = dark_scale_factor * (1.0f - x) + x;
|
||||
dark_scale_factor = dark_scale_factor * (1.0f - cx) + cx;
|
||||
} else {
|
||||
dark_scale_factor = 1.f;
|
||||
}
|
||||
@ -2021,15 +2021,15 @@ void PerceptualToneCurve::BatchApply(const size_t start, const size_t end, float
|
||||
// do nothing, keep scale factor
|
||||
} else if (J < hilim) {
|
||||
// S-curve transition
|
||||
float x = (J - lolim) / (hilim - lolim);
|
||||
float cx = (J - lolim) / (hilim - lolim);
|
||||
|
||||
if (x < 0.5f) {
|
||||
x = 2.f * SQR(x);
|
||||
if (cx < 0.5f) {
|
||||
cx = 2.f * SQR(cx);
|
||||
} else {
|
||||
x = 1.f - 2.f * SQR(1 - x);
|
||||
cx = 1.f - 2.f * SQR(1 - cx);
|
||||
}
|
||||
|
||||
dark_scale_factor = dark_scale_factor * (1.f - x) + x;
|
||||
dark_scale_factor = dark_scale_factor * (1.f - cx) + cx;
|
||||
} else {
|
||||
dark_scale_factor = 1.f;
|
||||
}
|
||||
@ -2089,15 +2089,15 @@ void PerceptualToneCurve::BatchApply(const size_t start, const size_t end, float
|
||||
keep = 1.f;
|
||||
} else if (sat_scale < hilim) {
|
||||
// S-curve transition
|
||||
float x = (sat_scale - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim
|
||||
float cx = (sat_scale - lolim) / (hilim - lolim); // x = [0..1], 0 at lolim, 1 at hilim
|
||||
|
||||
if (x < 0.5f) {
|
||||
x = 2.f * SQR(x);
|
||||
if (cx < 0.5f) {
|
||||
cx = 2.f * SQR(cx);
|
||||
} else {
|
||||
x = 1.f - 2.f * SQR(1 - x);
|
||||
cx = 1.f - 2.f * SQR(1 - cx);
|
||||
}
|
||||
|
||||
keep = (1.f - x) + keep * x;
|
||||
keep = (1.f - cx) + keep * cx;
|
||||
} else {
|
||||
// do nothing, very high increase, keep minimum amount
|
||||
}
|
||||
|
@ -228,12 +228,12 @@ void ImProcFunctions::dehaze(Imagefloat *img)
|
||||
array2D<float> dark(W, H);
|
||||
|
||||
int patchsize = max(int(5 / scale), 2);
|
||||
int npatches = 0;
|
||||
float ambient[3];
|
||||
array2D<float> &t_tilde = dark;
|
||||
float max_t = 0.f;
|
||||
|
||||
{
|
||||
int npatches = 0;
|
||||
array2D<float> R(W, H);
|
||||
array2D<float> G(W, H);
|
||||
array2D<float> B(W, H);
|
||||
|
@ -356,24 +356,19 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw,
|
||||
{
|
||||
const TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix(params->icm.workingProfile);
|
||||
|
||||
double dx = Color::D50x;
|
||||
double dz = Color::D50z;
|
||||
{
|
||||
dx = dz = 1.0;
|
||||
}
|
||||
const float toxyz[3][3] = {
|
||||
{
|
||||
static_cast<float>(wprof[0][0] / (dx * (normalizeIn ? 65535.0 : 1.0))), //I have suppressed / Color::D50x
|
||||
static_cast<float>(wprof[0][1] / (dx * (normalizeIn ? 65535.0 : 1.0))),
|
||||
static_cast<float>(wprof[0][2] / (dx * (normalizeIn ? 65535.0 : 1.0)))
|
||||
static_cast<float>(wprof[0][0] / ((normalizeIn ? 65535.0 : 1.0))), //I have suppressed / Color::D50x
|
||||
static_cast<float>(wprof[0][1] / ((normalizeIn ? 65535.0 : 1.0))),
|
||||
static_cast<float>(wprof[0][2] / ((normalizeIn ? 65535.0 : 1.0)))
|
||||
}, {
|
||||
static_cast<float>(wprof[1][0] / (normalizeIn ? 65535.0 : 1.0)),
|
||||
static_cast<float>(wprof[1][1] / (normalizeIn ? 65535.0 : 1.0)),
|
||||
static_cast<float>(wprof[1][2] / (normalizeIn ? 65535.0 : 1.0))
|
||||
}, {
|
||||
static_cast<float>(wprof[2][0] / (dz * (normalizeIn ? 65535.0 : 1.0))), //I have suppressed / Color::D50z
|
||||
static_cast<float>(wprof[2][1] / (dz * (normalizeIn ? 65535.0 : 1.0))),
|
||||
static_cast<float>(wprof[2][2] / (dz * (normalizeIn ? 65535.0 : 1.0)))
|
||||
static_cast<float>(wprof[2][0] / ((normalizeIn ? 65535.0 : 1.0))), //I have suppressed / Color::D50z
|
||||
static_cast<float>(wprof[2][1] / ((normalizeIn ? 65535.0 : 1.0))),
|
||||
static_cast<float>(wprof[2][2] / ((normalizeIn ? 65535.0 : 1.0)))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -234,8 +234,6 @@ rtengine::LCPProfile::LCPProfile(const Glib::ustring& fname) :
|
||||
pCurCommon(nullptr),
|
||||
aPersModel{}
|
||||
{
|
||||
const int BufferSize = 8192;
|
||||
char buf[BufferSize];
|
||||
|
||||
XML_Parser parser = XML_ParserCreate(nullptr);
|
||||
|
||||
@ -250,6 +248,8 @@ rtengine::LCPProfile::LCPProfile(const Glib::ustring& fname) :
|
||||
FILE* const pFile = g_fopen(fname.c_str (), "rb");
|
||||
|
||||
if (pFile) {
|
||||
constexpr int BufferSize = 8192;
|
||||
char buf[BufferSize];
|
||||
bool done;
|
||||
|
||||
do {
|
||||
@ -362,9 +362,8 @@ void rtengine::LCPProfile::calcParams(
|
||||
const float focDist = aPersModel[pm]->focDist;
|
||||
const float focDistLog = std::log(focDist) + euler;
|
||||
|
||||
double meanErr = 0.0;
|
||||
|
||||
if (aPersModel[pm]->hasModeData(mode)) {
|
||||
double meanErr = 0.0;
|
||||
double lowMeanErr = 0.0;
|
||||
double highMeanErr = 0.0;
|
||||
|
||||
|
@ -16,8 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef _MYTIME_
|
||||
#define _MYTIME_
|
||||
#pragma once
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
@ -58,11 +57,11 @@ public:
|
||||
t.tv_sec = tv.tv_sec;
|
||||
t.tv_nsec = tv.tv_usec * 1000;
|
||||
#else
|
||||
clock_gettime (CLOCK_REALTIME, &t);
|
||||
clock_gettime(CLOCK_REALTIME, &t);
|
||||
#endif
|
||||
}
|
||||
|
||||
int etime (MyTime a)
|
||||
int etime (const MyTime &a) const
|
||||
{
|
||||
#ifndef WIN32
|
||||
return (t.tv_sec - a.t.tv_sec) * 1000000 + (t.tv_nsec - a.t.tv_nsec) / 1000;
|
||||
@ -71,6 +70,3 @@ public:
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -176,9 +176,11 @@ void PipetteBuffer::getPipetteData(int x, int y, const int squareSize)
|
||||
}
|
||||
}
|
||||
|
||||
dataProvider->setPipetteVal1(-1.f);
|
||||
dataProvider->setPipetteVal2(-1.f);
|
||||
dataProvider->setPipetteVal3(-1.f);
|
||||
if (dataProvider) {
|
||||
dataProvider->setPipetteVal1(-1.f);
|
||||
dataProvider->setPipetteVal2(-1.f);
|
||||
dataProvider->setPipetteVal3(-1.f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -261,12 +261,12 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
|
||||
return fileFound;
|
||||
}
|
||||
|
||||
int ProfileStore::findFolderId (const Glib::ustring &path)
|
||||
int ProfileStore::findFolderId (const Glib::ustring &path) const
|
||||
{
|
||||
// initialization must have been done when calling this
|
||||
for (std::vector<Glib::ustring>::iterator i = folders.begin(); i != folders.end(); ++i) {
|
||||
if (*i == path) {
|
||||
return i - folders.begin();
|
||||
for (size_t i = 0; i < folders.size(); ++i) {
|
||||
if (folders[i] == path) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,7 +454,7 @@ const PartialProfile* ProfileStore::getDefaultPartialProfile (bool isRaw)
|
||||
return pProf;
|
||||
}
|
||||
|
||||
const Glib::ustring ProfileStore::getPathFromId (int folderId)
|
||||
const Glib::ustring ProfileStore::getPathFromId (int folderId) const
|
||||
{
|
||||
// initialization must have been done when calling this
|
||||
return folders.at (folderId);
|
||||
|
@ -185,7 +185,7 @@ public:
|
||||
|
||||
bool init (bool loadAll = true);
|
||||
void parseProfiles ();
|
||||
int findFolderId (const Glib::ustring &path);
|
||||
int findFolderId (const Glib::ustring &path) const;
|
||||
const ProfileStoreEntry* findEntryFromFullPath (Glib::ustring path);
|
||||
const rtengine::procparams::PartialProfile* getProfile (Glib::ustring path);
|
||||
const rtengine::procparams::PartialProfile* getProfile (const ProfileStoreEntry* entry);
|
||||
@ -193,13 +193,13 @@ public:
|
||||
void releaseFileList ();
|
||||
const rtengine::procparams::ProcParams* getDefaultProcParams (bool isRaw);
|
||||
const rtengine::procparams::PartialProfile* getDefaultPartialProfile (bool isRaw);
|
||||
const Glib::ustring getPathFromId (int folderId);
|
||||
const ProfileStoreEntry* getInternalDefaultPSE()
|
||||
const Glib::ustring getPathFromId (int folderId) const;
|
||||
const ProfileStoreEntry* getInternalDefaultPSE() const
|
||||
{
|
||||
return internalDefaultEntry;
|
||||
}
|
||||
|
||||
const ProfileStoreEntry* getInternalDynamicPSE()
|
||||
const ProfileStoreEntry* getInternalDynamicPSE() const
|
||||
{
|
||||
return internalDynamicEntry;
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ void RawImageSource::rcd_demosaic(size_t chunkSize, bool measure)
|
||||
stop.reset(new StopWatch("rcd demosaic"));
|
||||
}
|
||||
|
||||
volatile double progress = 0.0;
|
||||
double progress = 0.0;
|
||||
|
||||
if (plistener) {
|
||||
plistener->setProgressStr(Glib::ustring::compose(M("TP_RAW_DMETHOD_PROGRESSBAR"), M("TP_RAW_RCD")));
|
||||
plistener->setProgress(0);
|
||||
plistener->setProgress(progress);
|
||||
}
|
||||
|
||||
constexpr int rcdBorder = 9;
|
||||
|
@ -39,9 +39,9 @@ const float d65_white[3] = { 0.950456, 1, 1.088754 };
|
||||
void RawImageSource::cielab (const float (*rgb)[3], float* l, float* a, float *b, const int width, const int height, const int labWidth, const float xyz_cam[3][3])
|
||||
{
|
||||
static LUTf cbrt(0x14000);
|
||||
static bool cbrtinit = false;
|
||||
|
||||
if (!rgb) {
|
||||
static bool cbrtinit = false;
|
||||
if(!cbrtinit) {
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < 0x14000; i++) {
|
||||
@ -291,8 +291,6 @@ void RawImageSource::xtrans_interpolate (const int passes, const bool useCieLab,
|
||||
#endif
|
||||
{
|
||||
int progressCounter = 0;
|
||||
int c;
|
||||
float color[3][6];
|
||||
|
||||
float *buffer = (float *) malloc ((ts * ts * (ndir * 4 + 3) + 128) * sizeof(float));
|
||||
float (*rgb)[ts][ts][3] = (float(*)[ts][ts][3]) buffer;
|
||||
@ -521,6 +519,7 @@ void RawImageSource::xtrans_interpolate (const int passes, const bool useCieLab,
|
||||
|
||||
/* Interpolate red and blue values for solitary green pixels: */
|
||||
int sgstartcol = (left - sgcol + 4) / 3 * 3 + sgcol;
|
||||
float color[3][6];
|
||||
|
||||
for (int row = (top - sgrow + 4) / 3 * 3 + sgrow; row < mrow - 2; row += 3) {
|
||||
for (int col = sgstartcol, h = fcol(row, col + 1); col < mcol - 2; col += 3, h ^= 2) {
|
||||
@ -564,7 +563,7 @@ void RawImageSource::xtrans_interpolate (const int passes, const bool useCieLab,
|
||||
}
|
||||
|
||||
int coloffset = (RightShift[row % 3] == 1 ? 3 : 1);
|
||||
c = (row - sgrow) % 3 ? ts : 1;
|
||||
int c = ((row - sgrow) % 3) ? ts : 1;
|
||||
int h = 3 * (c ^ ts ^ 1);
|
||||
|
||||
if(coloffset == 3) {
|
||||
@ -629,13 +628,13 @@ void RawImageSource::xtrans_interpolate (const int passes, const bool useCieLab,
|
||||
if (hex[d] + hex[d + 1]) {
|
||||
float g = 3 * rix[0][1] - 2 * rix[hex[d]][1] - rix[hex[d + 1]][1];
|
||||
|
||||
for (c = 0; c < 4; c += 2) {
|
||||
for (int c = 0; c < 4; c += 2) {
|
||||
rix[0][c] = CLIP((g + 2 * rix[hex[d]][c] + rix[hex[d + 1]][c]) * 0.33333333f);
|
||||
}
|
||||
} else {
|
||||
float g = 2 * rix[0][1] - rix[hex[d]][1] - rix[hex[d + 1]][1];
|
||||
|
||||
for (c = 0; c < 4; c += 2) {
|
||||
for (int c = 0; c < 4; c += 2) {
|
||||
rix[0][c] = CLIP((g + rix[hex[d]][c] + rix[hex[d + 1]][c]) * 0.5f);
|
||||
}
|
||||
}
|
||||
@ -656,10 +655,7 @@ void RawImageSource::xtrans_interpolate (const int passes, const bool useCieLab,
|
||||
// (presumably coming from original AHD) and converts taking
|
||||
// camera matrix into account. We use this in RT.
|
||||
for (int d = 0; d < ndir; d++) {
|
||||
float *l = &lab[0][0][0];
|
||||
float *a = &lab[1][0][0];
|
||||
float *b = &lab[2][0][0];
|
||||
cielab(&rgb[d][4][4], l, a, b, ts, mrow - 8, ts - 8, xyz_cam);
|
||||
cielab(&rgb[d][4][4], &lab[0][0][0], &lab[1][0][0], &lab[2][0][0], ts, mrow - 8, ts - 8, xyz_cam);
|
||||
int f = dir[d & 3];
|
||||
f = f == 1 ? 1 : f - 8;
|
||||
|
||||
|
@ -840,10 +840,10 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m)
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < mselected.size(); i++) {
|
||||
rtengine::procparams::ProcParams pp = mselected[i]->thumbnail->getProcParams();
|
||||
pp.raw.dark_frame = fc.get_filename();
|
||||
pp.raw.df_autoselect = false;
|
||||
mselected[i]->thumbnail->setProcParams(pp, nullptr, FILEBROWSER, false);
|
||||
rtengine::procparams::ProcParams lpp = mselected[i]->thumbnail->getProcParams();
|
||||
lpp.raw.dark_frame = fc.get_filename();
|
||||
lpp.raw.df_autoselect = false;
|
||||
mselected[i]->thumbnail->setProcParams(lpp, nullptr, FILEBROWSER, false);
|
||||
}
|
||||
|
||||
if (bppcl) {
|
||||
@ -916,10 +916,10 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m)
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < mselected.size(); i++) {
|
||||
rtengine::procparams::ProcParams pp = mselected[i]->thumbnail->getProcParams();
|
||||
pp.raw.ff_file = fc.get_filename();
|
||||
pp.raw.ff_AutoSelect = false;
|
||||
mselected[i]->thumbnail->setProcParams(pp, nullptr, FILEBROWSER, false);
|
||||
rtengine::procparams::ProcParams lpp = mselected[i]->thumbnail->getProcParams();
|
||||
lpp.raw.ff_file = fc.get_filename();
|
||||
lpp.raw.ff_AutoSelect = false;
|
||||
mselected[i]->thumbnail->setProcParams(lpp, nullptr, FILEBROWSER, false);
|
||||
}
|
||||
|
||||
if (bppcl) {
|
||||
@ -1079,17 +1079,17 @@ void FileBrowser::partPasteProfile ()
|
||||
bppcl->beginBatchPParamsChange(mselected.size());
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < mselected.size(); i++) {
|
||||
for (auto entry : mselected) {
|
||||
// copying read only clipboard PartialProfile to a temporary one, initialized to the thumb's ProcParams
|
||||
mselected[i]->thumbnail->createProcParamsForUpdate(false, false); // this can execute customprofilebuilder to generate param file
|
||||
entry->thumbnail->createProcParamsForUpdate(false, false); // this can execute customprofilebuilder to generate param file
|
||||
const rtengine::procparams::PartialProfile& cbPartProf = clipboard.getPartialProfile();
|
||||
rtengine::procparams::PartialProfile pastedPartProf(&mselected[i]->thumbnail->getProcParams (), nullptr);
|
||||
rtengine::procparams::PartialProfile pastedPartProf(&entry->thumbnail->getProcParams (), nullptr);
|
||||
|
||||
// pushing the selected values of the clipboard PartialProfile to the temporary PartialProfile
|
||||
partialPasteDlg.applyPaste (pastedPartProf.pparams, pastedPartProf.pedited, cbPartProf.pparams, cbPartProf.pedited);
|
||||
|
||||
// applying the temporary PartialProfile to the thumb's ProcParams
|
||||
mselected[i]->thumbnail->setProcParams (*pastedPartProf.pparams, pastedPartProf.pedited, FILEBROWSER);
|
||||
entry->thumbnail->setProcParams (*pastedPartProf.pparams, pastedPartProf.pedited, FILEBROWSER);
|
||||
pastedPartProf.deleteInstance();
|
||||
}
|
||||
|
||||
@ -1502,8 +1502,8 @@ bool FileBrowser::checkFilter (ThumbBrowserEntryBase* entryb) const // true ->
|
||||
std::transform(FileName.begin(), FileName.end(), FileName.begin(), ::toupper);
|
||||
int iFilenameMatch = 0;
|
||||
|
||||
for (const auto& entry : filter.vFilterStrings) {
|
||||
if (FileName.find(entry) != std::string::npos) {
|
||||
for (const auto& filter : filter.vFilterStrings) {
|
||||
if (FileName.find(filter) != std::string::npos) {
|
||||
++iFilenameMatch;
|
||||
break;
|
||||
}
|
||||
|
@ -422,9 +422,7 @@ bool Gradient::button1Pressed(int modifierKey)
|
||||
double diagonal = sqrt(double(imW) * double(imW) + double(imH) * double(imH));
|
||||
|
||||
// trick to get the correct angle (clockwise/counter-clockwise)
|
||||
int p = centerPos.y;
|
||||
centerPos.y = currPos.y;
|
||||
currPos.y = p;
|
||||
std::swap(centerPos.y, currPos.y);
|
||||
|
||||
draggedPoint = currPos - centerPos;
|
||||
// compute the projected value of the dragged point
|
||||
|
@ -952,38 +952,27 @@ bool MyScrolledWindow::on_scroll_event (GdkEventScroll* event)
|
||||
Gtk::Scrollbar *scroll = get_vscrollbar();
|
||||
|
||||
if (adjust && scroll) {
|
||||
double upper = adjust->get_upper();
|
||||
double lower = adjust->get_lower();
|
||||
const double upperBound = adjust->get_upper();
|
||||
const double lowerBound = adjust->get_lower();
|
||||
double value = adjust->get_value();
|
||||
double step = adjust->get_step_increment();
|
||||
double value2 = 0.;
|
||||
|
||||
// printf("MyScrolledwindow::on_scroll_event / delta_x=%.5f, delta_y=%.5f, direction=%d, type=%d, send_event=%d\n",
|
||||
// event->delta_x, event->delta_y, (int)event->direction, (int)event->type, event->send_event);
|
||||
|
||||
if (event->direction == GDK_SCROLL_DOWN) {
|
||||
value2 = value + step;
|
||||
|
||||
if (value2 > upper) {
|
||||
value2 = upper;
|
||||
}
|
||||
value2 = rtengine::min<double>(value + step, upperBound);
|
||||
|
||||
if (value2 != value) {
|
||||
scroll->set_value(value2);
|
||||
}
|
||||
} else if (event->direction == GDK_SCROLL_UP) {
|
||||
value2 = value - step;
|
||||
|
||||
if (value2 < lower) {
|
||||
value2 = lower;
|
||||
}
|
||||
value2 = rtengine::max<double>(value - step, lowerBound);
|
||||
|
||||
if (value2 != value) {
|
||||
scroll->set_value(value2);
|
||||
}
|
||||
} else if (event->direction == GDK_SCROLL_SMOOTH) {
|
||||
if (abs(event->delta_y) > 0.1) {
|
||||
value2 = rtengine::LIM<double>(value + (event->delta_y > 0 ? step : -step), lower, upper);
|
||||
value2 = rtengine::LIM<double>(value + (event->delta_y > 0 ? step : -step), lowerBound, upperBound);
|
||||
}
|
||||
if (value2 != value) {
|
||||
scroll->set_value(value2);
|
||||
@ -1032,8 +1021,8 @@ bool MyScrolledToolbar::on_scroll_event (GdkEventScroll* event)
|
||||
Gtk::Scrollbar *scroll = get_hscrollbar();
|
||||
|
||||
if (adjust && scroll) {
|
||||
double upper = adjust->get_upper();
|
||||
double lower = adjust->get_lower();
|
||||
const double upperBound = adjust->get_upper();
|
||||
const double lowerBound = adjust->get_lower();
|
||||
double value = adjust->get_value();
|
||||
double step = adjust->get_step_increment() * 2;
|
||||
double value2 = 0.;
|
||||
@ -1042,20 +1031,20 @@ bool MyScrolledToolbar::on_scroll_event (GdkEventScroll* event)
|
||||
// event->delta_x, event->delta_y, (int)event->direction, (int)event->type, event->send_event);
|
||||
|
||||
if (event->direction == GDK_SCROLL_DOWN) {
|
||||
value2 = rtengine::min<double>(value + step, upper);
|
||||
value2 = rtengine::min<double>(value + step, upperBound);
|
||||
if (value2 != value) {
|
||||
scroll->set_value(value2);
|
||||
}
|
||||
} else if (event->direction == GDK_SCROLL_UP) {
|
||||
value2 = rtengine::max<double>(value - step, lower);
|
||||
value2 = rtengine::max<double>(value - step, lowerBound);
|
||||
if (value2 != value) {
|
||||
scroll->set_value(value2);
|
||||
}
|
||||
} else if (event->direction == GDK_SCROLL_SMOOTH) {
|
||||
if (event->delta_x) { // if the user use a pad, it can scroll horizontally
|
||||
value2 = rtengine::LIM<double>(value + (event->delta_x > 0 ? 30 : -30), lower, upper);
|
||||
value2 = rtengine::LIM<double>(value + (event->delta_x > 0 ? 30 : -30), lowerBound, upperBound);
|
||||
} else if (event->delta_y) {
|
||||
value2 = rtengine::LIM<double>(value + (event->delta_y > 0 ? 30 : -30), lower, upper);
|
||||
value2 = rtengine::LIM<double>(value + (event->delta_y > 0 ? 30 : -30), lowerBound, upperBound);
|
||||
}
|
||||
if (value2 != value) {
|
||||
scroll->set_value(value2);
|
||||
|
@ -685,12 +685,9 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event)
|
||||
stopNumericalAdjustment();
|
||||
}
|
||||
}
|
||||
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
retval = true;
|
||||
}
|
||||
|
||||
|
@ -230,15 +230,15 @@ void PlacesBrowser::refreshPlacesList ()
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < options.favoriteDirs.size(); i++) {
|
||||
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (options.favoriteDirs[i]);
|
||||
Glib::RefPtr<Gio::File> fav = Gio::File::create_for_path (options.favoriteDirs[i]);
|
||||
|
||||
if (hfile && hfile->query_exists()) {
|
||||
if (fav && fav->query_exists()) {
|
||||
try {
|
||||
if (auto info = hfile->query_info ()) {
|
||||
if (auto info = fav->query_info ()) {
|
||||
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
||||
newrow[placesColumns.label] = info->get_display_name ();
|
||||
newrow[placesColumns.icon] = info->get_icon ();
|
||||
newrow[placesColumns.root] = hfile->get_parse_name ();
|
||||
newrow[placesColumns.root] = fav->get_parse_name ();
|
||||
newrow[placesColumns.type] = 5;
|
||||
newrow[placesColumns.rowSeparator] = false;
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ Glib::RefPtr<Gtk::CssProvider> fontcss;
|
||||
|
||||
Preferences::Preferences (RTWindow *rtwindow)
|
||||
: Gtk::Dialog (M ("MAIN_BUTTON_PREFERENCES"), *rtwindow, true)
|
||||
, regex(Glib::Regex::create (THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS))
|
||||
, splash (nullptr)
|
||||
, rprofiles (nullptr)
|
||||
, iprofiles (nullptr)
|
||||
@ -63,7 +64,6 @@ Preferences::Preferences (RTWindow *rtwindow)
|
||||
, newFont (false)
|
||||
, newCPFont (false)
|
||||
{
|
||||
regex = Glib::Regex::create (THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS);
|
||||
|
||||
moptions.copyFrom (&options);
|
||||
|
||||
|
@ -37,23 +37,22 @@ ProfileStoreComboBox::ProfileStoreComboBox ()
|
||||
setPreferredWidth (50, 120);
|
||||
}
|
||||
|
||||
Glib::ustring ProfileStoreComboBox::getCurrentLabel()
|
||||
Glib::ustring ProfileStoreComboBox::getCurrentLabel() const
|
||||
{
|
||||
Glib::ustring currLabel;
|
||||
Gtk::TreeModel::iterator currRow = get_active();
|
||||
const Gtk::TreeModel::const_iterator currRow = get_active();
|
||||
|
||||
if (currRow) {
|
||||
const ProfileStoreEntry *currEntry = (*currRow)[methodColumns.profileStoreEntry];
|
||||
return currEntry->label;
|
||||
}
|
||||
|
||||
return currLabel;
|
||||
return {};
|
||||
}
|
||||
|
||||
const ProfileStoreEntry* ProfileStoreComboBox::getSelectedEntry()
|
||||
const ProfileStoreEntry* ProfileStoreComboBox::getSelectedEntry() const
|
||||
{
|
||||
Gtk::TreeModel::iterator currRow_ = get_active();
|
||||
Gtk::TreeModel::Row currRow = *currRow_;
|
||||
const Gtk::TreeModel::const_iterator currRow_ = get_active();
|
||||
const Gtk::TreeModel::Row currRow = *currRow_;
|
||||
|
||||
if (currRow) {
|
||||
return currRow[methodColumns.profileStoreEntry];
|
||||
@ -145,18 +144,16 @@ void ProfileStoreComboBox::updateProfileList ()
|
||||
cellRenderer->property_ellipsize_set() = true;
|
||||
}
|
||||
|
||||
Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry_ (Gtk::TreeModel::Children childs, const ProfileStoreEntry *pse)
|
||||
Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry_ (Gtk::TreeModel::Children childs, const ProfileStoreEntry *pse) const
|
||||
{
|
||||
Gtk::TreeModel::Row row;
|
||||
Gtk::TreeIter rowInSubLevel;
|
||||
|
||||
for (Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
|
||||
row = *iter;
|
||||
for (const auto& iter : childs) {
|
||||
const Gtk::TreeModel::Row row = *iter;
|
||||
// Hombre: is there a smarter way of knowing if this row has childs?
|
||||
const ProfileStoreEntry *pse_ = row[methodColumns.profileStoreEntry];
|
||||
|
||||
if (pse_->type == PSET_FOLDER) {
|
||||
rowInSubLevel = findRowFromEntry_ (iter->children(), pse);
|
||||
const Gtk::TreeIter rowInSubLevel = findRowFromEntry_ (iter->children(), pse);
|
||||
|
||||
if (rowInSubLevel) {
|
||||
// entry found
|
||||
@ -171,30 +168,27 @@ Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry_ (Gtk::TreeModel::Children
|
||||
return childs.end();
|
||||
}
|
||||
|
||||
Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry (const ProfileStoreEntry *pse)
|
||||
Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry (const ProfileStoreEntry *pse) const
|
||||
{
|
||||
Gtk::TreeModel::Children childs = refTreeModel->children();
|
||||
|
||||
if (pse) {
|
||||
Gtk::TreeIter row = findRowFromEntry_ (childs, pse);
|
||||
return row;
|
||||
return findRowFromEntry_ (childs, pse);
|
||||
}
|
||||
|
||||
return childs.end();
|
||||
}
|
||||
|
||||
Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath_ (Gtk::TreeModel::Children childs, int parentFolderId, Glib::ustring &name)
|
||||
Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath_ (Gtk::TreeModel::Children childs, int parentFolderId, const Glib::ustring &name) const
|
||||
{
|
||||
Gtk::TreeModel::Row row;
|
||||
Gtk::TreeIter rowInSubLevel;
|
||||
|
||||
for (Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
|
||||
row = *iter;
|
||||
for (const auto iter : childs) {
|
||||
const Gtk::TreeModel::Row row = *iter;
|
||||
// Hombre: is there a smarter way of knowing if this row has childs?
|
||||
const ProfileStoreEntry *pse = row[methodColumns.profileStoreEntry];
|
||||
|
||||
if (pse->type == PSET_FOLDER) {
|
||||
rowInSubLevel = findRowFromFullPath_ (iter->children(), parentFolderId, name);
|
||||
const Gtk::TreeIter rowInSubLevel = findRowFromFullPath_ (iter->children(), parentFolderId, name);
|
||||
|
||||
if (rowInSubLevel) {
|
||||
// entry found
|
||||
@ -209,88 +203,77 @@ Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath_ (Gtk::TreeModel::Childr
|
||||
return childs.end();
|
||||
}
|
||||
|
||||
Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath (Glib::ustring path)
|
||||
Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath (const Glib::ustring &path) const
|
||||
{
|
||||
Gtk::TreeIter row;
|
||||
ProfileStore *profileStore = ProfileStore::getInstance();
|
||||
|
||||
if (path.empty()) {
|
||||
return row;
|
||||
return {};
|
||||
}
|
||||
|
||||
const ProfileStore *profileStore = ProfileStore::getInstance();
|
||||
|
||||
if (path == DEFPROFILE_INTERNAL) {
|
||||
row = findRowFromEntry (profileStore->getInternalDefaultPSE());
|
||||
return row;
|
||||
return findRowFromEntry (profileStore->getInternalDefaultPSE());
|
||||
}
|
||||
|
||||
if (path == DEFPROFILE_DYNAMIC) {
|
||||
row = findRowFromEntry (profileStore->getInternalDynamicPSE());
|
||||
return row;
|
||||
return findRowFromEntry (profileStore->getInternalDynamicPSE());
|
||||
}
|
||||
|
||||
// removing the filename
|
||||
Glib::ustring fName = Glib::path_get_basename (path);
|
||||
const Glib::ustring fName = Glib::path_get_basename(path);
|
||||
|
||||
if (!fName.empty()) {
|
||||
path = path.substr (0, path.length() - fName.length());
|
||||
} else {
|
||||
// path is malformed;
|
||||
return row;
|
||||
int parentFolderId = profileStore->findFolderId (Glib::path_get_dirname (path.substr (0, path.length() - fName.length())));
|
||||
// 1. find the path in the folder list
|
||||
if (parentFolderId != -1) {
|
||||
return findRowFromFullPath_ (refTreeModel->children(), parentFolderId, fName);
|
||||
}
|
||||
}
|
||||
|
||||
path = Glib::path_get_dirname (path);
|
||||
int parentFolderId = profileStore->findFolderId (path);
|
||||
|
||||
// 1. find the path in the folder list
|
||||
if (parentFolderId != -1) {
|
||||
row = findRowFromFullPath_ (refTreeModel->children(), parentFolderId, fName);
|
||||
}
|
||||
|
||||
return row;
|
||||
return {};
|
||||
}
|
||||
|
||||
/** @brief Get the absolute full path of the active row entry.
|
||||
* @return The absolute full path of the active row entry, or the "Internal" keyword,
|
||||
* or an empty string if the ComboBox is in an invalid state
|
||||
*/
|
||||
Glib::ustring ProfileStoreComboBox::getFullPathFromActiveRow()
|
||||
Glib::ustring ProfileStoreComboBox::getFullPathFromActiveRow() const
|
||||
{
|
||||
Glib::ustring path;
|
||||
Gtk::TreeModel::iterator currRowI = get_active();
|
||||
ProfileStore *profileStore = ProfileStore::getInstance();
|
||||
const Gtk::TreeModel::const_iterator currRowI = get_active();
|
||||
|
||||
if (!currRowI) {
|
||||
return path;
|
||||
return {};
|
||||
}
|
||||
|
||||
Gtk::TreeModel::Row currRow = *currRowI;
|
||||
|
||||
if (currRow) {
|
||||
|
||||
const ProfileStoreEntry *currEntry = currRow[methodColumns.profileStoreEntry];
|
||||
|
||||
if (!currEntry) {
|
||||
return path;
|
||||
return {};
|
||||
}
|
||||
|
||||
const ProfileStore *profileStore = ProfileStore::getInstance();
|
||||
if (currEntry == profileStore->getInternalDefaultPSE()) {
|
||||
return Glib::ustring (DEFPROFILE_INTERNAL);
|
||||
return DEFPROFILE_INTERNAL;
|
||||
}
|
||||
|
||||
if (currEntry == profileStore->getInternalDynamicPSE()) {
|
||||
return Glib::ustring (DEFPROFILE_DYNAMIC);
|
||||
return DEFPROFILE_DYNAMIC;
|
||||
}
|
||||
|
||||
path = Glib::build_filename (profileStore->getPathFromId (currEntry->parentFolderId), currEntry->label);
|
||||
return Glib::build_filename (profileStore->getPathFromId (currEntry->parentFolderId), currEntry->label);
|
||||
}
|
||||
|
||||
return path;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool ProfileStoreComboBox::setActiveRowFromFullPath (Glib::ustring path)
|
||||
bool ProfileStoreComboBox::setActiveRowFromFullPath (const Glib::ustring &path)
|
||||
{
|
||||
if (!path.empty()) {
|
||||
Gtk::TreeIter row = findRowFromFullPath (path);
|
||||
const Gtk::TreeIter row = findRowFromFullPath (path);
|
||||
|
||||
if (row) {
|
||||
set_active (row);
|
||||
@ -304,7 +287,7 @@ bool ProfileStoreComboBox::setActiveRowFromFullPath (Glib::ustring path)
|
||||
bool ProfileStoreComboBox::setActiveRowFromEntry (const ProfileStoreEntry *pse)
|
||||
{
|
||||
if (pse) {
|
||||
Gtk::TreeIter row = findRowFromEntry (pse);
|
||||
const Gtk::TreeIter row = findRowFromEntry (pse);
|
||||
|
||||
if (row) {
|
||||
set_active (row);
|
||||
@ -321,20 +304,17 @@ bool ProfileStoreComboBox::setInternalEntry ()
|
||||
}
|
||||
|
||||
/** @brief Get the row from the first level of the tree that match the provided name */
|
||||
Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel (Glib::ustring name)
|
||||
Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel (const Glib::ustring &name) const
|
||||
{
|
||||
Gtk::TreeIter row;
|
||||
Gtk::TreeModel::Children childs = refTreeModel->children();
|
||||
const Gtk::TreeModel::Children childs = refTreeModel->children();
|
||||
|
||||
if (!name.empty()) {
|
||||
Gtk::TreeModel::Row currRow;
|
||||
|
||||
for (Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
|
||||
currRow = *iter;
|
||||
for (const auto iter : childs) {
|
||||
const Gtk::TreeModel::Row currRow = *iter;
|
||||
const ProfileStoreEntry *pse = currRow[methodColumns.profileStoreEntry];
|
||||
|
||||
if (pse->label == name) {
|
||||
return currRow;
|
||||
return std::move(currRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <glibmm.h>
|
||||
|
||||
#include "../rtengine/rtengine.h"
|
||||
#include "../rtengine/noncopyable.h"
|
||||
#include "../rtengine/profilestore.h"
|
||||
|
||||
#include "threadutils.h"
|
||||
@ -35,7 +34,7 @@
|
||||
/**
|
||||
* @brief subclass of Gtk::Label with extra fields for Combobox and Menu, to link with a ProfileStoreEntry
|
||||
*/
|
||||
class ProfileStoreLabel : public Gtk::Label
|
||||
class ProfileStoreLabel final : public Gtk::Label
|
||||
{
|
||||
|
||||
public:
|
||||
@ -44,7 +43,7 @@ public:
|
||||
#ifndef NDEBUG
|
||||
ProfileStoreLabel() : Gtk::Label ("*** error ***"), entry (nullptr) {}
|
||||
#else
|
||||
ProfileStoreLabel() : Gtk::Label (""), entry (NULL) {}
|
||||
ProfileStoreLabel() : Gtk::Label (""), entry (nullptr) {}
|
||||
#endif
|
||||
|
||||
/** @brief Create a new ProfileStoreLabel
|
||||
@ -55,11 +54,11 @@ public:
|
||||
ProfileStoreLabel (const ProfileStoreLabel &other);
|
||||
};
|
||||
|
||||
class ProfileStoreComboBox : public MyComboBox
|
||||
class ProfileStoreComboBox final : public MyComboBox
|
||||
{
|
||||
|
||||
protected:
|
||||
class MethodColumns : public Gtk::TreeModel::ColumnRecord
|
||||
private:
|
||||
class MethodColumns final : public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
public:
|
||||
Gtk::TreeModelColumn<Glib::ustring> label;
|
||||
@ -74,21 +73,22 @@ protected:
|
||||
Glib::RefPtr<Gtk::TreeStore> refTreeModel;
|
||||
MethodColumns methodColumns;
|
||||
void refreshProfileList_ (Gtk::TreeModel::Row *parentRow, int parentFolderId, bool initial, const std::vector<const ProfileStoreEntry*> *entryList);
|
||||
Gtk::TreeIter findRowFromEntry_ (Gtk::TreeModel::Children childs, const ProfileStoreEntry *pse);
|
||||
Gtk::TreeIter findRowFromFullPath_ (Gtk::TreeModel::Children childs, int parentFolderId, Glib::ustring &name);
|
||||
Gtk::TreeIter findRowFromEntry_ (Gtk::TreeModel::Children childs, const ProfileStoreEntry *pse) const;
|
||||
Gtk::TreeIter findRowFromFullPath_ (Gtk::TreeModel::Children childs, int parentFolderId, const Glib::ustring &name) const;
|
||||
Gtk::TreeIter findRowFromEntry (const ProfileStoreEntry *pse) const;
|
||||
Gtk::TreeIter findRowFromFullPath (const Glib::ustring &path) const;
|
||||
|
||||
|
||||
public:
|
||||
ProfileStoreComboBox();
|
||||
void updateProfileList();
|
||||
Glib::ustring getCurrentLabel();
|
||||
const ProfileStoreEntry* getSelectedEntry();
|
||||
Gtk::TreeIter findRowFromEntry (const ProfileStoreEntry *pse);
|
||||
Gtk::TreeIter findRowFromFullPath (Glib::ustring path);
|
||||
Glib::ustring getFullPathFromActiveRow ();
|
||||
bool setActiveRowFromFullPath (Glib::ustring oldPath);
|
||||
Glib::ustring getCurrentLabel() const;
|
||||
const ProfileStoreEntry* getSelectedEntry() const;
|
||||
Glib::ustring getFullPathFromActiveRow () const;
|
||||
bool setActiveRowFromFullPath (const Glib::ustring &oldPath);
|
||||
bool setActiveRowFromEntry (const ProfileStoreEntry *pse);
|
||||
bool setInternalEntry ();
|
||||
Gtk::TreeIter getRowFromLabel (Glib::ustring name);
|
||||
Gtk::TreeIter getRowFromLabel (const Glib::ustring &name) const;
|
||||
Gtk::TreeIter addRow (const ProfileStoreEntry *profileStoreEntry);
|
||||
void deleteRow (const ProfileStoreEntry *profileStoreEntry);
|
||||
};
|
||||
|
@ -23,7 +23,7 @@
|
||||
using namespace rtengine;
|
||||
using namespace rtengine::procparams;
|
||||
|
||||
RGBCurves::RGBCurves () : FoldableToolPanel(this, "rgbcurves", M("TP_RGBCURVES_LABEL"), false, true)
|
||||
RGBCurves::RGBCurves () : FoldableToolPanel(this, "rgbcurves", M("TP_RGBCURVES_LABEL"), false, true), lastLumamode(false)
|
||||
{
|
||||
|
||||
lumamode = Gtk::manage (new Gtk::CheckButton (M("TP_RGBCURVES_LUMAMODE")));
|
||||
|
@ -39,8 +39,6 @@ RTImage::RTImage () {}
|
||||
|
||||
RTImage::RTImage (RTImage &other) : surface(other.surface), pixbuf(other.pixbuf)
|
||||
{
|
||||
dpiBack = other.dpiBack;
|
||||
scaleBack = other.scaleBack;
|
||||
if (pixbuf) {
|
||||
set(pixbuf);
|
||||
} else if (surface) {
|
||||
|
@ -220,7 +220,7 @@ Cairo::RefPtr<Cairo::ImageSurface> RTScalable::loadImage(const Glib::ustring &fn
|
||||
GError **error = nullptr;
|
||||
RsvgHandle *handle = rsvg_handle_new_from_data((unsigned const char*)updatedSVG.c_str(), updatedSVG.length(), error);
|
||||
|
||||
if (handle == nullptr) {
|
||||
if (error && !handle) {
|
||||
std::cerr << "ERROR: Can't use the provided data for \"" << fname << "\" to create a RsvgHandle:" << std::endl
|
||||
<< Glib::ustring((*error)->message) << std::endl;
|
||||
Cairo::RefPtr<Cairo::ImageSurface> surf = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24, 10, 10);
|
||||
|
@ -225,21 +225,21 @@ void ThumbBrowserBase::selectSet (ThumbBrowserEntryBase* clicked)
|
||||
|
||||
static void scrollToEntry (double& h, double& v, int iw, int ih, ThumbBrowserEntryBase* entry)
|
||||
{
|
||||
const int hmin = entry->getX ();
|
||||
const int hmax = hmin + entry->getEffectiveWidth () - iw;
|
||||
const int vmin = entry->getY ();
|
||||
const int vmax = vmin + entry->getEffectiveHeight () - ih;
|
||||
const int hMin = entry->getX();
|
||||
const int hMax = hMin + entry->getEffectiveWidth() - iw;
|
||||
const int vMin = entry->getY();
|
||||
const int vMax = vMin + entry->getEffectiveHeight() - ih;
|
||||
|
||||
if (hmin < 0) {
|
||||
h += hmin;
|
||||
} else if (hmax > 0) {
|
||||
h += hmax;
|
||||
if (hMin < 0) {
|
||||
h += hMin;
|
||||
} else if (hMax > 0) {
|
||||
h += hMax;
|
||||
}
|
||||
|
||||
if(vmin < 0) {
|
||||
v += vmin;
|
||||
} else if (vmax > 0) {
|
||||
v += vmax;
|
||||
if (vMin < 0) {
|
||||
v += vMin;
|
||||
} else if (vMax > 0) {
|
||||
v += vMax;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user