Compare commits
No commits in common. "ff5e3e74ad58f64db283099b2e1ea9dbaed48d90" and "06697b44760a6944dc87b043d6fdc9912a517228" have entirely different histories.
ff5e3e74ad
...
06697b4476
@ -5,10 +5,9 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QVariant>
|
|
||||||
|
|
||||||
LightPanel::LightPanel(int index, const QString& filePath, QWidget* parent)
|
LightPanel::LightPanel(int index, const QString& filePath, QWidget* parent)
|
||||||
: DataPanel(index, FileEntryType::Light, filePath, parent)
|
: DataPanel(index, FileEntryType::Curve, filePath, parent)
|
||||||
{
|
{
|
||||||
LOG_INFO("Created LightPanel {} for file: {}", index, filePath.toStdString());
|
LOG_INFO("Created LightPanel {} for file: {}", index, filePath.toStdString());
|
||||||
}
|
}
|
||||||
@ -46,6 +45,10 @@ void LightPanel::RefreshPanel()
|
|||||||
void LightPanel::InitUI()
|
void LightPanel::InitUI()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
QHBoxLayout* mainLayout = new QHBoxLayout(this);
|
||||||
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
//mainLayout->addWidget(m_pTableWidget);
|
||||||
|
setLayout(mainLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LightPanel::GetTypeDisplayName() const
|
QString LightPanel::GetTypeDisplayName() const
|
||||||
@ -58,41 +61,19 @@ void LightPanel::OnDataPanelUpdated(FileEntryLight* fileEntry)
|
|||||||
QString strName = fileEntry->GetName();
|
QString strName = fileEntry->GetName();
|
||||||
updateTitle(strName);
|
updateTitle(strName);
|
||||||
|
|
||||||
FileEntryLight::ColorProperties propChart = fileEntry->GetColorProperties();
|
//FileEntryTable::ChartProperties propChart = fileEntry->GetChartProperties();
|
||||||
|
|
||||||
QString openColor = QColorToString(propChart.openColor);
|
//QStringList tableHeader = propChart.headerString.split(',', Qt::SkipEmptyParts);
|
||||||
QString closeColor = QColorToString(propChart.closeColor);
|
//SetHeader(tableHeader);
|
||||||
updateLampColor(openColor, closeColor);
|
|
||||||
|
|
||||||
QString strFile = fileEntry->GetPath() + "/" + fileEntry->GetFileName();
|
//QString strFile = fileEntry->GetPath() + "/" + fileEntry->GetFileName();
|
||||||
FileEntryLight::LightRowProperties listCurve = fileEntry->GetLightProperties();
|
//FileEntryTable::TableProperties listCurve = fileEntry->GetTableProperties();
|
||||||
updateParseFile(strFile, propChart.timeParam, listCurve);
|
//updateParseFile(strFile, propChart.timeParam, listCurve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightPanel::OnTimeChanged(double time)
|
void LightPanel::OnTimeChanged(double time)
|
||||||
{
|
{
|
||||||
if (m_dataLamp.size() > 0)
|
|
||||||
{
|
|
||||||
QMap< double, QVariantMap >::const_iterator ite = m_dataLamp.lowerBound(time);
|
|
||||||
if (ite == m_dataLamp.end())
|
|
||||||
{
|
|
||||||
ite--;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap mapData = ite.value();
|
|
||||||
for (QVariantMap::Iterator it = mapData.begin(); it != mapData.end(); it++)
|
|
||||||
{
|
|
||||||
QString strKey = it.key();
|
|
||||||
int nState = it.value().toFloat();
|
|
||||||
|
|
||||||
SignalLabel* pLampLab = m_mapLamp.value(strKey);
|
|
||||||
if (pLampLab)
|
|
||||||
{
|
|
||||||
QString strStyle = m_lampColor.value(nState);
|
|
||||||
pLampLab->setStyleSheet(strStyle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightPanel::updateTitle(const QString & title)
|
void LightPanel::updateTitle(const QString & title)
|
||||||
@ -102,82 +83,3 @@ void LightPanel::updateTitle(const QString & title)
|
|||||||
dockWidget_->setWindowTitle(title);
|
dockWidget_->setWindowTitle(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightPanel::updateParseFile(const QString & strFile, int nT, FileEntryLight::LightRowProperties listCurve)
|
|
||||||
{
|
|
||||||
if (strFile.isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请检查数据文件路径!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile file(strFile);
|
|
||||||
if (file.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
QGridLayout* pMainLyt = new QGridLayout(this);
|
|
||||||
for (int nI = 0; nI < listCurve.size(); nI++)
|
|
||||||
{
|
|
||||||
FileEntryLight::LightRowProperty prop = listCurve.at(nI);
|
|
||||||
|
|
||||||
for (auto i = 0; i < prop.name.size(); ++i)
|
|
||||||
{
|
|
||||||
SignalLabel* pLampLab = new SignalLabel;
|
|
||||||
pLampLab->setFixedSize(24, 24);
|
|
||||||
|
|
||||||
QString strStyle = m_lampColor.value(0);
|
|
||||||
pLampLab->setStyleSheet(strStyle);
|
|
||||||
|
|
||||||
QLabel* pTextLab = new QLabel;
|
|
||||||
pTextLab->setText(prop.name.at(i));
|
|
||||||
|
|
||||||
QHBoxLayout* pLyt = new QHBoxLayout;
|
|
||||||
pLyt->addWidget(pLampLab);
|
|
||||||
pLyt->addWidget(pTextLab);
|
|
||||||
|
|
||||||
pMainLyt->addLayout(pLyt, nI, i);
|
|
||||||
|
|
||||||
QString strKey = QString::number(nI) + "-" + QString::number(i);
|
|
||||||
m_mapLamp.insert(strKey, pLampLab);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!file.atEnd())
|
|
||||||
{
|
|
||||||
QString strLine = file.readLine().simplified();
|
|
||||||
if (!strLine.isEmpty())
|
|
||||||
{
|
|
||||||
QStringList listLine = strLine.split(" ");
|
|
||||||
double t = listLine.at(nT).toDouble();
|
|
||||||
|
|
||||||
QVariantMap mapData;
|
|
||||||
for (int nI = 0; nI < listCurve.size(); nI++)
|
|
||||||
{
|
|
||||||
FileEntryLight::LightRowProperty prop = listCurve.at(nI);
|
|
||||||
|
|
||||||
for (int nJ = 0; nJ < prop.data.size(); ++nJ)
|
|
||||||
{
|
|
||||||
int nIndex = prop.data.at(nJ);
|
|
||||||
QString nState = listLine.at(nIndex);
|
|
||||||
QString strKey = QString::number(nI) + "-" + QString::number(nJ);
|
|
||||||
mapData.insert(strKey, nState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_dataLamp.insert(t, mapData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LightPanel::updateLampColor(const QString & strOpenColor, const QString & strCloseColor)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
QString strStyle = "QLabel{background-color: rgb(" + strCloseColor + ");border-radius: 10px;}; ";
|
|
||||||
m_lampColor.insert(0, strStyle);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
QString strStyle = "QLabel{background-color: rgb(" + strOpenColor + ");border-radius: 10px;}; ";
|
|
||||||
m_lampColor.insert(1, strStyle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3,8 +3,6 @@
|
|||||||
#include "DataPanel.h"
|
#include "DataPanel.h"
|
||||||
#include "workspace/FileEntry.h"
|
#include "workspace/FileEntry.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "ui/Layout/SignalLabel.h"
|
|
||||||
#include <QMap>
|
|
||||||
|
|
||||||
class LightPanel : public DataPanel
|
class LightPanel : public DataPanel
|
||||||
{
|
{
|
||||||
@ -61,12 +59,5 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void updateTitle(const QString& title);
|
void updateTitle(const QString& title);
|
||||||
void updateParseFile(const QString& strFile, int nT, FileEntryLight::LightRowProperties listCurve);
|
|
||||||
void updateLampColor(const QString& strOpenColor, const QString& strCloseColor);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QMap<int, QString> m_lampColor;
|
|
||||||
QMap<QString, SignalLabel*> m_mapLamp;
|
|
||||||
QMap< double, QVariantMap > m_dataLamp;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
#include <Q3DCamera>
|
#include <Q3DCamera>
|
||||||
|
|
||||||
SurfacePanel::SurfacePanel(int index, const QString& filePath, QWidget* parent)
|
SurfacePanel::SurfacePanel(int index, const QString& filePath, QWidget* parent)
|
||||||
: DataPanel(index, FileEntryType::Surface, filePath, parent)
|
: DataPanel(index, FileEntryType::Curve, filePath, parent)
|
||||||
{
|
{
|
||||||
m_iMinX = 0; m_iMaxX = 0;
|
m_iMinX = 0; m_iMaxX = 0;
|
||||||
m_iMinY = 0; m_iMaxY = 0;
|
m_iMinY = 0; m_iMaxY = 0;
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
|
||||||
TablePanel::TablePanel(int index, const QString& filePath, QWidget* parent)
|
TablePanel::TablePanel(int index, const QString& filePath, QWidget* parent)
|
||||||
: DataPanel(index, FileEntryType::Table, filePath, parent)
|
: DataPanel(index, FileEntryType::Curve, filePath, parent)
|
||||||
{
|
{
|
||||||
LOG_INFO("Created TablePanel {} for file: {}", index, filePath.toStdString());
|
LOG_INFO("Created TablePanel {} for file: {}", index, filePath.toStdString());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -648,4 +648,4 @@ bool FileEntryCurve::ParseFiles(const tinyxml2::XMLElement* chartElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -86,9 +86,6 @@ protected:
|
|||||||
QString name_;
|
QString name_;
|
||||||
};
|
};
|
||||||
|
|
||||||
QString QColorToString(const QColor& color);
|
|
||||||
QColor StringToQColor(const QString& colorStr);
|
|
||||||
|
|
||||||
// Factory functions for creating FileEntry objects
|
// Factory functions for creating FileEntry objects
|
||||||
std::shared_ptr<FileEntry> CreateFileEntry(FileEntryType type, const QString& filePath);
|
std::shared_ptr<FileEntry> CreateFileEntry(FileEntryType type, const QString& filePath);
|
||||||
std::shared_ptr<FileEntryCurve> CreateFileEntryCurve(const QString& filePath);
|
std::shared_ptr<FileEntryCurve> CreateFileEntryCurve(const QString& filePath);
|
||||||
@ -265,7 +262,6 @@ public:
|
|||||||
struct ColorProperties {
|
struct ColorProperties {
|
||||||
QColor openColor;
|
QColor openColor;
|
||||||
QColor closeColor;
|
QColor closeColor;
|
||||||
double timeParam;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LightRowProperty {
|
struct LightRowProperty {
|
||||||
@ -273,6 +269,7 @@ public:
|
|||||||
QList<int> data;
|
QList<int> data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
using LightRowProperties = QList<LightRowProperty>;
|
using LightRowProperties = QList<LightRowProperty>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -287,6 +284,7 @@ public:
|
|||||||
|
|
||||||
FileEntryLight* AsLight() override { return this; }
|
FileEntryLight* AsLight() override { return this; }
|
||||||
|
|
||||||
|
// XML处理方法
|
||||||
bool SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) override;
|
bool SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) override;
|
||||||
bool ParseFiles(const tinyxml2::XMLElement* element) override;
|
bool ParseFiles(const tinyxml2::XMLElement* element) override;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user