#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 #include "../global.h" #include "../utils/StringHelper.h" #include "../utils/TimeHelper.h" #include "../ChartletManager.h" //#include "FileDialog.h" #include #include #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() : m_TextureMap(nullptr){ } UIWin::~UIWin() { m_TextureMap = nullptr; } void UIWin::GLFWMouseWheelCallback(GLFWwindow* window, double xoffset, double yoffset) { UIWin* _this = (UIWin*)glfwGetWindowUserPointer(window); if (!_this->m_LockScreenWinShow) { EnterCriticalSection(&_this->m_IdleTimeCS); _this->m_IdleTime = 0; LeaveCriticalSection(&_this->m_IdleTimeCS); } #if 0 if (ImGui::IsAnyWindowHovered()) return; if (_this->m_Renderer) _this->m_Renderer->MouseWheelCallback(xoffset, yoffset); #endif } void UIWin::GLFWMousePositionCallback(GLFWwindow* window, double xpos, double ypos) { UIWin* _this = (UIWin*)glfwGetWindowUserPointer(window); if (!_this->m_LockScreenWinShow) { EnterCriticalSection(&_this->m_IdleTimeCS); _this->m_IdleTime = 0; LeaveCriticalSection(&_this->m_IdleTimeCS); } /*ImGui::ScopedContextSwitch outer_scope(_this->m_OskCtx); ImGuiIO &oskIO = ImGui::GetIO(); oskIO.AddMousePosEvent(xpos, ypos); if (!oskIO.WantCaptureMouse) { ImGui::ScopedContextSwitch inner_scope(_this->m_MainCtx); ImGuiIO& io = ImGui::GetIO(); if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { int window_x, window_y; glfwGetWindowPos(window, &window_x, &window_y); xpos += window_x; ypos += window_y; } io.AddMousePosEvent((float)xpos, (float)ypos); //ImGui::GetIO().AddMousePosEvent(xpos, ypos); }*/ // Same z-layering as OnMouseClick(), with keyboard having priority #if 0 if (ImGui::IsAnyWindowHovered()) return; if (_this->m_Renderer) { bool ctrl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS; bool shit = glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; _this->m_Renderer->MousePositionCallback(xpos, ypos, ctrl, shit); } #endif } void UIWin::GLFWMouseButtonCallback(GLFWwindow* window, int button, int action, int mods) { UIWin* _this = (UIWin*)glfwGetWindowUserPointer(window); if (!_this->m_LockScreenWinShow) { EnterCriticalSection(&_this->m_IdleTimeCS); _this->m_IdleTime = 0; LeaveCriticalSection(&_this->m_IdleTimeCS); } /*ImGui::ScopedContextSwitch outer_scope(_this->m_OskCtx); ImGuiIO &oskIO = ImGui::GetIO(); oskIO.AddMouseButtonEvent(button, action == GLFW_PRESS); if (!oskIO.WantCaptureMouse) { ImGui::ScopedContextSwitch inner_scope(_this->m_MainCtx); ImGui::GetIO().AddMouseButtonEvent(button, action == GLFW_PRESS); }*/ #if 0 if (ImGui::IsAnyWindowHovered()) return; if (_this->m_Renderer) { double xpos, ypos; glfwGetCursorPos(window, &xpos, &ypos); _this->m_Renderer->MouseButtonCallback(xpos, ypos, button, action, mods == GLFW_MOD_CONTROL, mods == GLFW_MOD_SHIFT, false); } #endif } void UIWin::GLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) { UIWin* _this = (UIWin*)glfwGetWindowUserPointer(window); if (!_this->m_LockScreenWinShow) { EnterCriticalSection(&_this->m_IdleTimeCS); _this->m_IdleTime = 0; LeaveCriticalSection(&_this->m_IdleTimeCS); } } bool UIWin::Init() { m_TextureMap = &ChartletManager::GetInstance()->m_TextureMap; m_Controller = DataHandle::Instance()->GetController(); //MetaData::InitTypeMap(); g_Admin = USER; m_IsShowInitError = true; //if (!m_Controller->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 = false; #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_Controller->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_Controller->m_MachineCfg->m_PlatformShape == PS_SQUARE) { m_PrevRenderer->SetPlatformShape(PS_SQUARE); m_PrevRenderer->SetPlatfromSize(m_Controller->m_MachineCfg->m_PlatformLength, m_Controller->m_MachineCfg->m_PlatformWidth, 100); m_Renderer->SetPlatformShape(PS_SQUARE); m_Renderer->SetPlatfromSize(m_Controller->m_MachineCfg->m_PlatformLength, m_Controller->m_MachineCfg->m_PlatformWidth, 100); } else { m_PrevRenderer->SetPlatformShape(PS_ROUND); m_PrevRenderer->SetPlatfromSize(m_Controller->m_MachineCfg->m_PlatformLength); m_Renderer->SetPlatformShape(PS_ROUND); m_Renderer->SetPlatfromSize(m_Controller->m_MachineCfg->m_PlatformLength); } //m_Controller->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::Instance()->GetMachineCfg(); string fontpath = g_AppPath + "wqy-zenhei.ttf"; ImFontConfig config; config.OversampleH = 1; config.OversampleV = 1; config.GlyphExtraSpacing.x = 1.0f; ImVector 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::Instance()->GetMachineCfg()->m_lastStartTime = TimeHelper::Str2Time(TimeHelper::GetStrNow()); //ConfigManager::Instance()->SaveMachineConfig(); } //ImGui_ImplOpenGL2_NewFrame(); m_IdleTime = 0; InitializeCriticalSection(&m_IdleTimeCS); //m_Controller->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::Draw() { SetupDockSpace(); DrawTitleBar(); DrawToolBar(); DrawPowder(); DrawMain(); } 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_Controller->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::SameLine(0, 50); if (m_Controller->m_MachineCfg->m_ExpriedTime != 0) { time_t tnow; time(&tnow); if ((m_Controller->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_Controller->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_Controller->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_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_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_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_Controller->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(), DataHandle::Instance()->GetVersion().c_str()); ImGui::GetWindowDrawList()->AddText(ImVec2(p1.x, p1.y + 5), IM_COL32_WHITE, dataBuffer); } 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_Controller->m_MachineCtrl->IsLaserActive()) { m_Controller->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_Controller->m_SystemAssist.exitTickCount = GetTickCount64(); //m_Controller->m_SystemAssist.exitSumTime = m_Controller->m_MachineCtrl->GetTimeWhenExit(); //m_Controller->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_Controller->m_SystemAssist.exitSumTime != 0L)exitProgress = (float)(tnow - m_Controller->m_SystemAssist.exitTickCount) / m_Controller->m_SystemAssist.exitSumTime; ImGui::Text(_(u8"系统将在激光器关闭后退出").c_str()); ImGui::ProgressBar(exitProgress); //if (!m_Controller->m_MachineCtrl->IsLaserActive() && exitProgress >= 1.0f) { // ImGui::CloseCurrentPopup(); // glfwSetWindowShouldClose(m_GLFWWin, GLFW_TRUE); //} ImGui::EndPopup(); } ImGui::End(); } 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_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->GetTex(), ImVec2((*m_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->m_Width, (*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_Controller->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((float)autoOxygenDisable->m_Width, (float)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_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->GetTex(), ImVec2((float)(*m_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->m_Width, (float)(*m_TextureMap)[ChartletManager::TOOLBAR_RIGHT]->m_Height)); TextureBean* laserOff = (*m_TextureMap)[ChartletManager::LASER_OFF]; TextureBean* laserOn = (*m_TextureMap)[ChartletManager::LASER_ON]; /*if (!m_Controller->m_MachineCtrl->IsLaserOn()) */{ if (ImGui::ImageButton(laserOff->GetTex(), ImVec2((float)laserOff->m_Width, (float)laserOff->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) { //if (m_Controller->m_ScannerCtrl->IsStandBy()) { // m_Controller->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_Controller->m_ScannerCtrl->IsStandBy()) { m_Controller->m_MachineCtrl->StopLaser(false); } } if (ImGui::IsItemHovered()) { ImGui::SetTooltip(_(u8"关闭激光").c_str()); } }*/ //IOCfg* lightCfg = m_Controller->m_IoCfgWrapper->m_LightOn; TextureBean* lightOn = (*m_TextureMap)[ChartletManager::LIGHT_ON]; TextureBean* lightOff = (*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((float)lightOn->m_Width, (float)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::Instance()->GetMachineCfg(); // if (mtc->m_MachineType == MachineTypeCfg::HBD_280 || mtc->m_HeatingEnable) { //IOCfg* heatCfg = m_Controller->m_IoCfgWrapper->m_Heating; //if (heatCfg) { // TextureBean* heatOn = (*m_TextureMap)[ChartletManager::HEAT_ON]; // TextureBean* heatOff = (*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_Controller->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_Controller->m_ScannerCtrl->StopHeatingMotion(false); // heatCfg->SetActive(false); // g_log->TraceInfo(_(u8"关闭基板加热").c_str()); // } // if (ImGui::IsItemHovered()) { // ImGui::SetTooltip(_(u8"关闭基板加热").c_str()); // } // } //} // } TextureBean* checkEnable = (*m_TextureMap)[ChartletManager::CHECK_ENABLE]; TextureBean* checkDiable = (*m_TextureMap)[ChartletManager::CHECK_DISABLE]; /* if (m_Controller->m_ExtCfg->m_CheckDataWhenInport) { if (ImGui::ImageButton(checkEnable->GetTex(), ImVec2(checkEnable->m_Width, checkEnable->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) { m_Controller->m_ExtCfg->m_CheckDataWhenInport = !m_Controller->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((float)checkDiable->m_Width, (float)checkDiable->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) { //m_Controller->m_ExtCfg->m_CheckDataWhenInport = !m_Controller->m_ExtCfg->m_CheckDataWhenInport; g_log->TraceInfo(_(u8"开启数据检验").c_str()); } if (ImGui::IsItemHovered()) { ImGui::SetTooltip(_(u8"开启数据检验").c_str()); } } TextureBean* fit_view = (*m_TextureMap)[ChartletManager::FIT_VIEW]; if (ImGui::ImageButton(fit_view->GetTex(), ImVec2((float)fit_view->m_Width, (float)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((float)setPlatformLevelPos->m_Width, (float)setPlatformLevelPos->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) { m_Controller->m_AxisRecordWrapper->m_PrintJackupPlatformPlanePosRecord->SetValue(true); Sleep(100); m_Controller->m_AxisRecordWrapper->m_PrintJackupPlatformPlanePosRecord->SetValue(false); /*m_Controller->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((float)resetException->m_Width, (float)resetException->m_Height), ImVec2(0, 0), ImVec2(1, 1), 0)) { m_Controller->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_Controller->m_ScannerCtrl->IsStandBy()) */{ //m_Controller->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_Controller->m_ScannerCtrl->IsStandBy()) { // m_Controller->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::DrawMain() { ImGui::Begin("HBDSystem1000", NULL, ImGuiWindowFlags_MenuBar); // Menu Begin bool enableFlag = true; bool exitStopLaserFlag = false; if (/*m_Controller->m_ScannerCtrl->IsStandBy() ||*/ g_Admin == ADMIN || g_Admin == USER_ADMIN) { enableFlag = true; } else { enableFlag = false; } m_MainWidth = (int)ImGui::GetContentRegionAvail().x; bool export_file_dialog = false; bool import_file_dialog = false; static bool fast_preview = false; if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenu(_(u8"系统").c_str())) { //ImGui::MenuItem(_(u8"添加任务").c_str(), 0, &m_Controller->m_MenuAssist.isAddTaskClick, m_Controller->m_ScannerCtrl->IsStandBy()); if (ImGui::MenuItem(_(u8"导入参数").c_str())) { import_file_dialog = true; } if (ImGui::MenuItem(_(u8"导出参数").c_str())) { export_file_dialog = true; } if (ImGui::MenuItem(_(u8"窗口最小化").c_str())) { glfwIconifyWindow(m_GLFWWin); } if (ImGui::MenuItem(_(u8"窗口显示").c_str())) { 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); } if (ImGui::MenuItem(_(u8"全屏显示").c_str())) { m_IsFullScreen = true; glfwSetWindowMonitor(m_GLFWWin, NULL, 0, 0, m_GLFWMode->width, m_GLFWMode->height, m_GLFWMode->refreshRate); } ImGui::PushItemFlag(ImGuiItemFlags_SelectableDontClosePopup, true); if (ImGui::MenuItem(_(u8"退出系统").c_str())) { //if (!m_Controller->m_ScannerCtrl->IsStandBy()) { // g_Toast->AddToast(new ToastBean(_(u8"正在打印中,请先结束打印后退出").c_str(), 5000)); //} /*else*/ { ImGui::OpenPopup(_(u8"退出系统").c_str()); } } ImGui::PopItemFlag(); 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_Controller->m_MachineCtrl->IsLaserActive()) { m_Controller->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(); } ImGui::EndMenu(); } if (ImGui::BeginMenu(_(u8"状态").c_str())) { //ImGui::MenuItem(_(u8"通讯状态").c_str(), NULL, &m_StateWinShow); //ImGui::MenuItem(_(u8"净化器状态").c_str(), NULL, &m_Controller->m_Purifier->m_PurifierWinShow); //ImGui::MenuItem(_(u8"激光器状态").c_str(), NULL, &m_LaserStateShow); //ImGui::MenuItem(_(u8"振镜状态").c_str(), NULL, &m_ScannerWinShow); //if (m_Controller->m_ComServer->m_PowerMeterClient && m_Controller->m_ComServer->m_PowerMeterClient->GetConfig()->m_Enable)ImGui::MenuItem(_(u8"电能质量").c_str(), NULL, &m_PowerMeterShow); //if (m_Controller->m_ComServer->m_LaserChillerClient)ImGui::MenuItem(_(u8"激光器冷水机").c_str(), NULL, &m_Controller->m_ComServer->m_LaserChillerClient->m_IsShowUI); ////if (m_Controller->m_ComServer->m_PurifierChillerClient)ImGui::MenuItem(_(u8"净化器冷水机").c_str(), NULL, &m_Controller->m_ComServer->m_PurifierChillerClient->m_IsShowUI); //if (m_Controller->m_ExtCfg->m_UseCamera)ImGui::MenuItem(_(u8"实时图像").c_str(), NULL, &m_Controller->m_Camera->m_ShowFlag); //if (m_Controller->m_ComServer->m_SimpleSupplyClient && m_Controller->m_ComServer->m_SimpleSupplyClient->GetConfig()->m_Enable)ImGui::MenuItem(_(u8"单供粉").c_str(), NULL, &m_SimpleSupplyWinShow); //ImGui::MenuItem(_(u8"日志").c_str(), NULL, &m_LogWinShow); //ImGui::MenuItem(_(u8"伺服状态").c_str(), NULL, &m_ServoStateShow); //ImGui::MenuItem(_(u8"扭力状态").c_str(), NULL, &m_Controller->m_ServoManager->m_IsShowServo); //ImGui::MenuItem(_(u8"信号状态").c_str(), NULL, &m_SignalStateShow); //if (m_Controller->m_RecoatCheckCfg->m_Enable)ImGui::MenuItem(_(u8"铺粉检测状态").c_str(), 0, &m_RecoatCheckWinShow); //ImGui::MenuItem(_(u8"快速层预览").c_str(), 0, &fast_preview); ImGui::EndMenu(); } if (ImGui::BeginMenu(_(u8"调试").c_str(), enableFlag)) { ImGui::MenuItem(_(u8"铺粉装置").c_str(), 0, &m_powderWinShow, enableFlag); if (g_Admin > USER) { ImGui::MenuItem(_(u8"IO端口").c_str(), 0, &m_IOWinShow, enableFlag); ImGui::MenuItem(_(u8"扫描装置").c_str(), 0, &m_scanWinShow, enableFlag); } //if (m_Controller->m_ExtCfg->m_UseCamera)ImGui::MenuItem(_(u8"图像调试").c_str(), 0, &m_Controller->m_Calibration->m_GraftingShow, enableFlag); ImGui::EndMenu(); } if (g_Admin > USER) { if (ImGui::BeginMenu(_(u8"设置").c_str(), enableFlag)) { ImGui::MenuItem(_(u8"参数设置").c_str(), NULL, &m_configWinShow); ImGui::EndMenu(); } } if (ImGui::BeginMenu(_(u8"帮助").c_str())) { ImGui::MenuItem(_(u8"关于").c_str()); if (ImGui::BeginMenu(_(u8"语言").c_str())) { if (ImGui::Selectable(_(u8"简体中文").c_str())) { m_Controller->m_MachineCfg->m_I18NLang = "zh_CN"; g_LngManager->VarTrans(); } if (ImGui::Selectable(_(u8"英文").c_str())) { m_Controller->m_MachineCfg->m_I18NLang = "en"; g_LngManager->VarTrans(); } ImGui::EndMenu(); } //if (g_isDebug)ImGui::MenuItem(u8"测试信息", NULL, &m_TestWinShow); if (g_Admin != USER) { if (ImGui::MenuItem(_(u8"注销管理员").c_str())) g_Admin = USER; } else { ImGui::PushItemFlag(ImGuiItemFlags_SelectableDontClosePopup, true); if (ImGui::MenuItem(_(u8"管理员").c_str())) ImGui::OpenPopup(_(u8"管理员").c_str()); ImGui::PopItemFlag(); if (ImGui::BeginPopupModal(_(u8"管理员").c_str(), NULL, ImGuiWindowFlags_NoResize)) { static char pwd_buf[7]; if (!ImGui::IsAnyItemActive()) ImGui::SetKeyboardFocusHere(); if (ImGui::InputText(_(u8"密码").c_str(), pwd_buf, sizeof(pwd_buf), ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_EnterReturnsTrue)) { g_Admin = SUPER; /*CheckUserPasswd(pwd_buf);*/ //wxxtest std::memset(pwd_buf, 0, sizeof(pwd_buf)); ImGui::CloseCurrentPopup(); } ImGui::Separator(); if (ImGui::Button(_(u8"确定").c_str(), ImVec2(120, 0))) { g_Admin = SUPER; /*CheckUserPasswd(pwd_buf);*/ //wxxtest std::memset(pwd_buf, 0, sizeof(pwd_buf)); ImGui::CloseCurrentPopup(); } ImGui::SetItemDefaultFocus(); ImGui::SameLine(); if (ImGui::Button(_(u8"取消").c_str(), ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } } ImGui::EndMenu(); } ImGui::EndMenuBar(); } // Menu End if (export_file_dialog) { ImGui::OpenPopup(_(u8"导出参数").c_str()); } if (ImGui::BeginPopupModalEx(_(u8"导出参数").c_str(), NULL, ImGuiWindowFlags_NoResize, ImVec2(600, 600))) { //if (FileDialog::GetInstance()->OpenDialog("Choose File", ".cfg", true)) //{ // if (FileDialog::GetInstance()->IsOk == true) // { // if (m_Controller->jc.IsLoadFinished()) // { // string filepath = StringHelper::Wstr2Str(FileDialog::GetInstance()->GetFilepathName()); // ConfigManager::Instance()->Export(filepath); // } // } // ImGui::CloseCurrentPopup(); //} ImGui::EndPopup(); } if (import_file_dialog) { ImGui::OpenPopup(_(u8"导入参数").c_str()); } if (ImGui::BeginPopupModalEx(_(u8"导入参数").c_str(), NULL, ImGuiWindowFlags_NoResize, ImVec2(600, 600))) { //if (FileDialog::GetInstance()->OpenDialog("Choose File", ".cfg;")) //{ // if (FileDialog::GetInstance()->IsOk == true) // { // if (m_Controller->jc.IsLoadFinished()) // { // string filepath = StringHelper::Wstr2Str(FileDialog::GetInstance()->GetFilepathName()); // ConfigManager::Instance()->Import(filepath); // m_PrevRenderer->SetPlatfromSize(600, 600, 1000); // m_Renderer->SetPlatfromSize(600, 600, 1000); // } // } // ImGui::CloseCurrentPopup(); //} ImGui::EndPopup(); } if (exitStopLaserFlag) { m_Controller->m_SystemAssist.exitTickCount = GetTickCount64(); //m_Controller->m_SystemAssist.exitSumTime = m_Controller->m_MachineCtrl->GetTimeWhenExit(); 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_Controller->m_SystemAssist.exitSumTime != 0L)exitProgress = (float)(tnow - m_Controller->m_SystemAssist.exitTickCount) / m_Controller->m_SystemAssist.exitSumTime; ImGui::Text(_(u8"系统将在激光器关闭后退出").c_str()); ImGui::ProgressBar(exitProgress); //if (!m_Controller->m_MachineCtrl->IsLaserActive() && exitProgress >= 1.0f) { // // //g_log->TraceInfo(u8"退出程序"); // //Sleep(300); // ImGui::CloseCurrentPopup(); // glfwSetWindowShouldClose(m_GLFWWin, GLFW_TRUE); //} ImGui::EndPopup(); } // Toolbar Begin //if (m_Controller->m_MenuAssist.isAddTaskClick) { // ImGui::OpenPopup(_(u8"添加任务").c_str()); // m_Controller->m_MenuAssist.isAddTaskClick = false; //} bool isOpenContinue = false; bool isReadFile = false; if (ImGui::BeginPopupModalEx(_(u8"添加任务").c_str(), NULL, ImGuiWindowFlags_NoResize, ImVec2(600, 600))) { /*if (FileDialog::GetInstance()->OpenDialog("Choose File", ".job;.h3d")) { if (FileDialog::GetInstance()->IsOk == true) { EnterCriticalSection(&m_Controller->jc.m_cs); m_Controller->jc.RemoveAllJob(); m_Renderer->ClearScene(true); m_PrevRenderer->ClearScene(true); LeaveCriticalSection(&m_Controller->jc.m_cs); if (m_Controller->jc.IsLoadFinished()) { string filepath = StringHelper::Wstr2Str(FileDialog::GetInstance()->GetFilepathName()); if (m_Controller->jc.LoadJob(filepath)) { isReadFile = true; } } } ImGui::CloseCurrentPopup(); }*/ ImGui::EndPopup(); } if (isReadFile) { ImGui::OpenPopup(_(u8"添加任务进度").c_str()); } //EnterCriticalSection(&m_Controller->jc.m_cs); //if (ImGui::BeginPopupModalEx(_(u8"添加任务进度").c_str(), NULL, ImGuiWindowFlags_NoResize, ImVec2(500, 150))) { // ImGui::SetWindowFontScale(1.2); // ImGui::Text(m_Controller->jc.GetLoadInfo().c_str()); // // ImGui::ProgressBar(m_Controller->jc.GetLoadProgress()); // if (m_Controller->jc.IsLoadFinished()) { // FileProcessor* pjp = m_Controller->jc.GetJob(); // if (pjp != NULL) { // vector infos; // pjp->GetMetaData()->GetErrorInfo(infos); // if (!infos.empty()) { // ImGui::TextColored(Toast::COLOR_RED, infos[0].c_str()); // if (ImGui::Button(_(u8"确定").c_str(), ImVec2(-1, 0))) { // m_Renderer->ClearScene(true); // m_PrevRenderer->ClearScene(true); // m_Renderer->SetJob(pjp); // m_PrevRenderer->SetJob(pjp); // g_SystemInfo->m_StateBean.jobCostMil = pjp->GetMetaData()->GetEvaTime(); // g_SystemInfo->m_StateBean.remainMil = pjp->GetMetaData()->GetRemainTime(); // g_SystemInfo->m_StateBean.maxLayerIndex = pjp->GetLayerCount(); // g_SystemInfo->m_StateBean.realCostSeconds = 0; // g_SystemInfo->m_StateBean.layerIndex = 0; // g_SystemInfo->m_StateBean.jobProgress = 0.0f; // pjp->SetStartIndex(0); // ImGui::CloseCurrentPopup(); // } // } // else { // m_Renderer->ClearScene(true); // m_PrevRenderer->ClearScene(true); // m_Renderer->SetJob(pjp); // m_PrevRenderer->SetJob(pjp); // g_SystemInfo->m_StateBean.jobCostMil = pjp->GetMetaData()->GetEvaTime(); // g_SystemInfo->m_StateBean.remainMil = pjp->GetMetaData()->GetRemainTime(); // g_SystemInfo->m_StateBean.maxLayerIndex = pjp->GetLayerCount(); // g_SystemInfo->m_StateBean.realCostSeconds = 0; // g_SystemInfo->m_StateBean.jobProgress = 0.0f; // g_SystemInfo->m_StateBean.layerIndex = 0; // pjp->SetStartIndex(0); // if (g_log->m_LogDao->GetCheckJob(pjp->GetJobUid(), m_Controller->m_JobAssist.continueJob)) // { // isOpenContinue = true; // } // vector partv; // g_log->m_LogDao->FindPartAddition(pjp->GetJobUid(), partv); // for (size_t paIndex = 0; paIndex < partv.size(); ++paIndex) // { // PartAddition* pa = partv[paIndex]; // MetaData::Part* sourcePart = pjp->GetMetaData()->GetPart(pa->m_SourcePart); // MetaData::Part* newPart = sourcePart->CopyPart(pjp->GetMetaData()->GetPartVec().size()); // newPart->id = pa->m_NewPart; // pjp->GetMetaData()->AddPart(newPart); // m_Renderer->AddPart(newPart); // m_PrevRenderer->AddPart(newPart); // } // for (size_t paIndex = 0; paIndex < partv.size(); ++paIndex) { // delete partv[paIndex]; // } // partv.clear(); // vector partIds; // pjp->GetMetaData()->GetPartIds(partIds); // g_log->m_LogDao->AddPartPos(pjp->GetJobUid(), partIds); // vector partPosv; // g_log->m_LogDao->FindPartPos(pjp->GetJobUid(), partPosv); // for (size_t paIndex = 0; paIndex < partPosv.size(); ++paIndex) // { // MetaData::Part* ppb = pjp->GetMetaData()->GetPart(partPosv[paIndex]->m_PartId); // if (ppb) { // ppb->partPosBean.m_XOffset = partPosv[paIndex]->m_XOffset; // ppb->partPosBean.m_YOffset = partPosv[paIndex]->m_YOffset; // ppb->partPosBean.m_RotateAngle = partPosv[paIndex]->m_RotateAngle; // ppb->partPosBean.m_Radians = (float)MathHelper::DegreesToRadians((double)ppb->partPosBean.m_RotateAngle); // ppb->partPosBean.m_PartCenterX = ppb->partPosBean.m_XOffset + ppb->partPosBean.m_SrcPartCenterX; // ppb->partPosBean.m_PartCenterY = ppb->partPosBean.m_YOffset + ppb->partPosBean.m_SrcPartCenterY; // Part* prev_part = m_PrevRenderer->GetPart(ppb->id); // if (prev_part)prev_part->UpdateOffset(); // Part* print_part = m_Renderer->GetPart(ppb->id); // if (print_part)print_part->UpdateOffset(); // } // } // for (size_t paIndex = 0; paIndex < partPosv.size(); ++paIndex) { // delete partPosv[paIndex]; // } // partPosv.clear(); // g_log->TraceInfo(_(u8"导入任务%s").c_str(), pjp->GetJobFileName().c_str()); // m_Controller->m_Calibration->UpdateData(pjp->GetMetaData()); // ImGui::CloseCurrentPopup(); // } // } // else { // ImGui::CloseCurrentPopup(); // } // } // else { // ImGui::ProgressBar(m_Controller->jc.GetLoadProgress()); // } // ImGui::EndPopup(); //} //LeaveCriticalSection(&m_Controller->jc.m_cs); if (isOpenContinue) { ImGui::OpenPopup(_(u8"继续任务").c_str()); } if (ImGui::BeginPopupModal(_(u8"继续任务").c_str(), NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize)) { //ImGui::Text(_(u8"检测到任务:%s 尚未完成,\n是否继续打印还是重新开始打印?").c_str(), m_Controller->m_JobAssist.continueJob.m_Name.c_str()); //if (ImGui::Button(_(u8"继续任务").c_str(), ImVec2(120, 0))) //{ // m_Controller->m_JobAssist.continueJob.m_IsContinue = true; // FileProcessor* pjp = m_Controller->jc.GetJob(); // pjp->SetJobbean(m_Controller->m_JobAssist.continueJob); // if (m_Controller->m_JobAssist.continueJob.m_PrintedLayerIndex + 1 < pjp->GetLayerCount()) { // pjp->SetStartIndex(m_Controller->m_JobAssist.continueJob.m_PrintedLayerIndex + 1); // pjp->GetMetaData()->CalcRemainTime(m_Controller->m_JobAssist.continueJob.m_PrintedLayerIndex + 1); // } // ImGui::CloseCurrentPopup(); // pjp->GetMetaData()->LoadLayerByIndex(m_Controller->m_JobAssist.continueJob.m_PrintedLayerIndex + 1); // g_SystemInfo->m_StateBean.remainMil = pjp->GetMetaData()->GetRemainTime(); // g_SystemInfo->m_StateBean.realCostSeconds = m_Controller->m_JobAssist.continueJob.m_PrintSecond; // g_SystemInfo->m_StateBean.layerIndex = m_Controller->m_JobAssist.continueJob.m_PrintedLayerIndex; // g_SystemInfo->m_StateBean.jobProgress = g_SystemInfo->m_StateBean.layerIndex / g_SystemInfo->m_StateBean.maxLayerIndex; //} ImGui::SameLine(0, 100); if (ImGui::Button(_(u8"重新任务").c_str(), ImVec2(120, 0))) { g_SystemInfo->m_StateBean.realCostSeconds = 0; //g_log->m_LogDao->UpdateJobInvalid(m_Controller->m_JobAssist.continueJob.m_Id); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } //if (ImGui::ImageButton((*m_Controller->m_TextureMap)[ChartletManager::LOCK]->GetTex(), ImVec2(60, 60), ImVec2(0, 0), ImVec2(1, 1), 0)) { // m_LockScreenWinShow = true; //} if (ImGui::IsItemHovered()) { ImGui::SetTooltip(_(u8"锁屏").c_str()); } ImGui::SameLine(); //if (!BaseCtrl::IsStandBy()) { // if (ImGui::ImageButton((*m_Controller->m_TextureMap)[ChartletManager::START_ENABLE]->GetTex(), ImVec2(60, 60), ImVec2(0, 0), ImVec2(1, 1), 0)) { // m_Controller->m_ScannerCtrl->PauseWork(); // } // if (ImGui::IsItemHovered()) { // ImGui::SetTooltip(_(u8"暂停").c_str()); // } //} //else if (BaseCtrl::GetState() == BaseCtrl::STANDBY || BaseCtrl::GetState() == BaseCtrl::STANDBY_STOP) { // if (ImGui::ImageButton((*m_Controller->m_TextureMap)[ChartletManager::START_DISABLE]->GetTex(), ImVec2(60, 60), ImVec2(0, 0), ImVec2(1, 1), 0)) // { // m_Controller->m_ScannerCtrl->BeginWork(); // } // if (ImGui::IsItemHovered()) { // ImGui::SetTooltip(_(u8"开始").c_str()); // } //} //else { // if (ImGui::ImageButton((*m_Controller->m_TextureMap)[ChartletManager::PAUSE]->GetTex(), ImVec2(60, 60), ImVec2(0, 0), ImVec2(1, 1), 0)) // { // m_Controller->m_ScannerCtrl->BeginWork(); // } // if (ImGui::IsItemHovered()) { // ImGui::SetTooltip(_(u8"继续").c_str()); // } //} ImGui::SameLine(); //if (BaseCtrl::IsStop() || BaseCtrl::GetState() == BaseCtrl::STANDBY_STOP) { // ImGui::ImageButton((*m_Controller->m_TextureMap)[ChartletManager::STOP_ENABLE]->GetTex(), ImVec2(60, 60), ImVec2(0, 0), ImVec2(1, 1), 0); //} //else{ // if (ImGui::ImageButton((*m_Controller->m_TextureMap)[ChartletManager::STOP_DISABLE]->GetTex(), ImVec2(60, 60), ImVec2(0, 0), ImVec2(1, 1), 0)) // { // m_Controller->m_ScannerCtrl->StopWork(); // } //} if (ImGui::IsItemHovered()) { ImGui::SetTooltip(_(u8"结束").c_str()); } // Toolbar End // Jobs List Begin ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); ImGui::BeginChild("TaskList", ImVec2(0, 0), true, ImGuiWindowFlags_MenuBar); //if (ImGui::BeginMenuBar()) //{ // if (ImGui::BeginMenu(_(u8"任务").c_str(), m_Controller->m_ScannerCtrl->IsStandBy())) // { // if (ImGui::MenuItem(_(u8"删除任务").c_str())) { // g_log->TraceInfo(_(u8"删除任务").c_str()); // m_Controller->jc.RemoveAllJob(); // m_Renderer->ClearScene(true); // m_PrevRenderer->ClearScene(true); // } // ImGui::EndMenu(); // } // ImGui::EndMenuBar(); //} //EnterCriticalSection(&m_Controller->jc.m_cs); //if (m_Controller->jc.GetJob() && m_PrevRenderer->GetBPData() && m_Renderer->GetBPData()) { // FileProcessor* jfp = m_Controller->jc.GetJob(); // if (ImGui::TreeNode(_(u8"任务信息").c_str())) // { // ImGui::Text(_(u8"文件名:%s").c_str(), jfp->GetJobTitle().c_str()); // MetaData::JobDimensions* jd = jfp->GetMetaData()->GetJobDimensions(); // ImGui::Text(_(u8"尺寸:%.3fx%.3fx%.3f").c_str(), jd->xmax - jd->xmin, jd->ymax - jd->ymin, jd->zmax - jd->zmin); // ImGui::Text(_(u8"材料:%s").c_str(), jfp->GetMetaData()->GetMaterial()); // ImGui::Text(_(u8"层厚:%uμm").c_str(), *jfp->GetMetaData()->GetLayerThickness()); // ImGui::Text(_(u8"层数:%d").c_str(), jfp->GetLayerCount()); // ImGui::Text(_(u8"部件数:%d").c_str(), jfp->GetComponentCount()); // ImGui::TreePop(); // } // if (ImGui::TreeNode(_(u8"分区信息").c_str())) // { // vector* sfs = jfp->GetMetaData()->GetScanFields(); // for (size_t sfIndex = 0; sfIndex < sfs->size(); sfIndex++) { // MetaData::ScanField* sf = (*sfs)[sfIndex]; // ImGui::BeginGroup(); // ImGui::Text(_(u8"分区%d").c_str(), sf->id); // ImGui::EndGroup(); // ImGui::SameLine(); // ImGui::BeginGroup(); // ImGui::Text(u8"X:(%.3f,%.3f)", sf->dimension->xmin, sf->dimension->xmax); // ImGui::Text(u8"Y:(%.3f,%.3f)", sf->dimension->ymin, sf->dimension->ymax); // ImGui::EndGroup(); // //ImGui::Text() // ImGui::Separator(); // } // ImGui::TreePop(); // } // //char item[100]; // if (ImGui::TreeNode(_(u8"部件参数").c_str())) // { // if (g_Admin > USER) { // vector SetParamTypeCombo = { _(u8"单个"),_(u8"相同"),_(u8"所有") }; // ImGui::PushItemWidth(90); // ImGui::SemicolonCombo(_(u8"修改限定").c_str(), &jfp->m_SetParamType, SetParamTypeCombo); // ImGui::PopItemWidth(); // } // char buffer[1024]; // vector& partVec = jfp->GetMetaData()->GetPartVec(); // // static MetaData::Part* addPart = nullptr; // // static MetaData::Part* delPart = nullptr; // for (size_t partIndex = 0; partIndex < partVec.size(); ++partIndex) { // MetaData::Part* part = partVec[partIndex]; // if (part->print_enable) { // sprintf_s(buffer, sizeof(buffer), u8"%d_%s", part->id, StringHelper::AsciiToUtf8(part->name).c_str()); // } // else sprintf_s(buffer, sizeof(buffer), _(u8"%d_%s 不打印").c_str(), part->id, StringHelper::AsciiToUtf8(part->name).c_str()); // if (ImGui::TreeNode(buffer)) { // /*if (BaseCtrl::IsStandBy()) { // if (!part->isCopy) { // if (ImGui::Button(_(u8"复制零件").c_str())) { // addPart = part; // } // } // else { // if (ImGui::Button(_(u8"删除零件").c_str())) { // delPart = part; // } // } // }*/ // ImGui::BeginGroup(); // sprintf_s(buffer, sizeof(buffer), "%d_%s_enable", part->id, part->name.c_str()); // ImGui::PushID(buffer); // if (ImGui::Checkbox(_(u8"打印").c_str(), &part->print_enable)) { // //vector* showparts = m_Renderer->GetParts(); // Part* printPart = m_Renderer->GetPart(part->id); // if (printPart) { // printPart->SetPrintable(part->print_enable); // } // Part* preprintPart = m_PrevRenderer->GetPart(part->id); // if (preprintPart) { // preprintPart->SetPrintable(part->print_enable); // } // if (part->print_enable) { // g_log->TraceInfo(_(u8"设置零件%d打印").c_str(), part->id); // } // else g_log->TraceInfo(_(u8"设置零件%d不打印").c_str(), part->id); // jfp->GetMetaData()->ReCalcEvaTime(); // g_SystemInfo->m_StateBean.jobCostMil = jfp->GetMetaData()->GetEvaTime(); // g_SystemInfo->m_StateBean.remainMil = jfp->GetMetaData()->GetRemainTime(); // } // ImGui::PopID(); // if (!part->paramSet.empty()) { // static int sel_param = 0; // ImGui::PushID("param_combo"); // ImGui::PushItemWidth(100); // ImGui::Combo("", &sel_param, [](void* data, int idx, const char** out_text) { // ParamSetCfg* ppsc = (ParamSetCfg*)data; // *out_text = ppsc->ParamSetVec[idx]->ConfigName.data(); // return true; }, // ConfigManager::Instance()->GetParamSetCfg(), // ConfigManager::Instance()->GetParamSetCfg()->ParamSetVec.size()); // ImGui::PopItemWidth(); // ImGui::SameLine(); // if (ImGui::Button(_(u8"应用参数").c_str())) // { // ParamSetCfg::ParamSet* ps = ConfigManager::Instance()->GetParamSetCfg()->ParamSetVec[sel_param]; // std::vector& layers = jfp->GetMetaData()->GetLayersVec(); // for (unsigned int i = 0; i < ps->PowderSets.size(); i++) // { // for (unsigned int layer = ps->PowderSets[i]->start_layer; // layer < jfp->GetLayerCount() && layer <= ps->PowderSets[i]->end_layer; // layer++) // { // layers[layer]->powder = ps->PowderSets[i]->powder * layers[layer]->layer_thickness; // } // } // if (jfp->m_SetParamType == JobFileProcessor::SingleParam) // { // for (set::iterator it = part->paramSet.begin(); it != part->paramSet.end(); it++) { // JobMetaData::ParameterSet* param = (*it); // ParamSetCfg::ParamSetCfg::LaserSet* ls = ps->LaserSetMap[param->set_type]; // if (ls == nullptr) // continue; // param->laser_speed = ls->laser_speed; // param->laser_set->laser_diameter = ls->laser_diameter; // param->laser_set->laser_power = ls->laser_power; // } // } // else // { // map* paramMap = jfp->GetMetaData()->GetParameterMap(); // map::iterator it; // for (it = (*paramMap).begin(); it != (*paramMap).end(); it++) // { // if (it->second) { // ParamSetCfg::LaserSet* ls = ps->LaserSetMap[it->second->set_type]; // if (ls == nullptr) // continue; // it->second->laser_speed = ls->laser_speed; // it->second->laser_set->laser_diameter = ls->laser_diameter; // it->second->laser_set->laser_power = ls->laser_power; // } // } // } // g_log->TraceInfo(_(u8"执行应用参数").c_str()); // } // ImGui::PopID(); // if (ImGui::TreeNode(_(u8"偏移设置").c_str())) // { // static bool is_changed; // ImGui::PushItemWidth(100); // sprintf_s(buffer, sizeof(buffer), "%d_xoffset", part->id); // ImGui::PushID(buffer); // if (ImGui::InputFloat(_(u8"X偏移").c_str(), &part->partPosBean.m_XOffset, 0, 0, "%.6f", ImGuiInputTextFlags_EnterReturnsTrue)) { // is_changed = true; // g_log->TraceInfo(_(u8"设置零件%dX方向偏移%.6f").c_str(), part->id, part->partPosBean.m_XOffset); // } // ImGui::PopID(); // sprintf_s(buffer, sizeof(buffer), "%d_yoffset", part->id); // ImGui::PushID(buffer); // if (ImGui::InputFloat(_(u8"Y偏移").c_str(), &part->partPosBean.m_YOffset, 0, 0, "%.6f", ImGuiInputTextFlags_EnterReturnsTrue)) { // is_changed = true; // g_log->TraceInfo(_(u8"设置零件%dY方向偏移%.6f").c_str(), part->id, part->partPosBean.m_YOffset); // } // ImGui::PopID(); // sprintf_s(buffer, sizeof(buffer), "%d_rotate", part->id); // ImGui::PushID(buffer); // if (ImGui::InputFloat(_(u8"旋转角度").c_str(), &part->partPosBean.m_RotateAngle, 0, 0, "%.6f", ImGuiInputTextFlags_EnterReturnsTrue)) { // is_changed = true; // g_log->TraceInfo(_(u8"设置零件%d逆时针旋转%.6f").c_str(), part->id, part->partPosBean.m_RotateAngle); // } // ImGui::PopID(); // ImGui::PopItemWidth(); // if (is_changed || m_PrevRenderer->GetPart(part->id)->IsOffsetUpdated()) // { // is_changed = false; // part->partPosBean.m_Radians = (float)MathHelper::DegreesToRadians(part->partPosBean.m_RotateAngle); // part->partPosBean.m_PartCenterX = (part->partPosBean.m_XOffset + part->partPosBean.m_SrcPartCenterX); // part->partPosBean.m_PartCenterY = (part->partPosBean.m_YOffset + part->partPosBean.m_SrcPartCenterY); // Part* prevPart = m_PrevRenderer->GetPart(part->id); // if (prevPart)prevPart->UpdateOffset(); // //double model_x_offset = 0.0, model_y_offset = 0.0, model_rotation = 0.0; // //m_PrevRenderer->GetPart(part->id)->GetOffset(&model_x_offset, &model_y_offset, &model_rotation); // Part* printPart = m_Renderer->GetPart(part->id); // //if (printPart)printPart->UpdateOffset(model_x_offset, model_y_offset, model_rotation); // if (printPart)printPart->UpdateOffset(); // g_log->m_LogDao->UpdatePartPos(jfp->GetJobUid(), part->id, part->partPosBean.m_XOffset, part->partPosBean.m_YOffset, part->partPosBean.m_RotateAngle); // //g_log->m_LogDao->UpdatePartAdditionOffset(jfp->GetJobUid(), part->id, (float)model_x_offset, (float)model_y_offset, (float)model_rotation); // } // ImGui::TreePop(); // } // ExtCfg* stc = m_Controller->m_ExtCfg; // if (stc->m_model_enable && ImGui::TreeNode(_(u8"模具拼接").c_str())) // { // ImGui::PushItemWidth(80); // ImGui::Text(_(u8"扫描方式").c_str()); // ImGui::SameLine(); // sprintf_s(buffer, sizeof(buffer), "%zd_scanMode", partIndex); // vector model_scan_modeCombo = { _(u8"激光"),_(u8"红光") }; // ImGui::PushID(buffer); // ImGui::SemicolonCombo("", &stc->m_model_scan_mode, model_scan_modeCombo); // ImGui::PopID(); // ImGui::Text(_(u8"扫描类型").c_str()); // ImGui::SameLine(); // sprintf_s(buffer, sizeof(buffer), "%d_scanType", part->id); // int scanType = stc->m_model_scan_type == "Border" ? 0 : 1; // vector scanTypeCombo = { _(u8"轮廓"),_(u8"实体") }; // ImGui::PushID(buffer); // if (ImGui::SemicolonCombo("", &scanType, scanTypeCombo)) { // if (scanType == 0) // stc->m_model_scan_type = "Border"; // else // stc->m_model_scan_type = "Hatching"; // } // ImGui::PopID(); // if (scanType == 0) { // ImGui::Combo(_(u8"轮廓类型").c_str(), &stc->m_model_border_type, "AllBorder\0Border\0BorderDown\0BorderAdditionalDown\0BorderBlockedDown\0BorderAdditional\0BorderBlocked\0BorderUp\0BorderAdditionalUp\0BorderBlockedUp\0BorderSupport\0BorderAdditionalSupport\0"); // } // ImGui::Text(_(u8"扫描速度").c_str()); // ImGui::SameLine(); // sprintf_s(buffer, sizeof(buffer), "%d_scanSpeed", part->id); // ImGui::PushID(buffer); // ImGui::InputDouble("", &stc->m_model_laser_speed, 0, 0, "%.2f", ImGuiInputTextFlags_EnterReturnsTrue); // ImGui::PopID(); // if (stc->m_model_scan_mode == 0) { // ImGui::Text(_(u8"扫描功率").c_str()); // ImGui::SameLine(); // sprintf_s(buffer, sizeof(buffer), "%d_scanPower", part->id); // ImGui::PushID(buffer); // ImGui::InputInt("", &stc->m_model_laser_power, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue); // ImGui::PopID(); // } // if (m_Controller->m_ScannerCtrl->IsTestLayerEnable()) { // if (ImGui::Button(_(u8"拼接测试").c_str())) { // if (g_isDebug) // { // stc->m_model_scan_part_id = part->id; // m_Controller->m_ScannerCtrl->ModelScan(); // } // else { // if (stc->m_model_scan_mode == 0 && m_Controller->m_AlarmCfg->m_PrintCabinDoorOpenAlarm->m_IsAlarm) { // g_Toast->AddToast(new ToastBean(_(u8"舱门打开,不能执行任务").c_str(), 3000, ImVec4(1, 0, 0, 1))); // } // else if (!m_Controller->m_IoCfgWrapper->m_Laser->IsActive()) { // g_Toast->AddToast(new ToastBean(_(u8"请先开启激光器").c_str(), 3000, ImVec4(1, 0, 0, 1))); // } // else { // stc->m_model_scan_part_id = part->id; // m_Controller->m_ScannerCtrl->ModelScan(); // g_log->TraceInfo(_(u8"执行模具拼接测试").c_str()); // } // } // } // } // else { // if (ImGui::Button(_(u8"停止拼接").c_str())) // { // m_Controller->m_ScannerCtrl->StopModelScan(); // g_log->TraceInfo(_(u8"中断模具拼接测试").c_str()); // } // } // ImGui::PopItemWidth(); // ImGui::TreePop(); // } // map* paramMap = jfp->GetMetaData()->GetParameterMap(); // char paramNameBuffer[50]; // int paramIndex = 0; // for (set::iterator it = part->paramSet.begin(); it != part->paramSet.end(); it++) // { // JobMetaData::ParameterSet* param = (*it); // if (param != NULL) { // sprintf_s(paramNameBuffer, sizeof(paramNameBuffer), u8"%s_%d", StringHelper::AsciiToUtf8(param->set_type).c_str(), paramIndex); // if (ImGui::TreeNode(paramNameBuffer)) // { // ImGui::Text(_(u8"扫描速度").c_str()); // ImGui::SameLine(); // sprintf_s(buffer, sizeof(buffer), "%d%s_speed", param->id, param->set_type.c_str()); // ImGui::PushID(buffer); // ImGui::PushItemWidth(80.0f); // if (ImGui::InputFloatEx("mm/s", ¶m->laser_speed, 0, 0, "%.4f", ImGuiInputTextFlags_EnterReturnsTrue, &m_Controller->m_ParamLimitCfg->m_ScanSpeedMin, &m_Controller->m_ParamLimitCfg->m_ScanSpeedMax)) { // if (jfp->m_SetParamType == JobFileProcessor::SameParam) { // for (map::iterator it = paramMap->begin(); it != paramMap->end(); it++) { // JobMetaData::ParameterSet* tempset = it->second; // if (tempset->set_type == param->set_type) { // tempset->laser_speed = param->laser_speed; // } // } // g_log->TraceInfo(_(u8"修改所有零件的%s扫描速度为:%.4f").c_str(), param->set_type, param->laser_speed); // } // else if (jfp->m_SetParamType == JobFileProcessor::AllParam) { // for (map::iterator it = paramMap->begin(); it != paramMap->end(); it++) { // JobMetaData::ParameterSet* tempset = it->second; // tempset->laser_speed = param->laser_speed; // } // g_log->TraceInfo(_(u8"修改所有%s的扫描速度为:%.4f").c_str(), param->set_type.c_str(), param->laser_speed); // } // else { // g_log->TraceInfo(_(u8"修改零件%d的%s扫描速度为:%.4f").c_str(), part->id, param->set_type.c_str(), param->laser_speed); // } // } // ImGui::PopItemWidth(); // ImGui::PopID(); // ImGui::Text(_(u8"扫描功率").c_str()); // ImGui::SameLine(); // sprintf_s(buffer, sizeof(buffer), "%d%s_power", param->id, param->set_type.c_str()); // ImGui::PushID(buffer); // ImGui::PushItemWidth(80.0f); // if (ImGui::InputFloatEx("%", ¶m->laser_set->laser_power, 0, 0, "%.4f", ImGuiInputTextFlags_EnterReturnsTrue, &m_Controller->m_ParamLimitCfg->m_ScanPowerMin, &m_Controller->m_ParamLimitCfg->m_ScanPowerMax)) { // param->laser_set->laser_real_power = param->laser_set->laser_power; // if (jfp->m_SetParamType == JobFileProcessor::SameParam) { // for (map::iterator it = paramMap->begin(); it != paramMap->end(); it++) { // JobMetaData::ParameterSet* tempset = it->second; // if (tempset->set_type == param->set_type) { // tempset->laser_set->laser_power = param->laser_set->laser_power; // tempset->laser_set->laser_real_power = param->laser_set->laser_real_power; // } // } // g_log->TraceInfo(_(u8"修改所有零件的%s扫描功率为:%.4f").c_str(), param->set_type.c_str(), param->laser_set->laser_power); // } // else if (jfp->m_SetParamType == JobFileProcessor::AllParam) { // for (map::iterator it = paramMap->begin(); it != paramMap->end(); it++) { // JobMetaData::ParameterSet* tempset = it->second; // tempset->laser_set->laser_power = param->laser_set->laser_power; // tempset->laser_set->laser_real_power = param->laser_set->laser_real_power; // } // g_log->TraceInfo(_(u8"修改所有%s的扫描功率为:%.4f").c_str(), param->set_type.c_str(), param->laser_set->laser_power); // } // else { // g_log->TraceInfo(_(u8"修改零件%d的%s扫描功率为:%.4f").c_str(), part->id, param->set_type.c_str(), param->laser_set->laser_power); // } // } // ImGui::PopItemWidth(); // ImGui::PopID(); // ImGui::Text(_(u8"光斑直径").c_str()); // ImGui::SameLine(); // sprintf_s(buffer, sizeof(buffer), "%d%s_diameter", param->id, param->set_type.c_str()); // ImGui::PushID(buffer); // ImGui::PushItemWidth(80.0f); // if (ImGui::InputFloatEx("mm", ¶m->laser_set->laser_diameter, 0, 0, "%.4f", ImGuiInputTextFlags_EnterReturnsTrue, &m_Controller->m_ParamLimitCfg->m_ScanDiameterMin, &m_Controller->m_ParamLimitCfg->m_ScanDiameterMax)) { // if (jfp->m_SetParamType == JobFileProcessor::SameParam) { // for (map::iterator it = paramMap->begin(); it != paramMap->end(); it++) { // JobMetaData::ParameterSet* tempset = it->second; // if (tempset->set_type == param->set_type) { // tempset->laser_set->laser_diameter = param->laser_set->laser_diameter; // } // } // g_log->TraceInfo(_(u8"修改所有零件的%s光斑直径为:%.4f").c_str(), param->set_type.c_str(), param->laser_set->laser_diameter); // } // else if (jfp->m_SetParamType == JobFileProcessor::AllParam) { // for (map::iterator it = paramMap->begin(); it != paramMap->end(); it++) { // JobMetaData::ParameterSet* tempset = it->second; // tempset->laser_set->laser_diameter = param->laser_set->laser_diameter; // } // g_log->TraceInfo(_(u8"修改所有%s的光斑直径为:%.4f").c_str(), param->set_type.c_str(), param->laser_set->laser_diameter); // } // else { // g_log->TraceInfo(_(u8"修改零件%d的%s光斑直径为:%.4f").c_str(), part->id, param->set_type.c_str(), param->laser_set->laser_diameter); // } // } // ImGui::PopItemWidth(); // ImGui::PopID(); // ImGui::TreePop(); // } // paramIndex++; // } // } // } // ImGui::EndGroup(); // ImGui::TreePop(); // } // if (ImGui::IsItemHovered()) // { // m_PrevRenderer->GetBPData()->SetSelected(partIndex); // } // else if (m_PrevRenderer->GetBPData()->GetSelected() == partIndex) // { // m_PrevRenderer->GetBPData()->Diselected(); // } // } // // ImGui::TreePop(); // } // if (ImGui::TreeNode(_(u8"图层浏览").c_str())) { // unsigned int layercount = jfp->GetLayerCount(); // static int selected_layer = 0; // if (fast_preview && m_RenderToPreview) // { // static bool layer_changed = false; // static uint64_t tick = 0; // if (ImGui::VSliderInt("##vInt", ImVec2(18, ImGui::GetCurrentWindowRead()->ContentRegionRect.GetHeight() - (ImGui::GetCursorScreenPos().y - ImGui::GetCurrentWindowRead()->ContentRegionRect.GetTL().y)), &selected_layer, 0, jfp->GetLayerCount(), "")) // { // layer_changed = true; // tick = GetTickCount64(); // } // if (ImGui::IsItemHovered()) // { // ImGui::SetTooltip(_(u8"第%d层").c_str(), selected_layer + 1); // ImGuiIO& io = ImGui::GetIO(); // if (io.MouseWheel != 0.0f) // { // selected_layer += io.MouseWheel; // if (selected_layer < 0)selected_layer = 0; // if (selected_layer > layercount - 1)selected_layer = layercount - 1; // layer_changed = true; // } // } // if (layer_changed && (GetTickCount64() - tick > 5)) // { // m_PrevRenderer->SetPreviewLayer(selected_layer); // layer_changed = false; // } // ImGui::SameLine(); // } // ImGui::BeginChild("layer_preview"); // char buffer[20]; // ImGui::BeginGroup(); // ImGuiListClipper clipper(layercount); // unsigned int selectIndex = 0; // JobMetaData::Layer* layer; // if (m_RenderToPreview) { // layer = m_PrevRenderer->GetJob()->GetMetaData()->GetPreviewLayer(); // if (layer)selectIndex = layer->index; // if (ImGui::IsWindowFocused() && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) // { // if (selectIndex < layercount - 1) { // selectIndex++; // m_PrevRenderer->SetPreviewLayer(selectIndex); // } // } // if (ImGui::IsWindowFocused() && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) // { // if (selectIndex > 0) { // selectIndex--; // m_PrevRenderer->SetPreviewLayer(selectIndex); // } // } // } // else { // layer = jfp->GetMetaData()->GetCurrentLayer(); // if (layer)selectIndex = layer->index; // m_Renderer->SetCurrentLayer(selectIndex); // } // while (clipper.Step()) { // for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { // if (jfp->GetStartIndex() == i) // sprintf_s(buffer, sizeof(buffer), _(u8"*层%u").c_str(), i + 1); // else sprintf_s(buffer, sizeof(buffer), _(u8"层%u").c_str(), i + 1); // const bool item_selected = (i == selectIndex); // if (ImGui::Selectable(buffer, item_selected)) { // if (m_RenderToPreview) // { // m_PrevRenderer->SetPreviewLayer(i); // selected_layer = i; // } // } // if (BaseCtrl::IsStart() && !m_RenderToPreview) { // ImGui::SetScrollY(selectIndex * clipper.ItemsHeight); // } // if (ImGui::IsItemHovered()) // { // MetaData::Layer* tmp_layer = m_PrevRenderer->GetJob()->GetLayer(i); // ImGui::BeginTooltip(); // ImGui::Text(_(u8"层厚(μm):%u").c_str(), tmp_layer->layer_thickness); // ImGui::Text(_(u8"供粉量(μm):%u").c_str(), tmp_layer->powder); // ImGui::EndTooltip(); // } // if (item_selected && m_RenderToPreview) { // if (m_Controller->m_ScannerCtrl->IsStandBy() || (g_Admin > USER)) { // if (ImGui::BeginPopupContextItem(buffer)) // { // if (m_Controller->m_ScannerCtrl->IsStandBy()) { // if (ImGui::Button(_(u8"设为开始").c_str())) { // jfp->SetStartIndex(selectIndex); // g_SystemInfo->m_StateBean.remainMil = jfp->GetMetaData()->GetRemainTime(); // g_log->TraceKeyInfo(_(u8"设定开始层:%u").c_str(), selectIndex + 1); // ImGui::CloseCurrentPopup(); // } // ImGui::SameLine(0, 10); // if (m_Controller->m_ScannerCtrl->IsTestLayerEnable()) { // if (ImGui::Button(_(u8"红光测试").c_str())) { // vector* laserCfg = ConfigManager::Instance()->GetMatchScannerControlCfg(); // for (size_t cIndex = 0; cIndex < laserCfg->size(); cIndex++) { // ScannerControlCfg* lcfg = (*laserCfg)[cIndex]; // if (lcfg->m_LaserEnable && lcfg->m_LaserEnable->IsActive()) { // lcfg->m_LaserEnable->SetActive(false); // } // if (lcfg->m_LaserRed && !lcfg->m_LaserRed->IsActive()) { // lcfg->m_LaserRed->SetActive(true); // } // } // ImGui::CloseCurrentPopup(); // m_Controller->m_ScannerCtrl->TestLayer(); // g_log->TraceInfo(_(u8"执行红光测试").c_str()); // } // } // else { // if (ImGui::Button(_(u8"停止红光测试").c_str())) { // vector* laserCfg = ConfigManager::Instance()->GetMatchScannerControlCfg(); // for (size_t lrIndex = 0; lrIndex < laserCfg->size(); lrIndex++) { // ScannerControlCfg* lcfg = (*laserCfg)[lrIndex]; // if (lcfg->m_LaserRed && lcfg->m_LaserRed->IsActive()) { // lcfg->m_LaserRed->SetActive(false); // } // } // ImGui::CloseCurrentPopup(); // m_Controller->m_ScannerCtrl->StopRedTest(); // g_log->TraceInfo(_(u8"终止红光测试").c_str()); // } // } // } // ImGui::Separator(); // //ImGui::BeginChild("layer_param", ImVec2(-1, g_Admin == USER ? 105 : 135), true, ImGuiWindowFlags_NoScrollWithMouse); // ImGui::PushItemWidth(80); // if (m_Controller->m_ScannerCtrl->IsStandBy() && g_Admin > USER) { // ImGui::Text(_(u8"层厚(μm):").c_str()); // ImGui::SameLine(0, 10); // ImGui::PushID("LayerThickInput"); // //double layer_thickness = layer->layer_thickness * 1000; // if (ImGui::InputScalarExFix("", ImGuiDataType_U32, &layer->layer_thickness, 0, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue, &m_Controller->m_ParamLimitCfg->m_LayerThicknessMin, &m_Controller->m_ParamLimitCfg->m_LayerThicknessMax)) // { // //layer->layer_thickness = layer_thickness / 1000; // if (jfp->IsLayerInherit()) // { // for (unsigned int layer_idx = i + 1; layer_idx < layercount; layer_idx++) // { // jfp->GetLayer(layer_idx)->layer_thickness = layer->layer_thickness; // m_PrevRenderer->GetJob()->GetLayer(layer_idx)->layer_thickness = layer->layer_thickness; // } // g_log->TraceKeyInfo(_(u8"修改第%d层开始的所有层厚为%u").c_str(), i + 1, layer->layer_thickness); // } // else { // g_log->TraceKeyInfo(_(u8"修改第%d层层厚为%u").c_str(), i + 1, layer->layer_thickness); // } // } // //ImGui::SameLine(); // //ImGui::Text("(%u - %u)", m_Controller->m_ParamLimitCfg->m_LayerThicknessMin, m_Controller->m_ParamLimitCfg->m_LayerThicknessMax); // ImGui::PopID(); // } // if (g_Admin > USER) { // ImGui::Text(_(u8"供粉量(μm):").c_str()); // ImGui::SameLine(0, 10); // ImGui::PushID("SupplyPowderInput"); // //double powder = layer->powder * 1000.0f; // if (ImGui::InputScalarExFix("", ImGuiDataType_U32, &layer->powder, 0, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue, &m_Controller->m_ParamLimitCfg->m_SupplyPowderMin, &m_Controller->m_ParamLimitCfg->m_SupplyPowderMax)) // { // //layer->powder = powder / 1000.0f; // if (jfp->IsLayerInherit()) // { // for (unsigned int layer_idx = i + 1; layer_idx < layercount; layer_idx++) // { // jfp->GetLayer(layer_idx)->powder = layer->powder; // m_PrevRenderer->GetJob()->GetLayer(layer_idx)->powder = layer->powder; // } // g_log->TraceKeyInfo(_(u8"修改第%d层开始的所有供粉量为%u").c_str(), i + 1, layer->powder); // } // else { // g_log->TraceKeyInfo(_(u8"修改第%d层供粉量为%u").c_str(), i + 1, layer->powder); // } // unsigned int judgeLevel = 0; // layer = jfp->GetMetaData()->GetCurrentLayer(); // unsigned int judgeIndex = 0; // if (layer)judgeIndex = layer->index; // //if (!jfp->JudgePowder(abs(m_Controller->m_GTSController->Powder()->GetState()->realPos), judgeIndex, judgeLevel)) { // // ImGui::CloseCurrentPopup(); // // char judgeBuffer[256]; // // sprintf_s(judgeBuffer, sizeof(judgeBuffer), _(u8"供粉不足,目前粉料只能打印到第%u层").c_str(), judgeLevel); // // g_Toast->AddToast(new ToastBean(judgeBuffer, 5000, Toast::COLOR_ORANGE)); // //} // } // ImGui::PopID(); // } // if (m_Controller->m_ScannerCtrl->IsStandBy() && g_Admin != USER) { // ImGui::Text(_(u8"扫描次数:").c_str()); // ImGui::SameLine(0, 10); // ImGui::PushID("ScanTimesInput"); // int scan_times = layer->scan_times; // if (ImGui::InputScalarExFix("", ImGuiDataType_S32, &scan_times, 0, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue, &m_Controller->m_ParamLimitCfg->m_ScanTimesMin, &m_Controller->m_ParamLimitCfg->m_ScanTimesMax)) // { // layer->scan_times = scan_times; // if (jfp->IsLayerInherit()) // { // for (unsigned int layer_idx = i + 1; layer_idx < layercount; layer_idx++) // { // jfp->GetLayer(layer_idx)->scan_times = layer->scan_times; // m_PrevRenderer->GetJob()->GetLayer(layer_idx)->scan_times = layer->scan_times; // } // g_log->TraceKeyInfo(_(u8"修改第%d层扫描次数为%u").c_str(), i + 1, layer->scan_times); // } // else { // g_log->TraceKeyInfo(_(u8"修改第%d层开始的所有扫描次数为%u").c_str(), i + 1, layer->scan_times); // } // } // ImGui::PopID(); // } // bool layer_inherit = jfp->IsLayerInherit(); // ImGui::Text(_(u8"层间继承").c_str()); ImGui::SameLine(); // ImGui::SameLine(0, 10); // if (ImGui::Checkbox(" ", &layer_inherit)) // jfp->SetLayerInherit(layer_inherit); // ImGui::PopItemWidth(); // // ImGui::EndChild(); // ImGui::EndPopup(); // } // } // } // } // } // ImGui::EndGroup(); // ImGui::EndChild(); // ImGui::TreePop(); // } //} //LeaveCriticalSection(&m_Controller->jc.m_cs); ImGui::EndChild(); ImGui::PopStyleVar(); // Jobs List End ImGui::End(); } void UIWin::DrawIO() { if (!m_IOWinShow)return; //if (!m_UIController.m_ScannerCtrl->IsStandBy() && g_Admin == USER)return; m_Controller->m_Machine->DrawIO(&m_IOWinShow); } void UIWin::DrawPowder(){ if (!m_powderWinShow)return; //if (!m_Controller->m_ScannerCtrl->IsStandBy() && g_Admin == USER)return; m_Controller->m_Machine->DrawPowderCtrl(&m_powderWinShow); } 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(); 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()); }