更换csv读取方式为csv.hpp为csv.h实现
This commit is contained in:
parent
dbcdb54f6d
commit
b11e142e11
1199
3rdlib/csv/csv.h
Normal file
1199
3rdlib/csv/csv.h
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -1,11 +1,13 @@
|
||||||
#include "DataProcessWorkPool.h"
|
#include "DataProcessWorkPool.h"
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include "csv.hpp"
|
#include <fstream>
|
||||||
|
#include "csv.h"
|
||||||
#include "MeasureAnalysisProjectModel.h"
|
#include "MeasureAnalysisProjectModel.h"
|
||||||
#include "OutputInfoDefine.h"
|
#include "OutputInfoDefine.h"
|
||||||
|
|
||||||
using namespace DataProcessWorkPool;
|
using namespace DataProcessWorkPool;
|
||||||
|
using namespace io;
|
||||||
|
|
||||||
void EveryChannelParticleDataTask::SetAllChannelParticleDataFilename(const QString& all_channel_particle_data_filename)
|
void EveryChannelParticleDataTask::SetAllChannelParticleDataFilename(const QString& all_channel_particle_data_filename)
|
||||||
{
|
{
|
||||||
|
|
@ -66,6 +68,21 @@ void EveryChannelParticleDataTask::run()
|
||||||
QMetaObject::invokeMethod(_finished_notifier, _finished_notifier_process, Qt::QueuedConnection, Q_ARG(QString, _project_name));
|
QMetaObject::invokeMethod(_finished_notifier, _finished_notifier_process, Qt::QueuedConnection, Q_ARG(QString, _project_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EveryChannelParticleDataSeparateTask::SetResultDataDir(const QString& result_data_dir)
|
||||||
|
{
|
||||||
|
this->_result_data_dir = result_data_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString& EveryChannelParticleDataSeparateTask::GetResultDataDir() const
|
||||||
|
{
|
||||||
|
return this->_result_data_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EveryChannelParticleDataSeparateTask::IsValidSetWorkParameters() const
|
||||||
|
{
|
||||||
|
return (!GetResultDataDir().isEmpty()) && EveryChannelParticleDataTask::IsValidSetWorkParameters();
|
||||||
|
}
|
||||||
|
|
||||||
bool EveryChannelParticleDataSeparateTask::processEveryChannelParticleData()
|
bool EveryChannelParticleDataSeparateTask::processEveryChannelParticleData()
|
||||||
{
|
{
|
||||||
bool ret_ok = true;
|
bool ret_ok = true;
|
||||||
|
|
@ -79,18 +96,18 @@ bool EveryChannelParticleDataSeparateTask::processEveryChannelParticleData()
|
||||||
try {
|
try {
|
||||||
QMap<uint, std::shared_ptr<std::ofstream>> ch_particle_data_of_list;
|
QMap<uint, std::shared_ptr<std::ofstream>> ch_particle_data_of_list;
|
||||||
|
|
||||||
csv::CSVFormat format;
|
std::string board_id_str = QString(QStringLiteral(u"板卡号")).toStdString();
|
||||||
format.delimiter(',').quote('"').trim({' ', '\t'}).variable_columns(csv::VariableColumnPolicy::THROW);
|
std::string channel_id_str = QString(QStringLiteral(u"通道号")).toStdString();
|
||||||
csv::CSVReader reader(all_channel_particle_data_filename.toStdString());
|
std::string address_str = QString(QStringLiteral(u"道址")).toStdString();
|
||||||
for (auto& row : reader) {
|
std::string time_str = QString(QStringLiteral(u"时间计数")).toStdString();
|
||||||
if (row.size() != 4) {
|
|
||||||
ret_ok = false;
|
io::CSVReader<4> reader(all_channel_particle_data_filename.toStdString());
|
||||||
break;
|
reader.read_header(io::ignore_no_column, board_id_str, channel_id_str, address_str, time_str);
|
||||||
}
|
uint board_id;
|
||||||
uint board_id = row[0].get<uint>();
|
uint channel_id;
|
||||||
uint channel_id = row[1].get<uint>();
|
uint address;
|
||||||
uint address = row[2].get<uint>();
|
unsigned long long time;
|
||||||
unsigned long long time = row[3].get<unsigned long long>();
|
while (reader.read_row(board_id, channel_id, address, time)) {
|
||||||
|
|
||||||
// 板卡和通道号计算,通道号 = 板卡号 * 4 + 通道号
|
// 板卡和通道号计算,通道号 = 板卡号 * 4 + 通道号
|
||||||
int channel_num = (board_id) * 4 + (channel_id + 1);
|
int channel_num = (board_id) * 4 + (channel_id + 1);
|
||||||
|
|
@ -104,12 +121,11 @@ bool EveryChannelParticleDataSeparateTask::processEveryChannelParticleData()
|
||||||
new std::ofstream(particle_data_filename.toStdString(), std::ios::out | std::ios::app),
|
new std::ofstream(particle_data_filename.toStdString(), std::ios::out | std::ios::app),
|
||||||
[](std::ofstream* p){p->close();}
|
[](std::ofstream* p){p->close();}
|
||||||
);
|
);
|
||||||
*out << QStringLiteral(u"板卡号,通道号,地址,时间计数") << std::endl;
|
*out << QString(QStringLiteral(u"板卡号,通道号,道址,时间计数")).toStdString() << std::endl;
|
||||||
ch_particle_data_of_list.insert(channel_num, out);
|
ch_particle_data_of_list.insert(channel_num, out);
|
||||||
}
|
}
|
||||||
auto ch_particle_data_of = ch_particle_data_of_list.value(channel_num);
|
auto ch_particle_data_of = ch_particle_data_of_list.value(channel_num);
|
||||||
auto writer = csv::make_csv_writer(*ch_particle_data_of);
|
*ch_particle_data_of << board_id << "," << channel_id << "," << address << "," << time << std::endl;
|
||||||
writer << std::vector<std::string>{std::to_string(board_id), std::to_string(channel_id), std::to_string(address), std::to_string(time)};
|
|
||||||
}
|
}
|
||||||
} catch (const std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
QString error = QString(QStringLiteral(u"处理%1发生运行时异常:%2")).arg(all_channel_particle_data_filename).arg(e.what());
|
QString error = QString(QStringLiteral(u"处理%1发生运行时异常:%2")).arg(all_channel_particle_data_filename).arg(e.what());
|
||||||
|
|
@ -137,50 +153,124 @@ bool EveryChannelParticleDataSeparateTask::processEveryChannelParticleData()
|
||||||
return ret_ok;
|
return ret_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EveryChannelParticleCountDataTask::SetAllChannelCountResultDir(const QString &dir_path)
|
||||||
|
{
|
||||||
|
this->_all_ch_count_dir = dir_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &EveryChannelParticleCountDataTask::GetAllChannelCountResultDir() const
|
||||||
|
{
|
||||||
|
return this->_all_ch_count_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EveryChannelParticleCountDataTask::SetEveryChannelCountResultDir(const QString &dir_path)
|
||||||
|
{
|
||||||
|
this->_every_ch_count_dir = dir_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &EveryChannelParticleCountDataTask::GetEveryChannelCountResultDir() const
|
||||||
|
{
|
||||||
|
return this->_every_ch_count_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EveryChannelParticleCountDataTask::IsValidSetWorkParameters() const
|
||||||
|
{
|
||||||
|
return (!GetAllChannelCountResultDir().isEmpty()) &&
|
||||||
|
(!GetEveryChannelCountResultDir().isEmpty()) &&
|
||||||
|
EveryChannelParticleDataTask::IsValidSetWorkParameters();
|
||||||
|
}
|
||||||
|
|
||||||
bool EveryChannelParticleCountDataTask::processEveryChannelParticleData()
|
bool EveryChannelParticleCountDataTask::processEveryChannelParticleData()
|
||||||
{
|
{
|
||||||
bool ret_ok = true;
|
bool ret_ok = true;
|
||||||
const QString& result_data_output_dir_path = GetResultDataDir();
|
const QString& all_ch_count_dir = GetAllChannelCountResultDir();
|
||||||
QDir result_data_output_dir(result_data_output_dir_path);
|
const QString& every_ch_count_dir = GetEveryChannelCountResultDir();
|
||||||
result_data_output_dir.mkpath(result_data_output_dir_path);
|
|
||||||
|
QDir all_ch_count_output_dir(all_ch_count_dir);
|
||||||
|
all_ch_count_output_dir.mkpath(all_ch_count_dir);
|
||||||
|
|
||||||
|
QDir every_ch_count_output_dir(every_ch_count_dir);
|
||||||
|
every_ch_count_output_dir.mkpath(every_ch_count_dir);
|
||||||
|
|
||||||
const QString& all_channel_particle_data_filename = GetAllChannelParticleDataFilename();
|
const QString& all_channel_particle_data_filename = GetAllChannelParticleDataFilename();
|
||||||
QMap<uint, QString> particle_data_filename_list;
|
QMap<uint, QString> particle_count_filename_list;
|
||||||
|
QString all_channel_total_count_filename;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
QMap<uint, std::shared_ptr<std::ofstream>> ch_particle_data_of_list;
|
// 统计每个通道的粒子计数(相同板卡号通道号相同道址)
|
||||||
|
QMap<uint, QMap<uint, uint>> channel_address_counts; // 通道号 -> 地址 -> 计数
|
||||||
csv::CSVFormat format;
|
|
||||||
format.delimiter(',').quote('"').trim({' ', '\t'}).variable_columns(csv::VariableColumnPolicy::THROW);
|
// 统计所有通道的粒子计数(不同板卡号通道号相同道址)
|
||||||
csv::CSVReader reader(all_channel_particle_data_filename.toStdString());
|
QMap<uint, uint> all_channel_address_counts; // 地址 -> 计数
|
||||||
for (auto& row : reader) {
|
|
||||||
if (row.size() != 4) {
|
std::string board_id_str = QString(QStringLiteral(u"板卡号")).toStdString();
|
||||||
ret_ok = false;
|
std::string channel_id_str = QString(QStringLiteral(u"通道号")).toStdString();
|
||||||
break;
|
std::string address_str = QString(QStringLiteral(u"道址")).toStdString();
|
||||||
}
|
std::string time_str = QString(QStringLiteral(u"时间计数")).toStdString();
|
||||||
uint board_id = row[0].get<uint>();
|
|
||||||
uint channel_id = row[1].get<uint>();
|
io::CSVReader<4> reader(all_channel_particle_data_filename.toStdString());
|
||||||
uint address = row[2].get<uint>();
|
reader.read_header(io::ignore_no_column, board_id_str, channel_id_str, address_str, time_str);
|
||||||
unsigned long long time = row[3].get<unsigned long long>();
|
uint board_id;
|
||||||
|
uint channel_id;
|
||||||
|
uint address;
|
||||||
|
unsigned long long time;
|
||||||
|
while (reader.read_row(board_id, channel_id, address, time)) {
|
||||||
// 板卡和通道号计算,通道号 = 板卡号 * 4 + 通道号
|
// 板卡和通道号计算,通道号 = 板卡号 * 4 + 通道号
|
||||||
int channel_num = (board_id) * 4 + (channel_id + 1);
|
int channel_num = (board_id) * 4 + (channel_id + 1);
|
||||||
QString particle_data_filename = result_data_output_dir.filePath(QString("ParticleCountData_ch_%1.csv").arg(channel_num));
|
|
||||||
if (!particle_data_filename_list.contains(channel_num)) {
|
// 统计每个通道的粒子计数
|
||||||
particle_data_filename_list.insert(channel_num, particle_data_filename);
|
if (!channel_address_counts.contains(channel_num)) {
|
||||||
|
channel_address_counts[channel_num] = QMap<uint, uint>();
|
||||||
}
|
}
|
||||||
|
channel_address_counts[channel_num][address]++;
|
||||||
if ( !ch_particle_data_of_list.contains(channel_num) ) {
|
|
||||||
std::shared_ptr<std::ofstream> out(
|
// 统计所有通道的粒子计数
|
||||||
new std::ofstream(particle_data_filename.toStdString(), std::ios::out | std::ios::app),
|
all_channel_address_counts[address]++;
|
||||||
[](std::ofstream* p){p->close();}
|
|
||||||
);
|
|
||||||
ch_particle_data_of_list.insert(channel_num, out);
|
|
||||||
}
|
|
||||||
auto ch_particle_data_of = ch_particle_data_of_list.value(channel_num);
|
|
||||||
auto writer = csv::make_csv_writer(*ch_particle_data_of);
|
|
||||||
writer << std::vector<std::string>{std::to_string(board_id), std::to_string(channel_id), std::to_string(address), std::to_string(time)};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 写入每个通道的粒子计数数据(优化:使用一次打开文件,批量写入)
|
||||||
|
QMap<uint, std::shared_ptr<std::ofstream>> channel_file_streams;
|
||||||
|
|
||||||
|
// 预创建所有通道的文件流
|
||||||
|
for (auto channel_it = channel_address_counts.begin(); channel_it != channel_address_counts.end(); ++channel_it) {
|
||||||
|
uint channel_num = channel_it.key();
|
||||||
|
QString count_data_filename = every_ch_count_output_dir.filePath(QString("ParticleCountData_ch_%1.csv").arg(channel_num));
|
||||||
|
particle_count_filename_list.insert(channel_num, count_data_filename);
|
||||||
|
|
||||||
|
// 创建文件流
|
||||||
|
std::shared_ptr<std::ofstream> out(new std::ofstream(count_data_filename.toStdString()));
|
||||||
|
channel_file_streams[channel_num] = out;
|
||||||
|
*out << QString(QStringLiteral(u"道址")).toStdString() << "," << QString(QStringLiteral(u"计数")).toStdString() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量写入数据
|
||||||
|
for (auto channel_it = channel_address_counts.begin(); channel_it != channel_address_counts.end(); ++channel_it) {
|
||||||
|
uint channel_num = channel_it.key();
|
||||||
|
const QMap<uint, uint>& address_counts = channel_it.value();
|
||||||
|
auto out_stream = channel_file_streams[channel_num];
|
||||||
|
|
||||||
|
for (auto address_it = address_counts.begin(); address_it != address_counts.end(); ++address_it) {
|
||||||
|
uint address = address_it.key();
|
||||||
|
uint count = address_it.value();
|
||||||
|
*out_stream << address << "," << count << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 文件流会在shared_ptr析构时自动关闭
|
||||||
|
channel_file_streams.clear();
|
||||||
|
|
||||||
|
// 写入所有通道的粒子计数数据
|
||||||
|
all_channel_total_count_filename = all_ch_count_output_dir.filePath("AllChannelParticleTotalCountData.csv");
|
||||||
|
std::ofstream all_channel_out(all_channel_total_count_filename.toStdString());
|
||||||
|
all_channel_out << QString(QStringLiteral(u"道址")).toStdString() << "," << QString(QStringLiteral(u"计数")).toStdString() << std::endl;
|
||||||
|
|
||||||
|
for (auto address_it = all_channel_address_counts.begin(); address_it != all_channel_address_counts.end(); ++address_it) {
|
||||||
|
uint address = address_it.key();
|
||||||
|
uint count = address_it.value();
|
||||||
|
all_channel_out << address << "," << count << std::endl;
|
||||||
|
}
|
||||||
|
all_channel_out.close();
|
||||||
|
|
||||||
} catch (const std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
QString error = QString(QStringLiteral(u"处理%1发生运行时异常:%2")).arg(all_channel_particle_data_filename).arg(e.what());
|
QString error = QString(QStringLiteral(u"处理%1发生运行时异常:%2")).arg(all_channel_particle_data_filename).arg(e.what());
|
||||||
LOG_ERROR(error)
|
LOG_ERROR(error)
|
||||||
|
|
@ -190,7 +280,7 @@ bool EveryChannelParticleCountDataTask::processEveryChannelParticleData()
|
||||||
LOG_ERROR(error)
|
LOG_ERROR(error)
|
||||||
ret_ok = false;
|
ret_ok = false;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
QString error = QString(QStringLiteral(u"处理%1未知异常.")).arg(all_channel_particle_data_filename);
|
QString error = QString(QStringLiteral(u"处理%1未知异常.").arg(all_channel_particle_data_filename));
|
||||||
LOG_ERROR(error)
|
LOG_ERROR(error)
|
||||||
ret_ok = false;
|
ret_ok = false;
|
||||||
}
|
}
|
||||||
|
|
@ -199,9 +289,13 @@ bool EveryChannelParticleCountDataTask::processEveryChannelParticleData()
|
||||||
MeasureAnalysisProjectModel* project_model = MeasureAnalysisProjectModelList::GetProjectModel(project_name);
|
MeasureAnalysisProjectModel* project_model = MeasureAnalysisProjectModelList::GetProjectModel(project_name);
|
||||||
if (project_model == nullptr) {
|
if (project_model == nullptr) {
|
||||||
ret_ok = false;
|
ret_ok = false;
|
||||||
}
|
} else {
|
||||||
for (auto it = particle_data_filename_list.begin(); it != particle_data_filename_list.end(); ++it) {
|
// 更新项目模型中的通道粒子计数数据文件名
|
||||||
project_model->SetChannelParticleDataFilename(it.key(), it.value());
|
for (auto it = particle_count_filename_list.begin(); it != particle_count_filename_list.end(); ++it) {
|
||||||
|
project_model->SetChannelParticleCountDataFilename(it.key(), it.value());
|
||||||
|
}
|
||||||
|
// 更新项目模型中的所有通道粒子总计数数据文件名
|
||||||
|
project_model->SetAllChannelParticleTotalCountDataFilename(all_channel_total_count_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_ok;
|
return ret_ok;
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ namespace DataProcessWorkPool
|
||||||
class EveryChannelParticleCountDataTask : public EveryChannelParticleDataTask
|
class EveryChannelParticleCountDataTask : public EveryChannelParticleDataTask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void SetAllChannelCountResultDir(const QString& filename);
|
void SetAllChannelCountResultDir(const QString& dir_path);
|
||||||
const QString& GetAllChannelCountResultDir() const;
|
const QString& GetAllChannelCountResultDir() const;
|
||||||
void SetEveryChannelCountResultDir(const QString&dir_path);
|
void SetEveryChannelCountResultDir(const QString&dir_path);
|
||||||
const QString& GetEveryChannelCountResultDir() const;
|
const QString& GetEveryChannelCountResultDir() const;
|
||||||
|
|
|
||||||
|
|
@ -87,16 +87,6 @@ MainWindow::MainWindow(QWidget* parent)
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
QList<CDockWidget*> dock_widget_list = this->_dock_manager->dockWidgetsMap().values();
|
|
||||||
for (auto it = dock_widget_list.constBegin(); it != dock_widget_list.constEnd(); ++it) {
|
|
||||||
CDockWidget* dock_widget = *it;
|
|
||||||
if (dock_widget) {
|
|
||||||
bool need_take_widget = dock_widget->property("TakeWidget").toBool();
|
|
||||||
if (need_take_widget) {
|
|
||||||
dock_widget->takeWidget();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,11 +117,11 @@ void MainWindow::initMainWindow()
|
||||||
|
|
||||||
// 构建测量分析工程树视图
|
// 构建测量分析工程树视图
|
||||||
_tree_measure_analysis = new MeasureAnalysisTree::TreeWidget;
|
_tree_measure_analysis = new MeasureAnalysisTree::TreeWidget;
|
||||||
ads::CDockWidget* dockw_measure_analysis_tree = new ads::CDockWidget(QStringLiteral(u"测量分析工作空间"));
|
_dockw_measure_analysis_tree = new ads::CDockWidget(QStringLiteral(u"测量分析工作空间"));
|
||||||
dockw_measure_analysis_tree->setWidget(_tree_measure_analysis);
|
_dockw_measure_analysis_tree->setWidget(_tree_measure_analysis);
|
||||||
dockw_measure_analysis_tree->setMinimumSizeHintMode(ads::CDockWidget::MinimumSizeHintFromContentMinimumSize);
|
_dockw_measure_analysis_tree->setMinimumSizeHintMode(ads::CDockWidget::MinimumSizeHintFromContentMinimumSize);
|
||||||
_dock_manager->addDockWidget(ads::DockWidgetArea::LeftDockWidgetArea, dockw_measure_analysis_tree);
|
_dock_manager->addDockWidget(ads::DockWidgetArea::LeftDockWidgetArea, _dockw_measure_analysis_tree);
|
||||||
ui->menu_view->addAction(dockw_measure_analysis_tree->toggleViewAction());
|
ui->menu_view->addAction(_dockw_measure_analysis_tree->toggleViewAction());
|
||||||
|
|
||||||
_menu_view_data_table_list = ui->menu_view->addMenu(QStringLiteral(u"查看数据列表"));
|
_menu_view_data_table_list = ui->menu_view->addMenu(QStringLiteral(u"查看数据列表"));
|
||||||
_menu_view_analysis_view_list = ui->menu_view->addMenu(QStringLiteral(u"分析视图列表"));
|
_menu_view_analysis_view_list = ui->menu_view->addMenu(QStringLiteral(u"分析视图列表"));
|
||||||
|
|
@ -155,12 +145,12 @@ void MainWindow::initAction()
|
||||||
this->_tree_measure_analysis->AddProjectModel(project_model);
|
this->_tree_measure_analysis->AddProjectModel(project_model);
|
||||||
if (project_model->GetIsMeasureComplete()) {
|
if (project_model->GetIsMeasureComplete()) {
|
||||||
const QString& project_name = project_model->GetProjectName();
|
const QString& project_name = project_model->GetProjectName();
|
||||||
const QString& result_data_dir = QDir(project_model->GetProjectDir()).filePath("EveryChannelParticleData");
|
// const QString& result_data_dir = QDir(project_model->GetProjectDir()).filePath("EveryChannelParticleData");
|
||||||
auto separate_task = new DataProcessWorkPool::EveryChannelParticleDataSeparateTask;
|
// auto separate_task = new DataProcessWorkPool::EveryChannelParticleDataSeparateTask;
|
||||||
separate_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
// separate_task->SetAllChannelParticleDataFilename(project_model->GetAllChannelParticleDataFilename());
|
||||||
separate_task->SetResultDataDir(result_data_dir);
|
// separate_task->SetResultDataDir(result_data_dir);
|
||||||
separate_task->SetFinishedNotifier(this->_tree_measure_analysis, "onFinishedSeparateEveryChannelParticleData", project_name);
|
// separate_task->SetFinishedNotifier(this->_tree_measure_analysis, "onFinishedSeparateEveryChannelParticleData", project_name);
|
||||||
separate_task->StartTask();
|
// separate_task->StartTask();
|
||||||
|
|
||||||
const QString& all_ch_count_dir = project_model->GetProjectDir();
|
const QString& all_ch_count_dir = project_model->GetProjectDir();
|
||||||
const QString& every_ch_count_dir = QDir(project_model->GetProjectDir()).filePath("EveryChannelParticleCountData");
|
const QString& every_ch_count_dir = QDir(project_model->GetProjectDir()).filePath("EveryChannelParticleCountData");
|
||||||
|
|
@ -202,7 +192,7 @@ void MainWindow::initAction()
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(_tree_measure_analysis, &MeasureAnalysisTree::TreeWidget::currentItemViewWidget, [this](MeasureAnalysisView* view) {
|
connect(_tree_measure_analysis, &MeasureAnalysisTree::TreeWidget::currentItemViewWidget, [this](MeasureAnalysisView* view) {
|
||||||
if (view) {
|
if (view && this->_dock_manager) {
|
||||||
bool view_exist = false;
|
bool view_exist = false;
|
||||||
QList<CDockWidget*> dock_widget_list = this->_dock_manager->dockWidgetsMap().values();
|
QList<CDockWidget*> dock_widget_list = this->_dock_manager->dockWidgetsMap().values();
|
||||||
for (auto it = dock_widget_list.constBegin(); it != dock_widget_list.constEnd(); ++it) {
|
for (auto it = dock_widget_list.constBegin(); it != dock_widget_list.constEnd(); ++it) {
|
||||||
|
|
@ -244,13 +234,15 @@ void MainWindow::initAction()
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(_tree_measure_analysis, &MeasureAnalysisTree::TreeWidget::removeItemViewFromStack, [this](MeasureAnalysisView* view) {
|
connect(_tree_measure_analysis, &MeasureAnalysisTree::TreeWidget::removeItemViewFromStack, [this](MeasureAnalysisView* view) {
|
||||||
QList<CDockWidget*> dock_widget_list = this->_dock_manager->dockWidgetsMap().values();
|
if (this->_dock_manager) {
|
||||||
for (auto it = dock_widget_list.constBegin(); it != dock_widget_list.constEnd(); ++it) {
|
QList<CDockWidget*> dock_widget_list = this->_dock_manager->dockWidgetsMap().values();
|
||||||
CDockWidget* dock_widget = *it;
|
for (auto it = dock_widget_list.constBegin(); it != dock_widget_list.constEnd(); ++it) {
|
||||||
if (dock_widget) {
|
CDockWidget* dock_widget = *it;
|
||||||
if ( dock_widget->widget() == view ) {
|
if (dock_widget) {
|
||||||
dock_widget->takeWidget();
|
if ( dock_widget->widget() == view ) {
|
||||||
dock_widget->close();
|
QWidget* content = dock_widget->takeWidget();
|
||||||
|
dock_widget->deleteDockWidget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -280,6 +272,19 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
// Delete dock manager here to delete all floating widgets. This ensures
|
// Delete dock manager here to delete all floating widgets. This ensures
|
||||||
// that all top level windows of the dock manager are properly closed
|
// that all top level windows of the dock manager are properly closed
|
||||||
|
if (this->_dock_manager) {
|
||||||
|
QList<CDockWidget*> dock_widget_list = this->_dock_manager->dockWidgetsMap().values();
|
||||||
|
for (auto it = dock_widget_list.constBegin(); it != dock_widget_list.constEnd(); ++it) {
|
||||||
|
CDockWidget* dock_widget = *it;
|
||||||
|
if (dock_widget) {
|
||||||
|
bool need_take_widget = dock_widget->property("TakeWidget").toBool();
|
||||||
|
if (need_take_widget) {
|
||||||
|
dock_widget->takeWidget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
_dock_manager->deleteLater();
|
_dock_manager->deleteLater();
|
||||||
|
_dock_manager = nullptr;
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ private:
|
||||||
ads::CDockAreaWidget* _central_dock_area { nullptr };
|
ads::CDockAreaWidget* _central_dock_area { nullptr };
|
||||||
QAction* _action_central_dock_widget { nullptr };
|
QAction* _action_central_dock_widget { nullptr };
|
||||||
MeasureAnalysisTree::TreeWidget* _tree_measure_analysis { nullptr };
|
MeasureAnalysisTree::TreeWidget* _tree_measure_analysis { nullptr };
|
||||||
|
ads::CDockWidget* _dockw_measure_analysis_tree { nullptr };
|
||||||
QMenu* _menu_view_data_table_list { nullptr };
|
QMenu* _menu_view_data_table_list { nullptr };
|
||||||
QMenu* _menu_view_analysis_view_list { nullptr };
|
QMenu* _menu_view_analysis_view_list { nullptr };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ MeasureAnalysisDataTableView::MeasureAnalysisDataTableView():
|
||||||
// 创建表格视图
|
// 创建表格视图
|
||||||
_tableView = new VirtualTableView(this);
|
_tableView = new VirtualTableView(this);
|
||||||
_tableView->setFixedRowHeight(25); // 设置固定行高
|
_tableView->setFixedRowHeight(25); // 设置固定行高
|
||||||
|
_tableView->setShowGrid(true);
|
||||||
|
_tableView->setAlternatingRowColors(false);
|
||||||
layout->addWidget(_tableView);
|
layout->addWidget(_tableView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ TreeWidget::TreeWidget(QWidget* parent)
|
||||||
this->setDragDropMode(QTreeWidget::NoDragDrop);
|
this->setDragDropMode(QTreeWidget::NoDragDrop);
|
||||||
this->setDefaultDropAction(Qt::IgnoreAction);
|
this->setDefaultDropAction(Qt::IgnoreAction);
|
||||||
this->setDropIndicatorShown(true);
|
this->setDropIndicatorShown(true);
|
||||||
this->setAlternatingRowColors(true);
|
this->setAlternatingRowColors(false);
|
||||||
|
|
||||||
// 设置鼠标落在项上,显示项的详细信息
|
// 设置鼠标落在项上,显示项的详细信息
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
@ -156,6 +156,19 @@ void TreeWidget::AddProjectModel(MeasureAnalysisProjectModel* model)
|
||||||
{
|
{
|
||||||
if (model) {
|
if (model) {
|
||||||
auto new_item = new TreeMeasureAnalysisProjectItem(model->GetProjectName(), model->GetDescriptionInfo());
|
auto new_item = new TreeMeasureAnalysisProjectItem(model->GetProjectName(), model->GetDescriptionInfo());
|
||||||
|
if (model) {
|
||||||
|
TreeItem* tree_item_analyze_data_group = new_item->GetAnalyzeDataGroupItem();
|
||||||
|
if (tree_item_analyze_data_group) {
|
||||||
|
const QString& all_ch_particle_data_filename = model->GetAllChannelParticleDataFilename();
|
||||||
|
TreeItem* new_item_particle_data = new TreeItem;
|
||||||
|
new_item_particle_data->SetName(QStringLiteral(u"测量粒子数据"));
|
||||||
|
new_item_particle_data->SetType(TreeItem::TreeItemType::ParticleData);
|
||||||
|
new_item_particle_data->SetDescription(all_ch_particle_data_filename);
|
||||||
|
new_item_particle_data->setData(0, Qt::UserRole, all_ch_particle_data_filename);
|
||||||
|
tree_item_analyze_data_group->insertChild(0, new_item_particle_data);
|
||||||
|
this->expandItem(tree_item_analyze_data_group);
|
||||||
|
}
|
||||||
|
}
|
||||||
this->addTopLevelItem(new_item);
|
this->addTopLevelItem(new_item);
|
||||||
this->setCurrentItem(new_item);
|
this->setCurrentItem(new_item);
|
||||||
this->expandItem(new_item);
|
this->expandItem(new_item);
|
||||||
|
|
@ -163,6 +176,7 @@ void TreeWidget::AddProjectModel(MeasureAnalysisProjectModel* model)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void TreeWidget::onFinishedSeparateEveryChannelParticleData(const QString& project_name)
|
void TreeWidget::onFinishedSeparateEveryChannelParticleData(const QString& project_name)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this->topLevelItemCount(); i++) {
|
for (int i = 0; i < this->topLevelItemCount(); i++) {
|
||||||
|
|
@ -198,6 +212,7 @@ void TreeWidget::onFinishedSeparateEveryChannelParticleData(const QString& proje
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void TreeWidget::onFinishedParticleCountData(const QString& project_name)
|
void TreeWidget::onFinishedParticleCountData(const QString& project_name)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public:
|
||||||
void AddProjectModel(MeasureAnalysisProjectModel* model);
|
void AddProjectModel(MeasureAnalysisProjectModel* model);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onFinishedSeparateEveryChannelParticleData(const QString& project_name);
|
// void onFinishedSeparateEveryChannelParticleData(const QString& project_name);
|
||||||
void onFinishedParticleCountData(const QString& project_name);
|
void onFinishedParticleCountData(const QString& project_name);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ int main(int argc, char *argv[])
|
||||||
// 设置样式
|
// 设置样式
|
||||||
app.setStyle(QStyleFactory::create("Fusion"));
|
app.setStyle(QStyleFactory::create("Fusion"));
|
||||||
app.setWindowIcon(QIcon(":/logo/256.png"));
|
app.setWindowIcon(QIcon(":/logo/256.png"));
|
||||||
// app.setQuitOnLastWindowClosed(false);
|
app.setQuitOnLastWindowClosed(true);
|
||||||
|
|
||||||
// 在应用程序可执行文件所在目录检查并创建Projects目录
|
// 在应用程序可执行文件所在目录检查并创建Projects目录
|
||||||
QString projects_dir_path = QDir(app.applicationDirPath()).filePath("Projects");
|
QString projects_dir_path = QDir(app.applicationDirPath()).filePath("Projects");
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ QT += core gui widgets concurrent
|
||||||
# In order to do so, uncomment the following line.
|
# In order to do so, uncomment the following line.
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
CONFIG += c++17 release
|
CONFIG += c++17 #release
|
||||||
msvc {
|
msvc {
|
||||||
QMAKE_CFLAGS += /utf-8
|
QMAKE_CFLAGS += /utf-8
|
||||||
QMAKE_CXXFLAGS += /utf-8
|
QMAKE_CXXFLAGS += /utf-8
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user