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

ImGui-based console #1748

Merged
merged 28 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ endif()
if(F3D_WINDOWS_GUI)
# Windows executable without console
set_target_properties(f3d PROPERTIES WIN32_EXECUTABLE TRUE)
else()
# force usage of wWinMainCRTStartup for Unicode support
list(APPEND f3d_link_options_public "/ENTRY:wWinMainCRTStartup")
endif()
Expand Down
4 changes: 2 additions & 2 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ f3d_test(NAME TestVerboseAnimationWrongAnimationTimeHigh DATA BoxAnimated.gltf A
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;
f3d_test(NAME TestInteractionSimpleExit DATA cow.vtp REGEXP "Interactor has been stopped" INTERACTION NO_BASELINE) #CTRL;Q

# No alternative baseline supports in F3D
if(F3D_MODULE_RAYTRACING)
Expand Down Expand Up @@ -806,7 +806,7 @@ f3d_test(NAME TestInteractionRotateCamera90 DATA f3d.glb INTERACTION)
f3d_test(NAME TestInteractionPanWithShift DATA f3d.glb INTERACTION) #Shift;LeftMouse;MouseMovements
f3d_test(NAME TestInteractionFileOpen INTERACTION NO_BASELINE ENV CTEST_OPEN_DIALOG_FILE=${F3D_SOURCE_DIR}/testing/data/cow.vtp)
f3d_test(NAME TestInteractionConsoleOpen DATA f3d.glb INTERACTION UI) #Escape
f3d_test(NAME TestInteractionConsoleOpenExit DATA f3d.glb INTERACTION UI) #Escape;exit;Return
f3d_test(NAME TestInteractionConsoleOpenExit DATA f3d.glb REGEXP "Interactor has been stopped" INTERACTION NO_BASELINE) #Escape;exit;Return
f3d_test(NAME TestInteractionConsoleOpenWarningKeyboard DATA f3d.glb ARGS --position=0 INTERACTION UI) #Escape
f3d_test(NAME TestInteractionConsoleOpenWarningClick DATA f3d.glb ARGS --position=0 INTERACTION UI) #Click badge
f3d_test(NAME TestInteractionConsoleToggleGrid DATA f3d.glb INTERACTION UI) #Escape;toggle render.grid.enable;Return;Escape
Expand Down
1 change: 1 addition & 0 deletions library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ interactor& interactor_impl::initBindings()
this->addBinding({mod_t::NONE, "Escape"}, "toggle ui.console", "Others", std::bind(docStr, "Toggle console display"));
#endif
this->addBinding({mod_t::ANY, "Question"}, "print_scene_info", "Others", std::bind(docStr, "Print scene descr to terminal"));
this->addBinding({mod_t::CTRL, "Q"}, "stop_interactor", "Others", std::bind(docStr, "Stop the interactor"));
this->addBinding({mod_t::NONE, "Return"}, "reset_camera", "Others", std::bind(docStr, "Reset camera to initial parameters"));
this->addBinding({mod_t::NONE, "Space"}, "toggle_animation", "Others", std::bind(docStr, "Play/Pause animation if any"));
this->addBinding({mod_t::NONE, "Drop"}, "add_files", "Others", std::bind(docStr, "Add files to the scene"));
Expand Down
3 changes: 0 additions & 3 deletions testing/baselines/TestInteractionConsoleOpenExit.png

This file was deleted.

11 changes: 6 additions & 5 deletions testing/recordings/TestInteractionSimpleExit.log
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# StreamVersion 1.1
ExposeEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
KeyPressEvent -604 609 0 0 1 Control_L
KeyPressEvent 529 510 0 113 1 q
# StreamVersion 1.2
KeyPressEvent -546 836 0 0 1 Control_L 0
CharEvent -546 836 0 0 1 Control_L 0
KeyPressEvent -546 836 2 113 1 q 0
CharEvent -546 836 2 113 1 q 0
KeyReleaseEvent -546 836 2 113 1 q 0
2 changes: 0 additions & 2 deletions vtkext/private/module/vtkF3DConfigure.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <string>

// TODO: Use CMake definitions and get rid of these
#cmakedefine01 F3D_WINDOWS_GUI

#cmakedefine01 F3D_MODULE_RAYTRACING
#cmakedefine01 F3D_MODULE_EXR
#cmakedefine01 F3D_MODULE_UI
Expand Down
3 changes: 1 addition & 2 deletions vtkext/private/module/vtkF3DImguiConsole.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ void vtkF3DImguiConsole::DisplayText(const char* text)
this->Pimpl->Logs.emplace_back(std::make_pair(Internals::LogType::Log, text));
}

// still print text to std::cout in
// order to be able to test verbose outputs
// also print text to std::cout
this->Superclass::DisplayText(text);
}

Expand Down
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DImguiConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* This class is used instead of vtkF3DConsoleOutputWindow if F3D_MODULE_UI is enabled
* On top of the regular behavior of printing the log in the console, all the logs are also added
* in an imgui window so the user can access it easily by pressing `Escape`.
* in an imgui window so the user can access it easily by enabling the `ui.console` option.
* It is also adding an input widget where commands registered in libf3d can be executed.
* Finally, a small icon is displayed on the top right corner when the console is hidden but a new
* warning or error is logged.
Expand Down
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DRenderer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ void vtkF3DRenderer::ConfigureTextActors()
{
this->DropZoneActor->GetTextProperty()->SetFontFamily(VTK_FONT_FILE);
this->DropZoneActor->GetTextProperty()->SetFontFile(tmpFontFile.c_str());
this->UIActor->SetFontFile(vtkOpenGLRenderWindow::SafeDownCast(this->RenderWindow), tmpFontFile);
this->UIActor->SetFontFile(tmpFontFile);
}
else
{
Expand Down
11 changes: 9 additions & 2 deletions vtkext/private/module/vtkF3DUIActor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,26 @@ void vtkF3DUIActor::SetFpsValue(int fps)
}

//----------------------------------------------------------------------------
void vtkF3DUIActor::SetFontFile(vtkOpenGLRenderWindow* renWin, const std::string& font)
void vtkF3DUIActor::SetFontFile(const std::string& font)
{
if (this->FontFile != font)
{
this->FontFile = font;
this->Initialize(renWin);
this->Initialized = false;
}
}

//----------------------------------------------------------------------------
int vtkF3DUIActor::RenderOverlay(vtkViewport* vp)
{
vtkOpenGLRenderWindow* renWin = vtkOpenGLRenderWindow::SafeDownCast(vp->GetVTKWindow());

if (!this->Initialized)
{
this->Initialize(renWin);
this->Initialized = true;
}

this->StartFrame(renWin);

if (this->FileNameVisible)
Expand Down
5 changes: 3 additions & 2 deletions vtkext/private/module/vtkF3DUIActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ class vtkF3DUIActor : public vtkProp
/**
* Set the font file path
* Use Inter font by default if empty
* A valid OpenGL context must be specified by providing the render window
*/
void SetFontFile(vtkOpenGLRenderWindow* renWin, const std::string& font);
void SetFontFile(const std::string& font);

/**
* Render the UI actor
Expand Down Expand Up @@ -155,6 +154,8 @@ class vtkF3DUIActor : public vtkProp
private:
vtkF3DUIActor(const vtkF3DUIActor&) = delete;
void operator=(const vtkF3DUIActor&) = delete;

bool Initialized = false;
};

#endif
Loading