36 this->savePalettes(config);
37 this->saveGui(config);
41 this->loadPalettes(config);
42 this->loadGui(config);
52 return int(value.
value);
70 template <
typename TOrig,
typename TNew>
83 void Project::saveGui(
Config& config) {
85 for (
const auto& entry : gui) {
88 throw ConfigException(
"No settings entry with id " + std::to_string(
int(entry.id)));
90 forValue(entry.value, [&guiNode, &key](
const auto& value) {
91 guiNode->set(key.value(), settingsToConfigValue(value));
96 void Project::savePalettes(
Config& config) {
98 for (
auto& element : palettes) {
100 const Palette& palette = element.value;
103 paletteNode->set(
"scale",
int(palette.
getScale()));
105 std::stringstream ss;
107 std::string data =
replaceAll(ss.str(),
"\n",
";");
108 paletteNode->set(
"data", data);
112 void Project::loadGui(
Config& config) {
114 for (
const auto& entry : gui) {
117 throw ConfigException(
"No settings entry with id " + std::to_string(
int(entry.id)));
120 forValue(entry.value, [
this, &guiNode, &key, &entry](
auto& value) {
121 using Type = decltype(settingsToConfigValue(value));
124 const Type loadedValue = guiNode->get<Type>(key.value());
125 gui.set(entry.id, configToSettingsValue(value, loadedValue));
135 background.
a() = 1.f;
144 void Project::loadPalettes(
Config& config) {
147 paletteParentNode->enumerateChildren([
this](
const std::string& name,
ConfigNode& paletteNode) {
148 const float lower = float(paletteNode.
get<
Float>(
"lower"));
149 const float upper = float(paletteNode.
get<
Float>(
"upper"));
154 std::string data = paletteNode.
get<std::string>(
"data");
156 std::stringstream ss(data);
158 palettes.insert(name, palette);
161 const std::string path = paletteNode.
get<std::string>(
"file");
163 palettes.insert(name, palette);
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
Exception ConfigException
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
INLINE auto configToSettingsValue(const TOrig &UNUSED(original), const TNew &value)
INLINE auto settingsToConfigValue(const T &value)
std::string replaceAll(const std::string &source, const std::string &old, const std::string &s)
Replaces all occurences of string with a new string.
decltype(auto) INLINE forValue(Variant< TArgs... > &variant, TFunctor &&functor)
BasicVector< Float > Vector
INLINE Vector getNormalized(const Vector &v)
Object providing connection between component parameters and values exposed to the user.
Represents a single node in the hierarchy written into config file.
Type get(const std::string &name)
Returns a value stored in the node.
bool contains(const std::string &name)
Checks if the node contains an entry of given name.
Provides functionality for reading and writing configuration files.
SharedPtr< ConfigNode > addNode(const std::string &name)
Adds a new node to the config.
SharedPtr< ConfigNode > getNode(const std::string &name)
Returns a node with given name.
INLINE GuiSettings & set(const GuiSettingsId id, const TValue &value)
Object representing a 1D interval of real numbers.
INLINE Float lower() const
Returns lower bound of the interval.
INLINE Float upper() const
Returns upper bound of the interval.
Represents a color palette, used for mapping arbitrary number to a color.
PaletteScale getScale() const
Returns the scale of the palette.
Outcome saveToStream(std::ostream &ofs, const Size lineCnt=256) const
Saves the palettes into given output stream.
Outcome loadFromFile(const Path &path)
Loads the palette from given .csv file.
Outcome loadFromStream(std::istream &ifs)
Loads the palette from given input stream.
Interval getInterval() const
Returns the interval for which the palette is defined.
Object representing a path on a filesystem.
void load(Config &config)
void save(Config &config)
static Optional< std::string > getEntryName(const GuiSettingsId idx)
Returns the human-readable name of the entry with given index.
Symmetric tensor of 2nd order.
Symmetric traceless 2nd order tensor.
@ RAYTRACE_ITERATION_LIMIT
@ IMAGES_NAME
Mask of the image names, having d where the output number will be placed.
@ PARTICLE_RADIUS
Displayed radius of particle in units of smoothing length.
@ SURFACE_RESOLUTION
Size of the grid used in MarchingCubes (in code units, not h).
@ CAMERA_ORTHO_CUTOFF
Max z-coordinate of particle to be displayed by ortho renderer.
@ SURFACE_LEVEL
Value of iso-surface being constructed; lower value means larget bodies.
@ IMAGES_SAVE
If true, rendered images are saved to disk.
@ SURFACE_SUN_POSITION
Direction to the sun used for shading.
@ CAMERA_ORTHO_FOV
View field of view (zoom). Special value 0 means the field of view is computed from the bounding box.
@ SURFACE_AMBIENT
Ambient color for surface renderer.
@ TOTAL_MOMENTUM
Evolution of the total momentum in time.
@ INTERNAL_ENERGY
Evolution of the total internal energy in time.
@ TOTAL_ANGULAR_MOMENTUM
Evolution of the total angular momentum in time.
@ KINETIC_ENERGY
Evolution of the total kinetic energy in time.