ExportJobProcessingHandler.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <QRegExp>
  9. #include <AzCore/Casting/numeric_cast.h>
  10. #include <AzToolsFramework/Debug/TraceContext.h>
  11. #include <AzToolsFramework/UI/Logging/LogEntry.h>
  12. #include <AzFramework/StringFunc/StringFunc.h>
  13. #include <SceneAPI/SceneCore/Utilities/Reporting.h>
  14. #include <SceneAPI/SceneUI/Handlers/ProcessingHandlers/ExportJobProcessingHandler.h>
  15. namespace AZ
  16. {
  17. namespace SceneAPI
  18. {
  19. namespace SceneUI
  20. {
  21. ExportJobProcessingHandler::ExportJobProcessingHandler(Uuid traceTag, const AZStd::string& sourceAssetPath, QObject* parent)
  22. : ProcessingHandler(traceTag, parent)
  23. , m_sourceAssetPath(sourceAssetPath)
  24. {
  25. }
  26. void ExportJobProcessingHandler::BeginProcessing()
  27. {
  28. m_jobWatcher.reset(new JobWatcher(m_sourceAssetPath, m_traceTag));
  29. connect(m_jobWatcher.get(), &JobWatcher::JobProcessingComplete, this, &ExportJobProcessingHandler::OnJobProcessingComplete);
  30. connect(m_jobWatcher.get(), &JobWatcher::AllJobsComplete, this, &ExportJobProcessingHandler::OnAllJobsComplete);
  31. m_jobWatcher->StartMonitoring();
  32. emit StatusMessageUpdated("File processing...");
  33. }
  34. void ExportJobProcessingHandler::OnJobQueryFailed([[maybe_unused]] const char* message)
  35. {
  36. emit StatusMessageUpdated("Processing failed.");
  37. AZ_TracePrintf(Utilities::ErrorWindow, "%s", message);
  38. emit ProcessingComplete();
  39. }
  40. void ExportJobProcessingHandler::OnJobProcessingComplete(const AZStd::string& platform, [[maybe_unused]] AZ::u64 jobId, bool success, const AZStd::string& fullLogText)
  41. {
  42. AZ_TraceContext("Platform", platform);
  43. if (!fullLogText.empty())
  44. {
  45. bool parseResult = AzToolsFramework::Logging::LogEntry::ParseLog(fullLogText.c_str(), aznumeric_cast<AZ::u64>(fullLogText.length()),
  46. [this](const AzToolsFramework::Logging::LogEntry& entry)
  47. {
  48. emit AddLogEntry(entry);
  49. });
  50. if (!parseResult)
  51. {
  52. AZ_TracePrintf(Utilities::ErrorWindow, "Failed to parse log. See Asset Processor for more info.");
  53. }
  54. }
  55. if (success)
  56. {
  57. AZ_TracePrintf(Utilities::SuccessWindow, "Job #%i compiled successfully", jobId);
  58. }
  59. else
  60. {
  61. AZ_TracePrintf(Utilities::ErrorWindow, "Job #%i failed", jobId);
  62. }
  63. }
  64. void ExportJobProcessingHandler::OnAllJobsComplete()
  65. {
  66. emit StatusMessageUpdated("All jobs completed.");
  67. emit ProcessingComplete();
  68. }
  69. }
  70. }
  71. }
  72. #include <Handlers/ProcessingHandlers/moc_ExportJobProcessingHandler.cpp>