Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProjectArray.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
27 #ifdef _WIN32
28 #include "wx/msw/wrapwin.h"
29 #endif
30 #include "ProjectArray.h"
31 #include <wx/arrimpl.cpp>
32 #include "base_wx/huginConfig.h"
33 #include <fstream>
34 
36 
37 Project::Project(wxString pth,wxString pfx, wxString newUserDefinedSequence, Project::Target newTarget)
38 {
41  path = pth;
42  prefix = pfx;
43  wxFileName file(path);
44  if(file.FileExists())
45  {
46  file.GetTimes(NULL,&modDate,NULL);
47  }
48  userDefindSequence = newUserDefinedSequence;
49  isAligned = true;
50  options = ReadOptions(pth);
51  skip = false;
52  status = WAITING;
53  target = newTarget;
54 }
55 
56 Project::Project(wxString command)
57 {
58  path = command;
61  skip = false;
62  isAligned = true;
63  status = WAITING;
64  target = STITCHING;
65 }
66 
68 {
69  switch(status)
70  {
71  case WAITING:
72  return _("Waiting");
73  case RUNNING:
74  return _("In progress");
75  case FINISHED:
76  return _("Complete");
77  case FAILED:
78  return _("Failed");
79  case MISSING:
80  return _("File missing");
81  case PAUSED:
82  return _("Paused");
83  default:
84  return _T("");
85  }
86 }
87 
89 {
91  std::ifstream prjfile((const char*)projectFile.mb_str(HUGIN_CONV_FILENAME));
92  if (prjfile.good())
93  {
94  wxString pathToPTO;
95  wxFileName::SplitPath(projectFile, &pathToPTO, NULL, NULL);
96  pathToPTO.Append(wxT("/"));
97 
99  int ptoVersion = 0;
100  if (newPano.loadPTScript(prjfile, ptoVersion, (const char*)pathToPTO.mb_str(HUGIN_CONV_FILENAME)))
101  {
102  pano.setMemento(newPano);
103  if (ptoVersion < 2)
104  {
106  // no options stored in file, use default arguments in config
107  opts.enblendOptions = wxConfigBase::Get()->Read(wxT("/Enblend/Args"), wxT("")).mb_str(wxConvLocal);
108  opts.enfuseOptions = wxConfigBase::Get()->Read(wxT("/Enfuse/Args"), wxT("")).mb_str(wxConvLocal);
109  pano.setOptions(opts);
110  }
111  // set default prefix, if not given
112  if (prefix.IsEmpty())
113  {
114  wxFileName prefixFilename(getDefaultOutputName(projectFile, pano));
115  prefixFilename.Normalize(wxPATH_NORM_ABSOLUTE | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_SHORTCUT);
116  prefix = prefixFilename.GetFullPath();
117  };
118  // if project contains at least 2 images and no control points add to assistant queue
119  // a single image project is assumed as target for reprojection/remapping
120  if (pano.getNrOfImages() > 1 && pano.getNrOfCtrlPoints() == 0)
121  {
122  isAligned = false;
123  };
124  };
125  };
126  // get options
127  return pano.getOptions();
128 }
129 
131 {
132  wxFileName file(path);
133  if(file.FileExists())
134  {
135  file.GetTimes(NULL,&modDate,NULL);
136  }
138 }
139 
140 WX_DEFINE_OBJARRAY(ProjectArray); //define the array in ProjectArray.h
HuginBase::PanoramaOptions ReadOptions(wxString projectFile)
wxString userDefindSequence
Definition: ProjectArray.h:73
void setMemento(const PanoramaMemento &memento)
set the internal state
Definition: Panorama.cpp:1507
WX_DEFINE_OBJARRAY(wxArrayTreeListColumnInfo)
#define HUGIN_CONV_FILENAME
Definition: platform.h:40
wxDateTime modDate
Definition: ProjectArray.h:75
Status status
Definition: ProjectArray.h:65
Project(wxString pth, wxString pfx, wxString newUserDefinedSequence=wxEmptyString, Project::Target newTarget=STITCHING)
std::size_t getNrOfCtrlPoints() const
number of control points
Definition: Panorama.h:306
HuginBase::PanoramaOptions options
Definition: ProjectArray.h:77
Model for a panorama.
Definition: Panorama.h:152
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
Target target
Definition: ProjectArray.h:67
bool isAligned
Definition: ProjectArray.h:81
wxString path
Definition: ProjectArray.h:69
static long idGenerator
Definition: ProjectArray.h:61
const PanoramaOptions & getOptions() const
returns the options for this panorama
Definition: Panorama.h:481
Memento class for a Panorama object.
Definition: Panorama.h:49
wxString GetStatusText()
functions for interaction with the hugin configuration file
void setOptions(const PanoramaOptions &opt)
set new output settings This is not used directly for optimizing/stiching, but it can be feed into ru...
Definition: Panorama.cpp:1531
Batch processor for Hugin.
wxString getDefaultOutputName(const wxString projectname, const HuginBase::Panorama &pano, const wxString filenameTemplate)
gets the default output prefix, based on filename and images in project the setting is read from the ...
Panorama image options.
wxString prefix
Definition: ProjectArray.h:71
void ResetOptions()
bool skip
Definition: ProjectArray.h:79