File options.h
Location: options.h
Classes
- f3d::options
- f3d::options::parsing_exception
- f3d::options::incompatible_exception
- f3d::options::inexistent_exception
- f3d::options::no_value_exception
- f3d::options::interactor
- f3d::options::model
- f3d::options::model::color
- f3d::options::model::emissive
- f3d::options::model::matcap
- f3d::options::model::material
- f3d::options::model::normal
- f3d::options::model::point_sprites
- f3d::options::model::scivis
- f3d::options::model::volume
- f3d::options::render
- f3d::options::render::armature
- f3d::options::render::axes_grid
- f3d::options::render::background
- f3d::options::render::background::blur
- f3d::options::render::effect
- f3d::options::render::effect::antialiasing
- f3d::options::render::grid
- f3d::options::render::hdri
- f3d::options::render::light
- f3d::options::render::raytracing
- f3d::options::scene
- f3d::options::scene::animation
- f3d::options::scene::camera
- f3d::options::ui
- f3d::options::ui::backdrop
- f3d::options::ui::drop_zone
Namespaces
Includes
- exception.h
- export.h
- types.h
Included by
Functions
Function operator<<
std::ostream & operator<<(std::ostream &os, const f3d::color_t &color)
Parameters:
- std::ostream & os
- const f3d::color_t & color
Return type: std::ostream &
Function operator<<
std::ostream & operator<<(std::ostream &os, const f3d::direction_t &direction)
Parameters:
- std::ostream & os
- const f3d::direction_t & direction
Return type: std::ostream &
Function operator<<
std::ostream & operator<<(std::ostream &os, const f3d::colormap_t &cm)
Parameters:
- std::ostream & os
- const f3d::colormap_t & cm
Return type: std::ostream &
Function operator<<
std::ostream & operator<<(std::ostream &os, const f3d::transform2d_t &transform)
Parameters:
- std::ostream & os
- const f3d::transform2d_t & transform
Return type: std::ostream &
Source
#ifndef f3d_options_h
#define f3d_options_h
#include "exception.h"
#include "export.h"
#include "types.h"
#include <array>
#include <filesystem>
#include <optional>
#include <string>
#include <variant>
#include <vector>
namespace f3d
{
// Declared here for simplicity
using option_variant_t =
std::variant<bool, int, double, std::string, std::vector<double>, std::vector<int>>;
class F3D_EXPORT options
{
public:
options();
~options();
options(const options& opt);
options& operator=(const options& opt);
options(options&& other) noexcept;
options& operator=(options&& other) noexcept;
options& set(std::string_view name, const option_variant_t& value);
[[nodiscard]] option_variant_t get(std::string_view name) const;
options& setAsString(std::string_view name, const std::string& str);
[[nodiscard]] std::string getAsString(std::string_view name) const;
options& toggle(std::string_view name);
[[nodiscard]] bool isSame(const options& other, std::string_view name) const;
[[nodiscard]] bool hasValue(std::string_view name) const;
options& copy(const options& other, std::string_view name);
[[nodiscard]] static std::vector<std::string> getAllNames();
[[nodiscard]] std::vector<std::string> getNames() const;
[[nodiscard]] std::pair<std::string, unsigned int> getClosestOption(
std::string_view option) const;
[[nodiscard]] bool isOptional(std::string_view option) const;
options& reset(std::string_view name);
options& removeValue(std::string_view name);
template<typename T>
[[nodiscard]] static T parse(const std::string& str);
template<typename T>
[[nodiscard]] static std::string format(const T& var);
struct parsing_exception : public exception
{
explicit parsing_exception(const std::string& what = "");
};
struct incompatible_exception : public exception
{
explicit incompatible_exception(const std::string& what = "");
};
struct inexistent_exception : public exception
{
explicit inexistent_exception(const std::string& what = "");
};
struct no_value_exception : public exception
{
explicit no_value_exception(const std::string& what = "");
};
// clang-format off
struct interactor {
bool invert_zoom = false;
bool trackball = false;
} interactor;
struct model {
struct color {
std::optional<double> opacity;
std::optional<f3d::color_t> rgb;
std::optional<std::filesystem::path> texture;
} color;
struct emissive {
std::optional<f3d::color_t> factor;
std::optional<std::filesystem::path> texture;
} emissive;
struct matcap {
std::optional<std::filesystem::path> texture;
} matcap;
struct material {
std::optional<double> base_ior;
std::optional<double> metallic;
std::optional<double> roughness;
std::optional<std::filesystem::path> texture;
} material;
struct normal {
std::optional<double> scale;
std::optional<std::filesystem::path> texture;
} normal;
struct point_sprites {
bool enable = false;
double size = 10.0;
std::string type = "sphere";
} point_sprites;
struct scivis {
std::optional<std::string> array_name;
bool cells = false;
f3d::colormap_t colormap = f3d::colormap_t{0.0, 0.0, 0.0, 0.0, 0.4, 0.9, 0.0, 0.0, 0.8, 0.9, 0.9, 0.0, 1.0, 1.0, 1.0, 1.0};
int component = -1;
std::optional<int> discretization;
bool enable = false;
std::optional<std::vector<double>> range;
} scivis;
std::optional<f3d::transform2d_t> textures_transform;
struct volume {
bool enable = false;
bool inverse = false;
} volume;
} model;
struct render {
struct armature {
bool enable = false;
} armature;
struct axes_grid {
bool enable = false;
} axes_grid;
std::optional<std::string> backface_type;
struct background {
struct blur {
double coc = 20.0;
bool enable = false;
} blur;
f3d::color_t color = f3d::color_t{0.2, 0.2, 0.2};
bool skybox = false;
} background;
struct effect {
bool ambient_occlusion = false;
[[deprecated("use render.effect.antialiasing.enable instead")]] bool anti_aliasing = false;
struct antialiasing {
bool enable = false;
std::string mode = "fxaa";
} antialiasing;
std::optional<std::string> final_shader;
bool tone_mapping = false;
bool translucency_support = false;
} effect;
struct grid {
bool absolute = false;
f3d::color_t color = f3d::color_t{0.0, 0.0, 0.0};
bool enable = false;
int subdivisions = 10;
std::optional<double> unit;
} grid;
struct hdri {
bool ambient = false;
std::optional<std::filesystem::path> file;
} hdri;
struct light {
double intensity = 1.0;
} light;
std::optional<double> line_width;
std::optional<double> point_size;
struct raytracing {
bool denoise = false;
bool enable = false;
int samples = 5;
} raytracing;
std::optional<bool> show_edges;
} render;
struct scene {
struct animation {
bool autoplay = false;
[[deprecated("use scene.animation.indices instead")]] int index = 0;
std::vector<int> indices = {0};
f3d::ratio_t speed_factor = f3d::ratio_t{1.0};
} animation;
struct camera {
std::optional<int> index;
std::optional<bool> orthographic;
} camera;
std::optional<std::string> force_reader;
f3d::direction_t up_direction = f3d::direction_t{0,1,0};
} scene;
struct ui {
bool animation_progress = false;
bool axis = false;
struct backdrop {
double opacity = 0.9;
} backdrop;
bool cheatsheet = false;
bool console = false;
struct drop_zone {
std::string custom_binds = "";
bool enable = false;
[[deprecated("use ui.drop_zone.custom_binds instead")]] std::string info = "";
bool show_logo = false;
} drop_zone;
[[deprecated("use ui.drop_zone.enable instead")]] bool dropzone = false;
[[deprecated("use ui.drop_zone.custom_binds instead")]] std::string dropzone_info = "";
bool filename = false;
std::string filename_info = "";
std::optional<std::filesystem::path> font_file;
bool fps = false;
bool loader_progress = false;
bool metadata = false;
bool minimal_console = false;
bool scalar_bar = false;
f3d::ratio_t scale = f3d::ratio_t{1.0};
} ui;
// clang-format on
};
}
// Certain options types are not trivially streamable
//----------------------------------------------------------------------------
inline std::ostream& operator<<(std::ostream& os, const f3d::color_t& color)
{
os << f3d::options::format(color);
return os;
}
inline std::ostream& operator<<(std::ostream& os, const f3d::direction_t& direction)
{
os << f3d::options::format(direction);
return os;
}
inline std::ostream& operator<<(std::ostream& os, const f3d::colormap_t& cm)
{
os << f3d::options::format(cm);
return os;
}
inline std::ostream& operator<<(std::ostream& os, const f3d::transform2d_t& transform)
{
os << f3d::options::format(transform);
return os;
}
#endif