-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRadarChartWidget.h
More file actions
80 lines (72 loc) · 3.37 KB
/
RadarChartWidget.h
File metadata and controls
80 lines (72 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "RadarChartWidget.generated.h"
UCLASS()
class RADARCHARTPROJECT_API URadarChartWidget : public UUserWidget
{
GENERATED_BODY()
public:
virtual void PostLoad() override;
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif
UFUNCTION(BlueprintCallable)
void SetAxisValue(const FName& AxisName, float Value);
UFUNCTION(BlueprintCallable)
void StartFilledPolygonAnimation(const TMap<FName, float>& AxesDiff);
protected:
virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;
virtual int32 NativePaint(
const FPaintArgs& Args,
const FGeometry& AllottedGeometry,
const FSlateRect& MyCullingRect,
FSlateWindowElementList& OutDrawElements,
int32 LayerId,
const FWidgetStyle& InWidgetStyle,
bool bParentEnabled
) const override;
private:
void SyncEditorData();
void DrawWiredPolygon(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 LayerId, float Scale) const;
void DrawAxes(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 LayerId) const;
void DrawFilledPolygon(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle) const;
void DrawFilledPolygonOutline(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle) const;
void DrawRadarChart(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 LayerId) const;
float GetAxisValue(const FName& Axis) const;
private:
UPROPERTY(EditAnywhere, Category = "Appearance")
FSlateBrush Brush;
UPROPERTY(EditAnywhere, Category = "Appearance", meta = (ToolTip = "Filled polygon vertices brush"))
FSlateBrush DotBrush;
UPROPERTY(EditAnywhere, Category = "Chart")
bool bDrawFilledPolygon = true;
UPROPERTY(EditAnywhere, Category = "Chart",
meta = (ToolTip = "Draw marks with specified steps", EditCondition = "!bDrawFilledPolygon"))
bool bDrawValueMarks = true;
UPROPERTY(EditAnywhere, Category = "Chart",
meta = (EditCondition = "!bDrawFilledPolygon && bDrawValueMarks", ClampMin = "0.1", ClampMax = "0.5"))
float MarkingStep = 0.2f;
UPROPERTY(EditAnywhere, Category = "Chart")
int32 NumAxes = 5;
UPROPERTY(EditAnywhere, Category = "Chart", meta = (ToolTip = "Normalized values per axis [0..1]"))
TMap<FName, float> AxesValuesMap;
UPROPERTY(EditAnywhere, Category = "Chart")
FLinearColor OutlineColor = FLinearColor(0.f, 0.8f, 1.f, 1.f);
UPROPERTY(EditAnywhere, Category = "Chart")
FLinearColor FilledOutlineColor = FLinearColor(0.8f, 0.1f, 0.1f, 1.f);
UPROPERTY(EditAnywhere, Category = "Chart")
float OutlineThickness = 2.f;
UPROPERTY(EditAnywhere, Category = "Chart")
float AnimDuration = 3.f;
UPROPERTY()
TArray<FVector2f> AxisDirections;
UPROPERTY()
TArray<FName> AxesOrderFromTop;
// --- Filled polygon animation ---
TMap<FName, float> StartValuesMap;
TMap<FName, float> DiffValuesMap;
float AnimElapsed = 0.f;
bool bAnimating = false;
// --- --- ---
};