add excure matlab file
This commit is contained in:
parent
0861f66413
commit
62f4ca29d3
@ -14,7 +14,7 @@ int main(int argc, char* argv[]) {
|
||||
#endif
|
||||
|
||||
Application app(argc, argv);
|
||||
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||
//app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||
//InstallCrashHandler();
|
||||
|
||||
RecourceHelper::ChangeSkin("default");
|
||||
|
@ -23,6 +23,7 @@ bool FramelessWindow::nativeEvent(const QByteArray& eventType, void* message, qi
|
||||
#else
|
||||
bool FramelessWindow::nativeEvent(const QByteArray & eventType, void* message, long* result) {
|
||||
#endif
|
||||
return QFrame::nativeEvent(eventType, message, result);
|
||||
if (!delegate_->nativeEvent(eventType, message, result)) {
|
||||
return QFrame::nativeEvent(eventType, message, result);
|
||||
}
|
||||
|
@ -10,9 +10,11 @@
|
||||
#include <qsettings.h>
|
||||
#include <qdebug.h>
|
||||
|
||||
#include "python/PythonModule.h"
|
||||
|
||||
#include "../../workspace/WorkSpaceManager.h"
|
||||
#include "../../common/RecourceHelper.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
AddParamSetting::AddParamSetting(const QString& strDir, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@ -26,10 +28,10 @@ AddParamSetting::AddParamSetting(const QString& strDir, QWidget* parent)
|
||||
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)";
|
||||
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\" 二维 \"s1\", \"s2\";\"s3\", \"s4\"";
|
||||
mapDataDes["a+bi"] = u8"a+bi 实部a,虚部b" ;
|
||||
|
||||
m_strDir = strDir;
|
||||
|
||||
@ -101,7 +103,7 @@ void AddParamSetting::InsertRow()
|
||||
int iCol = 0;
|
||||
// 参数名称
|
||||
{
|
||||
QString strText = tr("input param name");
|
||||
QString strText = tr("param");
|
||||
ui.tableWidget->setItem(iRow, iCol, new QTableWidgetItem(strText));
|
||||
iCol++;
|
||||
}
|
||||
@ -115,9 +117,6 @@ void AddParamSetting::InsertRow()
|
||||
|
||||
// 数据类型
|
||||
{
|
||||
QStringList listType;
|
||||
listType << "String" << "Int" << "Float";
|
||||
|
||||
QComboBox* pCombox = new QComboBox;
|
||||
pCombox->addItems(listType);
|
||||
pCombox->setCurrentIndex(0);
|
||||
@ -362,8 +361,12 @@ void AddParamSetting::InsertRow(QStringList values)
|
||||
|
||||
// 参数初始值
|
||||
{
|
||||
QLineEdit* pCuralue = new QLineEdit;
|
||||
|
||||
QString strText = values[6];
|
||||
ui.tableWidget->setItem(iRow, iCol, new QTableWidgetItem(strText));
|
||||
pCuralue->setText(strText);
|
||||
|
||||
ui.tableWidget->setCellWidget(iRow, iCol, pCuralue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,11 +410,26 @@ void AddParamSetting::slotButtonRemove()
|
||||
|
||||
void AddParamSetting::slotButtonCommit()
|
||||
{
|
||||
QString strMatlabFile = WorkSpaceManager::Get().GetDYTMatlabPFile();
|
||||
if (strMatlabFile.isEmpty())
|
||||
{
|
||||
strMatlabFile = RecourceHelper::Get().GetBasePath() + "/workspace/MatlabParam.m";
|
||||
WorkSpaceManager::Get().SetDYTMatlabPFile(strMatlabFile);
|
||||
}
|
||||
|
||||
QFile file(strMatlabFile);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qWarning() << "无法打开文件:" << file.errorString();
|
||||
return; // 处理错误
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
|
||||
QSettings sett(m_strDir, QSettings::IniFormat);
|
||||
sett.clear();
|
||||
sett.sync();
|
||||
|
||||
for (int iRow = 0; iRow < ui.tableWidget->rowCount()-1; iRow++)
|
||||
for (int iRow = 0; iRow < ui.tableWidget->rowCount(); iRow++)
|
||||
{
|
||||
QString strGroup = QString::number(iRow + 1);
|
||||
QString strName = ui.tableWidget->item(iRow, 0)->text();
|
||||
@ -437,6 +455,9 @@ void AddParamSetting::slotButtonCommit()
|
||||
|
||||
QSpinBox* pCuralue = (QSpinBox*)ui.tableWidget->cellWidget(iRow, 6);
|
||||
sett.setValue("Value", pCuralue->value());
|
||||
|
||||
QString strIn = QString("%1 = %2;").arg(strName).arg(pCuralue->value());
|
||||
out << strIn << "\n"; // 写入数据
|
||||
}
|
||||
else if (strType == "Double")
|
||||
{
|
||||
@ -451,6 +472,37 @@ void AddParamSetting::slotButtonCommit()
|
||||
|
||||
QDoubleSpinBox* pCuralue = (QDoubleSpinBox*)ui.tableWidget->cellWidget(iRow, 6);
|
||||
sett.setValue("Value", pCuralue->value());
|
||||
|
||||
QString strIn = QString("%1 = %2;").arg(strName).arg(pCuralue->value());
|
||||
out << strIn << "\n"; // 写入数据
|
||||
}
|
||||
else if (strType == "Int[]")
|
||||
{
|
||||
QLineEdit* pCuralue = (QLineEdit*)ui.tableWidget->cellWidget(iRow, 6);
|
||||
QString strValue = pCuralue->text();
|
||||
sett.setValue("Value", strValue);
|
||||
|
||||
QString strIn = QString("%1 = int32([%2]);").arg(strName).arg(strValue);
|
||||
out << strIn << "\n"; // 写入数据
|
||||
}
|
||||
else if (strType == "Double[]")
|
||||
{
|
||||
QLineEdit* pCuralue = (QLineEdit*)ui.tableWidget->cellWidget(iRow, 6);
|
||||
QString strValue = pCuralue->text();
|
||||
|
||||
sett.setValue("Value", strValue);
|
||||
|
||||
QString strIn = QString("%1 = double([%2]);").arg(strName).arg(strValue);
|
||||
out << strIn << "\n"; // 写入数据
|
||||
}
|
||||
else if (strType == "String[]")
|
||||
{
|
||||
QLineEdit* pCuralue = (QLineEdit*)ui.tableWidget->cellWidget(iRow, 6);
|
||||
QString strValue = pCuralue->text();
|
||||
QString strIn = QString("%1 = string([%2]);").arg(strName).arg(strValue);
|
||||
out << strIn << "\n"; // 写入数据
|
||||
|
||||
sett.setValue("Value", strValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -459,14 +511,19 @@ void AddParamSetting::slotButtonCommit()
|
||||
sett.setValue("Decimal", 0);
|
||||
|
||||
QLineEdit* pCuralue = (QLineEdit*)ui.tableWidget->cellWidget(iRow, 6);
|
||||
sett.setValue("Value", pCuralue->text());
|
||||
QString strValue = pCuralue->text();
|
||||
|
||||
sett.setValue("Value", strValue);
|
||||
|
||||
QString strIn = QString("%1 = \"%2\";").arg(strName).arg(strValue);
|
||||
out << strIn << "\n"; // 写入数据
|
||||
}
|
||||
|
||||
sett.endGroup();
|
||||
}
|
||||
|
||||
// 添加函数参数
|
||||
//PythonModule::Get().CallFunction("callMatlab", "ttt");
|
||||
// 关闭文件
|
||||
file.close();
|
||||
}
|
||||
|
||||
void AddParamSetting::slotIntMaxValueChanged(int iValue)
|
||||
@ -624,7 +681,7 @@ void AddParamSetting::slotSelectDataType(const QString& strType)
|
||||
|
||||
ui.tableWidget->setCellWidget(iRow, 6, pValue);
|
||||
}
|
||||
else if ("Float" == strType)
|
||||
else if ("Double" == strType)
|
||||
{
|
||||
// 移除参数值原控件
|
||||
ui.tableWidget->removeCellWidget(iRow, 3);
|
||||
@ -677,6 +734,10 @@ void AddParamSetting::slotSelectDataType(const QString& strType)
|
||||
|
||||
QWidget* pDecimalValue = ui.tableWidget->cellWidget(iRow, 5);
|
||||
pDecimalValue->setDisabled(true);
|
||||
|
||||
QLineEdit* pCuralue = new QLineEdit;
|
||||
pCuralue->setText(u8"");
|
||||
ui.tableWidget->setCellWidget(iRow, 6, pCuralue);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -192,10 +192,15 @@ void MainWindow::InitUI() {
|
||||
|
||||
const QString iniPath = RecourceHelper::Get().GetBasePath() + "/workspace/ParamSetting.ini";
|
||||
DockWidget* addParamSettingDock = new DockWidget(tr("ParamSetting"), 0);
|
||||
addParamDlg_ = new CodeEdtUI;
|
||||
addParamDlg_ = new AddParamSetting(iniPath);
|
||||
addParamDlg_->AttachDock(addParamSettingDock);
|
||||
m_mapDockWidget.insert("ParamSetting", addParamSettingDock);
|
||||
|
||||
DockWidget* matlabDock = new DockWidget(tr("Matlab File"), 0);
|
||||
matlabFileDlg_ = new CodeEdtUI;
|
||||
matlabFileDlg_->AttachDock(matlabDock);
|
||||
m_mapDockWidget.insert("Matlab", matlabDock);
|
||||
|
||||
//ui->discript->setText(tr("name: 5year 0412"));
|
||||
//ui->status->setText(tr("start: no start"));
|
||||
|
||||
|
@ -65,7 +65,8 @@ private:
|
||||
class TargetListWgt* targetUITable_{ nullptr };
|
||||
class QTabWidget* tabWidget_{ nullptr };
|
||||
class SignalIndicatorLampUI* signalIndicatorLampUI_{ nullptr };
|
||||
class CodeEdtUI* addParamDlg_{ nullptr };
|
||||
class CodeEdtUI* matlabFileDlg_{ nullptr };
|
||||
class AddParamSetting* addParamDlg_{ nullptr };
|
||||
|
||||
QMap<QString, QDockWidget*> m_mapDockWidget;
|
||||
|
||||
|
@ -65,6 +65,12 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetDYTMatlabPFile(const QString& file)
|
||||
{
|
||||
m_strMatlabPile = file;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString GetDYTWaveFile()
|
||||
{
|
||||
return m_waveFile;
|
||||
@ -95,6 +101,11 @@ public:
|
||||
return m_mSeekerSimFile;
|
||||
}
|
||||
|
||||
QString GetDYTMatlabPFile()
|
||||
{
|
||||
return m_strMatlabPile;
|
||||
}
|
||||
|
||||
void OnFrame();
|
||||
|
||||
signals:
|
||||
@ -117,4 +128,6 @@ private:
|
||||
QString m_mLDFile;
|
||||
QString m_mSeekerSimFile;
|
||||
|
||||
QString m_strMatlabPile;
|
||||
|
||||
};
|
@ -168,6 +168,17 @@ bool WorkSpaceXMLParse::ParseChart(const tinyxml2::XMLElement* element)
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
}
|
||||
else if (0 == strcmp(name, "MatlabP"))
|
||||
{
|
||||
QVariantMap varChart;
|
||||
const tinyxml2::XMLAttribute* attribute = xmlElement->FirstAttribute();
|
||||
while (nullptr != attribute) {
|
||||
|
||||
WorkSpaceManager::Get().SetDYTMatlabPFile(QString::fromLocal8Bit(attribute->Value()));
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
}
|
||||
|
||||
xmlElement = xmlElement->NextSiblingElement();
|
||||
}
|
||||
|
||||
|
@ -128,5 +128,11 @@ bool WorkSpaceXMLWrite::SaveChart(tinyxml2::XMLElement* scene, tinyxml2::XMLDocu
|
||||
|
||||
chart->SetAttribute("MSeekerSim", WorkSpaceManager::Get().GetDYTMSeekerSimFile().toLocal8Bit().constData());
|
||||
}
|
||||
{
|
||||
tinyxml2::XMLElement* chart = doc->NewElement("MatlabP");
|
||||
charts->LinkEndChild(chart);
|
||||
|
||||
chart->SetAttribute("MatlabP", WorkSpaceManager::Get().GetDYTMatlabPFile().toLocal8Bit().constData());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -28,7 +28,16 @@
|
||||
<DockRightArea Name="右侧区域"/>
|
||||
<DockBottomArea Name="下方区域"/>
|
||||
</MainWindow>
|
||||
<MainWindow Name="新增窗口">
|
||||
<MainWindow Name="Matlab文件编辑">
|
||||
<CentralWidget Name="中心区域"/>
|
||||
<DockLeftArea Name="左侧区域"/>
|
||||
<DockTopArea Name="上方区域"/>
|
||||
<DockRightArea Name="右侧区域">
|
||||
<Widget Plugin="Matlab" Name="参数设置"/>
|
||||
</DockRightArea>
|
||||
<DockBottomArea Name="下方区域"/>
|
||||
</MainWindow>
|
||||
<MainWindow Name="参数编辑">
|
||||
<CentralWidget Name="中心区域"/>
|
||||
<DockLeftArea Name="左侧区域"/>
|
||||
<DockTopArea Name="上方区域"/>
|
||||
|
Loading…
Reference in New Issue
Block a user