1 // -*- c-basic-offset: 4 -*- 2 3 /** @file BatchFrame.h 4 * 5 * @brief Batch processor for Hugin with GUI 6 * 7 * @author Marko Kuder <marko.kuder@gmail.com> 8 * 9 * $Id: BatchFrame.h 3322 2008-08-16 5:00:07Z 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 #ifndef BATCHFRAME_H 28 #define BATCHFRAME_H 29 30 #include "RunStitchFrame.h" 31 #include "Batch.h" 32 #include "ProjectListBox.h" 33 #include "DirTraverser.h" 34 #include "wx/help.h" 35 #if !wxUSE_HELP 36 #error wxWidgets needs to be compiled with help support (wxUSE_HELP not set) 37 #endif 38 #if defined __WXMSW__ && !(wxCHECK_VERSION(3,1,1)) 39 #include "base_wx/wxPlatform.h" 40 #define wxHelpController HuginCHMHelpController 41 #endif 42 #include "BatchTrayIcon.h" 43 //#include <wx/app.h> 44 #include "ProgressStatusBar.h" 45 #include <wx/timer.h> 46 47 /** Simple class that forward the drop to the mainframe */ 48 class BatchDropTarget : public wxFileDropTarget 49 { 50 public: 51 /** File/directory drag and drop handler method 52 * 53 * When a project file is droped, it is added with default prefix. 54 * When a directory is dropped, the directory and all sub-directory are scanned and 55 * all found project files are added to the queue. 56 */ 57 bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames); 58 }; 59 60 class BatchFrame : public wxFrame 61 { 62 public: 63 //Main constructor 64 BatchFrame(wxLocale* locale, wxString xrc); 65 // create statusbar with progress control 66 wxStatusBar* OnCreateStatusBar(int number, long style, wxWindowID id, const wxString& name); 67 68 void OnUserExit(wxCommandEvent& event); 69 void OnButtonAddCommand(wxCommandEvent& event); 70 void OnButtonAddDir(wxCommandEvent& event); 71 void OnButtonSearchPano(wxCommandEvent& e); 72 /** let the user select a project file which should be added to the stitching queue */ 73 void OnButtonAddToStitchingQueue(wxCommandEvent& event); 74 /** let the user select a project file which should be added to the stitching queue */ 75 void OnButtonAddToAssistantQueue(wxCommandEvent& event); 76 void OnButtonCancel(wxCommandEvent& event); 77 void OnButtonChangePrefix(wxCommandEvent& event); 78 void OnButtonClear(wxCommandEvent& event); 79 void OnMinimizeTrayMenu(wxCommandEvent& e); 80 void OnButtonHelp(wxCommandEvent& event); 81 void OnButtonMoveDown(wxCommandEvent& event); 82 void OnButtonMoveUp(wxCommandEvent& event); 83 void OnButtonOpenBatch(wxCommandEvent& event); 84 void OnButtonOpenWithHugin(wxCommandEvent& event); 85 void OnButtonPause(wxCommandEvent& event); 86 void OnButtonRemoveComplete(wxCommandEvent& event); 87 void OnButtonRemoveFromList(wxCommandEvent& event); 88 void OnButtonReset(wxCommandEvent& event); 89 void OnButtonResetAll(wxCommandEvent& event); 90 void OnButtonRunBatch(wxCommandEvent& event); 91 void OnButtonSaveBatch(wxCommandEvent& event); 92 void OnButtonSkip(wxCommandEvent& event); 93 94 void OnCheckOverwrite(wxCommandEvent& event); 95 void OnChoiceEnd(wxCommandEvent& event); 96 void OnCheckVerbose(wxCommandEvent& event); 97 /** event handler called when auto remove checkbox was changed */ 98 void OnCheckAutoRemove(wxCommandEvent& event); 99 /** event handler called when auto stitch checkbox was changed */ 100 void OnCheckAutoStitch(wxCommandEvent& event); 101 /** event handler called when always save log checkbox was changed */ 102 void OnCheckSaveLog(wxCommandEvent& event); 103 /** event handler for update progress controls */ 104 void OnProgress(wxCommandEvent& event); 105 106 //Called on window close to take care of the child thread 107 void OnClose(wxCloseEvent& event); 108 /** handle when minimize or restore image */ 109 void OnMinimize(wxIconizeEvent& e); 110 //Resets all checkboxes based on m_batch object properties 111 void PropagateDefaults(); 112 //Sets all checkboxes corresponding the setting in config 113 void SetCheckboxes(); 114 //Starts batch execution 115 void RunBatch(); 116 //Sets locale and XRC prefix pointers from main app 117 void SetLocaleAndXRC(wxLocale* locale, wxString xrc); 118 //Swaps the project entry at index in the list with the next (at index+1). 119 void SwapProject(int index, bool down); 120 //PanoramaOptions readOptions(wxString projectFile); 121 /** return which task should be executed at end*/ 122 Batch::EndTask GetEndTask(); 123 /** return if overwrite checkbox is checked */ 124 bool GetCheckOverwrite(); 125 /** return if verbose checkbox is checked */ 126 bool GetCheckVerbose(); 127 /** return if auto remove checkbox is checked */ 128 bool GetCheckAutoRemove(); 129 /** return if auto stitch checkbox is checked */ 130 bool GetCheckAutoStitch(); 131 /** return if always save log is checked */ 132 bool GetCheckSaveLog(); 133 void RestoreSize(); 134 void AddToList(wxString aFile, Project::Target target=Project::STITCHING); 135 void AddDirToList(wxString aDir); 136 void ChangePrefix(int index,wxString newPrefix); 137 /** returns true, if batch is running */ 138 bool IsRunning(); 139 /** returns true, if batch is paused */ 140 bool IsPaused(); 141 /** sets status message, also updates tooltip of taskbar icon 142 * @param status text for status bar 143 */ 144 void SetStatusInformation(wxString status); 145 /** update visibility of verbose output window depending on status of verbose checkbox */ 146 void UpdateBatchVerboseStatus(); 147 /** returns true, if last session was finished minimized */ IsStartedMinimized()148 bool IsStartedMinimized() 149 { 150 return m_startedMinimized; 151 }; 152 /** sets the current verbose status, does not update the checkbox */ 153 void SetInternalVerbose(bool newVerbose); 154 /** update the progress bar in the task bar */ 155 void UpdateTaskBarProgressBar(); 156 157 /** return help controller for open help */ GetHelpController()158 wxHelpController& GetHelpController() { return m_HelpController; } 159 160 //wxMutex* projListMutex; 161 ProjectListBox* projListBox; 162 163 private: 164 wxLocale* m_locale; 165 wxString m_xrcPrefix; 166 Batch* m_batch; 167 bool m_cancelled; 168 bool m_paused; 169 wxChoice* m_endChoice; 170 // help controller 171 wxHelpController m_HelpController; 172 BatchTaskBarIcon* m_tray; 173 ProgressStatusBar* m_progStatusBar; 174 wxIcon m_iconNormal; 175 wxIcon m_iconRunning; 176 wxIcon m_iconPaused; 177 // timer for checking of modified projects 178 wxTimer* m_updateProjectsTimer; 179 bool m_startedMinimized; 180 181 void OnProcessTerminate(wxProcessEvent& event); 182 /** called by thread to update listbox */ 183 void OnUpdateListBox(wxTimerEvent& event); 184 /** called when batch was finished and there are failed projects */ 185 void OnBatchFailed(wxCommandEvent& event); 186 /** called when batch wants to show some progress message */ 187 void OnBatchInformation(wxCommandEvent& e); 188 /** called if the project box needs to be updated, because projects were added or deleted */ 189 void OnRefillListBox(wxCommandEvent& e); 190 /** create or destroy the tray icon */ 191 void UpdateTrayIcon(const bool createTrayIcon); 192 193 DECLARE_EVENT_TABLE() 194 }; 195 196 #endif //BATCHFRAME_H 197