GrpcPrint/PrintC/UI/UIWin.cpp

621 lines
25 KiB
C++
Raw Normal View History

2024-04-01 18:26:14 +08:00
#include "UIWin.h"
#include "../external/imgui/imgui.h"
#include "../external/imgui/imgui_impl_glfw.h"
#include "../external/imgui/imgui_impl_opengl3.h"
#include "../external/imgui/imgui_custom.h"
#include "../external/imgui/imgui_plot.h"
#include "../external/imgui/imguidatechooser.h"
#include "../external/imgui/imgui_context_extensions.h"
#include <time.h>
#include "../global.h"
#include "../utils/StringHelper.h"
#include "../utils/TimeHelper.h"
#include "../ChartletManager.h"
//#include "FileDialog.h"
#include <cstdlib>
#include <ctime>
//#include "ICON.h"
#include "../utils/sha1.hpp"
#include "../utils/MathHelper.h"
#include "../utils/LineFit.h"
//#include "../purifier/XTPurifier.h"
#include "../config/bean/SystemBase.h"
#include "../SystemInfo.h"
#include "../LanguageManager.h"
#include "../Logger.h"
#include "../Toast.h"
//#include "../PLC/Axis.h"
#include "../external/imgui/implot.h"
#include "../utils/CryptHelper.h"
#include "../utils/ImageHelper.h"
#include "../external/stb/stb_image.h"
UserType g_Admin;
UIWin::UIWin() {
}
UIWin::~UIWin() {
}
bool UIWin::Init()
{
//MetaData::InitTypeMap();
g_Admin = USER;
m_IsShowInitError = true;
//if (!m_UIController.Init())return false;
if (!glfwInit())return false;
const char* glsl_version = "#version 130";
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
_setmaxstdio(5000);
GetVersion();
m_GLFWMon = glfwGetPrimaryMonitor();
m_GLFWMode = glfwGetVideoMode(m_GLFWMon);
glfwWindowHint(GLFW_RED_BITS, m_GLFWMode->redBits);
glfwWindowHint(GLFW_GREEN_BITS, m_GLFWMode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS, m_GLFWMode->blueBits);
glfwWindowHint(GLFW_REFRESH_RATE, m_GLFWMode->refreshRate);
glfwWindowHint(GLFW_DECORATED, GL_FALSE);
#ifdef _DEBUG
m_IsFullScreen = false;
#else
m_IsFullScreen = true;
#endif
if (m_IsFullScreen) {
m_GLFWWin = glfwCreateWindow(m_GLFWMode->width, m_GLFWMode->height, "HBDSystem1000", NULL, NULL);
}
else {
int wwidth = m_GLFWMode->width * 4 / 5;
int wheight = m_GLFWMode->height * 4 / 5;
m_GLFWWin = glfwCreateWindow(m_GLFWMode->width, m_GLFWMode->height, "HBDSystem1000", NULL, NULL);
glfwSetWindowMonitor(m_GLFWWin, NULL, (m_GLFWMode->width - wwidth) / 2, (m_GLFWMode->height - wheight) / 2, wwidth, wheight, m_GLFWMode->refreshRate);
}
if (m_GLFWWin == NULL) return false;
//ChartletManager::GetInstance()->LoadLogoIcon();
//if (ChartletManager::GetInstance()->HasIcoLogo())
{
int width = 0, height = 0, comp = 0;
//if (m_UIController.m_MachineCfg->m_I18NLang == "zh_CN")
//{
// TextureBean* l16 = ChartletManager::GetInstance()->m_AppLogo16;
// TextureBean* l32 = ChartletManager::GetInstance()->m_AppLogo32;
// TextureBean* l48 = ChartletManager::GetInstance()->m_AppLogo48;
// icons[0].pixels = stbi_load_from_memory(l16->m_PData, l16->m_DataLen, &width, &height, &comp, 4);
// icons[1].pixels = stbi_load_from_memory(l32->m_PData, l32->m_DataLen, &width, &height, &comp, 4);
// icons[2].pixels = stbi_load_from_memory(l48->m_PData, l48->m_DataLen, &width, &height, &comp, 4);
//}
//else {
// TextureBean* l16 = ChartletManager::GetInstance()->m_AppLogo16En;
// TextureBean* l32 = ChartletManager::GetInstance()->m_AppLogo32En;
// TextureBean* l48 = ChartletManager::GetInstance()->m_AppLogo48En;
// icons[0].pixels = stbi_load_from_memory(l16->m_PData, l16->m_DataLen, &width, &height, &comp, 4);
// icons[1].pixels = stbi_load_from_memory(l32->m_PData, l32->m_DataLen, &width, &height, &comp, 4);
// icons[2].pixels = stbi_load_from_memory(l48->m_PData, l48->m_DataLen, &width, &height, &comp, 4);
//}
}
//glfwSetWindowIcon(m_GLFWWin, 3, icons);
glfwSetWindowUserPointer(m_GLFWWin, this);
//glfwSetMouseButtonCallback(m_GLFWWin, GLFWMouseButtonCallback);
//glfwSetCursorPosCallback(m_GLFWWin, GLFWMousePositionCallback);
//glfwSetScrollCallback(m_GLFWWin, GLFWMouseWheelCallback);
//glfwSetKeyCallback(m_GLFWWin, GLFWKeyCallback);
glfwMakeContextCurrent(m_GLFWWin);
glfwSwapInterval(1);
m_PrevRenderer = new VLRenderer;
m_Renderer = new VLRenderer;
m_PrevRenderer->Init();
m_Renderer->Init();
//if (m_UIController.m_MachineCfg->m_PlatformShape == PS_SQUARE) {
m_PrevRenderer->SetPlatformShape(PS_SQUARE);
//m_PrevRenderer->SetPlatfromSize(m_UIController.m_MachineCfg->m_PlatformLength, m_UIController.m_MachineCfg->m_PlatformWidth, 100);
m_Renderer->SetPlatformShape(PS_SQUARE);
//m_Renderer->SetPlatfromSize(m_UIController.m_MachineCfg->m_PlatformLength, m_UIController.m_MachineCfg->m_PlatformWidth, 100);
//}
//else {
// m_PrevRenderer->SetPlatformShape(PS_ROUND);
// m_PrevRenderer->SetPlatfromSize(m_UIController.m_MachineCfg->m_PlatformLength);
// m_Renderer->SetPlatformShape(PS_ROUND);
// m_Renderer->SetPlatfromSize(m_UIController.m_MachineCfg->m_PlatformLength);
//}
//m_UIController.m_Calibration->SetRender(m_Renderer, m_PrevRenderer);
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
io.ConfigWindowsMoveFromTitleBarOnly = true;
ImGui_ImplGlfw_InitForOpenGL(m_GLFWWin, true);
ImGui_ImplOpenGL3_Init(glsl_version);
ImGui::StyleColorsDark();
ImPlot::CreateContext();
ImPlot::StyleColorsClassic();
//MachineCfg* machineCfg = ConfigManager::GetInstance()->GetMachineCfg();
string fontpath = g_AppPath + "wqy-zenhei.ttf";
ImFontConfig config;
config.OversampleH = 1;
config.OversampleV = 1;
config.GlyphExtraSpacing.x = 1.0f;
ImVector<ImWchar> ranges;
ImFontGlyphRangesBuilder builder;
builder.AddText(u8"轴伺屏滞芯频浏廓拟μ渲曝℃━帧氩氮刹栅钮√邦");
builder.AddRanges(io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted)
io.Fonts->AddFontFromFileTTF(fontpath.c_str(),20 /*machineCfg->m_fontSize*/, &config, ranges.Data);
io.Fonts->Build();
io.Fonts->Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;
io.FontGlobalScale = 1.0f;/* machineCfg->m_fontScale;*/
//ChartletManager::GetInstance()->LoadCharlet();
m_Reg.Init();
m_RegResult = m_Reg.CheckReg(time(0));
//m_RegResult = Registration::REG_SUCCESS;
//保存启动时间
if (m_RegResult != Registration::REG_FAIL) {
//ConfigManager::GetInstance()->GetMachineCfg()->m_lastStartTime = TimeHelper::Str2Time(TimeHelper::GetStrNow());
//ConfigManager::GetInstance()->SaveMachineConfig();
}
//ImGui_ImplOpenGL2_NewFrame();
m_IdleTime = 0;
InitializeCriticalSection(&m_IdleTimeCS);
//m_UIController.m_Calibration->Init();
#ifdef _DEBUG
g_Admin = ADMIN;
m_RegResult = Registration::REG_SUCCESS;
#endif
if (g_isDebug)
{
g_Admin = ADMIN;
m_RegResult = Registration::REG_SUCCESS;
}
return true;
}
//void UIWin::DrawTitleBar()
//{
// ImGui::SetNextWindowSize(ImVec2((float)m_winWidth, (float)TITLE_HEIGHT));
// ImGui::SetNextWindowPos(ImVec2(0, 0)); // 窗口起始位置为左上角
// ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
// ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(5.0f, 5.0f));
// ImGui::Begin("TitleBar", NULL,
// ImGuiWindowFlags_NoMove |
// ImGuiWindowFlags_NoResize |
// ImGuiWindowFlags_NoCollapse |
// ImGuiWindowFlags_NoTitleBar |
// ImGuiWindowFlags_NoFocusOnAppearing |
// ImGuiWindowFlags_NoBringToFrontOnFocus |
// ImGuiWindowFlags_NoScrollWithMouse |
// ImGuiWindowFlags_NoScrollbar |
// ImGuiWindowFlags_NoDocking
// );
// ImGui::PopStyleVar(2);
// if (!m_IsFullScreen && ImGui::IsWindowFocused() && ImGui::IsMouseDragging(0)) {
// ImVec2 mosvec = ImGui::GetMouseDragDelta(0);
// int posx, posy, winWidth, winHeight;
// glfwGetWindowPos(m_GLFWWin, &posx, &posy);
// glfwGetWindowSize(m_GLFWWin, &winWidth, &winHeight);
// glfwSetWindowMonitor(m_GLFWWin, NULL, posx + (int)mosvec.x, posy + (int)mosvec.y, winWidth, winHeight, m_GLFWMode->refreshRate);
//
// }
//
// ImGuiStyle* style = &ImGui::GetStyle();
// TextureBean* logotitle = ChartletManager::GetInstance()->m_LogoTitle;
// TextureBean* logotitleEn = ChartletManager::GetInstance()->m_LogoTitleEn;
//
// //if (m_UIController.m_MachineCfg->m_I18NLang == "zh_CN")ImGui::Image(logotitle->GetTex(), ImVec2((float)logotitle->m_Width, (float)logotitle->m_Height));
// //else ImGui::Image(logotitleEn->GetTex(), ImVec2((float)logotitleEn->m_Width, (float)logotitleEn->m_Height));
// //ImGui::Text(u8"汉邦HBDSystemL金属3D打印控制系统");
//
// ImGui::SameLine(0, 50);
// if (m_UIController.m_MachineCfg->m_ExpriedTime != 0) {
// time_t tnow;
// time(&tnow);
// if ((m_UIController.m_MachineCfg->m_ExpriedTime - tnow) < (60 * 60 * 24 * 60)) {
//
// const ImVec2 p1 = ImGui::GetCursorScreenPos();
// char dataBuffer[50];
// sprintf_s(dataBuffer, sizeof(dataBuffer), "%s %s", _(u8"系统到期:").c_str(), TimeHelper::Time2Str(m_UIController.m_MachineCfg->m_ExpriedTime).c_str());
// ImGui::GetWindowDrawList()->AddText(ImVec2(p1.x, p1.y + 5), ImColor(Toast::COLOR_ORANGE), dataBuffer);
// //ImGui::TextColored(Toast::COLOR_ORANGE, _(u8"系统到期:%s").c_str(), TimeHelper::Time2Str(m_UIController.m_MachineCfg->m_ExpriedTime).c_str());
// }
// }
// if (g_Admin != USER) {
// ImGui::SameLine(ImGui::GetWindowWidth() - 405);
// const ImVec2 p1 = ImGui::GetCursorScreenPos();
// char dataBuffer[50];
// sprintf_s(dataBuffer, sizeof(dataBuffer), "%s %s", TimeHelper::GetStrNow().c_str(), m_ProductVersion.c_str());
//
// ImGui::GetWindowDrawList()->AddText(ImVec2(p1.x, p1.y + 5), IM_COL32_WHITE, dataBuffer);
// //ImGui::Text("%s %s", TimeHelper::GetStrNow().c_str(), m_ProductVersion.c_str());
//
// ImGui::SameLine(ImGui::GetWindowWidth() - 110);
// TextureBean* screenWin = (*m_UIController.m_TextureMap)[ChartletManager::SCREEN_WIN];
// if (ImGui::ImageButton(screenWin->GetTex(), ImVec2(28, 28), ImVec2(0, 0), ImVec2(1, 1), 0, style->Colors[ImGuiCol_WindowBg]))
// {
// m_IsFullScreen = false;
// int wwidth = m_GLFWMode->width * 4 / 5;
// int wheight = m_GLFWMode->height * 4 / 5;
// glfwSetWindowMonitor(m_GLFWWin, NULL, (m_GLFWMode->width - wwidth) / 2, (m_GLFWMode->height - wheight) / 2, wwidth, wheight, m_GLFWMode->refreshRate);
// }
// ImGui::SameLine();
// TextureBean* screenFull = (*m_UIController.m_TextureMap)[ChartletManager::SCREEN_FULL];
// if (ImGui::ImageButton(screenFull->GetTex(), ImVec2(28, 28), ImVec2(0, 0), ImVec2(1, 1), 0, style->Colors[ImGuiCol_WindowBg]))
// {
// m_IsFullScreen = true;
// glfwSetWindowMonitor(m_GLFWWin, NULL, 0, 0, m_GLFWMode->width, m_GLFWMode->height, m_GLFWMode->refreshRate);
// }
// ImGui::SameLine();
// TextureBean* appClose = (*m_UIController.m_TextureMap)[ChartletManager::APP_CLOSE];
// if (ImGui::ImageButton(appClose->GetTex(), ImVec2(28, 28), ImVec2(0, 0), ImVec2(1, 1), 0, style->Colors[ImGuiCol_WindowBg]))
// {
// if (!m_UIController.m_ScannerCtrl->IsStandBy()) {
// g_Toast->AddToast(new ToastBean(_(u8"正在打印中,请先结束打印后退出").c_str(), 5000));
// }
// else {
// ImGui::OpenPopup(_(u8"退出系统").c_str());
// }
// }
//
// }
// else {
// ImGui::SameLine(ImGui::GetWindowWidth() - 300);
// const ImVec2 p1 = ImGui::GetCursorScreenPos();
// char dataBuffer[50];
// sprintf_s(dataBuffer, sizeof(dataBuffer), "%s %s", TimeHelper::GetStrNow().c_str(), m_ProductVersion.c_str());
// ImGui::GetWindowDrawList()->AddText(ImVec2(p1.x, p1.y + 5), IM_COL32_WHITE, dataBuffer);
// //ImGui::Text("%s", TimeHelper::GetStrNow().c_str());
// //ImGui::Text("%s %s", TimeHelper::GetStrNow().c_str(), m_ProductVersion.c_str());
// }
// bool exitStopLaserFlag = false;
// if (ImGui::BeginPopupModal(_(u8"退出系统").c_str(), NULL, ImGuiWindowFlags_NoResize))
// {
// ImGui::Text(_(u8"是否确认退出系统").c_str());
// ImGui::Separator();
//
// if (ImGui::Button(_(u8"是").c_str(), ImVec2(120, 0)))
// {
//#ifndef _DEBUG
// if (m_UIController.m_MachineCtrl->IsLaserActive()) {
// m_UIController.m_MachineCtrl->StopLaser(false);
// exitStopLaserFlag = true;
// }
// else {
//#endif
// glfwSetWindowShouldClose(m_GLFWWin, GLFW_TRUE);
//#ifndef _DEBUG
// }
//#endif
// ImGui::CloseCurrentPopup();
// }
// ImGui::SetItemDefaultFocus();
// ImGui::SameLine();
// if (ImGui::Button(_(u8"取消").c_str(), ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
// ImGui::EndPopup();
// }
//
// if (exitStopLaserFlag) {
// m_UIController.m_SystemAssist.exitTickCount = GetTickCount64();
// m_UIController.m_SystemAssist.exitSumTime = m_UIController.m_MachineCtrl->GetTimeWhenExit();
// //m_UIController.m_MachineCtrl->StopLaser(false);
// ImGui::OpenPopup(_(u8"正在退出系统").c_str());
// }
// if (ImGui::BeginPopupModal(_(u8"正在退出系统").c_str(), NULL, ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize)) {
// uint64_t tnow = GetTickCount64();
// float exitProgress = 1.0f;
// if (m_UIController.m_SystemAssist.exitSumTime != 0L)exitProgress = (float)(tnow - m_UIController.m_SystemAssist.exitTickCount) / m_UIController.m_SystemAssist.exitSumTime;
// ImGui::Text(_(u8"系统将在激光器关闭后退出").c_str());
// ImGui::ProgressBar(exitProgress);
// if (!m_UIController.m_MachineCtrl->IsLaserActive() && exitProgress >= 1.0f) {
// ImGui::CloseCurrentPopup();
// glfwSetWindowShouldClose(m_GLFWWin, GLFW_TRUE);
// }
// ImGui::EndPopup();
// }
//
// ImGui::End();
//}
void UIWin::Draw() {
SetupDockSpace();
//DrawTitleBar();
//DrawToolBar();
}
//void UIWin::DrawToolBar()
//{
// ImGui::SetNextWindowPos(ImVec2(0, 70));
// ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
// ImGui::Begin("toolbar", (bool*)0, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDecoration);
// static bool show_toolbar = false;
// bool isStopAutoPurifier = false;
// bool isStartAutoPurifier = false;
// if (!show_toolbar) {
// //ImGui::Image((*m_UIController.m_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->GetTex(), ImVec2((*m_UIController.m_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->m_Width, (*m_UIController.m_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->m_Height));
// if (ImGui::IsItemHovered())
// show_toolbar = true;
// }
// else {
// ImGui::BeginGroup();
// TextureBean* autoOxygenDisable = ChartletManager::GetInstance()->m_AutoOxygenDisable;
// TextureBean* autoOxygenEnable = ChartletManager::GetInstance()->m_AutoOxygenEnable;
// /*if (m_UIController.m_Purifier->IsAutoDeoxygen())*/ {
// if (ImGui::ImageButton(autoOxygenEnable->GetTex(), ImVec2(autoOxygenEnable->m_Width, autoOxygenEnable->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) {
// isStopAutoPurifier = true;
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"关闭一键除氧").c_str());
// }
// }
// /*else*/ {
// if (ImGui::ImageButton(autoOxygenDisable->GetTex(), ImVec2(autoOxygenDisable->m_Width, autoOxygenDisable->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) {
// isStartAutoPurifier = true;
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"开启一键除氧").c_str());
// }
// }
//
// ImGui::SameLine();
// ImGui::Image((*m_UIController.m_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->GetTex(), ImVec2((*m_UIController.m_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->m_Width, (*m_UIController.m_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->m_Height));
//
// TextureBean* laserOff = (*m_UIController.m_TextureMap)[ChartletManager::LASER_OFF];
// TextureBean* laserOn = (*m_UIController.m_TextureMap)[ChartletManager::LASER_ON];
//
// if (!m_UIController.m_MachineCtrl->IsLaserOn()) {
// if (ImGui::ImageButton(laserOff->GetTex(), ImVec2(laserOff->m_Width, laserOff->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0))
// {
// if (m_UIController.m_ScannerCtrl->IsStandBy()) {
// m_UIController.m_MachineCtrl->StartLaser(false);
// }
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"开启激光").c_str());
// }
// }
// else {
// if (ImGui::ImageButton(laserOn->GetTex(), ImVec2(laserOn->m_Width, laserOn->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0))
// {
// if (m_UIController.m_ScannerCtrl->IsStandBy()) {
// m_UIController.m_MachineCtrl->StopLaser(false);
// }
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"关闭激光").c_str());
// }
// }
//
// //IOCfg* lightCfg = m_UIController.m_IoCfgWrapper->m_LightOn;
// TextureBean* lightOn = (*m_UIController.m_TextureMap)[ChartletManager::LIGHT_ON];
// TextureBean* lightOff = (*m_UIController.m_TextureMap)[ChartletManager::LIGHT_OFF];
// if (!lightCfg->IsActive()) {
// if (ImGui::ImageButton(lightOff->GetTex(), ImVec2(lightOff->m_Width, lightOff->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0))
// {
// lightCfg->SetActive(true);
// g_log->TraceInfo(_(u8"开启照明").c_str());
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"开启照明").c_str());
// }
// }
// else {
// if (ImGui::ImageButton(lightOn->GetTex(), ImVec2(lightOn->m_Width, lightOn->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) {
// lightCfg->SetActive(false);
// g_log->TraceInfo(_(u8"关闭照明").c_str());
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"关闭照明").c_str());
// }
// }
//
// // MachineCfg* mtc = ConfigManager::GetInstance()->GetMachineCfg();
// // if (mtc->m_MachineType == MachineTypeCfg::HBD_280 || mtc->m_HeatingEnable) {
// IOCfg* heatCfg = m_UIController.m_IoCfgWrapper->m_Heating;
// if (heatCfg) {
// TextureBean* heatOn = (*m_UIController.m_TextureMap)[ChartletManager::HEAT_ON];
// TextureBean* heatOff = (*m_UIController.m_TextureMap)[ChartletManager::HEAT_OFF];
// if (!heatCfg->IsActive()) {
// if (ImGui::ImageButton(heatOff->GetTex(), ImVec2(heatOff->m_Width, heatOff->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0))
// {
// heatCfg->SetActive(true);
// m_UIController.m_ScannerCtrl->StartHeatingMotion();
// g_log->TraceInfo(_(u8"打开基板加热").c_str());
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"打开基板加热").c_str());
// }
// }
// else {
// if (ImGui::ImageButton(heatOn->GetTex(), ImVec2(heatOn->m_Width, heatOn->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) {
// m_UIController.m_ScannerCtrl->StopHeatingMotion(false);
// heatCfg->SetActive(false);
// g_log->TraceInfo(_(u8"关闭基板加热").c_str());
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"关闭基板加热").c_str());
// }
// }
// }
// // }
//
//
// TextureBean* checkEnable = (*m_UIController.m_TextureMap)[ChartletManager::CHECK_ENABLE];
// TextureBean* checkDiable = (*m_UIController.m_TextureMap)[ChartletManager::CHECK_DISABLE];
//
// if (m_UIController.m_ExtCfg->m_CheckDataWhenInport) {
// if (ImGui::ImageButton(checkEnable->GetTex(), ImVec2(checkEnable->m_Width, checkEnable->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) {
// m_UIController.m_ExtCfg->m_CheckDataWhenInport = !m_UIController.m_ExtCfg->m_CheckDataWhenInport;
// g_log->TraceInfo(_(u8"关闭数据检验").c_str());
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"关闭数据检验").c_str());
// }
// }
// else {
// if (ImGui::ImageButton(checkDiable->GetTex(), ImVec2(checkDiable->m_Width, checkDiable->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) {
// m_UIController.m_ExtCfg->m_CheckDataWhenInport = !m_UIController.m_ExtCfg->m_CheckDataWhenInport;
// g_log->TraceInfo(_(u8"开启数据检验").c_str());
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"开启数据检验").c_str());
// }
// }
//
// TextureBean* fit_view = (*m_UIController.m_TextureMap)[ChartletManager::FIT_VIEW];
// if (ImGui::ImageButton(fit_view->GetTex(), ImVec2(fit_view->m_Width, fit_view->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0))
// {
// if (m_RenderToPreview)
// m_PrevRenderer->ResetCamera();
// else
// m_Renderer->ResetCamera();
//
// g_log->TraceInfo(_(u8"复位渲染视图").c_str());
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"复位渲染视图").c_str());
// }
//
// TextureBean* setPlatformLevelPos = ChartletManager::GetInstance()->m_SetPlatformLevelPos;
// if (ImGui::ImageButton(setPlatformLevelPos->GetTex(), ImVec2(setPlatformLevelPos->m_Width, setPlatformLevelPos->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0))
// {
// m_UIController.m_AxisRecordWrapper->m_PrintJackupPlatformPlanePosRecord->SetValue(true);
// Sleep(100);
// m_UIController.m_AxisRecordWrapper->m_PrintJackupPlatformPlanePosRecord->SetValue(false);
// m_UIController.m_RunCfg->m_HadSetBasePlatformPoint = true;
// g_Toast->AddToast(new ToastBean(_(u8"基板缸平面位置确定成功").c_str(), 3000, Toast::COLOR_GREEN));
// g_log->TraceInfo(_(u8"基板缸平面位置确定成功").c_str());
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"基板缸平面位置确定").c_str());
// }
//
// TextureBean* resetException = ChartletManager::GetInstance()->m_ResetException;
// if (ImGui::ImageButton(resetException->GetTex(), ImVec2(resetException->m_Width, resetException->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0))
// {
// m_UIController.m_SignalStateWrapper->m_CylinderExceptionReset->SetValue(true);
// g_Toast->AddToast(new ToastBean(_(u8"复位异常成功").c_str(), 3000, Toast::COLOR_GREEN));
// g_log->TraceInfo(_(u8"复位异常").c_str());
// }
// if (ImGui::IsItemHovered()) {
// ImGui::SetTooltip(_(u8"复位异常").c_str());
// }
//
//
//
// ImGui::EndGroup();
// if (!ImGui::IsItemHovered())
// show_toolbar = false;
// }
//
// if (isStopAutoPurifier) {
// ImGui::OpenPopup(_(u8"停止一键除氧确定").c_str());
// }
// if (ImGui::BeginPopupModal(_(u8"停止一键除氧确定").c_str(), NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
// ImGui::Text(_(u8"是否确定停止一键除氧?").c_str());
// ImGui::Spacing();
// ImGui::Separator();
// ImVec2 size = ImGui::GetWindowSize();
// if (ImGui::Button(_(u8"确定").c_str(), ImVec2(size.x / 2 - 10, 0))) {
// /*if (m_UIController.m_ScannerCtrl->IsStandBy()) */{
// //m_UIController.m_Purifier->StopAutoDeoxygen();
// //g_log->TraceInfo(_(u8"关闭一键除氧").c_str());
// }
// ImGui::CloseCurrentPopup();
// }
// ImGui::SameLine();
// if (ImGui::Button(_(u8"取消").c_str(), ImVec2(size.x / 2 - 5, 0))) {
// ImGui::CloseCurrentPopup();
// }
// ImGui::Spacing();
// ImGui::EndPopup();
// }
// if (isStartAutoPurifier) {
// ImGui::OpenPopup(_(u8"开启一键除氧确定").c_str());
// }
// if (ImGui::BeginPopupModal(_(u8"开启一键除氧确定").c_str(), NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
// ImGui::Text(_(u8"是否确定开启一键除氧?").c_str());
// ImGui::Spacing();
// ImGui::Separator();
// ImVec2 size = ImGui::GetWindowSize();
// if (ImGui::Button(_(u8"确定").c_str(), ImVec2(size.x / 2 - 5, 0))) {
// if (m_UIController.m_ScannerCtrl->IsStandBy()) {
// m_UIController.m_Purifier->StartAutoDeoxygen();
// g_log->TraceInfo(_(u8"开启一键除氧").c_str());
// }
// ImGui::CloseCurrentPopup();
// }
// ImGui::SameLine();
// if (ImGui::Button(_(u8"取消").c_str(), ImVec2(size.x / 2 - 10, 0))) {
// ImGui::CloseCurrentPopup();
// }
// ImGui::Spacing();
// ImGui::EndPopup();
// }
// ImGui::End();
// ImGui::PopStyleVar();
//}
void UIWin::SetupDockSpace(void)
{
static ImGuiDockNodeFlags opt_flags = ImGuiDockNodeFlags_PassthruCentralNode | ImGuiDockNodeFlags_AutoHideTabBar;
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking;
ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowBgAlpha(255.0f);
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + TITLE_HEIGHT));
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, viewport->Size.y - TITLE_HEIGHT - STATUS_HEIGHT));
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus/* | ImGuiWindowFlags_NoBackground*/;
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("MainDockSpace", NULL, window_flags);
ImGui::PopStyleVar();
ImGui::PopStyleVar(2);
dockspace_id = ImGui::GetID("MainDockspace");
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), opt_flags);
ImGui::End();
}
void UIWin::Display() {
//g_log->TraceInfo(_(u8"系统启动").c_str());
while (!glfwWindowShouldClose(m_GLFWWin))
{
//glfwPollEvents();
glfwWaitEventsTimeout(0.02);
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
Draw();
SetupDockSpace();
ImGui::Render();
glfwGetFramebufferSize(m_GLFWWin, &m_winWidth, &m_winHeight);
glViewport(0, 0, m_winWidth, m_winHeight);
glClearColor(m_bgColor.x, m_bgColor.y, m_bgColor.z, m_bgColor.w);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
m_Renderer->Render();
m_PrevRenderer->Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwMakeContextCurrent(m_GLFWWin);
glfwSwapBuffers(m_GLFWWin);
}
//g_log->TraceInfo(_(u8"系统退出").c_str());
}