You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Include/mGui/mGuiAnal/iLayerTableModel.h

95 lines
2.7 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
////////////////////////////////////////////////////////////////////
// 特别说明由于进度限制并且为了测试AI编码对于多层的对话框设置功能相对比
// 较单一而且有对标软件的效果所以采用了AI直接编码模式基本没有做大的改动。
// 效果功能优先暂不予iFramework框架进行集成。
// 涉及类库及文件:iLayerColorBand.h/cpp
// iLayerTableModel.h/cpp
// iLayerTableView.h/cpp
// iLayerWx.h/cpp
// 创建日期2026-01-08
// 作者AI大模型
// 整合者wangzg
// 后附:具体交互见 iLayerWx.h
////////////////////////////////////////////////////////////////////
#include <QColor>
#include <QAbstractTableModel>
#include "mGuiAnal_global.h"
struct LayerData
{
QString layerName;
double thickness; // unit: meter
double ratio; // percentage
QString remark;
QColor color;
LayerData() : thickness(10.0), ratio(0.0)
{}
LayerData(const QString& name, double thick, const QColor& col)
: layerName(name), thickness(thick), ratio(0.0), color(col)
{}
};
class M_GUI_ANAL_EXPORT iLayerTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
iLayerTableModel(QObject *parent = 0);
~iLayerTableModel();
// Basic override functions
int rowCount(const QModelIndex &parent = QModelIndex()) const ;
int columnCount(const QModelIndex &parent = QModelIndex()) const ;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const ;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
// Custom functions
void addLayer(const QString& defaultName = "", double thickness = 10.0);
void insertLayer(int row, const QString& defaultName = "", double thickness = 10.0);
void removeLayer(int row);
void setRowCount(int count);
// Update ratios for all rows
void updateRatios();
// Get total thickness
double getTotalThickness() const;
// Get/Set layer data
QList<LayerData> getLayerData() const;
void setLayerData(const QList<LayerData>& data);
// Get/Set color for specific layer
QColor getLayerColor(int row) const;
void setLayerColor(int row, const QColor& color);
// Get default color
QColor getDefaultColor(int index) const;
static QColor defaultColorOf(int index);
// Modify layer thickness and update ratio
bool setOneRowThickness(int row, double thickness, double newRatio);
signals:
// 添加这个信号,用于通知厚度或名称发生变化
void layerDataChanged();
private:
void initDefaultLayers();
private:
QList<LayerData> m_layers;
};