28 #include <wx/busyinfo.h>
34 wxArrayString subDirs;
42 bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS);
45 subDirs.Add(filename);
46 cont = dir.GetNext(&filename);
54 const wxString formatString = wxString::Format(
"%%0%dd", width);
55 return wxString::Format(formatString, x);
83 wxXmlResource::Get()->LoadDialog(
this,batchframe,
"generate_sequence_dialog");
86 wxIconBundle myIcons(xrcPrefix+
"data/ptbatcher.ico",wxBITMAP_TYPE_ICO);
89 wxIcon myIcon(xrcPrefix +
"data/ptbatcher.png",wxBITMAP_TYPE_PNG);
92 m_batchframe=batchframe;
93 m_filename = ptoFilename;
95 if (IsValidPanorama())
97 this->SetLabel(wxString::Format(_(
"Generating sequence from %s"), m_filename.c_str()));
98 m_basepath = XRCCTRL(*
this,
"sequence_base_path", wxTextCtrl);
99 m_basepath->SetValue(wxPathOnly(m_filename));
101 m_choiceSubDir = XRCCTRL(*
this,
"sequence_choice_subdirectory", wxChoice);
102 m_subDirTextCtrl = XRCCTRL(*
this,
"sequence_directory_name", wxTextCtrl);
104 m_imagesListCtrl = XRCCTRL(*
this,
"sequence_images_list", wxListCtrl);
105 m_imagesListCtrl->InsertColumn(0, _(
"Template image name"));
106 m_imagesListCtrl->InsertColumn(1, _(
"Sequence image name"));
109 m_originalImage = XRCCTRL(*
this,
"sequence_orignal_image_text", wxStaticText);
110 m_imageTemplate = XRCCTRL(*
this,
"sequence_image_text", wxTextCtrl);
111 m_changeImageTemplate = XRCCTRL(*
this,
"sequence_change_image", wxButton);
112 m_changeAllImagesTemplate = XRCCTRL(*
this,
"sequence_change_all_images", wxButton);
114 m_spinCounterP_offset = XRCCTRL(*
this,
"sequence_p_offset", wxSpinCtrl);
115 m_spinCounterP_step = XRCCTRL(*
this,
"sequence_p_step", wxSpinCtrl);
116 m_spinCounterP_end = XRCCTRL(*
this,
"sequence_p_end", wxSpinCtrl);
117 m_spinCounterI_offset = XRCCTRL(*
this,
"sequence_i_offset", wxSpinCtrl);
118 m_spinCounterI_step = XRCCTRL(*
this,
"sequence_i_step", wxSpinCtrl);
119 m_spinCounterI_end = XRCCTRL(*
this,
"sequence_i_end", wxSpinCtrl);
120 m_spinCounterX_offset = XRCCTRL(*
this,
"sequence_x_offset", wxSpinCtrl);
121 m_spinCounterX_step = XRCCTRL(*
this,
"sequence_x_step", wxSpinCtrl);
122 m_spinCounterX_end = XRCCTRL(*
this,
"sequence_x_end", wxSpinCtrl);
124 wxCommandEvent dummy;
125 OnSelectSubDir(dummy);
129 wxConfigBase* config = wxConfigBase::Get();
132 wxDisplaySize(&dx, &dy);
133 bool maximized = config->Read(
"/GenerateSequenceDialog/maximized", 0l) != 0;
141 int w = config->Read(
"/GenerateSequenceDialog/width", -1l);
142 int h = config->Read(
"/GenerateSequenceDialog/height", -1l);
143 if (w > 0 && w <= dx)
145 this->SetClientSize(w, h);
152 int x = config->Read(
"/GenerateSequenceDialog/positionX", -1l);
153 int y = config->Read(
"/GenerateSequenceDialog/positionY", -1l);
154 if (y >= 0 && x >= 0 && x < dx && y < dy)
164 m_imagesListCtrl->SetColumnWidth(0, config->Read(
"/GenerateSequenceDialog/ImageListColumn0Width", 200l));
165 m_imagesListCtrl->SetColumnWidth(1, config->Read(
"/GenerateSequenceDialog/ImageListColumn1Width", 200l));
166 XRCCTRL(*
this,
"sequence_naming", wxChoice)->SetSelection(config->Read(
"/GenerateSequenceDialog/NamingConvention", 0l));
168 XRCCTRL(*
this,
"sequence_counter_help", wxTextCtrl)->SetBackgroundColour(this->GetBackgroundColour());
173 wxConfigBase* config=wxConfigBase::Get();
174 if(!this->IsMaximized())
176 wxSize sz = this->GetClientSize();
177 config->Write(
"/GenerateSequenceDialog/width", sz.GetWidth());
178 config->Write(
"/GenerateSequenceDialog/height", sz.GetHeight());
179 wxPoint ps = this->GetPosition();
180 config->Write(
"/GenerateSequenceDialog/positionX", ps.x);
181 config->Write(
"/GenerateSequenceDialog/positionY", ps.y);
182 config->Write(
"/GenerateSequenceDialog/maximized", 0);
186 config->Write(wxT(
"/GenerateSequenceDialog/maximized"), 1l);
188 config->Write(
"/GenerateSequenceDialog/ImageListColumn0Width",
m_imagesListCtrl->GetColumnWidth(0));
189 config->Write(
"/GenerateSequenceDialog/ImageListColumn1Width",
m_imagesListCtrl->GetColumnWidth(1));
190 config->Write(
"/GenerateSequenceDialog/NamingConvention", XRCCTRL(*
this,
"sequence_naming", wxChoice)->GetSelection());
225 selItem =
m_imagesListCtrl->GetNextItem(selItem, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
238 m_imagesListCtrl->SetItemState(selItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
244 wxDirDialog dlg(
this, _(
"Specify a directory to search for projects in"),
245 m_basepath->GetValue(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
246 if (dlg.ShowModal() == wxID_OK)
286 item =
m_imagesListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
305 item =
m_imagesListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
375 const size_t pano_width = XRCCTRL(*
this,
"sequence_p_width", wxSpinCtrl)->GetValue();
378 const size_t img_width = XRCCTRL(*
this,
"sequence_i_width", wxSpinCtrl)->GetValue();
381 const size_t x_width = XRCCTRL(*
this,
"sequence_x_width", wxSpinCtrl)->GetValue();
382 const size_t pano_count = (pano_end - pano_offset) / pano_step + 1;
388 if (panoSubDirs.IsEmpty())
397 panoSubDirs.resize(pano_count);
398 if (!panoNameTemplate.IsEmpty())
400 size_t panoCounter = pano_offset;
401 for (
size_t i = 0; i < pano_count; ++i, panoCounter += pano_step)
403 panoSubDirs[i] = panoNameTemplate;
405 panoSubDirs[i].Replace(
"%p",
GetNumberString(panoCounter, pano_width),
true);
410 size_t panoCounter = pano_offset;
411 size_t xCounter = x_offset;
412 for (
size_t i = 0; i < pano_count; ++i, panoCounter += pano_step)
414 wxFileName currentPath;
416 if (!panoSubDirs[i].IsEmpty())
418 currentPath.AppendDir(panoSubDirs[i]);
420 size_t imgCounter = img_offset;
421 wxArrayString panoFileList;
422 for (
size_t j = 0; j <
m_pano.
getNrOfImages(); ++j, imgCounter += img_step, xCounter += x_step)
430 wxFileName fileName(file);
431 fileName.MakeAbsolute(currentPath.GetPath());
432 panoFileList.Add(fileName.GetFullPath());
434 fileList.push_back(panoFileList);
440 wxWindowDisabler winDisable;
444 .Text(_(
"Generating preview list. Please wait..."))
448 wxArrayString subDirList;
449 std::vector<wxArrayString> fileList;
451 wxTextCtrl* preview = XRCCTRL(*
this,
"sequence_preview", wxTextCtrl);
455 const wxString linebreak(
"\r\n");
457 const wxString linebreak(
"\n");
459 if (fileList.empty())
461 text.Append(_(
"No matching sub-directories found."));
466 for (
size_t i = 0; i < fileList.size(); ++i)
468 text.Append(wxString::Format(_(
"Panorama %d"), i));
469 text.Append(linebreak);
470 if (!subDirList[i].IsEmpty())
472 text.Append(wxString::Format(_(
"Sub-directory: %s"), subDirList[i].c_str()));
473 text.Append(linebreak);
476 bool missingFiles =
false;
480 text.Append(fileList[i][j]);
484 text.Append(
" <-- ");
485 text.Append(_(
"File not found"));
487 text.Append(linebreak);
492 text.Append(_(
"This panorama will be skipped becaused of missing files."));
493 text.Append(linebreak);
497 preview->SetValue(text);
514 newSrcImg.setFilename(oldSrcImg.getFilename());
515 if (oldSrcImg.getSize() != newSrcImg.getSize())
518 newSrcImg.
resize(oldSrcImg.getSize(), &vars[i]);
525 if (!vars[i].empty())
539 projectFile.SetPath(basePath);
540 projectFile.SetExt(wxT(
"pto"));
541 if (!projectFile.IsDirWritable())
549 mask = wxString::Format(
"panorama%d", currentIndex);
556 mask = f1.GetName() + wxT(
"-") + f2.GetName();
562 wxArrayString folders = projectFile.GetDirs();
563 if (folders.GetCount() == 0)
567 mask = folders.Last();
574 mask = newProject.GetName();
575 projectFile.SetName(mask);
579 mask = wxString::Format(
"panorama%d", currentIndex);
582 projectFile.SetName(mask);
583 if (projectFile.FileExists())
586 mask = mask.Append(
"_%d");
587 projectFile.SetName(wxString::Format(mask, i));
588 while (projectFile.FileExists())
591 projectFile.SetName(wxString::Format(mask, i));
604 wxWindowDisabler winDisable;
608 .Text(_(
"Generating panorama files. Please wait..."))
611 wxArrayString subDirList;
612 std::vector<wxArrayString> fileList;
614 if (fileList.empty())
616 wxMessageBox(_(
"No matching sub-directories found."),
622 wxOK | wxICON_EXCLAMATION, NULL);
626 const wxString basePath =
m_basepath->GetValue();
627 wxArrayString ptoFileList;
629 for (
size_t i = 0; i < fileList.size(); ++i)
632 bool missingFiles =
false;
645 bool allFilesReadable =
true;
652 allFilesReadable =
false;
657 if (allFilesReadable)
662 wxFileName projectFile;
663 if (!
GetNewProjectFilename(XRCCTRL(*
this,
"sequence_naming", wxChoice)->GetSelection(), newGeneratedPano, basePath, projectFile, i))
670 ptoFileList.Add(projectFile.GetFullPath());
675 if (!ptoFileList.IsEmpty())
wxArrayString m_orignalFilenames
wxTextCtrl * m_subDirTextCtrl
wxTextCtrl * m_imageTemplate
bool FileExists(const std::string &filename)
checks if file exists
wxString GetNumberString(size_t x, size_t width)
return given number as string with given number of digits
Definition of GenerateSequenceDialog class.
void setMemento(const PanoramaMemento &memento)
set the internal state
BatchFrame * m_batchframe
void OnGenerateAssistantPanorama(wxCommandEvent &e)
generate assistant sequence button
SrcPanoImage getSrcImage(unsigned imgNr) const
get a description of a source image
HuginBase::Panorama m_pano
bool checkImageSizeKnown()
check if the image size is known, if try to load the information from the file
void OnUpdateImageTemplate(wxCommandEvent &e)
update image filename template on selected image
Dialog for generate panoramas from a sequence of images.
void OnGenerateStitchingPanorama(wxCommandEvent &e)
generate stitching sequence button
wxStaticText * m_originalImage
wxSpinCtrl * m_spinCounterP_end
#define DEBUG_ASSERT(cond)
include file for the hugin project
void ApplyTemplate(const HuginBase::Panorama &pano, HuginBase::Panorama &newPano)
copy the image files from pano to newPano -> this corresponds to apply the template newPano to pano t...
wxSpinCtrl * m_spinCounterI_end
wxListCtrl * m_imagesListCtrl
virtual void updateVariables(const VariableMapVector &vars)
Set the variables.
Panorama duplicate() const
duplicate the panorama
std::vector< VariableMap > VariableMapVector
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
bool loadPTScript(std::istream &i, int &ptoVersion, const std::string &prefix="")
load a Hugin file
wxArrayString m_mappedFilenames
std::size_t getNrOfImages() const
number of images.
void setCtrlPoints(const CPVector &points)
set all control points (Ippei: Is this supposed to be 'add' method?)
void OnSelectBasePath(wxCommandEvent &e)
show select directory dialog
wxSpinCtrl * m_spinCounterP_step
void OnUpdateAllImagesTemplate(wxCommandEvent &e)
update images filename template for all images
void FillImagesList()
fill the images list with current values
void GenerateFileList(wxArrayString &panoSubDirs, std::vector< wxArrayString > &fileList)
generate a list of all panorama and images in panoramas
void OnImageListSelected(wxListEvent &e)
image in list ctrl selected
void resize(const vigra::Size2D &size, VariableMap *potentialLinkedVars)
"resize" image, adjusts all distortion coefficients for usage with a source image of size size potent...
wxSpinCtrl * m_spinCounterP_offset
wxChoice * m_choiceSubDir
void OnUpdateCounters(wxSpinEvent &e)
update all spin controls with current numbers
unsigned int addImage(const SrcPanoImage &img)
the the number for a specific image
bool GetNewProjectFilename(long index, const HuginBase::Panorama &pano, const wxString basePath, wxFileName &projectFile, unsigned int currentIndex)
generate filename from given settings and panorama append a number if file already exists ...
wxArrayString GetAllSubDirectories(const wxString baseDir)
return a list of all sub-directories
void DoGeneratePanorama(const Project::Target target)
generates all panoramas and add them to the batch queue with given queue target
wxSpinCtrl * m_spinCounterX_offset
void OnSelectSubDir(wxCommandEvent &e)
select which sub-directory should be used
void UpdateCounters()
update all counters, enable/disable end value and calculate end values
wxSpinCtrl * m_spinCounterI_offset
~GenerateSequenceDialog()
destructor, saves size and position
Memento class for a Panorama object.
void OnGeneratePreview(wxCommandEvent &e)
generate preview
void ReadPTOFile()
read pto template from file
std::vector< ControlPoint > CPVector
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
bool IsValidPanorama() const
return true if given template is a valid pto file, if not the dialog should not be used ...
void setSrcImage(unsigned int nr, const SrcPanoImage &img)
set input image parameters
wxSpinCtrl * m_spinCounterX_end
All variables of a source image.
wxButton * m_changeImageTemplate
wxButton * m_changeAllImagesTemplate
wxSpinCtrl * m_spinCounterX_step
wxString getDefaultProjectName(const HuginBase::Panorama &pano, const wxString filenameTemplate)
gets the default project name, as defined in the preferences
wxSpinCtrl * m_spinCounterI_step
void AddArrayToList(const wxArrayString &fileList, Project::Target target)