Skip to content

Commit

Permalink
Add imgui-based console
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk committed Dec 5, 2024
1 parent 1d2f6b0 commit 8eff437
Show file tree
Hide file tree
Showing 86 changed files with 843 additions and 371 deletions.
3 changes: 1 addition & 2 deletions .github/actions/generic-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ runs:
-DF3D_TESTING_ENABLE_LONG_TIMEOUT_TESTS=${{ (runner.os == 'Linux' || runner.os == 'Windows') && 'ON' || 'OFF' }}
-DF3D_TESTING_ENABLE_OSMESA_TESTS=${{ runner.os == 'Linux' && 'ON' || 'OFF' }}
-DF3D_TESTING_FORCE_RENDERING_BACKEND=${{ inputs.rendering_backend }}
-DF3D_WINDOWS_GUI=ON
${{ runner.os == 'Windows' && '-Ax64 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL' || null }}
${{ runner.os == 'macOS' && '-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15' || null }}
Expand Down Expand Up @@ -348,7 +347,7 @@ runs:
inputs.cpu != 'arm64' && inputs.static_label == 'no-static' && inputs.optional_deps_label == 'optional-deps'
shell: bash
working-directory: ${{github.workspace}}/install
run: F3D_PLUGINS_PATH=$(pwd)/../build_plugins/example-plugin${{ runner.os == 'Windows' && '/Release' || null }} ${{ env.F3D_BIN_PATH }} ../source/examples/plugins/example-plugin/data.expl --load-plugins=example --output=../install_example_plugin_output.png --ref=../source/.github/baselines/install_example_plugin_output.png --resolution=300,300 --verbose
run: F3D_PLUGINS_PATH=$(pwd)/../build_plugins/example-plugin${{ runner.os == 'Windows' && '/Release' || null }} ${{ env.F3D_BIN_PATH }} ../source/examples/plugins/example-plugin/data.expl --load-plugins=example --output=../install_example_plugin_output.png --ref=../source/.github/baselines/install_example_plugin_output.png --resolution=300,300 --rendering-backend=${{ inputs.rendering_backend }} --verbose

- name: Install plugin examples
if: inputs.static_label == 'no-static'
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ endif()

# Shared options between application and library
include(GNUInstallDirs)
cmake_dependent_option(F3D_WINDOWS_GUI "Build a non-console Win32 application" ON "WIN32" OFF)
cmake_dependent_option(F3D_MACOS_BUNDLE "Build a macOS bundle application" ON "APPLE" OFF)

# Force static library when creating a macOS bundle
Expand Down
8 changes: 2 additions & 6 deletions application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,8 @@ endif()

# Windows executable without console
if(WIN32)
if(F3D_WINDOWS_GUI)
set_target_properties(f3d PROPERTIES WIN32_EXECUTABLE TRUE)
else()
# force usage of wWinMainCRTStartup in console mode for Unicode support
list(APPEND f3d_link_options_public "/ENTRY:wWinMainCRTStartup")
endif()
# force usage of wWinMainCRTStartup in console mode for Unicode support
list(APPEND f3d_link_options_public "/ENTRY:wWinMainCRTStartup")
endif()

target_compile_options(f3d PUBLIC ${f3d_compile_options_public} PRIVATE ${f3d_compile_options_private})
Expand Down
4 changes: 2 additions & 2 deletions application/F3DConfigFileTools.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ F3DConfigFileTools::ReadConfigFiles(const std::string& userConfig)
}
}

// If we used a configSearch but did not find any, warn the user
// If we used a configSearch but did not find any, inform the user
if (!configSearch.empty() && actualConfigFilePaths.empty())
{
f3d::log::warn("Configuration file for \"", configSearch, "\" could not be found");
f3d::log::info("Configuration file for \"", configSearch, "\" could not be found");
}

// Read config files
Expand Down
4 changes: 0 additions & 4 deletions application/F3DOptionsTools.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ void PrintHelp(const std::string& execName, const cxxopts::Options& cxxOptions)
}
f3d::log::info("\nReport bugs to https://github.com/f3d-app/f3d/issues");
f3d::log::setUseColoring(true);
f3d::log::waitForUser();
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -266,7 +265,6 @@ void PrintVersion()
}
f3d::log::info("License " + libInfo.License + ".");
f3d::log::setUseColoring(true);
f3d::log::waitForUser();
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -338,7 +336,6 @@ void PrintReadersList()
f3d::log::info(readerLine.str());
}
}
f3d::log::waitForUser();
}
}

Expand Down Expand Up @@ -530,7 +527,6 @@ F3DOptionsTools::OptionsDict F3DOptionsTools::ParseCLIOptions(
}
if (foundUnknownOption)
{
f3d::log::waitForUser();
throw F3DExFailure("unknown options");
}

Expand Down
1 change: 1 addition & 0 deletions application/F3DStarter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,7 @@ void F3DStarter::SaveScreenshot(const std::string& filenameTemplate, bool minima
{
options.ui.scalar_bar = false;
options.ui.cheatsheet = false;
options.ui.console = false;
options.ui.filename = false;
options.ui.fps = false;
options.ui.metadata = false;
Expand Down
1 change: 0 additions & 1 deletion application/main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ int main(int argc, char** argv)
{
f3d::log::error("F3D encountered an unexpected exception:");
f3d::log::error(ex.what());
f3d::log::waitForUser();
exit(EXIT_FAILURE);
}

Expand Down
28 changes: 15 additions & 13 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ f3d_test(NAME TestVTU DATA dragon.vtu)
f3d_test(NAME TestVTP DATA cow.vtp)
f3d_test(NAME TestVTR DATA RectGrid2.vtr ARGS --scalar-coloring --roughness=1)
f3d_test(NAME TestVTS DATA bluntfin.vts)
f3d_test(NAME TestVTM DATA mb.vtm)
f3d_test(NAME TestVTM DATA mb.vtm UI)
f3d_test(NAME TestVTK DATA cow.vtk)
f3d_test(NAME TestNRRD DATA beach.nrrd ARGS -s)
f3d_test(NAME TestSPLAT DATA small.splat ARGS -osy --up=-Y --point-sprites-size=1)
Expand Down Expand Up @@ -226,8 +226,8 @@ f3d_test(NAME TestComponentName DATA from_abq.vtu ARGS --scalar-coloring --bar -
f3d_test(NAME TestNoRender DATA dragon.vtu NO_RENDER)
f3d_test(NAME TestNoRenderWithOptions DATA dragon.vtu ARGS --hdri-ambient --axis NO_RENDER) # These options causes issues if not handled correctly
f3d_test(NAME TestNoFile NO_DATA_FORCE_RENDER)
f3d_test(NAME TestMultiFile DATA mb/recursive ARGS --multi-file-mode=all)
f3d_test(NAME TestMultiFileColoring DATA mb/recursive ARGS --multi-file-mode=all -s --coloring-array=Polynomial -b)
f3d_test(NAME TestMultiFile DATA mb/recursive ARGS --multi-file-mode=all UI)
f3d_test(NAME TestMultiFileColoring DATA mb/recursive ARGS --multi-file-mode=all -s --coloring-array=Polynomial -b UI)
f3d_test(NAME TestMultiFileVolume DATA multi ARGS --multi-file-mode=all -vsb --coloring-array=Scalars_)
f3d_test(NAME TestMultiFileColoringTexture DATA mb/recursive/mb_1_0.vtp mb/recursive/mb_2_0.vtp world.obj ARGS --multi-file-mode=all -sb --coloring-array=Normals --comp=1)
f3d_test(NAME TestMultiFilePositionals DATA mb/recursive/mb_0_0.vtu mb/recursive/mb_1_0.vtp ARGS --multi-file-mode=all -s --coloring-array=Polynomial -b)
Expand Down Expand Up @@ -395,9 +395,6 @@ f3d_test(NAME TestInteractionAnimationFrameRate DATA InterpolationTest.glb ARGS
f3d_test(NAME TestVerboseAnimationWrongAnimationTimeHigh DATA BoxAnimated.gltf ARGS --animation-time=10 --verbose REGEXP "Animation time 10 is outside of range \\[0, 3\\.70833\\], using 3\\.70833" NO_BASELINE)
f3d_test(NAME TestVerboseAnimationWrongAnimationTimeLow DATA BoxAnimated.gltf ARGS --animation-time=-5 --verbose REGEXP "Animation time -5 is outside of range \\[0, 3\\.70833\\], using 0" NO_BASELINE)

# Test exit hotkey
f3d_test(NAME TestInteractionSimpleExit DATA cow.vtp REGEXP "Interactor has been stopped" INTERACTION NO_BASELINE) #Escape;

# No alternative baseline supports in F3D
if(F3D_MODULE_RAYTRACING)
f3d_test(NAME TestInteractionCheatsheetRaytracing DATA cow.vtp INTERACTION UI) #H
Expand Down Expand Up @@ -465,7 +462,7 @@ if(VTK_VERSION VERSION_GREATER_EQUAL 9.2.20221220)
f3d_test(NAME TestInvalidHDRI DATA cow.vtp HDRI invalid.png REGEXP "Cannot open HDRI file" NO_BASELINE)

# Use a dummy HDRI for simplicity to test default HDRI
f3d_test(NAME TestHDRIDefault DATA suzanne.ply HDRI dummy.png THRESHOLD 0.11) # Threshold is needed for legacy comparison method for VTK 9.3
f3d_test(NAME TestHDRIDefault DATA suzanne.ply HDRI dummy.png THRESHOLD 0.11 UI) # Threshold is needed for legacy comparison method for VTK 9.3

configure_file("${F3D_SOURCE_DIR}/testing/configs/hdri.json.in" "${CMAKE_BINARY_DIR}/hdri.json")
f3d_test(NAME TestConfigFileHDRI DATA dragon.vtu CONFIG "${CMAKE_BINARY_DIR}/hdri.json" LONG_TIMEOUT)
Expand Down Expand Up @@ -769,18 +766,18 @@ f3d_test(NAME TestInteractionVolumeAfterColoring DATA waveletArrays.vti ARGS INT
f3d_test(NAME TestInteractionVolumeInverse DATA HeadMRVolume.mhd ARGS --camera-position=127.5,-400,127.5 --camera-view-up=0,0,1 INTERACTION) #VI
f3d_test(NAME TestInteractionMultiFileVolume DATA multi ARGS --multi-file-mode=all INTERACTION) #SSVB
f3d_test(NAME TestInteractionPointCloud DATA pointsCloud.vtp ARGS --point-sprites-size=20 INTERACTION) #O
f3d_test(NAME TestInteractionDirectory DATA mb INTERACTION ARGS --scalar-coloring) #Right;Right;Right;Left;Up;
f3d_test(NAME TestInteractionDirectory DATA mb INTERACTION ARGS --scalar-coloring UI) #Right;Right;Right;Left;Up;
f3d_test(NAME TestInteractionDirectoryLoop DATA mb/recursive INTERACTION ARGS --scalar-coloring --filename UI) #Left;Left;Left;Left;Left;
f3d_test(NAME TestInteractionDirectoryEmpty DATA mb INTERACTION NO_DATA_FORCE_RENDER) #Right;Right;Right;
f3d_test(NAME TestInteractionDirectoryEmpty DATA mb INTERACTION NO_DATA_FORCE_RENDER UI) #Right;Right;Right;
f3d_test(NAME TestInteractionDirectoryEmptyVerbose DATA mb ARGS --verbose NO_BASELINE INTERACTION REGEXP "is not a file of a supported file format") #Right;Right;Right;HMCSY
f3d_test(NAME TestInteractionAnimationNotStopped DATA InterpolationTest.glb NO_BASELINE INTERACTION)#Space;
f3d_test(NAME TestInteractionResetCamera DATA dragon.vtu INTERACTION LONG_TIMEOUT)#MouseMovements;Return;
f3d_test(NAME TestInteractionResetCameraWithCameraIndex DATA CameraAnimated.glb ARGS --camera-index=0 INTERACTION)#MouseMovements;Return;
f3d_test(NAME TestInteractionTensorsCycleComp DATA tensors.vti ARGS --scalar-coloring --comp=-2 INTERACTION) #SYYYYYYYYYY
f3d_test(NAME TestInteractionTensorsCycleComp DATA tensors.vti ARGS --scalar-coloring --comp=-2 INTERACTION UI) #SYYYYYYYYYY
f3d_test(NAME TestInteractionCycleScalarsCompCheck DATA dragon.vtu ARGS -b --scalar-coloring --comp=2 INTERACTION) #S
f3d_test(NAME TestInteractionConfigFileNoColorBar DATA multi CONFIG ${F3D_SOURCE_DIR}/testing/configs/complex.json INTERACTION) #Right;Right;Left
f3d_test(NAME TestInteractionConfigFileBindings DATA dragon.vtu CONFIG ${F3D_SOURCE_DIR}/testing/configs/bindings.json INTERACTION UI) #Ctrl+Shift+O;Ctrl+O;Shift+O;O;3
f3d_test(NAME TestInteractionConfigFileMulti DATA multi CONFIG ${F3D_SOURCE_DIR}/testing/configs/complex.json INTERACTION) #SY;Right;XG;Right;N;Right;Right
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 TestInteractionDumpSceneState DATA dragon.vtu NO_BASELINE INTERACTION REGEXP "Camera position: 2.23745,3.83305,507.598")#?
f3d_test(NAME TestInteractionCycleVerbose DATA dragon.vtu ARGS --verbose -s NO_BASELINE INTERACTION REGEXP "Not coloring")#SSSSYC
Expand All @@ -790,7 +787,7 @@ f3d_test(NAME TestInteractionFocalPointPickingDefault DATA dragon.vtu INTERACTIO
f3d_test(NAME TestInteractionFocalPointPickingShift DATA dragon.vtu INTERACTION LONG_TIMEOUT)
f3d_test(NAME TestInteractionFocalPointPickingPoints DATA pointsCloud.vtp INTERACTION)
f3d_test(NAME TestInteractionLightIntensity DATA dragon.vtu INTERACTION LONG_TIMEOUT)
f3d_test(NAME TestInteractionMultiFileColoring DATA mb/recursive ARGS --multi-file-mode=all INTERACTION) #SSSB
f3d_test(NAME TestInteractionMultiFileColoring DATA mb/recursive ARGS --multi-file-mode=all INTERACTION UI) #SSSB
f3d_test(NAME TestInteractionReload DATA dragon.vtu ARGS -e INTERACTION) #Up;
f3d_test(NAME TestInteractionLoadParentDirectory DATA multi/dragon.vtu ARGS --filename INTERACTION UI) #Down;
f3d_test(NAME TestInteractionEmptyLoadParentDirectory INTERACTION NO_BASELINE REGEXP "No files loaded, no rendering performed") #Down;
Expand All @@ -803,6 +800,11 @@ f3d_test(NAME TestInteractionZoomToggleOrthographicProjection DATA cow.vtp INTER
f3d_test(NAME TestInteractionRotateCameraMinus90 DATA f3d.glb INTERACTION)
f3d_test(NAME TestInteractionRotateCamera90 DATA f3d.glb INTERACTION)
f3d_test(NAME TestInteractionPanWithShift DATA f3d.glb INTERACTION) #Shift;LeftMouse;MouseMovements
f3d_test(NAME TestInteractionConsoleOpen DATA f3d.glb INTERACTION UI) #Escape
f3d_test(NAME TestInteractionConsoleToggleGrid DATA f3d.glb INTERACTION UI) #Escape;toggle render.grid.enable;Return;Escape
f3d_test(NAME TestInteractionConsoleInvalidCommand DATA f3d.glb INTERACTION UI) #Escape;foo;Return
f3d_test(NAME TestInteractionConsoleInvalidOption DATA f3d.glb INTERACTION UI) #Escape;toggle foo;Return
f3d_test(NAME TestInteractionConsoleTypingSceneInfo DATA f3d.glb INTERACTION UI) #Escape;e;Escape;printt;BackSpace;_scee;Left;Right;_info;Return

# Progress test
f3d_test(NAME TestProgress DATA cow.vtp ARGS --progress NO_BASELINE)
Expand All @@ -815,7 +817,7 @@ f3d_test(NAME TestInteractionCycleAnimationNoAnimation DATA cow.vtp INTERACTION

f3d_test(NAME TestInteractionDropFiles ARGS -n INTERACTION_CONFIGURE UI)#X;DropEvent cow.vtp;DropEvent dragon.vtu suzanne.stl;
f3d_test(NAME TestInteractionMultiFileDrop ARGS --multi-file-mode=all -e INTERACTION_CONFIGURE) #DropEvent mb_1_0.vtp mb_2_0.vtp
f3d_test(NAME TestInteractionDropSameFiles ARGS -x INTERACTION_CONFIGURE)#DropEvent cow.vtp;#DropEvent dragon.vtu;#DropEvent cow.vtp#DropEvent cow.vtp;
f3d_test(NAME TestInteractionDropSameFiles ARGS -x INTERACTION_CONFIGURE UI) #DropEvent cow.vtp;#DropEvent dragon.vtu;#DropEvent cow.vtp#DropEvent cow.vtp;

# A proper test for this is not possible because of the double quotes
f3d_test(NAME TestInteractionDropFileWithQuotes ARGS -n INTERACTION REGEXP "\"'`Quotes\"'`.stl does not exist" NO_BASELINE)#X;DropEvent "'`Quotes"'`.stl";
Expand Down
1 change: 0 additions & 1 deletion doc/dev/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Here is some CMake options of interest:
* `F3D_BUILD_APPLICATION`: Build the F3D executable.
* `BUILD_TESTING`: Enable the [tests](TESTING.md).
* `F3D_MACOS_BUNDLE`: On macOS, build a `.app` bundle.
* `F3D_WINDOWS_GUI`: On Windows, build a Win32 application (without console).
* `F3D_WINDOWS_BUILD_SHELL_THUMBNAILS_EXTENSION`: On Windows, build the shell thumbnails extension.
* `F3D_PLUGINS_STATIC_BUILD`: Build all plugins as static library (embedded into `libf3d`) and automatically loaded by the application. Incompatible with `F3D_MACOS_BUNDLE`.
* `BUILD_SHARED_LIBS`: Build the libf3d and all plugins as static library (embedded into `f3d` executable). The `library` and `plugin_sdk` component will not be installed.
Expand Down
1 change: 1 addition & 0 deletions doc/libf3d/OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Option|Type<br>Default<br>Trigger|Description|F3D option
:---:|:---:|:---|:---:
ui.scalar_bar|bool<br>false<br>render|Show *scalar bar* of the coloring by data array.|\-\-bar
ui.cheatsheet|bool<br>false<br>render|Show a interactor cheatsheet
ui.console|bool<br>false<br>render|Show the console
ui.filename|bool<br>false<br>render|Display the *filename info content* on top of the window.|\-\-filename
ui.filename_info|string<br>-<br>render|Content of *filename info* to display.
ui.font_file|string<br>optional<br>render|Use the provided FreeType compatible font file to display text.<br>Can be useful to display non-ASCII filenames.|\-\-font-file
Expand Down
6 changes: 5 additions & 1 deletion doc/user/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Supports `front`, `top`, `right`, `isometric` arguments. eg: `set_camera top`.

`toggle_volume_rendering`: A specific command to toggle `model.volume.enable` and print coloring information. No argument.

`stop_interactor`: A specific command to stop the interactor hence quitting the application. No argument.
`exit`: A specific command to stop the interactor hence quitting the application. No argument.

`reset_camera`: A specific command to reset the camera to its original location. No argument.

Expand Down Expand Up @@ -91,6 +91,10 @@ print_scene_info # Another comment
increase_light_intensity
```

## Console

If F3D is built with `F3D_MODULE_UI` support, pressing <kbd>Esc</kbd> will open the console mode. It's possible to type any command in the input field and pressing <kbd>Enter</kbd> will trigger the command instantly.

## Command syntax

Command syntax is similar to bash, as in they will be split by "token" to be processed.
Expand Down
2 changes: 1 addition & 1 deletion doc/user/INTERACTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Other hotkeys and interactions are available:

* <kbd>H</kbd>: key to toggle the display of a cheat sheet showing all these hotkeys and their statuses.
* <kbd>?</kbd>: key to print scene description to the terminal.
* <kbd>Esc</kbd>: close the window and quit F3D.
* <kbd>Esc</kbd>: display/hide the console.
* <kbd>Space</kbd>: play the animation if any.
* <kbd>&larr;</kbd>: load the previous file if any and reset the camera.
* <kbd>&rarr;</kbd>: load the next file if any and reset the camera.
Expand Down
4 changes: 4 additions & 0 deletions library/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
"type": "bool",
"default_value": "false"
},
"console": {
"type": "bool",
"default_value": "false"
},
"dropzone": {
"type": "bool",
"default_value": "false"
Expand Down
7 changes: 0 additions & 7 deletions library/public/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace f3d
* A class to output logs to the standard output.
* It supports different levels, errors, warnings and info, with associated coloring.
* A few static methods exists to control the coloring and the verbosity level
* A waitForUser utility static method exist for windows.
*
*/
class F3D_EXPORT log
Expand Down Expand Up @@ -106,12 +105,6 @@ class F3D_EXPORT log
*/
static void setVerboseLevel(VerboseLevel level, bool forceStdErr = false);

/**
* Wait for user if applicable (eg: win32 output window).
* No effect otherwise.
*/
static void waitForUser();

protected:
//! @cond
static void appendArg(std::stringstream&)
Expand Down
Loading

0 comments on commit 8eff437

Please sign in to comment.