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);
503 if (e.GetExitCode() == 0)
507 wxMessageBox(_(
"Could not process the output of reference image.\nFurther processed images will not have a consistent white balance."),
513 wxOK | wxICON_INFORMATION,
this);
520 if (rawFiles.IsEmpty())
523 if (wxConfigBase::Get()->Read(wxT(
"CopyLogToClipboard"), 0l) == 1l)
545 if (e.GetExitCode() == 0)
548 if (wxConfigBase::Get()->Read(wxT(
"CopyLogToClipboard"), 0l) == 1l)
562 if (event.GetInt() >= 0)
576 EndModal(wxID_CANCEL);
600 wxXmlResource::Get()->LoadDialog(
this, parent, wxT(
"import_raw_dialog"));
603 wxIconBundle myIcons(
huginApp::Get()->GetXRCPath() + wxT(
"data/hugin.ico"),wxBITMAP_TYPE_ICO);
606 wxIcon myIcon(
huginApp::Get()->GetXRCPath() + wxT(
"data/hugin.png"),wxBITMAP_TYPE_PNG);
611 wxConfigBase* config = wxConfig::Get();
613 wxString s = config->Read(
"/RawImportDialog/dcrawParameter",
"");
614 XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->SetValue(s);
617 s = config->Read(
"/RawImportDialog/RTProcessingProfile",
"");
618 wxTextCtrl* ctrl = XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl);
620 ctrl->AutoCompleteFileNames();
622 const long converter = config->Read(
"/RawImportDialog/Converter", 0l);
627 XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->SetValue(
true);
630 XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->SetValue(
true);
633 XRCCTRL(*
this,
"raw_rb_darktable", wxRadioButton)->SetValue(
true);
636 wxCommandEvent dummy;
640 for (
auto& file : rawFiles)
663 wxArrayString errorReadingFile;
664 wxArrayString differentCam;
669 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
670 #if defined EXV_ENABLE_BMFF && !EXIV2_TEST_VERSION(0,28,3)
676 Exiv2::Image::UniquePtr image;
678 Exiv2::Image::AutoPtr image;
684 catch (
const Exiv2::Error& e)
686 std::cerr <<
"Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
687 errorReadingFile.push_back(file);
693 image->readMetadata();
695 catch (
const Exiv2::Error& e)
697 std::cerr <<
"Caught Exiv2 exception '" << e.what() <<
"' for file " << file << std::endl;
698 errorReadingFile.push_back(file);
700 Exiv2::ExifData &exifData = image->exifData();
701 if (exifData.empty())
703 errorReadingFile.push_back(file);
707 auto make = Exiv2::make(exifData);
708 if (make != exifData.end() && make->count())
710 cam = make->toString();
712 auto model = Exiv2::model(exifData);
713 if (model != exifData.end() && model->count())
715 cam +=
"|" + model->toString();
725 differentCam.push_back(file);
730 if (!errorReadingFile.IsEmpty())
733 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_filename"));
734 dlg.SetLabel(_(
"Warning: Read error"));
735 XRCCTRL(dlg,
"dlg_warning_text", wxStaticText)->SetLabel(_(
"The following files will be skipped because the metadata of these files could not read."));
736 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(errorReadingFile);
738 dlg.CenterOnScreen();
740 for (
auto& file : errorReadingFile)
742 m_rawImages.Remove(file);
744 if (m_rawImages.IsEmpty())
749 if (differentCam.IsEmpty())
757 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_filename"));
758 dlg.SetLabel(_(
"Warning: raw images from different cameras"));
759 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."));
760 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(differentCam);
762 dlg.CenterOnScreen();
770 std::shared_ptr<RawImport> rawConverter;
771 long rawConverterInt;
772 if (XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->GetValue())
774 rawConverter = std::make_shared<DCRawImport>();
779 if (XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->GetValue())
781 rawConverter = std::make_shared<RTRawImport>();
786 rawConverter = std::make_shared<DarkTableRawImport>();
791 if (!rawConverter->CheckExe(
this))
796 if (!rawConverter->ProcessAdditionalParameters(
this))
803 wxArrayString existingImages;
806 wxFileName newImage(img);
807 newImage.SetExt(rawConverter->GetImageExtension());
808 m_images.push_back(newImage.GetFullPath());
809 if (newImage.FileExists())
811 existingImages.push_back(newImage.GetFullPath());
814 if (!existingImages.IsEmpty())
817 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_warning_overwrite"));
818 XRCCTRL(dlg,
"dlg_overwrite_list", wxListBox)->Append(existingImages);
820 dlg.CenterOnScreen();
821 if (dlg.ShowModal() != wxID_OK)
826 if (!rawConverter->SupportsOverwrite())
830 for (
auto& img : existingImages)
837 if (dlg.ShowModal() == wxID_OK)
840 wxConfigBase* config = wxConfig::Get();
841 config->Write(
"/RawImportDialog/Converter", rawConverterInt);
842 config->Write(
"/RawImportDialog/dcrawParameter", XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->GetValue().Trim(
true).Trim(
false));
843 config->Write(
"/RawImportDialog/RTProcessingProfile", XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl)->GetValue());
846 std::vector<std::string> files;
847 bool missingFiles =
false;
859 if (missingFiles || files.empty())
861 wxMessageBox(_(
"At least one raw images was not successfully converted.\nThis image(s) will be skipped"),
867 wxOK | wxICON_INFORMATION,
this);
874 std::vector<PanoCommand::PanoCommand*> cmds;
883 EndModal(wxID_CANCEL);
888 wxTextCtrl* input = XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl);
889 wxFileDialog dlg(
this, _(
"Select default RT processing profile"),
"", input->GetValue(), _(
"RT processing profile|*.pp3"), wxFD_OPEN, wxDefaultPosition);
890 if (dlg.ShowModal() == wxID_OK)
892 input->SetValue(dlg.GetPath());
903 if (XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->GetValue())
905 rawConverter = Converter::DCRAW;
909 if (XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->GetValue())
911 rawConverter = Converter::RAWTHERAPEE;
915 rawConverter = Converter::DARKTABLE;
918 XRCCTRL(*
this,
"raw_dcraw_text", wxStaticText)->Enable(rawConverter == Converter::DCRAW);
919 XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->Enable(rawConverter == Converter::DCRAW);
920 XRCCTRL(*
this,
"raw_rt_text", wxStaticText)->Enable(rawConverter == Converter::RAWTHERAPEE);
921 XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl)->Enable(rawConverter == Converter::RAWTHERAPEE);
922 XRCCTRL(*
this,
"raw_rt_processing_profile_select", wxButton)->Enable(rawConverter == Converter::RAWTHERAPEE);
927 wxChoice* choice = XRCCTRL(*
this,
"raw_choice_wb", wxChoice);
931 choice->Append(file.GetFullName());
933 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