更新数据绑定程序

This commit is contained in:
15712809671 2025-05-25 11:32:25 +08:00
parent a4969a8aba
commit 183d51b538
17 changed files with 787 additions and 495 deletions

View File

@ -13,7 +13,7 @@ int main(int argc, char* argv[]) {
Application app(argc, argv);
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
InstallCrashHandler();
//InstallCrashHandler();
RecourceHelper::ChangeSkin("default");

View File

@ -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_);

View File

@ -96,38 +96,30 @@
</message>
<message>
<location filename="../ui/Menu/ChartPlotMenu.ui" line="28"/>
<source>Wave文件</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/Menu/ChartPlotMenu.ui" line="41"/>
<source>Report文件</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/Menu/ChartPlotMenu.ui" line="54"/>
<source>RD文件</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/Menu/ChartPlotMenu.ui" line="67"/>
<source>Matlab文件</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/Menu/ChartPlotMenu.ui" line="80"/>
<source>Run Simu</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CodeEdtUI</name>
<message>
<location filename="../ui/Layout/CodeEdtUI.cpp" line="74"/>
<source>matlab editor</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/Layout/CodeEdtUI.cpp" line="82"/>
<source>&amp;bat</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/Layout/CodeEdtUI.cpp" line="102"/>
<source>&amp;Control</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/Layout/CodeEdtUI.cpp" line="104"/>
<source>&amp;Run</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/Layout/CodeEdtUI.cpp" line="107"/>
<source>&amp;Save</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CodeEdtUIClass</name>
<message>
@ -612,7 +604,7 @@
</message>
<message>
<location filename="../ui/MainWindow.cpp" line="175"/>
<source>Matlab File</source>
<source>bat File</source>
<translation type="unfinished"></translation>
</message>
<message>
@ -923,43 +915,43 @@
<context>
<name>QtConeWaveComponentManager</name>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8848"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8857"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8731"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8740"/>
<source>ConeWaveComponent</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8944"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8827"/>
<source>Height</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8951"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8834"/>
<source>Radius</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8958"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8841"/>
<source>levelCount</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8965"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8848"/>
<source>levelHeight</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8972"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8855"/>
<source>Color1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8979"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8862"/>
<source>Color2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8986"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8869"/>
<source>Color3</source>
<translation type="unfinished"></translation>
</message>
@ -1065,28 +1057,28 @@
<context>
<name>QtDashedLineComponentManager</name>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9171"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9180"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9054"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9063"/>
<source>DashedLineComponent</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9249"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9132"/>
<source>Start</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9256"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9139"/>
<source>End</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9263"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9146"/>
<source>Radius</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9270"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9153"/>
<source>Color</source>
<translation type="unfinished"></translation>
</message>
@ -1102,12 +1094,12 @@
<context>
<name>QtEntityPropertyManager</name>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8328"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8211"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8335"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8218"/>
<source>Transform</source>
<translation type="unfinished"></translation>
</message>
@ -1189,13 +1181,13 @@
<context>
<name>QtMeshComponetManager</name>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8442"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8451"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8325"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8334"/>
<source>MeshComponent</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8524"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8407"/>
<source>Mesh</source>
<translation type="unfinished"></translation>
</message>
@ -1226,16 +1218,10 @@
<context>
<name>QtOsgViewWidget</name>
<message>
<location filename="../viewer/QtOsgViewWidget.cpp" line="131"/>
<location filename="../viewer/QtOsgViewWidget.cpp" line="139"/>
<source>warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../viewer/QtOsgViewWidget.cpp" line="131"/>
<source>default workspace failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../viewer/QtOsgViewWidget.cpp" line="139"/>
<source>open dyt file failed</source>
@ -1245,13 +1231,13 @@
<context>
<name>QtPathComponentManager</name>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8601"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8610"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8484"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8493"/>
<source>PathComponent</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8683"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8566"/>
<source>Path</source>
<translation type="unfinished"></translation>
</message>
@ -1501,45 +1487,20 @@
<context>
<name>QtWorkspacePropertyManager</name>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8059"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8012"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8066"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8019"/>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8073"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8026"/>
<source>Timestep</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8080"/>
<source>SimMatlab</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8087"/>
<source>MatlabParam</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8094"/>
<source>Wave</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8101"/>
<source>RD</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8108"/>
<source>Report</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SignalIndicatorLampUI</name>

View File

@ -5,6 +5,16 @@
#include <QLabel>
#include <QTimer>
#include <QApplication>
#include <QMainWindow>
#include <QMouseEvent>
#include <QDrag>
#include <QMimeData>
#include <QJsonObject>
#include <QTextStream>
#include <QFile>
#include <QJsonDocument>
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 };
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<QDockWidget*>()) {
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<QDockWidget*>(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<Qt::DockWidgetArea>(
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<DockWidget*>(event->source());
if (dock && dock->parent() != this) {
// 从原窗口移除
QMainWindow* oldParent = qobject_cast<QMainWindow*>(dock->parent());
if (oldParent) oldParent->removeDockWidget(dock);
// 添加到当前窗口
dock->setParent(this);
addDockWidget(Qt::RightDockWidgetArea, dock);
dock->show();
event->acceptProposedAction();
}
}
};

View File

@ -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);

View File

@ -87,7 +87,7 @@ void MainWindow::InitUI() {
qtOsgViewWidget_->Initialize();
m_mapDockWidget.insert("PropertyBrowser", attribte);
QString wavePath ="", speedPath = "", rdPath = "", matlabParam="";
QString wavePath = "", speedPath = "", rdPath = "", matlabParam = "";
if (WorkSpaceManager::Get().GetCurrent())
{
if (!WorkSpaceManager::Get().GetCurrent()->GetWavePath().isEmpty())
@ -172,7 +172,7 @@ void MainWindow::InitUI() {
addParamDlg_->AttachDock(addParamSettingDock);
m_mapDockWidget.insert("ParamSetting", addParamSettingDock);
DockWidget* matlabDock = new DockWidget(tr("Matlab File"), 0);
DockWidget* matlabDock = new DockWidget(tr("bat File"), 0);
matlabFileDlg_ = new CodeEdtUI;
matlabFileDlg_->AttachDock(matlabDock);
m_mapDockWidget.insert("Matlab", matlabDock);
@ -187,7 +187,7 @@ void MainWindow::InitUI() {
OsgViewer::Get().Initialize();
OsgViewer::Get().OnFrame();
#if 1
#if 0
// MatlabObject* mtlb = new MatlabObject;
MatlabObject::GetInstance()->RunMatlabFile("");
#endif // 1
@ -198,12 +198,18 @@ void MainWindow::InitDockLayout() {
tabWidget_->removeTab(0);
}
tabWidget_->tabBar()->setExpanding(true);
QVariantList listTab = pSettingUI->GetAreaLayout().toList();
for (int i = 0; i < listTab.size(); i++) {
QVariantMap mapTab = listTab[i].toMap();
QString strTabName = mapTab.value("Name").toString();
QMainWindow* mainWindow_ = new QMainWindow;
CustomMainWindow* mainWindow_ = new CustomMainWindow;
mainWindow_->setDockOptions(QMainWindow::AllowNestedDocks |
QMainWindow::AllowTabbedDocks | QMainWindow::AnimatedDocks |
QMainWindow::ForceTabbedDocks | QMainWindow::VerticalTabs);
connect(mainWindow_, &QMainWindow::tabifiedDockWidgetActivated, this, &MainWindow::OnTabifiedDockWidgetActivated);
QVariantList listDocArea = mapTab.value("Widget").toList();
@ -213,11 +219,11 @@ void MainWindow::InitDockLayout() {
mainWindow_->setCentralWidget(qtOsgViewWidget_);
OsgViewer::Get().Initialize();
OsgViewer::Get().OnFrame();
} else {
}
else {
mainWindow_->takeCentralWidget();
}
if (listDocArea.size() > 0) {
QDockWidget* lastDock = nullptr;
@ -225,11 +231,14 @@ void MainWindow::InitDockLayout() {
Qt::DockWidgetArea dockArea;
if (j == 1) {
dockArea = Qt::LeftDockWidgetArea;
} else if (j == 2) {
}
else if (j == 2) {
dockArea = Qt::TopDockWidgetArea;
} else if (j == 3) {
}
else if (j == 3) {
dockArea = Qt::RightDockWidgetArea;
} else if (j == 4) {
}
else if (j == 4) {
dockArea = Qt::BottomDockWidgetArea;
}
@ -244,7 +253,8 @@ void MainWindow::InitDockLayout() {
}
mainWindow_->addDockWidget(dockArea, pDock);
lastDock = pDock;
} else {
}
else {
QVariantList listWidget = varWidget.toList();
for (int k = 0; k < listWidget.size(); k++) {
QDockWidget* pDock = m_mapDockWidget.value(listWidget[k].toString());
@ -254,7 +264,8 @@ void MainWindow::InitDockLayout() {
if (lastDock) {
mainWindow_->splitDockWidget(lastDock, pDock, Qt::Vertical);
}
} else {
}
else {
mainWindow_->splitDockWidget(lastDock, pDock, Qt::Horizontal);
}
@ -266,6 +277,8 @@ void MainWindow::InitDockLayout() {
}
}
tabWidget_->tabBar()->setMinimumWidth(500);
/* AddDockArea("DockLeftArea");
AddDockArea("DockTopArea");
AddDockArea("DockRightArea");
@ -279,16 +292,20 @@ void MainWindow::AddDockArea(const QString& strArea) {
if (strArea == "DockLeftArea") {
dockArea = Qt::LeftDockWidgetArea;
orient = Qt::Vertical;
} else if (strArea == "DockTopArea") {
}
else if (strArea == "DockTopArea") {
dockArea = Qt::TopDockWidgetArea;
orient = Qt::Horizontal;
} else if (strArea == "DockRightArea") {
}
else if (strArea == "DockRightArea") {
dockArea = Qt::RightDockWidgetArea;
orient = Qt::Vertical;
} else if (strArea == "DockBottomArea") {
}
else if (strArea == "DockBottomArea") {
dockArea = Qt::BottomDockWidgetArea;
orient = Qt::Horizontal;
} else {
}
else {
return;
}
@ -297,16 +314,17 @@ void MainWindow::AddDockArea(const QString& strArea) {
QVariant varArea = pSettingUI->GetAreaLayout();
if (varArea.isValid()) {
QVariantList listWidget = varArea.toList();
for each(QVariant varWidget in listWidget) {
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 {
}
else {
QDockWidget* pLastDock = nullptr;
QVariantList listTab = varWidget.toList();
for each(QVariant tabChild in listTab) {
for each (QVariant tabChild in listTab) {
QDockWidget* pDock = m_mapDockWidget.value(tabChild.toString());
addDockWidget(dockArea, pDock);
@ -330,15 +348,20 @@ void MainWindow::AddDockArea(const QString& strArea) {
resizeDocks(listAdd, listSpliter, orient);
}
void MainWindow::OnTabifiedDockWidgetActivated(QDockWidget* dockWidget) {
if (dockWidget) {
QMainWindow* mainWindow = qobject_cast<QMainWindow*>(dockWidget->parentWidget());
if (mainWindow) {
mainWindow->removeDockWidget(dockWidget);
}
void MainWindow::SaveDockStatus()
{
// tabWidget_->setCurrentWidget(dockWidget->parentWidget());
}
}
void MainWindow::OnTabifiedDockWidgetActivated(QDockWidget* dockWidget) {
//if (dockWidget) {
// QMainWindow* mainWindow = qobject_cast<QMainWindow*>(dockWidget->parentWidget());
// if (mainWindow) {
// mainWindow->removeDockWidget(dockWidget);
// }
// // tabWidget_->setCurrentWidget(dockWidget->parentWidget());
//}
}
void MainWindow::slotShowUISetting() {
@ -352,17 +375,20 @@ void MainWindow::slotResetWorkSpace()
{
if (!WorkSpaceManager::Get().GetCurrent()->GetWavePath().isEmpty())
{
wavePath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetWavePath();
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();
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();
rdPath = WorkSpaceManager::Get().GetCurrent()->GetRDPath();
//rdPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetRDPath();
}
}

View File

@ -46,6 +46,8 @@ private:
void InitDockLayout();
void AddDockArea(const QString& strArea);
void SaveDockStatus();
protected:
void OnTabifiedDockWidgetActivated(QDockWidget* dockWidget);

View File

@ -6,6 +6,8 @@
#include "workspace/WorkSpaceManager.h"
#include <qmessagebox.h>
#include <qfiledialog.h>
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);
});
}

View File

@ -16,6 +16,58 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="toolButton_5">
<property name="minimumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Wave文件</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_4">
<property name="minimumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Report文件</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_3">
<property name="minimumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>RD文件</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_2">
<property name="minimumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Matlab文件</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="minimumSize">

View File

@ -7875,22 +7875,10 @@ public:
QMap<const QtProperty*, QtProperty*> m_properyToName;
QMap<const QtProperty*, QtProperty*> m_properyToDescription;
QMap<const QtProperty*, QtProperty*> m_properyToTimestep;
QMap<const QtProperty*, QtProperty*> m_properyToSimMatlab;
QMap<const QtProperty*, QtProperty*> m_properyToMatlabParam;
QMap<const QtProperty*, QtProperty*> m_properyToWave;
QMap<const QtProperty*, QtProperty*> m_properyToReport;
QMap<const QtProperty*, QtProperty*> m_properyToRD;
QMap<const QtProperty*, QtProperty*> m_nameToPropery;
QMap<const QtProperty*, QtProperty*> m_descriptionToPropery;
QMap<const QtProperty*, QtProperty*> m_timestepToPropery;
QMap<const QtProperty*, QtProperty*> m_simMatlabToPropery;
QMap<const QtProperty*, QtProperty*> m_matlabParamToPropery;
QMap<const QtProperty*, QtProperty*> m_waveToPropery;
QMap<const QtProperty*, QtProperty*> m_reportToPropery;
QMap<const QtProperty*, QtProperty*> m_rdToPropery;
};
void QtWorkspacePropertyManagerPrivate::slotStringChanged(QtProperty* property, QString value) {
@ -7906,10 +7894,6 @@ 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);
}
}
@ -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

View File

@ -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"));
}
}

View File

@ -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");

View File

@ -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_;
@ -156,5 +145,7 @@ private:
OEScene* scene_{ nullptr };
class Timestep* timestep_{ nullptr };
class LampStatus* lampStatus_{ nullptr };
friend class WorkSpaceXMLWrite;
};

View File

@ -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();
}

View File

@ -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_;

View File

@ -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;

View File

@ -28,12 +28,12 @@
<DockRightArea Name="右侧区域"/>
<DockBottomArea Name="下方区域"/>
</MainWindow>
<MainWindow Name="Matlab文件编辑">
<MainWindow Name="bat文件管理">
<CentralWidget Name="中心区域"/>
<DockLeftArea Name="左侧区域"/>
<DockTopArea Name="上方区域"/>
<DockRightArea Name="右侧区域">
<Widget Plugin="Matlab" Name="参数设置"/>
<Widget Plugin="Matlab" Name="bat文件"/>
</DockRightArea>
<DockBottomArea Name="下方区域"/>
</MainWindow>