Files
UnrealEngineUWP/Engine/Source/Developer/LogVisualizer/Private/SLogVisualizer.h

324 lines
9.8 KiB
C
Raw Normal View History

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "STimeline.h"
#include "Debug/DebugDrawService.h"
class SLogFilterList;
struct FLogsListItem
{
FString Name;
float StartTimestamp;
float EndTimestamp;
float LastEndTimestamp;
int32 LogIndex;
FLogsListItem(const FString& InName, float InStart, float InEnd, int32 InLogIndex = INDEX_NONE)
: Name(InName), StartTimestamp(InStart), EndTimestamp(InEnd), LastEndTimestamp(0), LogIndex(InLogIndex)
{
}
bool operator==(const FLogsListItem& Other) const
{
return LogIndex == Other.LogIndex;
}
};
struct FLogEntryItem
{
FString Category;
FLinearColor CategoryColor;
ELogVerbosity::Type Verbosity;
FString Line;
int64 UserData;
FName TagName;
};
namespace ELogsSortMode
{
enum Type
{
ByName,
ByStartTime,
ByEndTime,
};
}
struct FLogStatusItem
{
FString ItemText;
FString ValueText;
TArray< TSharedPtr< FLogStatusItem > > Children;
FLogStatusItem(const FString& InItemText) : ItemText(InItemText) {}
FLogStatusItem(const FString& InItemText, const FString& InValueText) : ItemText(InItemText), ValueText(InValueText) {}
};
template <typename ItemType>
class SLogListView;
/** Main LogVisualizer UI widget */
class SLogVisualizer : public SCompoundWidget
{
#if ENABLE_VISUAL_LOG
public:
static const FName NAME_LogName;
static const FName NAME_StartTime;
static const FName NAME_EndTime;
static const FName NAME_LogTimeSpan;
/** Expressed in Hz */
static const int32 FullUpdateFrequency = 2;
DECLARE_MULTICAST_DELEGATE_TwoParams(FOnZoomChanged, float, float);
DECLARE_MULTICAST_DELEGATE_OneParam(FOnHistogramWindowChanged, float);
SLATE_BEGIN_ARGS(SLogVisualizer) {}
SLATE_END_ARGS()
void Construct(const FArguments& InArgs, FLogVisualizer* InAnalyzer);
virtual ~SLogVisualizer();
virtual void Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime ) override;
// overrides
virtual FReply OnMouseWheel( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent ) override;
virtual FReply OnKeyDown( const FGeometry& MyGeometry, const FKeyboardEvent& InKeyboardEvent) override;
// Get delegates
const FSlateBrush* GetRecordButtonBrush() const;
FString GetStatusText() const;
ESlateCheckBoxState::Type GetPauseState() const;
EColumnSortMode::Type GetLogsSortMode() const;
// Handler delegates
FReply OnRecordButtonClicked();
FReply OnLoad();
FReply OnSave();
FReply OnRemove();
void OnPauseChanged(ESlateCheckBoxState::Type NewState);
void FilterTextCommitted(const FText& CommentText, ETextCommit::Type CommitInfo);
void OnQuickFilterTextChanged(const FText& CommentText, ETextCommit::Type CommitInfo);
Asset View now supports secondary sorting #UDN: Feature suggestion; Content browser can sort by a second column #branch UE4 #change Added two new images for secondary sort ascending and descending. (Updated styles where needed). Added new enum EColumnSortPriority: currently only lists Primary and Secondary, but can easily accommodate more*. (FOnSortModeChanged was modified to also have the priority as a param, fixedup existing usage). SHeaderRow now also has a SortPriority attribute to specify the SortMode order (Defaults to Primary if unused). Modified TUniquePtr so that assigning one from another worked correctly. (Reviewed by Steve Robb). SAssetView is the only table that has been modified, so far, to take advantage of the secondary sort. SetMajorityAssetType has been updated to correctly filter out all those sorts which are no longer relevant and bump the priority of the remaining sorts to fill in the ægapsÆ made by non-longer-relevant ones. FAssetViewSortManager has been overhauled to take SortPriority into consideration when sortingà Firstly, duplicate comparison structs were removed in favour of single structs which have æascendingÆ as a paramà any remaining duplicate code was removed in favour of an inherited usage. The base struct has an array of æfurther methodsÆ to employ in the result of a tie. Should a tie occur the ænextÆ comparison is done, and so on until itÆs not a tie or we run out of comparisons to perform.* The manager defaults to having no secondary sort, so it relies on the interface thatÆs using it to provide it. Whenever a column is assign the code makes sure that itÆs not already assigned to another column and corrects the order to take this into account. Fixed a bug in FCompareFAssetItemByTagNumericalAscending comparing A with A (instead of B). Various optimizations to the sort to descrease times *The only places æSecondaryÆ is referred to in code is in GetSortingBrush (so it can display the correct icon for the sort), and OnTitleClicked (so it can set to correct sort based on input). The sorting code itself has no concept as to a secondary sort, it can support any number of sorting levels so if in future a tertiary (or more) is added, it is only these two function which should need updating as the sort will automatically accommodate it. reviewed by Thomas.Sarkanen, Bob.Tellez [CL 2119201 by Andrew Brown in Main branch]
2014-06-27 04:30:08 -04:00
void OnSortByChanged(const EColumnSortPriority::Type SortPriority, const FName& ColumnName, const EColumnSortMode::Type NewSortMode);
// Table delegates
TSharedRef<ITableRow> LogsListGenerateRow(TSharedPtr<FLogsListItem> InItem, const TSharedRef<STableViewBase>& OwnerTable);
void LogsListSelectionChanged(TSharedPtr<FLogsListItem> SelectedItem, ESelectInfo::Type SelectInfo);
TSharedRef<ITableRow> LogEntryLinesGenerateRow(TSharedPtr<FLogEntryItem> Item, const TSharedRef<STableViewBase>& OwnerTable);
void LogEntryLineSelectionChanged(TSharedPtr<FLogEntryItem> SelectedItem, ESelectInfo::Type SelectInfo);
FOnZoomChanged& OnZoomChanged() { return ZoomChangedNotify; }
FOnHistogramWindowChanged& OnHistogramWindowChanged() { return HistogramWindowChangedNotify; }
Merging using UE4-Fortnite-To-UE4 up to CL 2082758 Includes following engine CLs: CL 2080462: Added verbosity selection to category filters in Log Visualizer window CL 2081939: Fixed crash in Log Visualizer and missing entry on timeline with log containing only 2 entries. CL 2082118: Fixes and improovements for VisLogs - fixed logs visualization for logs with only one entry (Log Visualizer window) - fixed logs spam about missing json field (Log Visualizer window) - fixed crash with categories in Log Visualization window - added category and verbosity serialization for vislog shape elements (vlog files) CL 2080253: Added categories to VisLog shapes CL 2081762: Fixes to Log Visualizer. Logs without any log lines but with geometry elements are set on timeline properly. CL 2081859: Added double click to Log Visualizer action, to move editor camera to view current log location CL 2080159: Gameply Tag Pin now only allows single select #TTP 335383 - Editor: GameplayTag Pin should only allow a single selection #proj UE4 #change Removes all other tags from the correct container when in single select mode, was a missed variable change from a previous TTP CL 2081306: Made changes to navigation filters that allow for usage of virtual verstion dtQueryFilter #UE4 The scary part here is that having a dtQueryFilter contan a vftable was messing up FRecastQueryFilter's vftable it was getting from INavigationQueryFilterInterface. Reversing order of parent clas declaration of FRecastQueryFilter fixed the issue, but it's scary and looks like a compiler issue. [CL 2088758 by Billy Bramer in Main branch]
2014-05-29 17:46:51 -04:00
void OnListDoubleClick(TSharedPtr<FLogsListItem>);
void DoFullUpdate();
void DoTickUpdate();
void RequestFullUpdate() { TimeTillNextUpdate = 0; }
float GetZoom() const
{
return MinZoom + ZoomSliderValue * ( MaxZoom - MinZoom );
}
float GetScrollbarOffset() const { return ScrollbarOffset; }
TSharedPtr<STimeline> GetTimeline() { return Timeline; }
void SetCurrentViewedTime(float NewTime, const bool bForce = false);
void RequestShowLogEntry(TSharedPtr<FLogsListItem> Item, TSharedPtr<FVisualLogEntry> LogEntry);
void UpdateVisibleEntriesCache(const TSharedPtr<FActorsVisLog>& Log, int32 Index);
void GetVisibleEntries(const TSharedPtr<FActorsVisLog>& Log, TArray<TSharedPtr<FVisualLogEntry> >& OutEntries);
int32 GetCurrentVisibleLogEntryIndex(const TArray<TSharedPtr<FVisualLogEntry> >& InVisibleEntries);
protected:
void ShowLogEntry(TSharedPtr<FLogsListItem> Item, TSharedPtr<FVisualLogEntry> LogEntry);
void SelectionChanged(class AActor* DebuggedActor, bool bIsBeingDebuggedNow);
public:
/** Pointer to the visualizer object we want to show ui for */
FLogVisualizer* LogVisualizer;
/** Current way we are sorting logs */
ELogsSortMode::Type SortBy;
float LogsStartTime;
float LogsEndTime;
float GetCurrentViewedTime() const { return CurrentViewedTime; }
static FLinearColor GetColorForUsedCategory(int32 Index);
float GetHistogramPreviewWindow() { return HistogramPreviewWindow; }
protected:
float GetMaxScrollOffsetFraction() const
{
return 1.0f - 1.0f / GetZoom();
}
float GetMaxGraphOffset() const
{
return GetZoom() - 1.0f;
}
void DrawOnCanvas(UCanvas* Canvas, APlayerController*);
void LoadFiles(TArray<FString>& OpenFilenames);
void SaveSelectedLogs(FString& Filename);
private:
void InvalidateCanvas();
void UpdateStatusItems(const FVisualLogEntry* LogEntry);
TSharedRef<ITableRow> HandleGenerateLogStatus(TSharedPtr<FLogStatusItem> InItem, const TSharedRef<STableViewBase>& OwnerTable);
void OnLogStatusGetChildren(TSharedPtr<FLogStatusItem> InItem, TArray< TSharedPtr<FLogStatusItem> >& OutItems);
/** Construct main menu */
TSharedRef< SWidget > MakeMainMenu();
void FillHelpMenu(FMenuBuilder& MenuBuilder);
void OpenSavedSession(FMenuBuilder& MenuBuilder);
FString GetLogEntryStatusText() const;
void AddOrUpdateLog(int32 Index, const FActorsVisLog* Log);
void SelectActor(class AActor* SelectedActor);
void CameraActorSelected(class AActor* SelectedActor);
void IncrementCurrentLogIndex(int32 IncrementBy);
/** Called when a single log is added */
void OnLogAdded();
/** Regenerate logs list based on current filter */
void RebuildFilteredList();
/** Update filtering members from entry widgets */
void UpdateFilterInfo();
// zoom functionality
float GetZoomValue() const;
void OnSetZoomValue(float NewValue);
void OnZoomScrolled(float InScrollOffsetFraction);
void OnSetHistogramWindowValue(float NewValue);
/** handler for toggling DrawLogEntriesPath option change */
void OnDrawLogEntriesPathChanged(ESlateCheckBoxState::Type NewState);
/** retrieves whether DrawLogEntriesPath checkbox should be checked */
ESlateCheckBoxState::Type GetDrawLogEntriesPathState() const;
/** handler for toggling IgnoreTrivialLogs option change */
void OnIgnoreTrivialLogs(ESlateCheckBoxState::Type NewState);
/** retrieves whether IgnoreTrivialLogs checkbox should be checked */
ESlateCheckBoxState::Type GetIgnoreTrivialLogs() const;
void OnChangeHistogramLabelLocation(ESlateCheckBoxState::Type NewState);
ESlateCheckBoxState::Type GetHistogramLabelLocation() const;
void OnStickToLastData(ESlateCheckBoxState::Type NewState);
ESlateCheckBoxState::Type GetStickToLastData() const;
/** handler for toggling log visualizer camera in game view */
void OnToggleCamera(ESlateCheckBoxState::Type NewState);
/** retrieves whether ToggleCamera toggle button should appear pressed */
ESlateCheckBoxState::Type GetToggleCameraState() const;
void OnOffsetDataSets(ESlateCheckBoxState::Type NewState);
ESlateCheckBoxState::Type GetOffsetDataSets() const;
void OnHistogramGraphsFilter(ESlateCheckBoxState::Type NewState);
ESlateCheckBoxState::Type GetHistogramGraphsFilter() const;
/** See if a particular log passes the current filter and other display flags */
bool ShouldListLog(const TSharedPtr<FActorsVisLog>& Log);
void ShowEntry(const FVisualLogEntry* LogEntry);
int32 FindIndexInLogsList(const int32 LogIndex) const;
void OnLogCategoryFiltersChanged();
UWorld* GetWorld() const;
// MEMBERS
/** The filter list */
TSharedPtr<SLogFilterList> FilterListPtr;
/** Index into LogVisualizer->Logs array for entries you want to show. */
TArray<TSharedPtr<FLogsListItem> > LogsList;
/** filled with current log entry's log lines is a source of LogsLinesWidget */
TArray<TSharedPtr<FLogEntryItem> > LogEntryLines;
TArray<FString> UsedCategories;
TMap<FString, TArray<FString> > UsedGraphCategories;
/** Color palette for bars coloring */
static FColor ColorPalette[];
/** used to filter logs by name */
FString LogNameFilterString;
FString LastBrowsePath;
FString QuickFilterText;
/** index of currently viewed log */
int32 LogEntryIndex;
/** index of entry withing currently viewed log */
int32 SelectedLogIndex;
float TimeTillNextUpdate;
/** Zoom slider value */
float ZoomSliderValue;
float ScrollbarOffset;
float LastBarsOffset;
float CurrentViewedTime;
float MinZoom;
float MaxZoom;
FOnZoomChanged ZoomChangedNotify;
FOnHistogramWindowChanged HistogramWindowChangedNotify;
float HistogramPreviewWindow;
FDebugDrawDelegate DrawingOnCanvasDelegate;
bool bDrawLogEntriesPath;
bool bIgnoreTrivialLogs;
bool bShowHistogramLabelsOutside;
bool bStickToLastData;
bool bOffsetDataSet;
bool bHistogramGraphsFilter;
TWeakObjectPtr<class ALogVisualizerCameraController> CameraController;
TArray< TSharedPtr<FLogStatusItem> > StatusItems;
struct FCachedEntries
{
TSharedPtr<FActorsVisLog> Log;
TArray<TSharedPtr<FVisualLogEntry> > CachedEntries;
};
TArray<FCachedEntries> OutEntriesCached;
// WIDGETS
/** Main log list widget */
TSharedPtr<SLogListView<TSharedPtr<FLogsListItem> > > LogsListWidget;
TSharedPtr< STreeView< TSharedPtr<FLogStatusItem> > > StatusItemsView;
TSharedPtr<SEditableTextBox> LogNameFilterBox;
TSharedPtr<SEditableTextBox> QuickFilterBox;
TSharedPtr<STextBlock> StatusTextBlock;
TSharedPtr<SListView<TSharedPtr<FLogEntryItem> > > LogsLinesWidget;
TSharedPtr<STimeline> Timeline;
TSharedPtr<SScrollBar> ScrollBar;
TSharedPtr<SSlider> ZoomSlider;
#endif
};