添加客户端功能

This commit is contained in:
wangxx1809 2024-04-02 17:45:03 +08:00
parent 15bf52f751
commit 7413c55df5
24 changed files with 681 additions and 486 deletions

View File

@ -3,12 +3,10 @@
DataHandle::DataHandle()
: m_dataCallBack(nullptr)
, m_streamClient(nullptr){
}
DataHandle::~DataHandle() {
delete m_streamClient;
m_streamClient = nullptr;
DELP(m_streamClient);
}
@ -19,8 +17,44 @@ void DataHandle::Init() {
}
void DataHandle::DataCallBackProc(void* pthis, const ReadData& msg) {
DataHandle* p = (DataHandle*)pthis;
std::istringstream issKey(msg.nameKey),issVal(msg.strValue);
string key, value;
if (msg.dataType == TIMEDATA) {
SysParam::Lck();
while (issKey >> key && issVal >> value) {
size_t pos = value.find("_");
if (pos == string::npos || SysParam::m_sysParamMp.find(key) == SysParam::m_sysParamMp.end()) continue;
DATATYPE valType = (DATATYPE)atoi(value.substr(pos + 1).c_str()); //值类型
string val = value.substr(0, pos); //值
DValue& param = SysParam::m_sysParamMp.at(key);
switch (valType) {
case iBOOL:
param.sysParamB->SetValue((bool)atoi(val.c_str()));
break;
case iSHORT:
param.sysParamW->SetValue((short)atoi(val.c_str()));
break;
//case iUSHORT:
// param.sysParamB->SetValue((bool)atoi(val.c_str()));
// break;
case iINT:
param.sysParamI->SetValue(atoi(val.c_str()));
break;
//case iUINT:
// param.sysParamB->SetValue((bool)atoi(val.c_str()));
// break;
case iFLOAT:
param.sysParamB->SetValue(atof(val.c_str()));
break;
default: break;
}
}
SysParam::UnLck();
}
}

View File

@ -1,19 +1,45 @@
#pragma once
#include <string>
#include "StreamClient.h"
//#include "../Machine/Machine.h"
#include "../Machine/Machine.h"
#include "../UI/UIBean.h"
class DataHandle{
typedef void (*DataCallBack)(void* pthis, const ReadData& msg);
public:
DataHandle();
~DataHandle();
static DataHandle* Instance() {
static DataHandle dh;
return &dh;
}
void Init();
static void DataCallBackProc(void* pthis, const ReadData& msg);
//void SetPushMsg(WriteData* msg) {
// if (m_streamClient) {
// m_streamClient->SetPushMsg(msg);
// }
//}
void SetPushMsg(WRITETYPE dataType,const string& nameKey,const string& strValue,DATATYPE valueType) {
if (m_streamClient) {
WriteData* msg = new WriteData();
msg->dataType = dataType;
msg->nameKey = nameKey;
msg->strValue = strValue;
msg->valueType = valueType;
m_streamClient->SetPushMsg(msg);
}
}
private:
DataHandle();
virtual ~DataHandle();
//DataHandle(const DataHandle& d) = delete;
//DataHandle& operator = (const DataHandle& d) = delete;
private:
DataCallBack m_dataCallBack;
StreamClient* m_streamClient;
};

View File

@ -17,6 +17,10 @@ StreamClient::~StreamClient() {
m_readQuitFlag = true;
m_writeQuitFlag = true;
if (m_connectTd.joinable()) {
m_connectTd.join();
}
}
void StreamClient::Init() {

View File

@ -16,7 +16,7 @@ using stream::ResponseInfo;
enum READTYPE {
ALARM = 0, //报警
RESPOND, //回应
TIMEDATA //定时数据
TIMEDATA //定时数据 一次大概50个左右
};
enum DATATYPE {
@ -31,9 +31,11 @@ enum DATATYPE {
struct ReadData {
READTYPE dataType;
bool result;
std::string nameKey; //参数key
std::string strValue; //value
std::string nameKey; //参数key 空格隔开
std::string strValue; //value 空格隔开
DATATYPE valueType; //数据类型
};

View File

@ -3,6 +3,7 @@
//#include "CoreCommunication.h"
std::map<std::string, DValue> SysParam::m_sysParamMp;
CRITICAL_SECTION SysParam::m_ValueCS;
SysParam::SysParam(int addr, int num, void* cc,const string& context, const std::string& code)
: /*PLCCommand(cc),*/
m_Addr(addr)
@ -10,7 +11,7 @@ SysParam::SysParam(int addr, int num, void* cc,const string& context, const std:
, m_context(context)
, m_code(code)
{
InitializeCriticalSection(&m_ValueCS);
}
SysParam::~SysParam()
@ -21,6 +22,8 @@ SysParam::~SysParam()
++item;
}
m_sysParamMp.clear();
DeleteCriticalSection(&m_ValueCS);
}
SysParam::SysParam(SysParam* sp) /*:PLCCommand(sp->m_Receiver)*/

View File

@ -1,4 +1,5 @@
#pragma once
#include "../stdafx.h"
#include <queue>
#include <shared_mutex>
#include <condition_variable>
@ -19,7 +20,12 @@ public:
int GetAddr() { return m_Addr; }
string GetCode() { return m_code; }
static void Lck() {
EnterCriticalSection(&m_ValueCS);
}
static void UnLck() {
LeaveCriticalSection(&m_ValueCS);
}
static std::map<std::string, DValue > m_sysParamMp; //记录
protected:
int m_Addr;
@ -28,6 +34,8 @@ protected:
string m_context2; //名称内容2
string m_code; //key编码
string m_code2; //key编码2
static CRITICAL_SECTION m_ValueCS;
//S7Command* m_CtrlCommand;
//PLCReveiver* m_cc;
@ -174,6 +182,7 @@ struct DValue {
if (sysParamF) return sysParamF;
if (sysParamFU) return sysParamFU;
if (sysParamWU) return sysParamWU;
return nullptr;
}
};
@ -689,7 +698,7 @@ class StateCtrlWrapper {
public:
StateCtrlWrapper() {}
~StateCtrlWrapper() {}
void Init(void* cc);
void Init(void* cc = nullptr);
public:
SysParamBool* m_MoldMainServoOn; //打印主轴伺服ON_RW
SysParamBool* m_MoldMainServoHomeIndexOn; //打印主轴伺服成立原点_RW

View File

@ -203,7 +203,7 @@
<ClCompile Include="Render\Renderer.cpp" />
<ClCompile Include="SystemInfo.cpp" />
<ClCompile Include="Toast.cpp" />
<ClCompile Include="UI\Controler.cpp" />
<ClCompile Include="UI\Controller.cpp" />
<ClCompile Include="UI\TextureBean.cpp" />
<ClCompile Include="UI\UIWin.cpp" />
<ClCompile Include="utils\CryptHelper.cpp" />
@ -299,7 +299,7 @@
<ClInclude Include="stdafx.h" />
<ClInclude Include="SystemInfo.h" />
<ClInclude Include="Toast.h" />
<ClInclude Include="UI\Controler.h" />
<ClInclude Include="UI\Controller.h" />
<ClInclude Include="UI\TextureBean.h" />
<ClInclude Include="UI\UIBean.h" />
<ClInclude Include="UI\UIWin.h" />

View File

@ -288,7 +288,7 @@
<ClCompile Include="Render\Renderer.cpp">
<Filter>Renderer</Filter>
</ClCompile>
<ClCompile Include="UI\Controler.cpp">
<ClCompile Include="UI\Controller.cpp">
<Filter>UI</Filter>
</ClCompile>
</ItemGroup>
@ -570,7 +570,7 @@
<ClInclude Include="Render\Renderer.h">
<Filter>Renderer</Filter>
</ClInclude>
<ClInclude Include="UI\Controler.h">
<ClInclude Include="UI\Controller.h">
<Filter>UI</Filter>
</ClInclude>
</ItemGroup>

View File

@ -1,31 +0,0 @@
//#pragma once
//
//#include "../Machine/Machine.h"
//#include "../PLC/MachineCtrl.h"
//#include "../PLC/CoreCommunication.h"
//#include "../Config/ConfigManager.h"
//#include "../Communication/ComServer.h"
//#include "../remote/RemoteClient.h"
//
//class Controler {
//public:
// Controler();
// ~Controler();
//
// void Init();
//
//
//private:
// Machine* m_Machine;
// CoreCommunication* m_CoreCommunication;
// PLCAxis* m_Axis;
// StateCtrlWrapper* m_StateCtrlWrapper;
// SysParamWrapper* m_SysParamWrapper;
// AxisRecordWrapper* m_AxisRecordWrapper;
// SignalStateWrapper* m_SignalStateWrapper;
//
// MachineCtrl* m_MachineCtrl;
// RemoteClient* m_RemoteClient;
// ComServer* m_ComServer;
//
//};

38
PrintC/UI/Controller.cpp Normal file
View File

@ -0,0 +1,38 @@
#include "Controller.h"
Controller::Controller()
: m_Machine(nullptr)
//, m_Axis(nullptr)
, m_StateCtrlWrapper(nullptr)
, m_SysParamWrapper(nullptr)
, m_AxisRecordWrapper(nullptr)
, m_SignalStateWrapper(nullptr) {
}
Controller::~Controller() {
//DELP(m_Axis);
DELP(m_StateCtrlWrapper);
DELP(m_SysParamWrapper);
DELP(m_AxisRecordWrapper);
DELP(m_SignalStateWrapper);
DELP(m_Machine);
}
void Controller::Init() {
m_StateCtrlWrapper = new StateCtrlWrapper();
m_SysParamWrapper = new SysParamWrapper();
m_AxisRecordWrapper = new AxisRecordWrapper();
m_SignalStateWrapper = new SignalStateWrapper();
m_Machine = Machine::CreateInstance(MachineTypeCfg::MachineTypeId::HBD_1000);
m_Machine->SetAxisAndSignal(m_SysParamWrapper, m_AxisRecordWrapper);
}

33
PrintC/UI/Controller.h Normal file
View File

@ -0,0 +1,33 @@
#pragma once
#include "../stdafx.h"
#include "../Machine/Machine.h"
#include "UIBean.h"
//#include "../PLC/MachineCtrl.h"
//#include "../PLC/CoreCommunication.h"
//#include "../Config/ConfigManager.h"
//#include "../Communication/ComServer.h"
class Controller {
public:
Controller();
~Controller();
void Init();
public:
Machine* m_Machine;
//PLCAxis* m_Axis;
StateCtrlWrapper* m_StateCtrlWrapper;
SysParamWrapper* m_SysParamWrapper;
AxisRecordWrapper* m_AxisRecordWrapper;
SignalStateWrapper* m_SignalStateWrapper;
SystemAssist m_SystemAssist;
//MachineCtrl* m_MachineCtrl;
//RemoteClient* m_RemoteClient;
//ComServer* m_ComServer;
};

View File

@ -255,8 +255,8 @@ struct LogAssist {
int64_t selected_sp_id;
explicit LogAssist() {
time_t t = time(nullptr);
selectBeginTime = *localtime(&t);
selectEndTime = *localtime(&t);
/*selectBeginTime = *localtime(&t);*/ localtime_s(&selectBeginTime, &t);
/*selectEndTime = *localtime(&t);*/ localtime_s(&selectEndTime, &t);
layer_selected_param = 0;
layer_selected_style = 0;
layer_selected_base = 0;

View File

@ -29,30 +29,37 @@
#include "../utils/CryptHelper.h"
#include "../utils/ImageHelper.h"
#include "../external/stb/stb_image.h"
UserType g_Admin;
UIWin::UIWin() {
UIWin::UIWin()
: m_TextureMap(nullptr){
}
UIWin::~UIWin() {
m_TextureMap = nullptr;
}
bool UIWin::Init()
{
m_TextureMap = &ChartletManager::GetInstance()->m_TextureMap;
//MetaData::InitTypeMap();
g_Admin = USER;
m_IsShowInitError = true;
//if (!m_UIController.Init())return false;
//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();
//GetVersion();
m_GLFWMon = glfwGetPrimaryMonitor();
m_GLFWMode = glfwGetVideoMode(m_GLFWMon);
glfwWindowHint(GLFW_RED_BITS, m_GLFWMode->redBits);
@ -63,7 +70,7 @@ bool UIWin::Init()
#ifdef _DEBUG
m_IsFullScreen = false;
#else
m_IsFullScreen = true;
m_IsFullScreen = false;
#endif
if (m_IsFullScreen) {
m_GLFWWin = glfwCreateWindow(m_GLFWMode->width, m_GLFWMode->height, "HBDSystem1000", NULL, NULL);
@ -79,7 +86,7 @@ bool UIWin::Init()
//if (ChartletManager::GetInstance()->HasIcoLogo())
{
int width = 0, height = 0, comp = 0;
//if (m_UIController.m_MachineCfg->m_I18NLang == "zh_CN")
//if (m_Controller.m_MachineCfg->m_I18NLang == "zh_CN")
//{
// TextureBean* l16 = ChartletManager::GetInstance()->m_AppLogo16;
// TextureBean* l32 = ChartletManager::GetInstance()->m_AppLogo32;
@ -111,20 +118,20 @@ bool UIWin::Init()
m_Renderer = new VLRenderer;
m_PrevRenderer->Init();
m_Renderer->Init();
//if (m_UIController.m_MachineCfg->m_PlatformShape == PS_SQUARE) {
//if (m_Controller.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_PrevRenderer->SetPlatfromSize(m_Controller.m_MachineCfg->m_PlatformLength, m_Controller.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);
//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_UIController.m_MachineCfg->m_PlatformLength);
// m_PrevRenderer->SetPlatfromSize(m_Controller.m_MachineCfg->m_PlatformLength);
// m_Renderer->SetPlatformShape(PS_ROUND);
// m_Renderer->SetPlatfromSize(m_UIController.m_MachineCfg->m_PlatformLength);
// m_Renderer->SetPlatfromSize(m_Controller.m_MachineCfg->m_PlatformLength);
//}
//m_UIController.m_Calibration->SetRender(m_Renderer, m_PrevRenderer);
//m_Controller.m_Calibration->SetRender(m_Renderer, m_PrevRenderer);
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
@ -165,7 +172,7 @@ bool UIWin::Init()
//ImGui_ImplOpenGL2_NewFrame();
m_IdleTime = 0;
InitializeCriticalSection(&m_IdleTimeCS);
//m_UIController.m_Calibration->Init();
//m_Controller.m_Calibration->Init();
#ifdef _DEBUG
g_Admin = ADMIN;
m_RegResult = Registration::REG_SUCCESS;
@ -179,388 +186,392 @@ bool UIWin::Init()
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();
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::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::Text(u8"汉邦HBDSystemL金属3D打印控制系统");
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(), 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_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::GetInstance()->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::SetupDockSpace(void)
{
@ -592,7 +603,7 @@ void UIWin::SetupDockSpace(void)
void UIWin::Display() {
//g_log->TraceInfo(_(u8"系统启动").c_str());
g_log->TraceInfo(_(u8"系统启动").c_str());
while (!glfwWindowShouldClose(m_GLFWWin))
{
//glfwPollEvents();
@ -602,7 +613,6 @@ void UIWin::Display() {
ImGui::NewFrame();
Draw();
SetupDockSpace();
ImGui::Render();
glfwGetFramebufferSize(m_GLFWWin, &m_winWidth, &m_winHeight);
@ -617,5 +627,5 @@ void UIWin::Display() {
glfwSwapBuffers(m_GLFWWin);
}
//g_log->TraceInfo(_(u8"系统退出").c_str());
g_log->TraceInfo(_(u8"系统退出").c_str());
}

View File

@ -4,9 +4,13 @@
#include "../external/imgui/glfw3.h"
#include "../external/imgui/imgui.h"
#include "../Render/Renderer.h"
//#include "UIController.h"
#include "Controller.h"
#include "UIBean.h"
#include "TextureBean.h"
#include "../Registration/Registration.h"
#include "../DataManage/DataHandle.h"
class UIWin {
public:
@ -17,9 +21,9 @@ public:
private:
void SetupDockSpace(void);
//void DrawTitleBar();
void DrawTitleBar();
void Draw();
//void DrawToolBar();
void DrawToolBar();
private:
GLFWwindow* m_GLFWWin;
GLFWwindow* m_SplashWin;
@ -57,7 +61,7 @@ private:
const int DEFAULT_WIN_WIDTH = 1440;
const int DEFAULT_WIN_HEIGHT = 900;
int STATUS_HEIGHT = 45;
//UIController m_UIController;
Controller m_Controller;
VLRenderer* m_Renderer;
VLRenderer* m_PrevRenderer;
@ -79,4 +83,6 @@ private:
bool m_IsShowInitError;
string m_ProductVersion;
map<string, TextureBean*>* m_TextureMap ;
};

View File

@ -1,4 +1,4 @@
/**************************************************************************************/
/**************************************************************************************/
/* */
/* Visualization Library */
/* http://visualizationlibrary.org */
@ -228,7 +228,7 @@ namespace vl
//! @param tangent [out] Returns the tangent vector of the vertices. This parameter is mandatory.
//! @param bitangent [out] Returns the bitangent vector of the vertics. This parameter can be NULL.
// Based on:
// Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”. Terathon Software 3D Graphics Library, 2001.
// Lengyel, Eric. 揅omputing Tangent Space Basis Vectors for an Arbitrary Mesh? Terathon Software 3D Graphics Library, 2001.
// http://www.terathon.com/code/tangent.html
static void computeTangentSpace(
u32 vert_count,

View File

@ -1,9 +1,9 @@
#pragma once
#include "stdafx.h"
//#include "config/bean/SystemBase.h"
#include "config/bean/SystemBase.h"
extern std::string g_AppPath;
extern std::string g_AppDisk;
extern bool g_isDebug;
extern uint32_t g_ScanSerial;
extern string g_gno;
//extern UserType g_Admin;
extern UserType g_Admin;

View File

@ -1,6 +1,6 @@
[Window][MainDockSpace]
Pos=0,40
Size=1920,995
Size=1536,779
Collapsed=0
[Window][Debug##Default]
@ -8,6 +8,21 @@ Pos=60,60
Size=400,400
Collapsed=0
[Docking][Data]
DockSpace ID=0x0204CCDD Window=0xDEDC5B90 Pos=0,40 Size=1920,995 CentralNode=1
[Window][Dear ImGui Demo]
Pos=848,106
Size=550,680
Collapsed=0
[Window][TitleBar]
Pos=0,0
Size=1536,40
Collapsed=0
[Window][toolbar]
Pos=0,70
Size=32,32
Collapsed=0
[Docking][Data]
DockSpace ID=0x0204CCDD Window=0xDEDC5B90 Pos=0,40 Size=1536,779 CentralNode=1

View File

@ -1,4 +1,4 @@
// Copyright 2016 Google Inc. All Rights Reserved.
// Copyright 2016 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -400,14 +400,13 @@ class civil_time {
preserves_data<U, T>* = nullptr) noexcept
: civil_time(ct.f_) {}
// Factories for the maximum/minimum representable civil_time.
static CONSTEXPR_F civil_time(max)() {
const auto max_year = (std::numeric_limits<std::int_least64_t>::max)();
return civil_time(max_year, 12, 31, 23, 59, 59);
static CONSTEXPR_F auto(max)() -> civil_time {
const auto max_year = (std::numeric_limits<std::int_least64_t>::max)();
return civil_time(max_year, 12, 31, 23, 59, 59);
}
static CONSTEXPR_F civil_time(min)() {
const auto min_year = (std::numeric_limits<std::int_least64_t>::min)();
return civil_time(min_year, 1, 1, 0, 0, 0);
static CONSTEXPR_F auto(min)() -> civil_time {
const auto min_year = (std::numeric_limits<std::int_least64_t>::min)();
return civil_time(min_year, 1, 1, 0, 0, 0);
}
// Field accessors. Note: All but year() return an int.

View File

@ -4,7 +4,6 @@
#include <thread>
#include <codecvt>
#include <grpcpp/grpcpp.h>
#include "DataManage/DataHandle.h"
#include "UI/UIWin.h"
#include "global.h"
#include "SystemInfo.h"
@ -17,7 +16,6 @@
#include "Machine/HBD1000.h"
#include "LanguageManager.h"
//UserType g_Admin;
string g_AppPath;
string g_AppDisk;
Logger* g_log;
@ -37,20 +35,36 @@ public:
~HBDSystem()
{
if (m_win != nullptr)delete m_win;
//ConfigManager::GetInstance()->SaveConfig();
DELP(g_log);
DELP(g_Toast);
DELP(m_controller);
DELP(m_win);
}
bool init(){
char szFilePath[MAX_PATH + 1] = { 0 };
GetModuleFileName(NULL, szFilePath, MAX_PATH);
(strrchr(szFilePath, '\\'))[1] = 0;
g_AppPath = szFilePath;
g_AppDisk = g_AppPath.substr(0, 2);
g_isDebug = false;
g_log = new Logger();
g_log->m_LogDao->Init();
g_SystemInfo = new SystemInfo();
g_Toast = new Toast();
g_Lang = (char*)"zh_CN";
m_controller = new Controller();
m_controller->Init();
DataHandle::Instance()->Init();
m_win = new UIWin();
if (!m_win->Init()) return false;
return true;
}
@ -59,37 +73,32 @@ public:
}
private:
UIWin* m_win;
Controller* m_controller;
};
int main(int argc, char** argv) {
printf("你好!" );
DataHandle* dataHandle = new DataHandle();
dataHandle->Init();
printf("你好fdfdfd");
HBDSystem* system = new HBDSystem();
system->init();
system->run();
return 0;
}
//int main(int argc, char** argv) {
// printf("你好!" );
//
// DataHandle* dataHandle = new DataHandle();
// dataHandle->Init();
// printf("你好fdfdfd");
// HBDSystem* system = new HBDSystem();
// system->init();
// system->run();
//
// return 0;
//
//}
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,_In_opt_ HINSTANCE hPrevInstance,_In_ LPWSTR lpCmdLine,_In_ int nCmdShow) {
cout << "dfdfdfdf" << endl;
printf("你好dfdfdf");
DataHandle* dataHandle = new DataHandle();
dataHandle->Init();
HBDSystem* system = new HBDSystem();
system->init();
system->run();
DELP(system);
return 0;
}

View File

@ -0,0 +1,23 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Dear ImGui Demo]
Pos=1049,244
Size=550,680
Collapsed=0
[Window][TitleBar]
Pos=0,0
Size=1536,40
Collapsed=0
[Window][MainDockSpace]
Pos=0,40
Size=1536,779
Collapsed=0
[Docking][Data]
DockSpace ID=0x0204CCDD Window=0xDEDC5B90 Pos=0,40 Size=1536,779 CentralNode=1

View File

@ -0,0 +1,15 @@
Visualization Library v2.0.0 [f32]
Dec 24 2020 - 15:48:43 - MSVC compiler [RELEASE] [x64]
--- Environment ---
VL_LOGFILE_PATH <not present>
VL_DATA_PATH <not present>
VL_VERBOSITY_LEVEL <not present>
VL_CHECK_GL_STATES <not present>
--- Global Settings ---
Log file = log.txt
Data path = ../data
Verbosity level = ERROR
Check OpenGL States = NO

Binary file not shown.

Binary file not shown.