diff --git a/rtengine/iimage.h b/rtengine/iimage.h index 01c4ef716..4d01b9eb9 100644 --- a/rtengine/iimage.h +++ b/rtengine/iimage.h @@ -94,6 +94,10 @@ namespace rtengine { dstValue = (unsigned char)(srcValue >> 8); } template <> + inline void ImageDatas::convertTo (unsigned char srcValue, int &dstValue) { + dstValue = (int)(srcValue) << 8; + } + template <> inline void ImageDatas::convertTo (unsigned char srcValue, unsigned short &dstValue) { dstValue = (unsigned short)(srcValue) << 8; } @@ -435,31 +439,40 @@ namespace rtengine { for (int i=0; i>histcompr]++; - histogram[(int)Color::igamma_srgb (g(i,j))>>histcompr]++; - histogram[(int)Color::igamma_srgb (b(i,j))>>histcompr]++; + float r_, g_, b_; + convertTo(r(i,j), r_); + convertTo(g(i,j), g_); + convertTo(b(i,j), b_); + histogram[(int)Color::igamma_srgb (r_)>>histcompr]++; + histogram[(int)Color::igamma_srgb (g_)>>histcompr]++; + histogram[(int)Color::igamma_srgb (b_)>>histcompr]++; } } - void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, int compression) { + void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, const int compression) { histogram.clear(); + avg_r = avg_g = avg_b = 0.; + n=0; for (unsigned int i=0; i<(unsigned int)(height); i++) for (unsigned int j=0; j<(unsigned int)(width); j++) { - int rtmp = Color::igamma_srgb (r(i,j)); - int gtmp = Color::igamma_srgb (g(i,j)); - int btmp = Color::igamma_srgb (b(i,j)); + float r_, g_, b_; + convertTo(r(i,j), r_); + convertTo(g(i,j), g_); + convertTo(b(i,j), b_); + int rtemp = Color::igamma_srgb (r_); + int gtemp = Color::igamma_srgb (g_); + int btemp = Color::igamma_srgb (b_); - histogram[rtmp>>compression]++; - histogram[gtmp>>compression]+=2; - histogram[btmp>>compression]++; + histogram[rtemp>>compression]++; + histogram[gtemp>>compression]+=2; + histogram[btemp>>compression]++; - if (rtmp<64000 && gtmp<64000 && btmp<64000) { - // autowb computation - avg_r += rtmp; - avg_g += gtmp; - avg_b += btmp; - n++; - } + // autowb computation + if (r_>64000.f || g_>64000.f || b_>64000.f) continue; + avg_r += double(r_); + avg_g += double(g_); + avg_b += double(b_); + n++; } } @@ -471,46 +484,23 @@ namespace rtengine { int n = 0; //int p = 6; - for (int i=1; i64000 || g(i, j)>64000 || b(i, j)>64000) - continue; - avg_r += SQR(r(i, j)); - avg_g += SQR(g(i, j)); - avg_b += SQR(b(i, j)); + for (unsigned int i=0; i<(unsigned int)(height); i++) + for (unsigned int j=0; j<(unsigned int)(width); j++) { + float r_, g_, b_; + convertTo(r(i,j), r_); + convertTo(g(i,j), g_); + convertTo(b(i,j), b_); + + if (r_>64000.f || g_>64000.f || b_>64000.f) continue; + avg_r += double(r_); + avg_g += double(g_); + avg_b += double(b_); /*avg_r += intpow( (double)r(i, j), p); avg_g += intpow( (double)g(i, j), p); avg_b += intpow( (double)b(i, j), p);*/ - n++; } - for (int i=1; i64000 || g(i, j)>64000 || b(i, j)>64000) - continue; - avg_r += SQR(r(i, j)); - avg_g += SQR(g(i, j)); - avg_b += SQR(b(i, j)); - /*avg_r += intpow((double)r(i, j), p); - avg_g += intpow((double)g(i, j), p); - avg_b += intpow((double)b(i, j), p);*/ - - n++; - } - for (int i=1; i64000 || g(i, j)>64000 || b(i, j)>64000) - continue; - avg_r += SQR(r(i, j)); - avg_g += SQR(g(i, j)); - avg_b += SQR(b(i, j)); - /*avg_r += intpow((double)r(i, j), p); - avg_g += intpow((double)g(i, j), p); - avg_b += intpow((double)b(i, j), p);*/ - - n++; - } - return ColorTemp (sqrt(avg_r/n), sqrt(avg_g/n), sqrt(avg_b/n)); + return ColorTemp (avg_r/double(n), avg_g/double(n), avg_b/double(n)); //return ColorTemp (pow(avg_r/n, 1.0/p), pow(avg_g/n, 1.0/p), pow(avg_b/n, 1.0/p)); } @@ -557,17 +547,23 @@ namespace rtengine { for (size_t i=0; i=0 && y>=0 && xr(y, x); + float v; + convertTo(this->r(y, x), v); + reds += double(v); rn++; } transformPixel (green[i].x, green[i].y, tran, x, y); if (x>=0 && y>=0 && xg(y, x); + float v; + convertTo(this->g(y, x), v); + greens += double(v); gn++; } transformPixel (blue[i].x, blue[i].y, tran, x, y); if (x>=0 && y>=0 && xb(y, x); + float v; + convertTo(this->b(y, x), v); + blues += double(v); bn++; } } @@ -872,31 +868,40 @@ namespace rtengine { for (int i=0; i>histcompr]++; - histogram[(int)Color::igamma_srgb (g(i,j))>>histcompr]++; - histogram[(int)Color::igamma_srgb (b(i,j))>>histcompr]++; + float r_, g_, b_; + convertTo(r(i,j), r_); + convertTo(g(i,j), g_); + convertTo(b(i,j), b_); + histogram[(int)Color::igamma_srgb (r_)>>histcompr]++; + histogram[(int)Color::igamma_srgb (g_)>>histcompr]++; + histogram[(int)Color::igamma_srgb (b_)>>histcompr]++; } } - void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, int compression) { + void computeHistogramAutoWB (double &avg_r, double &avg_g, double &avg_b, int &n, LUTu &histogram, const int compression) { histogram.clear(); + avg_r = avg_g = avg_b = 0.; + n=0; for (unsigned int i=0; i<(unsigned int)(height); i++) for (unsigned int j=0; j<(unsigned int)(width); j++) { - int rtmp = Color::igamma_srgb (r(i,j)); - int gtmp = Color::igamma_srgb (g(i,j)); - int btmp = Color::igamma_srgb (b(i,j)); + float r_, g_, b_; + convertTo(r(i,j), r_); + convertTo(g(i,j), g_); + convertTo(b(i,j), b_); + int rtemp = Color::igamma_srgb (r_); + int gtemp = Color::igamma_srgb (g_); + int btemp = Color::igamma_srgb (b_); - histogram[rtmp>>compression]++; - histogram[gtmp>>compression]+=2; - histogram[btmp>>compression]++; + histogram[rtemp>>compression]++; + histogram[gtemp>>compression]+=2; + histogram[btemp>>compression]++; - if (rtmp<64000 && gtmp<64000 && btmp<64000) { - // autowb computation - avg_r += rtmp; - avg_g += gtmp; - avg_b += btmp; - n++; - } + // autowb computation + if (r_>64000.f || g_>64000.f || b_>64000.f) continue; + avg_r += double(r_); + avg_g += double(g_); + avg_b += double(b_); + n++; } } @@ -908,46 +913,23 @@ namespace rtengine { int n = 0; //int p = 6; - for (int i=1; i64000 || g(i, j)>64000 || b(i, j)>64000) - continue; - avg_r += SQR(r(i, j)); - avg_g += SQR(g(i, j)); - avg_b += SQR(b(i, j)); + for (unsigned int i=0; i<(unsigned int)(height); i++) + for (unsigned int j=0; j<(unsigned int)(width); j++) { + float r_, g_, b_; + convertTo(r(i,j), r_); + convertTo(g(i,j), g_); + convertTo(b(i,j), b_); + + if (r_>64000.f || g_>64000.f || b_>64000.f) continue; + avg_r += double(r_); + avg_g += double(g_); + avg_b += double(b_); /*avg_r += intpow( (double)r(i, j), p); avg_g += intpow( (double)g(i, j), p); avg_b += intpow( (double)b(i, j), p);*/ - n++; } - for (int i=1; i64000 || g(i, j)>64000 || b(i, j)>64000) - continue; - avg_r += SQR(r(i, j)); - avg_g += SQR(g(i, j)); - avg_b += SQR(b(i, j)); - /*avg_r += intpow((double)r(i, j), p); - avg_g += intpow((double)g(i, j), p); - avg_b += intpow((double)b(i, j), p);*/ - - n++; - } - for (int i=1; i64000 || g(i, j)>64000 || b(i, j)>64000) - continue; - avg_r += SQR(r(i, j)); - avg_g += SQR(g(i, j)); - avg_b += SQR(b(i, j)); - /*avg_r += intpow((double)r(i, j), p); - avg_g += intpow((double)g(i, j), p); - avg_b += intpow((double)b(i, j), p);*/ - - n++; - } - return ColorTemp (sqrt(avg_r/n), sqrt(avg_g/n), sqrt(avg_b/n)); + return ColorTemp (avg_r/double(n), avg_g/double(n), avg_b/double(n)); //return ColorTemp (pow(avg_r/n, 1.0/p), pow(avg_g/n, 1.0/p), pow(avg_b/n, 1.0/p)); } @@ -994,17 +976,23 @@ namespace rtengine { for (size_t i=0; i=0 && y>=0 && xr(y, x); + float v; + convertTo(this->r(y, x), v); + reds += double(v); rn++; } transformPixel (green[i].x, green[i].y, tran, x, y); if (x>=0 && y>=0 && xg(y, x); + float v; + convertTo(this->g(y, x), v); + greens += double(v); gn++; } transformPixel (blue[i].x, blue[i].y, tran, x, y); if (x>=0 && y>=0 && xb(y, x); + float v; + convertTo(this->b(y, x), v); + blues += double(v); bn++; } } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index d2520e468..13a290659 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -162,25 +162,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { { if (settings->verbose) printf("Demosaic %s\n",rp.dmethod.c_str()); - - //TODO - denoise branch - is this code for WB params still necessary? - currWB = ColorTemp (params.wb.temperature, params.wb.green, params.wb.method); - if (params.wb.method=="Camera") - currWB = imgsrc->getWB (); - else if (params.wb.method=="Auto") { - if (!awbComputed) { - autoWB = imgsrc->getAutoWB (); - awbComputed = true; - } - currWB = autoWB; - } - params.wb.temperature = currWB.getTemp (); - params.wb.green = currWB.getGreen (); - - imgsrc->demosaic( rp ); - //imgsrc->getImage (currWB, tr, orig_prev, pp, params.hlrecovery, params.icm, params.raw); - //imgsrc->convertColorSpace(orig_prev, params.icm, params.raw); + imgsrc->demosaic( rp ); if (highDetailNeeded) { highDetailRawComputed = true; @@ -190,8 +173,6 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { } else highDetailRawComputed = false; - - } diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 5577fcc10..4c77ecbaa 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2222,7 +2222,7 @@ void RawImageSource::getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LU if (ri->isBayer()) { for (int j=start; jdata[i][j]-(cblacksom[c4]/*+black_lev[c4]*/)))); switch (c) { @@ -2279,35 +2279,31 @@ void RawImageSource::getRowStartEnd (int x, int &start, int &end) { int end = min(H+W-fw-i, fw+i) - 32; for (int j=start; jisBayer()) { - double d = CLIP(initialGain*(rawData[i][3*j])); - if (d>64000) - continue; - avg_r += d; rn++; - d = CLIP(initialGain*(rawData[i][3*j+1])); - if (d>64000) - continue; - avg_g += d; gn++; - d = CLIP(initialGain*(rawData[i][3*j+2])); - if (d>64000) - continue; - avg_b += d; bn++; + double dr = CLIP(initialGain*(rawData[i][3*j] )); + double dg = CLIP(initialGain*(rawData[i][3*j+1])); + double db = CLIP(initialGain*(rawData[i][3*j+2])); + if (dr>64000. || dg>64000. || db>64000.) continue; + avg_r += dr; + avg_g += dg; + avg_b += db; + rn = gn = ++bn; } else { int c = FC( i, j); double d = CLIP(initialGain*(rawData[i][j])); - if (d>64000) + if (d>64000.) continue; - double dp = d; - if (c==0) { - avg_r += dp; - rn++; - } - else if (c==1) { - avg_g += dp; + // Let's test green first, because they are more numerous + if (c==1) { + avg_g += d; gn++; } - else if (c==2) { - avg_b += dp; + else if (c==0) { + avg_r += d; + rn++; + } + else /*if (c==2)*/ { + avg_b += d; bn++; } } @@ -2318,10 +2314,12 @@ void RawImageSource::getRowStartEnd (int x, int &start, int &end) { if (!ri->isBayer()) { for (int i=32; i64000 || dg>64000 || db>64000) continue; + if (dr>64000. || dg>64000. || db>64000.) continue; avg_r += dr; rn++; avg_g += dg; avg_b += db; @@ -2338,19 +2336,28 @@ void RawImageSource::getRowStartEnd (int x, int &start, int &end) { double d[2][2]; for (int i=32; i64000 || d[0][1]>64000 || d[1][0]>64000 || d[1][1]>64000 ) continue; - avg_r += d[ey][ex]; - avg_g += d[1-ey][ex] + d[ey][1-ex]; - avg_b += d[1-ey][1-ex]; - rn++; + if (d[ey][ex] <= 64000.) { + avg_r += d[ey][ex]; + rn++; + } + if (d[1-ey][ex] <= 64000.) { + avg_g += d[1-ey][ex]; + gn++; + } + if (d[ey][1-ex] <= 64000.) { + avg_g += d[ey][1-ex]; + gn++; + } + if (d[1-ey][1-ex] <= 64000.) { + avg_b += d[1-ey][1-ex]; + bn++; + } } - gn = 2*rn; - bn = rn; } } if( settings->verbose ) diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 2539d8e99..9c9b270bf 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -124,7 +124,7 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h, if (n>0) { ColorTemp cTemp; - cTemp.mul2temp (avg_r/n, avg_g/n, avg_b/n, tpp->autowbTemp, tpp->autowbGreen); + cTemp.mul2temp (avg_r/double(n), avg_g/double(n), avg_b/double(n), tpp->autowbTemp, tpp->autowbGreen); } tpp->init (); @@ -435,21 +435,21 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati for (int j = start; j < end; j++) { if (FISGREEN(filter,i,j)) { double d = tpp->defGain * image[i * width + j][1]; - if (d > 64000) + if (d > 64000.) continue; avg_g += d; gn++; } - if (FISRED(filter,i,j)) { + else if (FISRED(filter,i,j)) { double d = tpp->defGain * image[i * width + j][0]; - if (d > 64000) + if (d > 64000.) continue; avg_r += d; rn++; } - if (FISBLUE(filter,i,j)) { + else if (FISBLUE(filter,i,j)) { double d = tpp->defGain * image[i * width + j][2]; - if (d > 64000) + if (d > 64000.) continue; avg_b += d; bn++; @@ -542,11 +542,8 @@ IImage8* Thumbnail::quickProcessImage (const procparams::ProcParams& params, int Image8* baseImg = resizeTo(rwidth, rheight, interp, thumbImg); - if (params.coarse.rotate) { - printf("Thumbnail::quickProcessImage: demande la rotation de l'image de %d degres / %d(%d) x %d(%d) devient ", params.coarse.rotate, baseImg->getW(), baseImg->getWidth(), baseImg->getH(), baseImg->getHeight()); + if (params.coarse.rotate) baseImg->rotate (params.coarse.rotate); - printf("%d(%d) x %d(%d)\n", baseImg->getW(), baseImg->getWidth(), baseImg->getH(), baseImg->getHeight()); - } if (params.coarse.hflip) baseImg->hflip (); @@ -907,9 +904,6 @@ void Thumbnail::getSpotWB (const procparams::ProcParams& params, int xp, int yp, if (params.coarse.vflip) tr |= TR_VFLIP; // calculate spot wb (copy & pasted from stdimagesource) - unsigned short igammatab[256]; - for (int i=0; i<256; i++) - igammatab[i] = (unsigned short)(255.0*pow(i/255.0,Color::sRGBGamma)); double reds = 0, greens = 0, blues = 0; int rn = 0, gn = 0, bn = 0; thumbImg->getSpotWBData(reds, greens, blues, rn, gn, bn, red, green, blue, tr); diff --git a/rtengine/stdimagesource.cc b/rtengine/stdimagesource.cc index 0ba498763..090d8abe7 100644 --- a/rtengine/stdimagesource.cc +++ b/rtengine/stdimagesource.cc @@ -302,7 +302,8 @@ ColorTemp StdImageSource::getSpotWB (std::vector &red, std::vectorgetSpotWBData(reds, greens, blues, rn, gn, bn, red, green, blue, tran); double img_r, img_g, img_b; wb.getMultipliers (img_r, img_g, img_b); - printf ("AVG: %g %g %g\n", reds/rn, greens/gn, blues/bn); + if( settings->verbose ) + printf ("AVG: %g %g %g\n", reds/rn, greens/gn, blues/bn); return ColorTemp (reds/rn*img_r, greens/gn*img_g, blues/bn*img_b); } diff --git a/rtgui/filebrowserentry.cc b/rtgui/filebrowserentry.cc index c6058e25c..69d21401e 100644 --- a/rtgui/filebrowserentry.cc +++ b/rtgui/filebrowserentry.cc @@ -324,6 +324,9 @@ bool FileBrowserEntry::pressNotify (int button, int type, int bstate, int x, i bool b = ThumbBrowserEntryBase::pressNotify (button, type, bstate, x, y); + if (!iatlistener || !iatlistener->getToolBar()) + return true; + ToolMode tm = iatlistener->getToolBar()->getTool (); int ix = x - startx - ofsX; int iy = y - starty - ofsY; @@ -407,13 +410,13 @@ bool FileBrowserEntry::releaseNotify (int button, int type, int bstate, int x, i if (!b) { if (state==SRotateSelecting) { iatlistener->rotateSelectionReady (rot_deg, thumbnail); - iatlistener->getToolBar()->setTool (TMHand); + if (iatlistener->getToolBar()) iatlistener->getToolBar()->setTool (TMHand); } else if (cropgl && (state==SCropSelecting || state==SResizeH1 || state==SResizeH2 || state==SResizeW1 || state==SResizeW2 || state==SCropMove)) { cropgl->cropManipReady (); cropgl = NULL; iatlistener->cropSelectionReady (); - iatlistener->getToolBar()->setTool (TMHand); + if (iatlistener->getToolBar()) iatlistener->getToolBar()->setTool (TMHand); } state = SNormal; if (parent) @@ -472,7 +475,7 @@ bool FileBrowserEntry::onArea (CursorArea a, int x, int y) { void FileBrowserEntry::updateCursor (int x, int y) { - if (!iatlistener) + if (!iatlistener || !iatlistener->getToolBar()) return; ToolMode tm = iatlistener->getToolBar()->getTool (); diff --git a/rtgui/filepanel.cc b/rtgui/filepanel.cc index 34041a40d..bf670a4a0 100644 --- a/rtgui/filepanel.cc +++ b/rtgui/filepanel.cc @@ -49,6 +49,7 @@ FilePanel::FilePanel () : parent(NULL) { dirpaned->pack1 (*placespaned, false, true); tpc = new BatchToolPanelCoordinator (this); + tpc->removeWbTool(); fileCatalog = Gtk::manage ( new FileCatalog (tpc->coarse, tpc->getToolBar(),this) ); ribbonPane = Gtk::manage ( new Gtk::Paned() ); ribbonPane->add(*fileCatalog); @@ -247,7 +248,7 @@ bool FilePanel::handleShortcutKey (GdkEventKey* event) { } } - if(tpc->getToolBar()->handleShortcutKey(event)) + if(tpc->getToolBar() && tpc->getToolBar()->handleShortcutKey(event)) return true; if(tpc->handleShortcutKey(event)) diff --git a/rtgui/imagearea.cc b/rtgui/imagearea.cc index e56fc44ea..de95e526a 100644 --- a/rtgui/imagearea.cc +++ b/rtgui/imagearea.cc @@ -455,7 +455,7 @@ void ImageArea::setPointerMotionHListener (PointerMotionListener* pml) { ToolMode ImageArea::getToolMode () { - if (listener) + if (listener && listener->getToolBar()) return listener->getToolBar()->getTool (); else return TMHand; @@ -463,7 +463,7 @@ ToolMode ImageArea::getToolMode () { void ImageArea::setToolHand () { - if (listener) + if (listener && listener->getToolBar()) listener->getToolBar()->setTool (TMHand); } diff --git a/rtgui/imageareatoollistener.h b/rtgui/imageareatoollistener.h index 7e7900b43..cc26c70a8 100644 --- a/rtgui/imageareatoollistener.h +++ b/rtgui/imageareatoollistener.h @@ -31,6 +31,7 @@ class ImageAreaToolListener { virtual void cropSelectionReady () {} virtual void rotateSelectionReady (double rotate_deg, Thumbnail* thm=NULL) {} virtual ToolBar* getToolBar () { return NULL; } + virtual void removeWbTool() =0; virtual CropGUIListener* startCropEditing (Thumbnail* thm=NULL) { return NULL; } }; diff --git a/rtgui/thumbnail.h b/rtgui/thumbnail.h index 63c3422a6..c88dbe7ef 100644 --- a/rtgui/thumbnail.h +++ b/rtgui/thumbnail.h @@ -108,9 +108,9 @@ class Thumbnail { const Glib::ustring& getExifString (); const Glib::ustring& getDateTimeString (); - void getCamWB (double& temp, double& green) { if (tpp) tpp->getCamWB (temp, green); } - void getAutoWB (double& temp, double& green) { if (tpp) tpp->getAutoWB (temp, green); } - void getSpotWB (int x, int y, int rect, double& temp, double& green) { if (tpp) tpp->getSpotWB (getProcParams(), x, y, rect, temp, green); } + void getCamWB (double& temp, double& green) { if (tpp) tpp->getCamWB (temp, green); else temp = green = -1.0; } + void getAutoWB (double& temp, double& green) { if (tpp) tpp->getAutoWB (temp, green); else temp = green = -1.0; } + void getSpotWB (int x, int y, int rect, double& temp, double& green) { if (tpp) tpp->getSpotWB (getProcParams(), x, y, rect, temp, green); else temp = green = -1.0; } void applyAutoExp (rtengine::procparams::ProcParams& pparams) { if (tpp) tpp->applyAutoExp (pparams); } ThFileType getType (); diff --git a/rtgui/toolbar.cc b/rtgui/toolbar.cc index 99835e2ef..de852e63d 100644 --- a/rtgui/toolbar.cc +++ b/rtgui/toolbar.cc @@ -19,8 +19,7 @@ #include "toolbar.h" #include "multilangmgr.h" #include "rtimage.h" - -extern Glib::ustring argv0; +#include "guiutils.h" ToolBar::ToolBar () : listener (NULL) { @@ -82,11 +81,11 @@ void ToolBar::setTool (ToolMode tool) { handConn.block (true); cropConn.block (true); - wbConn.block (true); + if (wbTool) wbConn.block (true); straConn.block (true); handTool->set_active (false); - wbTool->set_active (false); + if (wbTool) wbTool->set_active (false); cropTool->set_active (false); straTool->set_active (false); @@ -95,7 +94,7 @@ void ToolBar::setTool (ToolMode tool) { handTool->grab_focus();; // switch focus to the handTool button } else if (tool==TMSpotWB) - wbTool->set_active (true); + if (wbTool) wbTool->set_active (true); else if (tool==TMCropSelect) cropTool->set_active (true); else if (tool==TMStraighten) @@ -105,7 +104,7 @@ void ToolBar::setTool (ToolMode tool) { handConn.block (false); cropConn.block (false); - wbConn.block (false); + if (wbTool) wbConn.block (false); straConn.block (false); } @@ -113,10 +112,10 @@ void ToolBar::hand_pressed () { handConn.block (true); cropConn.block (true); - wbConn.block (true); + if (wbTool) wbConn.block (true); straConn.block (true); if (current!=TMHand) { - wbTool->set_active (false); + if (wbTool) wbTool->set_active (false); cropTool->set_active (false); straTool->set_active (false); current = TMHand; @@ -124,7 +123,7 @@ void ToolBar::hand_pressed () { handTool->set_active (true); handConn.block (false); cropConn.block (false); - wbConn.block (false); + if (wbTool) wbConn.block (false); straConn.block (false); if (listener) @@ -135,7 +134,7 @@ void ToolBar::wb_pressed () { handConn.block (true); cropConn.block (true); - wbConn.block (true); + if (wbTool) wbConn.block (true); straConn.block (true); if (current!=TMSpotWB) { handTool->set_active (false); @@ -143,10 +142,10 @@ void ToolBar::wb_pressed () { straTool->set_active (false); current = TMSpotWB; } - wbTool->set_active (true); + if (wbTool) wbTool->set_active (true); handConn.block (false); cropConn.block (false); - wbConn.block (false); + if (wbTool) wbConn.block (false); straConn.block (false); if (listener) @@ -157,11 +156,11 @@ void ToolBar::crop_pressed () { handConn.block (true); cropConn.block (true); - wbConn.block (true); + if (wbTool) wbConn.block (true); straConn.block (true); if (current!=TMCropSelect) { handTool->set_active (false); - wbTool->set_active (false); + if (wbTool) wbTool->set_active (false); straTool->set_active (false); current = TMCropSelect; } @@ -179,18 +178,18 @@ void ToolBar::stra_pressed () { handConn.block (true); cropConn.block (true); - wbConn.block (true); + if (wbTool) wbConn.block (true); straConn.block (true); if (current!=TMStraighten) { handTool->set_active (false); - wbTool->set_active (false); + if (wbTool) wbTool->set_active (false); cropTool->set_active (false); current = TMStraighten; } straTool->set_active (true); handConn.block (false); cropConn.block (false); - wbConn.block (false); + if (wbTool) wbConn.block (false); straConn.block (false); if (listener) @@ -231,3 +230,11 @@ bool ToolBar::handleShortcutKey (GdkEventKey* event) { return false; } +void ToolBar::removeWbTool() { + if (wbTool) { + wbConn.disconnect(); + removeIfThere(this, wbTool, false); + wbTool = NULL; + } +} + diff --git a/rtgui/toolbar.h b/rtgui/toolbar.h index e6c845552..3217f33a0 100644 --- a/rtgui/toolbar.h +++ b/rtgui/toolbar.h @@ -57,6 +57,7 @@ class ToolBar : public Gtk::HBox { void stra_pressed (); bool handleShortcutKey (GdkEventKey* event); + void removeWbTool(); }; #endif diff --git a/rtgui/toolpanelcoord.h b/rtgui/toolpanelcoord.h index a37504193..5e54a4995 100644 --- a/rtgui/toolpanelcoord.h +++ b/rtgui/toolpanelcoord.h @@ -232,6 +232,7 @@ class ToolPanelCoordinator : public ToolPanelListener, void cropSelectionReady (); void rotateSelectionReady (double rotate_deg, Thumbnail* thm=NULL); ToolBar* getToolBar () { return toolBar; } + void removeWbTool() { if (toolBar) toolBar->removeWbTool(); } int getSpotWBRectSize (); CropGUIListener* startCropEditing (Thumbnail* thm=NULL) { return crop; }