LoggingWindowSession.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #pragma once
  9. #include <AzCore/PlatformDef.h>
  10. // qbrush.h(118): warning C4251: 'QBrush::d': class 'QScopedPointer<QBrushData,QBrushDataPointerDeleter>' needs to have dll-interface to be used by clients of class 'QBrush'
  11. // qwidget.h(858): warning C4800: 'uint': forcing value to bool 'true' or 'false' (performance warning)
  12. AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option")
  13. #if !defined(Q_MOC_RUN)
  14. #include <QAbstractItemModel>
  15. #include <QIcon>
  16. #include <QSortFilterProxyModel>
  17. #include <QWidget>
  18. AZ_POP_DISABLE_WARNING
  19. #include <AzCore/Component/NamedEntityId.h>
  20. #include <AzCore/std/smart_ptr/unique_ptr.h>
  21. #include <GraphCanvas/Components/StyleBus.h>
  22. #include <GraphCanvas/Editor/AssetEditorBus.h>
  23. #include <GraphCanvas/Styling/StyleHelper.h>
  24. #include <GraphCanvas/Widgets/GraphCanvasTreeItem.h>
  25. #include <GraphCanvas/Widgets/GraphCanvasTreeModel.h>
  26. #include <Editor/View/Widgets/LoggingPanel/LoggingDataAggregator.h>
  27. #include <Editor/View/Widgets/LoggingPanel/LoggingWindowTreeItems.h>
  28. #include <ScriptCanvas/Core/Endpoint.h>
  29. #include <ScriptCanvas/Core/NodeBus.h>
  30. // Qt Generated
  31. // warning C4251: 'QLayoutItem::align': class 'QFlags<Qt::AlignmentFlag>' needs to have dll-interface to be used by clients of class 'QLayoutItem'
  32. AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option")
  33. #include <Editor/View/Widgets/LoggingPanel/ui_LoggingWindowSession.h>
  34. #endif
  35. AZ_POP_DISABLE_WARNING
  36. namespace ScriptCanvasEditor
  37. {
  38. class LoggingWindowFilterModel
  39. : public QSortFilterProxyModel
  40. {
  41. public:
  42. AZ_CLASS_ALLOCATOR(LoggingWindowFilterModel, AZ::SystemAllocator);
  43. LoggingWindowFilterModel() = default;
  44. bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
  45. void SetFilter(const QString& filter);
  46. void ClearFilter();
  47. bool HasFilter() const;
  48. private:
  49. QString m_filter;
  50. DebugLogFilter m_logFilter;
  51. };
  52. class LoggingWindowSession
  53. : public QWidget
  54. , public GraphCanvas::AssetEditorNotificationBus::Handler
  55. , public GraphCanvas::SceneNotificationBus::Handler
  56. {
  57. Q_OBJECT
  58. protected:
  59. LoggingWindowSession(QWidget* parentWidget = nullptr);
  60. public:
  61. ~LoggingWindowSession() override;
  62. const LoggingDataId& GetDataId() const;
  63. void ClearFilter();
  64. // GraphCanvas::AssetEditorNotificationBus
  65. void OnActiveGraphChanged(const AZ::EntityId& graphId) override;
  66. ////
  67. // GraphCanvas::SceneNotificationBus
  68. void OnSelectionChanged() override;
  69. ////
  70. protected:
  71. void RegisterTreeRoot(DebugLogRootItem* debugRoot);
  72. void SetDataId(const LoggingDataId& loggingDataId);
  73. virtual void OnCaptureButtonPressed() = 0;
  74. virtual void OnPlaybackButtonPressed() = 0;
  75. virtual void OnOptionsButtonPressed() = 0;
  76. virtual void OnTargetChanged(int currentIndex) = 0;
  77. void OnExpandAll();
  78. void OnCollapseAll();
  79. protected:
  80. AZStd::unique_ptr< Ui::LoggingWindowSession > m_ui;
  81. private:
  82. void OnSearchFilterChanged(const QString& filterString);
  83. void OnLogScrolled(int value);
  84. void OnLogItemExpanded(const QModelIndex& modelIndex);
  85. void OnLogRangeChanged(int min, int max);
  86. void OnLogClicked(const QModelIndex& modelIndex);
  87. void OnLogDoubleClicked(const QModelIndex& modelIndex);
  88. void OnLogSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
  89. ExecutionLogTreeItem* ResolveExecutionItem(const QModelIndex& proxyModelIndex);
  90. void HandleQueuedFocus();
  91. void FocusOnElement(const AZ::Data::AssetId& assetId, const AZ::EntityId& assetNodeId);
  92. void HighlightElement(const AZ::Data::AssetId& assetId, const AZ::EntityId& assetNodeId);
  93. void RemoveHighlight(const AZ::Data::AssetId& assetId, const AZ::EntityId& assetNodeId);
  94. void ScrollToSelection();
  95. void ClearLoggingSelection();
  96. bool m_clearSelectionOnSceneSelectionChange;
  97. bool m_scrollToBottom;
  98. LoggingDataId m_loggingDataId;
  99. DebugLogRootItem* m_debugRoot;
  100. GraphCanvas::GraphCanvasTreeModel* m_treeModel;
  101. LoggingWindowFilterModel* m_filterModel;
  102. AZStd::unordered_map< AZ::EntityId, GraphCanvas::GraphicsEffectId > m_highlightEffects;
  103. QTimer m_focusDelayTimer;
  104. AZ::Data::AssetId m_assetId;
  105. AZ::EntityId m_assetNodeId;
  106. };
  107. }