岩心图片 右键菜单
This commit is contained in:
parent
c95c843a43
commit
a757d6583e
113
logPlus/YxzpDialog.cpp
Normal file
113
logPlus/YxzpDialog.cpp
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
#include "YxzpDialog.h"
|
||||||
|
|
||||||
|
YxzpDialog::YxzpDialog(QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
// setStyleSheet("QDialog { background-color: #888; }");
|
||||||
|
setWindowTitle("图片");
|
||||||
|
setFixedSize(600, 500); // 固定窗口大小,和示例接近
|
||||||
|
|
||||||
|
// 1. 边框属性行(示例里是占位,这里也做一个输入框)
|
||||||
|
QHBoxLayout *layoutBorder = new QHBoxLayout;
|
||||||
|
QLabel *labelBorder = new QLabel(QObject::tr("边框属性:"));
|
||||||
|
labelBorder->setMinimumWidth(60); // 统一最小宽度(可根据文本调整)
|
||||||
|
labelBorder->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||||
|
QLineEdit *editBorder = new QLineEdit;
|
||||||
|
editBorder->setReadOnly(true);
|
||||||
|
editBorder->setPlaceholderText("");
|
||||||
|
layoutBorder->setContentsMargins(0, 20, 0, 0);
|
||||||
|
layoutBorder->addWidget(labelBorder);
|
||||||
|
layoutBorder->addWidget(editBorder);
|
||||||
|
|
||||||
|
// 2. 图片路径行
|
||||||
|
QHBoxLayout *layoutPath = new QHBoxLayout;
|
||||||
|
QLabel *labelPath = new QLabel(QObject::tr("图片路径:"));
|
||||||
|
labelPath->setMinimumWidth(60); // 统一最小宽度(可根据文本调整)
|
||||||
|
labelPath->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||||
|
m_editPath = new QLineEdit;
|
||||||
|
m_editPath->setReadOnly(true); // 只读,只能通过按钮选择
|
||||||
|
QPushButton *btnSelect = new QPushButton("...");
|
||||||
|
btnSelect->setFixedWidth(80);
|
||||||
|
layoutPath->addWidget(labelPath);
|
||||||
|
layoutPath->addWidget(m_editPath);
|
||||||
|
layoutPath->addWidget(btnSelect);
|
||||||
|
|
||||||
|
// 3. 预览区域
|
||||||
|
QVBoxLayout *layoutPreview = new QVBoxLayout;
|
||||||
|
QLabel *labelPreviewTitle = new QLabel(QObject::tr("预览"));
|
||||||
|
m_labelPreview = new QLabel;
|
||||||
|
m_labelPreview->setFrameStyle(QFrame::Box | QFrame::Sunken); // 加边框
|
||||||
|
m_labelPreview->setAlignment(Qt::AlignCenter);
|
||||||
|
m_labelPreview->setMinimumSize(550, 320); // 预览区域最小尺寸
|
||||||
|
layoutPreview->addWidget(labelPreviewTitle);
|
||||||
|
layoutPreview->addWidget(m_labelPreview);
|
||||||
|
|
||||||
|
// 4. 按钮行
|
||||||
|
QHBoxLayout *layoutButtons = new QHBoxLayout;
|
||||||
|
QPushButton *btnOk = new QPushButton(QObject::tr("确定"));
|
||||||
|
QPushButton *btnCancel = new QPushButton(QObject::tr("取消"));
|
||||||
|
// layoutButtons->setContentsMargins(0, 20, 0, 0);
|
||||||
|
layoutButtons->addStretch(); // 推到右侧
|
||||||
|
layoutButtons->addWidget(btnOk);
|
||||||
|
layoutButtons->addWidget(btnCancel);
|
||||||
|
|
||||||
|
// 总布局
|
||||||
|
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||||
|
mainLayout->addLayout(layoutBorder);
|
||||||
|
mainLayout->addLayout(layoutPath);
|
||||||
|
mainLayout->addLayout(layoutPreview);
|
||||||
|
mainLayout->addStretch();
|
||||||
|
mainLayout->addLayout(layoutButtons);
|
||||||
|
mainLayout->setContentsMargins(20, 0, 20, 10);
|
||||||
|
mainLayout->setSpacing(15);
|
||||||
|
|
||||||
|
// 信号槽连接
|
||||||
|
connect(btnSelect, &QPushButton::clicked, this, &YxzpDialog::onSelectImage);
|
||||||
|
connect(btnOk, &QPushButton::clicked, this, &YxzpDialog::onAccept);
|
||||||
|
connect(btnCancel, &QPushButton::clicked, this, &YxzpDialog::onReject);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString YxzpDialog::getImagePath() const
|
||||||
|
{
|
||||||
|
return m_imagePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YxzpDialog::onSelectImage()
|
||||||
|
{
|
||||||
|
// 弹出文件选择框,仅允许 JPG 图片
|
||||||
|
QString filePath = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
"选择图片",
|
||||||
|
QDir::homePath(),
|
||||||
|
"JPG 图片 (*.jpg *.jpeg)"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!filePath.isEmpty())
|
||||||
|
{
|
||||||
|
m_editPath->setText(filePath);
|
||||||
|
// 加载并预览图片
|
||||||
|
QPixmap pixmap(filePath);
|
||||||
|
if (!pixmap.isNull())
|
||||||
|
{
|
||||||
|
// 按比例缩放预览
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(
|
||||||
|
m_labelPreview->size(),
|
||||||
|
Qt::KeepAspectRatio,
|
||||||
|
Qt::SmoothTransformation
|
||||||
|
);
|
||||||
|
m_labelPreview->setPixmap(scaledPixmap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YxzpDialog::onAccept()
|
||||||
|
{
|
||||||
|
m_imagePath = m_editPath->text();
|
||||||
|
accept(); // 关闭对话框,返回 QDialog::Accepted
|
||||||
|
}
|
||||||
|
|
||||||
|
void YxzpDialog::onReject()
|
||||||
|
{
|
||||||
|
m_imagePath.clear();
|
||||||
|
reject(); // 关闭对话框,返回 QDialog::Rejected
|
||||||
|
}
|
||||||
38
logPlus/YxzpDialog.h
Normal file
38
logPlus/YxzpDialog.h
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef YXZPDIALOG_H
|
||||||
|
#define YXZPDIALOG_H
|
||||||
|
// 岩心照片 自定义 dialog
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
|
class YxzpDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit YxzpDialog(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
// 获取最终选择的图片路径
|
||||||
|
QString getImagePath() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
// 选择图片按钮点击
|
||||||
|
void onSelectImage();
|
||||||
|
// 确认按钮点击
|
||||||
|
void onAccept();
|
||||||
|
// 取消按钮点击
|
||||||
|
void onReject();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLineEdit *m_editPath; // 图片路径输入框
|
||||||
|
QLabel *m_labelPreview; // 预览图片
|
||||||
|
QString m_imagePath; // 存储最终路径
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // YXZPCUSDIALOG_H
|
||||||
|
|
@ -58,6 +58,7 @@ SOURCES += \
|
||||||
TransparentDraggableSwallCore.cpp \
|
TransparentDraggableSwallCore.cpp \
|
||||||
TransparentGroupResult.cpp \
|
TransparentGroupResult.cpp \
|
||||||
ViewInfo.cpp \
|
ViewInfo.cpp \
|
||||||
|
YxzpDialog.cpp \
|
||||||
backgrounddelegate.cpp \
|
backgrounddelegate.cpp \
|
||||||
customtabbar.cpp \
|
customtabbar.cpp \
|
||||||
customtabwidget.cpp \
|
customtabwidget.cpp \
|
||||||
|
|
@ -121,6 +122,7 @@ HEADERS += \
|
||||||
TransparentDraggableSwallCore.h \
|
TransparentDraggableSwallCore.h \
|
||||||
TransparentGroupResult.h \
|
TransparentGroupResult.h \
|
||||||
ViewInfo.h \
|
ViewInfo.h \
|
||||||
|
YxzpDialog.h \
|
||||||
backgrounddelegate.h \
|
backgrounddelegate.h \
|
||||||
customtabbar.h \
|
customtabbar.h \
|
||||||
customtabwidget.h \
|
customtabwidget.h \
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "slf.h"
|
#include "slf.h"
|
||||||
#include "MemRdWt.h"
|
#include "MemRdWt.h"
|
||||||
#include "PropertyWidget.h"
|
#include "PropertyWidget.h"
|
||||||
|
#include "YxzpDialog.h"
|
||||||
|
|
||||||
//是否隐藏刻度
|
//是否隐藏刻度
|
||||||
extern int g_iShow;
|
extern int g_iShow;
|
||||||
|
|
@ -1094,6 +1095,18 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
|
||||||
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer);
|
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer);
|
||||||
menu.exec(event->globalPos());
|
menu.exec(event->globalPos());
|
||||||
}
|
}
|
||||||
|
else if (m_strLineName == "IMAGE_DATA")
|
||||||
|
{
|
||||||
|
QMenu menu(this);
|
||||||
|
//岩心图片
|
||||||
|
menu.addAction(QIcon(::GetImagePath() + "curve.png"), "开始编辑岩心图片", this, &QMyCustomPlot::onEditImage);
|
||||||
|
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItemsImage);
|
||||||
|
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() + "development.png"), "合并结论", this, &QMyCustomPlot::MegResultImage);
|
||||||
|
menu.exec(event->globalPos());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//右键--添加分段线
|
//右键--添加分段线
|
||||||
|
|
@ -1451,6 +1464,99 @@ void QMyCustomPlot::onEditGujing()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QMyCustomPlot::onEditImage()
|
||||||
|
{
|
||||||
|
this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式
|
||||||
|
this->setSelectionRectMode(QCP::srmCustom); // 鼠标框选
|
||||||
|
|
||||||
|
if(m_bFirstTimeConnect)
|
||||||
|
{
|
||||||
|
//信号槽只绑定一次,避免重复绑定
|
||||||
|
m_bFirstTimeConnect = false;
|
||||||
|
|
||||||
|
for (int i=0; i < this->graphCount(); ++i) {
|
||||||
|
QCPGraph *graph = this->graph(i);
|
||||||
|
graph->setSelectable(QCP::stDataRange);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(this->selectionRect(), &QCPSelectionRect::accepted, [this](){
|
||||||
|
if(this->m_bDrawRect == false)
|
||||||
|
{
|
||||||
|
this->m_bDrawRect = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 当选择完成时,获取矩形范围并放大
|
||||||
|
QRectF rect = this->selectionRect()->rect(); // 获取选择的矩形区域(像素坐标)
|
||||||
|
m_bEditRect=true;//当前是否正在编辑曲线。
|
||||||
|
|
||||||
|
// 转换为坐标轴范围
|
||||||
|
double top = rect.top();
|
||||||
|
double bottom = rect.bottom();
|
||||||
|
|
||||||
|
double right_Hight = this->xAxis->pixelToCoord(top);
|
||||||
|
double left_Low = this->xAxis->pixelToCoord(bottom);
|
||||||
|
|
||||||
|
//追加判断,避免框选重叠
|
||||||
|
TransparentDraggableGujing *pDraggableRect =NULL;
|
||||||
|
{
|
||||||
|
QMap<QString,QObject *>::Iterator it = m_mapDraggable_Gujing.begin();
|
||||||
|
while( it != m_mapDraggable_Gujing.end() )
|
||||||
|
{
|
||||||
|
pDraggableRect = (TransparentDraggableGujing*)it.value();
|
||||||
|
//
|
||||||
|
QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
if(tmpRange.lower >= left_Low && tmpRange.upper <= right_Hight)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tmpRange.upper >= left_Low && tmpRange.upper <= right_Hight)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tmpRange.lower >= left_Low && tmpRange.lower <= right_Hight)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// 弹框选择图片
|
||||||
|
YxzpDialog dlg(nullptr);
|
||||||
|
QString imagePath = "";
|
||||||
|
if (dlg.exec() == QDialog::Accepted) // 点击“确定”按钮
|
||||||
|
{
|
||||||
|
imagePath = dlg.getImagePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加固井结论
|
||||||
|
this->addImageToPlot(left_Low, right_Hight, imagePath);
|
||||||
|
|
||||||
|
//保存
|
||||||
|
this->SaveToSLF_Gujing();
|
||||||
|
|
||||||
|
//属性清空
|
||||||
|
PropertyService()->InitCurrentViewInfo();
|
||||||
|
|
||||||
|
//取消框选
|
||||||
|
this->setInteractions(QCP::iSelectLegend | QCP::iSelectPlottables);
|
||||||
|
this->setSelectionRectMode(QCP::srmNone);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//this->selectionRect()->cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QMyCustomPlot::addItemsImage(){}
|
||||||
|
void QMyCustomPlot::DeleteItemsImage(){}
|
||||||
|
void QMyCustomPlot::RefreshItemsImage(){}
|
||||||
|
void QMyCustomPlot::MegResultImage(){}
|
||||||
|
|
||||||
//右键--添加录井剖面
|
//右键--添加录井剖面
|
||||||
void QMyCustomPlot::onEditGeoLith()
|
void QMyCustomPlot::onEditGeoLith()
|
||||||
{
|
{
|
||||||
|
|
@ -3493,7 +3599,7 @@ void QMyCustomPlot::addImageToPlot(double left_Low, double right_Hight, const QS
|
||||||
dragRect->setResult(imagePath);
|
dragRect->setResult(imagePath);
|
||||||
// 设置初始范围
|
// 设置初始范围
|
||||||
dragRect->setRange(left_Low, right_Hight);
|
dragRect->setRange(left_Low, right_Hight);
|
||||||
// 可选:设置颜色
|
// 可选:设置颜色`
|
||||||
dragRect->setColor(QColor(255, 255, 255, 80)); // 半透明红色
|
dragRect->setColor(QColor(255, 255, 255, 80)); // 半透明红色
|
||||||
//最小宽度
|
//最小宽度
|
||||||
dragRect->setMinWidth(0.1);
|
dragRect->setMinWidth(0.1);
|
||||||
|
|
|
||||||
|
|
@ -373,6 +373,13 @@ public slots:
|
||||||
//右键--气测-管柱-文本-FMT-射孔
|
//右键--气测-管柱-文本-FMT-射孔
|
||||||
void RefreshItems_Jiegutext(QString strAliasName = "气测-FMT-射孔-文本"); //刷新数据
|
void RefreshItems_Jiegutext(QString strAliasName = "气测-FMT-射孔-文本"); //刷新数据
|
||||||
|
|
||||||
|
//右键--编辑岩心照片
|
||||||
|
void onEditImage();
|
||||||
|
void addItemsImage(); //从剪切板文本数据粘贴
|
||||||
|
void DeleteItemsImage(); //全部清空
|
||||||
|
void RefreshItemsImage(); //刷新数据
|
||||||
|
void MegResultImage(); //合并结论
|
||||||
|
|
||||||
//
|
//
|
||||||
void addItems_Core();
|
void addItems_Core();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user