we started scaling up
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
inc += include_directories('.')
|
||||
|
||||
headers = [
|
||||
############ GUI/COMPONENTS
|
||||
'monitor/gui/components/audio/audio.hpp',
|
||||
'monitor/gui/components/file_dialog/file_dialog.hpp',
|
||||
'monitor/gui/components/markers/markers.hpp',
|
||||
'monitor/gui/components/spinner/spinner.hpp',
|
||||
|
||||
'monitor/gui/win/win.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',
|
||||
'monitor/gui/components/file_dialog/file_dialog.hpp',
|
||||
|
||||
############ GUI/WIN
|
||||
'monitor/gui/win/win.hpp',
|
||||
'monitor/gui/components/tabs/tabs.hpp',
|
||||
'monitor/gui/components/snapshot/snapshot.hpp',
|
||||
'monitor/gui/components/base_plugins/base_plugins.hpp',
|
||||
'monitor/gui/components/base_controls/base_controls.hpp',
|
||||
'monitor/gui/components/graph/graph.hpp',
|
||||
|
||||
############ UTILS
|
||||
'monitor/utils/var.hpp',
|
||||
@@ -27,38 +28,64 @@ headers = [
|
||||
|
||||
sources = [
|
||||
############ GUI/COMPONENTS
|
||||
'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/file_dialog/file_dialog.cpp',
|
||||
'monitor/gui/components/markers/cpp/base.cpp',
|
||||
'monitor/gui/components/markers/cpp/on_event.cpp',
|
||||
'monitor/gui/components/markers/cpp/render.cpp',
|
||||
|
||||
# win
|
||||
'monitor/gui/win/cpp/base.cpp',
|
||||
'monitor/gui/win/cpp/on_event.cpp',
|
||||
'monitor/gui/win/cpp/render.cpp',
|
||||
|
||||
# win/panel
|
||||
'monitor/gui/components/panel/cpp/base.cpp',
|
||||
'monitor/gui/components/panel/cpp/on_event.cpp',
|
||||
'monitor/gui/components/panel/cpp/render.cpp',
|
||||
|
||||
# win/panel/creator
|
||||
'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/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/creator/cpp/render/setup.cpp',
|
||||
|
||||
# win/panel/helpers
|
||||
'monitor/gui/components/helpers/cpp/base.cpp',
|
||||
'monitor/gui/components/helpers/cpp/on_event.cpp',
|
||||
'monitor/gui/components/helpers/cpp/render.cpp',
|
||||
'monitor/gui/components/file_dialog/file_dialog.cpp',
|
||||
|
||||
# win/tabs
|
||||
'monitor/gui/components/tabs/cpp/base.cpp',
|
||||
'monitor/gui/components/tabs/cpp/on_event.cpp',
|
||||
'monitor/gui/components/tabs/cpp/render.cpp',
|
||||
|
||||
# win/tabs/snapshot
|
||||
'monitor/gui/components/snapshot/cpp/base.cpp',
|
||||
'monitor/gui/components/snapshot/cpp/on_event.cpp',
|
||||
'monitor/gui/components/snapshot/cpp/render.cpp',
|
||||
|
||||
# win/tabs/snapshot/base_plugins
|
||||
'monitor/gui/components/base_plugins/cpp/base.cpp',
|
||||
'monitor/gui/components/base_plugins/cpp/on_event.cpp',
|
||||
'monitor/gui/components/base_plugins/cpp/render.cpp',
|
||||
|
||||
# win/tabs/snapshot/base_plugins/graph
|
||||
'monitor/gui/components/graph/cpp/base.cpp',
|
||||
'monitor/gui/components/graph/cpp/on_event.cpp',
|
||||
'monitor/gui/components/graph/cpp/render.cpp',
|
||||
|
||||
# win/tabs/snapshot/base_controls
|
||||
'monitor/gui/components/base_controls/cpp/base.cpp',
|
||||
'monitor/gui/components/base_controls/cpp/on_event.cpp',
|
||||
'monitor/gui/components/base_controls/cpp/render.cpp',
|
||||
|
||||
############ UTILS
|
||||
'monitor/libs/audio/audio.cpp',
|
||||
'monitor/libs/gtkfd/gtkfd.cpp',
|
||||
|
||||
############ GUI/WIN
|
||||
'monitor/gui/win/cpp/base.cpp',
|
||||
'monitor/gui/win/cpp/on_event.cpp',
|
||||
'monitor/gui/win/cpp/render.cpp'
|
||||
]
|
||||
|
||||
lib = library(
|
||||
|
||||
@@ -47,8 +47,7 @@ namespace monitor::components
|
||||
for (std::size_t i = 0; i < m_domains.size(); ++i)
|
||||
{
|
||||
const bool is_selected = (domain_id == i);
|
||||
if (ImGui::Selectable(m_domains[i].c_str(), is_selected))
|
||||
domain_id = i;
|
||||
if (ImGui::Selectable(m_domains[i].c_str(), is_selected)) domain_id = i;
|
||||
if (is_selected) ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
|
||||
18
src/monitor/gui/components/base_controls/base_controls.hpp
Normal file
18
src/monitor/gui/components/base_controls/base_controls.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <VE.hpp>
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
class base_controls : public VE::layer, public VE::connector
|
||||
{
|
||||
VE_OVERIDE();
|
||||
VE_EVENT_OVERIDE();
|
||||
|
||||
private:
|
||||
ImVec2 m_size = { 0.f, 0.f };
|
||||
ImVec2 m_past_win_pos;
|
||||
ImVec2 m_past_win_size;
|
||||
};
|
||||
}
|
||||
|
||||
22
src/monitor/gui/components/base_controls/cpp/base.cpp
Normal file
22
src/monitor/gui/components/base_controls/cpp/base.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "monitor/gui/components/base_controls/base_controls.hpp"
|
||||
#include "monitor/utils/var.hpp"
|
||||
|
||||
using namespace monitor::utils;
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
void base_controls::on_attach()
|
||||
{
|
||||
CONNECT(this);
|
||||
m_size.x = VE::application::get()->get_glfw()->width() / 4.f - var::WIN_PADDING * 3.f;
|
||||
m_size.y = 300.f;
|
||||
m_past_win_size.x = VE::application::get()->get_glfw()->width() - VE::application::get()->get_glfw()->width() / 4.f;
|
||||
}
|
||||
|
||||
void base_controls::on_detach()
|
||||
{
|
||||
DISCONNECT();
|
||||
}
|
||||
|
||||
void base_controls::update() { }
|
||||
}
|
||||
23
src/monitor/gui/components/base_controls/cpp/on_event.cpp
Normal file
23
src/monitor/gui/components/base_controls/cpp/on_event.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "monitor/gui/components/base_controls/base_controls.hpp"
|
||||
#include "monitor/utils/event_type.hpp"
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
void base_controls::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_COMPLETED:
|
||||
// {
|
||||
// clear();
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
src/monitor/gui/components/base_controls/cpp/render.cpp
Normal file
19
src/monitor/gui/components/base_controls/cpp/render.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "monitor/gui/components/base_controls/base_controls.hpp"
|
||||
#include "monitor/utils/func.hpp"
|
||||
#include "monitor/utils/var.hpp"
|
||||
|
||||
using namespace monitor::utils;
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
void base_controls::render()
|
||||
{
|
||||
ImGui::SetNextWindowPos({ m_past_win_size.x + var::WIN_PADDING * 2.f, 70.f });
|
||||
ImGui::SetNextWindowSize(m_size);
|
||||
if (!ImGui::BeginChild("scale")) ImGui::EndChild();
|
||||
|
||||
func::draw_border(m_size);
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
}
|
||||
34
src/monitor/gui/components/base_plugins/base_plugins.hpp
Normal file
34
src/monitor/gui/components/base_plugins/base_plugins.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <VE.hpp>
|
||||
#include "monitor/gui/components/graph/graph.hpp"
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
// сектор отрисовывающий базовые плагины, по табам
|
||||
class base_plugins : public VE::layer, public VE::connector
|
||||
{
|
||||
VE_OVERIDE();
|
||||
VE_EVENT_OVERIDE();
|
||||
|
||||
private:
|
||||
ImVec2 m_size = { 0.f, 0.f };
|
||||
ImVec2 m_pos = { 4.f, 70.f };
|
||||
ImGuiTabBarFlags m_tab_bar_flags { ImGuiTabBarFlags_None };
|
||||
std::size_t m_current_open_index = 0;
|
||||
graph m_graph;
|
||||
std::string m_snapshot_id;
|
||||
|
||||
private:
|
||||
hr::setup m_setup;
|
||||
std::vector<std::shared_ptr<utils::plugin>> m_base_plugins = {
|
||||
std::make_shared<utils::plugin>(utils::plugin{ .m_type = utils::plugin::TYPE::RAW_DATA, .m_display_name = "Raw Data"}),
|
||||
std::make_shared<utils::plugin>(utils::plugin{ .m_type = utils::plugin::TYPE::MAGNITUDE, .m_display_name = "Magnitude"}),
|
||||
std::make_shared<utils::plugin>(utils::plugin{ .m_type = utils::plugin::TYPE::ENERGY, .m_display_name = "Energy"}),
|
||||
};
|
||||
|
||||
public:
|
||||
void init(std::string snapshot_id, hr::setup setup);
|
||||
};
|
||||
}
|
||||
|
||||
33
src/monitor/gui/components/base_plugins/cpp/base.cpp
Normal file
33
src/monitor/gui/components/base_plugins/cpp/base.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "monitor/gui/components/base_plugins/base_plugins.hpp"
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
void base_plugins::on_attach()
|
||||
{
|
||||
CONNECT(this);
|
||||
|
||||
m_graph.on_attach();
|
||||
m_size.x = VE::application::get()->get_glfw()->width() - VE::application::get()->get_glfw()->width() / 4.f;
|
||||
m_size.y = VE::application::get()->get_glfw()->height() / 2.f;
|
||||
}
|
||||
|
||||
void base_plugins::on_detach()
|
||||
{
|
||||
DISCONNECT();
|
||||
m_graph.on_detach();
|
||||
}
|
||||
|
||||
void base_plugins::update()
|
||||
{
|
||||
m_graph.update();
|
||||
}
|
||||
|
||||
void base_plugins::init(std::string snapshot_id, hr::setup setup)
|
||||
{
|
||||
m_snapshot_id = snapshot_id;
|
||||
m_setup = setup;
|
||||
m_graph.init(m_snapshot_id, m_setup);
|
||||
m_graph.set_plugin(m_base_plugins[0]);
|
||||
m_graph.fill();
|
||||
}
|
||||
}
|
||||
23
src/monitor/gui/components/base_plugins/cpp/on_event.cpp
Normal file
23
src/monitor/gui/components/base_plugins/cpp/on_event.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "monitor/gui/components/base_plugins/base_plugins.hpp"
|
||||
#include "monitor/utils/event_type.hpp"
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
void base_plugins::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_COMPLETED:
|
||||
// {
|
||||
// clear();
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
src/monitor/gui/components/base_plugins/cpp/render.cpp
Normal file
40
src/monitor/gui/components/base_plugins/cpp/render.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "monitor/gui/components/base_plugins/base_plugins.hpp"
|
||||
#include "monitor/utils/func.hpp"
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
void base_plugins::render()
|
||||
{
|
||||
ImGui::SetNextWindowPos(m_pos);
|
||||
ImGui::SetNextWindowSize(m_size);
|
||||
if (!ImGui::BeginChild(VE_NO_NAME("line" + m_snapshot_id))) ImGui::EndChild();
|
||||
|
||||
if (ImGui::BeginTabBar(VE_NO_NAME("tabs_line" + m_snapshot_id), m_tab_bar_flags))
|
||||
{
|
||||
for (std::size_t i = 0; i < m_base_plugins.size(); ++i)
|
||||
{
|
||||
ImGuiTabItemFlags flags = ImGuiTabItemFlags_NoCloseButton;
|
||||
// if (m_current_open_index == i) flags |= ImGuiTabItemFlags_SetSelected; // Добавляем флаг выделения если нужно
|
||||
bool open = true;
|
||||
if (ImGui::BeginTabItem(("[ " + std::to_string(i + 1) + " ] " + utils::func::string_cut(m_base_plugins[i]->m_display_name, 30)).c_str(), &open, flags))
|
||||
{
|
||||
m_graph.render();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::IsItemClicked())
|
||||
{
|
||||
m_current_open_index = i;
|
||||
m_graph.set_plugin(m_base_plugins[i]);
|
||||
m_graph.fill();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
|
||||
utils::func::draw_border(m_size);
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,16 @@ namespace monitor::components
|
||||
clear();
|
||||
break;
|
||||
}
|
||||
case utils::event_type::STATUS_PROCESS:
|
||||
{
|
||||
m_status = utils::var::STATUS::PROCESS;
|
||||
break;
|
||||
}
|
||||
case utils::event_type::STATUS_COMPLETED:
|
||||
{
|
||||
m_status = utils::var::STATUS::COMPLETED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,23 +5,28 @@ namespace monitor::components
|
||||
{
|
||||
void creator::render()
|
||||
{
|
||||
auto ctx = ImGui::GetCurrentContext();
|
||||
render_spinner();
|
||||
|
||||
float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
|
||||
ImGui::SameLine(0.0f, 30.f);
|
||||
|
||||
ImGui::BeginDisabled(m_status == utils::var::STATUS::PROCESS);
|
||||
ImGui::BeginDisabled(m_status == utils::var::STATUS::COMPLETED);
|
||||
if (ImGui::Button("open", ImVec2{ 94.f, 27.f }))
|
||||
if (ImGui::Button("open file", ImVec2{ 94.f, 27.f }))
|
||||
{
|
||||
m_file_path = m_fd.open();
|
||||
if (!m_file_path.empty()) m_status = utils::var::STATUS::READY;
|
||||
else m_status = utils::var::STATUS::EMPTY;
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (!m_file_path.empty())
|
||||
{
|
||||
render_setup();
|
||||
float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
|
||||
ImGui::SameLine(0.f, 3.f * spacing);
|
||||
|
||||
ImGui::Text(m_file_path.filename().c_str());
|
||||
ImGui::SameLine();
|
||||
|
||||
@@ -32,8 +37,6 @@ namespace monitor::components
|
||||
ImGui::EndDisabled();
|
||||
ImGui::EndDisabled();
|
||||
ImGui::EndDisabled();
|
||||
|
||||
render_spinner();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
75
src/monitor/gui/components/creator/cpp/render/setup.cpp
Normal file
75
src/monitor/gui/components/creator/cpp/render/setup.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#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(spacing);
|
||||
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(0.f, spacing);
|
||||
|
||||
ImGui::SetCursorPosY(spacing);
|
||||
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, 3.f * spacing);
|
||||
|
||||
// step size
|
||||
ImGui::Text("step size:");
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
|
||||
ImGui::SetCursorPosY(spacing);
|
||||
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(0.f, spacing);
|
||||
|
||||
ImGui::SetCursorPosY(spacing);
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,11 @@ extern ImRect g_ComboSize;
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
void creator::render_spinner()
|
||||
void creator::render_spinner(ImVec2 pos)
|
||||
{
|
||||
ImVec2 buttonPos = ImGui::GetItemRectMin(); // левый верхний угол кнопки
|
||||
ImVec2 buttonSize = ImGui::GetItemRectSize(); // размер кнопки
|
||||
float spacing = 10.f;
|
||||
ImVec2 pos = ImVec2(buttonPos.x + buttonSize.x + spacing, buttonPos.y);
|
||||
// float spacing = 10.f;
|
||||
// float size = 30.f;
|
||||
// ImVec2 pos = ImVec2(pos.x + size + spacing, pos.y);
|
||||
|
||||
if (m_status == utils::var::STATUS::COMPLETED) m_spinner.render(pos);
|
||||
else if (m_status == utils::var::STATUS::READY) m_spinner.render(pos, "#B4CF16");
|
||||
|
||||
@@ -23,7 +23,8 @@ namespace monitor::components
|
||||
std::filesystem::path m_file_path;
|
||||
|
||||
private:
|
||||
void render_spinner();
|
||||
void render_setup();
|
||||
void render_spinner(ImVec2 pos = { 10.f, 8.f });
|
||||
void create();
|
||||
void clear();
|
||||
};
|
||||
|
||||
103
src/monitor/gui/components/graph/cpp/base.cpp
Executable file
103
src/monitor/gui/components/graph/cpp/base.cpp
Executable file
@@ -0,0 +1,103 @@
|
||||
#include "monitor/gui/components/graph/graph.hpp"
|
||||
#include "monitor/utils/var.hpp"
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
void graph::on_attach()
|
||||
{
|
||||
CONNECT(this);
|
||||
}
|
||||
|
||||
void graph::on_detach()
|
||||
{
|
||||
DISCONNECT();
|
||||
}
|
||||
|
||||
void graph::update()
|
||||
{
|
||||
}
|
||||
|
||||
void graph::init(std::string snapshot_id, hr::setup setup)
|
||||
{
|
||||
m_snapshot_id = snapshot_id;
|
||||
m_setup = setup;
|
||||
}
|
||||
|
||||
void graph::set_plugin(std::shared_ptr<utils::plugin> plugin) noexcept
|
||||
{
|
||||
m_plugin = std::move(plugin);
|
||||
}
|
||||
|
||||
void graph::fill()
|
||||
{
|
||||
if (!m_plugin) hack::error()("The object is not installed");
|
||||
|
||||
if (m_plugin->empty())
|
||||
{
|
||||
switch (m_plugin->m_type)
|
||||
{
|
||||
case utils::plugin::TYPE::RAW_DATA:
|
||||
{
|
||||
m_plugin->m_result = hr::run<hr::plugins::raw_data>(m_setup);
|
||||
m_total_size = m_plugin->m_result.size();
|
||||
m_k = static_cast<float>(m_total_size) / utils::var::MAX_RENDER_SIZE;
|
||||
downsampling();
|
||||
break;
|
||||
}
|
||||
case utils::plugin::TYPE::MAGNITUDE:
|
||||
{
|
||||
m_setup.m_domain = hr::DOMAIN_PLUGIN::FREQUENSY;
|
||||
m_plugin->m_result = hr::run<hr::plugins::magnitude>(m_setup);
|
||||
downsampling();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void graph::downsampling()
|
||||
{
|
||||
if (m_total_size == 0)
|
||||
{
|
||||
hack::error()("Пусто в расчетах!");
|
||||
hack::warn()("Нет данных для отрисовки, возможно что-то не так с плагином...");
|
||||
return;
|
||||
}
|
||||
|
||||
m_plugin->base_fill();
|
||||
if (m_k > 1.f) m_plugin->fill(m_k);
|
||||
else m_plugin->fill();
|
||||
}
|
||||
|
||||
void graph::refresh()
|
||||
{
|
||||
auto k = m_plugin->m_result.size() / m_current_limits.Size().x;
|
||||
hack::log()(k, m_plugin->m_result.size(), m_k, m_current_limits.X.Min, m_current_limits.X.Max);
|
||||
if (k > 70.f && k < 80.f)
|
||||
{
|
||||
m_plugin->fill(m_k - 3);
|
||||
}
|
||||
if (k > 100.f && k < 110.f)
|
||||
{
|
||||
m_plugin->fill(m_k - 4);
|
||||
}
|
||||
if (k > 150.f && k < 160.f)
|
||||
{
|
||||
m_plugin->fill(m_k - 5);
|
||||
}
|
||||
if (k > 190.f && k < 200.f)
|
||||
{
|
||||
m_plugin->fill(m_k - 6);
|
||||
}
|
||||
if (k > 250.f && k < 300.f)
|
||||
{
|
||||
m_plugin->fill(m_k - 7);
|
||||
}
|
||||
if (k > 310.f && k < 1'000)
|
||||
{
|
||||
m_plugin->fill(0.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
8
src/monitor/gui/components/graph/cpp/on_event.cpp
Executable file
8
src/monitor/gui/components/graph/cpp/on_event.cpp
Executable file
@@ -0,0 +1,8 @@
|
||||
#include "monitor/gui/components/graph/graph.hpp"
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
void graph::on_event(VE::event& e)
|
||||
{
|
||||
}
|
||||
}
|
||||
44
src/monitor/gui/components/graph/cpp/render.cpp
Executable file
44
src/monitor/gui/components/graph/cpp/render.cpp
Executable file
@@ -0,0 +1,44 @@
|
||||
#include "monitor/gui/components/graph/graph.hpp"
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
void graph::render()
|
||||
{
|
||||
if (ImPlot::BeginPlot(VE_NO_NAME(m_plugin->m_display_name + m_snapshot_id), ImVec2(-1, 0), ImPlotFlags_NoMenus))
|
||||
{
|
||||
// по оси X
|
||||
ImPlot::SetupAxes(nullptr, nullptr, ImPlotAxisFlags_Opposite | // смена полюсов у надписей оси x. они вверху
|
||||
ImPlotAxisFlags_NoSideSwitch | // нельзя перетаскивать оси по сторонам
|
||||
(m_is_first_render ? ImPlotAxisFlags_AutoFit : ImPlotAxisFlags_None) | // авто подстройка размера по горизонтале
|
||||
ImPlotAxisFlags_NoHighlight, // не разобрался что это там подсвечивается, что-то с фоном оси
|
||||
// по оси Y
|
||||
ImPlotAxisFlags_AutoFit | // авто подстройка размера по вертикале
|
||||
ImPlotAxisFlags_NoSideSwitch |
|
||||
ImPlotAxisFlags_NoHighlight |
|
||||
ImPlotAxisFlags_NoTickLabels // текстовые надписи отображаться не будут
|
||||
);
|
||||
|
||||
ImPlot::SetupAxisLimits(ImAxis_X1, 0.f, m_plugin->m_graph.m_data.size());
|
||||
ImPlot::SetupAxisLimits(ImAxis_Y1, 0.f, m_plugin->m_graph.m_max_element + 2.f);
|
||||
ImPlot::SetupAxisLimitsConstraints(ImAxis_X1, 0, INFINITY);
|
||||
ImPlot::SetupLegend(ImPlotLocation_NorthEast);
|
||||
|
||||
for (std::size_t i = 0; i < m_plugin->m_graph.m_data.size(); ++i)
|
||||
{
|
||||
if (m_plugin->m_type == utils::plugin::TYPE::ENERGY)
|
||||
ImPlot::PlotStems(VE_NAME(std::to_string(i)), m_plugin->m_graph.m_ox.data(), m_plugin->m_graph.m_data[i].data(), m_plugin->m_graph.m_data[i].size());
|
||||
else
|
||||
ImPlot::PlotLine(VE_NAME(std::to_string(i)), m_plugin->m_graph.m_ox.data(), m_plugin->m_graph.m_data[i].data(), m_plugin->m_graph.m_data[i].size());
|
||||
}
|
||||
|
||||
if (m_k > 1.f)
|
||||
{
|
||||
m_current_limits = ImPlot::GetPlotLimits();
|
||||
refresh();
|
||||
}
|
||||
|
||||
m_is_first_render = false;
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
}
|
||||
41
src/monitor/gui/components/graph/graph.hpp
Executable file
41
src/monitor/gui/components/graph/graph.hpp
Executable file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <VE.hpp>
|
||||
#include <harmonica.hpp>
|
||||
#include "monitor/utils/plugin.hpp"
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
class graph : public VE::layer, public VE::flags, public VE::connector
|
||||
{
|
||||
VE_OVERIDE();
|
||||
VE_EVENT_OVERIDE();
|
||||
|
||||
private:
|
||||
ImVec2 m_size = { 0.f, 0.f };
|
||||
ImGuiTabBarFlags m_tab_bar_flags { ImGuiTabBarFlags_None };
|
||||
ImPlotRect m_current_limits;
|
||||
bool m_is_first_render = true;
|
||||
|
||||
public:
|
||||
void init(std::string snapshot_id, hr::setup setup);
|
||||
void set_plugin(std::shared_ptr<utils::plugin> plugin) noexcept;
|
||||
void fill();
|
||||
|
||||
private:
|
||||
void downsampling();
|
||||
void refresh();
|
||||
|
||||
private:
|
||||
std::shared_ptr<utils::plugin> m_plugin;
|
||||
hr::setup m_setup;
|
||||
std::string m_snapshot_id;
|
||||
|
||||
private:
|
||||
// Общая длинна всех данных
|
||||
std::size_t m_total_size;
|
||||
// коеффициент того, на сколько данные больше возможного рендеринга
|
||||
float m_k;
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "monitor/gui/components/panel/panel.hpp"
|
||||
#include <hack/math/math.hpp>
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
|
||||
@@ -1,30 +1,38 @@
|
||||
#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_base_plugins.on_attach();
|
||||
m_base_controls.on_attach();
|
||||
|
||||
|
||||
|
||||
|
||||
// HERE
|
||||
// то что ниже будем убирать
|
||||
m_audio.on_attach();
|
||||
m_markers.on_attach();
|
||||
|
||||
m_plugins.emplace_back(combo{ .m_id = 0, .m_name = "Magnitude", .m_type = utils::var::PLUGIN_TYPE::MAGNITUDE });
|
||||
m_plugins.emplace_back(combo{ .m_id = 1, .m_name = "Energy", .m_type = utils::var::PLUGIN_TYPE::ENERGY });
|
||||
// m_plugins.emplace_back(combo{ .m_id = 0, .m_name = "Magnitude", .m_type = utils::var::PLUGIN_TYPE::MAGNITUDE });
|
||||
// m_plugins.emplace_back(combo{ .m_id = 1, .m_name = "Energy", .m_type = utils::var::PLUGIN_TYPE::ENERGY });
|
||||
}
|
||||
|
||||
void snapshot::on_detach()
|
||||
{
|
||||
DISCONNECT();
|
||||
m_base_plugins.on_detach();
|
||||
|
||||
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_base_plugins.update();
|
||||
|
||||
m_audio.update();
|
||||
m_markers.update();
|
||||
}
|
||||
@@ -39,102 +47,61 @@ namespace monitor::components
|
||||
void snapshot::init(hr::setup setup)
|
||||
{
|
||||
m_setup = setup;
|
||||
m_base_plugins.init(m_snapshot_id, m_setup);
|
||||
|
||||
auto r = hr::run<hr::plugins::raw_data>(m_setup);
|
||||
if (fill_raw_data(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);
|
||||
}
|
||||
}
|
||||
|
||||
bool snapshot::fill_raw_data(hr::result& r)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
// Общая длинна всех данных
|
||||
auto total_size = r.m_data.size();
|
||||
hack::log()(total_size);
|
||||
|
||||
// if (total_size > utils::var::MAX_RENDER_SIZE)
|
||||
// HERE
|
||||
// auto r = hr::run<hr::plugins::raw_data>(m_setup);
|
||||
// if (fill_raw_data(r))
|
||||
// {
|
||||
// hack::warn()("Данный файл превышает максимально допустимый размер рендеринга");
|
||||
// hack::log()("Возможно пришло время чтобы написать тут код... см. dspv.v3");
|
||||
// hack::log()("но там есть tmp, которая может ту быть сомнительной...");
|
||||
// m_audio.init(m_setup.m_file);
|
||||
// m_audio.set_step(r.m_data.size());
|
||||
// m_markers.init();
|
||||
// set_status(utils::var::STATUS::ACTIVE);
|
||||
// }
|
||||
// else if (total_size == 0)
|
||||
if (total_size == 0)
|
||||
{
|
||||
hack::error()("Пусто в расчетах!");
|
||||
hack::warn()("Нет данных для отрисовки, возможно что-то не так с плагином...");
|
||||
return !ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
utils::types::graph_data data;
|
||||
data.m_render_data.push_back(hr::fvec_t());
|
||||
|
||||
// тут резирвируем именно длинну по оси X всех линий
|
||||
data.m_ox.reserve(total_size);
|
||||
|
||||
// заполняем данными все линии графиков
|
||||
for (auto el : r.m_data)
|
||||
{
|
||||
data.m_max_element = hack::math::max(el.m_value[0], data.m_max_element);
|
||||
data.m_render_data[0].push_back(el.m_value[0]);
|
||||
}
|
||||
for (std::size_t i = 0; i < total_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);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool snapshot::fill(hr::result& r)
|
||||
{
|
||||
bool is_ok = false;
|
||||
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 if (base_size == 0)
|
||||
{
|
||||
hack::error()("Пусто в расчетах!");
|
||||
hack::warn()("Нет данных для отрисовки, возможно что-то не так с плагином...");
|
||||
}
|
||||
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);
|
||||
is_ok = true;
|
||||
}
|
||||
// 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 if (base_size == 0)
|
||||
// {
|
||||
// hack::error()("Пусто в расчетах!");
|
||||
// hack::warn()("Нет данных для отрисовки, возможно что-то не так с плагином...");
|
||||
// }
|
||||
// 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);
|
||||
// is_ok = true;
|
||||
// }
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
@@ -142,24 +109,24 @@ namespace monitor::components
|
||||
{
|
||||
hr::result r;
|
||||
|
||||
switch (m_plugin.m_type)
|
||||
{
|
||||
case utils::var::PLUGIN_TYPE::MAGNITUDE:
|
||||
{
|
||||
// HERE
|
||||
// это нужно устанавливать в combo
|
||||
m_setup.m_domain = hr::DOMAIN_PLUGIN::FREQUENSY;
|
||||
r = hr::run<hr::plugins::magnitude>(m_setup);
|
||||
hack::log()("asdf");
|
||||
break;
|
||||
}
|
||||
|
||||
// case utils::var::PLUGIN_TYPE::ENERGY:
|
||||
// {
|
||||
// r = hr::run<hr::plugins::energy>(m_setup);
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
// switch (m_plugin.m_type)
|
||||
// {
|
||||
// case utils::var::PLUGIN_TYPE::MAGNITUDE:
|
||||
// {
|
||||
// // HERE
|
||||
// // это нужно устанавливать в combo
|
||||
// m_setup.m_domain = hr::DOMAIN_PLUGIN::FREQUENSY;
|
||||
// r = hr::run<hr::plugins::magnitude>(m_setup);
|
||||
// hack::log()("asdf");
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// // case utils::var::PLUGIN_TYPE::ENERGY:
|
||||
// // {
|
||||
// // r = hr::run<hr::plugins::energy>(m_setup);
|
||||
// // break;
|
||||
// // }
|
||||
// }
|
||||
|
||||
fill(r);
|
||||
m_plugin.clear();
|
||||
|
||||
@@ -4,92 +4,101 @@ namespace monitor::components
|
||||
{
|
||||
void snapshot::render()
|
||||
{
|
||||
m_audio.render();
|
||||
ImGui::PushID("line");
|
||||
m_base_plugins.render();
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
// HERE
|
||||
// выбор домена для плагина
|
||||
auto ctx = ImGui::GetCurrentContext();
|
||||
ImGui::SameLine(0.f, ctx->Style.FramePadding.x);
|
||||
ImGui::SetNextItemWidth(120.f);
|
||||
static std::size_t domain_id = 0;
|
||||
if (ImGui::BeginCombo(VE_NO_NAME("select_domain"), m_domains[domain_id].c_str()))
|
||||
{
|
||||
for (std::size_t i = 0; i < m_domains.size(); ++i)
|
||||
{
|
||||
const bool is_selected = (domain_id == i);
|
||||
if (ImGui::Selectable(m_domains[i].c_str(), is_selected))
|
||||
domain_id = i;
|
||||
if (is_selected) ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
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);
|
||||
ImGui::PushID("scale");
|
||||
m_base_controls.render();
|
||||
ImGui::PopID();
|
||||
|
||||
|
||||
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;
|
||||
// m_audio.render();
|
||||
//
|
||||
// ImGui::SameLine();
|
||||
//
|
||||
// // HERE
|
||||
// // выбор домена для плагина
|
||||
// auto ctx = ImGui::GetCurrentContext();
|
||||
// ImGui::SameLine(0.f, ctx->Style.FramePadding.x);
|
||||
// ImGui::SetNextItemWidth(120.f);
|
||||
// static std::size_t domain_id = 0;
|
||||
// if (ImGui::BeginCombo(VE_NO_NAME("select_domain"), m_domains[domain_id].c_str()))
|
||||
// {
|
||||
// for (std::size_t i = 0; i < m_domains.size(); ++i)
|
||||
// {
|
||||
// const bool is_selected = (domain_id == i);
|
||||
// if (ImGui::Selectable(m_domains[i].c_str(), is_selected))
|
||||
// domain_id = i;
|
||||
// if (is_selected) ImGui::SetItemDefaultFocus();
|
||||
// }
|
||||
// ImGui::EndCombo();
|
||||
// }
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
#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"
|
||||
#include "monitor/gui/components/base_plugins/base_plugins.hpp"
|
||||
#include "monitor/gui/components/base_controls/base_controls.hpp"
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
@@ -14,17 +15,21 @@ namespace monitor::components
|
||||
VE_OVERIDE();
|
||||
VE_EVENT_OVERIDE();
|
||||
|
||||
public:
|
||||
base_plugins m_base_plugins;
|
||||
base_controls m_base_controls;
|
||||
|
||||
public:
|
||||
std::string m_snapshot_id;
|
||||
utils::var::STATUS m_status;
|
||||
audio m_audio;
|
||||
hr::setup m_setup;
|
||||
audio m_audio;
|
||||
|
||||
private:
|
||||
ImVec2 m_size = { 0.f, 0.f };
|
||||
|
||||
private:
|
||||
std::vector<utils::types::graph_data> m_graphs;
|
||||
// std::vector<utils::types::graph_data> m_graphs;
|
||||
ImGuiTabBarFlags m_tab_bar_flags { ImGuiTabBarFlags_None };
|
||||
int m_rows = 7;
|
||||
int m_cols = 1;
|
||||
@@ -39,7 +44,7 @@ namespace monitor::components
|
||||
{
|
||||
int m_id = -1;
|
||||
std::string m_name;
|
||||
utils::var::PLUGIN_TYPE m_type;
|
||||
// utils::var::PLUGIN_TYPE m_type;
|
||||
void clear() { m_id = -1; m_name.clear(); }
|
||||
} m_plugin;
|
||||
|
||||
@@ -52,8 +57,6 @@ namespace monitor::components
|
||||
|
||||
private:
|
||||
bool fill(hr::result& r);
|
||||
bool fill_raw_data(hr::result& r);
|
||||
void add_plugin();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,18 +34,6 @@ namespace monitor::components
|
||||
EMIT(e);
|
||||
}
|
||||
|
||||
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 };
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include "monitor/gui/components/tabs/tabs.hpp"
|
||||
#include "monitor/utils/func.hpp"
|
||||
|
||||
using namespace monitor::utils;
|
||||
|
||||
namespace monitor::components
|
||||
{
|
||||
@@ -23,7 +26,7 @@ namespace monitor::components
|
||||
{
|
||||
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))
|
||||
if (ImGui::BeginTabItem(("[" + std::to_string(i) + "] " + func::string_cut(m_snapshots[i]->m_setup.m_file, 30)).c_str(), &open, flags))
|
||||
{
|
||||
m_snapshots[i]->render();
|
||||
ImGui::EndTabItem();
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace monitor::components
|
||||
|
||||
private:
|
||||
void create_snapshot(hr::setup setup);
|
||||
std::string string_cut(std::filesystem::path p, int n);
|
||||
void change_tab(std::size_t i);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,10 +17,5 @@ namespace monitor
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,7 +6,13 @@ namespace monitor::utils
|
||||
{
|
||||
CREATE_SNAPSHOT,
|
||||
CREATE_SNAPSHOT_COMPLETED,
|
||||
STATUS_PROCESS,
|
||||
STATUS_COMPLETED,
|
||||
|
||||
|
||||
|
||||
|
||||
/// делать
|
||||
SET_AUDIO_POSITION,
|
||||
AUDIO_PAUSE,
|
||||
AUDIO_STOP,
|
||||
|
||||
34
src/monitor/utils/func.hpp
Normal file
34
src/monitor/utils/func.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <VE.hpp>
|
||||
|
||||
namespace monitor::utils::func
|
||||
{
|
||||
// бордюрчики у окна рисует нужного цвета и толщины
|
||||
inline void draw_border(ImVec2 win_size)
|
||||
{
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
ImVec2 win_pos = ImGui::GetWindowPos();
|
||||
draw_list->AddRect(
|
||||
win_pos,
|
||||
ImVec2{ win_pos.x + win_size.x, win_pos.y + win_size.y },
|
||||
VE::func::colorU32("#606373"),
|
||||
0.f,
|
||||
0,
|
||||
1.f
|
||||
);
|
||||
}
|
||||
|
||||
// обрезает строку до нужного размера если борльше заявленного
|
||||
inline std::string 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;
|
||||
}
|
||||
}
|
||||
106
src/monitor/utils/plugin.hpp
Normal file
106
src/monitor/utils/plugin.hpp
Normal file
@@ -0,0 +1,106 @@
|
||||
#pragma once
|
||||
|
||||
#include <harmonica.hpp>
|
||||
#include "monitor/utils/var.hpp"
|
||||
|
||||
namespace monitor::utils
|
||||
{
|
||||
struct plugin
|
||||
{
|
||||
public:
|
||||
enum class TYPE
|
||||
{
|
||||
RAW_DATA,
|
||||
MAGNITUDE,
|
||||
ENERGY
|
||||
};
|
||||
|
||||
struct graph_data
|
||||
{
|
||||
public:
|
||||
// ось X
|
||||
hr::fvec_t m_ox;
|
||||
// максимальное значение по оси Y
|
||||
double m_max_element = 0.0;
|
||||
std::size_t m_line_count = 1;
|
||||
// отличие этих данных от тех что в плагине:
|
||||
// тут кол-во графиков на массив данных из этих графиков
|
||||
// т.е.
|
||||
// [1] = [1, 2, ..., 1'000'000]
|
||||
// [2] = [1, 2, ..., 1'000'000]
|
||||
// в плагине массив данных на кол-во графиков
|
||||
// [1] = [1, 2,...,7]
|
||||
// [...] = [1, 2,...,7]
|
||||
// [1'000'000] = [1, 2,...,7]
|
||||
// потому как на рендеринг подается кол-во данных для одного графика сразу
|
||||
std::vector<hr::fvec_t> m_data;
|
||||
|
||||
void fill_ox() noexcept
|
||||
{
|
||||
m_ox.reserve(var::MAX_RENDER_SIZE);
|
||||
for (std::size_t i = 0; i < var::MAX_RENDER_SIZE; ++i) m_ox.push_back(i);
|
||||
}
|
||||
|
||||
} m_graph;
|
||||
|
||||
public:
|
||||
hr::result m_result;
|
||||
TYPE m_type;
|
||||
const std::string m_display_name;
|
||||
|
||||
public:
|
||||
bool empty() { return m_result.empty(); }
|
||||
|
||||
void base_fill()
|
||||
{
|
||||
// смотрим сколько линий на графике
|
||||
if (empty()) m_graph.m_line_count = m_result.m_data[0].m_value.size();
|
||||
|
||||
// заполняем даннеы для всех линий графика
|
||||
for (std::size_t i = 0; i < m_graph.m_line_count; ++i)
|
||||
m_graph.m_data.push_back(hr::fvec_t(var::MAX_RENDER_SIZE, 0.f));
|
||||
m_graph.fill_ox();
|
||||
}
|
||||
|
||||
void fill()
|
||||
{
|
||||
// заполняется, когда данных пришло меньше чем нужно для полного рендеринга
|
||||
// т.е. идем от пришедших данных. ниже наоборот от var::MAX_RENDER_SIZE
|
||||
std::size_t index = 0;
|
||||
for (auto el : m_result.m_data)
|
||||
{
|
||||
std::size_t graph_count = 0;
|
||||
for (auto e : el.m_value)
|
||||
{
|
||||
m_graph.m_max_element = hack::math::max(e, m_graph.m_max_element);
|
||||
m_graph.m_data[graph_count++][index] = e;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
void fill(float k)
|
||||
{
|
||||
std::size_t step = k + 1;
|
||||
std::size_t index = step;
|
||||
std::size_t graph_count = 0;
|
||||
|
||||
for (auto& gd : m_graph.m_data)
|
||||
{
|
||||
for (auto& g : gd)
|
||||
{
|
||||
for (std::size_t j = index - step; j < index; ++j)
|
||||
{
|
||||
auto e = m_result.m_data[j].m_value[graph_count];
|
||||
g = hack::math::max_abs(e, g);
|
||||
}
|
||||
m_graph.m_max_element = hack::math::max(g, m_graph.m_max_element);
|
||||
index += step;
|
||||
if (index > m_result.m_data.size()) index = m_result.m_data.size();
|
||||
}
|
||||
++graph_count;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#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;
|
||||
};
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
#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; }
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#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); }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <hack/logger/logger.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace monitor::utils::var
|
||||
{
|
||||
const std::size_t MAX_RENDER_SIZE = 1'200'000;
|
||||
const std::size_t MAX_RENDER_SIZE = 1'000'000;
|
||||
const float WIN_PADDING = 4.f;
|
||||
|
||||
enum class STATUS
|
||||
{
|
||||
@@ -15,11 +16,4 @@ namespace monitor::utils::var
|
||||
ACTIVE,
|
||||
INACTIVE
|
||||
};
|
||||
|
||||
enum class PLUGIN_TYPE
|
||||
{
|
||||
MAGNITUDE,
|
||||
SEGMENTER,
|
||||
ENERGY
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user