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);
62 wxXmlResource::Get()->LoadDialog(
this,batchframe,
"generate_sequence_dialog");
69 this->SetLabel(wxString::Format(_(
"Generating sequence from %s"),
m_filename.c_str()));
70 m_basepath = XRCCTRL(*
this,
"sequence_base_path", wxTextCtrl);
73 m_choiceSubDir = XRCCTRL(*
this,
"sequence_choice_subdirectory", wxChoice);
85 m_originalImage = XRCCTRL(*
this,
"sequence_orignal_image_text", wxStaticText);
111 wxCommandEvent dummy;
116 wxConfigBase* config = wxConfigBase::Get();
119 wxDisplaySize(&dx, &dy);
120 bool maximized = config->Read(
"/GenerateSequenceDialog/maximized", 0l) != 0;
128 int w = config->Read(
"/GenerateSequenceDialog/width", -1l);
129 int h = config->Read(
"/GenerateSequenceDialog/height", -1l);
130 if (w > 0 && w <= dx)
132 this->SetClientSize(w, h);
139 int x = config->Read(
"/GenerateSequenceDialog/positionX", -1l);
140 int y = config->Read(
"/GenerateSequenceDialog/positionY", -1l);
141 if (y >= 0 && x >= 0 && x < dx && y < dy)
151 m_imagesListCtrl->SetColumnWidth(0, config->Read(
"/GenerateSequenceDialog/ImageListColumn0Width", 200l));
152 m_imagesListCtrl->SetColumnWidth(1, config->Read(
"/GenerateSequenceDialog/ImageListColumn1Width", 200l));
153 XRCCTRL(*
this,
"sequence_naming", wxChoice)->SetSelection(config->Read(
"/GenerateSequenceDialog/NamingConvention", 0l));
155 XRCCTRL(*
this,
"sequence_counter_help", wxTextCtrl)->SetBackgroundColour(this->GetBackgroundColour());
165 wxConfigBase* config=wxConfigBase::Get();
166 if(!this->IsMaximized())
168 wxSize sz = this->GetClientSize();
169 config->Write(
"/GenerateSequenceDialog/width", sz.GetWidth());
170 config->Write(
"/GenerateSequenceDialog/height", sz.GetHeight());
171 wxPoint ps = this->GetPosition();
172 config->Write(
"/GenerateSequenceDialog/positionX", ps.x);
173 config->Write(
"/GenerateSequenceDialog/positionY", ps.y);
174 config->Write(
"/GenerateSequenceDialog/maximized", 0);
178 config->Write(wxT(
"/GenerateSequenceDialog/maximized"), 1l);
180 config->Write(
"/GenerateSequenceDialog/ImageListColumn0Width",
m_imagesListCtrl->GetColumnWidth(0));
181 config->Write(
"/GenerateSequenceDialog/ImageListColumn1Width",
m_imagesListCtrl->GetColumnWidth(1));
182 config->Write(
"/GenerateSequenceDialog/NamingConvention", XRCCTRL(*
this,
"sequence_naming", wxChoice)->GetSelection());
217 selItem =
m_imagesListCtrl->GetNextItem(selItem, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
230 m_imagesListCtrl->SetItemState(selItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
236 wxDirDialog dlg(
this, _(
"Specify a directory to search for projects in"),
237 m_basepath->GetValue(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
238 if (dlg.ShowModal() == wxID_OK)
278 item =
m_imagesListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
297 item =
m_imagesListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
367 const size_t pano_width = XRCCTRL(*
this,
"sequence_p_width", wxSpinCtrl)->GetValue();
370 const size_t img_width = XRCCTRL(*
this,
"sequence_i_width", wxSpinCtrl)->GetValue();
373 const size_t x_width = XRCCTRL(*
this,
"sequence_x_width", wxSpinCtrl)->GetValue();
374 const size_t pano_count = (pano_end - pano_offset) / pano_step + 1;
380 if (panoSubDirs.IsEmpty())
389 panoSubDirs.resize(pano_count);
390 if (!panoNameTemplate.IsEmpty())
392 size_t panoCounter = pano_offset;
393 for (
size_t i = 0; i < pano_count; ++i, panoCounter += pano_step)
395 panoSubDirs[i] = panoNameTemplate;
397 panoSubDirs[i].Replace(
"%p",
GetNumberString(panoCounter, pano_width),
true);
402 size_t panoCounter = pano_offset;
403 size_t xCounter = x_offset;
404 for (
size_t i = 0; i < pano_count; ++i, panoCounter += pano_step)
406 wxFileName currentPath;
408 if (!panoSubDirs[i].IsEmpty())
410 currentPath.AppendDir(panoSubDirs[i]);
412 size_t imgCounter = img_offset;
413 wxArrayString panoFileList;
414 for (
size_t j = 0; j <
m_pano.
getNrOfImages(); ++j, imgCounter += img_step, xCounter += x_step)
422 wxFileName fileName(file);
423 fileName.MakeAbsolute(currentPath.GetPath());
424 panoFileList.Add(fileName.GetFullPath());
426 fileList.push_back(panoFileList);
432 wxWindowDisabler winDisable;
436 .Text(_(
"Generating preview list. Please wait..."))
440 wxArrayString subDirList;
441 std::vector<wxArrayString> fileList;
443 wxTextCtrl* preview = XRCCTRL(*
this,
"sequence_preview", wxTextCtrl);
447 const wxString linebreak(
"\r\n");
449 const wxString linebreak(
"\n");
451 if (fileList.empty())
453 text.Append(_(
"No matching sub-directories found."));
458 for (
size_t i = 0; i < fileList.size(); ++i)
460 text.Append(wxString::Format(_(
"Panorama %d"), i));
461 text.Append(linebreak);
462 if (!subDirList[i].IsEmpty())
464 text.Append(wxString::Format(_(
"Sub-directory: %s"), subDirList[i].c_str()));
465 text.Append(linebreak);
468 bool missingFiles =
false;
472 text.Append(fileList[i][j]);
476 text.Append(
" <-- ");
477 text.Append(_(
"File not found"));
479 text.Append(linebreak);
484 text.Append(_(
"This panorama will be skipped becaused of missing files."));
485 text.Append(linebreak);
489 preview->SetValue(text);
506 newSrcImg.setFilename(oldSrcImg.getFilename());
507 if (oldSrcImg.getSize() != newSrcImg.getSize())
510 newSrcImg.
resize(oldSrcImg.getSize(), &vars[i]);
517 if (!vars[i].empty())
531 projectFile.SetPath(basePath);
532 projectFile.SetExt(wxT(
"pto"));
533 if (!projectFile.IsDirWritable())
541 mask = wxString::Format(
"panorama%d", currentIndex);
548 mask = f1.GetName() + wxT(
"-") + f2.GetName();
554 wxArrayString folders = projectFile.GetDirs();
555 if (folders.GetCount() == 0)
559 mask = folders.Last();
566 mask = newProject.GetName();
567 projectFile.SetName(mask);
571 mask = wxString::Format(
"panorama%d", currentIndex);
574 projectFile.SetName(mask);
575 if (projectFile.FileExists())
578 mask = mask.Append(
"_%d");
579 projectFile.SetName(wxString::Format(mask, i));
580 while (projectFile.FileExists())
583 projectFile.SetName(wxString::Format(mask, i));
596 wxWindowDisabler winDisable;
600 .Text(_(
"Generating panorama files. Please wait..."))
603 wxArrayString subDirList;
604 std::vector<wxArrayString> fileList;
606 if (fileList.empty())
608 wxMessageBox(_(
"No matching sub-directories found."),
614 wxOK | wxICON_EXCLAMATION, NULL);
618 const wxString basePath =
m_basepath->GetValue();
619 wxArrayString ptoFileList;
621 for (
size_t i = 0; i < fileList.size(); ++i)
624 bool missingFiles =
false;
637 bool allFilesReadable =
true;
644 allFilesReadable =
false;
649 if (allFilesReadable)
654 wxFileName projectFile;
655 if (!
GetNewProjectFilename(XRCCTRL(*
this,
"sequence_naming", wxChoice)->GetSelection(), newGeneratedPano, basePath, projectFile, i))
662 ptoFileList.Add(projectFile.GetFullPath());
667 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
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
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)