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

Clear command #1836

Merged
merged 11 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
18 changes: 18 additions & 0 deletions library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include "window_impl.h"

#include "vtkF3DConsoleOutputWindow.h"

#if F3D_MODULE_UI
#include "vtkF3DImguiConsole.h"
#endif

#include "vtkF3DInteractorEventRecorder.h"
#include "vtkF3DInteractorStyle.h"
#include "vtkF3DRenderer.h"
Expand Down Expand Up @@ -603,6 +608,19 @@
check_args(args, 1, "reset");
this->Internals->Options.reset(args[0]);
});
this->addCommand("clear",
[&](const std::vector<std::string>& args)

Check warning on line 612 in library/src/interactor_impl.cxx

View check run for this annotation

Codecov / codecov/patch

library/src/interactor_impl.cxx#L612

Added line #L612 was not covered by tests
{
check_args(args, 0, "clear");

Check warning on line 614 in library/src/interactor_impl.cxx

View check run for this annotation

Codecov / codecov/patch

library/src/interactor_impl.cxx#L614

Added line #L614 was not covered by tests
#if F3D_MODULE_UI
vtkF3DImguiConsole* console =
vtkF3DImguiConsole::SafeDownCast(vtkOutputWindow::GetInstance());
if (console)

Check warning on line 618 in library/src/interactor_impl.cxx

View check run for this annotation

Codecov / codecov/patch

library/src/interactor_impl.cxx#L617-L618

Added lines #L617 - L618 were not covered by tests
0xfedcafe marked this conversation as resolved.
Show resolved Hide resolved
{
console->Clear();

Check warning on line 620 in library/src/interactor_impl.cxx

View check run for this annotation

Codecov / codecov/patch

library/src/interactor_impl.cxx#L620

Added line #L620 was not covered by tests
}
#endif
});

Check warning on line 623 in library/src/interactor_impl.cxx

View check run for this annotation

Codecov / codecov/patch

library/src/interactor_impl.cxx#L623

Added line #L623 was not covered by tests
this->addCommand("print",
[&](const std::vector<std::string>& args)
{
Expand Down
6 changes: 6 additions & 0 deletions library/testing/TestSDKInteractorCommand.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ int TestSDKInteractorCommand(int argc, char* argv[])
inter.triggerCommand("reset render.hdri.file");
test("triggerCommand reset optional", options.render.hdri.file.has_value() == false);

// Test clear
#if F3D_MODULE_UI
inter.triggerCommand("print_scene_info");
test("triggerCommand clear", (inter.triggerCommand("clear") == true));
#endif
0xfedcafe marked this conversation as resolved.
Show resolved Hide resolved

// Test toggle
inter.triggerCommand("toggle model.scivis.cells");
test("triggerCommand toggle", options.model.scivis.cells == true);
Expand Down
10 changes: 10 additions & 0 deletions vtkext/private/module/vtkF3DImguiActor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,13 @@
ImGuiIO& io = ImGui::GetIO();
io.DeltaTime = time;
}

//----------------------------------------------------------------------------
void vtkF3DImguiActor::Clear()

Check warning on line 467 in vtkext/private/module/vtkF3DImguiActor.cxx

View check run for this annotation

Codecov / codecov/patch

vtkext/private/module/vtkF3DImguiActor.cxx#L467

Added line #L467 was not covered by tests
{
vtkF3DImguiConsole* console = vtkF3DImguiConsole::SafeDownCast(vtkOutputWindow::GetInstance());
if (console)

Check warning on line 470 in vtkext/private/module/vtkF3DImguiActor.cxx

View check run for this annotation

Codecov / codecov/patch

vtkext/private/module/vtkF3DImguiActor.cxx#L469-L470

Added lines #L469 - L470 were not covered by tests
{
console->Clear();

Check warning on line 472 in vtkext/private/module/vtkF3DImguiActor.cxx

View check run for this annotation

Codecov / codecov/patch

vtkext/private/module/vtkF3DImguiActor.cxx#L472

Added line #L472 was not covered by tests
}
}

Check warning on line 474 in vtkext/private/module/vtkF3DImguiActor.cxx

View check run for this annotation

Codecov / codecov/patch

vtkext/private/module/vtkF3DImguiActor.cxx#L474

Added line #L474 was not covered by tests
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 RenderConsoleBadge() override;

/**
* Clear console
*/
void Clear() override;
0xfedcafe marked this conversation as resolved.
Show resolved Hide resolved

private:
vtkF3DImguiActor(const vtkF3DImguiActor&) = delete;
void operator=(const vtkF3DImguiActor&) = delete;
Expand Down
14 changes: 14 additions & 0 deletions vtkext/private/module/vtkF3DImguiConsole.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,17 @@
ImGui::End();
}
}

//----------------------------------------------------------------------------
void vtkF3DImguiConsole::Clear()

Check warning on line 202 in vtkext/private/module/vtkF3DImguiConsole.cxx

View check run for this annotation

Codecov / codecov/patch

vtkext/private/module/vtkF3DImguiConsole.cxx#L202

Added line #L202 was not covered by tests
{
this->Pimpl->Logs.clear();
this->Pimpl->NewError = false;
this->Pimpl->NewWarning = false;
}

Check warning on line 207 in vtkext/private/module/vtkF3DImguiConsole.cxx

View check run for this annotation

Codecov / codecov/patch

vtkext/private/module/vtkF3DImguiConsole.cxx#L204-L207

Added lines #L204 - L207 were not covered by tests

//----------------------------------------------------------------------------
size_t vtkF3DImguiConsole::GetLogsSize()

Check warning on line 210 in vtkext/private/module/vtkF3DImguiConsole.cxx

View check run for this annotation

Codecov / codecov/patch

vtkext/private/module/vtkF3DImguiConsole.cxx#L210

Added line #L210 was not covered by tests
{
return this->Pimpl->Logs.size();

Check warning on line 212 in vtkext/private/module/vtkF3DImguiConsole.cxx

View check run for this annotation

Codecov / codecov/patch

vtkext/private/module/vtkF3DImguiConsole.cxx#L212

Added line #L212 was not covered by tests
}
10 changes: 10 additions & 0 deletions vtkext/private/module/vtkF3DImguiConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ class vtkF3DImguiConsole : public vtkF3DConsoleOutputWindow
*/
void ShowBadge();

/**
* Clear console
*/
void Clear();

/**
* Get console history size
*/
size_t GetLogsSize();
0xfedcafe marked this conversation as resolved.
Show resolved Hide resolved

protected:
vtkF3DImguiConsole();
~vtkF3DImguiConsole() override;
Expand Down
5 changes: 5 additions & 0 deletions vtkext/private/module/vtkF3DUIActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
*/
virtual void SetDeltaTime(double) {}

/**
* Clear console
*/
virtual void Clear() {}

Check warning on line 102 in vtkext/private/module/vtkF3DUIActor.h

View check run for this annotation

Codecov / codecov/patch

vtkext/private/module/vtkF3DUIActor.h#L102

Added line #L102 was not covered by tests
0xfedcafe marked this conversation as resolved.
Show resolved Hide resolved

protected:
vtkF3DUIActor();
~vtkF3DUIActor() override;
Expand Down
Loading