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 hugin_utils::HuginMessageBox(wxString::Format(_(
"Executable \"%s\" not found.\nPlease specify a valid executable in preferences."), exePath.GetFullPath()),
74 _(
"Hugin"), wxOK | wxICON_INFORMATION, dlg);
82 pathlist.AddEnvList(
"PATH");
83 m_exe = pathlist.FindAbsoluteValidPath(exePath.GetFullPath());
86 hugin_utils::HuginMessageBox(wxString::Format(_(
"Executable \"%s\" not found in PATH.\nPlease specify a valid executable in preferences."), exePath.GetFullPath()),
87 _(
"Hugin"), wxOK | wxICON_INFORMATION, dlg);
116 m_additionalParameters = XRCCTRL(*dlg,
"raw_dcraw_parameter", wxTextCtrl)->GetValue().Trim(
true).Trim(
false);
122 wxString args(
" -w -v -4 -T ");
131 args.Append(
"-overwrite_original -tagsfromfile ");
133 args.Append(
" -all:all ");
140 for (
auto& s : output)
142 int pos = s.Find(
"multipliers");
145 m_wb =
"-r " + s.Mid(pos + 12);
154 wxConfigBase* config = wxConfig::Get();
156 for (
size_t i = 0; i < rawFilenames.size(); ++i)
159 args.Append(
" -v -4 -T ");
168 args.Append(
"-overwrite_original -tagsfromfile ");
170 args.Append(
" -all:all ");
180 fill_set(imgs, oldImageCount, oldImageCount + addedImageCount - 1);
204 m_processingProfile = XRCCTRL(*dlg,
"raw_rt_processing_profile", wxTextCtrl)->GetValue().Trim(
true).Trim(
false);
208 _(
"Hugin"), wxOK | wxICON_INFORMATION, dlg);
228 args.Append(
" -b16 -tz -Y -c ");
239 config.Write(
"/White Balance/Setting",
"Custom");
246 for (
size_t i = 0; i < rawFilenames.size(); ++i)
250 args.Append(
" -b16 -tz -Y -c ");
262 wxRegKey regkey(wxRegKey::HKLM,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\rawtherapee-cli.exe");
264 if (regkey.HasValue(wxEmptyString) && regkey.QueryRawValue(wxEmptyString, prog))
274 wxRegKey regkeyUser(wxRegKey::HKCU,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\rawtherapee-cli.exe");
276 if (regkeyUser.HasValue(wxEmptyString) && regkeyUser.QueryRawValue(wxEmptyString, prog))
285 return "rawtherapee-cli.exe";
286 #elif defined __WXMAC__
287 return "/Applications/RawTherapee.app/Contents/MacOS/rawtherapee-cli";
289 return "rawtherapee-cli";
314 wxString args(
" --verbose ");
320 wxString file(imageFilename);
321 file.Replace(
"\\",
"/",
true);
327 args.Append(
" --core --conf plugins/imageio/format/tiff/bpp=16");
335 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
336 Exiv2::Image::UniquePtr image;
338 Exiv2::Image::AutoPtr image;
344 catch (
const Exiv2::Error& e)
346 std::cerr <<
"Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
351 image->readMetadata();
353 catch (
const Exiv2::Error& e)
355 std::cerr <<
"Caught Exiv2 exception " << e.what() << std::endl;
359 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
360 Exiv2::Image::UniquePtr image2;
362 Exiv2::Image::AutoPtr image2;
368 catch (
const Exiv2::Error& e)
370 std::cerr <<
"Exiv2: Error creating temp xmp file (" << e.what() <<
")" << std::endl;
373 image2->setXmpData(image->xmpData());
374 image2->writeMetadata();
380 for (
size_t i = 0; i < rawFilenames.size(); ++i)
382 wxString args(
"--verbose ");
390 wxString file(imageFilenames[i]);
391 file.Replace(
"\\",
"/",
true);
397 args.Append(
" --core --conf plugins/imageio/format/tiff/bpp=16");
407 wxRegKey regkey(wxRegKey::HKLM,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\darktable-cli.exe");
409 if (regkey.HasValue(wxEmptyString) && regkey.QueryRawValue(wxEmptyString, prog))
419 wxRegKey regkeyUser(wxRegKey::HKCU,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\darktable-cli.exe");
421 if (regkeyUser.HasValue(wxEmptyString) && regkeyUser.QueryRawValue(wxEmptyString, prog))
430 return "darktable-cli.exe";
431 #elif defined __WXMAC__
432 return "/Applications/darktable.app/Contents/MacOS/darktable-cli";
434 return "darktable-cli";
447 RawImportProgress(wxWindow * parent, std::shared_ptr<RawImport>& converter,
const wxArrayString& rawImages,
const wxArrayString& images,
const int refImg) :
448 wxDialog(parent, wxID_ANY, _(
"Import Raw Images"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
461 wxBoxSizer * topsizer =
new wxBoxSizer(wxVERTICAL);
465 wxBoxSizer* bottomsizer =
new wxBoxSizer(wxHORIZONTAL);
466 m_progress =
new wxGauge(
this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_PROGRESS);
467 bottomsizer->Add(
m_progress, 1, wxEXPAND | wxALL, 10);
471 topsizer->Add(bottomsizer, 0, wxEXPAND);
485 if (e.GetExitCode() == 0)
489 hugin_utils::HuginMessageBox(_(
"Could not process the output of reference image.\nFurther processed images will not have a consistent white balance."),
490 _(
"Hugin"), wxOK | wxICON_INFORMATION,
this);
497 if (rawFiles.IsEmpty())
500 if (wxConfigBase::Get()->Read(
"CopyLogToClipboard", 0l) == 1l)
522 if (e.GetExitCode() == 0)
525 if (wxConfigBase::Get()->Read(
"CopyLogToClipboard", 0l) == 1l)
539 if (event.GetInt() >= 0)
553 EndModal(wxID_CANCEL);
577 wxXmlResource::Get()->LoadDialog(
this, parent,
"import_raw_dialog");
580 wxConfigBase* config = wxConfig::Get();
582 wxString s = config->Read(
"/RawImportDialog/dcrawParameter",
"");
583 XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->SetValue(s);
586 s = config->Read(
"/RawImportDialog/RTProcessingProfile",
"");
587 wxTextCtrl* ctrl = XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl);
589 ctrl->AutoCompleteFileNames();
591 const long converter = config->Read(
"/RawImportDialog/Converter", 0l);
596 XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->SetValue(
true);
599 XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->SetValue(
true);
602 XRCCTRL(*
this,
"raw_rb_darktable", wxRadioButton)->SetValue(
true);
605 wxCommandEvent dummy;
609 for (
auto& file : rawFiles)
632 wxArrayString errorReadingFile;
633 wxArrayString differentCam;
638 #if defined EXIV2_VERSION && EXIV2_TEST_VERSION(0,27,99)
639 #if defined EXV_ENABLE_BMFF && !EXIV2_TEST_VERSION(0,28,3)
645 Exiv2::Image::UniquePtr image;
647 Exiv2::Image::AutoPtr image;
653 catch (
const Exiv2::Error& e)
655 std::cerr <<
"Exiv2: Error reading metadata (" << e.what() <<
")" << std::endl;
656 errorReadingFile.push_back(file);
662 image->readMetadata();
664 catch (
const Exiv2::Error& e)
666 std::cerr <<
"Caught Exiv2 exception '" << e.what() <<
"' for file " << file << std::endl;
667 errorReadingFile.push_back(file);
669 Exiv2::ExifData &exifData = image->exifData();
670 if (exifData.empty())
672 errorReadingFile.push_back(file);
676 auto make = Exiv2::make(exifData);
677 if (make != exifData.end() && make->count())
679 cam = make->toString();
681 auto model = Exiv2::model(exifData);
682 if (model != exifData.end() && model->count())
684 cam +=
"|" + model->toString();
694 differentCam.push_back(file);
699 if (!errorReadingFile.IsEmpty())
702 wxXmlResource::Get()->LoadDialog(&dlg,
this,
"dlg_warning_filename");
703 dlg.SetLabel(_(
"Warning: Read error"));
704 XRCCTRL(dlg,
"dlg_warning_text", wxStaticText)->SetLabel(_(
"The following files will be skipped because the metadata of these files could not read."));
705 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(errorReadingFile);
707 dlg.CenterOnScreen();
709 for (
auto& file : errorReadingFile)
711 m_rawImages.Remove(file);
713 if (m_rawImages.IsEmpty())
718 if (differentCam.IsEmpty())
726 wxXmlResource::Get()->LoadDialog(&dlg,
this,
"dlg_warning_filename");
727 dlg.SetLabel(_(
"Warning: raw images from different cameras"));
728 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."));
729 XRCCTRL(dlg,
"dlg_warning_list", wxListBox)->Append(differentCam);
731 dlg.CenterOnScreen();
739 std::shared_ptr<RawImport> rawConverter;
740 long rawConverterInt;
741 if (XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->GetValue())
743 rawConverter = std::make_shared<DCRawImport>();
748 if (XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->GetValue())
750 rawConverter = std::make_shared<RTRawImport>();
755 rawConverter = std::make_shared<DarkTableRawImport>();
760 if (!rawConverter->CheckExe(
this))
765 if (!rawConverter->ProcessAdditionalParameters(
this))
772 wxArrayString existingImages;
775 wxFileName newImage(img);
776 newImage.SetExt(rawConverter->GetImageExtension());
777 m_images.push_back(newImage.GetFullPath());
778 if (newImage.FileExists())
780 existingImages.push_back(newImage.GetFullPath());
783 if (!existingImages.IsEmpty())
786 wxXmlResource::Get()->LoadDialog(&dlg,
this,
"dlg_warning_overwrite");
787 XRCCTRL(dlg,
"dlg_overwrite_list", wxListBox)->Append(existingImages);
789 dlg.CenterOnScreen();
790 if (dlg.ShowModal() != wxID_OK)
795 if (!rawConverter->SupportsOverwrite())
799 for (
auto& img : existingImages)
806 if (dlg.ShowModal() == wxID_OK)
809 wxConfigBase* config = wxConfig::Get();
810 config->Write(
"/RawImportDialog/Converter", rawConverterInt);
811 config->Write(
"/RawImportDialog/dcrawParameter", XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->GetValue().Trim(
true).Trim(
false));
812 config->Write(
"/RawImportDialog/RTProcessingProfile", XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl)->GetValue());
815 std::vector<std::string> files;
816 bool missingFiles =
false;
828 if (missingFiles || files.empty())
831 _(
"Hugin"), wxOK | wxICON_INFORMATION,
this);
838 std::vector<PanoCommand::PanoCommand*> cmds;
847 EndModal(wxID_CANCEL);
852 wxTextCtrl* input = XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl);
853 wxFileDialog dlg(
this, _(
"Select default RT processing profile"),
"", input->GetValue(), _(
"RT processing profile|*.pp3"), wxFD_OPEN, wxDefaultPosition);
854 if (dlg.ShowModal() == wxID_OK)
856 input->SetValue(dlg.GetPath());
867 if (XRCCTRL(*
this,
"raw_rb_dcraw", wxRadioButton)->GetValue())
869 rawConverter = Converter::DCRAW;
873 if (XRCCTRL(*
this,
"raw_rb_rt", wxRadioButton)->GetValue())
875 rawConverter = Converter::RAWTHERAPEE;
879 rawConverter = Converter::DARKTABLE;
882 XRCCTRL(*
this,
"raw_dcraw_text", wxStaticText)->Enable(rawConverter == Converter::DCRAW);
883 XRCCTRL(*
this,
"raw_dcraw_parameter", wxTextCtrl)->Enable(rawConverter == Converter::DCRAW);
884 XRCCTRL(*
this,
"raw_rt_text", wxStaticText)->Enable(rawConverter == Converter::RAWTHERAPEE);
885 XRCCTRL(*
this,
"raw_rt_processing_profile", wxTextCtrl)->Enable(rawConverter == Converter::RAWTHERAPEE);
886 XRCCTRL(*
this,
"raw_rt_processing_profile_select", wxButton)->Enable(rawConverter == Converter::RAWTHERAPEE);
891 wxChoice* choice = XRCCTRL(*
this,
"raw_choice_wb", wxChoice);
895 choice->Append(file.GetFullName());
897 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
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
virtual wxString GetImageExtension()
image extension of converted files
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
RawImportDialog(wxWindow *parent, HuginBase::Panorama *pano, std::vector< std::string > &rawFiles)
Constructor, read from xrc ressource; restore last uses settings and position.
wxString GetDefaultExe() override
returns the default name of the executable
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)
wxwindows specific panorama commands
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)
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
wxString GetDefaultExe() override
returns the default name of the executable
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
wxString GetDefaultExe() override
returns the default name of the executable
virtual bool SupportsOverwrite()
return true if program supports overwritting output, otherwise false
void OnProgress(wxCommandEvent &event)
virtual ~RawImportProgress()
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
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