From 183d51b5380ec2ee19ae1c8cac4d35b239b4704e Mon Sep 17 00:00:00 2001
From: 15712809671 <136563253+15712809671@users.noreply.github.com>
Date: Sun, 25 May 2025 11:32:25 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E7=BB=91?=
=?UTF-8?q?=E5=AE=9A=E7=A8=8B=E5=BA=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main.cpp | 2 +-
src/scene/ui/OESceneUI.cpp | 5 +
src/translations/Dyt_zh_CN.ts | 133 ++---
src/ui/DockWidget.h | 131 ++++-
src/ui/Layout/CodeEdtUI.cpp | 10 +-
src/ui/MainWindow.cpp | 528 ++++++++++---------
src/ui/MainWindow.h | 2 +
src/ui/Menu/ChartPlotMenu.cpp | 149 +++++-
src/ui/Menu/ChartPlotMenu.ui | 52 ++
src/ui/PropertyBrowser/qtpropertymanager.cpp | 119 +----
src/viewer/QtOsgViewWidget.cpp | 2 +-
src/workspace/WorkSpace.cpp | 71 +++
src/workspace/WorkSpace.h | 41 +-
src/workspace/WorkSpaceXMLParse.cpp | 30 ++
src/workspace/WorkSpaceXMLParse.h | 1 +
src/workspace/WorkSpaceXMLWrite.cpp | 2 +-
workspace/UILayout.xml | 4 +-
17 files changed, 787 insertions(+), 495 deletions(-)
diff --git a/src/main.cpp b/src/main.cpp
index 66651a6a..4fe99b41 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -13,7 +13,7 @@ int main(int argc, char* argv[]) {
Application app(argc, argv);
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
- InstallCrashHandler();
+ //InstallCrashHandler();
RecourceHelper::ChangeSkin("default");
diff --git a/src/scene/ui/OESceneUI.cpp b/src/scene/ui/OESceneUI.cpp
index 5a1898cc..9299cbc7 100644
--- a/src/scene/ui/OESceneUI.cpp
+++ b/src/scene/ui/OESceneUI.cpp
@@ -27,6 +27,8 @@ void OESceneUI::InitUI(OsgViewUI* ui) {
return;
}
+ return;
+
compositeWidgetManager_ = new CompositeWidgetManager();
compositeWidgetManager_->AttachViewUI(ui);
zoomManager_ = new ZoomManager();
@@ -43,6 +45,9 @@ void OESceneUI::InitUI(OsgViewUI* ui) {
}
void OESceneUI::OnResize(double width, double height) {
+
+ return;
+
dyt_check(compositeWidgetManager_);
dyt_check(zoomManager_);
diff --git a/src/translations/Dyt_zh_CN.ts b/src/translations/Dyt_zh_CN.ts
index 6a64aaad..6b0c2844 100644
--- a/src/translations/Dyt_zh_CN.ts
+++ b/src/translations/Dyt_zh_CN.ts
@@ -96,38 +96,30 @@
+ Wave文件
+
+
+
+
+ Report文件
+
+
+
+
+ RD文件
+
+
+
+
+ Matlab文件
+
+
+
+
Run Simu
-
- CodeEdtUI
-
-
- matlab editor
-
-
-
-
- &bat
-
-
-
-
- &Control
-
-
-
-
- &Run
-
-
-
-
- &Save
-
-
-
CodeEdtUIClass
@@ -612,7 +604,7 @@
- Matlab File
+ bat File
@@ -923,43 +915,43 @@
QtConeWaveComponentManager
-
-
+
+
ConeWaveComponent
-
+
Height
-
+
Radius
-
+
levelCount
-
+
levelHeight
-
+
Color1
-
+
Color2
-
+
Color3
@@ -1065,28 +1057,28 @@
QtDashedLineComponentManager
-
-
+
+
DashedLineComponent
-
+
Start
-
+
End
-
+
Radius
-
+
Color
@@ -1102,12 +1094,12 @@
QtEntityPropertyManager
-
+
Name
名称
-
+
Transform
@@ -1189,13 +1181,13 @@
QtMeshComponetManager
-
-
+
+
MeshComponent
-
+
Mesh
@@ -1226,16 +1218,10 @@
QtOsgViewWidget
-
warning
警告
-
-
- default workspace failed
-
-
open dyt file failed
@@ -1245,13 +1231,13 @@
QtPathComponentManager
-
-
+
+
PathComponent
-
+
Path
路径
@@ -1501,45 +1487,20 @@
QtWorkspacePropertyManager
-
+
Name
名称
-
+
Description
-
+
Timestep
-
-
- SimMatlab
-
-
-
-
- MatlabParam
-
-
-
-
- Wave
-
-
-
-
- RD
-
-
-
-
- Report
-
-
SignalIndicatorLampUI
diff --git a/src/ui/DockWidget.h b/src/ui/DockWidget.h
index 8a049bf4..b988ab24 100644
--- a/src/ui/DockWidget.h
+++ b/src/ui/DockWidget.h
@@ -5,6 +5,16 @@
#include
#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
class DockWidgetTitleBar : public QWidget {
Q_OBJECT
@@ -43,9 +53,128 @@ protected:
void resizeEvent(QResizeEvent* e) override;
void paintEvent(QPaintEvent* e) override;
+ void mousePressEvent(QMouseEvent* event) override {
+ if (event->button() == Qt::LeftButton)
+ m_dragStartPosition = event->pos();
+ QDockWidget::mousePressEvent(event);
+ }
+
+ void mouseMoveEvent(QMouseEvent* event) override {
+ if (!(event->buttons() & Qt::LeftButton))
+ return;
+ if ((event->pos() - m_dragStartPosition).manhattanLength() < QApplication::startDragDistance())
+ return;
+
+ QDrag* drag = new QDrag(this);
+ QMimeData* mimeData = new QMimeData;
+ mimeData->setData("application/x-dockwidget", QByteArray());
+ drag->setMimeData(mimeData);
+ drag->exec(Qt::MoveAction);
+ }
+
private:
void OnClose();
private:
DockWidgetTitleBar* titleBar_{ nullptr };
-};
\ No newline at end of file
+
+ QPoint m_dragStartPosition;
+};
+
+class CustomMainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ CustomMainWindow(QWidget* parent = nullptr) : QMainWindow(parent) {
+ setAcceptDrops(true);
+ }
+
+ void saveStateToFile(const QString& filename) {
+ QByteArray state = saveState(); // ȡ״̬
+ QByteArray base64 = state.toBase64(); // תΪ Base64 ַ
+
+ QFile file(filename);
+ if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ QTextStream out(&file);
+ out << base64; // дıļ
+ file.close();
+ }
+ }
+
+ void saveDocksToJson(const QString& filename) {
+ QJsonObject mainData;
+
+ // ÿ DockWidget
+ for (QDockWidget* dock : findChildren()) {
+ QJsonObject dockData;
+ dockData["visible"] = dock->isVisible();
+ dockData["floating"] = dock->isFloating();
+ dockData["geometry"] = QString("%1,%2,%3,%4")
+ .arg(dock->geometry().x())
+ .arg(dock->geometry().y())
+ .arg(dock->geometry().width())
+ .arg(dock->geometry().height());
+ dockData["area"] = dockWidgetArea(dock); // ͣ
+
+ mainData[dock->objectName()] = dockData;
+ }
+
+ // дļ
+ QFile file(filename);
+ if (file.open(QIODevice::WriteOnly)) {
+ QJsonDocument doc(mainData);
+ file.write(doc.toJson());
+ file.close();
+ }
+ }
+
+ void restoreDocksFromJson(const QString& filename) {
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly)) return;
+
+ QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
+ QJsonObject mainData = doc.object();
+
+ foreach(const QString & key, mainData.keys()) {
+ QDockWidget* dock = findChild(key);
+ if (!dock) continue;
+
+ QJsonObject dockData = mainData[key].toObject();
+ dock->setVisible(dockData["visible"].toBool());
+ dock->setFloating(dockData["floating"].toBool());
+
+ // λ
+ QStringList geom = dockData["geometry"].toString().split(",");
+ if (geom.size() == 4) {
+ dock->setGeometry(geom[0].toInt(), geom[1].toInt(),
+ geom[2].toInt(), geom[3].toInt());
+ }
+
+ // ָͣ
+ Qt::DockWidgetArea area = static_cast(
+ dockData["area"].toInt());
+
+ addDockWidget(area, dock);
+ }
+ }
+
+protected:
+ void dragEnterEvent(QDragEnterEvent* event) override {
+ if (event->mimeData()->hasFormat("application/x-dockwidget"))
+ event->acceptProposedAction();
+ }
+
+ void dropEvent(QDropEvent* event) override {
+ DockWidget* dock = qobject_cast(event->source());
+ if (dock && dock->parent() != this) {
+ // ԭƳ
+ QMainWindow* oldParent = qobject_cast(dock->parent());
+ if (oldParent) oldParent->removeDockWidget(dock);
+
+ // ӵǰ
+ dock->setParent(this);
+ addDockWidget(Qt::RightDockWidgetArea, dock);
+ dock->show();
+ event->acceptProposedAction();
+ }
+ }
+};
diff --git a/src/ui/Layout/CodeEdtUI.cpp b/src/ui/Layout/CodeEdtUI.cpp
index 18ca4965..e1225488 100644
--- a/src/ui/Layout/CodeEdtUI.cpp
+++ b/src/ui/Layout/CodeEdtUI.cpp
@@ -71,7 +71,7 @@ void CodeEdtUI::AttachDock(DockWidget* dockWidget)
DockTitleBar* dockTitleBar = new DockTitleBar;
- dockTitleBar->SetTitle(tr("matlab editor"));
+ dockTitleBar->SetTitle(u8"batļ");
dockWidget->SetDockWidgetTitleBar(dockTitleBar);
}
@@ -79,7 +79,7 @@ void CodeEdtUI::AttachDock(DockWidget* dockWidget)
void CodeEdtUI::InitBat()
{
{
- QMenu* fileMenu = menuBar()->addMenu(tr("&bat"));
+ QMenu* fileMenu = menuBar()->addMenu(u8"ļ");
QDir dir(RecourceHelper::Get().GetBasePath() + "/bat");
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks);
@@ -99,12 +99,12 @@ void CodeEdtUI::InitBat()
}
{
- QMenu* ctrlMenu = menuBar()->addMenu(tr("&Control"));
+ QMenu* ctrlMenu = menuBar()->addMenu(u8"");
- QAction* runAction = new QAction(tr("&Run"), this);
+ QAction* runAction = new QAction(tr(u8"ִ"), this);
ctrlMenu->addAction(runAction);
- QAction* saveAction = new QAction(tr("&Save"), this);
+ QAction* saveAction = new QAction(u8"", this);
ctrlMenu->addAction(saveAction);
connect(runAction, &QAction::triggered, this, &CodeEdtUI::runFile);
diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp
index 112041d5..9553d037 100644
--- a/src/ui/MainWindow.cpp
+++ b/src/ui/MainWindow.cpp
@@ -36,338 +36,364 @@
#include "ui_MainWindow.h"
MainWindow::MainWindow(QWidget* parent)
- : QMainWindow(parent)
- , ui(new Ui::MainWindow) {
- ui->setupUi(this);
+ : QMainWindow(parent)
+ , ui(new Ui::MainWindow) {
+ ui->setupUi(this);
- InitUI();
+ InitUI();
}
MainWindow::~MainWindow() {
- OsgViewer::Get().Uninitialize();
- delete ui;
+ OsgViewer::Get().Uninitialize();
+ delete ui;
}
void MainWindow::InitUI() {
- tabWidget_ = new QTabWidget;
- tabWidget_->setTabPosition(QTabWidget::South);
- tabWidget_->tabBar()->setMinimumWidth(300);
+ tabWidget_ = new QTabWidget;
+ tabWidget_->setTabPosition(QTabWidget::South);
+ tabWidget_->tabBar()->setMinimumWidth(300);
- ui->viewWidget->layout()->addWidget(tabWidget_);
+ ui->viewWidget->layout()->addWidget(tabWidget_);
- pSettingUI = new LayoutSettingUI();
+ pSettingUI = new LayoutSettingUI();
- const QString uiLaytouPath = RecourceHelper::Get().GetBasePath() + "/workspace/UILayout.xml";
+ const QString uiLaytouPath = RecourceHelper::Get().GetBasePath() + "/workspace/UILayout.xml";
- pSettingUI->InitConfig(uiLaytouPath);
- //pSettingUI->show();
+ pSettingUI->InitConfig(uiLaytouPath);
+ //pSettingUI->show();
- connect(pSettingUI, &LayoutSettingUI::signalUpdate, this, &MainWindow::InitDockLayout);
+ connect(pSettingUI, &LayoutSettingUI::signalUpdate, this, &MainWindow::InitDockLayout);
- setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
- setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
+ setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
+ setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
- DockWidget* model = new DockWidget(tr("model elements"), 0);
- // addDockWidget(pSettingUI->GetArea("ModelBrowser"), model);
- modelBrowser_ = new ModelBrowser(0);
- modelBrowser_->AttachDock(model);
- m_mapDockWidget.insert("ModelBrowser", model);
+ DockWidget* model = new DockWidget(tr("model elements"), 0);
+ // addDockWidget(pSettingUI->GetArea("ModelBrowser"), model);
+ modelBrowser_ = new ModelBrowser(0);
+ modelBrowser_->AttachDock(model);
+ m_mapDockWidget.insert("ModelBrowser", model);
- DockWidget* attribte = new DockWidget(tr("attribte"), 0);
- //addDockWidget(pSettingUI->GetArea("PropertyBrowser"), attribte);
- propertyBrowser_ = new PropertyBrowser(0);
- propertyBrowser_->AttachDock(attribte);
- m_mapDockWidget.insert("PropertyBrowser", attribte);
+ DockWidget* attribte = new DockWidget(tr("attribte"), 0);
+ //addDockWidget(pSettingUI->GetArea("PropertyBrowser"), attribte);
+ propertyBrowser_ = new PropertyBrowser(0);
+ propertyBrowser_->AttachDock(attribte);
+ m_mapDockWidget.insert("PropertyBrowser", attribte);
- connect(modelBrowser_, &ModelBrowser::WorkSpaceChange, propertyBrowser_, &PropertyBrowser::OnWorkSpaceChange);
- connect(modelBrowser_, &ModelBrowser::EntityChange, propertyBrowser_, &PropertyBrowser::OnEntityChange);
+ connect(modelBrowser_, &ModelBrowser::WorkSpaceChange, propertyBrowser_, &PropertyBrowser::OnWorkSpaceChange);
+ connect(modelBrowser_, &ModelBrowser::EntityChange, propertyBrowser_, &PropertyBrowser::OnEntityChange);
- qtOsgViewWidget_ = new QtOsgViewWidget;
- qtOsgViewWidget_->Initialize();
- m_mapDockWidget.insert("PropertyBrowser", attribte);
+ qtOsgViewWidget_ = new QtOsgViewWidget;
+ qtOsgViewWidget_->Initialize();
+ m_mapDockWidget.insert("PropertyBrowser", attribte);
- QString wavePath ="", speedPath = "", rdPath = "", matlabParam="";
- if (WorkSpaceManager::Get().GetCurrent())
- {
- if (!WorkSpaceManager::Get().GetCurrent()->GetWavePath().isEmpty())
- {
- wavePath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetWavePath();
- }
+ QString wavePath = "", speedPath = "", rdPath = "", matlabParam = "";
+ if (WorkSpaceManager::Get().GetCurrent())
+ {
+ if (!WorkSpaceManager::Get().GetCurrent()->GetWavePath().isEmpty())
+ {
+ wavePath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetWavePath();
+ }
- if (!WorkSpaceManager::Get().GetCurrent()->GetReportPath().isEmpty())
- {
- speedPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetReportPath();
- }
+ if (!WorkSpaceManager::Get().GetCurrent()->GetReportPath().isEmpty())
+ {
+ speedPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetReportPath();
+ }
- if (!WorkSpaceManager::Get().GetCurrent()->GetRDPath().isEmpty())
- {
- rdPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetRDPath();
- }
+ if (!WorkSpaceManager::Get().GetCurrent()->GetRDPath().isEmpty())
+ {
+ rdPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetRDPath();
+ }
- if (!WorkSpaceManager::Get().GetCurrent()->GetMatlabParam().isEmpty())
- {
- matlabParam = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetMatlabParam();
- }
- }
+ if (!WorkSpaceManager::Get().GetCurrent()->GetMatlabParam().isEmpty())
+ {
+ matlabParam = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetMatlabParam();
+ }
+ }
- DockWidget* fitCurveDock = new DockWidget(tr("Wave Curve"), 0);
- fitCurveDlg_ = new FitCurveDialog(1);
- fitCurveDlg_->AttachDock(fitCurveDock);
- m_mapDockWidget.insert("WaveCurveDialog", fitCurveDock);
+ DockWidget* fitCurveDock = new DockWidget(tr("Wave Curve"), 0);
+ fitCurveDlg_ = new FitCurveDialog(1);
+ fitCurveDlg_->AttachDock(fitCurveDock);
+ m_mapDockWidget.insert("WaveCurveDialog", fitCurveDock);
- fitCurveDlg_->InitWaveFile(wavePath);
- DockWidget* fitLgCurveDock = new DockWidget(tr("Speed Curve"), 0);
+ fitCurveDlg_->InitWaveFile(wavePath);
+ DockWidget* fitLgCurveDock = new DockWidget(tr("Speed Curve"), 0);
- fitYLgCurveDlg_ = new FitCurveDialog(1);
- fitYLgCurveDlg_->AttachDock(fitLgCurveDock);
- m_mapDockWidget.insert("SpeedCurveDialog", fitLgCurveDock);
+ fitYLgCurveDlg_ = new FitCurveDialog(1);
+ fitYLgCurveDlg_->AttachDock(fitLgCurveDock);
+ m_mapDockWidget.insert("SpeedCurveDialog", fitLgCurveDock);
- fitYLgCurveDlg_->InitReportFile(speedPath);
+ fitYLgCurveDlg_->InitReportFile(speedPath);
- DockWidget* surfaceCurveDock = new DockWidget(tr("3D Curve"), 0);
-
- surfaceDlg_ = new SurfaceDialog();
- surfaceDlg_->AttachDock(surfaceCurveDock);
- m_mapDockWidget.insert("3DCurveDialog", surfaceCurveDock);
+ DockWidget* surfaceCurveDock = new DockWidget(tr("3D Curve"), 0);
- surfaceDlg_->InitRD(rdPath);
+ surfaceDlg_ = new SurfaceDialog();
+ surfaceDlg_->AttachDock(surfaceCurveDock);
+ m_mapDockWidget.insert("3DCurveDialog", surfaceCurveDock);
- {
- targetUITable_ = new TargetListWgt;
+ surfaceDlg_->InitRD(rdPath);
- QStringList headerLabels;
- 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_ = new TargetListWgt;
- targetUITable_->SetHeader(headerLabels);
- //const QString reportPath = RecourceHelper::Get().GetBasePath() + "/workspace/Report.txt";
- targetUITable_->InitFile(speedPath, 50);
+ QStringList headerLabels;
+ 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");
- DockWidget* dataTableDock = new DockWidget(tr("Report Table"), 0);
- // addDockWidget(pSettingUI->GetArea("TargetListWgt"), dataTableDock);
- targetUITable_->AttachDock(dataTableDock);
- m_mapDockWidget.insert("TargetListWgt_Table", dataTableDock);
+ targetUITable_->SetHeader(headerLabels);
+ //const QString reportPath = RecourceHelper::Get().GetBasePath() + "/workspace/Report.txt";
+ targetUITable_->InitFile(speedPath, 50);
- }
+ DockWidget* dataTableDock = new DockWidget(tr("Report Table"), 0);
+ // addDockWidget(pSettingUI->GetArea("TargetListWgt"), dataTableDock);
+ targetUITable_->AttachDock(dataTableDock);
+ m_mapDockWidget.insert("TargetListWgt_Table", dataTableDock);
- const QString lampPath = RecourceHelper::Get().GetBasePath() + "/workspace/Lamp.txt";
+ }
- DockWidget* signalIndicatorLampDock = new DockWidget(tr("Signal Indicator Lamp"), 0);
- signalIndicatorLampUI_ = new SignalIndicatorLampUI;
- signalIndicatorLampUI_->AttachDock(signalIndicatorLampDock);
- signalIndicatorLampUI_->InitLamp(lampPath);
+ const QString lampPath = RecourceHelper::Get().GetBasePath() + "/workspace/Lamp.txt";
- m_mapDockWidget.insert("SignalIndicatorLampUI", signalIndicatorLampDock);
+ DockWidget* signalIndicatorLampDock = new DockWidget(tr("Signal Indicator Lamp"), 0);
+ signalIndicatorLampUI_ = new SignalIndicatorLampUI;
+ signalIndicatorLampUI_->AttachDock(signalIndicatorLampDock);
+ signalIndicatorLampUI_->InitLamp(lampPath);
- DockWidget* addParamSettingDock = new DockWidget(tr("ParamSetting"), 0);
- addParamDlg_ = new AddParamSetting(matlabParam);
- addParamDlg_->AttachDock(addParamSettingDock);
- m_mapDockWidget.insert("ParamSetting", addParamSettingDock);
+ m_mapDockWidget.insert("SignalIndicatorLampUI", signalIndicatorLampDock);
- DockWidget* matlabDock = new DockWidget(tr("Matlab File"), 0);
- matlabFileDlg_ = new CodeEdtUI;
- matlabFileDlg_->AttachDock(matlabDock);
- m_mapDockWidget.insert("Matlab", matlabDock);
+ DockWidget* addParamSettingDock = new DockWidget(tr("ParamSetting"), 0);
+ addParamDlg_ = new AddParamSetting(matlabParam);
+ addParamDlg_->AttachDock(addParamSettingDock);
+ m_mapDockWidget.insert("ParamSetting", addParamSettingDock);
- ui->discript->setText(tr("name: 5year 0412"));
- //ui->status->setText(tr("start: no start"));
+ DockWidget* matlabDock = new DockWidget(tr("bat File"), 0);
+ matlabFileDlg_ = new CodeEdtUI;
+ matlabFileDlg_->AttachDock(matlabDock);
+ m_mapDockWidget.insert("Matlab", matlabDock);
- InitDockLayout();
-
- //ui->viewWidget->layout()->addWidget(qtOsgViewWidget_);
- qtOsgViewWidget_->LoadDefaultScene();
- OsgViewer::Get().Initialize();
- OsgViewer::Get().OnFrame();
+ ui->discript->setText(tr("name: 5year 0412"));
+ //ui->status->setText(tr("start: no start"));
-#if 1
- // MatlabObject* mtlb = new MatlabObject;
- MatlabObject::GetInstance()->RunMatlabFile("");
+ InitDockLayout();
+
+ //ui->viewWidget->layout()->addWidget(qtOsgViewWidget_);
+ qtOsgViewWidget_->LoadDefaultScene();
+ OsgViewer::Get().Initialize();
+ OsgViewer::Get().OnFrame();
+
+#if 0
+ // MatlabObject* mtlb = new MatlabObject;
+ MatlabObject::GetInstance()->RunMatlabFile("");
#endif // 1
}
void MainWindow::InitDockLayout() {
- while (tabWidget_->count() > 0) {
- tabWidget_->removeTab(0);
- }
+ while (tabWidget_->count() > 0) {
+ tabWidget_->removeTab(0);
+ }
- QVariantList listTab = pSettingUI->GetAreaLayout().toList();
- for (int i = 0; i < listTab.size(); i++) {
- QVariantMap mapTab = listTab[i].toMap();
- QString strTabName = mapTab.value("Name").toString();
+ tabWidget_->tabBar()->setExpanding(true);
- QMainWindow* mainWindow_ = new QMainWindow;
- connect(mainWindow_, &QMainWindow::tabifiedDockWidgetActivated, this, &MainWindow::OnTabifiedDockWidgetActivated);
+ QVariantList listTab = pSettingUI->GetAreaLayout().toList();
+ for (int i = 0; i < listTab.size(); i++) {
+ QVariantMap mapTab = listTab[i].toMap();
+ QString strTabName = mapTab.value("Name").toString();
- QVariantList listDocArea = mapTab.value("Widget").toList();
+ CustomMainWindow* mainWindow_ = new CustomMainWindow;
+ mainWindow_->setDockOptions(QMainWindow::AllowNestedDocks |
+ QMainWindow::AllowTabbedDocks | QMainWindow::AnimatedDocks |
+ QMainWindow::ForceTabbedDocks | QMainWindow::VerticalTabs);
- tabWidget_->insertTab(i, mainWindow_, strTabName);
- if (listDocArea[0].toList().size() > 0) {
- mainWindow_->setCentralWidget(qtOsgViewWidget_);
- OsgViewer::Get().Initialize();
- OsgViewer::Get().OnFrame();
- } else {
- mainWindow_->takeCentralWidget();
- }
+ connect(mainWindow_, &QMainWindow::tabifiedDockWidgetActivated, this, &MainWindow::OnTabifiedDockWidgetActivated);
+ QVariantList listDocArea = mapTab.value("Widget").toList();
- if (listDocArea.size() > 0) {
- QDockWidget* lastDock = nullptr;
+ tabWidget_->insertTab(i, mainWindow_, strTabName);
+ if (listDocArea[0].toList().size() > 0) {
+ mainWindow_->setCentralWidget(qtOsgViewWidget_);
+ OsgViewer::Get().Initialize();
+ OsgViewer::Get().OnFrame();
+ }
+ else {
+ mainWindow_->takeCentralWidget();
+ }
- for (int j = 1; j < listDocArea.size(); j++) {
- Qt::DockWidgetArea dockArea;
- if (j == 1) {
- dockArea = Qt::LeftDockWidgetArea;
- } else if (j == 2) {
- dockArea = Qt::TopDockWidgetArea;
- } else if (j == 3) {
- dockArea = Qt::RightDockWidgetArea;
- } else if (j == 4) {
- dockArea = Qt::BottomDockWidgetArea;
- }
+ if (listDocArea.size() > 0) {
+ QDockWidget* lastDock = nullptr;
- QVariantList listDocAreaChild = listDocArea[j].toList();
- for (int m = 0; m < listDocAreaChild.size(); m++) {
- QVariant varWidget = listDocAreaChild[m];
+ for (int j = 1; j < listDocArea.size(); j++) {
+ Qt::DockWidgetArea dockArea;
+ if (j == 1) {
+ dockArea = Qt::LeftDockWidgetArea;
+ }
+ else if (j == 2) {
+ dockArea = Qt::TopDockWidgetArea;
+ }
+ else if (j == 3) {
+ dockArea = Qt::RightDockWidgetArea;
+ }
+ else if (j == 4) {
+ dockArea = Qt::BottomDockWidgetArea;
+ }
- if (varWidget.type() == QVariant::String) {
- QDockWidget* pDock = m_mapDockWidget.value(varWidget.toString());
- if (pDock == nullptr) {
- continue;
- }
- mainWindow_->addDockWidget(dockArea, pDock);
- lastDock = pDock;
- } else {
- QVariantList listWidget = varWidget.toList();
- for (int k = 0; k < listWidget.size(); k++) {
- QDockWidget* pDock = m_mapDockWidget.value(listWidget[k].toString());
- mainWindow_->addDockWidget(dockArea, pDock);
+ QVariantList listDocAreaChild = listDocArea[j].toList();
+ for (int m = 0; m < listDocAreaChild.size(); m++) {
+ QVariant varWidget = listDocAreaChild[m];
- if (k == 0) {
- if (lastDock) {
- mainWindow_->splitDockWidget(lastDock, pDock, Qt::Vertical);
- }
- } else {
- mainWindow_->splitDockWidget(lastDock, pDock, Qt::Horizontal);
- }
+ if (varWidget.type() == QVariant::String) {
+ QDockWidget* pDock = m_mapDockWidget.value(varWidget.toString());
+ if (pDock == nullptr) {
+ continue;
+ }
+ mainWindow_->addDockWidget(dockArea, pDock);
+ lastDock = pDock;
+ }
+ else {
+ QVariantList listWidget = varWidget.toList();
+ for (int k = 0; k < listWidget.size(); k++) {
+ QDockWidget* pDock = m_mapDockWidget.value(listWidget[k].toString());
+ mainWindow_->addDockWidget(dockArea, pDock);
- lastDock = pDock;
- }
- }
- }
- }
- }
- }
+ if (k == 0) {
+ if (lastDock) {
+ mainWindow_->splitDockWidget(lastDock, pDock, Qt::Vertical);
+ }
+ }
+ else {
+ mainWindow_->splitDockWidget(lastDock, pDock, Qt::Horizontal);
+ }
- /* AddDockArea("DockLeftArea");
- AddDockArea("DockTopArea");
- AddDockArea("DockRightArea");
- AddDockArea("DockBottomArea");*/
+ lastDock = pDock;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ tabWidget_->tabBar()->setMinimumWidth(500);
+
+ /* AddDockArea("DockLeftArea");
+ AddDockArea("DockTopArea");
+ AddDockArea("DockRightArea");
+ AddDockArea("DockBottomArea");*/
}
void MainWindow::AddDockArea(const QString& strArea) {
- Qt::DockWidgetArea dockArea;
- Qt::Orientation orient;
+ Qt::DockWidgetArea dockArea;
+ Qt::Orientation orient;
- if (strArea == "DockLeftArea") {
- dockArea = Qt::LeftDockWidgetArea;
- orient = Qt::Vertical;
- } else if (strArea == "DockTopArea") {
- dockArea = Qt::TopDockWidgetArea;
- orient = Qt::Horizontal;
- } else if (strArea == "DockRightArea") {
- dockArea = Qt::RightDockWidgetArea;
- orient = Qt::Vertical;
- } else if (strArea == "DockBottomArea") {
- dockArea = Qt::BottomDockWidgetArea;
- orient = Qt::Horizontal;
- } else {
- return;
- }
+ if (strArea == "DockLeftArea") {
+ dockArea = Qt::LeftDockWidgetArea;
+ orient = Qt::Vertical;
+ }
+ else if (strArea == "DockTopArea") {
+ dockArea = Qt::TopDockWidgetArea;
+ orient = Qt::Horizontal;
+ }
+ else if (strArea == "DockRightArea") {
+ dockArea = Qt::RightDockWidgetArea;
+ orient = Qt::Vertical;
+ }
+ else if (strArea == "DockBottomArea") {
+ dockArea = Qt::BottomDockWidgetArea;
+ orient = Qt::Horizontal;
+ }
+ else {
+ return;
+ }
- QList listAdd;
+ QList listAdd;
- QVariant varArea = pSettingUI->GetAreaLayout();
- if (varArea.isValid()) {
- QVariantList listWidget = varArea.toList();
- for each(QVariant varWidget in listWidget) {
- if (varWidget.type() == QVariant::String) {
- QDockWidget* pDock = m_mapDockWidget.value(varWidget.toString());
- addDockWidget(dockArea, pDock);
+ QVariant varArea = pSettingUI->GetAreaLayout();
+ if (varArea.isValid()) {
+ QVariantList listWidget = varArea.toList();
+ for each (QVariant varWidget in listWidget) {
+ if (varWidget.type() == QVariant::String) {
+ QDockWidget* pDock = m_mapDockWidget.value(varWidget.toString());
+ addDockWidget(dockArea, pDock);
- listAdd.push_back(pDock);
- } else {
- QDockWidget* pLastDock = nullptr;
- QVariantList listTab = varWidget.toList();
- for each(QVariant tabChild in listTab) {
- QDockWidget* pDock = m_mapDockWidget.value(tabChild.toString());
- addDockWidget(dockArea, pDock);
+ listAdd.push_back(pDock);
+ }
+ else {
+ QDockWidget* pLastDock = nullptr;
+ QVariantList listTab = varWidget.toList();
+ for each (QVariant tabChild in listTab) {
+ QDockWidget* pDock = m_mapDockWidget.value(tabChild.toString());
+ addDockWidget(dockArea, pDock);
- if (pLastDock) {
- //tabifyDockWidget(pLastDock, pDock);
- splitDockWidget(pLastDock, pDock, Qt::Horizontal);
- }
+ if (pLastDock) {
+ //tabifyDockWidget(pLastDock, pDock);
+ splitDockWidget(pLastDock, pDock, Qt::Horizontal);
+ }
- listAdd.push_back(pDock);
+ listAdd.push_back(pDock);
- pLastDock = pDock;
- }
- }
- }
- }
- QList listSpliter;
- for (size_t i = 0; i < listAdd.size(); i++) {
- listSpliter.push_back(1);
- }
+ pLastDock = pDock;
+ }
+ }
+ }
+ }
+ QList listSpliter;
+ for (size_t i = 0; i < listAdd.size(); i++) {
+ listSpliter.push_back(1);
+ }
+
+ resizeDocks(listAdd, listSpliter, orient);
+}
+
+void MainWindow::SaveDockStatus()
+{
- resizeDocks(listAdd, listSpliter, orient);
}
void MainWindow::OnTabifiedDockWidgetActivated(QDockWidget* dockWidget) {
- if (dockWidget) {
- QMainWindow* mainWindow = qobject_cast(dockWidget->parentWidget());
- if (mainWindow) {
- mainWindow->removeDockWidget(dockWidget);
- }
+ //if (dockWidget) {
+ // QMainWindow* mainWindow = qobject_cast(dockWidget->parentWidget());
+ // if (mainWindow) {
+ // mainWindow->removeDockWidget(dockWidget);
+ // }
- // tabWidget_->setCurrentWidget(dockWidget->parentWidget());
- }
+ // // tabWidget_->setCurrentWidget(dockWidget->parentWidget());
+ //}
}
void MainWindow::slotShowUISetting() {
- pSettingUI->show();
+ pSettingUI->show();
}
void MainWindow::slotResetWorkSpace()
{
- QString wavePath = "", speedPath = "", rdPath = "";
- if (WorkSpaceManager::Get().GetCurrent())
- {
- if (!WorkSpaceManager::Get().GetCurrent()->GetWavePath().isEmpty())
- {
- wavePath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetWavePath();
- }
+ QString wavePath = "", speedPath = "", rdPath = "";
+ if (WorkSpaceManager::Get().GetCurrent())
+ {
+ if (!WorkSpaceManager::Get().GetCurrent()->GetWavePath().isEmpty())
+ {
+ wavePath = WorkSpaceManager::Get().GetCurrent()->GetWavePath();
+ //wavePath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetWavePath();
+ }
- if (!WorkSpaceManager::Get().GetCurrent()->GetReportPath().isEmpty())
- {
- speedPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetReportPath();
- }
+ if (!WorkSpaceManager::Get().GetCurrent()->GetReportPath().isEmpty())
+ {
+ speedPath = WorkSpaceManager::Get().GetCurrent()->GetReportPath();
+ //speedPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetReportPath();
+ }
- if (!WorkSpaceManager::Get().GetCurrent()->GetRDPath().isEmpty())
- {
- rdPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetRDPath();
- }
- }
+ if (!WorkSpaceManager::Get().GetCurrent()->GetRDPath().isEmpty())
+ {
+ rdPath = WorkSpaceManager::Get().GetCurrent()->GetRDPath();
+ //rdPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetRDPath();
+ }
+ }
- fitCurveDlg_->InitWaveFile(wavePath);
- fitYLgCurveDlg_->InitReportFile(speedPath);
- surfaceDlg_->InitRD(rdPath);
- targetUITable_->InitFile(speedPath, 50);
+ fitCurveDlg_->InitWaveFile(wavePath);
+ fitYLgCurveDlg_->InitReportFile(speedPath);
+ surfaceDlg_->InitRD(rdPath);
+ targetUITable_->InitFile(speedPath, 50);
}
diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h
index 13d0abc8..13ac7702 100644
--- a/src/ui/MainWindow.h
+++ b/src/ui/MainWindow.h
@@ -46,6 +46,8 @@ private:
void InitDockLayout();
void AddDockArea(const QString& strArea);
+ void SaveDockStatus();
+
protected:
void OnTabifiedDockWidgetActivated(QDockWidget* dockWidget);
diff --git a/src/ui/Menu/ChartPlotMenu.cpp b/src/ui/Menu/ChartPlotMenu.cpp
index 7d4d9407..d0af89f7 100644
--- a/src/ui/Menu/ChartPlotMenu.cpp
+++ b/src/ui/Menu/ChartPlotMenu.cpp
@@ -6,6 +6,8 @@
#include "workspace/WorkSpaceManager.h"
#include
+#include
+
ChartPlotMenu::ChartPlotMenu(QWidget *parent)
: QWidget(parent)
{
@@ -24,13 +26,9 @@ void ChartPlotMenu::InitMenu()
connect(ui.toolButton, &QToolButton::clicked, this, [=] {
if (WorkSpaceManager::Get().GetCurrent())
{
-
QString strFile = WorkSpaceManager::Get().GetCurrent()->GetSimMatlab();
if (!strFile.isEmpty())
{
- strFile = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetSimMatlab();
-
- //MatlabObject::GetInstance()->RunMatlabFile("D:\\DYT\\TestGUI\\xierutest.m");
MatlabObject::GetInstance()->RunMatlabFile(strFile);
}
else
@@ -39,4 +37,147 @@ void ChartPlotMenu::InitMenu()
}
}
});
+
+ connect(ui.toolButton_2, &QToolButton::clicked, this, [=] {
+ auto current = WorkSpaceManager::Get().GetCurrent();
+ if (nullptr == current) {
+ QMessageBox::information(nullptr, QString::fromLocal8Bit("ʾ"), QString::fromLocal8Bit("ȴռ䣡"));
+ return;
+ }
+ QString strSel = QFileDialog::getOpenFileName(this, u8"ѡļ", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.m");
+ if (strSel.isEmpty()) {
+ LOG_WARN("ѡļΪ");
+ return;
+ }
+
+ const QString old = current->GetSimMatlab();
+ if (old == strSel) {
+ LOG_INFO("ѡļ뵱ǰļͬ");
+ return;
+ } else if (!old.isEmpty()) {
+ if (QMessageBox::Yes == QMessageBox::question(nullptr,
+ QString::fromLocal8Bit("ѯ"),
+ QString::fromLocal8Bit("滻ǰļ"),
+ QMessageBox::Yes | QMessageBox::No)
+ ) {
+ if (!QFile::remove(old)) {
+ LOG_WARN("ɾļʧ");
+ QMessageBox::information(nullptr,
+ QString::fromLocal8Bit("ʾ"),
+ QString::fromLocal8Bit("ɾļʧܣ"));
+ return;
+ }
+ }
+ }
+
+ current->SetSimMatlab(strSel);
+ });
+
+ connect(ui.toolButton_5, &QToolButton::clicked, this, [=] {
+ auto current = WorkSpaceManager::Get().GetCurrent();
+ if (nullptr == current) {
+ QMessageBox::information(nullptr, QString::fromLocal8Bit("ʾ"), QString::fromLocal8Bit("ȴռ䣡"));
+ return;
+ }
+ QString strSel = QFileDialog::getOpenFileName(this, u8"ѡWaveļ", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt");
+ if (strSel.isEmpty()) {
+ LOG_WARN("ѡļΪ");
+ return;
+ }
+
+ const QString old = current->GetWavePath();
+ if (old == strSel) {
+ LOG_INFO("ѡļ뵱ǰļͬ");
+ return;
+ }
+ else if (!old.isEmpty()) {
+ if (QMessageBox::Yes == QMessageBox::question(nullptr,
+ QString::fromLocal8Bit("ѯ"),
+ QString::fromLocal8Bit("滻ǰWaveļ"),
+ QMessageBox::Yes | QMessageBox::No)
+ ) {
+ if (!QFile::remove(old)) {
+ LOG_WARN("ɾļʧ");
+ QMessageBox::information(nullptr,
+ QString::fromLocal8Bit("ʾ"),
+ QString::fromLocal8Bit("ɾļʧܣ"));
+ return;
+ }
+ }
+ }
+
+ current->SetWavePath(strSel);
+ });
+
+ connect(ui.toolButton_3, &QToolButton::clicked, this, [=] {
+ auto current = WorkSpaceManager::Get().GetCurrent();
+ if (nullptr == current) {
+ QMessageBox::information(nullptr, QString::fromLocal8Bit("ʾ"), QString::fromLocal8Bit("ȴռ䣡"));
+ return;
+ }
+ QString strSel = QFileDialog::getOpenFileName(this, u8"ѡRDļ", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt");
+ if (strSel.isEmpty()) {
+ LOG_WARN("ѡļΪ");
+ return;
+ }
+
+ const QString old = current->GetRDPath();
+ if (old == strSel) {
+ LOG_INFO("ѡļ뵱ǰļͬ");
+ return;
+ }
+ else if (!old.isEmpty()) {
+ if (QMessageBox::Yes == QMessageBox::question(nullptr,
+ QString::fromLocal8Bit("ѯ"),
+ QString::fromLocal8Bit("滻ǰRDļ"),
+ QMessageBox::Yes | QMessageBox::No)
+ ) {
+ if (!QFile::remove(old)) {
+ LOG_WARN("ɾļʧ");
+ QMessageBox::information(nullptr,
+ QString::fromLocal8Bit("ʾ"),
+ QString::fromLocal8Bit("ɾļʧܣ"));
+ return;
+ }
+ }
+ }
+
+ current->SetRDPath(strSel);
+ });
+
+ connect(ui.toolButton_4, &QToolButton::clicked, this, [=] {
+ auto current = WorkSpaceManager::Get().GetCurrent();
+ if (nullptr == current) {
+ QMessageBox::information(nullptr, QString::fromLocal8Bit("ʾ"), QString::fromLocal8Bit("ȴռ䣡"));
+ return;
+ }
+ QString strSel = QFileDialog::getOpenFileName(this, u8"ѡReportļ", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt");
+ if (strSel.isEmpty()) {
+ LOG_WARN("ѡļΪ");
+ return;
+ }
+
+ const QString old = current->GetReportPath();
+ if (old == strSel) {
+ LOG_INFO("ѡļ뵱ǰļͬ");
+ return;
+ }
+ else if (!old.isEmpty()) {
+ if (QMessageBox::Yes == QMessageBox::question(nullptr,
+ QString::fromLocal8Bit("ѯ"),
+ QString::fromLocal8Bit("滻ǰReportļ"),
+ QMessageBox::Yes | QMessageBox::No)
+ ) {
+ if (!QFile::remove(old)) {
+ LOG_WARN("ɾļʧ");
+ QMessageBox::information(nullptr,
+ QString::fromLocal8Bit("ʾ"),
+ QString::fromLocal8Bit("ɾļʧܣ"));
+ return;
+ }
+ }
+ }
+
+ current->SetReportPath(strSel);
+ });
}
diff --git a/src/ui/Menu/ChartPlotMenu.ui b/src/ui/Menu/ChartPlotMenu.ui
index 6fed6772..bb5c389d 100644
--- a/src/ui/Menu/ChartPlotMenu.ui
+++ b/src/ui/Menu/ChartPlotMenu.ui
@@ -16,6 +16,58 @@
-
+
-
+
+
+
+ 60
+ 30
+
+
+
+ Wave文件
+
+
+
+ -
+
+
+
+ 60
+ 30
+
+
+
+ Report文件
+
+
+
+ -
+
+
+
+ 60
+ 30
+
+
+
+ RD文件
+
+
+
+ -
+
+
+
+ 60
+ 30
+
+
+
+ Matlab文件
+
+
+
-
diff --git a/src/ui/PropertyBrowser/qtpropertymanager.cpp b/src/ui/PropertyBrowser/qtpropertymanager.cpp
index 1c9bcb9b..5c234904 100644
--- a/src/ui/PropertyBrowser/qtpropertymanager.cpp
+++ b/src/ui/PropertyBrowser/qtpropertymanager.cpp
@@ -7875,22 +7875,10 @@ public:
QMap m_properyToName;
QMap m_properyToDescription;
QMap m_properyToTimestep;
- QMap m_properyToSimMatlab;
- QMap m_properyToMatlabParam;
-
- QMap m_properyToWave;
- QMap m_properyToReport;
- QMap m_properyToRD;
QMap m_nameToPropery;
QMap m_descriptionToPropery;
QMap m_timestepToPropery;
- QMap m_simMatlabToPropery;
- QMap m_matlabParamToPropery;
-
- QMap m_waveToPropery;
- QMap m_reportToPropery;
- QMap m_rdToPropery;
};
void QtWorkspacePropertyManagerPrivate::slotStringChanged(QtProperty* property, QString value) {
@@ -7906,11 +7894,7 @@ void QtWorkspacePropertyManagerPrivate::slotStringChanged(QtProperty* property,
QWorkspaceAttribute c = m_values[prop];
c.SetTimeStep(value);
q_ptr->setValue(prop, c);
- } else if (QtProperty* prop = m_simMatlabToPropery.value(property, 0)) {
- QWorkspaceAttribute c = m_values[prop];
- c.SetSimMatlab(value);
- q_ptr->setValue(prop, c);
- }
+ }
}
void QtWorkspacePropertyManagerPrivate::slotPropertyDestroyed(QtProperty* property) {
@@ -7928,31 +7912,6 @@ void QtWorkspacePropertyManagerPrivate::slotPropertyDestroyed(QtProperty* proper
m_timestepToPropery[subProp] = 0;
m_timestepToPropery.remove(property);
}
-
- if (QtProperty* subProp = m_simMatlabToPropery.value(property, nullptr)) {
- m_simMatlabToPropery[subProp] = 0;
- m_simMatlabToPropery.remove(property);
- }
-
- if (QtProperty* subProp = m_matlabParamToPropery.value(property, nullptr)) {
- m_matlabParamToPropery[subProp] = 0;
- m_matlabParamToPropery.remove(property);
- }
-
- if (QtProperty* subProp = m_waveToPropery.value(property, nullptr)) {
- m_waveToPropery[subProp] = 0;
- m_waveToPropery.remove(property);
- }
-
- if (QtProperty* subProp = m_reportToPropery.value(property, nullptr)) {
- m_reportToPropery[subProp] = 0;
- m_reportToPropery.remove(property);
- }
-
- if (QtProperty* subProp = m_rdToPropery.value(property, nullptr)) {
- m_rdToPropery[subProp] = 0;
- m_rdToPropery.remove(property);
- }
}
QtWorkspacePropertyManager::QtWorkspacePropertyManager(QObject* parent)
@@ -8037,12 +7996,6 @@ void QtWorkspacePropertyManager::setValue(QtProperty* property, const QWorkspace
d_ptr->m_stringProperyManager->setValue(d_ptr->m_properyToName[property], value.GetName());
d_ptr->m_stringProperyManager->setValue(d_ptr->m_properyToDescription[property], value.GetDescription());
d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToTimestep[property], value.GetTimeStep());
- d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToSimMatlab[property], value.GetSimMatlab());
- d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToMatlabParam[property], value.GetMatlabParam());
-
- d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToWave[property], value.GetWavePath());
- d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToReport[property], value.GetReportPath());
- d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToRD[property], value.GetRDPath());
emit propertyChanged(property);
emit valueChanged(property, value);
@@ -8075,41 +8028,6 @@ void QtWorkspacePropertyManager::initializeProperty(QtProperty* property) {
d_ptr->m_properyToTimestep[property] = prop;
d_ptr->m_timestepToPropery[prop] = property;
property->addSubProperty(prop);
-
- prop = d_ptr->m_filesProperyManager->addProperty();
- prop->setPropertyName(tr("SimMatlab"));
- d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetSimMatlab());
- d_ptr->m_properyToSimMatlab[property] = prop;
- d_ptr->m_simMatlabToPropery[prop] = property;
- property->addSubProperty(prop);
-
- prop = d_ptr->m_filesProperyManager->addProperty();
- prop->setPropertyName(tr("MatlabParam"));
- d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetMatlabParam());
- d_ptr->m_properyToMatlabParam[property] = prop;
- d_ptr->m_matlabParamToPropery[prop] = property;
- property->addSubProperty(prop);
-
- prop = d_ptr->m_filesProperyManager->addProperty();
- prop->setPropertyName(tr("Wave"));
- d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetWavePath());
- d_ptr->m_properyToWave[property] = prop;
- d_ptr->m_waveToPropery[prop] = property;
- property->addSubProperty(prop);
-
- prop = d_ptr->m_filesProperyManager->addProperty();
- prop->setPropertyName(tr("RD"));
- d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetRDPath());
- d_ptr->m_properyToRD[property] = prop;
- d_ptr->m_rdToPropery[prop] = property;
- property->addSubProperty(prop);
-
- prop = d_ptr->m_filesProperyManager->addProperty();
- prop->setPropertyName(tr("Report"));
- d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetReportPath());
- d_ptr->m_properyToReport[property] = prop;
- d_ptr->m_reportToPropery[prop] = property;
- property->addSubProperty(prop);
}
/*!
@@ -8136,41 +8054,6 @@ void QtWorkspacePropertyManager::uninitializeProperty(QtProperty* property) {
delete prop;
}
d_ptr->m_properyToTimestep.remove(property);
-
- prop = d_ptr->m_simMatlabToPropery[property];
- if (prop) {
- d_ptr->m_simMatlabToPropery.remove(prop);
- delete prop;
- }
- d_ptr->m_properyToSimMatlab.remove(property);
-
- prop = d_ptr->m_matlabParamToPropery[property];
- if (prop) {
- d_ptr->m_matlabParamToPropery.remove(prop);
- delete prop;
- }
- d_ptr->m_properyToMatlabParam.remove(property);
-
- prop = d_ptr->m_waveToPropery[property];
- if (prop) {
- d_ptr->m_waveToPropery.remove(prop);
- delete prop;
- }
- d_ptr->m_properyToWave.remove(property);
-
- prop = d_ptr->m_reportToPropery[property];
- if (prop) {
- d_ptr->m_reportToPropery.remove(prop);
- delete prop;
- }
- d_ptr->m_properyToReport.remove(property);
-
- prop = d_ptr->m_rdToPropery[property];
- if (prop) {
- d_ptr->m_rdToPropery.remove(prop);
- delete prop;
- }
- d_ptr->m_properyToRD.remove(property);
}
#pragma endregion
diff --git a/src/viewer/QtOsgViewWidget.cpp b/src/viewer/QtOsgViewWidget.cpp
index a57a24a0..c1dafbce 100644
--- a/src/viewer/QtOsgViewWidget.cpp
+++ b/src/viewer/QtOsgViewWidget.cpp
@@ -128,7 +128,7 @@ void QtOsgViewWidget::LoadDefaultScene(void) {
dyt_check(nullptr != activeScene_);
if (nullptr == WorkSpaceManager::Get().LoadDefaultWorkspace(activeScene_)) {
LOG_ERROR("load default workspace failed");
- QMessageBox::warning(this, tr("warning"), tr("default workspace failed"));
+ //QMessageBox::warning(this, tr("warning"), tr("default workspace failed"));
}
}
diff --git a/src/workspace/WorkSpace.cpp b/src/workspace/WorkSpace.cpp
index 677410a3..11fe22d1 100644
--- a/src/workspace/WorkSpace.cpp
+++ b/src/workspace/WorkSpace.cpp
@@ -14,6 +14,7 @@
#include "xml/tinyxml2.h"
#include "common/SpdLogger.h"
#include "entities/Entity.h"
+#include "utils/FileUtils.h"
//#include "workspace/WorkSpaceItemGroup.h"
//#include "workspace/WorkSpaceRiverGroup.h"
//#include "workspace/WorkSpaceRiverNetGroup.h"
@@ -38,6 +39,76 @@ const QString WorkSpace::GetDir() const {
return info.absolutePath();
}
+void WorkSpace::SetSimMatlab(const QString& path) {
+ QFileInfo fileInfo(path);
+ QString dirPath = QString("%1/%2").arg(GetDir(), fileInfo.fileName());
+ bool sucess = FileUtils::CopyFileToPath(path, dirPath, true);
+ LOG_INFO("copy simmatlab file {}: {} to {}",
+ path.toLocal8Bit().data(),
+ dirPath.toLocal8Bit().data(),
+ sucess);
+ simMatlabPath_ = fileInfo.fileName();
+}
+
+const QString WorkSpace::GetSimMatlab() const {
+ QString path = QString("%1/%2").arg(GetDir(), simMatlabPath_);
+ return path;
+}
+
+void WorkSpace::SetWavePath(const QString& path)
+{
+ QFileInfo fileInfo(path);
+ QString dirPath = QString("%1/%2").arg(GetDir(), fileInfo.fileName());
+ bool sucess = FileUtils::CopyFileToPath(path, dirPath, true);
+ LOG_INFO("copy Wave file {}: {} to {}",
+ path.toLocal8Bit().data(),
+ dirPath.toLocal8Bit().data(),
+ sucess);
+ waveFile_ = fileInfo.fileName();
+}
+
+const QString WorkSpace::GetWavePath() const
+{
+ QString path = QString("%1/%2").arg(GetDir(), waveFile_);
+ return path;
+}
+
+void WorkSpace::SetReportPath(const QString& path)
+{
+ QFileInfo fileInfo(path);
+ QString dirPath = QString("%1/%2").arg(GetDir(), fileInfo.fileName());
+ bool sucess = FileUtils::CopyFileToPath(path, dirPath, true);
+ LOG_INFO("copy Wave file {}: {} to {}",
+ path.toLocal8Bit().data(),
+ dirPath.toLocal8Bit().data(),
+ sucess);
+ reportFile_ = fileInfo.fileName();
+}
+
+const QString WorkSpace::GetReportPath() const
+{
+ QString path = QString("%1/%2").arg(GetDir(), reportFile_);
+ return path;
+}
+
+void WorkSpace::SetRDPath(const QString& path)
+{
+ QFileInfo fileInfo(path);
+ QString dirPath = QString("%1/%2").arg(GetDir(), fileInfo.fileName());
+ bool sucess = FileUtils::CopyFileToPath(path, dirPath, true);
+ LOG_INFO("copy RD file {}: {} to {}",
+ path.toLocal8Bit().data(),
+ dirPath.toLocal8Bit().data(),
+ sucess);
+ rdFile_ = fileInfo.fileName();
+}
+
+const QString WorkSpace::GetRDPath() const
+{
+ QString path = QString("%1/%2").arg(GetDir(), rdFile_);
+ return path;
+}
+
void WorkSpace::AddEntity(Entity* entity) {
if (nullptr == entity) {
LOG_WARN("entity is nullptr");
diff --git a/src/workspace/WorkSpace.h b/src/workspace/WorkSpace.h
index a61eabed..c540a062 100644
--- a/src/workspace/WorkSpace.h
+++ b/src/workspace/WorkSpace.h
@@ -46,12 +46,8 @@ public:
inline const QString& GetDescribe() const {
return describe_;
}
- inline void SetSimMatlab(const QString& path) {
- simMatlabPath_ = path;
- }
- inline const QString GetSimMatlab() const {
- return simMatlabPath_;
- }
+ void SetSimMatlab(const QString& path);
+ const QString GetSimMatlab() const;
inline void SetMatlabParam(const QString& path) {
matlabParamPath_ = path;
@@ -60,26 +56,14 @@ public:
return matlabParamPath_;
}
- inline void SetWavePath(const QString& path) {
- waveFile_ = path;
- }
- inline const QString GetWavePath() const {
- return waveFile_;
- }
+ void SetWavePath(const QString& path);
+ const QString GetWavePath() const;
- inline void SetReportPath(const QString& path) {
- reportFile_ = path;
- }
- inline const QString GetReportPath() const {
- return reportFile_;
- }
+ void SetReportPath(const QString& path) ;
+ const QString GetReportPath() const;
- inline void SetRDPath(const QString& path) {
- rdFile_ = path;
- }
- inline const QString GetRDPath() const {
- return rdFile_;
- }
+ void SetRDPath(const QString& path);
+ const QString GetRDPath() const;
inline void SetHomeViewpoint(const osgEarth::Viewpoint& viewpoint) {
homeViewpoint_ = viewpoint;
@@ -137,6 +121,11 @@ Q_SIGNALS:
void TimestepChanged(class Timestep* timestep);
void LampStatusChanged(class LampStatus* lampStatus);
+protected:
+ const QString& GetSimMatlabName() const {
+ return simMatlabPath_;
+ }
+
private:
QString name_;
QString uuid_;
@@ -155,6 +144,8 @@ private:
std::vector entities_;
OEScene* scene_{ nullptr };
class Timestep* timestep_{ nullptr };
- class LampStatus* lampStatus_{ nullptr };
+ class LampStatus* lampStatus_{ nullptr };
+
+ friend class WorkSpaceXMLWrite;
};
diff --git a/src/workspace/WorkSpaceXMLParse.cpp b/src/workspace/WorkSpaceXMLParse.cpp
index 71604656..e3321cfc 100644
--- a/src/workspace/WorkSpaceXMLParse.cpp
+++ b/src/workspace/WorkSpaceXMLParse.cpp
@@ -155,6 +155,33 @@ bool WorkSpaceXMLParse::ParseChart(const tinyxml2::XMLElement* element)
return true;
}
+bool WorkSpaceXMLParse::ParseSimMatlab(const tinyxml2::XMLElement* element)
+{
+ if (nullptr == element) {
+ LOG_WARN("element is nullptr");
+ return false;
+ }
+
+ const tinyxml2::XMLElement* xmlElement = element->FirstChildElement();
+ while (nullptr != xmlElement) {
+ const char* name = xmlElement->Name();
+ if (0 == strcmp(name, "SimMatlab"))
+ {
+ QVariantMap varChart;
+ const tinyxml2::XMLAttribute* attribute = xmlElement->FirstAttribute();
+ while (nullptr != attribute) {
+
+ WorkSpaceManager::Get().GetCurrent()->SetSimMatlab(QString::fromLocal8Bit(attribute->Value()));
+ attribute = attribute->Next();
+ }
+ }
+
+ xmlElement = xmlElement->NextSiblingElement();
+ }
+
+ return true;
+}
+
bool WorkSpaceXMLParse::ParseReport(const tinyxml2::XMLElement* element)
{
QString strFile = "";
@@ -208,6 +235,9 @@ bool WorkSpaceXMLParse::Load(const QString& dyt) {
else if (0 == strcmp(name, "ReportInfo")) {
ParseReport(xmlElement);
}
+ else if (0 == strcmp(name, "SimMatlab")) {
+ ParseSimMatlab(xmlElement);
+ }
xmlElement = xmlElement->NextSiblingElement();
}
diff --git a/src/workspace/WorkSpaceXMLParse.h b/src/workspace/WorkSpaceXMLParse.h
index 219f6fb5..60f4b468 100644
--- a/src/workspace/WorkSpaceXMLParse.h
+++ b/src/workspace/WorkSpaceXMLParse.h
@@ -34,6 +34,7 @@ private:
bool ParseEntities(const tinyxml2::XMLElement* element);
bool ParseChart(const tinyxml2::XMLElement* element);
bool ParseReport(const tinyxml2::XMLElement* element);
+ bool ParseSimMatlab(const tinyxml2::XMLElement* element);
private:
QString name_;
diff --git a/src/workspace/WorkSpaceXMLWrite.cpp b/src/workspace/WorkSpaceXMLWrite.cpp
index acaa67b8..8a55034e 100644
--- a/src/workspace/WorkSpaceXMLWrite.cpp
+++ b/src/workspace/WorkSpaceXMLWrite.cpp
@@ -114,7 +114,7 @@ bool WorkSpaceXMLWrite::SaveChart(tinyxml2::XMLElement* scene, tinyxml2::XMLDocu
tinyxml2::XMLElement* chart = doc->NewElement("SimMatlab");
charts->LinkEndChild(chart);
- chart->SetAttribute("SimMatlab", workSpace_->GetSimMatlab().toLocal8Bit().constData());
+ chart->SetAttribute("SimMatlab", workSpace_->GetSimMatlabName().toLocal8Bit().constData());
}
return true;
diff --git a/workspace/UILayout.xml b/workspace/UILayout.xml
index 59a9464b..9a86fca4 100644
--- a/workspace/UILayout.xml
+++ b/workspace/UILayout.xml
@@ -28,12 +28,12 @@
-
+
-
+