Skip to content

Commit

Permalink
fixup application
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphal committed Jul 14, 2024
1 parent 0cbbfbc commit 8af35be
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
13 changes: 8 additions & 5 deletions application/F3DOptionsParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,8 @@ void ConfigurationOptions::GetOptions(F3DAppOptions& appOptions, f3d::options& o

try
{
// TODO recover list of keys from somwhere
std::map<std::string, std::string> libArgs;
std::vector<std::string> keys = options.getOptionStrings();
std::vector<std::string> keys = options.getNames();
for (const std::string& key : keys)
{
libArgs[key] = options.getString(key);
Expand Down Expand Up @@ -468,7 +467,7 @@ void ConfigurationOptions::GetOptions(F3DAppOptions& appOptions, f3d::options& o
{
options.setString(key, val);
}

/*
#ifndef F3D_NO_DEPRECATED
if (deprecatedQuiet)
{
Expand All @@ -488,7 +487,7 @@ void ConfigurationOptions::GetOptions(F3DAppOptions& appOptions, f3d::options& o
for (const std::string& input : deprecatedInputs)
{
/* `deprecatedInputs` may contain an empty string instead of being empty itself */
// `deprecatedInputs` may contain an empty string instead of being empty itself
if (!input.empty())
{
f3d::log::warn("--input option is deprecated, please use positional arguments instead.");
Expand All @@ -497,7 +496,7 @@ void ConfigurationOptions::GetOptions(F3DAppOptions& appOptions, f3d::options& o
}
inputs = deprecatedInputs;
#endif

*/
auto unmatched = result.unmatched();
bool found_unknown_option = false;
for (std::string unknownOption : unmatched)
Expand Down Expand Up @@ -567,6 +566,10 @@ void ConfigurationOptions::GetOptions(F3DAppOptions& appOptions, f3d::options& o
{
// this will update the options using the config file without parsing actual argc/argv
cxxOptions.parse(1, nullptr);
for(auto [key,val] : libArgs)
{
options.setString(key, val);
}
}
}
catch (const cxxopts::exceptions::exception& ex)
Expand Down
41 changes: 19 additions & 22 deletions application/F3DStarter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@ F3DStarter::F3DStarter()
: Internals(std::make_unique<F3DStarter::F3DInternals>())
{
// Set option outside of command line and config file
this->Internals->DynamicOptions.set(
"ui.dropzone-info", "Drop a file or HDRI to load it\nPress H to show cheatsheet");
this->Internals->DynamicOptions.getStruct().ui.dropzone_info = "Drop a file or HDRI to load it\nPress H to show cheatsheet";

// Initialize dmon
dmon_init();
Expand Down Expand Up @@ -510,9 +509,9 @@ int F3DStarter::Start(int argc, char** argv)
// TODO: add a image::canRead

// Load the file as an HDRI instead of adding it.
this->Internals->Engine->getOptions().set("render.hdri.file", file);
this->Internals->Engine->getOptions().set("render.hdri.ambient", true);
this->Internals->Engine->getOptions().set("render.background.skybox", true);
this->Internals->Engine->getOptions().getStruct().render.hdri.file = file;
this->Internals->Engine->getOptions().getStruct().render.hdri.ambient = true;
this->Internals->Engine->getOptions().getStruct().render.background.skybox = true;

// Rendering now is needed for correct lighting
this->Render();
Expand Down Expand Up @@ -557,13 +556,12 @@ int F3DStarter::Start(int argc, char** argv)

if (!fullPath.empty())
{
this->Internals->Engine->getOptions().set(
"model.scivis.colormap", F3DColorMapTools::Read(fullPath));
this->Internals->Engine->getOptions().getStruct().model.scivis.colormap = F3DColorMapTools::Read(fullPath);
}
else
{
f3d::log::error("Cannot find the colormap ", this->Internals->AppOptions.ColorMapFile);
this->Internals->Engine->getOptions().set("model.scivis.colormap", std::vector<double>{});
this->Internals->Engine->getOptions().getStruct().model.scivis.colormap = std::vector<double>{};
}
}

Expand Down Expand Up @@ -896,8 +894,8 @@ void F3DStarter::LoadFile(int index, bool relativeIndex)
loader.loadGeometry("", true);
}

this->Internals->Engine->getOptions().set("ui.dropzone", !this->Internals->LoadedFile);
this->Internals->Engine->getOptions().set("ui.filename-info", filenameInfo);
this->Internals->Engine->getOptions().getStruct().ui.dropzone = !this->Internals->LoadedFile;
this->Internals->Engine->getOptions().getStruct().ui.filename_info = filenameInfo;
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -948,28 +946,27 @@ void F3DStarter::SaveScreenshot(const std::string& filenameTemplate, bool minima
f3d::options& options = this->Internals->Engine->getOptions();
f3d::options optionsCopy = this->Internals->Engine->getOptions();

/* TODO
bool noBackground = this->Internals->AppOptions.NoBackground;
bool noBackground = this->Internals->AppOptions.NoBackground;
f3d::options_struct& optionStruct = options.getStruct();
if (minimal)
{
options.set("ui.bar", false);
options.set("ui.cheatsheet", false);
options.set("ui.filename", false);
options.set("ui.fps", false);
options.set("ui.metadata", false);
options.set("ui.animation-progress", false);
options.set("interactor.axis", false);
options.set("render.grid.enable", false);
optionStruct.ui.scalar_bar = false;
optionStruct.ui.cheatsheet = false;
optionStruct.ui.filename = false;
optionStruct.ui.fps = false;
optionStruct.ui.metadata = false;
optionStruct.ui.animation_progress = false;
optionStruct.interactor.axis = false;
optionStruct.render.grid.enable = false;
noBackground = true;
}

f3d::image img = this->Internals->Engine->getWindow().renderToImage(noBackground);
this->Internals->addOutputImageMetadata(img);
img.save(path.string(), f3d::image::SaveFormat::PNG);

options.getAsDoubleRef("render.light.intensity") *= 5;
optionStruct.render.light.intensity = optionStruct.render.light.intensity * 5;
this->Render();
*/

this->Internals->Engine->setOptions(optionsCopy);
this->Render();
Expand Down

0 comments on commit 8af35be

Please sign in to comment.