From 6af67249a3fab3e11c7512519342dd5230c53c15 Mon Sep 17 00:00:00 2001 From: jiegeaiai Date: Fri, 3 Jan 2025 08:24:38 +0800 Subject: [PATCH] modify matlab --- Source/src/CMakeLists.txt | 5 +- Source/src/common/SpdLogger.cpp | 3 +- Source/src/scene/MeshManager.h | 3 +- Source/src/translations/Dyt_zh_CN.ts | 373 +++- Source/src/translations/Dyt_zh_CN_.ts | 1608 +++++++++++++++++ Source/src/ui/FramelessDelegateWin.cpp | 19 +- Source/src/ui/FramelessDelegateWin.h | 3 +- Source/src/ui/Layout/AddParamSetting.cpp | 55 +- Source/src/ui/Layout/AddParamSetting.h | 3 + Source/src/ui/Layout/AddParamSetting.ui | 5 + Source/src/ui/Layout/CodeEdtUI.cpp | 86 + Source/src/ui/Layout/CodeEdtUI.h | 24 + Source/src/ui/Layout/CodeEdtUI.ui | 28 + Source/src/ui/Layout/DockChildList.cpp | 24 +- .../src/ui/Layout/SignalIndicatorLampUI.cpp | 2 +- Source/src/ui/Layout/SyntaxHighlighter.cpp | 58 + Source/src/ui/Layout/SyntaxHighlighter.h | 24 + Source/src/ui/MainFrame.cpp | 3 +- Source/src/ui/MainWindow.cpp | 64 +- Source/src/ui/MainWindow.h | 7 +- Source/src/ui/Matlab/MatlabObject.cpp | 25 +- Source/src/ui/Matlab/MatlabObject.h | 2 +- Source/src/viewer/QtOsgViewWidget.cpp | 7 +- Source/src/viewer/QtOsgViewWidget.h | 3 + Source/src/workspace/WorkSpaceXMLParse.cpp | 2 +- 25 files changed, 2269 insertions(+), 167 deletions(-) create mode 100644 Source/src/translations/Dyt_zh_CN_.ts create mode 100644 Source/src/ui/Layout/CodeEdtUI.cpp create mode 100644 Source/src/ui/Layout/CodeEdtUI.h create mode 100644 Source/src/ui/Layout/CodeEdtUI.ui create mode 100644 Source/src/ui/Layout/SyntaxHighlighter.cpp create mode 100644 Source/src/ui/Layout/SyntaxHighlighter.h diff --git a/Source/src/CMakeLists.txt b/Source/src/CMakeLists.txt index 3a7f8a51..e87a18be 100644 --- a/Source/src/CMakeLists.txt +++ b/Source/src/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -SET(CMAKE_CXX_STANDARD 17) +SET(CMAKE_CXX_STANDARD 14) SET(CMAKE_CXX_STANDARD_REQUIRED ON) SET(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -169,6 +169,9 @@ target_link_libraries( Triton-MT-DLL libMatlabDataArray libMatlabEngine + libeng + libmx + libmat # python39 ) diff --git a/Source/src/common/SpdLogger.cpp b/Source/src/common/SpdLogger.cpp index a9f5a9c6..ca8a44af 100644 --- a/Source/src/common/SpdLogger.cpp +++ b/Source/src/common/SpdLogger.cpp @@ -37,11 +37,12 @@ static void LogMessageOutput(QtMsgType type, const QMessageLogContext& context, SpdLogger::SpdLogger(const std::string& filename, int flush) { constexpr std::size_t max_size = 1024 * 1024 * 10; constexpr std::size_t max_files = 5; + //auto tp = std::make_shared(1, 1); //std::shared_ptr logHander = spdlog::rotating_logger_mt(LoggerName, filename, max_size, max_files); auto file_sink = std::make_shared(filename, max_size, max_files); auto console_sink = std::make_shared(); - const char* pFormat = "[%Y-%m-%d %H:%M:%S.%e][%t][%^%l%$][%@]%v"; + std::string pFormat("[%Y-%m-%d %H:%M:%S.%e][%t][%^%l%$][%@]%v"); file_sink->set_pattern(pFormat); console_sink->set_pattern(pFormat); std::vector sinks; diff --git a/Source/src/scene/MeshManager.h b/Source/src/scene/MeshManager.h index d8b66eb6..27636bbd 100644 --- a/Source/src/scene/MeshManager.h +++ b/Source/src/scene/MeshManager.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -17,6 +18,6 @@ public: osg::MatrixTransform* ReadNode(const std::string& file); private: - using NodeMap = std::unordered_map>; + using NodeMap = std::map>; NodeMap nodes_; }; diff --git a/Source/src/translations/Dyt_zh_CN.ts b/Source/src/translations/Dyt_zh_CN.ts index 8452bdeb..908a6616 100644 --- a/Source/src/translations/Dyt_zh_CN.ts +++ b/Source/src/translations/Dyt_zh_CN.ts @@ -4,10 +4,25 @@ AddParamSetting - + ParamSetting + + + input param name + + + + + input param descript + + + + + input value + + AddParamSettingClass @@ -52,17 +67,22 @@ - + + 数据输入示例 + + + + 添加 - + 删除 - + 应用 @@ -90,6 +110,37 @@ + + CodeEdtUI + + + &file + + + + + &Import the template + + + + + &save + + + + + matlab editor + + + + + CodeEdtUIClass + + + CodeEdtUI + + + DYTChart @@ -221,6 +272,61 @@ + + DockChildList + + + Added a window + + + + + Central area + + + + + Left area + + + + + Upper area + + + + + Right area + + + + + Underneath the area + + + + + delete Window + + + + + + Move down + + + + + + Move up + + + + + add window + + + DockTitleBar @@ -260,29 +366,29 @@ FileManagerMenu - 文件管理 + Dyt (*.dyt) - + open dyt file - 打开dyt文件 + Dyt (*.dyt);;All files (*.*) - + save dyt file - 保存Dyt文件 + @@ -290,7 +396,7 @@ FitCurveChartView - + @@ -298,17 +404,17 @@ FitCurveDialog - + 2D Curve - + 2D(y(lg)) Curve - + @@ -316,22 +422,22 @@ Frame - + default - 默认 + silver - 银色 + blue - 苹果绿 + @@ -339,7 +445,7 @@ LayoutSettingUI - + @@ -347,37 +453,37 @@ Dyt - + file manager - 文件管理 + view manager - 视图管理 + plan manager - 想定管理 + dynamic display - 动态显示 + system manager - 系统管理 + play manager - 播放管理 + @@ -385,60 +491,156 @@ MainWindow - + - + model elements - 模型元素 + - + attribte - 属性 + - + Wave Curve - + - + Speed Curve - + - + 3D Curve - + - + + + Target number + + + + + + Signal-to-noise ratio + + + + + + Azimuth line of sight + + + + + + Pitch gaze angle + + + + + + azimuth + + + + + + Pitch angle + + + + + + attribute + + + + + + Doppler + + + + + + course + + + + + + Speed + + + + + + longitude + + + + + + latitude + + + + + + distance + + + + + + velocity + + + + + + Radial dimensions + + + + + + Target RCS + + + + Report Table - + - + Report - + - + Signal Indicator Lamp - + - + ParamSetting - - - - - name: 5year 0412 + name: 5year 0412 + + + + start: no start @@ -448,7 +650,7 @@ model elements - 模型元素 + @@ -456,17 +658,17 @@ ModelBrowserPannal - + 新建列 - + 新建项目 - + @@ -474,57 +676,57 @@ Release Track - 释放跟踪 + Add boke Entity - 添加BOKE实体 + Add lsjhqt Entity - 添加LSJHQT实体 + Add nimizi Entity - 添加NIMIZI实体 + Add tkdlj Entity - 添加TKDLJ实体 + Add jiaofan Entity - 添加JIAOFAN实体 + Add satellite Entity - 添加SATELLITE实体 + Track - 跟踪实体 + Add Mesh Component - 添加Mesh组件 + Add Path Component - 添加路径组件 + Delete - 删除 + @@ -532,7 +734,7 @@ PlanManagerMenu - + @@ -540,43 +742,43 @@ PlayManagerMenu - + play - 播放 + stop - 停止 + 000.000 - + 00000 - + x1 - + up - 加速 + down - 减速 + @@ -588,7 +790,7 @@ question - 询问 + @@ -600,13 +802,13 @@ has not workspace - 没有想定 + pause - 暂停 + @@ -614,29 +816,29 @@ attribute - 属性 + WorkSpace - + Entity - + ModelBase - + color base - + @@ -644,12 +846,12 @@ Open File - + All Files (*) - + @@ -1360,6 +1562,11 @@ Signal Indicator Lamp + + + light + + SurfaceDialog @@ -1425,7 +1632,7 @@ question - 询问 + diff --git a/Source/src/translations/Dyt_zh_CN_.ts b/Source/src/translations/Dyt_zh_CN_.ts new file mode 100644 index 00000000..62e24a18 --- /dev/null +++ b/Source/src/translations/Dyt_zh_CN_.ts @@ -0,0 +1,1608 @@ + + + + + AddParamSetting + + + ParamSetting + 参数设置 + + + + AddParamSettingClass + + + AddParamSetting + 添加参数设置 + + + + 参数名称 + 参数名称 + + + + 描述 + 描述 + + + + 数据类型 + 数据类型 + + + + 最大值 + 最大值 + + + + 最小值 + 最小值 + + + + 小数点有效位 + 小数点有效位 + + + + 初始值 + 初始值 + + + + 添加 + 添加 + + + + 删除 + 删除 + + + + 应用 + 应用 + + + + ChartPlotMenuClass + + + ChartPlotMenu + 绘图 + + + + 2D Curver + 2D画布 + + + + 2D(lg) Curver + 2D(lg)画布 + + + + 3D Curver + 3D画布 + + + + DYTChart + + + 2D Curve + 2D画布 + + + + 2D(lg) Curve + 2D(lg)画图 + + + + 3D Curve + 3D画布 + + + + DYTChartClass + + + Form + 窗口 + + + + x轴 + x轴 + + + + + + 选择数据列 + 选择数据列 + + + + y轴 + y轴 + + + + z轴 + z轴 + + + + 已添加的曲线 + 已经添加的曲线 + + + + 曲线名称 + 曲线名称 + + + + 颜色 + 颜色 + + + + + + + ... + ... + + + + x轴标题 + x轴标题 + + + + 绑定x轴数据 + 绑定x轴数据 + + + + y轴标题 + y轴数据 + + + + 绑定y轴数据 + 绑定y轴数据 + + + + z轴标题 + z轴标题 + + + + 绑定z轴数据 + 绑定z轴数据 + + + + y轴数据类型 + y轴数据类型 + + + + 一般 + 一般 + + + + 对数 + 对数 + + + + 删除 + 删除 + + + + 更新 + 更新 + + + + 添加 + 添加 + + + + DockTitleBar + + + DockTitleBar + 标题 + + + + DynamicDisplayMenu + + + DynamicDisplayMenu + 动态显示 + + + + EntityListDialog + + + ModelBrowserPannal + 模型浏览版 + + + + 新建列 + 新建列 + + + + 新建项目 + 新建项目 + + + + FileManagerMenu + + + FileManagerMenu + 文件管理 + + + + + Dyt (*.dyt) + Dyt (*.dyt) + + + + open dyt file + 打开Dyt文件 + + + + + Dyt (*.dyt);;All files (*.*) + + + + + save dyt file + 保存Dyt文件 + + + + FitCurveChartView + + + FitCurveChartView + 绘图视图 + + + + FitCurveDialog + + + FitCurveDialog + 绘图对话框 + + + + 2D Curve + 2D画布 + + + + 2D(y(lg)) Curve + 2D(y(lg))画布 + + + + FrameTitleBar + + + Frame + Frame + + + + default + 默认 + + + + silver + 银色 + + + + blue + 蓝色 + + + + LayoutSettingUIClass + + + LayoutSettingUI + + + + + MainFrame + + + Dyt + DYT + + + + file manager + 文件管理 + + + + view manager + 视图管理 + + + + plan manager + 想定管理 + + + + dynamic display + 动态显示 + + + + system manager + 系统管理 + + + + play manager + 播放管理 + + + + MainWindow + + + MainWindow + 主窗口 + + + + model elements + 模型元素 + + + + attribte + 属性 + + + + Wave Curve + 波浪曲线 + + + + Speed Curve + 速度曲线 + + + + 3D Curve + 3D曲线 + + + + Report Table + 报表 + + + + Report + 上报 + + + + Signal Indicator Lamp + 信号指示灯 + + + + ParamSetting + 参数设置 + + + + name: 5year 0412 + + + + + start: no start + + + + + ModelBrowser + + + model elements + 实体 + + + + ModelBrowserPannal + + + ModelBrowserPannal + 模型列表 + + + + 新建列 + + + + + 新建项目 + + + + + ModelTreeWidget + + + Release Track + 释放跟踪 + + + + Add boke Entity + 添加BOKE实体 + + + + Add lsjhqt Entity + 添加LSJHQT实体 + + + + Add nimizi Entity + 添加NIMIZI实体 + + + + Add tkdlj Entity + 添加TKDLJ实体 + + + + Add jiaofan Entity + 添加jiaofan实体 + + + + Add satellite Entity + 添加SATELLITE实体 + + + + Track + 跟踪 + + + + Add Mesh Component + 添加MESH组件 + + + + Add Path Component + 添加PATH组件 + + + + Delete + 删除 + + + + PlanManagerMenu + + + PlanManagerMenu + 想定管理 + + + + PlayManagerMenu + + + PlayManagerMenu + 播放管理 + + + + + play + 播放 + + + + stop + 停止 + + + + 000.000 + + + + + 00000 + + + + + x1 + + + + + up + 加速 + + + + down + 减速 + + + + + + + + + + + question + 询问 + + + + + + + + + + + has not workspace + 没有工作空间 + + + + + pause + 暂停 + + + + PropertyBrowser + + + attribute + 属性 + + + + + WorkSpace + 工作空间 + + + + + Entity + 实体 + + + + ModelBase + 模型 + + + + color base + 颜色 + + + + QFilePathEdit + + + Open File + 打开 + + + + All Files (*) + + + + + QObject + + + error + 磁盘我 + + + + the appliaction is crash + 程序出现了问题 + + + + List all tabs + + + + + Detach Group + + + + + Close Active Tab + + + + + Close Group + + + + + Close Tab + + + + + QtBoolEdit + + + + + True + + + + + + False + + + + + QtBoolPropertyManager + + + True + + + + + False + + + + + QtCharEdit + + + Clear Char + + + + + QtColorEditWidget + + + ... + + + + + QtColorPropertyManager + + + Red + + + + + Green + + + + + Blue + + + + + Alpha + + + + + QtConeWaveComponentManager + + + + ConeWaveComponent + + + + + Height + + + + + Radius + + + + + Color1 + + + + + Color2 + + + + + Color3 + + + + + QtCursorDatabase + + + Arrow + + + + + Up Arrow + + + + + Cross + + + + + Wait + + + + + IBeam + + + + + Size Vertical + + + + + Size Horizontal + + + + + Size Backslash + + + + + Size Slash + + + + + Size All + + + + + Blank + + + + + Split Vertical + + + + + Split Horizontal + + + + + Pointing Hand + + + + + Forbidden + + + + + Open Hand + + + + + Closed Hand + + + + + What's This + + + + + Busy + + + + + QtDashedLineComponentManager + + + + DashedLineComponent + + + + + Start + + + + + End + + + + + Radius + + + + + Color + + + + + QtEntityEditWidget + + + ... + + + + + QtEntityPropertyManager + + + Name + + + + + Transform + + + + + QtFontEditWidget + + + ... + + + + + Select Font + + + + + QtFontPropertyManager + + + Family + + + + + Point Size + + + + + Bold + + + + + Italic + + + + + Underline + + + + + Strikeout + + + + + Kerning + + + + + QtLocalePropertyManager + + + <Invalid> + + + + + %1, %2 + + + + + Language + + + + + Country + + + + + QtMeshComponetManager + + + + MeshComponent + + + + + Mesh + Mesh + + + + QtModelBasePropertyManager + + + Name + + + + + Description + + + + + Inflow + + + + + InnerBottomElevation + + + + + QtOsgViewWidget + + + notify + 通知 + + + + open dyt file failed + 打开dyt文件失败 + + + + QtPathComponentManager + + + + PathComponent + + + + + Path + + + + + QtPointFPropertyManager + + + (%1, %2) + + + + + X + + + + + Y + + + + + QtPointPropertyManager + + + (%1, %2) + + + + + X + + + + + Y + + + + + QtPropertyBrowserUtils + + + [%1, %2, %3] (%4) + + + + + [%1, %2] + + + + + [%1, %2, %3] + + + + + [%1, %2, %3] [%4, %5, %6] [%7, %8, %9] + + + + + QtRectFPropertyManager + + + [(%1, %2), %3 x %4] + + + + + X + + + + + Y + + + + + Width + + + + + Height + + + + + QtRectPropertyManager + + + [(%1, %2), %3 x %4] + + + + + X + + + + + Y + + + + + Width + + + + + Height + + + + + QtSizeFPropertyManager + + + %1 x %2 + + + + + Width + + + + + Height + + + + + QtSizePolicyPropertyManager + + + + <Invalid> + + + + + [%1, %2, %3, %4] + + + + + Horizontal Policy + + + + + Vertical Policy + + + + + Horizontal Stretch + + + + + Vertical Stretch + + + + + QtSizePropertyManager + + + %1 x %2 + + + + + Width + + + + + Height + + + + + QtTransfromEditWidget + + + ... + + + + + QtTransfromPropertyManager + + + Location + + + + + Rotation + + + + + Scale + + + + + QtTreePropertyBrowser + + + Property + + + + + Value + + + + + QtVec3PropertyManager + + + X + + + + + Y + + + + + Z + + + + + QtWorkspacePropertyManager + + + Name + + + + + Description + + + + + Timestep + + + + + SignalIndicatorLampUI + + + SignalIndicatorLampUI + + + + + Signal Indicator Lamp + 信号指示灯 + + + + SurfaceDialog + + + DSurfaceDialog + + + + + 3D Curve + 3D曲线 + + + + SystemManagerMenu + + + SystemManagerMenu + 系统管理 + + + + exit + 退出 + + + + restart + 重启 + + + + setting + 设置 + + + + setting restore + 设置重置 + + + + help + 帮助 + + + + license + 权限 + + + + logs + 日志 + + + + + clean logs + 清除日志 + + + + question + 询问 + + + + are you sure to exit + 确认退出 + + + + TargetListWgt + + + TargetListWgt + 目标列表权重 + + + + 停止更新 + + + + + 显示行数 + + + + + 前一页 + + + + + / + + + + + 后一页 + + + + + 跳转 + + + + + Data Table + 时间表 + + + + ViewManagerMenu + + + ViewManagerMenu + 视图管理 + + + + WorkSpaceDlg + + + New WorkSpace + 新空间 + + + + Name + 名称 + + + + 1 + + + + + Path + 路径 + + + + d:/hysw + + + + + ... + + + + + describe + 描述 + + + + Sure + 确认 + + + + Cancel + 取消 + + + + + warning + 警告 + + + + name or save path is empty, please check it + 名称或者保存路径为空,请核查 + + + + name is exits + 文件已经存在 + + + + save spaceWork directory + 保存空间目录 + + + + ads::CDockAreaTitleBar + + + Detach Area + + + + + Close Area + + + + + Close Other Areas + + + + + ads::CDockManager + + + Show View + + + + + ads::CDockWidgetTab + + + Detach + + + + + Close + + + + + Close Others + + + + + osgQOpenGLWidget + + + Screen %1 + + + + + Choose fullscreen target screen + + + + + Screen + + + + diff --git a/Source/src/ui/FramelessDelegateWin.cpp b/Source/src/ui/FramelessDelegateWin.cpp index a4f2fb68..06524d4c 100644 --- a/Source/src/ui/FramelessDelegateWin.cpp +++ b/Source/src/ui/FramelessDelegateWin.cpp @@ -48,10 +48,10 @@ inline void ExtendFrameIntoClientArea(QWindow* window, int left, int top, int ri #endif } -inline std::optional GetScreenNativeWorkRect(HWND hwnd) { +inline QRect GetScreenNativeWorkRect(HWND hwnd) { auto monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL); if (!monitor) - return std::nullopt; + return QRect(); MONITORINFO info; ::ZeroMemory(&info, sizeof(info)); info.cbSize = sizeof(info); @@ -94,21 +94,23 @@ bool FramelessDelegateWin::nativeEvent(const QByteArray & eventType, void* messa if (IsZoomed(msg->hwnd)) { CheckMonitorChanged(); auto rc = workRect_; - if (!rc) + if (!rc.isValid()) return false; - if (auto ret = DefWindowProcW(msg->hwnd, WM_NCCALCSIZE, msg->wParam, msg->lParam); ret) { + auto ret = DefWindowProcW(msg->hwnd, WM_NCCALCSIZE, msg->wParam, msg->lParam); + if ( ret) { *result = ret; return true; } NCCALCSIZE_PARAMS* ncParam = reinterpret_cast(msg->lParam); - ncParam->rgrc[0].top = rc->top(); - ncParam->rgrc[0].bottom = rc->bottom() + 1; + ncParam->rgrc[0].top = rc.top(); + ncParam->rgrc[0].bottom = rc.bottom() + 1; *result = 0; return true; } else { const auto clientRect = reinterpret_cast(msg->lParam); const auto before = *clientRect; - if (auto ret = DefWindowProcW(msg->hwnd, WM_NCCALCSIZE, msg->wParam, msg->lParam); ret) { + auto ret = DefWindowProcW(msg->hwnd, WM_NCCALCSIZE, msg->wParam, msg->lParam); + if ( ret) { *result = ret; return true; } @@ -276,7 +278,8 @@ void FramelessDelegateWin::CheckMonitorChanged() { auto newMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL); if (newMonitor != monitor_) { monitor_ = newMonitor; - if (auto ret = GetScreenNativeWorkRect(hwnd); ret) + auto ret = GetScreenNativeWorkRect(hwnd); + if (!ret.isValid()) workRect_ = ret; } } diff --git a/Source/src/ui/FramelessDelegateWin.h b/Source/src/ui/FramelessDelegateWin.h index 69d0208b..f84aa5c2 100644 --- a/Source/src/ui/FramelessDelegateWin.h +++ b/Source/src/ui/FramelessDelegateWin.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include "FramelessDelegate.h" @@ -43,7 +42,7 @@ private: private: bool firstShow_{ true }; - std::optional workRect_; + QRect workRect_; HMONITOR monitor_{ nullptr }; WINDOWPLACEMENT wndPlaceMent_{ 0, 0, 0, {0, 0}, {0, 0}, {0, 0, 0, 0} }; }; \ No newline at end of file diff --git a/Source/src/ui/Layout/AddParamSetting.cpp b/Source/src/ui/Layout/AddParamSetting.cpp index 9b4d7850..b29d14b5 100644 --- a/Source/src/ui/Layout/AddParamSetting.cpp +++ b/Source/src/ui/Layout/AddParamSetting.cpp @@ -12,6 +12,8 @@ #include "python/PythonModule.h" + + AddParamSetting::AddParamSetting(const QString& strDir, QWidget* parent) : QWidget(parent) { @@ -19,6 +21,16 @@ AddParamSetting::AddParamSetting(const QString& strDir, QWidget* parent) setWindowFlags(/*Qt::FramelessWindowHint | */Qt::Window); + listType << "String" << "Int" << "Double" << "Int[]" << "Double[]" << "String[]" << "a+bi"; + + mapDataDes["String"] = "Value"; + mapDataDes["Int"] = "1"; + mapDataDes["Double"] = "1.0"; + mapDataDes["Int[]"] = u8"һά[1,2,3,4,5....]ά[1,2,3,4,5;6,7,8,9,10]"; + mapDataDes["Double[]"] = u8"һά[1.0,2.0,3.0,...]ά[1.0,2.0,3.0;6.0,7.0,8.0]"; + mapDataDes["String[]"] = u8"һά[s1,s2,s3,s4,s5....]ά[s1,s2,s3,s4,s5;s6,s7,s8,s9,s10]"; + mapDataDes["a+bi"] = "1+2(i)"; + m_strDir = strDir; QHeaderView* horizontalHeader = ui.tableWidget->horizontalHeader(); @@ -70,7 +82,7 @@ void AddParamSetting::InitTable() QString strMaxValue = sett.value("MaxValue").toString(); QString strMinValue = sett.value("MinValue").toString(); QString strDecimal = sett.value("Decimal").toString(); - QString strValue = sett.value("Value","0").toString(); + QString strValue = sett.value("Value", "0").toString(); QStringList values; values << strName << strDes << strType << strMaxValue << strMinValue << strDecimal << strValue; @@ -89,14 +101,14 @@ void AddParamSetting::InsertRow() int iCol = 0; // { - QString strText = u8""; + QString strText = tr("input param name"); ui.tableWidget->setItem(iRow, iCol, new QTableWidgetItem(strText)); iCol++; } // { - QString strText = u8""; + QString strText = tr("input param descript"); ui.tableWidget->setItem(iRow, iCol, new QTableWidgetItem(strText)); iCol++; } @@ -150,13 +162,20 @@ void AddParamSetting::InsertRow() iCol++; } - // + // { - QString strText = u8"ֵ"; + QString strText = tr("input value"); // "ֵ"; QLineEdit* pValue = new QLineEdit; pValue->setText(strText); pValue->setProperty("Row", iRow); ui.tableWidget->setCellWidget(iRow, iCol, pValue); + iCol++; + } + + { + QString strText = mapDataDes["String"]; + ui.tableWidget->setItem(iRow, iCol, new QTableWidgetItem(strText)); + ui.tableWidget->item(iRow, iCol)->setSelected(false); } } @@ -182,9 +201,6 @@ void AddParamSetting::InsertRow(QStringList values) // { - QStringList listType; - listType << "String" << "Int" << "Float"; - QComboBox* pCombox = new QComboBox; pCombox->addItems(listType); pCombox->setCurrentText(values[2]); @@ -196,7 +212,7 @@ void AddParamSetting::InsertRow(QStringList values) iCol++; } - if (values[2] == "Float") + if (values[2] == "Double") { // ֵ { @@ -350,6 +366,13 @@ void AddParamSetting::InsertRow(QStringList values) ui.tableWidget->setItem(iRow, iCol, new QTableWidgetItem(strText)); } } + + { + iCol++; + QString strText = mapDataDes[values[2]]; + ui.tableWidget->setItem(iRow, iCol, new QTableWidgetItem(strText)); + ui.tableWidget->item(iRow, iCol)->setSelected(false); + } } void AddParamSetting::RemoveRow() @@ -388,7 +411,7 @@ void AddParamSetting::slotButtonCommit() sett.clear(); sett.sync(); - for (int iRow = 0; iRow < ui.tableWidget->rowCount(); iRow++) + for (int iRow = 0; iRow < ui.tableWidget->rowCount()-1; iRow++) { QString strGroup = QString::number(iRow + 1); QString strName = ui.tableWidget->item(iRow, 0)->text(); @@ -415,7 +438,7 @@ void AddParamSetting::slotButtonCommit() QSpinBox* pCuralue = (QSpinBox*)ui.tableWidget->cellWidget(iRow, 6); sett.setValue("Value", pCuralue->value()); } - else if (strType == "Float") + else if (strType == "Double") { QDoubleSpinBox* pMaxValue = (QDoubleSpinBox*)ui.tableWidget->cellWidget(iRow, 3); sett.setValue("MaxValue", pMaxValue->value()); @@ -438,7 +461,7 @@ void AddParamSetting::slotButtonCommit() QLineEdit* pCuralue = (QLineEdit*)ui.tableWidget->cellWidget(iRow, 6); sett.setValue("Value", pCuralue->text()); } - + sett.endGroup(); } @@ -452,7 +475,7 @@ void AddParamSetting::slotIntMaxValueChanged(int iValue) int iRow = pSender->property("Row").toInt(); // жСֵǷСڵǰõֵ - QSpinBox* pMinValue = (QSpinBox*)ui.tableWidget->cellWidget(iRow,4); + QSpinBox* pMinValue = (QSpinBox*)ui.tableWidget->cellWidget(iRow, 4); if (pMinValue->value() >= iValue) { // ûԭֵ @@ -655,5 +678,11 @@ void AddParamSetting::slotSelectDataType(const QString& strType) QWidget* pDecimalValue = ui.tableWidget->cellWidget(iRow, 5); pDecimalValue->setDisabled(true); } + + { + QString strText = mapDataDes[strType]; + ui.tableWidget->setItem(iRow, 7, new QTableWidgetItem(strText)); + ui.tableWidget->item(iRow, 7)->setSelected(false); + } } } diff --git a/Source/src/ui/Layout/AddParamSetting.h b/Source/src/ui/Layout/AddParamSetting.h index 8f6f5d59..f94e21f0 100644 --- a/Source/src/ui/Layout/AddParamSetting.h +++ b/Source/src/ui/Layout/AddParamSetting.h @@ -40,4 +40,7 @@ private: Ui::AddParamSettingClass ui; QString m_strDir; + + QStringList listType; + QMap mapDataDes; }; diff --git a/Source/src/ui/Layout/AddParamSetting.ui b/Source/src/ui/Layout/AddParamSetting.ui index 7206e230..82dc229a 100644 --- a/Source/src/ui/Layout/AddParamSetting.ui +++ b/Source/src/ui/Layout/AddParamSetting.ui @@ -51,6 +51,11 @@ 初始值 + + + 数据输入示例 + + diff --git a/Source/src/ui/Layout/CodeEdtUI.cpp b/Source/src/ui/Layout/CodeEdtUI.cpp new file mode 100644 index 00000000..fdf31c9e --- /dev/null +++ b/Source/src/ui/Layout/CodeEdtUI.cpp @@ -0,0 +1,86 @@ +#include "CodeEdtUI.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SyntaxHighlighter.h" + +#include "../DockTitleBar.h" +#include "../DockWidget.h" + +CodeEdtUI::CodeEdtUI(QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); + + // ༭ + editor = new QPlainTextEdit(this); + + QFont serifFont("Times", 20, QFont::Bold); + editor->setFont(serifFont); + + syntaxHighlighter = new SyntaxHighlighter(editor->document()); + + setCentralWidget(editor); + + // ˵ + QMenu* fileMenu = menuBar()->addMenu(tr("&file")); + QAction* openAction = new QAction(tr("&Import the template"), this); + QAction* saveAction = new QAction(tr("&save"), this); + fileMenu->addAction(openAction); + fileMenu->addAction(saveAction); + + connect(openAction, &QAction::triggered, this, &CodeEdtUI::openFile); + connect(saveAction, &QAction::triggered, this, &CodeEdtUI::saveFile); + + // ״̬ + statusBar(); +} + +void CodeEdtUI::AttachDock(DockWidget* dockWidget) +{ + if (nullptr == dockWidget) { + qDebug() << __FUNCTION__ << "dockwidget is nullptr"; + return; + } + + dockWidget->SetDockWidgetTitleBar(nullptr); + dockWidget->setWidget(this); + + DockTitleBar* dockTitleBar = new DockTitleBar; + + dockTitleBar->SetTitle(tr("matlab editor")); + + dockWidget->SetDockWidgetTitleBar(dockTitleBar); +} + +void CodeEdtUI::openFile() { + QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Matlab Files (*.m)"); + if (!fileName.isEmpty()) { + QFile file(fileName); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&file); + editor->setPlainText(in.readAll()); + file.close(); + } + } +} + +void CodeEdtUI::saveFile() { + QString fileName = QFileDialog::getSaveFileName(this, "Save File", "", "Matlab Files (*.m)"); + if (!fileName.isEmpty()) { + QFile file(fileName); + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QTextStream out(&file); + out << editor->toPlainText(); + file.close(); + } + } +} \ No newline at end of file diff --git a/Source/src/ui/Layout/CodeEdtUI.h b/Source/src/ui/Layout/CodeEdtUI.h new file mode 100644 index 00000000..c6e98a64 --- /dev/null +++ b/Source/src/ui/Layout/CodeEdtUI.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "ui_CodeEdtUI.h" + +class CodeEdtUI : public QMainWindow +{ + Q_OBJECT + +public: + CodeEdtUI(QWidget *parent = Q_NULLPTR); + void AttachDock(class DockWidget* dockWidget); + +protected slots: + void openFile(); + void saveFile(); + +private: + Ui::CodeEdtUIClass ui; + + class QPlainTextEdit* editor; + + class SyntaxHighlighter* syntaxHighlighter{ nullptr }; +}; diff --git a/Source/src/ui/Layout/CodeEdtUI.ui b/Source/src/ui/Layout/CodeEdtUI.ui new file mode 100644 index 00000000..e6c647ac --- /dev/null +++ b/Source/src/ui/Layout/CodeEdtUI.ui @@ -0,0 +1,28 @@ + + CodeEdtUIClass + + + CodeEdtUIClass + + + + 0 + 0 + 600 + 400 + + + + CodeEdtUI + + + + + + + + + + + + diff --git a/Source/src/ui/Layout/DockChildList.cpp b/Source/src/ui/Layout/DockChildList.cpp index e3f230ab..5839c9fe 100644 --- a/Source/src/ui/Layout/DockChildList.cpp +++ b/Source/src/ui/Layout/DockChildList.cpp @@ -378,7 +378,7 @@ void DockChildList::slotAddWindow() QTreeWidgetItem* pMainWindowItem = new QTreeWidgetItem; pMainWindowItem->setTextColor(0, Qt::green); - pMainWindowItem->setText(0, QString::fromLocal8Bit("")); + pMainWindowItem->setText(0,tr("Added a window")); pMainWindowItem->setData(0, Qt::UserRole, true); // Ƿק pMainWindowItem->setData(0, Qt::UserRole + 1, "MainWindow"); pMainWindowItem->setData(0, Qt::UserRole + 2, "MainWindow"); @@ -387,7 +387,7 @@ void DockChildList::slotAddWindow() { QTreeWidgetItem* pDocAreaItem = new QTreeWidgetItem; pDocAreaItem->setTextColor(0, Qt::green); - pDocAreaItem->setText(0, QString::fromLocal8Bit("")); + pDocAreaItem->setText(0, tr("Central area")); pDocAreaItem->setData(0, Qt::UserRole, true); // Ƿק pDocAreaItem->setData(0, Qt::UserRole + 1, "CentralWidget"); pDocAreaItem->setData(0, Qt::UserRole + 2, "CentralWidget"); @@ -397,7 +397,7 @@ void DockChildList::slotAddWindow() { QTreeWidgetItem* pDocAreaItem = new QTreeWidgetItem; pDocAreaItem->setTextColor(0, Qt::green); - pDocAreaItem->setText(0, QString::fromLocal8Bit("")); + pDocAreaItem->setText(0, tr("Left area")); pDocAreaItem->setData(0, Qt::UserRole, true); // Ƿק pDocAreaItem->setData(0, Qt::UserRole + 1, "DocArea"); pDocAreaItem->setData(0, Qt::UserRole + 2, "DockLeftArea"); @@ -407,7 +407,7 @@ void DockChildList::slotAddWindow() { QTreeWidgetItem* pDocAreaItem = new QTreeWidgetItem; pDocAreaItem->setTextColor(0, Qt::green); - pDocAreaItem->setText(0, QString::fromLocal8Bit("Ϸ")); + pDocAreaItem->setText(0, tr("Upper area")); pDocAreaItem->setData(0, Qt::UserRole, true); // Ƿק pDocAreaItem->setData(0, Qt::UserRole + 1, "DocArea"); pDocAreaItem->setData(0, Qt::UserRole + 2, "DockTopArea"); @@ -417,7 +417,7 @@ void DockChildList::slotAddWindow() { QTreeWidgetItem* pDocAreaItem = new QTreeWidgetItem; pDocAreaItem->setTextColor(0, Qt::green); - pDocAreaItem->setText(0, QString::fromLocal8Bit("Ҳ")); + pDocAreaItem->setText(0, tr("Right area")); pDocAreaItem->setData(0, Qt::UserRole, true); // Ƿק pDocAreaItem->setData(0, Qt::UserRole + 1, "DocArea"); pDocAreaItem->setData(0, Qt::UserRole + 2, "DockRightArea"); @@ -427,7 +427,7 @@ void DockChildList::slotAddWindow() { QTreeWidgetItem* pDocAreaItem = new QTreeWidgetItem; pDocAreaItem->setTextColor(0, Qt::green); - pDocAreaItem->setText(0, QString::fromLocal8Bit("·")); + pDocAreaItem->setText(0, tr("Underneath the area")); pDocAreaItem->setData(0, Qt::UserRole, true); // Ƿק pDocAreaItem->setData(0, Qt::UserRole + 1, "DocArea"); pDocAreaItem->setData(0, Qt::UserRole + 2, "DockBottomArea"); @@ -579,7 +579,7 @@ void DockChildList::contextMenuEvent(QContextMenuEvent* event) } } - QAction* addMainWindowAction = menu.addAction(QString::fromLocal8Bit("ɾ")); + QAction* addMainWindowAction = menu.addAction(tr("delete Window")); connect(addMainWindowAction, &QAction::triggered, this, &DockChildList::slotRemoveWindow); } else @@ -595,20 +595,20 @@ void DockChildList::contextMenuEvent(QContextMenuEvent* event) int iCurIndex = pItem->parent()->indexOfChild(pItem); if (iCurIndex < 1) { - QAction* backItemAction = menu.addAction(QString::fromLocal8Bit("")); + QAction* backItemAction = menu.addAction(tr("Move down")); // connect(backItemAction, &QAction::triggered, this, &DockChildList::slotBack); } else if (iCurIndex == pItem->parent()->childCount() - 1) { - QAction* frontItemAction = menu.addAction(QString::fromLocal8Bit("")); + QAction* frontItemAction = menu.addAction(tr("Move up")); // connect(frontItemAction, &QAction::triggered, this, &DockChildList::slotFront); } else { - QAction* frontItemAction = menu.addAction(QString::fromLocal8Bit("")); + QAction* frontItemAction = menu.addAction(tr("Move up")); // connect(frontItemAction, &QAction::triggered, this, &DockChildList::slotFront); - QAction* backItemAction = menu.addAction(QString::fromLocal8Bit("")); + QAction* backItemAction = menu.addAction(tr("Move down")); // connect(backItemAction, &QAction::triggered, this, &DockChildList::slotBack); } } @@ -619,7 +619,7 @@ void DockChildList::contextMenuEvent(QContextMenuEvent* event) { QMenu menu(this); - QAction* addMainWindowAction = menu.addAction(QString::fromLocal8Bit("Ӵ")); + QAction* addMainWindowAction = menu.addAction(tr("add window")); connect(addMainWindowAction, &QAction::triggered, this, &DockChildList::slotAddWindow); menu.exec(pos); diff --git a/Source/src/ui/Layout/SignalIndicatorLampUI.cpp b/Source/src/ui/Layout/SignalIndicatorLampUI.cpp index 6c25016c..ed14530b 100644 --- a/Source/src/ui/Layout/SignalIndicatorLampUI.cpp +++ b/Source/src/ui/Layout/SignalIndicatorLampUI.cpp @@ -183,7 +183,7 @@ void SignalIndicatorLampUI::InitLamp(const QString& strFile) QStringList listLamp; for (size_t i = 0; i < m_iLampCount; i++) { - listLamp << QString::fromLocal8Bit("ָʾ") + QString::number(i+1); + listLamp < +#include + +class SyntaxHighlighter : public QSyntaxHighlighter +{ + Q_OBJECT + +public: + SyntaxHighlighter(QTextDocument* parent = nullptr); + ~SyntaxHighlighter(); + +protected: + void highlightBlock(const QString& text) override; + +private: + struct HighlightingRule { + QRegularExpression pattern; + QTextCharFormat format; + }; + + QVector highlightingRules; +}; diff --git a/Source/src/ui/MainFrame.cpp b/Source/src/ui/MainFrame.cpp index 25f0c91e..d71cd058 100644 --- a/Source/src/ui/MainFrame.cpp +++ b/Source/src/ui/MainFrame.cpp @@ -118,6 +118,7 @@ void MainFrame::InitUI() { QtOsgViewWidget* viewWidget = mainWindow->GetViewWidget(); connect(fileMenu, &FileManagerMenu::LoadDyt, viewWidget, &QtOsgViewWidget::OnLoadDyt); + connect(viewWidget, &QtOsgViewWidget::signalResetWorkSpace, mainWindow, &MainWindow::slotResetWorkSpace); //connect(chartMenu, &ChartPlotMenu::signalAddCurve, mainWindow->GetFitCurveDlg(), &FitCurveDialog::slotAddSeries); //connect(chartMenu, &ChartPlotMenu::signalDelCurve, mainWindow->GetFitCurveDlg(), &FitCurveDialog::slotDelCurve); @@ -127,7 +128,7 @@ void MainFrame::InitUI() { //connect(chartMenu, &ChartPlotMenu::signalAddSurfaceCurve, mainWindow->GetSurfaceDlg(), &SurfaceDialog::slotAddSeries); - //connect(system_, &SystemManagerMenu::signalShowUISetting, mainWindow, &MainWindow::slotShowUISetting); + connect(system_, &SystemManagerMenu::signalShowUISetting, mainWindow, &MainWindow::slotShowUISetting); if (ui->menuWidget->count() > 0) { ui->menuWidget->setCurrentIndex(0); diff --git a/Source/src/ui/MainWindow.cpp b/Source/src/ui/MainWindow.cpp index 9d695215..468c429d 100644 --- a/Source/src/ui/MainWindow.cpp +++ b/Source/src/ui/MainWindow.cpp @@ -21,6 +21,7 @@ #include "Layout/LayoutSettingUI.h" #include "Layout/SignalIndicatorLampUI.h" #include "Layout/AddParamSetting.h" +#include "Layout/CodeEdtUI.h" #include "Table/targetlistwgt.h" #include "common/RecourceHelper.h" @@ -141,14 +142,14 @@ void MainWindow::InitUI() { targetUITable_ = new TargetListWgt; QStringList headerLabels; - headerLabels << QString::fromLocal8Bit("Ŀ") << QString::fromLocal8Bit("") - << QString::fromLocal8Bit("λ߽") << QString::fromLocal8Bit("߽") - << QString::fromLocal8Bit("λ") << QString::fromLocal8Bit("") - << QString::fromLocal8Bit("") << QString::fromLocal8Bit("") - << QString::fromLocal8Bit("") << QString::fromLocal8Bit("") - << QString::fromLocal8Bit("") << QString::fromLocal8Bit("γ") - << QString::fromLocal8Bit("") << QString::fromLocal8Bit("ٶ") - << QString::fromLocal8Bit("ߴ") << QString::fromLocal8Bit("ĿRCS"); + headerLabels << tr("Target number") << tr("Signal-to-noise ratio") //QString::fromLocal8Bit("Ŀ") << QString::fromLocal8Bit("") + << tr("Azimuth line of sight") << tr("Pitch gaze angle") // QString::fromLocal8Bit("λ߽") << QString::fromLocal8Bit("߽") + << tr("azimuth") << tr("Pitch angle") // QString::fromLocal8Bit("λ") << QString::fromLocal8Bit("") + << tr("attribute") << tr("Doppler") // QString::fromLocal8Bit("") << QString::fromLocal8Bit("") + << tr("course") << tr("Speed") // QString::fromLocal8Bit("") << QString::fromLocal8Bit("") + << tr("longitude") << tr("latitude") // QString::fromLocal8Bit("") << QString::fromLocal8Bit("γ") + << tr("distance") << tr("velocity") // QString::fromLocal8Bit("") << QString::fromLocal8Bit("ٶ") + << tr("Radial dimensions") << tr("Target RCS"); // QString::fromLocal8Bit("ߴ") << QString::fromLocal8Bit("ĿRCS"); targetUITable_->SetHeader(headerLabels); //const QString reportPath = RecourceHelper::Get().GetBasePath() + "/workspace/Report.txt"; @@ -167,14 +168,14 @@ void MainWindow::InitUI() { //WorkSpaceManager::Get().SetTargetListWgt(targetUITable_); QStringList headerLabels; - headerLabels << QString::fromLocal8Bit("Ŀ") << QString::fromLocal8Bit("") - << QString::fromLocal8Bit("λ߽") << QString::fromLocal8Bit("߽") - << QString::fromLocal8Bit("λ") << QString::fromLocal8Bit("") - << QString::fromLocal8Bit("") << QString::fromLocal8Bit("") - << QString::fromLocal8Bit("") << QString::fromLocal8Bit("") - << QString::fromLocal8Bit("") << QString::fromLocal8Bit("γ") - << QString::fromLocal8Bit("") << QString::fromLocal8Bit("ٶ") - << QString::fromLocal8Bit("ߴ") << QString::fromLocal8Bit("ĿRCS"); + headerLabels << tr("Target number") << tr("Signal-to-noise ratio") //QString::fromLocal8Bit("Ŀ") << QString::fromLocal8Bit("") + << tr("Azimuth line of sight") << tr("Pitch gaze angle") // QString::fromLocal8Bit("λ߽") << QString::fromLocal8Bit("߽") + << tr("azimuth") << tr("Pitch angle") // QString::fromLocal8Bit("λ") << QString::fromLocal8Bit("") + << tr("attribute") << tr("Doppler") // QString::fromLocal8Bit("") << QString::fromLocal8Bit("") + << tr("course") << tr("Speed") // QString::fromLocal8Bit("") << QString::fromLocal8Bit("") + << tr("longitude") << tr("latitude") // QString::fromLocal8Bit("") << QString::fromLocal8Bit("γ") + << tr("distance") << tr("velocity") // QString::fromLocal8Bit("") << QString::fromLocal8Bit("ٶ") + << tr("Radial dimensions") << tr("Target RCS"); // QString::fromLocal8Bit("ߴ") << QString::fromLocal8Bit("ĿRCS"); targetUI_->SetHeader(headerLabels); const QString reportPath = RecourceHelper::Get().GetBasePath() + "/workspace/Report.txt"; @@ -201,7 +202,7 @@ void MainWindow::InitUI() { const QString iniPath = RecourceHelper::Get().GetBasePath() + "/workspace/ParamSetting.ini"; DockWidget* addParamSettingDock = new DockWidget(tr("ParamSetting"), 0); - addParamDlg_ = new AddParamSetting(iniPath); + addParamDlg_ = new CodeEdtUI; addParamDlg_->AttachDock(addParamSettingDock); m_mapDockWidget.insert("ParamSetting", addParamSettingDock); @@ -355,3 +356,32 @@ void MainWindow::AddDockArea(const QString& strArea) { void MainWindow::slotShowUISetting() { pSettingUI->show(); } + +void MainWindow::slotResetWorkSpace() +{ + QString wavePath = WorkSpaceManager::Get().GetDYTWaveFile(); + if (wavePath.isEmpty()) + { + wavePath = RecourceHelper::Get().GetBasePath() + "/workspace/Wave.txt"; + WorkSpaceManager::Get().SetDYTWaveFile(wavePath); + } + + QString speedPath = WorkSpaceManager::Get().GetDYTReportFile(); + if (speedPath.isEmpty()) + { + speedPath = RecourceHelper::Get().GetBasePath() + "/workspace/Report.txt"; + WorkSpaceManager::Get().SetDYTReportFile(speedPath); + } + + QString rdPath = WorkSpaceManager::Get().GetDYTRDFile(); + if (rdPath.isEmpty()) + { + rdPath = RecourceHelper::Get().GetBasePath() + "/workspace/RD.txt"; + WorkSpaceManager::Get().SetDYTRDFile(rdPath); + } + + fitCurveDlg_->InitWaveFile(wavePath); + fitYLgCurveDlg_->InitReportFile(speedPath); + surfaceDlg_->InitRD(rdPath); + targetUITable_->InitFile(speedPath, 50); +} diff --git a/Source/src/ui/MainWindow.h b/Source/src/ui/MainWindow.h index ba04855e..9d314a9c 100644 --- a/Source/src/ui/MainWindow.h +++ b/Source/src/ui/MainWindow.h @@ -37,6 +37,9 @@ public: void slotShowUISetting(); +public slots: + void slotResetWorkSpace(); + private: void InitUI(); @@ -44,7 +47,7 @@ private: void AddDockArea(const QString& strArea); protected: - + private: Ui::MainWindow* ui; @@ -62,7 +65,7 @@ private: class TargetListWgt* targetUITable_{ nullptr }; class QTabWidget* tabWidget_{ nullptr }; class SignalIndicatorLampUI* signalIndicatorLampUI_{ nullptr }; - class AddParamSetting* addParamDlg_{ nullptr }; + class CodeEdtUI* addParamDlg_{ nullptr }; QMap m_mapDockWidget; diff --git a/Source/src/ui/Matlab/MatlabObject.cpp b/Source/src/ui/Matlab/MatlabObject.cpp index 98bc715b..334347c1 100644 --- a/Source/src/ui/Matlab/MatlabObject.cpp +++ b/Source/src/ui/Matlab/MatlabObject.cpp @@ -2,10 +2,7 @@ #include -#include -#include - -using namespace matlab::engine; +#include "engine.h" MatlabObject::MatlabObject(QObject *parent) : QObject(parent) @@ -25,20 +22,12 @@ void MatlabObject::RunMatlabFile(const QString& strFile) QTextCodec* code = QTextCodec::codecForName("utf-8"); std::string strRun = code->fromUnicode(strMatlabRun.toUtf8().data()).data(); - std::u16string utf16_str = string2u16string(strRun); - // MATLAB Engine - std::unique_ptr matlabPtr = startMATLAB(); - if (matlabPtr) - { - // Mļ - matlabPtr->eval(utf16_str); + Engine* ep; + if (!(ep = engOpen("\0"))) { + fprintf(stderr, "\nCan't start MATLAB engine\n"); + return; // EXIT_FAILURE; } + + engClose(ep); } -std::u16string MatlabObject::string2u16string(std::string& str) -{ - std::wstring_convert, char16_t> convert; - std::u16string utf16_str = convert.from_bytes(str); - - return utf16_str; -} diff --git a/Source/src/ui/Matlab/MatlabObject.h b/Source/src/ui/Matlab/MatlabObject.h index a9973e1b..c0c960d8 100644 --- a/Source/src/ui/Matlab/MatlabObject.h +++ b/Source/src/ui/Matlab/MatlabObject.h @@ -14,5 +14,5 @@ public: protected: - std::u16string string2u16string(std::string& str); + //std::u16string string2u16string(std::string& str); }; diff --git a/Source/src/viewer/QtOsgViewWidget.cpp b/Source/src/viewer/QtOsgViewWidget.cpp index bd982399..8807569a 100644 --- a/Source/src/viewer/QtOsgViewWidget.cpp +++ b/Source/src/viewer/QtOsgViewWidget.cpp @@ -151,12 +151,9 @@ void QtOsgViewWidget::OnLoadDyt(const QString& path) { } workspace_ = workSpace; -} -//void QtOsgViewWidget::setKeyboardModifiers(QInputEvent* event) { -// dyt_check(nullptr != view_); -// view_->KeyPress(event); -//} + emit signalResetWorkSpace(); +} void QtOsgViewWidget::resizeEvent(QResizeEvent* event) { if (nullptr == view_) { diff --git a/Source/src/viewer/QtOsgViewWidget.h b/Source/src/viewer/QtOsgViewWidget.h index 6d339217..b8a8cd52 100644 --- a/Source/src/viewer/QtOsgViewWidget.h +++ b/Source/src/viewer/QtOsgViewWidget.h @@ -27,6 +27,9 @@ public: void OnLoadDyt(const QString& path); //void setKeyboardModifiers(QInputEvent* event); +signals: + void signalResetWorkSpace(); + protected: void keyPressEvent(QKeyEvent* event) override; diff --git a/Source/src/workspace/WorkSpaceXMLParse.cpp b/Source/src/workspace/WorkSpaceXMLParse.cpp index 85ae9dd7..e1ae56a0 100644 --- a/Source/src/workspace/WorkSpaceXMLParse.cpp +++ b/Source/src/workspace/WorkSpaceXMLParse.cpp @@ -161,7 +161,7 @@ bool WorkSpaceXMLParse::Load(const QString& dyt) { tinyxml2::XMLDocument xmlDocument; tinyxml2::XMLError error = xmlDocument.LoadFile(path.c_str()); if (tinyxml2::XMLError::XML_SUCCESS != error) { - LOG_INFO("load feiled:{}", error); + LOG_INFO("load feiled:{}", static_cast(error)); return false; }