initial commit

This commit is contained in:
2026-02-16 19:15:59 +03:00
commit c14177e664
76 changed files with 24383 additions and 0 deletions

85
src/meson.build Executable file
View File

@@ -0,0 +1,85 @@
inc += include_directories('.')
headers = [
############ GUI/COMPONENTS
'monitor/gui/components/plots/2d/implot.h',
'monitor/gui/components/plots/2d/implot_internal.h',
'monitor/gui/components/plots/3d/implot3d.h',
'monitor/gui/components/plots/3d/implot3d_internal.h',
'monitor/gui/components/spinner/spinner.hpp',
'monitor/gui/components/panel/panel.hpp',
'monitor/gui/components/creator/creator.hpp',
'monitor/gui/components/snapshot/snapshot.hpp',
'monitor/gui/components/tabs/tabs.hpp',
'monitor/gui/components/audio/audio.hpp',
'monitor/gui/components/markers/markers.hpp',
'monitor/gui/components/helpers/helpers.hpp',
############ GUI/WIN
'monitor/gui/win/win.hpp',
############ UTILS
'monitor/utils/var.hpp',
'monitor/libs/audio/audio.hpp',
############
# RUN
'run.hpp'
]
sources = [
############ GUI/COMPONENTS
'monitor/gui/components/plots/2d/implot.cpp',
'monitor/gui/components/plots/2d/implot_demo.cpp',
'monitor/gui/components/plots/2d/implot_items.cpp',
'monitor/gui/components/plots/3d/implot3d.cpp',
'monitor/gui/components/plots/3d/implot3d_items.cpp',
'monitor/gui/components/plots/3d/implot3d_meshes.cpp',
'monitor/gui/components/plots/3d/implot3d_demo.cpp',
'monitor/gui/components/panel/cpp/base.cpp',
'monitor/gui/components/panel/cpp/on_event.cpp',
'monitor/gui/components/panel/cpp/render.cpp',
'monitor/gui/components/creator/cpp/base.cpp',
'monitor/gui/components/creator/cpp/on_event.cpp',
'monitor/gui/components/creator/cpp/render/render.cpp',
'monitor/gui/components/creator/cpp/render/buttons.cpp',
'monitor/gui/components/creator/cpp/render/combo.cpp',
'monitor/gui/components/creator/cpp/render/setup.cpp',
'monitor/gui/components/creator/cpp/render/spinner.cpp',
'monitor/gui/components/snapshot/cpp/base.cpp',
'monitor/gui/components/snapshot/cpp/on_event.cpp',
'monitor/gui/components/snapshot/cpp/render.cpp',
'monitor/gui/components/tabs/cpp/base.cpp',
'monitor/gui/components/tabs/cpp/on_event.cpp',
'monitor/gui/components/tabs/cpp/render.cpp',
'monitor/gui/components/audio/cpp/base.cpp',
'monitor/gui/components/audio/cpp/on_event.cpp',
'monitor/gui/components/audio/cpp/render.cpp',
'monitor/gui/components/markers/cpp/base.cpp',
'monitor/gui/components/markers/cpp/on_event.cpp',
'monitor/gui/components/markers/cpp/render.cpp',
'monitor/gui/components/helpers/cpp/base.cpp',
'monitor/gui/components/helpers/cpp/on_event.cpp',
'monitor/gui/components/helpers/cpp/render.cpp',
############ UTILS
'monitor/libs/audio/audio.cpp',
############ GUI/WIN
'monitor/gui/win/cpp/base.cpp',
'monitor/gui/win/cpp/on_event.cpp',
'monitor/gui/win/cpp/render.cpp'
]
lib = library(
meson.project_name(),
include_directories : inc,
sources: [headers, sources],
dependencies : deps,
cpp_args: args
)
deps += declare_dependency(
include_directories: inc,
link_with: lib,
)

View File

@@ -0,0 +1,32 @@
#pragma once
#include <VE.hpp>
#include "monitor/libs/audio/audio.hpp"
#include "monitor/utils/var.hpp"
namespace monitor::components
{
class audio : public VE::layer, public VE::connector
{
VE_OVERIDE();
VE_EVENT_OVERIDE();
public:
void init(std::filesystem::path file);
void set_step(std::size_t step);
void set_pos(double pos);
void set_bs(std::string type, std::size_t bs);
void toggle();
void pause();
void drop();
void set_status(utils::var::STATUS s);
private:
utils::var::STATUS m_status;
libs::audio m_player;
std::filesystem::path m_file;
private:
void callback(sf::Time time, double pos);
};
}

View File

@@ -0,0 +1,67 @@
#include "monitor/gui/components/audio/audio.hpp"
#include "monitor/utils/event_type.hpp"
namespace monitor::components
{
void audio::on_attach()
{
CONNECT(this);
m_player.set_callback(std::bind(&audio::callback, this, std::placeholders::_1, std::placeholders::_2));
}
void audio::on_detach()
{
DISCONNECT();
}
void audio::update()
{
}
void audio::toggle()
{
auto f = [this]() { m_player.toggle_play(); };
std::thread t(f);
t.detach();
}
void audio::pause()
{
m_player.pause();
}
void audio::init(std::filesystem::path file)
{
m_file = file;
m_player.set_file(m_file);
}
void audio::set_status(utils::var::STATUS s)
{
m_status = s;
}
// step - шаг отправки сигнала на смещение маркера. он же кол-во block_size-ов на все произведение
void audio::set_step(std::size_t step)
{
m_player.set_step(step);
}
void audio::callback(sf::Time time, double pos)
{
VE::event e { utils::event_type::INCREMENT_MARKER_AUDIO_POSITION, pos };
EMIT(e);
}
void audio::drop()
{
m_player.stop();
VE::event e { utils::event_type::AUDIO_STOP, nullptr };
EMIT(e);
}
void audio::set_pos(double pos)
{
m_player.set_audio_pos(pos);
}
}

View File

@@ -0,0 +1,46 @@
#include "monitor/gui/components/audio/audio.hpp"
#include "monitor/utils/event_type.hpp"
namespace monitor::components
{
void audio::on_event(VE::event& e)
{
if (m_status != utils::var::STATUS::ACTIVE) return;
if (e.m_type.type() == typeid(VE::event_type))
{
auto type = std::any_cast<VE::event_type>(e.m_type);
switch (type)
{
case VE::event_type::KEY_PRESSED:
{
auto d = std::any_cast<int>(e.m_data);
if (d == VE::key::SPACE) toggle();
break;
};
}
}
if (e.m_type.type() == typeid(utils::event_type))
{
auto type = std::any_cast<utils::event_type>(e.m_type);
switch (type)
{
case utils::event_type::AUDIO_PAUSE:
{
pause();
break;
}
case utils::event_type::SET_AUDIO_POSITION:
{
auto d = std::any_cast<double>(e.m_data);
set_pos(d);
break;
}
}
}
}
}

View File

@@ -0,0 +1,39 @@
#include "monitor/gui/components/audio/audio.hpp"
#include "monitor/utils/event_type.hpp"
namespace monitor::components
{
void audio::render()
{
bool is_play = m_player.is_playing();
if (is_play)
{
ImGui::PushStyleColor(ImGuiCol_Button, VE_COLOR("#298FD4", 180));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, VE_COLOR("#298FD4", 255));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, VE_COLOR("#298FD4", 200));
}
else
{
ImGui::PushStyleColor(ImGuiCol_Button, VE_COLOR("#125C25", 180));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, VE_COLOR("#125C25", 255));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, VE_COLOR("#125C25", 200));
}
if (ImGui::Button(is_play ? "pause" : "play", ImVec2{70.f, 26.f} ))
{
auto f = [this]() { m_player.toggle_play(); };
std::thread t(f);
t.detach();
}
ImGui::PopStyleColor(3);
ImGui::SameLine(80.f);
if (ImGui::Button("<<<"))
{
m_player.stop();
VE::event e { utils::event_type::AUDIO_STOP, nullptr };
EMIT(e);
}
}
}

View File

@@ -0,0 +1,51 @@
#include "monitor/gui/components/creator/creator.hpp"
#include "monitor/utils/event_type.hpp"
#include "monitor/utils/var.hpp"
namespace monitor::components
{
void creator::on_attach()
{
CONNECT(this);
for (const auto& entry : std::filesystem::directory_iterator(utils::var::DIR))
if (entry.is_directory()) m_dirs.push_back(entry.path().filename().string());
}
void creator::on_detach()
{
DISCONNECT();
}
void creator::update() { }
void creator::create()
{
m_status = utils::var::STATUS::PROCESS;
auto f = [this]() {
auto file = utils::var::DIR / m_dir.m_name / m_file.m_name;
// send to: tabs
m_setup.m_file = file;
VE::event e { utils::event_type::CREATE_SNAPSHOT, m_setup };
EMIT(e);
clear();
};
std::thread th(f);
th.detach();
}
void creator::clear()
{
m_dir.clear();
m_file.clear();
m_files.clear();
m_status = utils::var::STATUS::COMPLETED;
auto future = std::async(std::launch::async, [this]() {
std::this_thread::sleep_for(std::chrono::seconds(3));
m_status = utils::var::STATUS::EMPTY;
});
}
}

View File

@@ -0,0 +1,23 @@
#include "monitor/gui/components/creator/creator.hpp"
#include "monitor/utils/event_type.hpp"
namespace monitor::components
{
void creator::on_event(VE::event& e)
{
if (e.m_type.type() == typeid(utils::event_type))
{
auto type = std::any_cast<utils::event_type>(e.m_type);
switch (type)
{
// case utils::event_type::CREATE_WORKSPACE_COMPLETE:
// {
// clear();
// break;
// }
}
}
}
}

View File

@@ -0,0 +1,22 @@
#include "monitor/gui/components/creator/creator.hpp"
#include "monitor/utils/var.hpp"
namespace monitor::components
{
void creator::render_buttons()
{
ImGui::BeginDisabled(m_status == utils::var::STATUS::EMPTY);
ImGui::BeginDisabled(m_status == utils::var::STATUS::PROCESS);
ImGui::BeginDisabled(m_status == utils::var::STATUS::COMPLETED);
ImGui::PushStyleColor(ImGuiCol_Button, VE_COLOR("#298FD4", 180));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, VE_COLOR("#298FD4", 255));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, VE_COLOR("#298FD4", 200));
if (ImGui::Button("create", ImVec2{ 94.f, 27.f })) create();
ImGui::PopStyleColor(3);
ImGui::EndDisabled();
ImGui::EndDisabled();
ImGui::EndDisabled();
}
}

View File

@@ -0,0 +1,49 @@
#include "monitor/gui/components/creator/creator.hpp"
#include "monitor/utils/var.hpp"
namespace monitor::components
{
void creator::render_combo()
{
ImGui::SetNextItemWidth(400.f);
if (ImGui::BeginCombo(VE_NO_NAME("select_dir"), m_dir.m_id < 0 ? "---" : m_dirs[m_dir.m_id].c_str()))
{
for (std::size_t i = 0; i < m_dirs.size(); ++i)
{
const bool is_selected = (m_dir.m_id == static_cast<int>(i));
if (ImGui::Selectable(m_dirs[i].c_str(), is_selected))
{
m_files.clear();
m_dir.init(i, m_dirs[i]);
for (const auto& entry : std::filesystem::directory_iterator(utils::var::DIR/m_dir.m_name))
if (entry.is_regular_file()) m_files.push_back(entry.path().filename().string());
}
if (is_selected) ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
auto ctx = ImGui::GetCurrentContext();
ImGui::SameLine(0.f, ctx->Style.FramePadding.x);
ImGui::SetNextItemWidth(400.f);
if (ImGui::BeginCombo(VE_NO_NAME("select_file"), m_file.m_id < 0 ? "---" : m_files[m_file.m_id].c_str()))
{
if (!m_files.empty())
{
for (std::size_t i = 0; i < m_files.size(); ++i)
{
const bool is_selected = (m_file.m_id == static_cast<int>(i));
if (ImGui::Selectable(m_files[i].c_str(), is_selected))
{
m_file.init(i, m_files[i]);
m_status = utils::var::STATUS::READY;
}
if (is_selected) ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
}
}

View File

@@ -0,0 +1,16 @@
#include "monitor/gui/components/creator/creator.hpp"
namespace monitor::components
{
void creator::render()
{
auto ctx = ImGui::GetCurrentContext();
render_combo();
render_spinner();
ImGui::SameLine(0.f, 9.f * ctx->Style.FramePadding.x);
render_setup();
ImGui::SameLine(0.f, 9.f * ctx->Style.FramePadding.x);
render_buttons();
}
}

View File

@@ -0,0 +1,109 @@
#include "monitor/gui/components/creator/creator.hpp"
#include <harmonica.hpp>
namespace monitor::components
{
void creator::render_setup()
{
float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
std::size_t step = 256;
// block_size
ImGui::Text("block size:");
ImGui::SameLine(0.0f, spacing);
ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
ImGui::SetCursorPosY(8.f);
VE_PUSH_FONT(ICON, 12);
ImGui::PushID(VE_NO_NAME("1"));
if (ImGui::Button(VE::style::icon::ICON_MINUS, ImVec2{24, 20}))
{
m_setup.m_block_size -= step;
m_setup.m_block_size = std::max(step, m_setup.m_block_size);
}
ImGui::PopID();
VE_POP_FONT();
ImGui::SameLine(0.0f, spacing);
ImGui::Text("%zu", m_setup.m_block_size);
// тут нужно жестко, а то при изменении циферек прагает в сторону поле
ImGui::SameLine(1000.0f);
ImGui::SetCursorPosY(8.f);
VE_PUSH_FONT(ICON, 12);
ImGui::PushID(VE_NO_NAME("2"));
if (ImGui::Button(VE::style::icon::ICON_PLUS, ImVec2{24, 20}))
m_setup.m_block_size += step;
ImGui::PopID();
VE_POP_FONT();
ImGui::PopItemFlag();
// end
ImGui::SameLine(0.f, 4.f * spacing);
// step size
ImGui::Text("step size:");
ImGui::SameLine(0.0f, spacing);
ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
ImGui::SetCursorPosY(8.f);
VE_PUSH_FONT(ICON, 12);
ImGui::PushID(VE_NO_NAME("3"));
if (ImGui::Button(VE::style::icon::ICON_MINUS, ImVec2{24, 20}))
{
m_setup.m_step_size -= step;
m_setup.m_step_size = std::max(step, m_setup.m_step_size);
}
ImGui::PopID();
VE_POP_FONT();
ImGui::SameLine(0.0f, spacing);
ImGui::Text("%zu", m_setup.m_step_size);
// тут нужно жестко, а то при изменении циферек прагает в сторону поле
ImGui::SameLine(1195.0f);
ImGui::SetCursorPosY(8.f);
VE_PUSH_FONT(ICON, 12);
ImGui::PushID(VE_NO_NAME("4"));
if (ImGui::Button(VE::style::icon::ICON_PLUS, ImVec2{24, 20}))
m_setup.m_step_size += step;
ImGui::PopID();
VE_POP_FONT();
ImGui::PopItemFlag();
// end
ImGui::SameLine(0.f, 4.f * spacing);
// compression
hr::base_t step_compression = 0.1;
ImGui::Text("compression:");
ImGui::SameLine(0.0f, spacing);
ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
ImGui::SetCursorPosY(8.f);
VE_PUSH_FONT(ICON, 12);
ImGui::PushID(VE_NO_NAME("4"));
if (ImGui::Button(VE::style::icon::ICON_MINUS, ImVec2{24, 20}))
{
m_setup.m_compression -= step_compression;
m_setup.m_compression = std::fmax(0.0, m_setup.m_compression);
}
ImGui::PopID();
VE_POP_FONT();
ImGui::SameLine(0.0f, spacing);
ImGui::Text("%.2f", m_setup.m_compression);
// тут нужно жестко, а то при изменении циферек прагает в сторону поле
ImGui::SameLine(1420.0f);
ImGui::SetCursorPosY(8.f);
VE_PUSH_FONT(ICON, 12);
ImGui::PushID(VE_NO_NAME("5"));
if (ImGui::Button(VE::style::icon::ICON_PLUS, ImVec2{24, 20}))
m_setup.m_compression += step_compression;
ImGui::PopID();
VE_POP_FONT();
ImGui::PopItemFlag();
// end
}
}

View File

@@ -0,0 +1,19 @@
#include "monitor/gui/components/creator/creator.hpp"
#include "monitor/utils/var.hpp"
extern ImRect g_ComboSize;
namespace monitor::components
{
void creator::render_spinner()
{
auto ctx = ImGui::GetCurrentContext();
auto s = ctx->CurrentWindow->Size;
ImVec2 pos{ 830.f, s.y / 2.f };
if (m_status == utils::var::STATUS::COMPLETED) m_spinner.render(pos);
else if (m_status == utils::var::STATUS::READY) m_spinner.render(pos, "#B4CF16");
else if (m_status == utils::var::STATUS::PROCESS) m_spinner.render(pos, "#B82C5C", true);
else m_spinner.render(pos, "#414243");
}
}

View File

@@ -0,0 +1,46 @@
#pragma once
#include <VE.hpp>
#include <harmonica.hpp>
#include "monitor/gui/components/spinner/spinner.hpp"
#include "monitor/utils/var.hpp"
namespace monitor::components
{
class creator : public VE::layer, public VE::connector
{
VE_OVERIDE();
VE_EVENT_OVERIDE();
private:
struct combo
{
std::string m_name;
int m_id = -1;
void init(int id, std::string name) { m_id = id; m_name = name; }
void clear()
{
m_name.clear();
m_id = -1;
}
};
private:
std::vector<std::string> m_dirs;
std::vector<std::string> m_files;
combo m_dir;
combo m_file;
utils::var::STATUS m_status = utils::var::STATUS::EMPTY;
components::spinner m_spinner;
hr::setup m_setup;
private:
void create();
void clear();
void render_combo();
void render_spinner();
void render_buttons();
void render_setup();
};
}

View File

@@ -0,0 +1,19 @@
#include "monitor/gui/components/helpers/helpers.hpp"
#include "monitor/gui/components/plots/2d/implot.h"
#include "monitor/gui/components/plots/3d/implot3d.h"
namespace monitor::components
{
void helpers::on_attach()
{
ImPlot3D::CreateContext();
ImPlot::CreateContext();
}
void helpers::on_detach()
{
}
void helpers::update() { }
}

View File

@@ -0,0 +1,9 @@
#include "monitor/gui/components/helpers/helpers.hpp"
namespace monitor::components
{
void helpers::on_event(VE::event& e)
{
}
}

View File

@@ -0,0 +1,28 @@
#include "monitor/gui/components/helpers/helpers.hpp"
#include "monitor/gui/components/plots/2d/implot.h"
#include "monitor/gui/components/plots/3d/implot3d.h"
namespace monitor::components
{
void helpers::render()
{
ImGui::SameLine( ImGui::GetWindowSize().x - 90.f );
ImGui::SetCursorPosY(6.f);
ImGui::Text(m_msg.data());
VE_PUSH_FONT(REGULAR, 12);
ImGui::SameLine( ImGui::GetWindowSize().x - 30.f );
ImGui::SetCursorPosY(8.f);
ImGui::Checkbox(VE_NO_NAME("demo_check"), &m_show_demo);
VE_POP_FONT();
if (m_show_demo)
{
ImGui::ShowDemoWindow();
ImPlot3D::ShowDemoWindow();
ImPlot::ShowDemoWindow();
}
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include <VE.hpp>
namespace monitor::components
{
class helpers : public VE::layer, public VE::flags, public VE::connector
{
VE_OVERIDE();
VE_EVENT_OVERIDE();
private:
bool m_show_demo = false;
private:
std::string m_msg = "helpers";
};
}

View File

@@ -0,0 +1,36 @@
#include "monitor/gui/components/markers/markers.hpp"
#include <hack/math/math.hpp>
namespace monitor::components
{
void markers::on_attach()
{
CONNECT(this);
}
void markers::on_detach()
{
DISCONNECT();
}
void markers::update()
{
}
void markers::set_status(utils::var::STATUS s)
{
m_status = s;
}
void markers::set_tag_show(bool v)
{
m_tag_show = v;
}
void markers::init()
{
m_marker_audio_color = ImGui::ColorConvertU32ToFloat4(VE_COLOR("#00FC7C", 180));
m_marker_mouse_color = ImGui::ColorConvertU32ToFloat4(VE_COLOR("#414243", 180));
m_marker_fixed_color = ImGui::ColorConvertU32ToFloat4(VE_COLOR("#B4CF16", 180));
}
}

View File

@@ -0,0 +1,74 @@
#include "monitor/gui/components/markers/markers.hpp"
#include "monitor/utils/event_type.hpp"
namespace monitor::components
{
void markers::on_event(VE::event& e)
{
if (m_status != utils::var::STATUS::ACTIVE) return;
if (e.m_type.type() == typeid(VE::event_type))
{
auto type = std::any_cast<VE::event_type>(e.m_type);
switch (type)
{
case VE::event_type::KEY_PRESSED:
{
auto d = std::any_cast<int>(e.m_data);
if (d == VE::key::LEFTSHIFT) m_shift_press = true;
break;
};
case VE::event_type::KEY_RELEASED:
{
auto d = std::any_cast<int>(e.m_data);
if (d == VE::key::LEFTSHIFT) m_shift_press = false;
break;
};
}
}
if (e.m_type.type() == typeid(utils::event_type))
{
auto type = std::any_cast<utils::event_type>(e.m_type);
switch (type)
{
case utils::event_type::INCREMENT_MARKER_AUDIO_POSITION:
{
auto pos = std::any_cast<double>(e.m_data);
m_marker_audio_position += pos;
break;
}
case utils::event_type::SET_MARKER_AUDIO_POSITION:
{
auto pos = std::any_cast<double>(e.m_data);
m_marker_audio_position = pos;
break;
}
case utils::event_type::AUDIO_STOP:
{
m_marker_audio_position = 0.0;
break;
}
case utils::event_type::SET_MARKER_MOUSE_POSITION:
{
auto pos = std::any_cast<double>(e.m_data);
m_marker_mouse_position = pos;
break;
}
// case utils::event_type::REMOVE_LAST_MARKER_SEGMENT:
// {
// if (m_marker_segment.size() > 0)
// m_marker_segment.pop_back();
// break;
// }
}
}
}
}

View File

@@ -0,0 +1,58 @@
#include "monitor/gui/components/markers/markers.hpp"
#include "monitor/gui/components/plots/2d/implot.h"
#include "monitor/utils/event_type.hpp"
namespace monitor::components
{
void markers::render()
{
// -1 это индекс т.к. там внизу тоже они индексируются
// ImPlotDragToolFlags_NoInputs - не дает передвинуть маркер
ImPlot::DragLineX(-1, &m_marker_audio_position, m_marker_audio_color, 0.1f, ImPlotDragToolFlags_NoCursors | ImPlotDragToolFlags_NoInputs);
// кликаем для установки маркера аудио (зеленый)
if (ImGui::IsMouseClicked(ImGuiMouseButton_Middle))
{
m_marker_audio_position = ImPlot::GetPlotMousePos().x;
VE::event e { utils::event_type::SET_AUDIO_POSITION, m_marker_audio_position };
EMIT(e);
}
// работает только при нажатом шифте
if (m_shift_press && ImPlot::IsPlotHovered())
{
m_marker_mouse_position = ImPlot::GetPlotMousePos().x;
ImPlot::DragLineX(1000, &m_marker_mouse_position, m_marker_mouse_color, 0.1f, ImPlotDragToolFlags_NoCursors | ImPlotDragToolFlags_NoInputs);
}
// кликаем для установки тэгов
if (m_shift_press && ImGui::IsMouseClicked(ImGuiMouseButton_Right) && ImPlot::IsPlotHovered())
m_marker_fixed.push_back(ImPlot::GetPlotMousePos().x);
for (std::size_t i = 0; i < m_marker_fixed.size(); ++i)
{
ImPlot::DragLineX(i, &m_marker_fixed[i], m_marker_fixed_color, 0.1f, ImPlotDragToolFlags_NoCursors | ImPlotDragToolFlags_NoInputs);
if (m_tag_show) ImPlot::TagX(m_marker_fixed[i], m_marker_fixed_color, std::to_string(i).c_str());
}
if (m_shift_press)
{
auto p = ImPlot::GetPlotMousePos().x;
for (std::size_t i = 0; i < m_marker_fixed.size(); ++i)
{
if (std::abs(p - m_marker_fixed[i]) < m_tolerance)
{
ImPlot::DragLineX(i, &m_marker_fixed[i], m_marker_fixed_color, 2.7f, ImPlotDragToolFlags_NoCursors | ImPlotDragToolFlags_NoInputs);
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left) && ImPlot::IsPlotHovered())
m_marker_fixed.erase(m_marker_fixed.begin() + i);
}
}
}
// показываем позицию при наведении мыши
auto p = ImPlot::GetPlotMousePos().x;
for (std::size_t i = 0; i < m_marker_fixed.size(); ++i)
if (std::abs(p - m_marker_fixed[i]) < m_tolerance * 4.0)
ImPlot::TagX(m_marker_fixed[i], m_marker_fixed_color, std::to_string(static_cast<int>(ImPlot::GetPlotMousePos().x)).c_str());
}
}

View File

@@ -0,0 +1,30 @@
#pragma once
#include <VE.hpp>
#include "monitor/utils/var.hpp"
namespace monitor::components
{
class markers : public VE::layer, public VE::connector
{
VE_OVERIDE();
VE_EVENT_OVERIDE();
public:
void init();
void set_status(utils::var::STATUS s);
void set_tag_show(bool v);
private:
utils::var::STATUS m_status;
ImVec4 m_marker_audio_color;
ImVec4 m_marker_mouse_color;
double m_marker_audio_position = 0.0;
double m_marker_mouse_position = 0.0;
bool m_shift_press = false;
double m_tolerance = 2.7; // Настройте чувствительность приближения мыши к тэгу
bool m_tag_show = false; // эта штука не ставит тэг на графике наже первого(Magnitude)
ImVec4 m_marker_fixed_color;
std::vector<double> m_marker_fixed;
};
}

View File

@@ -0,0 +1,29 @@
#include "monitor/gui/components/panel/panel.hpp"
#include <hack/math/math.hpp>
namespace monitor::components
{
void panel::on_attach()
{
CONNECT(this);
m_creator.on_attach();
m_helpers.on_attach();
}
void panel::on_detach()
{
DISCONNECT();
m_creator.on_detach();
m_helpers.on_detach();
}
void panel::update()
{
m_size.x = VE::application::get()->get_glfw()->width();
auto ctx = ImGui::GetCurrentContext();
m_size.x -= ctx->Style.FramePadding.x * 2.f;
m_creator.update();
m_helpers.update();
}
}

View File

@@ -0,0 +1,8 @@
#include "monitor/gui/components/panel/panel.hpp"
namespace monitor::components
{
void panel::on_event(VE::event& e)
{
}
}

View File

@@ -0,0 +1,15 @@
#include "monitor/gui/components/panel/panel.hpp"
namespace monitor::components
{
void panel::render()
{
auto ctx = ImGui::GetCurrentContext();
ImGui::SetNextWindowPos(ctx->Style.FramePadding);
ImGui::SetNextWindowSize(m_size);
if (!ImGui::Begin(VE_NO_NAME("panel"), &m_open, m_win_flags)) ImGui::End();
m_creator.render();
m_helpers.render();
ImGui::End();
}
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include <VE.hpp>
#include <harmonica.hpp>
#include "monitor/gui/components/creator/creator.hpp"
#include "monitor/gui/components/helpers/helpers.hpp"
namespace monitor::components
{
class panel : public VE::layer, public VE::flags, public VE::connector
{
VE_OVERIDE();
VE_EVENT_OVERIDE();
private:
ImVec2 m_size = { 950.f, 37.f };
components::creator m_creator;
components::helpers m_helpers;
};
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,778 @@
//--------------------------------------------------
// ImPlot3D v0.2
// implot3d.h
// Date: 2024-11-16
// Author: Breno Cunha Queiroz (brenocq.com)
//
// Acknowledgments:
// ImPlot3D is heavily inspired by ImPlot
// (https://github.com/epezent/implot) by Evan Pezent,
// and follows a similar code style and structure to
// maintain consistency with ImPlot's API.
//--------------------------------------------------
// Table of Contents:
// [SECTION] Macros and Defines
// [SECTION] Forward declarations and basic types
// [SECTION] Flags & Enumerations
// [SECTION] Callbacks
// [SECTION] Context
// [SECTION] Begin/End Plot
// [SECTION] Setup
// [SECTION] Plot Items
// [SECTION] Plot Utils
// [SECTION] Miscellaneous
// [SECTION] Styles
// [SECTION] Demo
// [SECTION] Debugging
// [SECTION] ImPlot3DPoint
// [SECTION] ImPlot3DRay
// [SECTION] ImPlot3DPlane
// [SECTION] ImPlot3DBox
// [SECTION] ImPlot3DQuat
// [SECTION] ImPlot3DStyle
// [SECTION] Meshes
#pragma once
#include <imgui.h>
#ifndef IMGUI_DISABLE
//-----------------------------------------------------------------------------
// [SECTION] Macros and Defines
//-----------------------------------------------------------------------------
#ifndef IMPLOT3D_API
#define IMPLOT3D_API
#endif
#define IMPLOT3D_VERSION "0.2" // ImPlot3D version
#define IMPLOT3D_VERSION_NUM 200 // Integer encoded version
#define IMPLOT3D_AUTO -1 // Deduce variable automatically
#define IMPLOT3D_AUTO_COL ImVec4(0, 0, 0, -1) // Deduce color automatically
#define IMPLOT3D_TMP template <typename T> IMPLOT3D_API
//-----------------------------------------------------------------------------
// [SECTION] Forward declarations and basic types
//-----------------------------------------------------------------------------
// Forward declarations
struct ImPlot3DContext;
struct ImPlot3DStyle;
struct ImPlot3DPoint;
struct ImPlot3DRay;
struct ImPlot3DPlane;
struct ImPlot3DBox;
struct ImPlot3DRange;
struct ImPlot3DQuat;
// Enums
typedef int ImPlot3DCond; // -> ImPlot3DCond_ // Enum: Condition for flags
typedef int ImPlot3DCol; // -> ImPlot3DCol_ // Enum: Styling colors
typedef int ImPlot3DStyleVar; // -> ImPlot3DStyleVar_ // Enum: Style variables
typedef int ImPlot3DMarker; // -> ImPlot3DMarker_ // Enum: Marker styles
typedef int ImPlot3DLocation; // -> ImPlot3DLocation_ // Enum: Locations
typedef int ImAxis3D; // -> ImAxis3D_ // Enum: Axis indices
typedef int ImPlane3D; // -> ImPlane3D_ // Enum: Plane indices
typedef int ImPlot3DColormap; // -> ImPlot3DColormap_ // Enum: Colormaps
// Flags
typedef int ImPlot3DFlags; // -> ImPlot3DFlags_ // Flags: for BeginPlot()
typedef int ImPlot3DItemFlags; // -> ImPlot3DItemFlags_ // Flags: Item flags
typedef int ImPlot3DScatterFlags; // -> ImPlot3DScatterFlags_ // Flags: Scatter plot flags
typedef int ImPlot3DLineFlags; // -> ImPlot3DLineFlags_ // Flags: Line plot flags
typedef int ImPlot3DTriangleFlags; // -> ImPlot3DTriangleFlags_ // Flags: Triangle plot flags
typedef int ImPlot3DQuadFlags; // -> ImPlot3DQuadFlags_ // Flags: QuadFplot flags
typedef int ImPlot3DSurfaceFlags; // -> ImPlot3DSurfaceFlags_ // Flags: Surface plot flags
typedef int ImPlot3DMeshFlags; // -> ImPlot3DMeshFlags_ // Flags: Mesh plot flags
typedef int ImPlot3DLegendFlags; // -> ImPlot3DLegendFlags_ // Flags: Legend flags
typedef int ImPlot3DAxisFlags; // -> ImPlot3DAxisFlags_ // Flags: Axis flags
//-----------------------------------------------------------------------------
// [SECTION] Flags & Enumerations
//-----------------------------------------------------------------------------
// Flags for ImPlot3D::BeginPlot()
enum ImPlot3DFlags_ {
ImPlot3DFlags_None = 0, // Default
ImPlot3DFlags_NoTitle = 1 << 0, // Hide plot title
ImPlot3DFlags_NoLegend = 1 << 1, // Hide plot legend
ImPlot3DFlags_NoMouseText = 1 << 2, // Hide mouse position in plot coordinates
ImPlot3DFlags_NoClip = 1 << 3, // Disable 3D box clipping
ImPlot3DFlags_NoMenus = 1 << 4, // The user will not be able to open context menus
ImPlot3DFlags_CanvasOnly = ImPlot3DFlags_NoTitle | ImPlot3DFlags_NoLegend | ImPlot3DFlags_NoMouseText,
};
// Represents a condition for SetupAxisLimits etc. (same as ImGuiCond, but we only support a subset of those enums)
enum ImPlot3DCond_ {
ImPlot3DCond_None = ImGuiCond_None, // No condition (always set the variable), same as _Always
ImPlot3DCond_Always = ImGuiCond_Always, // No condition (always set the variable)
ImPlot3DCond_Once = ImGuiCond_Once, // Set the variable once per runtime session (only the first call will succeed)
};
enum ImPlot3DCol_ {
// Item colors
ImPlot3DCol_Line = 0, // Line color
ImPlot3DCol_Fill, // Fill color
ImPlot3DCol_MarkerOutline, // Marker outline color
ImPlot3DCol_MarkerFill, // Marker fill color
// Plot colors
ImPlot3DCol_TitleText, // Title color
ImPlot3DCol_InlayText, // Color for texts appearing inside of plots
ImPlot3DCol_FrameBg, // Frame background color
ImPlot3DCol_PlotBg, // Plot area background color
ImPlot3DCol_PlotBorder, // Plot area border color
// Legend colors
ImPlot3DCol_LegendBg, // Legend background color
ImPlot3DCol_LegendBorder, // Legend border color
ImPlot3DCol_LegendText, // Legend text color
// Axis colors
ImPlot3DCol_AxisText, // Axis label and tick lables color
ImPlot3DCol_AxisGrid, // Axis grid color
ImPlot3DCol_AxisTick, // Axis tick color (defaults to AxisGrid)
ImPlot3DCol_COUNT,
};
// Plot styling variables
enum ImPlot3DStyleVar_ {
// Item style
ImPlot3DStyleVar_LineWeight, // float, plot item line weight in pixels
ImPlot3DStyleVar_Marker, // int, marker specification
ImPlot3DStyleVar_MarkerSize, // float, marker size in pixels (roughly the marker's "radius")
ImPlot3DStyleVar_MarkerWeight, // float, plot outline weight of markers in pixels
ImPlot3DStyleVar_FillAlpha, // float, alpha modifier applied to all plot item fills
// Plot style
ImPlot3DStyleVar_PlotDefaultSize, // ImVec2, default size used when ImVec2(0,0) is passed to BeginPlot
ImPlot3DStyleVar_PlotMinSize, // ImVec2, minimum size plot frame can be when shrunk
ImPlot3DStyleVar_PlotPadding, // ImVec2, padding between widget frame and plot area, labels, or outside legends (i.e. main padding)
ImPlot3DStyleVar_LabelPadding, // ImVec2, padding between axes labels, tick labels, and plot edge
// Legend style
ImPlot3DStyleVar_LegendPadding, // ImVec2, legend padding from plot edges
ImPlot3DStyleVar_LegendInnerPadding, // ImVec2, legend inner padding from legend edges
ImPlot3DStyleVar_LegendSpacing, // ImVec2, spacing between legend entries
ImPlot3DStyleVar_COUNT
};
enum ImPlot3DMarker_ {
ImPlot3DMarker_None = -1, // No marker
ImPlot3DMarker_Circle, // Circle marker (default)
ImPlot3DMarker_Square, // Square maker
ImPlot3DMarker_Diamond, // Diamond marker
ImPlot3DMarker_Up, // Upward-pointing triangle marker
ImPlot3DMarker_Down, // Downward-pointing triangle marker
ImPlot3DMarker_Left, // Leftward-pointing triangle marker
ImPlot3DMarker_Right, // Rightward-pointing triangle marker
ImPlot3DMarker_Cross, // Cross marker (not fillable)
ImPlot3DMarker_Plus, // Plus marker (not fillable)
ImPlot3DMarker_Asterisk, // Asterisk marker (not fillable)
ImPlot3DMarker_COUNT
};
// Flags for items
enum ImPlot3DItemFlags_ {
ImPlot3DItemFlags_None = 0, // Default
ImPlot3DItemFlags_NoLegend = 1 << 0, // The item won't have a legend entry displayed
ImPlot3DItemFlags_NoFit = 1 << 1, // The item won't be considered for plot fits
};
// Flags for PlotScatter
enum ImPlot3DScatterFlags_ {
ImPlot3DScatterFlags_None = 0, // Default
ImPlot3DScatterFlags_NoLegend = ImPlot3DItemFlags_NoLegend,
ImPlot3DScatterFlags_NoFit = ImPlot3DItemFlags_NoFit,
};
// Flags for PlotLine
enum ImPlot3DLineFlags_ {
ImPlot3DLineFlags_None = 0, // Default
ImPlot3DLineFlags_NoLegend = ImPlot3DItemFlags_NoLegend,
ImPlot3DLineFlags_NoFit = ImPlot3DItemFlags_NoFit,
ImPlot3DLineFlags_Segments = 1 << 10, // A line segment will be rendered from every two consecutive points
ImPlot3DLineFlags_Loop = 1 << 11, // The last and first point will be connected to form a closed loop
ImPlot3DLineFlags_SkipNaN = 1 << 12, // NaNs values will be skipped instead of rendered as missing data
};
// Flags for PlotTriangle
enum ImPlot3DTriangleFlags_ {
ImPlot3DTriangleFlags_None = 0, // Default
ImPlot3DTriangleFlags_NoLegend = ImPlot3DItemFlags_NoLegend,
ImPlot3DTriangleFlags_NoFit = ImPlot3DItemFlags_NoFit,
};
// Flags for PlotQuad
enum ImPlot3DQuadFlags_ {
ImPlot3DQuadFlags_None = 0, // Default
ImPlot3DQuadFlags_NoLegend = ImPlot3DItemFlags_NoLegend,
ImPlot3DQuadFlags_NoFit = ImPlot3DItemFlags_NoFit,
};
// Flags for PlotSurface
enum ImPlot3DSurfaceFlags_ {
ImPlot3DSurfaceFlags_None = 0, // Default
ImPlot3DSurfaceFlags_NoLegend = ImPlot3DItemFlags_NoLegend,
ImPlot3DSurfaceFlags_NoFit = ImPlot3DItemFlags_NoFit,
};
// Flags for PlotMesh
enum ImPlot3DMeshFlags_ {
ImPlot3DMeshFlags_None = 0, // Default
ImPlot3DMeshFlags_NoLegend = ImPlot3DItemFlags_NoLegend,
ImPlot3DMeshFlags_NoFit = ImPlot3DItemFlags_NoFit,
};
// Flags for legends
enum ImPlot3DLegendFlags_ {
ImPlot3DLegendFlags_None = 0, // Default
ImPlot3DLegendFlags_NoButtons = 1 << 0, // Legend icons will not function as hide/show buttons
ImPlot3DLegendFlags_NoHighlightItem = 1 << 1, // Plot items will not be highlighted when their legend entry is hovered
ImPlot3DLegendFlags_Horizontal = 1 << 2, // Legend entries will be displayed horizontally
};
// Used to position legend on a plot
enum ImPlot3DLocation_ {
ImPlot3DLocation_Center = 0, // Center-center
ImPlot3DLocation_North = 1 << 0, // Top-center
ImPlot3DLocation_South = 1 << 1, // Bottom-center
ImPlot3DLocation_West = 1 << 2, // Center-left
ImPlot3DLocation_East = 1 << 3, // Center-right
ImPlot3DLocation_NorthWest = ImPlot3DLocation_North | ImPlot3DLocation_West, // Top-left
ImPlot3DLocation_NorthEast = ImPlot3DLocation_North | ImPlot3DLocation_East, // Top-right
ImPlot3DLocation_SouthWest = ImPlot3DLocation_South | ImPlot3DLocation_West, // Bottom-left
ImPlot3DLocation_SouthEast = ImPlot3DLocation_South | ImPlot3DLocation_East // Bottom-right
};
// Flags for axis
enum ImPlot3DAxisFlags_ {
ImPlot3DAxisFlags_None = 0, // Default
ImPlot3DAxisFlags_NoLabel = 1 << 0, // No axis label will be displayed
ImPlot3DAxisFlags_NoGridLines = 1 << 1, // No grid lines will be displayed
ImPlot3DAxisFlags_NoTickMarks = 1 << 2, // No tick marks will be displayed
ImPlot3DAxisFlags_NoTickLabels = 1 << 3, // No tick labels will be displayed
ImPlot3DAxisFlags_LockMin = 1 << 4, // The axis minimum value will be locked when panning/zooming
ImPlot3DAxisFlags_LockMax = 1 << 5, // The axis maximum value will be locked when panning/zooming
ImPlot3DAxisFlags_AutoFit = 1 << 6, // Axis will be auto-fitting to data extents
ImPlot3DAxisFlags_Invert = 1 << 7, // The axis will be inverted
ImPlot3DAxisFlags_Lock = ImPlot3DAxisFlags_LockMin | ImPlot3DAxisFlags_LockMax,
ImPlot3DAxisFlags_NoDecorations = ImPlot3DAxisFlags_NoLabel | ImPlot3DAxisFlags_NoGridLines | ImPlot3DAxisFlags_NoTickLabels,
};
// Axis indices
enum ImAxis3D_ {
ImAxis3D_X = 0,
ImAxis3D_Y,
ImAxis3D_Z,
ImAxis3D_COUNT,
};
// Plane indices
enum ImPlane3D_ {
ImPlane3D_YZ = 0,
ImPlane3D_XZ,
ImPlane3D_XY,
ImPlane3D_COUNT,
};
// Colormaps
enum ImPlot3DColormap_ {
ImPlot3DColormap_Deep = 0, // Same as seaborn "deep"
ImPlot3DColormap_Dark = 1, // Same as matplotlib "Set1"
ImPlot3DColormap_Pastel = 2, // Same as matplotlib "Pastel1"
ImPlot3DColormap_Paired = 3, // Same as matplotlib "Paired"
ImPlot3DColormap_Viridis = 4, // Same as matplotlib "viridis"
ImPlot3DColormap_Plasma = 5, // Same as matplotlib "plasma"
ImPlot3DColormap_Hot = 6, // Same as matplotlib/MATLAB "hot"
ImPlot3DColormap_Cool = 7, // Same as matplotlib/MATLAB "cool"
ImPlot3DColormap_Pink = 8, // Same as matplotlib/MATLAB "pink"
ImPlot3DColormap_Jet = 9, // Same as matplotlib/MATLAB "jet"
ImPlot3DColormap_Twilight = 10, // Same as matplotlib "twilight"
ImPlot3DColormap_RdBu = 11, // Same as matplotlib "RdBu"
ImPlot3DColormap_BrBG = 12, // Same as matplotlib "BrGB"
ImPlot3DColormap_PiYG = 13, // Same as matplotlib "PiYG"
ImPlot3DColormap_Spectral = 14, // Same as matplotlib "Spectral"
ImPlot3DColormap_Greys = 15, // White/black
};
//-----------------------------------------------------------------------------
// [SECTION] Callbacks
//-----------------------------------------------------------------------------
// Callback signature for axis tick label formatter
typedef int (*ImPlot3DFormatter)(float value, char* buff, int size, void* user_data);
namespace ImPlot3D {
//-----------------------------------------------------------------------------
// [SECTION] Context
//-----------------------------------------------------------------------------
IMPLOT3D_API ImPlot3DContext* CreateContext();
IMPLOT3D_API void DestroyContext(ImPlot3DContext* ctx = nullptr);
IMPLOT3D_API ImPlot3DContext* GetCurrentContext();
IMPLOT3D_API void SetCurrentContext(ImPlot3DContext* ctx);
//-----------------------------------------------------------------------------
// [SECTION] Begin/End Plot
//-----------------------------------------------------------------------------
// Starts a 3D plotting context. If this function returns true, EndPlot() MUST
// be called! You are encouraged to use the following convention:
//
// if (ImPlot3D::BeginPlot(...)) {
// ImPlot3D::PlotLine(...);
// ...
// ImPlot3D::EndPlot();
// }
//
// Important notes:
// - #title_id must be unique to the current ImGui ID scope. If you need to avoid ID
// collisions or don't want to display a title in the plot, use double hashes
// (e.g. "MyPlot##HiddenIdText" or "##NoTitle").
// - #size is the **frame** size of the plot widget, not the plot area.
IMPLOT3D_API bool BeginPlot(const char* title_id, const ImVec2& size = ImVec2(-1, 0), ImPlot3DFlags flags = 0);
IMPLOT3D_API void EndPlot(); // Only call if BeginPlot() returns true!
//-----------------------------------------------------------------------------
// [SECTION] Setup
//-----------------------------------------------------------------------------
// The following API allows you to setup and customize various aspects of the
// current plot. The functions should be called immediately after BeginPlot()
// and before any other API calls. Typical usage is as follows:
// if (ImPlot3D::BeginPlot(...)) { 1) Begin a new plot
// ImPlot3D::SetupAxis(ImAxis3D_X, "My X-Axis"); 2) Make Setup calls
// ImPlot3D::SetupAxis(ImAxis3D_Y, "My Y-Axis");
// ImPlot3D::SetupLegend(ImPlotLocation_North);
// ...
// ImPlot3D::SetupFinish(); 3) [Optional] Explicitly finish setup
// ImPlot3D::PlotLine(...); 4) Plot items
// ...
// ImPlot3D::EndPlot(); 5) End the plot
// }
//
// Important notes:
//
// - Always call Setup code at the top of your BeginPlot conditional statement.
// - Setup is locked once you start plotting or explicitly call SetupFinish.
// Do NOT call Setup code after you begin plotting or after you make
// any non-Setup API calls (e.g. utils like PlotToPixels also lock Setup).
// - Calling SetupFinish is OPTIONAL, but probably good practice. If you do not
// call it yourself, then the first subsequent plotting or utility function will
// call it for you.
// Enables an axis or sets the label and/or flags for an existing axis. Leave #label = nullptr for no label
IMPLOT3D_API void SetupAxis(ImAxis3D axis, const char* label = nullptr, ImPlot3DAxisFlags flags = 0);
IMPLOT3D_API void SetupAxisLimits(ImAxis3D axis, double v_min, double v_max, ImPlot3DCond cond = ImPlot3DCond_Once);
IMPLOT3D_API void SetupAxisFormat(ImAxis3D idx, ImPlot3DFormatter formatter, void* data = nullptr);
// Sets an axis' ticks and optionally the labels. To keep the default ticks, set #keep_default=true
IMPLOT3D_API void SetupAxisTicks(ImAxis3D axis, const double* values, int n_ticks, const char* const labels[] = nullptr, bool keep_default = false);
// Sets an axis' ticks and optionally the labels for the next plot. To keep the default ticks, set #keep_default=true
IMPLOT3D_API void SetupAxisTicks(ImAxis3D axis, double v_min, double v_max, int n_ticks, const char* const labels[] = nullptr, bool keep_default = false);
// Sets the label and/or flags for primary X/Y/Z axes (shorthand for three calls to SetupAxis)
IMPLOT3D_API void SetupAxes(const char* x_label, const char* y_label, const char* z_label, ImPlot3DAxisFlags x_flags = 0, ImPlot3DAxisFlags y_flags = 0, ImPlot3DAxisFlags z_flags = 0);
// Sets the X/Y/Z axes range limits. If ImPlot3DCond_Always is used, the axes limits will be locked (shorthand for two calls to SetupAxisLimits)
IMPLOT3D_API void SetupAxesLimits(double x_min, double x_max, double y_min, double y_max, double z_min, double z_max, ImPlot3DCond cond = ImPlot3DCond_Once);
// Sets the plot box rotation given the elevation and azimuth angles in degrees. If ImPlot3DCond_Always is used, the rotation will be locked
IMPLOT3D_API void SetupBoxRotation(float elevation, float azimuth, bool animate = false, ImPlot3DCond cond = ImPlot3DCond_Once);
// Sets the plot box rotation given a quaternion. If ImPlot3DCond_Always is used, the rotation will be locked
IMPLOT3D_API void SetupBoxRotation(ImPlot3DQuat rotation, bool animate = false, ImPlot3DCond cond = ImPlot3DCond_Once);
// Sets the plot box initial rotation given the elevation and azimuth angles in degrees. The initial rotation is the rotation the plot goes back to when a left mouse button double click happens
IMPLOT3D_API void SetupBoxInitialRotation(float elevation, float azimuth);
// Sets the plot box initial rotation given a quaternion. The initial rotation is the rotation the plot goes back to when a left mouse button double click happens
IMPLOT3D_API void SetupBoxInitialRotation(ImPlot3DQuat rotation);
// Sets the plot box X/Y/Z scale. A scale of 1.0 is the default. Values greater than 1.0 enlarge the plot, while values between 0.0 and 1.0 shrink it
IMPLOT3D_API void SetupBoxScale(float x, float y, float z);
IMPLOT3D_API void SetupLegend(ImPlot3DLocation location, ImPlot3DLegendFlags flags = 0);
//-----------------------------------------------------------------------------
// [SECTION] Plot Items
//-----------------------------------------------------------------------------
IMPLOT3D_TMP void PlotScatter(const char* label_id, const T* xs, const T* ys, const T* zs, int count, ImPlot3DScatterFlags flags = 0, int offset = 0, int stride = sizeof(T));
IMPLOT3D_TMP void PlotLine(const char* label_id, const T* xs, const T* ys, const T* zs, int count, ImPlot3DLineFlags flags = 0, int offset = 0, int stride = sizeof(T));
IMPLOT3D_TMP void PlotTriangle(const char* label_id, const T* xs, const T* ys, const T* zs, int count, ImPlot3DTriangleFlags flags = 0, int offset = 0, int stride = sizeof(T));
IMPLOT3D_TMP void PlotQuad(const char* label_id, const T* xs, const T* ys, const T* zs, int count, ImPlot3DQuadFlags flags = 0, int offset = 0, int stride = sizeof(T));
// Plot the surface defined by a grid of vertices. The grid is defined by the x and y arrays, and the z array contains the height of each vertex. A total of x_count * y_count vertices are expected for each array. Leave #scale_min and #scale_max both at 0 for automatic color scaling, or set them to a predefined range
IMPLOT3D_TMP void PlotSurface(const char* label_id, const T* xs, const T* ys, const T* zs, int x_count, int y_count, double scale_min = 0.0, double scale_max = 0.0, ImPlot3DSurfaceFlags flags = 0, int offset = 0, int stride = sizeof(T));
IMPLOT3D_API void PlotMesh(const char* label_id, const ImPlot3DPoint* vtx, const unsigned int* idx, int vtx_count, int idx_count, ImPlot3DMeshFlags flags = 0);
// Plots a centered text label at point x,y,z. It is possible to set the text angle in radians and offset in pixels
IMPLOT3D_API void PlotText(const char* text, float x, float y, float z, float angle = 0.0f, const ImVec2& pix_offset = ImVec2(0, 0));
//-----------------------------------------------------------------------------
// [SECTION] Plot Utils
//-----------------------------------------------------------------------------
// Convert a position in the current plot's coordinate system to pixels
IMPLOT3D_API ImVec2 PlotToPixels(const ImPlot3DPoint& point);
IMPLOT3D_API ImVec2 PlotToPixels(double x, double y, double z);
// Convert a pixel coordinate to a ray in the current plot's coordinate system
IMPLOT3D_API ImPlot3DRay PixelsToPlotRay(const ImVec2& pix);
IMPLOT3D_API ImPlot3DRay PixelsToPlotRay(double x, double y);
// Convert a pixel coordinate to a point in an axis plane in the current plot's coordinate system
IMPLOT3D_API ImPlot3DPoint PixelsToPlotPlane(const ImVec2& pix, ImPlane3D plane, bool mask = true);
IMPLOT3D_API ImPlot3DPoint PixelsToPlotPlane(double x, double y, ImPlane3D plane, bool mask = true);
IMPLOT3D_API ImVec2 GetPlotPos(); // Get the current plot position (top-left) in pixels
IMPLOT3D_API ImVec2 GetPlotSize(); // Get the current plot size in pixels
//-----------------------------------------------------------------------------
// [SECTION] Miscellaneous
//-----------------------------------------------------------------------------
IMPLOT3D_API ImDrawList* GetPlotDrawList();
//-----------------------------------------------------------------------------
// [SECTION] Styles
//-----------------------------------------------------------------------------
// Get current style
IMPLOT3D_API ImPlot3DStyle& GetStyle();
// Set color styles
IMPLOT3D_API void StyleColorsAuto(ImPlot3DStyle* dst = nullptr); // Set colors with ImGui style
IMPLOT3D_API void StyleColorsDark(ImPlot3DStyle* dst = nullptr); // Set colors with dark style
IMPLOT3D_API void StyleColorsLight(ImPlot3DStyle* dst = nullptr); // Set colors with light style
IMPLOT3D_API void StyleColorsClassic(ImPlot3DStyle* dst = nullptr); // Set colors with classic style
// Temporarily modify a style color. Don't forget to call PopStyleColor!
IMPLOT3D_API void PushStyleColor(ImPlot3DCol idx, ImU32 col);
IMPLOT3D_API void PushStyleColor(ImPlot3DCol idx, const ImVec4& col);
// Undo temporary style color modification(s). Undo multiple pushes at once by increasing count
IMPLOT3D_API void PopStyleColor(int count = 1);
// Temporarily modify a style variable of float type. Don't forget to call PopStyleVar!
IMPLOT3D_API void PushStyleVar(ImPlot3DStyleVar idx, float val);
// Temporarily modify a style variable of int type. Don't forget to call PopStyleVar!
IMPLOT3D_API void PushStyleVar(ImPlot3DStyleVar idx, int val);
// Temporarily modify a style variable of ImVec2 type. Don't forget to call PopStyleVar!
IMPLOT3D_API void PushStyleVar(ImPlot3DStyleVar idx, const ImVec2& val);
// Undo temporary style variable modification(s). Undo multiple pushes at once by increasing count
IMPLOT3D_API void PopStyleVar(int count = 1);
// Set the line color and weight for the next item only
IMPLOT3D_API void SetNextLineStyle(const ImVec4& col = IMPLOT3D_AUTO_COL, float weight = IMPLOT3D_AUTO);
// Set the fill color for the next item only
IMPLOT3D_API void SetNextFillStyle(const ImVec4& col = IMPLOT3D_AUTO_COL, float alpha_mod = IMPLOT3D_AUTO);
// Set the marker style for the next item only
IMPLOT3D_API void SetNextMarkerStyle(ImPlot3DMarker marker = IMPLOT3D_AUTO, float size = IMPLOT3D_AUTO, const ImVec4& fill = IMPLOT3D_AUTO_COL, float weight = IMPLOT3D_AUTO, const ImVec4& outline = IMPLOT3D_AUTO_COL);
// Get color
IMPLOT3D_API ImVec4 GetStyleColorVec4(ImPlot3DCol idx);
IMPLOT3D_API ImU32 GetStyleColorU32(ImPlot3DCol idx);
//-----------------------------------------------------------------------------
// [SECTION] Colormaps
//-----------------------------------------------------------------------------
// Item styling is based on colormaps when the relevant ImPlot3DCol_XXX is set to
// IMPLOT3D_AUTO_COL (default). Several built-in colormaps are available. You can
// add and then push/pop your own colormaps as well. To permanently set a colormap,
// modify the Colormap index member of your ImPlot3DStyle.
// Colormap data will be ignored and a custom color will be used if you have done one of the following:
// 1) Modified an item style color in your ImPlot3DStyle to anything other than IMPLOT3D_AUTO_COL.
// 3) Set the next item style with a SetNextXXXStyle function.
// Add a new colormap. The color data will be copied. The colormap can be used by pushing either the returned index or the
// string name with PushColormap. The colormap name must be unique and the size must be greater than 1. You will receive
// an assert otherwise! By default colormaps are considered to be qualitative (i.e. discrete). If you want to create a
// continuous colormap, set #qual=false. This will treat the colors you provide as keys, and ImPlot3D will build a linearly
// interpolated lookup table. The memory footprint of this table will be exactly ((size-1)*255+1)*4 bytes.
IMPLOT3D_API ImPlot3DColormap AddColormap(const char* name, const ImVec4* cols, int size, bool qual = true);
IMPLOT3D_API ImPlot3DColormap AddColormap(const char* name, const ImU32* cols, int size, bool qual = true);
// Returns the number of available colormaps (i.e. the built-in + user-added count)
IMPLOT3D_API int GetColormapCount();
// Returns a null terminated string name for a colormap given an index. Returns nullptr if index is invalid
IMPLOT3D_API const char* GetColormapName(ImPlot3DColormap cmap);
// Returns an index number for a colormap given a valid string name. Returns -1 if name is invalid
IMPLOT3D_API ImPlot3DColormap GetColormapIndex(const char* name);
// Temporarily switch to one of the built-in (i.e. ImPlot3DColormap_XXX) or user-added colormaps (i.e. a return value of AddColormap). Don't forget to call PopColormap!
IMPLOT3D_API void PushColormap(ImPlot3DColormap cmap);
// Push a colormap by string name. Use built-in names such as "Default", "Deep", "Jet", etc. or a string you provided to AddColormap. Don't forget to call PopColormap!
IMPLOT3D_API void PushColormap(const char* name);
// Undo temporary colormap modification(s). Undo multiple pushes at once by increasing count
IMPLOT3D_API void PopColormap(int count = 1);
// Returns the next color from the current colormap and advances the colormap for the current plot
// Can also be used with no return value to skip colors if desired. You need to call it between Begin/EndPlot!
IMPLOT3D_API ImVec4 NextColormapColor();
// Returns the size of a colormap
IMPLOT3D_API int GetColormapSize(ImPlot3DColormap cmap = IMPLOT3D_AUTO);
// Returns a color from a colormap given an index >= 0 (modulo will be performed)
IMPLOT3D_API ImVec4 GetColormapColor(int idx, ImPlot3DColormap cmap = IMPLOT3D_AUTO);
// Sample a color from the current colormap given t between 0 and 1
IMPLOT3D_API ImVec4 SampleColormap(float t, ImPlot3DColormap cmap = IMPLOT3D_AUTO);
//-----------------------------------------------------------------------------
// [SECTION] Demo
//-----------------------------------------------------------------------------
// Add implot3d_demo.cpp to your sources to use methods in this section
// Shows the ImPlot3D demo window
IMPLOT3D_API void ShowDemoWindow(bool* p_open = nullptr);
// Shows ImPlot3D style editor block (not a window)
IMPLOT3D_API void ShowStyleEditor(ImPlot3DStyle* ref = nullptr);
} // namespace ImPlot3D
//-----------------------------------------------------------------------------
// [SECTION] ImPlot3DPoint
//-----------------------------------------------------------------------------
// ImPlot3DPoint: 3D vector to store points in 3D
struct ImPlot3DPoint {
float x, y, z;
constexpr ImPlot3DPoint() : x(0.0f), y(0.0f), z(0.0f) {}
constexpr ImPlot3DPoint(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
// Accessors
float& operator[](size_t idx) {
IM_ASSERT(idx == 0 || idx == 1 || idx == 2);
return ((float*)(void*)(char*)this)[idx];
}
float operator[](size_t idx) const {
IM_ASSERT(idx == 0 || idx == 1 || idx == 2);
return ((const float*)(const void*)(const char*)this)[idx];
}
// Binary operators
IMPLOT3D_API ImPlot3DPoint operator*(float rhs) const;
IMPLOT3D_API ImPlot3DPoint operator/(float rhs) const;
IMPLOT3D_API ImPlot3DPoint operator+(const ImPlot3DPoint& rhs) const;
IMPLOT3D_API ImPlot3DPoint operator-(const ImPlot3DPoint& rhs) const;
IMPLOT3D_API ImPlot3DPoint operator*(const ImPlot3DPoint& rhs) const;
IMPLOT3D_API ImPlot3DPoint operator/(const ImPlot3DPoint& rhs) const;
// Unary operator
IMPLOT3D_API ImPlot3DPoint operator-() const;
// Compound assignment operators
IMPLOT3D_API ImPlot3DPoint& operator*=(float rhs);
IMPLOT3D_API ImPlot3DPoint& operator/=(float rhs);
IMPLOT3D_API ImPlot3DPoint& operator+=(const ImPlot3DPoint& rhs);
IMPLOT3D_API ImPlot3DPoint& operator-=(const ImPlot3DPoint& rhs);
IMPLOT3D_API ImPlot3DPoint& operator*=(const ImPlot3DPoint& rhs);
IMPLOT3D_API ImPlot3DPoint& operator/=(const ImPlot3DPoint& rhs);
// Comparison operators
IMPLOT3D_API bool operator==(const ImPlot3DPoint& rhs) const;
IMPLOT3D_API bool operator!=(const ImPlot3DPoint& rhs) const;
// Dot product
IMPLOT3D_API float Dot(const ImPlot3DPoint& rhs) const;
// Cross product
IMPLOT3D_API ImPlot3DPoint Cross(const ImPlot3DPoint& rhs) const;
// Get vector length
IMPLOT3D_API float Length() const;
// Get vector squared length
IMPLOT3D_API float LengthSquared() const;
// Normalize to unit length
IMPLOT3D_API void Normalize();
// Return vector normalized to unit length
IMPLOT3D_API ImPlot3DPoint Normalized() const;
// Friend binary operators to allow commutative behavior
IMPLOT3D_API friend ImPlot3DPoint operator*(float lhs, const ImPlot3DPoint& rhs);
// Check if the point is NaN
IMPLOT3D_API bool IsNaN() const;
#ifdef IMPLOT3D_POINT_CLASS_EXTRA
IMPLOT3D_POINT_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImPlot3DPoint
#endif
};
//-----------------------------------------------------------------------------
// [SECTION] ImPlot3DRay
//-----------------------------------------------------------------------------
struct ImPlot3DRay {
ImPlot3DPoint Origin;
ImPlot3DPoint Direction;
};
//-----------------------------------------------------------------------------
// [SECTION] ImPlot3DPlane
//-----------------------------------------------------------------------------
struct ImPlot3DPlane {
ImPlot3DPoint Point;
ImPlot3DPoint Normal;
};
//-----------------------------------------------------------------------------
// [SECTION] ImPlot3DBox
//-----------------------------------------------------------------------------
struct ImPlot3DBox {
ImPlot3DPoint Min;
ImPlot3DPoint Max;
// Default constructor
constexpr ImPlot3DBox() : Min(ImPlot3DPoint()), Max(ImPlot3DPoint()) {}
// Constructor with two points
constexpr ImPlot3DBox(const ImPlot3DPoint& min, const ImPlot3DPoint& max) : Min(min), Max(max) {}
// Method to expand the box to include a point
IMPLOT3D_API void Expand(const ImPlot3DPoint& point);
// Method to check if a point is inside the box
IMPLOT3D_API bool Contains(const ImPlot3DPoint& point) const;
// Method to clip a line segment against the box
IMPLOT3D_API bool ClipLineSegment(const ImPlot3DPoint& p0, const ImPlot3DPoint& p1, ImPlot3DPoint& p0_clipped, ImPlot3DPoint& p1_clipped) const;
};
//-----------------------------------------------------------------------------
// [SECTION] ImPlot3DRange
//-----------------------------------------------------------------------------
struct ImPlot3DRange {
float Min;
float Max;
constexpr ImPlot3DRange() : Min(0.0f), Max(0.0f) {}
constexpr ImPlot3DRange(float min, float max) : Min(min), Max(max) {}
IMPLOT3D_API void Expand(float value);
IMPLOT3D_API bool Contains(float value) const;
float Size() const { return Max - Min; }
};
//-----------------------------------------------------------------------------
// [SECTION] ImPlot3DQuat
//-----------------------------------------------------------------------------
struct ImPlot3DQuat {
float x, y, z, w;
// Constructors
constexpr ImPlot3DQuat() : x(0.0f), y(0.0f), z(0.0f), w(1.0f) {}
constexpr ImPlot3DQuat(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) {}
IMPLOT3D_API ImPlot3DQuat(float _angle, const ImPlot3DPoint& _axis);
// Set quaternion from two vectors
IMPLOT3D_API static ImPlot3DQuat FromTwoVectors(const ImPlot3DPoint& v0, const ImPlot3DPoint& v1);
// Set quaternion given elevation and azimuth angles in radians
IMPLOT3D_API static ImPlot3DQuat FromElAz(float elevation, float azimuth);
// Get quaternion length
IMPLOT3D_API float Length() const;
// Get normalized quaternion
IMPLOT3D_API ImPlot3DQuat Normalized() const;
// Conjugate of the quaternion
IMPLOT3D_API ImPlot3DQuat Conjugate() const;
// Inverse of the quaternion
IMPLOT3D_API ImPlot3DQuat Inverse() const;
// Binary operators
IMPLOT3D_API ImPlot3DQuat operator*(const ImPlot3DQuat& rhs) const;
// Normalize the quaternion in place
IMPLOT3D_API ImPlot3DQuat& Normalize();
// Rotate a 3D point using the quaternion
IMPLOT3D_API ImPlot3DPoint operator*(const ImPlot3DPoint& point) const;
// Comparison operators
IMPLOT3D_API bool operator==(const ImPlot3DQuat& rhs) const;
IMPLOT3D_API bool operator!=(const ImPlot3DQuat& rhs) const;
// Interpolate between two quaternions
IMPLOT3D_API static ImPlot3DQuat Slerp(const ImPlot3DQuat& q1, const ImPlot3DQuat& q2, float t);
// Get quaternion dot product
IMPLOT3D_API float Dot(const ImPlot3DQuat& rhs) const;
#ifdef IMPLOT3D_QUAT_CLASS_EXTRA
IMPLOT3D_QUAT_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImPlot3DQuat
#endif
};
//-----------------------------------------------------------------------------
// [SECTION] ImPlot3DStyle
//-----------------------------------------------------------------------------
struct ImPlot3DStyle {
// Item style
float LineWeight; // Line weight in pixels
int Marker; // Default marker type (ImPlot3DMarker_None)
float MarkerSize; // Marker size in pixels (roughly the marker's "radius")
float MarkerWeight; // Marker outline weight in pixels
float FillAlpha; // Alpha modifier applied to plot fills
// Plot style
ImVec2 PlotDefaultSize;
ImVec2 PlotMinSize;
ImVec2 PlotPadding;
ImVec2 LabelPadding;
// Legend style
ImVec2 LegendPadding; // Legend padding from plot edges
ImVec2 LegendInnerPadding; // Legend inner padding from legend edges
ImVec2 LegendSpacing; // Spacing between legend entries
// Colors
ImVec4 Colors[ImPlot3DCol_COUNT];
// Colormap
ImPlot3DColormap Colormap; // The current colormap. Set this to either an ImPlot3DColormap_ enum or an index returned by AddColormap
// Constructor
IMPLOT3D_API ImPlot3DStyle();
};
//-----------------------------------------------------------------------------
// [SECTION] Meshes
//-----------------------------------------------------------------------------
namespace ImPlot3D {
// Cube
constexpr int CUBE_VTX_COUNT = 8; // Number of cube vertices
constexpr int CUBE_IDX_COUNT = 36; // Number of cube indices (12 triangles)
extern ImPlot3DPoint cube_vtx[CUBE_VTX_COUNT]; // Cube vertices
extern unsigned int cube_idx[CUBE_IDX_COUNT]; // Cube indices
// Sphere
constexpr int SPHERE_VTX_COUNT = 162; // Number of sphere vertices for 128 triangles
constexpr int SPHERE_IDX_COUNT = 960; // Number of sphere indices (128 triangles)
extern ImPlot3DPoint sphere_vtx[SPHERE_VTX_COUNT]; // Sphere vertices
extern unsigned int sphere_idx[SPHERE_IDX_COUNT]; // Sphere indices
// Duck (Rubber Duck by Poly by Google [CC-BY] via Poly Pizza)
constexpr int DUCK_VTX_COUNT = 254; // Number of duck vertices
constexpr int DUCK_IDX_COUNT = 1428; // Number of duck indices
extern ImPlot3DPoint duck_vtx[DUCK_VTX_COUNT]; // Duck vertices
extern unsigned int duck_idx[DUCK_IDX_COUNT]; // Duck indices
} // namespace ImPlot3D
#endif // #ifndef IMGUI_DISABLE

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,727 @@
//--------------------------------------------------
// ImPlot3D v0.2
// implot3d_internal.h
// Date: 2024-11-17
// Author: Breno Cunha Queiroz (brenocq.com)
//
// Acknowledgments:
// ImPlot3D is heavily inspired by ImPlot
// (https://github.com/epezent/implot) by Evan Pezent,
// and follows a similar code style and structure to
// maintain consistency with ImPlot's API.
//--------------------------------------------------
// Table of Contents:
// [SECTION] Constants
// [SECTION] Generic Helpers
// [SECTION] Forward Declarations
// [SECTION] Callbacks
// [SECTION] Structs
// [SECTION] Context Pointer
// [SECTION] Context Utils
// [SECTION] Style Utils
// [SECTION] Item Utils
// [SECTION] Plot Utils
// [SECTION] Setup Utils
// [SECTION] Formatter
// [SECTION] Locator
#pragma once
#ifndef IMPLOT3D_VERSION
#include "implot3d.h"
#endif
#ifndef IMGUI_DISABLE
#include <imgui_internal.h>
//-----------------------------------------------------------------------------
// [SECTION] Constants
//-----------------------------------------------------------------------------
// Default label format for axis labels
#define IMPLOT3D_LABEL_FORMAT "%g"
// Max character size for tick labels
#define IMPLOT3D_LABEL_MAX_SIZE 32
//-----------------------------------------------------------------------------
// [SECTION] Generic Helpers
//-----------------------------------------------------------------------------
namespace ImPlot3D {
// Computes the common (base-10) logarithm
static inline float ImLog10(float x) { return log10f(x); }
// Returns true if flag is set
template <typename TSet, typename TFlag>
static inline bool ImHasFlag(TSet set, TFlag flag) { return (set & flag) == flag; }
// Flips a flag in a flagset
template <typename TSet, typename TFlag>
static inline void ImFlipFlag(TSet& set, TFlag flag) { ImHasFlag(set, flag) ? set &= ~flag : set |= flag; }
template <typename T>
static inline T ImRemap01(T x, T x0, T x1) { return (x1 - x0) ? ((x - x0) / (x1 - x0)) : 0; }
// Returns true if val is NAN
static inline bool ImNan(float val) { return isnan(val); }
// Returns true if val is NAN or INFINITY
static inline bool ImNanOrInf(float val) { return !(val >= -FLT_MAX && val <= FLT_MAX) || ImNan(val); }
// Turns NANs to 0s
static inline double ImConstrainNan(float val) { return ImNan(val) ? 0 : val; }
// Turns infinity to floating point maximums
static inline double ImConstrainInf(double val) { return val >= FLT_MAX ? FLT_MAX : val <= -FLT_MAX ? -FLT_MAX
: val; }
// True if two numbers are approximately equal using units in the last place.
static inline bool ImAlmostEqual(double v1, double v2, int ulp = 2) { return ImAbs(v1 - v2) < FLT_EPSILON * ImAbs(v1 + v2) * ulp || ImAbs(v1 - v2) < FLT_MIN; }
// Set alpha channel of 32-bit color from float in range [0.0 1.0]
static inline ImU32 ImAlphaU32(ImU32 col, float alpha) {
return col & ~((ImU32)((1.0f - alpha) * 255) << IM_COL32_A_SHIFT);
}
// Mix color a and b by factor s in [0 256]
static inline ImU32 ImMixU32(ImU32 a, ImU32 b, ImU32 s) {
#ifdef IMPLOT3D_MIX64
const ImU32 af = 256 - s;
const ImU32 bf = s;
const ImU64 al = (a & 0x00ff00ff) | (((ImU64)(a & 0xff00ff00)) << 24);
const ImU64 bl = (b & 0x00ff00ff) | (((ImU64)(b & 0xff00ff00)) << 24);
const ImU64 mix = (al * af + bl * bf);
return ((mix >> 32) & 0xff00ff00) | ((mix & 0xff00ff00) >> 8);
#else
const ImU32 af = 256 - s;
const ImU32 bf = s;
const ImU32 al = (a & 0x00ff00ff);
const ImU32 ah = (a & 0xff00ff00) >> 8;
const ImU32 bl = (b & 0x00ff00ff);
const ImU32 bh = (b & 0xff00ff00) >> 8;
const ImU32 ml = (al * af + bl * bf);
const ImU32 mh = (ah * af + bh * bf);
return (mh & 0xff00ff00) | ((ml & 0xff00ff00) >> 8);
#endif
}
// Fills a buffer with n samples linear interpolated from vmin to vmax
template <typename T>
void FillRange(ImVector<T>& buffer, int n, T vmin, T vmax) {
buffer.resize(n);
T step = (vmax - vmin) / (n - 1);
for (int i = 0; i < n; ++i) {
buffer[i] = vmin + i * step;
}
}
} // namespace ImPlot3D
//-----------------------------------------------------------------------------
// [SECTION] Forward Declarations
//-----------------------------------------------------------------------------
struct ImPlot3DTicker;
//------------------------------------------------------------------------------
// [SECTION] Callbacks
//------------------------------------------------------------------------------
typedef void (*ImPlot3DLocator)(ImPlot3DTicker& ticker, const ImPlot3DRange& range, float pixels, ImPlot3DFormatter formatter, void* formatter_data);
//-----------------------------------------------------------------------------
// [SECTION] Structs
//-----------------------------------------------------------------------------
struct ImDrawList3D {
ImVector<ImDrawIdx> IdxBuffer; // Index buffer
ImVector<ImDrawVert> VtxBuffer; // Vertex buffer
ImVector<float> ZBuffer; // Z buffer. Depth value for each triangle
unsigned int _VtxCurrentIdx; // [Internal] current vertex index
ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
float* _ZWritePtr; // [Internal] point within ZBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
ImDrawListFlags _Flags; // [Internal] draw list flags
ImDrawListSharedData* _SharedData; // [Internal] shared draw list data
ImDrawList3D() {
_VtxCurrentIdx = 0;
_VtxWritePtr = nullptr;
_IdxWritePtr = nullptr;
_ZWritePtr = nullptr;
_Flags = ImDrawListFlags_None;
_SharedData = nullptr;
}
void PrimReserve(int idx_count, int vtx_count);
void PrimUnreserve(int idx_count, int vtx_count);
void SortedMoveToImGuiDrawList();
constexpr static unsigned int MaxIdx() { return sizeof(ImDrawIdx) == 2 ? 65535 : 4294967295; }
};
struct ImPlot3DNextItemData {
ImVec4 Colors[4]; // ImPlot3DCol_Line, ImPlot3DCol_Fill, ImPlot3DCol_MarkerOutline, ImPlot3DCol_MarkerFill,
float LineWeight;
ImPlot3DMarker Marker;
float MarkerSize;
float MarkerWeight;
float FillAlpha;
bool RenderLine;
bool RenderFill;
bool RenderMarkerLine;
bool RenderMarkerFill;
bool IsAutoFill;
bool IsAutoLine;
bool Hidden;
ImPlot3DNextItemData() { Reset(); }
void Reset() {
for (int i = 0; i < 4; i++)
Colors[i] = IMPLOT3D_AUTO_COL;
LineWeight = IMPLOT3D_AUTO;
Marker = IMPLOT3D_AUTO;
MarkerSize = IMPLOT3D_AUTO;
MarkerWeight = IMPLOT3D_AUTO;
FillAlpha = IMPLOT3D_AUTO;
RenderLine = false;
RenderFill = false;
RenderMarkerLine = true;
RenderMarkerFill = true;
IsAutoFill = true;
IsAutoLine = true;
Hidden = false;
}
};
// Colormap data storage
struct ImPlot3DColormapData {
ImVector<ImU32> Keys;
ImVector<int> KeyCounts;
ImVector<int> KeyOffsets;
ImVector<ImU32> Tables;
ImVector<int> TableSizes;
ImVector<int> TableOffsets;
ImGuiTextBuffer Text;
ImVector<int> TextOffsets;
ImVector<bool> Quals;
ImGuiStorage Map;
int Count;
ImPlot3DColormapData() { Count = 0; }
int Append(const char* name, const ImU32* keys, int count, bool qual) {
if (GetIndex(name) != -1)
return -1;
KeyOffsets.push_back(Keys.size());
KeyCounts.push_back(count);
Keys.reserve(Keys.size() + count);
for (int i = 0; i < count; ++i)
Keys.push_back(keys[i]);
TextOffsets.push_back(Text.size());
Text.append(name, name + strlen(name) + 1);
Quals.push_back(qual);
ImGuiID id = ImHashStr(name);
int idx = Count++;
Map.SetInt(id, idx);
_AppendTable(idx);
return idx;
}
void _AppendTable(ImPlot3DColormap cmap) {
int key_count = GetKeyCount(cmap);
const ImU32* keys = GetKeys(cmap);
int off = Tables.size();
TableOffsets.push_back(off);
if (IsQual(cmap)) {
Tables.reserve(key_count);
for (int i = 0; i < key_count; ++i)
Tables.push_back(keys[i]);
TableSizes.push_back(key_count);
} else {
int max_size = 255 * (key_count - 1) + 1;
Tables.reserve(off + max_size);
// ImU32 last = keys[0];
// Tables.push_back(last);
// int n = 1;
for (int i = 0; i < key_count - 1; ++i) {
for (int s = 0; s < 255; ++s) {
ImU32 a = keys[i];
ImU32 b = keys[i + 1];
ImU32 c = ImPlot3D::ImMixU32(a, b, s);
// if (c != last) {
Tables.push_back(c);
// last = c;
// n++;
// }
}
}
ImU32 c = keys[key_count - 1];
// if (c != last) {
Tables.push_back(c);
// n++;
// }
// TableSizes.push_back(n);
TableSizes.push_back(max_size);
}
}
void RebuildTables() {
Tables.resize(0);
TableSizes.resize(0);
TableOffsets.resize(0);
for (int i = 0; i < Count; ++i)
_AppendTable(i);
}
inline bool IsQual(ImPlot3DColormap cmap) const { return Quals[cmap]; }
inline const char* GetName(ImPlot3DColormap cmap) const { return cmap < Count ? Text.Buf.Data + TextOffsets[cmap] : nullptr; }
inline ImPlot3DColormap GetIndex(const char* name) const {
ImGuiID key = ImHashStr(name);
return Map.GetInt(key, -1);
}
inline const ImU32* GetKeys(ImPlot3DColormap cmap) const { return &Keys[KeyOffsets[cmap]]; }
inline int GetKeyCount(ImPlot3DColormap cmap) const { return KeyCounts[cmap]; }
inline ImU32 GetKeyColor(ImPlot3DColormap cmap, int idx) const { return Keys[KeyOffsets[cmap] + idx]; }
inline void SetKeyColor(ImPlot3DColormap cmap, int idx, ImU32 value) {
Keys[KeyOffsets[cmap] + idx] = value;
RebuildTables();
}
inline const ImU32* GetTable(ImPlot3DColormap cmap) const { return &Tables[TableOffsets[cmap]]; }
inline int GetTableSize(ImPlot3DColormap cmap) const { return TableSizes[cmap]; }
inline ImU32 GetTableColor(ImPlot3DColormap cmap, int idx) const { return Tables[TableOffsets[cmap] + idx]; }
inline ImU32 LerpTable(ImPlot3DColormap cmap, float t) const {
int off = TableOffsets[cmap];
int siz = TableSizes[cmap];
int idx = Quals[cmap] ? ImClamp((int)(siz * t), 0, siz - 1) : (int)((siz - 1) * t + 0.5f);
return Tables[off + idx];
}
};
// State information for plot items
struct ImPlot3DItem {
ImGuiID ID;
ImU32 Color;
int NameOffset;
bool Show;
bool LegendHovered;
bool SeenThisFrame;
ImPlot3DItem() {
ID = 0;
Color = IM_COL32_WHITE;
NameOffset = -1;
Show = true;
LegendHovered = false;
SeenThisFrame = false;
}
~ImPlot3DItem() { ID = 0; }
};
// Holds legend state
struct ImPlot3DLegend {
ImPlot3DLegendFlags Flags;
ImPlot3DLegendFlags PreviousFlags;
ImPlot3DLocation Location;
ImPlot3DLocation PreviousLocation;
ImVector<int> Indices;
ImGuiTextBuffer Labels;
ImRect Rect;
bool Hovered;
bool Held;
ImPlot3DLegend() {
PreviousFlags = Flags = ImPlot3DLegendFlags_None;
Hovered = Held = false;
PreviousLocation = Location = ImPlot3DLocation_NorthWest;
}
void Reset() {
Indices.shrink(0);
Labels.Buf.shrink(0);
}
};
// Holds items
struct ImPlot3DItemGroup {
ImPool<ImPlot3DItem> ItemPool;
ImPlot3DLegend Legend;
int ColormapIdx;
ImPlot3DItemGroup() {
ColormapIdx = 0;
}
int GetItemCount() const { return ItemPool.GetBufSize(); }
ImGuiID GetItemID(const char* label_id) { return ImGui::GetID(label_id); }
ImPlot3DItem* GetItem(ImGuiID id) { return ItemPool.GetByKey(id); }
ImPlot3DItem* GetItem(const char* label_id) { return GetItem(GetItemID(label_id)); }
ImPlot3DItem* GetOrAddItem(ImGuiID id) { return ItemPool.GetOrAddByKey(id); }
ImPlot3DItem* GetItemByIndex(int i) { return ItemPool.GetByIndex(i); }
int GetItemIndex(ImPlot3DItem* item) { return ItemPool.GetIndex(item); }
int GetLegendCount() const { return Legend.Indices.size(); }
ImPlot3DItem* GetLegendItem(int i) { return ItemPool.GetByIndex(Legend.Indices[i]); }
const char* GetLegendLabel(int i) { return Legend.Labels.Buf.Data + GetLegendItem(i)->NameOffset; }
void Reset() {
ItemPool.Clear();
Legend.Reset();
ColormapIdx = 0;
}
};
// Tick mark info
struct ImPlot3DTick {
float PlotPos;
bool Major;
bool ShowLabel;
ImVec2 LabelSize;
int TextOffset;
int Idx;
ImPlot3DTick(double value, bool major, bool show_label) {
PlotPos = (float)value;
Major = major;
ShowLabel = show_label;
TextOffset = -1;
}
};
// Collection of ticks
struct ImPlot3DTicker {
ImVector<ImPlot3DTick> Ticks;
ImGuiTextBuffer TextBuffer;
ImPlot3DTicker() {
Reset();
}
ImPlot3DTick& AddTick(double value, bool major, bool show_label, const char* label) {
ImPlot3DTick tick(value, major, show_label);
if (show_label && label != nullptr) {
tick.TextOffset = TextBuffer.size();
TextBuffer.append(label, label + strlen(label) + 1);
tick.LabelSize = ImGui::CalcTextSize(TextBuffer.Buf.Data + tick.TextOffset);
}
return AddTick(tick);
}
ImPlot3DTick& AddTick(double value, bool major, bool show_label, ImPlot3DFormatter formatter, void* data) {
ImPlot3DTick tick(value, major, show_label);
if (show_label && formatter != nullptr) {
char buff[IMPLOT3D_LABEL_MAX_SIZE];
tick.TextOffset = TextBuffer.size();
formatter(tick.PlotPos, buff, sizeof(buff), data);
TextBuffer.append(buff, buff + strlen(buff) + 1);
tick.LabelSize = ImGui::CalcTextSize(TextBuffer.Buf.Data + tick.TextOffset);
}
return AddTick(tick);
}
inline ImPlot3DTick& AddTick(ImPlot3DTick tick) {
tick.Idx = Ticks.size();
Ticks.push_back(tick);
return Ticks.back();
}
const char* GetText(int idx) const {
return TextBuffer.Buf.Data + Ticks[idx].TextOffset;
}
const char* GetText(const ImPlot3DTick& tick) const {
return GetText(tick.Idx);
}
void Reset() {
Ticks.shrink(0);
TextBuffer.Buf.shrink(0);
}
int TickCount() const {
return Ticks.Size;
}
};
// Holds axis information
struct ImPlot3DAxis {
ImPlot3DAxisFlags Flags;
ImPlot3DAxisFlags PreviousFlags;
ImPlot3DRange Range;
ImPlot3DCond RangeCond;
ImGuiTextBuffer Label;
// Ticks
ImPlot3DTicker Ticker;
ImPlot3DFormatter Formatter;
void* FormatterData;
ImPlot3DLocator Locator;
bool ShowDefaultTicks;
// Fit data
bool FitThisFrame;
ImPlot3DRange FitExtents;
// User input
bool Hovered;
bool Held;
// Constructor
ImPlot3DAxis() {
PreviousFlags = Flags = ImPlot3DAxisFlags_None;
// Range
Range.Min = 0.0f;
Range.Max = 1.0f;
RangeCond = ImPlot3DCond_None;
// Ticks
Formatter = nullptr;
FormatterData = nullptr;
Locator = nullptr;
ShowDefaultTicks = true;
// Fit data
FitThisFrame = true;
FitExtents.Min = HUGE_VAL;
FitExtents.Max = -HUGE_VAL;
// User input
Hovered = false;
Held = false;
}
inline void Reset() {
Formatter = nullptr;
FormatterData = nullptr;
Locator = nullptr;
ShowDefaultTicks = true;
FitExtents.Min = HUGE_VAL;
FitExtents.Max = -HUGE_VAL;
RangeCond = ImPlot3DCond_None;
Ticker.Reset();
}
inline void SetRange(double v1, double v2) {
Range.Min = (float)ImMin(v1, v2);
Range.Max = (float)ImMax(v1, v2);
}
inline bool SetMin(double _min, bool force = false) {
if (!force && IsLockedMin())
return false;
_min = ImPlot3D::ImConstrainNan((float)ImPlot3D::ImConstrainInf(_min));
if (_min >= Range.Max)
return false;
Range.Min = (float)_min;
return true;
}
inline bool SetMax(double _max, bool force = false) {
if (!force && IsLockedMax())
return false;
_max = ImPlot3D::ImConstrainNan((float)ImPlot3D::ImConstrainInf(_max));
if (_max <= Range.Min)
return false;
Range.Max = (float)_max;
return true;
}
inline bool IsRangeLocked() const { return RangeCond == ImPlot3DCond_Always; }
inline bool IsLockedMin() const { return IsRangeLocked() || ImPlot3D::ImHasFlag(Flags, ImPlot3DAxisFlags_LockMin); }
inline bool IsLockedMax() const { return IsRangeLocked() || ImPlot3D::ImHasFlag(Flags, ImPlot3DAxisFlags_LockMax); }
inline bool IsLocked() const { return IsLockedMin() && IsLockedMax(); }
inline bool IsInputLockedMin() const { return IsLockedMin() || IsAutoFitting(); }
inline bool IsInputLockedMax() const { return IsLockedMax() || IsAutoFitting(); }
inline bool IsInputLocked() const { return IsLocked() || IsAutoFitting(); }
inline void SetLabel(const char* label) {
Label.Buf.shrink(0);
if (label && ImGui::FindRenderedTextEnd(label, nullptr) != label)
Label.append(label, label + strlen(label) + 1);
}
inline const char* GetLabel() const { return Label.Buf.Data; }
bool HasLabel() const;
bool HasGridLines() const;
bool HasTickLabels() const;
bool HasTickMarks() const;
bool IsAutoFitting() const;
void ExtendFit(float value);
void ApplyFit();
};
// Holds plot state information that must persist after EndPlot
struct ImPlot3DPlot {
ImGuiID ID;
ImPlot3DFlags Flags;
ImPlot3DFlags PreviousFlags;
ImGuiTextBuffer Title;
bool JustCreated;
bool Initialized;
// Bounding rectangles
ImRect FrameRect; // Outermost bounding rectangle that encapsulates whole the plot/title/padding/etc
ImRect CanvasRect; // Frame rectangle reduced by padding
ImRect PlotRect; // Bounding rectangle for the actual plot area
// Rotation & axes & box
ImPlot3DQuat InitialRotation; // Initial rotation quaternion
ImPlot3DQuat Rotation; // Current rotation quaternion
ImPlot3DCond RotationCond;
ImPlot3DAxis Axes[3]; // X, Y, Z axes
ImPlot3DPoint BoxScale; // Scale factor for plot box X, Y, Z axes
// Animation
float AnimationTime; // Remaining animation time
ImPlot3DQuat RotationAnimationEnd; // End rotation for animation
// User input
bool SetupLocked;
bool Hovered;
bool Held;
int HeldEdgeIdx; // Index of the edge being held
int HeldPlaneIdx; // Index of the plane being held
// Fit data
bool FitThisFrame;
// Items
ImPlot3DItemGroup Items;
ImPlot3DItem* CurrentItem;
// 3D draw list
ImDrawList3D DrawList;
// Misc
bool ContextClick; // True if context button was clicked (to distinguish from double click)
bool OpenContextThisFrame;
ImPlot3DPlot() {
PreviousFlags = Flags = ImPlot3DFlags_None;
JustCreated = true;
Initialized = false;
InitialRotation = ImPlot3DQuat(-0.513269f, -0.212596f, -0.318184f, 0.76819f);
Rotation = ImPlot3DQuat(0.0f, 0.0f, 0.0f, 1.0f);
RotationCond = ImPlot3DCond_None;
for (int i = 0; i < 3; i++)
Axes[i] = ImPlot3DAxis();
BoxScale = ImPlot3DPoint(1.0f, 1.0f, 1.0f);
AnimationTime = 0.0f;
RotationAnimationEnd = Rotation;
SetupLocked = false;
Hovered = Held = false;
HeldEdgeIdx = -1;
HeldPlaneIdx = -1;
FitThisFrame = true;
CurrentItem = nullptr;
ContextClick = false;
OpenContextThisFrame = false;
}
inline void SetTitle(const char* title) {
Title.Buf.shrink(0);
if (title && ImGui::FindRenderedTextEnd(title, nullptr) != title)
Title.append(title, title + strlen(title) + 1);
}
inline bool HasTitle() const { return !Title.empty() && !ImPlot3D::ImHasFlag(Flags, ImPlot3DFlags_NoTitle); }
inline const char* GetTitle() const { return Title.Buf.Data; }
inline bool IsRotationLocked() const { return RotationCond == ImPlot3DCond_Always; }
void ExtendFit(const ImPlot3DPoint& point);
ImPlot3DPoint RangeMin() const;
ImPlot3DPoint RangeMax() const;
ImPlot3DPoint RangeCenter() const;
void SetRange(const ImPlot3DPoint& min, const ImPlot3DPoint& max);
float GetBoxZoom() const;
};
struct ImPlot3DContext {
ImPool<ImPlot3DPlot> Plots;
ImPlot3DPlot* CurrentPlot;
ImPlot3DItemGroup* CurrentItems;
ImPlot3DNextItemData NextItemData;
ImPlot3DStyle Style;
ImVector<ImGuiColorMod> ColorModifiers;
ImVector<ImGuiStyleMod> StyleModifiers;
ImVector<ImPlot3DColormap> ColormapModifiers;
ImPlot3DColormapData ColormapData;
};
//-----------------------------------------------------------------------------
// [SECTION] Context Pointer
//-----------------------------------------------------------------------------
namespace ImPlot3D {
#ifndef GImPlot3D
extern IMPLOT3D_API ImPlot3DContext* GImPlot3D; // Current context pointer
#endif
//-----------------------------------------------------------------------------
// [SECTION] Context Utils
//-----------------------------------------------------------------------------
IMPLOT3D_API void InitializeContext(ImPlot3DContext* ctx); // Initialize ImPlot3DContext
IMPLOT3D_API void ResetContext(ImPlot3DContext* ctx); // Reset ImPlot3DContext
//-----------------------------------------------------------------------------
// [SECTION] Style Utils
//-----------------------------------------------------------------------------
IMPLOT3D_API bool IsColorAuto(const ImVec4& col);
IMPLOT3D_API bool IsColorAuto(ImPlot3DCol idx);
IMPLOT3D_API ImVec4 GetAutoColor(ImPlot3DCol idx);
IMPLOT3D_API const char* GetStyleColorName(ImPlot3DCol idx);
// Get styling data for next item (call between BeginItem/EndItem)
IMPLOT3D_API const ImPlot3DNextItemData& GetItemData();
// Returns a color from the Color map given an index >= 0 (modulo will be performed)
IMPLOT3D_API ImU32 GetColormapColorU32(int idx, ImPlot3DColormap cmap);
// Returns the next unused colormap color and advances the colormap. Can be used to skip colors if desired
IMPLOT3D_API ImU32 NextColormapColorU32();
//-----------------------------------------------------------------------------
// [SECTION] Item Utils
//-----------------------------------------------------------------------------
IMPLOT3D_API bool BeginItem(const char* label_id, ImPlot3DItemFlags flags = 0, ImPlot3DCol recolor_from = IMPLOT3D_AUTO);
IMPLOT3D_API void EndItem();
// Register or get an existing item from the current plot
IMPLOT3D_API ImPlot3DItem* RegisterOrGetItem(const char* label_id, ImPlot3DItemFlags flags, bool* just_created = nullptr);
// Busts the cache for every item for every plot in the current context
IMPLOT3D_API void BustItemCache();
// TODO move to another place
IMPLOT3D_API void AddTextRotated(ImDrawList* draw_list, ImVec2 pos, float angle, ImU32 col, const char* text_begin, const char* text_end = nullptr);
//-----------------------------------------------------------------------------
// [SECTION] Plot Utils
//-----------------------------------------------------------------------------
// Gets the current plot from the current ImPlot3DContext
IMPLOT3D_API ImPlot3DPlot* GetCurrentPlot();
// Busts the cache for every plot in the current context
IMPLOT3D_API void BustPlotCache();
IMPLOT3D_API ImVec2 GetFramePos(); // Get the current frame position (top-left) in pixels
IMPLOT3D_API ImVec2 GetFrameSize(); // Get the current frame size in pixels
// Convert a position in the current plot's coordinate system to the current plot's normalized device coordinate system (NDC)
// When the cube aspect ratio is [1,1,1], the NDC varies from [-0.5, 0.5] in each axis
IMPLOT3D_API ImPlot3DPoint PlotToNDC(const ImPlot3DPoint& point);
IMPLOT3D_API ImPlot3DPoint NDCToPlot(const ImPlot3DPoint& point);
// Convert a position in the current plot's NDC to pixels
IMPLOT3D_API ImVec2 NDCToPixels(const ImPlot3DPoint& point);
// Convert a pixel coordinate to a ray in the NDC
IMPLOT3D_API ImPlot3DRay PixelsToNDCRay(const ImVec2& pix);
// Convert a ray in the NDC to a ray in the current plot's coordinate system
IMPLOT3D_API ImPlot3DRay NDCRayToPlotRay(const ImPlot3DRay& ray);
//-----------------------------------------------------------------------------
// [SECTION] Setup Utils
//-----------------------------------------------------------------------------
IMPLOT3D_API void SetupLock();
//-----------------------------------------------------------------------------
// [SECTION] Formatter
//-----------------------------------------------------------------------------
int Formatter_Default(float value, char* buff, int size, void* data);
//------------------------------------------------------------------------------
// [SECTION] Locator
//------------------------------------------------------------------------------
void Locator_Default(ImPlot3DTicker& ticker, const ImPlot3DRange& range, float pixels, ImPlot3DFormatter formatter, void* formatter_data);
} // namespace ImPlot3D
#endif // #ifndef IMGUI_DISABLE

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,113 @@
#include "monitor/gui/components/snapshot/snapshot.hpp"
#include "monitor/utils/var.hpp"
#include <hack/math/math.hpp>
namespace monitor::components
{
void snapshot::on_attach()
{
CONNECT(this);
m_audio.on_attach();
m_markers.on_attach();
m_plugins.emplace_back(combo{ .m_id = 0, .m_name = "Energy", .m_type = utils::var::PLUGIN_TYPE::ENERGY });
m_plugins.emplace_back(combo{ .m_id = 1, .m_name = "Segmenter", .m_type = utils::var::PLUGIN_TYPE::SEGMENTER });
}
void snapshot::on_detach()
{
DISCONNECT();
m_audio.on_detach();
m_markers.on_detach();
}
void snapshot::update()
{
m_size.x = VE::application::get()->get_glfw()->width();
m_size.y = VE::application::get()->get_glfw()->height();
m_audio.update();
m_markers.update();
}
void snapshot::set_status(utils::var::STATUS s)
{
m_status = s;
m_markers.set_status(m_status);
m_audio.set_status(m_status);
}
void snapshot::init(hr::setup setup)
{
m_setup = setup;
auto r = hr::run<hr::plugins::magnitude>(m_setup);
fill(r);
m_audio.init(m_setup.m_file);
m_audio.set_step(r.m_data.size());
m_markers.init();
set_status(utils::var::STATUS::ACTIVE);
}
void snapshot::fill(hr::result& r)
{
auto base_size = r.m_data.size();
utils::types::graph_data data;
if (base_size > utils::var::MAX_RENDER_SIZE)
{
hack::warn()("Данный файл превышает максимально допустимый размер рендеринга");
hack::log()("Возможно пришло время чтобы написать тут код... см. dspv.v3");
hack::log()("но там есть tmp, которая может ту быть сомнительной...");
}
else
{
// резервируем кол-во линий графиков исходя из того сколько данных нужно отрисовать в каждом бине из dsp
auto graph_count = r.m_data[0].m_value.size();
data.m_render_data.reserve(graph_count);
for (std::size_t i = 0; i < graph_count; ++i) data.m_render_data.push_back(hr::fvec_t());
// тут резирвируем именно длинну по оси X всех линий
data.m_ox.reserve(base_size);
// заполняем данными все линии графиков
for (auto el : r.m_data)
{
for (std::size_t i = 0; i < graph_count; ++i)
{
data.m_max_element = hack::math::max(el.m_value[i], data.m_max_element);
data.m_render_data[i].push_back(el.m_value[i]);
}
}
for (std::size_t i = 0; i < data.m_render_data[0].size(); ++i) data.m_ox.push_back(i);
}
data.m_name = m_plugin.m_name;
data.m_type = m_plugin.m_type;
m_graphs.push_back(data);
}
void snapshot::add_plugin()
{
hr::result r;
switch (m_plugin.m_type)
{
case utils::var::PLUGIN_TYPE::SEGMENTER:
{
r = hr::run<hr::plugins::segmenter>(m_setup);
break;
}
case utils::var::PLUGIN_TYPE::ENERGY:
{
r = hr::run<hr::plugins::energy>(m_setup);
break;
}
}
fill(r);
m_plugin.clear();
}
}

View File

@@ -0,0 +1,9 @@
#include "monitor/gui/components/snapshot/snapshot.hpp"
namespace monitor::components
{
void snapshot::on_event(VE::event& e)
{
if (m_status != utils::var::STATUS::ACTIVE) return;
}
}

View File

@@ -0,0 +1,74 @@
#include "monitor/gui/components/snapshot/snapshot.hpp"
#include "monitor/gui/components/plots/2d/implot.h"
namespace monitor::components
{
void snapshot::render()
{
m_audio.render();
ImGui::SameLine();
ImGui::SetNextItemWidth(400.f);
if (ImGui::BeginCombo(VE_NO_NAME("select_plugin"), m_plugin.m_id < 0 ? "---" : m_plugins[m_plugin.m_id].m_name.c_str()))
{
for (std::size_t i = 0; i < m_plugins.size(); ++i)
{
const bool is_selected = (m_plugin.m_id == static_cast<int>(i));
if (ImGui::Selectable(m_plugins[i].m_name.c_str(), is_selected))
m_plugin = m_plugins[i];
if (is_selected) ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::SameLine();
if (ImGui::Button("add plugin", ImVec2{ 94.f, 27.f })) add_plugin();
if (ImPlot::BeginSubplots(VE_NO_NAME("graph" + m_snapshot_id), m_rows, m_cols, ImVec2(-1, -1), ImPlotSubplotFlags_LinkRows | ImPlotSubplotFlags_LinkCols))
{
for (const auto& graph : m_graphs)
{
if (ImPlot::BeginPlot(VE_NAME(graph.m_name), ImVec2(-1, 0), ImPlotFlags_NoMenus))
{
// по оси X
ImPlot::SetupAxes(nullptr, nullptr, ImPlotAxisFlags_Opposite | // смена полюсов у надписей оси x. они вверху
ImPlotAxisFlags_NoSideSwitch | // нельзя перетаскивать оси по сторонам
(is_first_render ? ImPlotAxisFlags_AutoFit : ImPlotAxisFlags_None) | // авто подстройка размера по горизонтале
ImPlotAxisFlags_NoHighlight, // не разобрался что это там подсвечивается, что-то с фоном оси
// по оси Y
ImPlotAxisFlags_AutoFit | // авто подстройка размера по вертикале
ImPlotAxisFlags_NoSideSwitch |
ImPlotAxisFlags_NoHighlight |
ImPlotAxisFlags_NoTickLabels // текстовые надписи отображаться не будут
);
ImPlot::SetupAxisLimits(ImAxis_X1, 0.f, graph.m_render_data[0].size());
ImPlot::SetupAxisLimits(ImAxis_Y1, 0.f, graph.m_max_element);
ImPlot::SetupAxisLimitsConstraints(ImAxis_X1, 0, INFINITY);
ImPlot::SetupLegend(ImPlotLocation_NorthEast);
std::size_t index = 0;
for (auto& line : graph.m_render_data)
{
if (graph.m_type == utils::var::PLUGIN_TYPE::SEGMENTER)
ImPlot::PlotStems(VE_NAME(std::to_string(index)), graph.m_ox.data(), line.data(), line.size());
else
ImPlot::PlotLine(VE_NAME(std::to_string(index)), graph.m_ox.data(), line.data(), line.size());
++index;
}
if (graph.m_type != utils::var::PLUGIN_TYPE::MAGNITUDE) m_markers.set_tag_show(false);
else m_markers.set_tag_show(true);
m_markers.render();
ImPlot::EndPlot();
}
}
ImPlot::EndSubplots();
}
is_first_render = false;
}
}

View File

@@ -0,0 +1,56 @@
#pragma once
#include <VE.hpp>
#include <harmonica.hpp>
#include "monitor/utils/var.hpp"
#include "monitor/utils/types/graph_data.hpp"
#include "monitor/gui/components/audio/audio.hpp"
#include "monitor/gui/components/markers/markers.hpp"
namespace monitor::components
{
class snapshot : public VE::layer, public VE::flags, public VE::connector
{
VE_OVERIDE();
VE_EVENT_OVERIDE();
public:
std::string m_snapshot_id;
utils::var::STATUS m_status;
audio m_audio;
hr::setup m_setup;
public:
void set_status(utils::var::STATUS s);
void init(hr::setup setup);
private:
ImVec2 m_size = { 0.f, 0.f };
private:
void fill(hr::result& r);
void add_plugin();
private:
std::vector<utils::types::graph_data> m_graphs;
ImGuiTabBarFlags m_tab_bar_flags { ImGuiTabBarFlags_None };
int m_rows = 7;
int m_cols = 1;
// т.к. флаг ImPlotAxisFlags_AutoFit не дает увеличить масштаб или еще что-то подобное,
// то нужно при первом рендеренге разрешить его, чтобы он установли график как нужно, а потом
// снять чтобы можно было манипулировать мышкой.
bool is_first_render = true;
components::markers m_markers;
private:
struct combo
{
int m_id = -1;
std::string m_name { "Magnitude" };
utils::var::PLUGIN_TYPE m_type { utils::var::PLUGIN_TYPE::MAGNITUDE };
void clear() { m_id = -1; m_name.clear(); }
} m_plugin;
std::vector<combo> m_plugins;
};
}

View File

@@ -0,0 +1,42 @@
#pragma once
#include <VE.hpp>
namespace monitor::components
{
struct spinner
{
inline void render(ImVec2 pos, std::string color = "#1FDB11", bool animation = false)
{
ImVec2 size = { 12.f, 30.f };
std::size_t bars = 3;
float segment_height = 4.f;
float segment_size = 2.f;
ImDrawList* draw_list = ImGui::GetWindowDrawList();
const ImRect bb{ pos, ImVec2{ pos.x + size.x, size.y }};
ImVec2 centre = bb.GetCenter();
const float next_item_padding = 1.5f;
const float scale_y = 0.7f;
const float speed = 0.8f;
const float offset = std::numbers::pi / bars;
float start = (float)ImGui::GetTime() * 12.f;
for (size_t i = 0; i < bars; i++)
{
float a = start + (std::numbers::pi - i * offset);
if (animation) segment_height = (0.4f + 0.6f * ImMax(0.1f, ImSin(a * speed))) * (size.y / 2);
draw_list->AddRectFilled(ImVec2(centre.x + i * (segment_size * next_item_padding) + segment_size / 2, centre.y - segment_height * scale_y),
ImVec2(centre.x + i * (segment_size * next_item_padding) - segment_size / 2, centre.y + segment_height * scale_y),
VE_COLOR(color, 255));
if (i == 0) continue;
draw_list->AddRectFilled(ImVec2(centre.x - i * (segment_size * next_item_padding) + segment_size / 2, centre.y - segment_height * scale_y),
ImVec2(centre.x - i * (segment_size * next_item_padding) - segment_size / 2, centre.y + segment_height * scale_y),
VE_COLOR(color, 255));
}
}
};
}

View File

@@ -0,0 +1,55 @@
#include "monitor/gui/components/tabs/tabs.hpp"
#include "monitor/utils/event_type.hpp"
namespace monitor::components
{
void tabs::on_attach()
{
CONNECT(this);
for (auto & s : m_snapshots) s->on_attach();
}
void tabs::on_detach()
{
DISCONNECT();
for (auto & s : m_snapshots) s->on_detach();
}
void tabs::update()
{
m_size.x = VE::application::get()->get_glfw()->width();
m_size.y = VE::application::get()->get_glfw()->height();
for (auto & s : m_snapshots) s->update();
}
void tabs::create_snapshot(hr::setup setup)
{
auto s = std::make_shared<snapshot>();
s->init(setup);
s->on_attach();
m_snapshots.push_back(s);
}
std::string tabs::string_cut(std::filesystem::path p, int n)
{
std::string s_cut = p.filename();
if (static_cast<int>(s_cut.size()) > n)
{
s_cut.resize(n);
s_cut += " ...";
}
return s_cut;
}
void tabs::change_tab(std::size_t i)
{
VE::event e { utils::event_type::AUDIO_PAUSE, m_current_open_index };
EMIT(e);
m_snapshots[m_current_open_index]->set_status(utils::var::STATUS::INACTIVE);
m_snapshots[i]->set_status(utils::var::STATUS::ACTIVE);
m_current_open_index = i;
};
}

View File

@@ -0,0 +1,23 @@
#include "monitor/gui/components/tabs/tabs.hpp"
#include "monitor/utils/event_type.hpp"
namespace monitor::components
{
void tabs::on_event(VE::event& e)
{
if (e.m_type.type() == typeid(utils::event_type))
{
auto type = std::any_cast<utils::event_type>(e.m_type);
switch (type)
{
case utils::event_type::CREATE_SNAPSHOT:
{
auto data = std::any_cast<hr::setup>(e.m_data);
create_snapshot(data);
break;
}
}
}
}
}

View File

@@ -0,0 +1,48 @@
#include "monitor/gui/components/tabs/tabs.hpp"
namespace monitor::components
{
void tabs::render()
{
if (m_snapshots.empty()) return;
auto ctx = ImGui::GetCurrentContext();
auto past_window_area = 37.f + 2.f * ctx->Style.FramePadding.y;
ImGui::SetNextWindowPos(ImVec2{ ctx->Style.FramePadding.x, past_window_area });
ImGui::SetNextWindowSize(ImVec2{ m_size.x - 2.f * ctx->Style.FramePadding.x, m_size.y - past_window_area - ctx->Style.FramePadding.y });
if (!ImGui::Begin(VE_NO_NAME("tabs"), &m_open, m_win_flags)) ImGui::End();
if (ImGui::IsKeyPressed(ImGuiKey_D)) change_tab((m_current_open_index + 1) % m_snapshots.size());
if (ImGui::IsKeyPressed(ImGuiKey_A)) change_tab((m_current_open_index - 1 + m_snapshots.size()) % m_snapshots.size());
if (ImGui::BeginTabBar(VE_NO_NAME("tabs"), m_tab_bar_flags))
{
for (std::size_t i = 0; i < m_snapshots.size(); ++i)
{
ImGuiTabItemFlags flags = (m_current_open_index == i) ? ImGuiTabItemFlags_SetSelected : 0;
bool open = true;
if (ImGui::BeginTabItem(("[" + std::to_string(i) + "] " + string_cut(m_snapshots[i]->m_setup.m_file, 30)).c_str(), &open, flags))
{
m_snapshots[i]->render();
ImGui::EndTabItem();
}
// Если мышкой кликаем, то нужно это устанавливать
// причем кликаем на неактивный таб
if (ImGui::IsItemClicked()) change_tab(i);
// удаляем если не нужен
if (!open)
{
m_snapshots[i]->on_detach();
m_snapshots.erase(m_snapshots.begin() + i);
if (i > 0) m_snapshots[i - 1]->set_status(utils::var::STATUS::ACTIVE);
}
}
ImGui::EndTabBar();
}
ImGui::End();
}
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include <VE.hpp>
#include <harmonica.hpp>
#include "monitor/gui/components/snapshot/snapshot.hpp"
namespace monitor::components
{
class tabs : public VE::layer, public VE::flags, public VE::connector
{
VE_OVERIDE();
VE_EVENT_OVERIDE();
private:
ImVec2 m_size = { 0.f, 0.f };
std::vector<std::shared_ptr<snapshot>> m_snapshots;
ImGuiTabBarFlags m_tab_bar_flags { ImGuiTabBarFlags_Reorderable };
std::size_t m_current_open_index = 0;
private:
void create_snapshot(hr::setup setup);
std::string string_cut(std::filesystem::path p, int n);
void change_tab(std::size_t i);
};
}

View File

@@ -0,0 +1,28 @@
#include "monitor/gui/win/win.hpp"
#include "monitor/gui/components/plots/2d/implot.h"
#include "monitor/gui/components/plots/3d/implot3d.h"
namespace monitor
{
void win::on_attach()
{
CONNECT(this);
ImPlot3D::CreateContext();
ImPlot::CreateContext();
m_panel.on_attach();
m_tabs.on_attach();
}
void win::on_detach()
{
DISCONNECT();
m_panel.on_detach();
m_tabs.on_detach();
}
void win::update()
{
m_panel.update();
m_tabs.update();
}
}

View File

@@ -0,0 +1,13 @@
#include "monitor/gui/win/win.hpp"
namespace monitor
{
void win::on_event(VE::event& e)
{
if (e.m_type.type() == typeid(VE::event_type))
{
auto t = std::any_cast<VE::event_type>(e.m_type);
if (t == VE::event_type::WINDOW_RESIZE) update();
}
}
}

View File

@@ -0,0 +1,14 @@
#include "monitor/gui/win/win.hpp"
namespace monitor
{
void win::render()
{
VE_PUSH_FONT(REGULAR, 16);
m_panel.render();
m_tabs.render();
VE_POP_FONT();
}
}

26
src/monitor/gui/win/win.hpp Executable file
View File

@@ -0,0 +1,26 @@
#pragma once
#include <VE.hpp>
#include "monitor/gui/components/panel/panel.hpp"
#include "monitor/gui/components/tabs/tabs.hpp"
namespace monitor
{
class win : public VE::layer, public VE::flags, public VE::connector
{
VE_OVERIDE();
VE_EVENT_OVERIDE();
private:
ImVec2 m_size = { 0.f, 0.f };
private:
components::panel m_panel;
components::tabs m_tabs;
private:
bool m_imgui_help_render = false;
bool m_plot_2d_help_render = false;
bool m_plot_3d_help_render = false;
};
}

View File

@@ -0,0 +1,70 @@
#include "audio.hpp"
#include <hack/logger/logger.hpp>
namespace monitor::libs
{
void audio::set_file(std::filesystem::path p)
{
if (!m_music.openFromFile(p)) hack::error()("dont open file:", p.string());
}
void audio::set_callback(std::function<void(sf::Time, float)> c)
{
m_callback = c;
}
void audio::set_step(std::size_t step)
{
m_step = sf::microseconds(m_music.getDuration().asMicroseconds() / step);
}
void audio::set_audio_pos(double s)
{
m_ct = sf::microseconds(s * m_step.asMicroseconds());
m_music.setPlayingOffset(m_ct);
}
void audio::toggle_play()
{
if (m_music.getStatus() == sf::Sound::Status::Playing) m_music.pause();
else play();
}
void audio::play()
{
m_music.play();
// ATTENTION: это нужно делать тут именно ПОСЛЕ начала воспроизведения
// а НЕ перед воспроизведением. т.к. установка времени перед проигрыванием не работает
// см. https://www.sfml-dev.org/documentation/2.6.1/classsf_1_1SoundStream.php#af416a5f84c8750d2acb9821d78bc8646
m_music.setPlayingOffset(m_ct);
emit();
}
void audio::emit()
{
while (is_playing())
{
m_ct = m_music.getPlayingOffset();
m_callback(sf::Time(), 1.0);
sf::sleep(m_step);
}
}
bool audio::is_playing()
{
return m_music.getStatus() == sf::Sound::Status::Playing;
}
void audio::stop()
{
m_music.stop();
m_ct = sf::Time::Zero;
}
void audio::pause()
{
m_music.pause();
}
}

View File

@@ -0,0 +1,37 @@
#pragma once
#include <filesystem>
#include <functional>
#include <SFML/Audio.hpp>
namespace monitor::libs
{
class audio
{
public:
audio() = default;
~audio() =default;
public:
void set_file(std::filesystem::path p);
void play();
void stop();
void pause();
void toggle_play();
bool is_playing();
void set_callback(std::function<void(sf::Time, float)> c);
void set_step(std::size_t step);
void set_audio_pos(double s);
private:
void emit();
private:
std::filesystem::path m_file;
sf::Music m_music;
sf::Time m_ct = sf::Time::Zero;
sf::Time m_step;
std::function<void(sf::Time, float)> m_callback;
};
}

View File

@@ -0,0 +1,68 @@
#pragma once
#include <hack/patterns/singleton.hpp>
#include <hack/exception/exception.hpp>
#include <hack/logger/logger.hpp>
#include "pool_connection.hpp"
#ifndef PGXX
#define PGXX() libs::pgxx::instance()
#endif
namespace monitor::libs
{
class pgxx : public hack::patterns::singleton<pgxx>
{
friend hack::patterns::singleton<pgxx>;
public:
~pgxx() = default;
private:
pgxx() = default;
std::map<std::string, pool_connection> m_data_connections;
public:
bool ready() { return m_data_connections.size() != 0; }
void init(std::string connection_name, int connection_count, std::string connection_url)
{
m_data_connections[connection_name] = pool_connection { connection_count, connection_url };
hack::log("")("make connection [", connection_name, "] completed");
}
template<typename... Args>
pqxx::result execute_query(const std::string connection_name, std::string query)
{
pqxx::result r;
try
{
auto c = m_data_connections[connection_name].get();
pqxx::work work { *c };
r = work.exec(query);
work.commit();
m_data_connections[connection_name].release(c);
}
catch (const std::exception& e)
{
hack::exception ex;
ex.description("database dont execute query");
ex.system_error(e);
throw ex;
}
catch (...)
{
hack::exception ex;
ex.title("execute error");
ex.description("is alien system error it can be very dangerous!!! good luck my friend!");
throw ex;
}
return r;
}
};
}

View File

@@ -0,0 +1,46 @@
#pragma once
#include "pgxx.hpp"
#include "monitor/utils/var.hpp"
#include "monitor/libs/rhub/rhub.hpp"
namespace monitor::libs::db
{
inline void init()
{
try { PGXX().init("dspv.db", 300, utils::var::URL_DB); }
catch(hack::exception& ex) { ex.log(); throw; }
}
inline std::size_t create_project(std::string name)
{
std::size_t id;
auto q = std::format("INSERT INTO t_project (m_name) VALUES('{}') RETURNING m_id", name);
auto r = PGXX().execute_query("dspv.db", q);
for (auto el : r) id = el["m_id"].as<std::size_t>();
return id;
}
inline std::size_t create_workspace(std::string file)
{
std::size_t id;
auto q = std::format("INSERT INTO t_workspace (m_file, m_project_id) VALUES('{}', {}) RETURNING m_id", file, RHUB().m_project_id);
auto r = PGXX().execute_query("dspv.db", q);
for (auto el : r) id = el["m_id"].as<std::size_t>();
return id;
}
inline std::size_t init_plugin(std::size_t workspace_id)
{
std::size_t id;
auto q = std::format("INSERT INTO t_plugin (m_workspace_id) VALUES({}) RETURNING m_id", workspace_id);
auto r = PGXX().execute_query("dspv.db", q);
for (auto el : r) id = el["m_id"].as<std::size_t>();
return id;
}
}

View File

@@ -0,0 +1,66 @@
#pragma once
#include <condition_variable>
#include <queue>
#include <mutex>
#include <pqxx/pqxx>
namespace monitor::libs
{
class pool_connection
{
using connection = std::unique_ptr<pqxx::connection>;
public:
pool_connection() = default;
pool_connection(int connection_count, std::string connection_url)
{
for (int i = 0; i < connection_count; ++i)
{
auto c = std::make_unique<pqxx::connection>(connection_url);
m_connections.push(std::move(c));
}
}
~pool_connection()
{
while (!m_connections.empty())
{
auto c = std::move(m_connections.front());
m_connections.pop();
c->close();
}
}
public:
pool_connection& operator=(pool_connection&& pc) noexcept
{
if (this != &pc)
m_connections = std::move(pc.m_connections);
return *this;
}
public:
connection get()
{
std::unique_lock l { m_connections_mutex };
m_connections_cond.wait(l, [this]() { return !m_connections.empty(); });
auto manager = std::move(m_connections.front());
m_connections.pop();
return manager;
}
void release(connection& manager)
{
std::scoped_lock lock(m_connections_mutex);
m_connections.push(std::move(manager));
m_connections_cond.notify_one();
}
private:
std::mutex m_connections_mutex;
std::condition_variable m_connections_cond;
std::queue<connection> m_connections;
};
}

View File

@@ -0,0 +1,17 @@
#pragma once
namespace monitor::utils
{
enum class event_type
{
CREATE_SNAPSHOT,
SET_AUDIO_POSITION,
AUDIO_PAUSE,
AUDIO_STOP,
INCREMENT_MARKER_AUDIO_POSITION,
SET_MARKER_AUDIO_POSITION,
SET_MARKER_MOUSE_POSITION
};
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include <harmonica.hpp>
#include "monitor/utils/var.hpp"
namespace monitor::utils::types
{
struct graph_data
{
// Это не массив как в dsp, а массив графиков
// в dsp там массив массивов где нa второй массив это данные
// а тут эти данные нужно обединить сразу в график линий и каждую линию сложить в этот массив
// обединение происходит в методе fill у spanshot
// т.е. в dsp как бы матрица, а тут она же но поднятая
std::vector<hr::fvec_t> m_render_data;
// ось X
hr::fvec_t m_ox;
// максимальное значение по оси Y
double m_max_element = 0.0;
std::string m_name = "default name";
var::PLUGIN_TYPE m_type;
};
}

View File

@@ -0,0 +1,16 @@
#pragma once
#include <hack/security/uuid.hpp>
#include "plugin_params.hpp"
namespace monitor::utils::types
{
struct leaner_system
{
std::string m_systaem_id = hack::security::generate_uuid();
std::string m_name;
std::string m_graph_type;
std::vector<utils::types::plugin_params> m_als;
utils::types::plugin_params m_base;
};
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include <hack/security/uuid.hpp>
namespace monitor::utils::types
{
struct plugin_params
{
std::string m_plugin_id = hack::security::generate_uuid();
std::string m_type;
std::string m_name;
std::size_t m_block_size;
bool m_available = true;
// вся эта штука нужна для отрисовки бордюрчика когда данный фильтр
// выбран мышкой. Будь-то отдельная кнопка или массив кнопок.
bool m_selected = false;
bool m_on = false;
void clear() { m_name.clear(); m_selected = false; m_on = false; }
bool empty() { return m_name.empty(); }
void set(std::string n) { m_name = n; m_selected = true; on(); }
void off() { m_selected = false; m_on = false; }
void on() { m_on = true; }
bool operator==(const plugin_params& sf) { return sf.m_name == m_name; }
bool operator!=(const plugin_params& sf) { return sf.m_name != m_name; }
};
}

View File

@@ -0,0 +1,31 @@
#pragma once
#include <vector>
#include "monitor/libs/real_time/real_time.hpp"
#include "monitor/utils/using.hpp"
#include "monitor/utils/types/plugin_params.hpp"
namespace monitor::utils::types
{
class plugin_result
{
public:
struct bit
{
utils::real_time m_timestamp;
MATRIX m_value;
};
public:
plugin_params m_plugin_params;
std::vector<bit> m_data;
public:
void set_bit(bit& b) { m_data.push_back(b); }
std::size_t get_data_size() { return m_data.size(); }
std::size_t get_first_element_matrix_size(std::size_t i = 0) { return m_data[0].m_value[i].size(); }
void reserve(std::size_t s) { m_data.reserve(s); }
};
}

28
src/monitor/utils/var.hpp Normal file
View File

@@ -0,0 +1,28 @@
#pragma once
#include <string>
#include <hack/logger/logger.hpp>
#include "noinc.hpp"
namespace monitor::utils::var
{
const std::size_t MAX_RENDER_SIZE = 1'200'000;
enum class STATUS
{
EMPTY,
READY,
PROCESS,
COMPLETED,
ACTIVE,
INACTIVE
};
enum class PLUGIN_TYPE
{
MAGNITUDE,
SEGMENTER,
ENERGY
};
}

19
src/run.hpp Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include "monitor/gui/win/win.hpp"
class app : public VE::application
{
public:
app(std::string app_name) : VE::application{ app_name } {};
~app() = default;
};
inline void run()
{
app e{ "monitor" };
e.push_layer(
new monitor::win{}
);
e.run();
}