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  m_batch=batch;
39 
40  m_list=XRCCTRL(*this,"failed_list",wxListBox);
41  m_list->Bind(wxEVT_LISTBOX, &FailedProjectsDialog::OnSelectProject, this);
42  m_log=XRCCTRL(*this,"failed_log",wxTextCtrl);
43 
44  //fill list
45  for(unsigned int i=0; i<batch->GetFailedProjectsCount(); i++)
46  {
47  m_list->AppendString(batch->GetFailedProjectName(i));
48  };
49  if(m_list->GetCount()>0)
50  {
51  m_list->SetSelection(0);
52  wxCommandEvent dummy;
53  OnSelectProject(dummy);
54  };
55 
56  //set parameters
57  wxConfigBase* config = wxConfigBase::Get();
58  // restore position and size
59  int dx,dy;
60  wxDisplaySize(&dx,&dy);
61  bool maximized = config->Read(wxT("/FailedProjectsDialog/maximized"), 0l) != 0;
62  if (maximized)
63  {
64  this->Maximize();
65  }
66  else
67  {
68  //size
69  int w = config->Read(wxT("/FailedProjectsDialog/width"),-1l);
70  int h = config->Read(wxT("/FailedProjectsDialog/height"),-1l);
71  if (w > 0 && w <= dx)
72  {
73  this->SetClientSize(w,h);
74  }
75  else
76  {
77  this->Fit();
78  }
79  //splitter position
80  int splitter_pos=config->Read(wxT("/FailedProjectsDialog/splitterPos"),-1l);
81  wxSplitterWindow* splitWindow=XRCCTRL(*this,"failed_splitter",wxSplitterWindow);
82  if(splitter_pos>0 && splitter_pos<splitWindow->GetSize().GetWidth())
83  {
84  splitWindow->SetSashPosition(splitter_pos);
85  };
86  //position
87  int x = config->Read(wxT("/FailedProjectsDialog/positionX"),-1l);
88  int y = config->Read(wxT("/FailedProjectsDialog/positionY"),-1l);
89  if ( y >= 0 && x >= 0 && x < dx && y < dy)
90  {
91  this->Move(x, y);
92  }
93  else
94  {
95  this->Move(0, 44);
96  }
97  }
98 };
99 
101 {
102  wxConfigBase* config=wxConfigBase::Get();
103  if(!this->IsMaximized())
104  {
105  wxSize sz = this->GetClientSize();
106  config->Write(wxT("/FailedProjectsDialog/width"), sz.GetWidth());
107  config->Write(wxT("/FailedProjectsDialog/height"), sz.GetHeight());
108  wxPoint ps = this->GetPosition();
109  config->Write(wxT("/FailedProjectsDialog/positionX"), ps.x);
110  config->Write(wxT("/FailedProjectsDialog/positionY"), ps.y);
111  config->Write(wxT("/FailedProjectsDialog/maximized"), 0);
112  }
113  else
114  {
115  config->Write(wxT("/FailedProjectsDialog/maximized"), 1l);
116  };
117  config->Write(wxT("/FailedProjectsDialog/splitterPos"), XRCCTRL(*this,"failed_splitter",wxSplitterWindow)->GetSashPosition());
118 };
119 
121 {
122  int sel=m_list->GetSelection();
123  m_log->Clear();
124  if(sel!=wxNOT_FOUND)
125  {
126  wxString logfile=m_batch->GetFailedProjectLog(sel);
127  if(!logfile.IsEmpty())
128  {
129  if(wxFileName::FileExists(logfile))
130  {
131  m_log->LoadFile(logfile);
132  }
133  };
134  };
135 };
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