Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F3D: Fix a small issue with imperative options #2049

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 35 additions & 22 deletions application/F3DStarter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,15 @@ class F3DStarter::F3DInternals
}

void UpdateOptions(const std::vector<F3DOptionsTools::OptionsEntries>& entriesVector,
const std::vector<fs::path>& paths)
const std::vector<fs::path>& paths, bool quiet)
{
assert(!paths.empty());

f3d::log::debug("Updating Options:");
if (!quiet)
{
f3d::log::debug("Updating Options:");
}

// Initialize libf3dOptions
f3d::options libOptions;
libOptions.ui.dropzone_info = "Drop a file or HDRI to load it\nPress H to show cheatsheet";
Expand All @@ -445,7 +449,7 @@ class F3DStarter::F3DInternals
F3DOptionsTools::OptionsDict appOptions = F3DOptionsTools::DefaultAppOptions;

// Logging specific map
bool logOptions = this->AppOptions.VerboseLevel == "debug";
bool logOptions = this->AppOptions.VerboseLevel == "debug" && !quiet;
std::map<std::string, log_entry_t> loggingMap;

// For each input file, order matters
Expand Down Expand Up @@ -522,19 +526,25 @@ class F3DStarter::F3DInternals
}
catch (const f3d::options::parsing_exception& ex)
{
std::string origin =
source.empty() ? pattern : std::string(source) + ":`" + pattern + "`";
f3d::log::warn("Could not set '", keyForLog, "' to '", libf3dOptionValue, "' from ",
origin, " because: ", ex.what());
if (!quiet)
{
std::string origin =
source.empty() ? pattern : std::string(source) + ":`" + pattern + "`";
f3d::log::warn("Could not set '", keyForLog, "' to '", libf3dOptionValue,
"' from ", origin, " because: ", ex.what());
}
}
catch (const f3d::options::inexistent_exception&)
{
std::string origin =
source.empty() ? pattern : std::string(source) + ":`" + pattern + "`";
auto [closestName, dist] =
F3DOptionsTools::GetClosestOption(libf3dOptionName, true);
f3d::log::warn("'", keyForLog, "' option from ", origin,
" does not exists , did you mean '", closestName, "'?");
if (!quiet)
{
std::string origin =
source.empty() ? pattern : std::string(source) + ":`" + pattern + "`";
auto [closestName, dist] =
F3DOptionsTools::GetClosestOption(libf3dOptionName, true);
f3d::log::warn("'", keyForLog, "' option from ", origin,
" does not exists , did you mean '", closestName, "'?");
}
}
}
}
Expand Down Expand Up @@ -898,11 +908,12 @@ int F3DStarter::Start(int argc, char** argv)
}

// Update app and libf3d options based on config entries, with an empty input file
// config < cli
// config < cli.
// Force it to be quiet has another options update happens later.
this->Internals->UpdateOptions(
{ this->Internals->ConfigOptionsEntries, this->Internals->CLIOptionsEntries,
this->Internals->ImperativeConfigOptionsEntries },
{ "" });
{ "" }, true);

#if __APPLE__
// Initialize MacOS delegate
Expand Down Expand Up @@ -1307,6 +1318,13 @@ void F3DStarter::LoadFileGroup(

if (paths.empty())
{
// Update options even when there is no file
// as imperative options should override dynamic option even in that case
this->Internals->UpdateOptions(
{ this->Internals->ConfigOptionsEntries, this->Internals->CLIOptionsEntries,
this->Internals->DynamicOptionsEntries, this->Internals->ImperativeConfigOptionsEntries },
{ "" }, false);
this->Internals->Engine->setOptions(this->Internals->LibOptions);
f3d::log::debug("No files to load provided");
}
else
Expand All @@ -1319,7 +1337,7 @@ void F3DStarter::LoadFileGroup(
this->Internals->UpdateOptions(
{ this->Internals->ConfigOptionsEntries, this->Internals->CLIOptionsEntries,
this->Internals->DynamicOptionsEntries, this->Internals->ImperativeConfigOptionsEntries },
configPaths);
configPaths, false);
this->Internals->UpdateBindings(configPaths);

this->Internals->Engine->setOptions(this->Internals->LibOptions);
Expand Down Expand Up @@ -1692,14 +1710,9 @@ void F3DStarter::AddCommands()
{
this->Internals->Engine->getInteractor().stopAnimation();
}
f3d::scene& scene = this->Internals->Engine->getScene();
scene.clear();
this->Internals->FilesGroups.clear();
this->Internals->LoadedFiles.clear();
this->LoadFileGroup(0, false, true);
this->ResetWindowName();
f3d::options& options = this->Internals->Engine->getOptions();
options.ui.dropzone = true;
options.ui.filename_info = "";
});

interactor.addCommand("load_previous_file_group",
Expand Down
1 change: 1 addition & 0 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ f3d_test(NAME TestInteractionConfigFileBindings DATA dragon.vtu CONFIG ${F3D_SOU
f3d_test(NAME TestInteractionConfigFileMulti DATA multi CONFIG ${F3D_SOURCE_DIR}/testing/configs/complex.json INTERACTION UI) #SY;Right;XG;Right;N;Right;Right
f3d_test(NAME TestInteractionConfigFileAndCommand DATA multi ARGS -o CONFIG ${F3D_SOURCE_DIR}/testing/configs/complex.json INTERACTION UI) #OX;Right;N;Right;Right;Right
f3d_test(NAME TestInteractionConfigFileImperative DATA dragon.vtu suzanne.stl ARGS --edges CONFIG ${F3D_SOURCE_DIR}/testing/configs/imperative.json INTERACTION) #E;Right
f3d_test(NAME TestInteractionConfigFileImperativeNoData CONFIG ${F3D_SOURCE_DIR}/testing/configs/imperative.json INTERACTION NO_DATA_FORCE_RENDER) #X;Up
f3d_test(NAME TestInteractionCycleVerbose DATA dragon.vtu ARGS --verbose -s NO_BASELINE INTERACTION REGEXP "Not coloring")#SSSSYC
f3d_test(NAME TestInteractionEmptyDrop INTERACTION REGEXP "Drop event without any provided files.")#DropEvent Empty;
f3d_test(NAME TestInteractionCameraUpdate DATA dragon.vtu INTERACTION) #MouseWheel;MouseWheel;MouseWheel;S
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions testing/recordings/TestInteractionConfigFileImperativeNoData.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# StreamVersion 1.2
ConfigureEvent 960 1033 0 0 0 0 0
ExposeEvent 0 1055 0 0 0 0 0
RenderEvent 0 1055 0 0 0 0 0
TimerEvent 0 1055 0 0 0 0 0
TimerEvent 0 1055 0 0 0 0 0
EnterEvent 581 217 0 0 0 0 0
TimerEvent 581 217 0 0 0 0 0
TimerEvent 581 217 0 0 0 0 0
KeyPressEvent 581 217 0 101 1 x 0
CharEvent 581 217 0 101 1 x 0
TimerEvent 581 217 0 101 1 x 0
KeyReleaseEvent 581 217 0 101 1 x 0
TimerEvent 581 217 0 101 1 x 0
TimerEvent 581 217 0 101 1 x 0
KeyPressEvent 581 217 0 0 1 Up 0
CharEvent 581 217 0 0 1 Up 0
TimerEvent 581 217 0 0 1 Up 0
KeyReleaseEvent 581 217 0 0 1 Up 0