modify chat plot
This commit is contained in:
parent
8f0a32869e
commit
cdb7894e64
@ -116,6 +116,11 @@
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/ChartPlotMenu.ui" line="80"/>
|
<location filename="../ui/Menu/ChartPlotMenu.ui" line="80"/>
|
||||||
|
<source>Lamp文件</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/Menu/ChartPlotMenu.ui" line="93"/>
|
||||||
<source>Run Simu</source>
|
<source>Run Simu</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1550,12 +1555,12 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/SignalIndicatorLampUI.cpp" line="43"/>
|
<location filename="../ui/Layout/SignalIndicatorLampUI.cpp" line="44"/>
|
||||||
<source>Signal Indicator Lamp</source>
|
<source>Signal Indicator Lamp</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/SignalIndicatorLampUI.cpp" line="191"/>
|
<location filename="../ui/Layout/SignalIndicatorLampUI.cpp" line="192"/>
|
||||||
<source>light</source>
|
<source>light</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "workspace/WorkSpace.h"
|
#include "workspace/WorkSpace.h"
|
||||||
#include "workspace/Timestep.h"
|
#include "workspace/Timestep.h"
|
||||||
#include "workspace/WorkSpaceManager.h"
|
#include "workspace/WorkSpaceManager.h"
|
||||||
|
#include "workspace/LampStatus.h"
|
||||||
|
|
||||||
SignalIndicatorLampUI::SignalIndicatorLampUI(QWidget* parent)
|
SignalIndicatorLampUI::SignalIndicatorLampUI(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
@ -196,7 +197,6 @@ void SignalIndicatorLampUI::InitLamp(const QString& strFile)
|
|||||||
|
|
||||||
void SignalIndicatorLampUI::slotUpdateTime(double dTime)
|
void SignalIndicatorLampUI::slotUpdateTime(double dTime)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
if (dTime < 1)
|
if (dTime < 1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -241,7 +241,12 @@ void SignalIndicatorLampUI::OnWorkSpaceChanged(WorkSpace* worksapce) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worksapce, &WorkSpace::TimestepChanged, this, &SignalIndicatorLampUI::OnTimestepChanged);
|
connect(worksapce, &WorkSpace::TimestepChanged, this, &SignalIndicatorLampUI::OnTimestepChanged);
|
||||||
InitLamp(worksapce->GetRDPath());
|
auto lamp = worksapce->GetLampStatus();
|
||||||
|
if (nullptr != lamp) {
|
||||||
|
InitLamp(lamp->GetPath());
|
||||||
|
}
|
||||||
|
// Initialize the lamp with the current workspace's lamp file
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SignalIndicatorLampUI::OnTimestepChanged(Timestep* timestep) {
|
void SignalIndicatorLampUI::OnTimestepChanged(Timestep* timestep) {
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "../../common/RecourceHelper.h"
|
#include "../../common/RecourceHelper.h"
|
||||||
#include "workspace/WorkSpace.h"
|
#include "workspace/WorkSpace.h"
|
||||||
#include "workspace/WorkSpaceManager.h"
|
#include "workspace/WorkSpaceManager.h"
|
||||||
|
#include "workspace/LampStatus.h"
|
||||||
|
#include "utils/FileUtils.h"
|
||||||
#include <qmessagebox.h>
|
#include <qmessagebox.h>
|
||||||
|
|
||||||
#include <qfiledialog.h>
|
#include <qfiledialog.h>
|
||||||
@ -188,4 +190,52 @@ void ChartPlotMenu::InitMenu()
|
|||||||
|
|
||||||
current->SetReportPath(strSel);
|
current->SetReportPath(strSel);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(ui.toolButton_6, &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"选择Lamp文件", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt");
|
||||||
|
if (strSel.isEmpty()) {
|
||||||
|
LOG_WARN("选择文件为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto lampStatus = current->GetLampStatus();
|
||||||
|
if (nullptr != lampStatus) {
|
||||||
|
const QString& old = lampStatus->GetPath();
|
||||||
|
if (old == strSel) {
|
||||||
|
LOG_INFO("选择文件与当前文件相同");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!old.isEmpty()) {
|
||||||
|
if (QFileInfo(old).isFile() && QFile::exists(old)) {
|
||||||
|
if (QMessageBox::Yes == QMessageBox::question(nullptr,
|
||||||
|
QString::fromLocal8Bit("询问"),
|
||||||
|
QString::fromLocal8Bit("替换当前Lamp文件!"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No)
|
||||||
|
) {
|
||||||
|
if (!QFile::remove(old)) {
|
||||||
|
LOG_WARN("删除文件失败");
|
||||||
|
QMessageBox::information(nullptr,
|
||||||
|
QString::fromLocal8Bit("提示"),
|
||||||
|
QString::fromLocal8Bit("删除文件失败!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo fileInfo(strSel);
|
||||||
|
QString dirPath = QString("%1/%2").arg(current->GetDir(), fileInfo.fileName());
|
||||||
|
bool sucess = FileUtils::CopyFileToPath(strSel, dirPath, true);
|
||||||
|
LOG_INFO("copy Wave file {}: {} to {}",
|
||||||
|
strSel.toLocal8Bit().data(),
|
||||||
|
dirPath.toLocal8Bit().data(),
|
||||||
|
sucess);
|
||||||
|
current->SetLampPath(dirPath);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="toolButton_6">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>30</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Lamp文件</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="toolButton">
|
<widget class="QToolButton" name="toolButton">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
@ -16,7 +16,7 @@ LampStatus::LampStatus(const std::vector<int>& status, const QString& path, Work
|
|||||||
}
|
}
|
||||||
|
|
||||||
LampStatus* LampStatus::Load(const QString& path, WorkSpace* parent) {
|
LampStatus* LampStatus::Load(const QString& path, WorkSpace* parent) {
|
||||||
const QString filePath = QString("%1/%2").arg(RecourceHelper::Get().GetBasePath()).arg(path);
|
const QString filePath = path;
|
||||||
LOG_INFO("Load LampStatus: {}", filePath.toStdString());
|
LOG_INFO("Load LampStatus: {}", filePath.toStdString());
|
||||||
|
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
|
@ -34,6 +34,7 @@ bool WorkSpaceXMLWrite::Save(const QString& path) {
|
|||||||
|
|
||||||
SaveChart(scene, &doc);
|
SaveChart(scene, &doc);
|
||||||
SaveTimeStep(scene);
|
SaveTimeStep(scene);
|
||||||
|
SaveLamp(scene);
|
||||||
|
|
||||||
tinyxml2::XMLElement* entitiesXml = scene->InsertNewChildElement("entities");
|
tinyxml2::XMLElement* entitiesXml = scene->InsertNewChildElement("entities");
|
||||||
std::vector<Entity*>& entities = workSpace_->GetEntities();
|
std::vector<Entity*>& entities = workSpace_->GetEntities();
|
||||||
|
Loading…
Reference in New Issue
Block a user