Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ImguiSampleInspector.h
Go to the documentation of this file.
1#pragma once
2
3#include <Common/assertion.h>
4#include <Common/utility.h>
5#include <Utility/TSpan.h>
6
7#include <cstddef>
8#include <vector>
9#include <string>
10
11namespace ph::editor
12{
13
15{
16public:
18
19 void buildWindow(const char* title, bool* isOpening);
20
21private:
22 // Update `RNG_NAMES` if modified
23 enum ERng : int
24 {
25 MT_19937 = 0,
26 PCG_32,
27 PCG_64_DXSM
28 };
29
30 static constexpr const char* RNG_NAMES[] =
31 {
32 "Mersenne Twister",
33 "PCG-32",
34 "PCG-64-DXSM"
35 };
36
37 // Update `GENERATOR_NAMES` if modified
38 enum EGenerator : int
39 {
40 UniformRandom = 0,
41 Stratified,
42 Halton,
43 HaltonFixedScramble,
44 HaltonPerDigitScramble
45 };
46
47 static constexpr const char* GENERATOR_NAMES[] =
48 {
49 "Uniform Random",
50 "Stratified",
51 "Halton",
52 "Halton (Fixed Scramble)",
53 "Halton (Per-digit Scramble)"
54 };
55
56 enum ESource : int
57 {
58 Rng = 0,
59 Generator
60 };
61
62 struct ScatterPlotData
63 {
64 std::string name;
65 std::vector<float> xs;
66 std::vector<float> ys;
67
68 void clear();
69 void resize(std::size_t size);
70 void reserve(std::size_t size);
71 int getPointCount() const;
72 };
73
74 struct RngSettings
75 {
76 int type = 0;
77 int seed = 0;
78 int sequence = 0;
79 };
80
81 struct GeneratorSettings
82 {
83 int type = 0;
84 int xAxisDimIndex = 0;
85 int yAxisDimIndex = 1;
86 bool useSampleFlow = true;
87 };
88
89 void buildControlPanelContent();
90 void buildPlotterViewContent();
91 void safeguardParameters();
92 void genRngPoints(TSpan<float> out_xBuffer, TSpan<float> out_yBuffer) const;
93 void genGeneratorPoints(TSpan<float> out_xBuffer, TSpan<float> out_yBuffer) const;
94
95 std::vector<ScatterPlotData> m_scatterPlots;
96 std::vector<char> m_plotNameBuffer;
97 int m_numSamples;
98 int m_sourceType;
99 bool m_useParamSafeguards;
100 bool m_autoClearOnGenerate;
101 std::string m_paramSafeguardMessage;
102 RngSettings m_rngSettings;
103 GeneratorSettings m_generatorSettings;
104
105 bool m_isNormalizedFitRequested;
106};
107
108inline void ImguiSampleInspector::ScatterPlotData::clear()
109{
110 name.clear();
111 xs.clear();
112 ys.clear();
113}
114
115inline void ImguiSampleInspector::ScatterPlotData::resize(const std::size_t size)
116{
117 xs.resize(size);
118 ys.resize(size);
119}
120
121inline void ImguiSampleInspector::ScatterPlotData::reserve(const std::size_t size)
122{
123 xs.reserve(size);
124 ys.reserve(size);
125}
126
127inline int ImguiSampleInspector::ScatterPlotData::getPointCount() const
128{
129 PH_ASSERT_EQ(xs.size(), ys.size());
130
131 return lossless_cast<int>(xs.size());
132}
133
134}// end namespace ph::editor
Definition ImguiSampleInspector.h:15
ImguiSampleInspector()
Definition ImguiSampleInspector.cpp:23
void buildWindow(const char *title, bool *isOpening)
Definition ImguiSampleInspector.cpp:39
Definition ph_editor.h:10