From a64a6d1b2c6b1eaabe69f0190f867c4a52ea16f3 Mon Sep 17 00:00:00 2001 From: Oliver Duis Date: Sun, 29 May 2011 00:59:44 +0200 Subject: [PATCH] Custom profile builder GUI and capsulation see issue #704 --- rtdata/languages/default | 3 +++ rtgui/editorpanel.cc | 33 +++++---------------------------- rtgui/preferences.cc | 24 ++++++++++++++++++++++++ rtgui/preferences.h | 3 +++ rtgui/thumbnail.cc | 33 +++++++++++++++++++++++++++++++++ rtgui/thumbnail.h | 4 ++++ 6 files changed, 72 insertions(+), 28 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 83dd58ef9..28d489348 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -519,6 +519,9 @@ PREFERENCES_CACHETHUMBFORM;Cache Thumbnail Format PREFERENCES_CACHETHUMBHEIGHT;Maximal Thumbnail Height PREFERENCES_CLIPPINGIND;Clipping indication PREFERENCES_CMETRICINTENT;Colorimetric Intent +PREFERENCES_CUSTPROFBUILD;Custom image profile builder +PREFERENCES_CUSTPROFBUILDHINT;Executable (or script) file called when a new initial profile should be generated an image.\nReceives command line params to allow a rules based .pp3 generation:\n[Path RAW/JPG] [Path default profile] [f-no] [exposure in secs] [focal length in mm] [ISO] [Lens] [Camera] +PREFERENCES_CUSTPROFBUILDPATH;Executable path PREFERENCES_CUTOVERLAYBRUSH;Crop mask color/transparency PREFERENCES_DARKFRAME;Dark frame PREFERENCES_DARKFRAMEFOUND;Found diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index a6f002ee4..905af7e5c 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -383,37 +383,14 @@ void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc) { navigator->previewWindow->setPreviewHandler (previewHandler); navigator->previewWindow->setImageArea (iarea->imageArea); - // try to load the last saved parameters from the cache or from the paramfile file - ProcParams* ldprof = NULL; - - Glib::ustring defProf = openThm->getType()==FT_Raw ? options.defProfRaw : options.defProfImg; - - const CacheImageData* cfs=openThm->getCacheImageData(); - if (!options.customProfileBuilder.empty() && !openThm->hasProcParams() && cfs && cfs->exifValid) { - // For the filename etc. do NOT use streams, since they are not UTF8 safe - Glib::ustring cmdLine=Glib::ustring("\"") + options.customProfileBuilder + Glib::ustring("\" \"") + fname + Glib::ustring("\" \"") - + options.rtdir + Glib::ustring("/") + options.profilePath + Glib::ustring("/") + defProf + Glib::ustring(".pp3") + Glib::ustring("\" "); - - // ustring doesn't know int etc formatting, so take these via (unsafe) stream - std::ostringstream strm; - strm << cfs->fnumber << Glib::ustring(" ") << cfs->shutter << Glib::ustring(" "); - strm << cfs->focalLen << Glib::ustring(" ") << cfs->iso << Glib::ustring(" \""); - strm << cfs->lens << Glib::ustring("\" \"") << cfs->camera << Glib::ustring("\""); - - bool success = safe_spawn_command_line_sync (cmdLine + strm.str()); - - // Now they SHOULD be there, so try to load them - if (success) openThm->loadProcParams(); - } - - if (openThm->hasProcParams()) { - ldprof = new ProcParams (); - *ldprof = openThm->getProcParams (); - } - rtengine::ImageSource* is=isrc->getImageSource(); is->setProgressListener( this ); + + // try to load the last saved parameters from the cache or from the paramfile file + ProcParams* ldprof = openThm->createProcParamsForUpdate(); // will be freed by initProfile + // initialize profile + Glib::ustring defProf = openThm->getType()==FT_Raw ? options.defProfRaw : options.defProfImg; profilep->initProfile (defProf, ldprof, NULL); openThm->addThumbnailListener (this); diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index 8f313e355..b880602d6 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -568,6 +568,27 @@ Gtk::Widget* Preferences::getGeneralPanel () { fdg->add (*dgvb); mvbsd->pack_start (*fdg, Gtk::PACK_SHRINK, 4); + + // Custom profile builder box + Gtk::Frame* cpfrm = Gtk::manage( new Gtk::Frame (M("PREFERENCES_CUSTPROFBUILD")) ); + + Gtk::HBox* cphb = Gtk::manage( new Gtk::HBox () ); + cphb->set_border_width (4); + cphb->set_spacing (4); + + Gtk::Label* cplab = Gtk::manage( new Gtk::Label (M("PREFERENCES_CUSTPROFBUILDPATH")+":") ); + cphb->pack_start (*cplab, Gtk::PACK_SHRINK,4); + + txtCustProfBuilderPath = Gtk::manage( new Gtk::Entry () ); + txtCustProfBuilderPath->set_tooltip_markup (M("PREFERENCES_CUSTPROFBUILDHINT")); + cphb->set_tooltip_markup (M("PREFERENCES_CUSTPROFBUILDHINT")); + cphb->pack_start (*txtCustProfBuilderPath); + + cpfrm->add (*cphb); + + mvbsd->pack_start (*cpfrm, Gtk::PACK_SHRINK, 4); + + mvbsd->set_border_width (4); tconn = theme->signal_changed().connect( sigc::mem_fun(*this, &Preferences::themeChanged) ); @@ -842,6 +863,7 @@ void Preferences::storePreferences () { else if (edOther->get_active ()) moptions.editorToSendTo = 3; + moptions.customProfileBuilder = txtCustProfBuilderPath->get_text(); moptions.rtSettings.monitorProfile = monProfile->get_filename (); moptions.rtSettings.autoMonitorProfile = cbAutoMonProfile->get_active (); @@ -955,6 +977,8 @@ void Preferences::fillPreferences () { #endif editorToSendTo->set_text (moptions.customEditorProg); + txtCustProfBuilderPath->set_text(moptions.customProfileBuilder); + if (moptions.startupDir==STARTUPDIR_CURRENT) sdcurrent->set_active (); else if (moptions.startupDir==STARTUPDIR_LAST) diff --git a/rtgui/preferences.h b/rtgui/preferences.h index 52475d8f1..50d174316 100644 --- a/rtgui/preferences.h +++ b/rtgui/preferences.h @@ -117,6 +117,9 @@ class Preferences : public Gtk::Dialog { Gtk::CheckButton* ckbTunnelMetaData; Gtk::CheckButton* ckbInternalThumbIfUntouched; + Gtk::Entry* txtCustProfBuilderPath; + + Options moptions; sigc::connection tconn, fconn, usethcon, addc, setc, dfconn, ffconn, autoMonProfileConn; Glib::ustring initialTheme; diff --git a/rtgui/thumbnail.cc b/rtgui/thumbnail.cc index 0df11aad6..51d18a01f 100644 --- a/rtgui/thumbnail.cc +++ b/rtgui/thumbnail.cc @@ -161,6 +161,39 @@ const ProcParams& Thumbnail::getProcParams () { return pparams; // there is no valid pp to return, but we have to return something } +// Create default params on demand and returns a new updatable object +rtengine::procparams::ProcParams* Thumbnail::createProcParamsForUpdate() { + // try to load the last saved parameters from the cache or from the paramfile file + ProcParams* ldprof = NULL; + + Glib::ustring defProf = getType()==FT_Raw ? options.defProfRaw : options.defProfImg; + + const CacheImageData* cfs=getCacheImageData(); + if (!options.customProfileBuilder.empty() && !hasProcParams() && cfs && cfs->exifValid) { + // For the filename etc. do NOT use streams, since they are not UTF8 safe + Glib::ustring cmdLine=Glib::ustring("\"") + options.customProfileBuilder + Glib::ustring("\" \"") + fname + Glib::ustring("\" \"") + + options.rtdir + Glib::ustring("/") + options.profilePath + Glib::ustring("/") + defProf + Glib::ustring(".pp3") + Glib::ustring("\" "); + + // ustring doesn't know int etc formatting, so take these via (unsafe) stream + std::ostringstream strm; + strm << cfs->fnumber << Glib::ustring(" ") << cfs->shutter << Glib::ustring(" "); + strm << cfs->focalLen << Glib::ustring(" ") << cfs->iso << Glib::ustring(" \""); + strm << cfs->lens << Glib::ustring("\" \"") << cfs->camera << Glib::ustring("\""); + + bool success = safe_spawn_command_line_sync (cmdLine + strm.str()); + + // Now they SHOULD be there, so try to load them + if (success) loadProcParams(); + } + + if (hasProcParams()) { + ldprof = new ProcParams (); + *ldprof = getProcParams (); + } + + return ldprof; +} + void Thumbnail::loadProcParams () { // TODO: Check for Linux #ifdef WIN32 diff --git a/rtgui/thumbnail.h b/rtgui/thumbnail.h index 262e9d84e..163b61618 100644 --- a/rtgui/thumbnail.h +++ b/rtgui/thumbnail.h @@ -79,6 +79,10 @@ class Thumbnail { bool hasProcParams (); const rtengine::procparams::ProcParams& getProcParams (); + + // Use this to create params on demand for update + rtengine::procparams::ProcParams* createProcParamsForUpdate (); + void setProcParams (const rtengine::procparams::ProcParams& pp, int whoChangedIt=-1, bool updateCacheNow=true); void clearProcParams (int whoClearedIt=-1); void loadProcParams ();