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 #if wxCHECK_VERSION(3,1,0)
481 m_progress =
new wxGauge(
this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_PROGRESS);
483 m_progress =
new wxGauge(
this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL);
485 bottomsizer->Add(
m_progress, 1, wxEXPAND | wxALL, 10);
489 topsizer->Add(bottomsizer, 0, wxEXPAND);
507 if (e.GetExitCode() == 0)
511 wxMessageBox(_(
"Could not process the output of reference image.\nFurther processed images will not have a consistent white balance."),
517 wxOK | wxICON_INFORMATION,
this);
524 if (rawFiles.IsEmpty())
527 if (wxConfigBase::Get()->Read(wxT(
"CopyLogToClipboard"), 0l) == 1l)
549 if (e.GetExitCode() == 0)
552 if (wxConfigBase::Get()->Read(wxT(
"CopyLogToClipboard"), 0l) == 1l)
566 if (event.GetInt() >= 0)
580 EndModal(wxID_CANCEL);
601 EVT_BUTTON(XRCID("raw_rt_processing_profile_select"),
RawImportDialog::OnSelectRTProcessingProfile)
603 EVT_RADIOBUTTON(XRCID("raw_rb_dcraw"),
RawImportDialog::OnRawConverterSelected)
604 EVT_RADIOBUTTON(XRCID("raw_rb_rt"),
RawImportDialog::OnRawConverterSelected)
605 EVT_RADIOBUTTON(XRCID("raw_rb_darktable"),
RawImportDialog::OnRawConverterSelected)
612 wxXmlResource::Get()->LoadDialog(
this, parent, wxT(
"import_raw_dialog"));
615 wxIconBundle myIcons(
huginApp::Get()->GetXRCPath() + wxT(
"data/hugin.ico"),wxBITMAP_TYPE_ICO);
618 wxIcon myIcon(
huginApp::Get()->GetXRCPath() + wxT(
"data/hugin.png"),wxBITMAP_TYPE_PNG);
623 wxConfigBase* config = wxConfig::Get();
625 wxString s = config->Read(
"/RawImportDialog/dcrawParameter",
"");
626 XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->SetValue(s);
629 s = config->Read(
"/RawImportDialog/RTProcessingProfile",
"");
630 wxTextCtrl* ctrl = XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl);
632 ctrl->AutoCompleteFileNames();
634 const long converter = config->Read(
"/RawImportDialog/Converter", 0l);
639 XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->SetValue(
true);
642 XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->SetValue(
true);
645 XRCCTRL(*
this,
"raw_rb_darktable", wxRadioButton)->SetValue(
true);
648 wxCommandEvent dummy;
649 OnRawConverterSelected(dummy);
652 for (
auto& file : rawFiles)
670 wxArrayString errorReadingFile;
671 wxArrayString differentCam;
676 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
677 #if defined EXV_ENABLE_BMFF && !EXIV2_TEST_VERSION(0,28,3)
683 Exiv2::Image::UniquePtr image;
685 Exiv2::Image::AutoPtr image;
691 catch (
const Exiv2::Error& e)
693 std::cerr <<
"Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
694 errorReadingFile.push_back(file);
700 image->readMetadata();
702 catch (
const Exiv2::Error& e)
704 std::cerr <<
"Caught Exiv2 exception '" << e.what() <<
"' for file " << file << std::endl;
705 errorReadingFile.push_back(file);
707 Exiv2::ExifData &exifData = image->exifData();
708 if (exifData.empty())
710 errorReadingFile.push_back(file);
714 auto make = Exiv2::make(exifData);
715 if (make != exifData.end() && make->count())
717 cam = make->toString();
719 auto model = Exiv2::model(exifData);
720 if (model != exifData.end() && model->count())
722 cam +=
"|" + model->toString();
732 differentCam.push_back(file);
737 if (!errorReadingFile.IsEmpty())
740 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_filename"));
741 dlg.SetLabel(_(
"Warning: Read error"));
742 XRCCTRL(dlg,
"dlg_warning_text", wxStaticText)->SetLabel(_(
"The following files will be skipped because the metadata of these files could not read."));
743 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(errorReadingFile);
745 dlg.CenterOnScreen();
747 for (
auto& file : errorReadingFile)
749 m_rawImages.Remove(file);
751 if (m_rawImages.IsEmpty())
756 if (differentCam.IsEmpty())
764 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_filename"));
765 dlg.SetLabel(_(
"Warning: raw images from different cameras"));
766 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."));
767 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(differentCam);
769 dlg.CenterOnScreen();
777 std::shared_ptr<RawImport> rawConverter;
778 long rawConverterInt;
779 if (XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->GetValue())
781 rawConverter = std::make_shared<DCRawImport>();
786 if (XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->GetValue())
788 rawConverter = std::make_shared<RTRawImport>();
793 rawConverter = std::make_shared<DarkTableRawImport>();
798 if (!rawConverter->CheckExe(
this))
803 if (!rawConverter->ProcessAdditionalParameters(
this))
810 wxArrayString existingImages;
813 wxFileName newImage(img);
814 newImage.SetExt(rawConverter->GetImageExtension());
815 m_images.push_back(newImage.GetFullPath());
816 if (newImage.FileExists())
818 existingImages.push_back(newImage.GetFullPath());
821 if (!existingImages.IsEmpty())
824 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_overwrite"));
825 XRCCTRL(dlg,
"dlg_overwrite_list", wxListBox)->Append(existingImages);
827 dlg.CenterOnScreen();
828 if (dlg.ShowModal() != wxID_OK)
833 if (!rawConverter->SupportsOverwrite())
837 for (
auto& img : existingImages)
844 if (dlg.ShowModal() == wxID_OK)
847 wxConfigBase* config = wxConfig::Get();
848 config->Write(
"/RawImportDialog/Converter", rawConverterInt);
849 config->Write(
"/RawImportDialog/dcrawParameter", XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->GetValue().Trim(
true).Trim(
false));
850 config->Write(
"/RawImportDialog/RTProcessingProfile", XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl)->GetValue());
853 std::vector<std::string> files;
854 bool missingFiles =
false;
866 if (missingFiles || files.empty())
868 wxMessageBox(_(
"At least one raw images was not successfully converted.\nThis image(s) will be skipped"),
874 wxOK | wxICON_INFORMATION,
this);
881 std::vector<PanoCommand::PanoCommand*> cmds;
890 EndModal(wxID_CANCEL);
895 wxTextCtrl* input = XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl);
896 wxFileDialog dlg(
this, _(
"Select default RT processing profile"),
"", input->GetValue(), _(
"RT processing profile|*.pp3"), wxFD_OPEN, wxDefaultPosition);
897 if (dlg.ShowModal() == wxID_OK)
899 input->SetValue(dlg.GetPath());
910 if (XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->GetValue())
912 rawConverter = Converter::DCRAW;
916 if (XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->GetValue())
918 rawConverter = Converter::RAWTHERAPEE;
922 rawConverter = Converter::DARKTABLE;
925 XRCCTRL(*
this,
"raw_dcraw_text", wxStaticText)->Enable(rawConverter == Converter::DCRAW);
926 XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->Enable(rawConverter == Converter::DCRAW);
927 XRCCTRL(*
this,
"raw_rt_text", wxStaticText)->Enable(rawConverter == Converter::RAWTHERAPEE);
928 XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl)->Enable(rawConverter == Converter::RAWTHERAPEE);
929 XRCCTRL(*
this,
"raw_rt_processing_profile_select", wxButton)->Enable(rawConverter == Converter::RAWTHERAPEE);
934 wxChoice* choice = XRCCTRL(*
this,
"raw_choice_wb", wxChoice);
938 choice->Append(file.GetFullName());
940 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
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