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