28 #include <wx/busyinfo.h>
35 wxArrayString subDirs;
43 bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS);
46 subDirs.Add(filename);
47 cont = dir.GetNext(&filename);
55 const wxString formatString = wxString::Format(
"%%0%dd", width);
56 return wxString::Format(formatString, x);
63 wxXmlResource::Get()->LoadDialog(
this,batchframe,
"generate_sequence_dialog");
70 this->SetLabel(wxString::Format(_(
"Generating sequence from %s"),
m_filename.c_str()));
71 m_basepath = XRCCTRL(*
this,
"sequence_base_path", wxTextCtrl);
74 m_choiceSubDir = XRCCTRL(*
this,
"sequence_choice_subdirectory", wxChoice);
86 m_originalImage = XRCCTRL(*
this,
"sequence_orignal_image_text", wxStaticText);
112 wxCommandEvent dummy;
117 wxConfigBase* config = wxConfigBase::Get();
120 m_imagesListCtrl->SetColumnWidth(0, config->Read(
"/GenerateSequenceDialog/ImageListColumn0Width", 200l));
121 m_imagesListCtrl->SetColumnWidth(1, config->Read(
"/GenerateSequenceDialog/ImageListColumn1Width", 200l));
122 XRCCTRL(*
this,
"sequence_naming", wxChoice)->SetSelection(config->Read(
"/GenerateSequenceDialog/NamingConvention", 0l));
124 XRCCTRL(*
this,
"sequence_counter_help", wxTextCtrl)->SetBackgroundColour(this->GetBackgroundColour());
134 wxConfigBase* config=wxConfigBase::Get();
136 config->Write(
"/GenerateSequenceDialog/ImageListColumn0Width",
m_imagesListCtrl->GetColumnWidth(0));
137 config->Write(
"/GenerateSequenceDialog/ImageListColumn1Width",
m_imagesListCtrl->GetColumnWidth(1));
138 config->Write(
"/GenerateSequenceDialog/NamingConvention", XRCCTRL(*
this,
"sequence_naming", wxChoice)->GetSelection());
173 selItem =
m_imagesListCtrl->GetNextItem(selItem, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
186 m_imagesListCtrl->SetItemState(selItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
192 wxDirDialog dlg(
this, _(
"Specify a directory to search for projects in"),
193 m_basepath->GetValue(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
194 if (dlg.ShowModal() == wxID_OK)
234 item =
m_imagesListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
253 item =
m_imagesListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
323 const size_t pano_width = XRCCTRL(*
this,
"sequence_p_width", wxSpinCtrl)->GetValue();
326 const size_t img_width = XRCCTRL(*
this,
"sequence_i_width", wxSpinCtrl)->GetValue();
329 const size_t x_width = XRCCTRL(*
this,
"sequence_x_width", wxSpinCtrl)->GetValue();
330 const size_t pano_count = (pano_end - pano_offset) / pano_step + 1;
336 if (panoSubDirs.IsEmpty())
345 panoSubDirs.resize(pano_count);
346 if (!panoNameTemplate.IsEmpty())
348 size_t panoCounter = pano_offset;
349 for (
size_t i = 0; i < pano_count; ++i, panoCounter += pano_step)
351 panoSubDirs[i] = panoNameTemplate;
353 panoSubDirs[i].Replace(
"%p",
GetNumberString(panoCounter, pano_width),
true);
358 size_t panoCounter = pano_offset;
359 size_t xCounter = x_offset;
360 for (
size_t i = 0; i < pano_count; ++i, panoCounter += pano_step)
362 wxFileName currentPath;
364 if (!panoSubDirs[i].IsEmpty())
366 currentPath.AppendDir(panoSubDirs[i]);
368 size_t imgCounter = img_offset;
369 wxArrayString panoFileList;
370 for (
size_t j = 0; j <
m_pano.
getNrOfImages(); ++j, imgCounter += img_step, xCounter += x_step)
378 wxFileName fileName(file);
379 fileName.MakeAbsolute(currentPath.GetPath());
380 panoFileList.Add(fileName.GetFullPath());
382 fileList.push_back(panoFileList);
388 wxWindowDisabler winDisable;
392 .Text(_(
"Generating preview list. Please wait..."))
396 wxArrayString subDirList;
397 std::vector<wxArrayString> fileList;
399 wxTextCtrl* preview = XRCCTRL(*
this,
"sequence_preview", wxTextCtrl);
403 const wxString linebreak(
"\r\n");
405 const wxString linebreak(
"\n");
407 if (fileList.empty())
409 text.Append(_(
"No matching sub-directories found."));
414 for (
size_t i = 0; i < fileList.size(); ++i)
416 text.Append(wxString::Format(_(
"Panorama %d"), i));
417 text.Append(linebreak);
418 if (!subDirList[i].IsEmpty())
420 text.Append(wxString::Format(_(
"Sub-directory: %s"), subDirList[i].c_str()));
421 text.Append(linebreak);
424 bool missingFiles =
false;
428 text.Append(fileList[i][j]);
432 text.Append(
" <-- ");
433 text.Append(_(
"File not found"));
435 text.Append(linebreak);
440 text.Append(_(
"This panorama will be skipped becaused of missing files."));
441 text.Append(linebreak);
445 preview->SetValue(text);
462 newSrcImg.setFilename(oldSrcImg.getFilename());
463 if (oldSrcImg.getSize() != newSrcImg.getSize())
466 newSrcImg.
resize(oldSrcImg.getSize(), &vars[i]);
473 if (!vars[i].empty())
487 projectFile.SetPath(basePath);
488 projectFile.SetExt(
"pto");
489 if (!projectFile.IsDirWritable())
497 mask = wxString::Format(
"panorama%d", currentIndex);
504 mask = f1.GetName() +
"-" + f2.GetName();
510 wxArrayString folders = projectFile.GetDirs();
511 if (folders.GetCount() == 0)
515 mask = folders.Last();
522 mask = newProject.GetName();
523 projectFile.SetName(mask);
527 mask = wxString::Format(
"panorama%d", currentIndex);
530 projectFile.SetName(mask);
531 if (projectFile.FileExists())
534 mask = mask.Append(
"_%d");
535 projectFile.SetName(wxString::Format(mask, i));
536 while (projectFile.FileExists())
539 projectFile.SetName(wxString::Format(mask, i));
552 wxWindowDisabler winDisable;
556 .Text(_(
"Generating panorama files. Please wait..."))
559 wxArrayString subDirList;
560 std::vector<wxArrayString> fileList;
562 if (fileList.empty())
568 const wxString basePath =
m_basepath->GetValue();
569 wxArrayString ptoFileList;
571 for (
size_t i = 0; i < fileList.size(); ++i)
574 bool missingFiles =
false;
587 bool allFilesReadable =
true;
594 allFilesReadable =
false;
599 if (allFilesReadable)
604 wxFileName projectFile;
605 if (!
GetNewProjectFilename(XRCCTRL(*
this,
"sequence_naming", wxChoice)->GetSelection(), newGeneratedPano, basePath, projectFile, i))
612 ptoFileList.Add(projectFile.GetFullPath());
617 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
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
BatchFrame * m_batchframe
void OnGenerateAssistantPanorama(wxCommandEvent &e)
generate assistant sequence button
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
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
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 ...
GenerateSequenceDialog(BatchFrame *batchframe, wxString xrcPrefix, wxString ptoFilename)
Constructor, read from xrc ressource; restore last uses settings, size and position.
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
int HuginMessageBox(const wxString &message, const wxString &caption, int style, wxWindow *parent)
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)