Hugin trunk 0.1
Loading...
Searching...
No Matches
MyExternalCmdExecDialog.h
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
24// This class is written based on 'exec' sample of wxWidgets library.
25
26
27#ifndef _MYEXTERNALCMDEXECDIALOG__H
28#define _MYEXTERNALCMDEXECDIALOG__H
29
30#include <hugin_shared.h>
31#include <wx/utils.h>
32#include "Executor.h"
33
35
41
42// Define an array of process pointers used by MyFrame
43class MyPipedProcess;
45
47{
48public:
49 virtual void OnProcessTerminated(MyPipedProcess *process, int pid, int status) = 0;
50 virtual ~MyProcessListener() {}
51};
52
53// Define a new exec dialog
54class WXIMPEX MyExecPanel : public wxPanel, public MyProcessListener
55{
56public:
57 // ctor(s)
58 explicit MyExecPanel(wxWindow * parent);
59
60 void KillProcess();
61 void PauseProcess(bool pause = true);
62 void ContinueProcess();
63 long GetPid();
64
65 int ExecWithRedirect(wxString command);
66 int ExecQueue(HuginQueue::CommandQueue* queue);
67
68 // polling output of async processes
69 void OnTimer(wxTimerEvent& event);
70
71 // for MyPipedProcess
72 void OnProcessTerminated(MyPipedProcess *process, int pid, int status);
73
76 bool SaveLog(const wxString &filename);
78 void CopyLogToClipboard();
80 wxArrayString GetLogAsArrayString();
82 void AddString(const wxString& s);
84 void ClearOutput();
85
86 virtual ~MyExecPanel();
87
88private:
89
90 void AddToOutput(wxInputStream & s);
91
92 void DoAsyncExec(const wxString& cmd);
93
94 void AddAsyncProcess(MyPipedProcess *process);
95
96 void RemoveAsyncProcess(MyPipedProcess *process);
97
98 int ExecNextQueue();
99
100 // the PID of the last process we launched asynchronously
102
103 wxTextCtrl *m_textctrl;
105
107
108 // the idle event wake up timer
110 // store queue
113 // if the return code of the process should be checked
117};
118
119// ----------------------------------------------------------------------------
120// wxProcess-derived classes
121// ----------------------------------------------------------------------------
122
123// A specialization of MyProcess for redirecting the output
124class WXIMPEX MyPipedProcess : public wxProcess
125{
126public:
128 : wxProcess(0), m_cmd(cmd)
129 {
130 m_parent = parent;
131 Redirect();
132 }
133
134 // This is the handler for process termination events
135 virtual void OnTerminate(int pid, int status);
136protected:
139};
140
141// Define a new exec dialog, which uses MyExecPanel defined above
142class WXIMPEX MyExecDialog : public wxDialog
143{
144public:
145// ctor(s)
146 MyExecDialog(wxWindow * parent, const wxString& title, const wxPoint& pos, const wxSize& size);
147
148 void OnCancel(wxCommandEvent& event);
149
150 int ExecWithRedirect(wxString command);
151 int ExecQueue(HuginQueue::CommandQueue* queue);
153 void AddString(const wxString& s);
154
155 void OnProcessTerminate(wxProcessEvent & event);
156
157 virtual ~MyExecDialog();
158
159private:
160
163};
164
166
167#endif
basic classes and function for queuing commands in wxWidgets
const int HUGIN_EXIT_CODE_CANCELLED
wxDECLARE_EXPORTED_EVENT(WXIMPEX, EVT_QUEUE_PROGRESS, wxCommandEvent)
WXIMPEX int MyExecuteCommandOnDialog(wxString command, wxString args, wxWindow *parent, wxString title, bool isQuoted=false)
execute a single command in own dialog, redirect output to frame and allow canceling
WX_DEFINE_ARRAY_PTR(MyPipedProcess *, MyProcessesArray)
WXIMPEX int MyExecuteCommandQueue(HuginQueue::CommandQueue *queue, wxWindow *parent, const wxString &title, const wxString &comment=wxEmptyString)
execute all commands in queue with redirection of output to frame and allow canceling the queue will ...
MyExecPanel * m_execPanel
MyProcessesArray m_running
wxExecuteEnv m_executeEnv
HuginQueue::CommandQueue * m_queue
void DoAsyncExec(const wxString &cmd)
MyPipedProcess(MyProcessListener *parent, const wxString &cmd)
MyProcessListener * m_parent
virtual void OnProcessTerminated(MyPipedProcess *process, int pid, int status)=0
#define WXIMPEX
std::vector< NormalCommand * > CommandQueue
Definition Executor.h:61
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41