can render 2 cv::mats
This commit is contained in:
+59
-3
@@ -1,9 +1,15 @@
|
||||
#include "AppGLFW.hpp"
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
#include "imaging/Image.hpp"
|
||||
#include "portable-file-dialogs.h"
|
||||
#include "rendering/CvMatRender.hpp"
|
||||
#include "uiresources.h"
|
||||
|
||||
ui::AppGLFW::AppGLFW()
|
||||
using namespace pixelarium::imaging;
|
||||
|
||||
pixelarium::ui::AppGLFW::AppGLFW()
|
||||
{
|
||||
glfwSetErrorCallback(glfw_error_callback);
|
||||
if (!glfwInit())
|
||||
@@ -91,7 +97,7 @@ ui::AppGLFW::AppGLFW()
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
}
|
||||
|
||||
int ui::AppGLFW::Run()
|
||||
int pixelarium::ui::AppGLFW::Run()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
(void)io;
|
||||
@@ -103,7 +109,17 @@ int ui::AppGLFW::Run()
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
ImGui::DockSpaceOverViewport(ImGui::GetID("MainDockSpace"));
|
||||
ImGui::DockSpaceOverViewport(ImGui::GetID("Backspace"));
|
||||
|
||||
this->MenuBar();
|
||||
|
||||
if (this->_imagep)
|
||||
{
|
||||
auto render = render::CvMatRender(this->_img);
|
||||
ImGui::Begin("An image", &this->_imagep, NULL);
|
||||
ImGui::Image(render.Render(), ImVec2(this->_img.GetImage().cols, this->_img.GetImage().rows));
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
// Rendering
|
||||
ImGui::Render();
|
||||
@@ -133,3 +149,43 @@ int ui::AppGLFW::Run()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pixelarium::ui::AppGLFW::MenuBar()
|
||||
{
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
// main menu
|
||||
if (ImGui::BeginMenu(MAINMENUNAME))
|
||||
{
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
// file menu
|
||||
if (ImGui::BeginMenu(FILEMENUNAME))
|
||||
{
|
||||
if (ImGui::MenuItem("Load File"))
|
||||
{
|
||||
this->LoadImageProt();
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
void pixelarium::ui::AppGLFW::LoadImageProt()
|
||||
{
|
||||
auto res{pfd::open_file("Load Inputs", pfd::path::home(),
|
||||
{"All Files", "*"}, pfd::opt::multiselect)
|
||||
.result()};
|
||||
for (auto& p : res)
|
||||
{
|
||||
// lg::Logger::Debug("Adding image from " + std::string(p),
|
||||
// __FUNCTION__);
|
||||
|
||||
this->_img = Image(p);
|
||||
this->_imagep = true;
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -1,13 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "Image.hpp"
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_glfw.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
|
||||
namespace ui
|
||||
namespace pixelarium::ui
|
||||
{
|
||||
enum LogLevelSelection
|
||||
{
|
||||
@@ -23,10 +25,16 @@ class AppGLFW
|
||||
AppGLFW();
|
||||
int Run();
|
||||
|
||||
private:
|
||||
void MenuBar();
|
||||
void LoadImageProt();
|
||||
|
||||
private:
|
||||
LogLevelSelection log_level_ = static_cast<LogLevelSelection>(0);
|
||||
GLFWwindow* window = nullptr;
|
||||
ImGuiWindowFlags window_flags = 0;
|
||||
pixelarium::imaging::Image _img;
|
||||
bool _imagep { false };
|
||||
};
|
||||
|
||||
static void glfw_error_callback(int error, const char* description)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::cout << "ok\n";
|
||||
auto app = ui::AppGLFW();
|
||||
auto app = pixelarium::ui::AppGLFW();
|
||||
|
||||
return app.Run();
|
||||
}
|
||||
@@ -2,4 +2,7 @@
|
||||
|
||||
|
||||
/*-- Gets filled in during the cmake configuration step --*/
|
||||
#cmakedefine PIXELARIUM_TITLE "@PIXELARIUM_TITLE@"
|
||||
#cmakedefine PIXELARIUM_TITLE "@PIXELARIUM_TITLE@"
|
||||
|
||||
#define MAINMENUNAME "Menu"
|
||||
#define FILEMENUNAME "File"
|
||||
Reference in New Issue
Block a user