1 // -*- c-basic-offset: 4 -*- 2 3 /** @file PTBatcherGUI.h 4 * 5 * @brief Batch processor for Hugin with GUI 6 * 7 * @author Marko Kuder <marko.kuder@gmail.com> 8 * 9 * $Id: PTBatcherGUI.h 3448 2008-09-23 3:42:07 mkuder $ 10 * 11 * This program 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 * 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 "RunStitchFrame.h" 28 #include "Batch.h" 29 #include "BatchFrame.h" 30 31 #include <wx/dir.h> 32 #include <wx/wfstream.h> 33 #include <wx/filefn.h> 34 #include <wx/snglinst.h> 35 #include <wx/ipc.h> 36 37 #include <hugin_config.h> 38 #include <wx/cmdline.h> 39 40 #ifndef FRAMEARRAY 41 #define FRAMEARRAY 42 WX_DEFINE_ARRAY_PTR(RunStitchFrame*,FrameArray); 43 #endif 44 45 #ifndef PTBATCHERGUI_H 46 #define PTBATCHERGUI_H 47 // ********************************************************************** 48 49 /** class for communication between different PTBatcherGUI instances 50 * 51 * this class is used to transfer the commandline parameters of the second instance of PTBatcherGUI 52 * to the first and only running instance of PTBatcherGUI 53 */ 54 class BatchIPCConnection : public wxConnection 55 { 56 public: 57 /** request handler for transfer */ 58 virtual const void* OnRequest(const wxString& topic, const wxString& item, size_t* size = NULL, wxIPCFormat format = wxIPC_TEXT); 59 }; 60 61 /** server which implements the communication between different PTBatcherGUI instances (see BatchIPCConnection) */ 62 class BatchIPCServer : public wxServer 63 { 64 public: 65 /**accept connection handler (establish the connection) */ 66 virtual wxConnectionBase* OnAcceptConnection (const wxString& topic); 67 }; 68 69 /** topic name for BatchIPCConnection and BatchIPCServer */ 70 const wxString IPC_START(wxT("BatchStart")); 71 72 /** The application class for hugin_stitch_project 73 * 74 * it contains the main frame. 75 */ 76 class PTBatcherGUI : public wxApp 77 { 78 public: 79 /** pseudo constructor. with the ability to fail gracefully. 80 */ 81 virtual bool OnInit(); 82 virtual int OnExit(); 83 #if wxUSE_ON_FATAL_EXCEPTION 84 #if wxCHECK_VERSION(3,1,0) 85 virtual void OnFatalException() wxOVERRIDE; 86 #else 87 virtual void OnFatalException(); 88 #endif 89 #endif 90 91 //Handles some input keys for the frame 92 void OnItemActivated(wxListEvent& event); 93 void OnKeyDown(wxKeyEvent& event); 94 95 //Main batch list 96 ProjectArray projList; 97 //List of projects in progress (their RunStitchFrames) 98 FrameArray stitchFrames; GetFrame()99 BatchFrame* GetFrame() 100 { 101 return m_frame; 102 }; 103 104 #ifdef __WXMAC__ 105 /** the wx calls this method when the app gets "Open files" AppleEvent */ 106 void MacOpenFiles(const wxArrayString &fileNames); 107 #endif 108 109 private: 110 BatchFrame* m_frame; 111 wxLocale m_locale; 112 wxString m_xrcPrefix; 113 wxSingleInstanceChecker* m_checker; 114 BatchIPCServer* m_server; 115 116 DECLARE_EVENT_TABLE() 117 }; 118 119 DECLARE_APP(PTBatcherGUI) 120 121 #endif //PTBATCHERGUI_H 122