38 #include <exiv2/exiv2.hpp>
40 #include <wx/msw/registry.h>
47 RawImport(wxString ConfigExePath) {
m_exe = wxConfig::Get()->Read(ConfigExePath,
""); };
62 const wxFileName exePath(
m_exe);
63 if (exePath.IsAbsolute())
65 if (exePath.FileExists())
67 m_exe = exePath.GetFullPath();
72 wxMessageBox(wxString::Format(_(
"Executable \"%s\" not found.\nPlease specify a valid executable in preferences."), exePath.GetFullPath()),
78 wxOK | wxICON_INFORMATION, dlg);
86 pathlist.AddEnvList(wxT(
"PATH"));
87 m_exe = pathlist.FindAbsoluteValidPath(exePath.GetFullPath());
90 wxMessageBox(wxString::Format(_(
"Executable \"%s\" not found in PATH.\nPlease specify a valid executable in preferences."), exePath.GetFullPath()),
96 wxOK | wxICON_INFORMATION, dlg);
125 m_additionalParameters = XRCCTRL(*dlg,
"raw_dcraw_parameter", wxTextCtrl)->GetValue().Trim(
true).Trim(
false);
131 wxString args(
" -w -v -4 -T ");
140 args.Append(
"-overwrite_original -tagsfromfile ");
142 args.Append(
" -all:all ");
149 for (
auto& s : output)
151 int pos = s.Find(
"multipliers");
154 m_wb =
"-r " + s.Mid(pos + 12);
163 wxConfigBase* config = wxConfig::Get();
165 for (
size_t i = 0; i < rawFilenames.size(); ++i)
168 args.Append(
" -v -4 -T ");
177 args.Append(
"-overwrite_original -tagsfromfile ");
179 args.Append(
" -all:all ");
189 fill_set(imgs, oldImageCount, oldImageCount + addedImageCount - 1);
213 m_processingProfile = XRCCTRL(*dlg,
"raw_rt_processing_profile", wxTextCtrl)->GetValue().Trim(
true).Trim(
false);
216 wxMessageBox(wxString::Format(_(
"Processing profile \"%s\" not found.\nPlease specify a valid file or leave field empty for default settings."),
m_processingProfile),
222 wxOK | wxICON_INFORMATION, dlg);
242 args.Append(
" -b16 -tz -Y -c ");
253 config.Write(
"/White Balance/Setting",
"Custom");
260 for (
size_t i = 0; i < rawFilenames.size(); ++i)
264 args.Append(
" -b16 -tz -Y -c ");
276 wxRegKey regkey(wxRegKey::HKLM,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\rawtherapee-cli.exe");
278 if (regkey.HasValue(wxT(
"")) && regkey.QueryRawValue(wxT(
""), prog))
288 wxRegKey regkeyUser(wxRegKey::HKCU,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\rawtherapee-cli.exe");
290 if (regkeyUser.HasValue(wxT(
"")) && regkeyUser.QueryRawValue(wxT(
""), prog))
299 return "rawtherapee-cli.exe";
300 #elif defined __WXMAC__
301 return "/Applications/RawTherapee.app/Contents/MacOS/rawtherapee-cli";
303 return "rawtherapee-cli";
328 wxString args(
" --verbose ");
334 wxString file(imageFilename);
335 file.Replace(
"\\",
"/",
true);
341 args.Append(
" --core --conf plugins/imageio/format/tiff/bpp=16");
349 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
350 Exiv2::Image::UniquePtr image;
352 Exiv2::Image::AutoPtr image;
358 catch (
const Exiv2::Error& e)
360 std::cerr <<
"Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
365 image->readMetadata();
367 catch (
const Exiv2::Error& e)
369 std::cerr <<
"Caught Exiv2 exception " << e.what() << std::endl;
373 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
374 Exiv2::Image::UniquePtr image2;
376 Exiv2::Image::AutoPtr image2;
382 catch (
const Exiv2::Error& e)
384 std::cerr <<
"Exiv2: Error creating temp xmp file (" << e.what() <<
")" << std::endl;
387 image2->setXmpData(image->xmpData());
388 image2->writeMetadata();
394 for (
size_t i = 0; i < rawFilenames.size(); ++i)
396 wxString args(
"--verbose ");
404 wxString file(imageFilenames[i]);
405 file.Replace(
"\\",
"/",
true);
411 args.Append(
" --core --conf plugins/imageio/format/tiff/bpp=16");
421 wxRegKey regkey(wxRegKey::HKLM,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\darktable-cli.exe");
423 if (regkey.HasValue(wxT(
"")) && regkey.QueryRawValue(wxT(
""), prog))
433 wxRegKey regkeyUser(wxRegKey::HKCU,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\darktable-cli.exe");
435 if (regkeyUser.HasValue(wxT(
"")) && regkeyUser.QueryRawValue(wxT(
""), prog))
444 return "darktable-cli.exe";
445 #elif defined __WXMAC__
446 return "/Applications/darktable.app/Contents/MacOS/darktable-cli";
448 return "darktable-cli";
461 RawImportProgress(wxWindow * parent, std::shared_ptr<RawImport>& converter,
const wxArrayString& rawImages,
const wxArrayString& images,
const int refImg) :
462 wxDialog(parent, wxID_ANY, _(
"Import Raw Images"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
475 wxBoxSizer * topsizer =
new wxBoxSizer(wxVERTICAL);
479 wxBoxSizer* bottomsizer =
new wxBoxSizer(wxHORIZONTAL);
480 m_progress =
new wxGauge(
this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_PROGRESS);
481 bottomsizer->Add(
m_progress, 1, wxEXPAND | wxALL, 10);
485 topsizer->Add(bottomsizer, 0, wxEXPAND);
499 if (e.GetExitCode() == 0)
503 wxMessageBox(_(
"Could not process the output of reference image.\nFurther processed images will not have a consistent white balance."),
509 wxOK | wxICON_INFORMATION,
this);
516 if (rawFiles.IsEmpty())
519 if (wxConfigBase::Get()->Read(wxT(
"CopyLogToClipboard"), 0l) == 1l)
541 if (e.GetExitCode() == 0)
544 if (wxConfigBase::Get()->Read(wxT(
"CopyLogToClipboard"), 0l) == 1l)
558 if (event.GetInt() >= 0)
572 EndModal(wxID_CANCEL);
596 wxXmlResource::Get()->LoadDialog(
this, parent, wxT(
"import_raw_dialog"));
599 wxConfigBase* config = wxConfig::Get();
601 wxString s = config->Read(
"/RawImportDialog/dcrawParameter",
"");
602 XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->SetValue(s);
605 s = config->Read(
"/RawImportDialog/RTProcessingProfile",
"");
606 wxTextCtrl* ctrl = XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl);
608 ctrl->AutoCompleteFileNames();
610 const long converter = config->Read(
"/RawImportDialog/Converter", 0l);
615 XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->SetValue(
true);
618 XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->SetValue(
true);
621 XRCCTRL(*
this,
"raw_rb_darktable", wxRadioButton)->SetValue(
true);
624 wxCommandEvent dummy;
628 for (
auto& file : rawFiles)
651 wxArrayString errorReadingFile;
652 wxArrayString differentCam;
657 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
658 #if defined EXV_ENABLE_BMFF && !EXIV2_TEST_VERSION(0,28,3)
664 Exiv2::Image::UniquePtr image;
666 Exiv2::Image::AutoPtr image;
672 catch (
const Exiv2::Error& e)
674 std::cerr <<
"Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
675 errorReadingFile.push_back(file);
681 image->readMetadata();
683 catch (
const Exiv2::Error& e)
685 std::cerr <<
"Caught Exiv2 exception '" << e.what() <<
"' for file " << file << std::endl;
686 errorReadingFile.push_back(file);
688 Exiv2::ExifData &exifData = image->exifData();
689 if (exifData.empty())
691 errorReadingFile.push_back(file);
695 auto make = Exiv2::make(exifData);
696 if (make != exifData.end() && make->count())
698 cam = make->toString();
700 auto model = Exiv2::model(exifData);
701 if (model != exifData.end() && model->count())
703 cam +=
"|" + model->toString();
713 differentCam.push_back(file);
718 if (!errorReadingFile.IsEmpty())
721 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_filename"));
722 dlg.SetLabel(_(
"Warning: Read error"));
723 XRCCTRL(dlg,
"dlg_warning_text", wxStaticText)->SetLabel(_(
"The following files will be skipped because the metadata of these files could not read."));
724 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(errorReadingFile);
726 dlg.CenterOnScreen();
728 for (
auto& file : errorReadingFile)
730 m_rawImages.Remove(file);
732 if (m_rawImages.IsEmpty())
737 if (differentCam.IsEmpty())
745 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_filename"));
746 dlg.SetLabel(_(
"Warning: raw images from different cameras"));
747 XRCCTRL(dlg,
"dlg_warning_text", wxStaticText)->SetLabel(_(
"The following images were shot with different camera than the other one.\nThe raw import works only for images from the same cam."));
748 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(differentCam);
750 dlg.CenterOnScreen();
758 std::shared_ptr<RawImport> rawConverter;
759 long rawConverterInt;
760 if (XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->GetValue())
762 rawConverter = std::make_shared<DCRawImport>();
767 if (XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->GetValue())
769 rawConverter = std::make_shared<RTRawImport>();
774 rawConverter = std::make_shared<DarkTableRawImport>();
779 if (!rawConverter->CheckExe(
this))
784 if (!rawConverter->ProcessAdditionalParameters(
this))
791 wxArrayString existingImages;
794 wxFileName newImage(img);
795 newImage.SetExt(rawConverter->GetImageExtension());
796 m_images.push_back(newImage.GetFullPath());
797 if (newImage.FileExists())
799 existingImages.push_back(newImage.GetFullPath());
802 if (!existingImages.IsEmpty())
805 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_overwrite"));
806 XRCCTRL(dlg,
"dlg_overwrite_list", wxListBox)->Append(existingImages);
808 dlg.CenterOnScreen();
809 if (dlg.ShowModal() != wxID_OK)
814 if (!rawConverter->SupportsOverwrite())
818 for (
auto& img : existingImages)
825 if (dlg.ShowModal() == wxID_OK)
828 wxConfigBase* config = wxConfig::Get();
829 config->Write(
"/RawImportDialog/Converter", rawConverterInt);
830 config->Write(
"/RawImportDialog/dcrawParameter", XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->GetValue().Trim(
true).Trim(
false));
831 config->Write(
"/RawImportDialog/RTProcessingProfile", XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl)->GetValue());
834 std::vector<std::string> files;
835 bool missingFiles =
false;
847 if (missingFiles || files.empty())
849 wxMessageBox(_(
"At least one raw images was not successfully converted.\nThis image(s) will be skipped"),
855 wxOK | wxICON_INFORMATION,
this);
862 std::vector<PanoCommand::PanoCommand*> cmds;
871 EndModal(wxID_CANCEL);
876 wxTextCtrl* input = XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl);
877 wxFileDialog dlg(
this, _(
"Select default RT processing profile"),
"", input->GetValue(), _(
"RT processing profile|*.pp3"), wxFD_OPEN, wxDefaultPosition);
878 if (dlg.ShowModal() == wxID_OK)
880 input->SetValue(dlg.GetPath());
891 if (XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->GetValue())
893 rawConverter = Converter::DCRAW;
897 if (XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->GetValue())
899 rawConverter = Converter::RAWTHERAPEE;
903 rawConverter = Converter::DARKTABLE;
906 XRCCTRL(*
this,
"raw_dcraw_text", wxStaticText)->Enable(rawConverter == Converter::DCRAW);
907 XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->Enable(rawConverter == Converter::DCRAW);
908 XRCCTRL(*
this,
"raw_rt_text", wxStaticText)->Enable(rawConverter == Converter::RAWTHERAPEE);
909 XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl)->Enable(rawConverter == Converter::RAWTHERAPEE);
910 XRCCTRL(*
this,
"raw_rt_processing_profile_select", wxButton)->Enable(rawConverter == Converter::RAWTHERAPEE);
915 wxChoice* choice = XRCCTRL(*
this,
"raw_choice_wb", wxChoice);
919 choice->Append(file.GetFullName());
921 choice->SetSelection(0);
Base class for all panorama commands.
void OnOk(wxCommandEvent &e)
called when dialog is finished and does the conversion
normal command for queue, processing is stopped if an error occurred in program
bool FileExists(const std::string &filename)
checks if file exists
wxString GetImageExtension() override
image extension of converted files
wxArrayString GetLogAsArrayString()
returns the output
special class for raw import with dcraw
wxString m_usedProcessingProfile
virtual wxString GetImageExtension()
image extension of converted files
RawImportDialog(wxWindow *parent, HuginBase::Panorama *pano, std::vector< std::string > &rawFiles)
Constructor, read from xrc ressource; restore last uses settings and position.
virtual void AddAdditionalPanoramaCommand(std::vector< PanoCommand::PanoCommand * > &cmds, HuginBase::Panorama *pano, const int oldImageCount, const int addedImageCount)
add additional PanoCommand::PanoCommand to vector if needed hint: we need to pass old and new image n...
void OnProcessTerminate(wxProcessEvent &e)
optional command for queue, processing of queue is always continued, also if an error occurred ...
special class for Darktable raw import
HuginQueue::CommandQueue * GetCmdQueueForImport(const wxArrayString &rawFilenames, const wxArrayString &imageFilenames) override
return commands for processing of all other images with white balance read by RawImport::ProcessRefer...
int ExecQueue(HuginQueue::CommandQueue *queue)
std::shared_ptr< RawImport > m_converter
void OnSelectRTProcessingProfile(wxCommandEvent &e)
virtual void setName(const std::string &newName)
sets the name for the command
wxArrayString m_rawImages
HuginQueue::CommandQueue * GetCmdQueueForReference(const wxString &rawFilename, const wxString &imageFilename) override
return command for processing of reference image
#define DEBUG_ASSERT(cond)
include file for the hugin project
void FillImageChoice()
fill list with image names
void OnCancel(wxCommandEvent &event)
static huginApp * Get()
hack.. kind of a pseudo singleton...
wxString m_additionalParameters
virtual bool ProcessReferenceOutput(const wxArrayString &output)=0
read output of processing of reference image to read in white balance of reference image ...
bool ProcessAdditionalParameters(wxDialog *dlg) override
reads additional parameters from dialog into class
PanoCommand to combine other PanoCommands.
PanoCommand::PanoCommand * m_cmd
std::set< unsigned int > UIntSet
void OnInitDialog(wxInitDialogEvent &e)
std::string GetDataDir()
returns the full path to the data directory
Definition of dialog and functions to import RAW images to project file.
virtual HuginQueue::CommandQueue * GetCmdQueueForImport(const wxArrayString &rawFilenames, const wxArrayString &imageFilenames)=0
return commands for processing of all other images with white balance read by RawImport::ProcessRefer...
MyExecPanel * m_progressPanel
PanoCommand::PanoCommand * GetPanoCommand()
return PanoCommand for adding converted raw files to Panorama
HuginQueue::CommandQueue * GetCmdQueueForImport(const wxArrayString &rawFilenames, const wxArrayString &imageFilenames) override
return commands for processing of all other images with white balance read by RawImport::ProcessRefer...
std::size_t getNrOfImages() const
number of images.
HuginQueue::CommandQueue * GetCmdQueueForImport(const wxArrayString &rawFilenames, const wxArrayString &imageFilenames) override
return commands for processing of all other images with white balance read by RawImport::ProcessRefer...
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
dialog class for showing progress of raw import
virtual wxString GetDefaultExe()
returns the default name of the executable
wxButton * m_cancelButton
RawImportProgress(wxWindow *parent, std::shared_ptr< RawImport > &converter, const wxArrayString &rawImages, const wxArrayString &images, const int refImg)
base class for implementation of Raw import functions
bool ProcessReferenceOutput(const wxArrayString &output) override
read output of processing of reference image to read in white balance of reference image ...
void OnProcessReferenceTerminate(wxProcessEvent &e)
virtual wxString GetDefaultExe()
returns the default name of the executable
wxwindows specific panorama commands
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Restore window size and position from configfile/registry.
bool SupportsOverwrite() override
return true if program supports overwritting output, otherwise false
class for RawTherapee raw import
virtual bool ProcessAdditionalParameters(wxDialog *dlg)
reads additional parameters from dialog into class
~RawImportDialog()
destructor, saves position
bool ProcessAdditionalParameters(wxDialog *dlg) override
reads additional parameters from dialog into class
void OnRawConverterSelected(wxCommandEvent &e)
virtual wxString GetDefaultExe()
returns the default name of the executable
const wxString & GetUtilsBinDir()
bool CheckExe(wxDialog *dlg)
checks if valid executable was given in dialog either absolute path or when relative path is given ch...
bool ProcessReferenceOutput(const wxArrayString &output) override
read output of processing of reference image to read in white balance of reference image ...
bool ProcessReferenceOutput(const wxArrayString &output) override
read output of processing of reference image to read in white balance of reference image ...
wxString m_processingProfile
HuginBase::Panorama * m_pano
HuginQueue::CommandQueue * GetCmdQueueForReference(const wxString &rawFilename, const wxString &imageFilename) override
return command for processing of reference image
str wxEscapeFilename(const str &arg)
special escaping routine for CommandQueues
void AddAdditionalPanoramaCommand(std::vector< PanoCommand::PanoCommand * > &cmds, HuginBase::Panorama *pano, const int oldImageCount, const int addedImageCount) override
add additional PanoCommand::PanoCommand to vector if needed hint: we need to pass old and new image n...
wxArrayString m_rawImages
RawImport(wxString ConfigExePath)
add image(s) to a panorama
virtual HuginQueue::CommandQueue * GetCmdQueueForReference(const wxString &rawFilename, const wxString &imageFilename)=0
return command for processing of reference image
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
virtual bool SupportsOverwrite()
return true if program supports overwritting output, otherwise false
void OnProgress(wxCommandEvent &event)
virtual ~RawImportProgress()
HuginQueue::CommandQueue * GetCmdQueueForReference(const wxString &rawFilename, const wxString &imageFilename) override
return command for processing of reference image
wxString GetExternalProgram(wxConfigBase *config, const wxString &bindir, const wxString &name)
return path and name of external program, which can be overwritten by the user
std::vector< NormalCommand * > CommandQueue
bool CheckRawFiles()
return true, if all raw files are from the same camera
void CopyLogToClipboard()
copy the content of the log window into the clipboard
virtual wxString GetDefaultExe()
returns the default name of the executable