裂缝 属性
This commit is contained in:
parent
e510af2405
commit
30d7301cd6
|
|
@ -183,6 +183,7 @@ bool CPickFrac::saveToFile()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果没有裂缝,清空表记录
|
||||||
if (m_items.isEmpty()) {
|
if (m_items.isEmpty()) {
|
||||||
logio->SetTableRecordCount(iIndex, 0);
|
logio->SetTableRecordCount(iIndex, 0);
|
||||||
logio->CloseTable(iIndex);
|
logio->CloseTable(iIndex);
|
||||||
|
|
@ -191,6 +192,7 @@ bool CPickFrac::saveToFile()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 按深度排序
|
||||||
QMap<double, DraggableCrackItem*> sortedMap;
|
QMap<double, DraggableCrackItem*> sortedMap;
|
||||||
for (DraggableCrackItem *item : m_items) {
|
for (DraggableCrackItem *item : m_items) {
|
||||||
double depth = item->getDepthForSort();
|
double depth = item->getDepthForSort();
|
||||||
|
|
@ -216,11 +218,46 @@ void CPickFrac::onRemoveCrackItem(DraggableCrackItem *item)
|
||||||
{
|
{
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
if (m_items.removeOne(item)) {
|
if (m_items.removeOne(item)) {
|
||||||
|
// 立即从画布移除所有图形项
|
||||||
|
item->cleanupFromPlot();
|
||||||
|
// 失活并清空静态指针
|
||||||
|
if (DraggableCrackItem::getActiveItem() == item) {
|
||||||
|
item->deactivate();
|
||||||
|
}
|
||||||
|
// 断开信号
|
||||||
disconnect(item, nullptr, this, nullptr);
|
disconnect(item, nullptr, this, nullptr);
|
||||||
// 延迟删除,确保当前事件完全结束
|
// 直接删除,不再延迟
|
||||||
QTimer::singleShot(0, item, &QObject::deleteLater);
|
delete item;
|
||||||
saveToFile();
|
// 强制重绘
|
||||||
m_myCustomPlot->replot();
|
m_myCustomPlot->replot();
|
||||||
|
// 保存文件
|
||||||
|
saveToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DraggableCrackItem::cleanupFromPlot()
|
||||||
|
{
|
||||||
|
if (m_type == TypeA_Sine) {
|
||||||
|
if (m_curve) m_plot->removeItem(m_curve);
|
||||||
|
if (m_tracer1) m_plot->removeItem(m_tracer1);
|
||||||
|
if (m_tracer2) m_plot->removeItem(m_tracer2);
|
||||||
|
} else if (m_type == TypeB_Polyline) {
|
||||||
|
for (auto &item : m_lines) {
|
||||||
|
if (item.line) m_plot->removeItem(item.line);
|
||||||
|
if (item.startTracer) m_plot->removeItem(item.startTracer);
|
||||||
|
if (item.endTracer) m_plot->removeItem(item.endTracer);
|
||||||
|
}
|
||||||
|
m_lines.clear();
|
||||||
|
} else if (m_type == TypeC_Closed) {
|
||||||
|
if (m_curveC) {
|
||||||
|
m_plot->removePlottable(m_curveC);
|
||||||
|
m_curveC = nullptr;
|
||||||
|
}
|
||||||
|
for (auto label : m_labelsC) {
|
||||||
|
if (label) m_plot->removeItem(label);
|
||||||
|
}
|
||||||
|
m_labelsC.clear();
|
||||||
|
m_pointsC.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -316,12 +353,15 @@ void DraggableCrackItem::deactivate()
|
||||||
m_draggedPointIndex = -1;
|
m_draggedPointIndex = -1;
|
||||||
setDragPointsVisible(false);
|
setDragPointsVisible(false);
|
||||||
}
|
}
|
||||||
if (s_activeItem == this) s_activeItem = nullptr;
|
if (s_activeItem == this) {
|
||||||
|
s_activeItem = nullptr;
|
||||||
|
}
|
||||||
m_plot->replot();
|
m_plot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DraggableCrackItem::setDragPointsVisible(bool visible)
|
void DraggableCrackItem::setDragPointsVisible(bool visible)
|
||||||
{
|
{
|
||||||
|
if (m_pendingDelete) return;
|
||||||
if (m_type == TypeA_Sine) {
|
if (m_type == TypeA_Sine) {
|
||||||
if (m_tracer1) m_tracer1->setVisible(visible);
|
if (m_tracer1) m_tracer1->setVisible(visible);
|
||||||
if (m_tracer2) m_tracer2->setVisible(visible);
|
if (m_tracer2) m_tracer2->setVisible(visible);
|
||||||
|
|
@ -340,6 +380,7 @@ void DraggableCrackItem::setDragPointsVisible(bool visible)
|
||||||
|
|
||||||
void DraggableCrackItem::startEditing()
|
void DraggableCrackItem::startEditing()
|
||||||
{
|
{
|
||||||
|
if (m_pendingDelete) return;
|
||||||
m_editingMode = true;
|
m_editingMode = true;
|
||||||
if (s_activeItem && s_activeItem != this) s_activeItem->deactivate();
|
if (s_activeItem && s_activeItem != this) s_activeItem->deactivate();
|
||||||
s_activeItem = this;
|
s_activeItem = this;
|
||||||
|
|
@ -470,7 +511,6 @@ void DraggableCrackItem::setPolylineData(const QVector<QPointF> &points, double
|
||||||
item.startTracer = startTracer;
|
item.startTracer = startTracer;
|
||||||
item.endTracer = endTracer;
|
item.endTracer = endTracer;
|
||||||
m_lines.append(item);
|
m_lines.append(item);
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
updateLinesPosition();
|
updateLinesPosition();
|
||||||
}
|
}
|
||||||
|
|
@ -493,9 +533,9 @@ void DraggableCrackItem::updateLinesPosition()
|
||||||
void DraggableCrackItem::clearLines()
|
void DraggableCrackItem::clearLines()
|
||||||
{
|
{
|
||||||
for (auto &item : m_lines) {
|
for (auto &item : m_lines) {
|
||||||
if (item.line) { m_plot->removeItem(item.line); delete item.line; }
|
if (item.line) { m_plot->removeItem(item.line); }
|
||||||
if (item.startTracer) { m_plot->removeItem(item.startTracer); delete item.startTracer; }
|
if (item.startTracer) { m_plot->removeItem(item.startTracer); }
|
||||||
if (item.endTracer) { m_plot->removeItem(item.endTracer); delete item.endTracer; }
|
if (item.endTracer) { m_plot->removeItem(item.endTracer); }
|
||||||
}
|
}
|
||||||
m_lines.clear();
|
m_lines.clear();
|
||||||
m_plot->replot();
|
m_plot->replot();
|
||||||
|
|
@ -547,8 +587,7 @@ void DraggableCrackItem::clearPolylineC()
|
||||||
{
|
{
|
||||||
for (auto label : m_labelsC) {
|
for (auto label : m_labelsC) {
|
||||||
if (label) {
|
if (label) {
|
||||||
label->setParent(nullptr);
|
m_plot->removeItem(label);
|
||||||
delete label;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_labelsC.clear();
|
m_labelsC.clear();
|
||||||
|
|
@ -641,9 +680,9 @@ bool DraggableCrackItem::eventFilter(QObject *obj, QEvent *event)
|
||||||
if (selectedAction == deleteAction) {
|
if (selectedAction == deleteAction) {
|
||||||
m_pendingDelete = true;
|
m_pendingDelete = true;
|
||||||
deactivate(); // 清空全局激活指针
|
deactivate(); // 清空全局激活指针
|
||||||
emit removeMe(this);
|
emit removeMe(this); // 触发删除
|
||||||
}
|
}
|
||||||
return true;
|
return true; // 阻止事件继续传递
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -976,6 +1015,12 @@ bool DraggableCrackItem::eventFilter(QObject *obj, QEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s_activeItem == this) {
|
||||||
|
s_activeItem->deactivate();
|
||||||
|
s_activeItem = nullptr;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public:
|
||||||
void setDraggingEnabled(bool enabled);
|
void setDraggingEnabled(bool enabled);
|
||||||
QList<DraggableCrackItem*> getAllItems() const { return m_items; }
|
QList<DraggableCrackItem*> getAllItems() const { return m_items; }
|
||||||
bool saveToFile();
|
bool saveToFile();
|
||||||
bool createNewCrack(int iType, double depth); // 根据形状类型创建
|
bool createNewCrack(int iType, double depth);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QMyCustomPlot *m_myCustomPlot;
|
QMyCustomPlot *m_myCustomPlot;
|
||||||
|
|
@ -124,6 +124,8 @@ public:
|
||||||
// 获取当前激活的item(静态)
|
// 获取当前激活的item(静态)
|
||||||
static DraggableCrackItem* getActiveItem() { return s_activeItem; }
|
static DraggableCrackItem* getActiveItem() { return s_activeItem; }
|
||||||
|
|
||||||
|
void cleanupFromPlot(); // 立即从画布移除所有图形项
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataChanged();
|
void dataChanged();
|
||||||
void removeMe(DraggableCrackItem* item);
|
void removeMe(DraggableCrackItem* item);
|
||||||
|
|
@ -172,7 +174,9 @@ private:
|
||||||
|
|
||||||
// 编辑模式标志
|
// 编辑模式标志
|
||||||
bool m_editingMode = false;
|
bool m_editingMode = false;
|
||||||
bool m_pendingDelete = false; // 标记是否即将删除
|
|
||||||
|
// 删除安全标志
|
||||||
|
bool m_pendingDelete = false;
|
||||||
|
|
||||||
// 辅助函数
|
// 辅助函数
|
||||||
void updateCurveFromTargets();
|
void updateCurveFromTargets();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user