modify code merge

This commit is contained in:
brige 2025-07-04 08:14:15 +08:00
parent eba320eaeb
commit cf189a7600
6 changed files with 220 additions and 65 deletions

View File

@ -25,7 +25,6 @@ QString Application::GetWorkSpacePath() {
void Application::Init() {
Singleton<MeshManager>::Create(this);
//Singleton<OsgViewer>::Create(this);
Singleton<RecourceHelper>::Create(this);
Singleton<EntitiesManager>::Create(this);
Singleton<WorkSpaceManager>::Create(this);
@ -39,6 +38,5 @@ void Application::Uninit() {
Singleton<WorkSpaceManager>::Destory();
Singleton<EntitiesManager>::Destory();
Singleton<RecourceHelper>::Destory();
//Singleton<OsgViewer>::Destory();
Singleton<MeshManager>::Destory();
}

View File

@ -96,6 +96,26 @@
</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>

View File

@ -9,8 +9,7 @@
Dialog::Dialog(QWidget* parent)
: QDialog(parent)
, ui_(new Ui::Dialog)
/*, delegate_(FramelessDelegate::Create(this)) */{
, ui_(new Ui::Dialog) {
setWindowFlags(windowFlags() | Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
ui_->setupUi(this);
@ -20,8 +19,6 @@ Dialog::Dialog(QWidget* parent)
Dialog::~Dialog() {
delete ui_;
//delete delegate_;
//delegate_ = nullptr;
}
void Dialog::DeleteThisOnClose() {
@ -30,10 +27,6 @@ void Dialog::DeleteThisOnClose() {
void Dialog::SetTitleBar(FrameTitleBar* titleBar) {
/* delegate_->SetTitleBar(titleBar);
QVBoxLayout* layout = reinterpret_cast<QVBoxLayout*>(this->layout());
layout->insertWidget(0, titleBar, 0);*/
}
void Dialog::SetTitle(const QString& title) {
@ -53,9 +46,6 @@ bool Dialog::nativeEvent(const QByteArray& eventType, void* message, long* resul
bool Dialog::nativeEvent(const QByteArray& eventType, void* message, qintptr* result) {
#endif
return QDialog::nativeEvent(eventType, message, result);
/*if (!delegate_->nativeEvent(eventType, message, result)) {
return QDialog::nativeEvent(eventType, message, result);
}*/
return true;
}
@ -68,21 +58,4 @@ void Dialog::paintEvent(QPaintEvent* event) {
}
void Dialog::InitFrame() {
/* ui->
FrameTitleBar* titleBar = new FrameTitleBar(this);
titleBar->SetMainWidget(this);
titleBar->SetSysButton(FrameTitleBar::FTB_ICON | FrameTitleBar::FTB_CLOSE | FrameTitleBar::FTB_TTILE);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->setStretch(0, 0);
layout->setStretch(1, 1);
layout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
SetTitleBar(titleBar);
mainDilag_ = new QWidget(this);
layout->addWidget(mainDilag_, 1);*/
}

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,149 @@ 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 (QFileInfo(old).isFile()) {
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

@ -346,37 +346,6 @@ void ModelTreeWidget::OnTrackEntity(Entity* entity) {
LOG_INFO("track entity: {}", entity->GetName().toStdString());
workspace->TrackEntity(entity);
//scene->Track
//MainWindow::
//OsgCameraManipulator* manipulator = OsgViewer::Get().GetView()->GetCameraManipulator();
//if (nullptr == manipulator) {
// LOG_WARN("manipulator is nullptr");
// return;
//}
//
//osgGA::CameraManipulator* gaManipulator = manipulator->GetManipulator();
//osgEarth::Util::EarthManipulator* ccm = dynamic_cast<osgEarth::Util::EarthManipulator*>(gaManipulator);
//if (nullptr != ccm) {
// if (nullptr != entity) {
// osg::MatrixTransform* mt = entity->GetRootComponent()->GetMatrixTransform();
// ccm->setNode(mt);
// ccm->getSettings()->setTetherMode(osgEarth::Util::EarthManipulator::TETHER_CENTER);
// osgEarth::Util::Viewpoint newVP;
// newVP.setNode(mt);
// double range = mt->getBound().radius() * 10.0;
// newVP.range()->set(range, osgEarth::Units::METERS);
// const osg::Vec3 rotation = entity->GetRootComponent()->GetTransform()->GetRotation();
// newVP.heading()->set(rotation.x(), osgEarth::Units::DEGREES);
// newVP.pitch()->set(rotation.y() - 15.0, osgEarth::Units::DEGREES);
// //newVP.roll()->set(rotation.z(), osgEarth::Units::DEGREES);
// ccm->setViewpoint(newVP, 1.5);
// //ccm->setTetherMode(osgGA::CameraManipulator::TETHER_CENTER_AND_ROTATION);
// } else {
// ccm->clearViewpoint();
// }
//}
}
void ModelTreeWidget::AddEntity(class QTreeWidgetItem* parent, Entity* entity) {