From: <st...@us...> - 2009-02-20 08:11:55
|
Revision: 3657 http://hugin.svn.sourceforge.net/hugin/?rev=3657&view=rev Author: stativ Date: 2009-02-20 08:11:48 +0000 (Fri, 20 Feb 2009) Log Message: ----------- Unify line endings to \n Modified Paths: -------------- hugin/trunk/CMakeModules/FindJPEG.cmake hugin/trunk/CMakeModules/FindPNG.cmake hugin/trunk/CMakeModules/FindTIFF.cmake hugin/trunk/CMakeModules/FindZLIB.cmake hugin/trunk/src/PTBatcher/Batch.cpp hugin/trunk/src/PTBatcher/Batch.h hugin/trunk/src/PTBatcher/PTBatcher.cpp hugin/trunk/src/PTBatcher/PTBatcher.h hugin/trunk/src/PTBatcher/ProjectArray.cpp hugin/trunk/src/PTBatcherGUI/BatchFrame.cpp hugin/trunk/src/PTBatcherGUI/BatchFrame.h hugin/trunk/src/PTBatcherGUI/DirTraverser.h hugin/trunk/src/PTBatcherGUI/PTBatcherGUI.cpp hugin/trunk/src/PTBatcherGUI/ProjectListBox.cpp hugin/trunk/src/PTBatcherGUI/ProjectListBox.h hugin/trunk/src/hugin1/hugin/xrc/cp_editor_panel.xrc hugin/trunk/src/hugin1/hugin/xrc/pano_panel.xrc hugin/trunk/src/hugin1/hugin/xrc/pref_dialog.xrc Modified: hugin/trunk/CMakeModules/FindJPEG.cmake =================================================================== --- hugin/trunk/CMakeModules/FindJPEG.cmake 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/CMakeModules/FindJPEG.cmake 2009-02-20 08:11:48 UTC (rev 3657) @@ -1,37 +1,37 @@ -# - Find JPEG for Hugin 0.7 01Nov2007 TKSharpless -# Added to support Windows build but should work anywhere. -# After looking in UNIX standard places, tries wxWidgets build -# tree, which should have this package. -# -# Call FIND_PACKAGE(wxWidgets REQUIRED) before calling this! -# -# reads cache variables -# wxWidgets_ROOT_DIR -# wxWidgets_LIB_DIR -# defines cache variables -# JPEG_INCLUDE_DIR, where to find headers -# JPEG_LIBRARIES, list of release link libraries -# JPEG_DEBUG_LIBRARIES, list of debug link libraries -# JPEG_FOUND, If != "YES", do not try to use JPEG - -FIND_PATH(JPEG_INCLUDE_DIR jpeglib.h - /usr/local/include - /usr/include - ${wxWidgets_ROOT_DIR}/src/jpeg -) - -include(FindLibraryWithDebug) - -find_library_with_debug(JPEG_LIBRARIES - WIN32_DEBUG_POSTFIX d - NAMES jpeg libjpeg wxjpeg - PATHS /usr/lib /usr/local/lib ${wxWidgets_LIB_DIR} -) - - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(JPEG DEFAULT_MSG - JPEG_INCLUDE_DIR JPEG_LIBRARIES) - -MARK_AS_ADVANCED(JPEG_INCLUDE_DIR JPEG_LIBRARIES ) - +# - Find JPEG for Hugin 0.7 01Nov2007 TKSharpless +# Added to support Windows build but should work anywhere. +# After looking in UNIX standard places, tries wxWidgets build +# tree, which should have this package. +# +# Call FIND_PACKAGE(wxWidgets REQUIRED) before calling this! +# +# reads cache variables +# wxWidgets_ROOT_DIR +# wxWidgets_LIB_DIR +# defines cache variables +# JPEG_INCLUDE_DIR, where to find headers +# JPEG_LIBRARIES, list of release link libraries +# JPEG_DEBUG_LIBRARIES, list of debug link libraries +# JPEG_FOUND, If != "YES", do not try to use JPEG + +FIND_PATH(JPEG_INCLUDE_DIR jpeglib.h + /usr/local/include + /usr/include + ${wxWidgets_ROOT_DIR}/src/jpeg +) + +include(FindLibraryWithDebug) + +find_library_with_debug(JPEG_LIBRARIES + WIN32_DEBUG_POSTFIX d + NAMES jpeg libjpeg wxjpeg + PATHS /usr/lib /usr/local/lib ${wxWidgets_LIB_DIR} +) + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(JPEG DEFAULT_MSG + JPEG_INCLUDE_DIR JPEG_LIBRARIES) + +MARK_AS_ADVANCED(JPEG_INCLUDE_DIR JPEG_LIBRARIES ) + Modified: hugin/trunk/CMakeModules/FindPNG.cmake =================================================================== --- hugin/trunk/CMakeModules/FindPNG.cmake 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/CMakeModules/FindPNG.cmake 2009-02-20 08:11:48 UTC (rev 3657) @@ -1,43 +1,43 @@ -# - Find PNG for Hugin 0.7 01Nov2007 TKSharpless -# Added to support Windows build but should work anywhere. -# After looking in UNIX standard places, tries wxWidgets build -# tree, which should have this package. -# -# Call FIND_PACKAGE(wxWidgets REQUIRED) before calling this! -# -# reads cache variables -# wxWidgets_ROOT_DIR -# wxWidgets_LIB_DIR -# defines cache variables -# PNG_INCLUDE_DIR, where to find headers -# PNG_LIBRARIES, list of release link libraries. -# PNG_FOUND, If != "YES", do not try to use PNG. -# None of the above will be defined unless ZLIB can be found - -INCLUDE(FindZLIB) - -include(FindLibraryWithDebug) - -SET(PNG_FOUND "NO") - -IF (ZLIB_FOUND) - FIND_PATH(PNG_INCLUDE_DIR png.h - /usr/local/include - /usr/include - ${wxWidgets_ROOT_DIR}/src/png - ) - - find_library_with_debug(PNG_LIBRARIES - WIN32_DEBUG_POSTFIX d - NAMES png libpng wxpng - PATHS /usr/lib /usr/local/lib ${wxWidgets_LIB_DIR} - ) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(PNG DEFAULT_MSG - PNG_INCLUDE_DIR PNG_LIBRARIES) - - SET(PNG_LIBRARIES ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}) - MARK_AS_ADVANCED(PNG_INCLUDE_DIR PNG_LIBRARIES ) -ENDIF(ZLIB_FOUND) - +# - Find PNG for Hugin 0.7 01Nov2007 TKSharpless +# Added to support Windows build but should work anywhere. +# After looking in UNIX standard places, tries wxWidgets build +# tree, which should have this package. +# +# Call FIND_PACKAGE(wxWidgets REQUIRED) before calling this! +# +# reads cache variables +# wxWidgets_ROOT_DIR +# wxWidgets_LIB_DIR +# defines cache variables +# PNG_INCLUDE_DIR, where to find headers +# PNG_LIBRARIES, list of release link libraries. +# PNG_FOUND, If != "YES", do not try to use PNG. +# None of the above will be defined unless ZLIB can be found + +INCLUDE(FindZLIB) + +include(FindLibraryWithDebug) + +SET(PNG_FOUND "NO") + +IF (ZLIB_FOUND) + FIND_PATH(PNG_INCLUDE_DIR png.h + /usr/local/include + /usr/include + ${wxWidgets_ROOT_DIR}/src/png + ) + + find_library_with_debug(PNG_LIBRARIES + WIN32_DEBUG_POSTFIX d + NAMES png libpng wxpng + PATHS /usr/lib /usr/local/lib ${wxWidgets_LIB_DIR} + ) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(PNG DEFAULT_MSG + PNG_INCLUDE_DIR PNG_LIBRARIES) + + SET(PNG_LIBRARIES ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}) + MARK_AS_ADVANCED(PNG_INCLUDE_DIR PNG_LIBRARIES ) +ENDIF(ZLIB_FOUND) + Modified: hugin/trunk/CMakeModules/FindTIFF.cmake =================================================================== --- hugin/trunk/CMakeModules/FindTIFF.cmake 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/CMakeModules/FindTIFF.cmake 2009-02-20 08:11:48 UTC (rev 3657) @@ -1,42 +1,42 @@ -# - Find TIFF for Hugin 0.7 01Nov2007 TKSharpless -# Added to support Windows build but should work anywhere. -# After looking in UNIX standard places, tries wxWidgets build -# tree, which should have this package. -# -# Call FIND_PACKAGE(wxWidgets REQUIRED) before calling this! -# -# reads cache variables -# wxWidgets_ROOT_DIR -# wxWidgets_LIB_DIR -# defines cache variables -# TIFF_INCLUDE_DIR, where to find headers -# TIFF_LIBRARIES, list of link libraries for release -# TIFF_DEBUG_LIBRARIES ditto for debug -# TIFF_FOUND, If != "YES", do not try to use TIFF. - -FIND_PATH(TIFF_INCLUDE_DIR tiff.h - /usr/local/include - /usr/include - ${SOURCE_BASE_DIR}/tiff-3.8.2/libtiff - ${SOURCE_BASE_DIR}/tiff-4.0.0alpha/libtiff - ${wxWidgets_ROOT_DIR}/src/tiff -) - -include(FindLibraryWithDebug) - -find_library_with_debug(TIFF_LIBRARIES - WIN32_DEBUG_POSTFIX d - NAMES tiff libtiff wxtiff - PATHS /usr/lib /usr/local/lib - ${SOURCE_BASE_DIR}/tiff-3.8.2/libtiff - ${SOURCE_BASE_DIR}/tiff-4.0.0alpha/libtiff - ${wxWidgets_LIB_DIR} -) - - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(TIFF DEFAULT_MSG - TIFF_INCLUDE_DIR TIFF_LIBRARIES) - -MARK_AS_ADVANCED(TIFF_INCLUDE_DIR TIFF_LIBRARIES) - +# - Find TIFF for Hugin 0.7 01Nov2007 TKSharpless +# Added to support Windows build but should work anywhere. +# After looking in UNIX standard places, tries wxWidgets build +# tree, which should have this package. +# +# Call FIND_PACKAGE(wxWidgets REQUIRED) before calling this! +# +# reads cache variables +# wxWidgets_ROOT_DIR +# wxWidgets_LIB_DIR +# defines cache variables +# TIFF_INCLUDE_DIR, where to find headers +# TIFF_LIBRARIES, list of link libraries for release +# TIFF_DEBUG_LIBRARIES ditto for debug +# TIFF_FOUND, If != "YES", do not try to use TIFF. + +FIND_PATH(TIFF_INCLUDE_DIR tiff.h + /usr/local/include + /usr/include + ${SOURCE_BASE_DIR}/tiff-3.8.2/libtiff + ${SOURCE_BASE_DIR}/tiff-4.0.0alpha/libtiff + ${wxWidgets_ROOT_DIR}/src/tiff +) + +include(FindLibraryWithDebug) + +find_library_with_debug(TIFF_LIBRARIES + WIN32_DEBUG_POSTFIX d + NAMES tiff libtiff wxtiff + PATHS /usr/lib /usr/local/lib + ${SOURCE_BASE_DIR}/tiff-3.8.2/libtiff + ${SOURCE_BASE_DIR}/tiff-4.0.0alpha/libtiff + ${wxWidgets_LIB_DIR} +) + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(TIFF DEFAULT_MSG + TIFF_INCLUDE_DIR TIFF_LIBRARIES) + +MARK_AS_ADVANCED(TIFF_INCLUDE_DIR TIFF_LIBRARIES) + Modified: hugin/trunk/CMakeModules/FindZLIB.cmake =================================================================== --- hugin/trunk/CMakeModules/FindZLIB.cmake 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/CMakeModules/FindZLIB.cmake 2009-02-20 08:11:48 UTC (rev 3657) @@ -1,45 +1,45 @@ -# - Find zlib -# Find the native ZLIB includes and library -# -# ZLIB_INCLUDE_DIR - where to find zlib.h, etc. -# ZLIB_LIBRARIES - List of libraries when using zlib. -# ZLIB_FOUND - True if zlib found. - -# - Find TIFF for Hugin 0.7 01Nov2007 TKSharpless -# Added to support Windows build but should work anywhere. -# After looking in UNIX standard places, tries wxWidgets build -# tree, which should have this package. -# -# reads cache variables -# wxWidgets_ROOT_DIR -# wxWidgets_LIB_DIR -# - -IF (ZLIB_INCLUDE_DIR) - # Already in cache, be silent - SET(ZLIB_FIND_QUIETLY TRUE) -ENDIF (ZLIB_INCLUDE_DIR) - -FIND_PATH(ZLIB_INCLUDE_DIR zlib.h - /usr/local/include - /usr/include - ${wxWidgets_ROOT_DIR}/src/zlib -) - -include(FindLibraryWithDebug) - -find_library_with_debug(ZLIB_LIBRARIES - WIN32_DEBUG_POSTFIX d - NAMES z zlib wxzlib - PATHS /usr/lib /usr/local/lib ${wxWidgets_LIB_DIR} -) - - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ZLIB DEFAULT_MSG - ZLIB_INCLUDE_DIR ZLIB_LIBRARIES) - -MARK_AS_ADVANCED( - ZLIB_LIBRARIES - ZLIB_INCLUDE_DIR - ) +# - Find zlib +# Find the native ZLIB includes and library +# +# ZLIB_INCLUDE_DIR - where to find zlib.h, etc. +# ZLIB_LIBRARIES - List of libraries when using zlib. +# ZLIB_FOUND - True if zlib found. + +# - Find TIFF for Hugin 0.7 01Nov2007 TKSharpless +# Added to support Windows build but should work anywhere. +# After looking in UNIX standard places, tries wxWidgets build +# tree, which should have this package. +# +# reads cache variables +# wxWidgets_ROOT_DIR +# wxWidgets_LIB_DIR +# + +IF (ZLIB_INCLUDE_DIR) + # Already in cache, be silent + SET(ZLIB_FIND_QUIETLY TRUE) +ENDIF (ZLIB_INCLUDE_DIR) + +FIND_PATH(ZLIB_INCLUDE_DIR zlib.h + /usr/local/include + /usr/include + ${wxWidgets_ROOT_DIR}/src/zlib +) + +include(FindLibraryWithDebug) + +find_library_with_debug(ZLIB_LIBRARIES + WIN32_DEBUG_POSTFIX d + NAMES z zlib wxzlib + PATHS /usr/lib /usr/local/lib ${wxWidgets_LIB_DIR} +) + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ZLIB DEFAULT_MSG + ZLIB_INCLUDE_DIR ZLIB_LIBRARIES) + +MARK_AS_ADVANCED( + ZLIB_LIBRARIES + ZLIB_INCLUDE_DIR + ) Modified: hugin/trunk/src/PTBatcher/Batch.cpp =================================================================== --- hugin/trunk/src/PTBatcher/Batch.cpp 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/src/PTBatcher/Batch.cpp 2009-02-20 08:11:48 UTC (rev 3657) @@ -22,23 +22,23 @@ * License along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - */ - + */ + #include "Batch.h" -#include <wx/stdpaths.h> - +#include <wx/stdpaths.h> + BEGIN_EVENT_TABLE(Batch, wxFrame) EVT_END_PROCESS(-1, Batch::OnProcessTerminate) -END_EVENT_TABLE() - -Batch::Batch(wxFrame* parent, wxString path, bool bgui) : wxFrame(parent,wxID_ANY,_("Batch")){ - //default flag settings - parallel = false; - deleteFiles = false; - shutdown = false; - overwrite = true; - verbose = false; - gui = bgui; +END_EVENT_TABLE() + +Batch::Batch(wxFrame* parent, wxString path, bool bgui) : wxFrame(parent,wxID_ANY,_("Batch")){ + //default flag settings + parallel = false; + deleteFiles = false; + shutdown = false; + overwrite = true; + verbose = false; + gui = bgui; m_cancelled = false; m_paused = false; m_running = false; @@ -79,22 +79,22 @@ if(!gui) m_locale.AddCatalogLookupPathPrefix(wxT(INSTALL_LOCALE_DIR)); PTPrograms progs = getPTProgramsConfig(wxT(""), wxConfigBase::Get()); -#endif - +#endif + // update incompatible configuration entries. updateHuginConfig(wxConfigBase::Get()); // set the name of locale recource to look for - m_locale.AddCatalog(wxT("hugin")); -} - -void Batch::AddAppToBatch(wxString app) -{ + m_locale.AddCatalog(wxT("hugin")); +} + +void Batch::AddAppToBatch(wxString app) +{ Project *newApp = new Project(app); - m_projList.Add(newApp); -} - -void Batch::AddProjectToBatch(wxString projectFile, wxString outputFile) + m_projList.Add(newApp); +} + +void Batch::AddProjectToBatch(wxString projectFile, wxString outputFile) { wxFileName name(projectFile); @@ -102,22 +102,22 @@ { Project *proj = new Project(projectFile,outputFile); m_projList.Add(proj); - /*if(gui) - ((wxFrame*)GetParent())->SetStatusText(_T("Added project ")+projectFile+_T(" with output ")+outputFile); - else if(verbose) + /*if(gui) + ((wxFrame*)GetParent())->SetStatusText(_T("Added project ")+projectFile+_T(" with output ")+outputFile); + else if(verbose) cout << "Added project " << projectFile.char_str() << " with output " << outputFile.char_str() << endl;*/ } else { //on output set as "", it defaults to same path and name as project file Project *proj = new Project(projectFile,name.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + name.GetName()); m_projList.Add(proj); - /*if(gui) - ((wxFrame*)GetParent())->SetStatusText(_T("Added project ")+projectFile); - else if(verbose) - cout << "Added project " << projectFile.char_str() << endl;*/ - } -} - + /*if(gui) + ((wxFrame*)GetParent())->SetStatusText(_T("Added project ")+projectFile); + else if(verbose) + cout << "Added project " << projectFile.char_str() << endl;*/ + } +} + bool Batch::AllDone() { for(unsigned int i=0; i<m_projList.GetCount(); i++) @@ -162,7 +162,7 @@ //we set the id generator we got from file Project::idGenerator = idGenTemp; } -} +} void Batch::CancelBatch() { @@ -170,7 +170,7 @@ for(int i=0; i<GetRunningCount(); i++) CancelProject(i); m_running = false; -} +} void Batch::CancelProject(int index) { wxCommandEvent event; @@ -221,7 +221,7 @@ pid = m_stitchFrames.Item(i)->GetProcessId(); if(waitpid(pid,&status,0)==-1) SetStatus(GetIndex(m_stitchFrames.Item(i)->GetProjectId()),Project::FAILED); //we set to failed if waitpid terminated with an error - if(!WIFEXITED(status) || WEXITSTATUS(status)!=0) + if(!WIFEXITED(status) || WEXITSTATUS(status)!=0) SetStatus(GetIndex(m_stitchFrames.Item(i)->GetProjectId()),Project::FAILED); //we set to failed if child terminated abnormally or with a bad exit code } #endif @@ -343,39 +343,39 @@ return m_stitchFrames.GetCount(); } -Project::Status Batch::GetStatus(int index) -{ - if((unsigned int)index<m_projList.GetCount()) - return m_projList.Item(index).status; - else if(gui) - wxMessageBox( _("Error: Could not get status, project with index ")+wxString::Format(_("%d"),index)+_(" is not in list."),_("Error!"),wxOK | wxICON_INFORMATION ); - else if(verbose) - cout << "Error: Could not get status, project with index " << index << " is not in list." << endl; - return Project::MISSING; -} +Project::Status Batch::GetStatus(int index) +{ + if((unsigned int)index<m_projList.GetCount()) + return m_projList.Item(index).status; + else if(gui) + wxMessageBox( _("Error: Could not get status, project with index ")+wxString::Format(_("%d"),index)+_(" is not in list."),_("Error!"),wxOK | wxICON_INFORMATION ); + else if(verbose) + cout << "Error: Could not get status, project with index " << index << " is not in list." << endl; + return Project::MISSING; +} bool Batch::IsPaused() { return m_paused; } -void Batch::ListBatch() -{ - if(m_projList.GetCount() == 0) - cout << "Batch is empty." << endl; - else - { - cout << "List of projects in batch:" << endl << - "[ID] [project path] [output filename] [status]" << endl << - "-------------------------------------" << endl; - for(unsigned int i=0; i<m_projList.GetCount(); i++) - { +void Batch::ListBatch() +{ + if(m_projList.GetCount() == 0) + cout << "Batch is empty." << endl; + else + { + cout << "List of projects in batch:" << endl << + "[ID] [project path] [output filename] [status]" << endl << + "-------------------------------------" << endl; + for(unsigned int i=0; i<m_projList.GetCount(); i++) + { cout << m_projList.Item(i).id << " " << (const char*)m_projList.Item(i).path.char_str() << " " << (const char*)m_projList.Item(i).prefix.char_str() - << " " << (const char*)m_projList.Item(i).GetStatusText().char_str() << endl; - } - } -} - - + << " " << (const char*)m_projList.Item(i).GetStatusText().char_str() << endl; + } + } +} + + int Batch::LoadBatchFile(wxString file) { int clearCode = ClearBatch(); @@ -399,38 +399,38 @@ int Batch::LoadTemp() { - wxDir* workingDir = new wxDir(wxStandardPaths::Get().GetUserConfigDir()); - wxString pending; - wxString fileTemp = _T(".ptbt*"); - wxString temp = _T(""); - //we check for existing temporary files - if(workingDir->GetFirst(&temp,fileTemp,wxDIR_FILES)) - { - //we find the last existing tempfile (there should be at most two, but we check for multiple just in case) - while(workingDir->GetNext(&pending)) - { + wxDir* workingDir = new wxDir(wxStandardPaths::Get().GetUserConfigDir()); + wxString pending; + wxString fileTemp = _T(".ptbt*"); + wxString temp = _T(""); + //we check for existing temporary files + if(workingDir->GetFirst(&temp,fileTemp,wxDIR_FILES)) + { + //we find the last existing tempfile (there should be at most two, but we check for multiple just in case) + while(workingDir->GetNext(&pending)) + { wxFileName tempFile(temp); wxFileName pendingFile(pending); wxDateTime* create1 = new wxDateTime(); wxDateTime* create2 = new wxDateTime(); if(tempFile.FileExists() && pendingFile.FileExists()) { - tempFile.GetTimes(NULL,NULL,create1); - pendingFile.GetTimes(NULL,NULL,create2); - if(create2->IsLaterThan(*create1)) - { - wxRemoveFile(temp); - temp=wxString(pending); - } - } - else - { - //wxMessageBox( _T("Error reading temporary file"),_T("Error!"),wxOK | wxICON_INFORMATION ); - return 1; - } - } - } - //we load the data from the temp file + tempFile.GetTimes(NULL,NULL,create1); + pendingFile.GetTimes(NULL,NULL,create2); + if(create2->IsLaterThan(*create1)) + { + wxRemoveFile(temp); + temp=wxString(pending); + } + } + else + { + //wxMessageBox( _T("Error reading temporary file"),_T("Error!"),wxOK | wxICON_INFORMATION ); + return 1; + } + } + } + //we load the data from the temp file AppendBatchFile(workingDir->GetName()+wxFileName::GetPathSeparator()+temp); if(verbose && !gui) cout << "Loaded temp file." << endl; @@ -521,10 +521,10 @@ } i++; #if defined __WXMSW__ - Sleep(200); - #else - sleep(200); - #endif + Sleep(200); + #else + sleep(200); + #endif } progress.Close(); } @@ -692,51 +692,51 @@ } -void Batch::RemoveProject(int id) -{ - int index; - if((index=GetIndex(id)) != -1) - { - RemoveProjectAtIndex(GetIndex(id)); - } - else if(gui) - wxMessageBox( _("Error removing, project with id ")+wxString::Format(_T("%d"),id)+_(" is not in list."),_("Error!"),wxOK | wxICON_INFORMATION ); - else if(verbose) - cout << "Error: Project with id " << id << " is not in list." << endl; -} -void Batch::RemoveProjectAtIndex(int selIndex) -{ +void Batch::RemoveProject(int id) +{ + int index; + if((index=GetIndex(id)) != -1) + { + RemoveProjectAtIndex(GetIndex(id)); + } + else if(gui) + wxMessageBox( _("Error removing, project with id ")+wxString::Format(_T("%d"),id)+_(" is not in list."),_("Error!"),wxOK | wxICON_INFORMATION ); + else if(verbose) + cout << "Error: Project with id " << id << " is not in list." << endl; +} +void Batch::RemoveProjectAtIndex(int selIndex) +{ //we delete only successful project files and no applications - if(deleteFiles - && m_projList.Item(selIndex).id>=0 - && m_projList.Item(selIndex).status==Project::FINISHED) - { - wxFileName file(m_projList.Item(selIndex).path); - if(file.FileExists()) - { - if(!wxRemoveFile(file.GetFullPath())) - { - if(gui) - wxMessageBox( _("Error: Could not delete project file ")+file.GetFullPath(),_("Error!"),wxOK | wxICON_INFORMATION ); - else if(verbose) - cout << "Error: Could not delete project file " << (const char*)file.GetFullPath().char_str() << endl; - } + if(deleteFiles + && m_projList.Item(selIndex).id>=0 + && m_projList.Item(selIndex).status==Project::FINISHED) + { + wxFileName file(m_projList.Item(selIndex).path); + if(file.FileExists()) + { + if(!wxRemoveFile(file.GetFullPath())) + { + if(gui) + wxMessageBox( _("Error: Could not delete project file ")+file.GetFullPath(),_("Error!"),wxOK | wxICON_INFORMATION ); + else if(verbose) + cout << "Error: Could not delete project file " << (const char*)file.GetFullPath().char_str() << endl; + } } } - m_projList.RemoveAt(selIndex); - if(m_projList.GetCount()==0) //reset the id generator on empty list - Project::idGenerator=1; + m_projList.RemoveAt(selIndex); + if(m_projList.GetCount()==0) //reset the id generator on empty list + Project::idGenerator=1; } - + void Batch::RunBatch() -{ - if(!gui && m_projList.GetCount() == 0) - cout << "Batch is empty." << endl; - else if(!m_running) - { - if(gui) - ((wxFrame*)GetParent())->SetStatusText(_("Running batch...")); - else +{ + if(!gui && m_projList.GetCount() == 0) + cout << "Batch is empty." << endl; + else if(!m_running) + { + if(gui) + ((wxFrame*)GetParent())->SetStatusText(_("Running batch...")); + else cout << "Running batch..." << endl; bool cancelRun = false; //check for missing project files @@ -880,7 +880,7 @@ void Batch::SaveTemp() { //wxMessageBox( _T("saving temp file"),_T(""),wxOK | wxICON_INFORMATION ); - wxDir* workingDir = new wxDir(wxStandardPaths::Get().GetUserConfigDir()); + wxDir* workingDir = new wxDir(wxStandardPaths::Get().GetUserConfigDir()); wxString fileTemp = _T(".ptbt*"); //we get the old temp file fileTemp = workingDir->FindFirst(workingDir->GetName(),fileTemp,wxDIR_FILES); @@ -899,14 +899,14 @@ wxRemoveFile(fileTemp); } - + void Batch::SetStatus(int index,Project::Status status) { - if((unsigned int)index<m_projList.GetCount()) - m_projList.Item(index).status = status; - else if(gui) - wxMessageBox( _("Error: Could not set status, project with index ")+wxString::Format(_("%d"),index)+_(" is not in list."),_("Error!"),wxOK | wxICON_INFORMATION ); - else if(verbose) + if((unsigned int)index<m_projList.GetCount()) + m_projList.Item(index).status = status; + else if(gui) + wxMessageBox( _("Error: Could not set status, project with index ")+wxString::Format(_("%d"),index)+_(" is not in list."),_("Error!"),wxOK | wxICON_INFORMATION ); + else if(verbose) cout << "Error: Could not set status, project with index " << index << " is not in list." << endl; } void Batch::SwapProject(int index) Modified: hugin/trunk/src/PTBatcher/Batch.h =================================================================== --- hugin/trunk/src/PTBatcher/Batch.h 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/src/PTBatcher/Batch.h 2009-02-20 08:11:48 UTC (rev 3657) @@ -22,63 +22,63 @@ * License along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - */ - -#ifndef BATCH_H -#define BATCH_H - -#include <string> -#include "ProjectArray.h" -#include <wx/dir.h> -#ifndef __WXMSW__ + */ + +#ifndef BATCH_H +#define BATCH_H + +#include <string> +#include "ProjectArray.h" +#include <wx/dir.h> +#ifndef __WXMSW__ #include <sys/wait.h> #endif -//#include <wx/wfstream.h> -//#include <wx/event.h> -#include "RunStitchFrame.h" -//#include <hugin_config.h> - -#ifndef FRAMEARRAY -#define FRAMEARRAY - WX_DEFINE_ARRAY_PTR(RunStitchFrame*,FrameArray); -#endif - -using namespace std; - -class Batch : public wxFrame -{ -public: - bool parallel; - bool deleteFiles; - bool shutdown; - bool overwrite; - bool verbose; - bool gui; - - //Main constructor - Batch(wxFrame* parent, wxString path, bool bgui); - - //Adds an application entry in the batch list - void AddAppToBatch(wxString app); - //Adds a project entry in the batch list - void AddProjectToBatch(wxString projectFile, wxString outputFile = _T("")); - //Returns true if there are no more projects pending execution - bool AllDone(); - //Appends projects from file to batch list - void AppendBatchFile(wxString file); - //Stops batch run, failing projects in progress - void CancelBatch(); - //Cancels project at index in batch, failing it - void CancelProject(int index); - //Changes output prefix for project at index - void ChangePrefix(int index, wxString newPrefix); - //Called internally in console mode. Waits for running projects to complete and then runs next in batch - bool CheckProjectExistence(); - //Clears batch list and returns 0 if succesful - int ClearBatch(); - //Compares two project at indexes in both lists and returns true if they have identical project ids - bool CompareProjectsInLists(int stitchListIndex, int batchListIndex); - //Returns index of first waiting project in batch +//#include <wx/wfstream.h> +//#include <wx/event.h> +#include "RunStitchFrame.h" +//#include <hugin_config.h> + +#ifndef FRAMEARRAY +#define FRAMEARRAY + WX_DEFINE_ARRAY_PTR(RunStitchFrame*,FrameArray); +#endif + +using namespace std; + +class Batch : public wxFrame +{ +public: + bool parallel; + bool deleteFiles; + bool shutdown; + bool overwrite; + bool verbose; + bool gui; + + //Main constructor + Batch(wxFrame* parent, wxString path, bool bgui); + + //Adds an application entry in the batch list + void AddAppToBatch(wxString app); + //Adds a project entry in the batch list + void AddProjectToBatch(wxString projectFile, wxString outputFile = _T("")); + //Returns true if there are no more projects pending execution + bool AllDone(); + //Appends projects from file to batch list + void AppendBatchFile(wxString file); + //Stops batch run, failing projects in progress + void CancelBatch(); + //Cancels project at index in batch, failing it + void CancelProject(int index); + //Changes output prefix for project at index + void ChangePrefix(int index, wxString newPrefix); + //Called internally in console mode. Waits for running projects to complete and then runs next in batch + bool CheckProjectExistence(); + //Clears batch list and returns 0 if succesful + int ClearBatch(); + //Compares two project at indexes in both lists and returns true if they have identical project ids + bool CompareProjectsInLists(int stitchListIndex, int batchListIndex); + //Returns index of first waiting project in batch int GetFirstAvailable(); //Returns index of project with selected id int GetIndex(int id); @@ -89,61 +89,61 @@ //Returns number of projects in batch list with the input file path int GetProjectCountByPath(wxString path); //Returns number of projects currently in progress - int GetRunningCount(); - //Returns current status of project at index - Project::Status GetStatus(int index); - //Returns true if batch execution is currently paused - bool IsPaused(); - //Used in console mode. Prints out all projects and their statuses to the console - void ListBatch(); - //Clears current batch list and loads projects from batch file - int LoadBatchFile(wxString file); - //Loads temporary batch file - int LoadTemp(); - //Returns true if there are no failed projects in batch - bool NoErrors(); - //Called internally when all running processes have completed and need to be removed from running list - void OnProcessTerminate(wxProcessEvent & event); - //Called to start stitch of project with input scriptFile - bool OnStitch(wxString scriptFile, wxString outname, int id); - //Pauses and continues batch execution - void PauseBatch(); - //Removes project with id from batch list - void RemoveProject(int id); - //Removes project at index from batch list - void RemoveProjectAtIndex(int selIndex); - //Starts batch execution - void RunBatch(); - //Starts execution of next waiting project in batch - void RunNextInBatch(); - //Saves batch list to file - void SaveBatchFile(wxString file); - //Saves batch list to temporary file - void SaveTemp(); - //Used internally to set status of selected project - void SetStatus(int index,Project::Status status); - //Swaps position in batch of project at index with project at index+1 - void SwapProject(int index); - -private: - //environment config objects - wxConfigBase* m_config; - wxLocale m_locale; - //internal list of projects in batch - ProjectArray m_projList; - //list of projects in progress - FrameArray m_stitchFrames; + int GetRunningCount(); + //Returns current status of project at index + Project::Status GetStatus(int index); + //Returns true if batch execution is currently paused + bool IsPaused(); + //Used in console mode. Prints out all projects and their statuses to the console + void ListBatch(); + //Clears current batch list and loads projects from batch file + int LoadBatchFile(wxString file); + //Loads temporary batch file + int LoadTemp(); + //Returns true if there are no failed projects in batch + bool NoErrors(); + //Called internally when all running processes have completed and need to be removed from running list + void OnProcessTerminate(wxProcessEvent & event); + //Called to start stitch of project with input scriptFile + bool OnStitch(wxString scriptFile, wxString outname, int id); + //Pauses and continues batch execution + void PauseBatch(); + //Removes project with id from batch list + void RemoveProject(int id); + //Removes project at index from batch list + void RemoveProjectAtIndex(int selIndex); + //Starts batch execution + void RunBatch(); + //Starts execution of next waiting project in batch + void RunNextInBatch(); + //Saves batch list to file + void SaveBatchFile(wxString file); + //Saves batch list to temporary file + void SaveTemp(); + //Used internally to set status of selected project + void SetStatus(int index,Project::Status status); + //Swaps position in batch of project at index with project at index+1 + void SwapProject(int index); + +private: + //environment config objects + wxConfigBase* m_config; + wxLocale m_locale; + //internal list of projects in batch + ProjectArray m_projList; + //list of projects in progress + FrameArray m_stitchFrames; //batch state flags bool m_cancelled; - bool m_paused; - bool m_running; - bool m_clearedInProgress; - - //external program config - PTPrograms progs; - - DECLARE_EVENT_TABLE() -}; - -#endif //BATCH_H + bool m_paused; + bool m_running; + bool m_clearedInProgress; + + //external program config + PTPrograms progs; + + DECLARE_EVENT_TABLE() +}; + +#endif //BATCH_H Modified: hugin/trunk/src/PTBatcher/PTBatcher.cpp =================================================================== --- hugin/trunk/src/PTBatcher/PTBatcher.cpp 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/src/PTBatcher/PTBatcher.cpp 2009-02-20 08:11:48 UTC (rev 3657) @@ -1,251 +1,251 @@ -// -*- c-basic-offset: 4 -*- - -/** @file PTBatcher.cpp - * - * @brief Batch processor for Hugin - * - * @author Marko Kuder <mar...@gm...> - * - * $Id: PTBatcher.cpp 3322 2008-08-18 1:10:07Z mkuder $ - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include <string> - -#if (!defined __APPLE__) - #include "getopt.h" -#endif - -#ifdef WIN32 - #include <getopt.h> -#else - #include <unistd.h> -#endif - -#include "PTBatcher.h" - -using namespace std; - -//Prints out help text -void usage() -{ - cout << "PTBatcher: panotools batch stitcher" << endl - << endl - << "Usage: PTBatcher [options] input.pto output" << endl - << "Options:" << endl - << " -a file add project to queue. Unless -o option is present, the default prefix is appointed." << endl - << " -o output prefix (together with -a option)" << endl - << " -l list all projects in batch queue" << endl - << " -c clear all projects from batch queue" << endl - << " -x id remove project with specified id" << endl - << " -r reset all projects to waiting status" << endl - << " -b start batch process" << endl - << " -p use parallel processing (together with -b option)" << endl - << " -d delete .pto files when complete (together with -b option)" << endl - << " -s shutdown computer when complete (together with -b option)" << endl - << " -v verbose mode" << endl - << " -h print this help" << endl - << "Arguments:" << endl - << " input.pto Path to project file." << endl - << endl; -} - -#ifdef __WXMSW__ //windows version needs int main to enable console (and an OnInit function definition) -bool HostApp::OnInit(){return true;}; - -int main(int argc, char *argv[]) -#else //linux version needs main as OnInit for wxWidgets to work -bool HostApp::OnInit() -#endif -{ - //a character that defines the type of options - //encountered, so only logical combinations are used - char type = 'n'; - - bool optionError = false; - bool prefix = false; - - //create application and batch objects - #ifdef __WXMSW__ //windows version needs to create a wxApp object - HostApp app; - app.InitBatch(wxString::FromAscii(argv[0])); - Batch* batch = app.batch; - char** newArgv = argv; - #else //linux version needs to convert argv - InitBatch(argv[0]); - - char** newArgv = (char**)malloc(sizeof(char*)*argc); - for(int i=0; i<argc; i++) { - newArgv[i]= (char*)malloc(sizeof(char)*wxString(argv[i]).Length()); - strcpy(newArgv[i],wxString(argv[i]).char_str()); - } - #endif - //parse arguments - const char * optstring = "haolxrbpdsvc"; - char c; - while ((c = getopt (argc, newArgv, optstring)) != -1) - { - switch(c) { - case 'a': - if(type != 'n' && type != 'a') - optionError = true; - type = 'a'; break; - case 'l': - if(type != 'n' && type != 'l') - optionError = true; - type = 'l'; break; - case 'c': - if(type != 'n' && type != 'c') - optionError = true; - type = 'c'; break; - case 'x': - if(type != 'n' && type != 'x') - optionError = true; - type = 'x'; break; - case 'r': - if(type != 'n' && type != 'r') - optionError = true; - type = 'r'; break; - case 'b': - if(type != 'n' && type != 'b') - optionError = true; - type = 'b'; break; - case 'o': - prefix = true; break; - case 'p': - batch->parallel = true; break; - case 'd': - batch->deleteFiles = true; break; - case 's': - batch->shutdown = true; break; - case 'v': - batch->verbose = true; break; - case 'h': - usage(); return 0; - default: - usage(); return 0; - } - } - - //check for other errors in option definition - if(optionError || type == 'n' || - (type == 'a' && (batch->parallel || batch->deleteFiles || batch->shutdown)) || - (type == 'l' && (prefix || batch->parallel || batch->deleteFiles || batch->shutdown)) || - (type == 'c' && (prefix || batch->parallel || batch->deleteFiles || batch->shutdown)) || - (type == 'x' && (prefix || batch->parallel || batch->deleteFiles || batch->shutdown)) || - (type == 'r' && (prefix || batch->parallel || batch->deleteFiles || batch->shutdown)) || - (type == 'b' && prefix)) - { - usage(); - //this->OnExit(); - return 1; - } - string input = ""; - string output = ""; - if(type == 'a') - { - if(prefix && (optind+2 == argc)) - { - input = newArgv[optind]; - output = newArgv[optind+1]; - } - else if(!prefix && (optind+1 == argc)) - { - input = newArgv[optind]; - } - else - { - usage(); - return 1; - } - batch->LoadTemp(); - batch->AddProjectToBatch(wxString::FromAscii(input.c_str()),wxString::FromAscii(output.c_str())); - if(output == "") - cout << "Added project " << input << " with output " << output << endl; - else - cout << "Added project " << input << endl; - batch->SaveTemp(); - } - else if(type == 'l') - { - if(optind!=argc) - { - usage(); - return 1; - } - batch->LoadTemp(); - batch->ListBatch(); - //this->OnExit(); - return 0; - } - else if(type == 'c') - { - if(optind!=argc) - { - usage(); - return 1; - } - batch->LoadTemp(); - batch->ClearBatch(); - batch->SaveTemp(); - return 0; - } - else if(type == 'x') - { - if(optind+1==argc && atoi(newArgv[optind])!=0) - { - batch->LoadTemp(); - batch->RemoveProject(atoi(newArgv[optind])); - batch->SaveTemp(); - return 0; - } - else - { - usage(); - return 1; - } - } - else if(type == 'r') - { - if(optind!=argc) - { - usage(); - return 1; - } - batch->LoadTemp(); - for(int i=0; i<batch->GetProjectCount(); i++) - batch->SetStatus(i,Project::WAITING); - batch->SaveTemp(); - return 0; - } - else if(type == 'b') - { - batch->LoadTemp(); - batch->RunBatch(); - while(!batch->AllDone()) //wait for all projects to complete to save temp - { - #if defined __WXMSW__ - wxSleep(1); - #else - sleep(1000); - #endif - } - batch->SaveTemp(); - } - //this->OnExit(); - return EXIT_SUCCESS; -} +// -*- c-basic-offset: 4 -*- + +/** @file PTBatcher.cpp + * + * @brief Batch processor for Hugin + * + * @author Marko Kuder <mar...@gm...> + * + * $Id: PTBatcher.cpp 3322 2008-08-18 1:10:07Z mkuder $ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <string> + +#if (!defined __APPLE__) + #include "getopt.h" +#endif + +#ifdef WIN32 + #include <getopt.h> +#else + #include <unistd.h> +#endif + +#include "PTBatcher.h" + +using namespace std; + +//Prints out help text +void usage() +{ + cout << "PTBatcher: panotools batch stitcher" << endl + << endl + << "Usage: PTBatcher [options] input.pto output" << endl + << "Options:" << endl + << " -a file add project to queue. Unless -o option is present, the default prefix is appointed." << endl + << " -o output prefix (together with -a option)" << endl + << " -l list all projects in batch queue" << endl + << " -c clear all projects from batch queue" << endl + << " -x id remove project with specified id" << endl + << " -r reset all projects to waiting status" << endl + << " -b start batch process" << endl + << " -p use parallel processing (together with -b option)" << endl + << " -d delete .pto files when complete (together with -b option)" << endl + << " -s shutdown computer when complete (together with -b option)" << endl + << " -v verbose mode" << endl + << " -h print this help" << endl + << "Arguments:" << endl + << " input.pto Path to project file." << endl + << endl; +} + +#ifdef __WXMSW__ //windows version needs int main to enable console (and an OnInit function definition) +bool HostApp::OnInit(){return true;}; + +int main(int argc, char *argv[]) +#else //linux version needs main as OnInit for wxWidgets to work +bool HostApp::OnInit() +#endif +{ + //a character that defines the type of options + //encountered, so only logical combinations are used + char type = 'n'; + + bool optionError = false; + bool prefix = false; + + //create application and batch objects + #ifdef __WXMSW__ //windows version needs to create a wxApp object + HostApp app; + app.InitBatch(wxString::FromAscii(argv[0])); + Batch* batch = app.batch; + char** newArgv = argv; + #else //linux version needs to convert argv + InitBatch(argv[0]); + + char** newArgv = (char**)malloc(sizeof(char*)*argc); + for(int i=0; i<argc; i++) { + newArgv[i]= (char*)malloc(sizeof(char)*wxString(argv[i]).Length()); + strcpy(newArgv[i],wxString(argv[i]).char_str()); + } + #endif + //parse arguments + const char * optstring = "haolxrbpdsvc"; + char c; + while ((c = getopt (argc, newArgv, optstring)) != -1) + { + switch(c) { + case 'a': + if(type != 'n' && type != 'a') + optionError = true; + type = 'a'; break; + case 'l': + if(type != 'n' && type != 'l') + optionError = true; + type = 'l'; break; + case 'c': + if(type != 'n' && type != 'c') + optionError = true; + type = 'c'; break; + case 'x': + if(type != 'n' && type != 'x') + optionError = true; + type = 'x'; break; + case 'r': + if(type != 'n' && type != 'r') + optionError = true; + type = 'r'; break; + case 'b': + if(type != 'n' && type != 'b') + optionError = true; + type = 'b'; break; + case 'o': + prefix = true; break; + case 'p': + batch->parallel = true; break; + case 'd': + batch->deleteFiles = true; break; + case 's': + batch->shutdown = true; break; + case 'v': + batch->verbose = true; break; + case 'h': + usage(); return 0; + default: + usage(); return 0; + } + } + + //check for other errors in option definition + if(optionError || type == 'n' || + (type == 'a' && (batch->parallel || batch->deleteFiles || batch->shutdown)) || + (type == 'l' && (prefix || batch->parallel || batch->deleteFiles || batch->shutdown)) || + (type == 'c' && (prefix || batch->parallel || batch->deleteFiles || batch->shutdown)) || + (type == 'x' && (prefix || batch->parallel || batch->deleteFiles || batch->shutdown)) || + (type == 'r' && (prefix || batch->parallel || batch->deleteFiles || batch->shutdown)) || + (type == 'b' && prefix)) + { + usage(); + //this->OnExit(); + return 1; + } + string input = ""; + string output = ""; + if(type == 'a') + { + if(prefix && (optind+2 == argc)) + { + input = newArgv[optind]; + output = newArgv[optind+1]; + } + else if(!prefix && (optind+1 == argc)) + { + input = newArgv[optind]; + } + else + { + usage(); + return 1; + } + batch->LoadTemp(); + batch->AddProjectToBatch(wxString::FromAscii(input.c_str()),wxString::FromAscii(output.c_str())); + if(output == "") + cout << "Added project " << input << " with output " << output << endl; + else + cout << "Added project " << input << endl; + batch->SaveTemp(); + } + else if(type == 'l') + { + if(optind!=argc) + { + usage(); + return 1; + } + batch->LoadTemp(); + batch->ListBatch(); + //this->OnExit(); + return 0; + } + else if(type == 'c') + { + if(optind!=argc) + { + usage(); + return 1; + } + batch->LoadTemp(); + batch->ClearBatch(); + batch->SaveTemp(); + return 0; + } + else if(type == 'x') + { + if(optind+1==argc && atoi(newArgv[optind])!=0) + { + batch->LoadTemp(); + batch->RemoveProject(atoi(newArgv[optind])); + batch->SaveTemp(); + return 0; + } + else + { + usage(); + return 1; + } + } + else if(type == 'r') + { + if(optind!=argc) + { + usage(); + return 1; + } + batch->LoadTemp(); + for(int i=0; i<batch->GetProjectCount(); i++) + batch->SetStatus(i,Project::WAITING); + batch->SaveTemp(); + return 0; + } + else if(type == 'b') + { + batch->LoadTemp(); + batch->RunBatch(); + while(!batch->AllDone()) //wait for all projects to complete to save temp + { + #if defined __WXMSW__ + wxSleep(1); + #else + sleep(1000); + #endif + } + batch->SaveTemp(); + } + //this->OnExit(); + return EXIT_SUCCESS; +} Modified: hugin/trunk/src/PTBatcher/PTBatcher.h =================================================================== --- hugin/trunk/src/PTBatcher/PTBatcher.h 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/src/PTBatcher/PTBatcher.h 2009-02-20 08:11:48 UTC (rev 3657) @@ -22,22 +22,22 @@ * License along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - */ - -#include "Batch.h" - -//Host application needed to use wxWidgets frame objects in console -class HostApp : public wxApp -{ -public: - //Pseudo constructor - virtual bool OnInit(); - - //Initializes batch object - void InitBatch(wxString path){ - batch = new Batch(NULL,path,false); - }; - Batch* batch; -}; - -IMPLEMENT_APP(HostApp) + */ + +#include "Batch.h" + +//Host application needed to use wxWidgets frame objects in console +class HostApp : public wxApp +{ +public: + //Pseudo constructor + virtual bool OnInit(); + + //Initializes batch object + void InitBatch(wxString path){ + batch = new Batch(NULL,path,false); + }; + Batch* batch; +}; + +IMPLEMENT_APP(HostApp) Modified: hugin/trunk/src/PTBatcher/ProjectArray.cpp =================================================================== --- hugin/trunk/src/PTBatcher/ProjectArray.cpp 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/src/PTBatcher/ProjectArray.cpp 2009-02-20 08:11:48 UTC (rev 3657) @@ -95,7 +95,7 @@ pano.setMemento(newPano); if (ptoVersion < 2) { HuginBase::PanoramaOptions opts = pano.getOptions(); - //needed to access config data + //needed to access config data wxConfig* config = new wxConfig(wxT("hugin")); wxConfigBase::Set(config); // no options stored in file, use default arguments in config Modified: hugin/trunk/src/PTBatcherGUI/BatchFrame.cpp =================================================================== --- hugin/trunk/src/PTBatcherGUI/BatchFrame.cpp 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/src/PTBatcherGUI/BatchFrame.cpp 2009-02-20 08:11:48 UTC (rev 3657) @@ -243,84 +243,84 @@ projListBox->Fill(m_batch); } -void *BatchFrame::Entry() -{ - - //we define the working dir to search in and the file name syntax of the spool files - //wxMessageBox( _T("new file received1"),_T("new file received1"),wxOK | wxICON_INFORMATION ); - wxDir* workingDir = new wxDir(wxStandardPaths::Get().GetUserConfigDir()); - wxString fileSent = _T(".ptbs*"); - wxString pending; - /*wxString fileTemp = _T(".ptbt*"); - wxString temp = _T(""); - //we check for existing temporary files - if(workingDir->GetFirst(&temp,fileTemp,wxDIR_FILES)) - { - //we find the last existing tempfile (there should be at most two, but we check for multiple just in case) - while(workingDir->GetNext(&pending)) - { +void *BatchFrame::Entry() +{ + + //we define the working dir to search in and the file name syntax of the spool files + //wxMessageBox( _T("new file received1"),_T("new file received1"),wxOK | wxICON_INFORMATION ); + wxDir* workingDir = new wxDir(wxStandardPaths::Get().GetUserConfigDir()); + wxString fileSent = _T(".ptbs*"); + wxString pending; + /*wxString fileTemp = _T(".ptbt*"); + wxString temp = _T(""); + //we check for existing temporary files + if(workingDir->GetFirst(&temp,fileTemp,wxDIR_FILES)) + { + //we find the last existing tempfile (there should be at most two, but we check for multiple just in case) + while(workingDir->GetNext(&pending)) + { wxFileName tempFile(temp); wxFileName pendingFile(pending); wxDateTime* create1 = new wxDateTime(); wxDateTime* create2 = new wxDateTime(); if(tempFile.FileExists() && pendingFile.FileExists()) { - tempFile.GetTimes(NULL,NULL,create1); - pendingFile.GetTimes(NULL,NULL,create2); - if(create2->IsLaterThan(*create1)) - { - wxRemoveFile(temp); - temp=wxString(pending); - } - } - else - { - wxMessageBox( _T("Error reading temporary file"),_T("Error!"),wxOK | wxICON_INFORMATION ); - } - } - } - - //we load the data from the temp file - wxGetApp().AppendBatchFile(workingDir->GetName()+wxFileName::GetPathSeparator()+temp);*/ - - bool change = false; - int projectCount = m_batch->GetProjectCount(); - //we constantly poll the working dir for new files and wait a bit on each loop - while(!m_closeThread) - { - //wxMessageBox( _T("test"),_T("Error!"),wxOK | wxICON_INFORMATION ); - pending = workingDir->FindFirst(workingDir->GetName(),fileSent,wxDIR_FILES); - //wxMessageBox( _T("test1"),_T("Error!"),wxOK | wxICON_INFORMATION ); - if(!pending.IsEmpty()) - { - wxString projectPending = _T(""); - //wxMessageBox( _T("new file received"),spoolFile,wxOK | wxICON_INFORMATION ); - wxFileInputStream* spoolFile = new wxFileInputStream(pending); - wxChar input = spoolFile->GetC(); - while(spoolFile->LastRead()!=0) - { - projectPending = projectPending + input; - input = spoolFile->GetC(); - } - m_batch->AddProjectToBatch(projectPending); - projListBox->AppendProject(m_batch->GetProject(m_batch->GetProjectCount()-1)); - change = true; - spoolFile->~wxFileInputStream(); - if(!wxRemoveFile(pending)) - wxMessageBox( _("Error: Could not remove temporary file"),_("Error!"),wxOK | wxICON_INFORMATION ); - - } - //wxMessageBox( _T("test2"),_T("Error!"),wxOK | wxICON_INFORMATION ); - wxFileName* tempFile; - //wxMessageBox( _T("test3"),_T("Error!"),wxOK | wxICON_INFORMATION ); - //check all projects in list for changes - //wxString message = wxString(); - //message = message << wxGetApp().m_projList.GetCount(); - //wxMessageBox( message,_T("Error!"),wxOK | wxICON_INFORMATION ); - for(int i = 0; i< m_batch->GetProjectCount(); i++) - { - if(m_batch->GetProject(i)->id >= 0) - { + tempFile.GetTimes(NULL,NULL,create1); + pendingFile.GetTimes(NULL,NULL,create2); + if(create2->IsLaterThan(*create1)) + { + wxRemoveFile(temp); + temp=wxString(pending); + } + } + else + { + wxMessageBox( _T("Error reading temporary file"),_T("Error!"),wxOK | wxICON_INFORMATION ); + } + } + } + + //we load the data from the temp file + wxGetApp().AppendBatchFile(workingDir->GetName()+wxFileName::GetPathSeparator()+temp);*/ + + bool change = false; + int projectCount = m_batch->GetProjectCount(); + //we constantly poll the working dir for new files and wait a bit on each loop + while(!m_closeThread) + { + //wxMessageBox( _T("test"),_T("Error!"),wxOK | wxICON_INFORMATION ); + pending = workingDir->FindFirst(workingDir->GetName(),fileSent,wxDIR_FILES); + //wxMessageBox( _T("test1"),_T("Error!"),wxOK | wxICON_INFORMATION ); + if(!pending.IsEmpty()) + { + wxString projectPending = _T(""); + //wxMessageBox( _T("new file received"),spoolFile,wxOK | wxICON_INFORMATION ); + wxFileInputStream* spoolFile = new wxFileInputStream(pending); + wxChar input = spoolFile->GetC(); + while(spoolFile->LastRead()!=0) + { + projectPending = projectPending + input; + input = spoolFile->GetC(); + } + m_batch->AddProjectToBatch(projectPending); + projListBox->AppendProject(m_batch->GetProject(m_batch->GetProjectCount()-1)); + change = true; + spoolFile->~wxFileInputStream(); + if(!wxRemoveFile(pending)) + wxMessageBox( _("Error: Could not remove temporary file"),_("Error!"),wxOK | wxICON_INFORMATION ); + + } + //wxMessageBox( _T("test2"),_T("Error!"),wxOK | wxICON_INFORMATION ); + wxFileName* tempFile; + //wxMessageBox( _T("test3"),_T("Error!"),wxOK | wxICON_INFORMATION ); + //check all projects in list for changes + //wxString message = wxString(); + //message = message << wxGetApp().m_projList.GetCount(); + //wxMessageBox( message,_T("Error!"),wxOK | wxICON_INFORMATION ); + for(int i = 0; i< m_batch->GetProjectCount(); i++) + { + if(m_batch->GetProject(i)->id >= 0) + { tempFile = new wxFileName(m_batch->GetProject(i)->path); if(tempFile->FileExists()) { @@ -354,31 +354,31 @@ m_batch->SetStatus(i,Project::MISSING); projListBox->SetMissing(projListBox->GetIndex(m_batch->GetProject(i)->id)); } - } - } - if(projListBox->UpdateStatus(i,m_batch->GetProject(i))) - change = true; - } - if(m_batch->GetProjectCount()!=projectCount) - { - projectCount = m_batch->GetProjectCount(); - change = true; - } - //if(tempFile!=NULL) - // free(tempFile); - if(change) - { - change = false; - m_batch->SaveTemp(); - } - - GetThread()->Sleep(1000); - //wxFile file; - //file.Create(workingDir->GetName()+wxFileName::GetPathSeparator()+_T("krneki.txt")); - //file.Close(); - } - //wxMessageBox(_T("Ending thread...")); - return 0; + } + } + if(projListBox->UpdateStatus(i,m_batch->GetProject(i))) + change = true; + } + if(m_batch->GetProjectCount()!=projectCount) + { + projectCount = m_batch->GetProjectCount(); + change = true; + } + //if(tempFile!=NULL) + // free(tempFile); + if(change) + { + change = false; + m_batch->SaveTemp(); + } + + GetThread()->Sleep(1000); + //wxFile file; + //file.Create(workingDir->GetName()+wxFileName::GetPathSeparator()+_T("krneki.txt")); + //file.Close(); + } + //wxMessageBox(_T("Ending thread...")); + return 0; } void BatchFrame::OnButtonAddCommand(wxCommandEvent &event) @@ -410,8 +410,8 @@ { wxConfig::Get()->Write(wxT("/BatchFrame/actualPath"), dlg.GetPath()); // remember for later //we traverse all subdirectories of chosen path - DirTraverser traverser; - wxDir dir(dlg.GetPath()); + DirTraverser traverser; + wxDir dir(dlg.GetPath()); dir.Traverse(traverser); wxArrayString projects = traverser.GetProjectFiles(); for(unsigned int i=0; i<projects.GetCount(); i++) @@ -441,7 +441,7 @@ for(unsigned int i=0; i<paths.GetCount(); i++) { wxFileName name(paths.Item(i)); - m_batch->AddProjectToBatch(paths.Item(i),name.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + name.GetName()); + m_batch->AddProjectToBatch(paths.Item(i),name.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + name.GetName()); SetStatusText(_("Added project ")+paths.Item(i)); projListBox->AppendProject(m_batch->GetProject(m_batch->GetProjectCount()-1)); } @@ -628,21 +628,21 @@ bool removeErrors=false; if(!m_batch->NoErrors()) { - wxMessageDialog message(this,_("There are failed projects in the list.\nRemove them also?"), _("Question"), + wxMessageDialog message(this,_("There are failed projects in the list.\nRemove them also?"), _("Question"), wxYES | wxNO | wxICON_INFORMATION ); if(message.ShowModal()==wxID_YES) removeErrors=true; } - for(int i=projListBox->GetItemCount()-1; i>=0; i--) - { - if(m_batch->GetStatus(i)==Project::FINISHED || - (removeErrors && m_batch->GetStatus(i)==Project::FAILED)) - { - projListBox->DeleteItem(i); - m_batch->RemoveProjectAtIndex(i); - } - - + for(int i=projListBox->GetItemCount()-1; i>=0; i--) + { + if(m_batch->GetStatus(i)==Project::FINISHED || + (removeErrors && m_batch->GetStatus(i)==Project::FAILED)) + { + projListBox->DeleteItem(i); + m_batch->RemoveProjectAtIndex(i); + } + + } @@ -708,7 +708,7 @@ } else { - for(int i=projListBox->GetItemCount()-1; i>=0; i--) + for(int i=projListBox->GetItemCount()-1; i>=0; i--) m_batch->SetStatus(i,Project::WAITING); } } @@ -972,7 +972,7 @@ wxShutdown(wxSHUTDOWN_POWEROFF); } i++; - GetThread()->Sleep(200); + GetThread()->Sleep(200); } progress.Close(); } Modified: hugin/trunk/src/PTBatcherGUI/BatchFrame.h =================================================================== --- hugin/trunk/src/PTBatcherGUI/BatchFrame.h 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/src/PTBatcherGUI/BatchFrame.h 2009-02-20 08:11:48 UTC (rev 3657) @@ -22,12 +22,12 @@ * License along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - */ - -#ifndef BATCHFRAME_H -#define BATCHFRAME_H - -#include "../PTBatcher/RunStitchFrame.h" + */ + +#ifndef BATCHFRAME_H +#define BATCHFRAME_H + +#include "../PTBatcher/RunStitchFrame.h" #include "../PTBatcher/Batch.h" #include "ProjectListBox.h" #include "DirTraverser.h" Modified: hugin/trunk/src/PTBatcherGUI/DirTraverser.h =================================================================== --- hugin/trunk/src/PTBatcherGUI/DirTraverser.h 2009-02-20 07:15:29 UTC (rev 3656) +++ hugin/trunk/src/PTBatcherGUI/DirTraverser.h 2009-02-20 08:11:48 UTC (rev 3657) @@ -22,42 +22,42 @@ * License along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - */ - -#include <wx/dir.h> -#include <wx/filename.h> -//#include <wx/msgdlg.h> - -class DirTraverser : public wxDirTraverser -{ -public: - DirTraverser():wxDirTraverser(){ } - - //Called when directory traverser evaluates a file - virtual wxDirTraverseResult OnFile(const wxString& file) - { - wxFileName fileName(file); - wxString ext = fileName.GetExt(); - //we add all project files to array + */ + +#include <wx/dir.h> +#include <wx/filename.h> +//#include <wx/msgdlg.h> + +class DirTraverser : public wxDirTraverser +{ +public: + DirTraverser():wxDirTraverser(){ } + + //Called when directory traverser evaluates a file + virtual wxDirTraverseResult OnFile(const wxString& file) + { + wxFileName fileName(file); + wxString ext = fileName.GetExt(); + //we add all project files to array if (ext.CmpNoCase(wxT("pto")) == 0 || ext.CmpNoCase(wxT("ptp")) == 0|| - ext.CmpNoCase(wxT("pts")) == 0|| ext.CmpNoCase(wxT("oto")) == 0) - projectFiles.Add(file); - - //TO-DO: include image file heuristics to detect potential projects - return wxDIR_CONTINUE; - } - - //Called when directory traverser evaluates a directory - virtual wxDirTraverseResult OnDir(const wxString& WXUNUSED(dir)) - { - return wxDIR_CONTINUE; - } - - //Returns an array with all project files found - wxArrayString GetProjectFiles() - { - return projectFiles; - } -private: - wxArrayString projectFiles; -}; + ext.CmpNoCase(wxT("pts")) == 0|| ext.CmpNoCase(wxT("oto")) == 0) + projectFiles.Add(file); + + //TO-DO: include image file heuristics to detect potential projects + return wxDIR_CONTINUE; + } + + //Called when directory traverser evaluates a directory + virtual wxDirTraverseResult OnDir(const wxString& WXUNUSED(dir)) + { + return wxDIR_CO... [truncated message content] |