Custom profile builder GUI and capsulation

see issue #704
This commit is contained in:
Oliver Duis
2011-05-29 00:59:44 +02:00
parent 19ca183795
commit a64a6d1b2c
6 changed files with 72 additions and 28 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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)

View File

@@ -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;

View File

@@ -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

View File

@@ -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 ();