裂缝 画图
This commit is contained in:
parent
008191977c
commit
f62d24e4ce
1189
logPlus/PickFrac.cpp
1189
logPlus/PickFrac.cpp
File diff suppressed because it is too large
Load Diff
|
|
@ -2,75 +2,190 @@
|
|||
#define DrawFrac_H
|
||||
|
||||
#include <QObject>
|
||||
#include "qmycustomplot.h"
|
||||
#include <QColor>
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
#include <QPointer>
|
||||
#include <QPointF>
|
||||
|
||||
//裂缝
|
||||
//const int iFracType=15;
|
||||
class QMyCustomPlot;
|
||||
class QCustomPlot;
|
||||
class QCPItemCurve;
|
||||
class QCPItemTracer;
|
||||
class QCPItemLine;
|
||||
class QCPCurve;
|
||||
class QCPItemText;
|
||||
|
||||
typedef struct tagPOINTF
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
} POINTF;
|
||||
static const int iFracType2 = 15;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int iCode; //代码
|
||||
QString csName;// 名称
|
||||
int iType; //形状代码(1:正弦曲线 2:连线 3:封闭区域)
|
||||
QColor crColor; //颜色(红 绿 蓝)
|
||||
int nLineWidth;//线宽度
|
||||
int bDraw; // 是否显示
|
||||
}FRAC_DEF_Crack;
|
||||
typedef struct tagPOINTF { float x; float y; } POINTF;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float DEP;
|
||||
float AorX; //XRMI_DYN_DipHeight
|
||||
float XETAorH;//XRMI_DYN_Azimuth
|
||||
float W;
|
||||
float DIPorS;//XRMI_DYN_Dip_APP
|
||||
float DIR;//XRMI_DYN_Azimuth
|
||||
float TDIP; //真倾角 Dip_TRU
|
||||
float TDIR; //真倾向 Azimuth
|
||||
float ID;//裂缝代码,type
|
||||
float NUM;
|
||||
//float X[16],Y[16];//X0,Y0,X1,Y1,X2,Y2,X3,Y3,X4,Y4,X5,Y5,X6,Y6,X7,Y7,X8,Y8,X9,Y9;
|
||||
POINTF point[16];
|
||||
}FRAC_TABLE_Crack;
|
||||
typedef struct {
|
||||
int iCode;
|
||||
QString csName;
|
||||
int iType; // 1:正弦曲线 2:连线 3:封闭区域 4:直线
|
||||
QColor crColor;
|
||||
int nLineWidth;
|
||||
int bDraw;
|
||||
} FRAC_DEF_Crack;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
float DEP;
|
||||
float AorX;
|
||||
float XETAorH;
|
||||
float W;
|
||||
float DIPorS;
|
||||
float DIR;
|
||||
float ID;//裂缝代码
|
||||
}FRAC_TABLE_OLD_Crack;
|
||||
float TDIP;
|
||||
float TDIR;
|
||||
float ID;
|
||||
float NUM;
|
||||
POINTF point[16];
|
||||
} FRAC_TABLE_Crack;
|
||||
|
||||
typedef struct {
|
||||
float DEP;
|
||||
float AorX;
|
||||
float XETAorH;
|
||||
float W;
|
||||
float DIPorS;
|
||||
float DIR;
|
||||
float ID;
|
||||
} FRAC_TABLE_OLD_Crack;
|
||||
|
||||
class DraggableCrackItem;
|
||||
|
||||
class CPickFrac : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class CPickFrac:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CPickFrac(QMyCustomPlot *widget, QString strSlfName, QString csCurve, int iMyWidth);
|
||||
virtual ~CPickFrac(void);
|
||||
virtual ~CPickFrac();
|
||||
|
||||
void setDraggingEnabled(bool enabled);
|
||||
QList<DraggableCrackItem*> getAllItems() const { return m_items; }
|
||||
bool saveToFile();
|
||||
bool createNewCrack(int iType, double depth); // 根据形状类型创建
|
||||
|
||||
public:
|
||||
QString m_Name;
|
||||
QString m_strDevi, m_strHazi;
|
||||
QList <FRAC_DEF_Crack> m_FracDef;
|
||||
bool m_bTypeDraw[iFracType];
|
||||
|
||||
QMyCustomPlot *m_myCustomPlot;
|
||||
int m_iMyWidth=0;
|
||||
public:
|
||||
int m_iMyWidth = 0;
|
||||
QList<FRAC_DEF_Crack> m_FracDef;
|
||||
bool m_bTypeDraw[iFracType2];
|
||||
|
||||
void ReadFracDef();
|
||||
void ReadData(QString strSlfName, QString csCurve);
|
||||
void drawOne(FRAC_TABLE_Crack frac, QString cs, int iType, int nLineWidth, QColor crColor);
|
||||
void drawOne(FRAC_TABLE_Crack frac, int iType, int nLineWidth, QColor crColor);
|
||||
|
||||
public slots:
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void onRemoveCrackItem(DraggableCrackItem *item);
|
||||
|
||||
private:
|
||||
QList<DraggableCrackItem*> m_items;
|
||||
bool m_draggingEnabled = true;
|
||||
QString m_currentSlfName;
|
||||
QString m_currentTableName;
|
||||
};
|
||||
|
||||
// ========== 可拖拽裂缝项 ==========
|
||||
class DraggableCrackItem : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Type { TypeA_Sine, TypeB_Polyline, TypeC_Closed };
|
||||
DraggableCrackItem(QCustomPlot *plot, Type type, const QColor &color, int lineWidth);
|
||||
~DraggableCrackItem();
|
||||
|
||||
void setSineData(double depth, double amplitude, double phase, double xScale, double width);
|
||||
void setPolylineData(const QVector<QPointF> &points, double scaleX = 1.0, double flipY = -1.0);
|
||||
void setClosedData(const QVector<QPointF> &points, double scaleX = 1.0, double flipY = -1.0);
|
||||
void setVisible(bool visible);
|
||||
void deactivate();
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
// 保存接口
|
||||
Type getType() const { return m_type; }
|
||||
void setCrackCode(int code) { m_crackCode = code; }
|
||||
int getCrackCode() const { return m_crackCode; }
|
||||
double getDepthForSort() const;
|
||||
void getCurrentFracData(FRAC_TABLE_Crack &data) const;
|
||||
|
||||
// 编辑模式
|
||||
void startEditing();
|
||||
void finishEditing();
|
||||
|
||||
// 控制所有拖拽点的可见性
|
||||
void setDragPointsVisible(bool visible);
|
||||
|
||||
// 获取当前激活的item(静态)
|
||||
static DraggableCrackItem* getActiveItem() { return s_activeItem; }
|
||||
|
||||
signals:
|
||||
void dataChanged();
|
||||
void removeMe(DraggableCrackItem* item);
|
||||
|
||||
private:
|
||||
QCustomPlot *m_plot;
|
||||
Type m_type;
|
||||
QColor m_color;
|
||||
int m_lineWidth;
|
||||
int m_crackCode = 0;
|
||||
double m_originalXETAorH = 0.0;
|
||||
double m_originalAorX = 0.0;
|
||||
|
||||
// 模式A
|
||||
QCPItemCurve *m_curve = nullptr;
|
||||
QCPItemTracer *m_tracer1 = nullptr, *m_tracer2 = nullptr;
|
||||
double m_orig_x1, m_orig_x2, m_orig_y1, m_orig_y2;
|
||||
double m_orig_startX, m_orig_endX, m_orig_startDirX, m_orig_startDirY, m_orig_endDirX, m_orig_endDirY;
|
||||
double m_offsetXA = 0.0, m_offsetYA = 0.0;
|
||||
double m_depth = 0.0, m_endX = 0.0;
|
||||
enum DragStateA { IdleA, DraggingPoint1, DraggingPoint2, DraggingCurveA } m_dragStateA = IdleA;
|
||||
QPointF m_lastDragPixelA;
|
||||
|
||||
// 模式B
|
||||
struct LineItem {
|
||||
QCPItemLine *line;
|
||||
QCPItemTracer *startTracer, *endTracer;
|
||||
QPointF startOrig, endOrig;
|
||||
};
|
||||
QList<LineItem> m_lines;
|
||||
double m_offsetXB = 0.0, m_offsetYB = 0.0;
|
||||
bool m_isAddingLine = false;
|
||||
QPointF m_tempPoint;
|
||||
enum DragStateB { IdleB, DraggingStartPoint, DraggingEndPoint, DraggingLineOverall } m_dragStateB = IdleB;
|
||||
QPointF m_bDragStart;
|
||||
int m_draggedLineIndex = -1;
|
||||
|
||||
// 模式C
|
||||
QCPCurve *m_curveC = nullptr;
|
||||
QVector<QPointF> m_pointsC;
|
||||
QVector<QCPItemText*> m_labelsC;
|
||||
double m_offsetXC = 0.0, m_offsetYC = 0.0;
|
||||
bool m_cFinished = false, m_cDragging = false, m_draggingPoint = false;
|
||||
int m_draggedPointIndex = -1;
|
||||
QPointF m_cDragStart;
|
||||
|
||||
// 编辑模式标志
|
||||
bool m_editingMode = false;
|
||||
bool m_pendingDelete = false; // 标记是否即将删除
|
||||
|
||||
// 辅助函数
|
||||
void updateCurveFromTargets();
|
||||
void updateCurvePosition();
|
||||
void updateTracers();
|
||||
void setTracerHighlight(QCPItemTracer *tracer, bool highlight);
|
||||
void updateLineEndpoints(LineItem &item);
|
||||
void updateLinesPosition();
|
||||
void clearLines();
|
||||
void updatePolylineC(bool closed);
|
||||
void clearPolylineC();
|
||||
|
||||
static QPointer<DraggableCrackItem> s_activeItem;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3995,6 +3995,7 @@ void FormDraw::s_addCrack(QString strUuid, QString strSlfName, QString strWellNa
|
|||
//注意,不对调XY轴
|
||||
curv->m_bX2Y = false;
|
||||
CPickFrac *pickFrac = new CPickFrac(curv, strSlfName, strWaveName, iMyWidth);
|
||||
curv->m_cPickFrac = pickFrac;
|
||||
|
||||
//
|
||||
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
||||
|
|
|
|||
|
|
@ -2189,8 +2189,23 @@ void QMyCustomPlot::addCrackObject()
|
|||
double depth = editDepth->text().toDouble();
|
||||
QString type = cbbType->currentText();
|
||||
QString showNames = "";
|
||||
auto curve = new TransparentDraggableCrackObject(this, strUuid, -depth, type, showNames);
|
||||
m_mapDraggable_CrackObject[strUuid] = curve;
|
||||
|
||||
if("高导缝" == type)
|
||||
{
|
||||
this->m_cPickFrac->createNewCrack(1 ,depth);
|
||||
}
|
||||
else if("网状缝" == type)
|
||||
{
|
||||
this->m_cPickFrac->createNewCrack(2 ,depth);
|
||||
}
|
||||
else if("孔洞" == type)
|
||||
{
|
||||
this->m_cPickFrac->createNewCrack(3 ,depth);
|
||||
}
|
||||
// auto curve = new CPickFrac(this, strUuid, -depth, type, showNames);
|
||||
|
||||
// m_mapDraggable_CrackObject[strUuid] = curve;
|
||||
|
||||
// ========= 这里就是你要的结果!=========
|
||||
// qDebug() << "深度:" << depth << " 类型:" << type;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@
|
|||
#include "LogIO.h"
|
||||
#include "QCPSizeHandleManager.h"
|
||||
#include "qtColorSchemeComboBox.h"
|
||||
#include "PickFrac.h"
|
||||
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
const int iFracType=15;
|
||||
const int iFracType = 15;
|
||||
class CPickFrac;
|
||||
|
||||
//
|
||||
#define SideWallCoreWidth 1.2
|
||||
|
|
@ -765,6 +767,8 @@ public:
|
|||
//
|
||||
void Draw_Jykt();
|
||||
|
||||
CPickFrac *m_cPickFrac;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user