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 
32 BEGIN_EVENT_TABLE(FailedProjectsDialog,wxDialog)
33  EVT_LISTBOX(XRCID("failed_list"),FailedProjectsDialog::OnSelectProject)
35 
36 FailedProjectsDialog::FailedProjectsDialog(wxWindow* parent,Batch* batch,wxString xrcPrefix)
37 {
38  // load our children. some children might need special
39  // initialization. this will be done later.
40  wxXmlResource::Get()->LoadDialog(this,parent,wxT("failed_project_dialog"));
41 
42 #ifdef __WXMSW__
43  wxIconBundle myIcons(xrcPrefix+ wxT("data/ptbatcher.ico"),wxBITMAP_TYPE_ICO);
44  SetIcons(myIcons);
45 #else
46  wxIcon myIcon(xrcPrefix + wxT("data/ptbatcher.png"),wxBITMAP_TYPE_PNG);
47  SetIcon(myIcon);
48 #endif
49  m_batch=batch;
50 
51  m_list=XRCCTRL(*this,"failed_list",wxListBox);
52  m_log=XRCCTRL(*this,"failed_log",wxTextCtrl);
53 
54  //fill list
55  for(unsigned int i=0; i<batch->GetFailedProjectsCount(); i++)
56  {
57  m_list->AppendString(batch->GetFailedProjectName(i));
58  };
59  if(m_list->GetCount()>0)
60  {
61  m_list->SetSelection(0);
62  wxCommandEvent dummy;
63  OnSelectProject(dummy);
64  };
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("/FailedProjectsDialog/maximized"), 0l) != 0;
72  if (maximized)
73  {
74  this->Maximize();
75  }
76  else
77  {
78  //size
79  int w = config->Read(wxT("/FailedProjectsDialog/width"),-1l);
80  int h = config->Read(wxT("/FailedProjectsDialog/height"),-1l);
81  if (w > 0 && w <= dx)
82  {
83  this->SetClientSize(w,h);
84  }
85  else
86  {
87  this->Fit();
88  }
89  //splitter position
90  int splitter_pos=config->Read(wxT("/FailedProjectsDialog/splitterPos"),-1l);
91  wxSplitterWindow* splitWindow=XRCCTRL(*this,"failed_splitter",wxSplitterWindow);
92  if(splitter_pos>0 && splitter_pos<splitWindow->GetSize().GetWidth())
93  {
94  splitWindow->SetSashPosition(splitter_pos);
95  };
96  //position
97  int x = config->Read(wxT("/FailedProjectsDialog/positionX"),-1l);
98  int y = config->Read(wxT("/FailedProjectsDialog/positionY"),-1l);
99  if ( y >= 0 && x >= 0 && x < dx && y < dy)
100  {
101  this->Move(x, y);
102  }
103  else
104  {
105  this->Move(0, 44);
106  }
107  }
108 };
109 
111 {
112  wxConfigBase* config=wxConfigBase::Get();
113  if(!this->IsMaximized())
114  {
115  wxSize sz = this->GetClientSize();
116  config->Write(wxT("/FailedProjectsDialog/width"), sz.GetWidth());
117  config->Write(wxT("/FailedProjectsDialog/height"), sz.GetHeight());
118  wxPoint ps = this->GetPosition();
119  config->Write(wxT("/FailedProjectsDialog/positionX"), ps.x);
120  config->Write(wxT("/FailedProjectsDialog/positionY"), ps.y);
121  config->Write(wxT("/FailedProjectsDialog/maximized"), 0);
122  }
123  else
124  {
125  config->Write(wxT("/FailedProjectsDialog/maximized"), 1l);
126  };
127  config->Write(wxT("/FailedProjectsDialog/splitterPos"), XRCCTRL(*this,"failed_splitter",wxSplitterWindow)->GetSashPosition());
128 };
129 
131 {
132  int sel=m_list->GetSelection();
133  m_log->Clear();
134  if(sel!=wxNOT_FOUND)
135  {
136  wxString logfile=m_batch->GetFailedProjectLog(sel);
137  if(!logfile.IsEmpty())
138  {
139  if(wxFileName::FileExists(logfile))
140  {
141  m_log->LoadFile(logfile);
142  }
143  };
144  };
145 };
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
Definition of failed projects dialog.
END_EVENT_TABLE()
include file for the hugin project
~FailedProjectsDialog()
destructor, saves size and position
Dialog for finding panorama in given directory.
IMPEX double h[25][1024]
Definition: emor.cpp:169
Definition: Batch.h:48
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:963