matlab文件编辑界面,打开dyt文件刷新数据
This commit is contained in:
parent
1340460e34
commit
2db92867b5
@ -169,6 +169,9 @@ target_link_libraries(
|
||||
osgSim
|
||||
libMatlabDataArray
|
||||
libMatlabEngine
|
||||
libeng
|
||||
libmx
|
||||
libmat
|
||||
# python39
|
||||
)
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<context>
|
||||
<name>AddParamSetting</name>
|
||||
<message>
|
||||
<location filename="../ui/Layout/AddParamSetting.cpp" line="52"/>
|
||||
<location filename="../ui/Layout/AddParamSetting.cpp" line="64"/>
|
||||
<source>ParamSetting</source>
|
||||
<translation>参数设置</translation>
|
||||
</message>
|
||||
@ -52,17 +52,22 @@
|
||||
<translation>初始值</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/Layout/AddParamSetting.ui" line="67"/>
|
||||
<location filename="../ui/Layout/AddParamSetting.ui" line="56"/>
|
||||
<source>数据输入示例</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/Layout/AddParamSetting.ui" line="72"/>
|
||||
<source>添加</source>
|
||||
<translation>添加</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/Layout/AddParamSetting.ui" line="80"/>
|
||||
<location filename="../ui/Layout/AddParamSetting.ui" line="85"/>
|
||||
<source>删除</source>
|
||||
<translation>删除</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/Layout/AddParamSetting.ui" line="93"/>
|
||||
<location filename="../ui/Layout/AddParamSetting.ui" line="98"/>
|
||||
<source>应用</source>
|
||||
<translation>应用</translation>
|
||||
</message>
|
||||
@ -90,6 +95,21 @@
|
||||
<translation>3D画布</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>CodeEdtUI</name>
|
||||
<message>
|
||||
<source>ParamSetting</source>
|
||||
<translation type="obsolete">参数设置</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>CodeEdtUIClass</name>
|
||||
<message>
|
||||
<location filename="../ui/Layout/CodeEdtUI.ui" line="16"/>
|
||||
<source>CodeEdtUI</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DYTChart</name>
|
||||
<message>
|
||||
@ -388,37 +408,37 @@
|
||||
<translation>主窗口</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/MainWindow.cpp" line="70"/>
|
||||
<location filename="../ui/MainWindow.cpp" line="71"/>
|
||||
<source>model elements</source>
|
||||
<translation>模型元素</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/MainWindow.cpp" line="76"/>
|
||||
<location filename="../ui/MainWindow.cpp" line="77"/>
|
||||
<source>attribte</source>
|
||||
<translation>属性</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/MainWindow.cpp" line="115"/>
|
||||
<location filename="../ui/MainWindow.cpp" line="118"/>
|
||||
<source>Wave Curve</source>
|
||||
<translation>波浪曲线</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/MainWindow.cpp" line="124"/>
|
||||
<location filename="../ui/MainWindow.cpp" line="127"/>
|
||||
<source>Speed Curve</source>
|
||||
<translation>速度曲线</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/MainWindow.cpp" line="134"/>
|
||||
<location filename="../ui/MainWindow.cpp" line="137"/>
|
||||
<source>3D Curve</source>
|
||||
<translation>3D曲线</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/MainWindow.cpp" line="160"/>
|
||||
<location filename="../ui/MainWindow.cpp" line="163"/>
|
||||
<source>Report Table</source>
|
||||
<translation>报表</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/MainWindow.cpp" line="186"/>
|
||||
<location filename="../ui/MainWindow.cpp" line="189"/>
|
||||
<source>Report</source>
|
||||
<translation>上报</translation>
|
||||
</message>
|
||||
|
@ -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();
|
||||
@ -103,9 +115,6 @@ void AddParamSetting::InsertRow()
|
||||
|
||||
// 数据类型
|
||||
{
|
||||
QStringList listType;
|
||||
listType << "String" << "Int" << "Float";
|
||||
|
||||
QComboBox* pCombox = new QComboBox;
|
||||
pCombox->addItems(listType);
|
||||
pCombox->setCurrentIndex(0);
|
||||
@ -150,13 +159,20 @@ void AddParamSetting::InsertRow()
|
||||
iCol++;
|
||||
}
|
||||
|
||||
// 参数描述
|
||||
//
|
||||
{
|
||||
QString strText = u8"输入参数值";
|
||||
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 +198,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 +209,7 @@ void AddParamSetting::InsertRow(QStringList values)
|
||||
iCol++;
|
||||
}
|
||||
|
||||
if (values[2] == "Float")
|
||||
if (values[2] == "Double")
|
||||
{
|
||||
// 最大值
|
||||
{
|
||||
@ -350,6 +363,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 +408,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 +435,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());
|
||||
@ -655,5 +675,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,4 +40,7 @@ private:
|
||||
Ui::AddParamSettingClass ui;
|
||||
|
||||
QString m_strDir;
|
||||
|
||||
QStringList listType;
|
||||
QMap<QString, QString> mapDataDes;
|
||||
};
|
||||
|
@ -51,6 +51,11 @@
|
||||
<string>初始值</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>数据输入示例</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
86
Source/src/ui/Layout/CodeEdtUI.cpp
Normal file
86
Source/src/ui/Layout/CodeEdtUI.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
#include "CodeEdtUI.h"
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
#include <QMenuBar>
|
||||
#include <QAction>
|
||||
#include <QStatusBar>
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFont>
|
||||
#include <qdebug.h>
|
||||
|
||||
#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(u8"&匡숭");
|
||||
QAction* openAction = new QAction(u8"&돔흙친겼", this);
|
||||
QAction* saveAction = new QAction(u8"&괏닸", 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(u8"matlab긍서");
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
24
Source/src/ui/Layout/CodeEdtUI.h
Normal file
24
Source/src/ui/Layout/CodeEdtUI.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#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 };
|
||||
};
|
28
Source/src/ui/Layout/CodeEdtUI.ui
Normal file
28
Source/src/ui/Layout/CodeEdtUI.ui
Normal file
@ -0,0 +1,28 @@
|
||||
<UI version="4.0" >
|
||||
<class>CodeEdtUIClass</class>
|
||||
<widget class="QMainWindow" name="CodeEdtUIClass" >
|
||||
<property name="objectName" >
|
||||
<string notr="true">CodeEdtUIClass</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>CodeEdtUI</string>
|
||||
</property> <widget class="QMenuBar" name="menuBar" />
|
||||
<widget class="QToolBar" name="mainToolBar" />
|
||||
<widget class="QWidget" name="centralWidget" />
|
||||
<widget class="QStatusBar" name="statusBar" />
|
||||
</widget>
|
||||
<layoutDefault spacing="6" margin="11" />
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<resources>
|
||||
<include location="CodeEdtUI.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</UI>
|
58
Source/src/ui/Layout/SyntaxHighlighter.cpp
Normal file
58
Source/src/ui/Layout/SyntaxHighlighter.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include "SyntaxHighlighter.h"
|
||||
|
||||
SyntaxHighlighter::SyntaxHighlighter(QTextDocument* parent)
|
||||
: QSyntaxHighlighter(parent)
|
||||
{
|
||||
HighlightingRule rule;
|
||||
|
||||
// 关键字高亮
|
||||
QStringList keywordPatterns;
|
||||
keywordPatterns << "\\bif\\b" << "\\belse\\b" << "\\bwhile\\b" << "\\bfor\\b"
|
||||
<< "\\bclass\\b" << "\\bstruct\\b" << "\\bpublic\\b"
|
||||
<< "\\bprivate\\b" << "\\bprotected\\b" << "\\bvoid\\b"
|
||||
<< "\\bint\\b" << "\\bfloat\\b" << "\\bdouble\\b"
|
||||
<< "\\bfunction\\b" << "\\bconst\\b" << "\\bbool\\b"
|
||||
<< "\\bforeach\\b" << "\\bfor\\b" << "\\bauto\\b" << "\\bcase\\b"
|
||||
<< "\\bdefault\\b";
|
||||
|
||||
foreach(const QString & pattern, keywordPatterns) {
|
||||
rule.pattern = QRegularExpression(pattern);
|
||||
rule.format.setForeground(Qt::blue);
|
||||
highlightingRules.append(rule);
|
||||
}
|
||||
|
||||
// 类名高亮
|
||||
rule.pattern = QRegularExpression("\\b[A-Z][a-zA-Z0-9_]*\\b");
|
||||
rule.format.setForeground(Qt::darkGreen);
|
||||
highlightingRules.append(rule);
|
||||
|
||||
// 字符串高亮
|
||||
rule.pattern = QRegularExpression("\".*\"");
|
||||
rule.format.setForeground(Qt::darkMagenta);
|
||||
highlightingRules.append(rule);
|
||||
|
||||
// 单行注释高亮
|
||||
rule.pattern = QRegularExpression("//[^\n]*");
|
||||
rule.format.setForeground(Qt::gray);
|
||||
highlightingRules.append(rule);
|
||||
|
||||
// 多行注释高亮
|
||||
rule.pattern = QRegularExpression("/\\*.*?\\*/", QRegularExpression::DotMatchesEverythingOption);
|
||||
rule.format.setForeground(Qt::gray);
|
||||
highlightingRules.append(rule);
|
||||
}
|
||||
|
||||
SyntaxHighlighter::~SyntaxHighlighter()
|
||||
{
|
||||
}
|
||||
|
||||
void SyntaxHighlighter::highlightBlock(const QString& text)
|
||||
{
|
||||
foreach(const HighlightingRule & rule, highlightingRules) {
|
||||
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
|
||||
while (matchIterator.hasNext()) {
|
||||
QRegularExpressionMatch match = matchIterator.next();
|
||||
setFormat(match.capturedStart(), match.capturedLength(), rule.format);
|
||||
}
|
||||
}
|
||||
}
|
24
Source/src/ui/Layout/SyntaxHighlighter.h
Normal file
24
Source/src/ui/Layout/SyntaxHighlighter.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <QSyntaxHighlighter>
|
||||
#include <QRegularExpression>
|
||||
|
||||
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<HighlightingRule> highlightingRules;
|
||||
};
|
@ -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);
|
||||
|
@ -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"
|
||||
@ -112,6 +113,8 @@ void MainWindow::InitUI() {
|
||||
}
|
||||
// const QString rdPath = RecourceHelper::Get().GetBasePath() + "/workspace/RD.txt";
|
||||
|
||||
const QString lampPath = RecourceHelper::Get().GetBasePath() + "/workspace/Lamp.txt";
|
||||
|
||||
DockWidget* fitCurveDock = new DockWidget(tr("Wave Curve"), 0);
|
||||
// addDockWidget(pSettingUI->GetArea("2DCurveDialog"), fitCurveDock);
|
||||
fitCurveDlg_ = new FitCurveDialog(1);
|
||||
@ -191,9 +194,6 @@ void MainWindow::InitUI() {
|
||||
connect(WorkSpaceManager::Get().GetCurrent()->GetTimestep(), SIGNAL(TimeChanged(double)), targetUI_, SLOT(slotTimeChanged(double)));
|
||||
}
|
||||
|
||||
|
||||
const QString lampPath = RecourceHelper::Get().GetBasePath() + "/workspace/Lamp.txt";
|
||||
|
||||
DockWidget* signalIndicatorLampDock = new DockWidget(tr("Signal Indicator Lamp"), 0);
|
||||
signalIndicatorLampUI_ = new SignalIndicatorLampUI;
|
||||
signalIndicatorLampUI_->AttachDock(signalIndicatorLampDock);
|
||||
@ -204,7 +204,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);
|
||||
|
||||
@ -213,7 +213,7 @@ void MainWindow::InitUI() {
|
||||
|
||||
InitDockLayout();
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
MatlabObject* mtlb = new MatlabObject;
|
||||
mtlb->RunMatlabFile("D:\\DYT\\TestGUI\\TestGUI\\LDPlatformTest.m");
|
||||
#endif // 1
|
||||
@ -401,3 +401,32 @@ 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);
|
||||
}
|
||||
|
@ -37,6 +37,9 @@ public:
|
||||
|
||||
void slotShowUISetting();
|
||||
|
||||
public slots:
|
||||
void slotResetWorkSpace();
|
||||
|
||||
private:
|
||||
void InitUI();
|
||||
|
||||
@ -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<QString, QDockWidget*> m_mapDockWidget;
|
||||
|
||||
|
@ -2,10 +2,7 @@
|
||||
|
||||
#include <QTextCodec>
|
||||
|
||||
#include <MatlabEngine.hpp>
|
||||
#include <MatlabDataArray.hpp>
|
||||
|
||||
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<MATLABEngine> 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;
|
||||
}
|
||||
|
||||
std::u16string MatlabObject::string2u16string(std::string& str)
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
||||
std::u16string utf16_str = convert.from_bytes(str);
|
||||
|
||||
return utf16_str;
|
||||
engClose(ep);
|
||||
}
|
||||
|
||||
|
@ -14,5 +14,5 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
std::u16string string2u16string(std::string& str);
|
||||
//std::u16string string2u16string(std::string& str);
|
||||
};
|
||||
|
@ -142,6 +142,8 @@ void QtOsgViewWidget::OnLoadDyt(const QString& path) {
|
||||
}
|
||||
|
||||
workspace_ = workSpace;
|
||||
|
||||
emit signalResetWorkSpace();
|
||||
}
|
||||
|
||||
void QtOsgViewWidget::resizeEvent(QResizeEvent* event) {
|
||||
|
@ -29,6 +29,9 @@ public:
|
||||
void OnLoadDyt(const QString& path);
|
||||
// void setKeyboardModifiers(QInputEvent* event);
|
||||
|
||||
signals:
|
||||
void signalResetWorkSpace();
|
||||
|
||||
protected:
|
||||
|
||||
//void InitEventHandle(Core::ICameraManipulator* pCameraMainp, Core::IView* pView);
|
||||
|
@ -14,12 +14,10 @@
|
||||
<DockBottomArea Name="下方区域"/>
|
||||
</MainWindow>
|
||||
<MainWindow Name="窗口2">
|
||||
<CentralWidget Name="中心区域">
|
||||
</CentralWidget>
|
||||
<CentralWidget Name="中心区域"/>
|
||||
<DockLeftArea Name="左侧区域">
|
||||
<Widget Plugin="SignalIndicatorLampUI" Name="信号指示灯"/>
|
||||
<Widget Plugin="TargetListWgt_Table" Name="目标上报信息"/>
|
||||
<Widget Plugin="ParamSetting" Name="参数设置"/>
|
||||
<DocTab Name="水平分页">
|
||||
<Widget Plugin="WaveCurveDialog" Name="波形曲线图"/>
|
||||
<Widget Plugin="SpeedCurveDialog" Name="距离速度曲线"/>
|
||||
@ -31,11 +29,12 @@
|
||||
<DockBottomArea Name="下方区域"/>
|
||||
</MainWindow>
|
||||
<MainWindow Name="新增窗口">
|
||||
<CentralWidget Name="中心区域">
|
||||
</CentralWidget>
|
||||
<CentralWidget Name="中心区域"/>
|
||||
<DockLeftArea Name="左侧区域"/>
|
||||
<DockTopArea Name="上方区域"/>
|
||||
<DockRightArea Name="右侧区域"/>
|
||||
<DockRightArea Name="右侧区域">
|
||||
<Widget Plugin="ParamSetting" Name="参数设置"/>
|
||||
</DockRightArea>
|
||||
<DockBottomArea Name="下方区域"/>
|
||||
</MainWindow>
|
||||
</Layout>
|
||||
|
Loading…
Reference in New Issue
Block a user