Simple struct based domain#3232
Conversation
|
You are modifying libf3d public API! |
|
\ci fast |
6135506 to
39b547a
Compare
| } | ||
|
|
||
| const options& Options; | ||
| options& Options; |
There was a problem hiding this comment.
needed in order to be able to modify the domain
There was a problem hiding this comment.
If the user wants to modify the domain, it's probably better to do it from the engine? It's better to keep a const reference in the scene I think.
There was a problem hiding this comment.
its not the user, its us modifying the domain.
8790656 to
7c543e3
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3232 +/- ##
==========================================
+ Coverage 97.06% 97.08% +0.01%
==========================================
Files 213 213
Lines 17656 17673 +17
==========================================
+ Hits 17137 17157 +20
+ Misses 519 516 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| CLI: `--animation-time`. | ||
|
|
||
| ### `scene.camera.index` (_int_, optional, **on load**) | ||
| ### `scene.camera.index` (_int_, optional, **on load**, domain: enumeration: dynamic) |
There was a problem hiding this comment.
Should we be more explicit about dynamic value with something like that?
| ### `scene.camera.index` (_int_, optional, **on load**, domain: enumeration: dynamic) | |
| ### `scene.camera.index` (_int_, optional, **on load**, domain: enumeration: `0, 1, ...`) |
There was a problem hiding this comment.
hum, this could work, but in any case it requires some kind of clarification somewhere in the option doc.
There was a problem hiding this comment.
I suggest to drop the domain for indexing for now?
| } | ||
|
|
||
| // TODO keep here? | ||
| inline ratio_t& operator+=(const double& incr) |
There was a problem hiding this comment.
Well yeah I don't like the fact ratio_t only exist for parsing reason. Maybe we should remove it and do in increase() API instead: option = ratio_t(static_cast<double>(option) + increment)
There was a problem hiding this comment.
I removed the operator but it means creating a new f3d::ratio_t
| "type": "int" | ||
| "type": "int", | ||
| "domain": { | ||
| "enum": [] |
There was a problem hiding this comment.
I suppose this dynamic domain would prevent potential improvement in the future. Maybe it should be its own domain like domain_dynamic_indexing_t?
There was a problem hiding this comment.
it could, but it would be for a single option so I dont think its worth it.
All domains are dynamic btw, nothing prevent a user from changing a domain using the struct API.
The only one the libf3d changes is this one.
There was a problem hiding this comment.
Ok I haven't thought about the use case where a libf3d user would want to change the range or increment. That's valid indeed.
I'm still a bit reluctant to add a range domain for camera indexing. It feels like it's a completely different logic.
There was a problem hiding this comment.
It feels like it's a completely different logic.
It is indeed! I agree it could be a different domain but since the enum works as well, i think we can add that when we have more index domain.
That being said, it will mean deprecation, so maybe better to do it now.
There was a problem hiding this comment.
That being said, it will mean deprecation, so maybe better to do it now.
I also think so.
|
Style Checks CI failed: diff --git a/doc/libf3d/03-OPTIONS.md b/doc/libf3d/03-OPTIONS.md
index f05e66e..122daaa 100644
--- a/doc/libf3d/03-OPTIONS.md
+++ b/doc/libf3d/03-OPTIONS.md
@@ -603,7 +603,6 @@ Show corresponding keys when notifications are triggered by bindings key press e
## Domains
-
## APIs
There are three APIs to access the options
diff --git a/doc/libf3d/06-MIGRATION.md b/doc/libf3d/06-MIGRATION.md
index bc63a84..8bfb366 100644
--- a/doc/libf3d/06-MIGRATION.md
+++ b/doc/libf3d/06-MIGRATION.md
@@ -32,14 +32,14 @@ When running F3D, it was possible to specify the path for loading plugins using
The following commands have been removed and should be replaced:
- - `cycle_anti_aliasing` -> `cycle render.effect.antialiasing.mode`
- - `cycle_blending` -> `cycle render.effect.blending.mode`
- - `cycle_point_sprites` -> `cycle model.point_sprites.type`
- - `increase_light_intensity` -> `increase render.light.intensity` (increments are different)
- - `decrease_light_intensity` -> `decrease render.light.intensity` (increments are different)
- - `increase_opacity` -> `increase model.color.opacity`
- - `decrease_opacity` -> `decrease model.color.opacity`
- - `cycle_interactor_style` -> `cycle interactor.style`
+- `cycle_anti_aliasing` -> `cycle render.effect.antialiasing.mode`
+- `cycle_blending` -> `cycle render.effect.blending.mode`
+- `cycle_point_sprites` -> `cycle model.point_sprites.type`
+- `increase_light_intensity` -> `increase render.light.intensity` (increments are different)
+- `decrease_light_intensity` -> `decrease render.light.intensity` (increments are different)
+- `increase_opacity` -> `increase model.color.opacity`
+- `decrease_opacity` -> `decrease model.color.opacity`
+- `cycle_interactor_style` -> `cycle interactor.style`
The `jump_to_frame` and `jump_to_keyframe` commands no longer take a second boolean argument and now always perform an absolute jump. To perform a relative jump, use the new `jump_to_frame_relative` and `jump_to_keyframe_relative` commands:
diff --git a/library/private/options_generated.h.in b/library/private/options_generated.h.in
index 44f03cc..397185c 100644
--- a/library/private/options_generated.h.in
+++ b/library/private/options_generated.h.in
@@ -152,7 +152,8 @@ std::vector<std::string> getEnumDomain(const f3d::options& opt, std::string_view
/**
* Generated method, see `options::getRangeDomain`
*/
-std::pair<std::array<std::string, 2>, std::string> getRangeDomain(const f3d::options& opt, std::string_view name)
+std::pair<std::array<std::string, 2>, std::string> getRangeDomain(
+ const f3d::options& opt, std::string_view name)
{
// clang-format off
${_options_get_range_domain};
diff --git a/library/private/options_tools.h b/library/private/options_tools.h
index f33f3b8..cc8cf76 100644
--- a/library/private/options_tools.h
+++ b/library/private/options_tools.h
@@ -901,7 +901,8 @@ bool hasDomain(f3d::options::domain_style& styleVar, const f3d::options::domain_
* Get provided domain_range as a string vector
*/
template<typename T>
-std::pair<std::array<std::string, 2>, std::string> getRangeDomain(const f3d::options::domain_range_t<T>& domain)
+std::pair<std::array<std::string, 2>, std::string> getRangeDomain(
+ const f3d::options::domain_range_t<T>& domain)
{
std::pair<std::array<std::string, 2>, std::string> ret;
ret.first[0] = std::move(format(domain.range[0]));
@@ -914,7 +915,8 @@ std::pair<std::array<std::string, 2>, std::string> getRangeDomain(const f3d::opt
/**
* Get provided domain_range<std::string> as a string vector
*/
-std::pair<std::array<std::string, 2>, std::string> getRangeDomain(const f3d::options::domain_range_t<std::string>& domain)
+std::pair<std::array<std::string, 2>, std::string> getRangeDomain(
+ const f3d::options::domain_range_t<std::string>& domain)
{
std::pair<std::array<std::string, 2>, std::string> ret;
ret.first = domain.range;
@@ -944,7 +946,6 @@ std::vector<std::string> getEnumDomain(const f3d::options::domain_enum_t<std::st
return domain.enumeration;
}
-
//----------------------------------------------------------------------------
/**
* Needed for increase implementation for ratio_t
diff --git a/library/public/options.h.in b/library/public/options.h.in
index 59737e8..5921b6c 100644
--- a/library/public/options.h.in
+++ b/library/public/options.h.in
@@ -172,7 +172,8 @@ public:
* Throw options::incompatible_exception if option doesn't have a range domain.
* Throws an options::inexistent_exception if option does not exist.
*/
- [[nodiscard]] std::pair<std::array<std::string, 2>, std::string> getRangeDomain(std::string_view name) const;
+ [[nodiscard]] std::pair<std::array<std::string, 2>, std::string> getRangeDomain(
+ std::string_view name) const;
/**
* Return a the enumeration of the enum domain of provided option.
diff --git a/library/src/options.cxx b/library/src/options.cxx
index 49dc471..b9f6ce9 100644
--- a/library/src/options.cxx
+++ b/library/src/options.cxx
@@ -195,7 +195,8 @@ bool options::hasDomain(std::string_view name, domain_style& style) const
}
//----------------------------------------------------------------------------
-std::pair<std::array<std::string, 2>, std::string> options::getRangeDomain(std::string_view name) const
+std::pair<std::array<std::string, 2>, std::string> options::getRangeDomain(
+ std::string_view name) const
{
return options_generated::getRangeDomain(*this, name);
}
diff --git a/library/testing/TestSDKOptionsDomains.cxx b/library/testing/TestSDKOptionsDomains.cxx
index 50eb173..05ecb89 100644
--- a/library/testing/TestSDKOptionsDomains.cxx
+++ b/library/testing/TestSDKOptionsDomains.cxx
@@ -19,11 +19,12 @@ int TestSDKOptionsDomains([[maybe_unused]] int argc, [[maybe_unused]] char* argv
"hasDomain inexistent", [&]() { std::ignore = opt.hasDomain("inexistent", style); });
// Test getRangeDomain
- std::pair<std::array<std::string, 2>, std::string> rangeDomain = opt.getRangeDomain("scene.animation.speed_factor");
- test("getRangeDomain range", rangeDomain.first, {"0", "2"});
+ std::pair<std::array<std::string, 2>, std::string> rangeDomain =
+ opt.getRangeDomain("scene.animation.speed_factor");
+ test("getRangeDomain range", rangeDomain.first, { "0", "2" });
test("getRangeDomain increment", rangeDomain.second, std::string("0.1"));
- test.expect<f3d::options::incompatible_exception>(
- "getRangeDomain incompatible", [&]() { std::ignore = opt.getRangeDomain("model.scivis.cells"); });
+ test.expect<f3d::options::incompatible_exception>("getRangeDomain incompatible",
+ [&]() { std::ignore = opt.getRangeDomain("model.scivis.cells"); });
test.expect<f3d::options::inexistent_exception>(
"getRangeDomain inexistent", [&]() { std::ignore = opt.getRangeDomain("inexistent"); });
|
8bb6ca7 to
d7df19d
Compare
Describe your changes
options::hasDomain,options::getDomain,options::increase,options::decrease,options::cycleincreaseanddecreasecommands for range domain optionscyclecommands for enum domain optionscycle_andincrease_commands to useincreaseandcyclewhenever possibleJson syntax:
Added Domain list:
render.effect.blending.mode: donerender.effect.antialiasing.mode: donemodel.point_sprites.type: doneinteractor.style: donerender.light.intensity: done, but implementation is different (percentage)model.color.opacity: done, but implementation is different (start from min/max)scene.animation.speed_factor: donescene.camera.index: donerender.line_width: donerender.point_size: donerender.backface_type: donerender.raytracing.samples: donerender.background.blur.coc: doneui.backdrop.opacity: doneui.scale: donemodel.normal.scale: donemodel.material.metallic: donemodel.material.roughness: donemodel.material.base_ior: donemodel.scivis.discretization: donemodel.point_sprites.size: donemodel.normal_glyphs.scale: doneTODO:
Issue ticket number and link if any
Fix #2334
Checklist for finalizing the PR
.github/workflows/versions.json, I have updateddocker_timestampAI Disclosure
Continuous integration
Please write a comment to run CI, eg:
\ci fast.See here for more info.