Skip to content

Commit

Permalink
Rename options (f3d-app#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphal authored Aug 5, 2022
1 parent 7ea6833 commit deabd90
Show file tree
Hide file tree
Showing 15 changed files with 278 additions and 233 deletions.
92 changes: 47 additions & 45 deletions application/F3DOptionsParser.cxx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions library/src/animationManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void animationManager::Initialize(
}
log::debug("");

int animationIndex = options->getAsInt("animation-index");
int animationIndex = options->getAsInt("scene.animation.index");
if (animationIndex != 0 && availAnimations <= 0)
{
log::warn("An animation index has been specified but there are no animation available.");
Expand Down Expand Up @@ -168,7 +168,7 @@ void animationManager::ToggleAnimation()
{
this->CallBackId =
this->Interactor->createTimerCallBack(1000.0 / this->FrameRate, [this]() { this->Tick(); });
if (this->Options->getAsInt("camera-index") >= 0)
if (this->Options->getAsInt("scene.camera.index") >= 0)
{
this->Interactor->disableCameraMovement();
}
Expand Down
45 changes: 23 additions & 22 deletions library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -111,82 +111,83 @@ class interactor_impl::internals
}
break;
case 'B':
self->Options.toggle("bar");
self->Options.toggle("ui.bar");
render = true;
break;
case 'p':
case 'P':
self->Options.toggle("depth-peeling");
self->Options.toggle("render.effect.depth-peeling");
render = true;
break;
case 'Q':
self->Options.toggle("ssao");
self->Options.toggle("render.effect.ssao");
render = true;
break;
case 'A':
self->Options.toggle("fxaa");
self->Options.toggle("render.effect.fxaa");
render = true;
break;
case 'T':
self->Options.toggle("tone-mapping");
self->Options.toggle("render.effect.tone-mapping");
render = true;
break;
case 'E':
self->Options.toggle("edges");
self->Options.toggle("render.show-edges");
render = true;
break;
case 'X':
self->Options.toggle("axis");
self->Options.toggle("interactor.axis"); // XXX this should not be available in the
// cheatsheet when not provided ?
render = true;
break;
case 'G':
self->Options.toggle("grid");
self->Options.toggle("render.grid");
render = true;
break;
case 'N':
self->Options.toggle("filename");
self->Options.toggle("ui.filename");
render = true;
break;
case 'M':
self->Options.toggle("metadata");
self->Options.toggle("ui.metadata");
render = true;
break;
case 'Z':
self->Options.toggle("fps");
self->Options.toggle("ui.fps");
self->Window.render();
self->Window.render();
// XXX: Double render is needed here
break;
case 'R':
self->Options.toggle("raytracing");
self->Options.toggle("render.raytracing.enable");
render = true;
break;
case 'D':
self->Options.toggle("denoise");
self->Options.toggle("render.raytracing.denoise");
render = true;
break;
case 'V':
self->Options.toggle("volume");
self->Options.toggle("model.volume.enable");
render = true;
break;
case 'I':
self->Options.toggle("inverse");
self->Options.toggle("model.volume.inverse");
render = true;
break;
case 'O':
self->Options.toggle("point-sprites");
self->Options.toggle("model.point-sprites.enable");
render = true;
break;
case 'U':
self->Options.toggle("blur-background");
self->Options.toggle("render.background.blur");
render = true;
break;
case 'K':
self->Options.toggle("trackball");
self->Options.toggle("interactor.trackball");
render = true;
break;
case 'H':
self->Options.toggle("cheatsheet");
self->Options.toggle("ui.cheatsheet");
render = true;
break;
case '?':
Expand Down Expand Up @@ -233,9 +234,9 @@ class interactor_impl::internals
if (checkColoring)
{
// Resynchronise renderer coloring status with options
self->Options.set("cells", renWithColor->GetColoringUseCell());
self->Options.set("scalars", renWithColor->GetColoringArrayName());
self->Options.set("component", renWithColor->GetColoringComponent());
self->Options.set("model.scivis.cells", renWithColor->GetColoringUseCell());
self->Options.set("model.scivis.array-name", renWithColor->GetColoringArrayName());
self->Options.set("model.scivis.component", renWithColor->GetColoringComponent());
}
if (render)
{
Expand Down
39 changes: 22 additions & 17 deletions library/src/loader_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,22 @@ class loader_impl::internals

static void InitializeImporterWithOptions(const options& options, vtkF3DGenericImporter* importer)
{
importer->SetPointSize(options.getAsDouble("point-size"));
importer->SetSurfaceColor(options.getAsDoubleVector("color").data());
importer->SetOpacity(options.getAsDouble("opacity"));
importer->SetRoughness(options.getAsDouble("roughness"));
importer->SetMetallic(options.getAsDouble("metallic"));
importer->SetLineWidth(options.getAsDouble("line-width"));
importer->SetTextureBaseColor(options.getAsString("texture-base-color"));
importer->SetTextureEmissive(options.getAsString("texture-emissive"));
importer->SetEmissiveFactor(options.getAsDoubleVector("emissive-factor").data());
importer->SetTextureMaterial(options.getAsString("texture-material"));
importer->SetTextureNormal(options.getAsString("texture-normal"));
importer->SetNormalScale(options.getAsDouble("normal-scale"));
importer->SetLineWidth(options.getAsDouble("render.line-width"));
importer->SetPointSize(options.getAsDouble("render.point-size"));

importer->SetSurfaceColor(options.getAsDoubleVector("model.color.rgb").data());
importer->SetOpacity(options.getAsDouble("model.color.opacity"));
importer->SetTextureBaseColor(options.getAsString("model.color.texture"));

importer->SetRoughness(options.getAsDouble("model.material.roughness"));
importer->SetMetallic(options.getAsDouble("model.material.metallic"));
importer->SetTextureMaterial(options.getAsString("model.material.texture"));

importer->SetTextureEmissive(options.getAsString("model.emissive.texture"));
importer->SetEmissiveFactor(options.getAsDoubleVector("model.emissive.factor").data());

importer->SetTextureNormal(options.getAsString("model.normal.texture"));
importer->SetNormalScale(options.getAsDouble("model.normal.scale"));
}

static void CreateProgressRepresentationAndCallback(
Expand Down Expand Up @@ -320,7 +324,7 @@ bool loader_impl::loadFile(loader::LoadFileEnum load)

// Recover the importer
this->Internals->Importer = loader_impl::internals::GetImporter(
filePath, this->Internals->Options.getAsBool("geometry-only"));
filePath, this->Internals->Options.getAsBool("scene.geometry-only"));
vtkF3DGenericImporter* genericImporter =
vtkF3DGenericImporter::SafeDownCast(this->Internals->Importer);
if (!this->Internals->Importer)
Expand All @@ -342,19 +346,20 @@ bool loader_impl::loadFile(loader::LoadFileEnum load)
// Initialize importer for rendering
this->Internals->Importer->SetRenderWindow(this->Internals->Window.GetRenderWindow());

int cameraIndex = this->Internals->Options.getAsInt("scene.camera.index");
// Importer camera needs https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7701
#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 0, 20210303)
this->Internals->Importer->SetCamera(this->Internals->Options.getAsInt("camera-index"));
this->Internals->Importer->SetCamera(cameraIndex);
#else
// XXX There is no way to recover the init value yet, assume it is -1
if (this->Internals->Options.getAsInt("camera-index") != -1)
if (cameraIndex != -1)
{
log::warn("This VTK version does not support specifying the camera index, ignored.");
}
#endif

// Manage progress bar
if (this->Internals->Options.getAsBool("progress") && this->Internals->Interactor)
if (this->Internals->Options.getAsBool("ui.loader-progress") && this->Internals->Interactor)
{
loader_impl::internals::CreateProgressRepresentationAndCallback(
&callbackData, this->Internals->Importer, this->Internals->Interactor);
Expand Down Expand Up @@ -389,7 +394,7 @@ bool loader_impl::loadFile(loader::LoadFileEnum load)

// Initialize renderer and reset camera to bounds if needed
this->Internals->Window.UpdateDynamicOptions();
if (this->Internals->Options.getAsInt("camera-index") == -1)
if (cameraIndex == -1)
{
this->Internals->Window.getCamera().resetToBounds();
}
Expand Down
118 changes: 69 additions & 49 deletions library/src/options.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -106,57 +106,77 @@ class options::internals
options::options()
: Internals(new options::internals)
{
// Loader/Loading
this->Internals->init("animation-index", 0);
this->Internals->init("camera-index", -1);
this->Internals->init("color", std::vector<double>{ 1., 1., 1. });
this->Internals->init("emissive-factor", std::vector<double>{ 1., 1., 1. });
this->Internals->init("geometry-only", false);
this->Internals->init("line-width", 1.0);
this->Internals->init("metallic", 0.0);
this->Internals->init("normal-scale", 1.0);
this->Internals->init("opacity", 1.0);
this->Internals->init("point-size", 10.0);
this->Internals->init("progress", false);
this->Internals->init("roughness", 0.3);
this->Internals->init("texture-base-color", std::string());
this->Internals->init("texture-emissive", std::string());
this->Internals->init("texture-material", std::string());
this->Internals->init("texture-normal", std::string());
this->Internals->init("up", std::string("+Y"));

// Rendering/Dynamic
this->Internals->init("axis", false);
this->Internals->init("background-color", std::vector<double>{ 0.2, 0.2, 0.2 });
this->Internals->init("bar", false);
this->Internals->init("blur-background", false);
this->Internals->init("cells", false);
this->Internals->init("colormap",
// Scene
this->Internals->init("scene.animation.index", 0);
this->Internals->init("scene.camera.index", -1);
this->Internals->init("scene.geometry-only", false);
this->Internals->init("scene.up-direction", std::string("+Y"));

// Render
this->Internals->init("render.show-edges", false);
this->Internals->init("render.line-width", 1.0);
this->Internals->init("render.point-size", 10.0);
this->Internals->init("render.grid", false);

this->Internals->init("render.raytracing.enable", false);
this->Internals->init("render.raytracing.denoise", false);
this->Internals->init("render.raytracing.samples", 5);

this->Internals->init("render.effect.depth-peeling", false);
this->Internals->init("render.effect.fxaa", false);
this->Internals->init("render.effect.ssao", false);
this->Internals->init("render.effect.tone-mapping", false);

this->Internals->init("render.background.color", std::vector<double>{ 0.2, 0.2, 0.2 });
this->Internals->init(
"render.background.hdri", std::string()); // XXX This overrides background.color
this->Internals->init("render.background.blur", false);

// UI
this->Internals->init("ui.bar", false);
this->Internals->init("ui.filename", false);
this->Internals->init("ui.fps", false);
this->Internals->init("ui.cheatsheet", false);
this->Internals->init("ui.metadata", false);
this->Internals->init("ui.font-file", std::string());
this->Internals->init("ui.loader-progress", false);

// Model
this->Internals->init(
"model.color.rgb", std::vector<double>{ 1., 1., 1. }); // TODO Not compatible with scivis
this->Internals->init("model.color.opacity", 1.0);
this->Internals->init(
"model.color.texture", std::string()); // TODO Strange stuff when using with scivis

this->Internals->init("model.emissive.factor", std::vector<double>{ 1., 1., 1. });
this->Internals->init("model.emissive.texture", std::string());

this->Internals->init("model.normal.texture", std::string());
this->Internals->init("model.normal.scale", 1.0);

this->Internals->init("model.material.metallic", 0.0);
this->Internals->init("model.material.roughness", 0.3);
this->Internals->init("model.material.texture", std::string());

this->Internals->init("model.scivis.cells", false);
this->Internals->init("model.scivis.array-name", F3D_RESERVED_STRING);
this->Internals->init("model.scivis.component", -1);
this->Internals->init("model.scivis.colormap",
std::vector<double>{
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 });
this->Internals->init("component", -1);
this->Internals->init("denoise", false);
this->Internals->init("depth-peeling", false);
this->Internals->init("edges", false);
this->Internals->init("filename", false);
this->Internals->init("font-file", std::string());
this->Internals->init("fps", false);
this->Internals->init("fullscreen", false);
this->Internals->init("fxaa", false);
this->Internals->init("grid", false);
this->Internals->init("hdri", std::string());
this->Internals->init("inverse", false);
this->Internals->init("metadata", false);
this->Internals->init("point-sprites", false);
this->Internals->init("range", std::vector<double>());
this->Internals->init("raytracing", false);
this->Internals->init("samples", 5);
this->Internals->init("scalars", F3D_RESERVED_STRING);
this->Internals->init("ssao", false);
this->Internals->init("tone-mapping", false);
this->Internals->init("trackball", false);
this->Internals->init("volume", false);
this->Internals->init("cheatsheet", false);
this->Internals->init("model.scivis.range", std::vector<double>());

// TODO: Rename into a "rendering-mode" option
this->Internals->init("model.point-sprites.enable", false);
this->Internals->init("model.volume.enable", false);
this->Internals->init("model.volume.inverse", false);

// Window
this->Internals->init("window.fullscreen", false);

// Interactor
this->Internals->init("interactor.axis", false);
this->Internals->init("interactor.trackball", false);
};

//----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit deabd90

Please sign in to comment.