Skip to content

Add ImGui Minimal Console Feature #2099

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

Merged
merged 53 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
3ca2e69
Added binding for minimal console mode, added option and documentatio…
wizzebit Mar 23, 2025
d81f926
renamed option, added minimal console behavior
wizzebit Mar 23, 2025
721bbd3
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Mar 24, 2025
f87d1db
extra functionality, need to make comments
wizzebit Mar 25, 2025
6826c62
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Mar 26, 2025
8cfc009
new version of minimal console
wizzebit Mar 27, 2025
09f411c
Merge branch 'ImGUI-minimal' of https://github.com/wizzebit/f3d into …
wizzebit Mar 27, 2025
afb0c81
updated options.md
wizzebit Mar 28, 2025
d8da20a
Update library/src/interactor_impl.cxx
wizzebit Mar 28, 2025
0f8c910
Update library/src/interactor_impl.cxx
wizzebit Mar 28, 2025
4a6968a
Update vtkext/private/module/vtkF3DImguiConsole.cxx
wizzebit Mar 28, 2025
4cd259b
Update vtkext/private/module/vtkF3DImguiConsole.cxx
wizzebit Mar 28, 2025
ca8a7a8
Update vtkext/private/module/vtkF3DImguiConsole.cxx
wizzebit Mar 28, 2025
66d100d
minor fixes
wizzebit Mar 28, 2025
84830af
- changed minimal console format
wizzebit Mar 28, 2025
cb29634
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Mar 28, 2025
d264b9d
Update vtkext/private/module/vtkF3DImguiConsole.cxx
wizzebit Mar 28, 2025
c920c8b
Update vtkext/private/module/vtkF3DImguiConsole.h
wizzebit Mar 28, 2025
22d9533
Update vtkext/private/module/vtkF3DImguiConsole.h
wizzebit Mar 28, 2025
56e860a
attempt to fix github actions issue
wizzebit Mar 28, 2025
523c83c
Update vtkext/private/module/vtkF3DImguiConsole.h
wizzebit Mar 28, 2025
cf5e92e
added priority for console
wizzebit Mar 29, 2025
d990f59
Update library/src/interactor_impl.cxx
wizzebit Mar 29, 2025
a362e58
Update library/src/window_impl.cxx
wizzebit Mar 29, 2025
9f65921
merged master and imgui minimal mode branch
wizzebit Mar 30, 2025
5daeb5a
Update doc/libf3d/OPTIONS.md
wizzebit Mar 30, 2025
aab3048
Update doc/libf3d/OPTIONS.md
wizzebit Mar 30, 2025
9396a05
added colon binding
wizzebit Mar 30, 2025
f86fcc5
Merge branch 'ImGUI-minimal' of https://github.com/wizzebit/f3d into …
wizzebit Mar 30, 2025
2ec2782
fixed flashing issue
wizzebit Apr 4, 2025
e5ef03a
Fixed unresponsive badge issue
wizzebit Apr 4, 2025
463a92b
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Apr 4, 2025
99493fa
styling fixes
wizzebit Apr 4, 2025
b7f412d
styling
wizzebit Apr 4, 2025
a45c06b
styling
wizzebit Apr 4, 2025
31d4c02
styling
wizzebit Apr 4, 2025
2291004
styling
wizzebit Apr 4, 2025
26a4296
Merge branch 'ImGUI-minimal' of https://github.com/wizzebit/f3d into …
wizzebit Apr 4, 2025
91fb582
Update vtkF3DUIActor.h
wizzebit Apr 4, 2025
30eb9a3
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Apr 13, 2025
307fb93
Added Minimal Console Interaction Tests
wizzebit Apr 13, 2025
5bf6f95
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Apr 16, 2025
f88ea06
-modified console badge position to be level with minimal console
wizzebit Apr 16, 2025
1ded2e3
Merge branch 'ImGUI-minimal' of https://github.com/wizzebit/f3d into …
wizzebit Apr 16, 2025
42b6a77
Update vtkext/private/module/vtkF3DImguiConsole.cxx
wizzebit Apr 16, 2025
9c04f36
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Apr 17, 2025
d82aa90
- Shortened log code
wizzebit Apr 17, 2025
21f8774
Merge branch 'f3d-app:master' into ImGUI-minimal
wizzebit Apr 22, 2025
882ba5e
changed minimal console position and size
wizzebit Apr 22, 2025
ab5bba9
made minimal console resize when badge and updated test
wizzebit Apr 23, 2025
96dc206
updated cheatsheet test baseline
wizzebit Apr 24, 2025
25a6828
updated cheatsheet test baseline
wizzebit Apr 24, 2025
3b126e9
Merge branch 'ImGUI-minimal' of https://github.com/wizzebit/f3d into …
wizzebit Apr 24, 2025
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 doc/libf3d/OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ See the [APIs](#APIs) details below for more info.
| 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.minimal_console | bool<br>false<br>render | Enable minimal console mode. Only latest command output is displayed. | - |
| 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 | path<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
4 changes: 4 additions & 0 deletions library/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@
"type": "bool",
"default_value": "false"
},
"minimal_console": {
"type": "bool",
"default_value": "false"
},
"dropzone": {
"type": "bool",
"default_value": "false"
Expand Down
18 changes: 16 additions & 2 deletions library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ class interactor_impl::internals
internals* self = static_cast<internals*>(clientData);
vtkRenderWindowInteractor* rwi = self->Style->GetInteractor();
std::string interaction = rwi->GetKeySym();
if (interaction == "semicolon" && rwi->GetShiftKey() == 1)
{
interaction = "colon";
}
if (!interaction.empty())
{
// Make sure key symbols starts with an upper char (e.g. "space" -> "Space")
Expand Down Expand Up @@ -442,7 +446,7 @@ class interactor_impl::internals
{
mod = mod_t::CTRL;
}
else if (shift)
else if (shift && interaction != "Colon")
{
mod = mod_t::SHIFT;
}
Expand Down Expand Up @@ -671,6 +675,16 @@ interactor& interactor_impl::initCommands()
#endif
});

this->addCommand(":q",
[&](const std::vector<std::string>& args)
{
check_args(args, 0, ":q");
if (this->Internals->Options.ui.minimal_console)
{
this->Internals->Options.ui.minimal_console = false;
}
});

this->addCommand("print",
[&](const std::vector<std::string>& args)
{
Expand Down Expand Up @@ -1087,6 +1101,7 @@ interactor& interactor_impl::initBindings()
#if F3D_MODULE_UI
this->addBinding({mod_t::NONE, "H"}, "toggle ui.cheatsheet", "Others", std::bind(docStr, "Toggle cheatsheet display"));
this->addBinding({mod_t::NONE, "Escape"}, "toggle ui.console", "Others", std::bind(docStr, "Toggle console display"));
this->addBinding({mod_t::NONE, "Colon"}, "toggle ui.minimal_console", "Others", std::bind(docStr, "Toggle minimal console display"));
#endif
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"));
Expand Down Expand Up @@ -1216,7 +1231,6 @@ interactor& interactor_impl::toggleAnimation()
this->Internals->AnimationManager->ToggleAnimation();
return *this;
}

//----------------------------------------------------------------------------
interactor& interactor_impl::startAnimation()
{
Expand Down
1 change: 1 addition & 0 deletions library/src/window_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ void window_impl::UpdateDynamicOptions()
renderer->ShowMetaData(opt.ui.metadata);
renderer->ShowCheatSheet(opt.ui.cheatsheet);
renderer->ShowConsole(opt.ui.console);
renderer->ShowMinimalConsole(opt.ui.minimal_console);
renderer->ShowDropZone(opt.ui.dropzone);
renderer->SetDropZoneInfo(opt.ui.dropzone_info);
renderer->ShowArmature(opt.render.armature.enable);
Expand Down
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DConsoleOutputWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class vtkF3DConsoleOutputWindow : public vtkOutputWindow
{
TriggerEvent = vtkCommand::UserEvent + 200,
ShowEvent,
HideEvent
HideEvent,
};

/**
Expand Down
7 changes: 7 additions & 0 deletions vtkext/private/module/vtkF3DImguiActor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,13 @@ void vtkF3DImguiActor::RenderConsole()
console->ShowConsole();
}

//----------------------------------------------------------------------------
void vtkF3DImguiActor::RenderMinimalConsole()
{
vtkF3DImguiConsole* console = vtkF3DImguiConsole::SafeDownCast(vtkOutputWindow::GetInstance());
console->ShowMinimalConsole();
}

//----------------------------------------------------------------------------
void vtkF3DImguiActor::RenderConsoleBadge()
{
Expand Down
5 changes: 5 additions & 0 deletions vtkext/private/module/vtkF3DImguiActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ class vtkF3DImguiActor : public vtkF3DUIActor
*/
void RenderConsole() override;

/**
* Render the minimal console widget
*/
void RenderMinimalConsole() override;

/**
* Render the console badge
*/
Expand Down
113 changes: 112 additions & 1 deletion vtkext/private/module/vtkF3DImguiConsole.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,117 @@ void vtkF3DImguiConsole::ShowConsole()
ImGui::End();
}

//----------------------------------------------------------------------------
void vtkF3DImguiConsole::ShowMinimalConsole()
{
ImGuiViewport* viewport = ImGui::GetMainViewport();

constexpr float margin = 30.f;
const float reservedHeight = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();

this->Pimpl->NewError = false;
this->Pimpl->NewWarning = false;

ImGui::SetNextWindowPos(ImVec2(margin, margin));
if (this->Pimpl->Logs.empty())
{
ImGui::SetNextWindowSize(ImVec2(viewport->WorkSize.x - 2.f * margin, reservedHeight + margin));
}
else
{
const auto& [severity, msg] = this->Pimpl->Logs.back();
ImGui::SetNextWindowSize(ImVec2(viewport->WorkSize.x - 2.f * margin,
ImGui::CalcTextSize(msg.c_str()).y + reservedHeight + margin));
}
ImGui::SetNextWindowBgAlpha(0.9f);

ImGuiWindowFlags winFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove;

ImGui::Begin("Console", nullptr, winFlags);

// Log window
if (ImGui::BeginChild(
"LogRegion", ImVec2(0, -reservedHeight), 0, ImGuiWindowFlags_HorizontalScrollbar) &&
!this->Pimpl->Logs.empty())
!this->Pimpl->Logs.empty())
{
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing

const auto& [severity, msg] = this->Pimpl->Logs.back();
bool hasColor = true;

if (this->GetUseColoring())
{
switch (severity)
{
case Internals::LogType::Error:
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
break;
case Internals::LogType::Warning:
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 0.0f, 1.0f));
break;
case Internals::LogType::Typed:
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.0f, 1.0f, 1.0f, 1.0f));
break;
default:
hasColor = false;
}
}
else
{
hasColor = false;
}

ImGui::TextUnformatted(msg.c_str());
if (hasColor)
{
ImGui::PopStyleColor();
}

if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
{
ImGui::SetScrollHereY(1.0f);
}

ImGui::PopStyleVar();
}
ImGui::EndChild();

ImGui::Separator();

// input
ImGuiInputTextFlags inputFlags =
ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_EscapeClearsAll;

ImGui::Text("> ");
ImGui::SameLine();

ImGui::PushItemWidth(-1);
bool runCommand = ImGui::InputText("##ConsoleInput", this->Pimpl->CurrentInput.data(),
sizeof(this->Pimpl->CurrentInput), inputFlags, nullptr, this->Pimpl.get());
ImGui::PopItemWidth();

ImGui::SetItemDefaultFocus();

// if always forcing the focus, it prevents grabbing the scrollbar
if (!ImGui::IsAnyItemActive())
{
ImGui::SetKeyboardFocusHere(-1);
}

// do not run the command if nothing is in the input text
if (runCommand && this->Pimpl->CurrentInput[0] != 0)
{
this->Pimpl->Logs.emplace_back(std::make_pair(
Internals::LogType::Typed, std::string("> ") + this->Pimpl->CurrentInput.data()));
this->InvokeEvent(vtkF3DImguiConsole::TriggerEvent, this->Pimpl->CurrentInput.data());
this->Pimpl->CurrentInput = {};
}

ImGui::End();
}

//----------------------------------------------------------------------------
void vtkF3DImguiConsole::ShowBadge()
{
Expand Down Expand Up @@ -213,4 +324,4 @@ void vtkF3DImguiConsole::Clear()
this->Pimpl->Logs.clear();
this->Pimpl->NewError = false;
this->Pimpl->NewWarning = false;
}
}
7 changes: 6 additions & 1 deletion vtkext/private/module/vtkF3DImguiConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ class vtkF3DImguiConsole : public vtkF3DConsoleOutputWindow
*/
void ShowConsole();

/**
* Show minimal console window
*/
void ShowMinimalConsole();

/**
* Show console badge
*/
void ShowBadge();

/**
* Clear console
*/
Expand Down
11 changes: 11 additions & 0 deletions vtkext/private/module/vtkF3DRenderer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,17 @@ void vtkF3DRenderer::ShowConsole(bool show)
}
}

//----------------------------------------------------------------------------
void vtkF3DRenderer::ShowMinimalConsole(bool show)
{
if (this->MinimalConsoleVisible != show)
{
this->MinimalConsoleVisible = show;
this->UIActor->SetMinimalConsoleVisibility(show);
this->CheatSheetConfigured = false;
}
}

//----------------------------------------------------------------------------
void vtkF3DRenderer::ConfigureCheatSheet(const std::vector<vtkF3DUIActor::CheatSheetGroup>& info)
{
Expand Down
2 changes: 2 additions & 0 deletions vtkext/private/module/vtkF3DRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class vtkF3DRenderer : public vtkOpenGLRenderer
void ShowFilename(bool show);
void ShowCheatSheet(bool show);
void ShowConsole(bool show);
void ShowMinimalConsole(bool show);
void ShowDropZone(bool show);
void ShowHDRISkybox(bool show);
void ShowArmature(bool show);
Expand Down Expand Up @@ -515,6 +516,7 @@ class vtkF3DRenderer : public vtkOpenGLRenderer
bool MetaDataVisible = false;
bool CheatSheetVisible = false;
bool ConsoleVisible = false;
bool MinimalConsoleVisible = false;
bool DropZoneVisible = false;
bool HDRISkyboxVisible = false;
bool ArmatureVisible = false;
Expand Down
10 changes: 10 additions & 0 deletions vtkext/private/module/vtkF3DUIActor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ void vtkF3DUIActor::SetConsoleVisibility(bool show)
this->ConsoleVisible = show;
}

//----------------------------------------------------------------------------
void vtkF3DUIActor::SetMinimalConsoleVisibility(bool show)
{
this->MinimalConsoleVisible = show;
}

//----------------------------------------------------------------------------
void vtkF3DUIActor::SetConsoleBadgeEnabled(bool enabled)
{
Expand Down Expand Up @@ -158,6 +164,10 @@ int vtkF3DUIActor::RenderOverlay(vtkViewport* vp)
{
this->RenderConsole();
}
else if (this->MinimalConsoleVisible)
{
this->RenderMinimalConsole();
}
else if (this->ConsoleBadgeEnabled)
{
this->RenderConsoleBadge();
Expand Down
14 changes: 14 additions & 0 deletions vtkext/private/module/vtkF3DUIActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ class vtkF3DUIActor : public vtkProp
*/
void SetConsoleVisibility(bool show);

/**
* Set the minimal console visibility
* False by default
*/
void SetMinimalConsoleVisibility(bool show);

/**
* Set the console badge enabled status
* False by default
Expand Down Expand Up @@ -185,6 +191,13 @@ class vtkF3DUIActor : public vtkProp
{
}

/**
* Render the minimal console widget
*/
virtual void RenderMinimalConsole()
{
}

/**
* Render the console badge
*/
Expand All @@ -205,6 +218,7 @@ class vtkF3DUIActor : public vtkProp
std::vector<CheatSheetGroup> CheatSheet;

bool ConsoleVisible = false;
bool MinimalConsoleVisible = false;
bool ConsoleBadgeEnabled = false;

bool FpsCounterVisible = false;
Expand Down
Loading