00001
00002
00027 #include "RunStitchFrame.h"
00028
00029 BEGIN_EVENT_TABLE(RunStitchFrame, wxFrame)
00030 EVT_BUTTON(wxID_CANCEL, RunStitchFrame::OnCancel)
00031 EVT_END_PROCESS(-1, RunStitchFrame::OnProcessTerminate)
00032 END_EVENT_TABLE()
00033
00034 RunStitchFrame::RunStitchFrame(wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size)
00035 : wxFrame(parent, -1, title, pos, size, wxRESIZE_BORDER | wxCAPTION | wxCLIP_CHILDREN), m_isStitching(false)
00036 {
00037
00038 wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
00039 m_stitchPanel = new RunStitchPanel(this);
00040
00041 topsizer->Add(m_stitchPanel, 1, wxEXPAND | wxALL, 2);
00042
00043 topsizer->Add( new wxButton(this, wxID_CANCEL, _("Cancel")),
00044 0, wxALL | wxALIGN_RIGHT, 10);
00045
00046 #ifdef __WXMSW__
00047
00048 this->SetBackgroundColour(m_stitchPanel->GetBackgroundColour());
00049 #endif
00050
00051 SetSizer( topsizer );
00052 }
00053
00054 int RunStitchFrame::GetProcessId()
00055 {
00056 if(m_projectId<0)
00057 {
00058 return m_pid;
00059 }
00060 else
00061 {
00062 return m_stitchPanel->GetPid();
00063 }
00064 }
00065
00066 int RunStitchFrame::GetProjectId()
00067 {
00068 return m_projectId;
00069 }
00070
00071 void RunStitchFrame::SetProcessId(int pid)
00072 {
00073 if(m_projectId<0)
00074 {
00075 m_pid = pid;
00076 }
00077 else
00078 {
00079 m_pid = m_stitchPanel->GetPid();
00080 }
00081 }
00082
00083 void RunStitchFrame::SetProjectId(int id)
00084 {
00085 m_projectId=id;
00086 }
00087
00088 void RunStitchFrame::OnCancel(wxCommandEvent& WXUNUSED(event))
00089 {
00090 DEBUG_TRACE("");
00091 if (m_isStitching)
00092 {
00093 m_stitchPanel->CancelStitch();
00094 m_isStitching = false;
00095 }
00096 else
00097 {
00098 Close();
00099 }
00100 }
00101
00102 void RunStitchFrame::OnProcessTerminate(wxProcessEvent& event)
00103 {
00104 if (! m_isStitching)
00105 {
00106 event.SetEventObject( this );
00107 event.m_exitcode = 1;
00108 event.SetId(m_projectId);
00109 DEBUG_TRACE("Sending wxProcess event");
00110 this->GetParent()->GetEventHandler()->ProcessEvent( event );
00111
00112 Close();
00113 }
00114 else
00115 {
00116 m_isStitching = false;
00117 if (event.GetExitCode() != 0)
00118 {
00119 event.SetEventObject( this );
00120 event.SetId(m_projectId);
00121 this->GetParent()->GetEventHandler()->ProcessEvent( event );
00122 Close();
00123 }
00124 else
00125 {
00126 event.SetEventObject( this );
00127 event.SetId(m_projectId);
00128 DEBUG_TRACE("Sending wxProcess event");
00129 this->GetParent()->GetEventHandler()->ProcessEvent( event );
00130 Close();
00131 }
00132 }
00133 }
00134
00135 bool RunStitchFrame::StitchProject(wxString scriptFile, wxString outname,
00136 HuginBase::PanoramaMakefilelibExport::PTPrograms progs)
00137 {
00138 if (! m_stitchPanel->StitchProject(scriptFile, outname, progs))
00139 {
00140 return false;
00141 }
00142 m_isStitching = true;
00143 m_isDetecting = false;
00144 return true;
00145 }
00146
00147 bool RunStitchFrame::DetectProject(wxString scriptFile,
00148 HuginBase::AssistantMakefilelibExport::AssistantPrograms progs)
00149 {
00150 if (! m_stitchPanel->DetectProject(scriptFile, progs))
00151 {
00152 return false;
00153 }
00154 m_isStitching = true;
00155 m_isDetecting = true;
00156 return true;
00157 }
00158
00159 bool RunStitchFrame::SaveLog(const wxString& filename)
00160 {
00161 return m_stitchPanel->SaveLog(filename);
00162 };