Skip to content

Commit 992c2ee

Browse files
committed
Working style callback
1 parent 8f0a56f commit 992c2ee

File tree

5 files changed

+147
-139
lines changed

5 files changed

+147
-139
lines changed

Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ unrealToNativeVectorStyle(const FCesiumVectorStyle& style) {
3232
style.PolygonStyle.Color.A},
3333
(CesiumVectorData::ColorMode)style.PolygonStyle.ColorMode,
3434
style.PolygonStyle.Fill,
35-
style.PolygonStyle.Stroke}};
35+
style.PolygonStyle.Outline}};
3636
}
3737
} // namespace
3838

@@ -63,8 +63,14 @@ UCesiumVectorDocumentRasterOverlay::CreateOverlay(
6363
callbackOpt = [Callback = this->StyleCallback](
6464
const CesiumUtility::IntrusivePointer<
6565
CesiumVectorData::VectorDocument>& doc,
66-
const CesiumVectorData::VectorNode* pNode) {
67-
return Callback.Execute(FCesiumVectorNode(doc, pNode)).toNative();
66+
const CesiumVectorData::VectorNode* pNode)
67+
-> std::optional<CesiumVectorData::VectorStyle> {
68+
FCesiumVectorStyle style;
69+
if (Callback.Execute(FCesiumVectorNode(doc, pNode), style)) {
70+
return style.toNative();
71+
}
72+
73+
return std::nullopt;
6874
};
6975
}
7076

Source/CesiumRuntime/Private/CesiumVectorStyle.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "CesiumVectorStyle.h"
22

3-
CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const {
3+
CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const {
44
return CesiumVectorData::VectorStyle{
55
CesiumVectorData::LineStyle{
66
CesiumVectorData::Color{
@@ -22,7 +22,8 @@ CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const {
2222
this->PolygonStyle.Outline}};
2323
}
2424

25-
FCesiumVectorStyle FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) {
25+
FCesiumVectorStyle
26+
FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) {
2627
return FCesiumVectorStyle{
2728
FCesiumVectorLineStyle{
2829
FColor(

Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ enum class ECesiumVectorDocumentRasterOverlaySource : uint8 {
4343
FromCesiumIon = 1
4444
};
4545

46-
DECLARE_DYNAMIC_DELEGATE_RetVal_OneParam(
47-
FCesiumVectorStyle,
46+
DECLARE_DYNAMIC_DELEGATE_RetVal_TwoParams(
47+
bool,
4848
FCesiumVectorDocumentRasterOverlayStyleCallback,
4949
FCesiumVectorNode,
50-
InNode);
50+
InNode,
51+
FCesiumVectorStyle&,
52+
OutStyle);
5153

5254
UCLASS(
5355
ClassGroup = Cesium,
@@ -116,10 +118,7 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay
116118
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
117119
FCesiumVectorStyle DefaultStyle;
118120

119-
UPROPERTY(
120-
EditAnywhere,
121-
BlueprintReadWrite,
122-
Category = "Cesium")
121+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
123122
FCesiumVectorDocumentRasterOverlayStyleCallback StyleCallback;
124123

125124
protected:
Lines changed: 128 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,140 @@
11
#pragma once
22

3+
#include "CesiumVectorData/VectorStyle.h"
34
#include "CoreMinimal.h"
45
#include "UObject/ObjectMacros.h"
5-
#include "CesiumVectorData/VectorStyle.h"
66

77
#include "CesiumVectorStyle.generated.h"
88

99
/**
1010
* The mode used to render polylines and strokes.
1111
*/
12-
UENUM(BlueprintType)
13-
enum class ECesiumVectorLineWidthMode : uint8 {
14-
/**
15-
* The line width represents the number of pixels the line will take up,
16-
* regardless of LOD.
17-
*/
18-
Pixels = 0,
19-
/**
20-
* The line width represents the physical size of the line in meters.
21-
*/
22-
Meters = 1
23-
};
24-
25-
/**
26-
* The mode used to interpret the color value provided in a style.
27-
*/
28-
UENUM(BlueprintType)
29-
enum class ECesiumVectorColorMode : uint8 {
30-
/**
31-
* The normal color mode. The color will be used directly.
32-
*/
33-
Normal = 0,
34-
/**
35-
* The color will be chosen randomly.
36-
*
37-
* The color randomization will be applied to each component, with the
38-
* resulting value between 0 and the specified color component value. Alpha is
39-
* always ignored. For example, if the color was 0xff000077 (only 0x77 in the
40-
* green component), the resulting randomized value could be 0xff000041, or
41-
* 0xff000076, but never 0xff0000aa.
42-
*/
43-
Random = 1
44-
};
45-
46-
/**
47-
* The style used to draw polylines and strokes.
48-
*/
49-
USTRUCT(BlueprintType)
50-
struct FCesiumVectorLineStyle {
51-
GENERATED_BODY()
52-
53-
/**
54-
* The color to be used.
55-
*/
56-
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
57-
FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f);
58-
/**
59-
* The color mode to be used.
60-
*/
61-
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
62-
ECesiumVectorColorMode ColorMode =
63-
ECesiumVectorColorMode::Normal;
64-
/**
65-
* The width of the line or stroke, with the unit specified by `WidthMode`.
66-
*/
67-
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium", meta = (ClampMin = "0"))
68-
double Width = 1.0;
69-
/**
70-
* The mode to use when interpreting `Width`.
71-
*/
72-
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
73-
ECesiumVectorLineWidthMode WidthMode =
74-
ECesiumVectorLineWidthMode::Pixels;
75-
};
76-
77-
/**
78-
* The style used to draw polygons.
79-
*/
80-
USTRUCT(BlueprintType)
81-
struct FCesiumVectorPolygonStyle {
82-
GENERATED_BODY()
83-
84-
/**
85-
* The color to be used.
86-
*/
87-
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
88-
FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f);
89-
/**
90-
* The color mode to be used.
91-
*/
92-
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
93-
ECesiumVectorColorMode ColorMode =
94-
ECesiumVectorColorMode::Normal;
95-
/**
96-
* Whether the polygon should be filled. The `ColorStyle` specified
97-
* here will be used for the fill color.
98-
*/
99-
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
100-
bool Fill = true;
101-
/**
102-
* Whether the polygon should be outlined. The `LineStyle` specified on
103-
* the same `FCesiumVectorDocumentRasterOverlayStyle` as this will be used for
104-
* the stroke color.
105-
*/
106-
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
107-
bool Outline = false;
108-
};
109-
110-
/**
111-
* Style information to use when drawing vector data.
112-
*/
113-
USTRUCT(BlueprintType)
114-
struct FCesiumVectorStyle {
115-
GENERATED_BODY()
116-
117-
/**
118-
* Styles to use when drawing polylines and stroking shapes.
119-
*/
120-
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
121-
FCesiumVectorLineStyle LineStyle;
122-
123-
/**
124-
* Styles to use when drawing polygons.
125-
*/
126-
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
127-
FCesiumVectorPolygonStyle PolygonStyle;
12+
UENUM(BlueprintType)
13+
enum class ECesiumVectorLineWidthMode : uint8 {
14+
/**
15+
* The line width represents the number of pixels the line will take up,
16+
* regardless of LOD.
17+
*/
18+
Pixels = 0,
19+
/**
20+
* The line width represents the physical size of the line in meters.
21+
*/
22+
Meters = 1
23+
};
24+
25+
/**
26+
* The mode used to interpret the color value provided in a style.
27+
*/
28+
UENUM(BlueprintType)
29+
enum class ECesiumVectorColorMode : uint8 {
30+
/**
31+
* The normal color mode. The color will be used directly.
32+
*/
33+
Normal = 0,
34+
/**
35+
* The color will be chosen randomly.
36+
*
37+
* The color randomization will be applied to each component, with the
38+
* resulting value between 0 and the specified color component value. Alpha is
39+
* always ignored. For example, if the color was 0xff000077 (only 0x77 in the
40+
* green component), the resulting randomized value could be 0xff000041, or
41+
* 0xff000076, but never 0xff0000aa.
42+
*/
43+
Random = 1
44+
};
45+
46+
/**
47+
* The style used to draw polylines and strokes.
48+
*/
49+
USTRUCT(BlueprintType)
50+
struct FCesiumVectorLineStyle {
51+
GENERATED_BODY()
52+
53+
/**
54+
* The color to be used.
55+
*/
56+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
57+
FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f);
58+
/**
59+
* The color mode to be used.
60+
*/
61+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
62+
ECesiumVectorColorMode ColorMode = ECesiumVectorColorMode::Normal;
63+
/**
64+
* The width of the line or stroke, with the unit specified by `WidthMode`.
65+
*/
66+
UPROPERTY(
67+
EditAnywhere,
68+
BlueprintReadWrite,
69+
Category = "Cesium",
70+
meta = (ClampMin = "0"))
71+
double Width = 1.0;
72+
/**
73+
* The mode to use when interpreting `Width`.
74+
*/
75+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
76+
ECesiumVectorLineWidthMode WidthMode = ECesiumVectorLineWidthMode::Pixels;
77+
};
78+
79+
/**
80+
* The style used to draw polygons.
81+
*/
82+
USTRUCT(BlueprintType)
83+
struct FCesiumVectorPolygonStyle {
84+
GENERATED_BODY()
85+
86+
/**
87+
* The color to be used.
88+
*/
89+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
90+
FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f);
91+
/**
92+
* The color mode to be used.
93+
*/
94+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
95+
ECesiumVectorColorMode ColorMode = ECesiumVectorColorMode::Normal;
96+
/**
97+
* Whether the polygon should be filled. The `ColorStyle` specified
98+
* here will be used for the fill color.
99+
*/
100+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
101+
bool Fill = true;
102+
/**
103+
* Whether the polygon should be outlined. The `LineStyle` specified on
104+
* the same `FCesiumVectorDocumentRasterOverlayStyle` as this will be used for
105+
* the stroke color.
106+
*/
107+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
108+
bool Outline = false;
109+
};
110+
111+
/**
112+
* Style information to use when drawing vector data.
113+
*/
114+
USTRUCT(BlueprintType)
115+
struct FCesiumVectorStyle {
116+
GENERATED_BODY()
117+
118+
/**
119+
* Styles to use when drawing polylines and stroking shapes.
120+
*/
121+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
122+
FCesiumVectorLineStyle LineStyle;
123+
124+
/**
125+
* Styles to use when drawing polygons.
126+
*/
127+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
128+
FCesiumVectorPolygonStyle PolygonStyle;
128129

129-
/**
130-
* Converts this Unreal representation into the Cesium Native equivalent.
131-
*/
132-
CesiumVectorData::VectorStyle toNative() const;
130+
/**
131+
* Converts this Unreal representation into the Cesium Native equivalent.
132+
*/
133+
CesiumVectorData::VectorStyle toNative() const;
133134

134-
/**
135-
* Creates this Unreal representation from the Cesium Native equivalent.
136-
*/
137-
static FCesiumVectorStyle fromNative(const CesiumVectorData::VectorStyle& style);
138-
};
135+
/**
136+
* Creates this Unreal representation from the Cesium Native equivalent.
137+
*/
138+
static FCesiumVectorStyle
139+
fromNative(const CesiumVectorData::VectorStyle& style);
140+
};

0 commit comments

Comments
 (0)