From 44ac689d114bb02cb506ddf001444b46b3db5531 Mon Sep 17 00:00:00 2001 From: gabor Date: Fri, 28 May 2010 16:19:56 +0200 Subject: [PATCH] Perspective correction implemented --- rtdata/CMakeLists.txt | 2 +- rtdata/languages/English (UK) | 13 +- rtdata/languages/English (US) | 15 +- rtdata/profiles/{crisp.pp2 => crisp.pp3} | 0 rtdata/profiles/{default.pp2 => default.pp3} | 0 rtdata/profiles/{neutral.pp2 => neutral.pp3} | 0 rtengine/iptransform.cc | 107 +++++++-- rtengine/procevents.h | 229 ++++++++++--------- rtengine/procparams.cc | 42 +++- rtengine/procparams.h | 25 +- rtengine/refreshmap.cc | 169 +++++++------- rtengine/refreshmap.h | 2 - rtgui/CMakeLists.txt | 4 +- rtgui/addsetids.h | 4 +- rtgui/batchtoolpanelcoord.cc | 8 +- rtgui/cacorrection.cc | 14 +- rtgui/cacorrection.h | 4 +- rtgui/lensgeom.cc | 104 +++++++++ rtgui/lensgeom.h | 51 +++++ rtgui/lensgeomlistener.h | 29 +++ rtgui/options.cc | 2 +- rtgui/paramsedited.cc | 67 +++--- rtgui/paramsedited.h | 19 +- rtgui/perspective.cc | 100 ++++++++ rtgui/perspective.h | 46 ++++ rtgui/preferences.cc | 7 +- rtgui/rotate.cc | 53 +---- rtgui/rotate.h | 18 +- rtgui/toolpanelcoord.cc | 15 +- rtgui/toolpanelcoord.h | 8 +- 30 files changed, 796 insertions(+), 361 deletions(-) rename rtdata/profiles/{crisp.pp2 => crisp.pp3} (100%) rename rtdata/profiles/{default.pp2 => default.pp3} (100%) rename rtdata/profiles/{neutral.pp2 => neutral.pp3} (100%) create mode 100644 rtgui/lensgeom.cc create mode 100644 rtgui/lensgeom.h create mode 100644 rtgui/lensgeomlistener.h create mode 100644 rtgui/perspective.cc create mode 100644 rtgui/perspective.h diff --git a/rtdata/CMakeLists.txt b/rtdata/CMakeLists.txt index 023388934..96b4cec51 100644 --- a/rtdata/CMakeLists.txt +++ b/rtdata/CMakeLists.txt @@ -1,6 +1,6 @@ file (GLOB IMAGEFILES "images/*.png") -file (GLOB PROFILEFILES "profiles/*.pp2") +file (GLOB PROFILEFILES "profiles/*.pp3") file (GLOB LANGUAGEFILES "languages/*") # THEMEDIR includes subfolders for image resources for some themes; doing the normal glob won't work. set (THEMEDIR "themes") diff --git a/rtdata/languages/English (UK) b/rtdata/languages/English (UK) index d5ea6a723..d992de66b 100644 --- a/rtdata/languages/English (UK) +++ b/rtdata/languages/English (UK) @@ -180,7 +180,7 @@ HISTORY_MSG_58;Horizontal Flipping HISTORY_MSG_59;Vertical Flipping HISTORY_MSG_5;Brightness HISTORY_MSG_60;Rotation -HISTORY_MSG_61;Rotation +HISTORY_MSG_61;Auto Fill HISTORY_MSG_62;Lens Distortion Correction HISTORY_MSG_63;Snapshot Selected HISTORY_MSG_64;Crop Photo @@ -203,6 +203,9 @@ HISTORY_MSG_79;Resize width HISTORY_MSG_7;Black HISTORY_MSG_80;Resize height HISTORY_MSG_81;Resize enabled +HISTORY_MSG_82;Profile Changed +HISTORY_MSG_83;High quality shadows/highlights +HISTORY_MSG_84;Perspective correction HISTORY_MSG_8;Exposure Compensation HISTORY_MSG_9;Highlight Compression HISTORY_NEWSNAPSHOT;Add @@ -543,6 +546,9 @@ TP_ICM_OUTPUTDLGLABEL;Select Output ICC Profile... TP_ICM_OUTPUTPROFILE;Output Profile TP_ICM_SAVEREFERENCE;Save reference image for profiling TP_ICM_WORKINGPROFILE;Working Profile +TP_LENSGEOM_AUTOCROP;Auto Crop +TP_LENSGEOM_FILL;Auto Fill +TP_LENSGEOM_LABEL;Lens / Geometry TP_LUMACURVE_BLACKLEVEL;Black TP_LUMACURVE_BRIGHTNESS;Brightness TP_LUMACURVE_COMPRHIGHLIGHTS;Highlight compression @@ -553,6 +559,9 @@ TP_LUMACURVE_LABEL;Luminance Curve TP_LUMADENOISE_EDGETOLERANCE;Edge Tolerance TP_LUMADENOISE_LABEL;Luminance Noise Reduction TP_LUMADENOISE_RADIUS;Radius +TP_PERSPECTIVE_LABEL;Perspective +TP_PERSPECTIVE_HORIZONTAL;Horizontal +TP_PERSPECTIVE_VERTICAL;Vertical TP_RESIZE_BICUBIC;Bicubic TP_RESIZE_BICUBICSF;Bicubic (Softer) TP_RESIZE_BICUBICSH;Bicubic (Sharper) @@ -564,9 +573,7 @@ TP_RESIZE_METHOD;Method: TP_RESIZE_NEAREST;Nearest TP_RESIZE_SCALE;Scale TP_RESIZE_W;W: -TP_ROTATE_AUTOCROP;Auto Crop TP_ROTATE_DEGREE;Degree -TP_ROTATE_FILL;Fill TP_ROTATE_LABEL;Rotate TP_ROTATE_SELECTLINE; Select Straight Line TP_SHADOWSHLIGHTS_HIGHLIGHTS;Highlights diff --git a/rtdata/languages/English (US) b/rtdata/languages/English (US) index a4df8a322..b87063e3e 100644 --- a/rtdata/languages/English (US) +++ b/rtdata/languages/English (US) @@ -180,7 +180,7 @@ HISTORY_MSG_58;Horizontal Flipping HISTORY_MSG_59;Vertical Flipping HISTORY_MSG_5;Brightness HISTORY_MSG_60;Rotation -HISTORY_MSG_61;Rotation +HISTORY_MSG_61;Auto Fill HISTORY_MSG_62;Lens Distortion Correction HISTORY_MSG_63;Snapshot Selected HISTORY_MSG_64;Crop Photo @@ -203,6 +203,9 @@ HISTORY_MSG_79;Resize width HISTORY_MSG_7;Black HISTORY_MSG_80;Resize height HISTORY_MSG_81;Resize enabled +HISTORY_MSG_82;Profile Changed +HISTORY_MSG_83;High quality shadows/highlights +HISTORY_MSG_84;Perspective correction HISTORY_MSG_8;Exposure Compensation HISTORY_MSG_9;Highlight Compression HISTORY_NEWSNAPSHOT;Add @@ -544,7 +547,10 @@ TP_ICM_NOICM;No ICM: sRGB output TP_ICM_OUTPUTDLGLABEL;Select Output ICC Profile... TP_ICM_OUTPUTPROFILE;Output Profile TP_ICM_SAVEREFERENCE;Save reference image for profiling -TP_ICM_WORKINGPROFILE;Working Profile +TP_ICM_WORKINGPROFILE;Working Profile +TP_LENSGEOM_AUTOCROP;Auto Crop +TP_LENSGEOM_FILL;Auto Fill +TP_LENSGEOM_LABEL;Lens / Geometry TP_LUMACURVE_BLACKLEVEL;Black TP_LUMACURVE_BRIGHTNESS;Brightness TP_LUMACURVE_COMPRHIGHLIGHTS;Highlight compression @@ -555,6 +561,9 @@ TP_LUMACURVE_LABEL;Luminance Curve TP_LUMADENOISE_EDGETOLERANCE;Edge Tolerance TP_LUMADENOISE_LABEL;Luminance Noise Reduction TP_LUMADENOISE_RADIUS;Radius +TP_PERSPECTIVE_LABEL;Perspective +TP_PERSPECTIVE_HORIZONTAL;Horizontal +TP_PERSPECTIVE_VERTICAL;Vertical TP_RESIZE_BICUBIC;Bicubic TP_RESIZE_BICUBICSF;Bicubic (Softer) TP_RESIZE_BICUBICSH;Bicubic (Sharper) @@ -568,9 +577,7 @@ TP_RESIZE_METHOD;Method: TP_RESIZE_NEAREST;Nearest TP_RESIZE_SCALE;Scale TP_RESIZE_W;W: -TP_ROTATE_AUTOCROP;Auto Crop TP_ROTATE_DEGREE;Degree -TP_ROTATE_FILL;Fill TP_ROTATE_LABEL;Rotate TP_ROTATE_SELECTLINE; Select Straight Line TP_SHADOWSHLIGHTS_HIGHLIGHTS;Highlights diff --git a/rtdata/profiles/crisp.pp2 b/rtdata/profiles/crisp.pp3 similarity index 100% rename from rtdata/profiles/crisp.pp2 rename to rtdata/profiles/crisp.pp3 diff --git a/rtdata/profiles/default.pp2 b/rtdata/profiles/default.pp3 similarity index 100% rename from rtdata/profiles/default.pp2 rename to rtdata/profiles/default.pp3 diff --git a/rtdata/profiles/neutral.pp2 b/rtdata/profiles/neutral.pp3 similarity index 100% rename from rtdata/profiles/neutral.pp2 rename to rtdata/profiles/neutral.pp3 diff --git a/rtengine/iptransform.cc b/rtengine/iptransform.cc index a76f02e84..331f839aa 100644 --- a/rtengine/iptransform.cc +++ b/rtengine/iptransform.cc @@ -76,19 +76,34 @@ bool ImProcFunctions::transCoord (int W, int H, std::vector &src, std:: double oW = W*params->resize.scale; double oH = H*params->resize.scale; - double w2 = (double) oW / 2.0 - 0.5; - double h2 = (double) oH / 2.0 - 0.5; + double w2 = (double) oW / 2.0 - 0.5; + double h2 = (double) oH / 2.0 - 0.5; double a = params->distortion.amount; double cost = cos(params->rotate.degree * 3.14/180.0); double sint = sin(params->rotate.degree * 3.14/180.0); double maxRadius = sqrt( (double)( oW*oW + oH*oH ) ) / 2; - double ascale = ascaleDef>0 ? ascaleDef : (params->rotate.fill ? getTransformAutoFill (oW, oH) : 1.0); + double vpdeg = params->perspective.vertical / 100.0 * 45.0; + double vpalpha = (90.0 - vpdeg) / 180.0 * 3.14; + double vpteta = fabs(vpalpha-3.14/2)<1e-3 ? 0.0 : acos ((vpdeg>0 ? 1.0 : -1.0) * sqrt((-oW*oW*tan(vpalpha)*tan(vpalpha) + (vpdeg>0 ? 1.0 : -1.0) * oW*tan(vpalpha)*sqrt(16*maxRadius*maxRadius+oW*oW*tan(vpalpha)*tan(vpalpha)))/(maxRadius*maxRadius*8))); + double vpcospt = (vpdeg>=0 ? 1.0 : -1.0) * cos (vpteta), vptanpt = tan (vpteta); + double hpdeg = params->perspective.horizontal / 100.0 * 45.0; + double hpalpha = (90.0 - hpdeg) / 180.0 * 3.14; + double hpteta = fabs(hpalpha-3.14/2)<1e-3 ? 0.0 : acos ((hpdeg>0 ? 1.0 : -1.0) * sqrt((-oH*oH*tan(hpalpha)*tan(hpalpha) + (hpdeg>0 ? 1.0 : -1.0) * oH*tan(hpalpha)*sqrt(16*maxRadius*maxRadius+oH*oH*tan(hpalpha)*tan(hpalpha)))/(maxRadius*maxRadius*8))); + double hpcospt = (hpdeg>=0 ? 1.0 : -1.0) * cos (hpteta), hptanpt = tan (hpteta); + + double ascale = ascaleDef>0 ? ascaleDef : (params->commonTrans.autofill ? getTransformAutoFill (oW, oH) : 1.0); for (int i=0; ivignetting.amount != 0; - double ascale = params->rotate.fill ? getTransformAutoFill (oW, oH) : 1.0; + // auxiliary variables for vertical perspective correction + double vpdeg = params->perspective.vertical / 100.0 * 45.0; + double vpalpha = (90.0 - vpdeg) / 180.0 * 3.14; + double vpteta = fabs(vpalpha-3.14/2)<1e-3 ? 0.0 : acos ((vpdeg>0 ? 1.0 : -1.0) * sqrt((-oW*oW*tan(vpalpha)*tan(vpalpha) + (vpdeg>0 ? 1.0 : -1.0) * oW*tan(vpalpha)*sqrt(16*maxRadius*maxRadius+oW*oW*tan(vpalpha)*tan(vpalpha)))/(maxRadius*maxRadius*8))); + double vpcospt = (vpdeg>=0 ? 1.0 : -1.0) * cos (vpteta), vptanpt = tan (vpteta); + + // auxiliary variables for horizontal perspective correction + double hpdeg = params->perspective.horizontal / 100.0 * 45.0; + double hpalpha = (90.0 - hpdeg) / 180.0 * 3.14; + double hpteta = fabs(hpalpha-3.14/2)<1e-3 ? 0.0 : acos ((hpdeg>0 ? 1.0 : -1.0) * sqrt((-oH*oH*tan(hpalpha)*tan(hpalpha) + (hpdeg>0 ? 1.0 : -1.0) * oH*tan(hpalpha)*sqrt(16*maxRadius*maxRadius+oH*oH*tan(hpalpha)*tan(hpalpha)))/(maxRadius*maxRadius*8))); + double hpcospt = (hpdeg>=0 ? 1.0 : -1.0) * cos (hpteta), hptanpt = tan (hpteta); + + double ascale = params->commonTrans.autofill ? getTransformAutoFill (oW, oH) : 1.0; // main cycle #pragma omp parallel for if (multiThread) for (int y=0; yheight; y++) { - double y_d = ascale * (y + cy - h2); // centering y coord & scale for (int x=0; xwidth; x++) { double x_d = ascale * (x + cx - w2); // centering x coord & scale + double y_d = ascale * (y + cy - h2); // centering y coord & scale + + // horizontal perspective transformation + y_d = y_d * maxRadius / (maxRadius + x_d*hptanpt); + x_d = x_d * maxRadius * hpcospt / (maxRadius + x_d*hptanpt); + + // vertical perspective transformation + x_d = x_d * maxRadius / (maxRadius - y_d*vptanpt); + y_d = y_d * maxRadius * vpcospt / (maxRadius - y_d*vptanpt); // rotate double Dx = x_d * cost - y_d * sint; @@ -354,16 +385,36 @@ void ImProcFunctions::transformSep (Image16* original, Image16* transformed, int double mul = (1.0-v) / tanh(b); bool dovign = params->vignetting.amount != 0; - double ascale = params->rotate.fill ? getTransformAutoFill (oW, oH) : 1.0; + // auxiliary variables for vertical perspective correction + double vpdeg = params->perspective.vertical / 100.0 * 45.0; + double vpalpha = (90.0 - vpdeg) / 180.0 * 3.14; + double vpteta = fabs(vpalpha-3.14/2)<1e-3 ? 0.0 : acos ((vpdeg>0 ? 1.0 : -1.0) * sqrt((-oW*oW*tan(vpalpha)*tan(vpalpha) + (vpdeg>0 ? 1.0 : -1.0) * oW*tan(vpalpha)*sqrt(16*maxRadius*maxRadius+oW*oW*tan(vpalpha)*tan(vpalpha)))/(maxRadius*maxRadius*8))); + double vpcospt = (vpdeg>=0 ? 1.0 : -1.0) * cos (vpteta), vptanpt = tan (vpteta); + + // auxiliary variables for horizontal perspective correction + double hpdeg = params->perspective.horizontal / 100.0 * 45.0; + double hpalpha = (90.0 - hpdeg) / 180.0 * 3.14; + double hpteta = fabs(hpalpha-3.14/2)<1e-3 ? 0.0 : acos ((hpdeg>0 ? 1.0 : -1.0) * sqrt((-oH*oH*tan(hpalpha)*tan(hpalpha) + (hpdeg>0 ? 1.0 : -1.0) * oH*tan(hpalpha)*sqrt(16*maxRadius*maxRadius+oH*oH*tan(hpalpha)*tan(hpalpha)))/(maxRadius*maxRadius*8))); + double hpcospt = (hpdeg>=0 ? 1.0 : -1.0) * cos (hpteta), hptanpt = tan (hpteta); + + double ascale = params->commonTrans.autofill ? getTransformAutoFill (oW, oH) : 1.0; // main cycle #pragma omp parallel for if (multiThread) for (int y=0; yheight; y++) { - double y_d = ascale * (y + cy - h2); // centering y coord & scale for (int x=0; xwidth; x++) { double x_d = ascale * (x + cx - w2); // centering x coord & scale + double y_d = ascale * (y + cy - h2); // centering y coord & scale - // rotate + // horizontal perspective transformation + y_d = y_d * maxRadius / (maxRadius + x_d*hptanpt); + x_d = x_d * maxRadius * hpcospt / (maxRadius + x_d*hptanpt); + + // vertical perspective transformation + x_d = x_d * maxRadius / (maxRadius - y_d*vptanpt); + y_d = y_d * maxRadius * vpcospt / (maxRadius - y_d*vptanpt); + + // rotate double Dxc = x_d * cost - y_d * sint; double Dyc = x_d * sint + y_d * cost; @@ -430,15 +481,35 @@ void ImProcFunctions::simpltransform (Image16* original, Image16* transformed, i double mul = (1.0-v) / tanh(b); bool dovign = params->vignetting.amount != 0; - double ascale = params->rotate.fill ? getTransformAutoFill (oW, oH) : 1.0; + // auxiliary variables for vertical perspective correction + double vpdeg = params->perspective.vertical / 100.0 * 45.0; + double vpalpha = (90 - vpdeg) / 180.0 * 3.14; + double vpteta = fabs(vpalpha-3.14/2)<1e-3 ? 0.0 : acos ((vpdeg>0 ? 1.0 : -1.0) * sqrt((-oW*oW*tan(vpalpha)*tan(vpalpha) + (vpdeg>0 ? 1.0 : -1.0) * oW*tan(vpalpha)*sqrt(16*maxRadius*maxRadius+oW*oW*tan(vpalpha)*tan(vpalpha)))/(maxRadius*maxRadius*8))); + double vpcospt = (vpdeg>=0 ? 1.0 : -1.0) * cos (vpteta), vptanpt = tan (vpteta); + + // auxiliary variables for horizontal perspective correction + double hpdeg = params->perspective.horizontal / 100.0 * 45.0; + double hpalpha = (90 - hpdeg) / 180.0 * 3.14; + double hpteta = fabs(hpalpha-3.14/2)<1e-3 ? 0.0 : acos ((hpdeg>0 ? 1.0 : -1.0) * sqrt((-oH*oH*tan(hpalpha)*tan(hpalpha) + (hpdeg>0 ? 1.0 : -1.0) * oH*tan(hpalpha)*sqrt(16*maxRadius*maxRadius+oH*oH*tan(hpalpha)*tan(hpalpha)))/(maxRadius*maxRadius*8))); + double hpcospt = (hpdeg>=0 ? 1.0 : -1.0) * cos (hpteta), hptanpt = tan (hpteta); + + double ascale = params->commonTrans.autofill ? getTransformAutoFill (oW, oH) : 1.0; // main cycle #pragma omp parallel for if (multiThread) for (int y=0; yheight; y++) { - double y_d = ascale * (y + cy - h2); // centering y coord & scale for (int x=0; xwidth; x++) { + double y_d = ascale * (y + cy - h2); // centering y coord & scale double x_d = ascale * (x + cx - w2); // centering x coord & scale + // horizontal perspective transformation + y_d = y_d * maxRadius / (maxRadius + x_d*hptanpt); + x_d = x_d * maxRadius * hpcospt / (maxRadius + x_d*hptanpt); + + // vertical perspective transformation + x_d = x_d * maxRadius / (maxRadius - y_d*vptanpt); + y_d = y_d * maxRadius * vpcospt / (maxRadius - y_d*vptanpt); + // rotate double Dx = x_d * cost - y_d * sint; double Dy = x_d * sint + y_d * cost; @@ -498,8 +569,6 @@ void ImProcFunctions::simpltransform (Image16* original, Image16* transformed, i double ImProcFunctions::getTransformAutoFill (int oW, int oH) { - MyTime t1,t2; - t1.set (); double scaleU = 1.0; double scaleL = 0.001; while (scaleU - scaleL > 0.001) { @@ -513,8 +582,6 @@ double ImProcFunctions::getTransformAutoFill (int oW, int oH) { else scaleL = scale; } - t2.set (); - printf ("autofill time=%d\n", t2.etime(t1)); return scaleL; } @@ -532,11 +599,11 @@ bool ImProcFunctions::needsRotation () { } bool ImProcFunctions::needsPerspective () { - return false; + return params->perspective.horizontal || params->perspective.vertical; } bool ImProcFunctions::needsVignetting () { - return params->vignetting.amount != 0; + return params->vignetting.amount; } bool ImProcFunctions::needsTransform () { diff --git a/rtengine/procevents.h b/rtengine/procevents.h index 7c1729bc5..5c398f0f2 100644 --- a/rtengine/procevents.h +++ b/rtengine/procevents.h @@ -1,114 +1,115 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#ifndef __PROCEVENT__ -#define __PROCEVENT__ - -#include - -#define NUMOFEVENTS 83 - -namespace rtengine { - -enum ProcEvent { - EvPhotoLoaded=0, - EvProfileLoaded=1, - EvProfileChanged=2, - EvHistoryBrowsed=3, - EvBrightness=4, - EvContrast=5, - EvBlack=6, - EvExpComp=7, - EvHLCompr=8, - EvSHCompr=9, - EvToneCurve=10, - EvAutoExp=11, - EvClip=12, - EvLBrightness=13, - EvLContrast=14, - EvLBlack=15, - EvLHLCompr=16, - EvLSHCompr=17, - EvLCurve=18, - EvShrEnabled=19, - EvShrRadius=20, - EvShrAmount=21, - EvShrThresh=22, - EvShrEdgeOnly=23, - EvShrEdgeRadius=24, - EvShrEdgeTolerance=25, - EvShrHaloControl=26, - EvShrHaloAmount=27, - EvShrMethod=28, - EvShrDRadius=29, - EvShrDAmount=30, - EvShrDDamping=31, - EvShrDIterations=32, - EvCBAvoidClip=33, - EvCBSatLimiter=34, - EvCBSatLimit=35, - EvCBBoost=36, - EvWBMethod=37, - EvWBTemp=38, - EvWBGreen=39, - EvCShiftA=40, - EvCShiftB=41, - EvLDNEnabled=42, - EvLDNRadius=43, - EvLDNEdgeTolerance=44, - EvCDNEnabled=45, - EvCDNRadius=46, - EvCDNEdgeTolerance=47, - EvCDNEdgeSensitive=48, - EvSHEnabled=49, - EvSHHighlights=50, - EvSHShadows=51, - EvSHHLTonalW=52, - EvSHSHTonalW=53, - EvSHLContrast=54, - EvSHRadius=55, - EvCTRotate=56, - EvCTHFlip=57, - EvCTVFlip=58, - EvROTDegree=59, - EvROTFill=60, - EvDISTAmount=61, - EvBookmarkSelected=62, - EvCrop=63, - EvCACorr=64, - EvHREnabled=65, - EvHRAmount=66, - EvHRMethod=67, - EvWProfile=68, - EvOProfile=69, - EvIProfile=70, - EvVignetting=71, - EvChMixer=72, - EvResizeScale=73, - EvResizeMethod=74, - EvExif=75, - EvIPTC=76, - EvResizeSpec=77, - EvResizeWidth=78, - EvResizeHeight=79, - EvResizeEnabled=80, - EvProfileChangeNotification=81, - EvSHHighQuality=82 - }; -} -#endif +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#ifndef __PROCEVENT__ +#define __PROCEVENT__ + +#include + +#define NUMOFEVENTS 84 + +namespace rtengine { + +enum ProcEvent { + EvPhotoLoaded=0, + EvProfileLoaded=1, + EvProfileChanged=2, + EvHistoryBrowsed=3, + EvBrightness=4, + EvContrast=5, + EvBlack=6, + EvExpComp=7, + EvHLCompr=8, + EvSHCompr=9, + EvToneCurve=10, + EvAutoExp=11, + EvClip=12, + EvLBrightness=13, + EvLContrast=14, + EvLBlack=15, + EvLHLCompr=16, + EvLSHCompr=17, + EvLCurve=18, + EvShrEnabled=19, + EvShrRadius=20, + EvShrAmount=21, + EvShrThresh=22, + EvShrEdgeOnly=23, + EvShrEdgeRadius=24, + EvShrEdgeTolerance=25, + EvShrHaloControl=26, + EvShrHaloAmount=27, + EvShrMethod=28, + EvShrDRadius=29, + EvShrDAmount=30, + EvShrDDamping=31, + EvShrDIterations=32, + EvCBAvoidClip=33, + EvCBSatLimiter=34, + EvCBSatLimit=35, + EvCBBoost=36, + EvWBMethod=37, + EvWBTemp=38, + EvWBGreen=39, + EvCShiftA=40, + EvCShiftB=41, + EvLDNEnabled=42, + EvLDNRadius=43, + EvLDNEdgeTolerance=44, + EvCDNEnabled=45, + EvCDNRadius=46, + EvCDNEdgeTolerance=47, + EvCDNEdgeSensitive=48, + EvSHEnabled=49, + EvSHHighlights=50, + EvSHShadows=51, + EvSHHLTonalW=52, + EvSHSHTonalW=53, + EvSHLContrast=54, + EvSHRadius=55, + EvCTRotate=56, + EvCTHFlip=57, + EvCTVFlip=58, + EvROTDegree=59, + EvTransAutoFill=60, + EvDISTAmount=61, + EvBookmarkSelected=62, + EvCrop=63, + EvCACorr=64, + EvHREnabled=65, + EvHRAmount=66, + EvHRMethod=67, + EvWProfile=68, + EvOProfile=69, + EvIProfile=70, + EvVignetting=71, + EvChMixer=72, + EvResizeScale=73, + EvResizeMethod=74, + EvExif=75, + EvIPTC=76, + EvResizeSpec=77, + EvResizeWidth=78, + EvResizeHeight=79, + EvResizeEnabled=80, + EvProfileChangeNotification=81, + EvSHHighQuality=82, + EvPerspCorr=83 + }; +} +#endif diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 438a47c50..08e3db481 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -117,10 +117,16 @@ void ProcParams::setDefaults () { coarse.hflip = false; coarse.vflip = false; + commonTrans.autofill = true; + rotate.degree = 0; - rotate.fill = true; - distortion.amount = 0; + + distortion.amount = 0; + distortion.uselensfun = false; + perspective.horizontal = 0; + perspective.vertical = 0; + cacorrection.red = 0; cacorrection.blue = 0; @@ -259,12 +265,19 @@ int ProcParams::save (Glib::ustring fname) const { keyFile.set_boolean ("Coarse Transformation", "HorizontalFlip", coarse.hflip); keyFile.set_boolean ("Coarse Transformation", "VerticalFlip", coarse.vflip); + // save commonTrans + keyFile.set_boolean ("Common Properties for Transformations", "AutoFill", commonTrans.autofill); + // save rotate keyFile.set_double ("Rotation", "Degree", rotate.degree); - keyFile.set_double ("Rotation", "Fill", rotate.fill); // save distortion keyFile.set_double ("Distortion", "Amount", distortion.amount); + keyFile.set_boolean ("Distortion", "UseLensFun", distortion.uselensfun); + + // save perspective correction + keyFile.set_integer ("Perspective", "Horizontal", perspective.horizontal); + keyFile.set_integer ("Perspective", "Vertical", perspective.vertical); // save C/A correction keyFile.set_double ("CACorrection", "Red", cacorrection.red); @@ -464,15 +477,25 @@ if (keyFile.has_group ("Coarse Transformation")) { // load rotate if (keyFile.has_group ("Rotation")) { if (keyFile.has_key ("Rotation", "Degree")) rotate.degree = keyFile.get_double ("Rotation", "Degree"); - if (keyFile.has_key ("Rotation", "Fill")) rotate.fill = keyFile.get_double ("Rotation", "Fill"); +} + // load commonTrans +if (keyFile.has_group ("Common Properties for Transformations")) { + if (keyFile.has_key ("Common Properties for Transformations", "AutoFill")) commonTrans.autofill = keyFile.get_boolean ("Common Properties for Transformations", "AutoFill"); } // load distortion if (keyFile.has_group ("Distortion")) { - if (keyFile.has_key ("Distortion", "Amount")) distortion.amount = keyFile.get_double ("Distortion", "Amount"); + if (keyFile.has_key ("Distortion", "Amount")) distortion.amount = keyFile.get_double ("Distortion", "Amount"); + if (keyFile.has_key ("Distortion", "UseLensFun")) distortion.uselensfun = keyFile.get_boolean ("Distortion", "UseLensFun"); } - // load c/a correction + // load perspective correction +if (keyFile.has_group ("Perspective")) { + if (keyFile.has_key ("Perspective", "Horizontal")) perspective.horizontal = keyFile.get_integer ("Perspective", "Horizontal"); + if (keyFile.has_key ("Perspective", "Vertical")) perspective.vertical = keyFile.get_integer ("Perspective", "Vertical"); +} + +// load c/a correction if (keyFile.has_group ("CACorrection")) { if (keyFile.has_key ("CACorrection", "Red")) cacorrection.red = keyFile.get_double ("CACorrection", "Red"); if (keyFile.has_key ("CACorrection", "Blue")) cacorrection.blue = keyFile.get_double ("CACorrection", "Blue"); @@ -534,7 +557,7 @@ if (keyFile.has_group ("IPTC")) { printf ("-->%s\n", e.what().c_str()); } catch (...) { - printf ("-->ismeretlen exception!\n"); + printf ("-->unknown exception!\n"); return 1; } } @@ -614,8 +637,11 @@ bool ProcParams::operator== (const ProcParams& other) { && coarse.hflip == other.coarse.hflip && coarse.vflip == other.coarse.vflip && rotate.degree == other.rotate.degree - && rotate.fill == other.rotate.fill + && commonTrans.autofill == other.commonTrans.autofill + && distortion.uselensfun == other.distortion.uselensfun && distortion.amount == other.distortion.amount + && perspective.horizontal == other.perspective.horizontal + && perspective.vertical == other.perspective.vertical && cacorrection.red == other.cacorrection.red && cacorrection.blue == other.cacorrection.blue && vignetting.amount == other.vignetting.amount diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 5ffbe6b62..ae4bd0257 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -177,6 +177,15 @@ class CoarseTransformParams { bool vflip; }; +/** + * Common transformation parameters + */ +class CommonTransformParams { + + public: + bool autofill; +}; + /** * Parameters of the rotation */ @@ -184,7 +193,6 @@ class RotateParams { public: double degree; - bool fill; }; /** @@ -193,8 +201,19 @@ class RotateParams { class DistortionParams { public: + bool uselensfun; double amount; }; + +/** + * Parameters of the perspective correction + */ +class PerspectiveParams { + + public: + int horizontal; + int vertical; +}; /** * Parameters of the vignetting correction @@ -300,8 +319,10 @@ class ProcParams { SHParams sh; ///< Shadow/highlight enhancement parameters CropParams crop; ///< Crop parameters CoarseTransformParams coarse; ///< Coarse transformation (90, 180, 270 deg rotation, h/v flipping) parameters + CommonTransformParams commonTrans; ///< Common transformation parameters (autofill) RotateParams rotate; ///< Rotation parameters - DistortionParams distortion; ///< Lens distortion correction parameters + DistortionParams distortion; ///< Lens distortion correction parameters + PerspectiveParams perspective; ///< Perspective correction parameters CACorrParams cacorrection; ///< Lens c/a correction parameters VignettingParams vignetting; ///< Lens vignetting correction parameters ChannelMixerParams chmixer; ///< Channel mixer parameters diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 340c485d3..962a89a83 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -19,88 +19,89 @@ #include int refreshmap[] = { -ALL, // EvPhotoLoaded, -ALL, // EvProfileLoaded, -ALL, // EvProfileChanged, -ALL, // EvHistoryBrowsed, -RGBCURVE, // EvBrightness, -RGBCURVE, // EvContrast, -RGBCURVE, // EvBlack, -RGBCURVE, // EvExpComp, -RGBCURVE, // EvHLCompr, -RGBCURVE, // EvSHCompr, -RGBCURVE, // EvToneCurve, -AUTOEXP, // EvAutoExp, -AUTOEXP, // EvClip, -LUMINANCECURVE, // EvLBrightness, -LUMINANCECURVE, // EvLContrast, -LUMINANCECURVE, // EvLBlack, -LUMINANCECURVE, // EvLHLCompr, -LUMINANCECURVE, // EvLSHCompr, -LUMINANCECURVE, // EvLCurve, -SHARPENING, // EvShrEnabled, -SHARPENING, // EvShrRadius, -SHARPENING, // EvShrAmount, -SHARPENING, // EvShrThresh, -SHARPENING, // EvShrEdgeOnly, -SHARPENING, // EvShrEdgeRadius, -SHARPENING, // EvShrEdgeTolerance, -SHARPENING, // EvShrHaloControl, -SHARPENING, // EvShrHaloAmount, -SHARPENING, // EvShrMethod, -SHARPENING, // EvShrDRadius, -SHARPENING, // EvShrDAmount, -SHARPENING, // EvShrDDamping, -SHARPENING, // EvShrDIterations, -COLORBOOST, // EvCBAvoidClip, -COLORBOOST, // EvCBSatLimiter, -COLORBOOST, // EvCBSatLimit, -COLORBOOST, // EvCBBoost, -WHITEBALANCE, // EvWBMethod, -WHITEBALANCE, // EvWBTemp, -WHITEBALANCE, // EvWBGreen, -COLORBOOST, // EvCShiftA, -COLORBOOST, // EvCShiftB, -LUMADENOISE, // EvLDNEnabled, -LUMADENOISE, // EvLDNRadius, -LUMADENOISE, // EvLDNEdgeTolerance, -COLORDENOISE, // EvCDNEnabled, -COLORDENOISE, // EvCDNRadius, -COLORDENOISE, // EvCDNEdgeTolerance, -COLORDENOISE, // EvCDNEdgeSensitive, -RETINEX, // EvSHEnabled, -RGBCURVE, // EvSHHighlights, -RGBCURVE, // EvSHShadows, -RGBCURVE, // EvSHHLTonalW, -RGBCURVE, // EvSHSHTonalW, -RGBCURVE, // EvSHLContrast, -RETINEX, // EvSHRadius, -ALL, // EvCTRotate, -ALL, // EvCTHFlip, -ALL, // EvCTVFlip, -TRANSFORM, // EvROTDegree, -TRANSFORM, // EvROTFill, -TRANSFORM, // EvDISTAmount, -ALL, // EvBookmarkSelected, -CROP, // EvCrop, -TRANSFORM, // EvCACorr, -ALL, // EvHREnabled, -ALL, // EvHRAmount, -ALL, // EvHRMethod, -ALL, // EvWProfile, -ALL, // EvOProfile, -ALL, // EvIProfile, -TRANSFORM, // EvVignetting, -RGBCURVE, // EvChMixer, -ALL, // EvResizeScale, -ALL, // EvResizeMethod, -EXIF, // EvExif, -IPTC, // EvIPTC -ALL, // EvResizeSpec, -ALL, // EvResizeWidth -ALL, // EvResizeHeight -ALL, // EvResizeEnabled -ALL, // EvProfileChangeNotification -RETINEX // EvShrHighQuality - }; +ALL, // EvPhotoLoaded, +ALL, // EvProfileLoaded, +ALL, // EvProfileChanged, +ALL, // EvHistoryBrowsed, +RGBCURVE, // EvBrightness, +RGBCURVE, // EvContrast, +RGBCURVE, // EvBlack, +RGBCURVE, // EvExpComp, +RGBCURVE, // EvHLCompr, +RGBCURVE, // EvSHCompr, +RGBCURVE, // EvToneCurve, +AUTOEXP, // EvAutoExp, +AUTOEXP, // EvClip, +LUMINANCECURVE, // EvLBrightness, +LUMINANCECURVE, // EvLContrast, +LUMINANCECURVE, // EvLBlack, +LUMINANCECURVE, // EvLHLCompr, +LUMINANCECURVE, // EvLSHCompr, +LUMINANCECURVE, // EvLCurve, +SHARPENING, // EvShrEnabled, +SHARPENING, // EvShrRadius, +SHARPENING, // EvShrAmount, +SHARPENING, // EvShrThresh, +SHARPENING, // EvShrEdgeOnly, +SHARPENING, // EvShrEdgeRadius, +SHARPENING, // EvShrEdgeTolerance, +SHARPENING, // EvShrHaloControl, +SHARPENING, // EvShrHaloAmount, +SHARPENING, // EvShrMethod, +SHARPENING, // EvShrDRadius, +SHARPENING, // EvShrDAmount, +SHARPENING, // EvShrDDamping, +SHARPENING, // EvShrDIterations, +COLORBOOST, // EvCBAvoidClip, +COLORBOOST, // EvCBSatLimiter, +COLORBOOST, // EvCBSatLimit, +COLORBOOST, // EvCBBoost, +WHITEBALANCE, // EvWBMethod, +WHITEBALANCE, // EvWBTemp, +WHITEBALANCE, // EvWBGreen, +COLORBOOST, // EvCShiftA, +COLORBOOST, // EvCShiftB, +LUMADENOISE, // EvLDNEnabled, +LUMADENOISE, // EvLDNRadius, +LUMADENOISE, // EvLDNEdgeTolerance, +COLORDENOISE, // EvCDNEnabled, +COLORDENOISE, // EvCDNRadius, +COLORDENOISE, // EvCDNEdgeTolerance, +COLORDENOISE, // EvCDNEdgeSensitive, +RETINEX, // EvSHEnabled, +RGBCURVE, // EvSHHighlights, +RGBCURVE, // EvSHShadows, +RGBCURVE, // EvSHHLTonalW, +RGBCURVE, // EvSHSHTonalW, +RGBCURVE, // EvSHLContrast, +RETINEX, // EvSHRadius, +ALL, // EvCTRotate, +ALL, // EvCTHFlip, +ALL, // EvCTVFlip, +TRANSFORM, // EvROTDegree, +TRANSFORM, // EvTransAutoFill, +TRANSFORM, // EvDISTAmount, +ALL, // EvBookmarkSelected, +CROP, // EvCrop, +TRANSFORM, // EvCACorr, +ALL, // EvHREnabled, +ALL, // EvHRAmount, +ALL, // EvHRMethod, +ALL, // EvWProfile, +ALL, // EvOProfile, +ALL, // EvIProfile, +TRANSFORM, // EvVignetting, +RGBCURVE, // EvChMixer, +ALL, // EvResizeScale, +ALL, // EvResizeMethod, +EXIF, // EvExif, +IPTC, // EvIPTC +ALL, // EvResizeSpec, +ALL, // EvResizeWidth +ALL, // EvResizeHeight +ALL, // EvResizeEnabled +ALL, // EvProfileChangeNotification +RETINEX, // EvShrHighQuality +TRANSFORM // EvPerspCorr +}; diff --git a/rtengine/refreshmap.h b/rtengine/refreshmap.h index 4141072ee..6a9f9700f 100644 --- a/rtengine/refreshmap.h +++ b/rtengine/refreshmap.h @@ -21,8 +21,6 @@ #include -#define NUMOFEVENTS 83 - #define FIRST 65535 #define ALL 65535 #define TRANSFORM 127 diff --git a/rtgui/CMakeLists.txt b/rtgui/CMakeLists.txt index f707a4c4f..49fa71e50 100644 --- a/rtgui/CMakeLists.txt +++ b/rtgui/CMakeLists.txt @@ -3,8 +3,8 @@ set (BASESOURCEFILES batchtoolpanelcoord.cc paramsedited.cc cropwindow.cc previewhandler.cc previewwindow.cc navigator.cc indclippedpanel.cc filterpanel.cc cursormanager.cc rtwindow.cc renamedlg.cc recentbrowser.cc placesbrowser.cc filepanel.cc editorpanel.cc batchqueuepanel.cc ilabel.cc thumbbrowserbase.cc adjuster.cc filebrowserentry.cc filebrowser.cc filethumbnailbuttonset.cc - cachemanager.cc cacheimagedata.cc shcselector.cc - clipboard.cc thumbimageupdater.cc bqentryupdater.cc + cachemanager.cc cacheimagedata.cc shcselector.cc perspective.cc + clipboard.cc thumbimageupdater.cc bqentryupdater.cc lensgeom.cc coarsepanel.cc cacorrection.cc colorshift.cc hlrec.cc chmixer.cc colorboost.cc resize.cc icmpanel.cc crop.cc shadowshighlights.cc colordenoise.cc diff --git a/rtgui/addsetids.h b/rtgui/addsetids.h index 05be8f225..ed5192d8a 100644 --- a/rtgui/addsetids.h +++ b/rtgui/addsetids.h @@ -19,8 +19,8 @@ #define ADDSET_CS_GREENMAGENTA 15 #define ADDSET_ROTATE_DEGREE 16 #define ADDSET_DIST_AMOUNT 17 -#define ADDSET_CA_BLUE 18 -#define ADDSET_CA_RED 19 +#define ADDSET_PERSPECTIVE 18 +#define ADDSET_CA 19 #define ADDSET_VIGN_AMOUNT 20 #define ADDSET_PARAM_NUM 21 diff --git a/rtgui/batchtoolpanelcoord.cc b/rtgui/batchtoolpanelcoord.cc index c552d6c0d..8ad08c61e 100644 --- a/rtgui/batchtoolpanelcoord.cc +++ b/rtgui/batchtoolpanelcoord.cc @@ -126,7 +126,8 @@ void BatchToolPanelCoordinator::initSession () { vignetting->setAdjusterBehavior (options.baBehav[ADDSET_VIGN_AMOUNT]); rotate->setAdjusterBehavior (options.baBehav[ADDSET_ROTATE_DEGREE]); distortion->setAdjusterBehavior (options.baBehav[ADDSET_DIST_AMOUNT]); - cacorrection->setAdjusterBehavior (options.baBehav[ADDSET_CA_RED], options.baBehav[ADDSET_CA_BLUE]); + perspective->setAdjusterBehavior (options.baBehav[ADDSET_PERSPECTIVE]); + cacorrection->setAdjusterBehavior (options.baBehav[ADDSET_CA]); colorshift->setAdjusterBehavior (options.baBehav[ADDSET_CS_BLUEYELLOW], options.baBehav[ADDSET_CS_GREENMAGENTA]); colorboost->setAdjusterBehavior (options.baBehav[ADDSET_CBOOST_AMOUNT]); lumadenoise->setAdjusterBehavior (options.baBehav[ADDSET_LD_EDGETOLERANCE]); @@ -158,8 +159,9 @@ void BatchToolPanelCoordinator::initSession () { if (options.baBehav[ADDSET_ROTATE_DEGREE]) pparams.rotate.degree = 0; if (options.baBehav[ADDSET_DIST_AMOUNT]) pparams.distortion.amount = 0; - if (options.baBehav[ADDSET_CA_RED]) pparams.cacorrection.red = 0; - if (options.baBehav[ADDSET_CA_BLUE]) pparams.cacorrection.blue = 0; + if (options.baBehav[ADDSET_PERSPECTIVE]) pparams.perspective.horizontal = pparams.perspective.vertical = 0; + if (options.baBehav[ADDSET_CA]) pparams.cacorrection.red = 0; + if (options.baBehav[ADDSET_CA]) pparams.cacorrection.blue = 0; if (options.baBehav[ADDSET_VIGN_AMOUNT]) pparams.vignetting.amount = 0; for (int i=0; isetAdjusterListener (this); @@ -83,16 +83,14 @@ void CACorrection::adjusterChanged (Adjuster* a, double newval) { listener->panelChanged (EvCACorr, Glib::ustring::compose ("%1=%3\n%2=%4", M("TP_CACORRECTION_RED"), M("TP_CACORRECTION_BLUE"), Glib::ustring::format (std::setw(5), std::fixed, std::setprecision(4), red->getValue()), Glib::ustring::format (std::setw(5), std::fixed, std::setprecision(4), blue->getValue()))); } -void CACorrection::setAdjusterBehavior (bool baadd, bool bbadd) { +void CACorrection::setAdjusterBehavior (bool badd) { - if (!valaAdd && baadd || valaAdd && !baadd) + if (!vAdd && badd || vAdd && !badd) { red->setLimits (-0.005, 0.005, 0.0001, 0); - - if (!valbAdd && bbadd || valbAdd && !bbadd) blue->setLimits (-0.005, 0.005, 0.0001, 0); - - valaAdd = baadd; - valbAdd = bbadd; + } + + vAdd = badd; } void CACorrection::setBatchMode (bool batchMode) { diff --git a/rtgui/cacorrection.h b/rtgui/cacorrection.h index c9b4a8142..6fbd284ff 100644 --- a/rtgui/cacorrection.h +++ b/rtgui/cacorrection.h @@ -28,7 +28,7 @@ class CACorrection : public Gtk::VBox, public AdjusterListener, public ToolPanel protected: Adjuster* red; Adjuster* blue; - bool valaAdd, valbAdd; + bool vAdd; public: @@ -40,7 +40,7 @@ class CACorrection : public Gtk::VBox, public AdjusterListener, public ToolPanel void setBatchMode (bool batchMode); void adjusterChanged (Adjuster* a, double newval); - void setAdjusterBehavior (bool baadd, bool bbadd); + void setAdjusterBehavior (bool badd); }; #endif diff --git a/rtgui/lensgeom.cc b/rtgui/lensgeom.cc new file mode 100644 index 000000000..a7032c674 --- /dev/null +++ b/rtgui/lensgeom.cc @@ -0,0 +1,104 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#include +#include + +extern Glib::ustring argv0; + +using namespace rtengine; +using namespace rtengine::procparams; + +LensGeometry::LensGeometry () : ToolPanel(), rlistener(NULL) { + + fill = Gtk::manage (new Gtk::CheckButton (M("TP_LENSGEOM_FILL"))); + pack_start (*fill); + + autoCrop = Gtk::manage (new Gtk::Button (M("TP_LENSGEOM_AUTOCROP"))); + pack_start (*autoCrop, Gtk::PACK_SHRINK, 2); + + packBox = Gtk::manage (new Gtk::VBox ()); + pack_start (*packBox); + + autoCrop->signal_pressed().connect( sigc::mem_fun(*this, &LensGeometry::autoCropPressed) ); + fillConn = fill->signal_toggled().connect( sigc::mem_fun(*this, &LensGeometry::fillPressed) ); + + fill->set_active (true); + show_all (); +} + +void LensGeometry::read (const ProcParams* pp, const ParamsEdited* pedited) { + + disableListener (); + + if (pedited) + fill->set_inconsistent (!pedited->commonTrans.autofill); + + fillConn.block (true); + fill->set_active (pp->commonTrans.autofill); + fillConn.block (false); + + lastFill = pp->commonTrans.autofill; + + enableListener (); +} + +void LensGeometry::write (ProcParams* pp, ParamsEdited* pedited) { + + pp->commonTrans.autofill = fill->get_active (); + + if (pedited) + pedited->commonTrans.autofill = !fill->get_inconsistent(); +} + +void LensGeometry::autoCropPressed () { + + if (rlistener) + rlistener->autoCropRequested (); +} + +void LensGeometry::fillPressed () { + + if (batchMode) { + if (fill->get_inconsistent()) { + fill->set_inconsistent (false); + fillConn.block (true); + fill->set_active (false); + fillConn.block (false); + } + else if (lastFill) + fill->set_inconsistent (true); + + lastFill = fill->get_active (); + } + else + autoCrop->set_sensitive (!fill->get_active()); + + if (listener) { + if (fill->get_active ()) + listener->panelChanged (EvTransAutoFill, M("TP_LENSGEOM_AUTOFILL")+' '+M("GENERAL_ENABLED")); + else + listener->panelChanged (EvTransAutoFill, M("TP_LENSGEOM_AUTOFILL")+' '+M("GENERAL_DISABLED")); + } +} + +void LensGeometry::setBatchMode (bool batchMode) { + + ToolPanel::setBatchMode (batchMode); + removeIfThere (this, autoCrop); +} diff --git a/rtgui/lensgeom.h b/rtgui/lensgeom.h new file mode 100644 index 000000000..b176605e3 --- /dev/null +++ b/rtgui/lensgeom.h @@ -0,0 +1,51 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#ifndef _LENSGEOM_H_ +#define _LENSGEOM_H_ + +#include +#include +#include + +class LensGeometry : public Gtk::VBox, public ToolPanel { + + protected: + Gtk::Button* autoCrop; + LensGeomListener* rlistener; + Gtk::CheckButton* fill; + bool lastFill; + sigc::connection fillConn; + Gtk::VBox* packBox; + + public: + + LensGeometry (); + + Gtk::Box* getPackBox () { return packBox; } + + void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); + void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); + void setBatchMode (bool batchMode); + + void fillPressed (); + void autoCropPressed (); + void setLensGeomListener (LensGeomListener* l) { rlistener = l; } +}; + +#endif diff --git a/rtgui/lensgeomlistener.h b/rtgui/lensgeomlistener.h new file mode 100644 index 000000000..2f14ab346 --- /dev/null +++ b/rtgui/lensgeomlistener.h @@ -0,0 +1,29 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#ifndef _LENSGEOMLISTENER_H_ +#define _LENSGEOMLISTENER_H_ + +class LensGeomListener { + + public: + virtual void straightenRequested ()=0; + virtual void autoCropRequested ()=0; +}; + +#endif diff --git a/rtgui/options.cc b/rtgui/options.cc index f0a396f92..29aac88d1 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -27,7 +27,7 @@ Options options; Glib::ustring versionString = "v3.0 alpha 1"; -Glib::ustring paramFileExtension = ".pp2"; +Glib::ustring paramFileExtension = ".pp3"; Options::Options () { diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index aea204ab6..918d537ce 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -88,9 +88,12 @@ void ParamsEdited::set (bool v) { coarse.rotate = v; coarse.hflip = v; coarse.vflip = v; + commonTrans.autofill = v; rotate.degree = v; - rotate.fill = v; + distortion.uselensfun = v; distortion.amount = v; + perspective.horizontal = v; + perspective.vertical = v; cacorrection.red = v; cacorrection.blue = v; vignetting.amount = v; @@ -192,9 +195,12 @@ void ParamsEdited::initFrom (const std::vector coarse.rotate = coarse.rotate && p.coarse.rotate == other.coarse.rotate; coarse.hflip = coarse.hflip && p.coarse.hflip == other.coarse.hflip; coarse.vflip = coarse.vflip && p.coarse.vflip == other.coarse.vflip; + commonTrans.autofill = commonTrans.autofill && p.commonTrans.autofill == other.commonTrans.autofill; rotate.degree = rotate.degree && p.rotate.degree == other.rotate.degree; - rotate.fill = rotate.fill && p.rotate.fill == other.rotate.fill; + distortion.uselensfun = distortion.uselensfun && p.distortion.uselensfun == other.distortion.uselensfun; distortion.amount = distortion.amount && p.distortion.amount == other.distortion.amount; + perspective.horizontal = perspective.horizontal && p.perspective.horizontal == other.perspective.horizontal; + perspective.vertical = perspective.vertical && p.perspective.vertical == other.perspective.vertical; cacorrection.red = cacorrection.red && p.cacorrection.red == other.cacorrection.red; cacorrection.blue = cacorrection.blue && p.cacorrection.blue == other.cacorrection.blue; vignetting.amount = vignetting.amount && p.vignetting.amount == other.vignetting.amount; @@ -267,33 +273,36 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten if (lumaDenoise.edgetolerance) toEdit.lumaDenoise.edgetolerance = options.baBehav[ADDSET_LD_EDGETOLERANCE] ? toEdit.lumaDenoise.edgetolerance + mods.lumaDenoise.edgetolerance : mods.lumaDenoise.edgetolerance; if (colorDenoise.enabled) toEdit.colorDenoise.enabled = mods.colorDenoise.enabled; if (colorDenoise.amount) toEdit.colorDenoise.amount = mods.colorDenoise.amount; - if (sh.enabled) toEdit.sh.enabled = mods.sh.enabled; - if (sh.hq) toEdit.sh.hq = mods.sh.hq; - if (sh.highlights) toEdit.sh.highlights = options.baBehav[ADDSET_SH_HIGHLIGHTS] ? toEdit.sh.highlights + mods.sh.highlights : mods.sh.highlights; - if (sh.htonalwidth) toEdit.sh.htonalwidth = mods.sh.htonalwidth; - if (sh.shadows) toEdit.sh.shadows = options.baBehav[ADDSET_SH_SHADOWS] ? toEdit.sh.shadows + mods.sh.shadows : mods.sh.shadows; - if (sh.stonalwidth) toEdit.sh.stonalwidth = mods.sh.stonalwidth; - if (sh.localcontrast) toEdit.sh.localcontrast = options.baBehav[ADDSET_SH_LOCALCONTRAST] ? toEdit.sh.localcontrast + mods.sh.localcontrast : mods.sh.localcontrast; - if (sh.radius) toEdit.sh.radius = mods.sh.radius; - if (crop.enabled) toEdit.crop.enabled = mods.crop.enabled; - if (crop.x) toEdit.crop.x = mods.crop.x; - if (crop.y) toEdit.crop.y = mods.crop.y; - if (crop.w) toEdit.crop.w = mods.crop.w; - if (crop.h) toEdit.crop.h = mods.crop.h; - if (crop.fixratio) toEdit.crop.fixratio = mods.crop.fixratio; - if (crop.ratio) toEdit.crop.ratio = mods.crop.ratio; - if (crop.orientation) toEdit.crop.orientation = mods.crop.orientation; - if (crop.guide) toEdit.crop.guide = mods.crop.guide; - if (coarse.rotate) toEdit.coarse.rotate = (toEdit.coarse.rotate + mods.coarse.rotate) % 360; - if (coarse.hflip) toEdit.coarse.hflip = mods.coarse.hflip ? !toEdit.coarse.hflip : toEdit.coarse.hflip; - if (coarse.vflip) toEdit.coarse.vflip = mods.coarse.vflip ? !toEdit.coarse.vflip : toEdit.coarse.vflip; - if (rotate.degree) toEdit.rotate.degree = options.baBehav[17] ? toEdit.rotate.degree + mods.rotate.degree : mods.rotate.degree; - if (rotate.fill) toEdit.rotate.fill = mods.rotate.fill; - if (distortion.amount) toEdit.distortion.amount = options.baBehav[ADDSET_DIST_AMOUNT] ? toEdit.distortion.amount + mods.distortion.amount : mods.distortion.amount; - if (cacorrection.red) toEdit.cacorrection.red = options.baBehav[ADDSET_CA_RED] ? toEdit.cacorrection.red + mods.cacorrection.red : mods.cacorrection.red; - if (cacorrection.blue) toEdit.cacorrection.blue = options.baBehav[ADDSET_CA_BLUE] ? toEdit.cacorrection.blue + mods.cacorrection.blue : mods.cacorrection.blue; - if (vignetting.amount) toEdit.vignetting.amount = options.baBehav[ADDSET_VIGN_AMOUNT] ? toEdit.vignetting.amount + mods.vignetting.amount : mods.vignetting.amount; - if (vignetting.radius) toEdit.vignetting.radius = mods.vignetting.radius; + if (sh.enabled) toEdit.sh.enabled = mods.sh.enabled; + if (sh.hq) toEdit.sh.hq = mods.sh.hq; + if (sh.highlights) toEdit.sh.highlights = options.baBehav[ADDSET_SH_HIGHLIGHTS] ? toEdit.sh.highlights + mods.sh.highlights : mods.sh.highlights; + if (sh.htonalwidth) toEdit.sh.htonalwidth = mods.sh.htonalwidth; + if (sh.shadows) toEdit.sh.shadows = options.baBehav[ADDSET_SH_SHADOWS] ? toEdit.sh.shadows + mods.sh.shadows : mods.sh.shadows; + if (sh.stonalwidth) toEdit.sh.stonalwidth = mods.sh.stonalwidth; + if (sh.localcontrast) toEdit.sh.localcontrast = options.baBehav[ADDSET_SH_LOCALCONTRAST] ? toEdit.sh.localcontrast + mods.sh.localcontrast : mods.sh.localcontrast; + if (sh.radius) toEdit.sh.radius = mods.sh.radius; + if (crop.enabled) toEdit.crop.enabled = mods.crop.enabled; + if (crop.x) toEdit.crop.x = mods.crop.x; + if (crop.y) toEdit.crop.y = mods.crop.y; + if (crop.w) toEdit.crop.w = mods.crop.w; + if (crop.h) toEdit.crop.h = mods.crop.h; + if (crop.fixratio) toEdit.crop.fixratio = mods.crop.fixratio; + if (crop.ratio) toEdit.crop.ratio = mods.crop.ratio; + if (crop.orientation) toEdit.crop.orientation = mods.crop.orientation; + if (crop.guide) toEdit.crop.guide = mods.crop.guide; + if (coarse.rotate) toEdit.coarse.rotate = (toEdit.coarse.rotate + mods.coarse.rotate) % 360; + if (coarse.hflip) toEdit.coarse.hflip = mods.coarse.hflip ? !toEdit.coarse.hflip : toEdit.coarse.hflip; + if (coarse.vflip) toEdit.coarse.vflip = mods.coarse.vflip ? !toEdit.coarse.vflip : toEdit.coarse.vflip; + if (commonTrans.autofill) toEdit.commonTrans.autofill = mods.commonTrans.autofill; + if (rotate.degree) toEdit.rotate.degree = options.baBehav[17] ? toEdit.rotate.degree + mods.rotate.degree : mods.rotate.degree; + if (distortion.uselensfun) toEdit.distortion.uselensfun = mods.distortion.uselensfun; + if (distortion.amount) toEdit.distortion.amount = options.baBehav[ADDSET_DIST_AMOUNT] ? toEdit.distortion.amount + mods.distortion.amount : mods.distortion.amount; + if (perspective.horizontal) toEdit.perspective.horizontal = options.baBehav[ADDSET_PERSPECTIVE] ? toEdit.perspective.horizontal + mods.perspective.horizontal : mods.perspective.horizontal; + if (perspective.vertical) toEdit.perspective.vertical = options.baBehav[ADDSET_PERSPECTIVE] ? toEdit.perspective.vertical + mods.perspective.vertical : mods.perspective.vertical; + if (cacorrection.red) toEdit.cacorrection.red = options.baBehav[ADDSET_CA] ? toEdit.cacorrection.red + mods.cacorrection.red : mods.cacorrection.red; + if (cacorrection.blue) toEdit.cacorrection.blue = options.baBehav[ADDSET_CA] ? toEdit.cacorrection.blue + mods.cacorrection.blue : mods.cacorrection.blue; + if (vignetting.amount) toEdit.vignetting.amount = options.baBehav[ADDSET_VIGN_AMOUNT] ? toEdit.vignetting.amount + mods.vignetting.amount : mods.vignetting.amount; + if (vignetting.radius) toEdit.vignetting.radius = mods.vignetting.radius; if (chmixer.red[0]) toEdit.chmixer.red[0] = mods.chmixer.red[0]; if (chmixer.red[1]) toEdit.chmixer.red[1] = mods.chmixer.red[1]; if (chmixer.red[2]) toEdit.chmixer.red[2] = mods.chmixer.red[2]; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 3b48e2f63..a38b96fc6 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -140,19 +140,32 @@ class CoarseTransformParamsEdited { bool vflip; }; +class CommonTransformParamsEdited { + + public: + bool autofill; +}; + class RotateParamsEdited { public: bool degree; - bool fill; }; class DistortionParamsEdited { public: + bool uselensfun; bool amount; }; +class PerspectiveParamsEdited { + + public: + bool horizontal; + bool vertical; +}; + class VignettingParamsEdited { public: @@ -230,8 +243,10 @@ class ParamsEdited { SHParamsEdited sh; CropParamsEdited crop; CoarseTransformParamsEdited coarse; + CommonTransformParamsEdited commonTrans; RotateParamsEdited rotate; - DistortionParamsEdited distortion; + DistortionParamsEdited distortion; + PerspectiveParamsEdited perspective; CACorrParamsEdited cacorrection; VignettingParamsEdited vignetting; ChannelMixerParamsEdited chmixer; diff --git a/rtgui/perspective.cc b/rtgui/perspective.cc new file mode 100644 index 000000000..92f1c1ea8 --- /dev/null +++ b/rtgui/perspective.cc @@ -0,0 +1,100 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#include + +using namespace rtengine; +using namespace rtengine::procparams; + +PerspCorrection::PerspCorrection () : vAdd(false) { + + horiz = Gtk::manage (new Adjuster (M("TP_PERSPECTIVE_HORIZONTAL"), -100, 100, 1, 0)); + horiz->setAdjusterListener (this); + + vert = Gtk::manage (new Adjuster (M("TP_PERSPECTIVE_VERTICAL"), -100, 100, 1, 0)); + vert->setAdjusterListener (this); + + pack_start (*horiz); + pack_start (*vert); + + show_all(); +} + +void PerspCorrection::read (const ProcParams* pp, const ParamsEdited* pedited) { + + disableListener (); + + if (pedited) { + horiz->setEditedState (pedited->perspective.horizontal ? Edited : UnEdited); + vert->setEditedState (pedited->perspective.vertical ? Edited : UnEdited); + } + + horiz->setValue (pp->perspective.horizontal); + vert->setValue (pp->perspective.vertical); + + enableListener (); +} + +void PerspCorrection::write (ProcParams* pp, ParamsEdited* pedited) { + + pp->perspective.horizontal = horiz->getValue (); + pp->perspective.vertical = vert->getValue (); + + if (pedited) { + pedited->perspective.horizontal = horiz->getEditedState (); + pedited->perspective.vertical = vert->getEditedState (); + } +} + +void PerspCorrection::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) { + + horiz->setDefault (defParams->perspective.horizontal); + vert->setDefault (defParams->perspective.vertical); + + if (pedited) { + horiz->setDefaultEditedState (pedited->perspective.horizontal ? Edited : UnEdited); + vert->setDefaultEditedState (pedited->perspective.vertical ? Edited : UnEdited); + } + else { + horiz->setDefaultEditedState (Irrelevant); + vert->setDefaultEditedState (Irrelevant); + } +} + +void PerspCorrection::adjusterChanged (Adjuster* a, double newval) { + + if (listener) + listener->panelChanged (EvPerspCorr, Glib::ustring::compose ("%1=%3\n%2=%4", M("TP_PERSPECTIVE_HORIZONTAL"), M("TP_PERSPECTIVE_VERTICAL"), horiz->getValue(), vert->getValue())); +} + +void PerspCorrection::setAdjusterBehavior (bool badd) { + + if (!vAdd && badd || vAdd && !badd) { +// horiz->setLimits (-0.005, 0.005, 0.0001, 0); +// vert->setLimits (-0.005, 0.005, 0.0001, 0); + } + + vAdd = badd; +} + +void PerspCorrection::setBatchMode (bool batchMode) { + + ToolPanel::setBatchMode (batchMode); + horiz->showEditedCB (); + vert->showEditedCB (); +} diff --git a/rtgui/perspective.h b/rtgui/perspective.h new file mode 100644 index 000000000..7812a4472 --- /dev/null +++ b/rtgui/perspective.h @@ -0,0 +1,46 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#ifndef _PERSPECTIVE_PANEL_H_ +#define _PERSPECTIVE_PANEL_H_ + +#include +#include +#include + +class PerspCorrection : public Gtk::VBox, public AdjusterListener, public ToolPanel { + + protected: + Adjuster* horiz; + Adjuster* vert; + bool vAdd; + + public: + + PerspCorrection (); + + void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); + void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); + void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); + void setBatchMode (bool batchMode); + + void adjusterChanged (Adjuster* a, double newval); + void setAdjusterBehavior (bool badd); +}; + +#endif diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index 3db415ec8..2204d4698 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -173,10 +173,13 @@ Gtk::Widget* Preferences::getBatchProcPanel () { mi->set_value (behavColumns.label, M("TP_DISTORTION_LABEL")); appendBehavList (mi, M("TP_DISTORTION_AMOUNT"), ADDSET_DIST_AMOUNT, false); + mi = behModel->append (); + mi->set_value (behavColumns.label, M("TP_PERSPECTIVE_LABEL")); + appendBehavList (mi, M("TP_PERSPECTIVE_HORIZONTAL")+", "+M("TP_PERSPECTIVE_VERTICAL"), ADDSET_PERSPECTIVE, false); + mi = behModel->append (); mi->set_value (behavColumns.label, M("TP_CACORRECTION_LABEL")); - appendBehavList (mi, M("TP_CACORRECTION_BLUE"), ADDSET_CA_BLUE, true); - appendBehavList (mi, M("TP_CACORRECTION_RED"), ADDSET_CA_RED, true); + appendBehavList (mi, M("TP_CACORRECTION_BLUE")+", "+M("TP_CACORRECTION_RED"), ADDSET_CA, true); mi = behModel->append (); mi->set_value (behavColumns.label, M("TP_VIGNETTING_LABEL")); diff --git a/rtgui/rotate.cc b/rtgui/rotate.cc index 1cdd2861f..8c13b467e 100644 --- a/rtgui/rotate.cc +++ b/rtgui/rotate.cc @@ -33,22 +33,13 @@ Rotate::Rotate () : ToolPanel (), degAdd(false) { degree->setAdjusterListener (this); pack_start (*degree); - fill = Gtk::manage (new Gtk::CheckButton (M("TP_ROTATE_FILL"))); - pack_start (*fill); - selectStraight = Gtk::manage (new Gtk::Button (M("TP_ROTATE_SELECTLINE"))); Gtk::Image* selimg = Gtk::manage (new Gtk::Image (argv0+"/images/straighten16.png")); selectStraight->set_image (*selimg); pack_start (*selectStraight, Gtk::PACK_SHRINK, 2); - autoCrop = Gtk::manage (new Gtk::Button (M("TP_ROTATE_AUTOCROP"))); - pack_start (*autoCrop, Gtk::PACK_SHRINK, 2); - selectStraight->signal_pressed().connect( sigc::mem_fun(*this, &Rotate::selectStraightPressed) ); - autoCrop->signal_pressed().connect( sigc::mem_fun(*this, &Rotate::autoCropPressed) ); - fillConn = fill->signal_toggled().connect( sigc::mem_fun(*this, &Rotate::fillPressed) ); - fill->set_active (true); show_all (); } @@ -56,17 +47,10 @@ void Rotate::read (const ProcParams* pp, const ParamsEdited* pedited) { disableListener (); - if (pedited) { + if (pedited) degree->setEditedState (pedited->rotate.degree ? Edited : UnEdited); - fill->set_inconsistent (!pedited->rotate.fill); - } degree->setValue (pp->rotate.degree); - fillConn.block (true); - fill->set_active (pp->rotate.fill); - fillConn.block (false); - - lastFill = pp->rotate.fill; enableListener (); } @@ -74,12 +58,9 @@ void Rotate::read (const ProcParams* pp, const ParamsEdited* pedited) { void Rotate::write (ProcParams* pp, ParamsEdited* pedited) { pp->rotate.degree = degree->getValue (); - pp->rotate.fill = fill->get_active (); - if (pedited) { + if (pedited) pedited->rotate.degree = degree->getEditedState (); - pedited->rotate.fill = !fill->get_inconsistent(); - } } void Rotate::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited) { @@ -112,40 +93,10 @@ void Rotate::selectStraightPressed () { rlistener->straightenRequested (); } -void Rotate::autoCropPressed () { - - if (rlistener) - rlistener->autoCropRequested (); -} - -void Rotate::fillPressed () { - - if (batchMode) { - if (fill->get_inconsistent()) { - fill->set_inconsistent (false); - fillConn.block (true); - fill->set_active (false); - fillConn.block (false); - } - else if (lastFill) - fill->set_inconsistent (true); - - lastFill = fill->get_active (); - } - - if (listener) { - if (fill->get_active()) - listener->panelChanged (EvROTDegree, M("TP_ROTATE_FILL")+' '+M("GENERAL_ENABLED")); - else - listener->panelChanged (EvROTFill, M("TP_ROTATE_FILL")+' '+M("GENERAL_DISABLED")); - } -} - void Rotate::setBatchMode (bool batchMode) { ToolPanel::setBatchMode (batchMode); degree->showEditedCB (); - removeIfThere (this, autoCrop); } void Rotate::setAdjusterBehavior (bool brotadd) { diff --git a/rtgui/rotate.h b/rtgui/rotate.h index a4b215d17..5a2ea0bb8 100644 --- a/rtgui/rotate.h +++ b/rtgui/rotate.h @@ -22,25 +22,15 @@ #include #include #include - -class RotateListener { - - public: - virtual void straightenRequested () {} - virtual void autoCropRequested () {} -}; +#include class Rotate : public Gtk::VBox, public AdjusterListener, public ToolPanel { protected: Adjuster* degree; Gtk::Button* selectStraight; - Gtk::Button* autoCrop; - RotateListener* rlistener; - Gtk::CheckButton* fill; + LensGeomListener* rlistener; bool degAdd; - bool lastFill; - sigc::connection fillConn; public: @@ -56,9 +46,7 @@ class Rotate : public Gtk::VBox, public AdjusterListener, public ToolPanel { void adjusterChanged (Adjuster* a, double newval); void setAdjusterBehavior (bool brotadd); void selectStraightPressed (); - void fillPressed (); - void autoCropPressed (); - void setRotateListener (RotateListener* l) { rlistener = l; } + void setLensGeomListener (LensGeomListener* l) { rlistener = l; } }; #endif diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 8d6ec4d61..df8c7cc13 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -39,10 +39,12 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(NULL) { lcurve = Gtk::manage (new LCurve ()); colorboost = Gtk::manage (new ColorBoost ()); colorshift = Gtk::manage (new ColorShift ()); + lensgeom = Gtk::manage (new LensGeometry ()); distortion = Gtk::manage (new Distortion ()); rotate = Gtk::manage (new Rotate ()); whitebalance = Gtk::manage (new WhiteBalance ()); vignetting = Gtk::manage (new Vignetting ()); + perspective = Gtk::manage (new PerspCorrection ()); cacorrection = Gtk::manage (new CACorrection ()); hlrecovery = Gtk::manage (new HLRecovery ()); chmixer = Gtk::manage (new ChMixer ()); @@ -64,11 +66,13 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(NULL) { addPanel (detailsPanel, lumadenoise, M("TP_LUMADENOISE_LABEL")); toolPanels.push_back (lumadenoise); addPanel (detailsPanel, colordenoise, M("TP_COLORDENOISE_LABEL")); toolPanels.push_back (colordenoise); addPanel (transformPanel, crop, M("TP_CROP_LABEL")); toolPanels.push_back (crop); - addPanel (transformPanel, rotate, M("TP_ROTATE_LABEL")); toolPanels.push_back (rotate); - addPanel (transformPanel, distortion, M("TP_DISTORTION_LABEL")); toolPanels.push_back (distortion); - addPanel (transformPanel, cacorrection, M("TP_CACORRECTION_LABEL")); toolPanels.push_back (cacorrection); - addPanel (transformPanel, vignetting, M("TP_VIGNETTING_LABEL")); toolPanels.push_back (vignetting); addPanel (transformPanel, resize, M("TP_RESIZE_LABEL")); toolPanels.push_back (resize); + addPanel (transformPanel, lensgeom, M("TP_LENSGEOM_LABEL")); toolPanels.push_back (lensgeom); + addPanel (lensgeom->getPackBox(), rotate, M("TP_ROTATE_LABEL")); toolPanels.push_back (rotate); + addPanel (lensgeom->getPackBox(), perspective, M("TP_PERSPECTIVE_LABEL")); toolPanels.push_back (perspective); + addPanel (lensgeom->getPackBox(), distortion, M("TP_DISTORTION_LABEL")); toolPanels.push_back (distortion); + addPanel (lensgeom->getPackBox(), cacorrection, M("TP_CACORRECTION_LABEL")); toolPanels.push_back (cacorrection); + addPanel (lensgeom->getPackBox(), vignetting, M("TP_VIGNETTING_LABEL")); toolPanels.push_back (vignetting); addPanel (colorPanel, icm, M("TP_ICM_LABEL")); toolPanels.push_back (icm); toolPanels.push_back (coarse); @@ -110,7 +114,8 @@ ToolPanelCoordinator::ToolPanelCoordinator () : ipc(NULL) { whitebalance->setWBProvider (this); whitebalance->setSpotWBListener (this); - rotate->setRotateListener (this); + lensgeom->setLensGeomListener (this); + rotate->setLensGeomListener (this); crop->setCropPanelListener (this); icm->setICMPanelListener (this); diff --git a/rtgui/toolpanelcoord.h b/rtgui/toolpanelcoord.h index 9501c65d3..f3215b287 100644 --- a/rtgui/toolpanelcoord.h +++ b/rtgui/toolpanelcoord.h @@ -45,16 +45,20 @@ #include #include #include +#include #include #include #include +#include +#include + class ImageEditorCoordinator; class ToolPanelCoordinator : public ToolPanelListener, public ProfileChangeListener, public WBProvider, - public RotateListener, + public LensGeomListener, public SpotWBListener, public CropPanelListener, public ICMPanelListener, @@ -64,8 +68,10 @@ class ToolPanelCoordinator : public ToolPanelListener, WhiteBalance* whitebalance; Vignetting* vignetting; + LensGeometry* lensgeom; Rotate* rotate; Distortion* distortion; + PerspCorrection* perspective; CACorrection* cacorrection; ColorShift* colorshift; HLRecovery* hlrecovery;