~ubuntu-branches/ubuntu/trusty/hugin/trusty-proposed

« back to all changes in this revision

Viewing changes to src/hugin1/ptbatcher/FindPanoDialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2011-01-06 14:28:24 UTC
  • mfrom: (1.1.9 upstream) (0.1.21 experimental)
  • Revision ID: james.westby@ubuntu.com-20110106142824-zn9lxylg5z44dynn
* Drop Cyril Brulebois from Uploaders. Thank you very much for your work.
* Bump package version. (rc3 was re-released as 2010.4.0).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c-basic-offset: 4 -*-
 
2
 
 
3
/** @file FindPanoDialog.cpp
 
4
 *
 
5
 *      @brief implementation of FindPanoDialog class
 
6
 *
 
7
 *  @author Thomas Modes
 
8
 *
 
9
 */
 
10
 
 
11
/*  This is free software; you can redistribute it and/or
 
12
 *  modify it under the terms of the GNU General Public
 
13
 *  License as published by the Free Software Foundation; either
 
14
 *  version 2 of the License, or (at your option) any later version.
 
15
 *
 
16
 *  This software is distributed in the hope that it will be useful,
 
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
 *  Lesser General Public License for more details.
 
20
 *
 
21
 *  You should have received a copy of the GNU General Public
 
22
 *  License along with this software; if not, write to the Free Software
 
23
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
24
 *
 
25
 */
 
26
 
 
27
#include "FindPanoDialog.h"
 
28
#include "common/wxPlatform.h"
 
29
#include "panoinc.h"
 
30
#include "PTBatcherGUI.h"
 
31
 
 
32
BEGIN_EVENT_TABLE(FindPanoDialog,wxDialog)
 
33
EVT_BUTTON(XRCID("find_pano_close"), FindPanoDialog::OnButtonClose)
 
34
EVT_BUTTON(XRCID("find_pano_select_dir"), FindPanoDialog::OnButtonChoose)
 
35
EVT_BUTTON(XRCID("find_pano_start_stop"), FindPanoDialog::OnButtonStart)
 
36
EVT_BUTTON(XRCID("find_pano_add_queue"), FindPanoDialog::OnButtonSend)
 
37
EVT_CLOSE(FindPanoDialog::OnClose)
 
38
END_EVENT_TABLE()
 
39
 
 
40
FindPanoDialog::FindPanoDialog(BatchFrame *batchframe, wxString xrcPrefix)
 
41
{
 
42
    // load our children. some children might need special
 
43
    // initialization. this will be done later.
 
44
    wxXmlResource::Get()->LoadDialog(this,batchframe,wxT("find_pano_dialog"));
 
45
 
 
46
#ifdef __WXMSW__
 
47
    wxIcon myIcon(xrcPrefix+ wxT("data/ptbatcher.ico"),wxBITMAP_TYPE_ICO);
 
48
#else
 
49
    wxIcon myIcon(xrcPrefix + wxT("data/ptbatcher.png"),wxBITMAP_TYPE_PNG);
 
50
#endif
 
51
    SetIcon(myIcon);
 
52
    m_batchframe=batchframe;
 
53
    m_isRunning=false;
 
54
    m_stopped=false;
 
55
    
 
56
    m_button_start=XRCCTRL(*this,"find_pano_start_stop",wxButton);
 
57
    m_button_choose=XRCCTRL(*this,"find_pano_select_dir",wxButton);
 
58
    m_button_send=XRCCTRL(*this,"find_pano_add_queue",wxButton);
 
59
    m_button_close=XRCCTRL(*this,"find_pano_close",wxButton);
 
60
    m_textctrl_dir=XRCCTRL(*this,"find_pano_dir",wxTextCtrl);
 
61
    m_cb_subdir=XRCCTRL(*this,"find_pano_subdir",wxCheckBox);
 
62
    m_statustext=XRCCTRL(*this,"find_pano_label",wxStaticText);
 
63
    m_list_pano=XRCCTRL(*this,"find_pano_list",wxCheckListBox);
 
64
    m_cb_naming=XRCCTRL(*this,"find_pano_naming",wxChoice);
 
65
 
 
66
    //set parameters
 
67
    wxConfigBase * config = wxConfigBase::Get();
 
68
    // restore position and size
 
69
    int dx,dy;
 
70
    wxDisplaySize(&dx,&dy);
 
71
    bool maximized = config->Read(wxT("/FindPanoDialog/maximized"), 0l) != 0;
 
72
    if (maximized)
 
73
    {
 
74
        this->Maximize();
 
75
        }
 
76
    else
 
77
    {
 
78
        //size
 
79
        int w = config->Read(wxT("/FindPanoDialog/width"),-1l);
 
80
        int h = config->Read(wxT("/FindPanoDialog/height"),-1l);
 
81
        if (w > 0 && w <= dx)
 
82
        {
 
83
            this->SetClientSize(w,h);
 
84
        }
 
85
        else
 
86
        {
 
87
            this->Fit();
 
88
        }
 
89
        //position
 
90
        int x = config->Read(wxT("/FindPanoDialog/positionX"),-1l);
 
91
        int y = config->Read(wxT("/FindPanoDialog/positionY"),-1l);
 
92
        if ( y >= 0 && x >= 0 && x < dx && y < dy)
 
93
        {
 
94
            this->Move(x, y);
 
95
        }
 
96
        else
 
97
        {
 
98
            this->Move(0, 44);
 
99
        }
 
100
    }
 
101
    wxString path=config->Read(wxT("/FindPanoDialog/actualPath"),wxEmptyString);
 
102
    if(!path.IsEmpty())
 
103
        m_textctrl_dir->SetValue(path);
 
104
    bool val;
 
105
    config->Read(wxT("/FindPanoDialog/includeSubDirs"),&val,false);
 
106
    m_cb_subdir->SetValue(val);
 
107
    long i=config->Read(wxT("/FindPanoDialog/Naming"),0l);
 
108
    m_cb_naming->SetSelection(i);
 
109
    m_button_send->Disable();
 
110
};
 
111
 
 
112
FindPanoDialog::~FindPanoDialog()
 
113
{
 
114
    wxConfigBase* config=wxConfigBase::Get();
 
115
    if(!this->IsMaximized())
 
116
    {
 
117
        wxSize sz = this->GetClientSize();
 
118
        config->Write(wxT("/FindPanoDialog/width"), sz.GetWidth());
 
119
        config->Write(wxT("/FindPanoDialog/height"), sz.GetHeight());
 
120
        wxPoint ps = this->GetPosition();
 
121
        config->Write(wxT("/FindPanoDialog/positionX"), ps.x);
 
122
        config->Write(wxT("/FindPanoDialog/positionY"), ps.y);
 
123
        config->Write(wxT("/FindPanoDialog/maximized"), 0);
 
124
    }
 
125
    else
 
126
    {
 
127
        config->Write(wxT("/FindPanoDialog/maximized"), 1l);
 
128
    };
 
129
    config->Write(wxT("/FindPanoDialog/actualPath"),m_textctrl_dir->GetValue());
 
130
    config->Write(wxT("/FindPanoDialog/includeSubDirs"),m_cb_subdir->GetValue());
 
131
    config->Write(wxT("/FindPanoDialog/Naming"),m_cb_naming->GetSelection());
 
132
    CleanUpPanolist();
 
133
};
 
134
 
 
135
void FindPanoDialog::CleanUpPanolist()
 
136
{
 
137
    if(m_panos.size()>0)
 
138
    {
 
139
        for(unsigned int i=0;i<m_panos.size();i++)
 
140
        {
 
141
            m_panos[i].Cleanup();
 
142
        };
 
143
        m_panos.Clear();
 
144
    };
 
145
};
 
146
 
 
147
//prevent closing window when running detection
 
148
void FindPanoDialog::OnClose(wxCloseEvent &e)
 
149
{
 
150
    if(e.CanVeto() && m_isRunning)
 
151
    {
 
152
        wxBell();
 
153
        e.Veto();
 
154
    }
 
155
    else
 
156
    {
 
157
        e.Skip();
 
158
    };
 
159
};
 
160
 
 
161
void FindPanoDialog::OnButtonClose(wxCommandEvent &e)
 
162
{
 
163
    if(m_panos.size()>0)
 
164
    {
 
165
        if(wxMessageBox(_("The list contains possibly unprocessed panoramas.\nIf you close the dialog, you will lose them.\nContinue anyway?"),
 
166
            _("Question"),wxYES_NO|wxICON_QUESTION,this)==wxNO)
 
167
        {
 
168
            return;
 
169
        };
 
170
    };
 
171
    this->Close();  
 
172
};
 
173
 
 
174
void FindPanoDialog::OnButtonChoose(wxCommandEvent &e)
 
175
{
 
176
        wxDirDialog dlg(this, _("Specify a directory to search for projects in"),
 
177
                     m_textctrl_dir->GetValue(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
 
178
        if (dlg.ShowModal()==wxID_OK)
 
179
    {
 
180
        m_textctrl_dir->SetValue(dlg.GetPath());
 
181
    };
 
182
};
 
183
 
 
184
void FindPanoDialog::OnButtonStart(wxCommandEvent &e)
 
185
{
 
186
    if(m_isRunning)
 
187
    {
 
188
        //stop detection
 
189
        m_stopped=true;
 
190
        m_button_start->SetLabel(_("Accepted"));
 
191
    }
 
192
    else
 
193
    {
 
194
        //start detection
 
195
        m_start_dir=m_textctrl_dir->GetValue();
 
196
        if(wxDir::Exists(m_start_dir))
 
197
        {
 
198
            if(m_panos.Count()>0)
 
199
            {
 
200
                if(wxMessageBox(_("The list contains still not yet processed panoramas.\nIf you continue, they will be disregarded.\nDo you still want to continue?"),
 
201
                    _("Question"),wxYES_NO|wxICON_QUESTION,this)==wxNO)
 
202
                {
 
203
                    return;
 
204
                };
 
205
            };
 
206
            m_isRunning=true;
 
207
            m_stopped=false;
 
208
            //deactivate TIFF warning message boxes
 
209
            m_oldtiffwarning=TIFFSetWarningHandler(NULL);
 
210
            m_button_start->SetLabel(_("Stop"));
 
211
            CleanUpPanolist();
 
212
            m_list_pano->Clear();
 
213
            EnableButtons(false);
 
214
            SearchInDir(m_start_dir,m_cb_subdir->GetValue());
 
215
        }
 
216
        else
 
217
        {
 
218
            wxMessageBox(wxString::Format(_("Directory %s does not exist.\nPlease give an existing directory."),m_start_dir.c_str()),
 
219
                _("Warning"),wxOK | wxICON_EXCLAMATION,this);
 
220
        };
 
221
    };
 
222
}
 
223
 
 
224
void FindPanoDialog::OnButtonSend(wxCommandEvent &e)
 
225
{
 
226
    if(m_panos.size()==0)
 
227
        return;
 
228
    unsigned int nr=0;
 
229
    for(unsigned int i=0;i<m_list_pano->GetCount();i++)
 
230
    {
 
231
        if(m_list_pano->IsChecked(i))
 
232
        {
 
233
            nr++;
 
234
        };
 
235
    };
 
236
    if(nr==0)
 
237
    {
 
238
        wxMessageBox(_("You have selected no possible panorama.\nPlease select at least one panorama and try again."),_("Warning"),wxOK|wxICON_EXCLAMATION,this);
 
239
        return;
 
240
    }
 
241
    bool failed=false;
 
242
    for(unsigned int i=0;i<m_list_pano->GetCount();i++)
 
243
    {
 
244
        if(m_list_pano->IsChecked(i))
 
245
        {
 
246
            wxString filename=m_panos[i].GeneratePanorama((PossiblePano::NamingConvention)(m_cb_naming->GetSelection()));
 
247
            if(!filename.IsEmpty())
 
248
            {
 
249
                m_batchframe->AddToList(filename,Project::DETECTING);
 
250
            }
 
251
            else
 
252
            {
 
253
                failed=true;
 
254
            };
 
255
        };
 
256
    };
 
257
    if(failed)
 
258
    {
 
259
        wxMessageBox(_("Not all project files could be written successful.\nMaybe you have no write permission for these directories or your hard disc is full."),_("Error"),wxOK,this);
 
260
    };
 
261
    this->Close();
 
262
};
 
263
 
 
264
void FindPanoDialog::EnableButtons(const bool state)
 
265
{
 
266
    m_textctrl_dir->Enable(state);
 
267
    m_button_choose->Enable(state);
 
268
    m_cb_subdir->Enable(state);
 
269
    m_cb_naming->Enable(state);
 
270
    m_button_close->Enable(state);
 
271
    m_button_send->Enable(state);
 
272
};
 
273
 
 
274
void FindPanoDialog::SearchInDir(wxString dirstring, bool includeSubdir)
 
275
{
 
276
    wxDir dir(dirstring);
 
277
    PossiblePanoArray newPanos;
 
278
    wxTimeSpan max_diff(0,0,30,0); //max. 30 s difference between images
 
279
    wxString filename;
 
280
    bool cont=dir.GetFirst(&filename,wxEmptyString,wxDIR_FILES|wxDIR_HIDDEN);
 
281
    while(cont && !m_stopped)
 
282
    {
 
283
        m_statustext->SetLabel(wxString::Format(_("Reading file %s"),filename.c_str()));
 
284
        wxFileName file(dir.GetName(),filename);
 
285
        file.MakeAbsolute();
 
286
        wxString ext=file.GetExt();
 
287
        if(ext.CmpNoCase(wxT("jpg"))==0 || ext.CmpNoCase(wxT("jpeg"))==0 ||
 
288
        ext.CmpNoCase(wxT("tif"))==0 || ext.CmpNoCase(wxT("tiff"))==0)
 
289
        {
 
290
            std::string filenamestr(file.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
 
291
            SrcPanoImage *img=new SrcPanoImage(filenamestr);
 
292
            if(img->hasEXIFread())
 
293
            {
 
294
                bool found=false;
 
295
                for(unsigned int i=0;i<newPanos.size() && !m_stopped && !found;i++)
 
296
                {
 
297
                    //compare with all other image groups
 
298
                    if(newPanos[i].BelongsTo(img,max_diff))
 
299
                    {
 
300
                        newPanos[i].AddSrcPanoImage(img);
 
301
                        found=true;
 
302
                    };
 
303
                    if(i%10==0)
 
304
                    {
 
305
                        wxGetApp().Yield(true);
 
306
                    };
 
307
                };
 
308
                if(!found)
 
309
                {
 
310
                    PossiblePano *newPano=new PossiblePano();
 
311
                    newPano->AddSrcPanoImage(img);
 
312
                    newPanos.Add(newPano);
 
313
                };
 
314
            }
 
315
            else
 
316
            {
 
317
                //could not read exif infos, disregard this image
 
318
                delete img;
 
319
            };
 
320
 
 
321
        };
 
322
        //allow processing events
 
323
        wxGetApp().Yield(true);
 
324
        cont=dir.GetNext(&filename);
 
325
    }
 
326
    if(!m_stopped && newPanos.size()>0)
 
327
    {
 
328
        for(size_t i=0;i<newPanos.size();i++)
 
329
        {
 
330
            if(newPanos[i].GetImageCount()>1)
 
331
            {
 
332
                m_panos.Add(newPanos[i]);
 
333
                int newItem=m_list_pano->Append(m_panos[m_panos.size()-1].GetItemString(m_start_dir));
 
334
                m_list_pano->Check(newItem,true);
 
335
            }
 
336
            else
 
337
            {
 
338
                newPanos[i].Cleanup();
 
339
            };
 
340
        };
 
341
    };
 
342
                
 
343
    if(includeSubdir && !m_stopped)
 
344
    {
 
345
        //now we go into all directories
 
346
        cont=dir.GetFirst(&filename,wxEmptyString,wxDIR_DIRS);
 
347
        while(cont && !m_stopped)
 
348
        {
 
349
            SearchInDir(dir.GetName()+wxFileName::GetPathSeparator()+filename,includeSubdir);
 
350
            cont=dir.GetNext(&filename);
 
351
        }
 
352
    };
 
353
    if(m_start_dir.Cmp(dirstring)==0)
 
354
    {
 
355
        m_stopped=false;
 
356
        m_isRunning=false;
 
357
        m_button_start->SetLabel(_("Start"));
 
358
        EnableButtons(true);
 
359
        //enable send button if at least one panorama found
 
360
        m_button_send->Enable(m_panos.Count()>0);
 
361
        if(m_panos.Count()>0)
 
362
        {
 
363
            m_statustext->SetLabel(wxString::Format(_("Found %d possible panoramas."),m_panos.Count()));
 
364
        }
 
365
        else
 
366
        {
 
367
            m_statustext->SetLabel(_("No possible panoramas found."));
 
368
        };
 
369
        TIFFSetWarningHandler(m_oldtiffwarning);
 
370
    };
 
371
};
 
372
 
 
373
void PossiblePano::Cleanup()
 
374
{
 
375
    if(m_images.size()>0)
 
376
    {
 
377
        for(ImageSet::reverse_iterator it=m_images.rbegin();it!=m_images.rend();it++)
 
378
        {
 
379
            delete (*it);
 
380
        }
 
381
    };
 
382
};
 
383
 
 
384
bool PossiblePano::BelongsTo(SrcPanoImage *img, const wxTimeSpan max_time_diff)
 
385
{
 
386
    if(m_make.compare(img->getExifMake())!=0)
 
387
        return false;
 
388
    if(m_camera.compare(img->getExifModel())!=0)
 
389
        return false;
 
390
    if(fabs(m_focallength-img->getExifFocalLength())>0.01)
 
391
        return false;
 
392
    if(m_size!=img->getSize())
 
393
        return false;
 
394
    const wxDateTime dt=GetDateTime(img);
 
395
    if(!dt.IsBetween(m_dt_start,m_dt_end))
 
396
    {
 
397
        if(!dt.IsEqualUpTo(m_dt_start,max_time_diff))
 
398
        {
 
399
            if(!dt.IsEqualUpTo(m_dt_end,max_time_diff))
 
400
            {
 
401
                return false;
 
402
            };
 
403
        };
 
404
    };
 
405
    return true;
 
406
};
 
407
 
 
408
wxDateTime PossiblePano::GetDateTime(const SrcPanoImage* img)
 
409
{
 
410
    struct tm exifdatetime;
 
411
    if(img->getExifDateTime(&exifdatetime)==0)
 
412
    {
 
413
        return wxDateTime(exifdatetime);
 
414
    }
 
415
    else
 
416
    {
 
417
        wxFileName file(wxString(img->getFilename().c_str(),HUGIN_CONV_FILENAME));
 
418
        return file.GetModificationTime();
 
419
    };
 
420
};
 
421
 
 
422
void PossiblePano::AddSrcPanoImage(HuginBase::SrcPanoImage *img)
 
423
{
 
424
    if(m_images.size()==0)
 
425
    {
 
426
        //fill all values from first image
 
427
        m_make=img->getExifMake();
 
428
        m_camera=img->getExifModel();
 
429
        m_focallength=img->getExifFocalLength();
 
430
        m_size=img->getSize();
 
431
        m_dt_start=GetDateTime(img);
 
432
        m_dt_end=m_dt_start;
 
433
    }
 
434
    else
 
435
    {
 
436
        wxDateTime dt=GetDateTime(img);
 
437
        if(dt.IsEarlierThan(m_dt_start))
 
438
        {
 
439
            m_dt_start=dt;
 
440
        }
 
441
        if(dt.IsLaterThan(m_dt_end))
 
442
        {
 
443
            m_dt_end=dt;
 
444
        };
 
445
    };
 
446
    m_images.insert(img);
 
447
};
 
448
 
 
449
const wxString PossiblePano::GetFilestring(const wxString BasePath, const bool stripExtension) const
 
450
{
 
451
    ImageSet::const_iterator it=m_images.begin();
 
452
    wxFileName f1(wxString((*it)->getFilename().c_str(),HUGIN_CONV_FILENAME));
 
453
    f1.MakeRelativeTo(BasePath);
 
454
    ImageSet::const_reverse_iterator rit=m_images.rbegin();
 
455
    wxFileName f2(wxString((*rit)->getFilename().c_str(),HUGIN_CONV_FILENAME));
 
456
    if(stripExtension)
 
457
    {
 
458
        return f1.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR)+f1.GetName()+wxT("-")+f2.GetName();
 
459
    }
 
460
    else
 
461
    {
 
462
        return f1.GetFullPath()+wxT(" - ")+f2.GetFullName();
 
463
    };
 
464
};
 
465
 
 
466
const wxString PossiblePano::GetItemString(const wxString BasePath) const
 
467
{
 
468
    return wxString::Format(_("%d images: %s"),m_images.size(),GetFilestring(BasePath).c_str());
 
469
};
 
470
 
 
471
bool PossiblePano::GetNewProjectFilename(NamingConvention nc,const wxString basePath, wxFileName &projectFile)
 
472
{
 
473
    wxString mask;
 
474
    unsigned int i=1;
 
475
    projectFile.SetPath(basePath);
 
476
    projectFile.SetName(wxT("pano"));
 
477
    projectFile.SetExt(wxT("pto"));
 
478
    if(!projectFile.IsDirWritable())
 
479
    {
 
480
        return false;
 
481
    };
 
482
    switch(nc)
 
483
    {
 
484
        case NAMING_PANO:
 
485
            mask=wxT("panorama%d");
 
486
            break;
 
487
        case NAMING_FIRST_LAST:
 
488
            mask=GetFilestring(basePath,true);
 
489
            projectFile.SetName(mask);
 
490
            if(!projectFile.FileExists())
 
491
            {
 
492
                return true;
 
493
            };
 
494
            mask=mask+wxT("_%d");
 
495
            break;
 
496
        case NAMING_FOLDER:
 
497
            {
 
498
                wxArrayString folders=projectFile.GetDirs();
 
499
                if(folders.GetCount()==0)
 
500
                {
 
501
                    return false;
 
502
                }
 
503
                mask=folders.Last();
 
504
                projectFile.SetName(mask);
 
505
                if(!projectFile.FileExists())
 
506
                {
 
507
                    return true;
 
508
                }
 
509
                mask=mask+wxT("_%d");
 
510
            }
 
511
            break;
 
512
        default:
 
513
            mask=wxT("panorama%d");
 
514
    };
 
515
 
 
516
    projectFile.SetName(wxString::Format(mask,i));
 
517
    while(projectFile.FileExists())
 
518
    {
 
519
        i++;
 
520
        projectFile.SetName(wxString::Format(mask,i));
 
521
        //security fall through
 
522
        if(i>1000)
 
523
        {
 
524
            return false;
 
525
        };
 
526
    }
 
527
    return true;
 
528
};
 
529
 
 
530
wxString PossiblePano::GeneratePanorama(NamingConvention nc)
 
531
{
 
532
    if(m_images.size()==0)
 
533
    {
 
534
        return wxEmptyString;
 
535
    };
 
536
    ImageSet::const_iterator it=m_images.begin();
 
537
    wxFileName firstFile(wxString((*it)->getFilename().c_str(),HUGIN_CONV_FILENAME));
 
538
    firstFile.MakeAbsolute();
 
539
    wxFileName projectFile;
 
540
    if(!GetNewProjectFilename(nc,firstFile.GetPath(),projectFile))
 
541
    {
 
542
        return wxEmptyString;
 
543
    };
 
544
    //generate panorama
 
545
    HuginBase::Panorama pano;
 
546
    for(ImageSet::iterator it=m_images.begin();it!=m_images.end();it++)
 
547
    {
 
548
        pano.addImage(*(*it));
 
549
    };
 
550
    //assign all images the same lens number
 
551
    HuginBase::StandardImageVariableGroups variable_groups(pano);
 
552
    HuginBase::ImageVariableGroup & lenses = variable_groups.getLenses();
 
553
    if(pano.getNrOfImages()>1)
 
554
    {
 
555
        for(unsigned int i=1;i<pano.getNrOfImages();i++)
 
556
        {
 
557
            SrcPanoImage img=pano.getSrcImage(i);
 
558
            double ev=img.getExposureValue();
 
559
            lenses.switchParts(i,lenses.getPartNumber(0));
 
560
            lenses.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_ExposureValue, i);
 
561
            img.setExposureValue(ev);
 
562
            lenses.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_WhiteBalanceRed, i);
 
563
            lenses.unlinkVariableImage(HuginBase::ImageVariableGroup::IVE_WhiteBalanceBlue, i);
 
564
            img.setWhiteBalanceRed(1);
 
565
            img.setWhiteBalanceBlue(1);
 
566
            pano.setSrcImage(i, img);
 
567
        };
 
568
    };
 
569
    //set default exposure value
 
570
    PanoramaOptions opts = pano.getOptions();
 
571
    opts.outputExposureValue = pano.getImage(0).getExposureValue();
 
572
    pano.setOptions(opts);
 
573
 
 
574
    std::ofstream script(projectFile.GetFullPath().mb_str(HUGIN_CONV_FILENAME));
 
575
    script.exceptions ( std::ofstream::eofbit | std::ofstream::failbit | std::ofstream::badbit );
 
576
    if(!script.good())
 
577
    {
 
578
        return wxEmptyString;
 
579
    };
 
580
    PT::UIntSet all;
 
581
    fill_set(all, 0, pano.getNrOfImages()-1);
 
582
    try
 
583
    {
 
584
        std::string Pathprefix(projectFile.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR).mb_str(HUGIN_CONV_FILENAME));
 
585
        pano.printPanoramaScript(script, pano.getOptimizeVector(), pano.getOptions(), all, false, Pathprefix);
 
586
    }
 
587
    catch (std::exception & e) 
 
588
    {
 
589
        return wxEmptyString;
 
590
    };
 
591
    script.close();
 
592
    return projectFile.GetFullPath();
 
593
};
 
594
 
 
595
#include <wx/arrimpl.cpp>
 
596
WX_DEFINE_OBJARRAY(PossiblePanoArray);