Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GenerateSequenceDialog.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
10 /* This is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This software is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public
21  * License along with this software. If not, see
22  * <http://www.gnu.org/licenses/>.
23  *
24  */
25 
26 #include "GenerateSequenceDialog.h"
27 #include "base_wx/wxPlatform.h"
28 #include <wx/busyinfo.h>
29 #include "panoinc.h"
30 
32 wxArrayString GetAllSubDirectories(const wxString baseDir)
33 {
34  wxArrayString subDirs;
35  wxDir dir(baseDir);
36  if (!dir.IsOpened())
37  {
38  // could not open given directories
39  return subDirs;
40  }
41  wxString filename;
42  bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS);
43  while (cont)
44  {
45  subDirs.Add(filename);
46  cont = dir.GetNext(&filename);
47  };
48  return subDirs;
49 }
50 
52 wxString GetNumberString(size_t x, size_t width)
53 {
54  const wxString formatString = wxString::Format("%%0%dd", width);
55  return wxString::Format(formatString, x);
56 }
57 
58 GenerateSequenceDialog::GenerateSequenceDialog(BatchFrame* batchframe, wxString xrcPrefix, wxString ptoFilename)
59 {
60  // load our children. some children might need special
61  // initialization. this will be done later.
62  wxXmlResource::Get()->LoadDialog(this,batchframe, "generate_sequence_dialog");
63 
64  m_batchframe=batchframe;
65  m_filename = ptoFilename;
66  ReadPTOFile();
67  if (IsValidPanorama())
68  {
69  this->SetLabel(wxString::Format(_("Generating sequence from %s"), m_filename.c_str()));
70  m_basepath = XRCCTRL(*this, "sequence_base_path", wxTextCtrl);
71  m_basepath->SetValue(wxPathOnly(m_filename));
72 
73  m_choiceSubDir = XRCCTRL(*this, "sequence_choice_subdirectory", wxChoice);
74  m_choiceSubDir->Bind(wxEVT_CHOICE, &GenerateSequenceDialog::OnSelectSubDir, this);
75  m_subDirTextCtrl = XRCCTRL(*this, "sequence_directory_name", wxTextCtrl);
76 
77  m_imagesListCtrl = XRCCTRL(*this, "sequence_images_list", wxListCtrl);
78  m_imagesListCtrl->InsertColumn(0, _("Template image name"));
79  m_imagesListCtrl->InsertColumn(1, _("Sequence image name"));
81  m_imagesListCtrl->Bind(wxEVT_LIST_ITEM_SELECTED, &GenerateSequenceDialog::OnImageListSelected, this);
82  m_imagesListCtrl->Bind(wxEVT_LIST_ITEM_DESELECTED, &GenerateSequenceDialog::OnImageListSelected, this);
83 
84 
85  m_originalImage = XRCCTRL(*this, "sequence_orignal_image_text", wxStaticText);
86  m_imageTemplate = XRCCTRL(*this, "sequence_image_text", wxTextCtrl);
87  m_changeImageTemplate = XRCCTRL(*this, "sequence_change_image", wxButton);
89  m_changeAllImagesTemplate = XRCCTRL(*this, "sequence_change_all_images", wxButton);
91 
92  m_spinCounterP_offset = XRCCTRL(*this, "sequence_p_offset", wxSpinCtrl);
94  m_spinCounterP_step = XRCCTRL(*this, "sequence_p_step", wxSpinCtrl);
96  m_spinCounterP_end = XRCCTRL(*this, "sequence_p_end", wxSpinCtrl);
98  m_spinCounterI_offset = XRCCTRL(*this, "sequence_i_offset", wxSpinCtrl);
100  m_spinCounterI_step = XRCCTRL(*this, "sequence_i_step", wxSpinCtrl);
102  m_spinCounterI_end = XRCCTRL(*this, "sequence_i_end", wxSpinCtrl);
103  m_spinCounterI_end->Bind(wxEVT_SPINCTRL, &GenerateSequenceDialog::OnUpdateCounters, this);
104  m_spinCounterX_offset = XRCCTRL(*this, "sequence_x_offset", wxSpinCtrl);
106  m_spinCounterX_step = XRCCTRL(*this, "sequence_x_step", wxSpinCtrl);
108  m_spinCounterX_end = XRCCTRL(*this, "sequence_x_end", wxSpinCtrl);
109  m_spinCounterX_end->Bind(wxEVT_SPINCTRL, &GenerateSequenceDialog::OnUpdateCounters, this);
110 
111  wxCommandEvent dummy;
112  OnSelectSubDir(dummy);
113  // UpdateCounters();
114 
115  //set parameters
116  wxConfigBase* config = wxConfigBase::Get();
117  // restore position and size
118  int dx, dy;
119  wxDisplaySize(&dx, &dy);
120  bool maximized = config->Read("/GenerateSequenceDialog/maximized", 0l) != 0;
121  if (maximized)
122  {
123  this->Maximize();
124  }
125  else
126  {
127  //size
128  int w = config->Read("/GenerateSequenceDialog/width", -1l);
129  int h = config->Read("/GenerateSequenceDialog/height", -1l);
130  if (w > 0 && w <= dx)
131  {
132  this->SetClientSize(w, h);
133  }
134  else
135  {
136  this->Fit();
137  }
138  //position
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)
142  {
143  this->Move(x, y);
144  }
145  else
146  {
147  this->Move(0, 44);
148  }
149  }
150 
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));
154  };
155  XRCCTRL(*this, "sequence_counter_help", wxTextCtrl)->SetBackgroundColour(this->GetBackgroundColour());
156  Bind(wxEVT_BUTTON, &GenerateSequenceDialog::OnSelectBasePath, this, XRCID("sequence_select_base_path"));
157  Bind(wxEVT_BUTTON, &GenerateSequenceDialog::OnGeneratePreview, this, XRCID("sequence_generate_preview"));
158  Bind(wxEVT_BUTTON, &GenerateSequenceDialog::OnGenerateStitchingPanorama, this, XRCID("sequence_generate_stitching"));
159  Bind(wxEVT_BUTTON, &GenerateSequenceDialog::OnGenerateAssistantPanorama, this, XRCID("sequence_generate_assistant"));
160 
161 };
162 
164 {
165  wxConfigBase* config=wxConfigBase::Get();
166  if(!this->IsMaximized())
167  {
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);
175  }
176  else
177  {
178  config->Write(wxT("/GenerateSequenceDialog/maximized"), 1l);
179  };
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());
183 }
184 
186 {
187  return m_validPTO && m_pano.getNrOfImages() > 0;
188 }
189 
191 {
192  std::ifstream prjfile((const char*)m_filename.mb_str(HUGIN_CONV_FILENAME));
193  if (prjfile.good())
194  {
196  int ptoVersion = 0;
197  if (newPano.loadPTScript(prjfile, ptoVersion, ""))
198  {
199  m_pano.setMemento(newPano);
200  m_validPTO = true;
201  for (size_t i = 0; i < m_pano.getNrOfImages(); ++i)
202  {
203  const wxString imageFilename(wxString(m_pano.getImage(i).getFilename().c_str(), HUGIN_CONV_FILENAME));
204  m_orignalFilenames.Add(imageFilename);
205  m_mappedFilenames.Add(imageFilename);
206  };
207  };
208  };
209 }
210 
212 {
213  long selItem = -1;
214  if (m_imagesListCtrl->GetSelectedItemCount() > 0)
215  {
216  // remember selected item
217  selItem = m_imagesListCtrl->GetNextItem(selItem, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
218  };
219  m_imagesListCtrl->DeleteAllItems();
221  for (size_t i = 0; i < m_orignalFilenames.size(); ++i)
222  {
223  const size_t index = m_imagesListCtrl->GetItemCount();
224  m_imagesListCtrl->InsertItem(index, m_orignalFilenames[i]);
225  m_imagesListCtrl->SetItem(index, 1, m_mappedFilenames[i]);
226  };
227  // restore selected item
228  if (selItem != -1)
229  {
230  m_imagesListCtrl->SetItemState(selItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
231  };
232 }
233 
235 {
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)
239  {
240  m_basepath->SetValue(dlg.GetPath());
241  OnSelectSubDir(e);
242  };
243 }
244 
246 {
247  // show text ctrl only when "use name template" use selected
248  m_subDirTextCtrl->Enable(m_choiceSubDir->GetSelection() == 2);
249  if (m_choiceSubDir->GetSelection() != 2)
250  {
251  // clear input wxTextCtrl if not used
252  m_subDirTextCtrl->Clear();
253  };
254  if (m_choiceSubDir->GetSelection() == 1)
255  {
256  // get list of all sub-directories
257  wxArrayString subDirs = GetAllSubDirectories(m_basepath->GetValue());
258  m_subDirCount = subDirs.size();
259  }
260  else
261  {
262  m_subDirCount = 0;
263  };
264  UpdateCounters();
265 }
266 
268 {
269  if (m_imagesListCtrl->GetSelectedItemCount() > 0)
270  {
271  // enable all controls
272  // if one image is selected in list control
273  m_imageTemplate->Enable(true);
274  m_changeImageTemplate->Enable(true);
275  m_changeAllImagesTemplate->Enable(true);
276  // set text
277  long item = -1;
278  item = m_imagesListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
279  m_originalImage->SetLabel(m_orignalFilenames[item]);
280  m_imageTemplate->SetValue(m_mappedFilenames[item]);
281  }
282  else
283  {
284  // no item selected, disable all related ctrl
285  m_imageTemplate->Enable(false);
286  m_changeImageTemplate->Enable(false);
287  m_changeAllImagesTemplate->Enable(false);
288  }
289 }
290 
292 {
293  if (m_imagesListCtrl->GetSelectedItemCount() > 0)
294  {
295  // find selected item
296  long item = -1;
297  item = m_imagesListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
298  // now update value
299  m_mappedFilenames[item] = m_imageTemplate->GetValue();
300  FillImagesList();
301  }
302  else
303  {
304  wxBell();
305  };
306 }
307 
309 {
310  for (size_t i = 0; i < m_mappedFilenames.size(); ++i)
311  {
312  // update values
313  m_mappedFilenames[i] = m_imageTemplate->GetValue();
314  };
315  FillImagesList();
316 }
317 
319 {
320  UpdateCounters();
321 }
322 
324 {
325  // update %p counter
326  size_t pano_count;
327  if (m_choiceSubDir->GetSelection() == 1)
328  {
329  // iterate all sub-directories selected
330  m_spinCounterP_end->Enable(false);
331  pano_count = m_subDirCount;
332  if (pano_count > 0)
333  {
334  m_spinCounterP_end->SetValue(m_spinCounterP_offset->GetValue() + m_spinCounterI_step->GetValue() * (pano_count - 1));
335  }
336  else
337  {
338  m_spinCounterP_end->SetValue(m_spinCounterP_offset->GetValue());
339  };
340  }
341  else
342  {
343  m_spinCounterP_end->Enable(true);
344  m_spinCounterP_end->SetRange(m_spinCounterP_offset->GetValue(), m_spinCounterP_end->GetMax());
345  if (m_spinCounterP_end->GetValue() < m_spinCounterP_offset->GetValue())
346  {
347  m_spinCounterP_end->SetValue(m_spinCounterP_offset->GetValue());
348  };
349  pano_count = (m_spinCounterP_end->GetValue() - m_spinCounterP_offset->GetValue()) / m_spinCounterP_step->GetValue() + 1;
350  };
351  // update end value for image counter
352  m_spinCounterI_end->Enable(false);
353  m_spinCounterI_end->SetValue(m_spinCounterI_offset->GetValue() + m_spinCounterI_step->GetValue() * (m_pano.getNrOfImages() - 1));
354  // update end value for x counter
355  m_spinCounterX_end->Enable(false);
356  m_spinCounterX_end->SetValue(m_spinCounterX_offset->GetValue() + m_spinCounterX_step->GetValue() * (m_pano.getNrOfImages() * pano_count - 1));
357 }
358 
359 void GenerateSequenceDialog::GenerateFileList(wxArrayString& panoSubDirs, std::vector<wxArrayString>& fileList)
360 {
361  // read all counter values
362  // first update all counters if necessary
363  UpdateCounters();
364  const size_t pano_offset = m_spinCounterP_offset->GetValue();
365  const size_t pano_step = m_spinCounterP_step->GetValue();
366  const size_t pano_end = m_spinCounterP_end->GetValue();
367  const size_t pano_width = XRCCTRL(*this, "sequence_p_width", wxSpinCtrl)->GetValue();
368  const size_t img_offset = m_spinCounterI_offset->GetValue();
369  const size_t img_step = m_spinCounterI_step->GetValue();
370  const size_t img_width = XRCCTRL(*this, "sequence_i_width", wxSpinCtrl)->GetValue();
371  const size_t x_offset = m_spinCounterX_offset->GetValue();
372  const size_t x_step = m_spinCounterX_step->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;
375  const size_t img_count = m_pano.getNrOfImages();
376  // generate list of all sub-directories
377  if (m_choiceSubDir->GetSelection() == 1)
378  {
379  panoSubDirs = GetAllSubDirectories(m_basepath->GetValue());
380  if (panoSubDirs.IsEmpty())
381  {
382  wxBell();
383  return;
384  };
385  }
386  else
387  {
388  wxString panoNameTemplate = m_subDirTextCtrl->GetValue();
389  panoSubDirs.resize(pano_count);
390  if (!panoNameTemplate.IsEmpty())
391  {
392  size_t panoCounter = pano_offset;
393  for (size_t i = 0; i < pano_count; ++i, panoCounter += pano_step)
394  {
395  panoSubDirs[i] = panoNameTemplate;
396  // replace placeholder
397  panoSubDirs[i].Replace("%p", GetNumberString(panoCounter, pano_width), true);
398  };
399  };
400  };
401  // now iterate all panoramas and generate file list
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)
405  {
406  wxFileName currentPath;
407  currentPath.SetPath(m_basepath->GetValue());
408  if (!panoSubDirs[i].IsEmpty())
409  {
410  currentPath.AppendDir(panoSubDirs[i]);
411  };
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)
415  {
416  // replace all counter variables
417  wxString file = m_mappedFilenames[j];
418  // replace all placeholders
419  file.Replace("%p", GetNumberString(panoCounter, pano_width), true);
420  file.Replace("%i", GetNumberString(imgCounter, img_width), true);
421  file.Replace("%x", GetNumberString(xCounter, x_width), true);
422  wxFileName fileName(file);
423  fileName.MakeAbsolute(currentPath.GetPath());
424  panoFileList.Add(fileName.GetFullPath());
425  }
426  fileList.push_back(panoFileList);
427  };
428 }
429 
431 {
432  wxWindowDisabler winDisable;
433  wxBusyInfo waitInfo(
434  wxBusyInfoFlags()
435  .Parent(this)
436  .Text(_("Generating preview list. Please wait..."))
437  .Icon(GetIcon())
438  );
439  // generate a preview of all images in text form
440  wxArrayString subDirList;
441  std::vector<wxArrayString> fileList;
442  GenerateFileList(subDirList, fileList);
443  wxTextCtrl* preview = XRCCTRL(*this, "sequence_preview", wxTextCtrl);
444  preview->Clear();
445  wxString text;
446 #ifdef __WXMSW__
447  const wxString linebreak("\r\n");
448 #else
449  const wxString linebreak("\n");
450 #endif
451  if (fileList.empty())
452  {
453  text.Append(_("No matching sub-directories found."));
454  }
455  else
456  {
457  // iterate above all panoramas
458  for (size_t i = 0; i < fileList.size(); ++i)
459  {
460  text.Append(wxString::Format(_("Panorama %d"), i));
461  text.Append(linebreak);
462  if (!subDirList[i].IsEmpty())
463  {
464  text.Append(wxString::Format(_("Sub-directory: %s"), subDirList[i].c_str()));
465  text.Append(linebreak);
466  };
467  // iterate above all files in current pano
468  bool missingFiles = false;
469  for (size_t j = 0; j < m_pano.getNrOfImages(); ++j)
470  {
471  text.Append("\t");
472  text.Append(fileList[i][j]);
473  if (!wxFileName::FileExists(fileList[i][j]))
474  {
475  missingFiles = true;
476  text.Append(" <-- ");
477  text.Append(_("File not found"));
478  };
479  text.Append(linebreak);
480  };
481  if (missingFiles)
482  {
483  text.Append("\t");
484  text.Append(_("This panorama will be skipped becaused of missing files."));
485  text.Append(linebreak);
486  };
487  };
488  };
489  preview->SetValue(text);
490 }
491 
496 {
497  // check image sizes, and correct parameters if required.
499  for (unsigned int i = 0; i < newPano.getNrOfImages(); i++)
500  {
501  // check if image size is correct
502  const HuginBase::SrcPanoImage& oldSrcImg = pano.getImage(i);
503  HuginBase::SrcPanoImage newSrcImg = newPano.getSrcImage(i);
504 
505  // just keep the file name
506  newSrcImg.setFilename(oldSrcImg.getFilename());
507  if (oldSrcImg.getSize() != newSrcImg.getSize())
508  {
509  // adjust size properly.
510  newSrcImg.resize(oldSrcImg.getSize(), &vars[i]);
511  }
512  newPano.setSrcImage(i, newSrcImg);
513  }
514  // now update all possible linked variables
515  for (unsigned int i = 0; i < newPano.getNrOfImages(); ++i)
516  {
517  if (!vars[i].empty())
518  {
519  newPano.updateVariables(i, vars[i]);
520  };
521  };
522  // remove all control points, they are only valid for the original template
524 }
525 
528 bool GetNewProjectFilename(long index, const HuginBase::Panorama& pano, const wxString basePath, wxFileName& projectFile, unsigned int currentIndex)
529 {
530  wxString mask;
531  projectFile.SetPath(basePath);
532  projectFile.SetExt(wxT("pto"));
533  if (!projectFile.IsDirWritable())
534  {
535  return false;
536  };
537  switch (index)
538  {
539  case 0:
540  // panoramaXX.pto
541  mask = wxString::Format("panorama%d", currentIndex);
542  break;
543  case 1:
544  // First file - last file.pto
545  {
546  const wxFileName f1(wxString(pano.getImage(0).getFilename().c_str(), HUGIN_CONV_FILENAME));
547  const wxFileName f2(wxString(pano.getImage(pano.getNrOfImages() - 1).getFilename().c_str(), HUGIN_CONV_FILENAME));
548  mask = f1.GetName() + wxT("-") + f2.GetName();
549  }
550  break;
551  case 2:
552  // Foldername.pto
553  {
554  wxArrayString folders = projectFile.GetDirs();
555  if (folders.GetCount() == 0)
556  {
557  return false;
558  }
559  mask = folders.Last();
560  }
561  break;
562  case 3:
563  // Template from preferences
564  {
565  wxFileName newProject(getDefaultProjectName(pano));
566  mask = newProject.GetName();
567  projectFile.SetName(mask);
568  };
569  break;
570  default:
571  mask = wxString::Format("panorama%d", currentIndex);
572  };
573 
574  projectFile.SetName(mask);
575  if (projectFile.FileExists())
576  {
577  unsigned int i = 1;
578  mask = mask.Append("_%d");
579  projectFile.SetName(wxString::Format(mask, i));
580  while (projectFile.FileExists())
581  {
582  i++;
583  projectFile.SetName(wxString::Format(mask, i));
584  //security fall through
585  if (i > 1000)
586  {
587  return false;
588  };
589  };
590  };
591  return true;
592 }
593 
595 {
596  wxWindowDisabler winDisable;
597  wxBusyInfo waitInfo(
598  wxBusyInfoFlags()
599  .Parent(this)
600  .Text(_("Generating panorama files. Please wait..."))
601  .Icon(GetIcon())
602  );
603  wxArrayString subDirList;
604  std::vector<wxArrayString> fileList;
605  GenerateFileList(subDirList, fileList);
606  if (fileList.empty())
607  {
608  wxMessageBox(_("No matching sub-directories found."),
609 #ifdef __WXMSW__
610  wxT("PTBatcherGUI"),
611 #else
612  wxEmptyString,
613 #endif
614  wxOK | wxICON_EXCLAMATION, NULL);
615  }
616  else
617  {
618  const wxString basePath = m_basepath->GetValue();
619  wxArrayString ptoFileList;
620 
621  for (size_t i = 0; i < fileList.size(); ++i)
622  {
623  // check that all files exists
624  bool missingFiles = false;
625  for (size_t j = 0; j < m_pano.getNrOfImages(); ++j)
626  {
627  if (!wxFileName::FileExists(fileList[i][j]))
628  {
629  missingFiles = true;
630  break;
631  };
632  };
633  if (!missingFiles)
634  {
635  // now build the new panorama object
636  HuginBase::Panorama newPano;
637  bool allFilesReadable = true;
638  for (size_t j = 0; j < m_pano.getNrOfImages(); ++j)
639  {
641  image.setFilename(std::string(fileList[i][j].mb_str(HUGIN_CONV_FILENAME)));
642  if (!image.checkImageSizeKnown())
643  {
644  allFilesReadable = false;
645  break;
646  };
647  newPano.addImage(image);
648  };
649  if (allFilesReadable)
650  {
651  HuginBase::Panorama newGeneratedPano = m_pano.duplicate();
652  ApplyTemplate(newPano, newGeneratedPano);
653  // write to disc
654  wxFileName projectFile;
655  if (!GetNewProjectFilename(XRCCTRL(*this, "sequence_naming", wxChoice)->GetSelection(), newGeneratedPano, basePath, projectFile, i))
656  {
657  break;
658  };
659  const std::string scriptString(projectFile.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
660  newGeneratedPano.WritePTOFile(scriptString, hugin_utils::getPathPrefix(scriptString));
661  // all done, remember pto file name
662  ptoFileList.Add(projectFile.GetFullPath());
663  };
664  };
665  };
666  // all done, now add the pto files to queue
667  if (!ptoFileList.IsEmpty())
668  {
669  m_batchframe->AddArrayToList(ptoFileList, target);
670  };
671  EndModal(wxID_OK);
672  };
673 }
674 
676 {
678 }
679 
681 {
683 }
bool FileExists(const std::string &filename)
checks if file exists
Definition: utils.cpp:362
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
Definition: Panorama.cpp:1507
void OnGenerateAssistantPanorama(wxCommandEvent &e)
generate assistant sequence button
SrcPanoImage getSrcImage(unsigned imgNr) const
get a description of a source image
Definition: Panorama.cpp:1620
HuginBase::Panorama m_pano
#define HUGIN_CONV_FILENAME
Definition: platform.h:40
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
#define DEBUG_ASSERT(cond)
Definition: utils.h:80
include file for the hugin project
void ApplyTemplate(const HuginBase::Panorama &pano, HuginBase::Panorama &newPano)
copy the image files from pano to newPano -&gt; this corresponds to apply the template newPano to pano t...
virtual void updateVariables(const VariableMapVector &vars)
Set the variables.
Definition: Panorama.cpp:171
Panorama duplicate() const
duplicate the panorama
Definition: Panorama.cpp:1653
std::vector< VariableMap > VariableMapVector
Model for a panorama.
Definition: Panorama.h:152
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
Definition: utils.cpp:184
bool loadPTScript(std::istream &i, int &ptoVersion, const std::string &prefix="")
load a Hugin file
std::size_t getNrOfImages() const
number of images.
Definition: Panorama.h:205
void setCtrlPoints(const CPVector &points)
set all control points (Ippei: Is this supposed to be &#39;add&#39; method?)
Definition: Panorama.cpp:449
void OnSelectBasePath(wxCommandEvent &e)
show select directory dialog
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)
&quot;resize&quot; image, adjusts all distortion coefficients for usage with a source image of size size potent...
IMPEX double h[25][1024]
Definition: emor.cpp:169
void OnUpdateCounters(wxSpinEvent &e)
update all spin controls with current numbers
unsigned int addImage(const SrcPanoImage &img)
the the number for a specific image
Definition: Panorama.cpp:319
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
void OnSelectSubDir(wxCommandEvent &e)
select which sub-directory should be used
void UpdateCounters()
update all counters, enable/disable end value and calculate end values
~GenerateSequenceDialog()
destructor, saves size and position
Memento class for a Panorama object.
Definition: Panorama.h:49
void OnGeneratePreview(wxCommandEvent &e)
generate preview
void ReadPTOFile()
read pto template from file
std::vector< ControlPoint > CPVector
Definition: ControlPoint.h:99
platform/compiler specific stuff.
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
Definition: Panorama.cpp:2059
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition: Panorama.h:211
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
All variables of a source image.
Definition: SrcPanoImage.h:194
wxString getDefaultProjectName(const HuginBase::Panorama &pano, const wxString filenameTemplate)
gets the default project name, as defined in the preferences
void AddArrayToList(const wxArrayString &fileList, Project::Target target)
Definition: BatchFrame.cpp:509