Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FailedProjectsDialog.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
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, see
23  * <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #include "FailedProjectsDialog.h"
28 #include "base_wx/wxPlatform.h"
29 #include "panoinc.h"
30 #include "Batch.h"
31 #include "base_wx/wxutils.h"
32 
33 FailedProjectsDialog::FailedProjectsDialog(wxWindow* parent,Batch* batch,wxString xrcPrefix)
34 {
35  // load our children. some children might need special
36  // initialization. this will be done later.
37  wxXmlResource::Get()->LoadDialog(this,parent,"failed_project_dialog");
38 
39  m_batch=batch;
40 
41  m_list=XRCCTRL(*this,"failed_list",wxListBox);
42  m_list->Bind(wxEVT_LISTBOX, &FailedProjectsDialog::OnSelectProject, this);
43  m_log=XRCCTRL(*this,"failed_log",wxTextCtrl);
44 
45  //fill list
46  for(unsigned int i=0; i<batch->GetFailedProjectsCount(); i++)
47  {
48  m_list->AppendString(batch->GetFailedProjectName(i));
49  };
50  if(m_list->GetCount()>0)
51  {
52  m_list->SetSelection(0);
53  wxCommandEvent dummy;
54  OnSelectProject(dummy);
55  };
56 
57  //set parameters
58  wxConfigBase* config = wxConfigBase::Get();
59  // restore position and size
60  hugin_utils::RestoreFramePosition(this, "FailedProjectsDialog");
61  //splitter position
62  int splitter_pos=config->Read("/FailedProjectsDialog/splitterPos",-1l);
63  wxSplitterWindow* splitWindow=XRCCTRL(*this,"failed_splitter",wxSplitterWindow);
64  if(splitter_pos>0 && splitter_pos<splitWindow->GetSize().GetWidth())
65  {
66  splitWindow->SetSashPosition(splitter_pos);
67  };
68 };
69 
71 {
72  wxConfigBase* config=wxConfigBase::Get();
73  hugin_utils::StoreFramePosition(this, "FailedProjectsDialog");
74  config->Write("/FailedProjectsDialog/splitterPos", XRCCTRL(*this,"failed_splitter",wxSplitterWindow)->GetSashPosition());
75 };
76 
78 {
79  int sel=m_list->GetSelection();
80  m_log->Clear();
81  if(sel!=wxNOT_FOUND)
82  {
83  wxString logfile=m_batch->GetFailedProjectLog(sel);
84  if(!logfile.IsEmpty())
85  {
86  if(wxFileName::FileExists(logfile))
87  {
88  m_log->LoadFile(logfile);
89  }
90  };
91  };
92 };
bool FileExists(const std::string &filename)
checks if file exists
Definition: utils.cpp:362
void OnSelectProject(wxCommandEvent &e)
event handler, if new project was selected
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition: wxutils.cpp:67
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
Definition: wxutils.cpp:106
FailedProjectsDialog(wxWindow *parent, Batch *batch, wxString xrcPrefix)
Constructor, read from xrc ressource; restore last uses settings, size and position.
Definition of failed projects dialog.
size_t GetFailedProjectsCount()
returns number of failed projects
Definition: Batch.h:145
include file for the hugin project
wxString GetFailedProjectName(unsigned int i)
returns project file name of failed project with index i
Definition: Batch.cpp:931
~FailedProjectsDialog()
destructor, saves size and position
Definition: Batch.h:46
platform/compiler specific stuff.
Batch processor for Hugin.
wxString GetFailedProjectLog(unsigned int i)
returns log file name of failed project with index i
Definition: Batch.cpp:943