Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk committed Nov 27, 2024
1 parent b3cfee2 commit 3260ce0
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 52 deletions.
39 changes: 22 additions & 17 deletions vtkext/private/module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,33 @@ configure_file(

set(F3D_DEFAULT_HDRI "${F3D_SOURCE_DIR}/resources/defaultHDRI.png" CACHE STRING "Default HDRI when no HDRI file is provided")
mark_as_advanced(F3D_DEFAULT_HDRI)
set(F3D_FONT_FILE "${F3D_SOURCE_DIR}/resources/Inter-Regular.ttf" CACHE STRING "Font used in UI widgets")
mark_as_advanced(F3D_FONT_FILE)
include("f3dEmbed")
f3d_embed_file(
INPUT "${F3D_DEFAULT_HDRI}"
NAME F3DDefaultHDRI
BINARY)
f3d_embed_file(
INPUT "${F3D_FONT_FILE}"
NAME F3DFontBuffer
BINARY)
set(sources
${CMAKE_CURRENT_BINARY_DIR}/F3DDefaultHDRI.cxx
${CMAKE_CURRENT_BINARY_DIR}/F3DFontBuffer.cxx)
set(private_headers
${CMAKE_CURRENT_BINARY_DIR}/F3DDefaultHDRI.h
${CMAKE_CURRENT_BINARY_DIR}/F3DFontBuffer.h)

set(shader_files
glsl/vtkF3DComputeDepthCS.glsl
glsl/vtkF3DImguiFS.glsl
glsl/vtkF3DImguiVS.glsl)

set(sources ${CMAKE_CURRENT_BINARY_DIR}/F3DDefaultHDRI.cxx)
set(private_headers ${CMAKE_CURRENT_BINARY_DIR}/F3DDefaultHDRI.h)

if(F3D_MODULE_UI)
set(F3D_FONT_FILE "${F3D_SOURCE_DIR}/resources/Inter-Regular.ttf" CACHE STRING "Font used in UI widgets")
mark_as_advanced(F3D_FONT_FILE)

f3d_embed_file(
INPUT "${F3D_FONT_FILE}"
NAME F3DFontBuffer
BINARY)

list(APPEND sources ${CMAKE_CURRENT_BINARY_DIR}/F3DFontBuffer.cxx)
list(APPEND private_headers ${CMAKE_CURRENT_BINARY_DIR}/F3DFontBuffer.h)
endif()

set(shader_files glsl/vtkF3DComputeDepthCS.glsl)

if(F3D_MODULE_UI)
list(APPEND shader_files glsl/vtkF3DImguiFS.glsl glsl/vtkF3DImguiVS.glsl)
endif()

foreach(file IN LISTS shader_files)
vtk_encode_string(
Expand Down
2 changes: 0 additions & 2 deletions vtkext/private/module/vtkF3DGLXRenderWindow.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <vtkObjectFactory.h>
#include <vtkRendererCollection.h>
#include <vtkVersion.h>

#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240914)
Expand All @@ -10,7 +9,6 @@
#endif

#include "vtkF3DGLXRenderWindow.h"
#include "vtkF3DRenderer.h"

#include <X11/Xlib.h>

Expand Down
30 changes: 12 additions & 18 deletions vtkext/private/module/vtkF3DImguiActor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

#include "vtkF3DImguiFS.h"
#include "vtkF3DImguiVS.h"

#include "F3DFontBuffer.h"

#include "imgui.h"
#include <imgui.h>

struct vtkF3DImguiActor::Internals
{
Expand Down Expand Up @@ -174,17 +173,17 @@ struct vtkF3DImguiActor::Internals
(cmd->ClipRect.x - clipOff.x) * clipScale.x, (cmd->ClipRect.y - clipOff.y) * clipScale.y);
ImVec2 clipMax(
(cmd->ClipRect.z - clipOff.x) * clipScale.x, (cmd->ClipRect.w - clipOff.y) * clipScale.y);
if (clipMax.x <= clipMin.x || clipMax.y <= clipMin.y)
continue;

// Apply scissor/clipping rectangle (Y is inverted in OpenGL)
float fbHeight = drawData->DisplaySize.y * drawData->FramebufferScale.y;
state->vtkglScissor(static_cast<GLint>(clipMin.x), static_cast<GLint>(fbHeight - clipMax.y),
static_cast<GLsizei>(clipMax.x - clipMin.x), static_cast<GLsizei>(clipMax.y - clipMin.y));

glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(cmd->ElemCount),
sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
reinterpret_cast<void*>(cmd->IdxOffset * sizeof(ImDrawIdx)));
if (clipMax.x > clipMin.x && clipMax.y > clipMin.y)
{
// Apply scissor/clipping rectangle (Y is inverted in OpenGL)
float fbHeight = drawData->DisplaySize.y * drawData->FramebufferScale.y;
state->vtkglScissor(static_cast<GLint>(clipMin.x), static_cast<GLint>(fbHeight - clipMax.y),
static_cast<GLsizei>(clipMax.x - clipMin.x), static_cast<GLsizei>(clipMax.y - clipMin.y));

glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(cmd->ElemCount),
sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
reinterpret_cast<void*>(cmd->IdxOffset * sizeof(ImDrawIdx)));
}
}
}

Expand Down Expand Up @@ -295,12 +294,7 @@ void vtkF3DImguiActor::StartFrame(vtkOpenGLRenderWindow* renWin)

this->Pimpl->Initialize(renWin);

io.DisplaySize = ImVec2(static_cast<float>(size[0]), static_cast<float>(size[1]));

ImGui::NewFrame();

// debug
// ImGui::ShowDemoWindow(nullptr);
}

//----------------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions vtkext/private/module/vtkF3DImguiActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class vtkF3DImguiActor : public vtkF3DUIActor
*/
void ReleaseGraphicsResources(vtkWindow* w) override;

vtkF3DImguiActor(const vtkF3DImguiActor&) = delete;
void operator=(const vtkF3DImguiActor&) = delete;

protected:
vtkF3DImguiActor();
~vtkF3DImguiActor() override;
Expand All @@ -58,6 +55,10 @@ class vtkF3DImguiActor : public vtkF3DUIActor
* Render the filename UI widget
*/
void RenderFileName() override;

private:
vtkF3DImguiActor(const vtkF3DImguiActor&) = delete;
void operator=(const vtkF3DImguiActor&) = delete;
};

#endif
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DImguiObserver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <vtkRenderWindowInteractor.h>
#include <vtkRendererCollection.h>

#include "imgui.h"
#include <imgui.h>

namespace
{
Expand Down
6 changes: 3 additions & 3 deletions vtkext/private/module/vtkF3DImguiObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class vtkF3DImguiObserver : public vtkF3DUIObserver
*/
void InstallObservers(vtkRenderWindowInteractor* interactor) override;

vtkF3DImguiObserver(const vtkF3DImguiObserver&) = delete;
void operator=(const vtkF3DImguiObserver&) = delete;

protected:
vtkF3DImguiObserver() = default;
~vtkF3DImguiObserver() override = default;
Expand All @@ -51,6 +48,9 @@ class vtkF3DImguiObserver : public vtkF3DUIObserver
* Trigger a window rendering, but render only the UI/overlay actors.
*/
void RenderUI(vtkRenderWindowInteractor* interactor);

vtkF3DImguiObserver(const vtkF3DImguiObserver&) = delete;
void operator=(const vtkF3DImguiObserver&) = delete;
};

#endif
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DRenderer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ void vtkF3DRenderer::ConfigureTextActors()
this->CheatSheetActor->GetTextProperty()->SetFontFile(tmpFontFile.c_str());
this->DropZoneActor->GetTextProperty()->SetFontFamily(VTK_FONT_FILE);
this->DropZoneActor->GetTextProperty()->SetFontFile(tmpFontFile.c_str());
this->UIActor->SetFontFile(tmpFontFile.c_str());
this->UIActor->SetFontFile(tmpFontFile);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion vtkext/private/module/vtkF3DRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @brief A F3D dedicated renderer
*
* This renderers all the generic actors added by F3D which includes
* axis, grid, edges, timer, metadata and cheatsheet.
* UI, axis, grid, edges, timer, metadata and cheatsheet.
* It also handles the different rendering passes, including
* raytracing, ssao, fxaa, tonemapping.
*/
Expand Down
7 changes: 4 additions & 3 deletions vtkext/private/module/vtkF3DUIActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ class vtkF3DUIActor : public vtkProp
*/
int RenderOverlay(vtkViewport* vp) override;

vtkF3DUIActor(const vtkF3DUIActor&) = delete;
void operator=(const vtkF3DUIActor&) = delete;

protected:
vtkF3DUIActor();
~vtkF3DUIActor() override;
Expand All @@ -71,6 +68,10 @@ class vtkF3DUIActor : public vtkProp
bool FileNameVisible = false;
std::string FileName = "";
std::string FontFile = "";

private:
vtkF3DUIActor(const vtkF3DUIActor&) = delete;
void operator=(const vtkF3DUIActor&) = delete;
};

#endif
7 changes: 4 additions & 3 deletions vtkext/private/module/vtkF3DUIObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ class vtkF3DUIObserver : public vtkObject
*/
virtual void InstallObservers(vtkRenderWindowInteractor*) {}

Check warning on line 24 in vtkext/private/module/vtkF3DUIObserver.h

View check run for this annotation

Codecov / codecov/patch

vtkext/private/module/vtkF3DUIObserver.h#L24

Added line #L24 was not covered by tests

vtkF3DUIObserver(const vtkF3DUIObserver&) = delete;
void operator=(const vtkF3DUIObserver&) = delete;

protected:
vtkF3DUIObserver() = default;
~vtkF3DUIObserver() override = default;

private:
vtkF3DUIObserver(const vtkF3DUIObserver&) = delete;
void operator=(const vtkF3DUIObserver&) = delete;
};

#endif

0 comments on commit 3260ce0

Please sign in to comment.