39 #include <exiv2/exiv2.hpp>
41 #include <wx/msw/registry.h>
48 RawImport(wxString ConfigExePath) {
m_exe = wxConfig::Get()->Read(ConfigExePath,
""); };
63 const wxFileName exePath(
m_exe);
64 if (exePath.IsAbsolute())
66 if (exePath.FileExists())
68 m_exe = exePath.GetFullPath();
73 wxMessageBox(wxString::Format(_(
"Executable \"%s\" not found.\nPlease specify a valid executable in preferences."), exePath.GetFullPath()),
79 wxOK | wxICON_INFORMATION, dlg);
87 pathlist.AddEnvList(wxT(
"PATH"));
88 m_exe = pathlist.FindAbsoluteValidPath(exePath.GetFullPath());
91 wxMessageBox(wxString::Format(_(
"Executable \"%s\" not found in PATH.\nPlease specify a valid executable in preferences."), exePath.GetFullPath()),
97 wxOK | wxICON_INFORMATION, dlg);
126 m_additionalParameters = XRCCTRL(*dlg,
"raw_dcraw_parameter", wxTextCtrl)->GetValue().Trim(
true).Trim(
false);
132 wxString args(
" -w -v -4 -T ");
141 args.Append(
"-overwrite_original -tagsfromfile ");
143 args.Append(
" -all:all ");
150 for (
auto& s : output)
152 int pos = s.Find(
"multipliers");
155 m_wb =
"-r " + s.Mid(pos + 12);
164 wxConfigBase* config = wxConfig::Get();
166 for (
size_t i = 0; i < rawFilenames.size(); ++i)
169 args.Append(
" -v -4 -T ");
178 args.Append(
"-overwrite_original -tagsfromfile ");
180 args.Append(
" -all:all ");
190 fill_set(imgs, oldImageCount, oldImageCount + addedImageCount - 1);
214 m_processingProfile = XRCCTRL(*dlg,
"raw_rt_processing_profile", wxTextCtrl)->GetValue().Trim(
true).Trim(
false);
217 wxMessageBox(wxString::Format(_(
"Processing profile \"%s\" not found.\nPlease specify a valid file or leave field empty for default settings."),
m_processingProfile),
223 wxOK | wxICON_INFORMATION, dlg);
243 args.Append(
" -b16 -tz -Y -c ");
254 config.Write(
"/White Balance/Setting",
"Custom");
261 for (
size_t i = 0; i < rawFilenames.size(); ++i)
265 args.Append(
" -b16 -tz -Y -c ");
277 wxRegKey regkey(wxRegKey::HKLM,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\rawtherapee-cli.exe");
279 if (regkey.HasValue(wxT(
"")) && regkey.QueryRawValue(wxT(
""), prog))
289 wxRegKey regkeyUser(wxRegKey::HKCU,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\rawtherapee-cli.exe");
291 if (regkeyUser.HasValue(wxT(
"")) && regkeyUser.QueryRawValue(wxT(
""), prog))
300 return "rawtherapee-cli.exe";
301 #elif defined __WXMAC__
302 return "/Applications/RawTherapee.app/Contents/MacOS/rawtherapee-cli";
304 return "rawtherapee-cli";
329 wxString args(
" --verbose ");
335 wxString file(imageFilename);
336 file.Replace(
"\\",
"/",
true);
342 args.Append(
" --core --conf plugins/imageio/format/tiff/bpp=16");
350 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
351 Exiv2::Image::UniquePtr image;
353 Exiv2::Image::AutoPtr image;
359 catch (
const Exiv2::Error& e)
361 std::cerr <<
"Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
366 image->readMetadata();
368 catch (
const Exiv2::Error& e)
370 std::cerr <<
"Caught Exiv2 exception " << e.what() << std::endl;
374 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
375 Exiv2::Image::UniquePtr image2;
377 Exiv2::Image::AutoPtr image2;
383 catch (
const Exiv2::Error& e)
385 std::cerr <<
"Exiv2: Error creating temp xmp file (" << e.what() <<
")" << std::endl;
388 image2->setXmpData(image->xmpData());
389 image2->writeMetadata();
395 for (
size_t i = 0; i < rawFilenames.size(); ++i)
397 wxString args(
"--verbose ");
405 wxString file(imageFilenames[i]);
406 file.Replace(
"\\",
"/",
true);
412 args.Append(
" --core --conf plugins/imageio/format/tiff/bpp=16");
422 wxRegKey regkey(wxRegKey::HKLM,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\darktable-cli.exe");
424 if (regkey.HasValue(wxT(
"")) && regkey.QueryRawValue(wxT(
""), prog))
434 wxRegKey regkeyUser(wxRegKey::HKCU,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\darktable-cli.exe");
436 if (regkeyUser.HasValue(wxT(
"")) && regkeyUser.QueryRawValue(wxT(
""), prog))
445 return "darktable-cli.exe";
446 #elif defined __WXMAC__
447 return "/Applications/darktable.app/Contents/MacOS/darktable-cli";
449 return "darktable-cli";
462 RawImportProgress(wxWindow * parent, std::shared_ptr<RawImport>& converter,
const wxArrayString& rawImages,
const wxArrayString& images,
const int refImg) :
463 wxDialog(parent, wxID_ANY, _(
"Import Raw Images"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
476 wxBoxSizer * topsizer =
new wxBoxSizer(wxVERTICAL);
480 wxBoxSizer* bottomsizer =
new wxBoxSizer(wxHORIZONTAL);
481 m_progress =
new wxGauge(
this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_PROGRESS);
482 bottomsizer->Add(
m_progress, 1, wxEXPAND | wxALL, 10);
486 topsizer->Add(bottomsizer, 0, wxEXPAND);
500 if (e.GetExitCode() == 0)
504 wxMessageBox(_(
"Could not process the output of reference image.\nFurther processed images will not have a consistent white balance."),
510 wxOK | wxICON_INFORMATION,
this);
517 if (rawFiles.IsEmpty())
520 if (wxConfigBase::Get()->Read(wxT(
"CopyLogToClipboard"), 0l) == 1l)
542 if (e.GetExitCode() == 0)
545 if (wxConfigBase::Get()->Read(wxT(
"CopyLogToClipboard"), 0l) == 1l)
559 if (event.GetInt() >= 0)
573 EndModal(wxID_CANCEL);
597 wxXmlResource::Get()->LoadDialog(
this, parent, wxT(
"import_raw_dialog"));
600 wxConfigBase* config = wxConfig::Get();
602 wxString s = config->Read(
"/RawImportDialog/dcrawParameter",
"");
603 XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->SetValue(s);
606 s = config->Read(
"/RawImportDialog/RTProcessingProfile",
"");
607 wxTextCtrl* ctrl = XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl);
609 ctrl->AutoCompleteFileNames();
611 const long converter = config->Read(
"/RawImportDialog/Converter", 0l);
616 XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->SetValue(
true);
619 XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->SetValue(
true);
622 XRCCTRL(*
this,
"raw_rb_darktable", wxRadioButton)->SetValue(
true);
625 wxCommandEvent dummy;
629 for (
auto& file : rawFiles)
652 wxArrayString errorReadingFile;
653 wxArrayString differentCam;
658 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
659 #if defined EXV_ENABLE_BMFF && !EXIV2_TEST_VERSION(0,28,3)
665 Exiv2::Image::UniquePtr image;
667 Exiv2::Image::AutoPtr image;
673 catch (
const Exiv2::Error& e)
675 std::cerr <<
"Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
676 errorReadingFile.push_back(file);
682 image->readMetadata();
684 catch (
const Exiv2::Error& e)
686 std::cerr <<
"Caught Exiv2 exception '" << e.what() <<
"' for file " << file << std::endl;
687 errorReadingFile.push_back(file);
689 Exiv2::ExifData &exifData = image->exifData();
690 if (exifData.empty())
692 errorReadingFile.push_back(file);
696 auto make = Exiv2::make(exifData);
697 if (make != exifData.end() && make->count())
699 cam = make->toString();
701 auto model = Exiv2::model(exifData);
702 if (model != exifData.end() && model->count())
704 cam +=
"|" + model->toString();
714 differentCam.push_back(file);
719 if (!errorReadingFile.IsEmpty())
722 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_filename"));
723 dlg.SetLabel(_(
"Warning: Read error"));
724 XRCCTRL(dlg,
"dlg_warning_text", wxStaticText)->SetLabel(_(
"The following files will be skipped because the metadata of these files could not read."));
725 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(errorReadingFile);
727 dlg.CenterOnScreen();
729 for (
auto& file : errorReadingFile)
731 m_rawImages.Remove(file);
733 if (m_rawImages.IsEmpty())
738 if (differentCam.IsEmpty())
746 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_filename"));
747 dlg.SetLabel(_(
"Warning: raw images from different cameras"));
748 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."));
749 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(differentCam);
751 dlg.CenterOnScreen();
759 std::shared_ptr<RawImport> rawConverter;
760 long rawConverterInt;
761 if (XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->GetValue())
763 rawConverter = std::make_shared<DCRawImport>();
768 if (XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->GetValue())
770 rawConverter = std::make_shared<RTRawImport>();
775 rawConverter = std::make_shared<DarkTableRawImport>();
780 if (!rawConverter->CheckExe(
this))
785 if (!rawConverter->ProcessAdditionalParameters(
this))
792 wxArrayString existingImages;
795 wxFileName newImage(img);
796 newImage.SetExt(rawConverter->GetImageExtension());
797 m_images.push_back(newImage.GetFullPath());
798 if (newImage.FileExists())
800 existingImages.push_back(newImage.GetFullPath());
803 if (!existingImages.IsEmpty())
806 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_overwrite"));
807 XRCCTRL(dlg,
"dlg_overwrite_list", wxListBox)->Append(existingImages);
809 dlg.CenterOnScreen();
810 if (dlg.ShowModal() != wxID_OK)
815 if (!rawConverter->SupportsOverwrite())
819 for (
auto& img : existingImages)
826 if (dlg.ShowModal() == wxID_OK)
829 wxConfigBase* config = wxConfig::Get();
830 config->Write(
"/RawImportDialog/Converter", rawConverterInt);
831 config->Write(
"/RawImportDialog/dcrawParameter", XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->GetValue().Trim(
true).Trim(
false));
832 config->Write(
"/RawImportDialog/RTProcessingProfile", XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl)->GetValue());
835 std::vector<std::string> files;
836 bool missingFiles =
false;
848 if (missingFiles || files.empty())
850 wxMessageBox(_(
"At least one raw images was not successfully converted.\nThis image(s) will be skipped"),
856 wxOK | wxICON_INFORMATION,
this);
863 std::vector<PanoCommand::PanoCommand*> cmds;
872 EndModal(wxID_CANCEL);
877 wxTextCtrl* input = XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl);
878 wxFileDialog dlg(
this, _(
"Select default RT processing profile"),
"", input->GetValue(), _(
"RT processing profile|*.pp3"), wxFD_OPEN, wxDefaultPosition);
879 if (dlg.ShowModal() == wxID_OK)
881 input->SetValue(dlg.GetPath());
892 if (XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->GetValue())
894 rawConverter = Converter::DCRAW;
898 if (XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->GetValue())
900 rawConverter = Converter::RAWTHERAPEE;
904 rawConverter = Converter::DARKTABLE;
907 XRCCTRL(*
this,
"raw_dcraw_text", wxStaticText)->Enable(rawConverter == Converter::DCRAW);
908 XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->Enable(rawConverter == Converter::DCRAW);
909 XRCCTRL(*
this,
"raw_rt_text", wxStaticText)->Enable(rawConverter == Converter::RAWTHERAPEE);
910 XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl)->Enable(rawConverter == Converter::RAWTHERAPEE);
911 XRCCTRL(*
this,
"raw_rt_processing_profile_select", wxButton)->Enable(rawConverter == Converter::RAWTHERAPEE);
916 wxChoice* choice = XRCCTRL(*
this,
"raw_choice_wb", wxChoice);
920 choice->Append(file.GetFullName());
922 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...
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
bool SupportsOverwrite() override
return true if program supports overwritting output, otherwise false
class for RawTherapee raw import
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
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
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Restore window size and position from configfile/registry.