remove chart data
This commit is contained in:
parent
d734d33e0a
commit
bee7b6f8ec
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "DataPanel.h"
|
||||
#include "workspace/ChartData.h"
|
||||
#include "workspace/FileEntry.h"
|
||||
#include <memory>
|
||||
#include "ui/chartPlot/FitCurveChartView.h"
|
||||
|
||||
@ -1,120 +0,0 @@
|
||||
#ifndef CHARTDATA_H
|
||||
#define CHARTDATA_H
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <memory>
|
||||
|
||||
#include "workspace/FileEntry.h"
|
||||
|
||||
struct BaseCurveData {
|
||||
QString name;
|
||||
|
||||
BaseCurveData() = default;
|
||||
virtual ~BaseCurveData() = default;
|
||||
};
|
||||
|
||||
struct CurveColorData : public BaseCurveData {
|
||||
QString color;
|
||||
};
|
||||
|
||||
struct CurveData : public CurveColorData {
|
||||
int start;
|
||||
int stop;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
CurveData()
|
||||
{
|
||||
start = 0;
|
||||
stop = 0;
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct TableCurveData : public CurveColorData {
|
||||
QString data;
|
||||
};
|
||||
|
||||
struct SurfaceCurveData : public CurveColorData {
|
||||
double start;
|
||||
double stop;
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
};
|
||||
|
||||
struct LightCurveData : public BaseCurveData {
|
||||
QString data;
|
||||
};
|
||||
|
||||
class BaseChartData {
|
||||
public:
|
||||
QString name;
|
||||
QString path;
|
||||
QString t;
|
||||
|
||||
BaseChartData() = default;
|
||||
virtual ~BaseChartData() = default;
|
||||
virtual FileEntryType getType() const = 0;
|
||||
};
|
||||
|
||||
class CurveChartData : public BaseChartData {
|
||||
public:
|
||||
QString xTitle;
|
||||
QString yTitle;
|
||||
double xMin;
|
||||
double xMax;
|
||||
double yMin;
|
||||
double yMax;
|
||||
int xCount;
|
||||
int yCount;
|
||||
QList<CurveData> curves;
|
||||
|
||||
FileEntryType getType() const override { return FileEntryType::Curve; }
|
||||
};
|
||||
|
||||
class SurfaceChartData : public BaseChartData {
|
||||
public:
|
||||
QString xTitle;
|
||||
QString yTitle;
|
||||
QString zTitle;
|
||||
double xMin;
|
||||
double xMax;
|
||||
double yMin;
|
||||
double yMax;
|
||||
double zMin;
|
||||
double zMax;
|
||||
int xCount;
|
||||
int yCount;
|
||||
int zCount;
|
||||
QList<SurfaceCurveData> curves;
|
||||
|
||||
FileEntryType getType() const override { return FileEntryType::Surface; }
|
||||
};
|
||||
|
||||
class TableChartData : public BaseChartData {
|
||||
public:
|
||||
QString head;
|
||||
QList<TableCurveData> curves;
|
||||
|
||||
FileEntryType getType() const override { return FileEntryType::Table; }
|
||||
};
|
||||
|
||||
class LightChartData : public BaseChartData {
|
||||
public:
|
||||
QString openColor;
|
||||
QString closeColor;
|
||||
QList<LightCurveData> curves;
|
||||
|
||||
FileEntryType getType() const override { return FileEntryType::Light; }
|
||||
};
|
||||
|
||||
struct FileTypeData {
|
||||
QString typeName;
|
||||
int count;
|
||||
QList<std::shared_ptr<BaseChartData>> charts;
|
||||
};
|
||||
|
||||
#endif // CHARTDATA_H
|
||||
@ -440,59 +440,3 @@ void WorkSpace::ExecuteCommands(CommandWhen when) {
|
||||
}
|
||||
cmdMgr_->Execute(this, when);
|
||||
}
|
||||
|
||||
// Chart data management implementation
|
||||
void WorkSpace::SetFileTypeData(const QList<FileTypeData>& fileTypes) {
|
||||
fileTypeData_ = fileTypes;
|
||||
++filesSeq_;
|
||||
// Emit signals for each type that has data
|
||||
for (const auto& fileType : fileTypes) {
|
||||
FileEntryType type;
|
||||
if (FileEntryTypeFromString(fileType.typeName.toLocal8Bit().constData(), type)) {
|
||||
emit FilesChanged(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QList<FileTypeData>& WorkSpace::GetFileTypeData() const {
|
||||
return fileTypeData_;
|
||||
}
|
||||
|
||||
void WorkSpace::AddChartData(FileEntryType type, const std::shared_ptr<BaseChartData>& chart) {
|
||||
QString typeName = FileEntryTypeToString(type);
|
||||
|
||||
// Find existing file type data or create new one
|
||||
auto it = std::find_if(fileTypeData_.begin(), fileTypeData_.end(),
|
||||
[&typeName](const FileTypeData& data) {
|
||||
return data.typeName == typeName;
|
||||
});
|
||||
|
||||
if (it != fileTypeData_.end()) {
|
||||
it->charts.append(chart);
|
||||
it->count = it->charts.size();
|
||||
} else {
|
||||
FileTypeData newData;
|
||||
newData.typeName = typeName;
|
||||
newData.count = 1;
|
||||
newData.charts.append(chart);
|
||||
fileTypeData_.append(newData);
|
||||
}
|
||||
|
||||
++filesSeq_;
|
||||
emit FilesChanged(type);
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<BaseChartData>> WorkSpace::GetChartData(FileEntryType type) const {
|
||||
QString typeName = FileEntryTypeToString(type);
|
||||
|
||||
auto it = std::find_if(fileTypeData_.begin(), fileTypeData_.end(),
|
||||
[&typeName](const FileTypeData& data) {
|
||||
return data.typeName == typeName;
|
||||
});
|
||||
|
||||
if (it != fileTypeData_.end()) {
|
||||
return it->charts;
|
||||
}
|
||||
|
||||
return QList<std::shared_ptr<BaseChartData>>();
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
#include "config.h"
|
||||
#include "common/SpdLogger.h"
|
||||
#include "workspace/FileEntry.h"
|
||||
#include "workspace/ChartData.h"
|
||||
|
||||
//#include "../ui/chartPlot/DYTChart.h"
|
||||
|
||||
@ -92,12 +91,6 @@ public:
|
||||
bool SetFileEntryCount(FileEntryType type, int count);
|
||||
QString GetFileEntryAbsPath(FileEntryType type, int index) const;
|
||||
|
||||
// Chart data management
|
||||
void SetFileTypeData(const QList<FileTypeData>& fileTypes);
|
||||
const QList<FileTypeData>& GetFileTypeData() const;
|
||||
void AddChartData(FileEntryType type, const std::shared_ptr<BaseChartData>& chart);
|
||||
QList<std::shared_ptr<BaseChartData>> GetChartData(FileEntryType type) const;
|
||||
|
||||
inline void SetHomeViewpoint(const osgEarth::Viewpoint& viewpoint) {
|
||||
homeViewpoint_ = viewpoint;
|
||||
homeViewpoint_.setHeading(0.0); // Ensure heading is set to 0.0
|
||||
@ -186,8 +179,6 @@ private:
|
||||
class Entity* trackedEntity_{ nullptr };
|
||||
// Stored as file entries under workspace dir, keyed by type
|
||||
std::map<FileEntryType, std::vector<std::shared_ptr<FileEntry>>> files_;
|
||||
// Chart data storage
|
||||
QList<FileTypeData> fileTypeData_;
|
||||
// Monotonic sequence for file entries changes, used to trigger UI refresh
|
||||
std::uint64_t filesSeq_{ 0 };
|
||||
// Executor for command XML actions
|
||||
|
||||
@ -107,8 +107,6 @@ bool WorkSpaceXMLParse::ParseFiles(const tinyxml2::XMLElement* element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<FileTypeData> fileTypes;
|
||||
|
||||
const tinyxml2::XMLElement* typeElement = element->FirstChildElement("type");
|
||||
while (nullptr != typeElement) {
|
||||
const char* name = typeElement->Attribute("name");
|
||||
@ -116,10 +114,6 @@ bool WorkSpaceXMLParse::ParseFiles(const tinyxml2::XMLElement* element) {
|
||||
typeElement->QueryIntAttribute("count", &count);
|
||||
|
||||
if (nullptr != name && count > 0) {
|
||||
FileTypeData fileTypeData;
|
||||
fileTypeData.typeName = QString::fromLocal8Bit(name);
|
||||
fileTypeData.count = count;
|
||||
|
||||
QString typeName = QString::fromLocal8Bit(name);
|
||||
|
||||
// Create FileEntry objects and call their ParseFiles method
|
||||
@ -140,279 +134,10 @@ bool WorkSpaceXMLParse::ParseFiles(const tinyxml2::XMLElement* element) {
|
||||
// Also set file entry count for backward compatibility
|
||||
workSpace_->SetFileEntryCount(enumType, count);
|
||||
}
|
||||
|
||||
// Parse chart elements within this type (for chart data storage)
|
||||
const tinyxml2::XMLElement* chartElement = typeElement->FirstChildElement("chart");
|
||||
while (nullptr != chartElement) {
|
||||
std::shared_ptr<BaseChartData> chartData;
|
||||
|
||||
// Create appropriate chart type based on the file type
|
||||
if (typeName == FileEntryTypeToString(FileEntryType::Curve)) {
|
||||
auto curveChart = std::make_shared<CurveChartData>();
|
||||
|
||||
// Parse curve-specific attributes
|
||||
if (const char* chartName = chartElement->Attribute("name")) {
|
||||
curveChart->name = QString(chartName);
|
||||
}
|
||||
if (const char* path = chartElement->Attribute("path")) {
|
||||
curveChart->path = QString(path);
|
||||
}
|
||||
if (const char* xTitle = chartElement->Attribute("xTitle")) {
|
||||
curveChart->xTitle = QString(xTitle);
|
||||
}
|
||||
if (const char* yTitle = chartElement->Attribute("yTitle")) {
|
||||
curveChart->yTitle = QString(yTitle);
|
||||
}
|
||||
if (const char* xMin = chartElement->Attribute("xMin")) {
|
||||
curveChart->xMin = QString(xMin).toDouble();
|
||||
}
|
||||
if (const char* xMax = chartElement->Attribute("xMax")) {
|
||||
curveChart->xMax = QString(xMax).toDouble();
|
||||
}
|
||||
if (const char* yMin = chartElement->Attribute("yMin")) {
|
||||
curveChart->yMin = QString(yMin).toDouble();
|
||||
}
|
||||
if (const char* yMax = chartElement->Attribute("yMax")) {
|
||||
curveChart->yMax = QString(yMax).toDouble();
|
||||
}
|
||||
if (const char* xCount = chartElement->Attribute("xCount")) {
|
||||
curveChart->xCount = QString(xCount).toInt();
|
||||
}
|
||||
if (const char* yCount = chartElement->Attribute("yCount")) {
|
||||
curveChart->yCount = QString(yCount).toInt();
|
||||
}
|
||||
if (const char* t = chartElement->Attribute("t")) {
|
||||
curveChart->t = QString(t);
|
||||
}
|
||||
|
||||
// Parse curve elements
|
||||
const tinyxml2::XMLElement* curveElement = chartElement->FirstChildElement("curve");
|
||||
while (nullptr != curveElement) {
|
||||
CurveData curveData;
|
||||
|
||||
if (const char* curveName = curveElement->Attribute("name")) {
|
||||
curveData.name = QString(curveName);
|
||||
}
|
||||
if (const char* color = curveElement->Attribute("color")) {
|
||||
curveData.color = QString(color);
|
||||
}
|
||||
if (const char* start = curveElement->Attribute("start")) {
|
||||
curveData.start = QString(start).toInt();
|
||||
}
|
||||
if (const char* stop = curveElement->Attribute("stop")) {
|
||||
curveData.stop = QString(stop).toInt();
|
||||
}
|
||||
if (const char* stop = curveElement->Attribute("x")) {
|
||||
curveData.x = QString(stop).toInt();
|
||||
}
|
||||
if (const char* stop = curveElement->Attribute("y")) {
|
||||
curveData.y = QString(stop).toInt();
|
||||
}
|
||||
|
||||
curveChart->curves.append(curveData);
|
||||
curveElement = curveElement->NextSiblingElement("curve");
|
||||
}
|
||||
|
||||
chartData = curveChart;
|
||||
|
||||
} else if (typeName == FileEntryTypeToString(FileEntryType::Surface)) {
|
||||
auto surfaceChart = std::make_shared<SurfaceChartData>();
|
||||
|
||||
// Parse surface-specific attributes
|
||||
if (const char* chartName = chartElement->Attribute("name")) {
|
||||
surfaceChart->name = QString::fromLocal8Bit(chartName);
|
||||
}
|
||||
if (const char* chartName = chartElement->Attribute("Name")) { // Handle both cases
|
||||
surfaceChart->name = QString::fromLocal8Bit(chartName);
|
||||
}
|
||||
if (const char* path = chartElement->Attribute("path")) {
|
||||
surfaceChart->path = QString::fromLocal8Bit(path);
|
||||
}
|
||||
if (const char* xTitle = chartElement->Attribute("xTitle")) {
|
||||
surfaceChart->xTitle = QString::fromLocal8Bit(xTitle);
|
||||
}
|
||||
if (const char* yTitle = chartElement->Attribute("yTitle")) {
|
||||
surfaceChart->yTitle = QString::fromLocal8Bit(yTitle);
|
||||
}
|
||||
if (const char* zTitle = chartElement->Attribute("zTitle")) {
|
||||
surfaceChart->zTitle = QString::fromLocal8Bit(zTitle);
|
||||
}
|
||||
if (const char* xMin = chartElement->Attribute("xMin")) {
|
||||
surfaceChart->xMin = QString::fromLocal8Bit(xMin).toDouble();
|
||||
}
|
||||
if (const char* xMax = chartElement->Attribute("xMax")) {
|
||||
surfaceChart->xMax = QString::fromLocal8Bit(xMax).toDouble();
|
||||
}
|
||||
if (const char* yMin = chartElement->Attribute("yMin")) {
|
||||
surfaceChart->yMin = QString::fromLocal8Bit(yMin).toDouble();
|
||||
}
|
||||
if (const char* yMax = chartElement->Attribute("yMax")) {
|
||||
surfaceChart->yMax = QString::fromLocal8Bit(yMax).toDouble();
|
||||
}
|
||||
if (const char* zMin = chartElement->Attribute("zMin")) {
|
||||
surfaceChart->zMin = QString::fromLocal8Bit(zMin).toDouble();
|
||||
}
|
||||
if (const char* zMax = chartElement->Attribute("zMax")) {
|
||||
surfaceChart->zMax = QString::fromLocal8Bit(zMax).toDouble();
|
||||
}
|
||||
if (const char* xCount = chartElement->Attribute("xCount")) {
|
||||
surfaceChart->xCount = QString::fromLocal8Bit(xCount).toInt();
|
||||
}
|
||||
if (const char* yCount = chartElement->Attribute("yCount")) {
|
||||
surfaceChart->yCount = QString::fromLocal8Bit(yCount).toInt();
|
||||
}
|
||||
if (const char* zCount = chartElement->Attribute("zCount")) {
|
||||
surfaceChart->zCount = QString::fromLocal8Bit(zCount).toInt();
|
||||
}
|
||||
if (const char* t = chartElement->Attribute("t")) {
|
||||
surfaceChart->t = QString::fromLocal8Bit(t);
|
||||
}
|
||||
|
||||
// Parse curve elements
|
||||
const tinyxml2::XMLElement* curveElement = chartElement->FirstChildElement("curve");
|
||||
while (nullptr != curveElement) {
|
||||
SurfaceCurveData curveData;
|
||||
|
||||
if (const char* curveName = curveElement->Attribute("name")) {
|
||||
curveData.name = QString::fromLocal8Bit(curveName);
|
||||
}
|
||||
if (const char* curveName = curveElement->Attribute("Name")) { // Handle both cases
|
||||
curveData.name = QString::fromLocal8Bit(curveName);
|
||||
}
|
||||
if (const char* color = curveElement->Attribute("color")) {
|
||||
curveData.color = QString::fromLocal8Bit(color);
|
||||
}
|
||||
if (const char* color = curveElement->Attribute("Color")) { // Handle both cases
|
||||
curveData.color = QString::fromLocal8Bit(color);
|
||||
}
|
||||
if (const char* start = curveElement->Attribute("start")) {
|
||||
curveData.start = QString::fromLocal8Bit(start).toDouble();
|
||||
}
|
||||
if (const char* start = curveElement->Attribute("Start")) { // Handle both cases
|
||||
curveData.start = QString::fromLocal8Bit(start).toDouble();
|
||||
}
|
||||
if (const char* stop = curveElement->Attribute("stop")) {
|
||||
curveData.stop = QString::fromLocal8Bit(stop).toDouble();
|
||||
}
|
||||
if (const char* stop = curveElement->Attribute("Stop")) { // Handle both cases
|
||||
curveData.stop = QString::fromLocal8Bit(stop).toDouble();
|
||||
}
|
||||
if (const char* x = curveElement->Attribute("x")) {
|
||||
curveData.x = QString::fromLocal8Bit(x).toDouble();
|
||||
}
|
||||
if (const char* y = curveElement->Attribute("y")) {
|
||||
curveData.y = QString::fromLocal8Bit(y).toDouble();
|
||||
}
|
||||
if (const char* z = curveElement->Attribute("z")) {
|
||||
curveData.z = QString::fromLocal8Bit(z).toDouble();
|
||||
}
|
||||
|
||||
surfaceChart->curves.append(curveData);
|
||||
curveElement = curveElement->NextSiblingElement("curve");
|
||||
}
|
||||
|
||||
chartData = surfaceChart;
|
||||
|
||||
} else if (typeName == FileEntryTypeToString(FileEntryType::Table)) {
|
||||
auto tableChart = std::make_shared<TableChartData>();
|
||||
|
||||
// Parse table-specific attributes
|
||||
if (const char* chartName = chartElement->Attribute("name")) {
|
||||
tableChart->name = QString::fromLocal8Bit(chartName);
|
||||
}
|
||||
if (const char* chartName = chartElement->Attribute("Name")) { // Handle both cases
|
||||
tableChart->name = QString::fromLocal8Bit(chartName);
|
||||
}
|
||||
if (const char* path = chartElement->Attribute("path")) {
|
||||
tableChart->path = QString::fromLocal8Bit(path);
|
||||
}
|
||||
if (const char* head = chartElement->Attribute("head")) {
|
||||
tableChart->head = QString::fromLocal8Bit(head);
|
||||
}
|
||||
if (const char* t = chartElement->Attribute("t")) {
|
||||
tableChart->t = QString::fromLocal8Bit(t);
|
||||
}
|
||||
|
||||
// Parse curve elements
|
||||
const tinyxml2::XMLElement* curveElement = chartElement->FirstChildElement("curve");
|
||||
while (nullptr != curveElement) {
|
||||
TableCurveData curveData;
|
||||
|
||||
if (const char* curveName = curveElement->Attribute("name")) {
|
||||
curveData.name = QString::fromLocal8Bit(curveName);
|
||||
}
|
||||
if (const char* curveName = curveElement->Attribute("Name")) { // Handle both cases
|
||||
curveData.name = QString::fromLocal8Bit(curveName);
|
||||
}
|
||||
if (const char* color = curveElement->Attribute("color")) {
|
||||
curveData.color = QString::fromLocal8Bit(color);
|
||||
}
|
||||
if (const char* data = curveElement->Attribute("data")) {
|
||||
curveData.data = QString::fromLocal8Bit(data);
|
||||
}
|
||||
|
||||
tableChart->curves.append(curveData);
|
||||
curveElement = curveElement->NextSiblingElement("curve");
|
||||
}
|
||||
|
||||
chartData = tableChart;
|
||||
|
||||
} else if (typeName == FileEntryTypeToString(FileEntryType::Light)) {
|
||||
auto lightChart = std::make_shared<LightChartData>();
|
||||
|
||||
// Parse light-specific attributes
|
||||
if (const char* chartName = chartElement->Attribute("name")) {
|
||||
lightChart->name = QString::fromLocal8Bit(chartName);
|
||||
}
|
||||
if (const char* path = chartElement->Attribute("path")) {
|
||||
lightChart->path = QString::fromLocal8Bit(path);
|
||||
}
|
||||
if (const char* openColor = chartElement->Attribute("openColor")) {
|
||||
lightChart->openColor = QString::fromLocal8Bit(openColor);
|
||||
}
|
||||
if (const char* closeColor = chartElement->Attribute("closeColor")) {
|
||||
lightChart->closeColor = QString::fromLocal8Bit(closeColor);
|
||||
}
|
||||
if (const char* t = chartElement->Attribute("t")) {
|
||||
lightChart->t = QString::fromLocal8Bit(t);
|
||||
}
|
||||
|
||||
// Parse curve elements
|
||||
const tinyxml2::XMLElement* curveElement = chartElement->FirstChildElement("curve");
|
||||
while (nullptr != curveElement) {
|
||||
LightCurveData curveData;
|
||||
|
||||
if (const char* curveName = curveElement->Attribute("name")) {
|
||||
curveData.name = QString::fromLocal8Bit(curveName);
|
||||
}
|
||||
if (const char* data = curveElement->Attribute("data")) {
|
||||
curveData.data = QString::fromLocal8Bit(data);
|
||||
}
|
||||
|
||||
lightChart->curves.append(curveData);
|
||||
curveElement = curveElement->NextSiblingElement("curve");
|
||||
}
|
||||
|
||||
chartData = lightChart;
|
||||
}
|
||||
|
||||
if (chartData) {
|
||||
fileTypeData.charts.append(chartData);
|
||||
}
|
||||
chartElement = chartElement->NextSiblingElement("chart");
|
||||
}
|
||||
|
||||
fileTypes.append(fileTypeData);
|
||||
|
||||
// Note: FileEntry creation and parsing is already handled above
|
||||
// No need for additional backward compatibility code here
|
||||
}
|
||||
typeElement = typeElement->NextSiblingElement("type");
|
||||
}
|
||||
|
||||
// Store the parsed chart data
|
||||
workSpace_->SetFileTypeData(fileTypes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
#include <QObject>
|
||||
|
||||
#include "xml/tinyxml2.h"
|
||||
#include "workspace/ChartData.h"
|
||||
|
||||
class WorkSpace;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user