28 #if wxCHECK_VERSION(3,1,0)
29 #include <wx/busyinfo.h>
36 wxArrayString subDirs;
44 bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS);
47 subDirs.Add(filename);
48 cont = dir.GetNext(&filename);
56 const wxString formatString = wxString::Format(
"%%0%dd", width);
57 return wxString::Format(formatString, x);
85 wxXmlResource::Get()->LoadDialog(
this,batchframe,
"generate_sequence_dialog");
88 wxIconBundle myIcons(xrcPrefix+
"data/ptbatcher.ico",wxBITMAP_TYPE_ICO);
91 wxIcon myIcon(xrcPrefix +
"data/ptbatcher.png",wxBITMAP_TYPE_PNG);
94 m_batchframe=batchframe;
95 m_filename = ptoFilename;
97 if (IsValidPanorama())
99 this->SetLabel(wxString::Format(_(
"Generating sequence from %s"), m_filename.c_str()));
100 m_basepath = XRCCTRL(*
this,
"sequence_base_path", wxTextCtrl);
101 m_basepath->SetValue(wxPathOnly(m_filename));
103 m_choiceSubDir = XRCCTRL(*
this,
"sequence_choice_subdirectory", wxChoice);
104 m_subDirTextCtrl = XRCCTRL(*
this,
"sequence_directory_name", wxTextCtrl);
106 m_imagesListCtrl = XRCCTRL(*
this,
"sequence_images_list", wxListCtrl);
107 m_imagesListCtrl->InsertColumn(0, _(
"Template image name"));
108 m_imagesListCtrl->InsertColumn(1, _(
"Sequence image name"));
111 m_originalImage = XRCCTRL(*
this,
"sequence_orignal_image_text", wxStaticText);
112 m_imageTemplate = XRCCTRL(*
this,
"sequence_image_text", wxTextCtrl);
113 m_changeImageTemplate = XRCCTRL(*
this,
"sequence_change_image", wxButton);
114 m_changeAllImagesTemplate = XRCCTRL(*
this,
"sequence_change_all_images", wxButton);
116 m_spinCounterP_offset = XRCCTRL(*
this,
"sequence_p_offset", wxSpinCtrl);
117 m_spinCounterP_step = XRCCTRL(*
this,
"sequence_p_step", wxSpinCtrl);
118 m_spinCounterP_end = XRCCTRL(*
this,
"sequence_p_end", wxSpinCtrl);
119 m_spinCounterI_offset = XRCCTRL(*
this,
"sequence_i_offset", wxSpinCtrl);
120 m_spinCounterI_step = XRCCTRL(*
this,
"sequence_i_step", wxSpinCtrl);
121 m_spinCounterI_end = XRCCTRL(*
this,
"sequence_i_end", wxSpinCtrl);
122 m_spinCounterX_offset = XRCCTRL(*
this,
"sequence_x_offset", wxSpinCtrl);
123 m_spinCounterX_step = XRCCTRL(*
this,
"sequence_x_step", wxSpinCtrl);
124 m_spinCounterX_end = XRCCTRL(*
this,
"sequence_x_end", wxSpinCtrl);
126 wxCommandEvent dummy;
127 OnSelectSubDir(dummy);
131 wxConfigBase* config = wxConfigBase::Get();
134 wxDisplaySize(&dx, &dy);
135 bool maximized = config->Read(
"/GenerateSequenceDialog/maximized", 0l) != 0;
143 int w = config->Read(
"/GenerateSequenceDialog/width", -1l);
144 int h = config->Read(
"/GenerateSequenceDialog/height", -1l);
145 if (w > 0 && w <= dx)
147 this->SetClientSize(w, h);
154 int x = config->Read(
"/GenerateSequenceDialog/positionX", -1l);
155 int y = config->Read(
"/GenerateSequenceDialog/positionY", -1l);
156 if (y >= 0 && x >= 0 && x < dx && y < dy)
166 m_imagesListCtrl->SetColumnWidth(0, config->Read(
"/GenerateSequenceDialog/ImageListColumn0Width", 200l));
167 m_imagesListCtrl->SetColumnWidth(1, config->Read(
"/GenerateSequenceDialog/ImageListColumn1Width", 200l));
168 XRCCTRL(*
this,
"sequence_naming", wxChoice)->SetSelection(config->Read(
"/GenerateSequenceDialog/NamingConvention", 0l));
170 XRCCTRL(*
this,
"sequence_counter_help", wxTextCtrl)->SetBackgroundColour(this->GetBackgroundColour());
175 wxConfigBase* config=wxConfigBase::Get();
176 if(!this->IsMaximized())
178 wxSize sz = this->GetClientSize();
179 config->Write(
"/GenerateSequenceDialog/width", sz.GetWidth());
180 config->Write(
"/GenerateSequenceDialog/height", sz.GetHeight());
181 wxPoint ps = this->GetPosition();
182 config->Write(
"/GenerateSequenceDialog/positionX", ps.x);
183 config->Write(
"/GenerateSequenceDialog/positionY", ps.y);
184 config->Write(
"/GenerateSequenceDialog/maximized", 0);
188 config->Write(wxT(
"/GenerateSequenceDialog/maximized"), 1l);
190 config->Write(
"/GenerateSequenceDialog/ImageListColumn0Width",
m_imagesListCtrl->GetColumnWidth(0));
191 config->Write(
"/GenerateSequenceDialog/ImageListColumn1Width",
m_imagesListCtrl->GetColumnWidth(1));
192 config->Write(
"/GenerateSequenceDialog/NamingConvention", XRCCTRL(*
this,
"sequence_naming", wxChoice)->GetSelection());
227 selItem =
m_imagesListCtrl->GetNextItem(selItem, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
240 m_imagesListCtrl->SetItemState(selItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
246 wxDirDialog dlg(
this, _(
"Specify a directory to search for projects in"),
247 m_basepath->GetValue(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
248 if (dlg.ShowModal() == wxID_OK)
288 item =
m_imagesListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
307 item =
m_imagesListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
377 const size_t pano_width = XRCCTRL(*
this,
"sequence_p_width", wxSpinCtrl)->GetValue();
380 const size_t img_width = XRCCTRL(*
this,
"sequence_i_width", wxSpinCtrl)->GetValue();
383 const size_t x_width = XRCCTRL(*
this,
"sequence_x_width", wxSpinCtrl)->GetValue();
384 const size_t pano_count = (pano_end - pano_offset) / pano_step + 1;
390 if (panoSubDirs.IsEmpty())
399 panoSubDirs.resize(pano_count);
400 if (!panoNameTemplate.IsEmpty())
402 size_t panoCounter = pano_offset;
403 for (
size_t i = 0; i < pano_count; ++i, panoCounter += pano_step)
405 panoSubDirs[i] = panoNameTemplate;
407 panoSubDirs[i].Replace(
"%p",
GetNumberString(panoCounter, pano_width),
true);
412 size_t panoCounter = pano_offset;
413 size_t xCounter = x_offset;
414 for (
size_t i = 0; i < pano_count; ++i, panoCounter += pano_step)
416 wxFileName currentPath;
418 if (!panoSubDirs[i].IsEmpty())
420 currentPath.AppendDir(panoSubDirs[i]);
422 size_t imgCounter = img_offset;
423 wxArrayString panoFileList;
424 for (
size_t j = 0; j <
m_pano.
getNrOfImages(); ++j, imgCounter += img_step, xCounter += x_step)
432 wxFileName fileName(file);
433 fileName.MakeAbsolute(currentPath.GetPath());
434 panoFileList.Add(fileName.GetFullPath());
436 fileList.push_back(panoFileList);
442 wxWindowDisabler winDisable;
443 #if wxCHECK_VERSION(3,1,0)
447 .Text(_(
"Generating preview list. Please wait..."))
451 wxBusyCursor waitCursor;
454 wxArrayString subDirList;
455 std::vector<wxArrayString> fileList;
457 wxTextCtrl* preview = XRCCTRL(*
this,
"sequence_preview", wxTextCtrl);
461 const wxString linebreak(
"\r\n");
463 const wxString linebreak(
"\n");
465 if (fileList.empty())
467 text.Append(_(
"No matching sub-directories found."));
472 for (
size_t i = 0; i < fileList.size(); ++i)
474 text.Append(wxString::Format(_(
"Panorama %d"), i));
475 text.Append(linebreak);
476 if (!subDirList[i].IsEmpty())
478 text.Append(wxString::Format(_(
"Sub-directory: %s"), subDirList[i].c_str()));
479 text.Append(linebreak);
482 bool missingFiles =
false;
486 text.Append(fileList[i][j]);
490 text.Append(
" <-- ");
491 text.Append(_(
"File not found"));
493 text.Append(linebreak);
498 text.Append(_(
"This panorama will be skipped becaused of missing files."));
499 text.Append(linebreak);
503 preview->SetValue(text);
520 newSrcImg.setFilename(oldSrcImg.getFilename());
521 if (oldSrcImg.getSize() != newSrcImg.getSize())
524 newSrcImg.
resize(oldSrcImg.getSize(), &vars[i]);
531 if (!vars[i].empty())
545 projectFile.SetPath(basePath);
546 projectFile.SetExt(wxT(
"pto"));
547 if (!projectFile.IsDirWritable())
555 mask = wxString::Format(
"panorama%d", currentIndex);
562 mask = f1.GetName() + wxT(
"-") + f2.GetName();
568 wxArrayString folders = projectFile.GetDirs();
569 if (folders.GetCount() == 0)
573 mask = folders.Last();
580 mask = newProject.GetName();
581 projectFile.SetName(mask);
585 mask = wxString::Format(
"panorama%d", currentIndex);
588 projectFile.SetName(mask);
589 if (projectFile.FileExists())
592 mask = mask.Append(
"_%d");
593 projectFile.SetName(wxString::Format(mask, i));
594 while (projectFile.FileExists())
597 projectFile.SetName(wxString::Format(mask, i));
610 wxWindowDisabler winDisable;
611 #if wxCHECK_VERSION(3,1,0)
615 .Text(_(
"Generating panorama files. Please wait..."))
619 wxBusyCursor waitCursor;
621 wxArrayString subDirList;
622 std::vector<wxArrayString> fileList;
624 if (fileList.empty())
626 wxMessageBox(_(
"No matching sub-directories found."),
632 wxOK | wxICON_EXCLAMATION, NULL);
636 const wxString basePath =
m_basepath->GetValue();
637 wxArrayString ptoFileList;
639 for (
size_t i = 0; i < fileList.size(); ++i)
642 bool missingFiles =
false;
655 bool allFilesReadable =
true;
662 allFilesReadable =
false;
667 if (allFilesReadable)
672 wxFileName projectFile;
673 if (!
GetNewProjectFilename(XRCCTRL(*
this,
"sequence_naming", wxChoice)->GetSelection(), newGeneratedPano, basePath, projectFile, i))
680 ptoFileList.Add(projectFile.GetFullPath());
685 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)