modify color change to pannel
This commit is contained in:
parent
6389e530b4
commit
c8b53ec674
@ -2,6 +2,9 @@
|
||||
#include "ui/DockWidget.h"
|
||||
#include "ui/DockTitleBar.h"
|
||||
#include "common/SpdLogger.h"
|
||||
#include "workspace/WorkSpaceManager.h"
|
||||
#include "workspace/WorkSpace.h"
|
||||
#include "workspace/Timestep.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
@ -33,14 +36,14 @@ LightPanel::~LightPanel()
|
||||
|
||||
void LightPanel::RefreshPanel()
|
||||
{
|
||||
// Implement curve-specific refresh logic here
|
||||
DataPanel::RefreshPanel();
|
||||
// Implement curve-specific refresh logic here
|
||||
DataPanel::RefreshPanel();
|
||||
|
||||
if (auto fileEntry = fileEntry_->AsLight()) {
|
||||
OnDataPanelUpdated(fileEntry);
|
||||
}
|
||||
if (auto fileEntry = fileEntry_->AsLight()) {
|
||||
OnDataPanelUpdated(fileEntry);
|
||||
}
|
||||
|
||||
LOG_INFO("Refreshed TablePanel {}", GetIndex());
|
||||
LOG_INFO("Refreshed LightPanel {}", GetIndex());
|
||||
}
|
||||
|
||||
void LightPanel::InitUI()
|
||||
@ -57,8 +60,8 @@ QString LightPanel::GetTypeDisplayName() const
|
||||
|
||||
void LightPanel::OnDataPanelUpdated(FileEntryLight* fileEntry)
|
||||
{
|
||||
QString strName = fileEntry->GetName();
|
||||
updateTitle(strName);
|
||||
QString strName = fileEntry->GetName();
|
||||
updateTitle(strName);
|
||||
|
||||
FileEntryLight::ColorProperties propChart = fileEntry->GetColorProperties();
|
||||
|
||||
@ -66,35 +69,23 @@ void LightPanel::OnDataPanelUpdated(FileEntryLight* fileEntry)
|
||||
QString closeColor = QColorToString(propChart.closeColor);
|
||||
updateLampColor(openColor, closeColor);
|
||||
|
||||
QString strFile = fileEntry->GetPath() + "/" + fileEntry->GetFileName();
|
||||
FileEntryLight::LightRowProperties listCurve = fileEntry->GetLightProperties();
|
||||
updateParseFile(strFile, propChart.timeParam, listCurve);
|
||||
QString strFile = fileEntry->GetPath() + "/" + fileEntry->GetFileName();
|
||||
FileEntryLight::LightRowProperties listCurve = fileEntry->GetLightProperties();
|
||||
updateParseFile(strFile, propChart.timeParam, listCurve);
|
||||
|
||||
// 颜色或数据更新后,按当前时间重新应用灯样式,确保即时可见
|
||||
WorkSpace* ws = WorkSpaceManager::Get().GetCurrent();
|
||||
if (ws) {
|
||||
Timestep* ts = ws->GetTimestep();
|
||||
if (ts) {
|
||||
applyLampStylesForTime(ts->GetCurrent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
applyLampStylesForTime(time);
|
||||
}
|
||||
|
||||
void LightPanel::updateTitle(const QString & title)
|
||||
@ -109,7 +100,7 @@ void LightPanel::updateParseFile(const QString & strFile, int nT, FileEntryLight
|
||||
{
|
||||
if (strFile.isEmpty())
|
||||
{
|
||||
QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请检查数据文件路径!"));
|
||||
QMessageBox::information(nullptr, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -183,16 +174,42 @@ void LightPanel::updateParseFile(const QString & strFile, int nT, FileEntryLight
|
||||
|
||||
void LightPanel::updateLampColor(const QString & strOpenColor, const QString & strCloseColor)
|
||||
{
|
||||
m_lampColor.clear();
|
||||
m_lampColor.clear();
|
||||
|
||||
{
|
||||
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);
|
||||
}
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void LightPanel::applyLampStylesForTime(double time)
|
||||
{
|
||||
if (m_dataLamp.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto ite = m_dataLamp.lowerBound(time);
|
||||
if (ite == m_dataLamp.end()) {
|
||||
ite--;
|
||||
}
|
||||
|
||||
const QVariantMap mapData = ite.value();
|
||||
for (auto it = mapData.constBegin(); it != mapData.constEnd(); ++it)
|
||||
{
|
||||
const QString strKey = it.key();
|
||||
const int nState = it.value().toFloat();
|
||||
|
||||
SignalLabel* pLampLab = m_mapLamp.value(strKey);
|
||||
if (pLampLab)
|
||||
{
|
||||
const QString strStyle = m_lampColor.value(nState);
|
||||
pLampLab->setStyleSheet(strStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LightPanel::clearLightPanel()
|
||||
|
||||
@ -60,15 +60,16 @@ protected:
|
||||
virtual void OnTimeChanged(double time);
|
||||
|
||||
private:
|
||||
void updateTitle(const QString& title);
|
||||
void updateParseFile(const QString& strFile, int nT, FileEntryLight::LightRowProperties listCurve);
|
||||
void updateLampColor(const QString& strOpenColor, const QString& strCloseColor);
|
||||
void updateTitle(const QString& title);
|
||||
void updateParseFile(const QString& strFile, int nT, FileEntryLight::LightRowProperties listCurve);
|
||||
void updateLampColor(const QString& strOpenColor, const QString& strCloseColor);
|
||||
void applyLampStylesForTime(double time);
|
||||
|
||||
void clearLightPanel();
|
||||
|
||||
private:
|
||||
QMap<int, QString> m_lampColor;
|
||||
QMap<QString, SignalLabel*> m_mapLamp;
|
||||
QMap< double, QVariantMap > m_dataLamp;
|
||||
QMap<int, QString> m_lampColor;
|
||||
QMap<QString, SignalLabel*> m_mapLamp;
|
||||
QMap< double, QVariantMap > m_dataLamp;
|
||||
};
|
||||
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
#include "ui/Panel/TablePanel.h"
|
||||
#include "ui/DockWidget.h"
|
||||
#include "ui/DockTitleBar.h"
|
||||
#include "workspace/WorkSpaceManager.h"
|
||||
#include "workspace/WorkSpace.h"
|
||||
#include "workspace/Timestep.h"
|
||||
#include "common/SpdLogger.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileInfo>
|
||||
@ -80,17 +83,34 @@ QString TablePanel::GetTypeDisplayName() const
|
||||
|
||||
void TablePanel::OnDataPanelUpdated(FileEntryTable* fileEntry)
|
||||
{
|
||||
QString strName = fileEntry->GetName();
|
||||
updateTitle(strName);
|
||||
QString strName = fileEntry->GetName();
|
||||
updateTitle(strName);
|
||||
|
||||
FileEntryTable::ChartProperties propChart = fileEntry->GetChartProperties();
|
||||
FileEntryTable::ChartProperties propChart = fileEntry->GetChartProperties();
|
||||
|
||||
QStringList tableHeader = propChart.headerString.split(',', Qt::SkipEmptyParts);
|
||||
SetHeader(tableHeader);
|
||||
QStringList tableHeader = propChart.headerString.split(',', Qt::SkipEmptyParts);
|
||||
SetHeader(tableHeader);
|
||||
|
||||
QString strFile = fileEntry->GetPath() + "/" + fileEntry->GetFileName();
|
||||
FileEntryTable::TableProperties listCurve = fileEntry->GetTableProperties();
|
||||
updateParseFile(strFile, propChart.timeParam, listCurve);
|
||||
QString strFile = fileEntry->GetPath() + "/" + fileEntry->GetFileName();
|
||||
FileEntryTable::TableProperties listCurve = fileEntry->GetTableProperties();
|
||||
updateParseFile(strFile, propChart.timeParam, listCurve);
|
||||
|
||||
// After parsing new data and settings, immediately refresh the table to current time
|
||||
// so color changes from PropertyBrowser reflect in the UI right away
|
||||
WorkSpace* ws = WorkSpaceManager::Get().GetCurrent();
|
||||
if (ws) {
|
||||
Timestep* ts = ws->GetTimestep();
|
||||
if (ts) {
|
||||
updateTable(ts->GetCurrent());
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Fallback: render the latest snapshot if no workspace/timestep
|
||||
if (!m_dataTable.isEmpty()) {
|
||||
auto it = m_dataTable.end();
|
||||
--it;
|
||||
updateTable(it.key());
|
||||
}
|
||||
}
|
||||
|
||||
void TablePanel::OnTimeChanged(double time)
|
||||
@ -118,7 +138,7 @@ void TablePanel::updateParseFile(const QString & strFile, int nT, FileEntryTable
|
||||
{
|
||||
if (strFile.isEmpty())
|
||||
{
|
||||
QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请检查数据文件路径!"));
|
||||
QMessageBox::information(nullptr, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -187,9 +207,9 @@ void TablePanel::updateParseFile(const QString & strFile, int nT, FileEntryTable
|
||||
|
||||
void TablePanel::updateTable(double t)
|
||||
{
|
||||
if (m_dataTable.size() > 0)
|
||||
{
|
||||
clearTable();
|
||||
if (m_dataTable.size() > 0)
|
||||
{
|
||||
clearTable();
|
||||
|
||||
QMap< double, QMap<int, QVariantList> >::const_iterator ite = m_dataTable.lowerBound(t);
|
||||
if (ite == m_dataTable.end())
|
||||
@ -197,24 +217,37 @@ void TablePanel::updateTable(double t)
|
||||
ite--;
|
||||
}
|
||||
|
||||
QMap<int, QVariantList> mapData = ite.value();
|
||||
for (QMap<int, QVariantList>::Iterator it = mapData.begin(); it != mapData.end(); it++)
|
||||
{
|
||||
int nRow = it.key();
|
||||
QVariantList dataList = it.value();
|
||||
QMap<int, QVariantList> mapData = ite.value();
|
||||
for (QMap<int, QVariantList>::Iterator it = mapData.begin(); it != mapData.end(); it++)
|
||||
{
|
||||
int nRow = it.key();
|
||||
QVariantList dataList = it.value();
|
||||
|
||||
m_pTableWidget->insertRow(nRow);
|
||||
m_pTableWidget->insertRow(nRow);
|
||||
|
||||
for (int nI = 0; nI < dataList.size(); nI++)
|
||||
{
|
||||
QString strVal;
|
||||
strVal.sprintf("%.6f", dataList.at(nI).toFloat());
|
||||
QTableWidgetItem *item = new QTableWidgetItem(strVal);
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
m_pTableWidget->setItem(nRow, nI, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int nI = 0; nI < dataList.size(); nI++)
|
||||
{
|
||||
QString strVal;
|
||||
strVal.sprintf("%.6f", dataList.at(nI).toFloat());
|
||||
QTableWidgetItem *item = new QTableWidgetItem(strVal);
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
m_pTableWidget->setItem(nRow, nI, item);
|
||||
|
||||
// Apply color linkage: use FileEntryTable::TableProperty color for this row
|
||||
if (m_tableSetting.contains(nRow)) {
|
||||
const QColor rowColor = m_tableSetting.value(nRow).second;
|
||||
if (rowColor.isValid()) {
|
||||
// Prefer foreground text color to mirror curve color, keep readability
|
||||
item->setForeground(QBrush(rowColor));
|
||||
// Optionally add a subtle background tint to improve visibility
|
||||
QColor bg = rowColor;
|
||||
bg.setAlpha(40);
|
||||
item->setBackground(QBrush(bg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TablePanel::clearTable()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user