Merge branch 'main' of http://git.hivekion.com:3000/jiayulong/logplus
This commit is contained in:
commit
05b07b94ee
|
|
@ -5967,6 +5967,21 @@ void PropertyWidget::changedMCalsProperty(QString strProperty, QVariant varVal)
|
||||||
emit CallManage::getInstance()->sig_changeMCalsProperty(m_formInfo->m_strUuid, m_formInfo->m_strSlfName, m_formInfo->m_strWellName, m_formInfo->m_strTrackName, m_formInfo->m_strLineName, m_formInfo->m_strLineName);
|
emit CallManage::getInstance()->sig_changeMCalsProperty(m_formInfo->m_strUuid, m_formInfo->m_strSlfName, m_formInfo->m_strWellName, m_formInfo->m_strTrackName, m_formInfo->m_strLineName, m_formInfo->m_strLineName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//void initDrawImageProperty(FormInfo *formInfo);
|
||||||
|
//void changedDrawImageProperty(QString strProName, QVariant val);
|
||||||
|
|
||||||
|
void PropertyWidget::initDrawImageProperty(FormInfo *formInfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyWidget::changedDrawImageProperty(QString strProperty, QVariant varVal)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void PropertyWidget::initDcaProperty(FormInfo *formInfo)
|
void PropertyWidget::initDcaProperty(FormInfo *formInfo)
|
||||||
{
|
{
|
||||||
// 数据
|
// 数据
|
||||||
|
|
|
||||||
|
|
@ -264,6 +264,10 @@ public:
|
||||||
void initRoseProperty(FormInfo *formInfo);
|
void initRoseProperty(FormInfo *formInfo);
|
||||||
void changedRoseProperty(QString strProName, QVariant val);
|
void changedRoseProperty(QString strProName, QVariant val);
|
||||||
|
|
||||||
|
// 图像
|
||||||
|
void initDrawImageProperty(FormInfo *formInfo);
|
||||||
|
void changedDrawImageProperty(QString strProName, QVariant val);
|
||||||
|
|
||||||
// 裂缝DCA分析
|
// 裂缝DCA分析
|
||||||
void initDcaProperty(FormInfo *formInfo);
|
void initDcaProperty(FormInfo *formInfo);
|
||||||
void changedDcaProperty(QString strProperty, QVariant varVal);
|
void changedDcaProperty(QString strProperty, QVariant varVal);
|
||||||
|
|
|
||||||
|
|
@ -1,811 +0,0 @@
|
||||||
#include "TransparentDraggableCrackObject.h"
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QWheelEvent>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
QPointer<TransparentDraggableCrackObject> TransparentDraggableCrackObject::s_activeObject = nullptr;
|
|
||||||
|
|
||||||
TransparentDraggableCrackObject::TransparentDraggableCrackObject(QCustomPlot *parentPlot,
|
|
||||||
const QString &strUuid, double depth, QString type, QString showNames)
|
|
||||||
: QObject(parentPlot)
|
|
||||||
, mPlot(parentPlot)
|
|
||||||
, m_uuid(strUuid)
|
|
||||||
, m_depth(depth)
|
|
||||||
, m_endX(mPlot->xAxis->range().upper)
|
|
||||||
, mCurve(nullptr)
|
|
||||||
, m_tracer1(nullptr)
|
|
||||||
, m_tracer2(nullptr)
|
|
||||||
, m_dragStateA(IdleA)
|
|
||||||
, m_isAddingLine(false)
|
|
||||||
, m_offsetXB(0.0), m_offsetYB(0.0)
|
|
||||||
, m_dragStateB(IdleB)
|
|
||||||
, m_draggedLineIndex(-1)
|
|
||||||
, m_curveC(nullptr)
|
|
||||||
, m_offsetXC(0.0), m_offsetYC(0.0)
|
|
||||||
, m_cFinished(false)
|
|
||||||
, m_cDragging(false)
|
|
||||||
, m_draggingPoint(false)
|
|
||||||
, m_draggedPointIndex(-1)
|
|
||||||
{
|
|
||||||
if("高导缝" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_A;
|
|
||||||
m_lineColor.setNamedColor("#FF0000");
|
|
||||||
m_typeName = "高导缝";
|
|
||||||
}
|
|
||||||
else if("高阻缝" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_A;
|
|
||||||
m_lineColor.setNamedColor("#400040");
|
|
||||||
m_typeName = "高阻缝";
|
|
||||||
}
|
|
||||||
else if("诱导缝" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_A;
|
|
||||||
m_lineColor.setNamedColor("#00FFFF");
|
|
||||||
m_typeName = "诱导缝";
|
|
||||||
}
|
|
||||||
else if("层理" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_A;
|
|
||||||
m_lineColor.setNamedColor("#00FF00");
|
|
||||||
m_typeName = "层理";
|
|
||||||
}
|
|
||||||
else if("侵蚀面" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_A;
|
|
||||||
m_lineColor.setNamedColor("#409600");
|
|
||||||
m_typeName = "侵蚀面";
|
|
||||||
}
|
|
||||||
else if("断层" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_A;
|
|
||||||
m_lineColor.setNamedColor("#A65300");
|
|
||||||
m_typeName = "断层";
|
|
||||||
}
|
|
||||||
else if("自定义1" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_A;
|
|
||||||
m_lineColor.setNamedColor("#000000");
|
|
||||||
m_typeName = "自定义1";
|
|
||||||
}
|
|
||||||
else if("自定义2" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_A;
|
|
||||||
m_lineColor.setNamedColor("#000000");
|
|
||||||
m_typeName = "自定义2";
|
|
||||||
}
|
|
||||||
else if("网状缝" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_B;
|
|
||||||
m_lineColor.setNamedColor("#808000");
|
|
||||||
m_typeName = "网状缝";
|
|
||||||
}
|
|
||||||
else if("垂直缝" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_B;
|
|
||||||
m_lineColor.setNamedColor("#FF0000");
|
|
||||||
m_typeName = "垂直缝";
|
|
||||||
}
|
|
||||||
else if("孔洞" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_C;
|
|
||||||
m_lineColor.setNamedColor("#FF8064");
|
|
||||||
m_typeName = "孔洞";
|
|
||||||
}
|
|
||||||
else if("气孔" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_C;
|
|
||||||
m_lineColor.setNamedColor("#FFFF00");
|
|
||||||
m_typeName = "气孔";
|
|
||||||
}
|
|
||||||
else if("砾石" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_C;
|
|
||||||
m_lineColor.setNamedColor("#000096");
|
|
||||||
m_typeName = "砾石";
|
|
||||||
}
|
|
||||||
else if("结核" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_C;
|
|
||||||
m_lineColor.setNamedColor("#A65300");
|
|
||||||
m_typeName = "结核";
|
|
||||||
}
|
|
||||||
else if("团块" == type)
|
|
||||||
{
|
|
||||||
m_type = TYPE_C;
|
|
||||||
m_lineColor.setNamedColor("#000000");
|
|
||||||
m_typeName = "团块";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建的时候判断是否显示
|
|
||||||
// if(showNames.contains("高导缝"))
|
|
||||||
// {
|
|
||||||
// m_isShow = true;
|
|
||||||
// }
|
|
||||||
// else if(showNames.contains("高阻缝"))
|
|
||||||
// {
|
|
||||||
// m_isShow = true;
|
|
||||||
// }
|
|
||||||
// else if(showNames.contains("诱导缝"))
|
|
||||||
// {
|
|
||||||
// m_isShow = true;
|
|
||||||
// }
|
|
||||||
// else if(showNames.contains("层理"))
|
|
||||||
// {
|
|
||||||
// m_isShow = true;
|
|
||||||
// }
|
|
||||||
// else if(showNames.contains("侵蚀面"))
|
|
||||||
// {
|
|
||||||
// m_isShow = true;
|
|
||||||
// }
|
|
||||||
// else if("断层" == type)
|
|
||||||
// {
|
|
||||||
// m_type = TYPE_A;
|
|
||||||
// m_lineColor.setNamedColor("#A65300");
|
|
||||||
// }
|
|
||||||
// else if("自定义1" == type)
|
|
||||||
// {
|
|
||||||
// m_type = TYPE_A;
|
|
||||||
// m_lineColor.setNamedColor("#000000");
|
|
||||||
// }
|
|
||||||
// else if("自定义2" == type)
|
|
||||||
// {
|
|
||||||
// m_type = TYPE_A;
|
|
||||||
// m_lineColor.setNamedColor("#000000");
|
|
||||||
// }
|
|
||||||
// else if("网状缝" == type)
|
|
||||||
// {
|
|
||||||
// m_type = TYPE_B;
|
|
||||||
// m_lineColor.setNamedColor("#808000");
|
|
||||||
// }
|
|
||||||
// else if("垂直缝" == type)
|
|
||||||
// {
|
|
||||||
// m_type = TYPE_B;
|
|
||||||
// m_lineColor.setNamedColor("#FF0000");
|
|
||||||
// }
|
|
||||||
// else if("孔洞" == type)
|
|
||||||
// {
|
|
||||||
// m_type = TYPE_C;
|
|
||||||
// m_lineColor.setNamedColor("#FF8064");
|
|
||||||
// }
|
|
||||||
// else if("气孔" == type)
|
|
||||||
// {
|
|
||||||
// m_type = TYPE_C;
|
|
||||||
// m_lineColor.setNamedColor("#FFFF00");
|
|
||||||
// }
|
|
||||||
// else if("砾石" == type)
|
|
||||||
// {
|
|
||||||
// m_type = TYPE_C;
|
|
||||||
// m_lineColor.setNamedColor("#000096");
|
|
||||||
// }
|
|
||||||
// else if("结核" == type)
|
|
||||||
// {
|
|
||||||
// m_type = TYPE_C;
|
|
||||||
// m_lineColor.setNamedColor("#A65300");
|
|
||||||
// }
|
|
||||||
// else if("团块" == type)
|
|
||||||
// {
|
|
||||||
// m_type = TYPE_C;
|
|
||||||
// m_lineColor.setNamedColor("#000000");
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
if (m_type == TYPE_A) {
|
|
||||||
m_orig_x1 = m_endX * 0.18;
|
|
||||||
m_orig_x2 = m_endX * 0.82;
|
|
||||||
m_orig_y1 = depth + 1.0;
|
|
||||||
m_orig_y2 = depth - 1.0;
|
|
||||||
m_orig_startX = 0;
|
|
||||||
m_orig_endX = m_endX;
|
|
||||||
m_orig_startDirX = m_endX * 0.3;
|
|
||||||
m_orig_endDirX = m_endX * 0.7;
|
|
||||||
m_offsetXA = 0.0;
|
|
||||||
m_offsetYA = 0.0;
|
|
||||||
|
|
||||||
mCurve = new QCPItemCurve(mPlot);
|
|
||||||
mCurve->setPen(QPen(m_lineColor, 2));
|
|
||||||
mCurve->setLayer("overlay");
|
|
||||||
|
|
||||||
updateCurveFromTargets();
|
|
||||||
updateCurvePosition();
|
|
||||||
|
|
||||||
auto createTracer = [this](double x, double y) -> QCPItemTracer* {
|
|
||||||
QCPItemTracer *t = new QCPItemTracer(mPlot);
|
|
||||||
t->setStyle(QCPItemTracer::tsSquare);
|
|
||||||
t->setSize(8);
|
|
||||||
t->setPen(QPen(Qt::black, 1));
|
|
||||||
t->setBrush(QBrush(Qt::black));
|
|
||||||
t->setSelectable(true);
|
|
||||||
t->setLayer("overlay");
|
|
||||||
t->position->setCoords(x, y);
|
|
||||||
t->setVisible(false);
|
|
||||||
return t;
|
|
||||||
};
|
|
||||||
m_tracer1 = createTracer(m_orig_x1 + m_offsetXA, m_orig_y1 + m_offsetYA);
|
|
||||||
m_tracer2 = createTracer(m_orig_x2 + m_offsetXA, m_orig_y2 + m_offsetYA);
|
|
||||||
m_itemText = new QCPItemText(mPlot);
|
|
||||||
m_itemText->setText(m_typeName);
|
|
||||||
m_itemText->setFont(QFont("Arial", 6, QFont::Bold));
|
|
||||||
m_itemText->setColor(Qt::black);
|
|
||||||
m_itemText->position->setCoords(m_orig_x1 + m_offsetXA + 15, m_orig_y1 + m_offsetYA);
|
|
||||||
m_itemText->setPositionAlignment(Qt::AlignCenter);
|
|
||||||
m_itemText->setLayer("overlay");
|
|
||||||
m_labelsC.append(m_itemText);
|
|
||||||
updateTracers();
|
|
||||||
}
|
|
||||||
else if (m_type == TYPE_B) {
|
|
||||||
// nothing
|
|
||||||
}
|
|
||||||
else if (m_type == TYPE_C) {
|
|
||||||
m_curveC = new QCPCurve(mPlot->xAxis, mPlot->yAxis);
|
|
||||||
m_curveC->setPen(QPen(m_lineColor, 2));
|
|
||||||
m_curveC->setScatterStyle(QCPScatterStyle::ssCircle);
|
|
||||||
m_curveC->setLineStyle(QCPCurve::lsLine);
|
|
||||||
m_curveC->setLayer("overlay");
|
|
||||||
}
|
|
||||||
|
|
||||||
mPlot->installEventFilter(this);
|
|
||||||
mPlot->replot();
|
|
||||||
}
|
|
||||||
|
|
||||||
TransparentDraggableCrackObject::~TransparentDraggableCrackObject()
|
|
||||||
{
|
|
||||||
if (m_type == TYPE_B) clearLines();
|
|
||||||
if (m_type == TYPE_C) clearPolylineC();
|
|
||||||
if (s_activeObject == this) s_activeObject = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransparentDraggableCrackObject::isShow(bool is)
|
|
||||||
{
|
|
||||||
this->m_isShow = is;
|
|
||||||
if(this->mCurve)
|
|
||||||
{
|
|
||||||
this->mCurve->setVisible(this->m_isShow);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this->m_curveC)
|
|
||||||
{
|
|
||||||
this->m_curveC->setVisible(this->m_isShow);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const LineItem &item : m_lines) {
|
|
||||||
if (item.line) {
|
|
||||||
item.line->setVisible(this->m_isShow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->mPlot->replot();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 模式A辅助 ==========
|
|
||||||
void TransparentDraggableCrackObject::updateCurveFromTargets()
|
|
||||||
{
|
|
||||||
double t1 = m_orig_x1 / m_endX;
|
|
||||||
double t2 = m_orig_x2 / m_endX;
|
|
||||||
double u1 = 1 - t1, u2 = 1 - t2;
|
|
||||||
double P0x = 0, P0y = m_depth;
|
|
||||||
double P3x = m_endX, P3y = m_depth;
|
|
||||||
double P1x = m_orig_x1, P2x = m_orig_x2;
|
|
||||||
double a11 = 3 * u1 * u1 * t1;
|
|
||||||
double a12 = 3 * u1 * t1 * t1;
|
|
||||||
double b1 = m_orig_y1 - (u1*u1*u1 * P0y + t1*t1*t1 * P3y);
|
|
||||||
double a21 = 3 * u2 * u2 * t2;
|
|
||||||
double a22 = 3 * u2 * t2 * t2;
|
|
||||||
double b2 = m_orig_y2 - (u2*u2*u2 * P0y + t2*t2*t2 * P3y);
|
|
||||||
double det = a11 * a22 - a12 * a21;
|
|
||||||
if (fabs(det) > 1e-6) {
|
|
||||||
double P1y = (b1 * a22 - a12 * b2) / det;
|
|
||||||
double P2y = (a11 * b2 - b1 * a21) / det;
|
|
||||||
m_orig_startDirX = P1x;
|
|
||||||
m_orig_startDirY = P1y;
|
|
||||||
m_orig_endDirX = P2x;
|
|
||||||
m_orig_endDirY = P2y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransparentDraggableCrackObject::updateCurvePosition()
|
|
||||||
{
|
|
||||||
if (!mCurve) return;
|
|
||||||
mCurve->start->setCoords(m_orig_startX + m_offsetXA, m_depth + m_offsetYA);
|
|
||||||
mCurve->end->setCoords(m_orig_endX + m_offsetXA, m_depth + m_offsetYA);
|
|
||||||
mCurve->startDir->setCoords(m_orig_startDirX + m_offsetXA, m_orig_startDirY + m_offsetYA);
|
|
||||||
mCurve->endDir->setCoords(m_orig_endDirX + m_offsetXA, m_orig_endDirY + m_offsetYA);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransparentDraggableCrackObject::updateTracers()
|
|
||||||
{
|
|
||||||
if (!m_tracer1 || !m_tracer2) return;
|
|
||||||
m_tracer1->position->setCoords(m_orig_x1 + m_offsetXA, m_orig_y1 + m_offsetYA);
|
|
||||||
m_tracer2->position->setCoords(m_orig_x2 + m_offsetXA, m_orig_y2 + m_offsetYA);
|
|
||||||
m_itemText->position->setCoords(m_orig_x1 + m_offsetXA + 15, m_orig_y1 + m_offsetYA);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransparentDraggableCrackObject::setTracerHighlight(QCPItemTracer *tracer, bool highlight)
|
|
||||||
{
|
|
||||||
if (!tracer) return;
|
|
||||||
if (highlight) {
|
|
||||||
tracer->setPen(QPen(Qt::red, 2));
|
|
||||||
tracer->setBrush(QBrush(Qt::red));
|
|
||||||
} else {
|
|
||||||
tracer->setPen(QPen(Qt::black, 1));
|
|
||||||
tracer->setBrush(QBrush(Qt::black));
|
|
||||||
m_tracer1->setVisible(true);
|
|
||||||
m_tracer2->setVisible(true);
|
|
||||||
}
|
|
||||||
mPlot->replot();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 模式B辅助 ==========
|
|
||||||
void TransparentDraggableCrackObject::updateLineEndpoints(LineItem &item)
|
|
||||||
{
|
|
||||||
item.startTracer->position->setCoords(item.startOrig.x() + m_offsetXB, item.startOrig.y() + m_offsetYB);
|
|
||||||
item.endTracer->position->setCoords(item.endOrig.x() + m_offsetXB, item.endOrig.y() + m_offsetYB);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransparentDraggableCrackObject::updateLinesPosition()
|
|
||||||
{
|
|
||||||
for (auto &item : m_lines) {
|
|
||||||
item.line->start->setCoords(item.startOrig.x() + m_offsetXB, item.startOrig.y() + m_offsetYB);
|
|
||||||
item.line->end->setCoords(item.endOrig.x() + m_offsetXB, item.endOrig.y() + m_offsetYB);
|
|
||||||
updateLineEndpoints(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransparentDraggableCrackObject::clearLines()
|
|
||||||
{
|
|
||||||
for (auto &item : m_lines) {
|
|
||||||
mPlot->removeItem(item.line);
|
|
||||||
delete item.line;
|
|
||||||
if (item.startTracer) { mPlot->removeItem(item.startTracer); delete item.startTracer; }
|
|
||||||
if (item.endTracer) { mPlot->removeItem(item.endTracer); delete item.endTracer; }
|
|
||||||
}
|
|
||||||
m_lines.clear();
|
|
||||||
m_isAddingLine = false;
|
|
||||||
mPlot->replot();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 模式C辅助 ==========
|
|
||||||
void TransparentDraggableCrackObject::updatePolylineC(bool closed)
|
|
||||||
{
|
|
||||||
if (!m_curveC) return;
|
|
||||||
if (m_pointsC.isEmpty()) {
|
|
||||||
m_curveC->setData(QVector<double>(), QVector<double>());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QVector<double> xs, ys;
|
|
||||||
for (const auto &p : m_pointsC) {
|
|
||||||
xs << p.x() + m_offsetXC;
|
|
||||||
ys << p.y() + m_offsetYC;
|
|
||||||
}
|
|
||||||
if (closed && m_pointsC.size() >= 3) {
|
|
||||||
xs << m_pointsC.first().x() + m_offsetXC;
|
|
||||||
ys << m_pointsC.first().y() + m_offsetYC;
|
|
||||||
}
|
|
||||||
m_curveC->setData(xs, ys);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransparentDraggableCrackObject::clearPolylineC()
|
|
||||||
{
|
|
||||||
for (QCPItemText* label : m_labelsC) {
|
|
||||||
if (label) {
|
|
||||||
// 断开与 mPlot 的父子关系,防止 mPlot 销毁时自动删除
|
|
||||||
label->setParent(nullptr);
|
|
||||||
delete label;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_labelsC.clear();
|
|
||||||
m_pointsC.clear();
|
|
||||||
if (m_curveC) {
|
|
||||||
m_curveC->setData(QVector<double>(), QVector<double>());
|
|
||||||
}
|
|
||||||
m_offsetXC = m_offsetYC = 0.0;
|
|
||||||
m_cFinished = false;
|
|
||||||
m_draggingPoint = false;
|
|
||||||
m_draggedPointIndex = -1;
|
|
||||||
if (s_activeObject == this) s_activeObject = nullptr;
|
|
||||||
mPlot->replot();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 状态重置 ==========
|
|
||||||
void TransparentDraggableCrackObject::deactivate()
|
|
||||||
{
|
|
||||||
qDebug() << "[Deactivate]" << m_uuid;
|
|
||||||
if (m_type == TYPE_A) {
|
|
||||||
setTracerHighlight(m_tracer1, false);
|
|
||||||
setTracerHighlight(m_tracer2, false);
|
|
||||||
m_dragStateA = IdleA;
|
|
||||||
m_tracer1->setVisible(false);
|
|
||||||
m_tracer2->setVisible(false);
|
|
||||||
} else if (m_type == TYPE_B) {
|
|
||||||
m_dragStateB = IdleB;
|
|
||||||
m_draggedLineIndex = -1;
|
|
||||||
} else if (m_type == TYPE_C) {
|
|
||||||
m_cDragging = false;
|
|
||||||
m_draggingPoint = false;
|
|
||||||
m_draggedPointIndex = -1;
|
|
||||||
}
|
|
||||||
mPlot->replot();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 事件过滤器 ==========
|
|
||||||
bool TransparentDraggableCrackObject::eventFilter(QObject *obj, QEvent *event)
|
|
||||||
{
|
|
||||||
if (obj != mPlot) return false;
|
|
||||||
if (event->type() == QEvent::Wheel) return false;
|
|
||||||
|
|
||||||
QMouseEvent *me = static_cast<QMouseEvent*>(event);
|
|
||||||
bool shiftPressed = (me->modifiers() & Qt::ShiftModifier);
|
|
||||||
|
|
||||||
// 鼠标按下
|
|
||||||
if (event->type() == QEvent::MouseButtonPress && me->button() == Qt::LeftButton) {
|
|
||||||
bool hit = false;
|
|
||||||
|
|
||||||
// ========== 模式B:添加直线(优先级最高) ==========
|
|
||||||
if (m_type == TYPE_B && shiftPressed) {
|
|
||||||
if (!m_isAddingLine) {
|
|
||||||
double x = mPlot->xAxis->pixelToCoord(me->pos().x());
|
|
||||||
double y = mPlot->yAxis->pixelToCoord(me->pos().y());
|
|
||||||
m_tempPoint = QPointF(x - m_offsetXB, y - m_offsetYB);
|
|
||||||
m_isAddingLine = true;
|
|
||||||
qDebug() << "Start adding line, point:" << m_tempPoint;
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
double x = mPlot->xAxis->pixelToCoord(me->pos().x());
|
|
||||||
double y = mPlot->yAxis->pixelToCoord(me->pos().y());
|
|
||||||
QPointF p2(x - m_offsetXB, y - m_offsetYB);
|
|
||||||
QCPItemLine *line = new QCPItemLine(mPlot);
|
|
||||||
line->setPen(QPen(m_lineColor, 2));
|
|
||||||
line->setLayer("overlay");
|
|
||||||
auto createTracer = [this](double x, double y, const QColor &color) -> QCPItemTracer* {
|
|
||||||
QCPItemTracer *t = new QCPItemTracer(mPlot);
|
|
||||||
t->setStyle(QCPItemTracer::tsSquare);
|
|
||||||
t->setSize(10);
|
|
||||||
t->setPen(QPen(Qt::black, 1));
|
|
||||||
t->setBrush(QBrush(color));
|
|
||||||
t->setSelectable(true);
|
|
||||||
t->setLayer("overlay");
|
|
||||||
t->position->setCoords(x + m_offsetXB, y + m_offsetYB);
|
|
||||||
return t;
|
|
||||||
};
|
|
||||||
QCPItemTracer *startTracer = createTracer(m_tempPoint.x(), m_tempPoint.y(), Qt::black);
|
|
||||||
QCPItemTracer *endTracer = createTracer(p2.x(), p2.y(), Qt::black);
|
|
||||||
LineItem item;
|
|
||||||
item.startOrig = m_tempPoint;
|
|
||||||
item.endOrig = p2;
|
|
||||||
item.line = line;
|
|
||||||
item.startTracer = startTracer;
|
|
||||||
item.endTracer = endTracer;
|
|
||||||
m_lines.append(item);
|
|
||||||
updateLinesPosition();
|
|
||||||
m_isAddingLine = false;
|
|
||||||
mPlot->replot();
|
|
||||||
qDebug() << "Line added from" << m_tempPoint << "to" << p2;
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 模式A ==========
|
|
||||||
if (m_type == TYPE_A && !shiftPressed) {
|
|
||||||
QPointF pixel = me->localPos();
|
|
||||||
double d1 = m_tracer1->selectTest(pixel, false);
|
|
||||||
double d2 = m_tracer2->selectTest(pixel, false);
|
|
||||||
double curveDist = mCurve->selectTest(pixel, false);
|
|
||||||
if (d1 >= 0 && d1 < 15 || d2 >= 0 && d2 < 15 || (curveDist >= 0 && curveDist < 5)) {
|
|
||||||
hit = true;
|
|
||||||
if (s_activeObject && s_activeObject != this) {
|
|
||||||
s_activeObject->deactivate();
|
|
||||||
}
|
|
||||||
s_activeObject = this;
|
|
||||||
if (d1 >= 0 && d1 < 15) {
|
|
||||||
m_dragStateA = DraggingPoint1;
|
|
||||||
setTracerHighlight(m_tracer1, true);
|
|
||||||
} else if (d2 >= 0 && d2 < 15) {
|
|
||||||
m_dragStateA = DraggingPoint2;
|
|
||||||
setTracerHighlight(m_tracer2, true);
|
|
||||||
} else {
|
|
||||||
m_dragStateA = DraggingCurveA;
|
|
||||||
m_lastDragPixelA = pixel;
|
|
||||||
}
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 模式B:拖拽(非Shift) ==========
|
|
||||||
if (m_type == TYPE_B && !shiftPressed && !m_isAddingLine) {
|
|
||||||
QPointF pixel = me->localPos();
|
|
||||||
bool found = false;
|
|
||||||
for (int i = 0; i < m_lines.size(); ++i) {
|
|
||||||
auto &item = m_lines[i];
|
|
||||||
if (item.startTracer->selectTest(pixel, false) >= 0 && item.startTracer->selectTest(pixel, false) < 10) {
|
|
||||||
found = true;
|
|
||||||
hit = true;
|
|
||||||
if (s_activeObject && s_activeObject != this) s_activeObject->deactivate();
|
|
||||||
s_activeObject = this;
|
|
||||||
m_dragStateB = DraggingStartPoint;
|
|
||||||
m_draggedLineIndex = i;
|
|
||||||
m_bDragStart = pixel;
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (item.endTracer->selectTest(pixel, false) >= 0 && item.endTracer->selectTest(pixel, false) < 10) {
|
|
||||||
found = true;
|
|
||||||
hit = true;
|
|
||||||
if (s_activeObject && s_activeObject != this) s_activeObject->deactivate();
|
|
||||||
s_activeObject = this;
|
|
||||||
m_dragStateB = DraggingEndPoint;
|
|
||||||
m_draggedLineIndex = i;
|
|
||||||
m_bDragStart = pixel;
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
for (int i = 0; i < m_lines.size(); ++i) {
|
|
||||||
double dist = m_lines[i].line->selectTest(pixel, false);
|
|
||||||
if (dist >= 0 && dist < 3) {
|
|
||||||
hit = true;
|
|
||||||
if (s_activeObject && s_activeObject != this) s_activeObject->deactivate();
|
|
||||||
s_activeObject = this;
|
|
||||||
m_dragStateB = DraggingLineOverall;
|
|
||||||
m_bDragStart = pixel;
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 模式C ==========
|
|
||||||
if (m_type == TYPE_C) {
|
|
||||||
// 1. 左键添加点(Shift)
|
|
||||||
if (shiftPressed && me->button() == Qt::LeftButton && !m_cFinished) {
|
|
||||||
if (s_activeObject != this) {
|
|
||||||
if (s_activeObject) s_activeObject->deactivate();
|
|
||||||
s_activeObject = this;
|
|
||||||
}
|
|
||||||
double x = mPlot->xAxis->pixelToCoord(me->pos().x());
|
|
||||||
double y = mPlot->yAxis->pixelToCoord(me->pos().y());
|
|
||||||
QPointF pt(x - m_offsetXC, y - m_offsetYC);
|
|
||||||
m_pointsC.append(pt);
|
|
||||||
QCPItemText *label = new QCPItemText(mPlot);
|
|
||||||
label->setText(" ");
|
|
||||||
label->setFont(QFont("Arial", 6, QFont::Bold));
|
|
||||||
label->setColor(Qt::black);
|
|
||||||
label->setBrush(QBrush(Qt::black));
|
|
||||||
label->setPen(QPen(Qt::black, 1));
|
|
||||||
label->position->setCoords(x, y);
|
|
||||||
label->setPositionAlignment(Qt::AlignCenter);
|
|
||||||
label->setLayer("overlay");
|
|
||||||
m_labelsC.append(label);
|
|
||||||
updatePolylineC(false);
|
|
||||||
mPlot->replot();
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// 2. 左键空白闭环(非Shift,未完成时)
|
|
||||||
if (!shiftPressed && me->button() == Qt::LeftButton && !m_cFinished) {
|
|
||||||
if (m_pointsC.size() >= 3) {
|
|
||||||
m_cFinished = true;
|
|
||||||
updatePolylineC(true);
|
|
||||||
mPlot->replot();
|
|
||||||
} else {
|
|
||||||
clearPolylineC();
|
|
||||||
}
|
|
||||||
if (s_activeObject == this) {
|
|
||||||
s_activeObject->deactivate();
|
|
||||||
s_activeObject = nullptr;
|
|
||||||
}
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// 3. 拖拽整体或点(已完成,非Shift左键)
|
|
||||||
if (!shiftPressed && me->button() == Qt::LeftButton && m_cFinished) {
|
|
||||||
QPointF pixel = me->localPos();
|
|
||||||
// 优先检测是否命中某个数据点(通过标签)
|
|
||||||
int hitPointIndex = -1;
|
|
||||||
for (int i = 0; i < m_labelsC.size(); ++i) {
|
|
||||||
double dist = m_labelsC[i]->selectTest(pixel, false);
|
|
||||||
if (dist >= 0 && dist < 10) {
|
|
||||||
hitPointIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hitPointIndex >= 0) {
|
|
||||||
hit = true;
|
|
||||||
if (s_activeObject != this) {
|
|
||||||
if (s_activeObject) s_activeObject->deactivate();
|
|
||||||
s_activeObject = this;
|
|
||||||
}
|
|
||||||
m_draggingPoint = true;
|
|
||||||
m_draggedPointIndex = hitPointIndex;
|
|
||||||
// 记录拖拽开始时的鼠标像素坐标和点的原始坐标(用于计算偏移)
|
|
||||||
m_cDragStart = pixel;
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
// 未命中点,检测曲线本体
|
|
||||||
double curveDist = m_curveC ? m_curveC->selectTest(pixel, false) : -1;
|
|
||||||
if (curveDist >= 0 && curveDist < 3) {
|
|
||||||
hit = true;
|
|
||||||
if (s_activeObject != this) {
|
|
||||||
if (s_activeObject) s_activeObject->deactivate();
|
|
||||||
s_activeObject = this;
|
|
||||||
}
|
|
||||||
m_cDragging = true;
|
|
||||||
m_cDragStart = pixel;
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
// 未命中任何图元,清除活动对象
|
|
||||||
if (s_activeObject == this) {
|
|
||||||
s_activeObject->deactivate();
|
|
||||||
s_activeObject = nullptr;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 未命中任何图元:清除全局活动对象
|
|
||||||
if (!hit) {
|
|
||||||
if (s_activeObject) {
|
|
||||||
s_activeObject->deactivate();
|
|
||||||
s_activeObject = nullptr;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 鼠标移动
|
|
||||||
if (event->type() == QEvent::MouseMove) {
|
|
||||||
if (s_activeObject != this) return false;
|
|
||||||
|
|
||||||
// 模式A移动
|
|
||||||
if (m_type == TYPE_A) {
|
|
||||||
if (m_dragStateA == DraggingPoint1 || m_dragStateA == DraggingPoint2) {
|
|
||||||
double newY = mPlot->yAxis->pixelToCoord(me->localPos().y());
|
|
||||||
double currentY = (m_dragStateA == DraggingPoint1) ? m_orig_y1 : m_orig_y2;
|
|
||||||
double deltaY = newY - (currentY + m_offsetYA);
|
|
||||||
if (fabs(deltaY) > 5) deltaY = (deltaY > 0 ? 5 : -5);
|
|
||||||
double newOrigY = currentY + deltaY;
|
|
||||||
double minY = m_depth - 100;
|
|
||||||
double maxY = m_depth + 100;
|
|
||||||
newOrigY = qBound(minY, newOrigY, maxY);
|
|
||||||
if (m_dragStateA == DraggingPoint1) m_orig_y1 = newOrigY;
|
|
||||||
else m_orig_y2 = newOrigY;
|
|
||||||
updateCurveFromTargets();
|
|
||||||
updateCurvePosition();
|
|
||||||
updateTracers();
|
|
||||||
mPlot->replot();
|
|
||||||
return true;
|
|
||||||
} else if (m_dragStateA == DraggingCurveA) {
|
|
||||||
QPointF current = me->localPos();
|
|
||||||
double oldX = mPlot->xAxis->pixelToCoord(m_lastDragPixelA.x());
|
|
||||||
double newX = mPlot->xAxis->pixelToCoord(current.x());
|
|
||||||
double oldY = mPlot->yAxis->pixelToCoord(m_lastDragPixelA.y());
|
|
||||||
double newY = mPlot->yAxis->pixelToCoord(current.y());
|
|
||||||
double dx = newX - oldX;
|
|
||||||
double dy = newY - oldY;
|
|
||||||
m_offsetXA += dx;
|
|
||||||
m_offsetYA += dy;
|
|
||||||
updateCurvePosition();
|
|
||||||
updateTracers();
|
|
||||||
mPlot->replot();
|
|
||||||
m_lastDragPixelA = current;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 模式B移动
|
|
||||||
else if (m_type == TYPE_B && m_dragStateB != IdleB) {
|
|
||||||
QPointF current = me->localPos();
|
|
||||||
double oldX = mPlot->xAxis->pixelToCoord(m_bDragStart.x());
|
|
||||||
double newX = mPlot->xAxis->pixelToCoord(current.x());
|
|
||||||
double oldY = mPlot->yAxis->pixelToCoord(m_bDragStart.y());
|
|
||||||
double newY = mPlot->yAxis->pixelToCoord(current.y());
|
|
||||||
double dx = newX - oldX;
|
|
||||||
double dy = newY - oldY;
|
|
||||||
if (m_dragStateB == DraggingLineOverall) {
|
|
||||||
m_offsetXB += dx;
|
|
||||||
m_offsetYB += dy;
|
|
||||||
updateLinesPosition();
|
|
||||||
} else if (m_dragStateB == DraggingStartPoint || m_dragStateB == DraggingEndPoint) {
|
|
||||||
int idx = m_draggedLineIndex;
|
|
||||||
if (idx >= 0 && idx < m_lines.size()) {
|
|
||||||
LineItem &item = m_lines[idx];
|
|
||||||
if (m_dragStateB == DraggingStartPoint) {
|
|
||||||
item.startOrig.rx() += dx;
|
|
||||||
item.startOrig.ry() += dy;
|
|
||||||
} else {
|
|
||||||
item.endOrig.rx() += dx;
|
|
||||||
item.endOrig.ry() += dy;
|
|
||||||
}
|
|
||||||
item.line->start->setCoords(item.startOrig.x() + m_offsetXB, item.startOrig.y() + m_offsetYB);
|
|
||||||
item.line->end->setCoords(item.endOrig.x() + m_offsetXB, item.endOrig.y() + m_offsetYB);
|
|
||||||
updateLineEndpoints(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mPlot->replot();
|
|
||||||
m_bDragStart = current;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// 模式C移动
|
|
||||||
// 模式C移动
|
|
||||||
else if (m_type == TYPE_C) {
|
|
||||||
if (m_cDragging) {
|
|
||||||
// 整体拖拽
|
|
||||||
QPointF current = me->localPos();
|
|
||||||
double oldX = mPlot->xAxis->pixelToCoord(m_cDragStart.x());
|
|
||||||
double newX = mPlot->xAxis->pixelToCoord(current.x());
|
|
||||||
double oldY = mPlot->yAxis->pixelToCoord(m_cDragStart.y());
|
|
||||||
double newY = mPlot->yAxis->pixelToCoord(current.y());
|
|
||||||
double dx = newX - oldX;
|
|
||||||
double dy = newY - oldY;
|
|
||||||
m_offsetXC += dx;
|
|
||||||
m_offsetYC += dy;
|
|
||||||
for (int i = 0; i < m_pointsC.size(); ++i) {
|
|
||||||
m_labelsC[i]->position->setCoords(m_pointsC[i].x() + m_offsetXC, m_pointsC[i].y() + m_offsetYC);
|
|
||||||
}
|
|
||||||
updatePolylineC(m_cFinished && m_pointsC.size() >= 3);
|
|
||||||
mPlot->replot();
|
|
||||||
m_cDragStart = current;
|
|
||||||
return true;
|
|
||||||
} else if (m_draggingPoint) {
|
|
||||||
// 点拖拽:支持二维移动
|
|
||||||
QPointF current = me->localPos();
|
|
||||||
// 计算鼠标在轴坐标系下的移动量(直接使用像素转坐标,但为了精确,计算差值)
|
|
||||||
double oldX = mPlot->xAxis->pixelToCoord(m_cDragStart.x());
|
|
||||||
double newX = mPlot->xAxis->pixelToCoord(current.x());
|
|
||||||
double oldY = mPlot->yAxis->pixelToCoord(m_cDragStart.y());
|
|
||||||
double newY = mPlot->yAxis->pixelToCoord(current.y());
|
|
||||||
double dx = newX - oldX;
|
|
||||||
double dy = newY - oldY;
|
|
||||||
// 更新点的原始坐标
|
|
||||||
m_pointsC[m_draggedPointIndex].rx() += dx;
|
|
||||||
m_pointsC[m_draggedPointIndex].ry() += dy;
|
|
||||||
// 更新标签位置
|
|
||||||
m_labelsC[m_draggedPointIndex]->position->setCoords(m_pointsC[m_draggedPointIndex].x() + m_offsetXC,
|
|
||||||
m_pointsC[m_draggedPointIndex].y() + m_offsetYC);
|
|
||||||
updatePolylineC(m_cFinished && m_pointsC.size() >= 3);
|
|
||||||
mPlot->replot();
|
|
||||||
// 更新拖拽起始点
|
|
||||||
m_cDragStart = current;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 鼠标释放
|
|
||||||
if (event->type() == QEvent::MouseButtonRelease && me->button() == Qt::LeftButton) {
|
|
||||||
if (s_activeObject != this) return false;
|
|
||||||
|
|
||||||
if (m_type == TYPE_A && m_dragStateA != IdleA) {
|
|
||||||
setTracerHighlight(m_tracer1, false);
|
|
||||||
setTracerHighlight(m_tracer2, false);
|
|
||||||
m_dragStateA = IdleA;
|
|
||||||
return true;
|
|
||||||
} else if (m_type == TYPE_B && m_dragStateB != IdleB) {
|
|
||||||
m_dragStateB = IdleB;
|
|
||||||
m_draggedLineIndex = -1;
|
|
||||||
return true;
|
|
||||||
} else if (m_type == TYPE_C) {
|
|
||||||
if (m_cDragging) {
|
|
||||||
m_cDragging = false;
|
|
||||||
return true;
|
|
||||||
} else if (m_draggingPoint) {
|
|
||||||
m_draggingPoint = false;
|
|
||||||
m_draggedPointIndex = -1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
#ifndef TRANSPARENTDRAGGABLECRACKOBJECT_H
|
|
||||||
#define TRANSPARENTDRAGGABLECRACKOBJECT_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QPointer>
|
|
||||||
#include <QVector>
|
|
||||||
#include "qcustomplot.h"
|
|
||||||
|
|
||||||
#pragma execution_character_set("utf-8")
|
|
||||||
|
|
||||||
class TransparentDraggableCrackObject : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
enum CurveType { TYPE_A, TYPE_B, TYPE_C };
|
|
||||||
|
|
||||||
explicit TransparentDraggableCrackObject(QCustomPlot *parentPlot,
|
|
||||||
const QString &strUuid, double depth, QString type, QString showNames);
|
|
||||||
~TransparentDraggableCrackObject();
|
|
||||||
|
|
||||||
bool m_isShow = false;
|
|
||||||
QString m_typeName;
|
|
||||||
void isShow(bool is);
|
|
||||||
protected:
|
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QCustomPlot *mPlot;
|
|
||||||
CurveType m_type;
|
|
||||||
QString m_uuid;
|
|
||||||
double m_depth;
|
|
||||||
double m_endX;
|
|
||||||
QColor m_lineColor;
|
|
||||||
|
|
||||||
static QPointer<TransparentDraggableCrackObject> s_activeObject;
|
|
||||||
|
|
||||||
QCPItemText *m_itemText;
|
|
||||||
// 模式A
|
|
||||||
QCPItemCurve *mCurve;
|
|
||||||
double m_orig_x1, m_orig_x2;
|
|
||||||
double m_orig_y1, m_orig_y2;
|
|
||||||
double m_orig_startX, m_orig_endX;
|
|
||||||
double m_orig_startDirX, m_orig_startDirY;
|
|
||||||
double m_orig_endDirX, m_orig_endDirY;
|
|
||||||
double m_offsetXA, m_offsetYA;
|
|
||||||
QCPItemTracer *m_tracer1, *m_tracer2;
|
|
||||||
enum DragStateA { IdleA, DraggingPoint1, DraggingPoint2, DraggingCurveA };
|
|
||||||
DragStateA m_dragStateA;
|
|
||||||
QPointF m_lastDragPixelA;
|
|
||||||
|
|
||||||
// 模式B
|
|
||||||
struct LineItem {
|
|
||||||
QPointF startOrig;
|
|
||||||
QPointF endOrig;
|
|
||||||
QCPItemLine *line;
|
|
||||||
QCPItemTracer *startTracer;
|
|
||||||
QCPItemTracer *endTracer;
|
|
||||||
};
|
|
||||||
QVector<LineItem> m_lines;
|
|
||||||
bool m_isAddingLine;
|
|
||||||
QPointF m_tempPoint;
|
|
||||||
double m_offsetXB, m_offsetYB;
|
|
||||||
enum DragStateB { IdleB, DraggingLineOverall, DraggingStartPoint, DraggingEndPoint };
|
|
||||||
DragStateB m_dragStateB;
|
|
||||||
QPointF m_bDragStart;
|
|
||||||
int m_draggedLineIndex;
|
|
||||||
|
|
||||||
// 模式C
|
|
||||||
QCPCurve *m_curveC;
|
|
||||||
QVector<QPointF> m_pointsC; // 原始点(无偏移)
|
|
||||||
QVector<QCPItemText*> m_labelsC; // 序号标签
|
|
||||||
double m_offsetXC, m_offsetYC; // 整体偏移
|
|
||||||
bool m_cFinished; // 是否已完成选点
|
|
||||||
bool m_cDragging; // 是否正在拖拽整体
|
|
||||||
bool m_draggingPoint; // 是否正在拖拽点
|
|
||||||
int m_draggedPointIndex; // 拖拽的点的索引
|
|
||||||
QPointF m_cDragStart; // 拖拽起始像素
|
|
||||||
|
|
||||||
void updateCurveFromTargets();
|
|
||||||
void updateCurvePosition();
|
|
||||||
void updateTracers();
|
|
||||||
void setTracerHighlight(QCPItemTracer *tracer, bool highlight);
|
|
||||||
void updateLinesPosition();
|
|
||||||
void clearLines();
|
|
||||||
void updateLineEndpoints(LineItem &item);
|
|
||||||
void updatePolylineC(bool closed);
|
|
||||||
void clearPolylineC();
|
|
||||||
void deactivate();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -4022,7 +4022,7 @@ void FormDraw::s_addDrawImage(QString strUuid, QString strSlfName, QString strWe
|
||||||
//
|
//
|
||||||
m_listLineName.push_back(strLineName);
|
m_listLineName.push_back(strLineName);
|
||||||
|
|
||||||
QString strAliasName = "成图";
|
QString strAliasName = "成像";
|
||||||
QString strUnit = "";
|
QString strUnit = "";
|
||||||
QColor newlineColor=QColor(0,0,0);
|
QColor newlineColor=QColor(0,0,0);
|
||||||
double width=2;
|
double width=2;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ SOURCES += \
|
||||||
QCPSizeHandle.cpp \
|
QCPSizeHandle.cpp \
|
||||||
QCPSizeHandleManager.cpp \
|
QCPSizeHandleManager.cpp \
|
||||||
TransparentDraggableCorePhysics.cpp \
|
TransparentDraggableCorePhysics.cpp \
|
||||||
TransparentDraggableCrackObject.cpp \
|
|
||||||
TransparentDraggableFac.cpp \
|
TransparentDraggableFac.cpp \
|
||||||
TransparentDraggableGeoLith.cpp \
|
TransparentDraggableGeoLith.cpp \
|
||||||
TransparentDraggableGujing.cpp \
|
TransparentDraggableGujing.cpp \
|
||||||
|
|
@ -114,7 +113,6 @@ HEADERS += \
|
||||||
QCPSizeHandle.h \
|
QCPSizeHandle.h \
|
||||||
QCPSizeHandleManager.h \
|
QCPSizeHandleManager.h \
|
||||||
TransparentDraggableCorePhysics.h \
|
TransparentDraggableCorePhysics.h \
|
||||||
TransparentDraggableCrackObject.h \
|
|
||||||
TransparentDraggableFac.h \
|
TransparentDraggableFac.h \
|
||||||
TransparentDraggableGeoLith.h \
|
TransparentDraggableGeoLith.h \
|
||||||
TransparentDraggableGujing.h \
|
TransparentDraggableGujing.h \
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
#include "transparentdraggableLayer.h"
|
#include "transparentdraggableLayer.h"
|
||||||
#include "transparentdraggableRightList.h"
|
#include "transparentdraggableRightList.h"
|
||||||
#include "TransparentDraggableCorePhysics.h"
|
#include "TransparentDraggableCorePhysics.h"
|
||||||
#include "TransparentDraggableCrackObject.h"
|
|
||||||
#include "qtcommonclass.h"
|
#include "qtcommonclass.h"
|
||||||
#include "slf.h"
|
#include "slf.h"
|
||||||
#include "MemRdWt.h"
|
#include "MemRdWt.h"
|
||||||
|
|
@ -1442,11 +1441,21 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
//岩心图片
|
//岩心图片
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
menu.addAction(QIcon(::GetImagePath() + "curve.png"), "开始编辑岩心图片", this, &QMyCustomPlot::onEditImage);
|
if (!m_bEditor)
|
||||||
|
{
|
||||||
|
menu.addAction(QIcon(::GetImagePath() + "curve.png"), "开始编辑岩心图片", this, &QMyCustomPlot::onOpenEditResult);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu.addAction(QIcon(::GetImagePath() + "curve.png"), "增加", this, &QMyCustomPlot::onEditImage);
|
||||||
|
menu.addAction(QIcon(::GetImagePath() + "curve.png"), "关闭编辑岩心图片", this, &QMyCustomPlot::onCloseEditResult);
|
||||||
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItemsImage);
|
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItemsImage);
|
||||||
|
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::clearItemsImage);
|
||||||
|
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "设置深度移动量", this, &QMyCustomPlot::setImageDepth);
|
||||||
|
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "删除选中对象", this, &QMyCustomPlot::deleteItemsImage);
|
||||||
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
|
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
|
||||||
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::deleteItemsImage);
|
|
||||||
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::refreshItemsImage);
|
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::refreshItemsImage);
|
||||||
|
}
|
||||||
menu.exec(event->globalPos());
|
menu.exec(event->globalPos());
|
||||||
}
|
}
|
||||||
else if (m_strLineName == "CORE_PHYSICS")
|
else if (m_strLineName == "CORE_PHYSICS")
|
||||||
|
|
@ -1881,6 +1890,7 @@ void QMyCustomPlot::onEditImage()
|
||||||
{
|
{
|
||||||
this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式
|
this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式
|
||||||
this->setSelectionRectMode(QCP::srmCustom); // 鼠标框选
|
this->setSelectionRectMode(QCP::srmCustom); // 鼠标框选
|
||||||
|
this->setCursor(Qt::CrossCursor);
|
||||||
|
|
||||||
if(m_bFirstTimeConnect)
|
if(m_bFirstTimeConnect)
|
||||||
{
|
{
|
||||||
|
|
@ -2055,7 +2065,100 @@ void QMyCustomPlot::addItemsImage(){
|
||||||
//属性清空
|
//属性清空
|
||||||
PropertyService()->InitCurrentViewInfo();
|
PropertyService()->InitCurrentViewInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QMyCustomPlot::setImageDepth()
|
||||||
|
{
|
||||||
|
// 1. 创建对话框
|
||||||
|
QDialog dlg(nullptr);
|
||||||
|
dlg.setWindowTitle("添加裂缝");
|
||||||
|
dlg.setFixedSize(320, 200); // 窗口大小
|
||||||
|
|
||||||
|
// ====================== 控件创建 ======================
|
||||||
|
// 深度标签 + 输入框
|
||||||
|
QLabel *labDepth = new QLabel("请输入移动的深度量(上移-, 下移+)");
|
||||||
|
QSpinBox *editDepth = new QSpinBox;
|
||||||
|
editDepth->setValue(0); // 默认值
|
||||||
|
editDepth->setFixedWidth(300);
|
||||||
|
editDepth->setMinimum(-1000000); // 允许输入负数
|
||||||
|
|
||||||
|
// 按钮
|
||||||
|
QPushButton *btnOk = new QPushButton("确定");
|
||||||
|
QPushButton *btnCancel = new QPushButton("放弃");
|
||||||
|
|
||||||
|
// ====================== 布局 ======================
|
||||||
|
QVBoxLayout *lay1 = new QVBoxLayout ;
|
||||||
|
lay1->addWidget(labDepth);
|
||||||
|
lay1->addWidget(editDepth);
|
||||||
|
lay1->setSpacing(20);
|
||||||
|
// lay1->setContentsMargins(30, 0, 30, 0);
|
||||||
|
|
||||||
|
QHBoxLayout *layBtn = new QHBoxLayout;
|
||||||
|
layBtn->addStretch();
|
||||||
|
layBtn->addWidget(btnOk);
|
||||||
|
layBtn->addWidget(btnCancel);
|
||||||
|
layBtn->addStretch();
|
||||||
|
// layBtn->setContentsMargins(30, 0, 30, 0);
|
||||||
|
|
||||||
|
QVBoxLayout *mainLay = new QVBoxLayout(&dlg);
|
||||||
|
mainLay->addStretch();
|
||||||
|
mainLay->addLayout(lay1);
|
||||||
|
// mainLay->addSpacing(40);
|
||||||
|
mainLay->addStretch();
|
||||||
|
mainLay->addLayout(layBtn);
|
||||||
|
// mainLay->addSpacing(40);
|
||||||
|
// mainLay->setContentsMargins(20, 20, 20, 20);
|
||||||
|
|
||||||
|
// ====================== 信号绑定 ======================
|
||||||
|
|
||||||
|
connect(btnOk, &QPushButton::clicked, &dlg, [&](){
|
||||||
|
dlg.accept(); // 确认关闭
|
||||||
|
});
|
||||||
|
connect(btnCancel, &QPushButton::clicked, &dlg, &QDialog::reject);
|
||||||
|
|
||||||
|
// ====================== 弹出对话框并获取结果 ======================
|
||||||
|
if(dlg.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
// 获取用户输入
|
||||||
|
int depth = editDepth->text().toDouble();
|
||||||
|
TransparentDraggableImage *pDraggableRect = (TransparentDraggableImage*)this->m_selectItem;
|
||||||
|
if(pDraggableRect == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QCPRange cpr = pDraggableRect->getRange();
|
||||||
|
cpr.lower = cpr.lower - depth;
|
||||||
|
cpr.upper = cpr.upper - depth;
|
||||||
|
pDraggableRect->setRange(cpr.lower, cpr.upper, true);
|
||||||
|
|
||||||
|
this->SaveToSLFImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QMyCustomPlot::deleteItemsImage()
|
void QMyCustomPlot::deleteItemsImage()
|
||||||
|
{
|
||||||
|
//删除对象
|
||||||
|
TransparentDraggableImage *pDraggableRect =NULL;
|
||||||
|
QMap<QString,QObject *>::Iterator it = m_mapDraggable_Image.begin();
|
||||||
|
while( it != m_mapDraggable_Image.end() )
|
||||||
|
{
|
||||||
|
pDraggableRect = (TransparentDraggableImage*)it.value();
|
||||||
|
if(this->m_selectItem == pDraggableRect)
|
||||||
|
{
|
||||||
|
pDraggableRect->deleteRect();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
this->replot();
|
||||||
|
|
||||||
|
//保存
|
||||||
|
SaveToSLFImage();
|
||||||
|
// m_mapDraggable_Image.clear();
|
||||||
|
//属性清空
|
||||||
|
PropertyService()->InitCurrentViewInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QMyCustomPlot::clearItemsImage()
|
||||||
{
|
{
|
||||||
if(QMessageBox::information(NULL,QObject::tr("提示"),QObject::tr("该功能将清除当前组件展示的全部信息,清除后无法恢复,但会备份到对应的\"_BAK\"中,确定清除吗?"),QMessageBox::Yes|QMessageBox::No)!=QMessageBox::Yes) return;
|
if(QMessageBox::information(NULL,QObject::tr("提示"),QObject::tr("该功能将清除当前组件展示的全部信息,清除后无法恢复,但会备份到对应的\"_BAK\"中,确定清除吗?"),QMessageBox::Yes|QMessageBox::No)!=QMessageBox::Yes) return;
|
||||||
QString obj = m_strLineName + "BAK";
|
QString obj = m_strLineName + "BAK";
|
||||||
|
|
@ -2079,6 +2182,7 @@ void QMyCustomPlot::deleteItemsImage()
|
||||||
//属性清空
|
//属性清空
|
||||||
PropertyService()->InitCurrentViewInfo();
|
PropertyService()->InitCurrentViewInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMyCustomPlot::refreshItemsImage()
|
void QMyCustomPlot::refreshItemsImage()
|
||||||
{
|
{
|
||||||
//删除对象
|
//删除对象
|
||||||
|
|
@ -2201,24 +2305,6 @@ void QMyCustomPlot::addCrackObject()
|
||||||
QString showNames = "";
|
QString showNames = "";
|
||||||
|
|
||||||
this->m_cPickFrac->createNewCrack(depth, type);
|
this->m_cPickFrac->createNewCrack(depth, type);
|
||||||
|
|
||||||
// if("高导缝" == type)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// else if("网状缝" == type)
|
|
||||||
// {
|
|
||||||
// this->m_cPickFrac->createNewCrack(2, depth, type);
|
|
||||||
// }
|
|
||||||
// else if("孔洞" == type)
|
|
||||||
// {
|
|
||||||
// this->m_cPickFrac->createNewCrack(3, depth, type);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// auto curve = new CPickFrac(this, strUuid, -depth, type, showNames);
|
|
||||||
// m_mapDraggable_CrackObject[strUuid] = curve;
|
|
||||||
|
|
||||||
// ========= 这里就是你要的结果!=========
|
|
||||||
// qDebug() << "深度:" << depth << " 类型:" << type;
|
// qDebug() << "深度:" << depth << " 类型:" << type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -290,6 +290,7 @@ public:
|
||||||
|
|
||||||
QObject* m_SelectShiftLine=nullptr;//当前选中的分段线
|
QObject* m_SelectShiftLine=nullptr;//当前选中的分段线
|
||||||
QObject* m_SelectRect=nullptr;//当前选中的曲线编辑框
|
QObject* m_SelectRect=nullptr;//当前选中的曲线编辑框
|
||||||
|
QObject* m_selectItem = nullptr;
|
||||||
|
|
||||||
//固井
|
//固井
|
||||||
QMap<QString,QString> zoneOrder_Gujing;
|
QMap<QString,QString> zoneOrder_Gujing;
|
||||||
|
|
@ -541,7 +542,9 @@ public slots:
|
||||||
//右键--编辑岩心照片
|
//右键--编辑岩心照片
|
||||||
void onEditImage();
|
void onEditImage();
|
||||||
void addItemsImage(); //从剪切板文本数据粘贴
|
void addItemsImage(); //从剪切板文本数据粘贴
|
||||||
void deleteItemsImage(); //全部清空
|
void clearItemsImage(); //全部清空
|
||||||
|
void setImageDepth();
|
||||||
|
void deleteItemsImage();
|
||||||
void refreshItemsImage(); //刷新数据
|
void refreshItemsImage(); //刷新数据
|
||||||
|
|
||||||
//右键--编辑岩心分析
|
//右键--编辑岩心分析
|
||||||
|
|
|
||||||
|
|
@ -396,46 +396,46 @@ void TransparentDraggableImage::onMousePress(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(event->button() != Qt::LeftButton)//右键
|
if(event->button() != Qt::LeftButton)//右键
|
||||||
{
|
{
|
||||||
double y = mPlot->xAxis->pixelToCoord(event->pos().y());//x轴展示深度
|
// double y = mPlot->xAxis->pixelToCoord(event->pos().y());//x轴展示深度
|
||||||
QCPRange currentRange = getRange();
|
// QCPRange currentRange = getRange();
|
||||||
if(mLeftHandle->selectTest(event->pos(), false) < 5) {
|
// if(mLeftHandle->selectTest(event->pos(), false) < 5) {
|
||||||
mDragMode = DragNone;
|
// mDragMode = DragNone;
|
||||||
}
|
|
||||||
else if(mRightHandle->selectTest(event->pos(), false) < 5) {
|
|
||||||
mDragMode = DragNone;
|
|
||||||
}
|
|
||||||
//else if(x >= currentRange.lower && x <= currentRange.upper) {
|
|
||||||
else if(y >= currentRange.lower && y <= currentRange.upper) {
|
|
||||||
mDragMode = DragNone;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mDragMode = DragNone;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//event->accept();
|
|
||||||
// 显示属性
|
|
||||||
double low = mRect->topLeft->coords().x();
|
|
||||||
double hight = mRect->bottomRight->coords().x();
|
|
||||||
double left = getLeft();
|
|
||||||
double width = getWidth();
|
|
||||||
QColor borderColor = this->m_BorderColor; // 边框颜色
|
|
||||||
Qt::PenStyle borderStyle = this->m_BorderStyle; // 边框线型
|
|
||||||
int borderWidth = this->m_BorderWidth; // 边框线宽(像素)
|
|
||||||
PropertyService()->initImageItemProperty(this, low, hight, m_Result, left, width,borderColor,borderStyle,borderWidth);
|
|
||||||
|
|
||||||
QMenu menu(nullptr);
|
|
||||||
QAction *delAction = menu.addAction("删除框图");
|
|
||||||
//delAction->installEventFilter(this);
|
|
||||||
connect(delAction, &QAction::triggered, this, &TransparentDraggableImage::onDelRect);
|
|
||||||
// QAction* pItem = menu.exec(event->globalPos());
|
|
||||||
// if(pItem == delAction)
|
|
||||||
// {
|
|
||||||
// //event->accept();
|
|
||||||
// int ii=0;
|
|
||||||
// ii++;
|
|
||||||
// }
|
// }
|
||||||
menu.exec(event->globalPos());
|
// else if(mRightHandle->selectTest(event->pos(), false) < 5) {
|
||||||
|
// mDragMode = DragNone;
|
||||||
|
// }
|
||||||
|
// //else if(x >= currentRange.lower && x <= currentRange.upper) {
|
||||||
|
// else if(y >= currentRange.lower && y <= currentRange.upper) {
|
||||||
|
// mDragMode = DragNone;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// mDragMode = DragNone;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //event->accept();
|
||||||
|
// // 显示属性
|
||||||
|
// double low = mRect->topLeft->coords().x();
|
||||||
|
// double hight = mRect->bottomRight->coords().x();
|
||||||
|
// double left = getLeft();
|
||||||
|
// double width = getWidth();
|
||||||
|
// QColor borderColor = this->m_BorderColor; // 边框颜色
|
||||||
|
// Qt::PenStyle borderStyle = this->m_BorderStyle; // 边框线型
|
||||||
|
// int borderWidth = this->m_BorderWidth; // 边框线宽(像素)
|
||||||
|
// PropertyService()->initImageItemProperty(this, low, hight, m_Result, left, width,borderColor,borderStyle,borderWidth);
|
||||||
|
|
||||||
|
// QMenu menu(nullptr);
|
||||||
|
// QAction *delAction = menu.addAction("删除框图");
|
||||||
|
// //delAction->installEventFilter(this);
|
||||||
|
// connect(delAction, &QAction::triggered, this, &TransparentDraggableImage::onDelRect);
|
||||||
|
// // QAction* pItem = menu.exec(event->globalPos());
|
||||||
|
// // if(pItem == delAction)
|
||||||
|
// // {
|
||||||
|
// // //event->accept();
|
||||||
|
// // int ii=0;
|
||||||
|
// // ii++;
|
||||||
|
// // }
|
||||||
|
// menu.exec(event->globalPos());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -469,6 +469,7 @@ void TransparentDraggableImage::onMousePress(QMouseEvent *event)
|
||||||
mDragStartY = y;
|
mDragStartY = y;
|
||||||
mDragStartRange = currentRange;
|
mDragStartRange = currentRange;
|
||||||
|
|
||||||
|
mPlot->m_selectItem = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransparentDraggableImage::onMouseMove(QMouseEvent *event)
|
void TransparentDraggableImage::onMouseMove(QMouseEvent *event)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user