Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RunStitchFrame.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
27 #include "RunStitchFrame.h"
28 
29 BEGIN_EVENT_TABLE(RunStitchFrame, wxFrame)
30  EVT_BUTTON(wxID_CANCEL, RunStitchFrame::OnCancel)
31  EVT_END_PROCESS(-1, RunStitchFrame::OnProcessTerminate)
33 
34 RunStitchFrame::RunStitchFrame(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size) //ProjectArray projList, wxListBox *projListBox)
35  : wxFrame(parent, -1, title, pos, size, wxRESIZE_BORDER | wxCAPTION | wxCLIP_CHILDREN), m_isStitching(false)
36 {
37 
38  wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
39  m_stitchPanel = new RunStitchPanel(this);
40 
41  topsizer->Add(m_stitchPanel, 1, wxEXPAND | wxALL, 2);
42 
43  topsizer->Add( new wxButton(this, wxID_CANCEL, _("Cancel")),
44  0, wxALL | wxALIGN_RIGHT, 10);
45 
46 #ifdef __WXMSW__
47  // wxFrame does have a strange background color on Windows..
48  this->SetBackgroundColour(m_stitchPanel->GetBackgroundColour());
49 #endif
50 
51  SetSizer( topsizer );
52 }
53 
55 {
56  if(m_projectId<0) //if a fake stitchframe is used (for a command), it doesn't have a stitch panel
57  {
58  return m_pid;
59  }
60  else
61  {
62  return m_stitchPanel->GetPid();
63  }
64 }
65 
67 {
68  return m_projectId;
69 }
70 
72 {
73  if(m_projectId<0) //if a fake stitchframe is used (for a command), it doesn't have a stitch panel
74  {
75  m_pid = pid;
76  }
77  else
78  {
80  }
81 }
82 
84 {
85  m_projectId=id;
86 }
87 
88 void RunStitchFrame::OnCancel(wxCommandEvent& WXUNUSED(event))
89 {
90  DEBUG_TRACE("");
91  if (m_isStitching)
92  {
94  m_isStitching = false;
95  }
96  else
97  {
98  Close();
99  }
100 }
101 
102 void RunStitchFrame::OnProcessTerminate(wxProcessEvent& event)
103 {
104  if (! m_isStitching)
105  {
106  event.SetEventObject( this );
107  event.m_exitcode = 1;
108  event.SetId(m_projectId);
109  DEBUG_TRACE("Sending wxProcess event");
110  this->GetParent()->GetEventHandler()->ProcessEvent( event );
111  // TODO: Cleanup files?
112  Close();
113  }
114  else
115  {
116  m_isStitching = false;
117  if (event.GetExitCode() != 0)
118  {
119  event.SetEventObject( this );
120  event.SetId(m_projectId);
121  this->GetParent()->GetEventHandler()->ProcessEvent( event );
122  Close();
123  }
124  else
125  {
126  event.SetEventObject( this );
127  event.SetId(m_projectId);
128  DEBUG_TRACE("Sending wxProcess event");
129  this->GetParent()->GetEventHandler()->ProcessEvent( event );
130  Close();
131  }
132  }
133 }
134 
135 bool RunStitchFrame::StitchProject(wxString scriptFile, wxString outname, wxString userDefinedOutput)
136 {
137  if (! m_stitchPanel->StitchProject(scriptFile, outname, userDefinedOutput))
138  {
139  return false;
140  }
141  m_isStitching = true;
142  m_isDetecting = false;
143  return true;
144 }
145 
146 bool RunStitchFrame::DetectProject(wxString scriptFile, wxString userDefinedAssistant)
147 {
148  if (! m_stitchPanel->DetectProject(scriptFile, userDefinedAssistant))
149  {
150  return false;
151  }
152  m_isStitching = true;
153  m_isDetecting = true;
154  return true;
155 }
156 
157 bool RunStitchFrame::SaveLog(const wxString& filename)
158 {
159  return m_stitchPanel->SaveLog(filename);
160 };
Stitch a pto project file, with GUI output etc.
void OnCancel(wxCommandEvent &event)
Cancels project execution - kills process.
void OnProcessTerminate(wxProcessEvent &event)
RunStitchPanel * m_stitchPanel
bool StitchProject(const wxString &scriptFile, const wxString &outname, const wxString &userDefinedOutput=wxEmptyString)
#define DEBUG_TRACE(msg)
Definition: utils.h:67
END_EVENT_TABLE()
bool StitchProject(wxString scriptFile, wxString outname, wxString userDefinedOutput=wxEmptyString)
Starts stitching of project file.
int GetProcessId()
Returns process ID of running process.
bool DetectProject(wxString scriptFile, wxString userDefinedAssistant=wxEmptyString)
starts assistant of project file
bool SaveLog(const wxString &filename)
save the content of the window into a given log file
bool DetectProject(const wxString &scriptFile, const wxString &userDefinedAssistant=wxEmptyString)
void SetProjectId(int id)
Sets project id from batch.
int GetProjectId()
Gets project id from batch.
void SetProcessId(int pid)
Sets process ID of running process (if running process from outside)
bool SaveLog(const wxString &filename)
save the content of the window into a given log file