mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:30:05 +00:00
Add imgui debug window, still need to use unique contexts
This commit is contained in:
parent
b18692657a
commit
cd01bb70b6
10 changed files with 325 additions and 3 deletions
|
|
@ -119,6 +119,8 @@ set(SRC_TYPES source/scwx/qt/types/radar_product_record.cpp
|
|||
set(HDR_UI source/scwx/qt/ui/alert_dialog.hpp
|
||||
source/scwx/qt/ui/alert_dock_widget.hpp
|
||||
source/scwx/qt/ui/flow_layout.hpp
|
||||
source/scwx/qt/ui/imgui_debug_dialog.hpp
|
||||
source/scwx/qt/ui/imgui_debug_widget.hpp
|
||||
source/scwx/qt/ui/level2_products_widget.hpp
|
||||
source/scwx/qt/ui/level2_settings_widget.hpp
|
||||
source/scwx/qt/ui/level3_products_widget.hpp
|
||||
|
|
@ -126,12 +128,15 @@ set(HDR_UI source/scwx/qt/ui/alert_dialog.hpp
|
|||
set(SRC_UI source/scwx/qt/ui/alert_dialog.cpp
|
||||
source/scwx/qt/ui/alert_dock_widget.cpp
|
||||
source/scwx/qt/ui/flow_layout.cpp
|
||||
source/scwx/qt/ui/imgui_debug_dialog.cpp
|
||||
source/scwx/qt/ui/imgui_debug_widget.cpp
|
||||
source/scwx/qt/ui/level2_products_widget.cpp
|
||||
source/scwx/qt/ui/level2_settings_widget.cpp
|
||||
source/scwx/qt/ui/level3_products_widget.cpp
|
||||
source/scwx/qt/ui/radar_site_dialog.cpp)
|
||||
set(UI_UI source/scwx/qt/ui/alert_dialog.ui
|
||||
source/scwx/qt/ui/alert_dock_widget.ui
|
||||
source/scwx/qt/ui/imgui_debug_dialog.ui
|
||||
source/scwx/qt/ui/radar_site_dialog.ui)
|
||||
set(HDR_UTIL source/scwx/qt/util/font.hpp
|
||||
source/scwx/qt/util/font_buffer.hpp
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <scwx/qt/model/radar_product_model.hpp>
|
||||
#include <scwx/qt/ui/alert_dock_widget.hpp>
|
||||
#include <scwx/qt/ui/flow_layout.hpp>
|
||||
#include <scwx/qt/ui/imgui_debug_dialog.hpp>
|
||||
#include <scwx/qt/ui/level2_products_widget.hpp>
|
||||
#include <scwx/qt/ui/level2_settings_widget.hpp>
|
||||
#include <scwx/qt/ui/level3_products_widget.hpp>
|
||||
|
|
@ -49,6 +50,7 @@ public:
|
|||
level2SettingsWidget_ {nullptr},
|
||||
level3ProductsWidget_ {nullptr},
|
||||
alertDockWidget_ {nullptr},
|
||||
imGuiDebugDialog_ {nullptr},
|
||||
radarSiteDialog_ {nullptr},
|
||||
radarProductModel_ {nullptr},
|
||||
textEventManager_ {manager::TextEventManager::Instance()},
|
||||
|
|
@ -109,8 +111,9 @@ public:
|
|||
|
||||
ui::Level3ProductsWidget* level3ProductsWidget_;
|
||||
|
||||
ui::AlertDockWidget* alertDockWidget_;
|
||||
ui::RadarSiteDialog* radarSiteDialog_;
|
||||
ui::AlertDockWidget* alertDockWidget_;
|
||||
ui::ImGuiDebugDialog* imGuiDebugDialog_;
|
||||
ui::RadarSiteDialog* radarSiteDialog_;
|
||||
|
||||
std::unique_ptr<model::RadarProductModel> radarProductModel_;
|
||||
std::shared_ptr<manager::TextEventManager> textEventManager_;
|
||||
|
|
@ -196,6 +199,9 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||
ui->settingsFrame->layout()->addWidget(p->level2SettingsWidget_);
|
||||
p->level2SettingsWidget_->setVisible(false);
|
||||
|
||||
// ImGui Debug Dialog
|
||||
p->imGuiDebugDialog_ = new ui::ImGuiDebugDialog(this);
|
||||
|
||||
auto mapSettings = manager::SettingsManager::map_settings();
|
||||
for (size_t i = 0; i < p->maps_.size(); i++)
|
||||
{
|
||||
|
|
@ -323,6 +329,11 @@ void MainWindow::on_actionExit_triggered()
|
|||
close();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionImGuiDebug_triggered()
|
||||
{
|
||||
p->imGuiDebugDialog_->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_radarSiteSelectButton_clicked()
|
||||
{
|
||||
p->radarSiteDialog_->show();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ private slots:
|
|||
void on_actionOpenNexrad_triggered();
|
||||
void on_actionOpenTextEvent_triggered();
|
||||
void on_actionExit_triggered();
|
||||
void on_actionImGuiDebug_triggered();
|
||||
void on_radarSiteSelectButton_clicked();
|
||||
void on_resourceTreeCollapseAllButton_clicked();
|
||||
void on_resourceTreeExpandAllButton_clicked();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1024</width>
|
||||
<height>22</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
@ -67,8 +67,15 @@
|
|||
<addaction name="actionResourceExplorer"/>
|
||||
<addaction name="actionAlerts"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuDebug">
|
||||
<property name="title">
|
||||
<string>&Debug</string>
|
||||
</property>
|
||||
<addaction name="actionImGuiDebug"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuView"/>
|
||||
<addaction name="menuDebug"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
|
|
@ -342,6 +349,11 @@
|
|||
<string>&Alerts</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImGuiDebug">
|
||||
<property name="text">
|
||||
<string>&ImGui Debug</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../../scwx-qt.qrc"/>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <scwx/util/logger.hpp>
|
||||
|
||||
#include <backends/imgui_impl_opengl3.h>
|
||||
#include <backends/imgui_impl_qt.hpp>
|
||||
#include <imgui.h>
|
||||
#include <QOffscreenSurface>
|
||||
#include <QOpenGLContext>
|
||||
|
|
@ -53,8 +54,20 @@ static void InitializeImGui()
|
|||
|
||||
// Initialize ImGui
|
||||
ImGui::CreateContext();
|
||||
ImGui_ImplQt_Init();
|
||||
ImGui_ImplOpenGL3_Init();
|
||||
QOpenGLContext::globalShareContext()->doneCurrent();
|
||||
|
||||
// ImGui Configuration
|
||||
auto& io = ImGui::GetIO();
|
||||
|
||||
// Disable automatic configuration loading/saving
|
||||
io.IniFilename = nullptr;
|
||||
|
||||
// Style
|
||||
auto& style = ImGui::GetStyle();
|
||||
|
||||
style.WindowMinSize = {10.0f, 10.0f};
|
||||
}
|
||||
|
||||
static void LoadFonts()
|
||||
|
|
@ -77,6 +90,7 @@ static void ShutdownImGui()
|
|||
{
|
||||
QOpenGLContext::globalShareContext()->makeCurrent(surface_.get());
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplQt_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
QOpenGLContext::globalShareContext()->doneCurrent();
|
||||
}
|
||||
|
|
|
|||
45
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.cpp
Normal file
45
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include "imgui_debug_dialog.hpp"
|
||||
#include "ui_imgui_debug_dialog.h"
|
||||
|
||||
#include <scwx/qt/ui/imgui_debug_widget.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::ui::imgui_debug_dialog";
|
||||
|
||||
class ImGuiDebugDialogImpl
|
||||
{
|
||||
public:
|
||||
explicit ImGuiDebugDialogImpl() : imGuiDebugWidget_ {nullptr} {}
|
||||
~ImGuiDebugDialogImpl() = default;
|
||||
|
||||
ImGuiDebugWidget* imGuiDebugWidget_;
|
||||
};
|
||||
|
||||
ImGuiDebugDialog::ImGuiDebugDialog(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
p {std::make_unique<ImGuiDebugDialogImpl>()},
|
||||
ui(new Ui::ImGuiDebugDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// ImGui Debug Widget
|
||||
p->imGuiDebugWidget_ = new ImGuiDebugWidget(this);
|
||||
p->imGuiDebugWidget_->setSizePolicy(QSizePolicy::Policy::Expanding,
|
||||
QSizePolicy::Policy::Expanding);
|
||||
ui->verticalLayout->insertWidget(0, p->imGuiDebugWidget_);
|
||||
}
|
||||
|
||||
ImGuiDebugDialog::~ImGuiDebugDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
36
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.hpp
Normal file
36
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.hpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ImGuiDebugDialog;
|
||||
}
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
class ImGuiDebugDialogImpl;
|
||||
|
||||
class ImGuiDebugDialog : public QDialog
|
||||
{
|
||||
private:
|
||||
Q_DISABLE_COPY(ImGuiDebugDialog)
|
||||
|
||||
public:
|
||||
explicit ImGuiDebugDialog(QWidget* parent = nullptr);
|
||||
~ImGuiDebugDialog();
|
||||
|
||||
private:
|
||||
friend class ImGuiDebugDialogImpl;
|
||||
std::unique_ptr<ImGuiDebugDialogImpl> p;
|
||||
Ui::ImGuiDebugDialog* ui;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
104
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.ui
Normal file
104
scwx-qt/source/scwx/qt/ui/imgui_debug_dialog.ui
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ImGuiDebugDialog</class>
|
||||
<widget class="QDialog" name="ImGuiDebugDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>570</width>
|
||||
<height>760</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>ImGui Debug</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="bottomFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="contextLabel">
|
||||
<property name="text">
|
||||
<string>Context</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="contextComboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ImGuiDebugDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ImGuiDebugDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
56
scwx-qt/source/scwx/qt/ui/imgui_debug_widget.cpp
Normal file
56
scwx-qt/source/scwx/qt/ui/imgui_debug_widget.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include <scwx/qt/ui/imgui_debug_widget.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <backends/imgui_impl_opengl3.h>
|
||||
#include <backends/imgui_impl_qt.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::ui::imgui_debug_widget";
|
||||
|
||||
class ImGuiDebugWidgetImpl
|
||||
{
|
||||
public:
|
||||
explicit ImGuiDebugWidgetImpl(ImGuiDebugWidget* self) : self_ {self}
|
||||
{
|
||||
// ImGui Configuration
|
||||
auto& io = ImGui::GetIO();
|
||||
|
||||
// Initialize Qt backend
|
||||
ImGui_ImplQt_RegisterWidget(self_);
|
||||
}
|
||||
~ImGuiDebugWidgetImpl() {}
|
||||
|
||||
ImGuiDebugWidget* self_;
|
||||
};
|
||||
|
||||
ImGuiDebugWidget::ImGuiDebugWidget(QWidget* parent) :
|
||||
QOpenGLWidget(parent), p {std::make_unique<ImGuiDebugWidgetImpl>(this)}
|
||||
{
|
||||
}
|
||||
|
||||
void ImGuiDebugWidget::initializeGL() {}
|
||||
|
||||
void ImGuiDebugWidget::paintGL()
|
||||
{
|
||||
ImGui_ImplQt_NewFrame(this);
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
|
||||
ImGui::NewFrame();
|
||||
|
||||
ImGui::ShowDemoWindow();
|
||||
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
ImGuiDebugWidget::~ImGuiDebugWidget() {}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
38
scwx-qt/source/scwx/qt/ui/imgui_debug_widget.hpp
Normal file
38
scwx-qt/source/scwx/qt/ui/imgui_debug_widget.hpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ImGuiDebugWidget;
|
||||
}
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
class ImGuiDebugWidgetImpl;
|
||||
|
||||
class ImGuiDebugWidget : public QOpenGLWidget
|
||||
{
|
||||
private:
|
||||
Q_DISABLE_COPY(ImGuiDebugWidget)
|
||||
|
||||
public:
|
||||
explicit ImGuiDebugWidget(QWidget* parent = nullptr);
|
||||
~ImGuiDebugWidget();
|
||||
|
||||
void initializeGL() override;
|
||||
void paintGL() override;
|
||||
|
||||
private:
|
||||
friend class ImGuiDebugWidgetImpl;
|
||||
std::unique_ptr<ImGuiDebugWidgetImpl> p;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
Loading…
Add table
Add a link
Reference in a new issue